@onerjs/core 9.0.0 → 9.0.1

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 (352) hide show
  1. package/Animations/animationGroup.pure.js.map +1 -1
  2. package/Cameras/targetCamera.pure.js +6 -1
  3. package/Cameras/targetCamera.pure.js.map +1 -1
  4. package/Engines/Native/nativeHardwareTexture.d.ts +8 -1
  5. package/Engines/Native/nativeHardwareTexture.js +7 -0
  6. package/Engines/Native/nativeHardwareTexture.js.map +1 -1
  7. package/Engines/Native/nativeHelpers.js +56 -1
  8. package/Engines/Native/nativeHelpers.js.map +1 -1
  9. package/Engines/Native/nativeInterfaces.d.ts +37 -8
  10. package/Engines/Native/nativeInterfaces.js.map +1 -1
  11. package/Engines/Native/nativeRenderTargetWrapper.d.ts +40 -0
  12. package/Engines/Native/nativeRenderTargetWrapper.js +265 -5
  13. package/Engines/Native/nativeRenderTargetWrapper.js.map +1 -1
  14. package/Engines/Processors/shaderCodeCursor.d.ts +1 -0
  15. package/Engines/Processors/shaderCodeCursor.js +40 -3
  16. package/Engines/Processors/shaderCodeCursor.js.map +1 -1
  17. package/Engines/WebGPU/Extensions/engine.renderTarget.pure.js +1 -0
  18. package/Engines/WebGPU/Extensions/engine.renderTarget.pure.js.map +1 -1
  19. package/Engines/abstractEngine.pure.d.ts +15 -1
  20. package/Engines/abstractEngine.pure.js +12 -4
  21. package/Engines/abstractEngine.pure.js.map +1 -1
  22. package/Engines/engine.pure.d.ts +0 -1
  23. package/Engines/engine.pure.js +0 -7
  24. package/Engines/engine.pure.js.map +1 -1
  25. package/Engines/nativeEngine.pure.js +1 -1
  26. package/Engines/nativeEngine.pure.js.map +1 -1
  27. package/Engines/thinEngine.pure.d.ts +1 -0
  28. package/Engines/thinEngine.pure.js +13 -2
  29. package/Engines/thinEngine.pure.js.map +1 -1
  30. package/Engines/thinNativeEngine.pure.d.ts +217 -17
  31. package/Engines/thinNativeEngine.pure.js +1431 -164
  32. package/Engines/thinNativeEngine.pure.js.map +1 -1
  33. package/Engines/thinWebGPUEngine.js +6 -1
  34. package/Engines/thinWebGPUEngine.js.map +1 -1
  35. package/Engines/webgpuEngine.pure.d.ts +12 -1
  36. package/Engines/webgpuEngine.pure.js +8 -0
  37. package/Engines/webgpuEngine.pure.js.map +1 -1
  38. package/FlowGraph/Blocks/Data/Transformers/flowGraphJsonPointerParserBlock.pure.d.ts +10 -0
  39. package/FlowGraph/Blocks/Data/Transformers/flowGraphJsonPointerParserBlock.pure.js +24 -12
  40. package/FlowGraph/Blocks/Data/Transformers/flowGraphJsonPointerParserBlock.pure.js.map +1 -1
  41. package/FlowGraph/Blocks/Data/flowGraphGetPropertyBlock.pure.d.ts +7 -0
  42. package/FlowGraph/Blocks/Data/flowGraphGetPropertyBlock.pure.js +43 -0
  43. package/FlowGraph/Blocks/Data/flowGraphGetPropertyBlock.pure.js.map +1 -1
  44. package/FlowGraph/Blocks/Event/flowGraphSceneTickEventBlock.pure.d.ts +16 -4
  45. package/FlowGraph/Blocks/Event/flowGraphSceneTickEventBlock.pure.js +20 -6
  46. package/FlowGraph/Blocks/Event/flowGraphSceneTickEventBlock.pure.js.map +1 -1
  47. package/FlowGraph/Blocks/Execution/Animation/flowGraphInterpolationBlock.pure.js +3 -3
  48. package/FlowGraph/Blocks/Execution/Animation/flowGraphInterpolationBlock.pure.js.map +1 -1
  49. package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.pure.d.ts +7 -7
  50. package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.pure.js +52 -35
  51. package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.pure.js.map +1 -1
  52. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCancelDelayBlock.pure.d.ts +12 -1
  53. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCancelDelayBlock.pure.js +8 -0
  54. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCancelDelayBlock.pure.js.map +1 -1
  55. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphForLoopBlock.pure.js +4 -1
  56. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphForLoopBlock.pure.js.map +1 -1
  57. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.pure.d.ts +12 -1
  58. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.pure.js +5 -1
  59. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.pure.js.map +1 -1
  60. package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.pure.d.ts +2 -0
  61. package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.pure.js +14 -2
  62. package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.pure.js.map +1 -1
  63. package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.pure.d.ts +5 -1
  64. package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.pure.js +23 -8
  65. package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.pure.js.map +1 -1
  66. package/FlowGraph/CustomTypes/flowGraphInteger.pure.d.ts +5 -0
  67. package/FlowGraph/CustomTypes/flowGraphInteger.pure.js +7 -0
  68. package/FlowGraph/CustomTypes/flowGraphInteger.pure.js.map +1 -1
  69. package/FlowGraph/CustomTypes/flowGraphMatrix.d.ts +10 -0
  70. package/FlowGraph/CustomTypes/flowGraphMatrix.js +14 -0
  71. package/FlowGraph/CustomTypes/flowGraphMatrix.js.map +1 -1
  72. package/FlowGraph/flowGraph.d.ts +2 -1
  73. package/FlowGraph/flowGraph.js +3 -2
  74. package/FlowGraph/flowGraph.js.map +1 -1
  75. package/FlowGraph/flowGraphAnimationHelpers.d.ts +24 -0
  76. package/FlowGraph/flowGraphAnimationHelpers.js +21 -0
  77. package/FlowGraph/flowGraphAnimationHelpers.js.map +1 -0
  78. package/FlowGraph/flowGraphContext.js +1 -0
  79. package/FlowGraph/flowGraphContext.js.map +1 -1
  80. package/FlowGraph/flowGraphValidator.js +0 -4
  81. package/FlowGraph/flowGraphValidator.js.map +1 -1
  82. package/FlowGraph/index.d.ts +2 -0
  83. package/FlowGraph/index.js +2 -0
  84. package/FlowGraph/index.js.map +1 -1
  85. package/FlowGraph/pure.d.ts +2 -0
  86. package/FlowGraph/pure.js +2 -0
  87. package/FlowGraph/pure.js.map +1 -1
  88. package/FlowGraph/serialization.d.ts +2 -2
  89. package/FlowGraph/serialization.js +2 -2
  90. package/FlowGraph/serialization.js.map +1 -1
  91. package/FlowGraph/typeDefinitions.d.ts +1 -1
  92. package/FlowGraph/typeDefinitions.js.map +1 -1
  93. package/FrameGraph/Node/Blocks/Textures/minMaxReducerBlock.d.ts +1 -0
  94. package/FrameGraph/Node/Blocks/Textures/minMaxReducerBlock.js +4 -0
  95. package/FrameGraph/Node/Blocks/Textures/minMaxReducerBlock.js.map +1 -0
  96. package/FrameGraph/Node/Blocks/Textures/minMaxReducerBlock.pure.d.ts +54 -0
  97. package/FrameGraph/Node/Blocks/Textures/minMaxReducerBlock.pure.js +155 -0
  98. package/FrameGraph/Node/Blocks/Textures/minMaxReducerBlock.pure.js.map +1 -0
  99. package/FrameGraph/Node/Blocks/Textures/pure.d.ts +1 -0
  100. package/FrameGraph/Node/Blocks/Textures/pure.js +1 -0
  101. package/FrameGraph/Node/Blocks/Textures/pure.js.map +1 -1
  102. package/FrameGraph/Node/Blocks/allBlocks.pure.js +2 -0
  103. package/FrameGraph/Node/Blocks/allBlocks.pure.js.map +1 -1
  104. package/FrameGraph/Node/Blocks/index.d.ts +1 -0
  105. package/FrameGraph/Node/Blocks/index.js +1 -0
  106. package/FrameGraph/Node/Blocks/index.js.map +1 -1
  107. package/FrameGraph/Node/Blocks/pure.d.ts +1 -0
  108. package/FrameGraph/Node/Blocks/pure.js +1 -0
  109. package/FrameGraph/Node/Blocks/pure.js.map +1 -1
  110. package/FrameGraph/Tasks/Misc/minMaxReducerTask.d.ts +62 -0
  111. package/FrameGraph/Tasks/Misc/minMaxReducerTask.js +159 -0
  112. package/FrameGraph/Tasks/Misc/minMaxReducerTask.js.map +1 -0
  113. package/FrameGraph/Tasks/Rendering/geometryRendererTask.js +3 -1
  114. package/FrameGraph/Tasks/Rendering/geometryRendererTask.js.map +1 -1
  115. package/FrameGraph/frameGraph.d.ts +4 -0
  116. package/FrameGraph/frameGraph.js +14 -0
  117. package/FrameGraph/frameGraph.js.map +1 -1
  118. package/FrameGraph/index.d.ts +1 -0
  119. package/FrameGraph/index.js +1 -0
  120. package/FrameGraph/index.js.map +1 -1
  121. package/FrameGraph/pure.d.ts +1 -0
  122. package/FrameGraph/pure.js +1 -0
  123. package/FrameGraph/pure.js.map +1 -1
  124. package/Inputs/scene.inputManager.js +1 -1
  125. package/Inputs/scene.inputManager.js.map +1 -1
  126. package/Lights/Clustered/clusteredLightingSceneComponent.pure.d.ts +5 -0
  127. package/Lights/Clustered/clusteredLightingSceneComponent.pure.js +22 -1
  128. package/Lights/Clustered/clusteredLightingSceneComponent.pure.js.map +1 -1
  129. package/Lights/Shadows/cascadedShadowGenerator.pure.js +7 -3
  130. package/Lights/Shadows/cascadedShadowGenerator.pure.js.map +1 -1
  131. package/Materials/GaussianSplatting/gaussianPointSplattingBlitMaterial.d.ts +7 -0
  132. package/Materials/GaussianSplatting/gaussianPointSplattingBlitMaterial.js +8 -0
  133. package/Materials/GaussianSplatting/gaussianPointSplattingBlitMaterial.js.map +1 -0
  134. package/Materials/GaussianSplatting/gaussianPointSplattingBlitMaterial.pure.d.ts +54 -0
  135. package/Materials/GaussianSplatting/gaussianPointSplattingBlitMaterial.pure.js +81 -0
  136. package/Materials/GaussianSplatting/gaussianPointSplattingBlitMaterial.pure.js.map +1 -0
  137. package/Materials/GaussianSplatting/gaussianPointSplattingDepthBlitMaterial.d.ts +7 -0
  138. package/Materials/GaussianSplatting/gaussianPointSplattingDepthBlitMaterial.js +8 -0
  139. package/Materials/GaussianSplatting/gaussianPointSplattingDepthBlitMaterial.js.map +1 -0
  140. package/Materials/GaussianSplatting/gaussianPointSplattingDepthBlitMaterial.pure.d.ts +60 -0
  141. package/Materials/GaussianSplatting/gaussianPointSplattingDepthBlitMaterial.pure.js +90 -0
  142. package/Materials/GaussianSplatting/gaussianPointSplattingDepthBlitMaterial.pure.js.map +1 -0
  143. package/Materials/GaussianSplatting/gaussianSplattingDebugMaterialPlugin.pure.d.ts +31 -0
  144. package/Materials/GaussianSplatting/gaussianSplattingDebugMaterialPlugin.pure.js +98 -0
  145. package/Materials/GaussianSplatting/gaussianSplattingDebugMaterialPlugin.pure.js.map +1 -1
  146. package/Materials/GaussianSplatting/gaussianSplattingGpuPickingMaterialPlugin.pure.js +1 -1
  147. package/Materials/GaussianSplatting/gaussianSplattingGpuPickingMaterialPlugin.pure.js.map +1 -1
  148. package/Materials/GaussianSplatting/gaussianSplattingMaterial.pure.js +2 -2
  149. package/Materials/GaussianSplatting/gaussianSplattingMaterial.pure.js.map +1 -1
  150. package/Materials/GaussianSplatting/gaussianSplattingOverdrawMaterialPlugin.d.ts +1 -0
  151. package/Materials/GaussianSplatting/gaussianSplattingOverdrawMaterialPlugin.js +4 -0
  152. package/Materials/GaussianSplatting/gaussianSplattingOverdrawMaterialPlugin.js.map +1 -0
  153. package/Materials/GaussianSplatting/gaussianSplattingOverdrawMaterialPlugin.pure.d.ts +83 -0
  154. package/Materials/GaussianSplatting/gaussianSplattingOverdrawMaterialPlugin.pure.js +191 -0
  155. package/Materials/GaussianSplatting/gaussianSplattingOverdrawMaterialPlugin.pure.js.map +1 -0
  156. package/Materials/GaussianSplatting/gaussianSplattingSizeMaterialPlugin.d.ts +1 -0
  157. package/Materials/GaussianSplatting/gaussianSplattingSizeMaterialPlugin.js +4 -0
  158. package/Materials/GaussianSplatting/gaussianSplattingSizeMaterialPlugin.js.map +1 -0
  159. package/Materials/GaussianSplatting/gaussianSplattingSizeMaterialPlugin.pure.d.ts +62 -0
  160. package/Materials/GaussianSplatting/gaussianSplattingSizeMaterialPlugin.pure.js +125 -0
  161. package/Materials/GaussianSplatting/gaussianSplattingSizeMaterialPlugin.pure.js.map +1 -0
  162. package/Materials/GaussianSplatting/pure.d.ts +4 -0
  163. package/Materials/GaussianSplatting/pure.js +4 -0
  164. package/Materials/GaussianSplatting/pure.js.map +1 -1
  165. package/Materials/Node/Blocks/Dual/imageSourceBlock.pure.d.ts +1 -0
  166. package/Materials/Node/Blocks/Dual/imageSourceBlock.pure.js +12 -0
  167. package/Materials/Node/Blocks/Dual/imageSourceBlock.pure.js.map +1 -1
  168. package/Materials/Textures/Procedurals/proceduralTexture.pure.d.ts +1 -0
  169. package/Materials/Textures/Procedurals/proceduralTexture.pure.js +31 -7
  170. package/Materials/Textures/Procedurals/proceduralTexture.pure.js.map +1 -1
  171. package/Materials/Textures/mirrorTexture.pure.js +3 -1
  172. package/Materials/Textures/mirrorTexture.pure.js.map +1 -1
  173. package/Materials/Textures/texture.pure.js +1 -1
  174. package/Materials/Textures/texture.pure.js.map +1 -1
  175. package/Materials/effectRenderer.pure.d.ts +4 -0
  176. package/Materials/effectRenderer.pure.js +3 -2
  177. package/Materials/effectRenderer.pure.js.map +1 -1
  178. package/Materials/index.d.ts +4 -0
  179. package/Materials/index.js +4 -0
  180. package/Materials/index.js.map +1 -1
  181. package/Materials/material.pure.js +25 -12
  182. package/Materials/material.pure.js.map +1 -1
  183. package/Materials/pure.d.ts +4 -0
  184. package/Materials/pure.js +4 -0
  185. package/Materials/pure.js.map +1 -1
  186. package/Materials/standardMaterial.pure.d.ts +8 -0
  187. package/Materials/standardMaterial.pure.js +24 -2
  188. package/Materials/standardMaterial.pure.js.map +1 -1
  189. package/Meshes/Builders/polygonBuilder.pure.js +1 -1
  190. package/Meshes/Builders/polygonBuilder.pure.js.map +1 -1
  191. package/Meshes/GaussianSplatting/gaussianPointSplattingController.d.ts +8 -0
  192. package/Meshes/GaussianSplatting/gaussianPointSplattingController.js +11 -0
  193. package/Meshes/GaussianSplatting/gaussianPointSplattingController.js.map +1 -0
  194. package/Meshes/GaussianSplatting/gaussianPointSplattingController.pure.d.ts +231 -0
  195. package/Meshes/GaussianSplatting/gaussianPointSplattingController.pure.js +1212 -0
  196. package/Meshes/GaussianSplatting/gaussianPointSplattingController.pure.js.map +1 -0
  197. package/Meshes/GaussianSplatting/gaussianPointSplattingRenderer.d.ts +14 -0
  198. package/Meshes/GaussianSplatting/gaussianPointSplattingRenderer.js +15 -0
  199. package/Meshes/GaussianSplatting/gaussianPointSplattingRenderer.js.map +1 -0
  200. package/Meshes/GaussianSplatting/gaussianPointSplattingRenderer.pure.d.ts +285 -0
  201. package/Meshes/GaussianSplatting/gaussianPointSplattingRenderer.pure.js +812 -0
  202. package/Meshes/GaussianSplatting/gaussianPointSplattingRenderer.pure.js.map +1 -0
  203. package/Meshes/GaussianSplatting/gaussianSplattingMesh.d.ts +1 -0
  204. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +2 -0
  205. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
  206. package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.d.ts +160 -0
  207. package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.js +219 -0
  208. package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.js.map +1 -1
  209. package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.d.ts +32 -4
  210. package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js +114 -21
  211. package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js.map +1 -1
  212. package/Meshes/GaussianSplatting/pure.d.ts +2 -0
  213. package/Meshes/GaussianSplatting/pure.js +2 -0
  214. package/Meshes/GaussianSplatting/pure.js.map +1 -1
  215. package/Meshes/Node/Blocks/booleanGeometryBlock.pure.js +25 -11
  216. package/Meshes/Node/Blocks/booleanGeometryBlock.pure.js.map +1 -1
  217. package/Meshes/abstractMesh.pure.d.ts +12 -0
  218. package/Meshes/abstractMesh.pure.js +32 -0
  219. package/Meshes/abstractMesh.pure.js.map +1 -1
  220. package/Meshes/index.d.ts +1 -0
  221. package/Meshes/index.js +1 -0
  222. package/Meshes/index.js.map +1 -1
  223. package/Meshes/pure.d.ts +1 -0
  224. package/Meshes/pure.js +1 -0
  225. package/Meshes/pure.js.map +1 -1
  226. package/Meshes/subMesh.pure.d.ts +11 -2
  227. package/Meshes/subMesh.pure.js +20 -5
  228. package/Meshes/subMesh.pure.js.map +1 -1
  229. package/Meshes/thinInstanceMesh.pure.js +1 -0
  230. package/Meshes/thinInstanceMesh.pure.js.map +1 -1
  231. package/Misc/andOrNotEvaluator.js +4 -0
  232. package/Misc/andOrNotEvaluator.js.map +1 -1
  233. package/Misc/minMaxReducer.pure.d.ts +6 -0
  234. package/Misc/minMaxReducer.pure.js +10 -0
  235. package/Misc/minMaxReducer.pure.js.map +1 -1
  236. package/Misc/thinMinMaxReducer.d.ts +19 -2
  237. package/Misc/thinMinMaxReducer.js +74 -21
  238. package/Misc/thinMinMaxReducer.js.map +1 -1
  239. package/Misc/tools.pure.js +1 -1
  240. package/Misc/tools.pure.js.map +1 -1
  241. package/Particles/Node/Blocks/Update/updateNoiseBlock.pure.js +19 -7
  242. package/Particles/Node/Blocks/Update/updateNoiseBlock.pure.js.map +1 -1
  243. package/Particles/Node/Blocks/particleSourceTextureBlock.pure.js +3 -2
  244. package/Particles/Node/Blocks/particleSourceTextureBlock.pure.js.map +1 -1
  245. package/Particles/gpuParticleSystem.pure.d.ts +2 -0
  246. package/Particles/gpuParticleSystem.pure.js +12 -4
  247. package/Particles/gpuParticleSystem.pure.js.map +1 -1
  248. package/Particles/particle.js +3 -2
  249. package/Particles/particle.js.map +1 -1
  250. package/Particles/solidParticleSystem.js +7 -1
  251. package/Particles/solidParticleSystem.js.map +1 -1
  252. package/Particles/thinParticleSystem.function.d.ts +6 -0
  253. package/Particles/thinParticleSystem.function.js +144 -88
  254. package/Particles/thinParticleSystem.function.js.map +1 -1
  255. package/Particles/thinParticleSystem.pure.d.ts +6 -0
  256. package/Particles/thinParticleSystem.pure.js +70 -9
  257. package/Particles/thinParticleSystem.pure.js.map +1 -1
  258. package/Physics/v2/ragdoll.d.ts +2 -4
  259. package/Physics/v2/ragdoll.js +11 -4
  260. package/Physics/v2/ragdoll.js.map +1 -1
  261. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.pure.d.ts +12 -0
  262. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.pure.js +43 -18
  263. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.pure.js.map +1 -1
  264. package/Rendering/depthRenderer.pure.d.ts +9 -0
  265. package/Rendering/depthRenderer.pure.js +12 -0
  266. package/Rendering/depthRenderer.pure.js.map +1 -1
  267. package/Rendering/fluidRenderer/fluidRenderingObject.d.ts +4 -0
  268. package/Rendering/fluidRenderer/fluidRenderingObject.js +6 -0
  269. package/Rendering/fluidRenderer/fluidRenderingObject.js.map +1 -1
  270. package/Rendering/fluidRenderer/fluidRenderingObjectParticleSystem.d.ts +4 -0
  271. package/Rendering/fluidRenderer/fluidRenderingObjectParticleSystem.js +8 -0
  272. package/Rendering/fluidRenderer/fluidRenderingObjectParticleSystem.js.map +1 -1
  273. package/Rendering/fluidRenderer/fluidRenderingTargetRenderer.js +3 -0
  274. package/Rendering/fluidRenderer/fluidRenderingTargetRenderer.js.map +1 -1
  275. package/Rendering/geometryBufferRenderer.pure.js +4 -1
  276. package/Rendering/geometryBufferRenderer.pure.js.map +1 -1
  277. package/Rendering/prePassRenderer.pure.js +3 -3
  278. package/Rendering/prePassRenderer.pure.js.map +1 -1
  279. package/Shaders/ShadersInclude/gaussianSplatting.js +3 -1
  280. package/Shaders/ShadersInclude/gaussianSplatting.js.map +1 -1
  281. package/Shaders/ShadersInclude/lightsFragmentFunctions.js +27 -3
  282. package/Shaders/ShadersInclude/lightsFragmentFunctions.js.map +1 -1
  283. package/Shaders/ShadersInclude/oitDeclaration.js +1 -1
  284. package/Shaders/ShadersInclude/oitDeclaration.js.map +1 -1
  285. package/Shaders/minmaxRedux.fragment.js +6 -1
  286. package/Shaders/minmaxRedux.fragment.js.map +1 -1
  287. package/ShadersWGSL/ShadersInclude/gaussianPointSplatting.d.ts +5 -0
  288. package/ShadersWGSL/ShadersInclude/gaussianPointSplatting.js +65 -0
  289. package/ShadersWGSL/ShadersInclude/gaussianPointSplatting.js.map +1 -0
  290. package/ShadersWGSL/ShadersInclude/gaussianPointSplattingScan.d.ts +5 -0
  291. package/ShadersWGSL/ShadersInclude/gaussianPointSplattingScan.js +17 -0
  292. package/ShadersWGSL/ShadersInclude/gaussianPointSplattingScan.js.map +1 -0
  293. package/ShadersWGSL/ShadersInclude/gaussianSplatting.d.ts +1 -0
  294. package/ShadersWGSL/ShadersInclude/gaussianSplatting.js +6 -78
  295. package/ShadersWGSL/ShadersInclude/gaussianSplatting.js.map +1 -1
  296. package/ShadersWGSL/ShadersInclude/gaussianSplattingFragmentDeclaration.js +2 -2
  297. package/ShadersWGSL/ShadersInclude/gaussianSplattingFragmentDeclaration.js.map +1 -1
  298. package/ShadersWGSL/ShadersInclude/gaussianSplattingShared.d.ts +5 -0
  299. package/ShadersWGSL/ShadersInclude/gaussianSplattingShared.js +79 -0
  300. package/ShadersWGSL/ShadersInclude/gaussianSplattingShared.js.map +1 -0
  301. package/ShadersWGSL/ShadersInclude/lightsFragmentFunctions.js +27 -3
  302. package/ShadersWGSL/ShadersInclude/lightsFragmentFunctions.js.map +1 -1
  303. package/ShadersWGSL/gaussianPointSplattingBlit.fragment.d.ts +5 -0
  304. package/ShadersWGSL/gaussianPointSplattingBlit.fragment.js +22 -0
  305. package/ShadersWGSL/gaussianPointSplattingBlit.fragment.js.map +1 -0
  306. package/ShadersWGSL/gaussianPointSplattingBlit.vertex.d.ts +5 -0
  307. package/ShadersWGSL/gaussianPointSplattingBlit.vertex.js +19 -0
  308. package/ShadersWGSL/gaussianPointSplattingBlit.vertex.js.map +1 -0
  309. package/ShadersWGSL/gaussianPointSplattingDepthBlit.fragment.d.ts +5 -0
  310. package/ShadersWGSL/gaussianPointSplattingDepthBlit.fragment.js +21 -0
  311. package/ShadersWGSL/gaussianPointSplattingDepthBlit.fragment.js.map +1 -0
  312. package/ShadersWGSL/gaussianSplatting.vertex.js +2 -1
  313. package/ShadersWGSL/gaussianSplatting.vertex.js.map +1 -1
  314. package/ShadersWGSL/gaussianSplattingDepth.vertex.js +2 -1
  315. package/ShadersWGSL/gaussianSplattingDepth.vertex.js.map +1 -1
  316. package/ShadersWGSL/gaussianSplattingVoxel.vertex.js +2 -1
  317. package/ShadersWGSL/gaussianSplattingVoxel.vertex.js.map +1 -1
  318. package/ShadersWGSL/gpsHiZBuild.compute.d.ts +5 -0
  319. package/ShadersWGSL/gpsHiZBuild.compute.js +16 -0
  320. package/ShadersWGSL/gpsHiZBuild.compute.js.map +1 -0
  321. package/ShadersWGSL/gpsPartition.compute.d.ts +5 -0
  322. package/ShadersWGSL/gpsPartition.compute.js +27 -0
  323. package/ShadersWGSL/gpsPartition.compute.js.map +1 -0
  324. package/ShadersWGSL/gpsPreprocess.compute.d.ts +5 -0
  325. package/ShadersWGSL/gpsPreprocess.compute.js +86 -0
  326. package/ShadersWGSL/gpsPreprocess.compute.js.map +1 -0
  327. package/ShadersWGSL/gpsResolve.compute.d.ts +5 -0
  328. package/ShadersWGSL/gpsResolve.compute.js +41 -0
  329. package/ShadersWGSL/gpsResolve.compute.js.map +1 -0
  330. package/ShadersWGSL/gpsScanAdd.compute.d.ts +5 -0
  331. package/ShadersWGSL/gpsScanAdd.compute.js +22 -0
  332. package/ShadersWGSL/gpsScanAdd.compute.js.map +1 -0
  333. package/ShadersWGSL/gpsScanBlocks.compute.d.ts +5 -0
  334. package/ShadersWGSL/gpsScanBlocks.compute.js +23 -0
  335. package/ShadersWGSL/gpsScanBlocks.compute.js.map +1 -0
  336. package/ShadersWGSL/gpsScanSums.compute.d.ts +5 -0
  337. package/ShadersWGSL/gpsScanSums.compute.js +30 -0
  338. package/ShadersWGSL/gpsScanSums.compute.js.map +1 -0
  339. package/ShadersWGSL/gpsSplat.compute.d.ts +5 -0
  340. package/ShadersWGSL/gpsSplat.compute.js +37 -0
  341. package/ShadersWGSL/gpsSplat.compute.js.map +1 -0
  342. package/ShadersWGSL/minmaxRedux.fragment.js +20 -3
  343. package/ShadersWGSL/minmaxRedux.fragment.js.map +1 -1
  344. package/XR/features/WebXRSpaceWarp.pure.js +2 -1
  345. package/XR/features/WebXRSpaceWarp.pure.js.map +1 -1
  346. package/assetContainer.d.ts +1 -0
  347. package/assetContainer.js +5 -1
  348. package/assetContainer.js.map +1 -1
  349. package/package.json +1 -1
  350. package/scene.pure.d.ts +13 -2
  351. package/scene.pure.js +28 -4
  352. package/scene.pure.js.map +1 -1
@@ -3,26 +3,8 @@ import { FlowGraphAsyncExecutionBlock } from "../../../flowGraphAsyncExecutionBl
3
3
  import { RichTypeAny, RichTypeNumber, RichTypeBoolean } from "../../../flowGraphRichTypes.pure.js";
4
4
  import { AnimationGroup } from "../../../../Animations/animationGroup.pure.js";
5
5
  import { RegisterClass } from "../../../../Misc/typeStore.js";
6
- /**
7
- * Removes observers owned by the play block that started an animation group.
8
- * @param context active FlowGraph context
9
- * @param animationGroup animation group being replaced or stopped
10
- * @returns the owning play block, when one was registered
11
- */
12
- export function RemoveFlowGraphAnimationGroupObservers(context, animationGroup) {
13
- const observerSets = context._getGlobalContextVariable("animationGroupObserverSets", new Map());
14
- const observers = observerSets.get(animationGroup.uniqueId);
15
- if (!observers) {
16
- return undefined;
17
- }
18
- animationGroup.onAnimationGroupEndObservable.remove(observers.groupEnd);
19
- animationGroup.onAnimationEndObservable.remove(observers.animationEnd);
20
- animationGroup.onAnimationLoopObservable.remove(observers.animationLoop);
21
- animationGroup.onAnimationGroupLoopObservable.remove(observers.groupLoop);
22
- observerSets.delete(animationGroup.uniqueId);
23
- context._setGlobalContextVariable("animationGroupObserverSets", observerSets);
24
- return observers.block;
25
- }
6
+ import { RemoveFlowGraphAnimationGroupObservers } from "../../../flowGraphAnimationHelpers.js";
7
+ export { RemoveFlowGraphAnimationGroupObservers } from "../../../flowGraphAnimationHelpers.js";
26
8
  /**
27
9
  * @experimental
28
10
  * A block that plays an animation on an animatable object.
@@ -44,6 +26,7 @@ export class FlowGraphPlayAnimationBlock extends FlowGraphAsyncExecutionBlock {
44
26
  this.currentAnimationGroup = this.registerDataOutput("currentAnimationGroup", RichTypeAny);
45
27
  this.animationGroup = this.registerDataInput("animationGroup", RichTypeAny, config?.animationGroup);
46
28
  this.animation = this.registerDataInput("animation", RichTypeAny);
29
+ this.animationTargets = this.registerDataInput("animationTargets", RichTypeAny);
47
30
  this.object = this.registerDataInput("object", RichTypeAny);
48
31
  }
49
32
  /**
@@ -59,8 +42,8 @@ export class FlowGraphPlayAnimationBlock extends FlowGraphAsyncExecutionBlock {
59
42
  return;
60
43
  }
61
44
  context._addPendingBlock(this);
62
- this.out._activateSignal(context);
63
45
  context._setExecutionVariable(this, "_initialized", true);
46
+ this.out._activateSignal(context);
64
47
  }
65
48
  /**
66
49
  * @internal
@@ -77,12 +60,26 @@ export class FlowGraphPlayAnimationBlock extends FlowGraphAsyncExecutionBlock {
77
60
  * @returns whether the animation was prepared and started successfully
78
61
  */
79
62
  _tryPreparePendingTasks(context) {
80
- const ag = this.animationGroup.getValue(context);
81
- const animation = this.animation.getValue(context);
63
+ let ag;
64
+ let animation;
65
+ let animationTargets;
66
+ try {
67
+ ag = this.animationGroup.getValue(context);
68
+ animation = this.animation.getValue(context);
69
+ animationTargets = ag ? undefined : this.animationTargets.getValue(context);
70
+ }
71
+ catch (error) {
72
+ this._reportError(context, error);
73
+ return false;
74
+ }
82
75
  if (!ag && !animation) {
83
76
  this._reportError(context, "No animation or animation group provided");
84
77
  return false;
85
78
  }
79
+ else if (!ag && Array.isArray(animation) && animation.length === 0) {
80
+ this._reportError(context, "Animation array is empty");
81
+ return false;
82
+ }
86
83
  else if (ag && ag.targetedAnimations.length === 0) {
87
84
  this._reportError(context, "Animation group has no targeted animations");
88
85
  return false;
@@ -99,17 +96,30 @@ export class FlowGraphPlayAnimationBlock extends FlowGraphAsyncExecutionBlock {
99
96
  let interpolationTarget;
100
97
  // check which animation to use. If no animationGroup was defined and an animation was provided, use the animation
101
98
  if (animation && !animationGroupToUse) {
102
- const target = this.object.getValue(context);
103
- if (!target) {
99
+ const target = animationTargets === undefined ? this.object.getValue(context) : undefined;
100
+ const animationsArray = Array.isArray(animation) ? animation : [animation];
101
+ if (animationTargets !== undefined && (!Array.isArray(animationTargets) || animationTargets.length !== animationsArray.length)) {
102
+ this._reportError(context, "Animation targets must match the animation array.");
103
+ return false;
104
+ }
105
+ if (!animationTargets && !target) {
104
106
  this._reportError(context, "No target object provided");
105
107
  return false;
106
108
  }
107
- const animationsArray = Array.isArray(animation) ? animation : [animation];
109
+ if (animationTargets) {
110
+ for (const animationTarget of animationTargets) {
111
+ if (!animationTarget) {
112
+ this._reportError(context, "No target object provided");
113
+ return false;
114
+ }
115
+ }
116
+ }
108
117
  const name = animationsArray[0].name;
109
- animationGroupToUse = new AnimationGroup("flowGraphAnimationGroup-" + name + "-" + target.name, context.configuration.scene);
118
+ animationGroupToUse = new AnimationGroup("flowGraphAnimationGroup-" + name + "-" + (target?.name ?? "targets"), context.configuration.scene);
110
119
  const interpolationAnimations = context._getGlobalContextVariable("interpolationAnimations", []);
111
- for (const anim of animationsArray) {
112
- animationGroupToUse.addTargetedAnimation(anim, target);
120
+ for (let index = 0; index < animationsArray.length; index++) {
121
+ const anim = animationsArray[index];
122
+ animationGroupToUse.addTargetedAnimation(anim, animationTargets ? animationTargets[index] : target);
113
123
  if (interpolationAnimations.indexOf(anim.uniqueId) !== -1) {
114
124
  isInterpolation = true;
115
125
  }
@@ -183,8 +193,8 @@ export class FlowGraphPlayAnimationBlock extends FlowGraphAsyncExecutionBlock {
183
193
  // Stop any interpolation already running on the same target/property, but only after validation has
184
194
  // passed. An invalid interpolation (bad duration or NaN control points) must report [err] without
185
195
  // disturbing an interpolation that is already running on the same target.
186
- if (isInterpolation && interpolationAnimationsArray && interpolationTarget !== undefined) {
187
- this._checkInterpolationDuplications(context, interpolationAnimationsArray, interpolationTarget);
196
+ if (isInterpolation && interpolationAnimationsArray) {
197
+ this._checkInterpolationDuplications(context, interpolationAnimationsArray, interpolationTarget, animationTargets);
188
198
  }
189
199
  const loop = !isFinite(to) || this.loop.getValue(context);
190
200
  this.currentAnimationGroup.setValue(animationGroupToUse, context);
@@ -250,17 +260,24 @@ export class FlowGraphPlayAnimationBlock extends FlowGraphAsyncExecutionBlock {
250
260
  * If they do, we want to stop the already-running animation group.
251
261
  * @internal
252
262
  */
253
- _checkInterpolationDuplications(context, animation, target) {
263
+ _checkInterpolationDuplications(context, animation, target, targets) {
254
264
  const currentlyRunningAnimationGroups = context._getGlobalContextVariable("currentlyRunningAnimationGroups", []);
255
- for (const uniqueId of currentlyRunningAnimationGroups) {
265
+ for (let groupIndex = currentlyRunningAnimationGroups.length - 1; groupIndex >= 0; groupIndex--) {
266
+ const uniqueId = currentlyRunningAnimationGroups[groupIndex];
256
267
  const ag = context.assetsContext.animationGroups.find((ag) => ag.uniqueId === uniqueId);
257
268
  if (ag) {
269
+ let stopped = false;
258
270
  for (const anim of ag.targetedAnimations) {
259
- for (const animToCheck of animation) {
260
- if (anim.animation.targetProperty === animToCheck.targetProperty && anim.target === target) {
271
+ for (let index = 0; index < animation.length; index++) {
272
+ if (anim.animation.targetProperty === animation[index].targetProperty && anim.target === (targets ? targets[index] : target)) {
261
273
  this._stopAnimationGroup(context, ag);
274
+ stopped = true;
275
+ break;
262
276
  }
263
277
  }
278
+ if (stopped) {
279
+ break;
280
+ }
264
281
  }
265
282
  }
266
283
  }
@@ -1 +1 @@
1
- {"version":3,"file":"flowGraphPlayAnimationBlock.pure.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.pure.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAI7D,OAAO,EAAE,4BAA4B,EAAE,MAAM,uCAAuC,CAAC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C,iCAAiC,EAAE,+BAA+B,CAAC,CAAC;QAC1G,CAAC;IACL,CAAC;IAED;;;OAGG;IACa,mBAAmB,CAAC,OAAyB;QACzD,MAAM,EAAE,GAAG,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QACxD,IAAI,EAAE,EAAE,CAAC;YACL,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QAC1C,CAAC;IACL,CAAC;IAED;;OAEG;IACa,YAAY;QACxB,6EAAyC;IAC7C,CAAC;CACJ;AAED,IAAI,WAAW,GAAG,KAAK,CAAC;AACxB;;;GAGG;AACH,MAAM,UAAU,mCAAmC;IAC/C,IAAI,WAAW,EAAE,CAAC;QACd,OAAO;IACX,CAAC;IACD,WAAW,GAAG,IAAI,CAAC;IAEnB,aAAa,wEAAoC,2BAA2B,CAAC,CAAC;AAClF,CAAC","sourcesContent":["/** This file must only contain pure code and pure imports */\r\n\r\nimport { type FlowGraphContext } from \"../../../flowGraphContext\";\r\nimport { type FlowGraphDataConnection } from \"../../../flowGraphDataConnection.pure\";\r\nimport { FlowGraphAsyncExecutionBlock } from \"../../../flowGraphAsyncExecutionBlock\";\r\nimport { RichTypeAny, RichTypeNumber, RichTypeBoolean } from \"../../../flowGraphRichTypes.pure\";\r\nimport { type IFlowGraphBlockConfiguration } from \"../../../flowGraphBlock\";\r\nimport { AnimationGroup } from \"core/Animations/animationGroup.pure\";\r\nimport { type Animation } from \"core/Animations/animation.pure\";\r\nimport { FlowGraphBlockNames } from \"../../flowGraphBlockNames\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { type Observer } from \"core/Misc/observable.pure\";\r\n\r\n/**\r\n * Configuration for playing an animation.\r\n */\r\nexport interface IFlowGraphPlayAnimationBlockConfiguration extends IFlowGraphBlockConfiguration {\r\n /**\r\n * Whether animation-group playback uses the unbounded KHR_interactivity timeline.\r\n */\r\n useVirtualTimeline?: boolean;\r\n}\r\n\r\ntype AnimationObserverSet = {\r\n block: FlowGraphPlayAnimationBlock;\r\n groupEnd: Observer<AnimationGroup>;\r\n animationEnd: Observer<any>;\r\n animationLoop: Observer<any>;\r\n groupLoop: Observer<AnimationGroup>;\r\n};\r\n\r\n/**\r\n * Removes observers owned by the play block that started an animation group.\r\n * @param context active FlowGraph context\r\n * @param animationGroup animation group being replaced or stopped\r\n * @returns the owning play block, when one was registered\r\n */\r\nexport function RemoveFlowGraphAnimationGroupObservers(context: FlowGraphContext, animationGroup: AnimationGroup): FlowGraphPlayAnimationBlock | undefined {\r\n const observerSets = context._getGlobalContextVariable(\"animationGroupObserverSets\", new Map<number, AnimationObserverSet>()) as Map<number, AnimationObserverSet>;\r\n const observers = observerSets.get(animationGroup.uniqueId);\r\n if (!observers) {\r\n return undefined;\r\n }\r\n animationGroup.onAnimationGroupEndObservable.remove(observers.groupEnd);\r\n animationGroup.onAnimationEndObservable.remove(observers.animationEnd);\r\n animationGroup.onAnimationLoopObservable.remove(observers.animationLoop);\r\n animationGroup.onAnimationGroupLoopObservable.remove(observers.groupLoop);\r\n observerSets.delete(animationGroup.uniqueId);\r\n context._setGlobalContextVariable(\"animationGroupObserverSets\", observerSets);\r\n return observers.block;\r\n}\r\n\r\n/**\r\n * @experimental\r\n * A block that plays an animation on an animatable object.\r\n */\r\nexport class FlowGraphPlayAnimationBlock extends FlowGraphAsyncExecutionBlock {\r\n /**\r\n * Input connection: The speed of the animation.\r\n */\r\n public readonly speed: FlowGraphDataConnection<number>;\r\n /**\r\n * Input connection: Should the animation loop?\r\n * Not in glTF specs, but useful for the engine.\r\n */\r\n public readonly loop: FlowGraphDataConnection<boolean>;\r\n /**\r\n * Input connection: The starting frame of the animation.\r\n */\r\n public readonly from: FlowGraphDataConnection<number>;\r\n /**\r\n * Input connection: The ending frame of the animation.\r\n */\r\n public readonly to: FlowGraphDataConnection<number>;\r\n\r\n /**\r\n * Output connection: The current frame of the animation.\r\n */\r\n public readonly currentFrame: FlowGraphDataConnection<number>;\r\n\r\n /**\r\n * Output connection: The current time of the animation.\r\n */\r\n public readonly currentTime: FlowGraphDataConnection<number>;\r\n\r\n /**\r\n * Output connection: The animatable that is currently running.\r\n */\r\n public readonly currentAnimationGroup: FlowGraphDataConnection<AnimationGroup>;\r\n\r\n /**\r\n * Input: Will be initialized if no animation group was provided in the configuration.\r\n */\r\n public readonly animationGroup: FlowGraphDataConnection<AnimationGroup>;\r\n\r\n /**\r\n * Input: If provided this animation will be used. Priority will be given to the animation group input.\r\n */\r\n public readonly animation: FlowGraphDataConnection<Animation | Animation[]>;\r\n\r\n /**\r\n * Input connection: The target object that will be animated. If animation group is provided this input will be ignored.\r\n */\r\n public readonly object: FlowGraphDataConnection<any>;\r\n\r\n public constructor(\r\n /**\r\n * the configuration of the block\r\n */\r\n public override config?: IFlowGraphPlayAnimationBlockConfiguration\r\n ) {\r\n super(config, [\"animationLoop\", \"animationEnd\", \"animationGroupLoop\"]);\r\n\r\n this.speed = this.registerDataInput(\"speed\", RichTypeNumber);\r\n this.loop = this.registerDataInput(\"loop\", RichTypeBoolean);\r\n this.from = this.registerDataInput(\"from\", RichTypeNumber, 0);\r\n this.to = this.registerDataInput(\"to\", RichTypeNumber);\r\n\r\n this.currentFrame = this.registerDataOutput(\"currentFrame\", RichTypeNumber);\r\n this.currentTime = this.registerDataOutput(\"currentTime\", RichTypeNumber);\r\n\r\n this.currentAnimationGroup = this.registerDataOutput(\"currentAnimationGroup\", RichTypeAny);\r\n this.animationGroup = this.registerDataInput(\"animationGroup\", RichTypeAny, config?.animationGroup);\r\n this.animation = this.registerDataInput(\"animation\", RichTypeAny);\r\n this.object = this.registerDataInput(\"object\", RichTypeAny);\r\n }\r\n\r\n /**\r\n * @internal\r\n * @param context\r\n */\r\n public override _startPendingTasks(context: FlowGraphContext): void {\r\n if (context._getExecutionVariable(this, \"_initialized\", false)) {\r\n this._cancelPendingTasks(context);\r\n this._resetAfterCanceled(context);\r\n }\r\n\r\n if (!this._tryPreparePendingTasks(context)) {\r\n return;\r\n }\r\n context._addPendingBlock(this);\r\n this.out._activateSignal(context);\r\n context._setExecutionVariable(this, \"_initialized\", true);\r\n }\r\n\r\n /**\r\n * @internal\r\n * @param context the graph context\r\n */\r\n public override _preparePendingTasks(context: FlowGraphContext): void {\r\n this._tryPreparePendingTasks(context);\r\n }\r\n\r\n /**\r\n * Prepares and starts the animation, reporting whether it could be started. Invalid inputs\r\n * activate `err` and return false, so the caller neither activates `out` nor registers the\r\n * block as pending.\r\n * @param context the graph context\r\n * @returns whether the animation was prepared and started successfully\r\n */\r\n private _tryPreparePendingTasks(context: FlowGraphContext): boolean {\r\n const ag = this.animationGroup.getValue(context);\r\n const animation = this.animation.getValue(context);\r\n if (!ag && !animation) {\r\n this._reportError(context, \"No animation or animation group provided\");\r\n return false;\r\n } else if (ag && ag.targetedAnimations.length === 0) {\r\n this._reportError(context, \"Animation group has no targeted animations\");\r\n return false;\r\n } else {\r\n // if an animation group was already created, dispose it and create a new one\r\n const currentAnimationGroup = this.currentAnimationGroup.getValue(context);\r\n if (currentAnimationGroup && currentAnimationGroup !== ag) {\r\n currentAnimationGroup.dispose();\r\n }\r\n let animationGroupToUse = ag;\r\n let isInterpolation = false;\r\n let interpolationAnimationsArray: Animation[] | undefined;\r\n let interpolationTarget: any;\r\n // check which animation to use. If no animationGroup was defined and an animation was provided, use the animation\r\n if (animation && !animationGroupToUse) {\r\n const target = this.object.getValue(context);\r\n if (!target) {\r\n this._reportError(context, \"No target object provided\");\r\n return false;\r\n }\r\n const animationsArray = Array.isArray(animation) ? animation : [animation];\r\n const name = animationsArray[0].name;\r\n animationGroupToUse = new AnimationGroup(\"flowGraphAnimationGroup-\" + name + \"-\" + target.name, context.configuration.scene);\r\n const interpolationAnimations = context._getGlobalContextVariable(\"interpolationAnimations\", []) as number[];\r\n for (const anim of animationsArray) {\r\n animationGroupToUse.addTargetedAnimation(anim, target);\r\n if (interpolationAnimations.indexOf(anim.uniqueId) !== -1) {\r\n isInterpolation = true;\r\n }\r\n }\r\n interpolationAnimationsArray = animationsArray;\r\n interpolationTarget = target;\r\n }\r\n // not accepting 0\r\n const speed = this.speed.getValue(context) || 1;\r\n const from = this.from.getValue(context) ?? 0;\r\n // Read the raw end time before it is defaulted to the animation group's natural end, so that an\r\n // explicitly provided NaN end time can still be detected by the animation/start validation below.\r\n const rawTo = this.to.getValue(context);\r\n const hasTo = this.to.isConnected() || context._hasConnectionValue(this.to);\r\n const to = hasTo ? rawTo : animationGroupToUse.to;\r\n\r\n // Input validation. Only applies to animation-group playback\r\n // (animation/start); interpolation uses the `animation` input and has its own validation below.\r\n // The operation activates its `err` flow when the speed is NaN, infinite, or <= 0, or\r\n // when the end time is NaN. A NaN or infinite start time is caught by the finite check on `from`.\r\n if (!animation) {\r\n if (isNaN(rawTo)) {\r\n this._reportError(context, \"Invalid animation end time\");\r\n return false;\r\n }\r\n // Only validate a speed that was explicitly provided; an unconnected speed keeps the engine\r\n // default of 1 (matching the historical Babylon behavior for animation/start without a speed).\r\n if (this.speed.isConnected() || context._hasConnectionValue(this.speed)) {\r\n const providedSpeed = this.speed.getValue(context);\r\n if (!isFinite(providedSpeed) || providedSpeed <= 0) {\r\n this._reportError(context, \"Invalid animation speed\");\r\n return false;\r\n }\r\n }\r\n }\r\n\r\n // The start value (interpolation start frame / animation start time) must always be finite. For\r\n // animation/start this also satisfies the spec requirement that a NaN or infinite start time\r\n // activates the err flow.\r\n if (!isFinite(from)) {\r\n this._reportError(context, \"Invalid animation duration\");\r\n return false;\r\n }\r\n // For interpolation the end value is the animation duration and must be a finite, non-negative number.\r\n // Animation-group playback (animation/start) instead allows an infinite end time — it means \"play to\r\n // the natural end / loop\" (see the `loop` computation below) — and its NaN end time was already\r\n // rejected above, so the end value is only range-checked here for the interpolation case.\r\n if (animation && (!isFinite(to) || to < 0)) {\r\n this._reportError(context, \"Invalid animation duration\");\r\n return false;\r\n }\r\n\r\n // CSS cubic-bezier control points must be finite, and the X components must be in [0, 1].\r\n if (animation) {\r\n const animationsArray = Array.isArray(animation) ? animation : [animation];\r\n for (const anim of animationsArray) {\r\n const easing = anim.getEasingFunction?.();\r\n if (easing && \"x1\" in easing) {\r\n const bezier = easing as unknown as { x1: number; y1: number; x2: number; y2: number };\r\n if (\r\n !Number.isFinite(bezier.x1) ||\r\n !Number.isFinite(bezier.y1) ||\r\n !Number.isFinite(bezier.x2) ||\r\n !Number.isFinite(bezier.y2) ||\r\n bezier.x1 < 0 ||\r\n bezier.x1 > 1 ||\r\n bezier.x2 < 0 ||\r\n bezier.x2 > 1\r\n ) {\r\n this._reportError(context, \"Invalid bezier curve control points\");\r\n return false;\r\n }\r\n }\r\n }\r\n }\r\n\r\n // Stop any interpolation already running on the same target/property, but only after validation has\r\n // passed. An invalid interpolation (bad duration or NaN control points) must report [err] without\r\n // disturbing an interpolation that is already running on the same target.\r\n if (isInterpolation && interpolationAnimationsArray && interpolationTarget !== undefined) {\r\n this._checkInterpolationDuplications(context, interpolationAnimationsArray, interpolationTarget);\r\n }\r\n\r\n const loop = !isFinite(to) || this.loop.getValue(context);\r\n this.currentAnimationGroup.setValue(animationGroupToUse, context);\r\n\r\n const currentlyRunningAnimationGroups = context._getGlobalContextVariable(\"currentlyRunningAnimationGroups\", []) as number[];\r\n // check if it already running\r\n if (currentlyRunningAnimationGroups.indexOf(animationGroupToUse.uniqueId) !== -1) {\r\n this._stopAnimationGroup(context, animationGroupToUse);\r\n }\r\n try {\r\n if (this.config?.useVirtualTimeline) {\r\n animationGroupToUse.startWithVirtualTimeline(loop, speed, from, to);\r\n } else {\r\n animationGroupToUse.start(loop, speed, from, to);\r\n }\r\n const observers: AnimationObserverSet = {\r\n block: this,\r\n groupEnd: animationGroupToUse.onAnimationGroupEndObservable.add(() => this._onAnimationGroupEnd(context, animationGroupToUse)),\r\n animationEnd: animationGroupToUse.onAnimationEndObservable.add(() => this._eventsSignalOutputs[\"animationEnd\"]._activateSignal(context)),\r\n animationLoop: animationGroupToUse.onAnimationLoopObservable.add(() => this._eventsSignalOutputs[\"animationLoop\"]._activateSignal(context)),\r\n groupLoop: animationGroupToUse.onAnimationGroupLoopObservable.add(() => this._eventsSignalOutputs[\"animationGroupLoop\"]._activateSignal(context)),\r\n };\r\n const observerSets = context._getGlobalContextVariable(\"animationGroupObserverSets\", new Map<number, AnimationObserverSet>()) as Map<number, AnimationObserverSet>;\r\n observerSets.set(animationGroupToUse.uniqueId, observers);\r\n context._setGlobalContextVariable(\"animationGroupObserverSets\", observerSets);\r\n currentlyRunningAnimationGroups.push(animationGroupToUse.uniqueId);\r\n context._setGlobalContextVariable(\"currentlyRunningAnimationGroups\", currentlyRunningAnimationGroups);\r\n } catch (e) {\r\n this._reportError(context, e);\r\n return false;\r\n }\r\n return true;\r\n }\r\n }\r\n\r\n protected override _reportError(context: FlowGraphContext, error: string | Error): void {\r\n super._reportError(context, error);\r\n this.currentFrame.setValue(-1, context);\r\n this.currentTime.setValue(-1, context);\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public override _executeOnTick(_context: FlowGraphContext): void {\r\n const ag = this.currentAnimationGroup.getValue(_context);\r\n if (ag) {\r\n this.currentFrame.setValue(ag.getCurrentFrame(), _context);\r\n this.currentTime.setValue(ag.animatables[0]?.elapsedTime ?? 0, _context);\r\n }\r\n }\r\n\r\n public _execute(context: FlowGraphContext): void {\r\n this._startPendingTasks(context);\r\n }\r\n\r\n private _onAnimationGroupEnd(context: FlowGraphContext, animationGroup: AnimationGroup) {\r\n RemoveFlowGraphAnimationGroupObservers(context, animationGroup);\r\n this._removeFromCurrentlyRunning(context, animationGroup);\r\n this._resetAfterCanceled(context);\r\n this.done._activateSignal(context);\r\n }\r\n\r\n /**\r\n * The idea behind this function is to check every running animation group and check if the targeted animations it uses are interpolation animations.\r\n * If they are, we want to see that they don't collide with the current interpolation animations that are starting to play.\r\n * If they do, we want to stop the already-running animation group.\r\n * @internal\r\n */\r\n private _checkInterpolationDuplications(context: FlowGraphContext, animation: Animation[], target: any) {\r\n const currentlyRunningAnimationGroups = context._getGlobalContextVariable(\"currentlyRunningAnimationGroups\", []) as number[];\r\n for (const uniqueId of currentlyRunningAnimationGroups) {\r\n const ag = context.assetsContext.animationGroups.find((ag) => ag.uniqueId === uniqueId);\r\n if (ag) {\r\n for (const anim of ag.targetedAnimations) {\r\n for (const animToCheck of animation) {\r\n if (anim.animation.targetProperty === animToCheck.targetProperty && anim.target === target) {\r\n this._stopAnimationGroup(context, ag);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n private _stopAnimationGroup(context: FlowGraphContext, animationGroup: AnimationGroup) {\r\n const owner = RemoveFlowGraphAnimationGroupObservers(context, animationGroup);\r\n owner?._cleanupAfterExternalStop(context, animationGroup);\r\n // stop, while skipping the on AnimationEndObservable to avoid the \"done\" signal\r\n animationGroup.stop(true);\r\n // Only dispose animation groups that were internally created by this block\r\n // (i.e. built from individual animations). Scene-provided animation groups\r\n // must not be disposed as that removes them from the scene catalog and\r\n // breaks the editor dropdown / re-use on replay.\r\n if (animationGroup.name.startsWith(\"flowGraphAnimationGroup-\")) {\r\n animationGroup.dispose();\r\n }\r\n this._removeFromCurrentlyRunning(context, animationGroup);\r\n }\r\n\r\n /** @internal */\r\n public _cleanupAfterExternalStop(context: FlowGraphContext, animationGroup: AnimationGroup): void {\r\n this._removeFromCurrentlyRunning(context, animationGroup);\r\n this._resetAfterCanceled(context);\r\n }\r\n\r\n private _removeFromCurrentlyRunning(context: FlowGraphContext, animationGroup: AnimationGroup) {\r\n const currentlyRunningAnimationGroups = context._getGlobalContextVariable(\"currentlyRunningAnimationGroups\", []) as number[];\r\n const idx = currentlyRunningAnimationGroups.indexOf(animationGroup.uniqueId);\r\n if (idx !== -1) {\r\n currentlyRunningAnimationGroups.splice(idx, 1);\r\n context._setGlobalContextVariable(\"currentlyRunningAnimationGroups\", currentlyRunningAnimationGroups);\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n * Stop any currently running animations.\r\n */\r\n public override _cancelPendingTasks(context: FlowGraphContext): void {\r\n const ag = this.currentAnimationGroup.getValue(context);\r\n if (ag) {\r\n this._stopAnimationGroup(context, ag);\r\n }\r\n }\r\n\r\n /**\r\n * @returns class name of the block.\r\n */\r\n public override getClassName(): string {\r\n return FlowGraphBlockNames.PlayAnimation;\r\n }\r\n}\r\n\r\nlet _Registered = false;\r\n/**\r\n * Register side effects for flowGraphPlayAnimationBlock.\r\n * Safe to call multiple times; only the first call has an effect.\r\n */\r\nexport function RegisterFlowGraphPlayAnimationBlock(): void {\r\n if (_Registered) {\r\n return;\r\n }\r\n _Registered = true;\r\n\r\n RegisterClass(FlowGraphBlockNames.PlayAnimation, FlowGraphPlayAnimationBlock);\r\n}\r\n"]}
1
+ {"version":3,"file":"flowGraphPlayAnimationBlock.pure.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.pure.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAI7D,OAAO,EAAE,4BAA4B,EAAE,MAAM,uCAAuC,CAAC;AACrF,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAEhG,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAIrE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,sCAAsC,EAAuC,MAAM,oCAAoC,CAAC;AACjI,OAAO,EAAE,sCAAsC,EAAE,MAAM,oCAAoC,CAAC;AAY5F;;;GAGG;AACH,MAAM,OAAO,2BAA4B,SAAQ,4BAA4B;IAuDzE;IACI;;OAEG;IACa,MAAkD;QAElE,KAAK,CAAC,MAAM,EAAE,CAAC,eAAe,EAAE,cAAc,EAAE,oBAAoB,CAAC,CAAC,CAAC;QAFvD,WAAM,GAAN,MAAM,CAA4C;QAIlE,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;QAC7D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AA2B,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;IAC9D,CAAC;IAED,gBAAgB;IACT,yBAAyB,CAAC,OAAyB,EAAE,cAA8B;QACtF,IAAI,CAAC,2BAA2B,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;QAC1D,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;IAEO,2BAA2B,CAAC,OAAyB,EAAE,cAA8B;QACzF,MAAM,+BAA+B,GAAG,OAAO,CAAC,yBAAyB,CAAC,iCAAiC,EAAE,EAAE,CAAa,CAAC;QAC7H,MAAM,GAAG,GAAG,+BAA+B,CAAC,OAAO,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;QAC7E,IAAI,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC;YACb,+BAA+B,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;YAC/C,OAAO,CAAC,yBAAyB,CAAC,iCAAiC,EAAE,+BAA+B,CAAC,CAAC;QAC1G,CAAC;IACL,CAAC;IAED;;;OAGG;IACa,mBAAmB,CAAC,OAAyB;QACzD,MAAM,EAAE,GAAG,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QACxD,IAAI,EAAE,EAAE,CAAC;YACL,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QAC1C,CAAC;IACL,CAAC;IAED;;OAEG;IACa,YAAY;QACxB,6EAAyC;IAC7C,CAAC;CACJ;AAED,IAAI,WAAW,GAAG,KAAK,CAAC;AACxB;;;GAGG;AACH,MAAM,UAAU,mCAAmC;IAC/C,IAAI,WAAW,EAAE,CAAC;QACd,OAAO;IACX,CAAC;IACD,WAAW,GAAG,IAAI,CAAC;IAEnB,aAAa,wEAAoC,2BAA2B,CAAC,CAAC;AAClF,CAAC","sourcesContent":["/** This file must only contain pure code and pure imports */\r\n\r\nimport { type FlowGraphContext } from \"../../../flowGraphContext\";\r\nimport { type FlowGraphDataConnection } from \"../../../flowGraphDataConnection.pure\";\r\nimport { FlowGraphAsyncExecutionBlock } from \"../../../flowGraphAsyncExecutionBlock\";\r\nimport { RichTypeAny, RichTypeNumber, RichTypeBoolean } from \"../../../flowGraphRichTypes.pure\";\r\nimport { type IFlowGraphBlockConfiguration } from \"../../../flowGraphBlock\";\r\nimport { AnimationGroup } from \"core/Animations/animationGroup.pure\";\r\nimport { type Animation } from \"core/Animations/animation.pure\";\r\nimport { type IAnimatable } from \"core/Animations/animatable.interface\";\r\nimport { FlowGraphBlockNames } from \"../../flowGraphBlockNames\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { RemoveFlowGraphAnimationGroupObservers, type IFlowGraphAnimationObserverSet } from \"../../../flowGraphAnimationHelpers\";\r\nexport { RemoveFlowGraphAnimationGroupObservers } from \"../../../flowGraphAnimationHelpers\";\r\n\r\n/**\r\n * Configuration for playing an animation.\r\n */\r\nexport interface IFlowGraphPlayAnimationBlockConfiguration extends IFlowGraphBlockConfiguration {\r\n /**\r\n * Whether animation-group playback uses the unbounded KHR_interactivity timeline.\r\n */\r\n useVirtualTimeline?: boolean;\r\n}\r\n\r\n/**\r\n * @experimental\r\n * A block that plays an animation on an animatable object.\r\n */\r\nexport class FlowGraphPlayAnimationBlock extends FlowGraphAsyncExecutionBlock {\r\n /**\r\n * Input connection: The speed of the animation.\r\n */\r\n public readonly speed: FlowGraphDataConnection<number>;\r\n /**\r\n * Input connection: Should the animation loop?\r\n * Not in glTF specs, but useful for the engine.\r\n */\r\n public readonly loop: FlowGraphDataConnection<boolean>;\r\n /**\r\n * Input connection: The starting frame of the animation.\r\n */\r\n public readonly from: FlowGraphDataConnection<number>;\r\n /**\r\n * Input connection: The ending frame of the animation.\r\n */\r\n public readonly to: FlowGraphDataConnection<number>;\r\n\r\n /**\r\n * Output connection: The current frame of the animation.\r\n */\r\n public readonly currentFrame: FlowGraphDataConnection<number>;\r\n\r\n /**\r\n * Output connection: The current time of the animation.\r\n */\r\n public readonly currentTime: FlowGraphDataConnection<number>;\r\n\r\n /**\r\n * Output connection: The animatable that is currently running.\r\n */\r\n public readonly currentAnimationGroup: FlowGraphDataConnection<AnimationGroup>;\r\n\r\n /**\r\n * Input: Will be initialized if no animation group was provided in the configuration.\r\n */\r\n public readonly animationGroup: FlowGraphDataConnection<AnimationGroup>;\r\n\r\n /**\r\n * Input: If provided this animation will be used. Priority will be given to the animation group input.\r\n */\r\n public readonly animation: FlowGraphDataConnection<Animation | Animation[]>;\r\n\r\n /**\r\n * Input connection: Optional targets matching the animation array in order.\r\n * When supplied, these replace the single object target. Ignored when animationGroup is supplied.\r\n */\r\n public readonly animationTargets: FlowGraphDataConnection<IAnimatable[] | undefined>;\r\n\r\n /**\r\n * Input connection: The target object that will be animated. If animation group is provided this input will be ignored.\r\n */\r\n public readonly object: FlowGraphDataConnection<any>;\r\n\r\n public constructor(\r\n /**\r\n * the configuration of the block\r\n */\r\n public override config?: IFlowGraphPlayAnimationBlockConfiguration\r\n ) {\r\n super(config, [\"animationLoop\", \"animationEnd\", \"animationGroupLoop\"]);\r\n\r\n this.speed = this.registerDataInput(\"speed\", RichTypeNumber);\r\n this.loop = this.registerDataInput(\"loop\", RichTypeBoolean);\r\n this.from = this.registerDataInput(\"from\", RichTypeNumber, 0);\r\n this.to = this.registerDataInput(\"to\", RichTypeNumber);\r\n\r\n this.currentFrame = this.registerDataOutput(\"currentFrame\", RichTypeNumber);\r\n this.currentTime = this.registerDataOutput(\"currentTime\", RichTypeNumber);\r\n\r\n this.currentAnimationGroup = this.registerDataOutput(\"currentAnimationGroup\", RichTypeAny);\r\n this.animationGroup = this.registerDataInput(\"animationGroup\", RichTypeAny, config?.animationGroup);\r\n this.animation = this.registerDataInput(\"animation\", RichTypeAny);\r\n this.animationTargets = this.registerDataInput(\"animationTargets\", RichTypeAny);\r\n this.object = this.registerDataInput(\"object\", RichTypeAny);\r\n }\r\n\r\n /**\r\n * @internal\r\n * @param context\r\n */\r\n public override _startPendingTasks(context: FlowGraphContext): void {\r\n if (context._getExecutionVariable(this, \"_initialized\", false)) {\r\n this._cancelPendingTasks(context);\r\n this._resetAfterCanceled(context);\r\n }\r\n\r\n if (!this._tryPreparePendingTasks(context)) {\r\n return;\r\n }\r\n context._addPendingBlock(this);\r\n context._setExecutionVariable(this, \"_initialized\", true);\r\n this.out._activateSignal(context);\r\n }\r\n\r\n /**\r\n * @internal\r\n * @param context the graph context\r\n */\r\n public override _preparePendingTasks(context: FlowGraphContext): void {\r\n this._tryPreparePendingTasks(context);\r\n }\r\n\r\n /**\r\n * Prepares and starts the animation, reporting whether it could be started. Invalid inputs\r\n * activate `err` and return false, so the caller neither activates `out` nor registers the\r\n * block as pending.\r\n * @param context the graph context\r\n * @returns whether the animation was prepared and started successfully\r\n */\r\n private _tryPreparePendingTasks(context: FlowGraphContext): boolean {\r\n let ag: AnimationGroup;\r\n let animation: Animation | Animation[];\r\n let animationTargets: IAnimatable[] | undefined;\r\n try {\r\n ag = this.animationGroup.getValue(context);\r\n animation = this.animation.getValue(context);\r\n animationTargets = ag ? undefined : this.animationTargets.getValue(context);\r\n } catch (error) {\r\n this._reportError(context, error);\r\n return false;\r\n }\r\n if (!ag && !animation) {\r\n this._reportError(context, \"No animation or animation group provided\");\r\n return false;\r\n } else if (!ag && Array.isArray(animation) && animation.length === 0) {\r\n this._reportError(context, \"Animation array is empty\");\r\n return false;\r\n } else if (ag && ag.targetedAnimations.length === 0) {\r\n this._reportError(context, \"Animation group has no targeted animations\");\r\n return false;\r\n } else {\r\n // if an animation group was already created, dispose it and create a new one\r\n const currentAnimationGroup = this.currentAnimationGroup.getValue(context);\r\n if (currentAnimationGroup && currentAnimationGroup !== ag) {\r\n currentAnimationGroup.dispose();\r\n }\r\n let animationGroupToUse = ag;\r\n let isInterpolation = false;\r\n let interpolationAnimationsArray: Animation[] | undefined;\r\n let interpolationTarget: any;\r\n // check which animation to use. If no animationGroup was defined and an animation was provided, use the animation\r\n if (animation && !animationGroupToUse) {\r\n const target = animationTargets === undefined ? this.object.getValue(context) : undefined;\r\n const animationsArray = Array.isArray(animation) ? animation : [animation];\r\n if (animationTargets !== undefined && (!Array.isArray(animationTargets) || animationTargets.length !== animationsArray.length)) {\r\n this._reportError(context, \"Animation targets must match the animation array.\");\r\n return false;\r\n }\r\n if (!animationTargets && !target) {\r\n this._reportError(context, \"No target object provided\");\r\n return false;\r\n }\r\n if (animationTargets) {\r\n for (const animationTarget of animationTargets) {\r\n if (!animationTarget) {\r\n this._reportError(context, \"No target object provided\");\r\n return false;\r\n }\r\n }\r\n }\r\n const name = animationsArray[0].name;\r\n animationGroupToUse = new AnimationGroup(\"flowGraphAnimationGroup-\" + name + \"-\" + (target?.name ?? \"targets\"), context.configuration.scene);\r\n const interpolationAnimations = context._getGlobalContextVariable(\"interpolationAnimations\", []) as number[];\r\n for (let index = 0; index < animationsArray.length; index++) {\r\n const anim = animationsArray[index];\r\n animationGroupToUse.addTargetedAnimation(anim, animationTargets ? animationTargets[index] : target);\r\n if (interpolationAnimations.indexOf(anim.uniqueId) !== -1) {\r\n isInterpolation = true;\r\n }\r\n }\r\n interpolationAnimationsArray = animationsArray;\r\n interpolationTarget = target;\r\n }\r\n // not accepting 0\r\n const speed = this.speed.getValue(context) || 1;\r\n const from = this.from.getValue(context) ?? 0;\r\n // Read the raw end time before it is defaulted to the animation group's natural end, so that an\r\n // explicitly provided NaN end time can still be detected by the animation/start validation below.\r\n const rawTo = this.to.getValue(context);\r\n const hasTo = this.to.isConnected() || context._hasConnectionValue(this.to);\r\n const to = hasTo ? rawTo : animationGroupToUse.to;\r\n\r\n // Input validation. Only applies to animation-group playback\r\n // (animation/start); interpolation uses the `animation` input and has its own validation below.\r\n // The operation activates its `err` flow when the speed is NaN, infinite, or <= 0, or\r\n // when the end time is NaN. A NaN or infinite start time is caught by the finite check on `from`.\r\n if (!animation) {\r\n if (isNaN(rawTo)) {\r\n this._reportError(context, \"Invalid animation end time\");\r\n return false;\r\n }\r\n // Only validate a speed that was explicitly provided; an unconnected speed keeps the engine\r\n // default of 1 (matching the historical Babylon behavior for animation/start without a speed).\r\n if (this.speed.isConnected() || context._hasConnectionValue(this.speed)) {\r\n const providedSpeed = this.speed.getValue(context);\r\n if (!isFinite(providedSpeed) || providedSpeed <= 0) {\r\n this._reportError(context, \"Invalid animation speed\");\r\n return false;\r\n }\r\n }\r\n }\r\n\r\n // The start value (interpolation start frame / animation start time) must always be finite. For\r\n // animation/start this also satisfies the spec requirement that a NaN or infinite start time\r\n // activates the err flow.\r\n if (!isFinite(from)) {\r\n this._reportError(context, \"Invalid animation duration\");\r\n return false;\r\n }\r\n // For interpolation the end value is the animation duration and must be a finite, non-negative number.\r\n // Animation-group playback (animation/start) instead allows an infinite end time — it means \"play to\r\n // the natural end / loop\" (see the `loop` computation below) — and its NaN end time was already\r\n // rejected above, so the end value is only range-checked here for the interpolation case.\r\n if (animation && (!isFinite(to) || to < 0)) {\r\n this._reportError(context, \"Invalid animation duration\");\r\n return false;\r\n }\r\n\r\n // CSS cubic-bezier control points must be finite, and the X components must be in [0, 1].\r\n if (animation) {\r\n const animationsArray = Array.isArray(animation) ? animation : [animation];\r\n for (const anim of animationsArray) {\r\n const easing = anim.getEasingFunction?.();\r\n if (easing && \"x1\" in easing) {\r\n const bezier = easing as unknown as { x1: number; y1: number; x2: number; y2: number };\r\n if (\r\n !Number.isFinite(bezier.x1) ||\r\n !Number.isFinite(bezier.y1) ||\r\n !Number.isFinite(bezier.x2) ||\r\n !Number.isFinite(bezier.y2) ||\r\n bezier.x1 < 0 ||\r\n bezier.x1 > 1 ||\r\n bezier.x2 < 0 ||\r\n bezier.x2 > 1\r\n ) {\r\n this._reportError(context, \"Invalid bezier curve control points\");\r\n return false;\r\n }\r\n }\r\n }\r\n }\r\n\r\n // Stop any interpolation already running on the same target/property, but only after validation has\r\n // passed. An invalid interpolation (bad duration or NaN control points) must report [err] without\r\n // disturbing an interpolation that is already running on the same target.\r\n if (isInterpolation && interpolationAnimationsArray) {\r\n this._checkInterpolationDuplications(context, interpolationAnimationsArray, interpolationTarget, animationTargets);\r\n }\r\n\r\n const loop = !isFinite(to) || this.loop.getValue(context);\r\n this.currentAnimationGroup.setValue(animationGroupToUse, context);\r\n\r\n const currentlyRunningAnimationGroups = context._getGlobalContextVariable(\"currentlyRunningAnimationGroups\", []) as number[];\r\n // check if it already running\r\n if (currentlyRunningAnimationGroups.indexOf(animationGroupToUse.uniqueId) !== -1) {\r\n this._stopAnimationGroup(context, animationGroupToUse);\r\n }\r\n try {\r\n if (this.config?.useVirtualTimeline) {\r\n animationGroupToUse.startWithVirtualTimeline(loop, speed, from, to);\r\n } else {\r\n animationGroupToUse.start(loop, speed, from, to);\r\n }\r\n const observers: IFlowGraphAnimationObserverSet = {\r\n block: this,\r\n groupEnd: animationGroupToUse.onAnimationGroupEndObservable.add(() => this._onAnimationGroupEnd(context, animationGroupToUse)),\r\n animationEnd: animationGroupToUse.onAnimationEndObservable.add(() => this._eventsSignalOutputs[\"animationEnd\"]._activateSignal(context)),\r\n animationLoop: animationGroupToUse.onAnimationLoopObservable.add(() => this._eventsSignalOutputs[\"animationLoop\"]._activateSignal(context)),\r\n groupLoop: animationGroupToUse.onAnimationGroupLoopObservable.add(() => this._eventsSignalOutputs[\"animationGroupLoop\"]._activateSignal(context)),\r\n };\r\n const observerSets = context._getGlobalContextVariable(\"animationGroupObserverSets\", new Map<number, IFlowGraphAnimationObserverSet>());\r\n observerSets.set(animationGroupToUse.uniqueId, observers);\r\n context._setGlobalContextVariable(\"animationGroupObserverSets\", observerSets);\r\n currentlyRunningAnimationGroups.push(animationGroupToUse.uniqueId);\r\n context._setGlobalContextVariable(\"currentlyRunningAnimationGroups\", currentlyRunningAnimationGroups);\r\n } catch (e) {\r\n this._reportError(context, e);\r\n return false;\r\n }\r\n return true;\r\n }\r\n }\r\n\r\n protected override _reportError(context: FlowGraphContext, error: string | Error): void {\r\n super._reportError(context, error);\r\n this.currentFrame.setValue(-1, context);\r\n this.currentTime.setValue(-1, context);\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public override _executeOnTick(_context: FlowGraphContext): void {\r\n const ag = this.currentAnimationGroup.getValue(_context);\r\n if (ag) {\r\n this.currentFrame.setValue(ag.getCurrentFrame(), _context);\r\n this.currentTime.setValue(ag.animatables[0]?.elapsedTime ?? 0, _context);\r\n }\r\n }\r\n\r\n public _execute(context: FlowGraphContext): void {\r\n this._startPendingTasks(context);\r\n }\r\n\r\n private _onAnimationGroupEnd(context: FlowGraphContext, animationGroup: AnimationGroup) {\r\n RemoveFlowGraphAnimationGroupObservers(context, animationGroup);\r\n this._removeFromCurrentlyRunning(context, animationGroup);\r\n this._resetAfterCanceled(context);\r\n this.done._activateSignal(context);\r\n }\r\n\r\n /**\r\n * The idea behind this function is to check every running animation group and check if the targeted animations it uses are interpolation animations.\r\n * If they are, we want to see that they don't collide with the current interpolation animations that are starting to play.\r\n * If they do, we want to stop the already-running animation group.\r\n * @internal\r\n */\r\n private _checkInterpolationDuplications(context: FlowGraphContext, animation: Animation[], target: any, targets?: IAnimatable[]) {\r\n const currentlyRunningAnimationGroups = context._getGlobalContextVariable(\"currentlyRunningAnimationGroups\", []) as number[];\r\n for (let groupIndex = currentlyRunningAnimationGroups.length - 1; groupIndex >= 0; groupIndex--) {\r\n const uniqueId = currentlyRunningAnimationGroups[groupIndex];\r\n const ag = context.assetsContext.animationGroups.find((ag) => ag.uniqueId === uniqueId);\r\n if (ag) {\r\n let stopped = false;\r\n for (const anim of ag.targetedAnimations) {\r\n for (let index = 0; index < animation.length; index++) {\r\n if (anim.animation.targetProperty === animation[index].targetProperty && anim.target === (targets ? targets[index] : target)) {\r\n this._stopAnimationGroup(context, ag);\r\n stopped = true;\r\n break;\r\n }\r\n }\r\n if (stopped) {\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n private _stopAnimationGroup(context: FlowGraphContext, animationGroup: AnimationGroup) {\r\n const owner = RemoveFlowGraphAnimationGroupObservers(context, animationGroup);\r\n owner?._cleanupAfterExternalStop(context, animationGroup);\r\n // stop, while skipping the on AnimationEndObservable to avoid the \"done\" signal\r\n animationGroup.stop(true);\r\n // Only dispose animation groups that were internally created by this block\r\n // (i.e. built from individual animations). Scene-provided animation groups\r\n // must not be disposed as that removes them from the scene catalog and\r\n // breaks the editor dropdown / re-use on replay.\r\n if (animationGroup.name.startsWith(\"flowGraphAnimationGroup-\")) {\r\n animationGroup.dispose();\r\n }\r\n this._removeFromCurrentlyRunning(context, animationGroup);\r\n }\r\n\r\n /** @internal */\r\n public _cleanupAfterExternalStop(context: FlowGraphContext, animationGroup: AnimationGroup): void {\r\n this._removeFromCurrentlyRunning(context, animationGroup);\r\n this._resetAfterCanceled(context);\r\n }\r\n\r\n private _removeFromCurrentlyRunning(context: FlowGraphContext, animationGroup: AnimationGroup) {\r\n const currentlyRunningAnimationGroups = context._getGlobalContextVariable(\"currentlyRunningAnimationGroups\", []) as number[];\r\n const idx = currentlyRunningAnimationGroups.indexOf(animationGroup.uniqueId);\r\n if (idx !== -1) {\r\n currentlyRunningAnimationGroups.splice(idx, 1);\r\n context._setGlobalContextVariable(\"currentlyRunningAnimationGroups\", currentlyRunningAnimationGroups);\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n * Stop any currently running animations.\r\n */\r\n public override _cancelPendingTasks(context: FlowGraphContext): void {\r\n const ag = this.currentAnimationGroup.getValue(context);\r\n if (ag) {\r\n this._stopAnimationGroup(context, ag);\r\n }\r\n }\r\n\r\n /**\r\n * @returns class name of the block.\r\n */\r\n public override getClassName(): string {\r\n return FlowGraphBlockNames.PlayAnimation;\r\n }\r\n}\r\n\r\nlet _Registered = false;\r\n/**\r\n * Register side effects for flowGraphPlayAnimationBlock.\r\n * Safe to call multiple times; only the first call has an effect.\r\n */\r\nexport function RegisterFlowGraphPlayAnimationBlock(): void {\r\n if (_Registered) {\r\n return;\r\n }\r\n _Registered = true;\r\n\r\n RegisterClass(FlowGraphBlockNames.PlayAnimation, FlowGraphPlayAnimationBlock);\r\n}\r\n"]}
@@ -5,6 +5,13 @@ import { type FlowGraphDataConnection } from "../../../flowGraphDataConnection.p
5
5
  import { FlowGraphExecutionBlockWithOutSignal } from "../../../flowGraphExecutionBlockWithOutSignal.js";
6
6
  import { type FlowGraphSignalConnection } from "../../../flowGraphSignalConnection.pure.js";
7
7
  import { type FlowGraphInteger } from "../../../CustomTypes/flowGraphInteger.pure.js";
8
+ /**
9
+ * Configuration for the cancel delay block.
10
+ */
11
+ export interface IFlowGraphCancelDelayBlockConfiguration extends IFlowGraphBlockConfiguration {
12
+ /** Whether invalid delay indices are ignored while still activating out. Defaults to false. */
13
+ ignoreInvalidDelay?: boolean;
14
+ }
8
15
  /**
9
16
  * This block cancels a delay that was previously scheduled.
10
17
  */
@@ -13,7 +20,11 @@ export declare class FlowGraphCancelDelayBlock extends FlowGraphExecutionBlockWi
13
20
  * Input connection: The index value of the scheduled activation to be cancelled.
14
21
  */
15
22
  readonly delayIndex: FlowGraphDataConnection<FlowGraphInteger>;
16
- constructor(config?: IFlowGraphBlockConfiguration);
23
+ /**
24
+ * Creates a delay cancellation block.
25
+ * @param config optional invalid-index handling
26
+ */
27
+ constructor(config?: IFlowGraphCancelDelayBlockConfiguration);
17
28
  _execute(context: FlowGraphContext, _callingSignal: FlowGraphSignalConnection): void;
18
29
  getClassName(): string;
19
30
  }
@@ -8,6 +8,10 @@ import { RegisterClass } from "../../../../Misc/typeStore.js";
8
8
  * This block cancels a delay that was previously scheduled.
9
9
  */
10
10
  export class FlowGraphCancelDelayBlock extends FlowGraphExecutionBlockWithOutSignal {
11
+ /**
12
+ * Creates a delay cancellation block.
13
+ * @param config optional invalid-index handling
14
+ */
11
15
  constructor(config) {
12
16
  super(config);
13
17
  this.delayIndex = this.registerDataInput("delayIndex", RichTypeFlowGraphInteger);
@@ -15,6 +19,10 @@ export class FlowGraphCancelDelayBlock extends FlowGraphExecutionBlockWithOutSig
15
19
  _execute(context, _callingSignal) {
16
20
  const delayIndex = getNumericValue(this.delayIndex.getValue(context));
17
21
  if (delayIndex < 0 || isNaN(delayIndex) || !isFinite(delayIndex)) {
22
+ if (this.config?.ignoreInvalidDelay) {
23
+ this.out._activateSignal(context);
24
+ return;
25
+ }
18
26
  return this._reportError(context, "Invalid delay index");
19
27
  }
20
28
  const timers = context._getGlobalContextVariable("pendingDelays", []);
@@ -1 +1 @@
1
- {"version":3,"file":"flowGraphCancelDelayBlock.pure.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCancelDelayBlock.pure.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAM7D,OAAO,EAAE,oCAAoC,EAAE,MAAM,+CAA+C,CAAC;AACrG,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAI5E,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD;;GAEG;AACH,MAAM,OAAO,yBAA0B,SAAQ,oCAAoC;IAM/E,YAAY,MAAqC;QAC7C,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,iBAAiB,CAAC,YAAY,EAAE,wBAAwB,CAAC,CAAC;IACrF,CAAC;IAEM,QAAQ,CAAC,OAAyB,EAAE,cAAyC;QAChF,MAAM,UAAU,GAAG,eAAe,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;QACtE,IAAI,UAAU,GAAG,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;YAC/D,OAAO,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,qBAAqB,CAAC,CAAC;QAC7D,CAAC;QACD,MAAM,MAAM,GAAG,OAAO,CAAC,yBAAyB,CAAC,eAAe,EAAE,EAAqB,CAAC,CAAC;QACzF,MAAM,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;QACjC,IAAI,KAAK,EAAE,CAAC;YACR,KAAK,CAAC,OAAO,EAAE,CAAC;YAChB,OAAO,MAAM,CAAC,UAAU,CAAC,CAAC;YAC1B,OAAO,CAAC,yBAAyB,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;QAC/D,CAAC;QACD,yFAAyF;QACzF,iBAAiB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QACvC,+BAA+B;QAC/B,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;IAEe,YAAY;QACxB,yEAAuC;IAC3C,CAAC;CACJ;AAED,IAAI,WAAW,GAAG,KAAK,CAAC;AACxB;;;GAGG;AACH,MAAM,UAAU,iCAAiC;IAC7C,IAAI,WAAW,EAAE,CAAC;QACd,OAAO;IACX,CAAC;IACD,WAAW,GAAG,IAAI,CAAC;IAEnB,aAAa,oEAAkC,yBAAyB,CAAC,CAAC;AAC9E,CAAC","sourcesContent":["/** This file must only contain pure code and pure imports */\n\nimport { type AdvancedTimer } from \"../../../../Misc/timer\";\nimport { type IFlowGraphBlockConfiguration } from \"../../../flowGraphBlock\";\nimport { type FlowGraphContext } from \"../../../flowGraphContext\";\nimport { type FlowGraphDataConnection } from \"../../../flowGraphDataConnection.pure\";\nimport { FlowGraphExecutionBlockWithOutSignal } from \"../../../flowGraphExecutionBlockWithOutSignal\";\nimport { RichTypeFlowGraphInteger } from \"../../../flowGraphRichTypes.pure\";\nimport { type FlowGraphSignalConnection } from \"../../../flowGraphSignalConnection.pure\";\nimport { FlowGraphBlockNames } from \"../../flowGraphBlockNames\";\nimport { type FlowGraphInteger } from \"core/FlowGraph/CustomTypes/flowGraphInteger.pure\";\nimport { getNumericValue } from \"core/FlowGraph/utils\";\nimport { MarkDelayInactive } from \"core/FlowGraph/flowGraphDelayRegistry\";\nimport { RegisterClass } from \"core/Misc/typeStore\";\n\n/**\n * This block cancels a delay that was previously scheduled.\n */\nexport class FlowGraphCancelDelayBlock extends FlowGraphExecutionBlockWithOutSignal {\n /**\n * Input connection: The index value of the scheduled activation to be cancelled.\n */\n public readonly delayIndex: FlowGraphDataConnection<FlowGraphInteger>;\n\n constructor(config?: IFlowGraphBlockConfiguration) {\n super(config);\n this.delayIndex = this.registerDataInput(\"delayIndex\", RichTypeFlowGraphInteger);\n }\n\n public _execute(context: FlowGraphContext, _callingSignal: FlowGraphSignalConnection): void {\n const delayIndex = getNumericValue(this.delayIndex.getValue(context));\n if (delayIndex < 0 || isNaN(delayIndex) || !isFinite(delayIndex)) {\n return this._reportError(context, \"Invalid delay index\");\n }\n const timers = context._getGlobalContextVariable(\"pendingDelays\", [] as AdvancedTimer[]);\n const timer = timers[delayIndex];\n if (timer) {\n timer.dispose();\n delete timers[delayIndex];\n context._setGlobalContextVariable(\"pendingDelays\", timers);\n }\n // The delay is cancelled, so drop it from the active set used by handle validity checks.\n MarkDelayInactive(context, delayIndex);\n // activate the out output flow\n this.out._activateSignal(context);\n }\n\n public override getClassName(): string {\n return FlowGraphBlockNames.CancelDelay;\n }\n}\n\nlet _Registered = false;\n/**\n * Register side effects for flowGraphCancelDelayBlock.\n * Safe to call multiple times; only the first call has an effect.\n */\nexport function RegisterFlowGraphCancelDelayBlock(): void {\n if (_Registered) {\n return;\n }\n _Registered = true;\n\n RegisterClass(FlowGraphBlockNames.CancelDelay, FlowGraphCancelDelayBlock);\n}\n"]}
1
+ {"version":3,"file":"flowGraphCancelDelayBlock.pure.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCancelDelayBlock.pure.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAM7D,OAAO,EAAE,oCAAoC,EAAE,MAAM,+CAA+C,CAAC;AACrG,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAI5E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C,+BAA+B;QAC/B,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;IAEe,YAAY;QACxB,yEAAuC;IAC3C,CAAC;CACJ;AAED,IAAI,WAAW,GAAG,KAAK,CAAC;AACxB;;;GAGG;AACH,MAAM,UAAU,iCAAiC;IAC7C,IAAI,WAAW,EAAE,CAAC;QACd,OAAO;IACX,CAAC;IACD,WAAW,GAAG,IAAI,CAAC;IAEnB,aAAa,oEAAkC,yBAAyB,CAAC,CAAC;AAC9E,CAAC","sourcesContent":["/** This file must only contain pure code and pure imports */\n\nimport { type AdvancedTimer } from \"../../../../Misc/timer\";\nimport { type IFlowGraphBlockConfiguration } from \"../../../flowGraphBlock\";\nimport { type FlowGraphContext } from \"../../../flowGraphContext\";\nimport { type FlowGraphDataConnection } from \"../../../flowGraphDataConnection.pure\";\nimport { FlowGraphExecutionBlockWithOutSignal } from \"../../../flowGraphExecutionBlockWithOutSignal\";\nimport { RichTypeFlowGraphInteger } from \"../../../flowGraphRichTypes.pure\";\nimport { type FlowGraphSignalConnection } from \"../../../flowGraphSignalConnection.pure\";\nimport { FlowGraphBlockNames } from \"../../flowGraphBlockNames\";\nimport { type FlowGraphInteger } from \"core/FlowGraph/CustomTypes/flowGraphInteger.pure\";\nimport { getNumericValue } from \"core/FlowGraph/utils\";\nimport { MarkDelayInactive } from \"core/FlowGraph/flowGraphDelayRegistry\";\nimport { RegisterClass } from \"core/Misc/typeStore\";\n\n/**\n * Configuration for the cancel delay block.\n */\nexport interface IFlowGraphCancelDelayBlockConfiguration extends IFlowGraphBlockConfiguration {\n /** Whether invalid delay indices are ignored while still activating out. Defaults to false. */\n ignoreInvalidDelay?: boolean;\n}\n\n/**\n * This block cancels a delay that was previously scheduled.\n */\nexport class FlowGraphCancelDelayBlock extends FlowGraphExecutionBlockWithOutSignal {\n /**\n * Input connection: The index value of the scheduled activation to be cancelled.\n */\n public readonly delayIndex: FlowGraphDataConnection<FlowGraphInteger>;\n\n /**\n * Creates a delay cancellation block.\n * @param config optional invalid-index handling\n */\n constructor(config?: IFlowGraphCancelDelayBlockConfiguration) {\n super(config);\n this.delayIndex = this.registerDataInput(\"delayIndex\", RichTypeFlowGraphInteger);\n }\n\n public _execute(context: FlowGraphContext, _callingSignal: FlowGraphSignalConnection): void {\n const delayIndex = getNumericValue(this.delayIndex.getValue(context));\n if (delayIndex < 0 || isNaN(delayIndex) || !isFinite(delayIndex)) {\n if (this.config?.ignoreInvalidDelay) {\n this.out._activateSignal(context);\n return;\n }\n return this._reportError(context, \"Invalid delay index\");\n }\n const timers = context._getGlobalContextVariable(\"pendingDelays\", [] as AdvancedTimer[]);\n const timer = timers[delayIndex];\n if (timer) {\n timer.dispose();\n delete timers[delayIndex];\n context._setGlobalContextVariable(\"pendingDelays\", timers);\n }\n // The delay is cancelled, so drop it from the active set used by handle validity checks.\n MarkDelayInactive(context, delayIndex);\n // activate the out output flow\n this.out._activateSignal(context);\n }\n\n public override getClassName(): string {\n return FlowGraphBlockNames.CancelDelay;\n }\n}\n\nlet _Registered = false;\n/**\n * Register side effects for flowGraphCancelDelayBlock.\n * Safe to call multiple times; only the first call has an effect.\n */\nexport function RegisterFlowGraphCancelDelayBlock(): void {\n if (_Registered) {\n return;\n }\n _Registered = true;\n\n RegisterClass(FlowGraphBlockNames.CancelDelay, FlowGraphCancelDelayBlock);\n}\n"]}
@@ -30,6 +30,9 @@ export class FlowGraphForLoopBlock extends FlowGraphExecutionBlockWithOutSignal
30
30
  const maxIterations = this.config?.maxLoopIterations ?? FlowGraphForLoopBlock.MaxLoopIterations;
31
31
  let iterations = 0;
32
32
  let truncated = false;
33
+ if (this.config?.incrementIndexWhenLoopDone && !(index < endIndex)) {
34
+ this.index.setValue(new FlowGraphInteger(index), context);
35
+ }
33
36
  for (let i = index; i < endIndex; i += step) {
34
37
  this.index.setValue(new FlowGraphInteger(i), context);
35
38
  this.executionFlow._activateSignal(context);
@@ -48,7 +51,7 @@ export class FlowGraphForLoopBlock extends FlowGraphExecutionBlockWithOutSignal
48
51
  // incrementIndexWhenLoopDone will not land on endIndex).
49
52
  Logger.Warn(`FlowGraphForLoopBlock: loop stopped after reaching the ${maxIterations}-iteration safety cap before its range completed.`);
50
53
  }
51
- if (this.config?.incrementIndexWhenLoopDone) {
54
+ if (this.config?.incrementIndexWhenLoopDone && iterations > 0) {
52
55
  this.index.setValue(new FlowGraphInteger(getNumericValue(this.index.getValue(context)) + step), context);
53
56
  }
54
57
  this.completed._activateSignal(context);
@@ -1 +1 @@
1
- {"version":3,"file":"flowGraphForLoopBlock.pure.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/FlowGraph/Blocks/Execution/ControlFlow/flowGraphForLoopBlock.pure.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAI7D,OAAO,EAAE,oCAAoC,EAAE,MAAM,qDAAqD,CAAC;AAE3G,OAAO,EAAE,WAAW,EAAE,wBAAwB,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAGzG,OAAO,EAAwB,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,kDAAkD,CAAC;AACpF,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AA0B3D;;GAEG;AACH,MAAM,OAAO,qBAAsB,SAAQ,oCAAoC;IAoC3E,YAAmB,MAA4C;QAC3D,KAAK,CAAC,MAAM,CAAC,CAAC;QAEd,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,iBAAiB,CAAC,YAAY,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC;QACvE,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,iBAAiB,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;QAChE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,iBAAiB,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC;QAE9D,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D,0FAA0F;YAC1F,mDAAmD;YACnD,IAAI,EAAE,UAAU,IAAI,aAAa,EAAE,CAAC;gBAChC,SAAS,GAAG,IAAI,CAAC;gBACjB,MAAM;YACV,CAAC;QACL,CAAC;QAED,IAAI,SAAS,EAAE,CAAC;YACZ,yFAAyF;YACzF,wFAAwF;YACxF,sFAAsF;YACtF,yDAAyD;YACzD,MAAM,CAAC,IAAI,CAAC,0DAA0D,aAAa,mDAAmD,CAAC,CAAC;QAC5I,CAAC;QAED,IAAI,IAAI,CAAC,MAAM,EAAE,0BAA0B,EAAE,CAAC;YAC1C,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,gBAAgB,CAAC,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC;QAC7G,CAAC;QAED,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IAC5C,CAAC;IAED;;OAEG;IACa,YAAY;QACxB,iEAAmC;IACvC,CAAC;;AA5FD;;;;;;GAMG;AACW,uCAAiB,GAAG,IAAI,CAAC;AAwF3C,IAAI,WAAW,GAAG,KAAK,CAAC;AACxB;;;GAGG;AACH,MAAM,UAAU,6BAA6B;IACzC,IAAI,WAAW,EAAE,CAAC;QACd,OAAO;IACX,CAAC;IACD,WAAW,GAAG,IAAI,CAAC;IAEnB,aAAa,4DAA8B,qBAAqB,CAAC,CAAC;AACtE,CAAC","sourcesContent":["/** This file must only contain pure code and pure imports */\r\n\r\nimport { type FlowGraphSignalConnection } from \"../../../flowGraphSignalConnection.pure\";\r\nimport { type FlowGraphDataConnection } from \"../../../flowGraphDataConnection.pure\";\r\nimport { FlowGraphExecutionBlockWithOutSignal } from \"core/FlowGraph/flowGraphExecutionBlockWithOutSignal\";\r\nimport { type FlowGraphContext } from \"../../../flowGraphContext\";\r\nimport { RichTypeAny, RichTypeFlowGraphInteger, RichTypeNumber } from \"../../../flowGraphRichTypes.pure\";\r\nimport { type IFlowGraphBlockConfiguration } from \"../../../flowGraphBlock\";\r\nimport { FlowGraphBlockNames } from \"../../flowGraphBlockNames\";\r\nimport { type FlowGraphNumber, getNumericValue } from \"core/FlowGraph/utils\";\r\nimport { FlowGraphInteger } from \"core/FlowGraph/CustomTypes/flowGraphInteger.pure\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\n\r\n/**\r\n * Configuration for the For Loop block.\r\n */\r\nexport interface IFlowGraphForLoopBlockConfiguration extends IFlowGraphBlockConfiguration {\r\n /**\r\n * The initial index of the loop.\r\n * if not set will default to 0\r\n */\r\n initialIndex?: FlowGraphNumber;\r\n\r\n /**\r\n * If set to true, the index of the case will be incremented when the loop is done.\r\n * This will result that the index will equal endIndex when the loop finished its work.\r\n * This is the default behavior in glTF interactivity\r\n */\r\n incrementIndexWhenLoopDone?: boolean;\r\n\r\n /**\r\n * Overrides {@link FlowGraphForLoopBlock.MaxLoopIterations} for this block only.\r\n * Lets a single graph opt into a higher (or lower) runaway-loop guard without changing the\r\n * process-wide default that every other FlowGraph relies on.\r\n */\r\n maxLoopIterations?: number;\r\n}\r\n/**\r\n * Block that executes an action in a loop.\r\n */\r\nexport class FlowGraphForLoopBlock extends FlowGraphExecutionBlockWithOutSignal {\r\n /**\r\n * The default maximum number of iterations allowed for the loop, used as a safety net against\r\n * runaway loops. Kept conservative so a runaway loop is caught before it can freeze the tab.\r\n * A single graph that legitimately needs more iterations should set the per-block\r\n * {@link IFlowGraphForLoopBlockConfiguration.maxLoopIterations} rather than raising this\r\n * process-wide default that every other FlowGraph relies on.\r\n */\r\n public static MaxLoopIterations = 1000;\r\n /**\r\n * Input connection: The start index of the loop.\r\n */\r\n public readonly startIndex: FlowGraphDataConnection<FlowGraphNumber>;\r\n /**\r\n * Input connection: The end index of the loop.\r\n */\r\n public readonly endIndex: FlowGraphDataConnection<FlowGraphNumber>;\r\n /**\r\n * Input connection: The step of the loop.\r\n */\r\n public readonly step: FlowGraphDataConnection<number>;\r\n /**\r\n * Output connection: The current index of the loop.\r\n */\r\n public readonly index: FlowGraphDataConnection<FlowGraphInteger>;\r\n /**\r\n * Output connection: The signal that is activated when the loop body is executed.\r\n */\r\n public readonly executionFlow: FlowGraphSignalConnection;\r\n\r\n /**\r\n * Output connection: The completed signal. Triggered when condition is false.\r\n * No out signal is available.\r\n */\r\n public readonly completed: FlowGraphSignalConnection;\r\n\r\n public constructor(config?: IFlowGraphForLoopBlockConfiguration) {\r\n super(config);\r\n\r\n this.startIndex = this.registerDataInput(\"startIndex\", RichTypeAny, 0);\r\n this.endIndex = this.registerDataInput(\"endIndex\", RichTypeAny);\r\n this.step = this.registerDataInput(\"step\", RichTypeNumber, 1);\r\n\r\n this.index = this.registerDataOutput(\"index\", RichTypeFlowGraphInteger, new FlowGraphInteger(getNumericValue(config?.initialIndex ?? 0)));\r\n this.executionFlow = this._registerSignalOutput(\"executionFlow\");\r\n this.completed = this._registerSignalOutput(\"completed\");\r\n\r\n this._unregisterSignalOutput(\"out\");\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _execute(context: FlowGraphContext): void {\r\n const index = getNumericValue(this.startIndex.getValue(context));\r\n const step = this.step.getValue(context);\r\n let endIndex = getNumericValue(this.endIndex.getValue(context));\r\n // Per-block override of the runaway-loop guard, falling back to the process-wide default.\r\n const maxIterations = (this.config as IFlowGraphForLoopBlockConfiguration | undefined)?.maxLoopIterations ?? FlowGraphForLoopBlock.MaxLoopIterations;\r\n let iterations = 0;\r\n let truncated = false;\r\n for (let i = index; i < endIndex; i += step) {\r\n this.index.setValue(new FlowGraphInteger(i), context);\r\n this.executionFlow._activateSignal(context);\r\n endIndex = getNumericValue(this.endIndex.getValue(context));\r\n // Safety net against runaway loops. The cap counts iterations (not the index value) so it\r\n // behaves correctly regardless of startIndex/step.\r\n if (++iterations >= maxIterations) {\r\n truncated = true;\r\n break;\r\n }\r\n }\r\n\r\n if (truncated) {\r\n // The loop hit its safety cap before its range completed, so the outputs below are for a\r\n // truncated run, not a natural finish. Warn so a genuinely runaway asset is diagnosable\r\n // rather than silently producing wrong numbers (the completed signal still fires, and\r\n // incrementIndexWhenLoopDone will not land on endIndex).\r\n Logger.Warn(`FlowGraphForLoopBlock: loop stopped after reaching the ${maxIterations}-iteration safety cap before its range completed.`);\r\n }\r\n\r\n if (this.config?.incrementIndexWhenLoopDone) {\r\n this.index.setValue(new FlowGraphInteger(getNumericValue(this.index.getValue(context)) + step), context);\r\n }\r\n\r\n this.completed._activateSignal(context);\r\n }\r\n\r\n /**\r\n * @returns class name of the block.\r\n */\r\n public override getClassName(): string {\r\n return FlowGraphBlockNames.ForLoop;\r\n }\r\n}\r\n\r\nlet _Registered = false;\r\n/**\r\n * Register side effects for flowGraphForLoopBlock.\r\n * Safe to call multiple times; only the first call has an effect.\r\n */\r\nexport function RegisterFlowGraphForLoopBlock(): void {\r\n if (_Registered) {\r\n return;\r\n }\r\n _Registered = true;\r\n\r\n RegisterClass(FlowGraphBlockNames.ForLoop, FlowGraphForLoopBlock);\r\n}\r\n"]}
1
+ {"version":3,"file":"flowGraphForLoopBlock.pure.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/FlowGraph/Blocks/Execution/ControlFlow/flowGraphForLoopBlock.pure.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAI7D,OAAO,EAAE,oCAAoC,EAAE,MAAM,qDAAqD,CAAC;AAE3G,OAAO,EAAE,WAAW,EAAE,wBAAwB,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAGzG,OAAO,EAAwB,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,kDAAkD,CAAC;AACpF,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AA0B3D;;GAEG;AACH,MAAM,OAAO,qBAAsB,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AEG;IACa,YAAY;QACxB,iEAAmC;IACvC,CAAC;;AA/FD;;;;;;GAMG;AACW,uCAAiB,GAAG,IAAI,CAAC;AA2F3C,IAAI,WAAW,GAAG,KAAK,CAAC;AACxB;;;GAGG;AACH,MAAM,UAAU,6BAA6B;IACzC,IAAI,WAAW,EAAE,CAAC;QACd,OAAO;IACX,CAAC;IACD,WAAW,GAAG,IAAI,CAAC;IAEnB,aAAa,4DAA8B,qBAAqB,CAAC,CAAC;AACtE,CAAC","sourcesContent":["/** This file must only contain pure code and pure imports */\r\n\r\nimport { type FlowGraphSignalConnection } from \"../../../flowGraphSignalConnection.pure\";\r\nimport { type FlowGraphDataConnection } from \"../../../flowGraphDataConnection.pure\";\r\nimport { FlowGraphExecutionBlockWithOutSignal } from \"core/FlowGraph/flowGraphExecutionBlockWithOutSignal\";\r\nimport { type FlowGraphContext } from \"../../../flowGraphContext\";\r\nimport { RichTypeAny, RichTypeFlowGraphInteger, RichTypeNumber } from \"../../../flowGraphRichTypes.pure\";\r\nimport { type IFlowGraphBlockConfiguration } from \"../../../flowGraphBlock\";\r\nimport { FlowGraphBlockNames } from \"../../flowGraphBlockNames\";\r\nimport { type FlowGraphNumber, getNumericValue } from \"core/FlowGraph/utils\";\r\nimport { FlowGraphInteger } from \"core/FlowGraph/CustomTypes/flowGraphInteger.pure\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\n\r\n/**\r\n * Configuration for the For Loop block.\r\n */\r\nexport interface IFlowGraphForLoopBlockConfiguration extends IFlowGraphBlockConfiguration {\r\n /**\r\n * The initial index of the loop.\r\n * if not set will default to 0\r\n */\r\n initialIndex?: FlowGraphNumber;\r\n\r\n /**\r\n * If set to true, the index of the case will be incremented when the loop is done.\r\n * This will result that the index will equal endIndex when the loop finished its work.\r\n * This is the default behavior in glTF interactivity\r\n */\r\n incrementIndexWhenLoopDone?: boolean;\r\n\r\n /**\r\n * Overrides {@link FlowGraphForLoopBlock.MaxLoopIterations} for this block only.\r\n * Lets a single graph opt into a higher (or lower) runaway-loop guard without changing the\r\n * process-wide default that every other FlowGraph relies on.\r\n */\r\n maxLoopIterations?: number;\r\n}\r\n/**\r\n * Block that executes an action in a loop.\r\n */\r\nexport class FlowGraphForLoopBlock extends FlowGraphExecutionBlockWithOutSignal {\r\n /**\r\n * The default maximum number of iterations allowed for the loop, used as a safety net against\r\n * runaway loops. Kept conservative so a runaway loop is caught before it can freeze the tab.\r\n * A single graph that legitimately needs more iterations should set the per-block\r\n * {@link IFlowGraphForLoopBlockConfiguration.maxLoopIterations} rather than raising this\r\n * process-wide default that every other FlowGraph relies on.\r\n */\r\n public static MaxLoopIterations = 1000;\r\n /**\r\n * Input connection: The start index of the loop.\r\n */\r\n public readonly startIndex: FlowGraphDataConnection<FlowGraphNumber>;\r\n /**\r\n * Input connection: The end index of the loop.\r\n */\r\n public readonly endIndex: FlowGraphDataConnection<FlowGraphNumber>;\r\n /**\r\n * Input connection: The step of the loop.\r\n */\r\n public readonly step: FlowGraphDataConnection<number>;\r\n /**\r\n * Output connection: The current index of the loop.\r\n */\r\n public readonly index: FlowGraphDataConnection<FlowGraphInteger>;\r\n /**\r\n * Output connection: The signal that is activated when the loop body is executed.\r\n */\r\n public readonly executionFlow: FlowGraphSignalConnection;\r\n\r\n /**\r\n * Output connection: The completed signal. Triggered when condition is false.\r\n * No out signal is available.\r\n */\r\n public readonly completed: FlowGraphSignalConnection;\r\n\r\n public constructor(config?: IFlowGraphForLoopBlockConfiguration) {\r\n super(config);\r\n\r\n this.startIndex = this.registerDataInput(\"startIndex\", RichTypeAny, 0);\r\n this.endIndex = this.registerDataInput(\"endIndex\", RichTypeAny);\r\n this.step = this.registerDataInput(\"step\", RichTypeNumber, 1);\r\n\r\n this.index = this.registerDataOutput(\"index\", RichTypeFlowGraphInteger, new FlowGraphInteger(getNumericValue(config?.initialIndex ?? 0)));\r\n this.executionFlow = this._registerSignalOutput(\"executionFlow\");\r\n this.completed = this._registerSignalOutput(\"completed\");\r\n\r\n this._unregisterSignalOutput(\"out\");\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _execute(context: FlowGraphContext): void {\r\n const index = getNumericValue(this.startIndex.getValue(context));\r\n const step = this.step.getValue(context);\r\n let endIndex = getNumericValue(this.endIndex.getValue(context));\r\n // Per-block override of the runaway-loop guard, falling back to the process-wide default.\r\n const maxIterations = (this.config as IFlowGraphForLoopBlockConfiguration | undefined)?.maxLoopIterations ?? FlowGraphForLoopBlock.MaxLoopIterations;\r\n let iterations = 0;\r\n let truncated = false;\r\n if (this.config?.incrementIndexWhenLoopDone && !(index < endIndex)) {\r\n this.index.setValue(new FlowGraphInteger(index), context);\r\n }\r\n for (let i = index; i < endIndex; i += step) {\r\n this.index.setValue(new FlowGraphInteger(i), context);\r\n this.executionFlow._activateSignal(context);\r\n endIndex = getNumericValue(this.endIndex.getValue(context));\r\n // Safety net against runaway loops. The cap counts iterations (not the index value) so it\r\n // behaves correctly regardless of startIndex/step.\r\n if (++iterations >= maxIterations) {\r\n truncated = true;\r\n break;\r\n }\r\n }\r\n\r\n if (truncated) {\r\n // The loop hit its safety cap before its range completed, so the outputs below are for a\r\n // truncated run, not a natural finish. Warn so a genuinely runaway asset is diagnosable\r\n // rather than silently producing wrong numbers (the completed signal still fires, and\r\n // incrementIndexWhenLoopDone will not land on endIndex).\r\n Logger.Warn(`FlowGraphForLoopBlock: loop stopped after reaching the ${maxIterations}-iteration safety cap before its range completed.`);\r\n }\r\n\r\n if (this.config?.incrementIndexWhenLoopDone && iterations > 0) {\r\n this.index.setValue(new FlowGraphInteger(getNumericValue(this.index.getValue(context)) + step), context);\r\n }\r\n\r\n this.completed._activateSignal(context);\r\n }\r\n\r\n /**\r\n * @returns class name of the block.\r\n */\r\n public override getClassName(): string {\r\n return FlowGraphBlockNames.ForLoop;\r\n }\r\n}\r\n\r\nlet _Registered = false;\r\n/**\r\n * Register side effects for flowGraphForLoopBlock.\r\n * Safe to call multiple times; only the first call has an effect.\r\n */\r\nexport function RegisterFlowGraphForLoopBlock(): void {\r\n if (_Registered) {\r\n return;\r\n }\r\n _Registered = true;\r\n\r\n RegisterClass(FlowGraphBlockNames.ForLoop, FlowGraphForLoopBlock);\r\n}\r\n"]}
@@ -4,6 +4,13 @@ import { type FlowGraphDataConnection } from "../../../flowGraphDataConnection.p
4
4
  import { type FlowGraphSignalConnection } from "../../../flowGraphSignalConnection.pure.js";
5
5
  import { FlowGraphExecutionBlockWithOutSignal } from "../../../flowGraphExecutionBlockWithOutSignal.js";
6
6
  import { type IFlowGraphBlockConfiguration } from "../../../flowGraphBlock.js";
7
+ /**
8
+ * Configuration for the throttle block.
9
+ */
10
+ export interface IFlowGraphThrottleBlockConfiguration extends IFlowGraphBlockConfiguration {
11
+ /** Whether a zero duration is accepted and always activates the output. Defaults to false. */
12
+ allowZeroDuration?: boolean;
13
+ }
7
14
  /**
8
15
  * A block that throttles the execution of its output flow.
9
16
  */
@@ -20,7 +27,11 @@ export declare class FlowGraphThrottleBlock extends FlowGraphExecutionBlockWithO
20
27
  * Output connection: The time remaining before the throttle is triggering again, in seconds.
21
28
  */
22
29
  readonly lastRemainingTime: FlowGraphDataConnection<number>;
23
- constructor(config?: IFlowGraphBlockConfiguration);
30
+ /**
31
+ * Creates a throttle block.
32
+ * @param config optional duration handling
33
+ */
34
+ constructor(config?: IFlowGraphThrottleBlockConfiguration);
24
35
  _execute(context: FlowGraphContext, callingSignal: FlowGraphSignalConnection): void;
25
36
  /**
26
37
  * @returns class name of the block.
@@ -6,6 +6,10 @@ import { RegisterClass } from "../../../../Misc/typeStore.js";
6
6
  * A block that throttles the execution of its output flow.
7
7
  */
8
8
  export class FlowGraphThrottleBlock extends FlowGraphExecutionBlockWithOutSignal {
9
+ /**
10
+ * Creates a throttle block.
11
+ * @param config optional duration handling
12
+ */
9
13
  constructor(config) {
10
14
  super(config);
11
15
  this.reset = this._registerSignalInput("reset");
@@ -21,7 +25,7 @@ export class FlowGraphThrottleBlock extends FlowGraphExecutionBlockWithOutSignal
21
25
  }
22
26
  // in seconds
23
27
  const durationValue = this.duration.getValue(context);
24
- if (durationValue <= 0 || isNaN(durationValue) || !isFinite(durationValue)) {
28
+ if (durationValue < 0 || (durationValue === 0 && !this.config?.allowZeroDuration) || isNaN(durationValue) || !isFinite(durationValue)) {
25
29
  return this._reportError(context, "Invalid duration in Throttle block");
26
30
  }
27
31
  const lastRemainingTime = context._getExecutionVariable(this, "lastRemainingTime", NaN);
@@ -1 +1 @@
1
- {"version":3,"file":"flowGraphThrottleBlock.pure.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.pure.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAI7D,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAElE,OAAO,EAAE,oCAAoC,EAAE,MAAM,+CAA+C,CAAC;AAGrG,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D;;GAEG;AACH,MAAM,OAAO,sBAAuB,SAAQ,oCAAoC;IAc5E,YAAY,MAAqC;QAC7C,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;QAChD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,iBAAiB,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;QACnE,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,kBAAkB,CAAC,mBAAmB,EAAE,cAAc,EAAE,GAAG,CAAC,CAAC;IAC/F,CAAC;IACM,QAAQ,CAAC,OAAyB,EAAE,aAAwC;QAC/E,IAAI,aAAa,KAAK,IAAI,CAAC,KAAK,EAAE,CAAC;YAC/B,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;YAC9C,OAAO,CAAC,qBAAqB,CAAC,IAAI,EAAE,mB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AAE,OAAO,CAAC,CAAC;gBAC5C,OAAO,CAAC,qBAAqB,CAAC,IAAI,EAAE,mBAAmB,EAAE,CAAC,CAAC,CAAC;gBAC5D,OAAO,CAAC,qBAAqB,CAAC,IAAI,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC;gBAC9D,OAAO,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;YAC7C,CAAC;iBAAM,CAAC;gBACJ,MAAM,aAAa,GAAG,YAAY,GAAG,WAAW,CAAC;gBACjD,uBAAuB;gBACvB,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,aAAa,GAAG,IAAI,EAAE,OAAO,CAAC,CAAC;gBAC/D,OAAO,CAAC,qBAAqB,CAAC,IAAI,EAAE,mBAAmB,EAAE,aAAa,CAAC,CAAC;YAC5E,CAAC;QACL,CAAC;IACL,CAAC;IACD;;OAEG;IACa,YAAY;QACxB,mEAAoC;IACxC,CAAC;CACJ;AAED,IAAI,WAAW,GAAG,KAAK,CAAC;AACxB;;;GAGG;AACH,MAAM,UAAU,8BAA8B;IAC1C,IAAI,WAAW,EAAE,CAAC;QACd,OAAO;IACX,CAAC;IACD,WAAW,GAAG,IAAI,CAAC;IAEnB,aAAa,8DAA+B,sBAAsB,CAAC,CAAC;AACxE,CAAC","sourcesContent":["/** This file must only contain pure code and pure imports */\r\n\r\nimport { type FlowGraphContext } from \"../../../flowGraphContext\";\r\nimport { type FlowGraphDataConnection } from \"../../../flowGraphDataConnection.pure\";\r\nimport { RichTypeNumber } from \"../../../flowGraphRichTypes.pure\";\r\nimport { type FlowGraphSignalConnection } from \"../../../flowGraphSignalConnection.pure\";\r\nimport { FlowGraphExecutionBlockWithOutSignal } from \"../../../flowGraphExecutionBlockWithOutSignal\";\r\nimport { type IFlowGraphBlockConfiguration } from \"../../../flowGraphBlock\";\r\nimport { FlowGraphBlockNames } from \"../../flowGraphBlockNames\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\n/**\r\n * A block that throttles the execution of its output flow.\r\n */\r\nexport class FlowGraphThrottleBlock extends FlowGraphExecutionBlockWithOutSignal {\r\n /**\r\n * Input connection: The duration of the throttle, in seconds.\r\n */\r\n public readonly duration: FlowGraphDataConnection<number>;\r\n /**\r\n * Input connection: Resets the throttle.\r\n */\r\n public readonly reset: FlowGraphSignalConnection;\r\n /**\r\n * Output connection: The time remaining before the throttle is triggering again, in seconds.\r\n */\r\n public readonly lastRemainingTime: FlowGraphDataConnection<number>;\r\n\r\n constructor(config?: IFlowGraphBlockConfiguration) {\r\n super(config);\r\n this.reset = this._registerSignalInput(\"reset\");\r\n this.duration = this.registerDataInput(\"duration\", RichTypeNumber);\r\n this.lastRemainingTime = this.registerDataOutput(\"lastRemainingTime\", RichTypeNumber, NaN);\r\n }\r\n public _execute(context: FlowGraphContext, callingSignal: FlowGraphSignalConnection): void {\r\n if (callingSignal === this.reset) {\r\n this.lastRemainingTime.setValue(NaN, context);\r\n context._setExecutionVariable(this, \"lastRemainingTime\", NaN);\r\n context._setExecutionVariable(this, \"timestamp\", 0);\r\n return;\r\n }\r\n // in seconds\r\n const durationValue = this.duration.getValue(context);\r\n if (durationValue <= 0 || isNaN(durationValue) || !isFinite(durationValue)) {\r\n return this._reportError(context, \"Invalid duration in Throttle block\");\r\n }\r\n const lastRemainingTime = context._getExecutionVariable(this, \"lastRemainingTime\", NaN);\r\n // Using Date.now() to get ms since epoch. not using performance.now() because its precision is not needed here\r\n const currentTime = Date.now();\r\n if (isNaN(lastRemainingTime)) {\r\n this.lastRemainingTime.setValue(0, context);\r\n context._setExecutionVariable(this, \"lastRemainingTime\", 0);\r\n context._setExecutionVariable(this, \"timestamp\", currentTime);\r\n // according to glTF interactivity specs\r\n return this.out._activateSignal(context);\r\n } else {\r\n const elapsedTime = currentTime - context._getExecutionVariable(this, \"timestamp\", 0);\r\n // duration is in seconds, so we need to multiply by 1000\r\n const durationInMs = durationValue * 1000;\r\n if (durationInMs <= elapsedTime) {\r\n this.lastRemainingTime.setValue(0, context);\r\n context._setExecutionVariable(this, \"lastRemainingTime\", 0);\r\n context._setExecutionVariable(this, \"timestamp\", currentTime);\r\n return this.out._activateSignal(context);\r\n } else {\r\n const remainingTime = durationInMs - elapsedTime;\r\n // output is in seconds\r\n this.lastRemainingTime.setValue(remainingTime / 1000, context);\r\n context._setExecutionVariable(this, \"lastRemainingTime\", remainingTime);\r\n }\r\n }\r\n }\r\n /**\r\n * @returns class name of the block.\r\n */\r\n public override getClassName(): string {\r\n return FlowGraphBlockNames.Throttle;\r\n }\r\n}\r\n\r\nlet _Registered = false;\r\n/**\r\n * Register side effects for flowGraphThrottleBlock.\r\n * Safe to call multiple times; only the first call has an effect.\r\n */\r\nexport function RegisterFlowGraphThrottleBlock(): void {\r\n if (_Registered) {\r\n return;\r\n }\r\n _Registered = true;\r\n\r\n RegisterClass(FlowGraphBlockNames.Throttle, FlowGraphThrottleBlock);\r\n}\r\n"]}
1
+ {"version":3,"file":"flowGraphThrottleBlock.pure.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.pure.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAI7D,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAElE,OAAO,EAAE,oCAAoC,EAAE,MAAM,+CAA+C,CAAC;AAGrG,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAS3D;;GAEG;AACH,MAAM,OAAO,sBAAuB,SAAQ,oCAAoC;IAc5E;;;OAGG;IACH,YAAY,MAA6C;QACrD,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;QAChD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,iBAAiB,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;QACnE,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,kBAAkB,CAA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C;YACxC,OAAO,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QAC7C,CAAC;aAAM,CAAC;YACJ,MAAM,WAAW,GAAG,WAAW,GAAG,OAAO,CAAC,qBAAqB,CAAC,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC;YACtF,yDAAyD;YACzD,MAAM,YAAY,GAAG,aAAa,GAAG,IAAI,CAAC;YAC1C,IAAI,YAAY,IAAI,WAAW,EAAE,CAAC;gBAC9B,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;gBAC5C,OAAO,CAAC,qBAAqB,CAAC,IAAI,EAAE,mBAAmB,EAAE,CAAC,CAAC,CAAC;gBAC5D,OAAO,CAAC,qBAAqB,CAAC,IAAI,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC;gBAC9D,OAAO,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;YAC7C,CAAC;iBAAM,CAAC;gBACJ,MAAM,aAAa,GAAG,YAAY,GAAG,WAAW,CAAC;gBACjD,uBAAuB;gBACvB,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,aAAa,GAAG,IAAI,EAAE,OAAO,CAAC,CAAC;gBAC/D,OAAO,CAAC,qBAAqB,CAAC,IAAI,EAAE,mBAAmB,EAAE,aAAa,CAAC,CAAC;YAC5E,CAAC;QACL,CAAC;IACL,CAAC;IACD;;OAEG;IACa,YAAY;QACxB,mEAAoC;IACxC,CAAC;CACJ;AAED,IAAI,WAAW,GAAG,KAAK,CAAC;AACxB;;;GAGG;AACH,MAAM,UAAU,8BAA8B;IAC1C,IAAI,WAAW,EAAE,CAAC;QACd,OAAO;IACX,CAAC;IACD,WAAW,GAAG,IAAI,CAAC;IAEnB,aAAa,8DAA+B,sBAAsB,CAAC,CAAC;AACxE,CAAC","sourcesContent":["/** This file must only contain pure code and pure imports */\r\n\r\nimport { type FlowGraphContext } from \"../../../flowGraphContext\";\r\nimport { type FlowGraphDataConnection } from \"../../../flowGraphDataConnection.pure\";\r\nimport { RichTypeNumber } from \"../../../flowGraphRichTypes.pure\";\r\nimport { type FlowGraphSignalConnection } from \"../../../flowGraphSignalConnection.pure\";\r\nimport { FlowGraphExecutionBlockWithOutSignal } from \"../../../flowGraphExecutionBlockWithOutSignal\";\r\nimport { type IFlowGraphBlockConfiguration } from \"../../../flowGraphBlock\";\r\nimport { FlowGraphBlockNames } from \"../../flowGraphBlockNames\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\n\r\n/**\r\n * Configuration for the throttle block.\r\n */\r\nexport interface IFlowGraphThrottleBlockConfiguration extends IFlowGraphBlockConfiguration {\r\n /** Whether a zero duration is accepted and always activates the output. Defaults to false. */\r\n allowZeroDuration?: boolean;\r\n}\r\n/**\r\n * A block that throttles the execution of its output flow.\r\n */\r\nexport class FlowGraphThrottleBlock extends FlowGraphExecutionBlockWithOutSignal {\r\n /**\r\n * Input connection: The duration of the throttle, in seconds.\r\n */\r\n public readonly duration: FlowGraphDataConnection<number>;\r\n /**\r\n * Input connection: Resets the throttle.\r\n */\r\n public readonly reset: FlowGraphSignalConnection;\r\n /**\r\n * Output connection: The time remaining before the throttle is triggering again, in seconds.\r\n */\r\n public readonly lastRemainingTime: FlowGraphDataConnection<number>;\r\n\r\n /**\r\n * Creates a throttle block.\r\n * @param config optional duration handling\r\n */\r\n constructor(config?: IFlowGraphThrottleBlockConfiguration) {\r\n super(config);\r\n this.reset = this._registerSignalInput(\"reset\");\r\n this.duration = this.registerDataInput(\"duration\", RichTypeNumber);\r\n this.lastRemainingTime = this.registerDataOutput(\"lastRemainingTime\", RichTypeNumber, NaN);\r\n }\r\n public _execute(context: FlowGraphContext, callingSignal: FlowGraphSignalConnection): void {\r\n if (callingSignal === this.reset) {\r\n this.lastRemainingTime.setValue(NaN, context);\r\n context._setExecutionVariable(this, \"lastRemainingTime\", NaN);\r\n context._setExecutionVariable(this, \"timestamp\", 0);\r\n return;\r\n }\r\n // in seconds\r\n const durationValue = this.duration.getValue(context);\r\n if (durationValue < 0 || (durationValue === 0 && !this.config?.allowZeroDuration) || isNaN(durationValue) || !isFinite(durationValue)) {\r\n return this._reportError(context, \"Invalid duration in Throttle block\");\r\n }\r\n const lastRemainingTime = context._getExecutionVariable(this, \"lastRemainingTime\", NaN);\r\n // Using Date.now() to get ms since epoch. not using performance.now() because its precision is not needed here\r\n const currentTime = Date.now();\r\n if (isNaN(lastRemainingTime)) {\r\n this.lastRemainingTime.setValue(0, context);\r\n context._setExecutionVariable(this, \"lastRemainingTime\", 0);\r\n context._setExecutionVariable(this, \"timestamp\", currentTime);\r\n // according to glTF interactivity specs\r\n return this.out._activateSignal(context);\r\n } else {\r\n const elapsedTime = currentTime - context._getExecutionVariable(this, \"timestamp\", 0);\r\n // duration is in seconds, so we need to multiply by 1000\r\n const durationInMs = durationValue * 1000;\r\n if (durationInMs <= elapsedTime) {\r\n this.lastRemainingTime.setValue(0, context);\r\n context._setExecutionVariable(this, \"lastRemainingTime\", 0);\r\n context._setExecutionVariable(this, \"timestamp\", currentTime);\r\n return this.out._activateSignal(context);\r\n } else {\r\n const remainingTime = durationInMs - elapsedTime;\r\n // output is in seconds\r\n this.lastRemainingTime.setValue(remainingTime / 1000, context);\r\n context._setExecutionVariable(this, \"lastRemainingTime\", remainingTime);\r\n }\r\n }\r\n }\r\n /**\r\n * @returns class name of the block.\r\n */\r\n public override getClassName(): string {\r\n return FlowGraphBlockNames.Throttle;\r\n }\r\n}\r\n\r\nlet _Registered = false;\r\n/**\r\n * Register side effects for flowGraphThrottleBlock.\r\n * Safe to call multiple times; only the first call has an effect.\r\n */\r\nexport function RegisterFlowGraphThrottleBlock(): void {\r\n if (_Registered) {\r\n return;\r\n }\r\n _Registered = true;\r\n\r\n RegisterClass(FlowGraphBlockNames.Throttle, FlowGraphThrottleBlock);\r\n}\r\n"]}
@@ -16,6 +16,8 @@ export interface IFlowGraphSetPropertyBlockConfiguration<O extends FlowGraphAsse
16
16
  * The target asset from which the property will be retrieved
17
17
  */
18
18
  target?: AssetType<O>;
19
+ /** Whether a failed write activates only error, without also activating out. Defaults to false. */
20
+ stopOnError?: boolean;
19
21
  }
20
22
  /**
21
23
  * This block will set a property on a given target asset.