@onerjs/core 8.42.6 → 8.42.8

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.
Files changed (480) hide show
  1. package/Animations/animatable.core.js +1 -1
  2. package/Animations/animatable.core.js.map +1 -1
  3. package/Animations/animatorAvatar.d.ts +5 -2
  4. package/Animations/animatorAvatar.js +42 -29
  5. package/Animations/animatorAvatar.js.map +1 -1
  6. package/Animations/runtimeAnimation.js +1 -1
  7. package/Animations/runtimeAnimation.js.map +1 -1
  8. package/Audio/audioSceneComponent.js +1 -2
  9. package/Audio/audioSceneComponent.js.map +1 -1
  10. package/AudioV2/webAudio/subNodes/webAudioBusAndSoundSubGraph.js +3 -3
  11. package/AudioV2/webAudio/subNodes/webAudioBusAndSoundSubGraph.js.map +1 -1
  12. package/AudioV2/webAudio/webAudioEngine.js +1 -1
  13. package/AudioV2/webAudio/webAudioEngine.js.map +1 -1
  14. package/Behaviors/Meshes/followBehavior.js +1 -1
  15. package/Behaviors/Meshes/followBehavior.js.map +1 -1
  16. package/Behaviors/Meshes/pointerDragBehavior.js +1 -1
  17. package/Behaviors/Meshes/pointerDragBehavior.js.map +1 -1
  18. package/Bones/boneLookController.js +1 -1
  19. package/Bones/boneLookController.js.map +1 -1
  20. package/Buffers/buffer.js +1 -1
  21. package/Buffers/buffer.js.map +1 -1
  22. package/Cameras/Inputs/arcRotateCameraMouseWheelInput.js +2 -2
  23. package/Cameras/Inputs/arcRotateCameraMouseWheelInput.js.map +1 -1
  24. package/Cameras/Inputs/geospatialCameraMouseWheelInput.d.ts +1 -2
  25. package/Cameras/Inputs/geospatialCameraMouseWheelInput.js +1 -2
  26. package/Cameras/Inputs/geospatialCameraMouseWheelInput.js.map +1 -1
  27. package/Cameras/Inputs/geospatialCameraPointersInput.d.ts +0 -4
  28. package/Cameras/Inputs/geospatialCameraPointersInput.js +1 -5
  29. package/Cameras/Inputs/geospatialCameraPointersInput.js.map +1 -1
  30. package/Cameras/camera.js +2 -2
  31. package/Cameras/camera.js.map +1 -1
  32. package/Cameras/cameraMovement.d.ts +1 -4
  33. package/Cameras/cameraMovement.js +1 -4
  34. package/Cameras/cameraMovement.js.map +1 -1
  35. package/Cameras/geospatialCamera.d.ts +22 -4
  36. package/Cameras/geospatialCamera.js +27 -9
  37. package/Cameras/geospatialCamera.js.map +1 -1
  38. package/Cameras/geospatialCameraMovement.d.ts +3 -3
  39. package/Cameras/geospatialCameraMovement.js +18 -18
  40. package/Cameras/geospatialCameraMovement.js.map +1 -1
  41. package/Engines/AbstractEngine/abstractEngine.renderPass.js +1 -0
  42. package/Engines/AbstractEngine/abstractEngine.renderPass.js.map +1 -1
  43. package/Engines/Extensions/engine.query.js +1 -1
  44. package/Engines/Extensions/engine.query.js.map +1 -1
  45. package/Engines/Processors/shaderProcessor.js +2 -3
  46. package/Engines/Processors/shaderProcessor.js.map +1 -1
  47. package/Engines/WebGL/webGLRenderTargetWrapper.js +1 -1
  48. package/Engines/WebGL/webGLRenderTargetWrapper.js.map +1 -1
  49. package/Engines/WebGPU/Extensions/engine.debugging.d.ts +87 -0
  50. package/Engines/WebGPU/Extensions/engine.debugging.js +135 -21
  51. package/Engines/WebGPU/Extensions/engine.debugging.js.map +1 -1
  52. package/Engines/WebGPU/webgpuBufferManager.js +1 -1
  53. package/Engines/WebGPU/webgpuBufferManager.js.map +1 -1
  54. package/Engines/WebGPU/webgpuShaderProcessor.js +1 -1
  55. package/Engines/WebGPU/webgpuShaderProcessor.js.map +1 -1
  56. package/Engines/WebGPU/webgpuShaderProcessorsGLSL.js +1 -1
  57. package/Engines/WebGPU/webgpuShaderProcessorsGLSL.js.map +1 -1
  58. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js +1 -1
  59. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js.map +1 -1
  60. package/Engines/WebGPU/webgpuTextureManager.js +10 -5
  61. package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
  62. package/Engines/abstractEngine.js +2 -2
  63. package/Engines/abstractEngine.js.map +1 -1
  64. package/Engines/engine.common.js +2 -2
  65. package/Engines/engine.common.js.map +1 -1
  66. package/Engines/engine.js +0 -1
  67. package/Engines/engine.js.map +1 -1
  68. package/Engines/engineFeatures.d.ts +0 -2
  69. package/Engines/engineFeatures.js.map +1 -1
  70. package/Engines/nullEngine.js +0 -1
  71. package/Engines/nullEngine.js.map +1 -1
  72. package/Engines/thinEngine.functions.js +1 -1
  73. package/Engines/thinEngine.functions.js.map +1 -1
  74. package/Engines/thinEngine.js +4 -6
  75. package/Engines/thinEngine.js.map +1 -1
  76. package/Engines/thinNativeEngine.js +2 -6
  77. package/Engines/thinNativeEngine.js.map +1 -1
  78. package/Engines/thinWebGPUEngine.d.ts +11 -4
  79. package/Engines/thinWebGPUEngine.js +58 -34
  80. package/Engines/thinWebGPUEngine.js.map +1 -1
  81. package/Engines/webgpuEngine.d.ts +3 -1
  82. package/Engines/webgpuEngine.js +30 -169
  83. package/Engines/webgpuEngine.js.map +1 -1
  84. package/FlowGraph/flowGraph.d.ts +1 -0
  85. package/FlowGraph/flowGraph.js.map +1 -1
  86. package/FlowGraph/flowGraphBlock.d.ts +1 -0
  87. package/FlowGraph/flowGraphBlock.js.map +1 -1
  88. package/FlowGraph/flowGraphContext.d.ts +1 -0
  89. package/FlowGraph/flowGraphContext.js.map +1 -1
  90. package/FlowGraph/flowGraphCoordinator.d.ts +1 -0
  91. package/FlowGraph/flowGraphCoordinator.js.map +1 -1
  92. package/FrameGraph/Node/nodeRenderGraph.d.ts +12 -1
  93. package/FrameGraph/Node/nodeRenderGraph.js +36 -2
  94. package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
  95. package/FrameGraph/Passes/renderPass.js +0 -3
  96. package/FrameGraph/Passes/renderPass.js.map +1 -1
  97. package/FrameGraph/Tasks/Layers/baseLayerTask.js +1 -1
  98. package/FrameGraph/Tasks/Layers/baseLayerTask.js.map +1 -1
  99. package/FrameGraph/Tasks/PostProcesses/ssao2RenderingPipelineTask.js +3 -0
  100. package/FrameGraph/Tasks/PostProcesses/ssao2RenderingPipelineTask.js.map +1 -1
  101. package/FrameGraph/Tasks/PostProcesses/ssrRenderingPipelineTask.js +3 -0
  102. package/FrameGraph/Tasks/PostProcesses/ssrRenderingPipelineTask.js.map +1 -1
  103. package/FrameGraph/Tasks/PostProcesses/volumetricLightingTask.d.ts +3 -1
  104. package/FrameGraph/Tasks/PostProcesses/volumetricLightingTask.js +14 -0
  105. package/FrameGraph/Tasks/PostProcesses/volumetricLightingTask.js.map +1 -1
  106. package/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.d.ts +2 -2
  107. package/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.js +20 -14
  108. package/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.js.map +1 -1
  109. package/FrameGraph/Tasks/Rendering/objectRendererTask.d.ts +2 -3
  110. package/FrameGraph/Tasks/Rendering/objectRendererTask.js +5 -29
  111. package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
  112. package/FrameGraph/Tasks/Rendering/shadowGeneratorTask.d.ts +3 -2
  113. package/FrameGraph/Tasks/Rendering/shadowGeneratorTask.js +38 -14
  114. package/FrameGraph/Tasks/Rendering/shadowGeneratorTask.js.map +1 -1
  115. package/FrameGraph/frameGraph.js +3 -0
  116. package/FrameGraph/frameGraph.js.map +1 -1
  117. package/FrameGraph/frameGraphContext.js +1 -1
  118. package/FrameGraph/frameGraphContext.js.map +1 -1
  119. package/FrameGraph/frameGraphTask.d.ts +0 -2
  120. package/FrameGraph/frameGraphTask.js +15 -17
  121. package/FrameGraph/frameGraphTask.js.map +1 -1
  122. package/FrameGraph/frameGraphTextureManager.js +1 -1
  123. package/FrameGraph/frameGraphTextureManager.js.map +1 -1
  124. package/Gizmos/axisScaleGizmo.js +2 -2
  125. package/Gizmos/axisScaleGizmo.js.map +1 -1
  126. package/Gizmos/cameraGizmo.d.ts +1 -1
  127. package/Gizmos/cameraGizmo.js +1 -1
  128. package/Gizmos/cameraGizmo.js.map +1 -1
  129. package/Gizmos/gizmo.d.ts +4 -4
  130. package/Gizmos/gizmo.js +5 -5
  131. package/Gizmos/gizmo.js.map +1 -1
  132. package/Gizmos/gizmoManager.d.ts +2 -2
  133. package/Gizmos/gizmoManager.js +1 -1
  134. package/Gizmos/gizmoManager.js.map +1 -1
  135. package/Gizmos/planeRotationGizmo.d.ts +2 -2
  136. package/Gizmos/planeRotationGizmo.js +2 -3
  137. package/Gizmos/planeRotationGizmo.js.map +1 -1
  138. package/Gizmos/positionGizmo.d.ts +1 -1
  139. package/Gizmos/positionGizmo.js +2 -2
  140. package/Gizmos/positionGizmo.js.map +1 -1
  141. package/Gizmos/rotationGizmo.d.ts +1 -1
  142. package/Gizmos/rotationGizmo.js +3 -3
  143. package/Gizmos/rotationGizmo.js.map +1 -1
  144. package/Gizmos/scaleGizmo.d.ts +1 -1
  145. package/Gizmos/scaleGizmo.js +1 -1
  146. package/Gizmos/scaleGizmo.js.map +1 -1
  147. package/Layers/glowLayer.js +1 -1
  148. package/Layers/glowLayer.js.map +1 -1
  149. package/Layers/highlightLayer.js +1 -1
  150. package/Layers/highlightLayer.js.map +1 -1
  151. package/Lights/Shadows/cascadedShadowGenerator.js +0 -1
  152. package/Lights/Shadows/cascadedShadowGenerator.js.map +1 -1
  153. package/Lights/Shadows/shadowGenerator.d.ts +28 -1
  154. package/Lights/Shadows/shadowGenerator.js +77 -11
  155. package/Lights/Shadows/shadowGenerator.js.map +1 -1
  156. package/Lights/lightingVolume.d.ts +1 -0
  157. package/Lights/lightingVolume.js +10 -2
  158. package/Lights/lightingVolume.js.map +1 -1
  159. package/Loading/Plugins/babylonFileLoader.js +44 -14
  160. package/Loading/Plugins/babylonFileLoader.js.map +1 -1
  161. package/Loading/sceneLoader.js +1 -1
  162. package/Loading/sceneLoader.js.map +1 -1
  163. package/Materials/GaussianSplatting/gaussianSplattingSolidColorMaterialPlugin.d.ts +12 -3
  164. package/Materials/GaussianSplatting/gaussianSplattingSolidColorMaterialPlugin.js +33 -8
  165. package/Materials/GaussianSplatting/gaussianSplattingSolidColorMaterialPlugin.js.map +1 -1
  166. package/Materials/Node/Blocks/Dual/fogBlock.js +1 -1
  167. package/Materials/Node/Blocks/Dual/fogBlock.js.map +1 -1
  168. package/Materials/Node/Blocks/Dual/imageSourceBlock.js +1 -1
  169. package/Materials/Node/Blocks/Dual/imageSourceBlock.js.map +1 -1
  170. package/Materials/Node/Blocks/PBR/sheenBlock.js +1 -2
  171. package/Materials/Node/Blocks/PBR/sheenBlock.js.map +1 -1
  172. package/Materials/Node/Blocks/cloudBlock.js +1 -1
  173. package/Materials/Node/Blocks/cloudBlock.js.map +1 -1
  174. package/Materials/Node/Blocks/curveBlock.js +2 -3
  175. package/Materials/Node/Blocks/curveBlock.js.map +1 -1
  176. package/Materials/Node/nodeMaterial.js +1 -2
  177. package/Materials/Node/nodeMaterial.js.map +1 -1
  178. package/Materials/PBR/openpbrMaterial.js +3 -5
  179. package/Materials/PBR/openpbrMaterial.js.map +1 -1
  180. package/Materials/PBR/pbrBaseMaterial.js +2 -3
  181. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  182. package/Materials/Textures/Procedurals/proceduralTexture.js +0 -1
  183. package/Materials/Textures/Procedurals/proceduralTexture.js.map +1 -1
  184. package/Materials/Textures/cubeTexture.js +1 -1
  185. package/Materials/Textures/cubeTexture.js.map +1 -1
  186. package/Materials/Textures/htmlElementTexture.js +2 -2
  187. package/Materials/Textures/htmlElementTexture.js.map +1 -1
  188. package/Materials/Textures/multiRenderTarget.js +1 -1
  189. package/Materials/Textures/multiRenderTarget.js.map +1 -1
  190. package/Materials/Textures/renderTargetTexture.js +13 -2
  191. package/Materials/Textures/renderTargetTexture.js.map +1 -1
  192. package/Materials/effect.js +2 -1
  193. package/Materials/effect.js.map +1 -1
  194. package/Materials/materialHelper.functions.js +1 -1
  195. package/Materials/materialHelper.functions.js.map +1 -1
  196. package/Materials/multiMaterial.js +1 -1
  197. package/Materials/multiMaterial.js.map +1 -1
  198. package/Materials/standardMaterial.js +1 -2
  199. package/Materials/standardMaterial.js.map +1 -1
  200. package/Materials/uniformBuffer.d.ts +0 -4
  201. package/Materials/uniformBuffer.js +0 -8
  202. package/Materials/uniformBuffer.js.map +1 -1
  203. package/Maths/index.d.ts +2 -0
  204. package/Maths/index.js +2 -0
  205. package/Maths/index.js.map +1 -1
  206. package/Maths/math.geospatial.d.ts +27 -0
  207. package/Maths/math.geospatial.functions.d.ts +33 -0
  208. package/Maths/math.geospatial.functions.js +60 -0
  209. package/Maths/math.geospatial.functions.js.map +1 -0
  210. package/Maths/math.geospatial.js +2 -0
  211. package/Maths/math.geospatial.js.map +1 -0
  212. package/Maths/math.path.js +1 -1
  213. package/Maths/math.path.js.map +1 -1
  214. package/Maths/math.scalar.functions.js +3 -3
  215. package/Maths/math.scalar.functions.js.map +1 -1
  216. package/Maths/math.vector.js +1 -1
  217. package/Maths/math.vector.js.map +1 -1
  218. package/Meshes/Builders/boxBuilder.js +1 -2
  219. package/Meshes/Builders/boxBuilder.js.map +1 -1
  220. package/Meshes/Builders/cylinderBuilder.js +2 -2
  221. package/Meshes/Builders/cylinderBuilder.js.map +1 -1
  222. package/Meshes/Builders/decalBuilder.js +1 -2
  223. package/Meshes/Builders/decalBuilder.js.map +1 -1
  224. package/Meshes/Builders/latheBuilder.js +2 -2
  225. package/Meshes/Builders/latheBuilder.js.map +1 -1
  226. package/Meshes/Builders/linesBuilder.js +11 -15
  227. package/Meshes/Builders/linesBuilder.js.map +1 -1
  228. package/Meshes/Builders/polygonBuilder.js +6 -6
  229. package/Meshes/Builders/polygonBuilder.js.map +1 -1
  230. package/Meshes/Builders/polyhedronBuilder.js +2 -2
  231. package/Meshes/Builders/polyhedronBuilder.js.map +1 -1
  232. package/Meshes/Builders/ribbonBuilder.js +6 -6
  233. package/Meshes/Builders/ribbonBuilder.js.map +1 -1
  234. package/Meshes/Builders/shapeBuilder.js +2 -3
  235. package/Meshes/Builders/shapeBuilder.js.map +1 -1
  236. package/Meshes/Builders/tiledBoxBuilder.js +1 -1
  237. package/Meshes/Builders/tiledBoxBuilder.js.map +1 -1
  238. package/Meshes/Builders/tiledPlaneBuilder.js +1 -1
  239. package/Meshes/Builders/tiledPlaneBuilder.js.map +1 -1
  240. package/Meshes/GreasedLine/greasedLineMesh.js +1 -2
  241. package/Meshes/GreasedLine/greasedLineMesh.js.map +1 -1
  242. package/Meshes/GreasedLine/greasedLineRibbonMesh.js +1 -1
  243. package/Meshes/GreasedLine/greasedLineRibbonMesh.js.map +1 -1
  244. package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.js +1 -1
  245. package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.js.map +1 -1
  246. package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.js +1 -1
  247. package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.js.map +1 -1
  248. package/Meshes/Node/Blocks/mappingBlock.js +1 -1
  249. package/Meshes/Node/Blocks/mappingBlock.js.map +1 -1
  250. package/Meshes/abstractMesh.d.ts +4 -0
  251. package/Meshes/abstractMesh.js +14 -10
  252. package/Meshes/abstractMesh.js.map +1 -1
  253. package/Meshes/csg.js +1 -1
  254. package/Meshes/csg.js.map +1 -1
  255. package/Meshes/csg2.js +1 -1
  256. package/Meshes/csg2.js.map +1 -1
  257. package/Meshes/geodesicMesh.js +11 -13
  258. package/Meshes/geodesicMesh.js.map +1 -1
  259. package/Meshes/geometry.js +2 -2
  260. package/Meshes/geometry.js.map +1 -1
  261. package/Meshes/groundMesh.js +7 -7
  262. package/Meshes/groundMesh.js.map +1 -1
  263. package/Meshes/mesh.d.ts +2 -0
  264. package/Meshes/mesh.js +22 -8
  265. package/Meshes/mesh.js.map +1 -1
  266. package/Meshes/mesh.vertexData.js +22 -22
  267. package/Meshes/mesh.vertexData.js.map +1 -1
  268. package/Meshes/meshSimplification.js +1 -1
  269. package/Meshes/meshSimplification.js.map +1 -1
  270. package/Meshes/polygonMesh.js +1 -1
  271. package/Meshes/polygonMesh.js.map +1 -1
  272. package/Meshes/trailMesh.js +1 -1
  273. package/Meshes/trailMesh.js.map +1 -1
  274. package/Misc/HighDynamicRange/hdr.js +4 -6
  275. package/Misc/HighDynamicRange/hdr.js.map +1 -1
  276. package/Misc/HighDynamicRange/panoramaToCubemap.js +1 -1
  277. package/Misc/HighDynamicRange/panoramaToCubemap.js.map +1 -1
  278. package/Misc/basisWorker.js +1 -1
  279. package/Misc/basisWorker.js.map +1 -1
  280. package/Misc/environmentTextureTools.js +1 -1
  281. package/Misc/environmentTextureTools.js.map +1 -1
  282. package/Misc/meshExploder.js +1 -2
  283. package/Misc/meshExploder.js.map +1 -1
  284. package/Misc/tga.js +2 -2
  285. package/Misc/tga.js.map +1 -1
  286. package/Misc/timer.js +4 -2
  287. package/Misc/timer.js.map +1 -1
  288. package/Misc/tools.d.ts +7 -0
  289. package/Misc/tools.js +20 -6
  290. package/Misc/tools.js.map +1 -1
  291. package/Morph/morphTargetManager.js +1 -1
  292. package/Morph/morphTargetManager.js.map +1 -1
  293. package/Navigation/INavigationEngine.d.ts +2 -2
  294. package/Navigation/INavigationEngine.js.map +1 -1
  295. package/Navigation/Plugins/recastJSPlugin.d.ts +2 -2
  296. package/Navigation/Plugins/recastJSPlugin.js +14 -5
  297. package/Navigation/Plugins/recastJSPlugin.js.map +1 -1
  298. package/Particles/Node/Blocks/Update/updateNoiseBlock.js +1 -1
  299. package/Particles/Node/Blocks/Update/updateNoiseBlock.js.map +1 -1
  300. package/Particles/Node/Blocks/particleSourceTextureBlock.d.ts +11 -1
  301. package/Particles/Node/Blocks/particleSourceTextureBlock.js +25 -11
  302. package/Particles/Node/Blocks/particleSourceTextureBlock.js.map +1 -1
  303. package/Particles/Node/nodeParticleSystemSet.helper.js +3 -3
  304. package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
  305. package/Particles/Node/nodeParticleSystemSet.js +1 -1
  306. package/Particles/Node/nodeParticleSystemSet.js.map +1 -1
  307. package/Particles/computeShaderParticleSystem.js +2 -0
  308. package/Particles/computeShaderParticleSystem.js.map +1 -1
  309. package/Particles/gpuParticleSystem.d.ts +14 -0
  310. package/Particles/gpuParticleSystem.js +94 -12
  311. package/Particles/gpuParticleSystem.js.map +1 -1
  312. package/Particles/particleSystem.js +4 -1
  313. package/Particles/particleSystem.js.map +1 -1
  314. package/Particles/pointsCloudSystem.js +46 -47
  315. package/Particles/pointsCloudSystem.js.map +1 -1
  316. package/Particles/solidParticleSystem.js +5 -6
  317. package/Particles/solidParticleSystem.js.map +1 -1
  318. package/Particles/thinParticleSystem.js +3 -4
  319. package/Particles/thinParticleSystem.js.map +1 -1
  320. package/Particles/webgl2ParticleSystem.js +2 -1
  321. package/Particles/webgl2ParticleSystem.js.map +1 -1
  322. package/Physics/castingResult.d.ts +4 -1
  323. package/Physics/castingResult.js +1 -1
  324. package/Physics/castingResult.js.map +1 -1
  325. package/Physics/joinedPhysicsEngineComponent.js +1 -1
  326. package/Physics/joinedPhysicsEngineComponent.js.map +1 -1
  327. package/Physics/physicsHelper.d.ts +8 -8
  328. package/Physics/physicsHelper.js +7 -7
  329. package/Physics/physicsHelper.js.map +1 -1
  330. package/Physics/shapeCastResult.d.ts +4 -0
  331. package/Physics/shapeCastResult.js +7 -0
  332. package/Physics/shapeCastResult.js.map +1 -1
  333. package/Physics/v1/Plugins/ammoJSPlugin.js +0 -8
  334. package/Physics/v1/Plugins/ammoJSPlugin.js.map +1 -1
  335. package/Physics/v2/IPhysicsEnginePlugin.d.ts +51 -4
  336. package/Physics/v2/IPhysicsEnginePlugin.js +12 -12
  337. package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -1
  338. package/Physics/v2/characterController.js +4 -8
  339. package/Physics/v2/characterController.js.map +1 -1
  340. package/Physics/v2/physicsBody.js.map +1 -1
  341. package/Physics/v2/physicsConstraint.d.ts +1 -1
  342. package/Physics/v2/physicsConstraint.js +1 -1
  343. package/Physics/v2/physicsConstraint.js.map +1 -1
  344. package/Physics/v2/physicsEngine.d.ts +0 -5
  345. package/Physics/v2/physicsEngine.js +0 -5
  346. package/Physics/v2/physicsEngine.js.map +1 -1
  347. package/Physics/v2/physicsEngineComponent.d.ts +1 -1
  348. package/Physics/v2/physicsEngineComponent.js.map +1 -1
  349. package/Physics/v2/physicsMaterial.d.ts +6 -0
  350. package/Physics/v2/physicsMaterial.js +2 -2
  351. package/Physics/v2/physicsMaterial.js.map +1 -1
  352. package/Physics/v2/ragdoll.js +1 -2
  353. package/Physics/v2/ragdoll.js.map +1 -1
  354. package/PostProcesses/postProcess.js +3 -3
  355. package/PostProcesses/postProcess.js.map +1 -1
  356. package/PostProcesses/thinDepthOfFieldEffect.js +2 -2
  357. package/PostProcesses/thinDepthOfFieldEffect.js.map +1 -1
  358. package/Probes/reflectionProbe.js +0 -1
  359. package/Probes/reflectionProbe.js.map +1 -1
  360. package/Rendering/IBLShadows/iblShadowsRenderPipeline.js +0 -5
  361. package/Rendering/IBLShadows/iblShadowsRenderPipeline.js.map +1 -1
  362. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js +4 -1
  363. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js.map +1 -1
  364. package/Rendering/depthRenderer.js +0 -11
  365. package/Rendering/depthRenderer.js.map +1 -1
  366. package/Rendering/depthRendererSceneComponent.js +1 -1
  367. package/Rendering/depthRendererSceneComponent.js.map +1 -1
  368. package/Rendering/edgesRenderer.js +1 -0
  369. package/Rendering/edgesRenderer.js.map +1 -1
  370. package/Rendering/geometryBufferRenderer.js +0 -1
  371. package/Rendering/geometryBufferRenderer.js.map +1 -1
  372. package/Rendering/objectRenderer.js +15 -9
  373. package/Rendering/objectRenderer.js.map +1 -1
  374. package/Rendering/renderingGroup.d.ts +1 -1
  375. package/Rendering/renderingGroup.js +1 -1
  376. package/Rendering/renderingGroup.js.map +1 -1
  377. package/Rendering/renderingManager.d.ts +1 -1
  378. package/Rendering/renderingManager.js.map +1 -1
  379. package/Rendering/thinDepthPeelingRenderer.js +1 -1
  380. package/Rendering/thinDepthPeelingRenderer.js.map +1 -1
  381. package/Rendering/utilityLayerRenderer.js +1 -1
  382. package/Rendering/utilityLayerRenderer.js.map +1 -1
  383. package/Shaders/ShadersInclude/screenSpaceRayTrace.js +18 -8
  384. package/Shaders/ShadersInclude/screenSpaceRayTrace.js.map +1 -1
  385. package/Shaders/gpuRenderParticles.vertex.js +4 -0
  386. package/Shaders/gpuRenderParticles.vertex.js.map +1 -1
  387. package/Shaders/gpuUpdateParticles.vertex.js +15 -3
  388. package/Shaders/gpuUpdateParticles.vertex.js.map +1 -1
  389. package/Shaders/iblVoxelGrid.fragment.js +4 -1
  390. package/Shaders/iblVoxelGrid.fragment.js.map +1 -1
  391. package/ShadersWGSL/ShadersInclude/screenSpaceRayTrace.js +18 -7
  392. package/ShadersWGSL/ShadersInclude/screenSpaceRayTrace.js.map +1 -1
  393. package/ShadersWGSL/background.vertex.js +8 -8
  394. package/ShadersWGSL/background.vertex.js.map +1 -1
  395. package/ShadersWGSL/boundingBoxRenderer.vertex.js +2 -2
  396. package/ShadersWGSL/boundingBoxRenderer.vertex.js.map +1 -1
  397. package/ShadersWGSL/clearQuad.vertex.js +1 -1
  398. package/ShadersWGSL/clearQuad.vertex.js.map +1 -1
  399. package/ShadersWGSL/color.vertex.js +1 -1
  400. package/ShadersWGSL/color.vertex.js.map +1 -1
  401. package/ShadersWGSL/depth.vertex.js +3 -3
  402. package/ShadersWGSL/depth.vertex.js.map +1 -1
  403. package/ShadersWGSL/fluidRenderingParticleDepth.vertex.js +2 -2
  404. package/ShadersWGSL/fluidRenderingParticleDepth.vertex.js.map +1 -1
  405. package/ShadersWGSL/fluidRenderingParticleDiffuse.vertex.js +2 -2
  406. package/ShadersWGSL/fluidRenderingParticleDiffuse.vertex.js.map +1 -1
  407. package/ShadersWGSL/fluidRenderingParticleThickness.vertex.js +2 -2
  408. package/ShadersWGSL/fluidRenderingParticleThickness.vertex.js.map +1 -1
  409. package/ShadersWGSL/fxaa.vertex.js +1 -1
  410. package/ShadersWGSL/fxaa.vertex.js.map +1 -1
  411. package/ShadersWGSL/gaussianSplatting.vertex.js +3 -3
  412. package/ShadersWGSL/gaussianSplatting.vertex.js.map +1 -1
  413. package/ShadersWGSL/gaussianSplattingDepth.vertex.js +3 -3
  414. package/ShadersWGSL/gaussianSplattingDepth.vertex.js.map +1 -1
  415. package/ShadersWGSL/geometry.vertex.js +4 -4
  416. package/ShadersWGSL/geometry.vertex.js.map +1 -1
  417. package/ShadersWGSL/glowMapGeneration.vertex.js +4 -4
  418. package/ShadersWGSL/glowMapGeneration.vertex.js.map +1 -1
  419. package/ShadersWGSL/glowMapMerge.vertex.js +1 -1
  420. package/ShadersWGSL/glowMapMerge.vertex.js.map +1 -1
  421. package/ShadersWGSL/gpuUpdateParticles.compute.js +16 -1
  422. package/ShadersWGSL/gpuUpdateParticles.compute.js.map +1 -1
  423. package/ShadersWGSL/greasedLine.vertex.js +10 -4
  424. package/ShadersWGSL/greasedLine.vertex.js.map +1 -1
  425. package/ShadersWGSL/hdrFiltering.vertex.js +1 -1
  426. package/ShadersWGSL/hdrFiltering.vertex.js.map +1 -1
  427. package/ShadersWGSL/hdrIrradianceFiltering.vertex.js +1 -1
  428. package/ShadersWGSL/hdrIrradianceFiltering.vertex.js.map +1 -1
  429. package/ShadersWGSL/iblVoxelGrid.vertex.js +2 -2
  430. package/ShadersWGSL/iblVoxelGrid.vertex.js.map +1 -1
  431. package/ShadersWGSL/iblVoxelSlabDebug.vertex.js +1 -1
  432. package/ShadersWGSL/iblVoxelSlabDebug.vertex.js.map +1 -1
  433. package/ShadersWGSL/kernelBlur.vertex.js +2 -2
  434. package/ShadersWGSL/kernelBlur.vertex.js.map +1 -1
  435. package/ShadersWGSL/layer.vertex.js +1 -1
  436. package/ShadersWGSL/layer.vertex.js.map +1 -1
  437. package/ShadersWGSL/lensFlare.vertex.js +1 -1
  438. package/ShadersWGSL/lensFlare.vertex.js.map +1 -1
  439. package/ShadersWGSL/line.vertex.js +2 -2
  440. package/ShadersWGSL/line.vertex.js.map +1 -1
  441. package/ShadersWGSL/meshUVSpaceRenderer.vertex.js +2 -2
  442. package/ShadersWGSL/meshUVSpaceRenderer.vertex.js.map +1 -1
  443. package/ShadersWGSL/meshUVSpaceRendererFinaliser.vertex.js +1 -1
  444. package/ShadersWGSL/meshUVSpaceRendererFinaliser.vertex.js.map +1 -1
  445. package/ShadersWGSL/meshUVSpaceRendererMasker.vertex.js +1 -1
  446. package/ShadersWGSL/meshUVSpaceRendererMasker.vertex.js.map +1 -1
  447. package/ShadersWGSL/particles.vertex.js +9 -9
  448. package/ShadersWGSL/particles.vertex.js.map +1 -1
  449. package/ShadersWGSL/picking.vertex.js +2 -2
  450. package/ShadersWGSL/picking.vertex.js.map +1 -1
  451. package/ShadersWGSL/procedural.vertex.js +1 -1
  452. package/ShadersWGSL/procedural.vertex.js.map +1 -1
  453. package/ShadersWGSL/shadowMap.vertex.js +4 -4
  454. package/ShadersWGSL/shadowMap.vertex.js.map +1 -1
  455. package/ShadersWGSL/sprites.vertex.js +3 -3
  456. package/ShadersWGSL/sprites.vertex.js.map +1 -1
  457. package/Sprites/spriteManager.js +4 -4
  458. package/Sprites/spriteManager.js.map +1 -1
  459. package/XR/features/WebXRAnchorSystem.js +2 -2
  460. package/XR/features/WebXRAnchorSystem.js.map +1 -1
  461. package/XR/features/WebXRControllerPhysics.js +0 -2
  462. package/XR/features/WebXRControllerPhysics.js.map +1 -1
  463. package/XR/features/WebXRHandTracking.js +4 -7
  464. package/XR/features/WebXRHandTracking.js.map +1 -1
  465. package/XR/features/WebXRNearInteraction.js +1 -1
  466. package/XR/features/WebXRNearInteraction.js.map +1 -1
  467. package/XR/motionController/webXRMicrosoftMixedRealityController.js +1 -1
  468. package/XR/motionController/webXRMicrosoftMixedRealityController.js.map +1 -1
  469. package/XR/motionController/webXROculusTouchMotionController.js +1 -1
  470. package/XR/motionController/webXROculusTouchMotionController.js.map +1 -1
  471. package/XR/webXRFeaturesManager.js +1 -1
  472. package/XR/webXRFeaturesManager.js.map +1 -1
  473. package/assetContainer.js +1 -1
  474. package/assetContainer.js.map +1 -1
  475. package/package.json +1 -1
  476. package/scene.d.ts +16 -0
  477. package/scene.js +30 -1
  478. package/scene.js.map +1 -1
  479. package/sceneComponent.js +1 -1
  480. package/sceneComponent.js.map +1 -1
@@ -39,6 +39,7 @@ export interface IFlowGraphParseOptions {
39
39
  * A function that parses complex values in a scene.
40
40
  * @param key the key of the value
41
41
  * @param serializationObject the object to read the value from
42
+ * @param assetsContainer the assets container
42
43
  * @param scene the scene to read the value from
43
44
  */
44
45
  valueParseFunction?: (key: string, serializationObject: any, assetsContainer: IAssetContainer, scene: Scene) => any;
@@ -1 +1 @@
1
- {"version":3,"file":"flowGraph.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraph.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAIhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAOpE,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAElF,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,MAAM,CAAN,IAAkB,cASjB;AATD,WAAkB,cAAc;IAC5B;;OAEG;IACH,yDAAO,CAAA;IACP;;OAEG;IACH,yDAAO,CAAA;AACX,CAAC,EATiB,cAAc,KAAd,cAAc,QAS/B;AAoCD;;;;;;;GAOG;AACH,MAAM,OAAO,SAAS;IAiClB;;OAEG;IACH,IAAW,KAAK;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,IAAW,KAAK,CAAC,KAAqB;QAClC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,wBAAwB,CAAC,eAAe,CAAC,KAAK,C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,CAAC;QAClE,CAAC;IACL,CAAC;CACJ","sourcesContent":["import type { Observer } from \"../Misc/observable\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { FlowGraphEventBlock } from \"./flowGraphEventBlock\";\r\nimport { FlowGraphContext } from \"./flowGraphContext\";\r\nimport type { FlowGraphBlock } from \"./flowGraphBlock\";\r\nimport { FlowGraphExecutionBlock } from \"./flowGraphExecutionBlock\";\r\nimport type { FlowGraphCoordinator } from \"./flowGraphCoordinator\";\r\nimport type { IObjectAccessor } from \"./typeDefinitions\";\r\nimport type { IPathToObjectConverter } from \"../ObjectModel/objectModelInterfaces\";\r\nimport type { IAssetContainer } from \"core/IAssetContainer\";\r\nimport { FlowGraphEventType } from \"./flowGraphEventType\";\r\nimport type { IFlowGraphEventTrigger } from \"./flowGraphSceneEventCoordinator\";\r\nimport { FlowGraphSceneEventCoordinator } from \"./flowGraphSceneEventCoordinator\";\r\nimport type { FlowGraphMeshPickEventBlock } from \"./Blocks/Event/flowGraphMeshPickEventBlock\";\r\nimport { _IsDescendantOf } from \"./utils\";\r\n\r\nexport const enum FlowGraphState {\r\n /**\r\n * The graph is stopped\r\n */\r\n Stopped,\r\n /**\r\n * The graph is running\r\n */\r\n Started,\r\n}\r\n\r\n/**\r\n * Parameters used to create a flow graph.\r\n */\r\nexport interface IFlowGraphParams {\r\n /**\r\n * The scene that the flow graph belongs to.\r\n */\r\n scene: Scene;\r\n /**\r\n * The event coordinator used by the flow graph.\r\n */\r\n coordinator: FlowGraphCoordinator;\r\n}\r\n\r\n/**\r\n * Options for parsing a flow graph.\r\n */\r\nexport interface IFlowGraphParseOptions {\r\n /**\r\n * A function that parses complex values in a scene.\r\n * @param key the key of the value\r\n * @param serializationObject the object to read the value from\r\n * @param scene the scene to read the value from\r\n */\r\n valueParseFunction?: (key: string, serializationObject: any, assetsContainer: IAssetContainer, scene: Scene) => any;\r\n /**\r\n * The flow graph coordinator.\r\n */\r\n coordinator: FlowGraphCoordinator;\r\n /**\r\n * A function that converts a path to an object accessor.\r\n */\r\n pathConverter?: IPathToObjectConverter<IObjectAccessor>;\r\n}\r\n/**\r\n * Class used to represent a flow graph.\r\n * A flow graph is a graph of blocks that can be used to create complex logic.\r\n * Blocks can be added to the graph and connected to each other.\r\n * The graph can then be started, which will init and start all of its event blocks.\r\n *\r\n * @experimental FlowGraph is still in development and is subject to change.\r\n */\r\nexport class FlowGraph {\r\n /**\r\n * An observable that is triggered when the state of the graph changes.\r\n */\r\n public onStateChangedObservable: Observable<FlowGraphState> = new Observable();\r\n /** @internal */\r\n public _eventBlocks: { [keyof in FlowGraphEventType]: FlowGraphEventBlock[] } = {\r\n [FlowGraphEventType.SceneReady]: [],\r\n [FlowGraphEventType.SceneDispose]: [],\r\n [FlowGraphEventType.SceneBeforeRender]: [],\r\n [FlowGraphEventType.MeshPick]: [],\r\n [FlowGraphEventType.PointerDown]: [],\r\n [FlowGraphEventType.PointerUp]: [],\r\n [FlowGraphEventType.PointerMove]: [],\r\n [FlowGraphEventType.PointerOver]: [],\r\n [FlowGraphEventType.PointerOut]: [],\r\n [FlowGraphEventType.SceneAfterRender]: [],\r\n [FlowGraphEventType.NoTrigger]: [],\r\n };\r\n /**\r\n * @internal\r\n */\r\n public readonly _scene: Scene;\r\n private _coordinator: FlowGraphCoordinator;\r\n private _executionContexts: FlowGraphContext[] = [];\r\n private _sceneEventCoordinator: FlowGraphSceneEventCoordinator;\r\n private _eventObserver: Nullable<Observer<IFlowGraphEventTrigger>>;\r\n\r\n /**\r\n * The state of the graph\r\n */\r\n private _state: FlowGraphState = FlowGraphState.Stopped;\r\n\r\n /**\r\n * The state of the graph\r\n */\r\n public get state() {\r\n return this._state;\r\n }\r\n\r\n /**\r\n * The state of the graph\r\n */\r\n public set state(value: FlowGraphState) {\r\n this._state = value;\r\n this.onStateChangedObservable.notifyObservers(value);\r\n }\r\n\r\n /**\r\n * Construct a Flow Graph\r\n * @param params construction parameters. currently only the scene\r\n */\r\n public constructor(params: IFlowGraphParams) {\r\n this._scene = params.scene;\r\n this._sceneEventCoordinator = new FlowGraphSceneEventCoordinator(this._scene);\r\n this._coordinator = params.coordinator;\r\n\r\n this._eventObserver = this._sceneEventCoordinator.onEventTriggeredObservable.add((event) => {\r\n for (const context of this._executionContexts) {\r\n const order = this._getContextualOrder(event.type, context);\r\n for (const block of order) {\r\n // iterate contexts\r\n if (!block._executeEvent(context, event.payload)) {\r\n break;\r\n }\r\n }\r\n }\r\n // custom behavior(s) of specific events\r\n switch (event.type) {\r\n case FlowGraphEventType.SceneReady:\r\n this._sceneEventCoordinator.sceneReadyTriggered = true;\r\n break;\r\n case FlowGraphEventType.SceneBeforeRender:\r\n for (const context of this._executionContexts) {\r\n context._notifyOnTick(event.payload);\r\n }\r\n break;\r\n case FlowGraphEventType.SceneDispose:\r\n this.dispose();\r\n break;\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Create a context. A context represents one self contained execution for the graph, with its own variables.\r\n * @returns the context, where you can get and set variables\r\n */\r\n public createContext() {\r\n const context = new FlowGraphContext({ scene: this._scene, coordinator: this._coordinator });\r\n this._executionContexts.push(context);\r\n return context;\r\n }\r\n\r\n /**\r\n * Returns the execution context at a given index\r\n * @param index the index of the context\r\n * @returns the execution context at that index\r\n */\r\n public getContext(index: number) {\r\n return this._executionContexts[index];\r\n }\r\n\r\n /**\r\n * Add an event block. When the graph is started, it will start listening to events\r\n * from the block and execute the graph when they are triggered.\r\n * @param block the event block to be added\r\n */\r\n public addEventBlock(block: FlowGraphEventBlock): void {\r\n if (block.type === FlowGraphEventType.PointerOver || block.type === FlowGraphEventType.PointerOut) {\r\n this._scene.constantlyUpdateMeshUnderPointer = true;\r\n }\r\n\r\n // don't add if NoTrigger, but still start the pending tasks\r\n if (block.type !== FlowGraphEventType.NoTrigger) {\r\n this._eventBlocks[block.type].push(block);\r\n }\r\n // if already started, sort and add to the pending\r\n if (this.state === FlowGraphState.Started) {\r\n for (const context of this._executionContexts) {\r\n block._startPendingTasks(context);\r\n }\r\n } else {\r\n this.onStateChangedObservable.addOnce((state) => {\r\n if (state === FlowGraphState.Started) {\r\n for (const context of this._executionContexts) {\r\n block._startPendingTasks(context);\r\n }\r\n }\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Starts the flow graph. Initializes the event blocks and starts listening to events.\r\n */\r\n public start() {\r\n if (this.state === FlowGraphState.Started) {\r\n return;\r\n }\r\n if (this._executionContexts.length === 0) {\r\n this.createContext();\r\n }\r\n this.onStateChangedObservable.add((state) => {\r\n if (state === FlowGraphState.Started) {\r\n this._startPendingEvents();\r\n // the only event we need to check is the scene ready event. If the scene is already ready when the graph starts, we should start the pending tasks.\r\n if (this._scene.isReady(true)) {\r\n this._sceneEventCoordinator.onEventTriggeredObservable.notifyObservers({ type: FlowGraphEventType.SceneReady });\r\n }\r\n }\r\n });\r\n this.state = FlowGraphState.Started;\r\n }\r\n\r\n private _startPendingEvents() {\r\n for (const context of this._executionContexts) {\r\n for (const type in this._eventBlocks) {\r\n const order = this._getContextualOrder(type as FlowGraphEventType, context);\r\n for (const block of order) {\r\n block._startPendingTasks(context);\r\n }\r\n }\r\n }\r\n }\r\n\r\n private _getContextualOrder(type: FlowGraphEventType, context: FlowGraphContext): FlowGraphEventBlock[] {\r\n const order = this._eventBlocks[type].sort((a, b) => b.initPriority - a.initPriority);\r\n\r\n if (type === FlowGraphEventType.MeshPick) {\r\n const meshPickOrder = [] as FlowGraphEventBlock[];\r\n for (const block1 of order) {\r\n // If the block is a mesh pick, guarantee that picks of children meshes come before picks of parent meshes\r\n const mesh1 = (block1 as FlowGraphMeshPickEventBlock).asset.getValue(context);\r\n let i = 0;\r\n for (; i < order.length; i++) {\r\n const block2 = order[i];\r\n const mesh2 = (block2 as FlowGraphMeshPickEventBlock).asset.getValue(context);\r\n if (mesh1 && mesh2 && _IsDescendantOf(mesh1, mesh2)) {\r\n break;\r\n }\r\n }\r\n meshPickOrder.splice(i, 0, block1);\r\n }\r\n return meshPickOrder;\r\n }\r\n return order;\r\n }\r\n\r\n /**\r\n * Disposes of the flow graph. Cancels any pending tasks and removes all event listeners.\r\n */\r\n public dispose() {\r\n if (this.state === FlowGraphState.Stopped) {\r\n return;\r\n }\r\n this.state = FlowGraphState.Stopped;\r\n for (const context of this._executionContexts) {\r\n context._clearPendingBlocks();\r\n }\r\n this._executionContexts.length = 0;\r\n for (const type in this._eventBlocks) {\r\n this._eventBlocks[type as FlowGraphEventType].length = 0;\r\n }\r\n this._eventObserver?.remove();\r\n this._sceneEventCoordinator.dispose();\r\n }\r\n\r\n /**\r\n * Executes a function in all blocks of a flow graph, starting with the event blocks.\r\n * @param visitor the function to execute.\r\n */\r\n public visitAllBlocks(visitor: (block: FlowGraphBlock) => void) {\r\n const visitList: FlowGraphBlock[] = [];\r\n const idsAddedToVisitList = new Set<string>();\r\n for (const type in this._eventBlocks) {\r\n for (const block of this._eventBlocks[type as FlowGraphEventType]) {\r\n visitList.push(block);\r\n idsAddedToVisitList.add(block.uniqueId);\r\n }\r\n }\r\n\r\n while (visitList.length > 0) {\r\n const block = visitList.pop()!;\r\n visitor(block);\r\n\r\n for (const dataIn of block.dataInputs) {\r\n for (const connection of dataIn._connectedPoint) {\r\n if (!idsAddedToVisitList.has(connection._ownerBlock.uniqueId)) {\r\n visitList.push(connection._ownerBlock);\r\n idsAddedToVisitList.add(connection._ownerBlock.uniqueId);\r\n }\r\n }\r\n }\r\n if (block instanceof FlowGraphExecutionBlock) {\r\n for (const signalOut of block.signalOutputs) {\r\n for (const connection of signalOut._connectedPoint) {\r\n if (!idsAddedToVisitList.has(connection._ownerBlock.uniqueId)) {\r\n visitList.push(connection._ownerBlock);\r\n idsAddedToVisitList.add(connection._ownerBlock.uniqueId);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Serializes a graph\r\n * @param serializationObject the object to write the values in\r\n * @param valueSerializeFunction a function to serialize complex values\r\n */\r\n public serialize(serializationObject: any = {}, valueSerializeFunction?: (key: string, value: any, serializationObject: any) => void) {\r\n serializationObject.allBlocks = [];\r\n this.visitAllBlocks((block) => {\r\n const serializedBlock: any = {};\r\n block.serialize(serializedBlock);\r\n serializationObject.allBlocks.push(serializedBlock);\r\n });\r\n serializationObject.executionContexts = [];\r\n for (const context of this._executionContexts) {\r\n const serializedContext: any = {};\r\n context.serialize(serializedContext, valueSerializeFunction);\r\n serializationObject.executionContexts.push(serializedContext);\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"flowGraph.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraph.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAIhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAOpE,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAElF,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,MAAM,CAAN,IAAkB,cASjB;AATD,WAAkB,cAAc;IAC5B;;OAEG;IACH,yDAAO,CAAA;IACP;;OAEG;IACH,yDAAO,CAAA;AACX,CAAC,EATiB,cAAc,KAAd,cAAc,QAS/B;AAqCD;;;;;;;GAOG;AACH,MAAM,OAAO,SAAS;IAiClB;;OAEG;IACH,IAAW,KAAK;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,IAAW,KAAK,CAAC,KAAqB;QAClC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,wBAAwB,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;IACzD,CAAC;IAED;;;OAGG;IACH,YAAmB,MAAwB;QAnD3C;;WAEG;QACI,6BAAwB,GAA+B,IAAI,UAAU,EAAE,CAAC;QAC/E,gBAAgB;QACT,iBAAY,GAA6D;YAC5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AAI,KAAK,YAAY,uBAAuB,EAAE,CAAC;gBAC3C,KAAK,MAAM,SAAS,IAAI,KAAK,CAAC,aAAa,EAAE,CAAC;oBAC1C,KAAK,MAAM,UAAU,IAAI,SAAS,CAAC,eAAe,EAAE,CAAC;wBACjD,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAC;4BAC5D,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;4BACvC,mBAAmB,CAAC,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;wBAC7D,CAAC;oBACL,CAAC;gBACL,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;IAED;;;;OAIG;IACI,SAAS,CAAC,sBAA2B,EAAE,EAAE,sBAAoF;QAChI,mBAAmB,CAAC,SAAS,GAAG,EAAE,CAAC;QACnC,IAAI,CAAC,cAAc,CAAC,CAAC,KAAK,EAAE,EAAE;YAC1B,MAAM,eAAe,GAAQ,EAAE,CAAC;YAChC,KAAK,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;YACjC,mBAAmB,CAAC,SAAS,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QACxD,CAAC,CAAC,CAAC;QACH,mBAAmB,CAAC,iBAAiB,GAAG,EAAE,CAAC;QAC3C,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC5C,MAAM,iBAAiB,GAAQ,EAAE,CAAC;YAClC,OAAO,CAAC,SAAS,CAAC,iBAAiB,EAAE,sBAAsB,CAAC,CAAC;YAC7D,mBAAmB,CAAC,iBAAiB,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAClE,CAAC;IACL,CAAC;CACJ","sourcesContent":["import type { Observer } from \"../Misc/observable\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { FlowGraphEventBlock } from \"./flowGraphEventBlock\";\r\nimport { FlowGraphContext } from \"./flowGraphContext\";\r\nimport type { FlowGraphBlock } from \"./flowGraphBlock\";\r\nimport { FlowGraphExecutionBlock } from \"./flowGraphExecutionBlock\";\r\nimport type { FlowGraphCoordinator } from \"./flowGraphCoordinator\";\r\nimport type { IObjectAccessor } from \"./typeDefinitions\";\r\nimport type { IPathToObjectConverter } from \"../ObjectModel/objectModelInterfaces\";\r\nimport type { IAssetContainer } from \"core/IAssetContainer\";\r\nimport { FlowGraphEventType } from \"./flowGraphEventType\";\r\nimport type { IFlowGraphEventTrigger } from \"./flowGraphSceneEventCoordinator\";\r\nimport { FlowGraphSceneEventCoordinator } from \"./flowGraphSceneEventCoordinator\";\r\nimport type { FlowGraphMeshPickEventBlock } from \"./Blocks/Event/flowGraphMeshPickEventBlock\";\r\nimport { _IsDescendantOf } from \"./utils\";\r\n\r\nexport const enum FlowGraphState {\r\n /**\r\n * The graph is stopped\r\n */\r\n Stopped,\r\n /**\r\n * The graph is running\r\n */\r\n Started,\r\n}\r\n\r\n/**\r\n * Parameters used to create a flow graph.\r\n */\r\nexport interface IFlowGraphParams {\r\n /**\r\n * The scene that the flow graph belongs to.\r\n */\r\n scene: Scene;\r\n /**\r\n * The event coordinator used by the flow graph.\r\n */\r\n coordinator: FlowGraphCoordinator;\r\n}\r\n\r\n/**\r\n * Options for parsing a flow graph.\r\n */\r\nexport interface IFlowGraphParseOptions {\r\n /**\r\n * A function that parses complex values in a scene.\r\n * @param key the key of the value\r\n * @param serializationObject the object to read the value from\r\n * @param assetsContainer the assets container\r\n * @param scene the scene to read the value from\r\n */\r\n valueParseFunction?: (key: string, serializationObject: any, assetsContainer: IAssetContainer, scene: Scene) => any;\r\n /**\r\n * The flow graph coordinator.\r\n */\r\n coordinator: FlowGraphCoordinator;\r\n /**\r\n * A function that converts a path to an object accessor.\r\n */\r\n pathConverter?: IPathToObjectConverter<IObjectAccessor>;\r\n}\r\n/**\r\n * Class used to represent a flow graph.\r\n * A flow graph is a graph of blocks that can be used to create complex logic.\r\n * Blocks can be added to the graph and connected to each other.\r\n * The graph can then be started, which will init and start all of its event blocks.\r\n *\r\n * @experimental FlowGraph is still in development and is subject to change.\r\n */\r\nexport class FlowGraph {\r\n /**\r\n * An observable that is triggered when the state of the graph changes.\r\n */\r\n public onStateChangedObservable: Observable<FlowGraphState> = new Observable();\r\n /** @internal */\r\n public _eventBlocks: { [keyof in FlowGraphEventType]: FlowGraphEventBlock[] } = {\r\n [FlowGraphEventType.SceneReady]: [],\r\n [FlowGraphEventType.SceneDispose]: [],\r\n [FlowGraphEventType.SceneBeforeRender]: [],\r\n [FlowGraphEventType.MeshPick]: [],\r\n [FlowGraphEventType.PointerDown]: [],\r\n [FlowGraphEventType.PointerUp]: [],\r\n [FlowGraphEventType.PointerMove]: [],\r\n [FlowGraphEventType.PointerOver]: [],\r\n [FlowGraphEventType.PointerOut]: [],\r\n [FlowGraphEventType.SceneAfterRender]: [],\r\n [FlowGraphEventType.NoTrigger]: [],\r\n };\r\n /**\r\n * @internal\r\n */\r\n public readonly _scene: Scene;\r\n private _coordinator: FlowGraphCoordinator;\r\n private _executionContexts: FlowGraphContext[] = [];\r\n private _sceneEventCoordinator: FlowGraphSceneEventCoordinator;\r\n private _eventObserver: Nullable<Observer<IFlowGraphEventTrigger>>;\r\n\r\n /**\r\n * The state of the graph\r\n */\r\n private _state: FlowGraphState = FlowGraphState.Stopped;\r\n\r\n /**\r\n * The state of the graph\r\n */\r\n public get state() {\r\n return this._state;\r\n }\r\n\r\n /**\r\n * The state of the graph\r\n */\r\n public set state(value: FlowGraphState) {\r\n this._state = value;\r\n this.onStateChangedObservable.notifyObservers(value);\r\n }\r\n\r\n /**\r\n * Construct a Flow Graph\r\n * @param params construction parameters. currently only the scene\r\n */\r\n public constructor(params: IFlowGraphParams) {\r\n this._scene = params.scene;\r\n this._sceneEventCoordinator = new FlowGraphSceneEventCoordinator(this._scene);\r\n this._coordinator = params.coordinator;\r\n\r\n this._eventObserver = this._sceneEventCoordinator.onEventTriggeredObservable.add((event) => {\r\n for (const context of this._executionContexts) {\r\n const order = this._getContextualOrder(event.type, context);\r\n for (const block of order) {\r\n // iterate contexts\r\n if (!block._executeEvent(context, event.payload)) {\r\n break;\r\n }\r\n }\r\n }\r\n // custom behavior(s) of specific events\r\n switch (event.type) {\r\n case FlowGraphEventType.SceneReady:\r\n this._sceneEventCoordinator.sceneReadyTriggered = true;\r\n break;\r\n case FlowGraphEventType.SceneBeforeRender:\r\n for (const context of this._executionContexts) {\r\n context._notifyOnTick(event.payload);\r\n }\r\n break;\r\n case FlowGraphEventType.SceneDispose:\r\n this.dispose();\r\n break;\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Create a context. A context represents one self contained execution for the graph, with its own variables.\r\n * @returns the context, where you can get and set variables\r\n */\r\n public createContext() {\r\n const context = new FlowGraphContext({ scene: this._scene, coordinator: this._coordinator });\r\n this._executionContexts.push(context);\r\n return context;\r\n }\r\n\r\n /**\r\n * Returns the execution context at a given index\r\n * @param index the index of the context\r\n * @returns the execution context at that index\r\n */\r\n public getContext(index: number) {\r\n return this._executionContexts[index];\r\n }\r\n\r\n /**\r\n * Add an event block. When the graph is started, it will start listening to events\r\n * from the block and execute the graph when they are triggered.\r\n * @param block the event block to be added\r\n */\r\n public addEventBlock(block: FlowGraphEventBlock): void {\r\n if (block.type === FlowGraphEventType.PointerOver || block.type === FlowGraphEventType.PointerOut) {\r\n this._scene.constantlyUpdateMeshUnderPointer = true;\r\n }\r\n\r\n // don't add if NoTrigger, but still start the pending tasks\r\n if (block.type !== FlowGraphEventType.NoTrigger) {\r\n this._eventBlocks[block.type].push(block);\r\n }\r\n // if already started, sort and add to the pending\r\n if (this.state === FlowGraphState.Started) {\r\n for (const context of this._executionContexts) {\r\n block._startPendingTasks(context);\r\n }\r\n } else {\r\n this.onStateChangedObservable.addOnce((state) => {\r\n if (state === FlowGraphState.Started) {\r\n for (const context of this._executionContexts) {\r\n block._startPendingTasks(context);\r\n }\r\n }\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Starts the flow graph. Initializes the event blocks and starts listening to events.\r\n */\r\n public start() {\r\n if (this.state === FlowGraphState.Started) {\r\n return;\r\n }\r\n if (this._executionContexts.length === 0) {\r\n this.createContext();\r\n }\r\n this.onStateChangedObservable.add((state) => {\r\n if (state === FlowGraphState.Started) {\r\n this._startPendingEvents();\r\n // the only event we need to check is the scene ready event. If the scene is already ready when the graph starts, we should start the pending tasks.\r\n if (this._scene.isReady(true)) {\r\n this._sceneEventCoordinator.onEventTriggeredObservable.notifyObservers({ type: FlowGraphEventType.SceneReady });\r\n }\r\n }\r\n });\r\n this.state = FlowGraphState.Started;\r\n }\r\n\r\n private _startPendingEvents() {\r\n for (const context of this._executionContexts) {\r\n for (const type in this._eventBlocks) {\r\n const order = this._getContextualOrder(type as FlowGraphEventType, context);\r\n for (const block of order) {\r\n block._startPendingTasks(context);\r\n }\r\n }\r\n }\r\n }\r\n\r\n private _getContextualOrder(type: FlowGraphEventType, context: FlowGraphContext): FlowGraphEventBlock[] {\r\n const order = this._eventBlocks[type].sort((a, b) => b.initPriority - a.initPriority);\r\n\r\n if (type === FlowGraphEventType.MeshPick) {\r\n const meshPickOrder = [] as FlowGraphEventBlock[];\r\n for (const block1 of order) {\r\n // If the block is a mesh pick, guarantee that picks of children meshes come before picks of parent meshes\r\n const mesh1 = (block1 as FlowGraphMeshPickEventBlock).asset.getValue(context);\r\n let i = 0;\r\n for (; i < order.length; i++) {\r\n const block2 = order[i];\r\n const mesh2 = (block2 as FlowGraphMeshPickEventBlock).asset.getValue(context);\r\n if (mesh1 && mesh2 && _IsDescendantOf(mesh1, mesh2)) {\r\n break;\r\n }\r\n }\r\n meshPickOrder.splice(i, 0, block1);\r\n }\r\n return meshPickOrder;\r\n }\r\n return order;\r\n }\r\n\r\n /**\r\n * Disposes of the flow graph. Cancels any pending tasks and removes all event listeners.\r\n */\r\n public dispose() {\r\n if (this.state === FlowGraphState.Stopped) {\r\n return;\r\n }\r\n this.state = FlowGraphState.Stopped;\r\n for (const context of this._executionContexts) {\r\n context._clearPendingBlocks();\r\n }\r\n this._executionContexts.length = 0;\r\n for (const type in this._eventBlocks) {\r\n this._eventBlocks[type as FlowGraphEventType].length = 0;\r\n }\r\n this._eventObserver?.remove();\r\n this._sceneEventCoordinator.dispose();\r\n }\r\n\r\n /**\r\n * Executes a function in all blocks of a flow graph, starting with the event blocks.\r\n * @param visitor the function to execute.\r\n */\r\n public visitAllBlocks(visitor: (block: FlowGraphBlock) => void) {\r\n const visitList: FlowGraphBlock[] = [];\r\n const idsAddedToVisitList = new Set<string>();\r\n for (const type in this._eventBlocks) {\r\n for (const block of this._eventBlocks[type as FlowGraphEventType]) {\r\n visitList.push(block);\r\n idsAddedToVisitList.add(block.uniqueId);\r\n }\r\n }\r\n\r\n while (visitList.length > 0) {\r\n const block = visitList.pop()!;\r\n visitor(block);\r\n\r\n for (const dataIn of block.dataInputs) {\r\n for (const connection of dataIn._connectedPoint) {\r\n if (!idsAddedToVisitList.has(connection._ownerBlock.uniqueId)) {\r\n visitList.push(connection._ownerBlock);\r\n idsAddedToVisitList.add(connection._ownerBlock.uniqueId);\r\n }\r\n }\r\n }\r\n if (block instanceof FlowGraphExecutionBlock) {\r\n for (const signalOut of block.signalOutputs) {\r\n for (const connection of signalOut._connectedPoint) {\r\n if (!idsAddedToVisitList.has(connection._ownerBlock.uniqueId)) {\r\n visitList.push(connection._ownerBlock);\r\n idsAddedToVisitList.add(connection._ownerBlock.uniqueId);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Serializes a graph\r\n * @param serializationObject the object to write the values in\r\n * @param valueSerializeFunction a function to serialize complex values\r\n */\r\n public serialize(serializationObject: any = {}, valueSerializeFunction?: (key: string, value: any, serializationObject: any) => void) {\r\n serializationObject.allBlocks = [];\r\n this.visitAllBlocks((block) => {\r\n const serializedBlock: any = {};\r\n block.serialize(serializedBlock);\r\n serializationObject.allBlocks.push(serializedBlock);\r\n });\r\n serializationObject.executionContexts = [];\r\n for (const context of this._executionContexts) {\r\n const serializedContext: any = {};\r\n context.serialize(serializedContext, valueSerializeFunction);\r\n serializationObject.executionContexts.push(serializedContext);\r\n }\r\n }\r\n}\r\n"]}
@@ -14,6 +14,7 @@ export interface IFlowGraphBlockParseOptions {
14
14
  * A function that parses a value from a serialization object.
15
15
  * @param key the key of the property
16
16
  * @param serializationObject the serialization object where the property is located
17
+ * @param assetsContainer the assets container
17
18
  * @param scene the scene that the block is being parsed in
18
19
  * @returns the parsed value
19
20
  */
@@ -1 +1 @@
1
- {"version":3,"file":"flowGraphBlock.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraphBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAGpE,OAAO,EAAE,iCAAiC,EAAE,MAAM,iBAAiB,CAAC;AA2CpE;;;;GAIG;AACH,MAAM,OAAO,cAAc;IAuBvB;;;OAGG;IACH;IACI;;OAEG;IACI,MAAqC;QAArC,WAAM,GAAN,MAAM,CAA+B;QA9BhD;;WAEG;QACI,aAAQ,GAAG,UAAU,EAAE,CAAC;QA6B3B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,MAAM,EAAE,IAAI,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;QACrD,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;QACrB,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;IAC1B,CAAC;IAED;;;;OAIG;IACI,cAAc,CAAC,QAA0B;QAC5C,8CAA8C;IAClD,CAAC;IAED;;;;;;OAMG;IACI,iBAAiB,CAAI,IAAY,EAAE,QAAqB,EAAE,YAAgB;QAC7E,MAAM,KAAK,GAAG,IAAI,uBAAuB,CAAC,IAAI,yCAAiC,IAAI,EAAE,QAAQ,EAAE,YAAY,CAA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AAC,UAAU,GAAG,EAAE,CAAC;QACpC,mBAAmB,CAAC,WAAW,GAAG,EAAE,CAAC;QACrC,mBAAmB,CAAC,SAAS,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QACpD,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YAClC,MAAM,eAAe,GAAQ,EAAE,CAAC;YAChC,KAAK,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;YACjC,mBAAmB,CAAC,UAAU,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QACzD,CAAC;QACD,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACpC,MAAM,gBAAgB,GAAQ,EAAE,CAAC;YACjC,MAAM,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;YACnC,mBAAmB,CAAC,WAAW,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAC3D,CAAC;IACL,CAAC;IAED;;;OAGG;IACI,WAAW,CAAC,oBAA+C;QAC9D,mBAAmB;IACvB,CAAC;IAES,IAAI,CAAC,OAAyB,EAAE,MAAuB,EAAE,OAAa;QAC5E,OAAO,CAAC,MAAM,EAAE,UAAU,CAAC;YACvB,MAAM;YACN,OAAO;YACP,SAAS,EAAE,IAAI,CAAC,YAAY,EAAE;YAC9B,QAAQ,EAAE,IAAI,CAAC,QAAQ;SAC1B,CAAC,CAAC;IACP,CAAC;IAED;;;OAGG;IACI,YAAY;QACf,OAAO,gBAAgB,CAAC;IAC5B,CAAC;CACJ","sourcesContent":["import { RandomGUID } from \"../Misc/guid\";\r\nimport { FlowGraphConnectionType } from \"./flowGraphConnection\";\r\nimport type { FlowGraphContext } from \"./flowGraphContext\";\r\nimport { FlowGraphDataConnection } from \"./flowGraphDataConnection\";\r\nimport type { RichType } from \"./flowGraphRichTypes\";\r\nimport type { ISerializedFlowGraphBlock, IObjectAccessor } from \"./typeDefinitions\";\r\nimport { defaultValueSerializationFunction } from \"./serialization\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { IPathToObjectConverter } from \"../ObjectModel/objectModelInterfaces\";\r\nimport type { IAssetContainer } from \"core/IAssetContainer\";\r\nimport type { FlowGraphAction } from \"./flowGraphLogger\";\r\n\r\n/**\r\n * Options for parsing a block.\r\n */\r\nexport interface IFlowGraphBlockParseOptions {\r\n /**\r\n * A function that parses a value from a serialization object.\r\n * @param key the key of the property\r\n * @param serializationObject the serialization object where the property is located\r\n * @param scene the scene that the block is being parsed in\r\n * @returns the parsed value\r\n */\r\n valueParseFunction?: (key: string, serializationObject: any, assetsContainer: IAssetContainer, scene: Scene) => any;\r\n /**\r\n * The assets container to use when loading assets.\r\n */\r\n assetsContainer?: IAssetContainer;\r\n /**\r\n * The scene that the block is being parsed in.\r\n */\r\n scene: Scene;\r\n /**\r\n * The path converter to use to convert the path to an object accessor.\r\n */\r\n pathConverter?: IPathToObjectConverter<IObjectAccessor>;\r\n}\r\n\r\n/**\r\n * Configuration for a block.\r\n */\r\nexport interface IFlowGraphBlockConfiguration {\r\n /**\r\n * The name of the block.\r\n */\r\n name?: string;\r\n [extraPropertyKey: string]: any;\r\n}\r\n\r\n/**\r\n * A block in a flow graph. The most basic form\r\n * of a block has inputs and outputs that contain\r\n * data.\r\n */\r\nexport class FlowGraphBlock {\r\n /**\r\n * A randomly generated GUID for each block.\r\n */\r\n public uniqueId = RandomGUID();\r\n /**\r\n * The name of the block.\r\n */\r\n public name: string;\r\n /**\r\n * The data inputs of the block.\r\n */\r\n public dataInputs: FlowGraphDataConnection<any>[];\r\n /**\r\n * The data outputs of the block.\r\n */\r\n public dataOutputs: FlowGraphDataConnection<any>[];\r\n\r\n /**\r\n * Metadata that can be used by the block.\r\n */\r\n public metadata: any;\r\n\r\n /** Constructor is protected so only subclasses can be instantiated\r\n * @param config optional configuration for this block\r\n * @internal - do not use directly. Extend this class instead.\r\n */\r\n constructor(\r\n /**\r\n * the configuration of the block\r\n */\r\n public config?: IFlowGraphBlockConfiguration\r\n ) {\r\n this.name = this.config?.name ?? this.getClassName();\r\n this.dataInputs = [];\r\n this.dataOutputs = [];\r\n }\r\n\r\n /**\r\n * @internal\r\n * This function is called when the block needs to update its output flows.\r\n * @param _context the context in which it is running\r\n */\r\n public _updateOutputs(_context: FlowGraphContext): void {\r\n // empty by default, overridden in data blocks\r\n }\r\n\r\n /**\r\n * Registers a data input on the block.\r\n * @param name the name of the input\r\n * @param richType the type of the input\r\n * @param defaultValue optional default value of the input. If not set, the rich type's default value will be used.\r\n * @returns the created connection\r\n */\r\n public registerDataInput<T>(name: string, richType: RichType<T>, defaultValue?: T): FlowGraphDataConnection<T> {\r\n const input = new FlowGraphDataConnection(name, FlowGraphConnectionType.Input, this, richType, defaultValue);\r\n this.dataInputs.push(input);\r\n return input;\r\n }\r\n\r\n /**\r\n * Registers a data output on the block.\r\n * @param name the name of the input\r\n * @param richType the type of the input\r\n * @param defaultValue optional default value of the input. If not set, the rich type's default value will be used.\r\n * @returns the created connection\r\n */\r\n public registerDataOutput<T>(name: string, richType: RichType<T>, defaultValue?: T): FlowGraphDataConnection<T> {\r\n const output = new FlowGraphDataConnection(name, FlowGraphConnectionType.Output, this, richType, defaultValue);\r\n this.dataOutputs.push(output);\r\n return output;\r\n }\r\n\r\n /**\r\n * Given the name of a data input, returns the connection if it exists\r\n * @param name the name of the input\r\n * @returns the connection if it exists, undefined otherwise\r\n */\r\n public getDataInput(name: string): FlowGraphDataConnection<any> | undefined {\r\n return this.dataInputs.find((i) => i.name === name);\r\n }\r\n\r\n /**\r\n * Given the name of a data output, returns the connection if it exists\r\n * @param name the name of the output\r\n * @returns the connection if it exists, undefined otherwise\r\n */\r\n public getDataOutput(name: string): FlowGraphDataConnection<any> | undefined {\r\n return this.dataOutputs.find((i) => i.name === name);\r\n }\r\n\r\n /**\r\n * Serializes this block\r\n * @param serializationObject the object to serialize to\r\n * @param _valueSerializeFunction a function that serializes a specific value\r\n */\r\n public serialize(serializationObject: any = {}, _valueSerializeFunction: (key: string, value: any, serializationObject: any) => any = defaultValueSerializationFunction) {\r\n serializationObject.uniqueId = this.uniqueId;\r\n serializationObject.config = {};\r\n if (this.config) {\r\n const config = this.config;\r\n const keys = Object.keys(config);\r\n for (const key of keys) {\r\n _valueSerializeFunction(key, config[key], serializationObject.config);\r\n }\r\n }\r\n serializationObject.dataInputs = [];\r\n serializationObject.dataOutputs = [];\r\n serializationObject.className = this.getClassName();\r\n for (const input of this.dataInputs) {\r\n const serializedInput: any = {};\r\n input.serialize(serializedInput);\r\n serializationObject.dataInputs.push(serializedInput);\r\n }\r\n for (const output of this.dataOutputs) {\r\n const serializedOutput: any = {};\r\n output.serialize(serializedOutput);\r\n serializationObject.dataOutputs.push(serializedOutput);\r\n }\r\n }\r\n\r\n /**\r\n * Deserializes this block\r\n * @param _serializationObject the object to deserialize from\r\n */\r\n public deserialize(_serializationObject: ISerializedFlowGraphBlock) {\r\n // no-op by default\r\n }\r\n\r\n protected _log(context: FlowGraphContext, action: FlowGraphAction, payload?: any) {\r\n context.logger?.addLogItem({\r\n action,\r\n payload,\r\n className: this.getClassName(),\r\n uniqueId: this.uniqueId,\r\n });\r\n }\r\n\r\n /**\r\n * Gets the class name of this block\r\n * @returns the class name\r\n */\r\n public getClassName() {\r\n return \"FlowGraphBlock\";\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"flowGraphBlock.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraphBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAGpE,OAAO,EAAE,iCAAiC,EAAE,MAAM,iBAAiB,CAAC;AA4CpE;;;;GAIG;AACH,MAAM,OAAO,cAAc;IAuBvB;;;OAGG;IACH;IACI;;OAEG;IACI,MAAqC;QAArC,WAAM,GAAN,MAAM,CAA+B;QA9BhD;;WAEG;QACI,aAAQ,GAAG,UAAU,EAAE,CAAC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YAAY,EAAE;YAC9B,QAAQ,EAAE,IAAI,CAAC,QAAQ;SAC1B,CAAC,CAAC;IACP,CAAC;IAED;;;OAGG;IACI,YAAY;QACf,OAAO,gBAAgB,CAAC;IAC5B,CAAC;CACJ","sourcesContent":["import { RandomGUID } from \"../Misc/guid\";\r\nimport { FlowGraphConnectionType } from \"./flowGraphConnection\";\r\nimport type { FlowGraphContext } from \"./flowGraphContext\";\r\nimport { FlowGraphDataConnection } from \"./flowGraphDataConnection\";\r\nimport type { RichType } from \"./flowGraphRichTypes\";\r\nimport type { ISerializedFlowGraphBlock, IObjectAccessor } from \"./typeDefinitions\";\r\nimport { defaultValueSerializationFunction } from \"./serialization\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { IPathToObjectConverter } from \"../ObjectModel/objectModelInterfaces\";\r\nimport type { IAssetContainer } from \"core/IAssetContainer\";\r\nimport type { FlowGraphAction } from \"./flowGraphLogger\";\r\n\r\n/**\r\n * Options for parsing a block.\r\n */\r\nexport interface IFlowGraphBlockParseOptions {\r\n /**\r\n * A function that parses a value from a serialization object.\r\n * @param key the key of the property\r\n * @param serializationObject the serialization object where the property is located\r\n * @param assetsContainer the assets container\r\n * @param scene the scene that the block is being parsed in\r\n * @returns the parsed value\r\n */\r\n valueParseFunction?: (key: string, serializationObject: any, assetsContainer: IAssetContainer, scene: Scene) => any;\r\n /**\r\n * The assets container to use when loading assets.\r\n */\r\n assetsContainer?: IAssetContainer;\r\n /**\r\n * The scene that the block is being parsed in.\r\n */\r\n scene: Scene;\r\n /**\r\n * The path converter to use to convert the path to an object accessor.\r\n */\r\n pathConverter?: IPathToObjectConverter<IObjectAccessor>;\r\n}\r\n\r\n/**\r\n * Configuration for a block.\r\n */\r\nexport interface IFlowGraphBlockConfiguration {\r\n /**\r\n * The name of the block.\r\n */\r\n name?: string;\r\n [extraPropertyKey: string]: any;\r\n}\r\n\r\n/**\r\n * A block in a flow graph. The most basic form\r\n * of a block has inputs and outputs that contain\r\n * data.\r\n */\r\nexport class FlowGraphBlock {\r\n /**\r\n * A randomly generated GUID for each block.\r\n */\r\n public uniqueId = RandomGUID();\r\n /**\r\n * The name of the block.\r\n */\r\n public name: string;\r\n /**\r\n * The data inputs of the block.\r\n */\r\n public dataInputs: FlowGraphDataConnection<any>[];\r\n /**\r\n * The data outputs of the block.\r\n */\r\n public dataOutputs: FlowGraphDataConnection<any>[];\r\n\r\n /**\r\n * Metadata that can be used by the block.\r\n */\r\n public metadata: any;\r\n\r\n /** Constructor is protected so only subclasses can be instantiated\r\n * @param config optional configuration for this block\r\n * @internal - do not use directly. Extend this class instead.\r\n */\r\n constructor(\r\n /**\r\n * the configuration of the block\r\n */\r\n public config?: IFlowGraphBlockConfiguration\r\n ) {\r\n this.name = this.config?.name ?? this.getClassName();\r\n this.dataInputs = [];\r\n this.dataOutputs = [];\r\n }\r\n\r\n /**\r\n * @internal\r\n * This function is called when the block needs to update its output flows.\r\n * @param _context the context in which it is running\r\n */\r\n public _updateOutputs(_context: FlowGraphContext): void {\r\n // empty by default, overridden in data blocks\r\n }\r\n\r\n /**\r\n * Registers a data input on the block.\r\n * @param name the name of the input\r\n * @param richType the type of the input\r\n * @param defaultValue optional default value of the input. If not set, the rich type's default value will be used.\r\n * @returns the created connection\r\n */\r\n public registerDataInput<T>(name: string, richType: RichType<T>, defaultValue?: T): FlowGraphDataConnection<T> {\r\n const input = new FlowGraphDataConnection(name, FlowGraphConnectionType.Input, this, richType, defaultValue);\r\n this.dataInputs.push(input);\r\n return input;\r\n }\r\n\r\n /**\r\n * Registers a data output on the block.\r\n * @param name the name of the input\r\n * @param richType the type of the input\r\n * @param defaultValue optional default value of the input. If not set, the rich type's default value will be used.\r\n * @returns the created connection\r\n */\r\n public registerDataOutput<T>(name: string, richType: RichType<T>, defaultValue?: T): FlowGraphDataConnection<T> {\r\n const output = new FlowGraphDataConnection(name, FlowGraphConnectionType.Output, this, richType, defaultValue);\r\n this.dataOutputs.push(output);\r\n return output;\r\n }\r\n\r\n /**\r\n * Given the name of a data input, returns the connection if it exists\r\n * @param name the name of the input\r\n * @returns the connection if it exists, undefined otherwise\r\n */\r\n public getDataInput(name: string): FlowGraphDataConnection<any> | undefined {\r\n return this.dataInputs.find((i) => i.name === name);\r\n }\r\n\r\n /**\r\n * Given the name of a data output, returns the connection if it exists\r\n * @param name the name of the output\r\n * @returns the connection if it exists, undefined otherwise\r\n */\r\n public getDataOutput(name: string): FlowGraphDataConnection<any> | undefined {\r\n return this.dataOutputs.find((i) => i.name === name);\r\n }\r\n\r\n /**\r\n * Serializes this block\r\n * @param serializationObject the object to serialize to\r\n * @param _valueSerializeFunction a function that serializes a specific value\r\n */\r\n public serialize(serializationObject: any = {}, _valueSerializeFunction: (key: string, value: any, serializationObject: any) => any = defaultValueSerializationFunction) {\r\n serializationObject.uniqueId = this.uniqueId;\r\n serializationObject.config = {};\r\n if (this.config) {\r\n const config = this.config;\r\n const keys = Object.keys(config);\r\n for (const key of keys) {\r\n _valueSerializeFunction(key, config[key], serializationObject.config);\r\n }\r\n }\r\n serializationObject.dataInputs = [];\r\n serializationObject.dataOutputs = [];\r\n serializationObject.className = this.getClassName();\r\n for (const input of this.dataInputs) {\r\n const serializedInput: any = {};\r\n input.serialize(serializedInput);\r\n serializationObject.dataInputs.push(serializedInput);\r\n }\r\n for (const output of this.dataOutputs) {\r\n const serializedOutput: any = {};\r\n output.serialize(serializedOutput);\r\n serializationObject.dataOutputs.push(serializedOutput);\r\n }\r\n }\r\n\r\n /**\r\n * Deserializes this block\r\n * @param _serializationObject the object to deserialize from\r\n */\r\n public deserialize(_serializationObject: ISerializedFlowGraphBlock) {\r\n // no-op by default\r\n }\r\n\r\n protected _log(context: FlowGraphContext, action: FlowGraphAction, payload?: any) {\r\n context.logger?.addLogItem({\r\n action,\r\n payload,\r\n className: this.getClassName(),\r\n uniqueId: this.uniqueId,\r\n });\r\n }\r\n\r\n /**\r\n * Gets the class name of this block\r\n * @returns the class name\r\n */\r\n public getClassName() {\r\n return \"FlowGraphBlock\";\r\n }\r\n}\r\n"]}
@@ -36,6 +36,7 @@ export interface IFlowGraphContextParseOptions {
36
36
  * A function that parses a value from a serialization object.
37
37
  * @param key the key of the value
38
38
  * @param serializationObject the object containing the value
39
+ * @param assetsContainer the assets container
39
40
  * @param scene the current scene
40
41
  * @returns
41
42
  */
@@ -1 +1 @@
1
- {"version":3,"file":"flowGraphContext.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraphContext.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAM1C,OAAO,EAAE,iCAAiC,EAAE,MAAM,iBAAiB,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAGrE,OAAO,EAAmB,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAwCrE;;;;;GAKG;AACH,MAAM,OAAO,gBAAgB;IA6DzB;;OAEG;IACH,IAAW,aAAa;QACpB,OAAO,IAAI,CAAC,cAAc,CAAC;IAC/B,CAAC;IAED,IAAW,aAAa,CAAC,KAAc;QACnC,IAAI,IAAI,CAAC,cAAc,KAAK,KAAK,EAAE,CAAC;YAChC,OAAO;QACX,CAAC;QACD,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC;QAC5B,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YACtB,IAAI,CAAC,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;YACpC,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,IAAI,CAAC;QACpC,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACvB,CAAC;IACL,CAAC;IAED,YAAY,MAAsC;QAhFlD;;WAEG;QAEI,aAAQ,GAAG,UAAU,EAAE,CAAC;QAC/B;;WAEG;QACK,mBAAc,GAA2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AAI,CAAC,aAAa,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACxD,eAAe,EAAE,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;gBACtE,UAAU,EAAE,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC1D,cAAc,EAAE,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBAClE,cAAc,EAAE,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACrE,CAAC;QACN,CAAC;IACL,CAAC;IAED;;OAEG;IACI,YAAY;QACf,OAAO,kBAAkB,CAAC;IAC9B,CAAC;CACJ;AAjdU;IADN,SAAS,EAAE;kDACmB","sourcesContent":["import { serialize } from \"../Misc/decorators\";\r\nimport { RandomGUID } from \"../Misc/guid\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { FlowGraphAsyncExecutionBlock } from \"./flowGraphAsyncExecutionBlock\";\r\nimport type { FlowGraphBlock } from \"./flowGraphBlock\";\r\nimport type { FlowGraphDataConnection } from \"./flowGraphDataConnection\";\r\nimport type { FlowGraph } from \"./flowGraph\";\r\nimport { defaultValueSerializationFunction } from \"./serialization\";\r\nimport type { FlowGraphCoordinator } from \"./flowGraphCoordinator\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport type { AssetType, FlowGraphAssetType } from \"./flowGraphAssetsContext\";\r\nimport { GetFlowGraphAssetWithType } from \"./flowGraphAssetsContext\";\r\nimport type { IAssetContainer } from \"core/IAssetContainer\";\r\nimport type { Nullable } from \"core/types\";\r\nimport { FlowGraphAction, FlowGraphLogger } from \"./flowGraphLogger\";\r\nimport type { IFlowGraphOnTickEventPayload } from \"./Blocks/Event/flowGraphSceneTickEventBlock\";\r\n\r\n/**\r\n * Construction parameters for the context.\r\n */\r\nexport interface IFlowGraphContextConfiguration {\r\n /**\r\n * The scene that the flow graph context belongs to.\r\n */\r\n readonly scene: Scene;\r\n /**\r\n * The event coordinator used by the flow graph context.\r\n */\r\n readonly coordinator: FlowGraphCoordinator;\r\n\r\n /**\r\n * The assets context used by the flow graph context.\r\n * If none is provided, a default one will be created.\r\n */\r\n readonly assetsContext?: IAssetContainer;\r\n}\r\n\r\n/**\r\n * Options for parsing a context.\r\n */\r\nexport interface IFlowGraphContextParseOptions {\r\n /**\r\n * A function that parses a value from a serialization object.\r\n * @param key the key of the value\r\n * @param serializationObject the object containing the value\r\n * @param scene the current scene\r\n * @returns\r\n */\r\n readonly valueParseFunction?: (key: string, serializationObject: any, assetsContainer: IAssetContainer, scene: Scene) => any;\r\n /**\r\n * The graph that the context is being parsed in.\r\n */\r\n readonly graph: FlowGraph;\r\n}\r\n/**\r\n * The context represents the current state and execution of the flow graph.\r\n * It contains both user-defined variables, which are derived from\r\n * a more general variable definition, and execution variables that\r\n * are set by the blocks.\r\n */\r\nexport class FlowGraphContext {\r\n /**\r\n * A randomly generated GUID for each context.\r\n */\r\n @serialize()\r\n public uniqueId = RandomGUID();\r\n /**\r\n * These are the variables defined by a user.\r\n */\r\n private _userVariables: { [key: string]: any } = {};\r\n /**\r\n * These are the variables set by the blocks.\r\n */\r\n private _executionVariables: { [key: string]: any } = {};\r\n\r\n /**\r\n * A context-specific global variables, available to all blocks in the context.\r\n */\r\n private _globalContextVariables: { [key: string]: any } = {};\r\n /**\r\n * These are the values for the data connection points\r\n */\r\n private _connectionValues: { [key: string]: any } = {};\r\n /**\r\n * These are the variables set by the graph.\r\n */\r\n private readonly _configuration: IFlowGraphContextConfiguration;\r\n /**\r\n * These are blocks that have currently pending tasks/listeners that need to be cleaned up.\r\n */\r\n private _pendingBlocks: FlowGraphAsyncExecutionBlock[] = [];\r\n /**\r\n * A monotonically increasing ID for each execution.\r\n * Incremented for every block executed.\r\n */\r\n private _executionId = 0;\r\n /**\r\n * Observable that is triggered when a node is executed.\r\n */\r\n public onNodeExecutedObservable: Observable<FlowGraphBlock> = new Observable<FlowGraphBlock>();\r\n\r\n /**\r\n * The assets context used by the flow graph context.\r\n * Note that it can be shared between flow graph contexts.\r\n */\r\n public assetsContext: IAssetContainer;\r\n\r\n /**\r\n * Whether to treat data as right-handed.\r\n * This is used when serializing data from a right-handed system, while running the context in a left-handed system, for example in glTF parsing.\r\n * Default is false.\r\n */\r\n public treatDataAsRightHanded = false;\r\n\r\n private _enableLogging = false;\r\n\r\n /**\r\n * The logger used by the context to log actions.\r\n */\r\n public logger: Nullable<FlowGraphLogger>;\r\n\r\n /**\r\n * Enable logging on this context\r\n */\r\n public get enableLogging() {\r\n return this._enableLogging;\r\n }\r\n\r\n public set enableLogging(value: boolean) {\r\n if (this._enableLogging === value) {\r\n return;\r\n }\r\n this._enableLogging = value;\r\n if (this._enableLogging) {\r\n this.logger = new FlowGraphLogger();\r\n this.logger.logToConsole = true;\r\n } else {\r\n this.logger = null;\r\n }\r\n }\r\n\r\n constructor(params: IFlowGraphContextConfiguration) {\r\n this._configuration = params;\r\n this.assetsContext = params.assetsContext ?? params.scene;\r\n }\r\n\r\n /**\r\n * Check if a user-defined variable is defined.\r\n * @param name the name of the variable\r\n * @returns true if the variable is defined\r\n */\r\n public hasVariable(name: string) {\r\n return name in this._userVariables;\r\n }\r\n\r\n /**\r\n * Set a user-defined variable.\r\n * @param name the name of the variable\r\n * @param value the value of the variable\r\n */\r\n public setVariable(name: string, value: any) {\r\n this._userVariables[name] = value;\r\n this.logger?.addLogItem({\r\n time: Date.now(),\r\n className: this.getClassName(),\r\n uniqueId: this.uniqueId,\r\n action: FlowGraphAction.ContextVariableSet,\r\n payload: {\r\n name,\r\n value,\r\n },\r\n });\r\n }\r\n\r\n /**\r\n * Get an assets from the assets context based on its type and index in the array\r\n * @param type The type of the asset\r\n * @param index The index of the asset\r\n * @returns The asset or null if not found\r\n */\r\n public getAsset<T extends FlowGraphAssetType>(type: T, index: number): Nullable<AssetType<T>> {\r\n return GetFlowGraphAssetWithType(this.assetsContext, type, index);\r\n }\r\n\r\n /**\r\n * Get a user-defined variable.\r\n * @param name the name of the variable\r\n * @returns the value of the variable\r\n */\r\n public getVariable(name: string): any {\r\n this.logger?.addLogItem({\r\n time: Date.now(),\r\n className: this.getClassName(),\r\n uniqueId: this.uniqueId,\r\n action: FlowGraphAction.ContextVariableGet,\r\n payload: {\r\n name,\r\n value: this._userVariables[name],\r\n },\r\n });\r\n return this._userVariables[name];\r\n }\r\n\r\n /**\r\n * Gets all user variables map\r\n */\r\n public get userVariables() {\r\n return this._userVariables;\r\n }\r\n\r\n /**\r\n * Get the scene that the context belongs to.\r\n * @returns the scene\r\n */\r\n public getScene() {\r\n return this._configuration.scene;\r\n }\r\n\r\n private _getUniqueIdPrefixedName(obj: FlowGraphBlock, name: string): string {\r\n return `${obj.uniqueId}_${name}`;\r\n }\r\n\r\n /**\r\n * @internal\r\n * @param name name of the variable\r\n * @param defaultValue default value to return if the variable is not defined\r\n * @returns the variable value or the default value if the variable is not defined\r\n */\r\n public _getGlobalContextVariable<T>(name: string, defaultValue: T): T {\r\n this.logger?.addLogItem({\r\n time: Date.now(),\r\n className: this.getClassName(),\r\n uniqueId: this.uniqueId,\r\n action: FlowGraphAction.GlobalVariableGet,\r\n payload: {\r\n name,\r\n defaultValue,\r\n possibleValue: this._globalContextVariables[name],\r\n },\r\n });\r\n if (this._hasGlobalContextVariable(name)) {\r\n return this._globalContextVariables[name];\r\n } else {\r\n return defaultValue;\r\n }\r\n }\r\n\r\n /**\r\n * Set a global context variable\r\n * @internal\r\n * @param name the name of the variable\r\n * @param value the value of the variable\r\n */\r\n public _setGlobalContextVariable<T>(name: string, value: T) {\r\n this.logger?.addLogItem({\r\n time: Date.now(),\r\n className: this.getClassName(),\r\n uniqueId: this.uniqueId,\r\n action: FlowGraphAction.GlobalVariableSet,\r\n payload: { name, value },\r\n });\r\n this._globalContextVariables[name] = value;\r\n }\r\n\r\n /**\r\n * Delete a global context variable\r\n * @internal\r\n * @param name the name of the variable\r\n */\r\n public _deleteGlobalContextVariable(name: string) {\r\n this.logger?.addLogItem({\r\n time: Date.now(),\r\n className: this.getClassName(),\r\n uniqueId: this.uniqueId,\r\n action: FlowGraphAction.GlobalVariableDelete,\r\n payload: { name },\r\n });\r\n delete this._globalContextVariables[name];\r\n }\r\n\r\n /**\r\n * Check if a global context variable is defined\r\n * @internal\r\n * @param name the name of the variable\r\n * @returns true if the variable is defined\r\n */\r\n public _hasGlobalContextVariable(name: string) {\r\n return name in this._globalContextVariables;\r\n }\r\n\r\n /**\r\n * Set an internal execution variable\r\n * @internal\r\n * @param name\r\n * @param value\r\n */\r\n public _setExecutionVariable(block: FlowGraphBlock, name: string, value: any) {\r\n this._executionVariables[this._getUniqueIdPrefixedName(block, name)] = value;\r\n }\r\n\r\n /**\r\n * Get an internal execution variable\r\n * @internal\r\n * @param name\r\n * @returns\r\n */\r\n public _getExecutionVariable<T>(block: FlowGraphBlock, name: string, defaultValue: T): T {\r\n if (this._hasExecutionVariable(block, name)) {\r\n return this._executionVariables[this._getUniqueIdPrefixedName(block, name)];\r\n } else {\r\n return defaultValue;\r\n }\r\n }\r\n\r\n /**\r\n * Delete an internal execution variable\r\n * @internal\r\n * @param block\r\n * @param name\r\n */\r\n public _deleteExecutionVariable(block: FlowGraphBlock, name: string) {\r\n delete this._executionVariables[this._getUniqueIdPrefixedName(block, name)];\r\n }\r\n\r\n /**\r\n * Check if an internal execution variable is defined\r\n * @internal\r\n * @param block\r\n * @param name\r\n * @returns\r\n */\r\n public _hasExecutionVariable(block: FlowGraphBlock, name: string) {\r\n return this._getUniqueIdPrefixedName(block, name) in this._executionVariables;\r\n }\r\n\r\n /**\r\n * Check if a connection value is defined\r\n * @internal\r\n * @param connectionPoint\r\n * @returns\r\n */\r\n public _hasConnectionValue(connectionPoint: FlowGraphDataConnection<any>) {\r\n return connectionPoint.uniqueId in this._connectionValues;\r\n }\r\n\r\n /**\r\n * Set a connection value\r\n * @internal\r\n * @param connectionPoint\r\n * @param value\r\n */\r\n public _setConnectionValue<T>(connectionPoint: FlowGraphDataConnection<T>, value: T) {\r\n this._connectionValues[connectionPoint.uniqueId] = value;\r\n this.logger?.addLogItem({\r\n time: Date.now(),\r\n className: this.getClassName(),\r\n uniqueId: this.uniqueId,\r\n action: FlowGraphAction.SetConnectionValue,\r\n payload: {\r\n connectionPointId: connectionPoint.uniqueId,\r\n value,\r\n },\r\n });\r\n }\r\n\r\n /**\r\n * Set a connection value by key\r\n * @internal\r\n * @param key the key of the connection value\r\n * @param value the value of the connection\r\n */\r\n public _setConnectionValueByKey<T>(key: string, value: T) {\r\n this._connectionValues[key] = value;\r\n }\r\n\r\n /**\r\n * Get a connection value\r\n * @internal\r\n * @param connectionPoint\r\n * @returns\r\n */\r\n public _getConnectionValue<T>(connectionPoint: FlowGraphDataConnection<T>): T {\r\n this.logger?.addLogItem({\r\n time: Date.now(),\r\n className: this.getClassName(),\r\n uniqueId: this.uniqueId,\r\n action: FlowGraphAction.GetConnectionValue,\r\n payload: {\r\n connectionPointId: connectionPoint.uniqueId,\r\n value: this._connectionValues[connectionPoint.uniqueId],\r\n },\r\n });\r\n return this._connectionValues[connectionPoint.uniqueId];\r\n }\r\n\r\n /**\r\n * Get the configuration\r\n * @internal\r\n * @param name\r\n * @param value\r\n */\r\n public get configuration() {\r\n return this._configuration;\r\n }\r\n\r\n /**\r\n * Check if there are any pending blocks in this context\r\n * @returns true if there are pending blocks\r\n */\r\n public get hasPendingBlocks() {\r\n return this._pendingBlocks.length > 0;\r\n }\r\n\r\n /**\r\n * Add a block to the list of blocks that have pending tasks.\r\n * @internal\r\n * @param block\r\n */\r\n public _addPendingBlock(block: FlowGraphAsyncExecutionBlock) {\r\n // check if block is already in the array\r\n if (this._pendingBlocks.includes(block)) {\r\n return;\r\n }\r\n this._pendingBlocks.push(block);\r\n // sort pending blocks by priority\r\n this._pendingBlocks.sort((a, b) => a.priority - b.priority);\r\n }\r\n\r\n /**\r\n * Remove a block from the list of blocks that have pending tasks.\r\n * @internal\r\n * @param block\r\n */\r\n public _removePendingBlock(block: FlowGraphAsyncExecutionBlock) {\r\n const index = this._pendingBlocks.indexOf(block);\r\n if (index !== -1) {\r\n this._pendingBlocks.splice(index, 1);\r\n }\r\n }\r\n\r\n /**\r\n * Clear all pending blocks.\r\n * @internal\r\n */\r\n public _clearPendingBlocks() {\r\n for (const block of this._pendingBlocks) {\r\n block._cancelPendingTasks(this);\r\n }\r\n this._pendingBlocks.length = 0;\r\n }\r\n\r\n /**\r\n * @internal\r\n * Function that notifies the node executed observable\r\n * @param node\r\n */\r\n public _notifyExecuteNode(node: FlowGraphBlock) {\r\n this.onNodeExecutedObservable.notifyObservers(node);\r\n this.logger?.addLogItem({\r\n time: Date.now(),\r\n className: node.getClassName(),\r\n uniqueId: node.uniqueId,\r\n action: FlowGraphAction.ExecuteBlock,\r\n });\r\n }\r\n\r\n public _notifyOnTick(framePayload: IFlowGraphOnTickEventPayload) {\r\n // set the values as global variables\r\n this._setGlobalContextVariable(\"timeSinceStart\", framePayload.timeSinceStart);\r\n this._setGlobalContextVariable(\"deltaTime\", framePayload.deltaTime);\r\n // iterate the pending blocks and run each one's onFrame function\r\n for (const block of this._pendingBlocks) {\r\n block._executeOnTick?.(this);\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _increaseExecutionId() {\r\n this._executionId++;\r\n }\r\n /**\r\n * A monotonically increasing ID for each execution.\r\n * Incremented for every block executed.\r\n */\r\n public get executionId() {\r\n return this._executionId;\r\n }\r\n\r\n /**\r\n * Serializes a context\r\n * @param serializationObject the object to write the values in\r\n * @param valueSerializationFunction a function to serialize complex values\r\n */\r\n public serialize(serializationObject: any = {}, valueSerializationFunction: (key: string, value: any, serializationObject: any) => void = defaultValueSerializationFunction) {\r\n serializationObject.uniqueId = this.uniqueId;\r\n serializationObject._userVariables = {};\r\n for (const key in this._userVariables) {\r\n valueSerializationFunction(key, this._userVariables[key], serializationObject._userVariables);\r\n }\r\n serializationObject._connectionValues = {};\r\n for (const key in this._connectionValues) {\r\n valueSerializationFunction(key, this._connectionValues[key], serializationObject._connectionValues);\r\n }\r\n // serialize assets context, if not scene\r\n if (this.assetsContext !== this.getScene()) {\r\n serializationObject._assetsContext = {\r\n meshes: this.assetsContext.meshes.map((m) => m.id),\r\n materials: this.assetsContext.materials.map((m) => m.id),\r\n textures: this.assetsContext.textures.map((m) => m.name),\r\n animations: this.assetsContext.animations.map((m) => m.name),\r\n lights: this.assetsContext.lights.map((m) => m.id),\r\n cameras: this.assetsContext.cameras.map((m) => m.id),\r\n sounds: this.assetsContext.sounds?.map((m) => m.name),\r\n skeletons: this.assetsContext.skeletons.map((m) => m.id),\r\n particleSystems: this.assetsContext.particleSystems.map((m) => m.name),\r\n geometries: this.assetsContext.geometries.map((m) => m.id),\r\n multiMaterials: this.assetsContext.multiMaterials.map((m) => m.id),\r\n transformNodes: this.assetsContext.transformNodes.map((m) => m.id),\r\n };\r\n }\r\n }\r\n\r\n /**\r\n * @returns the class name of the object.\r\n */\r\n public getClassName() {\r\n return \"FlowGraphContext\";\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"flowGraphContext.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraphContext.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAM1C,OAAO,EAAE,iCAAiC,EAAE,MAAM,iBAAiB,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;A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CAAC,CAAC,EAAE,CAAC;aACrE,CAAC;QACN,CAAC;IACL,CAAC;IAED;;OAEG;IACI,YAAY;QACf,OAAO,kBAAkB,CAAC;IAC9B,CAAC;CACJ;AAjdU;IADN,SAAS,EAAE;kDACmB","sourcesContent":["import { serialize } from \"../Misc/decorators\";\r\nimport { RandomGUID } from \"../Misc/guid\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { FlowGraphAsyncExecutionBlock } from \"./flowGraphAsyncExecutionBlock\";\r\nimport type { FlowGraphBlock } from \"./flowGraphBlock\";\r\nimport type { FlowGraphDataConnection } from \"./flowGraphDataConnection\";\r\nimport type { FlowGraph } from \"./flowGraph\";\r\nimport { defaultValueSerializationFunction } from \"./serialization\";\r\nimport type { FlowGraphCoordinator } from \"./flowGraphCoordinator\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport type { AssetType, FlowGraphAssetType } from \"./flowGraphAssetsContext\";\r\nimport { GetFlowGraphAssetWithType } from \"./flowGraphAssetsContext\";\r\nimport type { IAssetContainer } from \"core/IAssetContainer\";\r\nimport type { Nullable } from \"core/types\";\r\nimport { FlowGraphAction, FlowGraphLogger } from \"./flowGraphLogger\";\r\nimport type { IFlowGraphOnTickEventPayload } from \"./Blocks/Event/flowGraphSceneTickEventBlock\";\r\n\r\n/**\r\n * Construction parameters for the context.\r\n */\r\nexport interface IFlowGraphContextConfiguration {\r\n /**\r\n * The scene that the flow graph context belongs to.\r\n */\r\n readonly scene: Scene;\r\n /**\r\n * The event coordinator used by the flow graph context.\r\n */\r\n readonly coordinator: FlowGraphCoordinator;\r\n\r\n /**\r\n * The assets context used by the flow graph context.\r\n * If none is provided, a default one will be created.\r\n */\r\n readonly assetsContext?: IAssetContainer;\r\n}\r\n\r\n/**\r\n * Options for parsing a context.\r\n */\r\nexport interface IFlowGraphContextParseOptions {\r\n /**\r\n * A function that parses a value from a serialization object.\r\n * @param key the key of the value\r\n * @param serializationObject the object containing the value\r\n * @param assetsContainer the assets container\r\n * @param scene the current scene\r\n * @returns\r\n */\r\n readonly valueParseFunction?: (key: string, serializationObject: any, assetsContainer: IAssetContainer, scene: Scene) => any;\r\n /**\r\n * The graph that the context is being parsed in.\r\n */\r\n readonly graph: FlowGraph;\r\n}\r\n/**\r\n * The context represents the current state and execution of the flow graph.\r\n * It contains both user-defined variables, which are derived from\r\n * a more general variable definition, and execution variables that\r\n * are set by the blocks.\r\n */\r\nexport class FlowGraphContext {\r\n /**\r\n * A randomly generated GUID for each context.\r\n */\r\n @serialize()\r\n public uniqueId = RandomGUID();\r\n /**\r\n * These are the variables defined by a user.\r\n */\r\n private _userVariables: { [key: string]: any } = {};\r\n /**\r\n * These are the variables set by the blocks.\r\n */\r\n private _executionVariables: { [key: string]: any } = {};\r\n\r\n /**\r\n * A context-specific global variables, available to all blocks in the context.\r\n */\r\n private _globalContextVariables: { [key: string]: any } = {};\r\n /**\r\n * These are the values for the data connection points\r\n */\r\n private _connectionValues: { [key: string]: any } = {};\r\n /**\r\n * These are the variables set by the graph.\r\n */\r\n private readonly _configuration: IFlowGraphContextConfiguration;\r\n /**\r\n * These are blocks that have currently pending tasks/listeners that need to be cleaned up.\r\n */\r\n private _pendingBlocks: FlowGraphAsyncExecutionBlock[] = [];\r\n /**\r\n * A monotonically increasing ID for each execution.\r\n * Incremented for every block executed.\r\n */\r\n private _executionId = 0;\r\n /**\r\n * Observable that is triggered when a node is executed.\r\n */\r\n public onNodeExecutedObservable: Observable<FlowGraphBlock> = new Observable<FlowGraphBlock>();\r\n\r\n /**\r\n * The assets context used by the flow graph context.\r\n * Note that it can be shared between flow graph contexts.\r\n */\r\n public assetsContext: IAssetContainer;\r\n\r\n /**\r\n * Whether to treat data as right-handed.\r\n * This is used when serializing data from a right-handed system, while running the context in a left-handed system, for example in glTF parsing.\r\n * Default is false.\r\n */\r\n public treatDataAsRightHanded = false;\r\n\r\n private _enableLogging = false;\r\n\r\n /**\r\n * The logger used by the context to log actions.\r\n */\r\n public logger: Nullable<FlowGraphLogger>;\r\n\r\n /**\r\n * Enable logging on this context\r\n */\r\n public get enableLogging() {\r\n return this._enableLogging;\r\n }\r\n\r\n public set enableLogging(value: boolean) {\r\n if (this._enableLogging === value) {\r\n return;\r\n }\r\n this._enableLogging = value;\r\n if (this._enableLogging) {\r\n this.logger = new FlowGraphLogger();\r\n this.logger.logToConsole = true;\r\n } else {\r\n this.logger = null;\r\n }\r\n }\r\n\r\n constructor(params: IFlowGraphContextConfiguration) {\r\n this._configuration = params;\r\n this.assetsContext = params.assetsContext ?? params.scene;\r\n }\r\n\r\n /**\r\n * Check if a user-defined variable is defined.\r\n * @param name the name of the variable\r\n * @returns true if the variable is defined\r\n */\r\n public hasVariable(name: string) {\r\n return name in this._userVariables;\r\n }\r\n\r\n /**\r\n * Set a user-defined variable.\r\n * @param name the name of the variable\r\n * @param value the value of the variable\r\n */\r\n public setVariable(name: string, value: any) {\r\n this._userVariables[name] = value;\r\n this.logger?.addLogItem({\r\n time: Date.now(),\r\n className: this.getClassName(),\r\n uniqueId: this.uniqueId,\r\n action: FlowGraphAction.ContextVariableSet,\r\n payload: {\r\n name,\r\n value,\r\n },\r\n });\r\n }\r\n\r\n /**\r\n * Get an assets from the assets context based on its type and index in the array\r\n * @param type The type of the asset\r\n * @param index The index of the asset\r\n * @returns The asset or null if not found\r\n */\r\n public getAsset<T extends FlowGraphAssetType>(type: T, index: number): Nullable<AssetType<T>> {\r\n return GetFlowGraphAssetWithType(this.assetsContext, type, index);\r\n }\r\n\r\n /**\r\n * Get a user-defined variable.\r\n * @param name the name of the variable\r\n * @returns the value of the variable\r\n */\r\n public getVariable(name: string): any {\r\n this.logger?.addLogItem({\r\n time: Date.now(),\r\n className: this.getClassName(),\r\n uniqueId: this.uniqueId,\r\n action: FlowGraphAction.ContextVariableGet,\r\n payload: {\r\n name,\r\n value: this._userVariables[name],\r\n },\r\n });\r\n return this._userVariables[name];\r\n }\r\n\r\n /**\r\n * Gets all user variables map\r\n */\r\n public get userVariables() {\r\n return this._userVariables;\r\n }\r\n\r\n /**\r\n * Get the scene that the context belongs to.\r\n * @returns the scene\r\n */\r\n public getScene() {\r\n return this._configuration.scene;\r\n }\r\n\r\n private _getUniqueIdPrefixedName(obj: FlowGraphBlock, name: string): string {\r\n return `${obj.uniqueId}_${name}`;\r\n }\r\n\r\n /**\r\n * @internal\r\n * @param name name of the variable\r\n * @param defaultValue default value to return if the variable is not defined\r\n * @returns the variable value or the default value if the variable is not defined\r\n */\r\n public _getGlobalContextVariable<T>(name: string, defaultValue: T): T {\r\n this.logger?.addLogItem({\r\n time: Date.now(),\r\n className: this.getClassName(),\r\n uniqueId: this.uniqueId,\r\n action: FlowGraphAction.GlobalVariableGet,\r\n payload: {\r\n name,\r\n defaultValue,\r\n possibleValue: this._globalContextVariables[name],\r\n },\r\n });\r\n if (this._hasGlobalContextVariable(name)) {\r\n return this._globalContextVariables[name];\r\n } else {\r\n return defaultValue;\r\n }\r\n }\r\n\r\n /**\r\n * Set a global context variable\r\n * @internal\r\n * @param name the name of the variable\r\n * @param value the value of the variable\r\n */\r\n public _setGlobalContextVariable<T>(name: string, value: T) {\r\n this.logger?.addLogItem({\r\n time: Date.now(),\r\n className: this.getClassName(),\r\n uniqueId: this.uniqueId,\r\n action: FlowGraphAction.GlobalVariableSet,\r\n payload: { name, value },\r\n });\r\n this._globalContextVariables[name] = value;\r\n }\r\n\r\n /**\r\n * Delete a global context variable\r\n * @internal\r\n * @param name the name of the variable\r\n */\r\n public _deleteGlobalContextVariable(name: string) {\r\n this.logger?.addLogItem({\r\n time: Date.now(),\r\n className: this.getClassName(),\r\n uniqueId: this.uniqueId,\r\n action: FlowGraphAction.GlobalVariableDelete,\r\n payload: { name },\r\n });\r\n delete this._globalContextVariables[name];\r\n }\r\n\r\n /**\r\n * Check if a global context variable is defined\r\n * @internal\r\n * @param name the name of the variable\r\n * @returns true if the variable is defined\r\n */\r\n public _hasGlobalContextVariable(name: string) {\r\n return name in this._globalContextVariables;\r\n }\r\n\r\n /**\r\n * Set an internal execution variable\r\n * @internal\r\n * @param name\r\n * @param value\r\n */\r\n public _setExecutionVariable(block: FlowGraphBlock, name: string, value: any) {\r\n this._executionVariables[this._getUniqueIdPrefixedName(block, name)] = value;\r\n }\r\n\r\n /**\r\n * Get an internal execution variable\r\n * @internal\r\n * @param name\r\n * @returns\r\n */\r\n public _getExecutionVariable<T>(block: FlowGraphBlock, name: string, defaultValue: T): T {\r\n if (this._hasExecutionVariable(block, name)) {\r\n return this._executionVariables[this._getUniqueIdPrefixedName(block, name)];\r\n } else {\r\n return defaultValue;\r\n }\r\n }\r\n\r\n /**\r\n * Delete an internal execution variable\r\n * @internal\r\n * @param block\r\n * @param name\r\n */\r\n public _deleteExecutionVariable(block: FlowGraphBlock, name: string) {\r\n delete this._executionVariables[this._getUniqueIdPrefixedName(block, name)];\r\n }\r\n\r\n /**\r\n * Check if an internal execution variable is defined\r\n * @internal\r\n * @param block\r\n * @param name\r\n * @returns\r\n */\r\n public _hasExecutionVariable(block: FlowGraphBlock, name: string) {\r\n return this._getUniqueIdPrefixedName(block, name) in this._executionVariables;\r\n }\r\n\r\n /**\r\n * Check if a connection value is defined\r\n * @internal\r\n * @param connectionPoint\r\n * @returns\r\n */\r\n public _hasConnectionValue(connectionPoint: FlowGraphDataConnection<any>) {\r\n return connectionPoint.uniqueId in this._connectionValues;\r\n }\r\n\r\n /**\r\n * Set a connection value\r\n * @internal\r\n * @param connectionPoint\r\n * @param value\r\n */\r\n public _setConnectionValue<T>(connectionPoint: FlowGraphDataConnection<T>, value: T) {\r\n this._connectionValues[connectionPoint.uniqueId] = value;\r\n this.logger?.addLogItem({\r\n time: Date.now(),\r\n className: this.getClassName(),\r\n uniqueId: this.uniqueId,\r\n action: FlowGraphAction.SetConnectionValue,\r\n payload: {\r\n connectionPointId: connectionPoint.uniqueId,\r\n value,\r\n },\r\n });\r\n }\r\n\r\n /**\r\n * Set a connection value by key\r\n * @internal\r\n * @param key the key of the connection value\r\n * @param value the value of the connection\r\n */\r\n public _setConnectionValueByKey<T>(key: string, value: T) {\r\n this._connectionValues[key] = value;\r\n }\r\n\r\n /**\r\n * Get a connection value\r\n * @internal\r\n * @param connectionPoint\r\n * @returns\r\n */\r\n public _getConnectionValue<T>(connectionPoint: FlowGraphDataConnection<T>): T {\r\n this.logger?.addLogItem({\r\n time: Date.now(),\r\n className: this.getClassName(),\r\n uniqueId: this.uniqueId,\r\n action: FlowGraphAction.GetConnectionValue,\r\n payload: {\r\n connectionPointId: connectionPoint.uniqueId,\r\n value: this._connectionValues[connectionPoint.uniqueId],\r\n },\r\n });\r\n return this._connectionValues[connectionPoint.uniqueId];\r\n }\r\n\r\n /**\r\n * Get the configuration\r\n * @internal\r\n * @param name\r\n * @param value\r\n */\r\n public get configuration() {\r\n return this._configuration;\r\n }\r\n\r\n /**\r\n * Check if there are any pending blocks in this context\r\n * @returns true if there are pending blocks\r\n */\r\n public get hasPendingBlocks() {\r\n return this._pendingBlocks.length > 0;\r\n }\r\n\r\n /**\r\n * Add a block to the list of blocks that have pending tasks.\r\n * @internal\r\n * @param block\r\n */\r\n public _addPendingBlock(block: FlowGraphAsyncExecutionBlock) {\r\n // check if block is already in the array\r\n if (this._pendingBlocks.includes(block)) {\r\n return;\r\n }\r\n this._pendingBlocks.push(block);\r\n // sort pending blocks by priority\r\n this._pendingBlocks.sort((a, b) => a.priority - b.priority);\r\n }\r\n\r\n /**\r\n * Remove a block from the list of blocks that have pending tasks.\r\n * @internal\r\n * @param block\r\n */\r\n public _removePendingBlock(block: FlowGraphAsyncExecutionBlock) {\r\n const index = this._pendingBlocks.indexOf(block);\r\n if (index !== -1) {\r\n this._pendingBlocks.splice(index, 1);\r\n }\r\n }\r\n\r\n /**\r\n * Clear all pending blocks.\r\n * @internal\r\n */\r\n public _clearPendingBlocks() {\r\n for (const block of this._pendingBlocks) {\r\n block._cancelPendingTasks(this);\r\n }\r\n this._pendingBlocks.length = 0;\r\n }\r\n\r\n /**\r\n * @internal\r\n * Function that notifies the node executed observable\r\n * @param node\r\n */\r\n public _notifyExecuteNode(node: FlowGraphBlock) {\r\n this.onNodeExecutedObservable.notifyObservers(node);\r\n this.logger?.addLogItem({\r\n time: Date.now(),\r\n className: node.getClassName(),\r\n uniqueId: node.uniqueId,\r\n action: FlowGraphAction.ExecuteBlock,\r\n });\r\n }\r\n\r\n public _notifyOnTick(framePayload: IFlowGraphOnTickEventPayload) {\r\n // set the values as global variables\r\n this._setGlobalContextVariable(\"timeSinceStart\", framePayload.timeSinceStart);\r\n this._setGlobalContextVariable(\"deltaTime\", framePayload.deltaTime);\r\n // iterate the pending blocks and run each one's onFrame function\r\n for (const block of this._pendingBlocks) {\r\n block._executeOnTick?.(this);\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _increaseExecutionId() {\r\n this._executionId++;\r\n }\r\n /**\r\n * A monotonically increasing ID for each execution.\r\n * Incremented for every block executed.\r\n */\r\n public get executionId() {\r\n return this._executionId;\r\n }\r\n\r\n /**\r\n * Serializes a context\r\n * @param serializationObject the object to write the values in\r\n * @param valueSerializationFunction a function to serialize complex values\r\n */\r\n public serialize(serializationObject: any = {}, valueSerializationFunction: (key: string, value: any, serializationObject: any) => void = defaultValueSerializationFunction) {\r\n serializationObject.uniqueId = this.uniqueId;\r\n serializationObject._userVariables = {};\r\n for (const key in this._userVariables) {\r\n valueSerializationFunction(key, this._userVariables[key], serializationObject._userVariables);\r\n }\r\n serializationObject._connectionValues = {};\r\n for (const key in this._connectionValues) {\r\n valueSerializationFunction(key, this._connectionValues[key], serializationObject._connectionValues);\r\n }\r\n // serialize assets context, if not scene\r\n if (this.assetsContext !== this.getScene()) {\r\n serializationObject._assetsContext = {\r\n meshes: this.assetsContext.meshes.map((m) => m.id),\r\n materials: this.assetsContext.materials.map((m) => m.id),\r\n textures: this.assetsContext.textures.map((m) => m.name),\r\n animations: this.assetsContext.animations.map((m) => m.name),\r\n lights: this.assetsContext.lights.map((m) => m.id),\r\n cameras: this.assetsContext.cameras.map((m) => m.id),\r\n sounds: this.assetsContext.sounds?.map((m) => m.name),\r\n skeletons: this.assetsContext.skeletons.map((m) => m.id),\r\n particleSystems: this.assetsContext.particleSystems.map((m) => m.name),\r\n geometries: this.assetsContext.geometries.map((m) => m.id),\r\n multiMaterials: this.assetsContext.multiMaterials.map((m) => m.id),\r\n transformNodes: this.assetsContext.transformNodes.map((m) => m.id),\r\n };\r\n }\r\n }\r\n\r\n /**\r\n * @returns the class name of the object.\r\n */\r\n public getClassName() {\r\n return \"FlowGraphContext\";\r\n }\r\n}\r\n"]}
@@ -21,6 +21,7 @@ export interface IFlowGraphCoordinatorParseOptions {
21
21
  * A function that will be called to parse the value of a property.
22
22
  * @param key the key of the property
23
23
  * @param serializationObject the serialization object where the property is located
24
+ * @param assetsContainer the assets container
24
25
  * @param scene the scene that the block is being parsed in
25
26
  */
26
27
  valueParseFunction?: (key: string, serializationObject: any, assetsContainer: IAssetContainer, scene: Scene) => any;
@@ -1 +1 @@
1
- {"version":3,"file":"flowGraphCoordinator.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraphCoordinator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,8BAA6B;AAElD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAIxC,OAAO,EAAE,MAAM,EAAE,0BAAyB;AAgC1C;;;;;GAKG;AACH,MAAM,OAAO,oBAAoB;IAmC7B;IACI;;OAEG;IACI,MAA0C;QAA1C,WAAM,GAAN,MAAM,CAAoC;QArBrD;;;WAGG;QACI,gCAA2B,GAAY,IAAI,CAAC;QAElC,gBAAW,GAAgB,EAAE,CAAC;QAEvC,qBAAgB,GAAiC,IAAI,GAAG,EAAE,CAAC;QAE3D,2BAAsB,GAAwB,IAAI,GAAG,EAAE,CAAC;QAIxD,wBAAmB,GAAmD,EAAE,CAAC;QACzE,mBAAc,GAAW,CAAC,CAAC;QAQ/B,0EAA0E;QAC1E,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,MAAM,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AsB,CAAC,GAAG,CAAC,EAAE,CAAE,CAAC;YACnD,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,EAAE,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;YAC/C,IAAI,KAAK,IAAI,oBAAoB,CAAC,6BAA6B,EAAE,CAAC;gBAC9D,IAAI,KAAK,KAAK,oBAAoB,CAAC,6BAA6B,EAAE,CAAC;oBAC/D,MAAM,CAAC,IAAI,CAAC,uDAAuD,EAAE,IAAI,CAAC,CAAC;gBAC/E,CAAC;gBACD,OAAO;YACX,CAAC;QACL,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;QAC3C,CAAC;QACD,MAAM,UAAU,GAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACjD,IAAI,UAAU,EAAE,CAAC;YACb,UAAU,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QACrC,CAAC;IACL,CAAC;;AAvLD;;;;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","sourcesContent":["import type { Observer } from \"core/Misc/observable\";\r\nimport { 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\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\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 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 * 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 public constructor(\r\n /**\r\n * the configuration of the block\r\n */\r\n public config: IFlowGraphCoordinatorConfiguration\r\n ) {\r\n // When the scene is disposed, dispose all graphs currently running on it.\r\n this._disposeObserver = this.config.scene.onDisposeObservable.add(() => {\r\n this.dispose();\r\n });\r\n\r\n this._onBeforeRenderObserver = this.config.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 const coordinators = FlowGraphCoordinator.SceneCoordinators.get(this.config.scene) ?? [];\r\n coordinators.push(this);\r\n }\r\n\r\n /**\r\n * Creates a new flow graph and adds it to the list of existing flow graphs\r\n * @returns a new flow graph\r\n */\r\n public createGraph(): FlowGraph {\r\n const graph = new FlowGraph({ scene: this.config.scene, coordinator: this });\r\n this._flowGraphs.push(graph);\r\n return graph;\r\n }\r\n\r\n /**\r\n * Removes a flow graph from the list of existing flow graphs and disposes it\r\n * @param graph the graph to remove\r\n */\r\n public removeGraph(graph: FlowGraph) {\r\n const index = this._flowGraphs.indexOf(graph);\r\n if (index !== -1) {\r\n graph.dispose();\r\n this._flowGraphs.splice(index, 1);\r\n }\r\n }\r\n\r\n /**\r\n * Starts all graphs\r\n */\r\n public start() {\r\n 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 }\r\n this._flowGraphs.length = 0;\r\n this._disposeObserver?.remove();\r\n this._onBeforeRenderObserver?.remove();\r\n\r\n // Remove itself from the SceneCoordinators list for the Inspector.\r\n const coordinators = FlowGraphCoordinator.SceneCoordinators.get(this.config.scene) ?? [];\r\n const index = coordinators.indexOf(this);\r\n if (index !== -1) {\r\n coordinators.splice(index, 1);\r\n }\r\n }\r\n\r\n /**\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"]}
1
+ {"version":3,"file":"flowGraphCoordinator.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraphCoordinator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,8BAA6B;AAElD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAIxC,OAAO,EAAE,MAAM,EAAE,0BAAyB;AAiC1C;;;;;GAKG;AACH,MAAM,OAAO,oBAAoB;IAmC7B;IACI;;OAEG;IACI,MAA0C;QAA1C,WAAM,GAAN,MAAM,CAAoC;QArBrD;;;WAGG;QACI,gCAA2B,GAAY,IAAI,CAAC;QAElC,gBAAW,GAAgB,EAAE,CAAC;QAEvC,qBAAgB,GAAiC,IAAI,GAAG,EAAE,CAAC;QAE3D,2BAAsB,GAAwB,IAAI,GAAG,EAAE,CAAC;QAIxD,wBAAmB,GAAmD,EAAE,CAAC;QACzE,mBAAc,GAAW,CAAC,CAAC;QAQ/B,0EAA0E;QAC1E,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAAC,GAAG,CAAC,GAAG,EAAE;YACnE,IAAI,CAAC,OAAO,EAAE,CAAC;QACnB,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,uBAAuB,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,wBAAwB,CAAC,GAAG,CAAC,GAAG,EAAE;YAC/E,oEAAoE;YACpE,IAAI,CAAC,sBAAsB,CAAC,KAAK,EAAE,CAA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D,EAAE,IAAI,CAAC,CAAC;gBAC/E,CAAC;gBACD,OAAO;YACX,CAAC;QACL,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;QAC3C,CAAC;QACD,MAAM,UAAU,GAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACjD,IAAI,UAAU,EAAE,CAAC;YACb,UAAU,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QACrC,CAAC;IACL,CAAC;;AAvLD;;;;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","sourcesContent":["import type { Observer } from \"core/Misc/observable\";\r\nimport { 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\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\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 * 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 public constructor(\r\n /**\r\n * the configuration of the block\r\n */\r\n public config: IFlowGraphCoordinatorConfiguration\r\n ) {\r\n // When the scene is disposed, dispose all graphs currently running on it.\r\n this._disposeObserver = this.config.scene.onDisposeObservable.add(() => {\r\n this.dispose();\r\n });\r\n\r\n this._onBeforeRenderObserver = this.config.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 const coordinators = FlowGraphCoordinator.SceneCoordinators.get(this.config.scene) ?? [];\r\n coordinators.push(this);\r\n }\r\n\r\n /**\r\n * Creates a new flow graph and adds it to the list of existing flow graphs\r\n * @returns a new flow graph\r\n */\r\n public createGraph(): FlowGraph {\r\n const graph = new FlowGraph({ scene: this.config.scene, coordinator: this });\r\n this._flowGraphs.push(graph);\r\n return graph;\r\n }\r\n\r\n /**\r\n * Removes a flow graph from the list of existing flow graphs and disposes it\r\n * @param graph the graph to remove\r\n */\r\n public removeGraph(graph: FlowGraph) {\r\n const index = this._flowGraphs.indexOf(graph);\r\n if (index !== -1) {\r\n graph.dispose();\r\n this._flowGraphs.splice(index, 1);\r\n }\r\n }\r\n\r\n /**\r\n * Starts all graphs\r\n */\r\n public start() {\r\n 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 }\r\n this._flowGraphs.length = 0;\r\n this._disposeObserver?.remove();\r\n this._onBeforeRenderObserver?.remove();\r\n\r\n // Remove itself from the SceneCoordinators list for the Inspector.\r\n const coordinators = FlowGraphCoordinator.SceneCoordinators.get(this.config.scene) ?? [];\r\n const index = coordinators.indexOf(this);\r\n if (index !== -1) {\r\n coordinators.splice(index, 1);\r\n }\r\n }\r\n\r\n /**\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"]}
@@ -1,4 +1,4 @@
1
- import type { Nullable, NodeRenderGraphBlock, INodeRenderGraphCreateOptions, INodeRenderGraphEditorOptions, Scene, INodeRenderGraphCustomBlockDescription, Immutable } from "../../index.js";
1
+ import type { Nullable, NodeRenderGraphBlock, INodeRenderGraphCreateOptions, INodeRenderGraphEditorOptions, Scene, INodeRenderGraphCustomBlockDescription, Immutable, Camera } from "../../index.js";
2
2
  import { Observable } from "../../Misc/observable.js";
3
3
  import { NodeRenderGraphOutputBlock } from "./Blocks/outputBlock.js";
4
4
  import { FrameGraph } from "../frameGraph.js";
@@ -107,6 +107,17 @@ export declare class NodeRenderGraph {
107
107
  * @returns an array of InputBlocks
108
108
  */
109
109
  getInputBlocks(): NodeRenderGraphInputBlock[];
110
+ /**
111
+ * Replaces a camera in all camera input blocks of this node render graph.
112
+ * If the current camera is found in any input block, it is replaced by the new camera,
113
+ * optionally updating the scene's pointer camera and rebuilding the graph.
114
+ * @param currentCamera The camera to replace.
115
+ * @param newCamera The new camera to assign to the matching input blocks.
116
+ * @param updateCameraToUseForPointers If true (default), updates `scene.cameraToUseForPointers` to the new camera when a replacement occurs.
117
+ * @param rebuildGraph If true (default), rebuilds the graph asynchronously after the replacement.
118
+ * @returns A promise that resolves to true if at least one input block was updated, false otherwise.
119
+ */
120
+ replaceCameraAsync(currentCamera: Nullable<Camera>, newCamera: Camera, updateCameraToUseForPointers?: boolean, rebuildGraph?: boolean): Promise<boolean>;
110
121
  /**
111
122
  * Launch the node render graph editor
112
123
  * @param config Define the configuration of the editor
@@ -66,7 +66,6 @@ export class NodeRenderGraph {
66
66
  */
67
67
  constructor(name, scene, options) {
68
68
  this._buildId = NodeRenderGraph._BuildIdGenerator++;
69
- // eslint-disable-next-line @typescript-eslint/naming-convention
70
69
  this.BJSNODERENDERGRAPHEDITOR = this._getGlobalNodeRenderGraphEditor();
71
70
  /**
72
71
  * Gets or sets data used by visual editor
@@ -175,6 +174,42 @@ export class NodeRenderGraph {
175
174
  }
176
175
  return blocks;
177
176
  }
177
+ /**
178
+ * Replaces a camera in all camera input blocks of this node render graph.
179
+ * If the current camera is found in any input block, it is replaced by the new camera,
180
+ * optionally updating the scene's pointer camera and rebuilding the graph.
181
+ * @param currentCamera The camera to replace.
182
+ * @param newCamera The new camera to assign to the matching input blocks.
183
+ * @param updateCameraToUseForPointers If true (default), updates `scene.cameraToUseForPointers` to the new camera when a replacement occurs.
184
+ * @param rebuildGraph If true (default), rebuilds the graph asynchronously after the replacement.
185
+ * @returns A promise that resolves to true if at least one input block was updated, false otherwise.
186
+ */
187
+ async replaceCameraAsync(currentCamera, newCamera, updateCameraToUseForPointers = true, rebuildGraph = true) {
188
+ const inputBlocks = this.getInputBlocks();
189
+ let updated = false;
190
+ for (const block of inputBlocks) {
191
+ if (block.isCamera() && block.value === currentCamera) {
192
+ block.value = newCamera;
193
+ updated = true;
194
+ }
195
+ }
196
+ if (updated) {
197
+ if (updateCameraToUseForPointers) {
198
+ this._scene.cameraToUseForPointers = newCamera;
199
+ }
200
+ if (rebuildGraph) {
201
+ const currentAutoFill = this._options.autoFillExternalInputs;
202
+ try {
203
+ this._options.autoFillExternalInputs = false; // makes sure that the camera input block(s) we just updated don't get overwritten by autoFillExternalInputs
204
+ await this.buildAsync();
205
+ }
206
+ finally {
207
+ this._options.autoFillExternalInputs = currentAutoFill;
208
+ }
209
+ }
210
+ }
211
+ return updated;
212
+ }
178
213
  /**
179
214
  * Launch the node render graph editor
180
215
  * @param config Define the configuration of the editor
@@ -296,7 +331,6 @@ export class NodeRenderGraph {
296
331
  * @param maxTimeout Maximum time in ms to wait for the graph to be ready (default is 10000)
297
332
  * @returns The promise that resolves when the graph is ready
298
333
  */
299
- // eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax
300
334
  async whenReadyAsync(timeStep = 16, maxTimeout = 10000) {
301
335
  this._frameGraph.pausedExecution = true;
302
336
  await this._frameGraph.whenReadyAsync(timeStep, maxTimeout);