@babylonjs/core 7.52.2 → 7.53.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) hide show
  1. package/AudioV2/abstractAudio/abstractAudioBus.d.ts +11 -0
  2. package/AudioV2/abstractAudio/abstractAudioBus.js +10 -0
  3. package/AudioV2/abstractAudio/abstractAudioBus.js.map +1 -1
  4. package/AudioV2/abstractAudio/abstractSound.d.ts +10 -3
  5. package/AudioV2/abstractAudio/abstractSound.js +10 -0
  6. package/AudioV2/abstractAudio/abstractSound.js.map +1 -1
  7. package/AudioV2/abstractAudio/audioBus.d.ts +4 -4
  8. package/AudioV2/abstractAudio/audioBus.js.map +1 -1
  9. package/AudioV2/abstractAudio/mainAudioBus.d.ts +2 -2
  10. package/AudioV2/abstractAudio/mainAudioBus.js.map +1 -1
  11. package/AudioV2/abstractAudio/staticSound.d.ts +5 -5
  12. package/AudioV2/abstractAudio/staticSound.js +3 -3
  13. package/AudioV2/abstractAudio/staticSound.js.map +1 -1
  14. package/AudioV2/abstractAudio/streamingSound.d.ts +1 -1
  15. package/AudioV2/abstractAudio/streamingSound.js +1 -1
  16. package/AudioV2/abstractAudio/streamingSound.js.map +1 -1
  17. package/AudioV2/abstractAudio/subNodes/abstractAudioSubGraph.d.ts +30 -9
  18. package/AudioV2/abstractAudio/subNodes/abstractAudioSubGraph.js +52 -26
  19. package/AudioV2/abstractAudio/subNodes/abstractAudioSubGraph.js.map +1 -1
  20. package/AudioV2/abstractAudio/subNodes/audioAnalyzerSubNode.d.ts +24 -0
  21. package/AudioV2/abstractAudio/subNodes/audioAnalyzerSubNode.js +30 -0
  22. package/AudioV2/abstractAudio/subNodes/audioAnalyzerSubNode.js.map +1 -0
  23. package/AudioV2/abstractAudio/subNodes/audioSubNode.d.ts +1 -0
  24. package/AudioV2/abstractAudio/subNodes/audioSubNode.js +1 -0
  25. package/AudioV2/abstractAudio/subNodes/audioSubNode.js.map +1 -1
  26. package/AudioV2/abstractAudio/subNodes/stereoAudioSubNode.js.map +1 -1
  27. package/AudioV2/abstractAudio/subProperties/abstractAudioAnalyzer.d.ts +86 -0
  28. package/AudioV2/abstractAudio/subProperties/abstractAudioAnalyzer.js +29 -0
  29. package/AudioV2/abstractAudio/subProperties/abstractAudioAnalyzer.js.map +1 -0
  30. package/AudioV2/abstractAudio/subProperties/audioAnalyzer.d.ts +35 -0
  31. package/AudioV2/abstractAudio/subProperties/audioAnalyzer.js +96 -0
  32. package/AudioV2/abstractAudio/subProperties/audioAnalyzer.js.map +1 -0
  33. package/AudioV2/abstractAudio/subProperties/index.d.ts +1 -0
  34. package/AudioV2/abstractAudio/subProperties/index.js +1 -0
  35. package/AudioV2/abstractAudio/subProperties/index.js.map +1 -1
  36. package/AudioV2/abstractAudio/subProperties/spatialAudio.js +10 -5
  37. package/AudioV2/abstractAudio/subProperties/spatialAudio.js.map +1 -1
  38. package/AudioV2/webAudio/subNodes/webAudioAnalyzerSubNode.d.ts +37 -0
  39. package/AudioV2/webAudio/subNodes/webAudioAnalyzerSubNode.js +85 -0
  40. package/AudioV2/webAudio/subNodes/webAudioAnalyzerSubNode.js.map +1 -0
  41. package/AudioV2/webAudio/subNodes/webAudioBaseSubGraph.d.ts +5 -3
  42. package/AudioV2/webAudio/subNodes/webAudioBaseSubGraph.js +25 -2
  43. package/AudioV2/webAudio/subNodes/webAudioBaseSubGraph.js.map +1 -1
  44. package/AudioV2/webAudio/subNodes/webAudioBusAndSoundSubGraph.d.ts +2 -1
  45. package/AudioV2/webAudio/subNodes/webAudioBusAndSoundSubGraph.js +33 -18
  46. package/AudioV2/webAudio/subNodes/webAudioBusAndSoundSubGraph.js.map +1 -1
  47. package/Engines/WebGPU/webgpuTextureManager.d.ts +0 -1
  48. package/Engines/WebGPU/webgpuTextureManager.js +2 -57
  49. package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
  50. package/Engines/abstractEngine.d.ts +6 -0
  51. package/Engines/abstractEngine.js +3 -3
  52. package/Engines/abstractEngine.js.map +1 -1
  53. package/Engines/engine.common.js +4 -0
  54. package/Engines/engine.common.js.map +1 -1
  55. package/Engines/nativeEngine.d.ts +1 -0
  56. package/Engines/nativeEngine.js +3 -0
  57. package/Engines/nativeEngine.js.map +1 -1
  58. package/Engines/nullEngine.d.ts +1 -0
  59. package/Engines/nullEngine.js +1 -0
  60. package/Engines/nullEngine.js.map +1 -1
  61. package/Engines/thinEngine.d.ts +1 -0
  62. package/Engines/thinEngine.js +7 -4
  63. package/Engines/thinEngine.js.map +1 -1
  64. package/Engines/webgpuEngine.d.ts +2 -1
  65. package/Engines/webgpuEngine.js +12 -9
  66. package/Engines/webgpuEngine.js.map +1 -1
  67. package/FlowGraph/Blocks/Data/Transformers/flowGraphJsonPointerParserBlock.d.ts +3 -12
  68. package/FlowGraph/Blocks/Data/Transformers/flowGraphJsonPointerParserBlock.js +16 -36
  69. package/FlowGraph/Blocks/Data/Transformers/flowGraphJsonPointerParserBlock.js.map +1 -1
  70. package/FlowGraph/Blocks/Data/flowGraphCachedOperationBlock.d.ts +5 -1
  71. package/FlowGraph/Blocks/Data/flowGraphCachedOperationBlock.js +17 -4
  72. package/FlowGraph/Blocks/Data/flowGraphCachedOperationBlock.js.map +1 -1
  73. package/FlowGraph/Blocks/Data/flowGraphDataSwitchBlock.d.ts +48 -0
  74. package/FlowGraph/Blocks/Data/flowGraphDataSwitchBlock.js +54 -0
  75. package/FlowGraph/Blocks/Data/flowGraphDataSwitchBlock.js.map +1 -0
  76. package/FlowGraph/Blocks/Data/flowGraphGetPropertyBlock.d.ts +3 -11
  77. package/FlowGraph/Blocks/Data/flowGraphGetPropertyBlock.js +5 -14
  78. package/FlowGraph/Blocks/Data/flowGraphGetPropertyBlock.js.map +1 -1
  79. package/FlowGraph/Blocks/Data/index.d.ts +1 -0
  80. package/FlowGraph/Blocks/Data/index.js +1 -0
  81. package/FlowGraph/Blocks/Data/index.js.map +1 -1
  82. package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.d.ts +1 -0
  83. package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js +19 -13
  84. package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js.map +1 -1
  85. package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.js +3 -5
  86. package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.js.map +1 -1
  87. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCancelDelayBlock.js +1 -1
  88. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCancelDelayBlock.js.map +1 -1
  89. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSetDelayBlock.js +2 -4
  90. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSetDelayBlock.js.map +1 -1
  91. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.js +1 -1
  92. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.js.map +1 -1
  93. package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js +1 -2
  94. package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js.map +1 -1
  95. package/FlowGraph/Blocks/flowGraphBlockFactory.js +2 -0
  96. package/FlowGraph/Blocks/flowGraphBlockFactory.js.map +1 -1
  97. package/FlowGraph/Blocks/flowGraphBlockNames.d.ts +2 -1
  98. package/FlowGraph/Blocks/flowGraphBlockNames.js +1 -0
  99. package/FlowGraph/Blocks/flowGraphBlockNames.js.map +1 -1
  100. package/FlowGraph/CustomTypes/flowGraphInteger.d.ts +1 -0
  101. package/FlowGraph/CustomTypes/flowGraphInteger.js +3 -0
  102. package/FlowGraph/CustomTypes/flowGraphInteger.js.map +1 -1
  103. package/FlowGraph/CustomTypes/flowGraphMatrix.d.ts +2 -0
  104. package/FlowGraph/CustomTypes/flowGraphMatrix.js +6 -0
  105. package/FlowGraph/CustomTypes/flowGraphMatrix.js.map +1 -1
  106. package/FlowGraph/flowGraphExecutionBlock.d.ts +1 -0
  107. package/FlowGraph/flowGraphExecutionBlock.js +4 -0
  108. package/FlowGraph/flowGraphExecutionBlock.js.map +1 -1
  109. package/FlowGraph/utils.d.ts +2 -1
  110. package/FlowGraph/utils.js +7 -2
  111. package/FlowGraph/utils.js.map +1 -1
  112. package/FrameGraph/Node/Blocks/PostProcesses/bloomPostProcessBlock.js +2 -2
  113. package/FrameGraph/Node/Blocks/PostProcesses/bloomPostProcessBlock.js.map +1 -1
  114. package/FrameGraph/Node/Blocks/PostProcesses/depthOfFieldPostProcessBlock.js +2 -2
  115. package/FrameGraph/Node/Blocks/PostProcesses/depthOfFieldPostProcessBlock.js.map +1 -1
  116. package/FrameGraph/Node/Blocks/PostProcesses/ssrPostProcessBlock.d.ts +126 -0
  117. package/FrameGraph/Node/Blocks/PostProcesses/ssrPostProcessBlock.js +497 -0
  118. package/FrameGraph/Node/Blocks/PostProcesses/ssrPostProcessBlock.js.map +1 -0
  119. package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.d.ts +6 -0
  120. package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js +30 -4
  121. package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js.map +1 -1
  122. package/FrameGraph/Node/Blocks/index.d.ts +1 -0
  123. package/FrameGraph/Node/Blocks/index.js +1 -0
  124. package/FrameGraph/Node/Blocks/index.js.map +1 -1
  125. package/FrameGraph/Node/nodeRenderGraph.js +1 -1
  126. package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
  127. package/FrameGraph/Tasks/PostProcesses/bloomTask.d.ts +2 -3
  128. package/FrameGraph/Tasks/PostProcesses/bloomTask.js +3 -4
  129. package/FrameGraph/Tasks/PostProcesses/bloomTask.js.map +1 -1
  130. package/FrameGraph/Tasks/PostProcesses/blurTask.js +2 -2
  131. package/FrameGraph/Tasks/PostProcesses/blurTask.js.map +1 -1
  132. package/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.d.ts +2 -3
  133. package/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.js +4 -5
  134. package/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.js.map +1 -1
  135. package/FrameGraph/Tasks/PostProcesses/postProcessTask.d.ts +6 -0
  136. package/FrameGraph/Tasks/PostProcesses/postProcessTask.js +14 -0
  137. package/FrameGraph/Tasks/PostProcesses/postProcessTask.js.map +1 -1
  138. package/FrameGraph/Tasks/PostProcesses/ssrBlurTask.d.ts +11 -0
  139. package/FrameGraph/Tasks/PostProcesses/ssrBlurTask.js +18 -0
  140. package/FrameGraph/Tasks/PostProcesses/ssrBlurTask.js.map +1 -0
  141. package/FrameGraph/Tasks/PostProcesses/ssrRenderingPipelineTask.d.ts +76 -0
  142. package/FrameGraph/Tasks/PostProcesses/ssrRenderingPipelineTask.js +170 -0
  143. package/FrameGraph/Tasks/PostProcesses/ssrRenderingPipelineTask.js.map +1 -0
  144. package/FrameGraph/Tasks/PostProcesses/ssrTask.d.ts +16 -0
  145. package/FrameGraph/Tasks/PostProcesses/ssrTask.js +45 -0
  146. package/FrameGraph/Tasks/PostProcesses/ssrTask.js.map +1 -0
  147. package/FrameGraph/Tasks/Rendering/geometryRendererTask.d.ts +10 -0
  148. package/FrameGraph/Tasks/Rendering/geometryRendererTask.js +29 -0
  149. package/FrameGraph/Tasks/Rendering/geometryRendererTask.js.map +1 -1
  150. package/FrameGraph/frameGraph.d.ts +7 -3
  151. package/FrameGraph/frameGraph.js +10 -4
  152. package/FrameGraph/frameGraph.js.map +1 -1
  153. package/FrameGraph/frameGraphTextureManager.d.ts +2 -1
  154. package/FrameGraph/frameGraphTextureManager.js +4 -3
  155. package/FrameGraph/frameGraphTextureManager.js.map +1 -1
  156. package/FrameGraph/index.d.ts +1 -0
  157. package/FrameGraph/index.js +1 -0
  158. package/FrameGraph/index.js.map +1 -1
  159. package/Materials/Node/nodeMaterial.js +3 -0
  160. package/Materials/Node/nodeMaterial.js.map +1 -1
  161. package/Materials/PBR/pbrBaseMaterial.js +1 -1
  162. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  163. package/Materials/effectRenderer.js +1 -1
  164. package/Materials/effectRenderer.js.map +1 -1
  165. package/Materials/material.js +5 -3
  166. package/Materials/material.js.map +1 -1
  167. package/Materials/materialHelper.geometryrendering.d.ts +7 -5
  168. package/Materials/materialHelper.geometryrendering.js +8 -3
  169. package/Materials/materialHelper.geometryrendering.js.map +1 -1
  170. package/Materials/standardMaterial.js +1 -1
  171. package/Materials/standardMaterial.js.map +1 -1
  172. package/Meshes/Builders/shapeBuilder.d.ts +2 -0
  173. package/Meshes/Builders/shapeBuilder.js +7 -4
  174. package/Meshes/Builders/shapeBuilder.js.map +1 -1
  175. package/Meshes/geometry.js +4 -0
  176. package/Meshes/geometry.js.map +1 -1
  177. package/Particles/particleSystemComponent.d.ts +2 -1
  178. package/Particles/particleSystemComponent.js +2 -2
  179. package/Particles/particleSystemComponent.js.map +1 -1
  180. package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.d.ts +23 -30
  181. package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.js +226 -411
  182. package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.js.map +1 -1
  183. package/PostProcesses/RenderPipeline/Pipelines/thinSSRRenderingPipeline.d.ts +222 -0
  184. package/PostProcesses/RenderPipeline/Pipelines/thinSSRRenderingPipeline.js +373 -0
  185. package/PostProcesses/RenderPipeline/Pipelines/thinSSRRenderingPipeline.js.map +1 -0
  186. package/PostProcesses/postProcess.d.ts +5 -0
  187. package/PostProcesses/postProcess.js +10 -2
  188. package/PostProcesses/postProcess.js.map +1 -1
  189. package/PostProcesses/thinDepthOfFieldEffect.d.ts +4 -4
  190. package/PostProcesses/thinDepthOfFieldEffect.js.map +1 -1
  191. package/PostProcesses/thinSSRBlurCombinerPostProcess.d.ts +41 -0
  192. package/PostProcesses/thinSSRBlurCombinerPostProcess.js +185 -0
  193. package/PostProcesses/thinSSRBlurCombinerPostProcess.js.map +1 -0
  194. package/PostProcesses/thinSSRBlurPostProcess.d.ts +18 -0
  195. package/PostProcesses/thinSSRBlurPostProcess.js +47 -0
  196. package/PostProcesses/thinSSRBlurPostProcess.js.map +1 -0
  197. package/PostProcesses/thinSSRPostProcess.d.ts +94 -0
  198. package/PostProcesses/thinSSRPostProcess.js +416 -0
  199. package/PostProcesses/thinSSRPostProcess.js.map +1 -0
  200. package/Rendering/IBLShadows/iblShadowsRenderPipeline.d.ts +2 -0
  201. package/Rendering/IBLShadows/iblShadowsRenderPipeline.js +2 -0
  202. package/Rendering/IBLShadows/iblShadowsRenderPipeline.js.map +1 -1
  203. package/Rendering/iblCdfGenerator.js +1 -1
  204. package/Rendering/iblCdfGenerator.js.map +1 -1
  205. package/Shaders/screenSpaceReflection2BlurCombiner.fragment.js +13 -2
  206. package/Shaders/screenSpaceReflection2BlurCombiner.fragment.js.map +1 -1
  207. package/ShadersWGSL/geometry.fragment.js +1 -1
  208. package/ShadersWGSL/geometry.fragment.js.map +1 -1
  209. package/ShadersWGSL/screenSpaceReflection2BlurCombiner.fragment.js +13 -2
  210. package/ShadersWGSL/screenSpaceReflection2BlurCombiner.fragment.js.map +1 -1
  211. package/package.json +1 -1
@@ -33,9 +33,7 @@ export class FlowGraphPlayAnimationBlock extends FlowGraphAsyncExecutionBlock {
33
33
  const ag = this.animationGroup.getValue(context);
34
34
  const animation = this.animation.getValue(context);
35
35
  if (!ag && !animation) {
36
- this.error.payload = { message: "No animation group or animation provided" };
37
- this.error._activateSignal(context);
38
- return;
36
+ return this._reportError(context, "No animation or animation group provided");
39
37
  }
40
38
  else {
41
39
  // if an animation group was already created, dispose it and create a new one
@@ -48,9 +46,7 @@ export class FlowGraphPlayAnimationBlock extends FlowGraphAsyncExecutionBlock {
48
46
  if (animation && !animationGroupToUse) {
49
47
  const target = this.object.getValue(context);
50
48
  if (!target) {
51
- this.error.payload = { message: "No target object provided" };
52
- this.error._activateSignal(context);
53
- return;
49
+ return this._reportError(context, "No target object provided");
54
50
  }
55
51
  const animationsArray = Array.isArray(animation) ? animation : [animation];
56
52
  const name = animationsArray[0].name;
@@ -79,15 +75,25 @@ export class FlowGraphPlayAnimationBlock extends FlowGraphAsyncExecutionBlock {
79
75
  if (currentlyRunningAnimationGroups.indexOf(animationGroupToUse.uniqueId) !== -1) {
80
76
  animationGroupToUse.stop();
81
77
  }
82
- animationGroupToUse.start(loop, speed, from, to);
83
- animationGroupToUse.onAnimationGroupEndObservable.add(() => this._onAnimationGroupEnd(context));
84
- animationGroupToUse.onAnimationEndObservable.add(() => this._eventsSignalOutputs["animationEnd"]._activateSignal(context));
85
- animationGroupToUse.onAnimationLoopObservable.add(() => this._eventsSignalOutputs["animationLoop"]._activateSignal(context));
86
- animationGroupToUse.onAnimationGroupLoopObservable.add(() => this._eventsSignalOutputs["animationGroupLoop"]._activateSignal(context));
87
- currentlyRunningAnimationGroups.push(animationGroupToUse.uniqueId);
88
- context._setGlobalContextVariable("currentlyRunningAnimationGroups", currentlyRunningAnimationGroups);
78
+ try {
79
+ animationGroupToUse.start(loop, speed, from, to);
80
+ animationGroupToUse.onAnimationGroupEndObservable.add(() => this._onAnimationGroupEnd(context));
81
+ animationGroupToUse.onAnimationEndObservable.add(() => this._eventsSignalOutputs["animationEnd"]._activateSignal(context));
82
+ animationGroupToUse.onAnimationLoopObservable.add(() => this._eventsSignalOutputs["animationLoop"]._activateSignal(context));
83
+ animationGroupToUse.onAnimationGroupLoopObservable.add(() => this._eventsSignalOutputs["animationGroupLoop"]._activateSignal(context));
84
+ currentlyRunningAnimationGroups.push(animationGroupToUse.uniqueId);
85
+ context._setGlobalContextVariable("currentlyRunningAnimationGroups", currentlyRunningAnimationGroups);
86
+ }
87
+ catch (e) {
88
+ this._reportError(context, e);
89
+ }
89
90
  }
90
91
  }
92
+ _reportError(context, error) {
93
+ super._reportError(context, error);
94
+ this.currentFrame.setValue(-1, context);
95
+ this.currentTime.setValue(-1, context);
96
+ }
91
97
  /**
92
98
  * @internal
93
99
  */
@@ -1 +1 @@
1
- {"version":3,"file":"flowGraphPlayAnimationBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,4BAA4B,EAAE,MAAM,uCAAuC,CAAC;AACrF,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC3F,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,OAAO,EAAE,cAAc,EAAE,iDAAuC;AAIhE;;;GAGG;AACH,MAAM,OAAO,2BAA4B,SAAQ,4BAA4B;IAiDzE;IACI;;OAEG;IACa,MAAqC;QAErD,KAAK,CAAC,MAAM,EAAE,CAAC,eAAe,EAAE,cAAc,EAAE,oBAAoB,CAAC,CAAC,CAAC;QAFvD,WAAM,GAAN,MAAM,CAA+B;QAIrD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;QAC7D,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,iBAAiB,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;QAC5D,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,iBAAiB,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC;QAC9D,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,iBAAiB,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;QAEvD,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,kBAAkB,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC;QAC5E,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,kBAAkB,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC;QAE1E,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC,kBAAkB,CAAC,uBAAuB,EAAE,WAAW,CAAC,CAAC;QAC3F,IAAI,CAAC,cA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esContent":["import type { FlowGraphContext } from \"../../../flowGraphContext\";\r\nimport type { FlowGraphDataConnection } from \"../../../flowGraphDataConnection\";\r\nimport { FlowGraphAsyncExecutionBlock } from \"../../../flowGraphAsyncExecutionBlock\";\r\nimport { RichTypeAny, RichTypeNumber, RichTypeBoolean } from \"../../../flowGraphRichTypes\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport type { IFlowGraphBlockConfiguration } from \"../../../flowGraphBlock\";\r\nimport { AnimationGroup } from \"core/Animations/animationGroup\";\r\nimport type { Animation } from \"core/Animations/animation\";\r\nimport { FlowGraphBlockNames } from \"../../flowGraphBlockNames\";\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?: IFlowGraphBlockConfiguration\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 _preparePendingTasks(context: FlowGraphContext): void {\r\n const ag = this.animationGroup.getValue(context);\r\n const animation = this.animation.getValue(context);\r\n if (!ag && !animation) {\r\n this.error.payload = { message: \"No animation group or animation provided\" };\r\n this.error._activateSignal(context);\r\n return;\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 // 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.error.payload = { message: \"No target object provided\" };\r\n this.error._activateSignal(context);\r\n return;\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 let isInterpolation = false;\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\r\n if (isInterpolation) {\r\n this._checkInterpolationDuplications(context, animationsArray, target);\r\n }\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 // not accepting 0\r\n const to = this.to.getValue(context) || animationGroupToUse.to;\r\n const loop = 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 animationGroupToUse.stop();\r\n }\r\n animationGroupToUse.start(loop, speed, from, to);\r\n animationGroupToUse.onAnimationGroupEndObservable.add(() => this._onAnimationGroupEnd(context));\r\n animationGroupToUse.onAnimationEndObservable.add(() => this._eventsSignalOutputs[\"animationEnd\"]._activateSignal(context));\r\n animationGroupToUse.onAnimationLoopObservable.add(() => this._eventsSignalOutputs[\"animationLoop\"]._activateSignal(context));\r\n animationGroupToUse.onAnimationGroupLoopObservable.add(() => this._eventsSignalOutputs[\"animationGroupLoop\"]._activateSignal(context));\r\n currentlyRunningAnimationGroups.push(animationGroupToUse.uniqueId);\r\n context._setGlobalContextVariable(\"currentlyRunningAnimationGroups\", currentlyRunningAnimationGroups);\r\n }\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) {\r\n this._removeFromCurrentlyRunning(context, this.currentAnimationGroup.getValue(context));\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 // stop, while skipping the on AnimationEndObservable to avoid the \"done\" signal\r\n animationGroup.stop(true);\r\n animationGroup.dispose();\r\n this._removeFromCurrentlyRunning(context, animationGroup);\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 _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\nRegisterClass(FlowGraphBlockNames.PlayAnimation, FlowGraphPlayAnimationBlock);\r\n"]}
1
+ {"version":3,"file":"flowGraphPlayAnimationBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,4BAA4B,EAAE,MAAM,uCAAuC,CAAC;AACrF,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC3F,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,OAAO,EAAE,cAAc,EAAE,iDAAuC;AAIhE;;;GAGG;AACH,MAAM,OAAO,2BAA4B,SAAQ,4BAA4B;IAiDzE;IACI;;OAEG;IACa,MAAqC;QAErD,KAAK,CAAC,MAAM,EAAE,CAAC,eAAe,EAAE,cAAc,EAAE,oBAAoB,CAAC,CAAC,CAAC;QAFvD,WAAM,GAAN,MAAM,CAA+B;QAIrD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;QAC7D,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,iBAAiB,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;QAC5D,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,iBAAiB,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC;QAC9D,IAAI,CAAC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G,+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;IACI,mBAAmB,CAAC,OAAyB;QAChD,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,aAAa,wEAAoC,2BAA2B,CAAC,CAAC","sourcesContent":["import type { FlowGraphContext } from \"../../../flowGraphContext\";\r\nimport type { FlowGraphDataConnection } from \"../../../flowGraphDataConnection\";\r\nimport { FlowGraphAsyncExecutionBlock } from \"../../../flowGraphAsyncExecutionBlock\";\r\nimport { RichTypeAny, RichTypeNumber, RichTypeBoolean } from \"../../../flowGraphRichTypes\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport type { IFlowGraphBlockConfiguration } from \"../../../flowGraphBlock\";\r\nimport { AnimationGroup } from \"core/Animations/animationGroup\";\r\nimport type { Animation } from \"core/Animations/animation\";\r\nimport { FlowGraphBlockNames } from \"../../flowGraphBlockNames\";\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?: IFlowGraphBlockConfiguration\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 _preparePendingTasks(context: FlowGraphContext): void {\r\n const ag = this.animationGroup.getValue(context);\r\n const animation = this.animation.getValue(context);\r\n if (!ag && !animation) {\r\n return this._reportError(context, \"No animation or animation group provided\");\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 // 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 return this._reportError(context, \"No target object provided\");\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 let isInterpolation = false;\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\r\n if (isInterpolation) {\r\n this._checkInterpolationDuplications(context, animationsArray, target);\r\n }\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 // not accepting 0\r\n const to = this.to.getValue(context) || animationGroupToUse.to;\r\n const loop = 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 animationGroupToUse.stop();\r\n }\r\n try {\r\n animationGroupToUse.start(loop, speed, from, to);\r\n animationGroupToUse.onAnimationGroupEndObservable.add(() => this._onAnimationGroupEnd(context));\r\n animationGroupToUse.onAnimationEndObservable.add(() => this._eventsSignalOutputs[\"animationEnd\"]._activateSignal(context));\r\n animationGroupToUse.onAnimationLoopObservable.add(() => this._eventsSignalOutputs[\"animationLoop\"]._activateSignal(context));\r\n animationGroupToUse.onAnimationGroupLoopObservable.add(() => this._eventsSignalOutputs[\"animationGroupLoop\"]._activateSignal(context));\r\n currentlyRunningAnimationGroups.push(animationGroupToUse.uniqueId);\r\n context._setGlobalContextVariable(\"currentlyRunningAnimationGroups\", currentlyRunningAnimationGroups);\r\n } catch (e) {\r\n this._reportError(context, e);\r\n }\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) {\r\n this._removeFromCurrentlyRunning(context, this.currentAnimationGroup.getValue(context));\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 // stop, while skipping the on AnimationEndObservable to avoid the \"done\" signal\r\n animationGroup.stop(true);\r\n animationGroup.dispose();\r\n this._removeFromCurrentlyRunning(context, animationGroup);\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 _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\nRegisterClass(FlowGraphBlockNames.PlayAnimation, FlowGraphPlayAnimationBlock);\r\n"]}
@@ -41,13 +41,10 @@ export class FlowGraphStopAnimationBlock extends FlowGraphAsyncExecutionBlock {
41
41
  // check the values
42
42
  if (!animationToStopValue) {
43
43
  Logger.Warn("No animation group provided to stop.");
44
- this.error.payload = { message: "No animation group provided to stop." };
45
- this.error._activateSignal(context);
44
+ return this._reportError(context, "No animation group provided to stop.");
46
45
  }
47
46
  if (isNaN(stopTime)) {
48
- Logger.Warn("Invalid stop time provided.");
49
- this.error.payload = { message: "Invalid stop time provided." };
50
- this.error._activateSignal(context);
47
+ return this._reportError(context, "Invalid stop time.");
51
48
  }
52
49
  if (stopTime > 0) {
53
50
  this._startPendingTasks(context);
@@ -55,6 +52,7 @@ export class FlowGraphStopAnimationBlock extends FlowGraphAsyncExecutionBlock {
55
52
  else {
56
53
  this._stopAnimation(animationToStopValue, context);
57
54
  }
55
+ // note that out will not be triggered in case of an error
58
56
  this.out._activateSignal(context);
59
57
  }
60
58
  _executeOnTick(context) {
@@ -1 +1 @@
1
- {"version":3,"file":"flowGraphStopAnimationBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE1E,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAG3D,OAAO,EAAE,MAAM,EAAE,mCAAyB;AAC1C,OAAO,EAAE,4BAA4B,EAAE,iDAAoD;AAC3F;;;GAGG;AACH,MAAM,OAAO,2BAA4B,SAAQ,4BAA4B;IAWzE,YAAY,MAAqC;QAC7C,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,iBAAiB,CAAC,gBAAgB,EAAE,WAAW,CAAC,CAAC;QAC5E,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,iBAAiB,CAAC,aAAa,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC,CAAC;IACjF,CAAC;IAEe,oBAAoB,CAAC,OAAyB;QAC1D,MAAM,oBAAoB,GAAG,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QACnE,MAAM,WAAW,GAAG,I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AC,CAAC,WAAW,EAAE,CAAC;oBACjF,qBAAqB;oBACrB,IAAI,CAAC,cAAc,CAAC,oBAAoB,EAAE,OAAO,CAAC,CAAC;oBACnD,qCAAqC;oBACrC,qBAAqB,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;oBACnC,kCAAkC;oBAClC,OAAO,CAAC,yBAAyB,CAAC,uBAAuB,EAAE,qBAAqB,CAAC,CAAC;oBAClF,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;oBACnC,OAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;oBAClC,MAAM;gBACV,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;IAED;;OAEG;IACa,YAAY;QACxB,6EAAyC;IAC7C,CAAC;IAEO,cAAc,CAAC,cAA8B,EAAE,OAAyB;QAC5E,MAAM,gBAAgB,GAAG,OAAO,CAAC,yBAAyB,CAAC,iCAAiC,EAAE,EAAE,CAAa,CAAC;QAC9G,MAAM,KAAK,GAAG,gBAAgB,CAAC,OAAO,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;QAChE,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;YACf,cAAc,CAAC,IAAI,EAAE,CAAC;YACtB,gBAAgB,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;YAClC,qCAAqC;YACrC,OAAO,CAAC,yBAAyB,CAAC,iCAAiC,EAAE,gBAAgB,CAAC,CAAC;QAC3F,CAAC;aAAM,CAAC;YACJ,mEAAmE;YACnE,wDAAwD;QAC5D,CAAC;IACL,CAAC;CACJ;AACD,aAAa,wEAAoC,2BAA2B,CAAC,CAAC","sourcesContent":["import type { FlowGraphContext } from \"../../../flowGraphContext\";\r\nimport type { FlowGraphDataConnection } from \"../../../flowGraphDataConnection\";\r\nimport { RichTypeAny, RichTypeNumber } from \"../../../flowGraphRichTypes\";\r\nimport type { IFlowGraphBlockConfiguration } from \"../../../flowGraphBlock\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport type { AnimationGroup } from \"core/Animations/animationGroup\";\r\nimport { FlowGraphBlockNames } from \"../../flowGraphBlockNames\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport { FlowGraphAsyncExecutionBlock } from \"core/FlowGraph/flowGraphAsyncExecutionBlock\";\r\n/**\r\n * @experimental\r\n * Block that stops a running animation\r\n */\r\nexport class FlowGraphStopAnimationBlock extends FlowGraphAsyncExecutionBlock {\r\n /**\r\n * Input connection: The animation to stop.\r\n */\r\n public readonly animationGroup: FlowGraphDataConnection<AnimationGroup>;\r\n\r\n /**\r\n * Input connection - if defined (positive integer) the animation will stop at this frame.\r\n */\r\n public readonly stopAtFrame: FlowGraphDataConnection<number>;\r\n\r\n constructor(config?: IFlowGraphBlockConfiguration) {\r\n super(config);\r\n this.animationGroup = this.registerDataInput(\"animationGroup\", RichTypeAny);\r\n this.stopAtFrame = this.registerDataInput(\"stopAtFrame\", RichTypeNumber, -1);\r\n }\r\n\r\n public override _preparePendingTasks(context: FlowGraphContext): void {\r\n const animationToStopValue = this.animationGroup.getValue(context);\r\n const stopAtFrame = this.stopAtFrame.getValue(context) ?? -1;\r\n // get the context variable\r\n const pendingStopAnimations = context._getGlobalContextVariable(\r\n \"pendingStopAnimations\",\r\n [] as {\r\n uniqueId: number;\r\n stopAtFrame: number;\r\n }[]\r\n );\r\n // add the animation to the list\r\n pendingStopAnimations.push({ uniqueId: animationToStopValue.uniqueId, stopAtFrame });\r\n // set the global context variable\r\n context._setGlobalContextVariable(\"pendingStopAnimations\", pendingStopAnimations);\r\n }\r\n public override _cancelPendingTasks(context: FlowGraphContext): void {\r\n // remove the animation from the list\r\n const animationToStopValue = this.animationGroup.getValue(context);\r\n const pendingStopAnimations = context._getGlobalContextVariable(\r\n \"pendingStopAnimations\",\r\n [] as {\r\n uniqueId: number;\r\n stopAtFrame: number;\r\n }[]\r\n );\r\n for (let i = 0; i < pendingStopAnimations.length; i++) {\r\n if (pendingStopAnimations[i].uniqueId === animationToStopValue.uniqueId) {\r\n pendingStopAnimations.splice(i, 1);\r\n // set the global context variable\r\n context._setGlobalContextVariable(\"pendingStopAnimations\", pendingStopAnimations);\r\n break;\r\n }\r\n }\r\n }\r\n\r\n public _execute(context: FlowGraphContext): void {\r\n const animationToStopValue = this.animationGroup.getValue(context);\r\n const stopTime = this.stopAtFrame.getValue(context) ?? -1;\r\n // check the values\r\n if (!animationToStopValue) {\r\n Logger.Warn(\"No animation group provided to stop.\");\r\n this.error.payload = { message: \"No animation group provided to stop.\" };\r\n this.error._activateSignal(context);\r\n }\r\n if (isNaN(stopTime)) {\r\n Logger.Warn(\"Invalid stop time provided.\");\r\n this.error.payload = { message: \"Invalid stop time provided.\" };\r\n this.error._activateSignal(context);\r\n }\r\n if (stopTime > 0) {\r\n this._startPendingTasks(context);\r\n } else {\r\n this._stopAnimation(animationToStopValue, context);\r\n }\r\n this.out._activateSignal(context);\r\n }\r\n\r\n public override _executeOnTick(context: FlowGraphContext): void {\r\n const animationToStopValue = this.animationGroup.getValue(context);\r\n // check each frame if any animation should be stopped\r\n const pendingStopAnimations = context._getGlobalContextVariable(\"pendingStopAnimations\", [] as { uniqueId: number; stopAtFrame: number }[]);\r\n for (let i = 0; i < pendingStopAnimations.length; i++) {\r\n // compare the uniqueId to the animation to stop\r\n if (pendingStopAnimations[i].uniqueId === animationToStopValue.uniqueId) {\r\n // check if the current frame is AFTER the stopAtFrame\r\n if (animationToStopValue.getCurrentFrame() >= pendingStopAnimations[i].stopAtFrame) {\r\n // stop the animation\r\n this._stopAnimation(animationToStopValue, context);\r\n // remove the animation from the list\r\n pendingStopAnimations.splice(i, 1);\r\n // set the global context variable\r\n context._setGlobalContextVariable(\"pendingStopAnimations\", pendingStopAnimations);\r\n this.done._activateSignal(context);\r\n context._removePendingBlock(this);\r\n break;\r\n }\r\n }\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.StopAnimation;\r\n }\r\n\r\n private _stopAnimation(animationGroup: AnimationGroup, context: FlowGraphContext): void {\r\n const currentlyRunning = context._getGlobalContextVariable(\"currentlyRunningAnimationGroups\", []) as number[];\r\n const index = currentlyRunning.indexOf(animationGroup.uniqueId);\r\n if (index !== -1) {\r\n animationGroup.stop();\r\n currentlyRunning.splice(index, 1);\r\n // update the global context variable\r\n context._setGlobalContextVariable(\"currentlyRunningAnimationGroups\", currentlyRunning);\r\n } else {\r\n // Logger.Warn(\"Trying to stop an animation that is not running.\");\r\n // no-op for now. Probably no need to log anything here.\r\n }\r\n }\r\n}\r\nRegisterClass(FlowGraphBlockNames.StopAnimation, FlowGraphStopAnimationBlock);\r\n"]}
1
+ {"version":3,"file":"flowGraphStopAnimationBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE1E,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAG3D,OAAO,EAAE,MAAM,EAAE,mCAAyB;AAC1C,OAAO,EAAE,4BAA4B,EAAE,iDAAoD;AAC3F;;;GAGG;AACH,MAAM,OAAO,2BAA4B,SAAQ,4BAA4B;IAWzE,YAAY,MAAqC;QAC7C,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,iBAAiB,CAAC,gBAAgB,EAAE,WAAW,CAAC,CAAC;QAC5E,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,iBAAiB,CAAC,aAAa,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC,CAAC;IACjF,CAAC;IAEe,oBAAoB,CAAC,OAAyB;QAC1D,MAAM,oBAAoB,GAAG,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QACnE,MAAM,WA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,CAAC,CAAC,CAAC;oBACnC,kCAAkC;oBAClC,OAAO,CAAC,yBAAyB,CAAC,uBAAuB,EAAE,qBAAqB,CAAC,CAAC;oBAClF,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;oBACnC,OAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;oBAClC,MAAM;gBACV,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;IAED;;OAEG;IACa,YAAY;QACxB,6EAAyC;IAC7C,CAAC;IAEO,cAAc,CAAC,cAA8B,EAAE,OAAyB;QAC5E,MAAM,gBAAgB,GAAG,OAAO,CAAC,yBAAyB,CAAC,iCAAiC,EAAE,EAAE,CAAa,CAAC;QAC9G,MAAM,KAAK,GAAG,gBAAgB,CAAC,OAAO,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;QAChE,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;YACf,cAAc,CAAC,IAAI,EAAE,CAAC;YACtB,gBAAgB,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;YAClC,qCAAqC;YACrC,OAAO,CAAC,yBAAyB,CAAC,iCAAiC,EAAE,gBAAgB,CAAC,CAAC;QAC3F,CAAC;aAAM,CAAC;YACJ,mEAAmE;YACnE,wDAAwD;QAC5D,CAAC;IACL,CAAC;CACJ;AACD,aAAa,wEAAoC,2BAA2B,CAAC,CAAC","sourcesContent":["import type { FlowGraphContext } from \"../../../flowGraphContext\";\r\nimport type { FlowGraphDataConnection } from \"../../../flowGraphDataConnection\";\r\nimport { RichTypeAny, RichTypeNumber } from \"../../../flowGraphRichTypes\";\r\nimport type { IFlowGraphBlockConfiguration } from \"../../../flowGraphBlock\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport type { AnimationGroup } from \"core/Animations/animationGroup\";\r\nimport { FlowGraphBlockNames } from \"../../flowGraphBlockNames\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport { FlowGraphAsyncExecutionBlock } from \"core/FlowGraph/flowGraphAsyncExecutionBlock\";\r\n/**\r\n * @experimental\r\n * Block that stops a running animation\r\n */\r\nexport class FlowGraphStopAnimationBlock extends FlowGraphAsyncExecutionBlock {\r\n /**\r\n * Input connection: The animation to stop.\r\n */\r\n public readonly animationGroup: FlowGraphDataConnection<AnimationGroup>;\r\n\r\n /**\r\n * Input connection - if defined (positive integer) the animation will stop at this frame.\r\n */\r\n public readonly stopAtFrame: FlowGraphDataConnection<number>;\r\n\r\n constructor(config?: IFlowGraphBlockConfiguration) {\r\n super(config);\r\n this.animationGroup = this.registerDataInput(\"animationGroup\", RichTypeAny);\r\n this.stopAtFrame = this.registerDataInput(\"stopAtFrame\", RichTypeNumber, -1);\r\n }\r\n\r\n public override _preparePendingTasks(context: FlowGraphContext): void {\r\n const animationToStopValue = this.animationGroup.getValue(context);\r\n const stopAtFrame = this.stopAtFrame.getValue(context) ?? -1;\r\n // get the context variable\r\n const pendingStopAnimations = context._getGlobalContextVariable(\r\n \"pendingStopAnimations\",\r\n [] as {\r\n uniqueId: number;\r\n stopAtFrame: number;\r\n }[]\r\n );\r\n // add the animation to the list\r\n pendingStopAnimations.push({ uniqueId: animationToStopValue.uniqueId, stopAtFrame });\r\n // set the global context variable\r\n context._setGlobalContextVariable(\"pendingStopAnimations\", pendingStopAnimations);\r\n }\r\n public override _cancelPendingTasks(context: FlowGraphContext): void {\r\n // remove the animation from the list\r\n const animationToStopValue = this.animationGroup.getValue(context);\r\n const pendingStopAnimations = context._getGlobalContextVariable(\r\n \"pendingStopAnimations\",\r\n [] as {\r\n uniqueId: number;\r\n stopAtFrame: number;\r\n }[]\r\n );\r\n for (let i = 0; i < pendingStopAnimations.length; i++) {\r\n if (pendingStopAnimations[i].uniqueId === animationToStopValue.uniqueId) {\r\n pendingStopAnimations.splice(i, 1);\r\n // set the global context variable\r\n context._setGlobalContextVariable(\"pendingStopAnimations\", pendingStopAnimations);\r\n break;\r\n }\r\n }\r\n }\r\n\r\n public _execute(context: FlowGraphContext): void {\r\n const animationToStopValue = this.animationGroup.getValue(context);\r\n const stopTime = this.stopAtFrame.getValue(context) ?? -1;\r\n // check the values\r\n if (!animationToStopValue) {\r\n Logger.Warn(\"No animation group provided to stop.\");\r\n return this._reportError(context, \"No animation group provided to stop.\");\r\n }\r\n if (isNaN(stopTime)) {\r\n return this._reportError(context, \"Invalid stop time.\");\r\n }\r\n if (stopTime > 0) {\r\n this._startPendingTasks(context);\r\n } else {\r\n this._stopAnimation(animationToStopValue, context);\r\n }\r\n // note that out will not be triggered in case of an error\r\n this.out._activateSignal(context);\r\n }\r\n\r\n public override _executeOnTick(context: FlowGraphContext): void {\r\n const animationToStopValue = this.animationGroup.getValue(context);\r\n // check each frame if any animation should be stopped\r\n const pendingStopAnimations = context._getGlobalContextVariable(\"pendingStopAnimations\", [] as { uniqueId: number; stopAtFrame: number }[]);\r\n for (let i = 0; i < pendingStopAnimations.length; i++) {\r\n // compare the uniqueId to the animation to stop\r\n if (pendingStopAnimations[i].uniqueId === animationToStopValue.uniqueId) {\r\n // check if the current frame is AFTER the stopAtFrame\r\n if (animationToStopValue.getCurrentFrame() >= pendingStopAnimations[i].stopAtFrame) {\r\n // stop the animation\r\n this._stopAnimation(animationToStopValue, context);\r\n // remove the animation from the list\r\n pendingStopAnimations.splice(i, 1);\r\n // set the global context variable\r\n context._setGlobalContextVariable(\"pendingStopAnimations\", pendingStopAnimations);\r\n this.done._activateSignal(context);\r\n context._removePendingBlock(this);\r\n break;\r\n }\r\n }\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.StopAnimation;\r\n }\r\n\r\n private _stopAnimation(animationGroup: AnimationGroup, context: FlowGraphContext): void {\r\n const currentlyRunning = context._getGlobalContextVariable(\"currentlyRunningAnimationGroups\", []) as number[];\r\n const index = currentlyRunning.indexOf(animationGroup.uniqueId);\r\n if (index !== -1) {\r\n animationGroup.stop();\r\n currentlyRunning.splice(index, 1);\r\n // update the global context variable\r\n context._setGlobalContextVariable(\"currentlyRunningAnimationGroups\", currentlyRunning);\r\n } else {\r\n // Logger.Warn(\"Trying to stop an animation that is not running.\");\r\n // no-op for now. Probably no need to log anything here.\r\n }\r\n }\r\n}\r\nRegisterClass(FlowGraphBlockNames.StopAnimation, FlowGraphStopAnimationBlock);\r\n"]}
@@ -12,7 +12,7 @@ export class FlowGraphCancelDelayBlock extends FlowGraphExecutionBlockWithOutSig
12
12
  _execute(context, _callingSignal) {
13
13
  const delayIndex = this.delayIndex.getValue(context);
14
14
  if (delayIndex <= 0 || isNaN(delayIndex) || !isFinite(delayIndex)) {
15
- return this.error._activateSignal(context);
15
+ return this._reportError(context, "Invalid delay index");
16
16
  }
17
17
  const timers = context._getExecutionVariable(this, "pendingDelays", []);
18
18
  const timer = timers[delayIndex];
@@ -1 +1 @@
1
- {"version":3,"file":"flowGraphCancelDelayBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCancelDelayBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,sCAA4B;AAKpD,OAAO,EAAE,oCAAoC,EAAE,MAAM,+CAA+C,CAAC;AACrG,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAI7D;;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,cAAc,CAAC,CAAC;IAC3E,CAAC;IAEM,QAAQ,CAAC,OAAyB,EAAE,cAAyC;QAChF,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QACrD,IAAI,UAAU,IAAI,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;YAChE,OAAO,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QAC/C,CAAC;QACD,MAAM,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,IAAI,EAAE,eAAe,EAAE,EAAqB,CAAC,CAAC;QAC3F,MAAM,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;QACjC,IAAI,KAAK,EAAE,CAAC;YACR,KAAK,CAAC,OAAO,EAAE,CAAC;YAChB,+EAA+E;QACnF,CAAC;QACD,+BAA+B;QAC/B,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;IAEe,YAAY;QACxB,yEAAuC;IAC3C,CAAC;CACJ;AAED,aAAa,oEAAkC,yBAAyB,CAAC,CAAC","sourcesContent":["import { RegisterClass } from \"core/Misc/typeStore\";\nimport type { AdvancedTimer } from \"../../../../Misc/timer\";\nimport type { IFlowGraphBlockConfiguration } from \"../../../flowGraphBlock\";\nimport type { FlowGraphContext } from \"../../../flowGraphContext\";\nimport type { FlowGraphDataConnection } from \"../../../flowGraphDataConnection\";\nimport { FlowGraphExecutionBlockWithOutSignal } from \"../../../flowGraphExecutionBlockWithOutSignal\";\nimport { RichTypeNumber } from \"../../../flowGraphRichTypes\";\nimport type { FlowGraphSignalConnection } from \"../../../flowGraphSignalConnection\";\nimport { FlowGraphBlockNames } from \"../../flowGraphBlockNames\";\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<number>;\n\n constructor(config?: IFlowGraphBlockConfiguration) {\n super(config);\n this.delayIndex = this.registerDataInput(\"delayIndex\", RichTypeNumber);\n }\n\n public _execute(context: FlowGraphContext, _callingSignal: FlowGraphSignalConnection): void {\n const delayIndex = this.delayIndex.getValue(context);\n if (delayIndex <= 0 || isNaN(delayIndex) || !isFinite(delayIndex)) {\n return this.error._activateSignal(context);\n }\n const timers = context._getExecutionVariable(this, \"pendingDelays\", [] as AdvancedTimer[]);\n const timer = timers[delayIndex];\n if (timer) {\n timer.dispose();\n // not removing it from the array. Disposing it will clear all of its resources\n }\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\nRegisterClass(FlowGraphBlockNames.CancelDelay, FlowGraphCancelDelayBlock);\n"]}
1
+ {"version":3,"file":"flowGraphCancelDelayBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCancelDelayBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,sCAA4B;AAKpD,OAAO,EAAE,oCAAoC,EAAE,MAAM,+CAA+C,CAAC;AACrG,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAI7D;;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,cAAc,CAAC,CAAC;IAC3E,CAAC;IAEM,QAAQ,CAAC,OAAyB,EAAE,cAAyC;QAChF,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QACrD,IAAI,UAAU,IAAI,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;YAChE,OAAO,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,qBAAqB,CAAC,CAAC;QAC7D,CAAC;QACD,MAAM,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,IAAI,EAAE,eAAe,EAAE,EAAqB,CAAC,CAAC;QAC3F,MAAM,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;QACjC,IAAI,KAAK,EAAE,CAAC;YACR,KAAK,CAAC,OAAO,EAAE,CAAC;YAChB,+EAA+E;QACnF,CAAC;QACD,+BAA+B;QAC/B,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;IAEe,YAAY;QACxB,yEAAuC;IAC3C,CAAC;CACJ;AAED,aAAa,oEAAkC,yBAAyB,CAAC,CAAC","sourcesContent":["import { RegisterClass } from \"core/Misc/typeStore\";\nimport type { AdvancedTimer } from \"../../../../Misc/timer\";\nimport type { IFlowGraphBlockConfiguration } from \"../../../flowGraphBlock\";\nimport type { FlowGraphContext } from \"../../../flowGraphContext\";\nimport type { FlowGraphDataConnection } from \"../../../flowGraphDataConnection\";\nimport { FlowGraphExecutionBlockWithOutSignal } from \"../../../flowGraphExecutionBlockWithOutSignal\";\nimport { RichTypeNumber } from \"../../../flowGraphRichTypes\";\nimport type { FlowGraphSignalConnection } from \"../../../flowGraphSignalConnection\";\nimport { FlowGraphBlockNames } from \"../../flowGraphBlockNames\";\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<number>;\n\n constructor(config?: IFlowGraphBlockConfiguration) {\n super(config);\n this.delayIndex = this.registerDataInput(\"delayIndex\", RichTypeNumber);\n }\n\n public _execute(context: FlowGraphContext, _callingSignal: FlowGraphSignalConnection): void {\n const delayIndex = 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._getExecutionVariable(this, \"pendingDelays\", [] as AdvancedTimer[]);\n const timer = timers[delayIndex];\n if (timer) {\n timer.dispose();\n // not removing it from the array. Disposing it will clear all of its resources\n }\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\nRegisterClass(FlowGraphBlockNames.CancelDelay, FlowGraphCancelDelayBlock);\n"]}
@@ -16,14 +16,12 @@ export class FlowGraphSetDelayBlock extends FlowGraphAsyncExecutionBlock {
16
16
  _preparePendingTasks(context) {
17
17
  const duration = this.duration.getValue(context);
18
18
  if (duration < 0 || isNaN(duration) || !isFinite(duration)) {
19
- this.error.payload = { message: "Invalid duration" };
20
- return this.error._activateSignal(context);
19
+ return this._reportError(context, "Invalid duration in SetDelay block");
21
20
  }
22
21
  // active delays are global to the context
23
22
  const activeDelays = context._getGlobalContextVariable("activeDelays", 0);
24
23
  if (activeDelays >= FlowGraphSetDelayBlock.MaxParallelDelayCount) {
25
- this.error.payload = { message: "Max parallel delays reached" };
26
- return this.error._activateSignal(context);
24
+ return this._reportError(context, "Max parallel delays reached");
27
25
  }
28
26
  // get the last global delay index
29
27
  const lastDelayIndex = context._getGlobalContextVariable("lastDelayIndex", -1);
@@ -1 +1 @@
1
- {"version":3,"file":"flowGraphSetDelayBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSetDelayBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,uCAAuC,CAAC;AAIrF,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE7D,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEjD,OAAO,EAAE,aAAa,EAAE,sCAA4B;AAEpD;;GAEG;AACH,MAAM,OAAO,sBAAuB,SAAQ,4BAA4B;IAoBpE,YAAY,MAAqC;QAC7C,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,oBAAoB,CAAC,QA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QACtC,CAAC;IACL,CAAC;IAEe,YAAY;QACxB,mEAAoC;IACxC,CAAC;IAEO,QAAQ,CAAC,KAAoB,EAAE,OAAyB;QAC5D,MAAM,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,IAAI,EAAE,eAAe,EAAE,EAAqB,CAAC,CAAC;QAC3F,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACpC,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;YACf,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAC5B,CAAC;aAAM,CAAC;YACJ,MAAM,CAAC,IAAI,CAAC,+EAA+E,CAAC,CAAC;QACjG,CAAC;QACD,OAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;QAClC,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IACvC,CAAC;;AA5FD;;GAEG;AACW,4CAAqB,GAAG,GAAG,CAAC;AA4F9C,aAAa,8DAA+B,sBAAsB,CAAC,CAAC","sourcesContent":["import { FlowGraphAsyncExecutionBlock } from \"../../../flowGraphAsyncExecutionBlock\";\nimport type { IFlowGraphBlockConfiguration } from \"../../../flowGraphBlock\";\nimport type { FlowGraphContext } from \"../../../flowGraphContext\";\nimport type { FlowGraphDataConnection } from \"../../../flowGraphDataConnection\";\nimport { RichTypeNumber } from \"../../../flowGraphRichTypes\";\nimport type { FlowGraphSignalConnection } from \"../../../flowGraphSignalConnection\";\nimport { AdvancedTimer } from \"../../../../Misc/timer\";\nimport { Logger } from \"../../../../Misc/logger\";\nimport { FlowGraphBlockNames } from \"../../flowGraphBlockNames\";\nimport { RegisterClass } from \"core/Misc/typeStore\";\n\n/**\n * Block that sets a delay in seconds before activating the output signal.\n */\nexport class FlowGraphSetDelayBlock extends FlowGraphAsyncExecutionBlock {\n /**\n * The maximum number of parallel delays that can be set per node.\n */\n public static MaxParallelDelayCount = 100;\n /**\n * Input signal: If activated the delayed activations set by this block will be canceled.\n */\n public readonly cancel: FlowGraphSignalConnection;\n\n /**\n * Input connection: The duration of the delay in seconds.\n */\n public readonly duration: FlowGraphDataConnection<number>;\n\n /**\n * Output connection: The last delay index that was set.\n */\n public readonly lastDelayIndex: FlowGraphDataConnection<number>;\n\n constructor(config?: IFlowGraphBlockConfiguration) {\n super(config);\n this.cancel = this._registerSignalInput(\"cancel\");\n this.duration = this.registerDataInput(\"duration\", RichTypeNumber);\n this.lastDelayIndex = this.registerDataOutput(\"lastDelayIndex\", RichTypeNumber, -1);\n }\n\n public _preparePendingTasks(context: FlowGraphContext): void {\n const duration = this.duration.getValue(context);\n if (duration < 0 || isNaN(duration) || !isFinite(duration)) {\n this.error.payload = { message: \"Invalid duration\" };\n return this.error._activateSignal(context);\n }\n\n // active delays are global to the context\n const activeDelays: number = context._getGlobalContextVariable(\"activeDelays\", 0);\n if (activeDelays >= FlowGraphSetDelayBlock.MaxParallelDelayCount) {\n this.error.payload = { message: \"Max parallel delays reached\" };\n return this.error._activateSignal(context);\n }\n // get the last global delay index\n const lastDelayIndex: number = context._getGlobalContextVariable(\"lastDelayIndex\", -1);\n\n // these are block-specific and not global\n const timers = context._getExecutionVariable(this, \"pendingDelays\", [] as AdvancedTimer[]);\n const scene = context.configuration.scene;\n const timer: AdvancedTimer = new AdvancedTimer({\n timeout: duration * 1000, // duration is in seconds\n contextObservable: scene.onBeforeRenderObservable,\n onEnded: () => this._onEnded(timer, context),\n });\n timer.start();\n const newIndex = lastDelayIndex + 1;\n this.lastDelayIndex.setValue(newIndex, context);\n context._setGlobalContextVariable(\"lastDelayIndex\", newIndex);\n\n timers[newIndex] = timer;\n context._setExecutionVariable(this, \"pendingDelays\", timers);\n }\n\n public _cancelPendingTasks(context: FlowGraphContext): void {\n const timers = context._getExecutionVariable(this, \"pendingDelays\", [] as AdvancedTimer[]);\n for (const timer of timers) {\n timer?.dispose();\n }\n context._deleteExecutionVariable(this, \"pendingDelays\");\n this.lastDelayIndex.setValue(-1, context);\n }\n\n public _execute(context: FlowGraphContext, callingSignal: FlowGraphSignalConnection): void {\n if (callingSignal === this.cancel) {\n this._cancelPendingTasks(context);\n return;\n } else {\n this._preparePendingTasks(context);\n this.out._activateSignal(context);\n }\n }\n\n public override getClassName(): string {\n return FlowGraphBlockNames.SetDelay;\n }\n\n private _onEnded(timer: AdvancedTimer, context: FlowGraphContext) {\n const timers = context._getExecutionVariable(this, \"pendingDelays\", [] as AdvancedTimer[]);\n const index = timers.indexOf(timer);\n if (index !== -1) {\n timers.splice(index, 1);\n } else {\n Logger.Warn(\"FlowGraphTimerBlock: Timer ended but was not found in the running timers list\");\n }\n context._removePendingBlock(this);\n this.done._activateSignal(context);\n }\n}\n\nRegisterClass(FlowGraphBlockNames.SetDelay, FlowGraphSetDelayBlock);\n"]}
1
+ {"version":3,"file":"flowGraphSetDelayBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSetDelayBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,uCAAuC,CAAC;AAIrF,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE7D,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEjD,OAAO,EAAE,aAAa,EAAE,sCAA4B;AAEpD;;GAEG;AACH,MAAM,OAAO,sBAAuB,SAAQ,4BAA4B;IAoBpE,YAAY,MAAqC;QAC7C,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC;QAClD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,iBAAiB,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;QACnE,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,kBAAkB,CAAC,gBAAgB,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,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAC5B,CAAC;aAAM,CAAC;YACJ,MAAM,CAAC,IAAI,CAAC,+EAA+E,CAAC,CAAC;QACjG,CAAC;QACD,OAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;QAClC,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IACvC,CAAC;;AA1FD;;GAEG;AACW,4CAAqB,GAAG,GAAG,CAAC;AA0F9C,aAAa,8DAA+B,sBAAsB,CAAC,CAAC","sourcesContent":["import { FlowGraphAsyncExecutionBlock } from \"../../../flowGraphAsyncExecutionBlock\";\nimport type { IFlowGraphBlockConfiguration } from \"../../../flowGraphBlock\";\nimport type { FlowGraphContext } from \"../../../flowGraphContext\";\nimport type { FlowGraphDataConnection } from \"../../../flowGraphDataConnection\";\nimport { RichTypeNumber } from \"../../../flowGraphRichTypes\";\nimport type { FlowGraphSignalConnection } from \"../../../flowGraphSignalConnection\";\nimport { AdvancedTimer } from \"../../../../Misc/timer\";\nimport { Logger } from \"../../../../Misc/logger\";\nimport { FlowGraphBlockNames } from \"../../flowGraphBlockNames\";\nimport { RegisterClass } from \"core/Misc/typeStore\";\n\n/**\n * Block that sets a delay in seconds before activating the output signal.\n */\nexport class FlowGraphSetDelayBlock extends FlowGraphAsyncExecutionBlock {\n /**\n * The maximum number of parallel delays that can be set per node.\n */\n public static MaxParallelDelayCount = 100;\n /**\n * Input signal: If activated the delayed activations set by this block will be canceled.\n */\n public readonly cancel: FlowGraphSignalConnection;\n\n /**\n * Input connection: The duration of the delay in seconds.\n */\n public readonly duration: FlowGraphDataConnection<number>;\n\n /**\n * Output connection: The last delay index that was set.\n */\n public readonly lastDelayIndex: FlowGraphDataConnection<number>;\n\n constructor(config?: IFlowGraphBlockConfiguration) {\n super(config);\n this.cancel = this._registerSignalInput(\"cancel\");\n this.duration = this.registerDataInput(\"duration\", RichTypeNumber);\n this.lastDelayIndex = this.registerDataOutput(\"lastDelayIndex\", RichTypeNumber, -1);\n }\n\n public _preparePendingTasks(context: FlowGraphContext): void {\n const duration = this.duration.getValue(context);\n if (duration < 0 || isNaN(duration) || !isFinite(duration)) {\n return this._reportError(context, \"Invalid duration in SetDelay block\");\n }\n\n // active delays are global to the context\n const activeDelays: number = context._getGlobalContextVariable(\"activeDelays\", 0);\n if (activeDelays >= FlowGraphSetDelayBlock.MaxParallelDelayCount) {\n return this._reportError(context, \"Max parallel delays reached\");\n }\n // get the last global delay index\n const lastDelayIndex: number = context._getGlobalContextVariable(\"lastDelayIndex\", -1);\n\n // these are block-specific and not global\n const timers = context._getExecutionVariable(this, \"pendingDelays\", [] as AdvancedTimer[]);\n const scene = context.configuration.scene;\n const timer: AdvancedTimer = new AdvancedTimer({\n timeout: duration * 1000, // duration is in seconds\n contextObservable: scene.onBeforeRenderObservable,\n onEnded: () => this._onEnded(timer, context),\n });\n timer.start();\n const newIndex = lastDelayIndex + 1;\n this.lastDelayIndex.setValue(newIndex, context);\n context._setGlobalContextVariable(\"lastDelayIndex\", newIndex);\n\n timers[newIndex] = timer;\n context._setExecutionVariable(this, \"pendingDelays\", timers);\n }\n\n public _cancelPendingTasks(context: FlowGraphContext): void {\n const timers = context._getExecutionVariable(this, \"pendingDelays\", [] as AdvancedTimer[]);\n for (const timer of timers) {\n timer?.dispose();\n }\n context._deleteExecutionVariable(this, \"pendingDelays\");\n this.lastDelayIndex.setValue(-1, context);\n }\n\n public _execute(context: FlowGraphContext, callingSignal: FlowGraphSignalConnection): void {\n if (callingSignal === this.cancel) {\n this._cancelPendingTasks(context);\n return;\n } else {\n this._preparePendingTasks(context);\n this.out._activateSignal(context);\n }\n }\n\n public override getClassName(): string {\n return FlowGraphBlockNames.SetDelay;\n }\n\n private _onEnded(timer: AdvancedTimer, context: FlowGraphContext) {\n const timers = context._getExecutionVariable(this, \"pendingDelays\", [] as AdvancedTimer[]);\n const index = timers.indexOf(timer);\n if (index !== -1) {\n timers.splice(index, 1);\n } else {\n Logger.Warn(\"FlowGraphTimerBlock: Timer ended but was not found in the running timers list\");\n }\n context._removePendingBlock(this);\n this.done._activateSignal(context);\n }\n}\n\nRegisterClass(FlowGraphBlockNames.SetDelay, FlowGraphSetDelayBlock);\n"]}
@@ -21,7 +21,7 @@ export class FlowGraphThrottleBlock extends FlowGraphExecutionBlockWithOutSignal
21
21
  // in seconds
22
22
  const durationValue = this.duration.getValue(context);
23
23
  if (durationValue <= 0 || isNaN(durationValue) || !isFinite(durationValue)) {
24
- return this.error._activateSignal(context);
24
+ return this._reportError(context, "Invalid duration in Throttle block");
25
25
  }
26
26
  const lastRemainingTime = context._getExecutionVariable(this, "lastRemainingTime", NaN);
27
27
  // Using Date.now() to get ms since epoch. not using performance.now() because its precision is not needed here
@@ -1 +1 @@
1
- {"version":3,"file":"flowGraphThrottleBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE7D,OAAO,EAAE,oCAAoC,EAAE,MAAM,+CAA+C,CAAC;AAErG,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D;;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,CAA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D,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;AACD,aAAa,8DAA+B,sBAAsB,CAAC,CAAC","sourcesContent":["import type { FlowGraphContext } from \"../../../flowGraphContext\";\r\nimport type { FlowGraphDataConnection } from \"../../../flowGraphDataConnection\";\r\nimport { RichTypeNumber } from \"../../../flowGraphRichTypes\";\r\nimport type { FlowGraphSignalConnection } from \"../../../flowGraphSignalConnection\";\r\nimport { FlowGraphExecutionBlockWithOutSignal } from \"../../../flowGraphExecutionBlockWithOutSignal\";\r\nimport type { IFlowGraphBlockConfiguration } from \"../../../flowGraphBlock\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { FlowGraphBlockNames } from \"../../flowGraphBlockNames\";\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.error._activateSignal(context);\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\nRegisterClass(FlowGraphBlockNames.Throttle, FlowGraphThrottleBlock);\r\n"]}
1
+ {"version":3,"file":"flowGraphThrottleBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE7D,OAAO,EAAE,oCAAoC,EAAE,MAAM,+CAA+C,CAAC;AAErG,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D;;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,mBAAmB,EAAE,GAAG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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;AACD,aAAa,8DAA+B,sBAAsB,CAAC,CAAC","sourcesContent":["import type { FlowGraphContext } from \"../../../flowGraphContext\";\r\nimport type { FlowGraphDataConnection } from \"../../../flowGraphDataConnection\";\r\nimport { RichTypeNumber } from \"../../../flowGraphRichTypes\";\r\nimport type { FlowGraphSignalConnection } from \"../../../flowGraphSignalConnection\";\r\nimport { FlowGraphExecutionBlockWithOutSignal } from \"../../../flowGraphExecutionBlockWithOutSignal\";\r\nimport type { IFlowGraphBlockConfiguration } from \"../../../flowGraphBlock\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { FlowGraphBlockNames } from \"../../flowGraphBlockNames\";\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\nRegisterClass(FlowGraphBlockNames.Throttle, FlowGraphThrottleBlock);\r\n"]}
@@ -37,8 +37,7 @@ export class FlowGraphSetPropertyBlock extends FlowGraphExecutionBlockWithOutSig
37
37
  }
38
38
  }
39
39
  catch (e) {
40
- this.error.payload = e;
41
- this.error._activateSignal(context);
40
+ this._reportError(context, e);
42
41
  }
43
42
  this.out._activateSignal(context);
44
43
  }
@@ -1 +1 @@
1
- {"version":3,"file":"flowGraphSetPropertyBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oCAAoC,EAAE,sDAA4D;AAC3G,OAAO,EAAE,WAAW,EAAE,oCAA0C;AAEhE,OAAO,EAAE,aAAa,EAAE,mCAA4B;AAepD;;;;;;;;;GASG;AACH,MAAM,OAAO,yBAAuE,SAAQ,oCAAoC;IAsB5H;IACI;;OAEG;IACa,MAAkD;QAElE,KAAK,CAAC,MAAM,CAAC,CAAC;QAFE,WAAM,GAAN,MAAM,CAA4C;QAGlE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,iBAAiB,CAAC,QAAQ,EAAE,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;QAC3E,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;QAC1D,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,iBAAiB,CAAC,cAAc,EAAE,WAAW,EAAE,MAAM,CAAC,YAAY,CAAC,CAAC;QAC7F,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,iBAAiB,CAAC,mBAAmB,EAAE,WAAW,CAAC,CAAC;IACtF,CAAC;IACe,QAAQ,CAAC,OAAyB,EAAE,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G,EAAE,CAAC;YACnB,CAAC;YACD,GAAG,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC;QACpB,CAAC;QACD,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;IACvC,CAAC;IAEe,YAAY;QACxB,yEAAuC;IAC3C,CAAC;CACJ;AAED,aAAa,oEAAkC,yBAAyB,CAAC,CAAC","sourcesContent":["import type { AssetType, FlowGraphAssetType } from \"core/FlowGraph/flowGraphAssetsContext\";\nimport type { FlowGraphContext } from \"core/FlowGraph/flowGraphContext\";\nimport type { FlowGraphDataConnection } from \"core/FlowGraph/flowGraphDataConnection\";\nimport { FlowGraphExecutionBlockWithOutSignal } from \"core/FlowGraph/flowGraphExecutionBlockWithOutSignal\";\nimport { RichTypeAny } from \"core/FlowGraph/flowGraphRichTypes\";\nimport type { FlowGraphSignalConnection } from \"core/FlowGraph/flowGraphSignalConnection\";\nimport { RegisterClass } from \"core/Misc/typeStore\";\nimport { FlowGraphBlockNames } from \"../flowGraphBlockNames\";\n\nexport interface IFlowGraphSetPropertyBlockConfiguration<O extends FlowGraphAssetType> {\n /**\n * The name of the property that will be set\n */\n propertyName?: string;\n\n /**\n * The target asset from which the property will be retrieved\n */\n target?: AssetType<O>;\n}\n\n/**\n * This block will set a property on a given target asset.\n * The property name can include dots (\".\"), which will be interpreted as a path to the property.\n * The target asset is an input and can be changed at any time.\n * The value of the property is an input and can be changed at any time.\n *\n * For example, with an input of a mesh asset, the property name \"position.x\" will set the x component of the position of the mesh.\n *\n * Note that it is recommended to input the object on which you are working on (i.e. a material) than providing a mesh and then getting the material from it.\n */\nexport class FlowGraphSetPropertyBlock<P extends any, O extends FlowGraphAssetType> extends FlowGraphExecutionBlockWithOutSignal {\n /**\n * Input connection: The value to set on the property.\n */\n public readonly value: FlowGraphDataConnection<P>;\n\n /**\n * Input connection: The target asset from which the property will be retrieved\n */\n public readonly object: FlowGraphDataConnection<AssetType<O>>;\n\n /**\n * Input connection: The name of the property that will be set\n */\n public readonly propertyName: FlowGraphDataConnection<string>;\n\n /**\n * Input connection: A function that can be used to set the value of the property.\n * If set it will be used instead of the default set function.\n */\n public readonly customSetFunction: FlowGraphDataConnection<(target: AssetType<O>, propertyName: string, value: P, context: FlowGraphContext) => void>;\n\n constructor(\n /**\n * the configuration of the block\n */\n public override config: IFlowGraphSetPropertyBlockConfiguration<O>\n ) {\n super(config);\n this.object = this.registerDataInput(\"object\", RichTypeAny, config.target);\n this.value = this.registerDataInput(\"value\", RichTypeAny);\n this.propertyName = this.registerDataInput(\"propertyName\", RichTypeAny, config.propertyName);\n this.customSetFunction = this.registerDataInput(\"customSetFunction\", RichTypeAny);\n }\n public override _execute(context: FlowGraphContext, _callingSignal: FlowGraphSignalConnection): void {\n try {\n const target = this.object.getValue(context);\n const value = this.value.getValue(context);\n\n const setFunction = this.customSetFunction.getValue(context);\n if (setFunction) {\n setFunction(target, this.propertyName.getValue(context), value, context);\n } else {\n this._setPropertyValue(target, this.propertyName.getValue(context), value);\n }\n } catch (e) {\n this.error.payload = e;\n this.error._activateSignal(context);\n }\n this.out._activateSignal(context);\n }\n\n private _setPropertyValue(target: AssetType<O>, propertyName: string, value: P): void {\n const path = propertyName.split(\".\");\n let obj = target as any;\n for (let i = 0; i < path.length - 1; i++) {\n const prop = path[i];\n if (obj[prop] === undefined) {\n obj[prop] = {};\n }\n obj = obj[prop];\n }\n obj[path[path.length - 1]] = value;\n }\n\n public override getClassName(): string {\n return FlowGraphBlockNames.SetProperty;\n }\n}\n\nRegisterClass(FlowGraphBlockNames.SetProperty, FlowGraphSetPropertyBlock);\n"]}
1
+ {"version":3,"file":"flowGraphSetPropertyBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oCAAoC,EAAE,sDAA4D;AAC3G,OAAO,EAAE,WAAW,EAAE,oCAA0C;A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QAAC,OAAO,CAAC,EAAE,CAAC;YACT,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QAClC,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;IAEO,iBAAiB,CAAC,MAAoB,EAAE,YAAoB,EAAE,KAAQ;QAC1E,MAAM,IAAI,GAAG,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACrC,IAAI,GAAG,GAAG,MAAa,CAAC;QACxB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YACvC,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;YACrB,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;gBAC1B,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;YACnB,CAAC;YACD,GAAG,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC;QACpB,CAAC;QACD,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;IACvC,CAAC;IAEe,YAAY;QACxB,yEAAuC;IAC3C,CAAC;CACJ;AAED,aAAa,oEAAkC,yBAAyB,CAAC,CAAC","sourcesContent":["import type { AssetType, FlowGraphAssetType } from \"core/FlowGraph/flowGraphAssetsContext\";\nimport type { FlowGraphContext } from \"core/FlowGraph/flowGraphContext\";\nimport type { FlowGraphDataConnection } from \"core/FlowGraph/flowGraphDataConnection\";\nimport { FlowGraphExecutionBlockWithOutSignal } from \"core/FlowGraph/flowGraphExecutionBlockWithOutSignal\";\nimport { RichTypeAny } from \"core/FlowGraph/flowGraphRichTypes\";\nimport type { FlowGraphSignalConnection } from \"core/FlowGraph/flowGraphSignalConnection\";\nimport { RegisterClass } from \"core/Misc/typeStore\";\nimport { FlowGraphBlockNames } from \"../flowGraphBlockNames\";\n\nexport interface IFlowGraphSetPropertyBlockConfiguration<O extends FlowGraphAssetType> {\n /**\n * The name of the property that will be set\n */\n propertyName?: string;\n\n /**\n * The target asset from which the property will be retrieved\n */\n target?: AssetType<O>;\n}\n\n/**\n * This block will set a property on a given target asset.\n * The property name can include dots (\".\"), which will be interpreted as a path to the property.\n * The target asset is an input and can be changed at any time.\n * The value of the property is an input and can be changed at any time.\n *\n * For example, with an input of a mesh asset, the property name \"position.x\" will set the x component of the position of the mesh.\n *\n * Note that it is recommended to input the object on which you are working on (i.e. a material) than providing a mesh and then getting the material from it.\n */\nexport class FlowGraphSetPropertyBlock<P extends any, O extends FlowGraphAssetType> extends FlowGraphExecutionBlockWithOutSignal {\n /**\n * Input connection: The value to set on the property.\n */\n public readonly value: FlowGraphDataConnection<P>;\n\n /**\n * Input connection: The target asset from which the property will be retrieved\n */\n public readonly object: FlowGraphDataConnection<AssetType<O>>;\n\n /**\n * Input connection: The name of the property that will be set\n */\n public readonly propertyName: FlowGraphDataConnection<string>;\n\n /**\n * Input connection: A function that can be used to set the value of the property.\n * If set it will be used instead of the default set function.\n */\n public readonly customSetFunction: FlowGraphDataConnection<(target: AssetType<O>, propertyName: string, value: P, context: FlowGraphContext) => void>;\n\n constructor(\n /**\n * the configuration of the block\n */\n public override config: IFlowGraphSetPropertyBlockConfiguration<O>\n ) {\n super(config);\n this.object = this.registerDataInput(\"object\", RichTypeAny, config.target);\n this.value = this.registerDataInput(\"value\", RichTypeAny);\n this.propertyName = this.registerDataInput(\"propertyName\", RichTypeAny, config.propertyName);\n this.customSetFunction = this.registerDataInput(\"customSetFunction\", RichTypeAny);\n }\n public override _execute(context: FlowGraphContext, _callingSignal: FlowGraphSignalConnection): void {\n try {\n const target = this.object.getValue(context);\n const value = this.value.getValue(context);\n\n const setFunction = this.customSetFunction.getValue(context);\n if (setFunction) {\n setFunction(target, this.propertyName.getValue(context), value, context);\n } else {\n this._setPropertyValue(target, this.propertyName.getValue(context), value);\n }\n } catch (e) {\n this._reportError(context, e);\n }\n this.out._activateSignal(context);\n }\n\n private _setPropertyValue(target: AssetType<O>, propertyName: string, value: P): void {\n const path = propertyName.split(\".\");\n let obj = target as any;\n for (let i = 0; i < path.length - 1; i++) {\n const prop = path[i];\n if (obj[prop] === undefined) {\n obj[prop] = {};\n }\n obj = obj[prop];\n }\n obj[path[path.length - 1]] = value;\n }\n\n public override getClassName(): string {\n return FlowGraphBlockNames.SetProperty;\n }\n}\n\nRegisterClass(FlowGraphBlockNames.SetProperty, FlowGraphSetPropertyBlock);\n"]}
@@ -281,6 +281,8 @@ export function blockFactory(blockName) {
281
281
  return async () => (await import("./Data/Utils/flowGraphIndexOfBlock.js")).FlowGraphIndexOfBlock;
282
282
  case "FlowGraphFunctionReference" /* FlowGraphBlockNames.FunctionReference */:
283
283
  return async () => (await import("./Data/Utils/flowGraphFunctionReferenceBlock.js")).FlowGraphFunctionReferenceBlock;
284
+ case "FlowGraphDataSwitchBlock" /* FlowGraphBlockNames.DataSwitch */:
285
+ return async () => (await import("./Data/flowGraphDataSwitchBlock.js")).FlowGraphDataSwitchBlock;
284
286
  default:
285
287
  // check if the block is a custom block
286
288
  if (customBlocks[blockName]) {