@babylonjs/core 7.51.1 → 7.51.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (343) 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/ICanvas.d.ts +96 -1
  7. package/Engines/ICanvas.js.map +1 -1
  8. package/Engines/Native/nativeInterfaces.d.ts +7 -1
  9. package/Engines/Native/nativeInterfaces.js.map +1 -1
  10. package/Engines/WebGPU/webgpuTextureManager.js +3 -3
  11. package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
  12. package/Engines/abstractEngine.d.ts +7 -1
  13. package/Engines/abstractEngine.js +10 -2
  14. package/Engines/abstractEngine.js.map +1 -1
  15. package/Engines/constants.d.ts +32 -0
  16. package/Engines/constants.js +33 -0
  17. package/Engines/constants.js.map +1 -1
  18. package/Engines/nativeEngine.d.ts +7 -1
  19. package/Engines/nativeEngine.js +12 -0
  20. package/Engines/nativeEngine.js.map +1 -1
  21. package/Engines/webgpuEngine.js +6 -3
  22. package/Engines/webgpuEngine.js.map +1 -1
  23. package/FlowGraph/Blocks/Data/Math/flowGraphMathBlocks.d.ts +148 -465
  24. package/FlowGraph/Blocks/Data/Math/flowGraphMathBlocks.js +394 -691
  25. package/FlowGraph/Blocks/Data/Math/flowGraphMathBlocks.js.map +1 -1
  26. package/FlowGraph/Blocks/Data/Math/flowGraphMathCombineExtractBlocks.d.ts +142 -0
  27. package/FlowGraph/Blocks/Data/Math/flowGraphMathCombineExtractBlocks.js +342 -0
  28. package/FlowGraph/Blocks/Data/Math/flowGraphMathCombineExtractBlocks.js.map +1 -0
  29. package/FlowGraph/Blocks/Data/Math/flowGraphMatrixMathBlocks.d.ts +111 -0
  30. package/FlowGraph/Blocks/Data/Math/flowGraphMatrixMathBlocks.js +141 -0
  31. package/FlowGraph/Blocks/Data/Math/flowGraphMatrixMathBlocks.js.map +1 -0
  32. package/FlowGraph/Blocks/Data/Math/flowGraphVectorMathBlocks.d.ts +77 -0
  33. package/FlowGraph/Blocks/Data/Math/flowGraphVectorMathBlocks.js +139 -0
  34. package/FlowGraph/Blocks/Data/Math/flowGraphVectorMathBlocks.js.map +1 -0
  35. package/FlowGraph/Blocks/Data/Math/index.d.ts +3 -0
  36. package/FlowGraph/Blocks/Data/Math/index.js +3 -0
  37. package/FlowGraph/Blocks/Data/Math/index.js.map +1 -1
  38. package/FlowGraph/Blocks/Data/Transformers/flowGraphJsonPointerParserBlock.d.ts +85 -0
  39. package/FlowGraph/Blocks/Data/Transformers/flowGraphJsonPointerParserBlock.js +133 -0
  40. package/FlowGraph/Blocks/Data/Transformers/flowGraphJsonPointerParserBlock.js.map +1 -0
  41. package/FlowGraph/Blocks/Data/Transformers/flowGraphTypeToTypeBlocks.d.ts +49 -0
  42. package/FlowGraph/Blocks/Data/Transformers/flowGraphTypeToTypeBlocks.js +71 -0
  43. package/FlowGraph/Blocks/Data/Transformers/flowGraphTypeToTypeBlocks.js.map +1 -0
  44. package/FlowGraph/Blocks/Data/Transformers/index.d.ts +2 -0
  45. package/FlowGraph/Blocks/Data/Transformers/index.js +3 -0
  46. package/FlowGraph/Blocks/Data/Transformers/index.js.map +1 -0
  47. package/FlowGraph/Blocks/Data/Utils/flowGraphArrayIndexBlock.d.ts +39 -0
  48. package/FlowGraph/Blocks/Data/Utils/flowGraphArrayIndexBlock.js +46 -0
  49. package/FlowGraph/Blocks/Data/Utils/flowGraphArrayIndexBlock.js.map +1 -0
  50. package/FlowGraph/Blocks/Data/Utils/flowGraphCodeExecutionBlock.d.ts +35 -0
  51. package/FlowGraph/Blocks/Data/Utils/flowGraphCodeExecutionBlock.js +34 -0
  52. package/FlowGraph/Blocks/Data/Utils/flowGraphCodeExecutionBlock.js.map +1 -0
  53. package/FlowGraph/Blocks/Data/Utils/flowGraphContextBlock.d.ts +20 -0
  54. package/FlowGraph/Blocks/Data/Utils/flowGraphContextBlock.js +25 -0
  55. package/FlowGraph/Blocks/Data/Utils/flowGraphContextBlock.js.map +1 -0
  56. package/FlowGraph/Blocks/Data/Utils/flowGraphFunctionReferenceBlock.d.ts +34 -0
  57. package/FlowGraph/Blocks/Data/Utils/flowGraphFunctionReferenceBlock.js +35 -0
  58. package/FlowGraph/Blocks/Data/Utils/flowGraphFunctionReferenceBlock.js.map +1 -0
  59. package/FlowGraph/Blocks/Data/Utils/flowGraphIndexOfBlock.d.ts +39 -0
  60. package/FlowGraph/Blocks/Data/Utils/flowGraphIndexOfBlock.js +42 -0
  61. package/FlowGraph/Blocks/Data/Utils/flowGraphIndexOfBlock.js.map +1 -0
  62. package/FlowGraph/Blocks/Data/Utils/index.d.ts +5 -0
  63. package/FlowGraph/Blocks/Data/Utils/index.js +6 -0
  64. package/FlowGraph/Blocks/Data/Utils/index.js.map +1 -0
  65. package/FlowGraph/Blocks/Data/flowGraphBinaryOperationBlock.d.ts +0 -1
  66. package/FlowGraph/Blocks/Data/flowGraphBinaryOperationBlock.js +3 -2
  67. package/FlowGraph/Blocks/Data/flowGraphBinaryOperationBlock.js.map +1 -1
  68. package/FlowGraph/Blocks/Data/flowGraphCachedOperationBlock.d.ts +1 -1
  69. package/FlowGraph/Blocks/Data/flowGraphCachedOperationBlock.js +4 -4
  70. package/FlowGraph/Blocks/Data/flowGraphCachedOperationBlock.js.map +1 -1
  71. package/FlowGraph/Blocks/Data/flowGraphConditionalDataBlock.d.ts +6 -3
  72. package/FlowGraph/Blocks/Data/flowGraphConditionalDataBlock.js +12 -6
  73. package/FlowGraph/Blocks/Data/flowGraphConditionalDataBlock.js.map +1 -1
  74. package/FlowGraph/Blocks/Data/flowGraphConstantBlock.d.ts +0 -2
  75. package/FlowGraph/Blocks/Data/flowGraphConstantBlock.js +2 -3
  76. package/FlowGraph/Blocks/Data/flowGraphConstantBlock.js.map +1 -1
  77. package/FlowGraph/Blocks/Data/flowGraphConstantOperationBlock.d.ts +5 -4
  78. package/FlowGraph/Blocks/Data/flowGraphConstantOperationBlock.js +5 -4
  79. package/FlowGraph/Blocks/Data/flowGraphConstantOperationBlock.js.map +1 -1
  80. package/FlowGraph/Blocks/Data/flowGraphGetAssetBlock.d.ts +62 -0
  81. package/FlowGraph/Blocks/Data/flowGraphGetAssetBlock.js +41 -0
  82. package/FlowGraph/Blocks/Data/flowGraphGetAssetBlock.js.map +1 -0
  83. package/FlowGraph/Blocks/Data/flowGraphGetPropertyBlock.d.ts +38 -33
  84. package/FlowGraph/Blocks/Data/flowGraphGetPropertyBlock.js +42 -25
  85. package/FlowGraph/Blocks/Data/flowGraphGetPropertyBlock.js.map +1 -1
  86. package/FlowGraph/Blocks/Data/flowGraphGetVariableBlock.d.ts +11 -16
  87. package/FlowGraph/Blocks/Data/flowGraphGetVariableBlock.js +9 -17
  88. package/FlowGraph/Blocks/Data/flowGraphGetVariableBlock.js.map +1 -1
  89. package/FlowGraph/Blocks/Data/flowGraphTernaryOperationBlock.d.ts +1 -1
  90. package/FlowGraph/Blocks/Data/flowGraphTernaryOperationBlock.js +1 -1
  91. package/FlowGraph/Blocks/Data/flowGraphTernaryOperationBlock.js.map +1 -1
  92. package/FlowGraph/Blocks/Data/{flowGraphCoordinateTransformBlock.d.ts → flowGraphTransformCoordinatesSystemBlock.d.ts} +1 -2
  93. package/FlowGraph/Blocks/Data/{flowGraphCoordinateTransformBlock.js → flowGraphTransformCoordinatesSystemBlock.js} +4 -5
  94. package/FlowGraph/Blocks/Data/flowGraphTransformCoordinatesSystemBlock.js.map +1 -0
  95. package/FlowGraph/Blocks/Data/flowGraphUnaryOperationBlock.d.ts +1 -1
  96. package/FlowGraph/Blocks/Data/flowGraphUnaryOperationBlock.js +1 -1
  97. package/FlowGraph/Blocks/Data/flowGraphUnaryOperationBlock.js.map +1 -1
  98. package/FlowGraph/Blocks/Data/index.d.ts +7 -3
  99. package/FlowGraph/Blocks/Data/index.js +9 -4
  100. package/FlowGraph/Blocks/Data/index.js.map +1 -1
  101. package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.d.ts +45 -24
  102. package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.js +45 -51
  103. package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.js.map +1 -1
  104. package/FlowGraph/Blocks/Event/flowGraphPointerOutEventBlock.d.ts +61 -0
  105. package/FlowGraph/Blocks/Event/flowGraphPointerOutEventBlock.js +39 -0
  106. package/FlowGraph/Blocks/Event/flowGraphPointerOutEventBlock.js.map +1 -0
  107. package/FlowGraph/Blocks/Event/flowGraphPointerOverEventBlock.d.ts +61 -0
  108. package/FlowGraph/Blocks/Event/flowGraphPointerOverEventBlock.js +40 -0
  109. package/FlowGraph/Blocks/Event/flowGraphPointerOverEventBlock.js.map +1 -0
  110. package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.d.ts +12 -14
  111. package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js +19 -26
  112. package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js.map +1 -1
  113. package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.d.ts +6 -12
  114. package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.js +13 -24
  115. package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.js.map +1 -1
  116. package/FlowGraph/Blocks/Event/flowGraphSceneTickEventBlock.d.ts +31 -7
  117. package/FlowGraph/Blocks/Event/flowGraphSceneTickEventBlock.js +22 -20
  118. package/FlowGraph/Blocks/Event/flowGraphSceneTickEventBlock.js.map +1 -1
  119. package/FlowGraph/Blocks/{Execution → Event}/flowGraphSendCustomEventBlock.d.ts +12 -7
  120. package/FlowGraph/Blocks/Event/flowGraphSendCustomEventBlock.js +39 -0
  121. package/FlowGraph/Blocks/Event/flowGraphSendCustomEventBlock.js.map +1 -0
  122. package/FlowGraph/Blocks/Event/index.d.ts +3 -0
  123. package/FlowGraph/Blocks/Event/index.js +3 -0
  124. package/FlowGraph/Blocks/Event/index.js.map +1 -1
  125. package/FlowGraph/Blocks/Execution/Animation/flowGraphBezierCurveEasingBlock.d.ts +44 -0
  126. package/FlowGraph/Blocks/Execution/Animation/flowGraphBezierCurveEasingBlock.js +46 -0
  127. package/FlowGraph/Blocks/Execution/Animation/flowGraphBezierCurveEasingBlock.js.map +1 -0
  128. package/FlowGraph/Blocks/Execution/Animation/flowGraphEasingBlock.d.ts +60 -0
  129. package/FlowGraph/Blocks/Execution/Animation/flowGraphEasingBlock.js +93 -0
  130. package/FlowGraph/Blocks/Execution/Animation/flowGraphEasingBlock.js.map +1 -0
  131. package/FlowGraph/Blocks/Execution/Animation/flowGraphInterpolationBlock.d.ts +82 -0
  132. package/FlowGraph/Blocks/Execution/Animation/flowGraphInterpolationBlock.js +105 -0
  133. package/FlowGraph/Blocks/Execution/Animation/flowGraphInterpolationBlock.js.map +1 -0
  134. package/FlowGraph/Blocks/Execution/Animation/flowGraphPauseAnimationBlock.d.ts +2 -2
  135. package/FlowGraph/Blocks/Execution/Animation/flowGraphPauseAnimationBlock.js +2 -2
  136. package/FlowGraph/Blocks/Execution/Animation/flowGraphPauseAnimationBlock.js.map +1 -1
  137. package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.d.ts +40 -42
  138. package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js +116 -50
  139. package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js.map +1 -1
  140. package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.d.ts +12 -4
  141. package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.js +86 -8
  142. package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.js.map +1 -1
  143. package/FlowGraph/Blocks/Execution/Animation/index.d.ts +3 -0
  144. package/FlowGraph/Blocks/Execution/Animation/index.js +3 -0
  145. package/FlowGraph/Blocks/Execution/Animation/index.js.map +1 -1
  146. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphBranchBlock.d.ts +1 -2
  147. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphBranchBlock.js +3 -4
  148. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphBranchBlock.js.map +1 -1
  149. package/FlowGraph/Blocks/Execution/{Audio/flowGraphStopAudioBlock.d.ts → ControlFlow/flowGraphCancelDelayBlock.d.ts} +6 -8
  150. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCancelDelayBlock.js +31 -0
  151. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCancelDelayBlock.js.map +1 -0
  152. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCounterBlock.d.ts +2 -2
  153. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCounterBlock.js +5 -5
  154. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCounterBlock.js.map +1 -1
  155. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDebounceBlock.d.ts +0 -1
  156. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDebounceBlock.js +2 -3
  157. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDebounceBlock.js.map +1 -1
  158. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock.d.ts +5 -10
  159. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock.js +11 -15
  160. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock.js.map +1 -1
  161. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphFlipFlopBlock.d.ts +11 -3
  162. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphFlipFlopBlock.js +5 -6
  163. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphFlipFlopBlock.js.map +1 -1
  164. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphForLoopBlock.d.ts +27 -7
  165. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphForLoopBlock.js +28 -30
  166. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphForLoopBlock.js.map +1 -1
  167. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphMultiGateBlock.d.ts +13 -16
  168. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphMultiGateBlock.js +50 -52
  169. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphMultiGateBlock.js.map +1 -1
  170. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSequenceBlock.d.ts +8 -9
  171. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSequenceBlock.js +26 -13
  172. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSequenceBlock.js.map +1 -1
  173. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSetDelayBlock.d.ts +32 -0
  174. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSetDelayBlock.js +84 -0
  175. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSetDelayBlock.js.map +1 -0
  176. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSwitchBlock.d.ts +20 -6
  177. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSwitchBlock.js +55 -16
  178. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSwitchBlock.js.map +1 -1
  179. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.d.ts +3 -4
  180. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.js +36 -13
  181. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.js.map +1 -1
  182. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWaitAllBlock.d.ts +13 -5
  183. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWaitAllBlock.js +22 -17
  184. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWaitAllBlock.js.map +1 -1
  185. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock.d.ts +12 -16
  186. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock.js +21 -21
  187. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock.js.map +1 -1
  188. package/FlowGraph/Blocks/Execution/ControlFlow/index.d.ts +2 -1
  189. package/FlowGraph/Blocks/Execution/ControlFlow/index.js +2 -1
  190. package/FlowGraph/Blocks/Execution/ControlFlow/index.js.map +1 -1
  191. package/FlowGraph/Blocks/Execution/flowGraphConsoleLogBlock.d.ts +4 -5
  192. package/FlowGraph/Blocks/Execution/flowGraphConsoleLogBlock.js +13 -8
  193. package/FlowGraph/Blocks/Execution/flowGraphConsoleLogBlock.js.map +1 -1
  194. package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.d.ts +33 -36
  195. package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js +42 -26
  196. package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js.map +1 -1
  197. package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.d.ts +10 -25
  198. package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.js +38 -24
  199. package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.js.map +1 -1
  200. package/FlowGraph/Blocks/Execution/index.d.ts +0 -3
  201. package/FlowGraph/Blocks/Execution/index.js +0 -3
  202. package/FlowGraph/Blocks/Execution/index.js.map +1 -1
  203. package/FlowGraph/Blocks/flowGraphBlockFactory.d.ts +16 -0
  204. package/FlowGraph/Blocks/flowGraphBlockFactory.js +292 -0
  205. package/FlowGraph/Blocks/flowGraphBlockFactory.js.map +1 -0
  206. package/FlowGraph/Blocks/flowGraphBlockNames.d.ts +145 -0
  207. package/FlowGraph/Blocks/flowGraphBlockNames.js +147 -0
  208. package/FlowGraph/Blocks/flowGraphBlockNames.js.map +1 -0
  209. package/FlowGraph/Blocks/index.d.ts +2 -0
  210. package/FlowGraph/Blocks/index.js +2 -0
  211. package/FlowGraph/Blocks/index.js.map +1 -1
  212. package/FlowGraph/{flowGraphInteger.d.ts → CustomTypes/flowGraphInteger.d.ts} +2 -3
  213. package/FlowGraph/{flowGraphInteger.js → CustomTypes/flowGraphInteger.js} +4 -5
  214. package/FlowGraph/CustomTypes/flowGraphInteger.js.map +1 -0
  215. package/FlowGraph/CustomTypes/flowGraphMatrix.d.ts +196 -0
  216. package/FlowGraph/CustomTypes/flowGraphMatrix.js +272 -0
  217. package/FlowGraph/CustomTypes/flowGraphMatrix.js.map +1 -0
  218. package/FlowGraph/CustomTypes/index.d.ts +2 -0
  219. package/FlowGraph/CustomTypes/index.js +3 -0
  220. package/FlowGraph/CustomTypes/index.js.map +1 -0
  221. package/FlowGraph/flowGraph.d.ts +29 -34
  222. package/FlowGraph/flowGraph.js +120 -104
  223. package/FlowGraph/flowGraph.js.map +1 -1
  224. package/FlowGraph/flowGraphAssetsContext.d.ts +29 -0
  225. package/FlowGraph/flowGraphAssetsContext.js +52 -0
  226. package/FlowGraph/flowGraphAssetsContext.js.map +1 -0
  227. package/FlowGraph/flowGraphAsyncExecutionBlock.d.ts +15 -8
  228. package/FlowGraph/flowGraphAsyncExecutionBlock.js +25 -5
  229. package/FlowGraph/flowGraphAsyncExecutionBlock.js.map +1 -1
  230. package/FlowGraph/flowGraphBlock.d.ts +22 -15
  231. package/FlowGraph/flowGraphBlock.js +31 -52
  232. package/FlowGraph/flowGraphBlock.js.map +1 -1
  233. package/FlowGraph/flowGraphConnection.d.ts +13 -12
  234. package/FlowGraph/flowGraphConnection.js +31 -16
  235. package/FlowGraph/flowGraphConnection.js.map +1 -1
  236. package/FlowGraph/flowGraphContext.d.ts +89 -13
  237. package/FlowGraph/flowGraphContext.js +210 -23
  238. package/FlowGraph/flowGraphContext.js.map +1 -1
  239. package/FlowGraph/flowGraphCoordinator.d.ts +4 -10
  240. package/FlowGraph/flowGraphCoordinator.js +4 -16
  241. package/FlowGraph/flowGraphCoordinator.js.map +1 -1
  242. package/FlowGraph/flowGraphDataConnection.d.ts +52 -14
  243. package/FlowGraph/flowGraphDataConnection.js +73 -26
  244. package/FlowGraph/flowGraphDataConnection.js.map +1 -1
  245. package/FlowGraph/flowGraphEventBlock.d.ts +17 -1
  246. package/FlowGraph/flowGraphEventBlock.js +13 -2
  247. package/FlowGraph/flowGraphEventBlock.js.map +1 -1
  248. package/FlowGraph/flowGraphEventType.d.ts +16 -0
  249. package/FlowGraph/flowGraphEventType.js +18 -0
  250. package/FlowGraph/flowGraphEventType.js.map +1 -0
  251. package/FlowGraph/flowGraphExecutionBlock.d.ts +11 -1
  252. package/FlowGraph/flowGraphExecutionBlock.js +21 -2
  253. package/FlowGraph/flowGraphExecutionBlock.js.map +1 -1
  254. package/FlowGraph/flowGraphExecutionBlockWithOutSignal.d.ts +2 -2
  255. package/FlowGraph/flowGraphExecutionBlockWithOutSignal.js +0 -1
  256. package/FlowGraph/flowGraphExecutionBlockWithOutSignal.js.map +1 -1
  257. package/FlowGraph/flowGraphLogger.d.ts +60 -0
  258. package/FlowGraph/flowGraphLogger.js +53 -0
  259. package/FlowGraph/flowGraphLogger.js.map +1 -0
  260. package/FlowGraph/flowGraphParser.d.ts +85 -0
  261. package/FlowGraph/flowGraphParser.js +271 -0
  262. package/FlowGraph/flowGraphParser.js.map +1 -0
  263. package/FlowGraph/flowGraphPathConverter.d.ts +1 -1
  264. package/FlowGraph/flowGraphPathConverter.js +3 -2
  265. package/FlowGraph/flowGraphPathConverter.js.map +1 -1
  266. package/FlowGraph/flowGraphPathConverterComponent.d.ts +8 -1
  267. package/FlowGraph/flowGraphPathConverterComponent.js +18 -2
  268. package/FlowGraph/flowGraphPathConverterComponent.js.map +1 -1
  269. package/FlowGraph/flowGraphRichTypes.d.ts +51 -9
  270. package/FlowGraph/flowGraphRichTypes.js +160 -50
  271. package/FlowGraph/flowGraphRichTypes.js.map +1 -1
  272. package/FlowGraph/flowGraphSceneEventCoordinator.d.ts +45 -0
  273. package/FlowGraph/flowGraphSceneEventCoordinator.js +77 -0
  274. package/FlowGraph/flowGraphSceneEventCoordinator.js.map +1 -0
  275. package/FlowGraph/flowGraphSignalConnection.d.ts +8 -5
  276. package/FlowGraph/flowGraphSignalConnection.js +26 -9
  277. package/FlowGraph/flowGraphSignalConnection.js.map +1 -1
  278. package/FlowGraph/index.d.ts +6 -1
  279. package/FlowGraph/index.js +7 -1
  280. package/FlowGraph/index.js.map +1 -1
  281. package/FlowGraph/serialization.d.ts +5 -2
  282. package/FlowGraph/serialization.js +94 -22
  283. package/FlowGraph/serialization.js.map +1 -1
  284. package/FlowGraph/typeDefinitions.d.ts +74 -12
  285. package/FlowGraph/typeDefinitions.js.map +1 -1
  286. package/FlowGraph/utils.d.ts +47 -0
  287. package/FlowGraph/utils.js +55 -0
  288. package/FlowGraph/utils.js.map +1 -1
  289. package/Layers/effectLayer.d.ts +5 -0
  290. package/Layers/effectLayer.js +7 -0
  291. package/Layers/effectLayer.js.map +1 -1
  292. package/Loading/sceneLoader.d.ts +25 -11
  293. package/Loading/sceneLoader.js +28 -11
  294. package/Loading/sceneLoader.js.map +1 -1
  295. package/Materials/material.js +1 -0
  296. package/Materials/material.js.map +1 -1
  297. package/Maths/math.path.js +3 -0
  298. package/Maths/math.path.js.map +1 -1
  299. package/Meshes/csg2.d.ts +2 -2
  300. package/Meshes/csg2.js +2 -2
  301. package/Meshes/csg2.js.map +1 -1
  302. package/Meshes/geometry.d.ts +2 -1
  303. package/Meshes/geometry.js +8 -2
  304. package/Meshes/geometry.js.map +1 -1
  305. package/Meshes/instancedMesh.d.ts +5 -0
  306. package/Meshes/instancedMesh.js +6 -0
  307. package/Meshes/instancedMesh.js.map +1 -1
  308. package/Meshes/mesh.d.ts +2 -1
  309. package/Meshes/mesh.js +3 -2
  310. package/Meshes/mesh.js.map +1 -1
  311. package/Misc/environmentTextureTools.js +2 -2
  312. package/Misc/environmentTextureTools.js.map +1 -1
  313. package/ObjectModel/objectModelInterfaces.d.ts +2 -2
  314. package/ObjectModel/objectModelInterfaces.js.map +1 -1
  315. package/Rendering/IBLShadows/iblShadowsPluginMaterial.js +26 -18
  316. package/Rendering/IBLShadows/iblShadowsPluginMaterial.js.map +1 -1
  317. package/package.json +1 -1
  318. package/scene.js +8 -0
  319. package/scene.js.map +1 -1
  320. package/FlowGraph/Blocks/Data/Logic/flowGraphLogicBlocks.d.ts +0 -24
  321. package/FlowGraph/Blocks/Data/Logic/flowGraphLogicBlocks.js +0 -39
  322. package/FlowGraph/Blocks/Data/Logic/flowGraphLogicBlocks.js.map +0 -1
  323. package/FlowGraph/Blocks/Data/Logic/index.d.ts +0 -1
  324. package/FlowGraph/Blocks/Data/Logic/index.js +0 -2
  325. package/FlowGraph/Blocks/Data/Logic/index.js.map +0 -1
  326. package/FlowGraph/Blocks/Data/flowGraphCoordinateTransformBlock.js.map +0 -1
  327. package/FlowGraph/Blocks/Execution/Audio/flowGraphPlayAudioBlock.d.ts +0 -19
  328. package/FlowGraph/Blocks/Execution/Audio/flowGraphPlayAudioBlock.js +0 -26
  329. package/FlowGraph/Blocks/Execution/Audio/flowGraphPlayAudioBlock.js.map +0 -1
  330. package/FlowGraph/Blocks/Execution/Audio/flowGraphStopAudioBlock.js +0 -25
  331. package/FlowGraph/Blocks/Execution/Audio/flowGraphStopAudioBlock.js.map +0 -1
  332. package/FlowGraph/Blocks/Execution/Audio/index.d.ts +0 -2
  333. package/FlowGraph/Blocks/Execution/Audio/index.js +0 -3
  334. package/FlowGraph/Blocks/Execution/Audio/index.js.map +0 -1
  335. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphTimerBlock.d.ts +0 -31
  336. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphTimerBlock.js +0 -69
  337. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphTimerBlock.js.map +0 -1
  338. package/FlowGraph/Blocks/Execution/flowGraphSendCustomEventBlock.js +0 -38
  339. package/FlowGraph/Blocks/Execution/flowGraphSendCustomEventBlock.js.map +0 -1
  340. package/FlowGraph/flowGraphContextLogger.d.ts +0 -9
  341. package/FlowGraph/flowGraphContextLogger.js +0 -14
  342. package/FlowGraph/flowGraphContextLogger.js.map +0 -1
  343. package/FlowGraph/flowGraphInteger.js.map +0 -1
@@ -1,10 +1,9 @@
1
1
  import { RegisterClass } from "../../../../Misc/typeStore.js";
2
2
  import { FlowGraphExecutionBlock } from "../../../flowGraphExecutionBlock.js";
3
- import { RichTypeNumber } from "../../../flowGraphRichTypes.js";
3
+ import { RichTypeFlowGraphInteger } from "../../../flowGraphRichTypes.js";
4
+ import { FlowGraphInteger } from "../../../CustomTypes/flowGraphInteger.js";
4
5
  /**
5
- * @experimental
6
6
  * A block that has an input flow and routes it to any potential output flows, randomly or sequentially
7
- * @see https://docs.google.com/document/d/1MT7gL-IEn_PUw-4XGBazMxsyqsxqgAVGYcNeC4Cj_9Q/edit#heading=h.i2sn85fbjo60
8
7
  */
9
8
  export class FlowGraphMultiGateBlock extends FlowGraphExecutionBlock {
10
9
  constructor(
@@ -14,72 +13,71 @@ export class FlowGraphMultiGateBlock extends FlowGraphExecutionBlock {
14
13
  config) {
15
14
  super(config);
16
15
  this.config = config;
17
- this._cachedUnusedIndexes = [];
16
+ /**
17
+ * Output connections: The output signals.
18
+ */
19
+ this.outputSignals = [];
18
20
  this.reset = this._registerSignalInput("reset");
19
- this.currentIndex = this.registerDataOutput("currentIndex", RichTypeNumber);
20
- this.config.startIndex = this.config.startIndex !== undefined ? this.config.startIndex : 0;
21
- this.config.startIndex = Math.max(0, Math.min(this.config.startIndex, this.config.numberOutputFlows - 1));
22
- this.outFlows = [];
23
- for (let i = 0; i < this.config.numberOutputFlows; i++) {
24
- this.outFlows.push(this._registerSignalOutput(`out${i}`));
25
- }
21
+ this.lastIndex = this.registerDataOutput("lastIndex", RichTypeFlowGraphInteger, new FlowGraphInteger(-1));
22
+ this.setNumberOfOutputSignals(config?.outputSignalCount);
26
23
  }
27
- _getUnusedIndexes(context) {
28
- const result = this._cachedUnusedIndexes;
29
- result.length = 0;
30
- if (!context._hasExecutionVariable(this, "unusedIndexes")) {
31
- for (let i = 0; i < this.config.numberOutputFlows; i++) {
32
- result.push(i);
24
+ _getNextIndex(indexesUsed) {
25
+ // find the next index available from the indexes used array
26
+ // if all outputs were used, reset the indexes used array if we are in a loop multi gate
27
+ if (!indexesUsed.includes(false)) {
28
+ if (this.config.isLoop) {
29
+ indexesUsed.fill(false);
33
30
  }
34
31
  }
32
+ if (!this.config.isRandom) {
33
+ return indexesUsed.indexOf(false);
34
+ }
35
35
  else {
36
- const contextUnusedIndexes = context._getExecutionVariable(this, "unusedIndexes");
37
- for (let i = 0; i < contextUnusedIndexes.length; i++) {
38
- result.push(contextUnusedIndexes[i]);
39
- }
36
+ const unusedIndexes = indexesUsed.map((used, index) => (used ? -1 : index)).filter((index) => index !== -1);
37
+ return unusedIndexes.length ? unusedIndexes[Math.floor(Math.random() * unusedIndexes.length)] : -1;
40
38
  }
41
- return result;
42
39
  }
43
- _getNextOutput(currentIndex, unusedIndexes) {
44
- if (this.config.isRandom) {
45
- const nextIndex = Math.floor(Math.random() * unusedIndexes.length);
46
- return unusedIndexes[nextIndex];
40
+ /**
41
+ * Sets the block's output signals. Would usually be passed from the constructor but can be changed afterwards.
42
+ * @param numberOutputSignals the number of output flows
43
+ */
44
+ setNumberOfOutputSignals(numberOutputSignals = 1) {
45
+ // check the size of the outFlow Array, see if it is not larger than needed
46
+ while (this.outputSignals.length > numberOutputSignals) {
47
+ const flow = this.outputSignals.pop();
48
+ if (flow) {
49
+ flow.disconnectFromAll();
50
+ this._unregisterSignalOutput(flow.name);
51
+ }
47
52
  }
48
- else {
49
- return currentIndex + 1;
53
+ while (this.outputSignals.length < numberOutputSignals) {
54
+ this.outputSignals.push(this._registerSignalOutput(`out_${this.outputSignals.length}`));
50
55
  }
51
56
  }
52
57
  _execute(context, callingSignal) {
53
- const currentIndex = context._getExecutionVariable(this, "currentIndex") ?? this.config.startIndex - 1;
54
- let unusedIndexes = this._getUnusedIndexes(context);
55
- if (callingSignal === this.reset) {
56
- context._deleteExecutionVariable(this, "currentIndex");
57
- context._deleteExecutionVariable(this, "unusedIndexes");
58
- return;
58
+ // set the state(s) of the block
59
+ if (!context._hasExecutionVariable(this, "indexesUsed")) {
60
+ context._setExecutionVariable(this, "indexesUsed", this.outputSignals.map(() => false));
59
61
  }
60
- let nextIndex = this._getNextOutput(currentIndex, unusedIndexes);
61
- if (nextIndex >= this.config.numberOutputFlows && this.config.loop) {
62
- nextIndex = 0;
63
- }
64
- else if (nextIndex >= this.config.numberOutputFlows && !this.config.loop) {
62
+ if (callingSignal === this.reset) {
63
+ context._deleteExecutionVariable(this, "indexesUsed");
64
+ this.lastIndex.setValue(new FlowGraphInteger(-1), context);
65
65
  return;
66
66
  }
67
- unusedIndexes = unusedIndexes.filter((i) => i !== nextIndex);
68
- if (unusedIndexes.length === 0) {
69
- for (let i = 0; i < this.config.numberOutputFlows; i++) {
70
- unusedIndexes.push(i);
71
- }
67
+ const indexesUsed = context._getExecutionVariable(this, "indexesUsed", []);
68
+ const nextIndex = this._getNextIndex(indexesUsed);
69
+ if (nextIndex > -1) {
70
+ this.lastIndex.setValue(new FlowGraphInteger(nextIndex), context);
71
+ indexesUsed[nextIndex] = true;
72
+ context._setExecutionVariable(this, "indexesUsed", indexesUsed);
73
+ this.outputSignals[nextIndex]._activateSignal(context);
72
74
  }
73
- context._setExecutionVariable(this, "unusedIndexes", unusedIndexes);
74
- context._setExecutionVariable(this, "currentIndex", nextIndex);
75
- this.currentIndex.setValue(nextIndex, context);
76
- this.outFlows[nextIndex]._activateSignal(context);
77
75
  }
78
76
  /**
79
77
  * @returns class name of the block.
80
78
  */
81
79
  getClassName() {
82
- return "FGMultiGateBlock";
80
+ return "FlowGraphMultiGateBlock" /* FlowGraphBlockNames.MultiGate */;
83
81
  }
84
82
  /**
85
83
  * Serializes the block.
@@ -87,11 +85,11 @@ export class FlowGraphMultiGateBlock extends FlowGraphExecutionBlock {
87
85
  */
88
86
  serialize(serializationObject) {
89
87
  super.serialize(serializationObject);
90
- serializationObject.config.numberOutputFlows = this.config.numberOutputFlows;
88
+ serializationObject.config.outputSignalCount = this.config.outputSignalCount;
91
89
  serializationObject.config.isRandom = this.config.isRandom;
92
- serializationObject.config.loop = this.config.loop;
90
+ serializationObject.config.loop = this.config.isLoop;
93
91
  serializationObject.config.startIndex = this.config.startIndex;
94
92
  }
95
93
  }
96
- RegisterClass("FGMultiGateBlock", FlowGraphMultiGateBlock);
94
+ RegisterClass("FlowGraphMultiGateBlock" /* FlowGraphBlockNames.MultiGate */, FlowGraphMultiGateBlock);
97
95
  //# sourceMappingURL=flowGraphMultiGateBlock.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"flowGraphMultiGateBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/FlowGraph/Blocks/Execution/ControlFlow/flowGraphMultiGateBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAG3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAyB7D;;;;GAIG;AACH,MAAM,OAAO,uBAAwB,SAAQ,uBAAuB;IAehE;IACI;;OAEG;IACa,MAA6C;QAE7D,KAAK,CAAC,MAAM,CAAC,CAAC;QAFE,WAAM,GAAN,MAAM,CAAuC;QANzD,yBAAoB,GAAa,EAAE,CAAC;QASxC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;QAChD,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,kBAAkB,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC;QAC5E,IAAI,CAAC,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3F,IAAI,CAAC,MAAM,CAAC,UAAU,GAAG,IAA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AAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAC,EAAE,EAAE,CAAC;gBACrD,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAC1B,CAAC;QACL,CAAC;QACD,OAAO,CAAC,qBAAqB,CAAC,IAAI,EAAE,eAAe,EAAE,aAAa,CAAC,CAAC;QACpE,OAAO,CAAC,qBAAqB,CAAC,IAAI,EAAE,cAAc,EAAE,SAAS,CAAC,CAAC;QAC/D,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAC/C,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IACtD,CAAC;IAED;;OAEG;IACa,YAAY;QACxB,OAAO,kBAAkB,CAAC;IAC9B,CAAC;IAED;;;OAGG;IACa,SAAS,CAAC,mBAAyB;QAC/C,KAAK,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAAC;QACrC,mBAAmB,CAAC,MAAM,CAAC,iBAAiB,GAAG,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC;QAC7E,mBAAmB,CAAC,MAAM,CAAC,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;QAC3D,mBAAmB,CAAC,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;QACnD,mBAAmB,CAAC,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC;IACnE,CAAC;CACJ;AACD,aAAa,CAAC,kBAAkB,EAAE,uBAAuB,CAAC,CAAC","sourcesContent":["import { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport type { FlowGraphContext } from \"../../../flowGraphContext\";\r\nimport type { FlowGraphDataConnection } from \"../../../flowGraphDataConnection\";\r\nimport { FlowGraphExecutionBlock } from \"../../../flowGraphExecutionBlock\";\r\nimport { RichTypeNumber } from \"../../../flowGraphRichTypes\";\r\nimport type { FlowGraphSignalConnection } from \"../../../flowGraphSignalConnection\";\r\nimport type { IFlowGraphBlockConfiguration } from \"../../../flowGraphBlock\";\r\n/**\r\n * @experimental\r\n * Configuration for the multi gate block.\r\n */\r\nexport interface IFlowGraphMultiGateBlockConfiguration extends IFlowGraphBlockConfiguration {\r\n /**\r\n * The number of output flows.\r\n */\r\n numberOutputFlows: number;\r\n /**\r\n * If the block should pick a random output flow from the ones that haven't been executed. Default to false.\r\n */\r\n isRandom?: boolean;\r\n /**\r\n * If the block should loop back to the first output flow after executing the last one. Default to false.\r\n */\r\n loop?: boolean;\r\n /**\r\n * The index of the output flow to start with. Default to 0.\r\n */\r\n startIndex?: number;\r\n}\r\n/**\r\n * @experimental\r\n * A block that has an input flow and routes it to any potential output flows, randomly or sequentially\r\n * @see https://docs.google.com/document/d/1MT7gL-IEn_PUw-4XGBazMxsyqsxqgAVGYcNeC4Cj_9Q/edit#heading=h.i2sn85fbjo60\r\n */\r\nexport class FlowGraphMultiGateBlock extends FlowGraphExecutionBlock {\r\n /**\r\n * Input connection: Resets the gate.\r\n */\r\n public readonly reset: FlowGraphSignalConnection;\r\n /**\r\n * Output connections: The output flows.\r\n */\r\n public outFlows: FlowGraphSignalConnection[];\r\n /**\r\n * Output connection: The index of the current output flow.\r\n */\r\n public readonly currentIndex: FlowGraphDataConnection<number>;\r\n private _cachedUnusedIndexes: number[] = [];\r\n\r\n constructor(\r\n /**\r\n * the configuration of the block\r\n */\r\n public override config: IFlowGraphMultiGateBlockConfiguration\r\n ) {\r\n super(config);\r\n this.reset = this._registerSignalInput(\"reset\");\r\n this.currentIndex = this.registerDataOutput(\"currentIndex\", RichTypeNumber);\r\n this.config.startIndex = this.config.startIndex !== undefined ? this.config.startIndex : 0;\r\n this.config.startIndex = Math.max(0, Math.min(this.config.startIndex!, this.config.numberOutputFlows - 1));\r\n this.outFlows = [];\r\n for (let i = 0; i < this.config.numberOutputFlows; i++) {\r\n this.outFlows.push(this._registerSignalOutput(`out${i}`));\r\n }\r\n }\r\n\r\n private _getUnusedIndexes(context: FlowGraphContext): number[] {\r\n const result = this._cachedUnusedIndexes;\r\n result.length = 0;\r\n if (!context._hasExecutionVariable(this, \"unusedIndexes\")) {\r\n for (let i = 0; i < this.config.numberOutputFlows; i++) {\r\n result.push(i);\r\n }\r\n } else {\r\n const contextUnusedIndexes = context._getExecutionVariable(this, \"unusedIndexes\");\r\n for (let i = 0; i < contextUnusedIndexes.length; i++) {\r\n result.push(contextUnusedIndexes[i]);\r\n }\r\n }\r\n return result;\r\n }\r\n\r\n private _getNextOutput(currentIndex: number, unusedIndexes: number[]): number {\r\n if (this.config.isRandom) {\r\n const nextIndex = Math.floor(Math.random() * unusedIndexes.length);\r\n return unusedIndexes[nextIndex];\r\n } else {\r\n return currentIndex + 1;\r\n }\r\n }\r\n\r\n public _execute(context: FlowGraphContext, callingSignal: FlowGraphSignalConnection): void {\r\n const currentIndex = context._getExecutionVariable(this, \"currentIndex\") ?? this.config.startIndex! - 1;\r\n let unusedIndexes = this._getUnusedIndexes(context);\r\n\r\n if (callingSignal === this.reset) {\r\n context._deleteExecutionVariable(this, \"currentIndex\");\r\n context._deleteExecutionVariable(this, \"unusedIndexes\");\r\n return;\r\n }\r\n\r\n let nextIndex = this._getNextOutput(currentIndex, unusedIndexes);\r\n if (nextIndex >= this.config.numberOutputFlows && this.config.loop) {\r\n nextIndex = 0;\r\n } else if (nextIndex >= this.config.numberOutputFlows && !this.config.loop) {\r\n return;\r\n }\r\n\r\n unusedIndexes = unusedIndexes.filter((i) => i !== nextIndex);\r\n if (unusedIndexes.length === 0) {\r\n for (let i = 0; i < this.config.numberOutputFlows; i++) {\r\n unusedIndexes.push(i);\r\n }\r\n }\r\n context._setExecutionVariable(this, \"unusedIndexes\", unusedIndexes);\r\n context._setExecutionVariable(this, \"currentIndex\", nextIndex);\r\n this.currentIndex.setValue(nextIndex, context);\r\n this.outFlows[nextIndex]._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 \"FGMultiGateBlock\";\r\n }\r\n\r\n /**\r\n * Serializes the block.\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.numberOutputFlows = this.config.numberOutputFlows;\r\n serializationObject.config.isRandom = this.config.isRandom;\r\n serializationObject.config.loop = this.config.loop;\r\n serializationObject.config.startIndex = this.config.startIndex;\r\n }\r\n}\r\nRegisterClass(\"FGMultiGateBlock\", FlowGraphMultiGateBlock);\r\n"]}
1
+ {"version":3,"file":"flowGraphMultiGateBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/FlowGraph/Blocks/Execution/ControlFlow/flowGraphMultiGateBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAG3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AAIvE,OAAO,EAAE,gBAAgB,EAAE,iDAAoD;AAmB/E;;GAEG;AACH,MAAM,OAAO,uBAAwB,SAAQ,uBAAuB;IAchE;IACI;;OAEG;IACa,MAA6C;QAE7D,KAAK,CAAC,MAAM,CAAC,CAAC;QAFE,WAAM,GAAN,MAAM,CAAuC;QAbjE;;WAEG;QACa,kBAAa,GAAgC,EAAE,CAAC;QAa5D,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;QAChD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,kBAAkB,CAAC,WAAW,EAAE,wBAAwB,EAAE,IAAI,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1G,IAAI,CAAC,wBAAwB,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAC7D,CAAC;IAEO,aAAa,CAAC,W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ED;;OAEG;IACa,YAAY;QACxB,qEAAqC;IACzC,CAAC;IAED;;;OAGG;IACa,SAAS,CAAC,mBAAyB;QAC/C,KAAK,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAAC;QACrC,mBAAmB,CAAC,MAAM,CAAC,iBAAiB,GAAG,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC;QAC7E,mBAAmB,CAAC,MAAM,CAAC,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;QAC3D,mBAAmB,CAAC,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;QACrD,mBAAmB,CAAC,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC;IACnE,CAAC;CACJ;AACD,aAAa,gEAAgC,uBAAuB,CAAC,CAAC","sourcesContent":["import { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport type { FlowGraphContext } from \"../../../flowGraphContext\";\r\nimport type { FlowGraphDataConnection } from \"../../../flowGraphDataConnection\";\r\nimport { FlowGraphExecutionBlock } from \"../../../flowGraphExecutionBlock\";\r\nimport { RichTypeFlowGraphInteger } from \"../../../flowGraphRichTypes\";\r\nimport type { FlowGraphSignalConnection } from \"../../../flowGraphSignalConnection\";\r\nimport type { IFlowGraphBlockConfiguration } from \"../../../flowGraphBlock\";\r\nimport { FlowGraphBlockNames } from \"../../flowGraphBlockNames\";\r\nimport { FlowGraphInteger } from \"core/FlowGraph/CustomTypes/flowGraphInteger\";\r\n/**\r\n * Configuration for the multi gate block.\r\n */\r\nexport interface IFlowGraphMultiGateBlockConfiguration extends IFlowGraphBlockConfiguration {\r\n /**\r\n * The number of output signals. Required.\r\n */\r\n outputSignalCount: number;\r\n /**\r\n * If the block should pick a random output flow from the ones that haven't been executed. Default to false.\r\n */\r\n isRandom?: boolean;\r\n /**\r\n * If the block should loop back to the first output flow after executing the last one. Default to false.\r\n */\r\n isLoop?: boolean;\r\n}\r\n\r\n/**\r\n * A block that has an input flow and routes it to any potential output flows, randomly or sequentially\r\n */\r\nexport class FlowGraphMultiGateBlock extends FlowGraphExecutionBlock {\r\n /**\r\n * Input connection: Resets the gate.\r\n */\r\n public readonly reset: FlowGraphSignalConnection;\r\n /**\r\n * Output connections: The output signals.\r\n */\r\n public readonly outputSignals: FlowGraphSignalConnection[] = [];\r\n /**\r\n * Output connection: The index of the current output flow.\r\n */\r\n public readonly lastIndex: FlowGraphDataConnection<FlowGraphInteger>;\r\n\r\n constructor(\r\n /**\r\n * the configuration of the block\r\n */\r\n public override config: IFlowGraphMultiGateBlockConfiguration\r\n ) {\r\n super(config);\r\n this.reset = this._registerSignalInput(\"reset\");\r\n this.lastIndex = this.registerDataOutput(\"lastIndex\", RichTypeFlowGraphInteger, new FlowGraphInteger(-1));\r\n this.setNumberOfOutputSignals(config?.outputSignalCount);\r\n }\r\n\r\n private _getNextIndex(indexesUsed: boolean[]): number {\r\n // find the next index available from the indexes used array\r\n\r\n // if all outputs were used, reset the indexes used array if we are in a loop multi gate\r\n if (!indexesUsed.includes(false)) {\r\n if (this.config.isLoop) {\r\n indexesUsed.fill(false);\r\n }\r\n }\r\n if (!this.config.isRandom) {\r\n return indexesUsed.indexOf(false);\r\n } else {\r\n const unusedIndexes = indexesUsed.map((used, index) => (used ? -1 : index)).filter((index) => index !== -1);\r\n return unusedIndexes.length ? unusedIndexes[Math.floor(Math.random() * unusedIndexes.length)] : -1;\r\n }\r\n }\r\n\r\n /**\r\n * Sets the block's output signals. Would usually be passed from the constructor but can be changed afterwards.\r\n * @param numberOutputSignals the number of output flows\r\n */\r\n public setNumberOfOutputSignals(numberOutputSignals: number = 1) {\r\n // check the size of the outFlow Array, see if it is not larger than needed\r\n while (this.outputSignals.length > numberOutputSignals) {\r\n const flow = this.outputSignals.pop();\r\n if (flow) {\r\n flow.disconnectFromAll();\r\n this._unregisterSignalOutput(flow.name);\r\n }\r\n }\r\n\r\n while (this.outputSignals.length < numberOutputSignals) {\r\n this.outputSignals.push(this._registerSignalOutput(`out_${this.outputSignals.length}`));\r\n }\r\n }\r\n\r\n public _execute(context: FlowGraphContext, callingSignal: FlowGraphSignalConnection): void {\r\n // set the state(s) of the block\r\n if (!context._hasExecutionVariable(this, \"indexesUsed\")) {\r\n context._setExecutionVariable(\r\n this,\r\n \"indexesUsed\",\r\n this.outputSignals.map(() => false)\r\n );\r\n }\r\n\r\n if (callingSignal === this.reset) {\r\n context._deleteExecutionVariable(this, \"indexesUsed\");\r\n this.lastIndex.setValue(new FlowGraphInteger(-1), context);\r\n return;\r\n }\r\n const indexesUsed = context._getExecutionVariable(this, \"indexesUsed\", [] as boolean[]);\r\n const nextIndex = this._getNextIndex(indexesUsed);\r\n if (nextIndex > -1) {\r\n this.lastIndex.setValue(new FlowGraphInteger(nextIndex), context);\r\n indexesUsed[nextIndex] = true;\r\n context._setExecutionVariable(this, \"indexesUsed\", indexesUsed);\r\n this.outputSignals[nextIndex]._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.MultiGate;\r\n }\r\n\r\n /**\r\n * Serializes the block.\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.outputSignalCount = this.config.outputSignalCount;\r\n serializationObject.config.isRandom = this.config.isRandom;\r\n serializationObject.config.loop = this.config.isLoop;\r\n serializationObject.config.startIndex = this.config.startIndex;\r\n }\r\n}\r\nRegisterClass(FlowGraphBlockNames.MultiGate, FlowGraphMultiGateBlock);\r\n"]}
@@ -3,17 +3,15 @@ import type { FlowGraphContext } from "../../../flowGraphContext";
3
3
  import { FlowGraphExecutionBlock } from "../../../flowGraphExecutionBlock";
4
4
  import type { FlowGraphSignalConnection } from "../../../flowGraphSignalConnection";
5
5
  /**
6
- * @experimental
7
6
  * Configuration for the sequence block.
8
7
  */
9
8
  export interface IFlowGraphSequenceBlockConfiguration extends IFlowGraphBlockConfiguration {
10
9
  /**
11
- * The number of output flows.
10
+ * The number of output signals. Defaults to 1.
12
11
  */
13
- numberOutputFlows: number;
12
+ outputSignalCount?: number;
14
13
  }
15
14
  /**
16
- * @experimental
17
15
  * A block that executes its output flows in sequence.
18
16
  */
19
17
  export declare class FlowGraphSequenceBlock extends FlowGraphExecutionBlock {
@@ -24,7 +22,7 @@ export declare class FlowGraphSequenceBlock extends FlowGraphExecutionBlock {
24
22
  /**
25
23
  * The output flows.
26
24
  */
27
- outFlows: FlowGraphSignalConnection[];
25
+ executionSignals: FlowGraphSignalConnection[];
28
26
  constructor(
29
27
  /**
30
28
  * the configuration of the block
@@ -32,11 +30,12 @@ export declare class FlowGraphSequenceBlock extends FlowGraphExecutionBlock {
32
30
  config: IFlowGraphSequenceBlockConfiguration);
33
31
  _execute(context: FlowGraphContext): void;
34
32
  /**
35
- * @returns class name of the block.
33
+ * Sets the block's output flows. Would usually be passed from the constructor but can be changed afterwards.
34
+ * @param outputSignalCount the number of output flows
36
35
  */
37
- getClassName(): string;
36
+ setNumberOfOutputSignals(outputSignalCount?: number): void;
38
37
  /**
39
- * the class name of the block.
38
+ * @returns class name of the block.
40
39
  */
41
- static ClassName: string;
40
+ getClassName(): string;
42
41
  }
@@ -1,7 +1,6 @@
1
1
  import { RegisterClass } from "../../../../Misc/typeStore.js";
2
2
  import { FlowGraphExecutionBlock } from "../../../flowGraphExecutionBlock.js";
3
3
  /**
4
- * @experimental
5
4
  * A block that executes its output flows in sequence.
6
5
  */
7
6
  export class FlowGraphSequenceBlock extends FlowGraphExecutionBlock {
@@ -12,26 +11,40 @@ export class FlowGraphSequenceBlock extends FlowGraphExecutionBlock {
12
11
  config) {
13
12
  super(config);
14
13
  this.config = config;
15
- this.outFlows = [];
16
- for (let i = 0; i < this.config.numberOutputFlows; i++) {
17
- this.outFlows.push(this._registerSignalOutput(`${i}`));
18
- }
14
+ /**
15
+ * The output flows.
16
+ */
17
+ this.executionSignals = [];
18
+ this.setNumberOfOutputSignals(this.config.outputSignalCount);
19
19
  }
20
20
  _execute(context) {
21
- for (let i = 0; i < this.config.numberOutputFlows; i++) {
22
- this.outFlows[i]._activateSignal(context);
21
+ for (let i = 0; i < this.executionSignals.length; i++) {
22
+ this.executionSignals[i]._activateSignal(context);
23
+ }
24
+ }
25
+ /**
26
+ * Sets the block's output flows. Would usually be passed from the constructor but can be changed afterwards.
27
+ * @param outputSignalCount the number of output flows
28
+ */
29
+ setNumberOfOutputSignals(outputSignalCount = 1) {
30
+ // check the size of the outFlow Array, see if it is not larger than needed
31
+ while (this.executionSignals.length > outputSignalCount) {
32
+ const flow = this.executionSignals.pop();
33
+ if (flow) {
34
+ flow.disconnectFromAll();
35
+ this._unregisterSignalOutput(flow.name);
36
+ }
37
+ }
38
+ while (this.executionSignals.length < outputSignalCount) {
39
+ this.executionSignals.push(this._registerSignalOutput(`out_${this.executionSignals.length}`));
23
40
  }
24
41
  }
25
42
  /**
26
43
  * @returns class name of the block.
27
44
  */
28
45
  getClassName() {
29
- return FlowGraphSequenceBlock.ClassName;
46
+ return "FlowGraphSequenceBlock" /* FlowGraphBlockNames.Sequence */;
30
47
  }
31
48
  }
32
- /**
33
- * the class name of the block.
34
- */
35
- FlowGraphSequenceBlock.ClassName = "FGSequenceBlock";
36
- RegisterClass(FlowGraphSequenceBlock.ClassName, FlowGraphSequenceBlock);
49
+ RegisterClass("FlowGraphSequenceBlock" /* FlowGraphBlockNames.Sequence */, FlowGraphSequenceBlock);
37
50
  //# sourceMappingURL=flowGraphSequenceBlock.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"flowGraphSequenceBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSequenceBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAG3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAc3E;;;GAGG;AACH,MAAM,OAAO,sBAAuB,SAAQ,uBAAuB;IAM/D;IACI;;OAEG;IACa,MAA4C;QAE5D,KAAK,CAAC,MAAM,CAAC,CAAC;QAFE,WAAM,GAAN,MAAM,CAAsC;QAG5D,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;QACnB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAC,EAAE,EAAE,CAAC;YACrD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;QAC3D,CAAC;IACL,CAAC;IAEM,QAAQ,CAAC,OAAyB;QACrC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAC,EAAE,EAAE,CAAC;YACrD,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QAC9C,CAAC;IACL,CAAC;IAED;;OAEG;IACa,YAAY;QACxB,OAAO,sBAAsB,CAAC,SAAS,CAAC;IAC5C,CAAC;;AAED;;GAEG;AACW,gCAAS,GAAG,iBAAiB,CAAC;AAEhD,aAAa,CAAC,sBAAsB,CAAC,SAAS,EAAE,sBAAsB,CAAC,CAAC","sourcesContent":["import { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport type { IFlowGraphBlockConfiguration } from \"../../../flowGraphBlock\";\r\nimport type { FlowGraphContext } from \"../../../flowGraphContext\";\r\nimport { FlowGraphExecutionBlock } from \"../../../flowGraphExecutionBlock\";\r\nimport type { FlowGraphSignalConnection } from \"../../../flowGraphSignalConnection\";\r\n\r\n/**\r\n * @experimental\r\n * Configuration for the sequence block.\r\n */\r\nexport interface IFlowGraphSequenceBlockConfiguration extends IFlowGraphBlockConfiguration {\r\n /**\r\n * The number of output flows.\r\n */\r\n numberOutputFlows: number;\r\n}\r\n\r\n/**\r\n * @experimental\r\n * A block that executes its output flows in sequence.\r\n */\r\nexport class FlowGraphSequenceBlock extends FlowGraphExecutionBlock {\r\n /**\r\n * The output flows.\r\n */\r\n public outFlows: FlowGraphSignalConnection[];\r\n\r\n constructor(\r\n /**\r\n * the configuration of the block\r\n */\r\n public override config: IFlowGraphSequenceBlockConfiguration\r\n ) {\r\n super(config);\r\n this.outFlows = [];\r\n for (let i = 0; i < this.config.numberOutputFlows; i++) {\r\n this.outFlows.push(this._registerSignalOutput(`${i}`));\r\n }\r\n }\r\n\r\n public _execute(context: FlowGraphContext) {\r\n for (let i = 0; i < this.config.numberOutputFlows; i++) {\r\n this.outFlows[i]._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 FlowGraphSequenceBlock.ClassName;\r\n }\r\n\r\n /**\r\n * the class name of the block.\r\n */\r\n public static ClassName = \"FGSequenceBlock\";\r\n}\r\nRegisterClass(FlowGraphSequenceBlock.ClassName, FlowGraphSequenceBlock);\r\n"]}
1
+ {"version":3,"file":"flowGraphSequenceBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSequenceBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAI3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAa3E;;GAEG;AACH,MAAM,OAAO,sBAAuB,SAAQ,uBAAuB;IAM/D;IACI;;OAEG;IACa,MAA4C;QAE5D,KAAK,CAAC,MAAM,CAAC,CAAC;QAFE,WAAM,GAAN,MAAM,CAAsC;QAThE;;WAEG;QACI,qBAAgB,GAAgC,EAAE,CAAC;QAStD,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;IACjE,CAAC;IAEM,QAAQ,CAAC,OAAyB;QACrC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACpD,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QACtD,CAAC;IACL,CAAC;IAED;;;OAGG;IACI,wBAAwB,CAAC,oBAA4B,CAAC;QACzD,2EAA2E;QAC3E,OAAO,IAAI,CAAC,gBAAgB,CAAC,MAAM,GAAG,iBAAiB,EAAE,CAAC;YACtD,MAAM,IAAI,GAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,EAAE,CAAC;YACzC,IAAI,IAAI,EAAE,CAAC;gBACP,IAAI,CAAC,iBAAiB,EAAE,CAAC;gBACzB,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC5C,CAAC;QACL,CAAC;QAED,OAAO,IAAI,CAAC,gBAAgB,CAAC,MAAM,GAAG,iBAAiB,EAAE,CAAC;YACtD,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,OAAO,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QAClG,CAAC;IACL,CAAC;IAED;;OAEG;IACa,YAAY;QACxB,mEAAoC;IACxC,CAAC;CACJ;AAED,aAAa,8DAA+B,sBAAsB,CAAC,CAAC","sourcesContent":["import { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { FlowGraphBlockNames } from \"../../flowGraphBlockNames\";\r\nimport type { IFlowGraphBlockConfiguration } from \"../../../flowGraphBlock\";\r\nimport type { FlowGraphContext } from \"../../../flowGraphContext\";\r\nimport { FlowGraphExecutionBlock } from \"../../../flowGraphExecutionBlock\";\r\nimport type { FlowGraphSignalConnection } from \"../../../flowGraphSignalConnection\";\r\n\r\n/**\r\n * Configuration for the sequence block.\r\n */\r\nexport interface IFlowGraphSequenceBlockConfiguration extends IFlowGraphBlockConfiguration {\r\n /**\r\n * The number of output signals. Defaults to 1.\r\n */\r\n outputSignalCount?: number;\r\n}\r\n\r\n/**\r\n * A block that executes its output flows in sequence.\r\n */\r\nexport class FlowGraphSequenceBlock extends FlowGraphExecutionBlock {\r\n /**\r\n * The output flows.\r\n */\r\n public executionSignals: FlowGraphSignalConnection[] = [];\r\n\r\n constructor(\r\n /**\r\n * the configuration of the block\r\n */\r\n public override config: IFlowGraphSequenceBlockConfiguration\r\n ) {\r\n super(config);\r\n this.setNumberOfOutputSignals(this.config.outputSignalCount);\r\n }\r\n\r\n public _execute(context: FlowGraphContext) {\r\n for (let i = 0; i < this.executionSignals.length; i++) {\r\n this.executionSignals[i]._activateSignal(context);\r\n }\r\n }\r\n\r\n /**\r\n * Sets the block's output flows. Would usually be passed from the constructor but can be changed afterwards.\r\n * @param outputSignalCount the number of output flows\r\n */\r\n public setNumberOfOutputSignals(outputSignalCount: number = 1) {\r\n // check the size of the outFlow Array, see if it is not larger than needed\r\n while (this.executionSignals.length > outputSignalCount) {\r\n const flow = this.executionSignals.pop();\r\n if (flow) {\r\n flow.disconnectFromAll();\r\n this._unregisterSignalOutput(flow.name);\r\n }\r\n }\r\n\r\n while (this.executionSignals.length < outputSignalCount) {\r\n this.executionSignals.push(this._registerSignalOutput(`out_${this.executionSignals.length}`));\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.Sequence;\r\n }\r\n}\r\n\r\nRegisterClass(FlowGraphBlockNames.Sequence, FlowGraphSequenceBlock);\r\n"]}
@@ -0,0 +1,32 @@
1
+ import { FlowGraphAsyncExecutionBlock } from "../../../flowGraphAsyncExecutionBlock";
2
+ import type { IFlowGraphBlockConfiguration } from "../../../flowGraphBlock";
3
+ import type { FlowGraphContext } from "../../../flowGraphContext";
4
+ import type { FlowGraphDataConnection } from "../../../flowGraphDataConnection";
5
+ import type { FlowGraphSignalConnection } from "../../../flowGraphSignalConnection";
6
+ /**
7
+ * Block that sets a delay in seconds before activating the output signal.
8
+ */
9
+ export declare class FlowGraphSetDelayBlock extends FlowGraphAsyncExecutionBlock {
10
+ /**
11
+ * The maximum number of parallel delays that can be set per node.
12
+ */
13
+ static MaxParallelDelayCount: number;
14
+ /**
15
+ * Input signal: If activated the delayed activations set by this block will be canceled.
16
+ */
17
+ readonly cancel: FlowGraphSignalConnection;
18
+ /**
19
+ * Input connection: The duration of the delay in seconds.
20
+ */
21
+ readonly duration: FlowGraphDataConnection<number>;
22
+ /**
23
+ * Output connection: The last delay index that was set.
24
+ */
25
+ readonly lastDelayIndex: FlowGraphDataConnection<number>;
26
+ constructor(config?: IFlowGraphBlockConfiguration);
27
+ _preparePendingTasks(context: FlowGraphContext): void;
28
+ _cancelPendingTasks(context: FlowGraphContext): void;
29
+ _execute(context: FlowGraphContext, callingSignal: FlowGraphSignalConnection): void;
30
+ getClassName(): string;
31
+ private _onEnded;
32
+ }
@@ -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,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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"]}
@@ -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