@babylonjs/core 6.41.0 → 6.41.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Animations/animatable.js +1 -2
- package/Animations/animatable.js.map +1 -1
- package/Animations/animation.js +4 -6
- package/Animations/animation.js.map +1 -1
- package/Animations/animationGroup.js +3 -3
- package/Animations/animationGroup.js.map +1 -1
- package/Animations/runtimeAnimation.js +1 -1
- package/Animations/runtimeAnimation.js.map +1 -1
- package/Audio/audioEngine.js +3 -5
- package/Audio/audioEngine.js.map +1 -1
- package/Audio/audioSceneComponent.js +1 -2
- package/Audio/audioSceneComponent.js.map +1 -1
- package/Audio/sound.js +48 -74
- package/Audio/sound.js.map +1 -1
- package/Audio/soundTrack.js +6 -12
- package/Audio/soundTrack.js.map +1 -1
- package/BakedVertexAnimation/bakedVertexAnimationManager.js +1 -2
- package/BakedVertexAnimation/bakedVertexAnimationManager.js.map +1 -1
- package/Behaviors/Cameras/autoRotationBehavior.js +1 -1
- package/Behaviors/Cameras/autoRotationBehavior.js.map +1 -1
- package/Behaviors/Meshes/fadeInOutBehavior.js +2 -4
- package/Behaviors/Meshes/fadeInOutBehavior.js.map +1 -1
- package/Behaviors/Meshes/followBehavior.js +1 -2
- package/Behaviors/Meshes/followBehavior.js.map +1 -1
- package/Behaviors/Meshes/handConstraintBehavior.js +2 -2
- package/Behaviors/Meshes/handConstraintBehavior.js.map +1 -1
- package/Bones/bone.js +4 -6
- package/Bones/bone.js.map +1 -1
- package/Bones/skeleton.js +2 -3
- package/Bones/skeleton.js.map +1 -1
- package/Buffers/buffer.align.js +5 -8
- package/Buffers/buffer.align.js.map +1 -1
- package/Buffers/buffer.js +6 -8
- package/Buffers/buffer.js.map +1 -1
- package/Cameras/Inputs/BaseCameraPointersInput.js +3 -4
- package/Cameras/Inputs/BaseCameraPointersInput.js.map +1 -1
- package/Cameras/Inputs/arcRotateCameraMouseWheelInput.js +3 -5
- package/Cameras/Inputs/arcRotateCameraMouseWheelInput.js.map +1 -1
- package/Cameras/Inputs/flyCameraMouseInput.js +2 -2
- package/Cameras/Inputs/flyCameraMouseInput.js.map +1 -1
- package/Cameras/Inputs/freeCameraMouseInput.js +2 -2
- package/Cameras/Inputs/freeCameraMouseInput.js.map +1 -1
- package/Cameras/arcRotateCamera.js +1 -2
- package/Cameras/arcRotateCamera.js.map +1 -1
- package/Cameras/camera.d.ts +5 -0
- package/Cameras/camera.js +18 -11
- package/Cameras/camera.js.map +1 -1
- package/Collisions/pickingInfo.js +1 -1
- package/Collisions/pickingInfo.js.map +1 -1
- package/Compute/computeEffect.js +5 -8
- package/Compute/computeEffect.js.map +1 -1
- package/Compute/computeShader.js +12 -9
- package/Compute/computeShader.js.map +1 -1
- package/Culling/Octrees/octreeSceneComponent.js +1 -2
- package/Culling/Octrees/octreeSceneComponent.js.map +1 -1
- package/Culling/boundingBox.js +2 -3
- package/Culling/boundingBox.js.map +1 -1
- package/Culling/ray.d.ts +6 -1
- package/Culling/ray.js +9 -4
- package/Culling/ray.js.map +1 -1
- package/Debug/debugLayer.js +4 -1
- package/Debug/debugLayer.js.map +1 -1
- package/Debug/directionalLightFrustumViewer.js +7 -9
- package/Debug/directionalLightFrustumViewer.js.map +1 -1
- package/Debug/physicsViewer.js +5 -7
- package/Debug/physicsViewer.js.map +1 -1
- package/Debug/rayHelper.js +1 -2
- package/Debug/rayHelper.js.map +1 -1
- package/Debug/skeletonViewer.js +26 -31
- package/Debug/skeletonViewer.js.map +1 -1
- package/Decorators/nodeDecorator.js +1 -1
- package/Decorators/nodeDecorator.js.map +1 -1
- package/DeviceInput/InputDevices/deviceSourceManager.js +3 -5
- package/DeviceInput/InputDevices/deviceSourceManager.js.map +1 -1
- package/DeviceInput/eventFactory.js +1 -1
- package/DeviceInput/eventFactory.js.map +1 -1
- package/DeviceInput/internalDeviceSourceManager.js +1 -2
- package/DeviceInput/internalDeviceSourceManager.js.map +1 -1
- package/DeviceInput/webDeviceInputSystem.js +9 -12
- package/DeviceInput/webDeviceInputSystem.js.map +1 -1
- package/Engines/Extensions/engine.cubeTexture.js +6 -1
- package/Engines/Extensions/engine.cubeTexture.js.map +1 -1
- package/Engines/Extensions/engine.multiRender.js +3 -4
- package/Engines/Extensions/engine.multiRender.js.map +1 -1
- package/Engines/Extensions/engine.rawTexture.js +4 -4
- package/Engines/Extensions/engine.rawTexture.js.map +1 -1
- package/Engines/Extensions/engine.readTexture.js +2 -3
- package/Engines/Extensions/engine.readTexture.js.map +1 -1
- package/Engines/Extensions/engine.renderTarget.js +9 -5
- package/Engines/Extensions/engine.renderTarget.js.map +1 -1
- package/Engines/Extensions/engine.renderTargetCube.js +9 -1
- package/Engines/Extensions/engine.renderTargetCube.js.map +1 -1
- package/Engines/Extensions/engine.views.js +1 -2
- package/Engines/Extensions/engine.views.js.map +1 -1
- package/Engines/Processors/shaderCodeNode.js +6 -7
- package/Engines/Processors/shaderCodeNode.js.map +1 -1
- package/Engines/Processors/shaderProcessor.js +6 -11
- package/Engines/Processors/shaderProcessor.js.map +1 -1
- package/Engines/WebGL/webGLHardwareTexture.js +1 -2
- package/Engines/WebGL/webGLHardwareTexture.js.map +1 -1
- package/Engines/WebGL/webGLRenderTargetWrapper.js +3 -5
- package/Engines/WebGL/webGLRenderTargetWrapper.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.cubeTexture.js +9 -2
- package/Engines/WebGPU/Extensions/engine.cubeTexture.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.dynamicTexture.js +1 -2
- package/Engines/WebGPU/Extensions/engine.dynamicTexture.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.multiRender.js +5 -6
- package/Engines/WebGPU/Extensions/engine.multiRender.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.query.js +2 -4
- package/Engines/WebGPU/Extensions/engine.query.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.rawTexture.js +4 -4
- package/Engines/WebGPU/Extensions/engine.rawTexture.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.renderTarget.js +11 -5
- package/Engines/WebGPU/Extensions/engine.renderTarget.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.renderTargetCube.js +11 -3
- package/Engines/WebGPU/Extensions/engine.renderTargetCube.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.storageBuffer.js +2 -3
- package/Engines/WebGPU/Extensions/engine.storageBuffer.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.textureSampler.js +1 -2
- package/Engines/WebGPU/Extensions/engine.textureSampler.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.videoTexture.js +1 -2
- package/Engines/WebGPU/Extensions/engine.videoTexture.js.map +1 -1
- package/Engines/WebGPU/webgpuBufferManager.js +1 -1
- package/Engines/WebGPU/webgpuBufferManager.js.map +1 -1
- package/Engines/WebGPU/webgpuCacheBindGroups.js +6 -7
- package/Engines/WebGPU/webgpuCacheBindGroups.js.map +1 -1
- package/Engines/WebGPU/webgpuCacheRenderPipeline.js +15 -20
- package/Engines/WebGPU/webgpuCacheRenderPipeline.js.map +1 -1
- package/Engines/WebGPU/webgpuCacheSampler.js +10 -5
- package/Engines/WebGPU/webgpuCacheSampler.js.map +1 -1
- package/Engines/WebGPU/webgpuClearQuad.js +2 -3
- package/Engines/WebGPU/webgpuClearQuad.js.map +1 -1
- package/Engines/WebGPU/webgpuComputePipelineContext.js +1 -2
- package/Engines/WebGPU/webgpuComputePipelineContext.js.map +1 -1
- package/Engines/WebGPU/webgpuDepthCullingState.js +2 -2
- package/Engines/WebGPU/webgpuDepthCullingState.js.map +1 -1
- package/Engines/WebGPU/webgpuDrawContext.js +1 -2
- package/Engines/WebGPU/webgpuDrawContext.js.map +1 -1
- package/Engines/WebGPU/webgpuHardwareTexture.js +4 -6
- package/Engines/WebGPU/webgpuHardwareTexture.js.map +1 -1
- package/Engines/WebGPU/webgpuMaterialContext.js +2 -3
- package/Engines/WebGPU/webgpuMaterialContext.js.map +1 -1
- package/Engines/WebGPU/webgpuOcclusionQuery.js +3 -5
- package/Engines/WebGPU/webgpuOcclusionQuery.js.map +1 -1
- package/Engines/WebGPU/webgpuPipelineContext.js +2 -4
- package/Engines/WebGPU/webgpuPipelineContext.js.map +1 -1
- package/Engines/WebGPU/webgpuQuerySet.js +1 -1
- package/Engines/WebGPU/webgpuQuerySet.js.map +1 -1
- package/Engines/WebGPU/webgpuShaderProcessingContext.js +2 -4
- package/Engines/WebGPU/webgpuShaderProcessingContext.js.map +1 -1
- package/Engines/WebGPU/webgpuShaderProcessorsGLSL.js +2 -4
- package/Engines/WebGPU/webgpuShaderProcessorsGLSL.js.map +1 -1
- package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js +5 -4
- package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js.map +1 -1
- package/Engines/WebGPU/webgpuStencilStateComposer.js +1 -2
- package/Engines/WebGPU/webgpuStencilStateComposer.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureManager.js +40 -43
- package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
- package/Engines/WebGPU/webgpuTimestampQuery.js +12 -7
- package/Engines/WebGPU/webgpuTimestampQuery.js.map +1 -1
- package/Engines/WebGPU/webgpuTintWASM.js +4 -1
- package/Engines/WebGPU/webgpuTintWASM.js.map +1 -1
- package/Engines/engine.js +4 -7
- package/Engines/engine.js.map +1 -1
- package/Engines/nativeEngine.js +16 -22
- package/Engines/nativeEngine.js.map +1 -1
- package/Engines/nullEngine.js +9 -1
- package/Engines/nullEngine.js.map +1 -1
- package/Engines/renderTargetWrapper.js +11 -16
- package/Engines/renderTargetWrapper.js.map +1 -1
- package/Engines/thinEngine.js +32 -44
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.js +77 -95
- package/Engines/webgpuEngine.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.js +2 -3
- package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js +3 -6
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCounterBlock.js +1 -2
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCounterBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphMultiGateBlock.js +1 -2
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphMultiGateBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock.js +2 -4
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock.js.map +1 -1
- package/FlowGraph/flowGraph.js +1 -2
- package/FlowGraph/flowGraph.js.map +1 -1
- package/FlowGraph/flowGraphBlock.js +2 -4
- package/FlowGraph/flowGraphBlock.js.map +1 -1
- package/FlowGraph/flowGraphContext.js +1 -2
- package/FlowGraph/flowGraphContext.js.map +1 -1
- package/FlowGraph/flowGraphCoordinator.js +4 -7
- package/FlowGraph/flowGraphCoordinator.js.map +1 -1
- package/FlowGraph/flowGraphSignalConnection.js +1 -2
- package/FlowGraph/flowGraphSignalConnection.js.map +1 -1
- package/FlowGraph/serialization.js +2 -3
- package/FlowGraph/serialization.js.map +1 -1
- package/Gamepads/gamepadManager.js +1 -1
- package/Gamepads/gamepadManager.js.map +1 -1
- package/Gizmos/axisDragGizmo.js +2 -4
- package/Gizmos/axisDragGizmo.js.map +1 -1
- package/Gizmos/axisScaleGizmo.js +5 -8
- package/Gizmos/axisScaleGizmo.js.map +1 -1
- package/Gizmos/boundingBoxGizmo.js +1 -1
- package/Gizmos/boundingBoxGizmo.js.map +1 -1
- package/Gizmos/cameraGizmo.js +2 -3
- package/Gizmos/cameraGizmo.js.map +1 -1
- package/Gizmos/gizmo.js +4 -7
- package/Gizmos/gizmo.js.map +1 -1
- package/Gizmos/gizmoManager.js +3 -4
- package/Gizmos/gizmoManager.js.map +1 -1
- package/Gizmos/planeDragGizmo.js +2 -4
- package/Gizmos/planeDragGizmo.js.map +1 -1
- package/Gizmos/planeRotationGizmo.js +2 -4
- package/Gizmos/planeRotationGizmo.js.map +1 -1
- package/Helpers/environmentHelper.js +8 -2
- package/Helpers/environmentHelper.js.map +1 -1
- package/Helpers/videoDome.js +1 -2
- package/Helpers/videoDome.js.map +1 -1
- package/Inputs/scene.inputManager.js +8 -10
- package/Inputs/scene.inputManager.js.map +1 -1
- package/Layers/effectLayer.js +16 -10
- package/Layers/effectLayer.js.map +1 -1
- package/Layers/glowLayer.js +16 -6
- package/Layers/glowLayer.js.map +1 -1
- package/Layers/highlightLayer.js +12 -3
- package/Layers/highlightLayer.js.map +1 -1
- package/Layers/layer.js +1 -2
- package/Layers/layer.js.map +1 -1
- package/LensFlares/lensFlareSystem.js +1 -2
- package/LensFlares/lensFlareSystem.js.map +1 -1
- package/Lights/Shadows/cascadedShadowGenerator.js +21 -25
- package/Lights/Shadows/cascadedShadowGenerator.js.map +1 -1
- package/Lights/Shadows/shadowGenerator.js +18 -21
- package/Lights/Shadows/shadowGenerator.js.map +1 -1
- package/Lights/light.js +2 -4
- package/Lights/light.js.map +1 -1
- package/Lights/shadowLight.js +1 -1
- package/Lights/shadowLight.js.map +1 -1
- package/Loading/Plugins/babylonFileLoader.js +1 -2
- package/Loading/Plugins/babylonFileLoader.js.map +1 -1
- package/Loading/sceneLoader.js +1 -1
- package/Loading/sceneLoader.js.map +1 -1
- package/Materials/GreasedLine/greasedLinePluginMaterial.js +26 -32
- package/Materials/GreasedLine/greasedLinePluginMaterial.js.map +1 -1
- package/Materials/GreasedLine/greasedLineSimpleMaterial.js +22 -27
- package/Materials/GreasedLine/greasedLineSimpleMaterial.js.map +1 -1
- package/Materials/Node/Blocks/Dual/clipPlanesBlock.js +6 -7
- package/Materials/Node/Blocks/Dual/clipPlanesBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/imageSourceBlock.js +1 -2
- package/Materials/Node/Blocks/Dual/imageSourceBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.js +1 -2
- package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/sceneDepthBlock.js +1 -1
- package/Materials/Node/Blocks/Dual/sceneDepthBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/textureBlock.js +10 -16
- package/Materials/Node/Blocks/Dual/textureBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/TBNBlock.js +2 -3
- package/Materials/Node/Blocks/Fragment/TBNBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js +1 -2
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/imageProcessingBlock.js +2 -4
- package/Materials/Node/Blocks/Fragment/imageProcessingBlock.js.map +1 -1
- package/Materials/Node/Blocks/Input/inputBlock.js +1 -2
- package/Materials/Node/Blocks/Input/inputBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/clearCoatBlock.js +24 -26
- package/Materials/Node/Blocks/PBR/clearCoatBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/iridescenceBlock.js +3 -3
- package/Materials/Node/Blocks/PBR/iridescenceBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js +45 -49
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/reflectionBlock.js +1 -2
- package/Materials/Node/Blocks/PBR/reflectionBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/refractionBlock.js +1 -2
- package/Materials/Node/Blocks/PBR/refractionBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/sheenBlock.js +13 -13
- package/Materials/Node/Blocks/PBR/sheenBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/subSurfaceBlock.js +27 -28
- package/Materials/Node/Blocks/PBR/subSurfaceBlock.js.map +1 -1
- package/Materials/Node/Blocks/Teleport/teleportOutBlock.js +1 -2
- package/Materials/Node/Blocks/Teleport/teleportOutBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/instancesBlock.js +2 -2
- package/Materials/Node/Blocks/Vertex/instancesBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js +43 -33
- package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js.map +1 -1
- package/Materials/Node/Blocks/biPlanarBlock.js +1 -2
- package/Materials/Node/Blocks/biPlanarBlock.js.map +1 -1
- package/Materials/Node/Blocks/cloudBlock.js +2 -3
- package/Materials/Node/Blocks/cloudBlock.js.map +1 -1
- package/Materials/Node/Blocks/colorMergerBlock.js +4 -5
- package/Materials/Node/Blocks/colorMergerBlock.js.map +1 -1
- package/Materials/Node/Blocks/customBlock.js +4 -6
- package/Materials/Node/Blocks/customBlock.js.map +1 -1
- package/Materials/Node/Blocks/meshAttributeExistsBlock.js +2 -4
- package/Materials/Node/Blocks/meshAttributeExistsBlock.js.map +1 -1
- package/Materials/Node/Blocks/triPlanarBlock.js +14 -23
- package/Materials/Node/Blocks/triPlanarBlock.js.map +1 -1
- package/Materials/Node/Blocks/vectorMergerBlock.js +4 -5
- package/Materials/Node/Blocks/vectorMergerBlock.js.map +1 -1
- package/Materials/Node/nodeMaterial.js +16 -11
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Materials/Node/nodeMaterialBlock.js +3 -4
- package/Materials/Node/nodeMaterialBlock.js.map +1 -1
- package/Materials/Node/nodeMaterialBuildState.js +1 -1
- package/Materials/Node/nodeMaterialBuildState.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.js +25 -28
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/PBR/pbrClearCoatConfiguration.js +6 -9
- package/Materials/PBR/pbrClearCoatConfiguration.js.map +1 -1
- package/Materials/PBR/pbrIridescenceConfiguration.js +4 -7
- package/Materials/PBR/pbrIridescenceConfiguration.js.map +1 -1
- package/Materials/PBR/pbrSheenConfiguration.js +4 -7
- package/Materials/PBR/pbrSheenConfiguration.js.map +1 -1
- package/Materials/Textures/Loaders/envTextureLoader.js +2 -2
- package/Materials/Textures/Loaders/envTextureLoader.js.map +1 -1
- package/Materials/Textures/Packer/packer.js +13 -14
- package/Materials/Textures/Packer/packer.js.map +1 -1
- package/Materials/Textures/Procedurals/noiseProceduralTexture.js +1 -2
- package/Materials/Textures/Procedurals/noiseProceduralTexture.js.map +1 -1
- package/Materials/Textures/Procedurals/proceduralTexture.js +19 -11
- package/Materials/Textures/Procedurals/proceduralTexture.js.map +1 -1
- package/Materials/Textures/baseTexture.js +2 -4
- package/Materials/Textures/baseTexture.js.map +1 -1
- package/Materials/Textures/cubeTexture.js +7 -13
- package/Materials/Textures/cubeTexture.js.map +1 -1
- package/Materials/Textures/dynamicTexture.js +1 -2
- package/Materials/Textures/dynamicTexture.js.map +1 -1
- package/Materials/Textures/hdrCubeTexture.js +2 -4
- package/Materials/Textures/hdrCubeTexture.js.map +1 -1
- package/Materials/Textures/htmlElementTexture.js +5 -3
- package/Materials/Textures/htmlElementTexture.js.map +1 -1
- package/Materials/Textures/internalTexture.js +3 -5
- package/Materials/Textures/internalTexture.js.map +1 -1
- package/Materials/Textures/mirrorTexture.js +3 -6
- package/Materials/Textures/mirrorTexture.js.map +1 -1
- package/Materials/Textures/multiRenderTarget.js +5 -8
- package/Materials/Textures/multiRenderTarget.js.map +1 -1
- package/Materials/Textures/rawTexture.js +1 -1
- package/Materials/Textures/rawTexture.js.map +1 -1
- package/Materials/Textures/renderTargetTexture.js +22 -34
- package/Materials/Textures/renderTargetTexture.js.map +1 -1
- package/Materials/Textures/texture.js +16 -21
- package/Materials/Textures/texture.js.map +1 -1
- package/Materials/Textures/thinRenderTargetTexture.js +2 -4
- package/Materials/Textures/thinRenderTargetTexture.js.map +1 -1
- package/Materials/Textures/thinTexture.js +1 -1
- package/Materials/Textures/thinTexture.js.map +1 -1
- package/Materials/Textures/videoTexture.js +12 -10
- package/Materials/Textures/videoTexture.js.map +1 -1
- package/Materials/clipPlaneMaterialHelper.js +18 -21
- package/Materials/clipPlaneMaterialHelper.js.map +1 -1
- package/Materials/drawWrapper.js +2 -4
- package/Materials/drawWrapper.js.map +1 -1
- package/Materials/effect.d.ts +4 -0
- package/Materials/effect.js +18 -18
- package/Materials/effect.js.map +1 -1
- package/Materials/effectRenderer.js +2 -3
- package/Materials/effectRenderer.js.map +1 -1
- package/Materials/material.decalMapConfiguration.js +3 -3
- package/Materials/material.decalMapConfiguration.js.map +1 -1
- package/Materials/material.detailMapConfiguration.js +1 -2
- package/Materials/material.detailMapConfiguration.js.map +1 -1
- package/Materials/material.js +7 -4
- package/Materials/material.js.map +1 -1
- package/Materials/materialDefines.js +5 -6
- package/Materials/materialDefines.js.map +1 -1
- package/Materials/materialHelper.d.ts +1 -1
- package/Materials/materialHelper.js +3 -4
- package/Materials/materialHelper.js.map +1 -1
- package/Materials/materialPluginManager.js +3 -5
- package/Materials/materialPluginManager.js.map +1 -1
- package/Materials/meshDebugPluginMaterial.js +13 -14
- package/Materials/meshDebugPluginMaterial.js.map +1 -1
- package/Materials/multiMaterial.js +1 -2
- package/Materials/multiMaterial.js.map +1 -1
- package/Materials/shaderMaterial.d.ts +1 -1
- package/Materials/shaderMaterial.js +64 -32
- package/Materials/shaderMaterial.js.map +1 -1
- package/Materials/shadowDepthWrapper.js +24 -23
- package/Materials/shadowDepthWrapper.js.map +1 -1
- package/Materials/standardMaterial.js +10 -12
- package/Materials/standardMaterial.js.map +1 -1
- package/Materials/uniformBuffer.js +1 -1
- package/Materials/uniformBuffer.js.map +1 -1
- package/Maths/math.vector.js +1 -2
- package/Maths/math.vector.js.map +1 -1
- package/Meshes/Builders/decalBuilder.js +26 -29
- package/Meshes/Builders/decalBuilder.js.map +1 -1
- package/Meshes/Builders/greasedLineBuilder.js +16 -16
- package/Meshes/Builders/greasedLineBuilder.js.map +1 -1
- package/Meshes/Builders/groundBuilder.d.ts +5 -1
- package/Meshes/Builders/groundBuilder.js +13 -2
- package/Meshes/Builders/groundBuilder.js.map +1 -1
- package/Meshes/Builders/textBuilder.js +2 -3
- package/Meshes/Builders/textBuilder.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.d.ts +9 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +141 -12
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
- package/Meshes/GreasedLine/greasedLineBaseMesh.js +8 -11
- package/Meshes/GreasedLine/greasedLineBaseMesh.js.map +1 -1
- package/Meshes/GreasedLine/greasedLineMesh.js +3 -5
- package/Meshes/GreasedLine/greasedLineMesh.js.map +1 -1
- package/Meshes/GreasedLine/greasedLineRibbonMesh.js +13 -18
- package/Meshes/GreasedLine/greasedLineRibbonMesh.js.map +1 -1
- package/Meshes/Node/Blocks/Teleport/teleportOutBlock.js +1 -2
- package/Meshes/Node/Blocks/Teleport/teleportOutBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryTrigonometryBlock.d.ts +18 -18
- package/Meshes/Node/Blocks/geometryTrigonometryBlock.js +18 -18
- package/Meshes/Node/Blocks/geometryTrigonometryBlock.js.map +1 -1
- package/Meshes/Node/nodeGeometry.js +6 -3
- package/Meshes/Node/nodeGeometry.js.map +1 -1
- package/Meshes/Node/nodeGeometryBlock.js +1 -1
- package/Meshes/Node/nodeGeometryBlock.js.map +1 -1
- package/Meshes/Node/nodeGeometryBlockConnectionPoint.js +1 -2
- package/Meshes/Node/nodeGeometryBlockConnectionPoint.js.map +1 -1
- package/Meshes/Node/nodeGeometryBuildState.js +1 -2
- package/Meshes/Node/nodeGeometryBuildState.js.map +1 -1
- package/Meshes/abstractMesh.js +6 -10
- package/Meshes/abstractMesh.js.map +1 -1
- package/Meshes/csg.js +1 -2
- package/Meshes/csg.js.map +1 -1
- package/Meshes/geometry.js +1 -1
- package/Meshes/geometry.js.map +1 -1
- package/Meshes/instancedMesh.js +5 -10
- package/Meshes/instancedMesh.js.map +1 -1
- package/Meshes/mesh.js +13 -22
- package/Meshes/mesh.js.map +1 -1
- package/Meshes/mesh.vertexData.js +3 -4
- package/Meshes/mesh.vertexData.js.map +1 -1
- package/Meshes/meshUVSpaceRenderer.js +18 -15
- package/Meshes/meshUVSpaceRenderer.js.map +1 -1
- package/Meshes/subMesh.js +8 -14
- package/Meshes/subMesh.js.map +1 -1
- package/Meshes/thinInstanceMesh.js +12 -18
- package/Meshes/thinInstanceMesh.js.map +1 -1
- package/Meshes/trailMesh.js +2 -3
- package/Meshes/trailMesh.js.map +1 -1
- package/Misc/HighDynamicRange/cubemapToSphericalPolynomial.js +1 -2
- package/Misc/HighDynamicRange/cubemapToSphericalPolynomial.js.map +1 -1
- package/Misc/PerformanceViewer/performanceViewerCollectionStrategies.js +9 -14
- package/Misc/PerformanceViewer/performanceViewerCollectionStrategies.js.map +1 -1
- package/Misc/PerformanceViewer/performanceViewerCollector.js +2 -3
- package/Misc/PerformanceViewer/performanceViewerCollector.js.map +1 -1
- package/Misc/arrayTools.js +1 -1
- package/Misc/arrayTools.js.map +1 -1
- package/Misc/basis.js +2 -3
- package/Misc/basis.js.map +1 -1
- package/Misc/dataStorage.js +1 -1
- package/Misc/dataStorage.js.map +1 -1
- package/Misc/deepCopier.js +1 -1
- package/Misc/deepCopier.js.map +1 -1
- package/Misc/environmentTextureTools.js +3 -4
- package/Misc/environmentTextureTools.js.map +1 -1
- package/Misc/equirectangularCapture.js +2 -3
- package/Misc/equirectangularCapture.js.map +1 -1
- package/Misc/fileTools.js +4 -4
- package/Misc/fileTools.js.map +1 -1
- package/Misc/greasedLineTools.js +3 -5
- package/Misc/greasedLineTools.js.map +1 -1
- package/Misc/logger.js +1 -2
- package/Misc/logger.js.map +1 -1
- package/Misc/minMaxReducer.js +2 -3
- package/Misc/minMaxReducer.js.map +1 -1
- package/Misc/pressureObserverWrapper.js +5 -8
- package/Misc/pressureObserverWrapper.js.map +1 -1
- package/Misc/sceneRecorder.js +1 -1
- package/Misc/sceneRecorder.js.map +1 -1
- package/Misc/screenshotTools.js +1 -1
- package/Misc/screenshotTools.js.map +1 -1
- package/Misc/textureTools.js +5 -5
- package/Misc/textureTools.js.map +1 -1
- package/Misc/timer.js +3 -5
- package/Misc/timer.js.map +1 -1
- package/Misc/tools.d.ts +3 -2
- package/Misc/tools.js +6 -5
- package/Misc/tools.js.map +1 -1
- package/Misc/trajectoryClassifier.js +3 -3
- package/Misc/trajectoryClassifier.js.map +1 -1
- package/Misc/videoRecorder.js +6 -4
- package/Misc/videoRecorder.js.map +1 -1
- package/Misc/virtualJoystick.js +4 -1
- package/Misc/virtualJoystick.js.map +1 -1
- package/Morph/morphTargetManager.js +1 -2
- package/Morph/morphTargetManager.js.map +1 -1
- package/Particles/EmitterTypes/meshParticleEmitter.js +1 -2
- package/Particles/EmitterTypes/meshParticleEmitter.js.map +1 -1
- package/Particles/baseParticleSystem.d.ts +4 -0
- package/Particles/baseParticleSystem.js +4 -0
- package/Particles/baseParticleSystem.js.map +1 -1
- package/Particles/computeShaderParticleSystem.js +3 -6
- package/Particles/computeShaderParticleSystem.js.map +1 -1
- package/Particles/gpuParticleSystem.d.ts +2 -2
- package/Particles/gpuParticleSystem.js +30 -20
- package/Particles/gpuParticleSystem.js.map +1 -1
- package/Particles/particleSystem.d.ts +3 -2
- package/Particles/particleSystem.js +33 -30
- package/Particles/particleSystem.js.map +1 -1
- package/Particles/particleSystemComponent.js +2 -3
- package/Particles/particleSystemComponent.js.map +1 -1
- package/Particles/pointsCloudSystem.js +5 -8
- package/Particles/pointsCloudSystem.js.map +1 -1
- package/Particles/solidParticleSystem.js +5 -7
- package/Particles/solidParticleSystem.js.map +1 -1
- package/Particles/webgl2ParticleSystem.js +1 -2
- package/Particles/webgl2ParticleSystem.js.map +1 -1
- package/Physics/castingResult.js +1 -1
- package/Physics/castingResult.js.map +1 -1
- package/Physics/joinedPhysicsEngineComponent.js +2 -2
- package/Physics/joinedPhysicsEngineComponent.js.map +1 -1
- package/Physics/physicsHelper.js +19 -21
- package/Physics/physicsHelper.js.map +1 -1
- package/Physics/v2/IPhysicsEnginePlugin.d.ts +20 -0
- package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -1
- package/Physics/v2/Plugins/havokPlugin.js +48 -35
- package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
- package/Physics/v2/physicsAggregate.js +10 -12
- package/Physics/v2/physicsAggregate.js.map +1 -1
- package/Physics/v2/physicsBody.js +2 -4
- package/Physics/v2/physicsBody.js.map +1 -1
- package/Physics/v2/physicsShape.js +1 -2
- package/Physics/v2/physicsShape.js.map +1 -1
- package/Physics/v2/ragdoll.js +6 -8
- package/Physics/v2/ragdoll.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js +6 -8
- package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.js +14 -22
- package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.js.map +1 -1
- package/PostProcesses/colorCorrectionPostProcess.js +1 -1
- package/PostProcesses/colorCorrectionPostProcess.js.map +1 -1
- package/PostProcesses/postProcess.js +28 -34
- package/PostProcesses/postProcess.js.map +1 -1
- package/PostProcesses/postProcessManager.js +4 -6
- package/PostProcesses/postProcessManager.js.map +1 -1
- package/PostProcesses/screenSpaceReflectionPostProcess.js +2 -2
- package/PostProcesses/screenSpaceReflectionPostProcess.js.map +1 -1
- package/PostProcesses/volumetricLightScatteringPostProcess.js +4 -7
- package/PostProcesses/volumetricLightScatteringPostProcess.js.map +1 -1
- package/PostProcesses/vrMultiviewToSingleviewPostProcess.js +1 -1
- package/PostProcesses/vrMultiviewToSingleviewPostProcess.js.map +1 -1
- package/Probes/reflectionProbe.js +2 -4
- package/Probes/reflectionProbe.js.map +1 -1
- package/Rendering/GlobalIllumination/giRSMManager.js +22 -19
- package/Rendering/GlobalIllumination/giRSMManager.js.map +1 -1
- package/Rendering/boundingBoxRenderer.js +2 -3
- package/Rendering/boundingBoxRenderer.js.map +1 -1
- package/Rendering/depthPeelingRenderer.js +2 -4
- package/Rendering/depthPeelingRenderer.js.map +1 -1
- package/Rendering/depthPeelingSceneComponent.js +2 -4
- package/Rendering/depthPeelingSceneComponent.js.map +1 -1
- package/Rendering/depthRenderer.js +10 -13
- package/Rendering/depthRenderer.js.map +1 -1
- package/Rendering/edgesRenderer.js +8 -11
- package/Rendering/edgesRenderer.js.map +1 -1
- package/Rendering/fluidRenderer/fluidRenderer.js +6 -11
- package/Rendering/fluidRenderer/fluidRenderer.js.map +1 -1
- package/Rendering/fluidRenderer/fluidRenderingObject.js +3 -5
- package/Rendering/fluidRenderer/fluidRenderingObject.js.map +1 -1
- package/Rendering/fluidRenderer/fluidRenderingObjectCustomParticles.js +2 -4
- package/Rendering/fluidRenderer/fluidRenderingObjectCustomParticles.js.map +1 -1
- package/Rendering/fluidRenderer/fluidRenderingTargetRenderer.js +30 -36
- package/Rendering/fluidRenderer/fluidRenderingTargetRenderer.js.map +1 -1
- package/Rendering/fluidRenderer/fluidRenderingTextures.js +5 -7
- package/Rendering/fluidRenderer/fluidRenderingTextures.js.map +1 -1
- package/Rendering/geometryBufferRenderer.js +3 -2
- package/Rendering/geometryBufferRenderer.js.map +1 -1
- package/Rendering/outlineRenderer.js +5 -4
- package/Rendering/outlineRenderer.js.map +1 -1
- package/Rendering/prePassRenderer.js +3 -6
- package/Rendering/prePassRenderer.js.map +1 -1
- package/Rendering/reflectiveShadowMap.d.ts +1 -0
- package/Rendering/reflectiveShadowMap.js +5 -5
- package/Rendering/reflectiveShadowMap.js.map +1 -1
- package/Shaders/color.fragment.d.ts +2 -0
- package/Shaders/color.fragment.js +4 -0
- package/Shaders/color.fragment.js.map +1 -1
- package/Shaders/color.vertex.d.ts +2 -0
- package/Shaders/color.vertex.js +7 -0
- package/Shaders/color.vertex.js.map +1 -1
- package/Shaders/gpuRenderParticles.fragment.d.ts +2 -0
- package/Shaders/gpuRenderParticles.fragment.js +4 -0
- package/Shaders/gpuRenderParticles.fragment.js.map +1 -1
- package/Shaders/gpuRenderParticles.vertex.d.ts +2 -0
- package/Shaders/gpuRenderParticles.vertex.js +5 -1
- package/Shaders/gpuRenderParticles.vertex.js.map +1 -1
- package/Shaders/particles.fragment.d.ts +2 -0
- package/Shaders/particles.fragment.js +4 -0
- package/Shaders/particles.fragment.js.map +1 -1
- package/Shaders/particles.vertex.d.ts +2 -0
- package/Shaders/particles.vertex.js +5 -1
- package/Shaders/particles.vertex.js.map +1 -1
- package/Sprites/spriteManager.js +1 -2
- package/Sprites/spriteManager.js.map +1 -1
- package/Sprites/spriteRenderer.js +5 -7
- package/Sprites/spriteRenderer.js.map +1 -1
- package/States/stencilStateComposer.js +2 -4
- package/States/stencilStateComposer.js.map +1 -1
- package/XR/features/WebXRAbstractFeature.js +6 -2
- package/XR/features/WebXRAbstractFeature.js.map +1 -1
- package/XR/features/WebXRAnchorSystem.js +1 -2
- package/XR/features/WebXRAnchorSystem.js.map +1 -1
- package/XR/features/WebXRControllerMovement.js +6 -7
- package/XR/features/WebXRControllerMovement.js.map +1 -1
- package/XR/features/WebXRControllerPhysics.js +17 -10
- package/XR/features/WebXRControllerPhysics.js.map +1 -1
- package/XR/features/WebXRControllerPointerSelection.js +1 -2
- package/XR/features/WebXRControllerPointerSelection.js.map +1 -1
- package/XR/features/WebXRControllerTeleportation.d.ts +1 -0
- package/XR/features/WebXRControllerTeleportation.js +6 -3
- package/XR/features/WebXRControllerTeleportation.js.map +1 -1
- package/XR/features/WebXRDepthSensing.js +3 -5
- package/XR/features/WebXRDepthSensing.js.map +1 -1
- package/XR/features/WebXRHandTracking.d.ts +1 -0
- package/XR/features/WebXRHandTracking.js +31 -28
- package/XR/features/WebXRHandTracking.js.map +1 -1
- package/XR/features/WebXRLayers.js +9 -11
- package/XR/features/WebXRLayers.js.map +1 -1
- package/XR/features/WebXRLightEstimation.js +3 -6
- package/XR/features/WebXRLightEstimation.js.map +1 -1
- package/XR/features/WebXRMeshDetector.js +2 -4
- package/XR/features/WebXRMeshDetector.js.map +1 -1
- package/XR/features/WebXRNearInteraction.js +21 -18
- package/XR/features/WebXRNearInteraction.js.map +1 -1
- package/XR/features/WebXRPlaneDetector.js +1 -2
- package/XR/features/WebXRPlaneDetector.js.map +1 -1
- package/XR/features/WebXRRawCameraAccess.js +2 -3
- package/XR/features/WebXRRawCameraAccess.js.map +1 -1
- package/XR/features/WebXRSpaceWarp.js +1 -1
- package/XR/features/WebXRSpaceWarp.js.map +1 -1
- package/XR/motionController/webXRAbstractMotionController.js +4 -1
- package/XR/motionController/webXRAbstractMotionController.js.map +1 -1
- package/XR/native/nativeXRFrame.js +1 -2
- package/XR/native/nativeXRFrame.js.map +1 -1
- package/XR/webXRCamera.js +1 -2
- package/XR/webXRCamera.js.map +1 -1
- package/XR/webXRDefaultExperience.js +28 -6
- package/XR/webXRDefaultExperience.js.map +1 -1
- package/XR/webXRExperienceHelper.js +5 -7
- package/XR/webXRExperienceHelper.js.map +1 -1
- package/XR/webXRFeaturesManager.js +4 -1
- package/XR/webXRFeaturesManager.js.map +1 -1
- package/XR/webXRInput.js +6 -1
- package/XR/webXRInput.js.map +1 -1
- package/XR/webXRInputSource.js +1 -2
- package/XR/webXRInputSource.js.map +1 -1
- package/XR/webXRSessionManager.js +16 -29
- package/XR/webXRSessionManager.js.map +1 -1
- package/assetContainer.js +4 -1
- package/assetContainer.js.map +1 -1
- package/package.json +1 -1
- package/scene.js +18 -17
- package/scene.js.map +1 -1
|
@@ -33,10 +33,9 @@ export class FlowGraphMeshPickEventBlock extends FlowGraphEventBlock {
|
|
|
33
33
|
const mesh = this._getReferencedMesh();
|
|
34
34
|
context._setExecutionVariable(this, "mesh", mesh);
|
|
35
35
|
pickObserver = mesh.getScene().onPointerObservable.add((pointerInfo) => {
|
|
36
|
-
var _a, _b, _c;
|
|
37
36
|
if (pointerInfo.type === PointerEventTypes.POINTERPICK &&
|
|
38
|
-
|
|
39
|
-
(
|
|
37
|
+
pointerInfo.pickInfo?.pickedMesh &&
|
|
38
|
+
(pointerInfo.pickInfo?.pickedMesh === mesh || _isADescendantOf(pointerInfo.pickInfo?.pickedMesh, mesh))) {
|
|
40
39
|
this._execute(context);
|
|
41
40
|
}
|
|
42
41
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flowGraphMeshPickEventBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAGlE,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAgB/C;;;GAGG;AACH,MAAM,OAAO,2BAA4B,SAAQ,mBAAmB;IAChE;IACI;;OAEG;IACI,MAAiD;QAExD,KAAK,CAAC,MAAM,CAAC,CAAC;QAFP,WAAM,GAAN,MAAM,CAA2C;IAG5D,CAAC;IAEM,kBAAkB;QACrB,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAEtE,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,MAAM,CAAiB,CAAC;QACxE,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,YAAY,YAAY,CAAC,EAAE;YAC1C,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;SAClE;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;OAEG;IACI,oBAAoB,CAAC,OAAyB;QACjD,IAAI,YAAY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C,qBAAqB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACzD,MAAM,YAAY,GAAG,OAAO,CAAC,qBAAqB,CAAC,IAAI,EAAE,kBAAkB,CAAC,CAAC;QAC7E,MAAM,eAAe,GAAG,OAAO,CAAC,qBAAqB,CAAC,IAAI,EAAE,qBAAqB,CAAC,CAAC;QAEnF,IAAI,CAAC,QAAQ,EAAE,CAAC,mBAAmB,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;QACzD,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;QAEjD,OAAO,CAAC,wBAAwB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAC/C,OAAO,CAAC,wBAAwB,CAAC,IAAI,EAAE,kBAAkB,CAAC,CAAC;QAC3D,OAAO,CAAC,wBAAwB,CAAC,IAAI,EAAE,qBAAqB,CAAC,CAAC;IAClE,CAAC;IAED;;OAEG;IACI,YAAY;QACf,OAAO,2BAA2B,CAAC,SAAS,CAAC;IACjD,CAAC;IAED;;;OAGG;IACI,SAAS,CAAC,mBAAyB;QACtC,KAAK,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAAC;QACrC,mBAAmB,CAAC,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IACvD,CAAC;;AAED;;GAEG;AACW,qCAAS,GAAG,sBAAsB,CAAC;AAErD,aAAa,CAAC,2BAA2B,CAAC,SAAS,EAAE,2BAA2B,CAAC,CAAC","sourcesContent":["import { AbstractMesh } from \"../../../Meshes/abstractMesh\";\r\nimport { FlowGraphEventBlock } from \"../../flowGraphEventBlock\";\r\nimport { PointerEventTypes } from \"../../../Events/pointerEvents\";\r\nimport type { FlowGraphContext } from \"../../flowGraphContext\";\r\nimport type { IFlowGraphBlockConfiguration } from \"../../flowGraphBlock\";\r\nimport { RegisterClass } from \"../../../Misc/typeStore\";\r\nimport { _isADescendantOf } from \"../../utils\";\r\nimport type { IPathToObjectConverter } from \"../../../ObjectModel/objectModelInterfaces\";\r\nimport type { IObjectAccessor } from \"../../typeDefinitions\";\r\n/**\r\n * @experimental\r\n */\r\nexport interface IFlowGraphMeshPickEventBlockConfiguration extends IFlowGraphBlockConfiguration {\r\n /**\r\n * The path of the mesh to pick.\r\n */\r\n path: string;\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 * @experimental\r\n * A block that activates when a mesh is picked.\r\n */\r\nexport class FlowGraphMeshPickEventBlock extends FlowGraphEventBlock {\r\n public constructor(\r\n /**\r\n * the configuration of the block\r\n */\r\n public config: IFlowGraphMeshPickEventBlockConfiguration\r\n ) {\r\n super(config);\r\n }\r\n\r\n public _getReferencedMesh(): AbstractMesh {\r\n const iAccessor = this.config.pathConverter.convert(this.config.path);\r\n\r\n const mesh = iAccessor.info.getObject(iAccessor.object) as AbstractMesh;\r\n if (!mesh || !(mesh instanceof AbstractMesh)) {\r\n throw new Error(\"Mesh pick event block requires a valid mesh\");\r\n }\r\n return mesh;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _preparePendingTasks(context: FlowGraphContext): void {\r\n let pickObserver = context._getExecutionVariable(this, \"meshPickObserver\");\r\n if (!pickObserver) {\r\n const mesh = this._getReferencedMesh();\r\n context._setExecutionVariable(this, \"mesh\", mesh);\r\n pickObserver = mesh.getScene().onPointerObservable.add((pointerInfo) => {\r\n if (\r\n pointerInfo.type === PointerEventTypes.POINTERPICK &&\r\n pointerInfo.pickInfo?.pickedMesh &&\r\n (pointerInfo.pickInfo?.pickedMesh === mesh || _isADescendantOf(pointerInfo.pickInfo?.pickedMesh, mesh))\r\n ) {\r\n this._execute(context);\r\n }\r\n });\r\n const disposeObserver = mesh.onDisposeObservable.add(() => this._onDispose);\r\n context._setExecutionVariable(this, \"meshPickObserver\", pickObserver);\r\n context._setExecutionVariable(this, \"meshDisposeObserver\", disposeObserver);\r\n }\r\n }\r\n\r\n public _onDispose(context: FlowGraphContext) {\r\n this._cancelPendingTasks(context);\r\n context._removePendingBlock(this);\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _cancelPendingTasks(context: FlowGraphContext): void {\r\n const mesh = context._getExecutionVariable(this, \"mesh\");\r\n const pickObserver = context._getExecutionVariable(this, \"meshPickObserver\");\r\n const disposeObserver = context._getExecutionVariable(this, \"meshDisposeObserver\");\r\n\r\n mesh.getScene().onPointerObservable.remove(pickObserver);\r\n mesh.onDisposeObservable.remove(disposeObserver);\r\n\r\n context._deleteExecutionVariable(this, \"mesh\");\r\n context._deleteExecutionVariable(this, \"meshPickObserver\");\r\n context._deleteExecutionVariable(this, \"meshDisposeObserver\");\r\n }\r\n\r\n /**\r\n * @returns class name of the block.\r\n */\r\n public getClassName(): string {\r\n return FlowGraphMeshPickEventBlock.ClassName;\r\n }\r\n\r\n /**\r\n * Serializes the block to a JSON object.\r\n * @param serializationObject the object to serialize to.\r\n */\r\n public serialize(serializationObject?: any): void {\r\n super.serialize(serializationObject);\r\n serializationObject.config.path = this.config.path;\r\n }\r\n\r\n /**\r\n * Class name of the block.\r\n */\r\n public static ClassName = \"FGMeshPickEventBlock\";\r\n}\r\nRegisterClass(FlowGraphMeshPickEventBlock.ClassName, FlowGraphMeshPickEventBlock);\r\n"]}
|
|
@@ -27,7 +27,6 @@ export class FlowGraphPlayAnimationBlock extends FlowGraphAsyncExecutionBlock {
|
|
|
27
27
|
* @param context
|
|
28
28
|
*/
|
|
29
29
|
_preparePendingTasks(context) {
|
|
30
|
-
var _a;
|
|
31
30
|
const targetAccessor = this.templateTargetComponent.getAccessor(this.config.pathConverter, context);
|
|
32
31
|
const targetValue = targetAccessor.info.getObject(targetAccessor.object);
|
|
33
32
|
const animationAccessor = this.templateAnimationComponent.getAccessor(this.config.pathConverter, context);
|
|
@@ -35,7 +34,7 @@ export class FlowGraphPlayAnimationBlock extends FlowGraphAsyncExecutionBlock {
|
|
|
35
34
|
if (!targetValue || !animationValue) {
|
|
36
35
|
throw new Error("Cannot play animation without target or animation");
|
|
37
36
|
}
|
|
38
|
-
const contextAnimatables =
|
|
37
|
+
const contextAnimatables = context._getExecutionVariable(this, "runningAnimatables") ?? [];
|
|
39
38
|
// was an animation started on this target already and was just paused? if so, we can unpause it.
|
|
40
39
|
const existingAnimatable = this.runningAnimatable.getValue(context);
|
|
41
40
|
if (existingAnimatable && existingAnimatable.paused) {
|
|
@@ -54,8 +53,7 @@ export class FlowGraphPlayAnimationBlock extends FlowGraphAsyncExecutionBlock {
|
|
|
54
53
|
this.out._activateSignal(context);
|
|
55
54
|
}
|
|
56
55
|
_onAnimationEnd(animatable, context) {
|
|
57
|
-
|
|
58
|
-
const contextAnims = (_a = context._getExecutionVariable(this, "runningAnimatables")) !== null && _a !== void 0 ? _a : [];
|
|
56
|
+
const contextAnims = context._getExecutionVariable(this, "runningAnimatables") ?? [];
|
|
59
57
|
const index = contextAnims.indexOf(animatable);
|
|
60
58
|
if (index !== -1) {
|
|
61
59
|
contextAnims.splice(index, 1);
|
|
@@ -68,8 +66,7 @@ export class FlowGraphPlayAnimationBlock extends FlowGraphAsyncExecutionBlock {
|
|
|
68
66
|
* Stop any currently running animations.
|
|
69
67
|
*/
|
|
70
68
|
_cancelPendingTasks(context) {
|
|
71
|
-
|
|
72
|
-
const contextAnims = (_a = context._getExecutionVariable(this, "runningAnimatables")) !== null && _a !== void 0 ? _a : [];
|
|
69
|
+
const contextAnims = context._getExecutionVariable(this, "runningAnimatables") ?? [];
|
|
73
70
|
for (const anim of contextAnims) {
|
|
74
71
|
anim.stop();
|
|
75
72
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flowGraphPlayAnimationBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,4BAA4B,EAAE,MAAM,uCAAuC,CAAC;AACrF,OAAO,EAAE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a,GAAG,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC;IACzE,CAAC;;AAED;;GAEG;AACW,qCAAS,GAAG,sBAAsB,CAAC;AAGrD,aAAa,CAAC,2BAA2B,CAAC,SAAS,EAAE,2BAA2B,CAAC,CAAC","sourcesContent":["import type { FlowGraphContext } from \"../../../flowGraphContext\";\r\nimport type { Animatable } from \"../../../../Animations/animatable\";\r\nimport type { FlowGraphDataConnection } from \"../../../flowGraphDataConnection\";\r\nimport { FlowGraphAsyncExecutionBlock } from \"../../../flowGraphAsyncExecutionBlock\";\r\nimport { RichTypeAny, RichTypeNumber, RichTypeBoolean } from \"../../../flowGraphRichTypes\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport type { IFlowGraphBlockConfiguration } from \"../../../flowGraphBlock\";\r\nimport type { IPathToObjectConverter } from \"../../../../ObjectModel/objectModelInterfaces\";\r\nimport { FlowGraphPathConverterComponent } from \"../../../flowGraphPathConverterComponent\";\r\nimport type { IObjectAccessor } from \"../../../typeDefinitions\";\r\n\r\n/**\r\n * @experimental\r\n */\r\nexport interface IFlowGraphPlayAnimationBlockConfiguration extends IFlowGraphBlockConfiguration {\r\n /**\r\n * The path to the target object that will be animated.\r\n */\r\n targetPath: string;\r\n /**\r\n * The path to the animation that will be played.\r\n */\r\n animationPath: string;\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 * @experimental\r\n * A block that plays an animation on an animatable object.\r\n */\r\nexport class FlowGraphPlayAnimationBlock extends FlowGraphAsyncExecutionBlock {\r\n /**\r\n * The substitution inputs for template strings in the target\r\n */\r\n public readonly templateTargetComponent: FlowGraphPathConverterComponent;\r\n /**\r\n * The substitution inputs for template strings in the animation\r\n */\r\n public readonly templateAnimationComponent: FlowGraphPathConverterComponent;\r\n /**\r\n * Input connection: The speed of the animation.\r\n */\r\n public readonly speed: FlowGraphDataConnection<number>;\r\n /**\r\n * Input connection: Should the animation loop?\r\n */\r\n public readonly loop: FlowGraphDataConnection<boolean>;\r\n /**\r\n * Input connection: The starting frame of the animation.\r\n */\r\n public readonly from: FlowGraphDataConnection<number>;\r\n /**\r\n * Input connection: The ending frame of the animation.\r\n */\r\n public readonly to: FlowGraphDataConnection<number>;\r\n\r\n /**\r\n * Output connection: The animatable that is currently running.\r\n */\r\n public readonly runningAnimatable: FlowGraphDataConnection<Animatable>;\r\n\r\n public constructor(\r\n /**\r\n * the configuration of the block\r\n */\r\n public config: IFlowGraphPlayAnimationBlockConfiguration\r\n ) {\r\n super(config);\r\n\r\n this.templateTargetComponent = new FlowGraphPathConverterComponent(config.targetPath, this);\r\n this.templateAnimationComponent = new FlowGraphPathConverterComponent(config.animationPath, this);\r\n\r\n this.speed = this.registerDataInput(\"speed\", RichTypeNumber);\r\n this.loop = this.registerDataInput(\"loop\", RichTypeBoolean);\r\n this.from = this.registerDataInput(\"from\", RichTypeNumber);\r\n this.to = this.registerDataInput(\"to\", RichTypeNumber);\r\n\r\n this.runningAnimatable = this.registerDataOutput(\"runningAnimatable\", RichTypeAny);\r\n }\r\n\r\n /**\r\n * @internal\r\n * @param context\r\n */\r\n public _preparePendingTasks(context: FlowGraphContext): void {\r\n const targetAccessor = this.templateTargetComponent.getAccessor(this.config.pathConverter, context);\r\n const targetValue = targetAccessor.info.getObject(targetAccessor.object);\r\n const animationAccessor = this.templateAnimationComponent.getAccessor(this.config.pathConverter, context);\r\n const animationValue = animationAccessor.info.get(animationAccessor.object);\r\n\r\n if (!targetValue || !animationValue) {\r\n throw new Error(\"Cannot play animation without target or animation\");\r\n }\r\n\r\n const contextAnimatables = (context._getExecutionVariable(this, \"runningAnimatables\") as Animatable[]) ?? [];\r\n\r\n // was an animation started on this target already and was just paused? if so, we can unpause it.\r\n const existingAnimatable = this.runningAnimatable.getValue(context);\r\n if (existingAnimatable && existingAnimatable.paused) {\r\n existingAnimatable.restart();\r\n } else {\r\n const scene = context.configuration.scene;\r\n const animatable = scene.beginDirectAnimation(\r\n targetValue,\r\n [animationValue],\r\n this.from.getValue(context),\r\n this.to.getValue(context),\r\n this.loop.getValue(context),\r\n this.speed.getValue(context),\r\n () => this._onAnimationEnd(animatable, context)\r\n );\r\n this.runningAnimatable.setValue(animatable, context);\r\n contextAnimatables.push(animatable);\r\n }\r\n\r\n context._setExecutionVariable(this, \"runningAnimatables\", contextAnimatables);\r\n }\r\n\r\n public _execute(context: FlowGraphContext): void {\r\n this._startPendingTasks(context);\r\n\r\n this.out._activateSignal(context);\r\n }\r\n\r\n private _onAnimationEnd(animatable: Animatable, context: FlowGraphContext) {\r\n const contextAnims = (context._getExecutionVariable(this, \"runningAnimatables\") as Animatable[]) ?? [];\r\n const index = contextAnims.indexOf(animatable);\r\n if (index !== -1) {\r\n contextAnims.splice(index, 1);\r\n }\r\n context._removePendingBlock(this);\r\n this.done._activateSignal(context);\r\n }\r\n\r\n /**\r\n * @internal\r\n * Stop any currently running animations.\r\n */\r\n public _cancelPendingTasks(context: FlowGraphContext): void {\r\n const contextAnims = (context._getExecutionVariable(this, \"runningAnimatables\") as Animatable[]) ?? [];\r\n for (const anim of contextAnims) {\r\n anim.stop();\r\n }\r\n context._deleteExecutionVariable(this, \"runningAnimatables\");\r\n }\r\n\r\n /**\r\n * @returns class name of the block.\r\n */\r\n public getClassName(): string {\r\n return FlowGraphPlayAnimationBlock.ClassName;\r\n }\r\n\r\n /**\r\n * Serializes the block to a JSON object.\r\n * @param serializationObject the object to serialize to.\r\n */\r\n public serialize(serializationObject: any = {}) {\r\n super.serialize(serializationObject);\r\n serializationObject.config.targetPath = this.config.targetPath;\r\n serializationObject.config.animationPath = this.config.animationPath;\r\n }\r\n\r\n /**\r\n * Class name of the block.\r\n */\r\n public static ClassName = \"FGPlayAnimationBlock\";\r\n}\r\n\r\nRegisterClass(FlowGraphPlayAnimationBlock.ClassName, FlowGraphPlayAnimationBlock);\r\n"]}
|
|
1
|
+
{"version":3,"file":"flowGraphPlayAnimation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,CAAC,mBAAmB,CAAC,CAAC;QACrC,mBAAmB,CAAC,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC;QAC/D,mBAAmB,CAAC,MAAM,CAAC,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC;IACzE,CAAC;;AAED;;GAEG;AACW,qCAAS,GAAG,sBAAsB,CAAC;AAGrD,aAAa,CAAC,2BAA2B,CAAC,SAAS,EAAE,2BAA2B,CAAC,CAAC","sourcesContent":["import type { FlowGraphContext } from \"../../../flowGraphContext\";\r\nimport type { Animatable } from \"../../../../Animations/animatable\";\r\nimport type { FlowGraphDataConnection } from \"../../../flowGraphDataConnection\";\r\nimport { FlowGraphAsyncExecutionBlock } from \"../../../flowGraphAsyncExecutionBlock\";\r\nimport { RichTypeAny, RichTypeNumber, RichTypeBoolean } from \"../../../flowGraphRichTypes\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport type { IFlowGraphBlockConfiguration } from \"../../../flowGraphBlock\";\r\nimport type { IPathToObjectConverter } from \"../../../../ObjectModel/objectModelInterfaces\";\r\nimport { FlowGraphPathConverterComponent } from \"../../../flowGraphPathConverterComponent\";\r\nimport type { IObjectAccessor } from \"../../../typeDefinitions\";\r\n\r\n/**\r\n * @experimental\r\n */\r\nexport interface IFlowGraphPlayAnimationBlockConfiguration extends IFlowGraphBlockConfiguration {\r\n /**\r\n * The path to the target object that will be animated.\r\n */\r\n targetPath: string;\r\n /**\r\n * The path to the animation that will be played.\r\n */\r\n animationPath: string;\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 * @experimental\r\n * A block that plays an animation on an animatable object.\r\n */\r\nexport class FlowGraphPlayAnimationBlock extends FlowGraphAsyncExecutionBlock {\r\n /**\r\n * The substitution inputs for template strings in the target\r\n */\r\n public readonly templateTargetComponent: FlowGraphPathConverterComponent;\r\n /**\r\n * The substitution inputs for template strings in the animation\r\n */\r\n public readonly templateAnimationComponent: FlowGraphPathConverterComponent;\r\n /**\r\n * Input connection: The speed of the animation.\r\n */\r\n public readonly speed: FlowGraphDataConnection<number>;\r\n /**\r\n * Input connection: Should the animation loop?\r\n */\r\n public readonly loop: FlowGraphDataConnection<boolean>;\r\n /**\r\n * Input connection: The starting frame of the animation.\r\n */\r\n public readonly from: FlowGraphDataConnection<number>;\r\n /**\r\n * Input connection: The ending frame of the animation.\r\n */\r\n public readonly to: FlowGraphDataConnection<number>;\r\n\r\n /**\r\n * Output connection: The animatable that is currently running.\r\n */\r\n public readonly runningAnimatable: FlowGraphDataConnection<Animatable>;\r\n\r\n public constructor(\r\n /**\r\n * the configuration of the block\r\n */\r\n public config: IFlowGraphPlayAnimationBlockConfiguration\r\n ) {\r\n super(config);\r\n\r\n this.templateTargetComponent = new FlowGraphPathConverterComponent(config.targetPath, this);\r\n this.templateAnimationComponent = new FlowGraphPathConverterComponent(config.animationPath, this);\r\n\r\n this.speed = this.registerDataInput(\"speed\", RichTypeNumber);\r\n this.loop = this.registerDataInput(\"loop\", RichTypeBoolean);\r\n this.from = this.registerDataInput(\"from\", RichTypeNumber);\r\n this.to = this.registerDataInput(\"to\", RichTypeNumber);\r\n\r\n this.runningAnimatable = this.registerDataOutput(\"runningAnimatable\", RichTypeAny);\r\n }\r\n\r\n /**\r\n * @internal\r\n * @param context\r\n */\r\n public _preparePendingTasks(context: FlowGraphContext): void {\r\n const targetAccessor = this.templateTargetComponent.getAccessor(this.config.pathConverter, context);\r\n const targetValue = targetAccessor.info.getObject(targetAccessor.object);\r\n const animationAccessor = this.templateAnimationComponent.getAccessor(this.config.pathConverter, context);\r\n const animationValue = animationAccessor.info.get(animationAccessor.object);\r\n\r\n if (!targetValue || !animationValue) {\r\n throw new Error(\"Cannot play animation without target or animation\");\r\n }\r\n\r\n const contextAnimatables = (context._getExecutionVariable(this, \"runningAnimatables\") as Animatable[]) ?? [];\r\n\r\n // was an animation started on this target already and was just paused? if so, we can unpause it.\r\n const existingAnimatable = this.runningAnimatable.getValue(context);\r\n if (existingAnimatable && existingAnimatable.paused) {\r\n existingAnimatable.restart();\r\n } else {\r\n const scene = context.configuration.scene;\r\n const animatable = scene.beginDirectAnimation(\r\n targetValue,\r\n [animationValue],\r\n this.from.getValue(context),\r\n this.to.getValue(context),\r\n this.loop.getValue(context),\r\n this.speed.getValue(context),\r\n () => this._onAnimationEnd(animatable, context)\r\n );\r\n this.runningAnimatable.setValue(animatable, context);\r\n contextAnimatables.push(animatable);\r\n }\r\n\r\n context._setExecutionVariable(this, \"runningAnimatables\", contextAnimatables);\r\n }\r\n\r\n public _execute(context: FlowGraphContext): void {\r\n this._startPendingTasks(context);\r\n\r\n this.out._activateSignal(context);\r\n }\r\n\r\n private _onAnimationEnd(animatable: Animatable, context: FlowGraphContext) {\r\n const contextAnims = (context._getExecutionVariable(this, \"runningAnimatables\") as Animatable[]) ?? [];\r\n const index = contextAnims.indexOf(animatable);\r\n if (index !== -1) {\r\n contextAnims.splice(index, 1);\r\n }\r\n context._removePendingBlock(this);\r\n this.done._activateSignal(context);\r\n }\r\n\r\n /**\r\n * @internal\r\n * Stop any currently running animations.\r\n */\r\n public _cancelPendingTasks(context: FlowGraphContext): void {\r\n const contextAnims = (context._getExecutionVariable(this, \"runningAnimatables\") as Animatable[]) ?? [];\r\n for (const anim of contextAnims) {\r\n anim.stop();\r\n }\r\n context._deleteExecutionVariable(this, \"runningAnimatables\");\r\n }\r\n\r\n /**\r\n * @returns class name of the block.\r\n */\r\n public getClassName(): string {\r\n return FlowGraphPlayAnimationBlock.ClassName;\r\n }\r\n\r\n /**\r\n * Serializes the block to a JSON object.\r\n * @param serializationObject the object to serialize to.\r\n */\r\n public serialize(serializationObject: any = {}) {\r\n super.serialize(serializationObject);\r\n serializationObject.config.targetPath = this.config.targetPath;\r\n serializationObject.config.animationPath = this.config.animationPath;\r\n }\r\n\r\n /**\r\n * Class name of the block.\r\n */\r\n public static ClassName = \"FGPlayAnimationBlock\";\r\n}\r\n\r\nRegisterClass(FlowGraphPlayAnimationBlock.ClassName, FlowGraphPlayAnimationBlock);\r\n"]}
|
|
@@ -12,13 +12,12 @@ export class FlowGraphCounterBlock extends FlowGraphExecutionBlockWithOutSignal
|
|
|
12
12
|
this.reset = this._registerSignalInput("reset");
|
|
13
13
|
}
|
|
14
14
|
_execute(context, callingSignal) {
|
|
15
|
-
var _a;
|
|
16
15
|
if (callingSignal === this.reset) {
|
|
17
16
|
context._setExecutionVariable(this, "count", 0);
|
|
18
17
|
this.count.setValue(0, context);
|
|
19
18
|
return;
|
|
20
19
|
}
|
|
21
|
-
const countValue = (
|
|
20
|
+
const countValue = (context._getExecutionVariable(this, "count") ?? 0) + 1;
|
|
22
21
|
context._setExecutionVariable(this, "count", countValue);
|
|
23
22
|
this.count.setValue(countValue, context);
|
|
24
23
|
this.out._activateSignal(context);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flowGraphCounterBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCounterBlock.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE7D,OAAO,EAAE,oCAAoC,EAAE,MAAM,+CAA+C,CAAC;AACrG,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D;;;GAGG;AACH,MAAM,OAAO,qBAAsB,SAAQ,oCAAoC;IAU3E,YAAY,MAAqC;QAC7C,KAAK,CAAC,MAAM,CAAC,CAAC;QAEd,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;QAC9D,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;IACpD,CAAC;IAEM,QAAQ,CAAC,OAAyB,EAAE,aAAwC
|
|
1
|
+
{"version":3,"file":"flowG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B,EAAE,qBAAqB,CAAC,CAAC","sourcesContent":["import type { FlowGraphContext } from \"../../../flowGraphContext\";\r\nimport type { FlowGraphDataConnection } from \"../../../flowGraphDataConnection\";\r\nimport { RichTypeNumber } from \"../../../flowGraphRichTypes\";\r\nimport type { FlowGraphSignalConnection } from \"../../../flowGraphSignalConnection\";\r\nimport { FlowGraphExecutionBlockWithOutSignal } from \"../../../flowGraphExecutionBlockWithOutSignal\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport type { IFlowGraphBlockConfiguration } from \"../../../flowGraphBlock\";\r\n/**\r\n * @experimental\r\n * A block that counts the number of times it has been called.\r\n */\r\nexport class FlowGraphCounterBlock extends FlowGraphExecutionBlockWithOutSignal {\r\n /**\r\n * Output connection: The number of times the block has been called.\r\n */\r\n public readonly count: FlowGraphDataConnection<number>;\r\n /**\r\n * Input connection: Resets the counter.\r\n */\r\n public readonly reset: FlowGraphSignalConnection;\r\n\r\n constructor(config?: IFlowGraphBlockConfiguration) {\r\n super(config);\r\n\r\n this.count = this.registerDataOutput(\"count\", RichTypeNumber);\r\n this.reset = this._registerSignalInput(\"reset\");\r\n }\r\n\r\n public _execute(context: FlowGraphContext, callingSignal: FlowGraphSignalConnection): void {\r\n if (callingSignal === this.reset) {\r\n context._setExecutionVariable(this, \"count\", 0);\r\n this.count.setValue(0, context);\r\n return;\r\n }\r\n const countValue = (context._getExecutionVariable(this, \"count\") ?? 0) + 1;\r\n\r\n context._setExecutionVariable(this, \"count\", countValue);\r\n this.count.setValue(countValue, context);\r\n this.out._activateSignal(context);\r\n }\r\n\r\n /**\r\n * @returns class name of the block.\r\n */\r\n public getClassName(): string {\r\n return \"FGCounterBlock\";\r\n }\r\n}\r\nRegisterClass(\"FGCounterBlock\", FlowGraphCounterBlock);\r\n"]}
|
|
@@ -50,8 +50,7 @@ export class FlowGraphMultiGateBlock extends FlowGraphExecutionBlock {
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
_execute(context, callingSignal) {
|
|
53
|
-
|
|
54
|
-
const currentIndex = (_a = context._getExecutionVariable(this, "currentIndex")) !== null && _a !== void 0 ? _a : this.config.startIndex - 1;
|
|
53
|
+
const currentIndex = context._getExecutionVariable(this, "currentIndex") ?? this.config.startIndex - 1;
|
|
55
54
|
let unusedIndexes = this._getUnusedIndexes(context);
|
|
56
55
|
if (callingSignal === this.reset) {
|
|
57
56
|
context._deleteExecutionVariable(this, "currentIndex");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flowGraphMultiGateBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/FlowGraph/Blocks/Execution/ControlFlow/flowGraphMultiGateBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAG3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAyB7D;;;;GAIG;AACH,MAAM,OAAO,uBAAwB,SAAQ,uBAAuB;IAehE;IACI;;OAEG;IACI,MAA6C;QAEpD,KAAK,CAAC,MAAM,CAAC,CAAC;QAFP,WAAM,GAAN,MAAM,CAAuC;QANhD,yBAAoB,GAAa,EAAE,CAAC;QASxC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;QAChD,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,kBAAkB,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC;QAC5E,IAAI,CAAC,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3F,IAAI,CAAC,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM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E,OAAO,aAAa,CAAC,SAAS,CAAC,CAAC;SACnC;aAAM;YACH,OAAO,YAAY,GAAG,CAAC,CAAC;SAC3B;IACL,CAAC;IAEM,QAAQ,CAAC,OAAyB,EAAE,aAAwC
|
|
1
|
+
{"version":3,"file":"flowGraphMultiGateBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/FlowGraph/Blocks/Execution/ControlFlow/flowGraphMultiGateBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAG3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAyB7D;;;;GAIG;AACH,MAAM,OAAO,uBAAwB,SAAQ,uBAAuB;IAehE;IACI;;OAEG;IACI,MAA6C;QAEpD,KAAK,CAAC,MAAM,CAAC,CAAC;QAFP,WAAM,GAAN,MAAM,CAAuC;QANhD,yBAAoB,GAAa,EAAE,CAAC;QASxC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;QAChD,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,kBAAkB,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC;QAC5E,IAAI,CAAC,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3F,IAAI,CAAC,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,UAAW,EAAE,IAAI,CAAC,MAAM,CAAC,iBAAiB,GAAG,CAAC,CAAC,CAAC,CAAC;QAC3G,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;QACnB,KAAK,IAAI,CAAC,GAAG,CA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AAE,OAAO,CAAC,CAAC;QAC/C,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IACtD,CAAC;IAED;;OAEG;IACI,YAAY;QACf,OAAO,kBAAkB,CAAC;IAC9B,CAAC;IAED;;;OAGG;IACI,SAAS,CAAC,mBAAyB;QACtC,KAAK,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAAC;QACrC,mBAAmB,CAAC,MAAM,CAAC,iBAAiB,GAAG,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC;QAC7E,mBAAmB,CAAC,MAAM,CAAC,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;QAC3D,mBAAmB,CAAC,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;QACnD,mBAAmB,CAAC,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC;IACnE,CAAC;CACJ;AACD,aAAa,CAAC,kBAAkB,EAAE,uBAAuB,CAAC,CAAC","sourcesContent":["import { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport type { FlowGraphContext } from \"../../../flowGraphContext\";\r\nimport type { FlowGraphDataConnection } from \"../../../flowGraphDataConnection\";\r\nimport { FlowGraphExecutionBlock } from \"../../../flowGraphExecutionBlock\";\r\nimport { RichTypeNumber } from \"../../../flowGraphRichTypes\";\r\nimport type { FlowGraphSignalConnection } from \"../../../flowGraphSignalConnection\";\r\nimport type { IFlowGraphBlockConfiguration } from \"../../../flowGraphBlock\";\r\n/**\r\n * @experimental\r\n * Configuration for the multi gate block.\r\n */\r\nexport interface IFlowGraphMultiGateBlockConfiguration extends IFlowGraphBlockConfiguration {\r\n /**\r\n * The number of output flows.\r\n */\r\n numberOutputFlows: number;\r\n /**\r\n * If the block should pick a random output flow from the ones that haven't been executed. Default to false.\r\n */\r\n isRandom?: boolean;\r\n /**\r\n * If the block should loop back to the first output flow after executing the last one. Default to false.\r\n */\r\n loop?: boolean;\r\n /**\r\n * The index of the output flow to start with. Default to 0.\r\n */\r\n startIndex?: number;\r\n}\r\n/**\r\n * @experimental\r\n * A block that has an input flow and routes it to any potential output flows, randomly or sequentially\r\n * @see https://docs.google.com/document/d/1MT7gL-IEn_PUw-4XGBazMxsyqsxqgAVGYcNeC4Cj_9Q/edit#heading=h.i2sn85fbjo60\r\n */\r\nexport class FlowGraphMultiGateBlock extends FlowGraphExecutionBlock {\r\n /**\r\n * Input connection: Resets the gate.\r\n */\r\n public readonly reset: FlowGraphSignalConnection;\r\n /**\r\n * Output connections: The output flows.\r\n */\r\n public outFlows: FlowGraphSignalConnection[];\r\n /**\r\n * Output connection: The index of the current output flow.\r\n */\r\n public readonly currentIndex: FlowGraphDataConnection<number>;\r\n private _cachedUnusedIndexes: number[] = [];\r\n\r\n constructor(\r\n /**\r\n * the configuration of the block\r\n */\r\n public config: IFlowGraphMultiGateBlockConfiguration\r\n ) {\r\n super(config);\r\n this.reset = this._registerSignalInput(\"reset\");\r\n this.currentIndex = this.registerDataOutput(\"currentIndex\", RichTypeNumber);\r\n this.config.startIndex = this.config.startIndex !== undefined ? this.config.startIndex : 0;\r\n this.config.startIndex = Math.max(0, Math.min(this.config.startIndex!, this.config.numberOutputFlows - 1));\r\n this.outFlows = [];\r\n for (let i = 0; i < this.config.numberOutputFlows; i++) {\r\n this.outFlows.push(this._registerSignalOutput(`out${i}`));\r\n }\r\n }\r\n\r\n private _getUnusedIndexes(context: FlowGraphContext): number[] {\r\n const result = this._cachedUnusedIndexes;\r\n result.length = 0;\r\n if (!context._hasExecutionVariable(this, \"unusedIndexes\")) {\r\n for (let i = 0; i < this.config.numberOutputFlows; i++) {\r\n result.push(i);\r\n }\r\n } else {\r\n const contextUnusedIndexes = context._getExecutionVariable(this, \"unusedIndexes\");\r\n for (let i = 0; i < contextUnusedIndexes.length; i++) {\r\n result.push(contextUnusedIndexes[i]);\r\n }\r\n }\r\n return result;\r\n }\r\n\r\n private _getNextOutput(currentIndex: number, unusedIndexes: number[]): number {\r\n if (this.config.isRandom) {\r\n const nextIndex = Math.floor(Math.random() * unusedIndexes.length);\r\n return unusedIndexes[nextIndex];\r\n } else {\r\n return currentIndex + 1;\r\n }\r\n }\r\n\r\n public _execute(context: FlowGraphContext, callingSignal: FlowGraphSignalConnection): void {\r\n const currentIndex = context._getExecutionVariable(this, \"currentIndex\") ?? this.config.startIndex! - 1;\r\n let unusedIndexes = this._getUnusedIndexes(context);\r\n\r\n if (callingSignal === this.reset) {\r\n context._deleteExecutionVariable(this, \"currentIndex\");\r\n context._deleteExecutionVariable(this, \"unusedIndexes\");\r\n return;\r\n }\r\n\r\n let nextIndex = this._getNextOutput(currentIndex, unusedIndexes);\r\n if (nextIndex >= this.config.numberOutputFlows && this.config.loop) {\r\n nextIndex = 0;\r\n } else if (nextIndex >= this.config.numberOutputFlows && !this.config.loop) {\r\n return;\r\n }\r\n\r\n unusedIndexes = unusedIndexes.filter((i) => i !== nextIndex);\r\n if (unusedIndexes.length === 0) {\r\n for (let i = 0; i < this.config.numberOutputFlows; i++) {\r\n unusedIndexes.push(i);\r\n }\r\n }\r\n context._setExecutionVariable(this, \"unusedIndexes\", unusedIndexes);\r\n context._setExecutionVariable(this, \"currentIndex\", nextIndex);\r\n this.currentIndex.setValue(nextIndex, context);\r\n this.outFlows[nextIndex]._activateSignal(context);\r\n }\r\n\r\n /**\r\n * @returns class name of the block.\r\n */\r\n public getClassName(): string {\r\n return \"FGMultiGateBlock\";\r\n }\r\n\r\n /**\r\n * Serializes the block.\r\n * @param serializationObject the object to serialize to.\r\n */\r\n public serialize(serializationObject?: any): void {\r\n super.serialize(serializationObject);\r\n serializationObject.config.numberOutputFlows = this.config.numberOutputFlows;\r\n serializationObject.config.isRandom = this.config.isRandom;\r\n serializationObject.config.loop = this.config.loop;\r\n serializationObject.config.startIndex = this.config.startIndex;\r\n }\r\n}\r\nRegisterClass(\"FGMultiGateBlock\", FlowGraphMultiGateBlock);\r\n"]}
|
|
@@ -17,9 +17,8 @@ export class FlowGraphWhileLoopBlock extends FlowGraphExecutionBlockWithOutSigna
|
|
|
17
17
|
this.loopBody = this._registerSignalOutput("loopBody");
|
|
18
18
|
}
|
|
19
19
|
_execute(context, _callingSignal) {
|
|
20
|
-
var _a;
|
|
21
20
|
let conditionValue = this.condition.getValue(context);
|
|
22
|
-
if (
|
|
21
|
+
if (this.config?.isDo && !conditionValue) {
|
|
23
22
|
this.loopBody._activateSignal(context);
|
|
24
23
|
}
|
|
25
24
|
while (conditionValue) {
|
|
@@ -39,9 +38,8 @@ export class FlowGraphWhileLoopBlock extends FlowGraphExecutionBlockWithOutSigna
|
|
|
39
38
|
* @param serializationObject the object to serialize to.
|
|
40
39
|
*/
|
|
41
40
|
serialize(serializationObject) {
|
|
42
|
-
var _a;
|
|
43
41
|
super.serialize(serializationObject);
|
|
44
|
-
serializationObject.isDo =
|
|
42
|
+
serializationObject.isDo = this.config?.isDo;
|
|
45
43
|
}
|
|
46
44
|
}
|
|
47
45
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flowGraphWhileLoopBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAG9D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,oCAAoC,EAAE,MAAM,+CAA+C,CAAC;AAYrG;;;GAGG;AACH,MAAM,OAAO,uBAAwB,SAAQ,oCAAoC;IAU7E;IACI;;OAEG;IACI,MAA8C;QAErD,KAAK,CAAC,MAAM,CAAC,CAAC;QAFP,WAAM,GAAN,MAAM,CAAwC;QAIrD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,iBAAiB,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC;QACtE,IAAI,CAAC,QAAQ,G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IACI,YAAY;QACf,OAAO,uBAAuB,CAAC,SAAS,CAAC;IAC7C,CAAC;IAOD;;;OAGG;IACI,SAAS,CAAC,mBAAyB;QACtC,KAAK,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAAC;QACrC,mBAAmB,CAAC,IAAI,GAAG,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC;IACjD,CAAC;;AAZD;;GAEG;AACW,iCAAS,GAAG,kBAAkB,CAAC;AAWjD,aAAa,CAAC,uBAAuB,CAAC,SAAS,EAAE,uBAAuB,CAAC,CAAC","sourcesContent":["import type { FlowGraphContext } from \"../../../flowGraphContext\";\r\nimport type { FlowGraphDataConnection } from \"../../../flowGraphDataConnection\";\r\nimport { RichTypeBoolean } from \"../../../flowGraphRichTypes\";\r\nimport type { FlowGraphSignalConnection } from \"../../../flowGraphSignalConnection\";\r\nimport type { IFlowGraphBlockConfiguration } from \"../../../flowGraphBlock\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { FlowGraphExecutionBlockWithOutSignal } from \"../../../flowGraphExecutionBlockWithOutSignal\";\r\n/**\r\n * @experimental\r\n * Configuration for the while loop block.\r\n */\r\nexport interface IFlowGraphWhileLoopBlockConfiguration extends IFlowGraphBlockConfiguration {\r\n /**\r\n * If true, the loop body will be executed at least once.\r\n */\r\n isDo?: boolean;\r\n}\r\n\r\n/**\r\n * @experimental\r\n * A block that executes a branch while a condition is true.\r\n */\r\nexport class FlowGraphWhileLoopBlock extends FlowGraphExecutionBlockWithOutSignal {\r\n /**\r\n * Input connection: The condition to evaluate.\r\n */\r\n public readonly condition: FlowGraphDataConnection<boolean>;\r\n /**\r\n * Output connection: The loop body.\r\n */\r\n public readonly loopBody: FlowGraphSignalConnection;\r\n\r\n constructor(\r\n /**\r\n * the configuration of the block\r\n */\r\n public config?: IFlowGraphWhileLoopBlockConfiguration\r\n ) {\r\n super(config);\r\n\r\n this.condition = this.registerDataInput(\"condition\", RichTypeBoolean);\r\n this.loopBody = this._registerSignalOutput(\"loopBody\");\r\n }\r\n\r\n public _execute(context: FlowGraphContext, _callingSignal: FlowGraphSignalConnection): void {\r\n let conditionValue = this.condition.getValue(context);\r\n if (this.config?.isDo && !conditionValue) {\r\n this.loopBody._activateSignal(context);\r\n }\r\n while (conditionValue) {\r\n this.loopBody._activateSignal(context);\r\n conditionValue = this.condition.getValue(context);\r\n }\r\n this.out._activateSignal(context);\r\n }\r\n\r\n /**\r\n * @returns class name of the block.\r\n */\r\n public getClassName(): string {\r\n return FlowGraphWhileLoopBlock.ClassName;\r\n }\r\n\r\n /**\r\n * the class name of the block.\r\n */\r\n public static ClassName = \"FGWhileLoopBlock\";\r\n\r\n /**\r\n * Serializes the block to a JSON object.\r\n * @param serializationObject the object to serialize to.\r\n */\r\n public serialize(serializationObject?: any): void {\r\n super.serialize(serializationObject);\r\n serializationObject.isDo = this.config?.isDo;\r\n }\r\n}\r\nRegisterClass(FlowGraphWhileLoopBlock.ClassName, FlowGraphWhileLoopBlock);\r\n"]}
|
package/FlowGraph/flowGraph.js
CHANGED
|
@@ -215,10 +215,9 @@ export class FlowGraph {
|
|
|
215
215
|
* @returns the parsed graph
|
|
216
216
|
*/
|
|
217
217
|
static Parse(serializationObject, options) {
|
|
218
|
-
var _a;
|
|
219
218
|
const graph = options.coordinator.createGraph();
|
|
220
219
|
const blocks = [];
|
|
221
|
-
const valueParseFunction =
|
|
220
|
+
const valueParseFunction = options.valueParseFunction ?? defaultValueParseFunction;
|
|
222
221
|
// Parse all blocks
|
|
223
222
|
for (const serializedBlock of serializationObject.allBlocks) {
|
|
224
223
|
const block = FlowGraphBlock.Parse(serializedBlock, { scene: options.coordinator.config.scene, pathConverter: options.pathConverter, valueParseFunction });
|
|
@@ -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;A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AW,CAAC,MAAM,CAAC,KAAK,EAAE,aAAa,EAAE,OAAO,CAAC,aAAa,EAAE,kBAAkB,EAAE,CAAC,CAAC;YAC3J,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACnB,IAAI,KAAK,YAAY,mBAAmB,EAAE;gBACtC,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;aAC9B;SACJ;QACD,yCAAyC;QACzC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;YACxB,KAAK,MAAM,MAAM,IAAI,KAAK,CAAC,UAAU,EAAE;gBACnC,KAAK,MAAM,oBAAoB,IAAI,MAAM,CAAC,iBAAiB,EAAE;oBACzD,MAAM,UAAU,GAAG,SAAS,CAAC,8BAA8B,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;oBAC1F,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;iBAChC;aACJ;YACD,IAAI,KAAK,YAAY,uBAAuB,EAAE;gBAC1C,KAAK,MAAM,SAAS,IAAI,KAAK,CAAC,aAAa,EAAE;oBACzC,KAAK,MAAM,oBAAoB,IAAI,SAAS,CAAC,iBAAiB,EAAE;wBAC5D,MAAM,UAAU,GAAG,SAAS,CAAC,+BAA+B,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;wBAC3F,SAAS,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;qBACnC;iBACJ;aACJ;SACJ;QACD,KAAK,MAAM,iBAAiB,IAAI,mBAAmB,CAAC,iBAAiB,EAAE;YACnE,gBAAgB,CAAC,KAAK,CAAC,iBAAiB,EAAE,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 * @param key the key of the value\r\n * @param serializationObject the object to read the value from\r\n * @param scene the scene to read the value from\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 /**\r\n * Returns the execution context at a given index\r\n * @param index the index of the context\r\n * @returns the execution context at that index\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 the event block to be added\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 a list of flow graph blocks\r\n * @param uniqueId the unique id of a connection\r\n * @returns the connection that has this unique id. throws an error if none was found\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 a list of flow graph blocks\r\n * @param uniqueId the unique id of a connection\r\n * @returns the connection that has this unique id. throws an error if none was found\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 the parsed graph\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
|
+
{"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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AAkB,EAAE,CAAC,CAAC;YAC3J,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACnB,IAAI,KAAK,YAAY,mBAAmB,EAAE;gBACtC,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;aAC9B;SACJ;QACD,yCAAyC;QACzC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;YACxB,KAAK,MAAM,MAAM,IAAI,KAAK,CAAC,UAAU,EAAE;gBACnC,KAAK,MAAM,oBAAoB,IAAI,MAAM,CAAC,iBAAiB,EAAE;oBACzD,MAAM,UAAU,GAAG,SAAS,CAAC,8BAA8B,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;oBAC1F,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;iBAChC;aACJ;YACD,IAAI,KAAK,YAAY,uBAAuB,EAAE;gBAC1C,KAAK,MAAM,SAAS,IAAI,KAAK,CAAC,aAAa,EAAE;oBACzC,KAAK,MAAM,oBAAoB,IAAI,SAAS,CAAC,iBAAiB,EAAE;wBAC5D,MAAM,UAAU,GAAG,SAAS,CAAC,+BAA+B,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;wBAC3F,SAAS,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;qBACnC;iBACJ;aACJ;SACJ;QACD,KAAK,MAAM,iBAAiB,IAAI,mBAAmB,CAAC,iBAAiB,EAAE;YACnE,gBAAgB,CAAC,KAAK,CAAC,iBAAiB,EAAE,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 * @param key the key of the value\r\n * @param serializationObject the object to read the value from\r\n * @param scene the scene to read the value from\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 /**\r\n * Returns the execution context at a given index\r\n * @param index the index of the context\r\n * @returns the execution context at that index\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 the event block to be added\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 a list of flow graph blocks\r\n * @param uniqueId the unique id of a connection\r\n * @returns the connection that has this unique id. throws an error if none was found\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 a list of flow graph blocks\r\n * @param uniqueId the unique id of a connection\r\n * @returns the connection that has this unique id. throws an error if none was found\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 the parsed graph\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"]}
|
|
@@ -18,13 +18,12 @@ export class FlowGraphBlock {
|
|
|
18
18
|
* the configuration of the block
|
|
19
19
|
*/
|
|
20
20
|
config) {
|
|
21
|
-
var _a, _b;
|
|
22
21
|
this.config = config;
|
|
23
22
|
/**
|
|
24
23
|
* A randomly generated GUID for each block.
|
|
25
24
|
*/
|
|
26
25
|
this.uniqueId = RandomGUID();
|
|
27
|
-
this.name =
|
|
26
|
+
this.name = this.config?.name ?? this.getClassName();
|
|
28
27
|
this.dataInputs = [];
|
|
29
28
|
this.dataOutputs = [];
|
|
30
29
|
}
|
|
@@ -111,10 +110,9 @@ export class FlowGraphBlock {
|
|
|
111
110
|
* @returns the parsed block
|
|
112
111
|
*/
|
|
113
112
|
static Parse(serializationObject, parseOptions) {
|
|
114
|
-
var _a;
|
|
115
113
|
const classType = Tools.Instantiate(serializationObject.className);
|
|
116
114
|
const parsedConfig = {};
|
|
117
|
-
const valueParseFunction =
|
|
115
|
+
const valueParseFunction = parseOptions.valueParseFunction ?? defaultValueParseFunction;
|
|
118
116
|
if (serializationObject.config) {
|
|
119
117
|
for (const key in serializationObject.config) {
|
|
120
118
|
parsedConfig[key] = valueParseFunction(key, serializationObject.config, parseOptions.scene);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flowGraphBlock.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraphBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAEhE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAE,yBAAyB,EAAE,iCAAiC,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAuCnH;;;;;GAKG;AACH,MAAM,OAAO,cAAc;IAuBvB;;OAEG;IACH;IACI;;OAEG;IACI,MAAqC;;QAArC,WAAM,GAAN,MAAM,CAA+B;QA7BhD;;WAEG;QACI,aAAQ,GAAG,UAAU,EAAE,CAAC;QA4B3B,IAAI,CAAC,IAAI,GAAG,MAAA,MAAA,IAAI,CAAC,MAAM,0CAAE,IAAI,mCAAI,IAAI,CAAC,YAAY,EAAE,CAAC;QACrD,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;QACrB,IAAI,CAAC,WAAW,GAAG,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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 * @param key the key of the property\r\n * @param serializationObject the serialization object where the property is located\r\n * @param scene the scene that the block is being parsed in\r\n * @returns the parsed value\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 * @param config optional configuration for this block\r\n */\r\n protected constructor(\r\n /**\r\n * the configuration of the block\r\n */\r\n public config?: IFlowGraphBlockConfiguration\r\n ) {\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 /**\r\n * Registers a data input on the block.\r\n * @param name the name of the input\r\n * @param richType the type of the input\r\n * @returns the created connection\r\n */\r\n public registerDataInput<T>(name: string, richType: RichType<T>): FlowGraphDataConnection<T> {\r\n const input = new FlowGraphDataConnection(name, FlowGraphConnectionType.Input, this, richType);\r\n this.dataInputs.push(input);\r\n return input;\r\n }\r\n\r\n /**\r\n * Registers a data output on the block.\r\n * @param name the name of the input\r\n * @param richType the type of the input\r\n * @returns the created connection\r\n */\r\n public registerDataOutput<T>(name: string, richType: RichType<T>): FlowGraphDataConnection<T> {\r\n const output = new FlowGraphDataConnection(name, FlowGraphConnectionType.Output, this, richType);\r\n this.dataOutputs.push(output);\r\n return output;\r\n }\r\n\r\n /**\r\n * Given the name of a data input, returns the connection if it exists\r\n * @param name the name of the input\r\n * @returns the connection if it exists, undefined otherwise\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 /**\r\n * Given the name of a data output, returns the connection if it exists\r\n * @param name the name of the output\r\n * @returns the connection if it exists, undefined otherwise\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 /**\r\n * Serializes this block\r\n * @param serializationObject the object to serialize to\r\n * @param _valueSerializeFunction a function that serializes a specific value\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 /**\r\n * Gets the class name of this block\r\n * @returns the class name\r\n */\r\n public getClassName() {\r\n return \"FGBlock\";\r\n }\r\n\r\n /**\r\n * Parses a block from a serialization object\r\n * @param serializationObject the object to parse from\r\n * @param parseOptions options for parsing the block\r\n * @returns the parsed block\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"]}
|
|
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;AAuCnH;;;;;GAKG;AACH,MAAM,OAAO,cAAc;IAuBvB;;OAEG;IACH;IACI;;OAEG;IACI,MAAqC;QAArC,WAAM,GAAN,MAAM,CAA+B;QA7BhD;;WAEG;QACI,aAAQ,GAAG,UAAU,EAAE,CAAC;QA4B3B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,MAAM,EAAE,IAAI,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;QACrD,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;QACrB,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;IAC1B,CAAC;IAED;;OAEG;IACI,cAAc,CAAC,QAA0B;QAC5C,6CAA6C;IACjD,CA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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 * @param key the key of the property\r\n * @param serializationObject the serialization object where the property is located\r\n * @param scene the scene that the block is being parsed in\r\n * @returns the parsed value\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 * @param config optional configuration for this block\r\n */\r\n protected constructor(\r\n /**\r\n * the configuration of the block\r\n */\r\n public config?: IFlowGraphBlockConfiguration\r\n ) {\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 /**\r\n * Registers a data input on the block.\r\n * @param name the name of the input\r\n * @param richType the type of the input\r\n * @returns the created connection\r\n */\r\n public registerDataInput<T>(name: string, richType: RichType<T>): FlowGraphDataConnection<T> {\r\n const input = new FlowGraphDataConnection(name, FlowGraphConnectionType.Input, this, richType);\r\n this.dataInputs.push(input);\r\n return input;\r\n }\r\n\r\n /**\r\n * Registers a data output on the block.\r\n * @param name the name of the input\r\n * @param richType the type of the input\r\n * @returns the created connection\r\n */\r\n public registerDataOutput<T>(name: string, richType: RichType<T>): FlowGraphDataConnection<T> {\r\n const output = new FlowGraphDataConnection(name, FlowGraphConnectionType.Output, this, richType);\r\n this.dataOutputs.push(output);\r\n return output;\r\n }\r\n\r\n /**\r\n * Given the name of a data input, returns the connection if it exists\r\n * @param name the name of the input\r\n * @returns the connection if it exists, undefined otherwise\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 /**\r\n * Given the name of a data output, returns the connection if it exists\r\n * @param name the name of the output\r\n * @returns the connection if it exists, undefined otherwise\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 /**\r\n * Serializes this block\r\n * @param serializationObject the object to serialize to\r\n * @param _valueSerializeFunction a function that serializes a specific value\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 /**\r\n * Gets the class name of this block\r\n * @returns the class name\r\n */\r\n public getClassName() {\r\n return \"FGBlock\";\r\n }\r\n\r\n /**\r\n * Parses a block from a serialization object\r\n * @param serializationObject the object to parse from\r\n * @param parseOptions options for parsing the block\r\n * @returns the parsed block\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"]}
|
|
@@ -233,9 +233,8 @@ export class FlowGraphContext {
|
|
|
233
233
|
* @returns
|
|
234
234
|
*/
|
|
235
235
|
static Parse(serializationObject, options) {
|
|
236
|
-
var _a;
|
|
237
236
|
const result = options.graph.createContext();
|
|
238
|
-
const valueParseFunction =
|
|
237
|
+
const valueParseFunction = options.valueParseFunction ?? defaultValueParseFunction;
|
|
239
238
|
result.uniqueId = serializationObject.uniqueId;
|
|
240
239
|
for (const key in serializationObject._userVariables) {
|
|
241
240
|
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,iBAAiB,CAAC;AAE/F,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAmChD;;;;;;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,GAA2B,EAAE,CAAC;QACzD;;WA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I,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;AAlQU;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/**\r\n * @experimental\r\n * Options for parsing a context.\r\n */\r\nexport interface IFlowGraphContextParseOptions {\r\n /**\r\n * A function that parses a value from a serialization object.\r\n * @param key the key of the value\r\n * @param serializationObject the object containing the value\r\n * @param scene the current scene\r\n * @returns\r\n */\r\n readonly valueParseFunction?: (key: string, serializationObject: any, scene: Scene) => any;\r\n /**\r\n * The graph that the context is being parsed in.\r\n */\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 the name of the variable\r\n * @returns true if the variable is defined\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 the name of the variable\r\n * @param value the value of the variable\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 the name of the variable\r\n * @returns the value of the variable\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 /**\r\n * @returns the class name of the object.\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 options the options for parsing the context\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
|
+
{"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;AAmChD;;;;;;GAMG;AACH,MAAM,OAAO,gBAAgB;IAoCzB,YAAY,MAAsC;QAnClD;;WAEG;QAEI,aAA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C;QACxG,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC;QAC7C,MAAM,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,IAAI,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;AAlQU;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/**\r\n * @experimental\r\n * Options for parsing a context.\r\n */\r\nexport interface IFlowGraphContextParseOptions {\r\n /**\r\n * A function that parses a value from a serialization object.\r\n * @param key the key of the value\r\n * @param serializationObject the object containing the value\r\n * @param scene the current scene\r\n * @returns\r\n */\r\n readonly valueParseFunction?: (key: string, serializationObject: any, scene: Scene) => any;\r\n /**\r\n * The graph that the context is being parsed in.\r\n */\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 the name of the variable\r\n * @returns true if the variable is defined\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 the name of the variable\r\n * @param value the value of the variable\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 the name of the variable\r\n * @returns the value of the variable\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 /**\r\n * @returns the class name of the object.\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 options the options for parsing the context\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"]}
|