@babylonjs/core 6.36.0 → 6.37.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/Cameras/Inputs/arcRotateCameraGamepadInput.js +4 -0
- package/Cameras/Inputs/arcRotateCameraGamepadInput.js.map +1 -1
- package/Engines/Extensions/engine.dynamicTexture.d.ts +2 -2
- package/Engines/Extensions/engine.dynamicTexture.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.dynamicTexture.js +28 -3
- package/Engines/WebGPU/Extensions/engine.dynamicTexture.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.rawTexture.js +4 -0
- package/Engines/WebGPU/Extensions/engine.rawTexture.js.map +1 -1
- package/Engines/WebGPU/webgpuBufferManager.js +6 -2
- package/Engines/WebGPU/webgpuBufferManager.js.map +1 -1
- package/Engines/WebGPU/webgpuCacheBindGroups.d.ts +1 -0
- package/Engines/WebGPU/webgpuCacheBindGroups.js +12 -0
- package/Engines/WebGPU/webgpuCacheBindGroups.js.map +1 -1
- package/Engines/WebGPU/webgpuCacheRenderPipeline.js +2 -1
- package/Engines/WebGPU/webgpuCacheRenderPipeline.js.map +1 -1
- package/Engines/WebGPU/webgpuCacheRenderPipelineTree.d.ts +2 -2
- package/Engines/WebGPU/webgpuCacheRenderPipelineTree.js +5 -2
- package/Engines/WebGPU/webgpuCacheRenderPipelineTree.js.map +1 -1
- package/Engines/WebGPU/webgpuCacheSampler.js +3 -0
- package/Engines/WebGPU/webgpuCacheSampler.js.map +1 -1
- package/Engines/WebGPU/webgpuClearQuad.js +2 -1
- package/Engines/WebGPU/webgpuClearQuad.js.map +1 -1
- package/Engines/WebGPU/webgpuHardwareTexture.d.ts +1 -1
- package/Engines/WebGPU/webgpuHardwareTexture.js +23 -5
- package/Engines/WebGPU/webgpuHardwareTexture.js.map +1 -1
- package/Engines/WebGPU/webgpuPipelineContext.js +4 -5
- package/Engines/WebGPU/webgpuPipelineContext.js.map +1 -1
- package/Engines/WebGPU/webgpuQuerySet.js +10 -4
- package/Engines/WebGPU/webgpuQuerySet.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureHelper.d.ts +8 -53
- package/Engines/WebGPU/webgpuTextureHelper.js +4 -996
- package/Engines/WebGPU/webgpuTextureHelper.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureManager.d.ts +56 -0
- package/Engines/WebGPU/webgpuTextureManager.js +1012 -0
- package/Engines/WebGPU/webgpuTextureManager.js.map +1 -0
- package/Engines/engine.d.ts +1 -0
- package/Engines/engine.js +9 -2
- package/Engines/engine.js.map +1 -1
- package/Engines/renderTargetWrapper.d.ts +1 -0
- package/Engines/renderTargetWrapper.js +5 -1
- package/Engines/renderTargetWrapper.js.map +1 -1
- package/Engines/thinEngine.d.ts +1 -0
- package/Engines/thinEngine.js +11 -7
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.d.ts +9 -2
- package/Engines/webgpuEngine.js +75 -3
- package/Engines/webgpuEngine.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphGetPropertyBlock.d.ts +23 -6
- package/FlowGraph/Blocks/Data/flowGraphGetPropertyBlock.js +14 -3
- package/FlowGraph/Blocks/Data/flowGraphGetPropertyBlock.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.d.ts +14 -3
- package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.js +12 -11
- package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPauseAnimationBlock.d.ts +1 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPauseAnimationBlock.js +1 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPauseAnimationBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.d.ts +22 -7
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js +15 -9
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.d.ts +1 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.js +1 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphPlayAudioBlock.d.ts +1 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphPlayAudioBlock.js +1 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphPlayAudioBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphStopAudioBlock.d.ts +1 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphStopAudioBlock.js +1 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphStopAudioBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCounterBlock.d.ts +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCounterBlock.js +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCounterBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDebounceBlock.d.ts +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDebounceBlock.js +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDebounceBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock.d.ts +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock.js +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphForLoopBlock.d.ts +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphForLoopBlock.js +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphForLoopBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.d.ts +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.js +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWaitAllBlock.d.ts +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWaitAllBlock.js +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWaitAllBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock.d.ts +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock.js +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphConsoleLogBlock.d.ts +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphConsoleLogBlock.js +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphConsoleLogBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphSendCustomEventBlock.d.ts +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 +13 -5
- package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js +9 -5
- package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.d.ts +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.js +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.js.map +1 -1
- package/FlowGraph/flowGraph.d.ts +24 -6
- package/FlowGraph/flowGraph.js +12 -12
- package/FlowGraph/flowGraph.js.map +1 -1
- package/FlowGraph/flowGraphBlock.d.ts +31 -2
- package/FlowGraph/flowGraphBlock.js +8 -3
- package/FlowGraph/flowGraphBlock.js.map +1 -1
- package/FlowGraph/flowGraphContext.d.ts +5 -1
- package/FlowGraph/flowGraphContext.js +4 -2
- package/FlowGraph/flowGraphContext.js.map +1 -1
- package/FlowGraph/flowGraphCoordinator.d.ts +22 -2
- package/FlowGraph/flowGraphCoordinator.js +7 -11
- package/FlowGraph/flowGraphCoordinator.js.map +1 -1
- package/FlowGraph/{flowGraphWithOnDoneExecutionBlock.js → flowGraphExecutionBlockWithOutSignal.js} +1 -1
- package/FlowGraph/flowGraphExecutionBlockWithOutSignal.js.map +1 -0
- package/FlowGraph/flowGraphPathConverter.d.ts +13 -0
- package/FlowGraph/flowGraphPathConverter.js +31 -0
- package/FlowGraph/flowGraphPathConverter.js.map +1 -0
- package/FlowGraph/flowGraphPathConverterComponent.d.ts +19 -0
- package/FlowGraph/flowGraphPathConverterComponent.js +31 -0
- package/FlowGraph/flowGraphPathConverterComponent.js.map +1 -0
- package/FlowGraph/index.d.ts +0 -1
- package/FlowGraph/index.js +0 -1
- package/FlowGraph/index.js.map +1 -1
- package/FlowGraph/serialization.d.ts +8 -0
- package/FlowGraph/serialization.js +12 -4
- package/FlowGraph/serialization.js.map +1 -1
- package/FlowGraph/typeDefinitions.d.ts +86 -1
- package/FlowGraph/typeDefinitions.js.map +1 -1
- package/Materials/Textures/dynamicTexture.js +2 -1
- package/Materials/Textures/dynamicTexture.js.map +1 -1
- package/Materials/Textures/hardwareTextureWrapper.d.ts +1 -1
- package/Materials/Textures/hardwareTextureWrapper.js.map +1 -1
- package/Materials/Textures/internalTexture.d.ts +6 -2
- package/Materials/Textures/internalTexture.js +6 -4
- package/Materials/Textures/internalTexture.js.map +1 -1
- package/Materials/Textures/renderTargetTexture.js +10 -10
- package/Materials/Textures/renderTargetTexture.js.map +1 -1
- package/Materials/material.d.ts +1 -1
- package/Materials/material.js +3 -1
- package/Materials/material.js.map +1 -1
- package/Materials/shaderMaterial.js +2 -2
- package/Materials/shaderMaterial.js.map +1 -1
- package/Materials/uniformBuffer.d.ts +2 -0
- package/Materials/uniformBuffer.js +16 -0
- package/Materials/uniformBuffer.js.map +1 -1
- package/Meshes/GreasedLine/greasedLineMesh.d.ts +2 -1
- package/Meshes/GreasedLine/greasedLineMesh.js.map +1 -1
- package/Meshes/GreasedLine/greasedLineRibbonMesh.d.ts +2 -1
- package/Meshes/GreasedLine/greasedLineRibbonMesh.js.map +1 -1
- package/Meshes/WebGPU/webgpuDataBuffer.d.ts +1 -0
- package/Meshes/WebGPU/webgpuDataBuffer.js +2 -0
- package/Meshes/WebGPU/webgpuDataBuffer.js.map +1 -1
- package/Meshes/geometry.js +3 -3
- package/Meshes/geometry.js.map +1 -1
- package/Misc/brdfTextureTools.js +9 -7
- package/Misc/brdfTextureTools.js.map +1 -1
- package/Misc/rgbdTextureTools.js +37 -37
- package/Misc/rgbdTextureTools.js.map +1 -1
- package/ObjectModel/index.d.ts +1 -0
- package/ObjectModel/index.js +2 -0
- package/ObjectModel/index.js.map +1 -0
- package/ObjectModel/objectModelInterfaces.d.ts +21 -0
- package/ObjectModel/objectModelInterfaces.js +2 -0
- package/ObjectModel/objectModelInterfaces.js.map +1 -0
- package/Particles/computeShaderParticleSystem.js +2 -2
- package/Particles/computeShaderParticleSystem.js.map +1 -1
- package/Particles/gpuParticleSystem.js +1 -1
- package/Particles/gpuParticleSystem.js.map +1 -1
- package/Particles/particleSystem.js +2 -5
- package/Particles/particleSystem.js.map +1 -1
- package/Rendering/fluidRenderer/fluidRenderer.js +1 -6
- package/Rendering/fluidRenderer/fluidRenderer.js.map +1 -1
- package/Rendering/renderingManager.js +1 -1
- package/Rendering/renderingManager.js.map +1 -1
- package/XR/features/WebXRControllerTeleportation.d.ts +9 -1
- package/XR/features/WebXRControllerTeleportation.js +10 -0
- package/XR/features/WebXRControllerTeleportation.js.map +1 -1
- package/XR/webXRCamera.js.map +1 -1
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/types.d.ts +5 -1
- package/types.js +0 -2
- package/types.js.map +1 -1
- package/FlowGraph/flowGraphPath.d.ts +0 -45
- package/FlowGraph/flowGraphPath.js +0 -156
- package/FlowGraph/flowGraphPath.js.map +0 -1
- package/FlowGraph/flowGraphPathComponent.d.ts +0 -42
- package/FlowGraph/flowGraphPathComponent.js +0 -51
- package/FlowGraph/flowGraphPathComponent.js.map +0 -1
- package/FlowGraph/flowGraphWithOnDoneExecutionBlock.js.map +0 -1
- /package/FlowGraph/{flowGraphWithOnDoneExecutionBlock.d.ts → flowGraphExecutionBlockWithOutSignal.d.ts} +0 -0
|
@@ -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,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAKpE,OAAO,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAC;AACzF,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3C,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;IAgBlB;;;OAGG;IACH,YAAmB,MAAuB;QAnB1C,gBAAgB;QACT,iBAAY,GAA0B,EAAE,CAAC;QAOxC,uBAAkB,GAAuB,EAAE,CAAC;QAEpD;;WAEG;QACH,UAAK,GAAmB,cAAc,CAAC,OAAO,CAAC;QAO3C,I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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\nimport type { ISerializedFlowGraph } from \"./typeDefinitions\";\r\nimport { FlowGraphMeshPickEventBlock } from \"./Blocks/Event/flowGraphMeshPickEventBlock\";\r\nimport { _isADescendantOf } from \"./utils\";\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 public getContext(index: number) {\r\n return this._executionContexts[index];\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 // todo: when adding a mesh pick block, check if the target of the pick is child of a mesh that is already on the list\r\n // if it is, put the child before the parent\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 const contextualOrder = this._getContextualOrder(context);\r\n for (const block of contextualOrder) {\r\n block._startPendingTasks(context);\r\n }\r\n }\r\n }\r\n\r\n private _getContextualOrder(context: FlowGraphContext): FlowGraphEventBlock[] {\r\n const order: FlowGraphEventBlock[] = [];\r\n\r\n for (const block1 of this._eventBlocks) {\r\n // If the block is a mesh pick, guarantee that picks of children meshes come before picks of parent meshes\r\n if (block1.getClassName() === FlowGraphMeshPickEventBlock.ClassName) {\r\n const mesh1 = (block1 as FlowGraphMeshPickEventBlock)._getReferencedMesh(context);\r\n let i = 0;\r\n for (; i < order.length; i++) {\r\n const block2 = order[i];\r\n const mesh2 = (block2 as FlowGraphMeshPickEventBlock)._getReferencedMesh(context);\r\n if (mesh1 && mesh2 && _isADescendantOf(mesh1, mesh2)) {\r\n break;\r\n }\r\n }\r\n order.splice(i, 0, block1);\r\n } else {\r\n order.push(block1);\r\n }\r\n }\r\n return order;\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.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(\r\n serializationObject: ISerializedFlowGraph,\r\n coordinator: FlowGraphCoordinator,\r\n valueParseFunction?: (key: string, serializationObject: any, scene: Scene) => any\r\n ): 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, coordinator.config.scene, valueParseFunction);\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,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAA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,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,EAAE,KAAK,EAAE,kBAAkB,EAAE,CAAC,CAAC;SAC5E;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\nimport type { ISerializedFlowGraph, IObjectAccessor } from \"./typeDefinitions\";\r\nimport { FlowGraphMeshPickEventBlock } from \"./Blocks/Event/flowGraphMeshPickEventBlock\";\r\nimport { _isADescendantOf } from \"./utils\";\r\nimport type { IPathToObjectConverter } from \"../ObjectModel/objectModelInterfaces\";\r\nimport { defaultValueParseFunction } from \"./serialization\";\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 IFlowGraphParams {\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/**\r\n * @experimental\r\n * Options for parsing a flow graph.\r\n */\r\nexport interface IFlowGraphParseOptions {\r\n /**\r\n * A function that parses complex values in a scene.\r\n */\r\n valueParseFunction?: (key: string, serializationObject: any, scene: Scene) => any;\r\n /**\r\n * The flow graph coordinator.\r\n */\r\n coordinator: FlowGraphCoordinator;\r\n /**\r\n * A function that converts a path to an object accessor.\r\n */\r\n pathConverter: IPathToObjectConverter<IObjectAccessor>;\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: IFlowGraphParams) {\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 public getContext(index: number) {\r\n return this._executionContexts[index];\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 const contextualOrder = this._getContextualOrder();\r\n for (const block of contextualOrder) {\r\n block._startPendingTasks(context);\r\n }\r\n }\r\n }\r\n\r\n private _getContextualOrder(): FlowGraphEventBlock[] {\r\n const order: FlowGraphEventBlock[] = [];\r\n\r\n for (const block1 of this._eventBlocks) {\r\n // If the block is a mesh pick, guarantee that picks of children meshes come before picks of parent meshes\r\n if (block1.getClassName() === FlowGraphMeshPickEventBlock.ClassName) {\r\n const mesh1 = (block1 as FlowGraphMeshPickEventBlock)._getReferencedMesh();\r\n let i = 0;\r\n for (; i < order.length; i++) {\r\n const block2 = order[i];\r\n const mesh2 = (block2 as FlowGraphMeshPickEventBlock)._getReferencedMesh();\r\n if (mesh1 && mesh2 && _isADescendantOf(mesh1, mesh2)) {\r\n break;\r\n }\r\n }\r\n order.splice(i, 0, block1);\r\n } else {\r\n order.push(block1);\r\n }\r\n }\r\n return order;\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.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 options options for parsing the graph\r\n * @returns\r\n */\r\n public static Parse(serializationObject: ISerializedFlowGraph, options: IFlowGraphParseOptions): FlowGraph {\r\n const graph = options.coordinator.createGraph();\r\n const blocks: FlowGraphBlock[] = [];\r\n const valueParseFunction = options.valueParseFunction ?? defaultValueParseFunction;\r\n // Parse all blocks\r\n for (const serializedBlock of serializationObject.allBlocks) {\r\n const block = FlowGraphBlock.Parse(serializedBlock, { scene: options.coordinator.config.scene, pathConverter: options.pathConverter, valueParseFunction });\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,9 +1,35 @@
|
|
|
1
1
|
import type { FlowGraphContext } from "./flowGraphContext";
|
|
2
2
|
import { FlowGraphDataConnection } from "./flowGraphDataConnection";
|
|
3
3
|
import type { RichType } from "./flowGraphRichTypes";
|
|
4
|
-
import type { ISerializedFlowGraphBlock } from "./typeDefinitions";
|
|
4
|
+
import type { ISerializedFlowGraphBlock, IObjectAccessor } from "./typeDefinitions";
|
|
5
5
|
import type { Scene } from "../scene";
|
|
6
|
+
import type { IPathToObjectConverter } from "../ObjectModel/objectModelInterfaces";
|
|
7
|
+
/**
|
|
8
|
+
* @experimental
|
|
9
|
+
* Options for parsing a block.
|
|
10
|
+
*/
|
|
11
|
+
export interface IFlowGraphBlockParseOptions {
|
|
12
|
+
/**
|
|
13
|
+
* A function that parses a value from a serialization object.
|
|
14
|
+
*/
|
|
15
|
+
valueParseFunction?: (key: string, serializationObject: any, scene: Scene) => any;
|
|
16
|
+
/**
|
|
17
|
+
* The scene that the block is being parsed in.
|
|
18
|
+
*/
|
|
19
|
+
scene: Scene;
|
|
20
|
+
/**
|
|
21
|
+
* The path converter to use to convert the path to an object accessor.
|
|
22
|
+
*/
|
|
23
|
+
pathConverter: IPathToObjectConverter<IObjectAccessor>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* @experimental
|
|
27
|
+
* Configuration for a block.
|
|
28
|
+
*/
|
|
6
29
|
export interface IFlowGraphBlockConfiguration {
|
|
30
|
+
/**
|
|
31
|
+
* The name of the block.
|
|
32
|
+
*/
|
|
7
33
|
name?: string;
|
|
8
34
|
[extraPropertyKey: string]: any;
|
|
9
35
|
}
|
|
@@ -31,6 +57,9 @@ export declare class FlowGraphBlock {
|
|
|
31
57
|
* The data outputs of the block.
|
|
32
58
|
*/
|
|
33
59
|
dataOutputs: FlowGraphDataConnection<any>[];
|
|
60
|
+
/**
|
|
61
|
+
* Metadata that can be used by the block.
|
|
62
|
+
*/
|
|
34
63
|
metadata: any;
|
|
35
64
|
/** Constructor is protected so only subclasses can be instantiated */
|
|
36
65
|
protected constructor(config?: IFlowGraphBlockConfiguration | undefined);
|
|
@@ -45,5 +74,5 @@ export declare class FlowGraphBlock {
|
|
|
45
74
|
getDataOutput(name: string): FlowGraphDataConnection<any> | undefined;
|
|
46
75
|
serialize(serializationObject?: any, _valueSerializeFunction?: (key: string, value: any, serializationObject: any) => any): void;
|
|
47
76
|
getClassName(): string;
|
|
48
|
-
static Parse(serializationObject: ISerializedFlowGraphBlock,
|
|
77
|
+
static Parse(serializationObject: ISerializedFlowGraphBlock, parseOptions: IFlowGraphBlockParseOptions): FlowGraphBlock;
|
|
49
78
|
}
|
|
@@ -2,7 +2,7 @@ import { RandomGUID } from "../Misc/guid.js";
|
|
|
2
2
|
import { FlowGraphConnectionType } from "./flowGraphConnection.js";
|
|
3
3
|
import { FlowGraphDataConnection } from "./flowGraphDataConnection.js";
|
|
4
4
|
import { Tools } from "../Misc/tools.js";
|
|
5
|
-
import { defaultValueParseFunction, defaultValueSerializationFunction } from "./serialization.js";
|
|
5
|
+
import { defaultValueParseFunction, defaultValueSerializationFunction, needsPathConverter } from "./serialization.js";
|
|
6
6
|
/**
|
|
7
7
|
* @experimental
|
|
8
8
|
* A block in a flow graph. The most basic form
|
|
@@ -71,14 +71,19 @@ export class FlowGraphBlock {
|
|
|
71
71
|
getClassName() {
|
|
72
72
|
return "FGBlock";
|
|
73
73
|
}
|
|
74
|
-
static Parse(serializationObject,
|
|
74
|
+
static Parse(serializationObject, parseOptions) {
|
|
75
|
+
var _a;
|
|
75
76
|
const classType = Tools.Instantiate(serializationObject.className);
|
|
76
77
|
const parsedConfig = {};
|
|
78
|
+
const valueParseFunction = (_a = parseOptions.valueParseFunction) !== null && _a !== void 0 ? _a : defaultValueParseFunction;
|
|
77
79
|
if (serializationObject.config) {
|
|
78
80
|
for (const key in serializationObject.config) {
|
|
79
|
-
parsedConfig[key] = valueParseFunction(key, serializationObject.config, scene);
|
|
81
|
+
parsedConfig[key] = valueParseFunction(key, serializationObject.config, parseOptions.scene);
|
|
80
82
|
}
|
|
81
83
|
}
|
|
84
|
+
if (needsPathConverter(serializationObject.className)) {
|
|
85
|
+
parsedConfig.pathConverter = parseOptions.pathConverter;
|
|
86
|
+
}
|
|
82
87
|
const obj = new classType(parsedConfig);
|
|
83
88
|
obj.uniqueId = serializationObject.uniqueId;
|
|
84
89
|
for (let i = 0; i < serializationObject.dataInputs.length; i++) {
|
|
@@ -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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AC;aAC9D;iBAAM;gBACH,MAAM,IAAI,KAAK,CAAC,uCAAuC,GAAG,mBAAmB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,YAAY,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAC;aACrJ;SACJ;QACD,GAAG,CAAC,QAAQ,GAAG,mBAAmB,CAAC,QAAQ,CAAC;QAC5C,GAAG,CAAC,WAAW,IAAI,GAAG,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC;QACxD,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 type { ISerializedFlowGraphBlock } from \"./typeDefinitions\";\r\nimport { defaultValueParseFunction, defaultValueSerializationFunction } from \"./serialization\";\r\nimport type { Scene } from \"../scene\";\r\n\r\nexport interface IFlowGraphBlockConfiguration {\r\n name?: string;\r\n [extraPropertyKey: string]: any;\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 public metadata: 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 public 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 public 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 getDataOutput(name: string): FlowGraphDataConnection<any> | undefined {\r\n return this.dataOutputs.find((i) => i.name === name);\r\n }\r\n\r\n public serialize(serializationObject: any = {}, _valueSerializeFunction: (key: string, value: any, serializationObject: any) => any = defaultValueSerializationFunction) {\r\n serializationObject.uniqueId = this.uniqueId;\r\n serializationObject.config = {};\r\n if (this.config) {\r\n serializationObject.config[\"name\"] = this.config.name;\r\n }\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(\r\n serializationObject: ISerializedFlowGraphBlock,\r\n scene: Scene,\r\n valueParseFunction: (key: string, serializationObject: any, scene: Scene) => any = defaultValueParseFunction\r\n ): FlowGraphBlock {\r\n const classType = Tools.Instantiate(serializationObject.className);\r\n const parsedConfig: any = {};\r\n if (serializationObject.config) {\r\n for (const key in serializationObject.config) {\r\n parsedConfig[key] = valueParseFunction(key, serializationObject.config, scene);\r\n }\r\n }\r\n const obj = new classType(parsedConfig);\r\n obj.uniqueId = serializationObject.uniqueId;\r\n for (let i = 0; i < serializationObject.dataInputs.length; i++) {\r\n const dataInput = obj.getDataInput(serializationObject.dataInputs[i].name);\r\n if (dataInput) {\r\n dataInput.deserialize(serializationObject.dataInputs[i]);\r\n } else {\r\n throw new Error(\"Could not find data input with name \" + serializationObject.dataInputs[i].name + \" in block \" + serializationObject.className);\r\n }\r\n }\r\n for (let i = 0; i < serializationObject.dataOutputs.length; i++) {\r\n const dataOutput = obj.getDataOutput(serializationObject.dataOutputs[i].name);\r\n if (dataOutput) {\r\n dataOutput.deserialize(serializationObject.dataOutputs[i]);\r\n } else {\r\n throw new Error(\"Could not find data output with name \" + serializationObject.dataOutputs[i].name + \" in block \" + serializationObject.className);\r\n }\r\n }\r\n obj.metadata = serializationObject.metadata;\r\n obj.deserialize && obj.deserialize(serializationObject);\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,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAE,yBAAyB,EAAE,iCAAiC,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAmCnH;;;;;GAKG;AACH,MAAM,OAAO,cAAc;IAuBvB,sEAAsE;IACtE,YAA6B,MAAqC;QAArC,WAAM,GAAN,MAAM,CAA+B;QAvBlE;;WAEG;QACI,aA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KAAK,CAAC,uCAAuC,GAAG,mBAAmB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,YAAY,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAC;aACrJ;SACJ;QACD,GAAG,CAAC,QAAQ,GAAG,mBAAmB,CAAC,QAAQ,CAAC;QAC5C,GAAG,CAAC,WAAW,IAAI,GAAG,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC;QACxD,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 \"../Misc/tools\";\r\nimport type { ISerializedFlowGraphBlock, IObjectAccessor } from \"./typeDefinitions\";\r\nimport { defaultValueParseFunction, defaultValueSerializationFunction, needsPathConverter } from \"./serialization\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { IPathToObjectConverter } from \"../ObjectModel/objectModelInterfaces\";\r\n\r\n/**\r\n * @experimental\r\n * Options for parsing a block.\r\n */\r\nexport interface IFlowGraphBlockParseOptions {\r\n /**\r\n * A function that parses a value from a serialization object.\r\n */\r\n valueParseFunction?: (key: string, serializationObject: any, scene: Scene) => any;\r\n /**\r\n * The scene that the block is being parsed in.\r\n */\r\n scene: Scene;\r\n /**\r\n * The path converter to use to convert the path to an object accessor.\r\n */\r\n pathConverter: IPathToObjectConverter<IObjectAccessor>;\r\n}\r\n\r\n/**\r\n * @experimental\r\n * Configuration for a block.\r\n */\r\nexport interface IFlowGraphBlockConfiguration {\r\n /**\r\n * The name of the block.\r\n */\r\n name?: string;\r\n [extraPropertyKey: string]: any;\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 /**\r\n * Metadata that can be used by the block.\r\n */\r\n public metadata: 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 public 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 public 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 getDataOutput(name: string): FlowGraphDataConnection<any> | undefined {\r\n return this.dataOutputs.find((i) => i.name === name);\r\n }\r\n\r\n public serialize(serializationObject: any = {}, _valueSerializeFunction: (key: string, value: any, serializationObject: any) => any = defaultValueSerializationFunction) {\r\n serializationObject.uniqueId = this.uniqueId;\r\n serializationObject.config = {};\r\n if (this.config) {\r\n serializationObject.config[\"name\"] = this.config.name;\r\n }\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: ISerializedFlowGraphBlock, parseOptions: IFlowGraphBlockParseOptions): FlowGraphBlock {\r\n const classType = Tools.Instantiate(serializationObject.className);\r\n const parsedConfig: any = {};\r\n const valueParseFunction = parseOptions.valueParseFunction ?? defaultValueParseFunction;\r\n if (serializationObject.config) {\r\n for (const key in serializationObject.config) {\r\n parsedConfig[key] = valueParseFunction(key, serializationObject.config, parseOptions.scene);\r\n }\r\n }\r\n if (needsPathConverter(serializationObject.className)) {\r\n parsedConfig.pathConverter = parseOptions.pathConverter;\r\n }\r\n const obj = new classType(parsedConfig);\r\n obj.uniqueId = serializationObject.uniqueId;\r\n for (let i = 0; i < serializationObject.dataInputs.length; i++) {\r\n const dataInput = obj.getDataInput(serializationObject.dataInputs[i].name);\r\n if (dataInput) {\r\n dataInput.deserialize(serializationObject.dataInputs[i]);\r\n } else {\r\n throw new Error(\"Could not find data input with name \" + serializationObject.dataInputs[i].name + \" in block \" + serializationObject.className);\r\n }\r\n }\r\n for (let i = 0; i < serializationObject.dataOutputs.length; i++) {\r\n const dataOutput = obj.getDataOutput(serializationObject.dataOutputs[i].name);\r\n if (dataOutput) {\r\n dataOutput.deserialize(serializationObject.dataOutputs[i]);\r\n } else {\r\n throw new Error(\"Could not find data output with name \" + serializationObject.dataOutputs[i].name + \" in block \" + serializationObject.className);\r\n }\r\n }\r\n obj.metadata = serializationObject.metadata;\r\n obj.deserialize && obj.deserialize(serializationObject);\r\n return obj;\r\n }\r\n}\r\n"]}
|
|
@@ -20,6 +20,10 @@ export interface IFlowGraphContextConfiguration {
|
|
|
20
20
|
*/
|
|
21
21
|
readonly coordinator: FlowGraphCoordinator;
|
|
22
22
|
}
|
|
23
|
+
export interface IFlowGraphContextParseOptions {
|
|
24
|
+
readonly valueParseFunction?: (key: string, serializationObject: any, scene: Scene) => any;
|
|
25
|
+
readonly graph: FlowGraph;
|
|
26
|
+
}
|
|
23
27
|
/**
|
|
24
28
|
* @experimental
|
|
25
29
|
* The context represents the current state and execution of the flow graph.
|
|
@@ -190,5 +194,5 @@ export declare class FlowGraphContext {
|
|
|
190
194
|
* @param valueParseFunction a function to parse complex values
|
|
191
195
|
* @returns
|
|
192
196
|
*/
|
|
193
|
-
static Parse(serializationObject: ISerializedFlowGraphContext,
|
|
197
|
+
static Parse(serializationObject: ISerializedFlowGraphContext, options: IFlowGraphContextParseOptions): FlowGraphContext;
|
|
194
198
|
}
|
|
@@ -230,8 +230,10 @@ export class FlowGraphContext {
|
|
|
230
230
|
* @param valueParseFunction a function to parse complex values
|
|
231
231
|
* @returns
|
|
232
232
|
*/
|
|
233
|
-
static Parse(serializationObject,
|
|
234
|
-
|
|
233
|
+
static Parse(serializationObject, options) {
|
|
234
|
+
var _a;
|
|
235
|
+
const result = options.graph.createContext();
|
|
236
|
+
const valueParseFunction = (_a = options.valueParseFunction) !== null && _a !== void 0 ? _a : defaultValueParseFunction;
|
|
235
237
|
result.uniqueId = serializationObject.uniqueId;
|
|
236
238
|
for (const key in serializationObject._userVariables) {
|
|
237
239
|
const value = valueParseFunction(key, serializationObject._userVariables, result._configuration.scene);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flowGraphContext.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraphContext.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAO1C,OAAO,EAAE,yBAAyB,EAAE,iCAAiC,EAAE,MAAM,iBA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iB,CAAC,CAAC;SACvG;IACL,CAAC;IAEM,YAAY;QACf,OAAO,WAAW,CAAC;IACvB,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,KAAK,CACf,mBAAgD,EAChD,KAAgB,EAChB,qBAAmF,yBAAyB;QAE5G,MAAM,MAAM,GAAG,KAAK,CAAC,aAAa,EAAE,CAAC;QACrC,MAAM,CAAC,QAAQ,GAAG,mBAAmB,CAAC,QAAQ,CAAC;QAC/C,KAAK,MAAM,GAAG,IAAI,mBAAmB,CAAC,cAAc,EAAE;YAClD,MAAM,KAAK,GAAG,kBAAkB,CAAC,GAAG,EAAE,mBAAmB,CAAC,cAAc,EAAE,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;YACvG,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;SACtC;QACD,KAAK,MAAM,GAAG,IAAI,mBAAmB,CAAC,iBAAiB,EAAE;YACrD,MAAM,KAAK,GAAG,kBAAkB,CAAC,GAAG,EAAE,mBAAmB,CAAC,iBAAiB,EAAE,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;YAC1G,MAAM,CAAC,iBAAiB,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;SACzC;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AAnQU;IADN,SAAS,EAAE;kDACmB","sourcesContent":["import { serialize } from \"../Misc/decorators\";\r\nimport { RandomGUID } from \"../Misc/guid\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { FlowGraphAsyncExecutionBlock } from \"./flowGraphAsyncExecutionBlock\";\r\nimport type { FlowGraphBlock } from \"./flowGraphBlock\";\r\nimport type { FlowGraphDataConnection } from \"./flowGraphDataConnection\";\r\nimport type { FlowGraph } from \"./flowGraph\";\r\nimport type { ISerializedFlowGraphContext } from \"./typeDefinitions\";\r\nimport { defaultValueParseFunction, defaultValueSerializationFunction } from \"./serialization\";\r\nimport type { FlowGraphCoordinator } from \"./flowGraphCoordinator\";\r\nimport { Observable } from \"../Misc/observable\";\r\n\r\n/**\r\n * Construction parameters for the context.\r\n * @experimental\r\n */\r\nexport interface IFlowGraphContextConfiguration {\r\n /**\r\n * The scene that the flow graph context belongs to.\r\n */\r\n readonly scene: Scene;\r\n /**\r\n * The event coordinator used by the flow graph context.\r\n */\r\n readonly coordinator: FlowGraphCoordinator;\r\n}\r\n/**\r\n * @experimental\r\n * The context represents the current state and execution of the flow graph.\r\n * It contains both user-defined variables, which are derived from\r\n * a more general variable definition, and execution variables that\r\n * are set by the blocks.\r\n */\r\nexport class FlowGraphContext {\r\n /**\r\n * A randomly generated GUID for each context.\r\n */\r\n @serialize()\r\n public uniqueId = RandomGUID();\r\n /**\r\n * These are the variables defined by a user.\r\n */\r\n private _userVariables: { [key: string]: any } = {};\r\n /**\r\n * These are the variables set by the blocks.\r\n */\r\n private _executionVariables: { [key: string]: any } = {};\r\n /**\r\n * These are the values for the data connection points\r\n */\r\n private _connectionValues: { [key: string]: any } = {};\r\n /**\r\n * These are the variables set by the graph.\r\n */\r\n private readonly _configuration: IFlowGraphContextConfiguration;\r\n /**\r\n * These are blocks that have currently pending tasks/listeners that need to be cleaned up.\r\n */\r\n private _pendingBlocks: FlowGraphAsyncExecutionBlock[] = [];\r\n /**\r\n * A monotonically increasing ID for each execution.\r\n * Incremented for every block executed.\r\n */\r\n private _executionId = 0;\r\n /**\r\n * Observable that is triggered when a node is executed.\r\n */\r\n public onNodeExecutedObservable: Observable<FlowGraphBlock> = new Observable<FlowGraphBlock>();\r\n\r\n constructor(params: IFlowGraphContextConfiguration) {\r\n this._configuration = params;\r\n }\r\n\r\n /**\r\n * Check if a user-defined variable is defined.\r\n * @param name\r\n * @returns\r\n */\r\n public hasVariable(name: string) {\r\n return name in this._userVariables;\r\n }\r\n\r\n /**\r\n * Set a user-defined variable.\r\n * @param name\r\n * @param value\r\n */\r\n public setVariable(name: string, value: any) {\r\n this._userVariables[name] = value;\r\n }\r\n\r\n /**\r\n * Get a user-defined variable.\r\n * @param name\r\n * @returns\r\n */\r\n public getVariable(name: string): any {\r\n return this._userVariables[name];\r\n }\r\n\r\n /**\r\n * Gets all user variables map\r\n */\r\n public get userVariables() {\r\n return this._userVariables;\r\n }\r\n\r\n private _getUniqueIdPrefixedName(obj: FlowGraphBlock, name: string): string {\r\n return `${obj.uniqueId}_${name}`;\r\n }\r\n\r\n /**\r\n * Set an internal execution variable\r\n * @internal\r\n * @param name\r\n * @param value\r\n */\r\n public _setExecutionVariable(block: FlowGraphBlock, name: string, value: any) {\r\n this._executionVariables[this._getUniqueIdPrefixedName(block, name)] = value;\r\n }\r\n\r\n /**\r\n * Get an internal execution variable\r\n * @internal\r\n * @param name\r\n * @returns\r\n */\r\n public _getExecutionVariable(block: FlowGraphBlock, name: string, defaultValue?: any): any {\r\n if (this._hasExecutionVariable(block, name)) {\r\n return this._executionVariables[this._getUniqueIdPrefixedName(block, name)];\r\n } else {\r\n return defaultValue;\r\n }\r\n }\r\n\r\n /**\r\n * Delete an internal execution variable\r\n * @internal\r\n * @param block\r\n * @param name\r\n */\r\n public _deleteExecutionVariable(block: FlowGraphBlock, name: string) {\r\n delete this._executionVariables[this._getUniqueIdPrefixedName(block, name)];\r\n }\r\n\r\n /**\r\n * Check if an internal execution variable is defined\r\n * @internal\r\n * @param block\r\n * @param name\r\n * @returns\r\n */\r\n public _hasExecutionVariable(block: FlowGraphBlock, name: string) {\r\n return this._getUniqueIdPrefixedName(block, name) in this._executionVariables;\r\n }\r\n\r\n /**\r\n * Check if a connection value is defined\r\n * @internal\r\n * @param connectionPoint\r\n * @returns\r\n */\r\n public _hasConnectionValue(connectionPoint: FlowGraphDataConnection<any>) {\r\n return connectionPoint.uniqueId in this._connectionValues;\r\n }\r\n\r\n /**\r\n * Set a connection value\r\n * @internal\r\n * @param connectionPoint\r\n * @param value\r\n */\r\n public _setConnectionValue<T>(connectionPoint: FlowGraphDataConnection<T>, value: T) {\r\n this._connectionValues[connectionPoint.uniqueId] = value;\r\n }\r\n\r\n /**\r\n * Get a connection value\r\n * @internal\r\n * @param connectionPoint\r\n * @returns\r\n */\r\n public _getConnectionValue<T>(connectionPoint: FlowGraphDataConnection<T>): T {\r\n return this._connectionValues[connectionPoint.uniqueId];\r\n }\r\n\r\n /**\r\n * Get the configuration\r\n * @internal\r\n * @param name\r\n * @param value\r\n */\r\n public get configuration() {\r\n return this._configuration;\r\n }\r\n\r\n /**\r\n * Add a block to the list of blocks that have pending tasks.\r\n * @internal\r\n * @param block\r\n */\r\n public _addPendingBlock(block: FlowGraphAsyncExecutionBlock) {\r\n this._pendingBlocks.push(block);\r\n }\r\n\r\n /**\r\n * Remove a block from the list of blocks that have pending tasks.\r\n * @internal\r\n * @param block\r\n */\r\n public _removePendingBlock(block: FlowGraphAsyncExecutionBlock) {\r\n const index = this._pendingBlocks.indexOf(block);\r\n if (index !== -1) {\r\n this._pendingBlocks.splice(index, 1);\r\n }\r\n }\r\n\r\n /**\r\n * Clear all pending blocks.\r\n * @internal\r\n */\r\n public _clearPendingBlocks() {\r\n for (const block of this._pendingBlocks) {\r\n block._cancelPendingTasks(this);\r\n }\r\n this._pendingBlocks.length = 0;\r\n }\r\n\r\n /**\r\n * @internal\r\n * Function that notifies the node executed observable\r\n * @param node\r\n */\r\n public _notifyExecuteNode(node: FlowGraphBlock) {\r\n this.onNodeExecutedObservable.notifyObservers(node);\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _increaseExecutionId() {\r\n this._executionId++;\r\n }\r\n /**\r\n * A monotonically increasing ID for each execution.\r\n * Incremented for every block executed.\r\n */\r\n public get executionId() {\r\n return this._executionId;\r\n }\r\n\r\n /**\r\n * Serializes a context\r\n * @param serializationObject the object to write the values in\r\n * @param valueSerializationFunction a function to serialize complex values\r\n */\r\n public serialize(serializationObject: any = {}, valueSerializationFunction: (key: string, value: any, serializationObject: any) => void = defaultValueSerializationFunction) {\r\n serializationObject.uniqueId = this.uniqueId;\r\n serializationObject._userVariables = {};\r\n for (const key in this._userVariables) {\r\n valueSerializationFunction(key, this._userVariables[key], serializationObject._userVariables);\r\n }\r\n serializationObject._connectionValues = {};\r\n for (const key in this._connectionValues) {\r\n valueSerializationFunction(key, this._connectionValues[key], serializationObject._connectionValues);\r\n }\r\n }\r\n\r\n public getClassName() {\r\n return \"FGContext\";\r\n }\r\n\r\n /**\r\n * Parses a context\r\n * @param serializationObject the object containing the context serialization values\r\n * @param graph the graph to which the context should belong\r\n * @param valueParseFunction a function to parse complex values\r\n * @returns\r\n */\r\n public static Parse(\r\n serializationObject: ISerializedFlowGraphContext,\r\n graph: FlowGraph,\r\n valueParseFunction: (key: string, serializationObject: any, scene: Scene) => any = defaultValueParseFunction\r\n ): FlowGraphContext {\r\n const result = graph.createContext();\r\n result.uniqueId = serializationObject.uniqueId;\r\n for (const key in serializationObject._userVariables) {\r\n const value = valueParseFunction(key, serializationObject._userVariables, result._configuration.scene);\r\n result._userVariables[key] = value;\r\n }\r\n for (const key in serializationObject._connectionValues) {\r\n const value = valueParseFunction(key, serializationObject._connectionValues, result._configuration.scene);\r\n result._connectionValues[key] = value;\r\n }\r\n\r\n return result;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"flowGraphContext.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraphContext.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAO1C,OAAO,EAAE,yBAAyB,EAAE,iCAAiC,EAAE,MAAM,iBAAiB,CAAC;AAE/F,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAqBhD;;;;;;GAMG;AACH,MAAM,OAAO,gBAAgB;IAoCzB,YAAY,MAAsC;QAnClD;;WAEG;QAEI,aAAQ,GAAG,UAAU,EAAE,CAAC;QAC/B;;WAEG;QACK,mBAAc,GAA2B,EAAE,CAAC;QACpD;;WAEG;QACK,wBAAmB,GA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AC,kBAAkB,mCAAI,yBAAyB,CAAC;QACnF,MAAM,CAAC,QAAQ,GAAG,mBAAmB,CAAC,QAAQ,CAAC;QAC/C,KAAK,MAAM,GAAG,IAAI,mBAAmB,CAAC,cAAc,EAAE;YAClD,MAAM,KAAK,GAAG,kBAAkB,CAAC,GAAG,EAAE,mBAAmB,CAAC,cAAc,EAAE,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;YACvG,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;SACtC;QACD,KAAK,MAAM,GAAG,IAAI,mBAAmB,CAAC,iBAAiB,EAAE;YACrD,MAAM,KAAK,GAAG,kBAAkB,CAAC,GAAG,EAAE,mBAAmB,CAAC,iBAAiB,EAAE,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;YAC1G,MAAM,CAAC,iBAAiB,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;SACzC;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AAhQU;IADN,SAAS,EAAE;kDACmB","sourcesContent":["import { serialize } from \"../Misc/decorators\";\r\nimport { RandomGUID } from \"../Misc/guid\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { FlowGraphAsyncExecutionBlock } from \"./flowGraphAsyncExecutionBlock\";\r\nimport type { FlowGraphBlock } from \"./flowGraphBlock\";\r\nimport type { FlowGraphDataConnection } from \"./flowGraphDataConnection\";\r\nimport type { FlowGraph } from \"./flowGraph\";\r\nimport type { ISerializedFlowGraphContext } from \"./typeDefinitions\";\r\nimport { defaultValueParseFunction, defaultValueSerializationFunction } from \"./serialization\";\r\nimport type { FlowGraphCoordinator } from \"./flowGraphCoordinator\";\r\nimport { Observable } from \"../Misc/observable\";\r\n\r\n/**\r\n * Construction parameters for the context.\r\n * @experimental\r\n */\r\nexport interface IFlowGraphContextConfiguration {\r\n /**\r\n * The scene that the flow graph context belongs to.\r\n */\r\n readonly scene: Scene;\r\n /**\r\n * The event coordinator used by the flow graph context.\r\n */\r\n readonly coordinator: FlowGraphCoordinator;\r\n}\r\n\r\nexport interface IFlowGraphContextParseOptions {\r\n readonly valueParseFunction?: (key: string, serializationObject: any, scene: Scene) => any;\r\n readonly graph: FlowGraph;\r\n}\r\n/**\r\n * @experimental\r\n * The context represents the current state and execution of the flow graph.\r\n * It contains both user-defined variables, which are derived from\r\n * a more general variable definition, and execution variables that\r\n * are set by the blocks.\r\n */\r\nexport class FlowGraphContext {\r\n /**\r\n * A randomly generated GUID for each context.\r\n */\r\n @serialize()\r\n public uniqueId = RandomGUID();\r\n /**\r\n * These are the variables defined by a user.\r\n */\r\n private _userVariables: { [key: string]: any } = {};\r\n /**\r\n * These are the variables set by the blocks.\r\n */\r\n private _executionVariables: { [key: string]: any } = {};\r\n /**\r\n * These are the values for the data connection points\r\n */\r\n private _connectionValues: { [key: string]: any } = {};\r\n /**\r\n * These are the variables set by the graph.\r\n */\r\n private readonly _configuration: IFlowGraphContextConfiguration;\r\n /**\r\n * These are blocks that have currently pending tasks/listeners that need to be cleaned up.\r\n */\r\n private _pendingBlocks: FlowGraphAsyncExecutionBlock[] = [];\r\n /**\r\n * A monotonically increasing ID for each execution.\r\n * Incremented for every block executed.\r\n */\r\n private _executionId = 0;\r\n /**\r\n * Observable that is triggered when a node is executed.\r\n */\r\n public onNodeExecutedObservable: Observable<FlowGraphBlock> = new Observable<FlowGraphBlock>();\r\n\r\n constructor(params: IFlowGraphContextConfiguration) {\r\n this._configuration = params;\r\n }\r\n\r\n /**\r\n * Check if a user-defined variable is defined.\r\n * @param name\r\n * @returns\r\n */\r\n public hasVariable(name: string) {\r\n return name in this._userVariables;\r\n }\r\n\r\n /**\r\n * Set a user-defined variable.\r\n * @param name\r\n * @param value\r\n */\r\n public setVariable(name: string, value: any) {\r\n this._userVariables[name] = value;\r\n }\r\n\r\n /**\r\n * Get a user-defined variable.\r\n * @param name\r\n * @returns\r\n */\r\n public getVariable(name: string): any {\r\n return this._userVariables[name];\r\n }\r\n\r\n /**\r\n * Gets all user variables map\r\n */\r\n public get userVariables() {\r\n return this._userVariables;\r\n }\r\n\r\n private _getUniqueIdPrefixedName(obj: FlowGraphBlock, name: string): string {\r\n return `${obj.uniqueId}_${name}`;\r\n }\r\n\r\n /**\r\n * Set an internal execution variable\r\n * @internal\r\n * @param name\r\n * @param value\r\n */\r\n public _setExecutionVariable(block: FlowGraphBlock, name: string, value: any) {\r\n this._executionVariables[this._getUniqueIdPrefixedName(block, name)] = value;\r\n }\r\n\r\n /**\r\n * Get an internal execution variable\r\n * @internal\r\n * @param name\r\n * @returns\r\n */\r\n public _getExecutionVariable(block: FlowGraphBlock, name: string, defaultValue?: any): any {\r\n if (this._hasExecutionVariable(block, name)) {\r\n return this._executionVariables[this._getUniqueIdPrefixedName(block, name)];\r\n } else {\r\n return defaultValue;\r\n }\r\n }\r\n\r\n /**\r\n * Delete an internal execution variable\r\n * @internal\r\n * @param block\r\n * @param name\r\n */\r\n public _deleteExecutionVariable(block: FlowGraphBlock, name: string) {\r\n delete this._executionVariables[this._getUniqueIdPrefixedName(block, name)];\r\n }\r\n\r\n /**\r\n * Check if an internal execution variable is defined\r\n * @internal\r\n * @param block\r\n * @param name\r\n * @returns\r\n */\r\n public _hasExecutionVariable(block: FlowGraphBlock, name: string) {\r\n return this._getUniqueIdPrefixedName(block, name) in this._executionVariables;\r\n }\r\n\r\n /**\r\n * Check if a connection value is defined\r\n * @internal\r\n * @param connectionPoint\r\n * @returns\r\n */\r\n public _hasConnectionValue(connectionPoint: FlowGraphDataConnection<any>) {\r\n return connectionPoint.uniqueId in this._connectionValues;\r\n }\r\n\r\n /**\r\n * Set a connection value\r\n * @internal\r\n * @param connectionPoint\r\n * @param value\r\n */\r\n public _setConnectionValue<T>(connectionPoint: FlowGraphDataConnection<T>, value: T) {\r\n this._connectionValues[connectionPoint.uniqueId] = value;\r\n }\r\n\r\n /**\r\n * Get a connection value\r\n * @internal\r\n * @param connectionPoint\r\n * @returns\r\n */\r\n public _getConnectionValue<T>(connectionPoint: FlowGraphDataConnection<T>): T {\r\n return this._connectionValues[connectionPoint.uniqueId];\r\n }\r\n\r\n /**\r\n * Get the configuration\r\n * @internal\r\n * @param name\r\n * @param value\r\n */\r\n public get configuration() {\r\n return this._configuration;\r\n }\r\n\r\n /**\r\n * Add a block to the list of blocks that have pending tasks.\r\n * @internal\r\n * @param block\r\n */\r\n public _addPendingBlock(block: FlowGraphAsyncExecutionBlock) {\r\n this._pendingBlocks.push(block);\r\n }\r\n\r\n /**\r\n * Remove a block from the list of blocks that have pending tasks.\r\n * @internal\r\n * @param block\r\n */\r\n public _removePendingBlock(block: FlowGraphAsyncExecutionBlock) {\r\n const index = this._pendingBlocks.indexOf(block);\r\n if (index !== -1) {\r\n this._pendingBlocks.splice(index, 1);\r\n }\r\n }\r\n\r\n /**\r\n * Clear all pending blocks.\r\n * @internal\r\n */\r\n public _clearPendingBlocks() {\r\n for (const block of this._pendingBlocks) {\r\n block._cancelPendingTasks(this);\r\n }\r\n this._pendingBlocks.length = 0;\r\n }\r\n\r\n /**\r\n * @internal\r\n * Function that notifies the node executed observable\r\n * @param node\r\n */\r\n public _notifyExecuteNode(node: FlowGraphBlock) {\r\n this.onNodeExecutedObservable.notifyObservers(node);\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _increaseExecutionId() {\r\n this._executionId++;\r\n }\r\n /**\r\n * A monotonically increasing ID for each execution.\r\n * Incremented for every block executed.\r\n */\r\n public get executionId() {\r\n return this._executionId;\r\n }\r\n\r\n /**\r\n * Serializes a context\r\n * @param serializationObject the object to write the values in\r\n * @param valueSerializationFunction a function to serialize complex values\r\n */\r\n public serialize(serializationObject: any = {}, valueSerializationFunction: (key: string, value: any, serializationObject: any) => void = defaultValueSerializationFunction) {\r\n serializationObject.uniqueId = this.uniqueId;\r\n serializationObject._userVariables = {};\r\n for (const key in this._userVariables) {\r\n valueSerializationFunction(key, this._userVariables[key], serializationObject._userVariables);\r\n }\r\n serializationObject._connectionValues = {};\r\n for (const key in this._connectionValues) {\r\n valueSerializationFunction(key, this._connectionValues[key], serializationObject._connectionValues);\r\n }\r\n }\r\n\r\n public getClassName() {\r\n return \"FGContext\";\r\n }\r\n\r\n /**\r\n * Parses a context\r\n * @param serializationObject the object containing the context serialization values\r\n * @param graph the graph to which the context should belong\r\n * @param valueParseFunction a function to parse complex values\r\n * @returns\r\n */\r\n public static Parse(serializationObject: ISerializedFlowGraphContext, options: IFlowGraphContextParseOptions): FlowGraphContext {\r\n const result = options.graph.createContext();\r\n const valueParseFunction = options.valueParseFunction ?? defaultValueParseFunction;\r\n result.uniqueId = serializationObject.uniqueId;\r\n for (const key in serializationObject._userVariables) {\r\n const value = valueParseFunction(key, serializationObject._userVariables, result._configuration.scene);\r\n result._userVariables[key] = value;\r\n }\r\n for (const key in serializationObject._connectionValues) {\r\n const value = valueParseFunction(key, serializationObject._connectionValues, result._configuration.scene);\r\n result._connectionValues[key] = value;\r\n }\r\n\r\n return result;\r\n }\r\n}\r\n"]}
|
|
@@ -1,16 +1,36 @@
|
|
|
1
1
|
import { Observable } from "../Misc/observable.js";
|
|
2
2
|
import type { Scene } from "../scene";
|
|
3
3
|
import { FlowGraph } from "./flowGraph";
|
|
4
|
+
import type { IPathToObjectConverter } from "../ObjectModel/objectModelInterfaces";
|
|
5
|
+
import type { IObjectAccessor } from "./typeDefinitions";
|
|
4
6
|
/**
|
|
5
7
|
* @experimental
|
|
6
8
|
* Parameters used to create a flow graph engine.
|
|
7
9
|
*/
|
|
8
|
-
export
|
|
10
|
+
export interface IFlowGraphCoordinatorConfiguration {
|
|
9
11
|
/**
|
|
10
12
|
* The scene that the flow graph engine belongs to.
|
|
11
13
|
*/
|
|
12
14
|
scene: Scene;
|
|
13
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* @experimental
|
|
18
|
+
* Parameters used to parse a flow graph coordinator.
|
|
19
|
+
*/
|
|
20
|
+
export interface FlowGraphCoordinatorParseOptions {
|
|
21
|
+
/**
|
|
22
|
+
* A function that will be called to parse the value of a property.
|
|
23
|
+
*/
|
|
24
|
+
valueParseFunction?: (key: string, serializationObject: any, scene: Scene) => any;
|
|
25
|
+
/**
|
|
26
|
+
* The path converter to use to convert the path to an object accessor.
|
|
27
|
+
*/
|
|
28
|
+
pathConverter: IPathToObjectConverter<IObjectAccessor>;
|
|
29
|
+
/**
|
|
30
|
+
* The scene that the flow graph coordinator belongs to.
|
|
31
|
+
*/
|
|
32
|
+
scene: Scene;
|
|
33
|
+
}
|
|
14
34
|
/**
|
|
15
35
|
* This class holds all of the existing flow graphs and is responsible for creating new ones.
|
|
16
36
|
* It also handles starting/stopping multiple graphs and communication between them through an Event Coordinator
|
|
@@ -44,7 +64,7 @@ export declare class FlowGraphCoordinator {
|
|
|
44
64
|
*/
|
|
45
65
|
dispose(): void;
|
|
46
66
|
serialize(serializationObject: any, valueSerializeFunction?: (key: string, value: any, serializationObject: any) => void): void;
|
|
47
|
-
static Parse(serializedObject: any,
|
|
67
|
+
static Parse(serializedObject: any, options: FlowGraphCoordinatorParseOptions): FlowGraphCoordinator;
|
|
48
68
|
/**
|
|
49
69
|
* Gets the list of flow graphs
|
|
50
70
|
*/
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import { Observable } from "../Misc/observable.js";
|
|
2
2
|
import { FlowGraph } from "./flowGraph.js";
|
|
3
|
-
|
|
4
|
-
* @experimental
|
|
5
|
-
* Parameters used to create a flow graph engine.
|
|
6
|
-
*/
|
|
7
|
-
export class IFlowGraphCoordinatorConfiguration {
|
|
8
|
-
}
|
|
3
|
+
import { defaultValueParseFunction } from "./serialization.js";
|
|
9
4
|
/**
|
|
10
5
|
* This class holds all of the existing flow graphs and is responsible for creating new ones.
|
|
11
6
|
* It also handles starting/stopping multiple graphs and communication between them through an Event Coordinator
|
|
@@ -72,11 +67,12 @@ export class FlowGraphCoordinator {
|
|
|
72
67
|
serializationObject._flowGraphs.push(serializedGraph);
|
|
73
68
|
});
|
|
74
69
|
}
|
|
75
|
-
static Parse(serializedObject,
|
|
76
|
-
var _a;
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
70
|
+
static Parse(serializedObject, options) {
|
|
71
|
+
var _a, _b;
|
|
72
|
+
const valueParseFunction = (_a = options.valueParseFunction) !== null && _a !== void 0 ? _a : defaultValueParseFunction;
|
|
73
|
+
const coordinator = new FlowGraphCoordinator({ scene: options.scene });
|
|
74
|
+
(_b = serializedObject._flowGraphs) === null || _b === void 0 ? void 0 : _b.forEach((serializedGraph) => {
|
|
75
|
+
FlowGraph.Parse(serializedGraph, { coordinator, valueParseFunction, pathConverter: options.pathConverter });
|
|
80
76
|
});
|
|
81
77
|
return coordinator;
|
|
82
78
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flowGraphCoordinator.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraphCoordinator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,8BAA6B;AAElD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC
|
|
1
|
+
{"version":3,"file":"flowGraphCoordinator.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraphCoordinator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,8BAA6B;AAElD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAgC5D;;;GAGG;AACH,MAAM,OAAO,oBAAoB;IAW7B,YAA0B,MAA0C;;QAA1C,WAAM,GAAN,MAAM,CAAoC;QAJnD,gBAAW,GAAgB,EAAE,CAAC;QAEvC,qBAAgB,GAAiC,IAAI,GAAG,EAAE,CAAC;QAG/D,0EAA0E;QAC1E,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAAC,GAAG,CAAC,GAAG,EAAE;YAC3C,IAAI,CAAC,OAAO,EAAE,CAAC;QACnB,CAAC,CAAC,C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E;YACb,UAAU,GAAG,IAAI,UAAU,EAAO,CAAC;YACnC,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;SAC7C;QACD,OAAO,UAAU,CAAC;IACtB,CAAC;IAED;;;;OAIG;IACI,iBAAiB,CAAC,EAAU,EAAE,IAAS;QAC1C,MAAM,UAAU,GAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACjD,IAAI,UAAU,EAAE;YACZ,UAAU,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;SACpC;IACL,CAAC;;AAjHD;;;GAGG;AACoB,sCAAiB,GAAuC,IAAI,GAAG,EAAE,AAAhD,CAAiD","sourcesContent":["import { Observable } from \"core/Misc/observable\";\r\nimport type { Scene } from \"../scene\";\r\nimport { FlowGraph } from \"./flowGraph\";\r\nimport type { IPathToObjectConverter } from \"../ObjectModel/objectModelInterfaces\";\r\nimport { defaultValueParseFunction } from \"./serialization\";\r\nimport type { IObjectAccessor } from \"./typeDefinitions\";\r\n\r\n/**\r\n * @experimental\r\n * Parameters used to create a flow graph engine.\r\n */\r\nexport interface IFlowGraphCoordinatorConfiguration {\r\n /**\r\n * The scene that the flow graph engine belongs to.\r\n */\r\n scene: Scene;\r\n}\r\n\r\n/**\r\n * @experimental\r\n * Parameters used to parse a flow graph coordinator.\r\n */\r\nexport interface FlowGraphCoordinatorParseOptions {\r\n /**\r\n * A function that will be called to parse the value of a property.\r\n */\r\n valueParseFunction?: (key: string, serializationObject: any, scene: Scene) => any;\r\n /**\r\n * The path converter to use to convert the path to an object accessor.\r\n */\r\n pathConverter: IPathToObjectConverter<IObjectAccessor>;\r\n /**\r\n * The scene that the flow graph coordinator belongs to.\r\n */\r\n scene: Scene;\r\n}\r\n/**\r\n * This class holds all of the existing flow graphs and is responsible for creating new ones.\r\n * It also handles starting/stopping multiple graphs and communication between them through an Event Coordinator\r\n */\r\nexport class FlowGraphCoordinator {\r\n /**\r\n * @internal\r\n * A list of all the coordinators per scene. Will be used by the inspector\r\n */\r\n public static readonly SceneCoordinators: Map<Scene, FlowGraphCoordinator[]> = new Map();\r\n\r\n private readonly _flowGraphs: FlowGraph[] = [];\r\n\r\n private _customEventsMap: Map<string, Observable<any>> = new Map();\r\n\r\n public constructor(public config: IFlowGraphCoordinatorConfiguration) {\r\n // When the scene is disposed, dispose all graphs currently running on it.\r\n this.config.scene.onDisposeObservable.add(() => {\r\n this.dispose();\r\n });\r\n\r\n // Add itself to the SceneCoordinators list for the Inspector.\r\n const coordinators = FlowGraphCoordinator.SceneCoordinators.get(this.config.scene) ?? [];\r\n coordinators.push(this);\r\n }\r\n\r\n /**\r\n * Creates a new flow graph and adds it to the list of existing flow graphs\r\n * @returns a new flow graph\r\n */\r\n public createGraph(): FlowGraph {\r\n const graph = new FlowGraph({ scene: this.config.scene, coordinator: this });\r\n this._flowGraphs.push(graph);\r\n return graph;\r\n }\r\n\r\n /**\r\n * Removes a flow graph from the list of existing flow graphs and disposes it\r\n * @param graph the graph to remove\r\n */\r\n public removeGraph(graph: FlowGraph) {\r\n const index = this._flowGraphs.indexOf(graph);\r\n if (index !== -1) {\r\n graph.dispose();\r\n this._flowGraphs.splice(index, 1);\r\n }\r\n }\r\n\r\n /**\r\n * Starts all graphs\r\n */\r\n public start() {\r\n this._flowGraphs.forEach((graph) => graph.start());\r\n }\r\n\r\n /**\r\n * Disposes all graphs\r\n */\r\n public dispose() {\r\n this._flowGraphs.forEach((graph) => graph.dispose());\r\n this._flowGraphs.length = 0;\r\n\r\n // Remove itself from the SceneCoordinators list for the Inspector.\r\n const coordinators = FlowGraphCoordinator.SceneCoordinators.get(this.config.scene) ?? [];\r\n const index = coordinators.indexOf(this);\r\n if (index !== -1) {\r\n coordinators.splice(index, 1);\r\n }\r\n }\r\n\r\n public serialize(serializationObject: any, valueSerializeFunction?: (key: string, value: any, serializationObject: any) => void) {\r\n serializationObject._flowGraphs = [];\r\n this._flowGraphs.forEach((graph) => {\r\n const serializedGraph = {};\r\n graph.serialize(serializedGraph, valueSerializeFunction);\r\n serializationObject._flowGraphs.push(serializedGraph);\r\n });\r\n }\r\n\r\n public static Parse(serializedObject: any, options: FlowGraphCoordinatorParseOptions) {\r\n const valueParseFunction = options.valueParseFunction ?? defaultValueParseFunction;\r\n const coordinator = new FlowGraphCoordinator({ scene: options.scene });\r\n serializedObject._flowGraphs?.forEach((serializedGraph: any) => {\r\n FlowGraph.Parse(serializedGraph, { coordinator, valueParseFunction, pathConverter: options.pathConverter });\r\n });\r\n return coordinator;\r\n }\r\n\r\n /**\r\n * Gets the list of flow graphs\r\n */\r\n public get flowGraphs() {\r\n return this._flowGraphs;\r\n }\r\n\r\n /* Get an observable that will be notified when the event with the given id is fired.\r\n * @param id the id of the event\r\n * @returns the observable for the event\r\n */\r\n public getCustomEventObservable(id: string): Observable<any> {\r\n let observable = this._customEventsMap.get(id);\r\n if (!observable) {\r\n observable = new Observable<any>();\r\n this._customEventsMap.set(id, observable);\r\n }\r\n return observable;\r\n }\r\n\r\n /**\r\n * Notifies the observable for the given event id with the given data.\r\n * @param id the id of the event\r\n * @param data the data to send with the event\r\n */\r\n public notifyCustomEvent(id: string, data: any) {\r\n const observable = this._customEventsMap.get(id);\r\n if (observable) {\r\n observable.notifyObservers(data);\r\n }\r\n }\r\n}\r\n"]}
|
package/FlowGraph/{flowGraphWithOnDoneExecutionBlock.js → flowGraphExecutionBlockWithOutSignal.js}
RENAMED
|
@@ -11,4 +11,4 @@ export class FlowGraphExecutionBlockWithOutSignal extends FlowGraphExecutionBloc
|
|
|
11
11
|
this.out = this._registerSignalOutput("out");
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
//# sourceMappingURL=
|
|
14
|
+
//# sourceMappingURL=flowGraphExecutionBlockWithOutSignal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flowGraphExecutionBlockWithOutSignal.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraphExecutionBlockWithOutSignal.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAGpE;;;;;GAKG;AACH,MAAM,OAAgB,oCAAqC,SAAQ,uBAAuB;IAMtF,YAAsB,MAAqC;QACvD,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC;IACjD,CAAC;CACJ","sourcesContent":["import type { IFlowGraphBlockConfiguration } from \"./flowGraphBlock\";\r\nimport { FlowGraphExecutionBlock } from \"./flowGraphExecutionBlock\";\r\nimport type { FlowGraphSignalConnection } from \"./flowGraphSignalConnection\";\r\n\r\n/**\r\n * @experimental\r\n * An execution block that has an out signal. This signal is triggered when the synchronous execution of this block is done.\r\n * Most execution blocks will inherit from this, except for the ones that have multiple signals to be triggered.\r\n * (such as if blocks)\r\n */\r\nexport abstract class FlowGraphExecutionBlockWithOutSignal extends FlowGraphExecutionBlock {\r\n /**\r\n * Output connection: The signal that is triggered when the execution of this block is done.\r\n */\r\n public readonly out: FlowGraphSignalConnection;\r\n\r\n protected constructor(config?: IFlowGraphBlockConfiguration) {\r\n super(config);\r\n this.out = this._registerSignalOutput(\"out\");\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { FlowGraphContext } from "./flowGraphContext";
|
|
2
|
+
import type { IPathToObjectConverter, IObjectInfo } from "../ObjectModel/objectModelInterfaces";
|
|
3
|
+
import type { IObjectAccessor } from "./typeDefinitions";
|
|
4
|
+
/**
|
|
5
|
+
* @experimental
|
|
6
|
+
* A path converter that converts a path on the flow graph context variables to an object accessor.
|
|
7
|
+
*/
|
|
8
|
+
export declare class FlowGraphPathConverter implements IPathToObjectConverter<IObjectAccessor> {
|
|
9
|
+
private _context;
|
|
10
|
+
private _separator;
|
|
11
|
+
constructor(_context: FlowGraphContext, _separator?: string);
|
|
12
|
+
convert(path: string): IObjectInfo<IObjectAccessor>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @experimental
|
|
3
|
+
* A path converter that converts a path on the flow graph context variables to an object accessor.
|
|
4
|
+
*/
|
|
5
|
+
export class FlowGraphPathConverter {
|
|
6
|
+
constructor(_context, _separator = "/") {
|
|
7
|
+
this._context = _context;
|
|
8
|
+
this._separator = _separator;
|
|
9
|
+
}
|
|
10
|
+
convert(path) {
|
|
11
|
+
const parts = path.split(this._separator);
|
|
12
|
+
if (parts.length < 2) {
|
|
13
|
+
throw new Error(`Path ${path} is invalid`);
|
|
14
|
+
}
|
|
15
|
+
let currentObject = this._context.getVariable(parts[0]);
|
|
16
|
+
const property = parts[parts.length - 1];
|
|
17
|
+
for (let i = 1; i < parts.length - 1; i++) {
|
|
18
|
+
currentObject = currentObject[parts[i]];
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
object: currentObject,
|
|
22
|
+
info: {
|
|
23
|
+
type: "object",
|
|
24
|
+
get: () => currentObject[property],
|
|
25
|
+
set: (value) => (currentObject[property] = value),
|
|
26
|
+
getObject: () => currentObject,
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=flowGraphPathConverter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flowGraphPathConverter.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraphPathConverter.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,MAAM,OAAO,sBAAsB;IAC/B,YACY,QAA0B,EAC1B,aAAqB,GAAG;QADxB,aAAQ,GAAR,QAAQ,CAAkB;QAC1B,eAAU,GAAV,UAAU,CAAc;IACjC,CAAC;IAEG,OAAO,CAAC,IAAY;QACvB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC1C,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;YAClB,MAAM,IAAI,KAAK,CAAC,QAAQ,IAAI,aAAa,CAAC,CAAC;SAC9C;QACD,IAAI,aAAa,GAAG,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACxD,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACzC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;YACvC,aAAa,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;SAC3C;QACD,OAAO;YACH,MAAM,EAAE,aAAa;YACrB,IAAI,EAAE;gBACF,IAAI,EAAE,QAAQ;gBACd,GAAG,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,QAAQ,CAAC;gBAClC,GAAG,EAAE,CAAC,KAAU,EAAE,EAAE,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC;gBACtD,SAAS,EAAE,GAAG,EAAE,CAAC,aAAa;aACjC;SACJ,CAAC;IACN,CAAC;CACJ","sourcesContent":["import type { FlowGraphContext } from \"./flowGraphContext\";\r\nimport type { IPathToObjectConverter, IObjectInfo } from \"../ObjectModel/objectModelInterfaces\";\r\nimport type { IObjectAccessor } from \"./typeDefinitions\";\r\n\r\n/**\r\n * @experimental\r\n * A path converter that converts a path on the flow graph context variables to an object accessor.\r\n */\r\nexport class FlowGraphPathConverter implements IPathToObjectConverter<IObjectAccessor> {\r\n public constructor(\r\n private _context: FlowGraphContext,\r\n private _separator: string = \"/\"\r\n ) {}\r\n\r\n public convert(path: string): IObjectInfo<IObjectAccessor> {\r\n const parts = path.split(this._separator);\r\n if (parts.length < 2) {\r\n throw new Error(`Path ${path} is invalid`);\r\n }\r\n let currentObject = this._context.getVariable(parts[0]);\r\n const property = parts[parts.length - 1];\r\n for (let i = 1; i < parts.length - 1; i++) {\r\n currentObject = currentObject[parts[i]];\r\n }\r\n return {\r\n object: currentObject,\r\n info: {\r\n type: \"object\",\r\n get: () => currentObject[property],\r\n set: (value: any) => (currentObject[property] = value),\r\n getObject: () => currentObject,\r\n },\r\n };\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { IObjectInfo, IPathToObjectConverter } from "../ObjectModel/objectModelInterfaces";
|
|
2
|
+
import type { FlowGraphBlock } from "./flowGraphBlock";
|
|
3
|
+
import type { FlowGraphContext } from "./flowGraphContext";
|
|
4
|
+
import type { FlowGraphDataConnection } from "./flowGraphDataConnection";
|
|
5
|
+
import type { IObjectAccessor } from "./typeDefinitions";
|
|
6
|
+
/**
|
|
7
|
+
* @experimental
|
|
8
|
+
* A component that converts a path to an object accessor.
|
|
9
|
+
*/
|
|
10
|
+
export declare class FlowGraphPathConverterComponent {
|
|
11
|
+
path: string;
|
|
12
|
+
ownerBlock: FlowGraphBlock;
|
|
13
|
+
/**
|
|
14
|
+
* The templated inputs for the provided path.
|
|
15
|
+
*/
|
|
16
|
+
readonly templatedInputs: FlowGraphDataConnection<number>[];
|
|
17
|
+
constructor(path: string, ownerBlock: FlowGraphBlock);
|
|
18
|
+
getAccessor(pathConverter: IPathToObjectConverter<IObjectAccessor>, context: FlowGraphContext): IObjectInfo<IObjectAccessor>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { RichTypeNumber } from "./flowGraphRichTypes.js";
|
|
2
|
+
const pathHasTemplatesRegex = new RegExp(/\{(\w+)\}/g);
|
|
3
|
+
/**
|
|
4
|
+
* @experimental
|
|
5
|
+
* A component that converts a path to an object accessor.
|
|
6
|
+
*/
|
|
7
|
+
export class FlowGraphPathConverterComponent {
|
|
8
|
+
constructor(path, ownerBlock) {
|
|
9
|
+
this.path = path;
|
|
10
|
+
this.ownerBlock = ownerBlock;
|
|
11
|
+
/**
|
|
12
|
+
* The templated inputs for the provided path.
|
|
13
|
+
*/
|
|
14
|
+
this.templatedInputs = [];
|
|
15
|
+
let match = pathHasTemplatesRegex.exec(path);
|
|
16
|
+
while (match) {
|
|
17
|
+
const [, matchGroup] = match;
|
|
18
|
+
this.templatedInputs.push(ownerBlock.registerDataInput(matchGroup, RichTypeNumber));
|
|
19
|
+
match = pathHasTemplatesRegex.exec(path);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
getAccessor(pathConverter, context) {
|
|
23
|
+
let finalPath = this.path;
|
|
24
|
+
for (const templatedInput of this.templatedInputs) {
|
|
25
|
+
const valueToReplace = templatedInput.getValue(context);
|
|
26
|
+
finalPath = finalPath.replace(`{${templatedInput.name}}`, valueToReplace.toString());
|
|
27
|
+
}
|
|
28
|
+
return pathConverter.convert(finalPath);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=flowGraphPathConverterComponent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flowGraphPathConverterComponent.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraphPathConverterComponent.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD,MAAM,qBAAqB,GAAG,IAAI,MAAM,CAAC,YAAY,CAAC,CAAC;AAEvD;;;GAGG;AACH,MAAM,OAAO,+BAA+B;IAKxC,YACW,IAAY,EACZ,UAA0B;QAD1B,SAAI,GAAJ,IAAI,CAAQ;QACZ,eAAU,GAAV,UAAU,CAAgB;QANrC;;WAEG;QACa,oBAAe,GAAsC,EAAE,CAAC;QAKpE,IAAI,KAAK,GAAG,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7C,OAAO,KAAK,EAAE;YACV,MAAM,CAAC,EAAE,UAAU,CAAC,GAAG,KAAK,CAAC;YAC7B,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC,CAAC;YACpF,KAAK,GAAG,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SAC5C;IACL,CAAC;IAEM,WAAW,CAAC,aAAsD,EAAE,OAAyB;QAChG,IAAI,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC;QAC1B,KAAK,MAAM,cAAc,IAAI,IAAI,CAAC,eAAe,EAAE;YAC/C,MAAM,cAAc,GAAG,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;YACxD,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,IAAI,cAAc,CAAC,IAAI,GAAG,EAAE,cAAc,CAAC,QAAQ,EAAE,CAAC,CAAC;SACxF;QACD,OAAO,aAAa,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAC5C,CAAC;CACJ","sourcesContent":["import type { IObjectInfo, IPathToObjectConverter } from \"../ObjectModel/objectModelInterfaces\";\r\nimport type { FlowGraphBlock } from \"./flowGraphBlock\";\r\nimport type { FlowGraphContext } from \"./flowGraphContext\";\r\nimport type { FlowGraphDataConnection } from \"./flowGraphDataConnection\";\r\nimport { RichTypeNumber } from \"./flowGraphRichTypes\";\r\nimport type { IObjectAccessor } from \"./typeDefinitions\";\r\n\r\nconst pathHasTemplatesRegex = new RegExp(/\\{(\\w+)\\}/g);\r\n\r\n/**\r\n * @experimental\r\n * A component that converts a path to an object accessor.\r\n */\r\nexport class FlowGraphPathConverterComponent {\r\n /**\r\n * The templated inputs for the provided path.\r\n */\r\n public readonly templatedInputs: FlowGraphDataConnection<number>[] = [];\r\n public constructor(\r\n public path: string,\r\n public ownerBlock: FlowGraphBlock\r\n ) {\r\n let match = pathHasTemplatesRegex.exec(path);\r\n while (match) {\r\n const [, matchGroup] = match;\r\n this.templatedInputs.push(ownerBlock.registerDataInput(matchGroup, RichTypeNumber));\r\n match = pathHasTemplatesRegex.exec(path);\r\n }\r\n }\r\n\r\n public getAccessor(pathConverter: IPathToObjectConverter<IObjectAccessor>, context: FlowGraphContext): IObjectInfo<IObjectAccessor> {\r\n let finalPath = this.path;\r\n for (const templatedInput of this.templatedInputs) {\r\n const valueToReplace = templatedInput.getValue(context);\r\n finalPath = finalPath.replace(`{${templatedInput.name}}`, valueToReplace.toString());\r\n }\r\n return pathConverter.convert(finalPath);\r\n }\r\n}\r\n"]}
|
package/FlowGraph/index.d.ts
CHANGED
|
@@ -8,7 +8,6 @@ export * from "./flowGraphContext";
|
|
|
8
8
|
export * from "./flowGraphCoordinator";
|
|
9
9
|
export * from "./typeDefinitions";
|
|
10
10
|
export * from "./flowGraphContextLogger";
|
|
11
|
-
export * from "./flowGraphPath";
|
|
12
11
|
export * from "./flowGraphConnection";
|
|
13
12
|
export * from "./flowGraphDataConnection";
|
|
14
13
|
export * from "./Blocks/index";
|
package/FlowGraph/index.js
CHANGED
|
@@ -8,7 +8,6 @@ export * from "./flowGraphContext.js";
|
|
|
8
8
|
export * from "./flowGraphCoordinator.js";
|
|
9
9
|
export * from "./typeDefinitions.js";
|
|
10
10
|
export * from "./flowGraphContextLogger.js";
|
|
11
|
-
export * from "./flowGraphPath.js";
|
|
12
11
|
export * from "./flowGraphConnection.js";
|
|
13
12
|
export * from "./flowGraphDataConnection.js";
|
|
14
13
|
// eslint-disable-next-line import/no-internal-modules
|