@babylonjs/core 6.28.0 → 6.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Animations/animatable.js +1 -1
- package/Animations/animatable.js.map +1 -1
- package/Animations/animation.js +1 -1
- package/Animations/animation.js.map +1 -1
- package/Animations/animationKey.d.ts +5 -0
- package/Animations/animationKey.js.map +1 -1
- package/Behaviors/Meshes/fadeInOutBehavior.js +2 -1
- package/Behaviors/Meshes/fadeInOutBehavior.js.map +1 -1
- package/Cameras/arcRotateCamera.js +37 -13
- package/Cameras/arcRotateCamera.js.map +1 -1
- package/Cameras/camera.d.ts +21 -0
- package/Cameras/camera.js +35 -0
- package/Cameras/camera.js.map +1 -1
- package/Cameras/targetCamera.js +51 -30
- package/Cameras/targetCamera.js.map +1 -1
- package/Debug/debugLayer.d.ts +4 -0
- package/Debug/debugLayer.js +12 -1
- package/Debug/debugLayer.js.map +1 -1
- package/Engines/constants.d.ts +2 -0
- package/Engines/constants.js +2 -0
- package/Engines/constants.js.map +1 -1
- package/Engines/thinEngine.js +2 -2
- package/Engines/thinEngine.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js +2 -2
- package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphSendCustomEventBlock.js +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphSendCustomEventBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.d.ts +21 -9
- package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js +7 -8
- package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js.map +1 -1
- package/FlowGraph/flowGraph.d.ts +2 -8
- package/FlowGraph/flowGraph.js +2 -9
- package/FlowGraph/flowGraph.js.map +1 -1
- package/FlowGraph/flowGraphBlock.d.ts +1 -0
- package/FlowGraph/flowGraphBlock.js +3 -0
- package/FlowGraph/flowGraphBlock.js.map +1 -1
- package/FlowGraph/flowGraphContext.d.ts +20 -2
- package/FlowGraph/flowGraphContext.js +37 -33
- package/FlowGraph/flowGraphContext.js.map +1 -1
- package/FlowGraph/flowGraphContextLogger.d.ts +9 -0
- package/FlowGraph/flowGraphContextLogger.js +14 -0
- package/FlowGraph/flowGraphContextLogger.js.map +1 -0
- package/FlowGraph/flowGraphCoordinator.d.ts +14 -5
- package/FlowGraph/flowGraphCoordinator.js +27 -3
- package/FlowGraph/flowGraphCoordinator.js.map +1 -1
- package/FlowGraph/flowGraphDataConnection.js +1 -0
- package/FlowGraph/flowGraphDataConnection.js.map +1 -1
- package/FlowGraph/flowGraphEventBlock.js +1 -0
- package/FlowGraph/flowGraphEventBlock.js.map +1 -1
- package/FlowGraph/flowGraphSignalConnection.js +1 -0
- package/FlowGraph/flowGraphSignalConnection.js.map +1 -1
- package/FlowGraph/index.d.ts +1 -1
- package/FlowGraph/index.js +1 -1
- package/FlowGraph/index.js.map +1 -1
- package/FlowGraph/serialization.d.ts +16 -0
- package/FlowGraph/serialization.js +79 -0
- package/FlowGraph/serialization.js.map +1 -0
- package/Materials/Textures/baseTexture.d.ts +2 -1
- package/Materials/Textures/baseTexture.js +12 -1
- package/Materials/Textures/baseTexture.js.map +1 -1
- package/Materials/Textures/renderTargetTexture.d.ts +2 -0
- package/Materials/Textures/renderTargetTexture.js +5 -2
- package/Materials/Textures/renderTargetTexture.js.map +1 -1
- package/Materials/Textures/texture.d.ts +2 -0
- package/Materials/Textures/texture.js +8 -3
- package/Materials/Textures/texture.js.map +1 -1
- package/Materials/materialPluginManager.js +1 -1
- package/Materials/materialPluginManager.js.map +1 -1
- package/Maths/math.vector.js +41 -26
- package/Maths/math.vector.js.map +1 -1
- package/Meshes/Builders/textBuilder.js +0 -1
- package/Meshes/Builders/textBuilder.js.map +1 -1
- package/Meshes/GreasedLine/greasedLineMesh.js +1 -1
- package/Meshes/GreasedLine/greasedLineMesh.js.map +1 -1
- package/Meshes/GreasedLine/greasedLineRibbonMesh.js +2 -2
- package/Meshes/GreasedLine/greasedLineRibbonMesh.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/boxBlock.js +2 -1
- package/Meshes/Node/Blocks/Sources/boxBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/capsuleBlock.js +2 -1
- package/Meshes/Node/Blocks/Sources/capsuleBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/cylinderBlock.js +2 -1
- package/Meshes/Node/Blocks/Sources/cylinderBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/discBlock.js +2 -1
- package/Meshes/Node/Blocks/Sources/discBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/gridBlock.js +2 -1
- package/Meshes/Node/Blocks/Sources/gridBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/icoSphereBlock.js +2 -1
- package/Meshes/Node/Blocks/Sources/icoSphereBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/planeBlock.js +2 -1
- package/Meshes/Node/Blocks/Sources/planeBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/sphereBlock.js +2 -1
- package/Meshes/Node/Blocks/Sources/sphereBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/torusBlock.js +2 -1
- package/Meshes/Node/Blocks/Sources/torusBlock.js.map +1 -1
- package/Meshes/abstractMesh.js +13 -9
- package/Meshes/abstractMesh.js.map +1 -1
- package/Meshes/csg.d.ts +8 -8
- package/Meshes/csg.js +12 -12
- package/Meshes/csg.js.map +1 -1
- package/Misc/deepCopier.d.ts +3 -1
- package/Misc/deepCopier.js +7 -5
- package/Misc/deepCopier.js.map +1 -1
- package/Misc/observable.d.ts +6 -2
- package/Misc/observable.js +0 -14
- package/Misc/observable.js.map +1 -1
- package/Misc/precisionDate.js +2 -4
- package/Misc/precisionDate.js.map +1 -1
- package/Rendering/renderingManager.d.ts +4 -0
- package/Rendering/renderingManager.js +18 -13
- package/Rendering/renderingManager.js.map +1 -1
- package/package.json +1 -1
- package/scene.d.ts +6 -0
- package/scene.js +11 -1
- package/scene.js.map +1 -1
- package/FlowGraph/flowGraphCustomEvent.d.ts +0 -5
- package/FlowGraph/flowGraphCustomEvent.js +0 -2
- package/FlowGraph/flowGraphCustomEvent.js.map +0 -1
- package/FlowGraph/flowGraphEventCoordinator.d.ts +0 -23
- package/FlowGraph/flowGraphEventCoordinator.js +0 -37
- package/FlowGraph/flowGraphEventCoordinator.js.map +0 -1
- package/FlowGraph/flowGraphVariableDefinitions.d.ts +0 -32
- package/FlowGraph/flowGraphVariableDefinitions.js +0 -51
- package/FlowGraph/flowGraphVariableDefinitions.js.map +0 -1
|
@@ -13,14 +13,14 @@ export class FlowGraphReceiveCustomEventBlock extends FlowGraphEventBlock {
|
|
|
13
13
|
this.eventData = this._registerDataOutput("eventData", RichTypeAny);
|
|
14
14
|
}
|
|
15
15
|
_preparePendingTasks(context) {
|
|
16
|
-
const observable = context.configuration.
|
|
16
|
+
const observable = context.configuration.coordinator.getCustomEventObservable(this.config.eventId);
|
|
17
17
|
this._eventObserver = observable.add((eventData) => {
|
|
18
18
|
this.eventData.setValue(eventData, context);
|
|
19
19
|
this._execute(context);
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
22
|
_cancelPendingTasks(context) {
|
|
23
|
-
const observable = context.configuration.
|
|
23
|
+
const observable = context.configuration.coordinator.getCustomEventObservable(this.config.eventId);
|
|
24
24
|
if (observable) {
|
|
25
25
|
observable.remove(this._eventObserver);
|
|
26
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flowGraphReceiveCustomEventBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"flowGraphReceiveCustomEventBlock.js","sourceRoot":"","sources":["../../../../../../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ACL,CAAC;IAEM,YAAY;QACf,OAAO,2BAA2B,CAAC;IACvC,CAAC;CACJ;AACD,aAAa,CAAC,2BAA2B,EAAE,gCAAgC,CAAC,CAAC","sourcesContent":["import type { Observer } from \"../../../Misc/observable\";\r\nimport type { FlowGraphContext } from \"../../flowGraphContext\";\r\nimport { FlowGraphEventBlock } from \"../../flowGraphEventBlock\";\r\nimport type { Nullable } from \"../../../types\";\r\nimport { Tools } from \"../../../Misc/tools\";\r\nimport type { FlowGraphDataConnection } from \"../../flowGraphDataConnection\";\r\nimport { RichTypeAny } from \"../../flowGraphRichTypes\";\r\nimport type { IFlowGraphBlockConfiguration } from \"../../flowGraphBlock\";\r\nimport { RegisterClass } from \"../../../Misc/typeStore\";\r\n/**\r\n * @experimental\r\n * Parameters used to create a FlowGraphReceiveCustomEventBlock.\r\n */\r\nexport interface IFlowGraphReceiveCustomEventBlockConfiguration extends IFlowGraphBlockConfiguration {\r\n eventId: string;\r\n}\r\n\r\n/**\r\n * @experimental\r\n * A block that receives a custom event. It saves the data sent in the eventData output.\r\n */\r\nexport class FlowGraphReceiveCustomEventBlock extends FlowGraphEventBlock {\r\n private _eventObserver: Nullable<Observer<any>>;\r\n\r\n /**\r\n * Output connection: The data sent with the event.\r\n */\r\n public eventData: FlowGraphDataConnection<any>;\r\n\r\n constructor(public config: IFlowGraphReceiveCustomEventBlockConfiguration) {\r\n super(config);\r\n this.eventData = this._registerDataOutput(\"eventData\", RichTypeAny);\r\n }\r\n public _preparePendingTasks(context: FlowGraphContext): void {\r\n const observable = context.configuration.coordinator.getCustomEventObservable(this.config.eventId);\r\n this._eventObserver = observable.add((eventData) => {\r\n this.eventData.setValue(eventData, context);\r\n this._execute(context);\r\n });\r\n }\r\n public _cancelPendingTasks(context: FlowGraphContext): void {\r\n const observable = context.configuration.coordinator.getCustomEventObservable(this.config.eventId);\r\n if (observable) {\r\n observable.remove(this._eventObserver);\r\n } else {\r\n Tools.Warn(`FlowGraphReceiveCustomEventBlock: Missing observable for event ${this.config.eventId}`);\r\n }\r\n }\r\n\r\n public getClassName(): string {\r\n return \"FGReceiveCustomEventBlock\";\r\n }\r\n}\r\nRegisterClass(\"FGReceiveCustomEventBlock\", FlowGraphReceiveCustomEventBlock);\r\n"]}
|
|
@@ -13,7 +13,7 @@ export class FlowGraphSendCustomEventBlock extends FlowGraphWithOnDoneExecutionB
|
|
|
13
13
|
_execute(context) {
|
|
14
14
|
const eventId = this.eventId.getValue(context);
|
|
15
15
|
const eventData = this.eventData.getValue(context);
|
|
16
|
-
context.configuration.
|
|
16
|
+
context.configuration.coordinator.notifyCustomEvent(eventId, eventData);
|
|
17
17
|
this.onDone._activateSignal(context);
|
|
18
18
|
}
|
|
19
19
|
getClassName() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flowGraphSendCustomEventBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FlowGraph/Blocks/Execution/flowGraphSendCustomEventBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,oCAA0C;AAEhF,OAAO,EAAE,iCAAiC,EAAE,MAAM,yCAAyC,CAAC;AAE5F,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAGxD;;GAEG;AACH,MAAM,OAAO,6BAA8B,SAAQ,iCAAiC;IAUhF,YAAmB,MAAqC;QACpD,KAAK,CAAC,MAAM,CAAC,CAAC;QAEd,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,kBAAkB,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;QAClE,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,kBAAkB,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;IACvE,CAAC;IAEM,QAAQ,CAAC,OAAyB;QACrC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC/C,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAEnD,OAAO,CAAC,aAAa,CAAC,
|
|
1
|
+
{"version":3,"file":"flowGraphSendCustomEventBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FlowGraph/Blocks/Execution/flowGraphSendCustomEventBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,oCAA0C;AAEhF,OAAO,EAAE,iCAAiC,EAAE,MAAM,yCAAyC,CAAC;AAE5F,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAGxD;;GAEG;AACH,MAAM,OAAO,6BAA8B,SAAQ,iCAAiC;IAUhF,YAAmB,MAAqC;QACpD,KAAK,CAAC,MAAM,CAAC,CAAC;QAEd,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,kBAAkB,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;QAClE,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,kBAAkB,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;IACvE,CAAC;IAEM,QAAQ,CAAC,OAAyB;QACrC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC/C,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAEnD,OAAO,CAAC,aAAa,CAAC,WAAW,CAAC,iBAAiB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QAExE,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;IAEM,YAAY;QACf,OAAO,wBAAwB,CAAC;IACpC,CAAC;CACJ;AACD,aAAa,CAAC,wBAAwB,EAAE,6BAA6B,CAAC,CAAC","sourcesContent":["import { RichTypeAny, RichTypeString } from \"core/FlowGraph/flowGraphRichTypes\";\r\nimport type { FlowGraphDataConnection } from \"../../flowGraphDataConnection\";\r\nimport { FlowGraphWithOnDoneExecutionBlock } from \"../../flowGraphWithOnDoneExecutionBlock\";\r\nimport type { FlowGraphContext } from \"../../flowGraphContext\";\r\nimport { RegisterClass } from \"../../../Misc/typeStore\";\r\nimport type { IFlowGraphBlockConfiguration } from \"../../flowGraphBlock\";\r\n\r\n/**\r\n * @experimental\r\n */\r\nexport class FlowGraphSendCustomEventBlock extends FlowGraphWithOnDoneExecutionBlock {\r\n /**\r\n * Input connection: The id of the event to send.\r\n */\r\n public readonly eventId: FlowGraphDataConnection<string>;\r\n /**\r\n * Input connection: The data to send with the event.\r\n */\r\n public readonly eventData: FlowGraphDataConnection<any>;\r\n\r\n public constructor(config?: IFlowGraphBlockConfiguration) {\r\n super(config);\r\n\r\n this.eventId = this._registerDataInput(\"eventId\", RichTypeString);\r\n this.eventData = this._registerDataInput(\"eventData\", RichTypeAny);\r\n }\r\n\r\n public _execute(context: FlowGraphContext): void {\r\n const eventId = this.eventId.getValue(context);\r\n const eventData = this.eventData.getValue(context);\r\n\r\n context.configuration.coordinator.notifyCustomEvent(eventId, eventData);\r\n\r\n this.onDone._activateSignal(context);\r\n }\r\n\r\n public getClassName(): string {\r\n return \"FGSendCustomEventBlock\";\r\n }\r\n}\r\nRegisterClass(\"FGSendCustomEventBlock\", FlowGraphSendCustomEventBlock);\r\n"]}
|
|
@@ -4,24 +4,36 @@ import { FlowGraphWithOnDoneExecutionBlock } from "../../flowGraphWithOnDoneExec
|
|
|
4
4
|
import type { IFlowGraphBlockConfiguration } from "../../flowGraphBlock";
|
|
5
5
|
/**
|
|
6
6
|
* @experimental
|
|
7
|
-
*
|
|
8
|
-
* TODO: Add support for animating the property.
|
|
7
|
+
* Configuration for the set property block.
|
|
9
8
|
*/
|
|
10
|
-
export
|
|
9
|
+
export interface IFlowGraphSetPropertyBlockConfiguration extends IFlowGraphBlockConfiguration {
|
|
10
|
+
/**
|
|
11
|
+
* The path of the entity whose property will be set. Needs a corresponding
|
|
12
|
+
* entity on the context variables.
|
|
13
|
+
*/
|
|
14
|
+
path: string;
|
|
11
15
|
/**
|
|
12
|
-
*
|
|
16
|
+
* The property to set on the target object.
|
|
13
17
|
*/
|
|
14
|
-
|
|
18
|
+
property: string;
|
|
15
19
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
20
|
+
* A string that will be substituted by a node with the same name, if encountered enclosed by \{\}.
|
|
21
|
+
* It will create an input data node which expects a number. The value of the node will be used
|
|
22
|
+
* to substitute the string.
|
|
18
23
|
*/
|
|
19
|
-
|
|
24
|
+
subString: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* @experimental
|
|
28
|
+
* Block that sets a property on a target object.
|
|
29
|
+
*/
|
|
30
|
+
export declare class FlowGraphSetPropertyBlock<ValueT> extends FlowGraphWithOnDoneExecutionBlock {
|
|
31
|
+
config: IFlowGraphSetPropertyBlockConfiguration;
|
|
20
32
|
/**
|
|
21
33
|
* Input connection: The value to set on the property.
|
|
22
34
|
*/
|
|
23
35
|
readonly value: FlowGraphDataConnection<ValueT>;
|
|
24
|
-
constructor(config
|
|
36
|
+
constructor(config: IFlowGraphSetPropertyBlockConfiguration);
|
|
25
37
|
private _setProperty;
|
|
26
38
|
_execute(context: FlowGraphContext): void;
|
|
27
39
|
getClassName(): string;
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RichTypeAny, RichTypeNumber } from "../../flowGraphRichTypes.js";
|
|
2
2
|
import { FlowGraphWithOnDoneExecutionBlock } from "../../flowGraphWithOnDoneExecutionBlock.js";
|
|
3
3
|
import { RegisterClass } from "../../../Misc/typeStore.js";
|
|
4
4
|
/**
|
|
5
5
|
* @experimental
|
|
6
6
|
* Block that sets a property on a target object.
|
|
7
|
-
* TODO: Add support for animating the property.
|
|
8
7
|
*/
|
|
9
8
|
export class FlowGraphSetPropertyBlock extends FlowGraphWithOnDoneExecutionBlock {
|
|
10
9
|
constructor(config) {
|
|
11
10
|
super(config);
|
|
12
|
-
this.
|
|
13
|
-
this.property = this._registerDataInput("property", RichTypeString);
|
|
11
|
+
this.config = config;
|
|
14
12
|
this.value = this._registerDataInput("value", RichTypeAny);
|
|
13
|
+
this._registerDataInput(config.subString, RichTypeNumber);
|
|
15
14
|
}
|
|
16
15
|
_setProperty(target, property, value) {
|
|
17
16
|
const splitProp = property.split(".");
|
|
@@ -22,14 +21,14 @@ export class FlowGraphSetPropertyBlock extends FlowGraphWithOnDoneExecutionBlock
|
|
|
22
21
|
currentTarget[splitProp[splitProp.length - 1]] = value;
|
|
23
22
|
}
|
|
24
23
|
_execute(context) {
|
|
25
|
-
const target = this.
|
|
26
|
-
const property = this.property
|
|
24
|
+
const target = context._getTargetFromPath(this.config.path, this.config.subString, this);
|
|
25
|
+
const property = this.config.property;
|
|
27
26
|
const value = this.value.getValue(context);
|
|
28
|
-
if (target && property
|
|
27
|
+
if (target && property) {
|
|
29
28
|
this._setProperty(target, property, value);
|
|
30
29
|
}
|
|
31
30
|
else {
|
|
32
|
-
throw new Error("Invalid target
|
|
31
|
+
throw new Error("Invalid target or property");
|
|
33
32
|
}
|
|
34
33
|
this.onDone._activateSignal(context);
|
|
35
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flowGraphSetPropertyBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"flowGraphSetPropertyBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAGvE,OAAO,EAAE,iCAAiC,EAAE,MAAM,yCAAyC,CAAC;AAC5F,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAyBxD;;;GAGG;AACH,MAAM,OAAO,yBAAkC,SAAQ,iCAAiC;IAMpF,YAA0B,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AC,CAAC;IACzC,CAAC;IAEM,YAAY;QACf,OAAO,oBAAoB,CAAC;IAChC,CAAC;CACJ;AACD,aAAa,CAAC,oBAAoB,EAAE,yBAAyB,CAAC,CAAC","sourcesContent":["import { RichTypeAny, RichTypeNumber } from \"../../flowGraphRichTypes\";\r\nimport type { FlowGraphContext } from \"../../flowGraphContext\";\r\nimport type { FlowGraphDataConnection } from \"../../flowGraphDataConnection\";\r\nimport { FlowGraphWithOnDoneExecutionBlock } from \"../../flowGraphWithOnDoneExecutionBlock\";\r\nimport { RegisterClass } from \"../../../Misc/typeStore\";\r\nimport type { IFlowGraphBlockConfiguration } from \"../../flowGraphBlock\";\r\n\r\n/**\r\n * @experimental\r\n * Configuration for the set property block.\r\n */\r\nexport interface IFlowGraphSetPropertyBlockConfiguration extends IFlowGraphBlockConfiguration {\r\n /**\r\n * The path of the entity whose property will be set. Needs a corresponding\r\n * entity on the context variables.\r\n */\r\n path: string;\r\n /**\r\n * The property to set on the target object.\r\n */\r\n property: string;\r\n /**\r\n * A string that will be substituted by a node with the same name, if encountered enclosed by \\{\\}.\r\n * It will create an input data node which expects a number. The value of the node will be used\r\n * to substitute the string.\r\n */\r\n subString: string;\r\n}\r\n\r\n/**\r\n * @experimental\r\n * Block that sets a property on a target object.\r\n */\r\nexport class FlowGraphSetPropertyBlock<ValueT> extends FlowGraphWithOnDoneExecutionBlock {\r\n /**\r\n * Input connection: The value to set on the property.\r\n */\r\n public readonly value: FlowGraphDataConnection<ValueT>;\r\n\r\n public constructor(public config: IFlowGraphSetPropertyBlockConfiguration) {\r\n super(config);\r\n\r\n this.value = this._registerDataInput(\"value\", RichTypeAny);\r\n this._registerDataInput(config.subString, RichTypeNumber);\r\n }\r\n\r\n private _setProperty(target: any, property: string, value: any): void {\r\n const splitProp = property.split(\".\");\r\n\r\n let currentTarget = target;\r\n for (let i = 0; i < splitProp.length - 1; i++) {\r\n currentTarget = currentTarget[splitProp[i]];\r\n }\r\n\r\n currentTarget[splitProp[splitProp.length - 1]] = value;\r\n }\r\n\r\n public _execute(context: FlowGraphContext): void {\r\n const target = context._getTargetFromPath(this.config.path, this.config.subString, this);\r\n const property = this.config.property;\r\n const value = this.value.getValue(context);\r\n\r\n if (target && property) {\r\n this._setProperty(target, property, value);\r\n } else {\r\n throw new Error(\"Invalid target or property\");\r\n }\r\n\r\n this.onDone._activateSignal(context);\r\n }\r\n\r\n public getClassName(): string {\r\n return \"FGSetPropertyBlock\";\r\n }\r\n}\r\nRegisterClass(\"FGSetPropertyBlock\", FlowGraphSetPropertyBlock);\r\n"]}
|
package/FlowGraph/flowGraph.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type { Scene } from "../scene";
|
|
2
2
|
import { FlowGraphEventBlock } from "./flowGraphEventBlock";
|
|
3
|
-
import { FlowGraphVariableDefinitions } from "./flowGraphVariableDefinitions";
|
|
4
3
|
import { FlowGraphContext } from "./flowGraphContext";
|
|
5
|
-
import type { FlowGraphEventCoordinator } from "./flowGraphEventCoordinator";
|
|
6
4
|
import { FlowGraphBlock } from "./flowGraphBlock";
|
|
7
5
|
import type { FlowGraphCoordinator } from "./flowGraphCoordinator";
|
|
8
6
|
import type { FlowGraphSignalConnection } from "./flowGraphSignalConnection";
|
|
@@ -29,7 +27,7 @@ export interface FlowGraphParams {
|
|
|
29
27
|
/**
|
|
30
28
|
* The event coordinator used by the flow graph.
|
|
31
29
|
*/
|
|
32
|
-
|
|
30
|
+
coordinator: FlowGraphCoordinator;
|
|
33
31
|
}
|
|
34
32
|
/**
|
|
35
33
|
* @experimental
|
|
@@ -39,10 +37,6 @@ export interface FlowGraphParams {
|
|
|
39
37
|
* The graph can then be started, which will init and start all of its event blocks.
|
|
40
38
|
*/
|
|
41
39
|
export declare class FlowGraph {
|
|
42
|
-
/**
|
|
43
|
-
* The variables defined for this graph
|
|
44
|
-
*/
|
|
45
|
-
variableDefinitions: FlowGraphVariableDefinitions;
|
|
46
40
|
/** @internal */
|
|
47
41
|
_eventBlocks: FlowGraphEventBlock[];
|
|
48
42
|
private _sceneDisposeObserver;
|
|
@@ -50,7 +44,7 @@ export declare class FlowGraph {
|
|
|
50
44
|
* @internal
|
|
51
45
|
*/
|
|
52
46
|
readonly _scene: Scene;
|
|
53
|
-
private
|
|
47
|
+
private _coordinator;
|
|
54
48
|
private _executionContexts;
|
|
55
49
|
/**
|
|
56
50
|
* The state of the graph
|
package/FlowGraph/flowGraph.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { FlowGraphEventBlock } from "./flowGraphEventBlock.js";
|
|
2
|
-
import { FlowGraphVariableDefinitions } from "./flowGraphVariableDefinitions.js";
|
|
3
2
|
import { FlowGraphContext } from "./flowGraphContext.js";
|
|
4
3
|
import { FlowGraphBlock } from "./flowGraphBlock.js";
|
|
5
4
|
import { FlowGraphExecutionBlock } from "./flowGraphExecutionBlock.js";
|
|
@@ -27,10 +26,6 @@ export class FlowGraph {
|
|
|
27
26
|
* @param params construction parameters. currently only the scene
|
|
28
27
|
*/
|
|
29
28
|
constructor(params) {
|
|
30
|
-
/**
|
|
31
|
-
* The variables defined for this graph
|
|
32
|
-
*/
|
|
33
|
-
this.variableDefinitions = new FlowGraphVariableDefinitions();
|
|
34
29
|
/** @internal */
|
|
35
30
|
this._eventBlocks = [];
|
|
36
31
|
this._executionContexts = [];
|
|
@@ -39,7 +34,7 @@ export class FlowGraph {
|
|
|
39
34
|
*/
|
|
40
35
|
this.state = FlowGraphState.Stopped;
|
|
41
36
|
this._scene = params.scene;
|
|
42
|
-
this.
|
|
37
|
+
this._coordinator = params.coordinator;
|
|
43
38
|
this._sceneDisposeObserver = this._scene.onDisposeObservable.add(() => this.dispose());
|
|
44
39
|
}
|
|
45
40
|
/**
|
|
@@ -47,7 +42,7 @@ export class FlowGraph {
|
|
|
47
42
|
* @returns the context, where you can get and set variables
|
|
48
43
|
*/
|
|
49
44
|
createContext() {
|
|
50
|
-
const context =
|
|
45
|
+
const context = new FlowGraphContext({ scene: this._scene, coordinator: this._coordinator });
|
|
51
46
|
this._executionContexts.push(context);
|
|
52
47
|
return context;
|
|
53
48
|
}
|
|
@@ -133,7 +128,6 @@ export class FlowGraph {
|
|
|
133
128
|
*/
|
|
134
129
|
serialize(serializationObject = {}, valueSerializeFunction) {
|
|
135
130
|
serializationObject.variableDefinitions = {};
|
|
136
|
-
this.variableDefinitions.serialize(serializationObject.variableDefinitions);
|
|
137
131
|
serializationObject.allBlocks = [];
|
|
138
132
|
this.visitAllBlocks((block) => {
|
|
139
133
|
const serializedBlock = {};
|
|
@@ -190,7 +184,6 @@ export class FlowGraph {
|
|
|
190
184
|
*/
|
|
191
185
|
static Parse(serializationObject, coordinator, valueParseFunction) {
|
|
192
186
|
const graph = coordinator.createGraph();
|
|
193
|
-
graph.variableDefinitions.deserialize(serializationObject.variableDefinitions);
|
|
194
187
|
const blocks = [];
|
|
195
188
|
// Parse all blocks
|
|
196
189
|
for (const serializedBlock of serializationObject.allBlocks) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flowGraph.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraph.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAKpE,MAAM,CAAN,IAAY,cASX;AATD,WAAY,cAAc;IACtB;;OAEG;IACH,yDAAO,CAAA;IACP;;OAEG;IACH,yDAAO,CAAA;AACX,CAAC,EATW,cAAc,KAAd,cAAc,QASzB;AAgBD;;;;;;GAMG;AACH,MAAM,OAAO,SAAS;IAqBlB;;;OAGG;IACH,YAAmB,MAAuB;QAxB1C;;WAEG;Q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C,CAAC;YACnB,IAAI,KAAK,YAAY,mBAAmB,EAAE;gBACtC,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;aAC9B;SACJ;QACD,yCAAyC;QACzC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;YACxB,KAAK,MAAM,MAAM,IAAI,KAAK,CAAC,UAAU,EAAE;gBACnC,KAAK,MAAM,oBAAoB,IAAI,MAAM,CAAC,iBAAiB,EAAE;oBACzD,MAAM,UAAU,GAAG,SAAS,CAAC,8BAA8B,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;oBAC1F,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;iBAChC;aACJ;YACD,IAAI,KAAK,YAAY,uBAAuB,EAAE;gBAC1C,KAAK,MAAM,SAAS,IAAI,KAAK,CAAC,aAAa,EAAE;oBACzC,KAAK,MAAM,oBAAoB,IAAI,SAAS,CAAC,iBAAiB,EAAE;wBAC5D,MAAM,UAAU,GAAG,SAAS,CAAC,+BAA+B,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;wBAC3F,SAAS,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;qBACnC;iBACJ;aACJ;SACJ;QACD,KAAK,MAAM,iBAAiB,IAAI,mBAAmB,CAAC,iBAAiB,EAAE;YACnE,gBAAgB,CAAC,KAAK,CAAC,iBAAiB,EAAE,KAAK,EAAE,kBAAkB,CAAC,CAAC;SACxE;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ","sourcesContent":["import type { Observer } from \"../Misc/observable\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { Scene } from \"../scene\";\r\nimport { FlowGraphEventBlock } from \"./flowGraphEventBlock\";\r\nimport { FlowGraphVariableDefinitions } from \"./flowGraphVariableDefinitions\";\r\nimport { FlowGraphContext } from \"./flowGraphContext\";\r\nimport type { FlowGraphEventCoordinator } from \"./flowGraphEventCoordinator\";\r\nimport { FlowGraphBlock } from \"./flowGraphBlock\";\r\nimport { FlowGraphExecutionBlock } from \"./flowGraphExecutionBlock\";\r\nimport type { FlowGraphCoordinator } from \"./flowGraphCoordinator\";\r\nimport type { FlowGraphSignalConnection } from \"./flowGraphSignalConnection\";\r\nimport type { FlowGraphDataConnection } from \"./flowGraphDataConnection\";\r\n\r\nexport enum FlowGraphState {\r\n /**\r\n * The graph is stopped\r\n */\r\n Stopped,\r\n /**\r\n * The graph is running\r\n */\r\n Started,\r\n}\r\n\r\n/**\r\n * @experimental\r\n * Parameters used to create a flow graph.\r\n */\r\nexport interface FlowGraphParams {\r\n /**\r\n * The scene that the flow graph belongs to.\r\n */\r\n scene: Scene;\r\n /**\r\n * The event coordinator used by the flow graph.\r\n */\r\n eventCoordinator: FlowGraphEventCoordinator;\r\n}\r\n/**\r\n * @experimental\r\n * Class used to represent a flow graph.\r\n * A flow graph is a graph of blocks that can be used to create complex logic.\r\n * Blocks can be added to the graph and connected to each other.\r\n * The graph can then be started, which will init and start all of its event blocks.\r\n */\r\nexport class FlowGraph {\r\n /**\r\n * The variables defined for this graph\r\n */\r\n public variableDefinitions: FlowGraphVariableDefinitions = new FlowGraphVariableDefinitions();\r\n\r\n /** @internal */\r\n public _eventBlocks: FlowGraphEventBlock[] = [];\r\n private _sceneDisposeObserver: Nullable<Observer<Scene>>;\r\n /**\r\n * @internal\r\n */\r\n public readonly _scene: Scene;\r\n private _eventCoordinator: FlowGraphEventCoordinator;\r\n private _executionContexts: FlowGraphContext[] = [];\r\n\r\n /**\r\n * The state of the graph\r\n */\r\n state: FlowGraphState = FlowGraphState.Stopped;\r\n\r\n /**\r\n * Construct a Flow Graph\r\n * @param params construction parameters. currently only the scene\r\n */\r\n public constructor(params: FlowGraphParams) {\r\n this._scene = params.scene;\r\n this._eventCoordinator = params.eventCoordinator;\r\n this._sceneDisposeObserver = this._scene.onDisposeObservable.add(() => this.dispose());\r\n }\r\n\r\n /**\r\n * Create a context. A context represents one self contained execution for the graph, with its own variables.\r\n * @returns the context, where you can get and set variables\r\n */\r\n public createContext() {\r\n const context = this.variableDefinitions.generateContext({ scene: this._scene, eventCoordinator: this._eventCoordinator });\r\n this._executionContexts.push(context);\r\n return context;\r\n }\r\n\r\n /**\r\n * Add an event block. When the graph is started, it will start listening to events\r\n * from the block and execute the graph when they are triggered.\r\n * @param block\r\n */\r\n public addEventBlock(block: FlowGraphEventBlock): void {\r\n this._eventBlocks.push(block);\r\n }\r\n\r\n /**\r\n * Starts the flow graph. Initializes the event blocks and starts listening to events.\r\n */\r\n public start() {\r\n if (this.state === FlowGraphState.Started) {\r\n return;\r\n }\r\n this.state = FlowGraphState.Started;\r\n if (this._executionContexts.length === 0) {\r\n this.createContext();\r\n }\r\n for (const context of this._executionContexts) {\r\n for (const block of this._eventBlocks) {\r\n block._startPendingTasks(context);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Disposes of the flow graph. Cancels any pending tasks and removes all event listeners.\r\n */\r\n public dispose() {\r\n if (this.state === FlowGraphState.Stopped) {\r\n return;\r\n }\r\n this.state = FlowGraphState.Stopped;\r\n for (const context of this._executionContexts) {\r\n context._clearPendingBlocks();\r\n }\r\n this._executionContexts.length = 0;\r\n this._eventBlocks.length = 0;\r\n this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);\r\n this._sceneDisposeObserver = null;\r\n }\r\n\r\n /**\r\n * Executes a function in all blocks of a flow graph, starting with the event blocks.\r\n * @param visitor the function to execute.\r\n */\r\n public visitAllBlocks(visitor: (block: FlowGraphBlock) => void) {\r\n const visitList: FlowGraphBlock[] = [];\r\n const idsAddedToVisitList = new Set<string>();\r\n for (const block of this._eventBlocks) {\r\n visitList.push(block);\r\n idsAddedToVisitList.add(block.uniqueId);\r\n }\r\n\r\n while (visitList.length > 0) {\r\n const block = visitList.pop()!;\r\n visitor(block);\r\n\r\n for (const dataIn of block.dataInputs) {\r\n for (const connection of dataIn._connectedPoint) {\r\n if (!idsAddedToVisitList.has(connection._ownerBlock.uniqueId)) {\r\n visitList.push(connection._ownerBlock);\r\n idsAddedToVisitList.add(connection._ownerBlock.uniqueId);\r\n }\r\n }\r\n }\r\n if (block instanceof FlowGraphExecutionBlock) {\r\n for (const signalOut of block.signalOutputs) {\r\n for (const connection of signalOut._connectedPoint) {\r\n if (!idsAddedToVisitList.has(connection._ownerBlock.uniqueId)) {\r\n visitList.push(connection._ownerBlock);\r\n idsAddedToVisitList.add(connection._ownerBlock.uniqueId);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Serializes a graph\r\n * @param serializationObject the object to write the values in\r\n * @param valueSerializeFunction a function to serialize complex values\r\n */\r\n public serialize(serializationObject: any = {}, valueSerializeFunction?: (key: string, value: any, serializationObject: any) => void) {\r\n serializationObject.variableDefinitions = {};\r\n this.variableDefinitions.serialize(serializationObject.variableDefinitions);\r\n serializationObject.allBlocks = [];\r\n this.visitAllBlocks((block) => {\r\n const serializedBlock: any = {};\r\n block.serialize(serializedBlock);\r\n serializationObject.allBlocks.push(serializedBlock);\r\n });\r\n serializationObject.executionContexts = [];\r\n for (const context of this._executionContexts) {\r\n const serializedContext: any = {};\r\n context.serialize(serializedContext, valueSerializeFunction);\r\n serializationObject.executionContexts.push(serializedContext);\r\n }\r\n }\r\n\r\n /**\r\n * Given a list of blocks, find an output data connection that has a specific unique id\r\n * @param blocks\r\n * @param uniqueId\r\n * @returns\r\n */\r\n public static GetDataOutConnectionByUniqueId(blocks: FlowGraphBlock[], uniqueId: string): FlowGraphDataConnection<any> {\r\n for (const block of blocks) {\r\n for (const dataOut of block.dataOutputs) {\r\n if (dataOut.uniqueId === uniqueId) {\r\n return dataOut;\r\n }\r\n }\r\n }\r\n throw new Error(\"Could not find data out connection with unique id \" + uniqueId);\r\n }\r\n\r\n /**\r\n * Given a list of blocks, find an input signal connection that has a specific unique id\r\n * @param blocks\r\n * @param uniqueId\r\n * @returns\r\n */\r\n public static GetSignalInConnectionByUniqueId(blocks: FlowGraphBlock[], uniqueId: string): FlowGraphSignalConnection {\r\n for (const block of blocks) {\r\n if (block instanceof FlowGraphExecutionBlock) {\r\n for (const signalIn of block.signalInputs) {\r\n if (signalIn.uniqueId === uniqueId) {\r\n return signalIn;\r\n }\r\n }\r\n }\r\n }\r\n throw new Error(\"Could not find signal in connection with unique id \" + uniqueId);\r\n }\r\n\r\n /**\r\n * Parses a graph from a given serialization object\r\n * @param serializationObject the object where the values are written\r\n * @param coordinator the flow graph coordinator\r\n * @param valueParseFunction a function to parse complex values in a scene\r\n * @returns\r\n */\r\n public static Parse(serializationObject: any, coordinator: FlowGraphCoordinator, valueParseFunction?: (key: string, serializationObject: any, scene: Scene) => any): FlowGraph {\r\n const graph = coordinator.createGraph();\r\n graph.variableDefinitions.deserialize(serializationObject.variableDefinitions);\r\n const blocks: FlowGraphBlock[] = [];\r\n // Parse all blocks\r\n for (const serializedBlock of serializationObject.allBlocks) {\r\n const block = FlowGraphBlock.Parse(serializedBlock);\r\n blocks.push(block);\r\n if (block instanceof FlowGraphEventBlock) {\r\n graph.addEventBlock(block);\r\n }\r\n }\r\n // After parsing all blocks, connect them\r\n for (const block of blocks) {\r\n for (const dataIn of block.dataInputs) {\r\n for (const serializedConnection of dataIn.connectedPointIds) {\r\n const connection = FlowGraph.GetDataOutConnectionByUniqueId(blocks, serializedConnection);\r\n dataIn.connectTo(connection);\r\n }\r\n }\r\n if (block instanceof FlowGraphExecutionBlock) {\r\n for (const signalOut of block.signalOutputs) {\r\n for (const serializedConnection of signalOut.connectedPointIds) {\r\n const connection = FlowGraph.GetSignalInConnectionByUniqueId(blocks, serializedConnection);\r\n signalOut.connectTo(connection);\r\n }\r\n }\r\n }\r\n }\r\n for (const serializedContext of serializationObject.executionContexts) {\r\n FlowGraphContext.Parse(serializedContext, graph, valueParseFunction);\r\n }\r\n return graph;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"flowGraph.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraph.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAA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C,mBAAmB;QACnB,KAAK,MAAM,eAAe,IAAI,mBAAmB,CAAC,SAAS,EAAE;YACzD,MAAM,KAAK,GAAG,cAAc,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;YACpD,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACnB,IAAI,KAAK,YAAY,mBAAmB,EAAE;gBACtC,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;aAC9B;SACJ;QACD,yCAAyC;QACzC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;YACxB,KAAK,MAAM,MAAM,IAAI,KAAK,CAAC,UAAU,EAAE;gBACnC,KAAK,MAAM,oBAAoB,IAAI,MAAM,CAAC,iBAAiB,EAAE;oBACzD,MAAM,UAAU,GAAG,SAAS,CAAC,8BAA8B,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;oBAC1F,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;iBAChC;aACJ;YACD,IAAI,KAAK,YAAY,uBAAuB,EAAE;gBAC1C,KAAK,MAAM,SAAS,IAAI,KAAK,CAAC,aAAa,EAAE;oBACzC,KAAK,MAAM,oBAAoB,IAAI,SAAS,CAAC,iBAAiB,EAAE;wBAC5D,MAAM,UAAU,GAAG,SAAS,CAAC,+BAA+B,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;wBAC3F,SAAS,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;qBACnC;iBACJ;aACJ;SACJ;QACD,KAAK,MAAM,iBAAiB,IAAI,mBAAmB,CAAC,iBAAiB,EAAE;YACnE,gBAAgB,CAAC,KAAK,CAAC,iBAAiB,EAAE,KAAK,EAAE,kBAAkB,CAAC,CAAC;SACxE;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ","sourcesContent":["import type { Observer } from \"../Misc/observable\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { Scene } from \"../scene\";\r\nimport { FlowGraphEventBlock } from \"./flowGraphEventBlock\";\r\nimport { FlowGraphContext } from \"./flowGraphContext\";\r\nimport { FlowGraphBlock } from \"./flowGraphBlock\";\r\nimport { FlowGraphExecutionBlock } from \"./flowGraphExecutionBlock\";\r\nimport type { FlowGraphCoordinator } from \"./flowGraphCoordinator\";\r\nimport type { FlowGraphSignalConnection } from \"./flowGraphSignalConnection\";\r\nimport type { FlowGraphDataConnection } from \"./flowGraphDataConnection\";\r\n\r\nexport enum FlowGraphState {\r\n /**\r\n * The graph is stopped\r\n */\r\n Stopped,\r\n /**\r\n * The graph is running\r\n */\r\n Started,\r\n}\r\n\r\n/**\r\n * @experimental\r\n * Parameters used to create a flow graph.\r\n */\r\nexport interface FlowGraphParams {\r\n /**\r\n * The scene that the flow graph belongs to.\r\n */\r\n scene: Scene;\r\n /**\r\n * The event coordinator used by the flow graph.\r\n */\r\n coordinator: FlowGraphCoordinator;\r\n}\r\n/**\r\n * @experimental\r\n * Class used to represent a flow graph.\r\n * A flow graph is a graph of blocks that can be used to create complex logic.\r\n * Blocks can be added to the graph and connected to each other.\r\n * The graph can then be started, which will init and start all of its event blocks.\r\n */\r\nexport class FlowGraph {\r\n /** @internal */\r\n public _eventBlocks: FlowGraphEventBlock[] = [];\r\n private _sceneDisposeObserver: Nullable<Observer<Scene>>;\r\n /**\r\n * @internal\r\n */\r\n public readonly _scene: Scene;\r\n private _coordinator: FlowGraphCoordinator;\r\n private _executionContexts: FlowGraphContext[] = [];\r\n\r\n /**\r\n * The state of the graph\r\n */\r\n state: FlowGraphState = FlowGraphState.Stopped;\r\n\r\n /**\r\n * Construct a Flow Graph\r\n * @param params construction parameters. currently only the scene\r\n */\r\n public constructor(params: FlowGraphParams) {\r\n this._scene = params.scene;\r\n this._coordinator = params.coordinator;\r\n this._sceneDisposeObserver = this._scene.onDisposeObservable.add(() => this.dispose());\r\n }\r\n\r\n /**\r\n * Create a context. A context represents one self contained execution for the graph, with its own variables.\r\n * @returns the context, where you can get and set variables\r\n */\r\n public createContext() {\r\n const context = new FlowGraphContext({ scene: this._scene, coordinator: this._coordinator });\r\n this._executionContexts.push(context);\r\n return context;\r\n }\r\n\r\n /**\r\n * Add an event block. When the graph is started, it will start listening to events\r\n * from the block and execute the graph when they are triggered.\r\n * @param block\r\n */\r\n public addEventBlock(block: FlowGraphEventBlock): void {\r\n this._eventBlocks.push(block);\r\n }\r\n\r\n /**\r\n * Starts the flow graph. Initializes the event blocks and starts listening to events.\r\n */\r\n public start() {\r\n if (this.state === FlowGraphState.Started) {\r\n return;\r\n }\r\n this.state = FlowGraphState.Started;\r\n if (this._executionContexts.length === 0) {\r\n this.createContext();\r\n }\r\n for (const context of this._executionContexts) {\r\n for (const block of this._eventBlocks) {\r\n block._startPendingTasks(context);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Disposes of the flow graph. Cancels any pending tasks and removes all event listeners.\r\n */\r\n public dispose() {\r\n if (this.state === FlowGraphState.Stopped) {\r\n return;\r\n }\r\n this.state = FlowGraphState.Stopped;\r\n for (const context of this._executionContexts) {\r\n context._clearPendingBlocks();\r\n }\r\n this._executionContexts.length = 0;\r\n this._eventBlocks.length = 0;\r\n this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);\r\n this._sceneDisposeObserver = null;\r\n }\r\n\r\n /**\r\n * Executes a function in all blocks of a flow graph, starting with the event blocks.\r\n * @param visitor the function to execute.\r\n */\r\n public visitAllBlocks(visitor: (block: FlowGraphBlock) => void) {\r\n const visitList: FlowGraphBlock[] = [];\r\n const idsAddedToVisitList = new Set<string>();\r\n for (const block of this._eventBlocks) {\r\n visitList.push(block);\r\n idsAddedToVisitList.add(block.uniqueId);\r\n }\r\n\r\n while (visitList.length > 0) {\r\n const block = visitList.pop()!;\r\n visitor(block);\r\n\r\n for (const dataIn of block.dataInputs) {\r\n for (const connection of dataIn._connectedPoint) {\r\n if (!idsAddedToVisitList.has(connection._ownerBlock.uniqueId)) {\r\n visitList.push(connection._ownerBlock);\r\n idsAddedToVisitList.add(connection._ownerBlock.uniqueId);\r\n }\r\n }\r\n }\r\n if (block instanceof FlowGraphExecutionBlock) {\r\n for (const signalOut of block.signalOutputs) {\r\n for (const connection of signalOut._connectedPoint) {\r\n if (!idsAddedToVisitList.has(connection._ownerBlock.uniqueId)) {\r\n visitList.push(connection._ownerBlock);\r\n idsAddedToVisitList.add(connection._ownerBlock.uniqueId);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Serializes a graph\r\n * @param serializationObject the object to write the values in\r\n * @param valueSerializeFunction a function to serialize complex values\r\n */\r\n public serialize(serializationObject: any = {}, valueSerializeFunction?: (key: string, value: any, serializationObject: any) => void) {\r\n serializationObject.variableDefinitions = {};\r\n serializationObject.allBlocks = [];\r\n this.visitAllBlocks((block) => {\r\n const serializedBlock: any = {};\r\n block.serialize(serializedBlock);\r\n serializationObject.allBlocks.push(serializedBlock);\r\n });\r\n serializationObject.executionContexts = [];\r\n for (const context of this._executionContexts) {\r\n const serializedContext: any = {};\r\n context.serialize(serializedContext, valueSerializeFunction);\r\n serializationObject.executionContexts.push(serializedContext);\r\n }\r\n }\r\n\r\n /**\r\n * Given a list of blocks, find an output data connection that has a specific unique id\r\n * @param blocks\r\n * @param uniqueId\r\n * @returns\r\n */\r\n public static GetDataOutConnectionByUniqueId(blocks: FlowGraphBlock[], uniqueId: string): FlowGraphDataConnection<any> {\r\n for (const block of blocks) {\r\n for (const dataOut of block.dataOutputs) {\r\n if (dataOut.uniqueId === uniqueId) {\r\n return dataOut;\r\n }\r\n }\r\n }\r\n throw new Error(\"Could not find data out connection with unique id \" + uniqueId);\r\n }\r\n\r\n /**\r\n * Given a list of blocks, find an input signal connection that has a specific unique id\r\n * @param blocks\r\n * @param uniqueId\r\n * @returns\r\n */\r\n public static GetSignalInConnectionByUniqueId(blocks: FlowGraphBlock[], uniqueId: string): FlowGraphSignalConnection {\r\n for (const block of blocks) {\r\n if (block instanceof FlowGraphExecutionBlock) {\r\n for (const signalIn of block.signalInputs) {\r\n if (signalIn.uniqueId === uniqueId) {\r\n return signalIn;\r\n }\r\n }\r\n }\r\n }\r\n throw new Error(\"Could not find signal in connection with unique id \" + uniqueId);\r\n }\r\n\r\n /**\r\n * Parses a graph from a given serialization object\r\n * @param serializationObject the object where the values are written\r\n * @param coordinator the flow graph coordinator\r\n * @param valueParseFunction a function to parse complex values in a scene\r\n * @returns\r\n */\r\n public static Parse(serializationObject: any, coordinator: FlowGraphCoordinator, valueParseFunction?: (key: string, serializationObject: any, scene: Scene) => any): FlowGraph {\r\n const graph = coordinator.createGraph();\r\n const blocks: FlowGraphBlock[] = [];\r\n // Parse all blocks\r\n for (const serializedBlock of serializationObject.allBlocks) {\r\n const block = FlowGraphBlock.Parse(serializedBlock);\r\n blocks.push(block);\r\n if (block instanceof FlowGraphEventBlock) {\r\n graph.addEventBlock(block);\r\n }\r\n }\r\n // After parsing all blocks, connect them\r\n for (const block of blocks) {\r\n for (const dataIn of block.dataInputs) {\r\n for (const serializedConnection of dataIn.connectedPointIds) {\r\n const connection = FlowGraph.GetDataOutConnectionByUniqueId(blocks, serializedConnection);\r\n dataIn.connectTo(connection);\r\n }\r\n }\r\n if (block instanceof FlowGraphExecutionBlock) {\r\n for (const signalOut of block.signalOutputs) {\r\n for (const serializedConnection of signalOut.connectedPointIds) {\r\n const connection = FlowGraph.GetSignalInConnectionByUniqueId(blocks, serializedConnection);\r\n signalOut.connectTo(connection);\r\n }\r\n }\r\n }\r\n }\r\n for (const serializedContext of serializationObject.executionContexts) {\r\n FlowGraphContext.Parse(serializedContext, graph, valueParseFunction);\r\n }\r\n return graph;\r\n }\r\n}\r\n"]}
|
|
@@ -37,6 +37,7 @@ export declare class FlowGraphBlock {
|
|
|
37
37
|
_updateOutputs(_context: FlowGraphContext): void;
|
|
38
38
|
protected _registerDataInput<T>(name: string, className: RichType<T>): FlowGraphDataConnection<T>;
|
|
39
39
|
protected _registerDataOutput<T>(name: string, className: RichType<T>): FlowGraphDataConnection<T>;
|
|
40
|
+
getDataInput(name: string): FlowGraphDataConnection<any> | undefined;
|
|
40
41
|
serialize(serializationObject?: any): void;
|
|
41
42
|
getClassName(): string;
|
|
42
43
|
static Parse(serializationObject: any): FlowGraphBlock;
|
|
@@ -42,6 +42,9 @@ export class FlowGraphBlock {
|
|
|
42
42
|
this.dataOutputs.push(output);
|
|
43
43
|
return output;
|
|
44
44
|
}
|
|
45
|
+
getDataInput(name) {
|
|
46
|
+
return this.dataInputs.find((i) => i.name === name);
|
|
47
|
+
}
|
|
45
48
|
serialize(serializationObject = {}) {
|
|
46
49
|
serializationObject.uniqueId = this.uniqueId;
|
|
47
50
|
serializationObject.config = this.config;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flowGraphBlock.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraphBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAEhE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,OAAO,EAAE,KAAK,EAAE,yBAAwB;AACxC,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAMpE;;;;;GAKG;AACH,MAAM,OAAO,cAAc;IAkBvB,sEAAsE;IACtE,YAA6B,MAAqC;QAArC,WAAM,GAAN,MAAM,CAA+B;QAlBlE;;WAEG;QACI,aAAQ,GAAG,UAAU,EAAE,CAAC;QAgB3B,IAAI,CAAC,SAAS,EAAE,CAAC;IACrB,CAAC;IAEM,SAAS;;QACZ,0CAA0C;QAC1C,IAAI,CAAC,IAAI,GAAG,MAAA,MAAA,IAAI,CAAC,MAAM,0CAAE,IAAI,mCAAI,IAAI,CAAC,YAAY,EAAE,CAAC;QACrD,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;QACrB,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;IAC1B,CAAC;IAED;;OAEG;IACI,cAAc,CAAC,QAA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AAmB,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;aAC1E;SACJ;QACD,OAAO,GAAG,CAAC;IACf,CAAC;CACJ","sourcesContent":["import { RandomGUID } from \"../Misc/guid\";\r\nimport { FlowGraphConnectionType } from \"./flowGraphConnection\";\r\nimport type { FlowGraphContext } from \"./flowGraphContext\";\r\nimport { FlowGraphDataConnection } from \"./flowGraphDataConnection\";\r\nimport type { RichType } from \"./flowGraphRichTypes\";\r\nimport { Tools } from \"core/Misc/tools\";\r\nimport { FlowGraphExecutionBlock } from \"./flowGraphExecutionBlock\";\r\n\r\nexport interface IFlowGraphBlockConfiguration {\r\n name?: string;\r\n}\r\n\r\n/**\r\n * @experimental\r\n * A block in a flow graph. The most basic form\r\n * of a block has inputs and outputs that contain\r\n * data.\r\n */\r\nexport class FlowGraphBlock {\r\n /**\r\n * A randomly generated GUID for each block.\r\n */\r\n public uniqueId = RandomGUID();\r\n /**\r\n * The name of the block.\r\n */\r\n public name: string;\r\n /**\r\n * The data inputs of the block.\r\n */\r\n public dataInputs: FlowGraphDataConnection<any>[];\r\n /**\r\n * The data outputs of the block.\r\n */\r\n public dataOutputs: FlowGraphDataConnection<any>[];\r\n\r\n /** Constructor is protected so only subclasses can be instantiated */\r\n protected constructor(public config?: IFlowGraphBlockConfiguration) {\r\n this.configure();\r\n }\r\n\r\n public configure() {\r\n // overriden in child classes, uses config\r\n this.name = this.config?.name ?? this.getClassName();\r\n this.dataInputs = [];\r\n this.dataOutputs = [];\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _updateOutputs(_context: FlowGraphContext): void {\r\n // empty by default, overriden in data blocks\r\n }\r\n\r\n protected _registerDataInput<T>(name: string, className: RichType<T>): FlowGraphDataConnection<T> {\r\n const input = new FlowGraphDataConnection(name, FlowGraphConnectionType.Input, this, className);\r\n this.dataInputs.push(input);\r\n return input;\r\n }\r\n\r\n protected _registerDataOutput<T>(name: string, className: RichType<T>): FlowGraphDataConnection<T> {\r\n const output = new FlowGraphDataConnection(name, FlowGraphConnectionType.Output, this, className);\r\n this.dataOutputs.push(output);\r\n return output;\r\n }\r\n\r\n public serialize(serializationObject: any = {}) {\r\n serializationObject.uniqueId = this.uniqueId;\r\n serializationObject.config = this.config;\r\n serializationObject.dataInputs = [];\r\n serializationObject.dataOutputs = [];\r\n serializationObject.className = this.getClassName();\r\n for (const input of this.dataInputs) {\r\n const serializedInput: any = {};\r\n input.serialize(serializedInput);\r\n serializationObject.dataInputs.push(serializedInput);\r\n }\r\n for (const output of this.dataOutputs) {\r\n const serializedOutput: any = {};\r\n output.serialize(serializedOutput);\r\n serializationObject.dataOutputs.push(serializedOutput);\r\n }\r\n }\r\n\r\n public getClassName() {\r\n return \"FGBlock\";\r\n }\r\n\r\n public static Parse(serializationObject: any): FlowGraphBlock {\r\n const classType = Tools.Instantiate(serializationObject.className);\r\n const obj = new classType(serializationObject.config);\r\n obj.uniqueId = serializationObject.uniqueId;\r\n for (let i = 0; i < serializationObject.dataInputs.length; i++) {\r\n obj.dataInputs[i].deserialize(serializationObject.dataInputs[i]);\r\n }\r\n for (let i = 0; i < serializationObject.dataOutputs.length; i++) {\r\n obj.dataOutputs[i].deserialize(serializationObject.dataOutputs[i]);\r\n }\r\n if (obj instanceof FlowGraphExecutionBlock) {\r\n for (let i = 0; i < serializationObject.signalInputs.length; i++) {\r\n obj.signalInputs[i].deserialize(serializationObject.signalInputs[i]);\r\n }\r\n for (let i = 0; i < serializationObject.signalOutputs.length; i++) {\r\n obj.signalOutputs[i].deserialize(serializationObject.signalOutputs[i]);\r\n }\r\n }\r\n return obj;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"flowGraphBlock.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraphBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAEhE,OAAO,EAAE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UAAU,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;SACpE;QACD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,mBAAmB,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC7D,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;SACtE;QACD,IAAI,GAAG,YAAY,uBAAuB,EAAE;YACxC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,mBAAmB,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBAC9D,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;aACxE;YACD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,mBAAmB,CAAC,aAAa,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBAC/D,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;aAC1E;SACJ;QACD,OAAO,GAAG,CAAC;IACf,CAAC;CACJ","sourcesContent":["import { RandomGUID } from \"../Misc/guid\";\r\nimport { FlowGraphConnectionType } from \"./flowGraphConnection\";\r\nimport type { FlowGraphContext } from \"./flowGraphContext\";\r\nimport { FlowGraphDataConnection } from \"./flowGraphDataConnection\";\r\nimport type { RichType } from \"./flowGraphRichTypes\";\r\nimport { Tools } from \"core/Misc/tools\";\r\nimport { FlowGraphExecutionBlock } from \"./flowGraphExecutionBlock\";\r\n\r\nexport interface IFlowGraphBlockConfiguration {\r\n name?: string;\r\n}\r\n\r\n/**\r\n * @experimental\r\n * A block in a flow graph. The most basic form\r\n * of a block has inputs and outputs that contain\r\n * data.\r\n */\r\nexport class FlowGraphBlock {\r\n /**\r\n * A randomly generated GUID for each block.\r\n */\r\n public uniqueId = RandomGUID();\r\n /**\r\n * The name of the block.\r\n */\r\n public name: string;\r\n /**\r\n * The data inputs of the block.\r\n */\r\n public dataInputs: FlowGraphDataConnection<any>[];\r\n /**\r\n * The data outputs of the block.\r\n */\r\n public dataOutputs: FlowGraphDataConnection<any>[];\r\n\r\n /** Constructor is protected so only subclasses can be instantiated */\r\n protected constructor(public config?: IFlowGraphBlockConfiguration) {\r\n this.configure();\r\n }\r\n\r\n public configure() {\r\n // overriden in child classes, uses config\r\n this.name = this.config?.name ?? this.getClassName();\r\n this.dataInputs = [];\r\n this.dataOutputs = [];\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _updateOutputs(_context: FlowGraphContext): void {\r\n // empty by default, overriden in data blocks\r\n }\r\n\r\n protected _registerDataInput<T>(name: string, className: RichType<T>): FlowGraphDataConnection<T> {\r\n const input = new FlowGraphDataConnection(name, FlowGraphConnectionType.Input, this, className);\r\n this.dataInputs.push(input);\r\n return input;\r\n }\r\n\r\n protected _registerDataOutput<T>(name: string, className: RichType<T>): FlowGraphDataConnection<T> {\r\n const output = new FlowGraphDataConnection(name, FlowGraphConnectionType.Output, this, className);\r\n this.dataOutputs.push(output);\r\n return output;\r\n }\r\n\r\n public getDataInput(name: string): FlowGraphDataConnection<any> | undefined {\r\n return this.dataInputs.find((i) => i.name === name);\r\n }\r\n\r\n public serialize(serializationObject: any = {}) {\r\n serializationObject.uniqueId = this.uniqueId;\r\n serializationObject.config = this.config;\r\n serializationObject.dataInputs = [];\r\n serializationObject.dataOutputs = [];\r\n serializationObject.className = this.getClassName();\r\n for (const input of this.dataInputs) {\r\n const serializedInput: any = {};\r\n input.serialize(serializedInput);\r\n serializationObject.dataInputs.push(serializedInput);\r\n }\r\n for (const output of this.dataOutputs) {\r\n const serializedOutput: any = {};\r\n output.serialize(serializedOutput);\r\n serializationObject.dataOutputs.push(serializedOutput);\r\n }\r\n }\r\n\r\n public getClassName() {\r\n return \"FGBlock\";\r\n }\r\n\r\n public static Parse(serializationObject: any): FlowGraphBlock {\r\n const classType = Tools.Instantiate(serializationObject.className);\r\n const obj = new classType(serializationObject.config);\r\n obj.uniqueId = serializationObject.uniqueId;\r\n for (let i = 0; i < serializationObject.dataInputs.length; i++) {\r\n obj.dataInputs[i].deserialize(serializationObject.dataInputs[i]);\r\n }\r\n for (let i = 0; i < serializationObject.dataOutputs.length; i++) {\r\n obj.dataOutputs[i].deserialize(serializationObject.dataOutputs[i]);\r\n }\r\n if (obj instanceof FlowGraphExecutionBlock) {\r\n for (let i = 0; i < serializationObject.signalInputs.length; i++) {\r\n obj.signalInputs[i].deserialize(serializationObject.signalInputs[i]);\r\n }\r\n for (let i = 0; i < serializationObject.signalOutputs.length; i++) {\r\n obj.signalOutputs[i].deserialize(serializationObject.signalOutputs[i]);\r\n }\r\n }\r\n return obj;\r\n }\r\n}\r\n"]}
|
|
@@ -2,8 +2,9 @@ import type { Scene } from "../scene";
|
|
|
2
2
|
import type { FlowGraphAsyncExecutionBlock } from "./flowGraphAsyncExecutionBlock";
|
|
3
3
|
import type { FlowGraphBlock } from "./flowGraphBlock";
|
|
4
4
|
import type { FlowGraphDataConnection } from "./flowGraphDataConnection";
|
|
5
|
-
import type { FlowGraphEventCoordinator } from "./flowGraphEventCoordinator";
|
|
6
5
|
import type { FlowGraph } from "./flowGraph";
|
|
6
|
+
import type { FlowGraphCoordinator } from "./flowGraphCoordinator";
|
|
7
|
+
import { Observable } from "../Misc/observable";
|
|
7
8
|
/**
|
|
8
9
|
* Construction parameters for the context.
|
|
9
10
|
* @experimental
|
|
@@ -16,7 +17,7 @@ export interface IFlowGraphContextConfiguration {
|
|
|
16
17
|
/**
|
|
17
18
|
* The event coordinator used by the flow graph context.
|
|
18
19
|
*/
|
|
19
|
-
readonly
|
|
20
|
+
readonly coordinator: FlowGraphCoordinator;
|
|
20
21
|
}
|
|
21
22
|
/**
|
|
22
23
|
* @experimental
|
|
@@ -55,6 +56,10 @@ export declare class FlowGraphContext {
|
|
|
55
56
|
* Incremented for every block executed.
|
|
56
57
|
*/
|
|
57
58
|
private _executionId;
|
|
59
|
+
/**
|
|
60
|
+
* Observable that is triggered when a node is executed.
|
|
61
|
+
*/
|
|
62
|
+
onNodeExecutedObservable: Observable<FlowGraphBlock>;
|
|
58
63
|
constructor(params: IFlowGraphContextConfiguration);
|
|
59
64
|
/**
|
|
60
65
|
* Check if a user-defined variable is defined.
|
|
@@ -149,11 +154,24 @@ export declare class FlowGraphContext {
|
|
|
149
154
|
* @internal
|
|
150
155
|
*/
|
|
151
156
|
_clearPendingBlocks(): void;
|
|
157
|
+
/**
|
|
158
|
+
* @internal
|
|
159
|
+
* Function that notifies the node executed observable
|
|
160
|
+
* @param node
|
|
161
|
+
*/
|
|
162
|
+
_notifyExecuteNode(node: FlowGraphBlock): void;
|
|
152
163
|
/**
|
|
153
164
|
* @internal
|
|
154
165
|
*/
|
|
155
166
|
_increaseExecutionId(): void;
|
|
167
|
+
/**
|
|
168
|
+
* A monotonically increasing ID for each execution.
|
|
169
|
+
* Incremented for every block executed.
|
|
170
|
+
*/
|
|
156
171
|
get executionId(): number;
|
|
172
|
+
private _getEnclosedSubstring;
|
|
173
|
+
/** @internal */
|
|
174
|
+
_getTargetFromPath(path: string, subString: string, block: FlowGraphBlock): any;
|
|
157
175
|
/**
|
|
158
176
|
* Serializes a context
|
|
159
177
|
* @param serializationObject the object to write the values in
|
|
@@ -1,39 +1,8 @@
|
|
|
1
1
|
import { __decorate } from "../tslib.es6.js";
|
|
2
2
|
import { serialize } from "../Misc/decorators.js";
|
|
3
3
|
import { RandomGUID } from "../Misc/guid.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
className === "AbstractMesh" ||
|
|
7
|
-
className === "GroundMesh" ||
|
|
8
|
-
className === "InstanceMesh" ||
|
|
9
|
-
className === "LinesMesh" ||
|
|
10
|
-
className === "GoldbergMesh" ||
|
|
11
|
-
className === "GreasedLineMesh" ||
|
|
12
|
-
className === "TrailMesh");
|
|
13
|
-
}
|
|
14
|
-
function defaultValueSerializationFunction(key, value, serializationObject) {
|
|
15
|
-
if ((value === null || value === void 0 ? void 0 : value.getClassName) && isMeshClassName(value === null || value === void 0 ? void 0 : value.getClassName())) {
|
|
16
|
-
serializationObject[key] = {
|
|
17
|
-
name: value.name,
|
|
18
|
-
className: value.getClassName(),
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
serializationObject[key] = value;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
function defaultValueParseFunction(key, serializationObject, scene) {
|
|
26
|
-
const value = serializationObject[key];
|
|
27
|
-
let finalValue;
|
|
28
|
-
const className = value === null || value === void 0 ? void 0 : value.className;
|
|
29
|
-
if (isMeshClassName(className)) {
|
|
30
|
-
finalValue = scene.getMeshByName(value.name);
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
finalValue = value;
|
|
34
|
-
}
|
|
35
|
-
return finalValue;
|
|
36
|
-
}
|
|
4
|
+
import { defaultValueParseFunction, defaultValueSerializationFunction } from "./serialization.js";
|
|
5
|
+
import { Observable } from "../Misc/observable.js";
|
|
37
6
|
/**
|
|
38
7
|
* @experimental
|
|
39
8
|
* The context represents the current state and execution of the flow graph.
|
|
@@ -68,6 +37,10 @@ export class FlowGraphContext {
|
|
|
68
37
|
* Incremented for every block executed.
|
|
69
38
|
*/
|
|
70
39
|
this._executionId = 0;
|
|
40
|
+
/**
|
|
41
|
+
* Observable that is triggered when a node is executed.
|
|
42
|
+
*/
|
|
43
|
+
this.onNodeExecutedObservable = new Observable();
|
|
71
44
|
this._configuration = params;
|
|
72
45
|
}
|
|
73
46
|
/**
|
|
@@ -204,15 +177,46 @@ export class FlowGraphContext {
|
|
|
204
177
|
}
|
|
205
178
|
this._pendingBlocks.length = 0;
|
|
206
179
|
}
|
|
180
|
+
/**
|
|
181
|
+
* @internal
|
|
182
|
+
* Function that notifies the node executed observable
|
|
183
|
+
* @param node
|
|
184
|
+
*/
|
|
185
|
+
_notifyExecuteNode(node) {
|
|
186
|
+
this.onNodeExecutedObservable.notifyObservers(node);
|
|
187
|
+
}
|
|
207
188
|
/**
|
|
208
189
|
* @internal
|
|
209
190
|
*/
|
|
210
191
|
_increaseExecutionId() {
|
|
211
192
|
this._executionId++;
|
|
212
193
|
}
|
|
194
|
+
/**
|
|
195
|
+
* A monotonically increasing ID for each execution.
|
|
196
|
+
* Incremented for every block executed.
|
|
197
|
+
*/
|
|
213
198
|
get executionId() {
|
|
214
199
|
return this._executionId;
|
|
215
200
|
}
|
|
201
|
+
_getEnclosedSubstring(subString) {
|
|
202
|
+
return `{${subString}}`;
|
|
203
|
+
}
|
|
204
|
+
/** @internal */
|
|
205
|
+
_getTargetFromPath(path, subString, block) {
|
|
206
|
+
let finalPath = path;
|
|
207
|
+
if (subString && path.indexOf(this._getEnclosedSubstring(subString)) !== -1) {
|
|
208
|
+
const nodeToSub = block.getDataInput(subString);
|
|
209
|
+
if (!nodeToSub) {
|
|
210
|
+
throw new Error(`Invalid substitution input for substitution string ${subString}`);
|
|
211
|
+
}
|
|
212
|
+
const index = Math.floor(nodeToSub.getValue(this));
|
|
213
|
+
if (isNaN(index)) {
|
|
214
|
+
throw new Error(`Invalid substitution value for substitution string ${subString}`);
|
|
215
|
+
}
|
|
216
|
+
finalPath = path.replace(this._getEnclosedSubstring(subString), index.toString());
|
|
217
|
+
}
|
|
218
|
+
return this.getVariable(finalPath);
|
|
219
|
+
}
|
|
216
220
|
/**
|
|
217
221
|
* Serializes a context
|
|
218
222
|
* @param serializationObject the object to write the values in
|