Skip to content

Commit 9802c18

Browse files
deltakoshDavid Catuhe
andauthored
Allow debug node for NPE to refresh automatically (#16776)
Co-authored-by: David Catuhe <[email protected]>
1 parent 169ecc8 commit 9802c18

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

packages/dev/core/src/Particles/Node/Blocks/particleDebugBlock.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { NodeParticleBlockConnectionPointTypes } from "../Enums/nodeParticleBloc
55
import { NodeParticleBlock } from "../nodeParticleBlock";
66
import type { NodeParticleConnectionPoint } from "../nodeParticleBlockConnectionPoint";
77
import type { NodeParticleBuildState } from "../nodeParticleBuildState";
8+
import { Observable } from "core/Misc/observable";
89

910
/**
1011
* Defines a block used to debug values going through it
@@ -65,6 +66,11 @@ export class ParticleDebugBlock extends NodeParticleBlock {
6566
return this._outputs[0];
6667
}
6768

69+
/**
70+
* Observable raised when data is collected
71+
*/
72+
public onDataCollectedObservable = new Observable<ParticleDebugBlock>(undefined, true);
73+
6874
public override _build(state: NodeParticleBuildState) {
6975
if (!this.input.isConnected) {
7076
this.output._storedFunction = null;
@@ -100,6 +106,8 @@ export class ParticleDebugBlock extends NodeParticleBlock {
100106
break;
101107
}
102108

109+
this.onDataCollectedObservable.notifyObservers(this);
110+
103111
return input;
104112
};
105113

@@ -123,6 +131,11 @@ export class ParticleDebugBlock extends NodeParticleBlock {
123131

124132
this.stackSize = serializationObject.stackSize;
125133
}
134+
135+
public override dispose(): void {
136+
this.onDataCollectedObservable.clear();
137+
super.dispose();
138+
}
126139
}
127140

128141
RegisterClass("BABYLON.ParticleDebugBlock", ParticleDebugBlock);

packages/tools/nodeParticleEditor/src/graphSystem/properties/debugNodePropertyComponent.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import type { ParticleDebugBlock } from "core/Particles/Node/Blocks/particleDebu
99

1010
export class DebugPropertyTabComponent extends React.Component<IPropertyComponentProps> {
1111
private _onUpdateRequiredObserver: Nullable<Observer<any>>;
12+
private _dataCollectedObserver: Nullable<Observer<ParticleDebugBlock>>;
1213

1314
constructor(props: IPropertyComponentProps) {
1415
super(props);
@@ -21,12 +22,23 @@ export class DebugPropertyTabComponent extends React.Component<IPropertyComponen
2122
}
2223

2324
override componentWillUnmount() {
24-
this.props.stateManager.onUpdateRequiredObservable.remove(this._onUpdateRequiredObserver);
25+
this._onUpdateRequiredObserver?.remove();
26+
this._onUpdateRequiredObserver = null;
27+
this._dataCollectedObserver?.remove();
28+
this._dataCollectedObserver = null;
2529
}
2630

2731
override render() {
2832
const debugBlock = this.props.nodeData.data as ParticleDebugBlock;
2933

34+
if (this._dataCollectedObserver) {
35+
this._dataCollectedObserver.remove();
36+
}
37+
38+
this._dataCollectedObserver = debugBlock.onDataCollectedObservable.add((data) => {
39+
this.forceUpdate();
40+
});
41+
3042
return (
3143
<div>
3244
<GeneralPropertyTabComponent stateManager={this.props.stateManager} nodeData={this.props.nodeData} />

0 commit comments

Comments
 (0)