@babylonjs/core 7.51.1 → 7.51.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (313) hide show
  1. package/Animations/animation.js +2 -1
  2. package/Animations/animation.js.map +1 -1
  3. package/Buffers/bufferUtils.d.ts +7 -5
  4. package/Buffers/bufferUtils.js +13 -9
  5. package/Buffers/bufferUtils.js.map +1 -1
  6. package/Engines/abstractEngine.js +2 -2
  7. package/Engines/abstractEngine.js.map +1 -1
  8. package/Engines/constants.d.ts +32 -0
  9. package/Engines/constants.js +33 -0
  10. package/Engines/constants.js.map +1 -1
  11. package/Engines/webgpuEngine.js +6 -3
  12. package/Engines/webgpuEngine.js.map +1 -1
  13. package/FlowGraph/Blocks/Data/Math/flowGraphMathBlocks.d.ts +148 -465
  14. package/FlowGraph/Blocks/Data/Math/flowGraphMathBlocks.js +394 -691
  15. package/FlowGraph/Blocks/Data/Math/flowGraphMathBlocks.js.map +1 -1
  16. package/FlowGraph/Blocks/Data/Math/flowGraphMathCombineExtractBlocks.d.ts +142 -0
  17. package/FlowGraph/Blocks/Data/Math/flowGraphMathCombineExtractBlocks.js +342 -0
  18. package/FlowGraph/Blocks/Data/Math/flowGraphMathCombineExtractBlocks.js.map +1 -0
  19. package/FlowGraph/Blocks/Data/Math/flowGraphMatrixMathBlocks.d.ts +107 -0
  20. package/FlowGraph/Blocks/Data/Math/flowGraphMatrixMathBlocks.js +130 -0
  21. package/FlowGraph/Blocks/Data/Math/flowGraphMatrixMathBlocks.js.map +1 -0
  22. package/FlowGraph/Blocks/Data/Math/flowGraphVectorMathBlocks.d.ts +77 -0
  23. package/FlowGraph/Blocks/Data/Math/flowGraphVectorMathBlocks.js +139 -0
  24. package/FlowGraph/Blocks/Data/Math/flowGraphVectorMathBlocks.js.map +1 -0
  25. package/FlowGraph/Blocks/Data/Math/index.d.ts +3 -0
  26. package/FlowGraph/Blocks/Data/Math/index.js +3 -0
  27. package/FlowGraph/Blocks/Data/Math/index.js.map +1 -1
  28. package/FlowGraph/Blocks/Data/Transformers/flowGraphJsonPointerParserBlock.d.ts +85 -0
  29. package/FlowGraph/Blocks/Data/Transformers/flowGraphJsonPointerParserBlock.js +133 -0
  30. package/FlowGraph/Blocks/Data/Transformers/flowGraphJsonPointerParserBlock.js.map +1 -0
  31. package/FlowGraph/Blocks/Data/Transformers/flowGraphTypeToTypeBlocks.d.ts +49 -0
  32. package/FlowGraph/Blocks/Data/Transformers/flowGraphTypeToTypeBlocks.js +71 -0
  33. package/FlowGraph/Blocks/Data/Transformers/flowGraphTypeToTypeBlocks.js.map +1 -0
  34. package/FlowGraph/Blocks/Data/Transformers/index.d.ts +2 -0
  35. package/FlowGraph/Blocks/Data/Transformers/index.js +3 -0
  36. package/FlowGraph/Blocks/Data/Transformers/index.js.map +1 -0
  37. package/FlowGraph/Blocks/Data/Utils/flowGraphArrayIndexBlock.d.ts +39 -0
  38. package/FlowGraph/Blocks/Data/Utils/flowGraphArrayIndexBlock.js +46 -0
  39. package/FlowGraph/Blocks/Data/Utils/flowGraphArrayIndexBlock.js.map +1 -0
  40. package/FlowGraph/Blocks/Data/Utils/flowGraphCodeExecutionBlock.d.ts +35 -0
  41. package/FlowGraph/Blocks/Data/Utils/flowGraphCodeExecutionBlock.js +34 -0
  42. package/FlowGraph/Blocks/Data/Utils/flowGraphCodeExecutionBlock.js.map +1 -0
  43. package/FlowGraph/Blocks/Data/Utils/flowGraphContextBlock.d.ts +20 -0
  44. package/FlowGraph/Blocks/Data/Utils/flowGraphContextBlock.js +25 -0
  45. package/FlowGraph/Blocks/Data/Utils/flowGraphContextBlock.js.map +1 -0
  46. package/FlowGraph/Blocks/Data/Utils/flowGraphFunctionReferenceBlock.d.ts +34 -0
  47. package/FlowGraph/Blocks/Data/Utils/flowGraphFunctionReferenceBlock.js +35 -0
  48. package/FlowGraph/Blocks/Data/Utils/flowGraphFunctionReferenceBlock.js.map +1 -0
  49. package/FlowGraph/Blocks/Data/Utils/flowGraphIndexOfBlock.d.ts +39 -0
  50. package/FlowGraph/Blocks/Data/Utils/flowGraphIndexOfBlock.js +42 -0
  51. package/FlowGraph/Blocks/Data/Utils/flowGraphIndexOfBlock.js.map +1 -0
  52. package/FlowGraph/Blocks/Data/Utils/index.d.ts +5 -0
  53. package/FlowGraph/Blocks/Data/Utils/index.js +6 -0
  54. package/FlowGraph/Blocks/Data/Utils/index.js.map +1 -0
  55. package/FlowGraph/Blocks/Data/flowGraphBinaryOperationBlock.d.ts +0 -1
  56. package/FlowGraph/Blocks/Data/flowGraphBinaryOperationBlock.js +3 -2
  57. package/FlowGraph/Blocks/Data/flowGraphBinaryOperationBlock.js.map +1 -1
  58. package/FlowGraph/Blocks/Data/flowGraphCachedOperationBlock.d.ts +1 -1
  59. package/FlowGraph/Blocks/Data/flowGraphCachedOperationBlock.js +4 -4
  60. package/FlowGraph/Blocks/Data/flowGraphCachedOperationBlock.js.map +1 -1
  61. package/FlowGraph/Blocks/Data/flowGraphConditionalDataBlock.d.ts +6 -3
  62. package/FlowGraph/Blocks/Data/flowGraphConditionalDataBlock.js +12 -6
  63. package/FlowGraph/Blocks/Data/flowGraphConditionalDataBlock.js.map +1 -1
  64. package/FlowGraph/Blocks/Data/flowGraphConstantBlock.d.ts +0 -2
  65. package/FlowGraph/Blocks/Data/flowGraphConstantBlock.js +2 -3
  66. package/FlowGraph/Blocks/Data/flowGraphConstantBlock.js.map +1 -1
  67. package/FlowGraph/Blocks/Data/flowGraphConstantOperationBlock.d.ts +5 -4
  68. package/FlowGraph/Blocks/Data/flowGraphConstantOperationBlock.js +5 -4
  69. package/FlowGraph/Blocks/Data/flowGraphConstantOperationBlock.js.map +1 -1
  70. package/FlowGraph/Blocks/Data/flowGraphGetAssetBlock.d.ts +62 -0
  71. package/FlowGraph/Blocks/Data/flowGraphGetAssetBlock.js +41 -0
  72. package/FlowGraph/Blocks/Data/flowGraphGetAssetBlock.js.map +1 -0
  73. package/FlowGraph/Blocks/Data/flowGraphGetPropertyBlock.d.ts +38 -33
  74. package/FlowGraph/Blocks/Data/flowGraphGetPropertyBlock.js +42 -25
  75. package/FlowGraph/Blocks/Data/flowGraphGetPropertyBlock.js.map +1 -1
  76. package/FlowGraph/Blocks/Data/flowGraphGetVariableBlock.d.ts +11 -16
  77. package/FlowGraph/Blocks/Data/flowGraphGetVariableBlock.js +9 -17
  78. package/FlowGraph/Blocks/Data/flowGraphGetVariableBlock.js.map +1 -1
  79. package/FlowGraph/Blocks/Data/flowGraphTernaryOperationBlock.d.ts +1 -1
  80. package/FlowGraph/Blocks/Data/flowGraphTernaryOperationBlock.js +1 -1
  81. package/FlowGraph/Blocks/Data/flowGraphTernaryOperationBlock.js.map +1 -1
  82. package/FlowGraph/Blocks/Data/{flowGraphCoordinateTransformBlock.d.ts → flowGraphTransformCoordinatesSystemBlock.d.ts} +1 -2
  83. package/FlowGraph/Blocks/Data/{flowGraphCoordinateTransformBlock.js → flowGraphTransformCoordinatesSystemBlock.js} +4 -5
  84. package/FlowGraph/Blocks/Data/flowGraphTransformCoordinatesSystemBlock.js.map +1 -0
  85. package/FlowGraph/Blocks/Data/flowGraphUnaryOperationBlock.d.ts +1 -1
  86. package/FlowGraph/Blocks/Data/flowGraphUnaryOperationBlock.js +1 -1
  87. package/FlowGraph/Blocks/Data/flowGraphUnaryOperationBlock.js.map +1 -1
  88. package/FlowGraph/Blocks/Data/index.d.ts +7 -3
  89. package/FlowGraph/Blocks/Data/index.js +9 -4
  90. package/FlowGraph/Blocks/Data/index.js.map +1 -1
  91. package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.d.ts +45 -24
  92. package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.js +45 -51
  93. package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.js.map +1 -1
  94. package/FlowGraph/Blocks/Event/flowGraphPointerOutEventBlock.d.ts +61 -0
  95. package/FlowGraph/Blocks/Event/flowGraphPointerOutEventBlock.js +39 -0
  96. package/FlowGraph/Blocks/Event/flowGraphPointerOutEventBlock.js.map +1 -0
  97. package/FlowGraph/Blocks/Event/flowGraphPointerOverEventBlock.d.ts +61 -0
  98. package/FlowGraph/Blocks/Event/flowGraphPointerOverEventBlock.js +40 -0
  99. package/FlowGraph/Blocks/Event/flowGraphPointerOverEventBlock.js.map +1 -0
  100. package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.d.ts +12 -14
  101. package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js +19 -26
  102. package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js.map +1 -1
  103. package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.d.ts +6 -12
  104. package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.js +13 -24
  105. package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.js.map +1 -1
  106. package/FlowGraph/Blocks/Event/flowGraphSceneTickEventBlock.d.ts +31 -7
  107. package/FlowGraph/Blocks/Event/flowGraphSceneTickEventBlock.js +22 -20
  108. package/FlowGraph/Blocks/Event/flowGraphSceneTickEventBlock.js.map +1 -1
  109. package/FlowGraph/Blocks/{Execution → Event}/flowGraphSendCustomEventBlock.d.ts +12 -7
  110. package/FlowGraph/Blocks/Event/flowGraphSendCustomEventBlock.js +39 -0
  111. package/FlowGraph/Blocks/Event/flowGraphSendCustomEventBlock.js.map +1 -0
  112. package/FlowGraph/Blocks/Event/index.d.ts +3 -0
  113. package/FlowGraph/Blocks/Event/index.js +3 -0
  114. package/FlowGraph/Blocks/Event/index.js.map +1 -1
  115. package/FlowGraph/Blocks/Execution/Animation/flowGraphBezierCurveEasingBlock.d.ts +44 -0
  116. package/FlowGraph/Blocks/Execution/Animation/flowGraphBezierCurveEasingBlock.js +46 -0
  117. package/FlowGraph/Blocks/Execution/Animation/flowGraphBezierCurveEasingBlock.js.map +1 -0
  118. package/FlowGraph/Blocks/Execution/Animation/flowGraphEasingBlock.d.ts +60 -0
  119. package/FlowGraph/Blocks/Execution/Animation/flowGraphEasingBlock.js +93 -0
  120. package/FlowGraph/Blocks/Execution/Animation/flowGraphEasingBlock.js.map +1 -0
  121. package/FlowGraph/Blocks/Execution/Animation/flowGraphInterpolationBlock.d.ts +82 -0
  122. package/FlowGraph/Blocks/Execution/Animation/flowGraphInterpolationBlock.js +105 -0
  123. package/FlowGraph/Blocks/Execution/Animation/flowGraphInterpolationBlock.js.map +1 -0
  124. package/FlowGraph/Blocks/Execution/Animation/flowGraphPauseAnimationBlock.d.ts +2 -2
  125. package/FlowGraph/Blocks/Execution/Animation/flowGraphPauseAnimationBlock.js +2 -2
  126. package/FlowGraph/Blocks/Execution/Animation/flowGraphPauseAnimationBlock.js.map +1 -1
  127. package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.d.ts +40 -42
  128. package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js +116 -50
  129. package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js.map +1 -1
  130. package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.d.ts +12 -4
  131. package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.js +86 -8
  132. package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.js.map +1 -1
  133. package/FlowGraph/Blocks/Execution/Animation/index.d.ts +3 -0
  134. package/FlowGraph/Blocks/Execution/Animation/index.js +3 -0
  135. package/FlowGraph/Blocks/Execution/Animation/index.js.map +1 -1
  136. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphBranchBlock.d.ts +1 -2
  137. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphBranchBlock.js +3 -4
  138. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphBranchBlock.js.map +1 -1
  139. package/FlowGraph/Blocks/Execution/{Audio/flowGraphStopAudioBlock.d.ts → ControlFlow/flowGraphCancelDelayBlock.d.ts} +6 -8
  140. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCancelDelayBlock.js +31 -0
  141. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCancelDelayBlock.js.map +1 -0
  142. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCounterBlock.d.ts +2 -2
  143. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCounterBlock.js +5 -5
  144. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCounterBlock.js.map +1 -1
  145. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDebounceBlock.d.ts +0 -1
  146. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDebounceBlock.js +2 -3
  147. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDebounceBlock.js.map +1 -1
  148. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock.d.ts +5 -10
  149. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock.js +11 -15
  150. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock.js.map +1 -1
  151. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphFlipFlopBlock.d.ts +11 -3
  152. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphFlipFlopBlock.js +5 -6
  153. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphFlipFlopBlock.js.map +1 -1
  154. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphForLoopBlock.d.ts +27 -7
  155. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphForLoopBlock.js +28 -30
  156. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphForLoopBlock.js.map +1 -1
  157. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphMultiGateBlock.d.ts +13 -16
  158. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphMultiGateBlock.js +50 -52
  159. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphMultiGateBlock.js.map +1 -1
  160. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSequenceBlock.d.ts +8 -9
  161. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSequenceBlock.js +26 -13
  162. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSequenceBlock.js.map +1 -1
  163. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSetDelayBlock.d.ts +32 -0
  164. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSetDelayBlock.js +84 -0
  165. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSetDelayBlock.js.map +1 -0
  166. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSwitchBlock.d.ts +20 -6
  167. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSwitchBlock.js +55 -16
  168. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSwitchBlock.js.map +1 -1
  169. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.d.ts +3 -4
  170. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.js +36 -13
  171. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.js.map +1 -1
  172. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWaitAllBlock.d.ts +13 -5
  173. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWaitAllBlock.js +22 -17
  174. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWaitAllBlock.js.map +1 -1
  175. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock.d.ts +12 -16
  176. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock.js +21 -21
  177. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock.js.map +1 -1
  178. package/FlowGraph/Blocks/Execution/ControlFlow/index.d.ts +2 -1
  179. package/FlowGraph/Blocks/Execution/ControlFlow/index.js +2 -1
  180. package/FlowGraph/Blocks/Execution/ControlFlow/index.js.map +1 -1
  181. package/FlowGraph/Blocks/Execution/flowGraphConsoleLogBlock.d.ts +4 -5
  182. package/FlowGraph/Blocks/Execution/flowGraphConsoleLogBlock.js +13 -8
  183. package/FlowGraph/Blocks/Execution/flowGraphConsoleLogBlock.js.map +1 -1
  184. package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.d.ts +33 -36
  185. package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js +42 -26
  186. package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js.map +1 -1
  187. package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.d.ts +10 -25
  188. package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.js +38 -24
  189. package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.js.map +1 -1
  190. package/FlowGraph/Blocks/Execution/index.d.ts +0 -3
  191. package/FlowGraph/Blocks/Execution/index.js +0 -3
  192. package/FlowGraph/Blocks/Execution/index.js.map +1 -1
  193. package/FlowGraph/Blocks/flowGraphBlockFactory.d.ts +16 -0
  194. package/FlowGraph/Blocks/flowGraphBlockFactory.js +292 -0
  195. package/FlowGraph/Blocks/flowGraphBlockFactory.js.map +1 -0
  196. package/FlowGraph/Blocks/flowGraphBlockNames.d.ts +145 -0
  197. package/FlowGraph/Blocks/flowGraphBlockNames.js +147 -0
  198. package/FlowGraph/Blocks/flowGraphBlockNames.js.map +1 -0
  199. package/FlowGraph/Blocks/index.d.ts +2 -0
  200. package/FlowGraph/Blocks/index.js +2 -0
  201. package/FlowGraph/Blocks/index.js.map +1 -1
  202. package/FlowGraph/{flowGraphInteger.d.ts → CustomTypes/flowGraphInteger.d.ts} +2 -3
  203. package/FlowGraph/{flowGraphInteger.js → CustomTypes/flowGraphInteger.js} +4 -5
  204. package/FlowGraph/CustomTypes/flowGraphInteger.js.map +1 -0
  205. package/FlowGraph/CustomTypes/flowGraphMatrix.d.ts +196 -0
  206. package/FlowGraph/CustomTypes/flowGraphMatrix.js +272 -0
  207. package/FlowGraph/CustomTypes/flowGraphMatrix.js.map +1 -0
  208. package/FlowGraph/CustomTypes/index.d.ts +2 -0
  209. package/FlowGraph/CustomTypes/index.js +3 -0
  210. package/FlowGraph/CustomTypes/index.js.map +1 -0
  211. package/FlowGraph/flowGraph.d.ts +29 -34
  212. package/FlowGraph/flowGraph.js +120 -104
  213. package/FlowGraph/flowGraph.js.map +1 -1
  214. package/FlowGraph/flowGraphAssetsContext.d.ts +29 -0
  215. package/FlowGraph/flowGraphAssetsContext.js +52 -0
  216. package/FlowGraph/flowGraphAssetsContext.js.map +1 -0
  217. package/FlowGraph/flowGraphAsyncExecutionBlock.d.ts +15 -8
  218. package/FlowGraph/flowGraphAsyncExecutionBlock.js +25 -5
  219. package/FlowGraph/flowGraphAsyncExecutionBlock.js.map +1 -1
  220. package/FlowGraph/flowGraphBlock.d.ts +22 -15
  221. package/FlowGraph/flowGraphBlock.js +31 -52
  222. package/FlowGraph/flowGraphBlock.js.map +1 -1
  223. package/FlowGraph/flowGraphConnection.d.ts +13 -12
  224. package/FlowGraph/flowGraphConnection.js +31 -16
  225. package/FlowGraph/flowGraphConnection.js.map +1 -1
  226. package/FlowGraph/flowGraphContext.d.ts +89 -13
  227. package/FlowGraph/flowGraphContext.js +210 -23
  228. package/FlowGraph/flowGraphContext.js.map +1 -1
  229. package/FlowGraph/flowGraphCoordinator.d.ts +4 -10
  230. package/FlowGraph/flowGraphCoordinator.js +4 -16
  231. package/FlowGraph/flowGraphCoordinator.js.map +1 -1
  232. package/FlowGraph/flowGraphDataConnection.d.ts +52 -14
  233. package/FlowGraph/flowGraphDataConnection.js +73 -26
  234. package/FlowGraph/flowGraphDataConnection.js.map +1 -1
  235. package/FlowGraph/flowGraphEventBlock.d.ts +17 -1
  236. package/FlowGraph/flowGraphEventBlock.js +13 -2
  237. package/FlowGraph/flowGraphEventBlock.js.map +1 -1
  238. package/FlowGraph/flowGraphEventType.d.ts +16 -0
  239. package/FlowGraph/flowGraphEventType.js +18 -0
  240. package/FlowGraph/flowGraphEventType.js.map +1 -0
  241. package/FlowGraph/flowGraphExecutionBlock.d.ts +11 -1
  242. package/FlowGraph/flowGraphExecutionBlock.js +21 -2
  243. package/FlowGraph/flowGraphExecutionBlock.js.map +1 -1
  244. package/FlowGraph/flowGraphExecutionBlockWithOutSignal.d.ts +2 -2
  245. package/FlowGraph/flowGraphExecutionBlockWithOutSignal.js +0 -1
  246. package/FlowGraph/flowGraphExecutionBlockWithOutSignal.js.map +1 -1
  247. package/FlowGraph/flowGraphLogger.d.ts +60 -0
  248. package/FlowGraph/flowGraphLogger.js +53 -0
  249. package/FlowGraph/flowGraphLogger.js.map +1 -0
  250. package/FlowGraph/flowGraphParser.d.ts +85 -0
  251. package/FlowGraph/flowGraphParser.js +271 -0
  252. package/FlowGraph/flowGraphParser.js.map +1 -0
  253. package/FlowGraph/flowGraphPathConverter.d.ts +1 -1
  254. package/FlowGraph/flowGraphPathConverter.js +3 -2
  255. package/FlowGraph/flowGraphPathConverter.js.map +1 -1
  256. package/FlowGraph/flowGraphPathConverterComponent.d.ts +8 -1
  257. package/FlowGraph/flowGraphPathConverterComponent.js +18 -2
  258. package/FlowGraph/flowGraphPathConverterComponent.js.map +1 -1
  259. package/FlowGraph/flowGraphRichTypes.d.ts +51 -9
  260. package/FlowGraph/flowGraphRichTypes.js +160 -50
  261. package/FlowGraph/flowGraphRichTypes.js.map +1 -1
  262. package/FlowGraph/flowGraphSceneEventCoordinator.d.ts +45 -0
  263. package/FlowGraph/flowGraphSceneEventCoordinator.js +77 -0
  264. package/FlowGraph/flowGraphSceneEventCoordinator.js.map +1 -0
  265. package/FlowGraph/flowGraphSignalConnection.d.ts +8 -5
  266. package/FlowGraph/flowGraphSignalConnection.js +26 -9
  267. package/FlowGraph/flowGraphSignalConnection.js.map +1 -1
  268. package/FlowGraph/index.d.ts +6 -1
  269. package/FlowGraph/index.js +7 -1
  270. package/FlowGraph/index.js.map +1 -1
  271. package/FlowGraph/serialization.d.ts +5 -2
  272. package/FlowGraph/serialization.js +94 -22
  273. package/FlowGraph/serialization.js.map +1 -1
  274. package/FlowGraph/typeDefinitions.d.ts +74 -12
  275. package/FlowGraph/typeDefinitions.js.map +1 -1
  276. package/FlowGraph/utils.d.ts +47 -0
  277. package/FlowGraph/utils.js +55 -0
  278. package/FlowGraph/utils.js.map +1 -1
  279. package/Maths/math.path.js +3 -0
  280. package/Maths/math.path.js.map +1 -1
  281. package/Meshes/geometry.d.ts +2 -1
  282. package/Meshes/geometry.js +8 -2
  283. package/Meshes/geometry.js.map +1 -1
  284. package/Meshes/mesh.d.ts +2 -1
  285. package/Meshes/mesh.js +3 -2
  286. package/Meshes/mesh.js.map +1 -1
  287. package/ObjectModel/objectModelInterfaces.d.ts +2 -2
  288. package/ObjectModel/objectModelInterfaces.js.map +1 -1
  289. package/package.json +1 -1
  290. package/FlowGraph/Blocks/Data/Logic/flowGraphLogicBlocks.d.ts +0 -24
  291. package/FlowGraph/Blocks/Data/Logic/flowGraphLogicBlocks.js +0 -39
  292. package/FlowGraph/Blocks/Data/Logic/flowGraphLogicBlocks.js.map +0 -1
  293. package/FlowGraph/Blocks/Data/Logic/index.d.ts +0 -1
  294. package/FlowGraph/Blocks/Data/Logic/index.js +0 -2
  295. package/FlowGraph/Blocks/Data/Logic/index.js.map +0 -1
  296. package/FlowGraph/Blocks/Data/flowGraphCoordinateTransformBlock.js.map +0 -1
  297. package/FlowGraph/Blocks/Execution/Audio/flowGraphPlayAudioBlock.d.ts +0 -19
  298. package/FlowGraph/Blocks/Execution/Audio/flowGraphPlayAudioBlock.js +0 -26
  299. package/FlowGraph/Blocks/Execution/Audio/flowGraphPlayAudioBlock.js.map +0 -1
  300. package/FlowGraph/Blocks/Execution/Audio/flowGraphStopAudioBlock.js +0 -25
  301. package/FlowGraph/Blocks/Execution/Audio/flowGraphStopAudioBlock.js.map +0 -1
  302. package/FlowGraph/Blocks/Execution/Audio/index.d.ts +0 -2
  303. package/FlowGraph/Blocks/Execution/Audio/index.js +0 -3
  304. package/FlowGraph/Blocks/Execution/Audio/index.js.map +0 -1
  305. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphTimerBlock.d.ts +0 -31
  306. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphTimerBlock.js +0 -69
  307. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphTimerBlock.js.map +0 -1
  308. package/FlowGraph/Blocks/Execution/flowGraphSendCustomEventBlock.js +0 -38
  309. package/FlowGraph/Blocks/Execution/flowGraphSendCustomEventBlock.js.map +0 -1
  310. package/FlowGraph/flowGraphContextLogger.d.ts +0 -9
  311. package/FlowGraph/flowGraphContextLogger.js +0 -14
  312. package/FlowGraph/flowGraphContextLogger.js.map +0 -1
  313. package/FlowGraph/flowGraphInteger.js.map +0 -1
@@ -0,0 +1,84 @@
1
+ import { FlowGraphAsyncExecutionBlock } from "../../../flowGraphAsyncExecutionBlock.js";
2
+ import { RichTypeNumber } from "../../../flowGraphRichTypes.js";
3
+ import { AdvancedTimer } from "../../../../Misc/timer.js";
4
+ import { Logger } from "../../../../Misc/logger.js";
5
+ import { RegisterClass } from "../../../../Misc/typeStore.js";
6
+ /**
7
+ * Block that sets a delay in seconds before activating the output signal.
8
+ */
9
+ export class FlowGraphSetDelayBlock extends FlowGraphAsyncExecutionBlock {
10
+ constructor(config) {
11
+ super(config);
12
+ this.cancel = this._registerSignalInput("cancel");
13
+ this.duration = this.registerDataInput("duration", RichTypeNumber);
14
+ this.lastDelayIndex = this.registerDataOutput("lastDelayIndex", RichTypeNumber, -1);
15
+ }
16
+ _preparePendingTasks(context) {
17
+ const duration = this.duration.getValue(context);
18
+ if (duration < 0 || isNaN(duration) || !isFinite(duration)) {
19
+ this.error.payload = { message: "Invalid duration" };
20
+ return this.error._activateSignal(context);
21
+ }
22
+ // active delays are global to the context
23
+ const activeDelays = context._getGlobalContextVariable("activeDelays", 0);
24
+ if (activeDelays >= FlowGraphSetDelayBlock.MaxParallelDelayCount) {
25
+ this.error.payload = { message: "Max parallel delays reached" };
26
+ return this.error._activateSignal(context);
27
+ }
28
+ // get the last global delay index
29
+ const lastDelayIndex = context._getGlobalContextVariable("lastDelayIndex", -1);
30
+ // these are block-specific and not global
31
+ const timers = context._getExecutionVariable(this, "pendingDelays", []);
32
+ const scene = context.configuration.scene;
33
+ const timer = new AdvancedTimer({
34
+ timeout: duration * 1000, // duration is in seconds
35
+ contextObservable: scene.onBeforeRenderObservable,
36
+ onEnded: () => this._onEnded(timer, context),
37
+ });
38
+ timer.start();
39
+ const newIndex = lastDelayIndex + 1;
40
+ this.lastDelayIndex.setValue(newIndex, context);
41
+ context._setGlobalContextVariable("lastDelayIndex", newIndex);
42
+ timers[newIndex] = timer;
43
+ context._setExecutionVariable(this, "pendingDelays", timers);
44
+ }
45
+ _cancelPendingTasks(context) {
46
+ const timers = context._getExecutionVariable(this, "pendingDelays", []);
47
+ for (const timer of timers) {
48
+ timer?.dispose();
49
+ }
50
+ context._deleteExecutionVariable(this, "pendingDelays");
51
+ this.lastDelayIndex.setValue(-1, context);
52
+ }
53
+ _execute(context, callingSignal) {
54
+ if (callingSignal === this.cancel) {
55
+ this._cancelPendingTasks(context);
56
+ return;
57
+ }
58
+ else {
59
+ this._preparePendingTasks(context);
60
+ this.out._activateSignal(context);
61
+ }
62
+ }
63
+ getClassName() {
64
+ return "FlowGraphSetDelayBlock" /* FlowGraphBlockNames.SetDelay */;
65
+ }
66
+ _onEnded(timer, context) {
67
+ const timers = context._getExecutionVariable(this, "pendingDelays", []);
68
+ const index = timers.indexOf(timer);
69
+ if (index !== -1) {
70
+ timers.splice(index, 1);
71
+ }
72
+ else {
73
+ Logger.Warn("FlowGraphTimerBlock: Timer ended but was not found in the running timers list");
74
+ }
75
+ context._removePendingBlock(this);
76
+ this.done._activateSignal(context);
77
+ }
78
+ }
79
+ /**
80
+ * The maximum number of parallel delays that can be set per node.
81
+ */
82
+ FlowGraphSetDelayBlock.MaxParallelDelayCount = 100;
83
+ RegisterClass("FlowGraphSetDelayBlock" /* FlowGraphBlockNames.SetDelay */, FlowGraphSetDelayBlock);
84
+ //# sourceMappingURL=flowGraphSetDelayBlock.js.map
@@ -0,0 +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,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,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC,CAAC;IACxF,CAAC;IAEM,oBAAoB,CAAC,OAAyB;QACjD,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QACjD,IAAI,QAAQ,GAAG,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;YACzD,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,EAAE,OAAO,EAAE,kBAAkB,EAAE,CAAC;YACrD,OAAO,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QAC/C,CAAC;QAED,0CAA0C;QAC1C,MAAM,YAAY,GAAW,OAAO,CA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AsB,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"]}
@@ -3,8 +3,8 @@ import type { FlowGraphDataConnection } from "../../../flowGraphDataConnection";
3
3
  import { FlowGraphExecutionBlock } from "../../../flowGraphExecutionBlock";
4
4
  import type { FlowGraphSignalConnection } from "../../../flowGraphSignalConnection";
5
5
  import type { IFlowGraphBlockConfiguration } from "../../../flowGraphBlock";
6
+ import type { FlowGraphNumber } from "../../../utils.js";
6
7
  /**
7
- * @experimental
8
8
  * Configuration for a switch block.
9
9
  */
10
10
  export interface IFlowGraphSwitchBlockConfiguration<T> extends IFlowGraphBlockConfiguration {
@@ -14,10 +14,9 @@ export interface IFlowGraphSwitchBlockConfiguration<T> extends IFlowGraphBlockCo
14
14
  cases: T[];
15
15
  }
16
16
  /**
17
- * @experimental
18
17
  * A block that executes a branch based on a selection.
19
18
  */
20
- export declare class FlowGraphSwitchBlock<T> extends FlowGraphExecutionBlock {
19
+ export declare class FlowGraphSwitchBlock<T extends FlowGraphNumber> extends FlowGraphExecutionBlock {
21
20
  /**
22
21
  * the configuration of the block
23
22
  */
@@ -25,17 +24,32 @@ export declare class FlowGraphSwitchBlock<T> extends FlowGraphExecutionBlock {
25
24
  /**
26
25
  * Input connection: The value of the selection.
27
26
  */
28
- readonly selection: FlowGraphDataConnection<T>;
27
+ readonly case: FlowGraphDataConnection<T>;
29
28
  /**
30
- * Output connection: The output flows.
29
+ * The default case to execute if no other case is found.
31
30
  */
32
- outputFlows: FlowGraphSignalConnection[];
31
+ readonly default: FlowGraphSignalConnection;
32
+ private _caseToOutputFlow;
33
33
  constructor(
34
34
  /**
35
35
  * the configuration of the block
36
36
  */
37
37
  config: IFlowGraphSwitchBlockConfiguration<T>);
38
38
  _execute(context: FlowGraphContext, _callingSignal: FlowGraphSignalConnection): void;
39
+ /**
40
+ * Adds a new case to the switch block.
41
+ * @param newCase the new case to add.
42
+ */
43
+ addCase(newCase: T): void;
44
+ /**
45
+ * Removes a case from the switch block.
46
+ * @param caseToRemove the case to remove.
47
+ */
48
+ removeCase(caseToRemove: T): void;
49
+ /**
50
+ * @internal
51
+ */
52
+ _getOutputFlowForCase(caseValue: T): FlowGraphSignalConnection | undefined;
39
53
  /**
40
54
  * @returns class name of the block.
41
55
  */
@@ -1,8 +1,8 @@
1
1
  import { FlowGraphExecutionBlock } from "../../../flowGraphExecutionBlock.js";
2
2
  import { RichTypeAny } from "../../../flowGraphRichTypes.js";
3
3
  import { RegisterClass } from "../../../../Misc/typeStore.js";
4
+ import { getNumericValue, isNumeric } from "../../../utils.js";
4
5
  /**
5
- * @experimental
6
6
  * A block that executes a branch based on a selection.
7
7
  */
8
8
  export class FlowGraphSwitchBlock extends FlowGraphExecutionBlock {
@@ -13,28 +13,67 @@ export class FlowGraphSwitchBlock extends FlowGraphExecutionBlock {
13
13
  config) {
14
14
  super(config);
15
15
  this.config = config;
16
- this.selection = this.registerDataInput("selection", RichTypeAny);
17
- this.outputFlows = [];
18
- for (let i = 0; i <= this.config.cases.length; i++) {
19
- this.outputFlows.push(this._registerSignalOutput(`out${i}`));
20
- }
16
+ /**
17
+ * The default case to execute if no other case is found.
18
+ */
19
+ this.default = this._registerSignalOutput("default");
20
+ this._caseToOutputFlow = new Map();
21
+ this.case = this.registerDataInput("case", RichTypeAny);
22
+ // iterate the set not using for of
23
+ (this.config.cases || []).forEach((caseValue) => {
24
+ this._caseToOutputFlow.set(caseValue, this._registerSignalOutput(`out_${caseValue}`));
25
+ });
21
26
  }
22
27
  _execute(context, _callingSignal) {
23
- const selectionValue = this.selection.getValue(context);
24
- for (let i = 0; i < this.config.cases.length; i++) {
25
- if (selectionValue === this.config.cases[i]) {
26
- this.outputFlows[i]._activateSignal(context);
27
- return;
28
- }
28
+ const selectionValue = this.case.getValue(context);
29
+ let outputFlow;
30
+ if (isNumeric(selectionValue)) {
31
+ outputFlow = this._getOutputFlowForCase(getNumericValue(selectionValue));
32
+ }
33
+ else {
34
+ outputFlow = this._getOutputFlowForCase(selectionValue);
35
+ }
36
+ if (outputFlow) {
37
+ outputFlow._activateSignal(context);
38
+ }
39
+ else {
40
+ this.default._activateSignal(context);
41
+ }
42
+ }
43
+ /**
44
+ * Adds a new case to the switch block.
45
+ * @param newCase the new case to add.
46
+ */
47
+ addCase(newCase) {
48
+ if (this.config.cases.includes(newCase)) {
49
+ return;
29
50
  }
30
- // default case
31
- this.outputFlows[this.outputFlows.length - 1]._activateSignal(context);
51
+ this.config.cases.push(newCase);
52
+ this._caseToOutputFlow.set(newCase, this._registerSignalOutput(`out_${newCase}`));
53
+ }
54
+ /**
55
+ * Removes a case from the switch block.
56
+ * @param caseToRemove the case to remove.
57
+ */
58
+ removeCase(caseToRemove) {
59
+ if (!this.config.cases.includes(caseToRemove)) {
60
+ return;
61
+ }
62
+ const index = this.config.cases.indexOf(caseToRemove);
63
+ this.config.cases.splice(index, 1);
64
+ this._caseToOutputFlow.delete(caseToRemove);
65
+ }
66
+ /**
67
+ * @internal
68
+ */
69
+ _getOutputFlowForCase(caseValue) {
70
+ return this._caseToOutputFlow.get(caseValue);
32
71
  }
33
72
  /**
34
73
  * @returns class name of the block.
35
74
  */
36
75
  getClassName() {
37
- return "FGSwitchBlock";
76
+ return "FlowGraphSwitchBlock" /* FlowGraphBlockNames.Switch */;
38
77
  }
39
78
  /**
40
79
  * Serialize the block to a JSON representation.
@@ -45,5 +84,5 @@ export class FlowGraphSwitchBlock extends FlowGraphExecutionBlock {
45
84
  serializationObject.cases = this.config.cases;
46
85
  }
47
86
  }
48
- RegisterClass("FGSwitchBlock", FlowGraphSwitchBlock);
87
+ RegisterClass("FlowGraphSwitchBlock" /* FlowGraphBlockNames.Switch */, FlowGraphSwitchBlock);
49
88
  //# sourceMappingURL=flowGraphSwitchBlock.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"flowGraphSwitchBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSwitchBlock.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAG1D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAY3D;;;GAGG;AACH,MAAM,OAAO,oBAAwB,SA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ACrC,mBAAmB,CAAC,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;IAClD,CAAC;CACJ;AACD,aAAa,CAAC,eAAe,EAAE,oBAAoB,CAAC,CAAC","sourcesContent":["import type { FlowGraphContext } from \"../../../flowGraphContext\";\r\nimport type { FlowGraphDataConnection } from \"../../../flowGraphDataConnection\";\r\nimport { FlowGraphExecutionBlock } from \"../../../flowGraphExecutionBlock\";\r\nimport { RichTypeAny } from \"../../../flowGraphRichTypes\";\r\nimport type { FlowGraphSignalConnection } from \"../../../flowGraphSignalConnection\";\r\nimport type { IFlowGraphBlockConfiguration } from \"../../../flowGraphBlock\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\n/**\r\n * @experimental\r\n * Configuration for a switch block.\r\n */\r\nexport interface IFlowGraphSwitchBlockConfiguration<T> extends IFlowGraphBlockConfiguration {\r\n /**\r\n * The possible values for the selection.\r\n */\r\n cases: T[];\r\n}\r\n\r\n/**\r\n * @experimental\r\n * A block that executes a branch based on a selection.\r\n */\r\nexport class FlowGraphSwitchBlock<T> extends FlowGraphExecutionBlock {\r\n /**\r\n * Input connection: The value of the selection.\r\n */\r\n public readonly selection: FlowGraphDataConnection<T>;\r\n /**\r\n * Output connection: The output flows.\r\n */\r\n public outputFlows: FlowGraphSignalConnection[];\r\n\r\n constructor(\r\n /**\r\n * the configuration of the block\r\n */\r\n public override config: IFlowGraphSwitchBlockConfiguration<T>\r\n ) {\r\n super(config);\r\n\r\n this.selection = this.registerDataInput(\"selection\", RichTypeAny);\r\n this.outputFlows = [];\r\n for (let i = 0; i <= this.config.cases.length; i++) {\r\n this.outputFlows.push(this._registerSignalOutput(`out${i}`));\r\n }\r\n }\r\n\r\n public _execute(context: FlowGraphContext, _callingSignal: FlowGraphSignalConnection): void {\r\n const selectionValue = this.selection.getValue(context);\r\n\r\n for (let i = 0; i < this.config.cases.length; i++) {\r\n if (selectionValue === this.config.cases[i]) {\r\n this.outputFlows[i]._activateSignal(context);\r\n return;\r\n }\r\n }\r\n\r\n // default case\r\n this.outputFlows[this.outputFlows.length - 1]._activateSignal(context);\r\n }\r\n\r\n /**\r\n * @returns class name of the block.\r\n */\r\n public override getClassName(): string {\r\n return \"FGSwitchBlock\";\r\n }\r\n\r\n /**\r\n * Serialize the block to a JSON representation.\r\n * @param serializationObject the object to serialize to.\r\n */\r\n public override serialize(serializationObject?: any): void {\r\n super.serialize(serializationObject);\r\n serializationObject.cases = this.config.cases;\r\n }\r\n}\r\nRegisterClass(\"FGSwitchBlock\", FlowGraphSwitchBlock);\r\n"]}
1
+ {"version":3,"file":"flowGraphSwitchBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSwitchBlock.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAG1D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAG3D,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,0BAA6B;AAWlE;;GAEG;AACH,MAAM,OAAO,oBAAgD,SAAQ,uBAAuB;IAaxF;IACI;;OAEG;IACa,MAA6C;QAE7D,KAAK,CAAC,MAAM,CAAC,CAAC;QAFE,WAAM,GAAN,MAAM,CAAuC;QAXjE;;WAEG;QACa,YAAO,GAA8B,IAAI,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC;QAEnF,sBAAiB,GAAsC,IAAI,GAAG,EAAE,CAAC;QAUrE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,iBAAiB,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;QAExD,mCAAmC;QACnC,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE;YAC5C,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,SAAS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C,YAAY,CAAC,CAAC;QACtD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QACnC,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IAChD,CAAC;IAED;;OAEG;IACI,qBAAqB,CAAC,SAAY;QACrC,OAAO,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IACjD,CAAC;IAED;;OAEG;IACa,YAAY;QACxB,+DAAkC;IACtC,CAAC;IAED;;;OAGG;IACa,SAAS,CAAC,mBAAyB;QAC/C,KAAK,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAAC;QACrC,mBAAmB,CAAC,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;IAClD,CAAC;CACJ;AACD,aAAa,0DAA6B,oBAAoB,CAAC,CAAC","sourcesContent":["import type { FlowGraphContext } from \"../../../flowGraphContext\";\r\nimport type { FlowGraphDataConnection } from \"../../../flowGraphDataConnection\";\r\nimport { FlowGraphExecutionBlock } from \"../../../flowGraphExecutionBlock\";\r\nimport { RichTypeAny } from \"../../../flowGraphRichTypes\";\r\nimport type { FlowGraphSignalConnection } from \"../../../flowGraphSignalConnection\";\r\nimport type { IFlowGraphBlockConfiguration } from \"../../../flowGraphBlock\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { FlowGraphBlockNames } from \"../../flowGraphBlockNames\";\r\nimport type { FlowGraphNumber } from \"core/FlowGraph/utils\";\r\nimport { getNumericValue, isNumeric } from \"core/FlowGraph/utils\";\r\n/**\r\n * Configuration for a switch block.\r\n */\r\nexport interface IFlowGraphSwitchBlockConfiguration<T> extends IFlowGraphBlockConfiguration {\r\n /**\r\n * The possible values for the selection.\r\n */\r\n cases: T[];\r\n}\r\n\r\n/**\r\n * A block that executes a branch based on a selection.\r\n */\r\nexport class FlowGraphSwitchBlock<T extends FlowGraphNumber> extends FlowGraphExecutionBlock {\r\n /**\r\n * Input connection: The value of the selection.\r\n */\r\n public readonly case: FlowGraphDataConnection<T>;\r\n\r\n /**\r\n * The default case to execute if no other case is found.\r\n */\r\n public readonly default: FlowGraphSignalConnection = this._registerSignalOutput(\"default\");\r\n\r\n private _caseToOutputFlow: Map<T, FlowGraphSignalConnection> = new Map();\r\n\r\n constructor(\r\n /**\r\n * the configuration of the block\r\n */\r\n public override config: IFlowGraphSwitchBlockConfiguration<T>\r\n ) {\r\n super(config);\r\n\r\n this.case = this.registerDataInput(\"case\", RichTypeAny);\r\n\r\n // iterate the set not using for of\r\n (this.config.cases || []).forEach((caseValue) => {\r\n this._caseToOutputFlow.set(caseValue, this._registerSignalOutput(`out_${caseValue}`));\r\n });\r\n }\r\n\r\n public _execute(context: FlowGraphContext, _callingSignal: FlowGraphSignalConnection): void {\r\n const selectionValue = this.case.getValue(context);\r\n let outputFlow: FlowGraphSignalConnection | undefined;\r\n if (isNumeric(selectionValue)) {\r\n outputFlow = this._getOutputFlowForCase(getNumericValue(selectionValue) as T);\r\n } else {\r\n outputFlow = this._getOutputFlowForCase(selectionValue);\r\n }\r\n\r\n if (outputFlow) {\r\n outputFlow._activateSignal(context);\r\n } else {\r\n this.default._activateSignal(context);\r\n }\r\n }\r\n\r\n /**\r\n * Adds a new case to the switch block.\r\n * @param newCase the new case to add.\r\n */\r\n public addCase(newCase: T): void {\r\n if (this.config.cases.includes(newCase)) {\r\n return;\r\n }\r\n this.config.cases.push(newCase);\r\n this._caseToOutputFlow.set(newCase, this._registerSignalOutput(`out_${newCase}`));\r\n }\r\n\r\n /**\r\n * Removes a case from the switch block.\r\n * @param caseToRemove the case to remove.\r\n */\r\n public removeCase(caseToRemove: T): void {\r\n if (!this.config.cases.includes(caseToRemove)) {\r\n return;\r\n }\r\n const index = this.config.cases.indexOf(caseToRemove);\r\n this.config.cases.splice(index, 1);\r\n this._caseToOutputFlow.delete(caseToRemove);\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _getOutputFlowForCase(caseValue: T) {\r\n return this._caseToOutputFlow.get(caseValue);\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.Switch;\r\n }\r\n\r\n /**\r\n * Serialize the block to a JSON representation.\r\n * @param serializationObject the object to serialize to.\r\n */\r\n public override serialize(serializationObject?: any): void {\r\n super.serialize(serializationObject);\r\n serializationObject.cases = this.config.cases;\r\n }\r\n}\r\nRegisterClass(FlowGraphBlockNames.Switch, FlowGraphSwitchBlock);\r\n"]}
@@ -4,12 +4,11 @@ import type { FlowGraphSignalConnection } from "../../../flowGraphSignalConnecti
4
4
  import { FlowGraphExecutionBlockWithOutSignal } from "../../../flowGraphExecutionBlockWithOutSignal";
5
5
  import type { IFlowGraphBlockConfiguration } from "../../../flowGraphBlock";
6
6
  /**
7
- * @experimental
8
7
  * A block that throttles the execution of its output flow.
9
8
  */
10
9
  export declare class FlowGraphThrottleBlock extends FlowGraphExecutionBlockWithOutSignal {
11
10
  /**
12
- * Input connection: The duration of the throttle, in ms.
11
+ * Input connection: The duration of the throttle, in seconds.
13
12
  */
14
13
  readonly duration: FlowGraphDataConnection<number>;
15
14
  /**
@@ -17,9 +16,9 @@ export declare class FlowGraphThrottleBlock extends FlowGraphExecutionBlockWithO
17
16
  */
18
17
  readonly reset: FlowGraphSignalConnection;
19
18
  /**
20
- * Output connection: The time remaining before the throttle is done, in ms.
19
+ * Output connection: The time remaining before the throttle is triggering again, in seconds.
21
20
  */
22
- readonly timeRemaining: FlowGraphDataConnection<number>;
21
+ readonly lastRemainingTime: FlowGraphDataConnection<number>;
23
22
  constructor(config?: IFlowGraphBlockConfiguration);
24
23
  _execute(context: FlowGraphContext, callingSignal: FlowGraphSignalConnection): void;
25
24
  /**
@@ -2,7 +2,6 @@ import { RichTypeNumber } from "../../../flowGraphRichTypes.js";
2
2
  import { FlowGraphExecutionBlockWithOutSignal } from "../../../flowGraphExecutionBlockWithOutSignal.js";
3
3
  import { RegisterClass } from "../../../../Misc/typeStore.js";
4
4
  /**
5
- * @experimental
6
5
  * A block that throttles the execution of its output flow.
7
6
  */
8
7
  export class FlowGraphThrottleBlock extends FlowGraphExecutionBlockWithOutSignal {
@@ -10,30 +9,54 @@ export class FlowGraphThrottleBlock extends FlowGraphExecutionBlockWithOutSignal
10
9
  super(config);
11
10
  this.reset = this._registerSignalInput("reset");
12
11
  this.duration = this.registerDataInput("duration", RichTypeNumber);
13
- this.timeRemaining = this.registerDataOutput("timeRemaining", RichTypeNumber);
12
+ this.lastRemainingTime = this.registerDataOutput("lastRemainingTime", RichTypeNumber, NaN);
14
13
  }
15
14
  _execute(context, callingSignal) {
16
- const lastExecutedTime = context._getExecutionVariable(this, "lastExecutedTime");
15
+ if (callingSignal === this.reset) {
16
+ this.lastRemainingTime.setValue(NaN, context);
17
+ context._setExecutionVariable(this, "lastRemainingTime", NaN);
18
+ context._setExecutionVariable(this, "timestamp", 0);
19
+ return;
20
+ }
21
+ // in seconds
17
22
  const durationValue = this.duration.getValue(context);
23
+ if (durationValue <= 0 || isNaN(durationValue) || !isFinite(durationValue)) {
24
+ return this.error._activateSignal(context);
25
+ }
26
+ const lastRemainingTime = context._getExecutionVariable(this, "lastRemainingTime", NaN);
27
+ // Using Date.now() to get ms since epoch. not using performance.now() because its precision is not needed here
18
28
  const currentTime = Date.now();
19
- if (callingSignal === this.reset || lastExecutedTime === undefined || currentTime - lastExecutedTime > durationValue) {
20
- //activate the output flow
21
- this.timeRemaining.setValue(0, context);
22
- this.out._activateSignal(context);
23
- context._setExecutionVariable(this, "lastExecutedTime", currentTime);
29
+ if (isNaN(lastRemainingTime)) {
30
+ this.lastRemainingTime.setValue(0, context);
31
+ context._setExecutionVariable(this, "lastRemainingTime", 0);
32
+ context._setExecutionVariable(this, "timestamp", currentTime);
33
+ // according to glTF interactivity specs
34
+ return this.out._activateSignal(context);
24
35
  }
25
36
  else {
26
- //activate the output flow after the remaining time
27
- const remaining = durationValue - (currentTime - lastExecutedTime);
28
- this.timeRemaining.setValue(remaining, context);
37
+ const elapsedTime = currentTime - context._getExecutionVariable(this, "timestamp", 0);
38
+ // duration is in seconds, so we need to multiply by 1000
39
+ const durationInMs = durationValue * 1000;
40
+ if (durationInMs <= elapsedTime) {
41
+ this.lastRemainingTime.setValue(0, context);
42
+ context._setExecutionVariable(this, "lastRemainingTime", 0);
43
+ context._setExecutionVariable(this, "timestamp", currentTime);
44
+ return this.out._activateSignal(context);
45
+ }
46
+ else {
47
+ const remainingTime = durationInMs - elapsedTime;
48
+ // output is in seconds
49
+ this.lastRemainingTime.setValue(remainingTime / 1000, context);
50
+ context._setExecutionVariable(this, "lastRemainingTime", remainingTime);
51
+ }
29
52
  }
30
53
  }
31
54
  /**
32
55
  * @returns class name of the block.
33
56
  */
34
57
  getClassName() {
35
- return "FGThrottleBlock";
58
+ return "FlowGraphThrottleBlock" /* FlowGraphBlockNames.Throttle */;
36
59
  }
37
60
  }
38
- RegisterClass("FGThrottleBlock", FlowGraphThrottleBlock);
61
+ RegisterClass("FlowGraphThrottleBlock" /* FlowGraphBlockNames.Throttle */, FlowGraphThrottleBlock);
39
62
  //# sourceMappingURL=flowGraphThrottleBlock.js.map
@@ -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;AAC3D;;;GAGG;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,aAAa,GAAG,IAAI,CAAC,kBAAkB,CAAC,eAAe,EAAE,cAAc,CAAC,CAAC;IAClF,CAAC;IACM,QAAQ,CAAC,OAAyB,EAAE,aAAwC;QAC/E,MAAM,gBAAgB,GAAG,OAAO,CAAC,qBAAqB,CAAC,IAAI,EAAE,kBAAkB,CAAC,CAAC;QACjF,MAAM,aAAa,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QACtD,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC/B,IAAI,aAAa,KAAK,IAAI,CAAC,KAAK,IAAI,gBAAgB,KAAK,SAAS,IAAI,WAAW,GAAG,gBAAgB,GAAG,aAAa,EAAE,CAAC;YACnH,0BAA0B;YAC1B,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;YACxC,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;YAClC,OAAO,CAAC,qBAAqB,CAAC,IAAI,EAAE,kBAAkB,EAAE,WAAW,CAAC,CAAC;QACzE,CAAC;aAAM,CAAC;YACJ,mDAAmD;YACnD,MAAM,SAAS,GAAG,aAAa,GAAG,CAAC,WAAW,GAAG,gBAAgB,CAAC,CAAC;YACnE,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QACpD,CAAC;IACL,CAAC;IACD;;OAEG;IACa,YAAY;QACxB,OAAO,iBAAiB,CAAC;IAC7B,CAAC;CACJ;AACD,aAAa,CAAC,iBAAiB,EAAE,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\n/**\r\n * @experimental\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 ms.\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 done, in ms.\r\n */\r\n public readonly timeRemaining: 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.timeRemaining = this.registerDataOutput(\"timeRemaining\", RichTypeNumber);\r\n }\r\n public _execute(context: FlowGraphContext, callingSignal: FlowGraphSignalConnection): void {\r\n const lastExecutedTime = context._getExecutionVariable(this, \"lastExecutedTime\");\r\n const durationValue = this.duration.getValue(context);\r\n const currentTime = Date.now();\r\n if (callingSignal === this.reset || lastExecutedTime === undefined || currentTime - lastExecutedTime > durationValue) {\r\n //activate the output flow\r\n this.timeRemaining.setValue(0, context);\r\n this.out._activateSignal(context);\r\n context._setExecutionVariable(this, \"lastExecutedTime\", currentTime);\r\n } else {\r\n //activate the output flow after the remaining time\r\n const remaining = durationValue - (currentTime - lastExecutedTime);\r\n this.timeRemaining.setValue(remaining, context);\r\n }\r\n }\r\n /**\r\n * @returns class name of the block.\r\n */\r\n public override getClassName(): string {\r\n return \"FGThrottleBlock\";\r\n }\r\n}\r\nRegisterClass(\"FGThrottleBlock\", 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,CAAC,CAAC;YAC9D,OAAO,CAAC,qBAAqB,CAAC,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC;YACpD,OAAO;QACX,CAAC;QACD,aAAa;QACb,MAAM,aAAa,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QACtD,IAAI,aAAa,IAAI,CAAC,IAAI,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE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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"]}
@@ -2,18 +2,18 @@ import type { FlowGraphContext } from "../../../flowGraphContext";
2
2
  import type { FlowGraphSignalConnection } from "../../../flowGraphSignalConnection";
3
3
  import { FlowGraphExecutionBlockWithOutSignal } from "../../../flowGraphExecutionBlockWithOutSignal";
4
4
  import type { IFlowGraphBlockConfiguration } from "../../../flowGraphBlock";
5
+ import type { FlowGraphDataConnection } from "../../../flowGraphDataConnection.js";
5
6
  /**
6
- * @experimental
7
7
  * Configuration for the wait all block.
8
8
  */
9
9
  export interface IFlowGraphWaitAllBlockConfiguration extends IFlowGraphBlockConfiguration {
10
10
  /**
11
- * The number of input flows. There will always be at least one input flow.
11
+ * The number of input signals. There will always be at least one input flow.
12
+ * glTF interactivity has a max of 64 input flows.
12
13
  */
13
- numberInputFlows: number;
14
+ inputSignalCount: number;
14
15
  }
15
16
  /**
16
- * @experimental
17
17
  * A block that waits for all input flows to be activated before activating its output flow.
18
18
  */
19
19
  export declare class FlowGraphWaitAllBlock extends FlowGraphExecutionBlockWithOutSignal {
@@ -26,7 +26,15 @@ export declare class FlowGraphWaitAllBlock extends FlowGraphExecutionBlockWithOu
26
26
  */
27
27
  reset: FlowGraphSignalConnection;
28
28
  /**
29
- * Input connection: The 2nd to nth input flows (the first is named onStart)
29
+ * Output connection:When the last missing flow is activated
30
+ */
31
+ completed: FlowGraphSignalConnection;
32
+ /**
33
+ * Output connection: The number of remaining inputs to be activated.
34
+ */
35
+ remainingInputs: FlowGraphDataConnection<number>;
36
+ /**
37
+ * An array of input signals
30
38
  */
31
39
  readonly inFlows: FlowGraphSignalConnection[];
32
40
  private _cachedActivationState;
@@ -1,7 +1,7 @@
1
1
  import { FlowGraphExecutionBlockWithOutSignal } from "../../../flowGraphExecutionBlockWithOutSignal.js";
2
2
  import { RegisterClass } from "../../../../Misc/typeStore.js";
3
+ import { RichTypeNumber } from "../../../flowGraphRichTypes.js";
3
4
  /**
4
- * @experimental
5
5
  * A block that waits for all input flows to be activated before activating its output flow.
6
6
  */
7
7
  export class FlowGraphWaitAllBlock extends FlowGraphExecutionBlockWithOutSignal {
@@ -13,26 +13,30 @@ export class FlowGraphWaitAllBlock extends FlowGraphExecutionBlockWithOutSignal
13
13
  super(config);
14
14
  this.config = config;
15
15
  /**
16
- * Input connection: The 2nd to nth input flows (the first is named onStart)
16
+ * An array of input signals
17
17
  */
18
18
  this.inFlows = [];
19
19
  this._cachedActivationState = [];
20
20
  this.reset = this._registerSignalInput("reset");
21
+ this.completed = this._registerSignalOutput("completed");
22
+ this.remainingInputs = this.registerDataOutput("remainingInputs", RichTypeNumber, this.config.inputSignalCount || 0);
21
23
  // The first inFlow is the default input signal all execution blocks have
22
- for (let i = 1; i < this.config.numberInputFlows; i++) {
23
- this.inFlows.push(this._registerSignalInput(`in${i}`));
24
+ for (let i = 0; i < this.config.inputSignalCount; i++) {
25
+ this.inFlows.push(this._registerSignalInput(`in_${i}`));
24
26
  }
27
+ // no need for in
28
+ this._unregisterSignalInput("in");
25
29
  }
26
30
  _getCurrentActivationState(context) {
27
31
  const activationState = this._cachedActivationState;
28
32
  activationState.length = 0;
29
33
  if (!context._hasExecutionVariable(this, "activationState")) {
30
- for (let i = 0; i < this.config.numberInputFlows; i++) {
34
+ for (let i = 0; i < this.config.inputSignalCount; i++) {
31
35
  activationState.push(false);
32
36
  }
33
37
  }
34
38
  else {
35
- const contextActivationState = context._getExecutionVariable(this, "activationState");
39
+ const contextActivationState = context._getExecutionVariable(this, "activationState", []);
36
40
  for (let i = 0; i < contextActivationState.length; i++) {
37
41
  activationState.push(contextActivationState[i]);
38
42
  }
@@ -42,32 +46,33 @@ export class FlowGraphWaitAllBlock extends FlowGraphExecutionBlockWithOutSignal
42
46
  _execute(context, callingSignal) {
43
47
  const activationState = this._getCurrentActivationState(context);
44
48
  if (callingSignal === this.reset) {
45
- for (let i = 0; i < this.config.numberInputFlows; i++) {
49
+ for (let i = 0; i < this.config.inputSignalCount; i++) {
46
50
  activationState[i] = false;
47
51
  }
48
52
  }
49
- else if (callingSignal === this.in) {
50
- activationState[0] = true;
51
- }
52
53
  else {
53
54
  const index = this.inFlows.indexOf(callingSignal);
54
55
  if (index >= 0) {
55
- activationState[index + 1] = true;
56
+ activationState[index] = true;
56
57
  }
57
58
  }
59
+ this.remainingInputs.setValue(activationState.filter((v) => !v).length, context);
58
60
  context._setExecutionVariable(this, "activationState", activationState.slice());
59
- if (activationState.every((value) => value)) {
60
- this.out._activateSignal(context);
61
- for (let i = 0; i < this.config.numberInputFlows; i++) {
61
+ if (!activationState.includes(false)) {
62
+ this.completed._activateSignal(context);
63
+ for (let i = 0; i < this.config.inputSignalCount; i++) {
62
64
  activationState[i] = false;
63
65
  }
64
66
  }
67
+ else {
68
+ callingSignal !== this.reset && this.out._activateSignal(context);
69
+ }
65
70
  }
66
71
  /**
67
72
  * @returns class name of the block.
68
73
  */
69
74
  getClassName() {
70
- return "FGWaitAllBlock";
75
+ return "FlowGraphWaitAllBlock" /* FlowGraphBlockNames.WaitAll */;
71
76
  }
72
77
  /**
73
78
  * Serializes this block into a object
@@ -75,8 +80,8 @@ export class FlowGraphWaitAllBlock extends FlowGraphExecutionBlockWithOutSignal
75
80
  */
76
81
  serialize(serializationObject) {
77
82
  super.serialize(serializationObject);
78
- serializationObject.config.numberInputFlows = this.config.numberInputFlows;
83
+ serializationObject.config.inputFlows = this.config.inputSignalCount;
79
84
  }
80
85
  }
81
- RegisterClass("FGWaitAllBlock", FlowGraphWaitAllBlock);
86
+ RegisterClass("FlowGraphWaitAllBlock" /* FlowGraphBlockNames.WaitAll */, FlowGraphWaitAllBlock);
82
87
  //# sourceMappingURL=flowGraphWaitAllBlock.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"flowGraphWaitAllBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWaitAllBlock.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oCAAoC,EAAE,MAAM,+CAA+C,CAAC;AAErG,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAY3D;;;GAGG;AACH,MAAM,OAAO,qBAAsB,SAAQ,oCAAoC;IAW3E;IACI;;OAEG;IACa,MAA2C;QAE3D,KAAK,CAAC,MAAM,CAAC,C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,mBAAmB,CAAC,MAAM,CAAC,gBAAgB,GAAG,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC;IAC/E,CAAC;CACJ;AACD,aAAa,CAAC,gBAAgB,EAAE,qBAAqB,CAAC,CAAC","sourcesContent":["import type { FlowGraphContext } from \"../../../flowGraphContext\";\r\nimport type { FlowGraphSignalConnection } from \"../../../flowGraphSignalConnection\";\r\nimport { FlowGraphExecutionBlockWithOutSignal } from \"../../../flowGraphExecutionBlockWithOutSignal\";\r\nimport type { IFlowGraphBlockConfiguration } from \"../../../flowGraphBlock\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\n/**\r\n * @experimental\r\n * Configuration for the wait all block.\r\n */\r\nexport interface IFlowGraphWaitAllBlockConfiguration extends IFlowGraphBlockConfiguration {\r\n /**\r\n * The number of input flows. There will always be at least one input flow.\r\n */\r\n numberInputFlows: number;\r\n}\r\n\r\n/**\r\n * @experimental\r\n * A block that waits for all input flows to be activated before activating its output flow.\r\n */\r\nexport class FlowGraphWaitAllBlock extends FlowGraphExecutionBlockWithOutSignal {\r\n /**\r\n * Input connection: Resets the block.\r\n */\r\n public reset: FlowGraphSignalConnection;\r\n /**\r\n * Input connection: The 2nd to nth input flows (the first is named onStart)\r\n */\r\n public readonly inFlows: FlowGraphSignalConnection[] = [];\r\n private _cachedActivationState: boolean[] = [];\r\n\r\n constructor(\r\n /**\r\n * the configuration of the block\r\n */\r\n public override config: IFlowGraphWaitAllBlockConfiguration\r\n ) {\r\n super(config);\r\n\r\n this.reset = this._registerSignalInput(\"reset\");\r\n // The first inFlow is the default input signal all execution blocks have\r\n for (let i = 1; i < this.config.numberInputFlows; i++) {\r\n this.inFlows.push(this._registerSignalInput(`in${i}`));\r\n }\r\n }\r\n\r\n private _getCurrentActivationState(context: FlowGraphContext) {\r\n const activationState = this._cachedActivationState;\r\n activationState.length = 0;\r\n if (!context._hasExecutionVariable(this, \"activationState\")) {\r\n for (let i = 0; i < this.config.numberInputFlows; i++) {\r\n activationState.push(false);\r\n }\r\n } else {\r\n const contextActivationState = context._getExecutionVariable(this, \"activationState\");\r\n for (let i = 0; i < contextActivationState.length; i++) {\r\n activationState.push(contextActivationState[i]);\r\n }\r\n }\r\n return activationState;\r\n }\r\n\r\n public _execute(context: FlowGraphContext, callingSignal: FlowGraphSignalConnection): void {\r\n const activationState = this._getCurrentActivationState(context);\r\n if (callingSignal === this.reset) {\r\n for (let i = 0; i < this.config.numberInputFlows; i++) {\r\n activationState[i] = false;\r\n }\r\n } else if (callingSignal === this.in) {\r\n activationState[0] = true;\r\n } else {\r\n const index = this.inFlows.indexOf(callingSignal);\r\n if (index >= 0) {\r\n activationState[index + 1] = true;\r\n }\r\n }\r\n\r\n context._setExecutionVariable(this, \"activationState\", activationState.slice());\r\n\r\n if (activationState.every((value: boolean) => value)) {\r\n this.out._activateSignal(context);\r\n for (let i = 0; i < this.config.numberInputFlows; i++) {\r\n activationState[i] = false;\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 \"FGWaitAllBlock\";\r\n }\r\n\r\n /**\r\n * Serializes this block into a object\r\n * @param serializationObject the object to serialize to\r\n */\r\n public override serialize(serializationObject?: any): void {\r\n super.serialize(serializationObject);\r\n serializationObject.config.numberInputFlows = this.config.numberInputFlows;\r\n }\r\n}\r\nRegisterClass(\"FGWaitAllBlock\", FlowGraphWaitAllBlock);\r\n"]}
1
+ {"version":3,"file":"flowGraphWaitAllBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWaitAllBlock.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oCAAoC,EAAE,MAAM,+CAA+C,CAAC;AAErG,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,OAAO,EAAE,cAAc,EAAE,uCAA0C;AAanE;;GAEG;AACH,MAAM,OAAO,qBAAsB,SAAQ,oCAAoC;IAqB3E;IACI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IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE,CAAC,EAAE,EAAE,CAAC;gBACpD,eAAe,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;YAC/B,CAAC;QACL,CAAC;aAAM,CAAC;YACJ,aAAa,KAAK,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QACtE,CAAC;IACL,CAAC;IAED;;OAEG;IACa,YAAY;QACxB,iEAAmC;IACvC,CAAC;IAED;;;OAGG;IACa,SAAS,CAAC,mBAAyB;QAC/C,KAAK,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAAC;QACrC,mBAAmB,CAAC,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC;IACzE,CAAC;CACJ;AACD,aAAa,4DAA8B,qBAAqB,CAAC,CAAC","sourcesContent":["import type { FlowGraphContext } from \"../../../flowGraphContext\";\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 type { FlowGraphDataConnection } from \"core/FlowGraph/flowGraphDataConnection\";\r\nimport { RichTypeNumber } from \"core/FlowGraph/flowGraphRichTypes\";\r\nimport { FlowGraphBlockNames } from \"../../flowGraphBlockNames\";\r\n/**\r\n * Configuration for the wait all block.\r\n */\r\nexport interface IFlowGraphWaitAllBlockConfiguration extends IFlowGraphBlockConfiguration {\r\n /**\r\n * The number of input signals. There will always be at least one input flow.\r\n * glTF interactivity has a max of 64 input flows.\r\n */\r\n inputSignalCount: number;\r\n}\r\n\r\n/**\r\n * A block that waits for all input flows to be activated before activating its output flow.\r\n */\r\nexport class FlowGraphWaitAllBlock extends FlowGraphExecutionBlockWithOutSignal {\r\n /**\r\n * Input connection: Resets the block.\r\n */\r\n public reset: FlowGraphSignalConnection;\r\n\r\n /**\r\n * Output connection:When the last missing flow is activated\r\n */\r\n public completed: FlowGraphSignalConnection;\r\n\r\n /**\r\n * Output connection: The number of remaining inputs to be activated.\r\n */\r\n public remainingInputs: FlowGraphDataConnection<number>;\r\n /**\r\n * An array of input signals\r\n */\r\n public readonly inFlows: FlowGraphSignalConnection[] = [];\r\n private _cachedActivationState: boolean[] = [];\r\n\r\n constructor(\r\n /**\r\n * the configuration of the block\r\n */\r\n public override config: IFlowGraphWaitAllBlockConfiguration\r\n ) {\r\n super(config);\r\n\r\n this.reset = this._registerSignalInput(\"reset\");\r\n this.completed = this._registerSignalOutput(\"completed\");\r\n this.remainingInputs = this.registerDataOutput(\"remainingInputs\", RichTypeNumber, this.config.inputSignalCount || 0);\r\n // The first inFlow is the default input signal all execution blocks have\r\n for (let i = 0; i < this.config.inputSignalCount; i++) {\r\n this.inFlows.push(this._registerSignalInput(`in_${i}`));\r\n }\r\n // no need for in\r\n this._unregisterSignalInput(\"in\");\r\n }\r\n\r\n private _getCurrentActivationState(context: FlowGraphContext) {\r\n const activationState = this._cachedActivationState;\r\n activationState.length = 0;\r\n if (!context._hasExecutionVariable(this, \"activationState\")) {\r\n for (let i = 0; i < this.config.inputSignalCount; i++) {\r\n activationState.push(false);\r\n }\r\n } else {\r\n const contextActivationState = context._getExecutionVariable(this, \"activationState\", [] as boolean[]);\r\n for (let i = 0; i < contextActivationState.length; i++) {\r\n activationState.push(contextActivationState[i]);\r\n }\r\n }\r\n return activationState;\r\n }\r\n\r\n public _execute(context: FlowGraphContext, callingSignal: FlowGraphSignalConnection): void {\r\n const activationState = this._getCurrentActivationState(context);\r\n if (callingSignal === this.reset) {\r\n for (let i = 0; i < this.config.inputSignalCount; i++) {\r\n activationState[i] = false;\r\n }\r\n } else {\r\n const index = this.inFlows.indexOf(callingSignal);\r\n if (index >= 0) {\r\n activationState[index] = true;\r\n }\r\n }\r\n this.remainingInputs.setValue(activationState.filter((v) => !v).length, context);\r\n\r\n context._setExecutionVariable(this, \"activationState\", activationState.slice());\r\n\r\n if (!activationState.includes(false)) {\r\n this.completed._activateSignal(context);\r\n for (let i = 0; i < this.config.inputSignalCount; i++) {\r\n activationState[i] = false;\r\n }\r\n } else {\r\n callingSignal !== this.reset && this.out._activateSignal(context);\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.WaitAll;\r\n }\r\n\r\n /**\r\n * Serializes this block into a object\r\n * @param serializationObject the object to serialize to\r\n */\r\n public override serialize(serializationObject?: any): void {\r\n super.serialize(serializationObject);\r\n serializationObject.config.inputFlows = this.config.inputSignalCount;\r\n }\r\n}\r\nRegisterClass(FlowGraphBlockNames.WaitAll, FlowGraphWaitAllBlock);\r\n"]}