@onerjs/core 9.0.1 → 9.0.3
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/animationGroup.pure.js.map +1 -1
- package/Buffers/buffer.pure.js +4 -0
- package/Buffers/buffer.pure.js.map +1 -1
- package/Cameras/camera.pure.d.ts +14 -0
- package/Cameras/camera.pure.js +15 -0
- package/Cameras/camera.pure.js.map +1 -1
- package/Compute/computeShader.pure.d.ts +2 -1
- package/Compute/computeShader.pure.js +29 -10
- package/Compute/computeShader.pure.js.map +1 -1
- package/Culling/ray.core.js +22 -9
- package/Culling/ray.core.js.map +1 -1
- package/Engines/IDrawContext.d.ts +2 -0
- package/Engines/IDrawContext.js.map +1 -1
- package/Engines/Native/nativeInterfaces.d.ts +55 -4
- package/Engines/Native/nativeInterfaces.js.map +1 -1
- package/Engines/Native/nativeRenderTargetWrapper.d.ts +1 -0
- package/Engines/Native/nativeRenderTargetWrapper.js +5 -1
- package/Engines/Native/nativeRenderTargetWrapper.js.map +1 -1
- package/Engines/Processors/shaderCodeInliner.d.ts +2 -0
- package/Engines/Processors/shaderCodeInliner.js +251 -6
- package/Engines/Processors/shaderCodeInliner.js.map +1 -1
- package/Engines/Processors/shaderProcessor.js +10 -1
- package/Engines/Processors/shaderProcessor.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.debugging.pure.js +12 -0
- package/Engines/WebGPU/Extensions/engine.debugging.pure.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.multiRender.pure.js +0 -1
- package/Engines/WebGPU/Extensions/engine.multiRender.pure.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.query.pure.js +5 -0
- package/Engines/WebGPU/Extensions/engine.query.pure.js.map +1 -1
- package/Engines/WebGPU/webgpuBufferManager.js +7 -0
- package/Engines/WebGPU/webgpuBufferManager.js.map +1 -1
- package/Engines/WebGPU/webgpuCacheTextureView.d.ts +1 -1
- package/Engines/WebGPU/webgpuCacheTextureView.js +20 -8
- package/Engines/WebGPU/webgpuCacheTextureView.js.map +1 -1
- package/Engines/WebGPU/webgpuDrawContext.d.ts +2 -0
- package/Engines/WebGPU/webgpuDrawContext.js +6 -0
- package/Engines/WebGPU/webgpuDrawContext.js.map +1 -1
- package/Engines/WebGPU/webgpuQuerySet.d.ts +3 -3
- package/Engines/WebGPU/webgpuQuerySet.js +23 -9
- package/Engines/WebGPU/webgpuQuerySet.js.map +1 -1
- package/Engines/WebGPU/webgpuRenderPassCommandStream.d.ts +156 -0
- package/Engines/WebGPU/webgpuRenderPassCommandStream.js +323 -0
- package/Engines/WebGPU/webgpuRenderPassCommandStream.js.map +1 -0
- package/Engines/WebGPU/webgpuTextureManager.d.ts +1 -1
- package/Engines/WebGPU/webgpuTextureManager.js +4 -3
- package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
- package/Engines/WebGPU/webgpuTimestampQuery.d.ts +3 -1
- package/Engines/WebGPU/webgpuTimestampQuery.js +9 -6
- package/Engines/WebGPU/webgpuTimestampQuery.js.map +1 -1
- package/Engines/abstractEngine.pure.d.ts +2 -0
- package/Engines/abstractEngine.pure.js +14 -5
- package/Engines/abstractEngine.pure.js.map +1 -1
- package/Engines/constants.d.ts +6 -0
- package/Engines/constants.js +6 -0
- package/Engines/constants.js.map +1 -1
- package/Engines/engine.d.ts +198 -24
- package/Engines/pure.d.ts +1 -0
- package/Engines/pure.js +1 -0
- package/Engines/pure.js.map +1 -1
- package/Engines/renderCommandBatcher.pure.d.ts +16 -0
- package/Engines/renderCommandBatcher.pure.js +24 -0
- package/Engines/renderCommandBatcher.pure.js.map +1 -0
- package/Engines/thinEngine.functions.js +3 -2
- package/Engines/thinEngine.functions.js.map +1 -1
- package/Engines/thinEngine.pure.js +18 -2
- package/Engines/thinEngine.pure.js.map +1 -1
- package/Engines/thinNativeEngine.pure.d.ts +10 -7
- package/Engines/thinNativeEngine.pure.js +117 -46
- package/Engines/thinNativeEngine.pure.js.map +1 -1
- package/Engines/thinWebGPUEngine.d.ts +8 -0
- package/Engines/thinWebGPUEngine.js +11 -0
- package/Engines/thinWebGPUEngine.js.map +1 -1
- package/Engines/webgpuEngine.pure.d.ts +60 -1
- package/Engines/webgpuEngine.pure.js +238 -42
- package/Engines/webgpuEngine.pure.js.map +1 -1
- package/FlowGraph/Blocks/Data/Audio/flowGraphGetSoundVolumeBlock.pure.d.ts +3 -3
- package/FlowGraph/Blocks/Data/Audio/flowGraphGetSoundVolumeBlock.pure.js +2 -1
- package/FlowGraph/Blocks/Data/Audio/flowGraphGetSoundVolumeBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Data/Audio/flowGraphIsSoundPlayingBlock.pure.d.ts +3 -3
- package/FlowGraph/Blocks/Data/Audio/flowGraphIsSoundPlayingBlock.pure.js +2 -1
- package/FlowGraph/Blocks/Data/Audio/flowGraphIsSoundPlayingBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphMeshIntersectionEventBlock.d.ts +5 -0
- package/FlowGraph/Blocks/Event/flowGraphMeshIntersectionEventBlock.js +8 -0
- package/FlowGraph/Blocks/Event/flowGraphMeshIntersectionEventBlock.js.map +1 -0
- package/FlowGraph/Blocks/Event/flowGraphMeshIntersectionEventBlock.pure.d.ts +77 -0
- package/FlowGraph/Blocks/Event/flowGraphMeshIntersectionEventBlock.pure.js +141 -0
- package/FlowGraph/Blocks/Event/flowGraphMeshIntersectionEventBlock.pure.js.map +1 -0
- package/FlowGraph/Blocks/Event/flowGraphSoundEndedEventBlock.pure.d.ts +5 -3
- package/FlowGraph/Blocks/Event/flowGraphSoundEndedEventBlock.pure.js +38 -7
- package/FlowGraph/Blocks/Event/flowGraphSoundEndedEventBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Event/index.d.ts +1 -0
- package/FlowGraph/Blocks/Event/index.js +1 -0
- package/FlowGraph/Blocks/Event/index.js.map +1 -1
- package/FlowGraph/Blocks/Event/pure.d.ts +1 -0
- package/FlowGraph/Blocks/Event/pure.js +1 -0
- package/FlowGraph/Blocks/Event/pure.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphPauseSoundBlock.pure.d.ts +3 -3
- package/FlowGraph/Blocks/Execution/Audio/flowGraphPauseSoundBlock.pure.js +2 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphPauseSoundBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphPlaySoundBlock.pure.d.ts +3 -3
- package/FlowGraph/Blocks/Execution/Audio/flowGraphPlaySoundBlock.pure.js +2 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphPlaySoundBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphSetSoundVolumeBlock.pure.d.ts +3 -3
- package/FlowGraph/Blocks/Execution/Audio/flowGraphSetSoundVolumeBlock.pure.js +2 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphSetSoundVolumeBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphStopSoundBlock.pure.d.ts +3 -3
- package/FlowGraph/Blocks/Execution/Audio/flowGraphStopSoundBlock.pure.js +2 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphStopSoundBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/allBlocks.pure.js +2 -0
- package/FlowGraph/Blocks/allBlocks.pure.js.map +1 -1
- package/FlowGraph/Blocks/flowGraphBlockFactory.js +2 -0
- package/FlowGraph/Blocks/flowGraphBlockFactory.js.map +1 -1
- package/FlowGraph/Blocks/flowGraphBlockNames.d.ts +1 -0
- package/FlowGraph/Blocks/flowGraphBlockNames.js +1 -0
- package/FlowGraph/Blocks/flowGraphBlockNames.js.map +1 -1
- package/FlowGraph/flowGraph.d.ts +12 -1
- package/FlowGraph/flowGraph.js +38 -0
- package/FlowGraph/flowGraph.js.map +1 -1
- package/FlowGraph/flowGraphCoordinator.d.ts +44 -0
- package/FlowGraph/flowGraphCoordinator.js +141 -0
- package/FlowGraph/flowGraphCoordinator.js.map +1 -1
- package/FlowGraph/flowGraphDataConnection.pure.js +41 -14
- package/FlowGraph/flowGraphDataConnection.pure.js.map +1 -1
- package/FlowGraph/flowGraphParser.js +105 -5
- package/FlowGraph/flowGraphParser.js.map +1 -1
- package/FlowGraph/flowGraphSoundAssets.d.ts +40 -0
- package/FlowGraph/flowGraphSoundAssets.js +33 -0
- package/FlowGraph/flowGraphSoundAssets.js.map +1 -0
- package/FlowGraph/index.d.ts +1 -0
- package/FlowGraph/index.js +1 -0
- package/FlowGraph/index.js.map +1 -1
- package/FlowGraph/pure.d.ts +1 -0
- package/FlowGraph/pure.js +1 -0
- package/FlowGraph/pure.js.map +1 -1
- package/FlowGraph/serialization.d.ts +8 -0
- package/FlowGraph/serialization.js +31 -12
- package/FlowGraph/serialization.js.map +1 -1
- package/FlowGraph/typeDefinitions.d.ts +25 -0
- package/FlowGraph/typeDefinitions.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/taaTask.js +2 -0
- package/FrameGraph/Tasks/PostProcesses/taaTask.js.map +1 -1
- package/Instrumentation/engineInstrumentation.d.ts +1 -0
- package/Instrumentation/engineInstrumentation.js +25 -6
- package/Instrumentation/engineInstrumentation.js.map +1 -1
- package/Lights/Clustered/clusteredLightContainer.pure.js +2 -0
- package/Lights/Clustered/clusteredLightContainer.pure.js.map +1 -1
- package/Lights/Shadows/cascadedShadowGenerator.pure.d.ts +36 -1
- package/Lights/Shadows/cascadedShadowGenerator.pure.js +202 -27
- package/Lights/Shadows/cascadedShadowGenerator.pure.js.map +1 -1
- package/Lights/directionalLight.pure.d.ts +24 -10
- package/Lights/directionalLight.pure.js +29 -11
- package/Lights/directionalLight.pure.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.pure.js +4 -4
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.pure.js.map +1 -1
- package/Materials/Node/Blocks/Dual/lightBlock.pure.js +1 -1
- package/Materials/Node/Blocks/Dual/lightBlock.pure.js.map +1 -1
- package/Materials/Node/Blocks/Input/inputBlock.pure.js +4 -0
- package/Materials/Node/Blocks/Input/inputBlock.pure.js.map +1 -1
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.pure.d.ts +9 -0
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.pure.js +23 -3
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.pure.js.map +1 -1
- package/Materials/PBR/openpbrMaterial.pure.js +1 -1
- package/Materials/PBR/openpbrMaterial.pure.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.pure.d.ts +9 -0
- package/Materials/PBR/pbrBaseMaterial.pure.js +60 -1
- package/Materials/PBR/pbrBaseMaterial.pure.js.map +1 -1
- package/Materials/PBR/pbrBaseSimpleMaterial.d.ts +11 -0
- package/Materials/PBR/pbrBaseSimpleMaterial.js +21 -2
- package/Materials/PBR/pbrBaseSimpleMaterial.js.map +1 -1
- package/Materials/PBR/pbrMaterial.pure.d.ts +12 -0
- package/Materials/PBR/pbrMaterial.pure.js +23 -3
- package/Materials/PBR/pbrMaterial.pure.js.map +1 -1
- package/Materials/Textures/Filtering/hdrIrradianceFiltering.d.ts +1 -0
- package/Materials/Textures/Filtering/hdrIrradianceFiltering.js +10 -0
- package/Materials/Textures/Filtering/hdrIrradianceFiltering.js.map +1 -1
- package/Materials/Textures/HTML/htmlInCanvasPolyfill.d.ts +5 -0
- package/Materials/Textures/HTML/htmlInCanvasPolyfill.js +7 -0
- package/Materials/Textures/HTML/htmlInCanvasPolyfill.js.map +1 -1
- package/Materials/Textures/HTML/htmlInteractionManager.d.ts +9 -3
- package/Materials/Textures/HTML/htmlInteractionManager.js +64 -5
- package/Materials/Textures/HTML/htmlInteractionManager.js.map +1 -1
- package/Materials/Textures/HTML/htmlTexture.d.ts +11 -11
- package/Materials/Textures/HTML/htmlTexture.js +106 -65
- package/Materials/Textures/HTML/htmlTexture.js.map +1 -1
- package/Materials/Textures/Loaders/internalTextureLoader.d.ts +2 -1
- package/Materials/Textures/Loaders/internalTextureLoader.js.map +1 -1
- package/Materials/Textures/Loaders/ktxTextureLoader.d.ts +2 -1
- package/Materials/Textures/Loaders/ktxTextureLoader.js +4 -50
- package/Materials/Textures/Loaders/ktxTextureLoader.js.map +1 -1
- package/Materials/Textures/Procedurals/proceduralTexture.pure.js +10 -0
- package/Materials/Textures/Procedurals/proceduralTexture.pure.js.map +1 -1
- package/Materials/Textures/dynamicTexture.pure.js +6 -0
- package/Materials/Textures/dynamicTexture.pure.js.map +1 -1
- package/Materials/Textures/ktx2encoderTypes.d.ts +51 -0
- package/Materials/Textures/ktx2encoderTypes.js +2 -0
- package/Materials/Textures/ktx2encoderTypes.js.map +1 -0
- package/Materials/Textures/renderTargetTexture.pure.js +10 -2
- package/Materials/Textures/renderTargetTexture.pure.js.map +1 -1
- package/Materials/Textures/texture.pure.js +7 -1
- package/Materials/Textures/texture.pure.js.map +1 -1
- package/Materials/Textures/textureMerger.d.ts +11 -0
- package/Materials/Textures/textureMerger.js +34 -19
- package/Materials/Textures/textureMerger.js.map +1 -1
- package/Materials/Textures/textureProcessor.d.ts +145 -0
- package/Materials/Textures/textureProcessor.js +445 -45
- package/Materials/Textures/textureProcessor.js.map +1 -1
- package/Materials/Textures/textureSampling.functions.d.ts +41 -0
- package/Materials/Textures/textureSampling.functions.js +82 -0
- package/Materials/Textures/textureSampling.functions.js.map +1 -0
- package/Materials/drawWrapper.d.ts +8 -0
- package/Materials/drawWrapper.js +19 -0
- package/Materials/drawWrapper.js.map +1 -1
- package/Materials/effect.pure.d.ts +6 -0
- package/Materials/effect.pure.js +28 -6
- package/Materials/effect.pure.js.map +1 -1
- package/Materials/effect.webgl.functions.pure.js +1 -1
- package/Materials/effect.webgl.functions.pure.js.map +1 -1
- package/Materials/material.pure.d.ts +5 -0
- package/Materials/material.pure.js +9 -2
- package/Materials/material.pure.js.map +1 -1
- package/Materials/materialFlags.d.ts +6 -0
- package/Materials/materialFlags.js +14 -0
- package/Materials/materialFlags.js.map +1 -1
- package/Materials/materialHelper.functions.d.ts +2 -1
- package/Materials/materialHelper.functions.js +36 -2
- package/Materials/materialHelper.functions.js.map +1 -1
- package/Materials/materialHelper.geometryrendering.js +19 -16
- package/Materials/materialHelper.geometryrendering.js.map +1 -1
- package/Materials/materialPluginManager.pure.js +12 -8
- package/Materials/materialPluginManager.pure.js.map +1 -1
- package/Materials/prePassConfiguration.js +19 -16
- package/Materials/prePassConfiguration.js.map +1 -1
- package/Materials/shaderMaterial.pure.js +19 -6
- package/Materials/shaderMaterial.pure.js.map +1 -1
- package/Materials/shadowDepthWrapper.d.ts +6 -0
- package/Materials/shadowDepthWrapper.js +17 -0
- package/Materials/shadowDepthWrapper.js.map +1 -1
- package/Meshes/Compression/dracoCodec.d.ts +14 -0
- package/Meshes/Compression/dracoCodec.js +22 -0
- package/Meshes/Compression/dracoCodec.js.map +1 -1
- package/Meshes/Compression/dracoDecoder.d.ts +1 -0
- package/Meshes/Compression/dracoDecoder.js +27 -0
- package/Meshes/Compression/dracoDecoder.js.map +1 -1
- package/Meshes/Compression/dracoEncoder.d.ts +1 -0
- package/Meshes/Compression/dracoEncoder.js +8 -0
- package/Meshes/Compression/dracoEncoder.js.map +1 -1
- package/Meshes/Compression/meshoptCompression.d.ts +1 -0
- package/Meshes/Compression/meshoptCompression.js +9 -0
- package/Meshes/Compression/meshoptCompression.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingGpuSorter.d.ts +415 -0
- package/Meshes/GaussianSplatting/gaussianSplattingGpuSorter.js +912 -0
- package/Meshes/GaussianSplatting/gaussianSplattingGpuSorter.js.map +1 -0
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.d.ts +3 -0
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.js +40 -9
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.d.ts +112 -8
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js +696 -74
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js.map +1 -1
- package/Meshes/abstractMesh.pure.js +12 -4
- package/Meshes/abstractMesh.pure.js.map +1 -1
- package/Meshes/geometry.d.ts +5 -0
- package/Meshes/geometry.js +25 -0
- package/Meshes/geometry.js.map +1 -1
- package/Meshes/index.d.ts +1 -0
- package/Meshes/index.js +1 -0
- package/Meshes/index.js.map +1 -1
- package/Meshes/mesh.pure.d.ts +7 -0
- package/Meshes/mesh.pure.js +18 -13
- package/Meshes/mesh.pure.js.map +1 -1
- package/Meshes/pure.d.ts +1 -0
- package/Meshes/pure.js +1 -0
- package/Meshes/pure.js.map +1 -1
- package/Meshes/subMesh.pure.d.ts +3 -0
- package/Meshes/subMesh.pure.js +26 -0
- package/Meshes/subMesh.pure.js.map +1 -1
- package/Meshes/thinInstanceMesh.pure.js +5 -3
- package/Meshes/thinInstanceMesh.pure.js.map +1 -1
- package/Misc/index.d.ts +1 -0
- package/Misc/index.js +1 -0
- package/Misc/index.js.map +1 -1
- package/Misc/khronosTextureContainer2.d.ts +3 -2
- package/Misc/khronosTextureContainer2.js +24 -6
- package/Misc/khronosTextureContainer2.js.map +1 -1
- package/Misc/khronosTextureContainer2Encoder.d.ts +166 -0
- package/Misc/khronosTextureContainer2Encoder.js +556 -0
- package/Misc/khronosTextureContainer2Encoder.js.map +1 -0
- package/Misc/khronosTextureContainer2EncoderWorker.d.ts +61 -0
- package/Misc/khronosTextureContainer2EncoderWorker.js +55 -0
- package/Misc/khronosTextureContainer2EncoderWorker.js.map +1 -0
- package/Misc/pure.d.ts +1 -0
- package/Misc/pure.js +1 -0
- package/Misc/pure.js.map +1 -1
- package/Misc/textureFormat.functions.d.ts +6 -0
- package/Misc/textureFormat.functions.js +54 -0
- package/Misc/textureFormat.functions.js.map +1 -0
- package/Misc/textureTools.d.ts +6 -2
- package/Misc/textureTools.js +100 -42
- package/Misc/textureTools.js.map +1 -1
- package/Misc/tools.pure.js +1 -1
- package/Misc/tools.pure.js.map +1 -1
- package/Particles/Node/Blocks/systemBlock.pure.d.ts +1 -1
- package/Particles/Node/Blocks/systemBlock.pure.js +6 -3
- package/Particles/Node/Blocks/systemBlock.pure.js.map +1 -1
- package/Particles/computeShaderParticleSystem.pure.js +5 -0
- package/Particles/computeShaderParticleSystem.pure.js.map +1 -1
- package/Particles/gpuParticleSystem.pure.d.ts +2 -0
- package/Particles/gpuParticleSystem.pure.js +25 -1
- package/Particles/gpuParticleSystem.pure.js.map +1 -1
- package/Particles/solidParticle.d.ts +5 -0
- package/Particles/solidParticle.js +5 -0
- package/Particles/solidParticle.js.map +1 -1
- package/Particles/solidParticleSystem.d.ts +10 -0
- package/Particles/solidParticleSystem.js +72 -13
- package/Particles/solidParticleSystem.js.map +1 -1
- package/Particles/thinParticleSystem.pure.js +4 -0
- package/Particles/thinParticleSystem.pure.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/taaMaterialManager.pure.d.ts +27 -6
- package/PostProcesses/RenderPipeline/Pipelines/taaMaterialManager.pure.js +60 -5
- package/PostProcesses/RenderPipeline/Pipelines/taaMaterialManager.pure.js.map +1 -1
- package/PostProcesses/thinTAAPostProcess.d.ts +1 -0
- package/PostProcesses/thinTAAPostProcess.js +17 -1
- package/PostProcesses/thinTAAPostProcess.js.map +1 -1
- package/PostProcesses/volumetricLightScatteringPostProcess.pure.d.ts +2 -1
- package/PostProcesses/volumetricLightScatteringPostProcess.pure.js +6 -5
- package/PostProcesses/volumetricLightScatteringPostProcess.pure.js.map +1 -1
- package/Rendering/boundingBoxRenderer.pure.js +2 -3
- package/Rendering/boundingBoxRenderer.pure.js.map +1 -1
- package/Rendering/geometryBufferRenderer.pure.js +8 -2
- package/Rendering/geometryBufferRenderer.pure.js.map +1 -1
- package/Rendering/objectRenderer.d.ts +1 -0
- package/Rendering/objectRenderer.js +14 -0
- package/Rendering/objectRenderer.js.map +1 -1
- package/Shaders/ShadersInclude/bumpFragmentMainFunctions.js +2 -2
- package/Shaders/ShadersInclude/bumpFragmentMainFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/bumpVertex.js +1 -1
- package/Shaders/ShadersInclude/bumpVertex.js.map +1 -1
- package/Shaders/ShadersInclude/bumpVertexDeclaration.js +1 -1
- package/Shaders/ShadersInclude/bumpVertexDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/hdrFilteringFunctions.js +5 -1
- package/Shaders/ShadersInclude/hdrFilteringFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/helperFunctions.js +2 -2
- package/Shaders/ShadersInclude/helperFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/openpbrBackgroundTransmission.js +1 -1
- package/Shaders/ShadersInclude/openpbrBackgroundTransmission.js.map +1 -1
- package/Shaders/ShadersInclude/openpbrVertexDeclaration.js +6 -0
- package/Shaders/ShadersInclude/openpbrVertexDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockFinalLitComponents.js +11 -1
- package/Shaders/ShadersInclude/pbrBlockFinalLitComponents.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockNormalFinal.js +9 -0
- package/Shaders/ShadersInclude/pbrBlockNormalFinal.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockReflectance.js +1 -1
- package/Shaders/ShadersInclude/pbrBlockReflectance.js.map +1 -1
- package/Shaders/ShadersInclude/pbrClusteredLightingFunctions.js +1 -1
- package/Shaders/ShadersInclude/pbrClusteredLightingFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/pbrFragmentDeclaration.js +7 -1
- package/Shaders/ShadersInclude/pbrFragmentDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.js +1 -0
- package/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/pbrIBLFunctions.js +12 -0
- package/Shaders/ShadersInclude/pbrIBLFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/pbrUboDeclaration.js +1 -1
- package/Shaders/ShadersInclude/pbrUboDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/pbrVertexDeclaration.js +3 -0
- package/Shaders/ShadersInclude/pbrVertexDeclaration.js.map +1 -1
- package/Shaders/geometry.vertex.js +6 -6
- package/Shaders/geometry.vertex.js.map +1 -1
- package/Shaders/gpuUpdateParticles.vertex.js +1 -1
- package/Shaders/gpuUpdateParticles.vertex.js.map +1 -1
- package/Shaders/lod.fragment.js +15 -2
- package/Shaders/lod.fragment.js.map +1 -1
- package/Shaders/lod3D.fragment.js +15 -2
- package/Shaders/lod3D.fragment.js.map +1 -1
- package/Shaders/lodCube.fragment.js +15 -2
- package/Shaders/lodCube.fragment.js.map +1 -1
- package/Shaders/openpbr.vertex.js +2 -0
- package/Shaders/openpbr.vertex.js.map +1 -1
- package/Shaders/pbr.fragment.js +12 -1
- package/Shaders/pbr.fragment.js.map +1 -1
- package/Shaders/pbr.vertex.js +2 -0
- package/Shaders/pbr.vertex.js.map +1 -1
- package/Shaders/textureMerger.fragment.js +28 -0
- package/Shaders/textureMerger.fragment.js.map +1 -1
- package/Shaders/textureProcessor.fragment.js +26 -4
- package/Shaders/textureProcessor.fragment.js.map +1 -1
- package/Shaders/volumetricLightScattering.fragment.js +1 -1
- package/Shaders/volumetricLightScattering.fragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/bumpFragmentMainFunctions.js +2 -2
- package/ShadersWGSL/ShadersInclude/bumpFragmentMainFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/bumpVertex.js +1 -1
- package/ShadersWGSL/ShadersInclude/bumpVertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/bumpVertexDeclaration.js +1 -1
- package/ShadersWGSL/ShadersInclude/bumpVertexDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/hdrFilteringFunctions.js +1 -1
- package/ShadersWGSL/ShadersInclude/hdrFilteringFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/helperFunctions.js +2 -2
- package/ShadersWGSL/ShadersInclude/helperFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/lightFragment.js +44 -2
- package/ShadersWGSL/ShadersInclude/lightFragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/lightUboDeclaration.js +17 -3
- package/ShadersWGSL/ShadersInclude/lightUboDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/lightVxUboDeclaration.js +12 -1
- package/ShadersWGSL/ShadersInclude/lightVxUboDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/openpbrBackgroundTransmission.js +1 -1
- package/ShadersWGSL/ShadersInclude/openpbrBackgroundTransmission.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockFinalLitComponents.js +11 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockFinalLitComponents.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockNormalFinal.js +9 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockNormalFinal.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockReflectance.js +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockReflectance.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrClusteredLightingFunctions.js +1 -1
- package/ShadersWGSL/ShadersInclude/pbrClusteredLightingFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingSetupFunctions.js +1 -1
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingSetupFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrFragmentSamplersDeclaration.js +1 -0
- package/ShadersWGSL/ShadersInclude/pbrFragmentSamplersDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrIBLFunctions.js +8 -0
- package/ShadersWGSL/ShadersInclude/pbrIBLFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrUboDeclaration.js +1 -1
- package/ShadersWGSL/ShadersInclude/pbrUboDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/prePassVertex.js +2 -2
- package/ShadersWGSL/ShadersInclude/prePassVertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/prePassVertexDeclaration.js +1 -1
- package/ShadersWGSL/ShadersInclude/prePassVertexDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/sceneUboDeclaration.js +3 -1
- package/ShadersWGSL/ShadersInclude/sceneUboDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/shadowsVertex.js +16 -0
- package/ShadersWGSL/ShadersInclude/shadowsVertex.js.map +1 -1
- package/ShadersWGSL/default.fragment.js +4 -4
- package/ShadersWGSL/default.fragment.js.map +1 -1
- package/ShadersWGSL/default.vertex.js +1 -1
- package/ShadersWGSL/default.vertex.js.map +1 -1
- package/ShadersWGSL/gaussianSplatting.vertex.js +3 -3
- package/ShadersWGSL/gaussianSplatting.vertex.js.map +1 -1
- package/ShadersWGSL/gpuUpdateParticles.compute.js +1 -1
- package/ShadersWGSL/gpuUpdateParticles.compute.js.map +1 -1
- package/ShadersWGSL/gsSortCount.compute.d.ts +5 -0
- package/ShadersWGSL/gsSortCount.compute.js +19 -0
- package/ShadersWGSL/gsSortCount.compute.js.map +1 -0
- package/ShadersWGSL/gsSortKeys.compute.d.ts +5 -0
- package/ShadersWGSL/gsSortKeys.compute.js +49 -0
- package/ShadersWGSL/gsSortKeys.compute.js.map +1 -0
- package/ShadersWGSL/gsSortOutput.compute.d.ts +5 -0
- package/ShadersWGSL/gsSortOutput.compute.js +28 -0
- package/ShadersWGSL/gsSortOutput.compute.js.map +1 -0
- package/ShadersWGSL/gsSortScanLocal.compute.d.ts +5 -0
- package/ShadersWGSL/gsSortScanLocal.compute.js +23 -0
- package/ShadersWGSL/gsSortScanLocal.compute.js.map +1 -0
- package/ShadersWGSL/gsSortScanSums.compute.d.ts +5 -0
- package/ShadersWGSL/gsSortScanSums.compute.js +19 -0
- package/ShadersWGSL/gsSortScanSums.compute.js.map +1 -0
- package/ShadersWGSL/gsSortScatter.compute.d.ts +5 -0
- package/ShadersWGSL/gsSortScatter.compute.js +33 -0
- package/ShadersWGSL/gsSortScatter.compute.js.map +1 -0
- package/ShadersWGSL/lod.fragment.js +14 -2
- package/ShadersWGSL/lod.fragment.js.map +1 -1
- package/ShadersWGSL/lod3D.fragment.js +14 -2
- package/ShadersWGSL/lod3D.fragment.js.map +1 -1
- package/ShadersWGSL/lodCube.fragment.js +14 -2
- package/ShadersWGSL/lodCube.fragment.js.map +1 -1
- package/ShadersWGSL/openpbr.vertex.js +3 -1
- package/ShadersWGSL/openpbr.vertex.js.map +1 -1
- package/ShadersWGSL/pbr.fragment.js +11 -0
- package/ShadersWGSL/pbr.fragment.js.map +1 -1
- package/ShadersWGSL/pbr.vertex.js +3 -1
- package/ShadersWGSL/pbr.vertex.js.map +1 -1
- package/ShadersWGSL/textureMerger.fragment.js +40 -4
- package/ShadersWGSL/textureMerger.fragment.js.map +1 -1
- package/ShadersWGSL/textureProcessor.fragment.js +26 -4
- package/ShadersWGSL/textureProcessor.fragment.js.map +1 -1
- package/Sprites/spriteRenderer.js +15 -5
- package/Sprites/spriteRenderer.js.map +1 -1
- package/package.json +1 -1
- package/scene.pure.d.ts +23 -1
- package/scene.pure.js +83 -1
- package/scene.pure.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flowGraphCoordinator.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraphCoordinator.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4D,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAE5G,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAIxC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAA+B,2BAA2B,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAsC7H;;;;;GAKG;AACH,MAAM,OAAO,oBAAoB;IAkB7B;;;OAGG;IACI,MAAM,KAAK,0BAA0B;QACxC,OAAO,IAAI,CA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AC;;AA/TD;;;;GAIG;AACW,qCAAgB,GAAW,EAAE,AAAb,CAAc;AAE5C;;GAEG;AACW,kDAA6B,GAAW,EAAE,AAAb,CAAc;AACzD;;;GAGG;AACoB,sCAAiB,GAAuC,IAAI,GAAG,EAAE,AAAhD,CAAiD;AASjE,gDAA2B,GAAG,IAAI,UAAU,EAAa,AAA9B,CAA+B;AAS1D,kDAA6B,GAAG,IAAI,UAAU,EAAa,AAA9B,CAA+B","sourcesContent":["import { type EventState, type IReadonlyObservable, type Observer, Observable } from \"core/Misc/observable\";\r\nimport { type Scene } from \"../scene\";\r\nimport { FlowGraph } from \"./flowGraph\";\r\nimport { type IPathToObjectConverter } from \"../ObjectModel/objectModelInterfaces\";\r\nimport { type IObjectAccessor } from \"./typeDefinitions\";\r\nimport { type IAssetContainer } from \"core/IAssetContainer\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport { type IFlowGraphHostResolver, GetDefaultEventReferenceKey, GetDefaultEventReference } from \"./flowGraphHostResolver\";\r\n\r\n/**\r\n * Parameters used to create a flow graph engine.\r\n */\r\nexport interface IFlowGraphCoordinatorConfiguration {\r\n /**\r\n * The scene that the flow graph engine belongs to.\r\n */\r\n scene: Scene;\r\n /**\r\n * Optional resolver letting the environment hosting the graphs decide how runtime entities are\r\n * represented as opaque reference values. When omitted, a neutral built-in representation is used.\r\n */\r\n hostResolver?: IFlowGraphHostResolver;\r\n}\r\n\r\n/**\r\n * Parameters used to parse a flow graph coordinator.\r\n */\r\nexport interface IFlowGraphCoordinatorParseOptions {\r\n /**\r\n * A function that will be called to parse the value of a property.\r\n * @param key the key of the property\r\n * @param serializationObject the serialization object where the property is located\r\n * @param assetsContainer the assets container\r\n * @param scene the scene that the block is being parsed in\r\n */\r\n valueParseFunction?: (key: string, serializationObject: any, assetsContainer: IAssetContainer, scene: Scene) => any;\r\n /**\r\n * The path converter to use to convert the path to an object accessor.\r\n */\r\n pathConverter?: IPathToObjectConverter<IObjectAccessor>;\r\n /**\r\n * The scene that the flow graph coordinator belongs to.\r\n */\r\n scene: Scene;\r\n}\r\n/**\r\n * This class holds all of the existing flow graphs and is responsible for creating new ones.\r\n * It also handles starting/stopping multiple graphs and communication between them through an Event Coordinator\r\n * This is the entry point for the flow graph system.\r\n * @experimental This class is still in development and is subject to change.\r\n */\r\nexport class FlowGraphCoordinator {\r\n /**\r\n * The maximum number of events per type.\r\n * This is used to limit the number of events that can be created in a single scene.\r\n * This is to prevent infinite loops.\r\n */\r\n public static MaxEventsPerType: number = 30;\r\n\r\n /**\r\n * The maximum number of execution of a specific event in a single frame.\r\n */\r\n public static MaxEventTypeExecutionPerFrame: number = 30;\r\n /**\r\n * @internal\r\n * A list of all the coordinators per scene. Will be used by the inspector\r\n */\r\n public static readonly SceneCoordinators: Map<Scene, FlowGraphCoordinator[]> = new Map();\r\n\r\n /**\r\n * Observable raised when a flow graph is added to any coordinator. Used by the inspector to keep\r\n * the flow graph list in sync. The payload is the newly added flow graph.\r\n */\r\n public static get OnFlowGraphAddedObservable(): IReadonlyObservable<FlowGraph> {\r\n return this._OnFlowGraphAddedObservable;\r\n }\r\n private static readonly _OnFlowGraphAddedObservable = new Observable<FlowGraph>();\r\n\r\n /**\r\n * Observable raised when a flow graph is removed from any coordinator. Used by the inspector to keep\r\n * the flow graph list in sync. The payload is the removed flow graph.\r\n */\r\n public static get OnFlowGraphRemovedObservable(): IReadonlyObservable<FlowGraph> {\r\n return this._OnFlowGraphRemovedObservable;\r\n }\r\n private static readonly _OnFlowGraphRemovedObservable = new Observable<FlowGraph>();\r\n\r\n /**\r\n * When set to true (default) custom events will be dispatched synchronously.\r\n * This means that the events will be dispatched immediately when they are triggered.\r\n */\r\n public dispatchEventsSynchronously: boolean = true;\r\n\r\n private readonly _flowGraphs: FlowGraph[] = [];\r\n\r\n private _customEventsMap: Map<string, Observable<any>> = new Map();\r\n\r\n private _eventExecutionCounter: Map<string, number> = new Map();\r\n\r\n private _disposeObserver!: Observer<Scene>;\r\n private _onBeforeRenderObserver!: Observer<Scene>;\r\n private _executeOnNextFrame: { id: string; data?: any; uniqueId: number }[] = [];\r\n private _eventUniqueId: number = 0;\r\n\r\n /**\r\n * Stack of custom-event dispatches currently in progress. Each entry pairs the\r\n * dispatched event id with the Observable's EventState so that\r\n * `event/stopPropagation` can stop the remaining handlers of an in-flight\r\n * dispatch. A stack (rather than a single value) tolerates re-entrant\r\n * dispatching, e.g. an event handler synchronously sending another event.\r\n * @internal\r\n */\r\n public _eventDispatchStack: { eventId: string; state: EventState; propagationStopped: boolean }[] = [];\r\n\r\n public constructor(\r\n /**\r\n * the configuration of the block\r\n */\r\n public config: IFlowGraphCoordinatorConfiguration\r\n ) {\r\n this._attachToScene(this.config.scene);\r\n }\r\n\r\n private _attachToScene(scene: Scene): void {\r\n // When the scene is disposed, dispose all graphs currently running on it.\r\n this._disposeObserver = scene.onDisposeObservable.add(() => {\r\n this.dispose();\r\n });\r\n\r\n this._onBeforeRenderObserver = scene.onBeforeRenderObservable.add(() => {\r\n // Reset the event execution counter at the beginning of each frame.\r\n this._eventExecutionCounter.clear();\r\n // duplicate the _executeOnNextFrame array to avoid modifying it while iterating over it\r\n const executeOnNextFrame = this._executeOnNextFrame.slice(0);\r\n if (executeOnNextFrame.length) {\r\n // Execute the events that were triggered on the next frame.\r\n for (const event of executeOnNextFrame) {\r\n this.notifyCustomEvent(event.id, event.data, false);\r\n // remove the event from the array\r\n const index = this._executeOnNextFrame.findIndex((e) => e.uniqueId === event.uniqueId);\r\n if (index !== -1) {\r\n this._executeOnNextFrame.splice(index, 1);\r\n }\r\n }\r\n }\r\n });\r\n\r\n // Add itself to the SceneCoordinators list for the Inspector.\r\n let coordinators = FlowGraphCoordinator.SceneCoordinators.get(scene);\r\n if (!coordinators) {\r\n coordinators = [];\r\n FlowGraphCoordinator.SceneCoordinators.set(scene, coordinators);\r\n }\r\n coordinators.push(this);\r\n }\r\n\r\n private _detachFromScene(scene: Scene): void {\r\n this._disposeObserver.remove();\r\n this._onBeforeRenderObserver.remove();\r\n const coordinators = FlowGraphCoordinator.SceneCoordinators.get(scene);\r\n if (!coordinators) {\r\n return;\r\n }\r\n const index = coordinators.indexOf(this);\r\n if (index !== -1) {\r\n coordinators.splice(index, 1);\r\n }\r\n }\r\n\r\n /**\r\n * Reattaches this coordinator's lifecycle observers to another scene.\r\n * @param scene new scene owned by the coordinator\r\n * @param updateGraphs whether existing graphs should also be reattached\r\n * @internal\r\n */\r\n public _setScene(scene: Scene, updateGraphs = true): void {\r\n const previousScene = this.config.scene;\r\n if (scene === previousScene) {\r\n return;\r\n }\r\n this._detachFromScene(previousScene);\r\n this.config.scene = scene;\r\n if (updateGraphs) {\r\n for (const graph of this._flowGraphs) {\r\n graph.setScene(scene);\r\n }\r\n }\r\n this._attachToScene(scene);\r\n }\r\n\r\n /**\r\n * Creates a new flow graph and adds it to the list of existing flow graphs\r\n * @param name - optional name for the new graph. If not provided, an auto-generated name is used.\r\n * @returns a new flow graph\r\n */\r\n public createGraph(name?: string): FlowGraph {\r\n const graphName = name ?? `Graph ${this._flowGraphs.length + 1}`;\r\n const graph = new FlowGraph({ scene: this.config.scene, coordinator: this, name: graphName });\r\n this._flowGraphs.push(graph);\r\n FlowGraphCoordinator._OnFlowGraphAddedObservable.notifyObservers(graph);\r\n return graph;\r\n }\r\n\r\n /**\r\n * Removes a flow graph from the list of existing flow graphs and disposes it\r\n * @param graph the graph to remove\r\n */\r\n public removeGraph(graph: FlowGraph) {\r\n const index = this._flowGraphs.indexOf(graph);\r\n if (index !== -1) {\r\n graph.dispose();\r\n this._flowGraphs.splice(index, 1);\r\n FlowGraphCoordinator._OnFlowGraphRemovedObservable.notifyObservers(graph);\r\n }\r\n }\r\n\r\n /**\r\n * Starts all graphs\r\n */\r\n public start() {\r\n for (const graph of this._flowGraphs) {\r\n graph.start();\r\n }\r\n }\r\n\r\n /**\r\n * Disposes all graphs\r\n */\r\n public dispose() {\r\n for (const graph of this._flowGraphs) {\r\n graph.dispose();\r\n FlowGraphCoordinator._OnFlowGraphRemovedObservable.notifyObservers(graph);\r\n }\r\n this._flowGraphs.length = 0;\r\n this._detachFromScene(this.config.scene);\r\n }\r\n\r\n /**\r\n * Serializes this coordinator to a JSON object.\r\n * @param serializationObject the object to serialize to\r\n * @param valueSerializeFunction the function to use to serialize the value\r\n */\r\n public serialize(serializationObject: any, valueSerializeFunction?: (key: string, value: any, serializationObject: any) => void) {\r\n serializationObject._flowGraphs = [];\r\n for (const graph of this._flowGraphs) {\r\n const serializedGraph = {};\r\n graph.serialize(serializedGraph, valueSerializeFunction);\r\n serializationObject._flowGraphs.push(serializedGraph);\r\n }\r\n serializationObject.dispatchEventsSynchronously = this.dispatchEventsSynchronously;\r\n }\r\n\r\n /**\r\n * Gets the list of flow graphs\r\n */\r\n public get flowGraphs() {\r\n return this._flowGraphs;\r\n }\r\n\r\n /**\r\n * Get an observable that will be notified when the event with the given id is fired.\r\n * @param id the id of the event\r\n * @returns the observable for the event\r\n */\r\n public getCustomEventObservable(id: string): Observable<any> {\r\n let observable = this._customEventsMap.get(id);\r\n if (!observable) {\r\n // receive event is initialized before scene start, so no need to notify if triggered. but possible!\r\n observable = new Observable<any>(/*undefined, true*/);\r\n this._customEventsMap.set(id, observable);\r\n }\r\n return observable;\r\n }\r\n\r\n /**\r\n * Notifies the observable for the given event id with the given data.\r\n * @param id the id of the event\r\n * @param data the data to send with the event\r\n * @param async if true, the event will be dispatched asynchronously\r\n */\r\n public notifyCustomEvent(id: string, data: any, async: boolean = !this.dispatchEventsSynchronously) {\r\n if (async) {\r\n this._executeOnNextFrame.push({ id, data, uniqueId: this._eventUniqueId++ });\r\n return;\r\n }\r\n // check if we are not exceeding the max number of events\r\n if (this._eventExecutionCounter.has(id)) {\r\n const count = this._eventExecutionCounter.get(id)!;\r\n this._eventExecutionCounter.set(id, count + 1);\r\n if (count >= FlowGraphCoordinator.MaxEventTypeExecutionPerFrame) {\r\n if (count === FlowGraphCoordinator.MaxEventTypeExecutionPerFrame) {\r\n Logger.Warn(`FlowGraphCoordinator: Too many executions of event \"${id}\".`);\r\n }\r\n return;\r\n }\r\n } else {\r\n this._eventExecutionCounter.set(id, 1);\r\n }\r\n const observable = this._customEventsMap.get(id);\r\n if (observable) {\r\n observable.notifyObservers(data);\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n * Marks the beginning of a custom-event dispatch. Called by event receiver\r\n * blocks from within their Observable callback so that the dispatch's\r\n * EventState becomes reachable by `event/stopPropagation` while the receiver\r\n * flow executes synchronously.\r\n * @param eventId the id of the event being dispatched\r\n * @param state the Observable EventState for this dispatch\r\n */\r\n public _beginEventDispatch(eventId: string, state: EventState): void {\r\n this._eventDispatchStack.push({ eventId, state, propagationStopped: false });\r\n }\r\n\r\n /**\r\n * @internal\r\n * Marks the end of the most recent custom-event dispatch started with\r\n * {@link _beginEventDispatch}.\r\n */\r\n public _endEventDispatch(): { eventId: string; state: EventState; propagationStopped: boolean } | undefined {\r\n return this._eventDispatchStack.pop();\r\n }\r\n\r\n /**\r\n * Stops the propagation of an in-flight custom event, preventing any event\r\n * handler nodes that have not been activated yet from running for the current\r\n * dispatch.\r\n *\r\n * The `event` argument is the opaque event reference produced by an event block on its `event`\r\n * output. If it does not reference an event that is currently being dispatched, this is a no-op.\r\n *\r\n * Babylon custom events have no scene-graph propagation layer, so there are\r\n * no transitive activations to cancel when `stopImmediate` is false. When it\r\n * is true, the remaining handlers in the Observable dispatch are skipped.\r\n * @param event the event reference to stop propagation for\r\n * @param stopImmediate whether to also stop remaining immediate handlers\r\n */\r\n public stopEventPropagation(event: string, stopImmediate: boolean): void {\r\n if (typeof event !== \"string\") {\r\n return;\r\n }\r\n const decode = this.config.hostResolver?.decodeEventReference ?? GetDefaultEventReferenceKey;\r\n const eventId = decode(event);\r\n if (eventId === undefined) {\r\n return;\r\n }\r\n // Find the most recent matching in-flight dispatch and skip its remaining observers.\r\n for (let i = this._eventDispatchStack.length - 1; i >= 0; i--) {\r\n if (this._eventDispatchStack[i].eventId === eventId) {\r\n this._eventDispatchStack[i].propagationStopped = true;\r\n if (stopImmediate) {\r\n this._eventDispatchStack[i].state.skipNextObservers = true;\r\n }\r\n return;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n * Encodes an event source key as the opaque reference exposed on an event block's `event`\r\n * output, delegating to the host resolver when one is configured.\r\n * @param key the event source key\r\n * @returns the event reference\r\n */\r\n public _getEventReference(key: string): string {\r\n const encode = this.config.hostResolver?.encodeEventReference;\r\n return encode ? encode(key) : GetDefaultEventReference(key);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"flowGraphCoordinator.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraphCoordinator.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4D,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAE5G,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAIxC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAI1C,OAAO,EAA+B,2BAA2B,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAQ7H;;;GAGG;AACH,IAAI,0BAA0B,GAAqC,IAAI,CAAC;AACxE,IAAI,mBAAmB,GAA4B,IAAI,CAAC;AACxD,IAAI,wBAAwB,GAAG,CAAC,CAAC;AAEjC,SAAS,gCAAgC;IACrC,IAAI,wBAAwB,GAAG,CAAC,IAAI,CAAC,mBAAmB,EAAE,CAAC;QACvD,OAAO;IACX,CAAC;IACD,MAAM,MAAM,GAAG,mBAAmB,CAAC;IACnC,mBAAmB,GAAG,IAAI,CAAC;IAC3B,0BAA0B,GAAG,IAAI,CAAC;IAClC,MAAM,CAAC,OAAO,EAAE,CAAC;AACrB,CAAC;AAED,KAAK,UAAU,2BAA2B;IACtC,IAAI,CAAC,0BAA0B,EAAE,CAAC;QAC9B,0BAA0B,GAAG,CAAC,KAAK,IAAI,EAAE;YACrC,IAAI,CAAC;gBACD,MAAM,EAAE,sBAAsB,EAAE,GAAG,M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CAAC;gBACD,OAAO;YACX,CAAC;QACL,CAAC;IACL,CAAC;IAED;;;;;;OAMG;IACI,kBAAkB,CAAC,GAAW;QACjC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,oBAAoB,CAAC;QAC9D,OAAO,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,wBAAwB,CAAC,GAAG,CAAC,CAAC;IAChE,CAAC;;AAhbD;;;;GAIG;AACW,qCAAgB,GAAW,EAAE,AAAb,CAAc;AAE5C;;GAEG;AACW,kDAA6B,GAAW,EAAE,AAAb,CAAc;AACzD;;;GAGG;AACoB,sCAAiB,GAAuC,IAAI,GAAG,EAAE,AAAhD,CAAiD;AASjE,gDAA2B,GAAG,IAAI,UAAU,EAAa,AAA9B,CAA+B;AAS1D,kDAA6B,GAAG,IAAI,UAAU,EAAa,AAA9B,CAA+B","sourcesContent":["import { type EventState, type IReadonlyObservable, type Observer, Observable } from \"core/Misc/observable\";\r\nimport { type Scene } from \"../scene\";\r\nimport { FlowGraph } from \"./flowGraph\";\r\nimport { type IPathToObjectConverter } from \"../ObjectModel/objectModelInterfaces\";\r\nimport { type IObjectAccessor } from \"./typeDefinitions\";\r\nimport { type IAssetContainer } from \"core/IAssetContainer\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport { type Nullable } from \"core/types\";\r\nimport { type AudioEngineV2 } from \"../AudioV2/abstractAudio/audioEngineV2\";\r\nimport { type StaticSound } from \"../AudioV2/abstractAudio/staticSound\";\r\nimport { type IFlowGraphHostResolver, GetDefaultEventReferenceKey, GetDefaultEventReference } from \"./flowGraphHostResolver\";\r\nimport { type IFlowGraphSoundAsset } from \"./flowGraphSoundAssets\";\r\n\r\ninterface ISoundAssetEntry {\r\n asset: IFlowGraphSoundAsset;\r\n sound: Nullable<StaticSound>;\r\n}\r\n\r\n/**\r\n * Audio engine created by coordinators when no audio engine exists. It is shared by all coordinators\r\n * that need a fallback engine and disposed when the last of them is disposed.\r\n */\r\nlet FallbackAudioEnginePromise: Nullable<Promise<AudioEngineV2>> = null;\r\nlet FallbackAudioEngine: Nullable<AudioEngineV2> = null;\r\nlet FallbackAudioEngineUsers = 0;\r\n\r\nfunction DisposeUnusedFallbackAudioEngine(): void {\r\n if (FallbackAudioEngineUsers > 0 || !FallbackAudioEngine) {\r\n return;\r\n }\r\n const engine = FallbackAudioEngine;\r\n FallbackAudioEngine = null;\r\n FallbackAudioEnginePromise = null;\r\n engine.dispose();\r\n}\r\n\r\nasync function GetFallbackAudioEngineAsync(): Promise<AudioEngineV2> {\r\n if (!FallbackAudioEnginePromise) {\r\n FallbackAudioEnginePromise = (async () => {\r\n try {\r\n const { CreateAudioEngineAsync } = await import(\"../AudioV2/webAudio/webAudioEngine\");\r\n const engine = await CreateAudioEngineAsync();\r\n FallbackAudioEngine = engine;\r\n // All users may have been disposed while the engine was being created.\r\n DisposeUnusedFallbackAudioEngine();\r\n return engine;\r\n } catch (e) {\r\n FallbackAudioEnginePromise = null;\r\n throw e;\r\n }\r\n })();\r\n }\r\n return await FallbackAudioEnginePromise;\r\n}\r\n\r\n/**\r\n * Parameters used to create a flow graph engine.\r\n */\r\nexport interface IFlowGraphCoordinatorConfiguration {\r\n /**\r\n * The scene that the flow graph engine belongs to.\r\n */\r\n scene: Scene;\r\n /**\r\n * Optional resolver letting the environment hosting the graphs decide how runtime entities are\r\n * represented as opaque reference values. When omitted, a neutral built-in representation is used.\r\n */\r\n hostResolver?: IFlowGraphHostResolver;\r\n}\r\n\r\n/**\r\n * Parameters used to parse a flow graph coordinator.\r\n */\r\nexport interface IFlowGraphCoordinatorParseOptions {\r\n /**\r\n * A function that will be called to parse the value of a property.\r\n * @param key the key of the property\r\n * @param serializationObject the serialization object where the property is located\r\n * @param assetsContainer the assets container\r\n * @param scene the scene that the block is being parsed in\r\n */\r\n valueParseFunction?: (key: string, serializationObject: any, assetsContainer: IAssetContainer, scene: Scene) => any;\r\n /**\r\n * The path converter to use to convert the path to an object accessor.\r\n */\r\n pathConverter?: IPathToObjectConverter<IObjectAccessor>;\r\n /**\r\n * The scene that the flow graph coordinator belongs to.\r\n */\r\n scene: Scene;\r\n /**\r\n * The audio engine used to load the serialized sound assets.\r\n * When omitted, the most recently created audio engine is used, and a new one is created if none exists.\r\n */\r\n audioEngine?: AudioEngineV2;\r\n}\r\n/**\r\n * This class holds all of the existing flow graphs and is responsible for creating new ones.\r\n * It also handles starting/stopping multiple graphs and communication between them through an Event Coordinator\r\n * This is the entry point for the flow graph system.\r\n * @experimental This class is still in development and is subject to change.\r\n */\r\nexport class FlowGraphCoordinator {\r\n /**\r\n * The maximum number of events per type.\r\n * This is used to limit the number of events that can be created in a single scene.\r\n * This is to prevent infinite loops.\r\n */\r\n public static MaxEventsPerType: number = 30;\r\n\r\n /**\r\n * The maximum number of execution of a specific event in a single frame.\r\n */\r\n public static MaxEventTypeExecutionPerFrame: number = 30;\r\n /**\r\n * @internal\r\n * A list of all the coordinators per scene. Will be used by the inspector\r\n */\r\n public static readonly SceneCoordinators: Map<Scene, FlowGraphCoordinator[]> = new Map();\r\n\r\n /**\r\n * Observable raised when a flow graph is added to any coordinator. Used by the inspector to keep\r\n * the flow graph list in sync. The payload is the newly added flow graph.\r\n */\r\n public static get OnFlowGraphAddedObservable(): IReadonlyObservable<FlowGraph> {\r\n return this._OnFlowGraphAddedObservable;\r\n }\r\n private static readonly _OnFlowGraphAddedObservable = new Observable<FlowGraph>();\r\n\r\n /**\r\n * Observable raised when a flow graph is removed from any coordinator. Used by the inspector to keep\r\n * the flow graph list in sync. The payload is the removed flow graph.\r\n */\r\n public static get OnFlowGraphRemovedObservable(): IReadonlyObservable<FlowGraph> {\r\n return this._OnFlowGraphRemovedObservable;\r\n }\r\n private static readonly _OnFlowGraphRemovedObservable = new Observable<FlowGraph>();\r\n\r\n /**\r\n * When set to true (default) custom events will be dispatched synchronously.\r\n * This means that the events will be dispatched immediately when they are triggered.\r\n */\r\n public dispatchEventsSynchronously: boolean = true;\r\n\r\n private readonly _flowGraphs: FlowGraph[] = [];\r\n\r\n private _customEventsMap: Map<string, Observable<any>> = new Map();\r\n\r\n private readonly _soundAssets = new Map<string, ISoundAssetEntry>();\r\n\r\n private _usesFallbackAudioEngine = false;\r\n\r\n /**\r\n * Observable raised with the name of a sound asset when its loaded sound changes,\r\n * i.e. when the asset finishes loading, is replaced or is removed.\r\n */\r\n public readonly onSoundAssetChangedObservable = new Observable<string>();\r\n\r\n private _eventExecutionCounter: Map<string, number> = new Map();\r\n\r\n private _disposeObserver!: Observer<Scene>;\r\n private _onBeforeRenderObserver!: Observer<Scene>;\r\n private _executeOnNextFrame: { id: string; data?: any; uniqueId: number }[] = [];\r\n private _eventUniqueId: number = 0;\r\n\r\n /**\r\n * Stack of custom-event dispatches currently in progress. Each entry pairs the\r\n * dispatched event id with the Observable's EventState so that\r\n * `event/stopPropagation` can stop the remaining handlers of an in-flight\r\n * dispatch. A stack (rather than a single value) tolerates re-entrant\r\n * dispatching, e.g. an event handler synchronously sending another event.\r\n * @internal\r\n */\r\n public _eventDispatchStack: { eventId: string; state: EventState; propagationStopped: boolean }[] = [];\r\n\r\n public constructor(\r\n /**\r\n * the configuration of the block\r\n */\r\n public config: IFlowGraphCoordinatorConfiguration\r\n ) {\r\n this._attachToScene(this.config.scene);\r\n }\r\n\r\n private _attachToScene(scene: Scene): void {\r\n // When the scene is disposed, dispose all graphs currently running on it.\r\n this._disposeObserver = scene.onDisposeObservable.add(() => {\r\n this.dispose();\r\n });\r\n\r\n this._onBeforeRenderObserver = scene.onBeforeRenderObservable.add(() => {\r\n // Reset the event execution counter at the beginning of each frame.\r\n this._eventExecutionCounter.clear();\r\n // duplicate the _executeOnNextFrame array to avoid modifying it while iterating over it\r\n const executeOnNextFrame = this._executeOnNextFrame.slice(0);\r\n if (executeOnNextFrame.length) {\r\n // Execute the events that were triggered on the next frame.\r\n for (const event of executeOnNextFrame) {\r\n this.notifyCustomEvent(event.id, event.data, false);\r\n // remove the event from the array\r\n const index = this._executeOnNextFrame.findIndex((e) => e.uniqueId === event.uniqueId);\r\n if (index !== -1) {\r\n this._executeOnNextFrame.splice(index, 1);\r\n }\r\n }\r\n }\r\n });\r\n\r\n // Add itself to the SceneCoordinators list for the Inspector.\r\n let coordinators = FlowGraphCoordinator.SceneCoordinators.get(scene);\r\n if (!coordinators) {\r\n coordinators = [];\r\n FlowGraphCoordinator.SceneCoordinators.set(scene, coordinators);\r\n }\r\n coordinators.push(this);\r\n }\r\n\r\n private _detachFromScene(scene: Scene): void {\r\n this._disposeObserver.remove();\r\n this._onBeforeRenderObserver.remove();\r\n const coordinators = FlowGraphCoordinator.SceneCoordinators.get(scene);\r\n if (!coordinators) {\r\n return;\r\n }\r\n const index = coordinators.indexOf(this);\r\n if (index !== -1) {\r\n coordinators.splice(index, 1);\r\n }\r\n }\r\n\r\n /**\r\n * Reattaches this coordinator's lifecycle observers to another scene.\r\n * @param scene new scene owned by the coordinator\r\n * @param updateGraphs whether existing graphs should also be reattached\r\n * @internal\r\n */\r\n public _setScene(scene: Scene, updateGraphs = true): void {\r\n const previousScene = this.config.scene;\r\n if (scene === previousScene) {\r\n return;\r\n }\r\n this._detachFromScene(previousScene);\r\n this.config.scene = scene;\r\n if (updateGraphs) {\r\n for (const graph of this._flowGraphs) {\r\n graph.setScene(scene);\r\n }\r\n }\r\n this._attachToScene(scene);\r\n }\r\n\r\n /**\r\n * Creates a new flow graph and adds it to the list of existing flow graphs\r\n * @param name - optional name for the new graph. If not provided, an auto-generated name is used.\r\n * @returns a new flow graph\r\n */\r\n public createGraph(name?: string): FlowGraph {\r\n const graphName = name ?? `Graph ${this._flowGraphs.length + 1}`;\r\n const graph = new FlowGraph({ scene: this.config.scene, coordinator: this, name: graphName });\r\n this._flowGraphs.push(graph);\r\n FlowGraphCoordinator._OnFlowGraphAddedObservable.notifyObservers(graph);\r\n return graph;\r\n }\r\n\r\n /**\r\n * Removes a flow graph from the list of existing flow graphs and disposes it\r\n * @param graph the graph to remove\r\n */\r\n public removeGraph(graph: FlowGraph) {\r\n const index = this._flowGraphs.indexOf(graph);\r\n if (index !== -1) {\r\n graph.dispose();\r\n this._flowGraphs.splice(index, 1);\r\n FlowGraphCoordinator._OnFlowGraphRemovedObservable.notifyObservers(graph);\r\n }\r\n }\r\n\r\n /**\r\n * Starts all graphs\r\n */\r\n public start() {\r\n for (const graph of this._flowGraphs) {\r\n graph.start();\r\n }\r\n }\r\n\r\n /**\r\n * Disposes all graphs\r\n */\r\n public dispose() {\r\n for (const graph of this._flowGraphs) {\r\n graph.dispose();\r\n FlowGraphCoordinator._OnFlowGraphRemovedObservable.notifyObservers(graph);\r\n }\r\n this._flowGraphs.length = 0;\r\n for (const entry of this._soundAssets.values()) {\r\n entry.sound?.dispose();\r\n }\r\n this._soundAssets.clear();\r\n this.onSoundAssetChangedObservable.clear();\r\n if (this._usesFallbackAudioEngine) {\r\n this._usesFallbackAudioEngine = false;\r\n FallbackAudioEngineUsers--;\r\n DisposeUnusedFallbackAudioEngine();\r\n }\r\n this._detachFromScene(this.config.scene);\r\n }\r\n\r\n /**\r\n * Gets the sound assets declared on this coordinator.\r\n * Declared sound assets are serialized with the coordinator.\r\n */\r\n public get soundAssets(): IFlowGraphSoundAsset[] {\r\n return Array.from(this._soundAssets.values(), (entry) => ({ ...entry.asset }));\r\n }\r\n\r\n /**\r\n * Gets the loaded sound of a declared sound asset.\r\n * @param name the name of the sound asset\r\n * @returns the loaded sound, or null if the asset is not declared or not loaded yet\r\n */\r\n public getSoundAsset(name: string): Nullable<StaticSound> {\r\n return this._soundAssets.get(name)?.sound ?? null;\r\n }\r\n\r\n /**\r\n * Declares a sound asset on this coordinator and loads its sound.\r\n * An existing asset with the same name is replaced and its sound is disposed, so audio blocks that\r\n * reference the asset by name will play the new sound.\r\n * If loading fails, the asset stays declared (and serialized) without a sound, and the error is rethrown.\r\n * @param asset the sound asset to declare\r\n * @param audioEngine the audio engine used to load the sound. When omitted, the most recently created audio engine is used.\r\n * If no audio engine exists, a fallback engine is created; it is shared between coordinators and disposed with the last coordinator using it.\r\n * @returns a promise that resolves with the loaded sound\r\n */\r\n public async addSoundAssetAsync(asset: IFlowGraphSoundAsset, audioEngine?: AudioEngineV2): Promise<StaticSound> {\r\n // Copy the descriptor so that changes made by the caller while the sound loads do not affect this load.\r\n const entry: ISoundAssetEntry = { asset: { name: asset.name, url: asset.url }, sound: null };\r\n const { name, url } = entry.asset;\r\n this.removeSoundAsset(name);\r\n this._soundAssets.set(name, entry);\r\n\r\n const { CreateSoundAsync, LastCreatedAudioEngine } = await import(\"../AudioV2/abstractAudio/audioEngineV2\");\r\n this._throwIfSoundAssetChanged(entry);\r\n let engine: AudioEngineV2;\r\n if (audioEngine && audioEngine !== FallbackAudioEngine) {\r\n engine = audioEngine;\r\n } else {\r\n // A fallback engine is already listed by LastCreatedAudioEngine while it initializes, so join a pending\r\n // fallback before treating the last created engine as owned by someone else. Once the fallback is ready,\r\n // an engine created later by the application takes precedence.\r\n const isFallbackPending = !!FallbackAudioEnginePromise && !FallbackAudioEngine;\r\n const lastEngine = audioEngine ?? (isFallbackPending ? null : LastCreatedAudioEngine());\r\n if (lastEngine && lastEngine !== FallbackAudioEngine) {\r\n engine = lastEngine;\r\n } else {\r\n if (!this._usesFallbackAudioEngine) {\r\n this._usesFallbackAudioEngine = true;\r\n FallbackAudioEngineUsers++;\r\n }\r\n engine = await GetFallbackAudioEngineAsync();\r\n this._throwIfSoundAssetChanged(entry);\r\n }\r\n }\r\n\r\n const sound = await CreateSoundAsync(name, url, {}, engine);\r\n if (this._soundAssets.get(name) !== entry) {\r\n sound.dispose();\r\n this._throwIfSoundAssetChanged(entry);\r\n }\r\n entry.sound = sound;\r\n this.onSoundAssetChangedObservable.notifyObservers(name);\r\n return sound;\r\n }\r\n\r\n private _throwIfSoundAssetChanged(entry: ISoundAssetEntry): void {\r\n if (this._soundAssets.get(entry.asset.name) !== entry) {\r\n throw new Error(`Sound asset \"${entry.asset.name}\" was removed or replaced before it finished loading.`);\r\n }\r\n }\r\n\r\n /**\r\n * Removes a declared sound asset and disposes its sound.\r\n * @param name the name of the sound asset to remove\r\n */\r\n public removeSoundAsset(name: string): void {\r\n const entry = this._soundAssets.get(name);\r\n if (!entry) {\r\n return;\r\n }\r\n entry.sound?.dispose();\r\n this._soundAssets.delete(name);\r\n this.onSoundAssetChangedObservable.notifyObservers(name);\r\n }\r\n\r\n /**\r\n * Serializes this coordinator to a JSON object.\r\n * @param serializationObject the object to serialize to\r\n * @param valueSerializeFunction the function to use to serialize the value\r\n */\r\n public serialize(serializationObject: any, valueSerializeFunction?: (key: string, value: any, serializationObject: any) => void) {\r\n serializationObject._flowGraphs = [];\r\n for (const graph of this._flowGraphs) {\r\n const serializedGraph: any = {};\r\n graph.serialize(serializedGraph, valueSerializeFunction);\r\n serializationObject._flowGraphs.push(serializedGraph);\r\n }\r\n serializationObject.dispatchEventsSynchronously = this.dispatchEventsSynchronously;\r\n if (this._soundAssets.size > 0) {\r\n serializationObject.soundAssets = this.soundAssets;\r\n } else {\r\n delete serializationObject.soundAssets;\r\n }\r\n delete serializationObject.referenceProvenance;\r\n }\r\n\r\n /**\r\n * Gets the list of flow graphs\r\n */\r\n public get flowGraphs() {\r\n return this._flowGraphs;\r\n }\r\n\r\n /**\r\n * Get an observable that will be notified when the event with the given id is fired.\r\n * @param id the id of the event\r\n * @returns the observable for the event\r\n */\r\n public getCustomEventObservable(id: string): Observable<any> {\r\n let observable = this._customEventsMap.get(id);\r\n if (!observable) {\r\n // receive event is initialized before scene start, so no need to notify if triggered. but possible!\r\n observable = new Observable<any>(/*undefined, true*/);\r\n this._customEventsMap.set(id, observable);\r\n }\r\n return observable;\r\n }\r\n\r\n /**\r\n * Notifies the observable for the given event id with the given data.\r\n * @param id the id of the event\r\n * @param data the data to send with the event\r\n * @param async if true, the event will be dispatched asynchronously\r\n */\r\n public notifyCustomEvent(id: string, data: any, async: boolean = !this.dispatchEventsSynchronously) {\r\n if (async) {\r\n this._executeOnNextFrame.push({ id, data, uniqueId: this._eventUniqueId++ });\r\n return;\r\n }\r\n // check if we are not exceeding the max number of events\r\n if (this._eventExecutionCounter.has(id)) {\r\n const count = this._eventExecutionCounter.get(id)!;\r\n this._eventExecutionCounter.set(id, count + 1);\r\n if (count >= FlowGraphCoordinator.MaxEventTypeExecutionPerFrame) {\r\n if (count === FlowGraphCoordinator.MaxEventTypeExecutionPerFrame) {\r\n Logger.Warn(`FlowGraphCoordinator: Too many executions of event \"${id}\".`);\r\n }\r\n return;\r\n }\r\n } else {\r\n this._eventExecutionCounter.set(id, 1);\r\n }\r\n const observable = this._customEventsMap.get(id);\r\n if (observable) {\r\n observable.notifyObservers(data);\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n * Marks the beginning of a custom-event dispatch. Called by event receiver\r\n * blocks from within their Observable callback so that the dispatch's\r\n * EventState becomes reachable by `event/stopPropagation` while the receiver\r\n * flow executes synchronously.\r\n * @param eventId the id of the event being dispatched\r\n * @param state the Observable EventState for this dispatch\r\n */\r\n public _beginEventDispatch(eventId: string, state: EventState): void {\r\n this._eventDispatchStack.push({ eventId, state, propagationStopped: false });\r\n }\r\n\r\n /**\r\n * @internal\r\n * Marks the end of the most recent custom-event dispatch started with\r\n * {@link _beginEventDispatch}.\r\n */\r\n public _endEventDispatch(): { eventId: string; state: EventState; propagationStopped: boolean } | undefined {\r\n return this._eventDispatchStack.pop();\r\n }\r\n\r\n /**\r\n * Stops the propagation of an in-flight custom event, preventing any event\r\n * handler nodes that have not been activated yet from running for the current\r\n * dispatch.\r\n *\r\n * The `event` argument is the opaque event reference produced by an event block on its `event`\r\n * output. If it does not reference an event that is currently being dispatched, this is a no-op.\r\n *\r\n * Babylon custom events have no scene-graph propagation layer, so there are\r\n * no transitive activations to cancel when `stopImmediate` is false. When it\r\n * is true, the remaining handlers in the Observable dispatch are skipped.\r\n * @param event the event reference to stop propagation for\r\n * @param stopImmediate whether to also stop remaining immediate handlers\r\n */\r\n public stopEventPropagation(event: string, stopImmediate: boolean): void {\r\n if (typeof event !== \"string\") {\r\n return;\r\n }\r\n const decode = this.config.hostResolver?.decodeEventReference ?? GetDefaultEventReferenceKey;\r\n const eventId = decode(event);\r\n if (eventId === undefined) {\r\n return;\r\n }\r\n // Find the most recent matching in-flight dispatch and skip its remaining observers.\r\n for (let i = this._eventDispatchStack.length - 1; i >= 0; i--) {\r\n if (this._eventDispatchStack[i].eventId === eventId) {\r\n this._eventDispatchStack[i].propagationStopped = true;\r\n if (stopImmediate) {\r\n this._eventDispatchStack[i].state.skipNextObservers = true;\r\n }\r\n return;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n * Encodes an event source key as the opaque reference exposed on an event block's `event`\r\n * output, delegating to the host resolver when one is configured.\r\n * @param key the event source key\r\n * @returns the event reference\r\n */\r\n public _getEventReference(key: string): string {\r\n const encode = this.config.hostResolver?.encodeEventReference;\r\n return encode ? encode(key) : GetDefaultEventReference(key);\r\n }\r\n}\r\n"]}
|
|
@@ -1,8 +1,35 @@
|
|
|
1
1
|
/** This file must only contain pure code and pure imports */
|
|
2
2
|
import { FlowGraphConnection } from "./flowGraphConnection.js";
|
|
3
3
|
import { Observable } from "../Misc/observable.pure.js";
|
|
4
|
-
import { defaultValueSerializationFunction, GetSceneNodeFromSerializedReference } from "./serialization.js";
|
|
4
|
+
import { defaultValueSerializationFunction, GetSceneNodeFromSerializedReference, _IsSerializedNodeReference } from "./serialization.js";
|
|
5
5
|
import { RegisterClass } from "../Misc/typeStore.js";
|
|
6
|
+
/**
|
|
7
|
+
* Resolves a node or a serialized node reference against a scene.
|
|
8
|
+
* @param value a scene node, or a serialized node reference left by the parser
|
|
9
|
+
* @param scene the scene to resolve the reference against
|
|
10
|
+
* @returns the matching node in the scene, or undefined when the value does not need to (or cannot) be rebound
|
|
11
|
+
*/
|
|
12
|
+
function _ReresolveNodeReference(value, scene) {
|
|
13
|
+
if (!value || typeof value !== "object") {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
let reference;
|
|
17
|
+
if (typeof value.getClassName === "function" && typeof value.getScene === "function") {
|
|
18
|
+
// A scene node — only rebind when it belongs to a different scene.
|
|
19
|
+
if (value.getScene() === scene) {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
reference = { id: value.id, name: value.name, className: value.getClassName(), uniqueId: value.uniqueId };
|
|
23
|
+
}
|
|
24
|
+
else if (_IsSerializedNodeReference(value)) {
|
|
25
|
+
// An unresolved serialized node reference left by the parser.
|
|
26
|
+
reference = value;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
return GetSceneNodeFromSerializedReference(reference, scene);
|
|
32
|
+
}
|
|
6
33
|
/**
|
|
7
34
|
* Represents a connection point for data.
|
|
8
35
|
* An unconnected input point can have a default value.
|
|
@@ -120,22 +147,22 @@ export class FlowGraphDataConnection extends FlowGraphConnection {
|
|
|
120
147
|
if (!value || typeof value !== "object") {
|
|
121
148
|
return;
|
|
122
149
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
150
|
+
if (Array.isArray(value)) {
|
|
151
|
+
let changed = false;
|
|
152
|
+
const resolved = value.map((entry) => {
|
|
153
|
+
const node = _ReresolveNodeReference(entry, scene);
|
|
154
|
+
if (node) {
|
|
155
|
+
changed = true;
|
|
156
|
+
return node;
|
|
157
|
+
}
|
|
158
|
+
return entry;
|
|
159
|
+
});
|
|
160
|
+
if (changed) {
|
|
161
|
+
this._defaultValue = resolved;
|
|
128
162
|
}
|
|
129
|
-
reference = { id: value.id, name: value.name, className: value.getClassName(), uniqueId: value.uniqueId };
|
|
130
|
-
}
|
|
131
|
-
else if (typeof value.className === "string" && (value.id || value.name) && value.value === undefined) {
|
|
132
|
-
// An unresolved serialized node reference left by the parser.
|
|
133
|
-
reference = value;
|
|
134
|
-
}
|
|
135
|
-
else {
|
|
136
163
|
return;
|
|
137
164
|
}
|
|
138
|
-
const node =
|
|
165
|
+
const node = _ReresolveNodeReference(value, scene);
|
|
139
166
|
if (node) {
|
|
140
167
|
this._defaultValue = node;
|
|
141
168
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flowGraphDataConnection.pure.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraphDataConnection.pure.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAI7D,OAAO,EAAE,mBAAmB,EAA2B,MAAM,uBAAuB,CAAC;AAGrF,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,iCAAiC,EAAE,mCAAmC,EAAE,MAAM,iBAAiB,CAAC;AACzG,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD;;;;;GAKG;AACH,MAAM,OAAO,uBAA2B,SAAQ,mBAA+D;IAkB3G;;;;;;;;OAQG;IACH,YACI,IAAY,EACZ,cAAuC,EACvC,UAA0B;IAC1B;;OAEG;IACI,QAAqB;IAC5B;;OAEG;IACK,gBAAmB,QAAQ,CAAC,YAAY;IAChD;;OAEG;IACK,YAAqB,KAAK;QAElC,KAAK,CAAC,IAAI,EAAE,cAAc,EAAE,UAAU,CAAC,CAAC;QAVjC,aAAQ,GAAR,QAAQ,CAAa;QAIpB,kBAAa,GAAb,aAAa,CAA2B;QAIxC,cAAS,GAAT,SAAS,CAAiB;QAzC9B,gBAAW,GAAY,KAAK,CAAC;QACrC;;;WAGG;QACK,eAAU,GAAgB,IAAI,CAAC;QAEvC;;;WAGG;QACI,oBAAe,GAA8B,IAAI,CAAC;QAEzD;;WAEG;QACI,6BAAwB,GAAG,IAAI,UAAU,EAAK,CAAC;IA4BtD,CAAC;IAED;;;OAGG;IACH,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED;;;OAGG;IACH,IAAW,UAAU;QACjB,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAA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,OAAO;IACX,CAAC;IACD,WAAW,GAAG,IAAI,CAAC;IAEnB,aAAa,CAAC,yBAAyB,EAAE,uBAAuB,CAAC,CAAC;AACtE,CAAC","sourcesContent":["/** This file must only contain pure code and pure imports */\r\n\r\nimport { type Nullable } from \"core/types\";\r\nimport { type FlowGraphBlock } from \"./flowGraphBlock\";\r\nimport { FlowGraphConnection, FlowGraphConnectionType } from \"./flowGraphConnection\";\r\nimport { type FlowGraphContext } from \"./flowGraphContext\";\r\nimport { type RichType } from \"./flowGraphRichTypes.pure\";\r\nimport { Observable } from \"core/Misc/observable.pure\";\r\nimport { defaultValueSerializationFunction, GetSceneNodeFromSerializedReference } from \"./serialization\";\r\nimport { RegisterClass } from \"../Misc/typeStore\";\r\nimport { type Scene } from \"core/scene\";\r\n/**\r\n * Represents a connection point for data.\r\n * An unconnected input point can have a default value.\r\n * An output point will only have a value if it is connected to an input point. Furthermore,\r\n * if the point belongs to a \"function\" node, the node will run its function to update the value.\r\n */\r\nexport class FlowGraphDataConnection<T> extends FlowGraphConnection<FlowGraphBlock, FlowGraphDataConnection<T>> {\r\n private _isDisabled: boolean = false;\r\n /**\r\n * This is used for debugging purposes! It is the last value that was set to this connection with ANY context.\r\n * Do not use this value for anything else, as it might be wrong if used in a different context.\r\n */\r\n private _lastValue: Nullable<T> = null;\r\n\r\n /**\r\n * a data transformer function, if needed.\r\n * This can be used, for example, to force seconds into milliseconds output, if it makes sense in your case.\r\n */\r\n public dataTransformer: Nullable<(value: T) => T> = null;\r\n\r\n /**\r\n * An observable that is triggered when the value of the connection changes.\r\n */\r\n public onValueChangedObservable = new Observable<T>();\r\n /**\r\n * Create a new data connection point.\r\n * @param name the name of the connection\r\n * @param connectionType the type of the connection\r\n * @param ownerBlock the block that owns this connection\r\n * @param richType the type of the data in this block\r\n * @param _defaultValue the default value of the connection\r\n * @param _optional if the connection is optional\r\n */\r\n public constructor(\r\n name: string,\r\n connectionType: FlowGraphConnectionType,\r\n ownerBlock: FlowGraphBlock,\r\n /**\r\n * the type of the data in this block\r\n */\r\n public richType: RichType<T>,\r\n /**\r\n * [any] the default value of the connection\r\n */\r\n private _defaultValue: T = richType.defaultValue,\r\n /**\r\n * [false] if the connection is optional\r\n */\r\n private _optional: boolean = false\r\n ) {\r\n super(name, connectionType, ownerBlock);\r\n }\r\n\r\n /**\r\n * Whether or not the connection is optional.\r\n * Currently only used for UI control.\r\n */\r\n public get optional(): boolean {\r\n return this._optional;\r\n }\r\n\r\n /**\r\n * is this connection disabled\r\n * If the connection is disabled you will not be able to connect anything to it.\r\n */\r\n public get isDisabled(): boolean {\r\n return this._isDisabled;\r\n }\r\n\r\n public set isDisabled(value: boolean) {\r\n if (this._isDisabled === value) {\r\n return;\r\n }\r\n this._isDisabled = value;\r\n if (this._isDisabled) {\r\n this.disconnectFromAll();\r\n }\r\n }\r\n\r\n /**\r\n * An output data block can connect to multiple input data blocks,\r\n * but an input data block can only connect to one output data block.\r\n * @returns true if the connection is singular\r\n */\r\n public override _isSingularConnection(): boolean {\r\n return this.connectionType === FlowGraphConnectionType.Input;\r\n }\r\n\r\n /**\r\n * Set the value of the connection in a specific context.\r\n * @param value the value to set\r\n * @param context the context to which the value is set\r\n */\r\n public setValue(value: T, context: FlowGraphContext): void {\r\n // check if the value is different\r\n if (context._getConnectionValue(this) === value) {\r\n return;\r\n }\r\n context._setConnectionValue(this, value);\r\n this.onValueChangedObservable.notifyObservers(value);\r\n }\r\n\r\n /**\r\n * Reset the value of the connection to the default value.\r\n * @param context the context in which the value is reset\r\n */\r\n public resetToDefaultValue(context: FlowGraphContext): void {\r\n context._setConnectionValue(this, this._defaultValue);\r\n }\r\n\r\n /**\r\n * Re-resolves this input's default value against a (new) scene when the value is a node reference.\r\n * This handles two cases that occur when a graph is moved to a different scene (see\r\n * {@link FlowGraph.setScene}):\r\n * - the value is still an unresolved serialized reference (`{ id, name, className, uniqueId }`)\r\n * because the node did not yet exist in the scene at parse time, or\r\n * - the value is a node that belongs to a different (e.g. disposed) scene.\r\n * Values that are not node references (numbers, vectors, matrices, etc.) are left untouched, and\r\n * the default value is only replaced when a matching node is found in the new scene.\r\n * @param scene the scene to resolve the reference against\r\n * @internal\r\n */\r\n public _reresolveDefaultValueForScene(scene: Scene): void {\r\n const value = this._defaultValue as any;\r\n if (!value || typeof value !== \"object\") {\r\n return;\r\n }\r\n\r\n let reference: { id?: string; name?: string; className?: string; uniqueId?: number } | undefined;\r\n if (typeof value.getClassName === \"function\" && typeof value.getScene === \"function\") {\r\n // A scene node — only rebind when it belongs to a different scene.\r\n if (value.getScene() === scene) {\r\n return;\r\n }\r\n reference = { id: value.id, name: value.name, className: value.getClassName(), uniqueId: value.uniqueId };\r\n } else if (typeof value.className === \"string\" && (value.id || value.name) && value.value === undefined) {\r\n // An unresolved serialized node reference left by the parser.\r\n reference = value;\r\n } else {\r\n return;\r\n }\r\n\r\n const node = GetSceneNodeFromSerializedReference(reference, scene);\r\n if (node) {\r\n this._defaultValue = node as unknown as T;\r\n }\r\n }\r\n\r\n /**\r\n * Connect this point to another point.\r\n * @param point the point to connect to.\r\n */\r\n public override connectTo(point: FlowGraphDataConnection<T>): void {\r\n if (this._isDisabled) {\r\n return;\r\n }\r\n super.connectTo(point);\r\n }\r\n\r\n private _getValueOrDefault(context: FlowGraphContext): T {\r\n const val = context._getConnectionValue(this) ?? this._defaultValue;\r\n return this.dataTransformer ? this.dataTransformer(val) : val;\r\n }\r\n\r\n /**\r\n * Gets the value of the connection in a specific context.\r\n * @param context the context from which the value is retrieved\r\n * @returns the value of the connection\r\n */\r\n public getValue(context: FlowGraphContext): T {\r\n if (this.connectionType === FlowGraphConnectionType.Output) {\r\n context._notifyExecuteNode(this._ownerBlock);\r\n this._ownerBlock._updateOutputs(context);\r\n const value = this._getValueOrDefault(context);\r\n this._lastValue = value;\r\n return this.richType.typeTransformer ? this.richType.typeTransformer(value) : value;\r\n }\r\n const value = !this.isConnected() ? this._getValueOrDefault(context) : this._connectedPoint[0].getValue(context);\r\n this._lastValue = value;\r\n return this.richType.typeTransformer ? this.richType.typeTransformer(value) : value;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _getLastValue(): Nullable<T> {\r\n return this._lastValue;\r\n }\r\n\r\n /**\r\n * @returns class name of the object.\r\n */\r\n public override getClassName(): string {\r\n return \"FlowGraphDataConnection\";\r\n }\r\n\r\n /**\r\n * Serializes this object.\r\n * @param serializationObject the object to serialize to\r\n */\r\n public override serialize(serializationObject: any = {}) {\r\n super.serialize(serializationObject);\r\n serializationObject.richType = {};\r\n this.richType.serialize(serializationObject.richType);\r\n serializationObject.optional = this._optional;\r\n defaultValueSerializationFunction(\"defaultValue\", this._defaultValue, serializationObject);\r\n }\r\n}\r\n\r\nlet _Registered = false;\r\n/**\r\n * Register side effects for flowGraphDataConnection.\r\n * Safe to call multiple times; only the first call has an effect.\r\n */\r\nexport function RegisterFlowGraphDataConnection(): void {\r\n if (_Registered) {\r\n return;\r\n }\r\n _Registered = true;\r\n\r\n RegisterClass(\"FlowGraphDataConnection\", FlowGraphDataConnection);\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"flowGraphDataConnection.pure.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraphDataConnection.pure.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAI7D,OAAO,EAAE,mBAAmB,EAA2B,MAAM,uBAAuB,CAAC;AAGrF,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,iCAAiC,EAAE,mCAAmC,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AACrI,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAIlD;;;;;GAKG;AACH,SAAS,uBAAuB,CAAC,KAAU,EAAE,KAAY;IACrD,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACtC,OAAO,SAAS,CAAC;IACrB,CAAC;IACD,IAAI,SAAgF,CAAC;IACrF,IAAI,O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B,aAAa,CAAC,yBAAyB,EAAE,uBAAuB,CAAC,CAAC;AACtE,CAAC","sourcesContent":["/** This file must only contain pure code and pure imports */\r\n\r\nimport { type Nullable } from \"core/types\";\r\nimport { type FlowGraphBlock } from \"./flowGraphBlock\";\r\nimport { FlowGraphConnection, FlowGraphConnectionType } from \"./flowGraphConnection\";\r\nimport { type FlowGraphContext } from \"./flowGraphContext\";\r\nimport { type RichType } from \"./flowGraphRichTypes.pure\";\r\nimport { Observable } from \"core/Misc/observable.pure\";\r\nimport { defaultValueSerializationFunction, GetSceneNodeFromSerializedReference, _IsSerializedNodeReference } from \"./serialization\";\r\nimport { RegisterClass } from \"../Misc/typeStore\";\r\nimport { type Scene } from \"core/scene\";\r\nimport { type Node } from \"core/node\";\r\n\r\n/**\r\n * Resolves a node or a serialized node reference against a scene.\r\n * @param value a scene node, or a serialized node reference left by the parser\r\n * @param scene the scene to resolve the reference against\r\n * @returns the matching node in the scene, or undefined when the value does not need to (or cannot) be rebound\r\n */\r\nfunction _ReresolveNodeReference(value: any, scene: Scene): Node | undefined {\r\n if (!value || typeof value !== \"object\") {\r\n return undefined;\r\n }\r\n let reference: { id?: string; name?: string; className?: string; uniqueId?: number };\r\n if (typeof value.getClassName === \"function\" && typeof value.getScene === \"function\") {\r\n // A scene node — only rebind when it belongs to a different scene.\r\n if (value.getScene() === scene) {\r\n return undefined;\r\n }\r\n reference = { id: value.id, name: value.name, className: value.getClassName(), uniqueId: value.uniqueId };\r\n } else if (_IsSerializedNodeReference(value)) {\r\n // An unresolved serialized node reference left by the parser.\r\n reference = value;\r\n } else {\r\n return undefined;\r\n }\r\n return GetSceneNodeFromSerializedReference(reference, scene);\r\n}\r\n/**\r\n * Represents a connection point for data.\r\n * An unconnected input point can have a default value.\r\n * An output point will only have a value if it is connected to an input point. Furthermore,\r\n * if the point belongs to a \"function\" node, the node will run its function to update the value.\r\n */\r\nexport class FlowGraphDataConnection<T> extends FlowGraphConnection<FlowGraphBlock, FlowGraphDataConnection<T>> {\r\n private _isDisabled: boolean = false;\r\n /**\r\n * This is used for debugging purposes! It is the last value that was set to this connection with ANY context.\r\n * Do not use this value for anything else, as it might be wrong if used in a different context.\r\n */\r\n private _lastValue: Nullable<T> = null;\r\n\r\n /**\r\n * a data transformer function, if needed.\r\n * This can be used, for example, to force seconds into milliseconds output, if it makes sense in your case.\r\n */\r\n public dataTransformer: Nullable<(value: T) => T> = null;\r\n\r\n /**\r\n * An observable that is triggered when the value of the connection changes.\r\n */\r\n public onValueChangedObservable = new Observable<T>();\r\n /**\r\n * Create a new data connection point.\r\n * @param name the name of the connection\r\n * @param connectionType the type of the connection\r\n * @param ownerBlock the block that owns this connection\r\n * @param richType the type of the data in this block\r\n * @param _defaultValue the default value of the connection\r\n * @param _optional if the connection is optional\r\n */\r\n public constructor(\r\n name: string,\r\n connectionType: FlowGraphConnectionType,\r\n ownerBlock: FlowGraphBlock,\r\n /**\r\n * the type of the data in this block\r\n */\r\n public richType: RichType<T>,\r\n /**\r\n * [any] the default value of the connection\r\n */\r\n private _defaultValue: T = richType.defaultValue,\r\n /**\r\n * [false] if the connection is optional\r\n */\r\n private _optional: boolean = false\r\n ) {\r\n super(name, connectionType, ownerBlock);\r\n }\r\n\r\n /**\r\n * Whether or not the connection is optional.\r\n * Currently only used for UI control.\r\n */\r\n public get optional(): boolean {\r\n return this._optional;\r\n }\r\n\r\n /**\r\n * is this connection disabled\r\n * If the connection is disabled you will not be able to connect anything to it.\r\n */\r\n public get isDisabled(): boolean {\r\n return this._isDisabled;\r\n }\r\n\r\n public set isDisabled(value: boolean) {\r\n if (this._isDisabled === value) {\r\n return;\r\n }\r\n this._isDisabled = value;\r\n if (this._isDisabled) {\r\n this.disconnectFromAll();\r\n }\r\n }\r\n\r\n /**\r\n * An output data block can connect to multiple input data blocks,\r\n * but an input data block can only connect to one output data block.\r\n * @returns true if the connection is singular\r\n */\r\n public override _isSingularConnection(): boolean {\r\n return this.connectionType === FlowGraphConnectionType.Input;\r\n }\r\n\r\n /**\r\n * Set the value of the connection in a specific context.\r\n * @param value the value to set\r\n * @param context the context to which the value is set\r\n */\r\n public setValue(value: T, context: FlowGraphContext): void {\r\n // check if the value is different\r\n if (context._getConnectionValue(this) === value) {\r\n return;\r\n }\r\n context._setConnectionValue(this, value);\r\n this.onValueChangedObservable.notifyObservers(value);\r\n }\r\n\r\n /**\r\n * Reset the value of the connection to the default value.\r\n * @param context the context in which the value is reset\r\n */\r\n public resetToDefaultValue(context: FlowGraphContext): void {\r\n context._setConnectionValue(this, this._defaultValue);\r\n }\r\n\r\n /**\r\n * Re-resolves this input's default value against a (new) scene when the value is a node reference.\r\n * This handles two cases that occur when a graph is moved to a different scene (see\r\n * {@link FlowGraph.setScene}):\r\n * - the value is still an unresolved serialized reference (`{ id, name, className, uniqueId }`)\r\n * because the node did not yet exist in the scene at parse time, or\r\n * - the value is a node that belongs to a different (e.g. disposed) scene.\r\n * Values that are not node references (numbers, vectors, matrices, etc.) are left untouched, and\r\n * the default value is only replaced when a matching node is found in the new scene.\r\n * @param scene the scene to resolve the reference against\r\n * @internal\r\n */\r\n public _reresolveDefaultValueForScene(scene: Scene): void {\r\n const value = this._defaultValue as any;\r\n if (!value || typeof value !== \"object\") {\r\n return;\r\n }\r\n\r\n if (Array.isArray(value)) {\r\n let changed = false;\r\n const resolved = value.map((entry) => {\r\n const node = _ReresolveNodeReference(entry, scene);\r\n if (node) {\r\n changed = true;\r\n return node;\r\n }\r\n return entry;\r\n });\r\n if (changed) {\r\n this._defaultValue = resolved as unknown as T;\r\n }\r\n return;\r\n }\r\n\r\n const node = _ReresolveNodeReference(value, scene);\r\n if (node) {\r\n this._defaultValue = node as unknown as T;\r\n }\r\n }\r\n\r\n /**\r\n * Connect this point to another point.\r\n * @param point the point to connect to.\r\n */\r\n public override connectTo(point: FlowGraphDataConnection<T>): void {\r\n if (this._isDisabled) {\r\n return;\r\n }\r\n super.connectTo(point);\r\n }\r\n\r\n private _getValueOrDefault(context: FlowGraphContext): T {\r\n const val = context._getConnectionValue(this) ?? this._defaultValue;\r\n return this.dataTransformer ? this.dataTransformer(val) : val;\r\n }\r\n\r\n /**\r\n * Gets the value of the connection in a specific context.\r\n * @param context the context from which the value is retrieved\r\n * @returns the value of the connection\r\n */\r\n public getValue(context: FlowGraphContext): T {\r\n if (this.connectionType === FlowGraphConnectionType.Output) {\r\n context._notifyExecuteNode(this._ownerBlock);\r\n this._ownerBlock._updateOutputs(context);\r\n const value = this._getValueOrDefault(context);\r\n this._lastValue = value;\r\n return this.richType.typeTransformer ? this.richType.typeTransformer(value) : value;\r\n }\r\n const value = !this.isConnected() ? this._getValueOrDefault(context) : this._connectedPoint[0].getValue(context);\r\n this._lastValue = value;\r\n return this.richType.typeTransformer ? this.richType.typeTransformer(value) : value;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _getLastValue(): Nullable<T> {\r\n return this._lastValue;\r\n }\r\n\r\n /**\r\n * @returns class name of the object.\r\n */\r\n public override getClassName(): string {\r\n return \"FlowGraphDataConnection\";\r\n }\r\n\r\n /**\r\n * Serializes this object.\r\n * @param serializationObject the object to serialize to\r\n */\r\n public override serialize(serializationObject: any = {}) {\r\n super.serialize(serializationObject);\r\n serializationObject.richType = {};\r\n this.richType.serialize(serializationObject.richType);\r\n serializationObject.optional = this._optional;\r\n defaultValueSerializationFunction(\"defaultValue\", this._defaultValue, serializationObject);\r\n }\r\n}\r\n\r\nlet _Registered = false;\r\n/**\r\n * Register side effects for flowGraphDataConnection.\r\n * Safe to call multiple times; only the first call has an effect.\r\n */\r\nexport function RegisterFlowGraphDataConnection(): void {\r\n if (_Registered) {\r\n return;\r\n }\r\n _Registered = true;\r\n\r\n RegisterClass(\"FlowGraphDataConnection\", FlowGraphDataConnection);\r\n}\r\n"]}
|
|
@@ -6,6 +6,69 @@ import { _GetDefaultEventDataParseCount, defaultValueParseFunction, needsPathCon
|
|
|
6
6
|
import { getRichTypeByFlowGraphType, RichType } from "./flowGraphRichTypes.pure.js";
|
|
7
7
|
|
|
8
8
|
import { WebRequest } from "../Misc/webRequest.js";
|
|
9
|
+
import { Logger } from "../Misc/logger.js";
|
|
10
|
+
function _CreateReferenceProvenanceParseFunction(baseValueParseFunction, provenance) {
|
|
11
|
+
const locations = new Map();
|
|
12
|
+
const provenanceIndexes = new Map();
|
|
13
|
+
for (let provenanceIndex = 0; provenanceIndex < provenance.length; provenanceIndex++) {
|
|
14
|
+
const [uniqueId, location] = provenance[provenanceIndex];
|
|
15
|
+
const matchingLocations = locations.get(uniqueId) ?? [];
|
|
16
|
+
matchingLocations.push(location);
|
|
17
|
+
locations.set(uniqueId, matchingLocations);
|
|
18
|
+
provenanceIndexes.set(location, provenanceIndex);
|
|
19
|
+
}
|
|
20
|
+
const resolve = (serializedValue, parsedValue, scene) => {
|
|
21
|
+
if (Array.isArray(serializedValue)) {
|
|
22
|
+
if (!Array.isArray(parsedValue) ||
|
|
23
|
+
!serializedValue.every((entry) => entry && typeof entry === "object" && typeof entry.uniqueId === "number" && typeof entry.className === "string")) {
|
|
24
|
+
return parsedValue;
|
|
25
|
+
}
|
|
26
|
+
let changed = false;
|
|
27
|
+
const resolved = serializedValue.map((entry, index) => {
|
|
28
|
+
const resolvedEntry = resolve(entry, parsedValue[index], scene);
|
|
29
|
+
changed || (changed = resolvedEntry !== parsedValue[index]);
|
|
30
|
+
return resolvedEntry;
|
|
31
|
+
});
|
|
32
|
+
return changed ? resolved : parsedValue;
|
|
33
|
+
}
|
|
34
|
+
if (!serializedValue || typeof serializedValue !== "object" || typeof serializedValue.uniqueId !== "number" || typeof serializedValue.className !== "string") {
|
|
35
|
+
return parsedValue;
|
|
36
|
+
}
|
|
37
|
+
const matchingLocations = locations.get(serializedValue.uniqueId);
|
|
38
|
+
const location = matchingLocations?.find((candidate) => candidate.className === serializedValue.className && candidate.id === serializedValue.id && candidate.name === serializedValue.name) ??
|
|
39
|
+
matchingLocations?.find((candidate) => candidate.className === serializedValue.className && candidate.id === serializedValue.id) ??
|
|
40
|
+
matchingLocations?.find((candidate) => candidate.className === serializedValue.className && candidate.name === serializedValue.name) ??
|
|
41
|
+
(matchingLocations?.length === 1 ? matchingLocations[0] : undefined);
|
|
42
|
+
if (!location) {
|
|
43
|
+
return parsedValue;
|
|
44
|
+
}
|
|
45
|
+
const nodes = scene.getNodes().filter((node) => node.getClassName() === location.className);
|
|
46
|
+
let candidates = nodes.filter((node) => node.id === location.id);
|
|
47
|
+
let index = location.idIndex;
|
|
48
|
+
if (candidates.length === 0) {
|
|
49
|
+
candidates = nodes.filter((node) => node.name === location.name);
|
|
50
|
+
index = location.nameIndex;
|
|
51
|
+
}
|
|
52
|
+
const resolved = (location.sceneUid === scene.uid ? candidates.find((node) => node.uniqueId === serializedValue.uniqueId) : undefined) ?? candidates[index];
|
|
53
|
+
if (!resolved) {
|
|
54
|
+
return serializedValue;
|
|
55
|
+
}
|
|
56
|
+
const resolvedNodes = scene.getNodes().filter((node) => node.getClassName() === resolved.getClassName());
|
|
57
|
+
provenance[provenanceIndexes.get(location)] = [
|
|
58
|
+
resolved.uniqueId,
|
|
59
|
+
{
|
|
60
|
+
id: resolved.id,
|
|
61
|
+
name: resolved.name,
|
|
62
|
+
className: resolved.getClassName(),
|
|
63
|
+
idIndex: resolvedNodes.filter((node) => node.id === resolved.id).indexOf(resolved),
|
|
64
|
+
nameIndex: resolvedNodes.filter((node) => node.name === resolved.name).indexOf(resolved),
|
|
65
|
+
sceneUid: scene.uid,
|
|
66
|
+
},
|
|
67
|
+
];
|
|
68
|
+
return resolved;
|
|
69
|
+
};
|
|
70
|
+
return (key, serializationObject, assetsContainer, scene) => resolve(serializationObject[key], baseValueParseFunction(key, serializationObject, assetsContainer, scene), scene);
|
|
71
|
+
}
|
|
9
72
|
function ParseCustomEventData(serializedEventData, valueParseFunction, assetsContainer, scene) {
|
|
10
73
|
const eventData = Object.create(null);
|
|
11
74
|
if (Array.isArray(serializedEventData)) {
|
|
@@ -71,6 +134,20 @@ function ApplyCoordinatorSerializationSettings(serializedObject, coordinator) {
|
|
|
71
134
|
}
|
|
72
135
|
}
|
|
73
136
|
}
|
|
137
|
+
async function LoadSerializedSoundAssetsAsync(serializedObject, coordinator, audioEngine) {
|
|
138
|
+
const soundAssets = serializedObject.soundAssets;
|
|
139
|
+
if (!Array.isArray(soundAssets) || soundAssets.length === 0) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
await Promise.all(soundAssets.map(async (asset) => {
|
|
143
|
+
try {
|
|
144
|
+
await coordinator.addSoundAssetAsync(asset, audioEngine);
|
|
145
|
+
}
|
|
146
|
+
catch (e) {
|
|
147
|
+
Logger.Warn(`FlowGraph: unable to load sound asset "${asset.name}": ${e}`);
|
|
148
|
+
}
|
|
149
|
+
}));
|
|
150
|
+
}
|
|
74
151
|
/**
|
|
75
152
|
* Given a list of blocks, find an output data connection that has a specific unique id
|
|
76
153
|
* @param blocks a list of flow graph blocks
|
|
@@ -115,9 +192,14 @@ export async function ParseCoordinatorAsync(serializedObject, options) {
|
|
|
115
192
|
const valueParseFunction = options.valueParseFunction ?? defaultValueParseFunction;
|
|
116
193
|
const coordinator = new FlowGraphCoordinator({ scene: options.scene });
|
|
117
194
|
ApplyCoordinatorSerializationSettings(serializedObject, coordinator);
|
|
118
|
-
await options.scene.whenReadyAsync();
|
|
195
|
+
await Promise.all([options.scene.whenReadyAsync(), LoadSerializedSoundAssetsAsync(serializedObject, coordinator, options.audioEngine)]);
|
|
119
196
|
// async-parse the flow graphs. This can be done in parallel
|
|
120
|
-
await Promise.all(serializedObject._flowGraphs?.map(async (serializedGraph) => await ParseFlowGraphAsync(serializedGraph, {
|
|
197
|
+
await Promise.all(serializedObject._flowGraphs?.map(async (serializedGraph) => await ParseFlowGraphAsync(serializedGraph, {
|
|
198
|
+
coordinator,
|
|
199
|
+
valueParseFunction,
|
|
200
|
+
pathConverter: options.pathConverter,
|
|
201
|
+
referenceProvenance: serializedObject.referenceProvenance,
|
|
202
|
+
})));
|
|
121
203
|
return coordinator;
|
|
122
204
|
}
|
|
123
205
|
/**
|
|
@@ -134,7 +216,12 @@ export async function ParseFlowGraphCoordinatorFromSnippetAsync(snippetId, optio
|
|
|
134
216
|
const valueParseFunction = options.valueParseFunction ?? defaultValueParseFunction;
|
|
135
217
|
const coordinator = new FlowGraphCoordinator({ scene: options.scene });
|
|
136
218
|
await options.scene.whenReadyAsync();
|
|
137
|
-
await ParseFlowGraphAsync(serializedObject, {
|
|
219
|
+
await ParseFlowGraphAsync(serializedObject, {
|
|
220
|
+
coordinator,
|
|
221
|
+
valueParseFunction,
|
|
222
|
+
pathConverter: options.pathConverter,
|
|
223
|
+
referenceProvenance: serializedObject.referenceProvenance,
|
|
224
|
+
});
|
|
138
225
|
return coordinator;
|
|
139
226
|
}
|
|
140
227
|
/**
|
|
@@ -151,10 +238,17 @@ export async function ParseFlowGraphFromSnippetAsync(snippetId, options) {
|
|
|
151
238
|
return await ParseFlowGraphAsync(serializedObject, options);
|
|
152
239
|
}
|
|
153
240
|
ApplyCoordinatorSerializationSettings(serializedObject, options.coordinator);
|
|
241
|
+
await LoadSerializedSoundAssetsAsync(serializedObject, options.coordinator);
|
|
154
242
|
const parsedGraphs = [];
|
|
155
243
|
for (const serializedGraph of serializedObject._flowGraphs) {
|
|
244
|
+
parsedGraphs.push(
|
|
156
245
|
// eslint-disable-next-line no-await-in-loop -- graph order matters for the active graph index.
|
|
157
|
-
|
|
246
|
+
await ParseFlowGraphAsync(serializedGraph, {
|
|
247
|
+
coordinator: options.coordinator,
|
|
248
|
+
valueParseFunction,
|
|
249
|
+
pathConverter: options.pathConverter,
|
|
250
|
+
referenceProvenance: serializedObject.referenceProvenance,
|
|
251
|
+
}));
|
|
158
252
|
}
|
|
159
253
|
const activeGraphIndex = serializedObject.activeGraphIndex ?? 0;
|
|
160
254
|
return parsedGraphs[activeGraphIndex] ?? parsedGraphs[0];
|
|
@@ -192,7 +286,13 @@ export function ParseFlowGraph(serializationObject, options, resolvedClasses) {
|
|
|
192
286
|
}
|
|
193
287
|
graph.metadata = serializationObject.metadata;
|
|
194
288
|
const blocks = [];
|
|
195
|
-
const
|
|
289
|
+
const baseValueParseFunction = options.valueParseFunction ?? defaultValueParseFunction;
|
|
290
|
+
const serializedReferenceProvenance = options.referenceProvenance ?? serializationObject.referenceProvenance;
|
|
291
|
+
const referenceProvenance = serializedReferenceProvenance?.map(([uniqueId, location]) => [uniqueId, { ...location }]);
|
|
292
|
+
const valueParseFunction = referenceProvenance ? _CreateReferenceProvenanceParseFunction(baseValueParseFunction, referenceProvenance) : baseValueParseFunction;
|
|
293
|
+
if (referenceProvenance) {
|
|
294
|
+
graph._setReferenceProvenance(referenceProvenance);
|
|
295
|
+
}
|
|
196
296
|
// Parse all blocks
|
|
197
297
|
// for (const serializedBlock of serializationObject.allBlocks) {
|
|
198
298
|
for (let i = 0; i < serializationObject.allBlocks.length; i++) {
|