@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
@@ -1,10 +1,8 @@
1
- import { FlowGraphEventBlock } from "./flowGraphEventBlock.js";
1
+ import { Observable } from "../Misc/observable.js";
2
2
  import { FlowGraphContext } from "./flowGraphContext.js";
3
- import { FlowGraphBlock } from "./flowGraphBlock.js";
4
3
  import { FlowGraphExecutionBlock } from "./flowGraphExecutionBlock.js";
5
- import { FlowGraphMeshPickEventBlock } from "./Blocks/Event/flowGraphMeshPickEventBlock.js";
4
+ import { FlowGraphSceneEventCoordinator } from "./flowGraphSceneEventCoordinator.js";
6
5
  import { _isADescendantOf } from "./utils.js";
7
- import { defaultValueParseFunction } from "./serialization.js";
8
6
  export var FlowGraphState;
9
7
  (function (FlowGraphState) {
10
8
  /**
@@ -17,28 +15,83 @@ export var FlowGraphState;
17
15
  FlowGraphState[FlowGraphState["Started"] = 1] = "Started";
18
16
  })(FlowGraphState || (FlowGraphState = {}));
19
17
  /**
20
- * @experimental
21
18
  * Class used to represent a flow graph.
22
19
  * A flow graph is a graph of blocks that can be used to create complex logic.
23
20
  * Blocks can be added to the graph and connected to each other.
24
21
  * The graph can then be started, which will init and start all of its event blocks.
22
+ *
23
+ * @experimental FlowGraph is still in development and is subject to change.
25
24
  */
26
25
  export class FlowGraph {
26
+ /**
27
+ * The state of the graph
28
+ */
29
+ get state() {
30
+ return this._state;
31
+ }
32
+ /**
33
+ * The state of the graph
34
+ */
35
+ set state(value) {
36
+ this._state = value;
37
+ this.onStateChangedObservable.notifyObservers(value);
38
+ }
27
39
  /**
28
40
  * Construct a Flow Graph
29
41
  * @param params construction parameters. currently only the scene
30
42
  */
31
43
  constructor(params) {
44
+ /**
45
+ * An observable that is triggered when the state of the graph changes.
46
+ */
47
+ this.onStateChangedObservable = new Observable();
32
48
  /** @internal */
33
- this._eventBlocks = [];
49
+ this._eventBlocks = {
50
+ ["SceneReady" /* FlowGraphEventType.SceneReady */]: [],
51
+ ["SceneDispose" /* FlowGraphEventType.SceneDispose */]: [],
52
+ ["SceneBeforeRender" /* FlowGraphEventType.SceneBeforeRender */]: [],
53
+ ["MeshPick" /* FlowGraphEventType.MeshPick */]: [],
54
+ ["PointerDown" /* FlowGraphEventType.PointerDown */]: [],
55
+ ["PointerUp" /* FlowGraphEventType.PointerUp */]: [],
56
+ ["PointerMove" /* FlowGraphEventType.PointerMove */]: [],
57
+ ["PointerOver" /* FlowGraphEventType.PointerOver */]: [],
58
+ ["PointerOut" /* FlowGraphEventType.PointerOut */]: [],
59
+ ["SceneAfterRender" /* FlowGraphEventType.SceneAfterRender */]: [],
60
+ ["NoTrigger" /* FlowGraphEventType.NoTrigger */]: [],
61
+ };
34
62
  this._executionContexts = [];
35
63
  /**
36
64
  * The state of the graph
37
65
  */
38
- this.state = 0 /* FlowGraphState.Stopped */;
66
+ this._state = 0 /* FlowGraphState.Stopped */;
39
67
  this._scene = params.scene;
68
+ this._sceneEventCoordinator = new FlowGraphSceneEventCoordinator(this._scene);
40
69
  this._coordinator = params.coordinator;
41
- this._sceneDisposeObserver = this._scene.onDisposeObservable.add(() => this.dispose());
70
+ this._eventObserver = this._sceneEventCoordinator.onEventTriggeredObservable.add((event) => {
71
+ for (const context of this._executionContexts) {
72
+ const order = this._getContextualOrder(event.type, context);
73
+ for (const block of order) {
74
+ // iterate contexts
75
+ if (!block._executeEvent(context, event.payload)) {
76
+ break;
77
+ }
78
+ }
79
+ }
80
+ // custom behavior(s) of specific events
81
+ switch (event.type) {
82
+ case "SceneReady" /* FlowGraphEventType.SceneReady */:
83
+ this._sceneEventCoordinator.sceneReadyTriggered = true;
84
+ break;
85
+ case "SceneBeforeRender" /* FlowGraphEventType.SceneBeforeRender */:
86
+ for (const context of this._executionContexts) {
87
+ context._notifyOnTick(event.payload);
88
+ }
89
+ break;
90
+ case "SceneDispose" /* FlowGraphEventType.SceneDispose */:
91
+ this.dispose();
92
+ break;
93
+ }
94
+ });
42
95
  }
43
96
  /**
44
97
  * Create a context. A context represents one self contained execution for the graph, with its own variables.
@@ -63,7 +116,28 @@ export class FlowGraph {
63
116
  * @param block the event block to be added
64
117
  */
65
118
  addEventBlock(block) {
66
- this._eventBlocks.push(block);
119
+ if (block.type === "PointerOver" /* FlowGraphEventType.PointerOver */ || block.type === "PointerOut" /* FlowGraphEventType.PointerOut */) {
120
+ this._scene.constantlyUpdateMeshUnderPointer = true;
121
+ }
122
+ // don't add if NoTrigger, but still start the pending tasks
123
+ if (block.type !== "NoTrigger" /* FlowGraphEventType.NoTrigger */) {
124
+ this._eventBlocks[block.type].push(block);
125
+ }
126
+ // if already started, sort and add to the pending
127
+ if (this.state === 1 /* FlowGraphState.Started */) {
128
+ for (const context of this._executionContexts) {
129
+ block._startPendingTasks(context);
130
+ }
131
+ }
132
+ else {
133
+ this.onStateChangedObservable.addOnce((state) => {
134
+ if (state === 1 /* FlowGraphState.Started */) {
135
+ for (const context of this._executionContexts) {
136
+ block._startPendingTasks(context);
137
+ }
138
+ }
139
+ });
140
+ }
67
141
  }
68
142
  /**
69
143
  * Starts the flow graph. Initializes the event blocks and starts listening to events.
@@ -72,36 +146,48 @@ export class FlowGraph {
72
146
  if (this.state === 1 /* FlowGraphState.Started */) {
73
147
  return;
74
148
  }
75
- this.state = 1 /* FlowGraphState.Started */;
76
149
  if (this._executionContexts.length === 0) {
77
150
  this.createContext();
78
151
  }
152
+ this.onStateChangedObservable.add((state) => {
153
+ if (state === 1 /* FlowGraphState.Started */) {
154
+ this._startPendingEvents();
155
+ // the only event we need to check is the scene ready event. If the scene is already ready when the graph starts, we should start the pending tasks.
156
+ if (this._scene.isReady(true)) {
157
+ this._sceneEventCoordinator.onEventTriggeredObservable.notifyObservers({ type: "SceneReady" /* FlowGraphEventType.SceneReady */ });
158
+ }
159
+ }
160
+ });
161
+ this.state = 1 /* FlowGraphState.Started */;
162
+ }
163
+ _startPendingEvents() {
79
164
  for (const context of this._executionContexts) {
80
- const contextualOrder = this._getContextualOrder();
81
- for (const block of contextualOrder) {
82
- block._startPendingTasks(context);
165
+ for (const type in this._eventBlocks) {
166
+ const order = this._getContextualOrder(type, context);
167
+ for (const block of order) {
168
+ block._startPendingTasks(context);
169
+ }
83
170
  }
84
171
  }
85
172
  }
86
- _getContextualOrder() {
87
- const order = [];
88
- for (const block1 of this._eventBlocks) {
89
- // If the block is a mesh pick, guarantee that picks of children meshes come before picks of parent meshes
90
- if (block1.getClassName() === FlowGraphMeshPickEventBlock.ClassName) {
91
- const mesh1 = block1._getReferencedMesh();
173
+ _getContextualOrder(type, context) {
174
+ const order = this._eventBlocks[type].sort((a, b) => b.initPriority - a.initPriority);
175
+ if (type === "MeshPick" /* FlowGraphEventType.MeshPick */) {
176
+ const meshPickOrder = [];
177
+ for (const block1 of order) {
178
+ // If the block is a mesh pick, guarantee that picks of children meshes come before picks of parent meshes
179
+ const mesh1 = block1.asset.getValue(context);
92
180
  let i = 0;
93
181
  for (; i < order.length; i++) {
94
182
  const block2 = order[i];
95
- const mesh2 = block2._getReferencedMesh();
183
+ const mesh2 = block2.asset.getValue(context);
96
184
  if (mesh1 && mesh2 && _isADescendantOf(mesh1, mesh2)) {
97
185
  break;
98
186
  }
99
187
  }
100
- order.splice(i, 0, block1);
101
- }
102
- else {
103
- order.push(block1);
188
+ meshPickOrder.splice(i, 0, block1);
104
189
  }
190
+ return meshPickOrder;
105
191
  }
106
192
  return order;
107
193
  }
@@ -117,9 +203,11 @@ export class FlowGraph {
117
203
  context._clearPendingBlocks();
118
204
  }
119
205
  this._executionContexts.length = 0;
120
- this._eventBlocks.length = 0;
121
- this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
122
- this._sceneDisposeObserver = null;
206
+ for (const type in this._eventBlocks) {
207
+ this._eventBlocks[type].length = 0;
208
+ }
209
+ this._eventObserver?.remove();
210
+ this._sceneEventCoordinator.dispose();
123
211
  }
124
212
  /**
125
213
  * Executes a function in all blocks of a flow graph, starting with the event blocks.
@@ -128,9 +216,11 @@ export class FlowGraph {
128
216
  visitAllBlocks(visitor) {
129
217
  const visitList = [];
130
218
  const idsAddedToVisitList = new Set();
131
- for (const block of this._eventBlocks) {
132
- visitList.push(block);
133
- idsAddedToVisitList.add(block.uniqueId);
219
+ for (const type in this._eventBlocks) {
220
+ for (const block of this._eventBlocks[type]) {
221
+ visitList.push(block);
222
+ idsAddedToVisitList.add(block.uniqueId);
223
+ }
134
224
  }
135
225
  while (visitList.length > 0) {
136
226
  const block = visitList.pop();
@@ -174,79 +264,5 @@ export class FlowGraph {
174
264
  serializationObject.executionContexts.push(serializedContext);
175
265
  }
176
266
  }
177
- /**
178
- * Given a list of blocks, find an output data connection that has a specific unique id
179
- * @param blocks a list of flow graph blocks
180
- * @param uniqueId the unique id of a connection
181
- * @returns the connection that has this unique id. throws an error if none was found
182
- */
183
- static GetDataOutConnectionByUniqueId(blocks, uniqueId) {
184
- for (const block of blocks) {
185
- for (const dataOut of block.dataOutputs) {
186
- if (dataOut.uniqueId === uniqueId) {
187
- return dataOut;
188
- }
189
- }
190
- }
191
- throw new Error("Could not find data out connection with unique id " + uniqueId);
192
- }
193
- /**
194
- * Given a list of blocks, find an input signal connection that has a specific unique id
195
- * @param blocks a list of flow graph blocks
196
- * @param uniqueId the unique id of a connection
197
- * @returns the connection that has this unique id. throws an error if none was found
198
- */
199
- static GetSignalInConnectionByUniqueId(blocks, uniqueId) {
200
- for (const block of blocks) {
201
- if (block instanceof FlowGraphExecutionBlock) {
202
- for (const signalIn of block.signalInputs) {
203
- if (signalIn.uniqueId === uniqueId) {
204
- return signalIn;
205
- }
206
- }
207
- }
208
- }
209
- throw new Error("Could not find signal in connection with unique id " + uniqueId);
210
- }
211
- /**
212
- * Parses a graph from a given serialization object
213
- * @param serializationObject the object where the values are written
214
- * @param options options for parsing the graph
215
- * @returns the parsed graph
216
- */
217
- static Parse(serializationObject, options) {
218
- const graph = options.coordinator.createGraph();
219
- const blocks = [];
220
- const valueParseFunction = options.valueParseFunction ?? defaultValueParseFunction;
221
- // Parse all blocks
222
- for (const serializedBlock of serializationObject.allBlocks) {
223
- const block = FlowGraphBlock.Parse(serializedBlock, { scene: options.coordinator.config.scene, pathConverter: options.pathConverter, valueParseFunction });
224
- blocks.push(block);
225
- if (block instanceof FlowGraphEventBlock) {
226
- graph.addEventBlock(block);
227
- }
228
- }
229
- // After parsing all blocks, connect them
230
- for (const block of blocks) {
231
- for (const dataIn of block.dataInputs) {
232
- for (const serializedConnection of dataIn.connectedPointIds) {
233
- const connection = FlowGraph.GetDataOutConnectionByUniqueId(blocks, serializedConnection);
234
- dataIn.connectTo(connection);
235
- }
236
- }
237
- if (block instanceof FlowGraphExecutionBlock) {
238
- for (const signalOut of block.signalOutputs) {
239
- for (const serializedConnection of signalOut.connectedPointIds) {
240
- const connection = FlowGraph.GetSignalInConnectionByUniqueId(blocks, serializedConnection);
241
- signalOut.connectTo(connection);
242
- }
243
- }
244
- }
245
- }
246
- for (const serializedContext of serializationObject.executionContexts) {
247
- FlowGraphContext.Parse(serializedContext, { graph, valueParseFunction });
248
- }
249
- return graph;
250
- }
251
267
  }
252
268
  //# sourceMappingURL=flowGraph.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"flowGraph.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraph.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,C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E,gBAAgB,CAAC,KAAK,CAAC,iBAAiB,EAAE,EAAE,KAAK,EAAE,kBAAkB,EAAE,CAAC,CAAC;QAC7E,CAAC;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ","sourcesContent":["import type { Observer } from \"../Misc/observable\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { Scene } from \"../scene\";\r\nimport { FlowGraphEventBlock } from \"./flowGraphEventBlock\";\r\nimport { FlowGraphContext } from \"./flowGraphContext\";\r\nimport { FlowGraphBlock } from \"./flowGraphBlock\";\r\nimport { FlowGraphExecutionBlock } from \"./flowGraphExecutionBlock\";\r\nimport type { FlowGraphCoordinator } from \"./flowGraphCoordinator\";\r\nimport type { FlowGraphSignalConnection } from \"./flowGraphSignalConnection\";\r\nimport type { FlowGraphDataConnection } from \"./flowGraphDataConnection\";\r\nimport type { ISerializedFlowGraph, IObjectAccessor } from \"./typeDefinitions\";\r\nimport { FlowGraphMeshPickEventBlock } from \"./Blocks/Event/flowGraphMeshPickEventBlock\";\r\nimport { _isADescendantOf } from \"./utils\";\r\nimport type { IPathToObjectConverter } from \"../ObjectModel/objectModelInterfaces\";\r\nimport { defaultValueParseFunction } from \"./serialization\";\r\n\r\nexport const enum FlowGraphState {\r\n /**\r\n * The graph is stopped\r\n */\r\n Stopped,\r\n /**\r\n * The graph is running\r\n */\r\n Started,\r\n}\r\n\r\n/**\r\n * @experimental\r\n * Parameters used to create a flow graph.\r\n */\r\nexport interface IFlowGraphParams {\r\n /**\r\n * The scene that the flow graph belongs to.\r\n */\r\n scene: Scene;\r\n /**\r\n * The event coordinator used by the flow graph.\r\n */\r\n coordinator: FlowGraphCoordinator;\r\n}\r\n\r\n/**\r\n * @experimental\r\n * Options for parsing a flow graph.\r\n */\r\nexport interface IFlowGraphParseOptions {\r\n /**\r\n * A function that parses complex values in a scene.\r\n * @param key the key of the value\r\n * @param serializationObject the object to read the value from\r\n * @param scene the scene to read the value from\r\n */\r\n valueParseFunction?: (key: string, serializationObject: any, scene: Scene) => any;\r\n /**\r\n * The flow graph coordinator.\r\n */\r\n coordinator: FlowGraphCoordinator;\r\n /**\r\n * A function that converts a path to an object accessor.\r\n */\r\n pathConverter: IPathToObjectConverter<IObjectAccessor>;\r\n}\r\n/**\r\n * @experimental\r\n * Class used to represent a flow graph.\r\n * A flow graph is a graph of blocks that can be used to create complex logic.\r\n * Blocks can be added to the graph and connected to each other.\r\n * The graph can then be started, which will init and start all of its event blocks.\r\n */\r\nexport class FlowGraph {\r\n /** @internal */\r\n public _eventBlocks: FlowGraphEventBlock[] = [];\r\n private _sceneDisposeObserver: Nullable<Observer<Scene>>;\r\n /**\r\n * @internal\r\n */\r\n public readonly _scene: Scene;\r\n private _coordinator: FlowGraphCoordinator;\r\n private _executionContexts: FlowGraphContext[] = [];\r\n\r\n /**\r\n * The state of the graph\r\n */\r\n state: FlowGraphState = FlowGraphState.Stopped;\r\n\r\n /**\r\n * Construct a Flow Graph\r\n * @param params construction parameters. currently only the scene\r\n */\r\n public constructor(params: IFlowGraphParams) {\r\n this._scene = params.scene;\r\n this._coordinator = params.coordinator;\r\n this._sceneDisposeObserver = this._scene.onDisposeObservable.add(() => this.dispose());\r\n }\r\n\r\n /**\r\n * Create a context. A context represents one self contained execution for the graph, with its own variables.\r\n * @returns the context, where you can get and set variables\r\n */\r\n public createContext() {\r\n const context = new FlowGraphContext({ scene: this._scene, coordinator: this._coordinator });\r\n this._executionContexts.push(context);\r\n return context;\r\n }\r\n\r\n /**\r\n * Returns the execution context at a given index\r\n * @param index the index of the context\r\n * @returns the execution context at that index\r\n */\r\n public getContext(index: number) {\r\n return this._executionContexts[index];\r\n }\r\n\r\n /**\r\n * Add an event block. When the graph is started, it will start listening to events\r\n * from the block and execute the graph when they are triggered.\r\n * @param block the event block to be added\r\n */\r\n public addEventBlock(block: FlowGraphEventBlock): void {\r\n this._eventBlocks.push(block);\r\n }\r\n\r\n /**\r\n * Starts the flow graph. Initializes the event blocks and starts listening to events.\r\n */\r\n public start() {\r\n if (this.state === FlowGraphState.Started) {\r\n return;\r\n }\r\n this.state = FlowGraphState.Started;\r\n if (this._executionContexts.length === 0) {\r\n this.createContext();\r\n }\r\n for (const context of this._executionContexts) {\r\n const contextualOrder = this._getContextualOrder();\r\n for (const block of contextualOrder) {\r\n block._startPendingTasks(context);\r\n }\r\n }\r\n }\r\n\r\n private _getContextualOrder(): FlowGraphEventBlock[] {\r\n const order: FlowGraphEventBlock[] = [];\r\n\r\n for (const block1 of this._eventBlocks) {\r\n // If the block is a mesh pick, guarantee that picks of children meshes come before picks of parent meshes\r\n if (block1.getClassName() === FlowGraphMeshPickEventBlock.ClassName) {\r\n const mesh1 = (block1 as FlowGraphMeshPickEventBlock)._getReferencedMesh();\r\n let i = 0;\r\n for (; i < order.length; i++) {\r\n const block2 = order[i];\r\n const mesh2 = (block2 as FlowGraphMeshPickEventBlock)._getReferencedMesh();\r\n if (mesh1 && mesh2 && _isADescendantOf(mesh1, mesh2)) {\r\n break;\r\n }\r\n }\r\n order.splice(i, 0, block1);\r\n } else {\r\n order.push(block1);\r\n }\r\n }\r\n return order;\r\n }\r\n\r\n /**\r\n * Disposes of the flow graph. Cancels any pending tasks and removes all event listeners.\r\n */\r\n public dispose() {\r\n if (this.state === FlowGraphState.Stopped) {\r\n return;\r\n }\r\n this.state = FlowGraphState.Stopped;\r\n for (const context of this._executionContexts) {\r\n context._clearPendingBlocks();\r\n }\r\n this._executionContexts.length = 0;\r\n this._eventBlocks.length = 0;\r\n this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);\r\n this._sceneDisposeObserver = null;\r\n }\r\n\r\n /**\r\n * Executes a function in all blocks of a flow graph, starting with the event blocks.\r\n * @param visitor the function to execute.\r\n */\r\n public visitAllBlocks(visitor: (block: FlowGraphBlock) => void) {\r\n const visitList: FlowGraphBlock[] = [];\r\n const idsAddedToVisitList = new Set<string>();\r\n for (const block of this._eventBlocks) {\r\n visitList.push(block);\r\n idsAddedToVisitList.add(block.uniqueId);\r\n }\r\n\r\n while (visitList.length > 0) {\r\n const block = visitList.pop()!;\r\n visitor(block);\r\n\r\n for (const dataIn of block.dataInputs) {\r\n for (const connection of dataIn._connectedPoint) {\r\n if (!idsAddedToVisitList.has(connection._ownerBlock.uniqueId)) {\r\n visitList.push(connection._ownerBlock);\r\n idsAddedToVisitList.add(connection._ownerBlock.uniqueId);\r\n }\r\n }\r\n }\r\n if (block instanceof FlowGraphExecutionBlock) {\r\n for (const signalOut of block.signalOutputs) {\r\n for (const connection of signalOut._connectedPoint) {\r\n if (!idsAddedToVisitList.has(connection._ownerBlock.uniqueId)) {\r\n visitList.push(connection._ownerBlock);\r\n idsAddedToVisitList.add(connection._ownerBlock.uniqueId);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Serializes a graph\r\n * @param serializationObject the object to write the values in\r\n * @param valueSerializeFunction a function to serialize complex values\r\n */\r\n public serialize(serializationObject: any = {}, valueSerializeFunction?: (key: string, value: any, serializationObject: any) => void) {\r\n serializationObject.allBlocks = [];\r\n this.visitAllBlocks((block) => {\r\n const serializedBlock: any = {};\r\n block.serialize(serializedBlock);\r\n serializationObject.allBlocks.push(serializedBlock);\r\n });\r\n serializationObject.executionContexts = [];\r\n for (const context of this._executionContexts) {\r\n const serializedContext: any = {};\r\n context.serialize(serializedContext, valueSerializeFunction);\r\n serializationObject.executionContexts.push(serializedContext);\r\n }\r\n }\r\n\r\n /**\r\n * Given a list of blocks, find an output data connection that has a specific unique id\r\n * @param blocks a list of flow graph blocks\r\n * @param uniqueId the unique id of a connection\r\n * @returns the connection that has this unique id. throws an error if none was found\r\n */\r\n public static GetDataOutConnectionByUniqueId(blocks: FlowGraphBlock[], uniqueId: string): FlowGraphDataConnection<any> {\r\n for (const block of blocks) {\r\n for (const dataOut of block.dataOutputs) {\r\n if (dataOut.uniqueId === uniqueId) {\r\n return dataOut;\r\n }\r\n }\r\n }\r\n throw new Error(\"Could not find data out connection with unique id \" + uniqueId);\r\n }\r\n\r\n /**\r\n * Given a list of blocks, find an input signal connection that has a specific unique id\r\n * @param blocks a list of flow graph blocks\r\n * @param uniqueId the unique id of a connection\r\n * @returns the connection that has this unique id. throws an error if none was found\r\n */\r\n public static GetSignalInConnectionByUniqueId(blocks: FlowGraphBlock[], uniqueId: string): FlowGraphSignalConnection {\r\n for (const block of blocks) {\r\n if (block instanceof FlowGraphExecutionBlock) {\r\n for (const signalIn of block.signalInputs) {\r\n if (signalIn.uniqueId === uniqueId) {\r\n return signalIn;\r\n }\r\n }\r\n }\r\n }\r\n throw new Error(\"Could not find signal in connection with unique id \" + uniqueId);\r\n }\r\n\r\n /**\r\n * Parses a graph from a given serialization object\r\n * @param serializationObject the object where the values are written\r\n * @param options options for parsing the graph\r\n * @returns the parsed graph\r\n */\r\n public static Parse(serializationObject: ISerializedFlowGraph, options: IFlowGraphParseOptions): FlowGraph {\r\n const graph = options.coordinator.createGraph();\r\n const blocks: FlowGraphBlock[] = [];\r\n const valueParseFunction = options.valueParseFunction ?? defaultValueParseFunction;\r\n // Parse all blocks\r\n for (const serializedBlock of serializationObject.allBlocks) {\r\n const block = FlowGraphBlock.Parse(serializedBlock, { scene: options.coordinator.config.scene, pathConverter: options.pathConverter, valueParseFunction });\r\n blocks.push(block);\r\n if (block instanceof FlowGraphEventBlock) {\r\n graph.addEventBlock(block);\r\n }\r\n }\r\n // After parsing all blocks, connect them\r\n for (const block of blocks) {\r\n for (const dataIn of block.dataInputs) {\r\n for (const serializedConnection of dataIn.connectedPointIds) {\r\n const connection = FlowGraph.GetDataOutConnectionByUniqueId(blocks, serializedConnection);\r\n dataIn.connectTo(connection);\r\n }\r\n }\r\n if (block instanceof FlowGraphExecutionBlock) {\r\n for (const signalOut of block.signalOutputs) {\r\n for (const serializedConnection of signalOut.connectedPointIds) {\r\n const connection = FlowGraph.GetSignalInConnectionByUniqueId(blocks, serializedConnection);\r\n signalOut.connectTo(connection);\r\n }\r\n }\r\n }\r\n }\r\n for (const serializedContext of serializationObject.executionContexts) {\r\n FlowGraphContext.Parse(serializedContext, { graph, valueParseFunction });\r\n }\r\n return graph;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"flowGraph.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraph.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAIhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAOpE,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAElF,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3C,MAAM,CAAN,IAAkB,cASjB;AATD,WAAkB,cAAc;IAC5B;;OAEG;IACH,yDAAO,CAAA;IACP;;OAEG;IACH,yDAAO,CAAA;AACX,CAAC,EATiB,cAAc,KAAd,cAAc,QAS/B;AAoCD;;;;;;;GAOG;AACH,MAAM,OAAO,SAAS;IAiClB;;OAEG;IACH,IAAW,KAAK;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,IAAW,KAAK,CAAC,KAAqB;QAClC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,wBAAwB,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;IACzD,CAAC;IAED;;;OAGG;IACH,YAAmB,MAAwB;QAnD3C;;WAEG;QACI,6BAAwB,GAA+B,IAAI,UAAU,EAAE,CAAC;QAC/E,gBAAgB;QACT,iBAAY,GAA6D;YAC5E,kDAA+B,EAAE,EAAE;YACnC,sDAAiC,EAAE,EAAE;YACrC,gEAAsC,EAAE,EAAE;YAC1C,8CAA6B,EAAE,EAAE;YACjC,oDAAgC,EAAE,EAAE;YACpC,gDAA8B,EAAE,EAAE;YAClC,oDAAgC,EAAE,EAAE;YACpC,oDAAgC,EAAE,EAAE;YACpC,kDAA+B,EAAE,E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AC,QAAQ,CAAC,EAAE,CAAC;4BAC5D,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;4BACvC,mBAAmB,CAAC,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;wBAC7D,CAAC;oBACL,CAAC;gBACL,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;IAED;;;;OAIG;IACI,SAAS,CAAC,sBAA2B,EAAE,EAAE,sBAAoF;QAChI,mBAAmB,CAAC,SAAS,GAAG,EAAE,CAAC;QACnC,IAAI,CAAC,cAAc,CAAC,CAAC,KAAK,EAAE,EAAE;YAC1B,MAAM,eAAe,GAAQ,EAAE,CAAC;YAChC,KAAK,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;YACjC,mBAAmB,CAAC,SAAS,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QACxD,CAAC,CAAC,CAAC;QACH,mBAAmB,CAAC,iBAAiB,GAAG,EAAE,CAAC;QAC3C,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC5C,MAAM,iBAAiB,GAAQ,EAAE,CAAC;YAClC,OAAO,CAAC,SAAS,CAAC,iBAAiB,EAAE,sBAAsB,CAAC,CAAC;YAC7D,mBAAmB,CAAC,iBAAiB,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAClE,CAAC;IACL,CAAC;CACJ","sourcesContent":["import type { Observer } from \"../Misc/observable\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { FlowGraphEventBlock } from \"./flowGraphEventBlock\";\r\nimport { FlowGraphContext } from \"./flowGraphContext\";\r\nimport type { FlowGraphBlock } from \"./flowGraphBlock\";\r\nimport { FlowGraphExecutionBlock } from \"./flowGraphExecutionBlock\";\r\nimport type { FlowGraphCoordinator } from \"./flowGraphCoordinator\";\r\nimport type { IObjectAccessor } from \"./typeDefinitions\";\r\nimport type { IPathToObjectConverter } from \"../ObjectModel/objectModelInterfaces\";\r\nimport type { IAssetContainer } from \"core/IAssetContainer\";\r\nimport { FlowGraphEventType } from \"./flowGraphEventType\";\r\nimport type { IFlowGraphEventTrigger } from \"./flowGraphSceneEventCoordinator\";\r\nimport { FlowGraphSceneEventCoordinator } from \"./flowGraphSceneEventCoordinator\";\r\nimport type { FlowGraphMeshPickEventBlock } from \"./Blocks/Event/flowGraphMeshPickEventBlock\";\r\nimport { _isADescendantOf } from \"./utils\";\r\n\r\nexport const enum FlowGraphState {\r\n /**\r\n * The graph is stopped\r\n */\r\n Stopped,\r\n /**\r\n * The graph is running\r\n */\r\n Started,\r\n}\r\n\r\n/**\r\n * Parameters used to create a flow graph.\r\n */\r\nexport interface IFlowGraphParams {\r\n /**\r\n * The scene that the flow graph belongs to.\r\n */\r\n scene: Scene;\r\n /**\r\n * The event coordinator used by the flow graph.\r\n */\r\n coordinator: FlowGraphCoordinator;\r\n}\r\n\r\n/**\r\n * Options for parsing a flow graph.\r\n */\r\nexport interface IFlowGraphParseOptions {\r\n /**\r\n * A function that parses complex values in a scene.\r\n * @param key the key of the value\r\n * @param serializationObject the object to read the value from\r\n * @param scene the scene to read the value from\r\n */\r\n valueParseFunction?: (key: string, serializationObject: any, assetsContainer: IAssetContainer, scene: Scene) => any;\r\n /**\r\n * The flow graph coordinator.\r\n */\r\n coordinator: FlowGraphCoordinator;\r\n /**\r\n * A function that converts a path to an object accessor.\r\n */\r\n pathConverter?: IPathToObjectConverter<IObjectAccessor>;\r\n}\r\n/**\r\n * Class used to represent a flow graph.\r\n * A flow graph is a graph of blocks that can be used to create complex logic.\r\n * Blocks can be added to the graph and connected to each other.\r\n * The graph can then be started, which will init and start all of its event blocks.\r\n *\r\n * @experimental FlowGraph is still in development and is subject to change.\r\n */\r\nexport class FlowGraph {\r\n /**\r\n * An observable that is triggered when the state of the graph changes.\r\n */\r\n public onStateChangedObservable: Observable<FlowGraphState> = new Observable();\r\n /** @internal */\r\n public _eventBlocks: { [keyof in FlowGraphEventType]: FlowGraphEventBlock[] } = {\r\n [FlowGraphEventType.SceneReady]: [],\r\n [FlowGraphEventType.SceneDispose]: [],\r\n [FlowGraphEventType.SceneBeforeRender]: [],\r\n [FlowGraphEventType.MeshPick]: [],\r\n [FlowGraphEventType.PointerDown]: [],\r\n [FlowGraphEventType.PointerUp]: [],\r\n [FlowGraphEventType.PointerMove]: [],\r\n [FlowGraphEventType.PointerOver]: [],\r\n [FlowGraphEventType.PointerOut]: [],\r\n [FlowGraphEventType.SceneAfterRender]: [],\r\n [FlowGraphEventType.NoTrigger]: [],\r\n };\r\n /**\r\n * @internal\r\n */\r\n public readonly _scene: Scene;\r\n private _coordinator: FlowGraphCoordinator;\r\n private _executionContexts: FlowGraphContext[] = [];\r\n private _sceneEventCoordinator: FlowGraphSceneEventCoordinator;\r\n private _eventObserver: Nullable<Observer<IFlowGraphEventTrigger>>;\r\n\r\n /**\r\n * The state of the graph\r\n */\r\n private _state: FlowGraphState = FlowGraphState.Stopped;\r\n\r\n /**\r\n * The state of the graph\r\n */\r\n public get state() {\r\n return this._state;\r\n }\r\n\r\n /**\r\n * The state of the graph\r\n */\r\n public set state(value: FlowGraphState) {\r\n this._state = value;\r\n this.onStateChangedObservable.notifyObservers(value);\r\n }\r\n\r\n /**\r\n * Construct a Flow Graph\r\n * @param params construction parameters. currently only the scene\r\n */\r\n public constructor(params: IFlowGraphParams) {\r\n this._scene = params.scene;\r\n this._sceneEventCoordinator = new FlowGraphSceneEventCoordinator(this._scene);\r\n this._coordinator = params.coordinator;\r\n\r\n this._eventObserver = this._sceneEventCoordinator.onEventTriggeredObservable.add((event) => {\r\n for (const context of this._executionContexts) {\r\n const order = this._getContextualOrder(event.type, context);\r\n for (const block of order) {\r\n // iterate contexts\r\n if (!block._executeEvent(context, event.payload)) {\r\n break;\r\n }\r\n }\r\n }\r\n // custom behavior(s) of specific events\r\n switch (event.type) {\r\n case FlowGraphEventType.SceneReady:\r\n this._sceneEventCoordinator.sceneReadyTriggered = true;\r\n break;\r\n case FlowGraphEventType.SceneBeforeRender:\r\n for (const context of this._executionContexts) {\r\n context._notifyOnTick(event.payload);\r\n }\r\n break;\r\n case FlowGraphEventType.SceneDispose:\r\n this.dispose();\r\n break;\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Create a context. A context represents one self contained execution for the graph, with its own variables.\r\n * @returns the context, where you can get and set variables\r\n */\r\n public createContext() {\r\n const context = new FlowGraphContext({ scene: this._scene, coordinator: this._coordinator });\r\n this._executionContexts.push(context);\r\n return context;\r\n }\r\n\r\n /**\r\n * Returns the execution context at a given index\r\n * @param index the index of the context\r\n * @returns the execution context at that index\r\n */\r\n public getContext(index: number) {\r\n return this._executionContexts[index];\r\n }\r\n\r\n /**\r\n * Add an event block. When the graph is started, it will start listening to events\r\n * from the block and execute the graph when they are triggered.\r\n * @param block the event block to be added\r\n */\r\n public addEventBlock(block: FlowGraphEventBlock): void {\r\n if (block.type === FlowGraphEventType.PointerOver || block.type === FlowGraphEventType.PointerOut) {\r\n this._scene.constantlyUpdateMeshUnderPointer = true;\r\n }\r\n\r\n // don't add if NoTrigger, but still start the pending tasks\r\n if (block.type !== FlowGraphEventType.NoTrigger) {\r\n this._eventBlocks[block.type].push(block);\r\n }\r\n // if already started, sort and add to the pending\r\n if (this.state === FlowGraphState.Started) {\r\n for (const context of this._executionContexts) {\r\n block._startPendingTasks(context);\r\n }\r\n } else {\r\n this.onStateChangedObservable.addOnce((state) => {\r\n if (state === FlowGraphState.Started) {\r\n for (const context of this._executionContexts) {\r\n block._startPendingTasks(context);\r\n }\r\n }\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Starts the flow graph. Initializes the event blocks and starts listening to events.\r\n */\r\n public start() {\r\n if (this.state === FlowGraphState.Started) {\r\n return;\r\n }\r\n if (this._executionContexts.length === 0) {\r\n this.createContext();\r\n }\r\n this.onStateChangedObservable.add((state) => {\r\n if (state === FlowGraphState.Started) {\r\n this._startPendingEvents();\r\n // the only event we need to check is the scene ready event. If the scene is already ready when the graph starts, we should start the pending tasks.\r\n if (this._scene.isReady(true)) {\r\n this._sceneEventCoordinator.onEventTriggeredObservable.notifyObservers({ type: FlowGraphEventType.SceneReady });\r\n }\r\n }\r\n });\r\n this.state = FlowGraphState.Started;\r\n }\r\n\r\n private _startPendingEvents() {\r\n for (const context of this._executionContexts) {\r\n for (const type in this._eventBlocks) {\r\n const order = this._getContextualOrder(type as FlowGraphEventType, context);\r\n for (const block of order) {\r\n block._startPendingTasks(context);\r\n }\r\n }\r\n }\r\n }\r\n\r\n private _getContextualOrder(type: FlowGraphEventType, context: FlowGraphContext): FlowGraphEventBlock[] {\r\n const order = this._eventBlocks[type].sort((a, b) => b.initPriority - a.initPriority);\r\n\r\n if (type === FlowGraphEventType.MeshPick) {\r\n const meshPickOrder = [] as FlowGraphEventBlock[];\r\n for (const block1 of order) {\r\n // If the block is a mesh pick, guarantee that picks of children meshes come before picks of parent meshes\r\n const mesh1 = (block1 as FlowGraphMeshPickEventBlock).asset.getValue(context);\r\n let i = 0;\r\n for (; i < order.length; i++) {\r\n const block2 = order[i];\r\n const mesh2 = (block2 as FlowGraphMeshPickEventBlock).asset.getValue(context);\r\n if (mesh1 && mesh2 && _isADescendantOf(mesh1, mesh2)) {\r\n break;\r\n }\r\n }\r\n meshPickOrder.splice(i, 0, block1);\r\n }\r\n return meshPickOrder;\r\n }\r\n return order;\r\n }\r\n\r\n /**\r\n * Disposes of the flow graph. Cancels any pending tasks and removes all event listeners.\r\n */\r\n public dispose() {\r\n if (this.state === FlowGraphState.Stopped) {\r\n return;\r\n }\r\n this.state = FlowGraphState.Stopped;\r\n for (const context of this._executionContexts) {\r\n context._clearPendingBlocks();\r\n }\r\n this._executionContexts.length = 0;\r\n for (const type in this._eventBlocks) {\r\n this._eventBlocks[type as FlowGraphEventType].length = 0;\r\n }\r\n this._eventObserver?.remove();\r\n this._sceneEventCoordinator.dispose();\r\n }\r\n\r\n /**\r\n * Executes a function in all blocks of a flow graph, starting with the event blocks.\r\n * @param visitor the function to execute.\r\n */\r\n public visitAllBlocks(visitor: (block: FlowGraphBlock) => void) {\r\n const visitList: FlowGraphBlock[] = [];\r\n const idsAddedToVisitList = new Set<string>();\r\n for (const type in this._eventBlocks) {\r\n for (const block of this._eventBlocks[type as FlowGraphEventType]) {\r\n visitList.push(block);\r\n idsAddedToVisitList.add(block.uniqueId);\r\n }\r\n }\r\n\r\n while (visitList.length > 0) {\r\n const block = visitList.pop()!;\r\n visitor(block);\r\n\r\n for (const dataIn of block.dataInputs) {\r\n for (const connection of dataIn._connectedPoint) {\r\n if (!idsAddedToVisitList.has(connection._ownerBlock.uniqueId)) {\r\n visitList.push(connection._ownerBlock);\r\n idsAddedToVisitList.add(connection._ownerBlock.uniqueId);\r\n }\r\n }\r\n }\r\n if (block instanceof FlowGraphExecutionBlock) {\r\n for (const signalOut of block.signalOutputs) {\r\n for (const connection of signalOut._connectedPoint) {\r\n if (!idsAddedToVisitList.has(connection._ownerBlock.uniqueId)) {\r\n visitList.push(connection._ownerBlock);\r\n idsAddedToVisitList.add(connection._ownerBlock.uniqueId);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Serializes a graph\r\n * @param serializationObject the object to write the values in\r\n * @param valueSerializeFunction a function to serialize complex values\r\n */\r\n public serialize(serializationObject: any = {}, valueSerializeFunction?: (key: string, value: any, serializationObject: any) => void) {\r\n serializationObject.allBlocks = [];\r\n this.visitAllBlocks((block) => {\r\n const serializedBlock: any = {};\r\n block.serialize(serializedBlock);\r\n serializationObject.allBlocks.push(serializedBlock);\r\n });\r\n serializationObject.executionContexts = [];\r\n for (const context of this._executionContexts) {\r\n const serializedContext: any = {};\r\n context.serialize(serializedContext, valueSerializeFunction);\r\n serializationObject.executionContexts.push(serializedContext);\r\n }\r\n }\r\n}\r\n"]}
@@ -0,0 +1,29 @@
1
+ import type { AnimationGroup } from "../Animations/animationGroup.js";
2
+ import type { Animation } from "../Animations/animation.js";
3
+ import type { Nullable } from "../types.js";
4
+ import type { Mesh } from "../Meshes/mesh.js";
5
+ import type { Material } from "../Materials/material.js";
6
+ import type { Camera } from "../Cameras/camera.js";
7
+ import type { Light } from "../Lights/light.js";
8
+ import type { IAssetContainer } from "../IAssetContainer.js";
9
+ /**
10
+ * The type of the assets that flow graph supports
11
+ */
12
+ export declare enum FlowGraphAssetType {
13
+ Animation = "Animation",
14
+ AnimationGroup = "AnimationGroup",
15
+ Mesh = "Mesh",
16
+ Material = "Material",
17
+ Camera = "Camera",
18
+ Light = "Light"
19
+ }
20
+ export type AssetType<T extends FlowGraphAssetType> = T extends FlowGraphAssetType.Animation ? Animation : T extends FlowGraphAssetType.AnimationGroup ? AnimationGroup : T extends FlowGraphAssetType.Mesh ? Mesh : T extends FlowGraphAssetType.Material ? Material : T extends FlowGraphAssetType.Camera ? Camera : T extends FlowGraphAssetType.Light ? Light : never;
21
+ /**
22
+ * Returns the asset with the given index and type from the assets context.
23
+ * @param assetsContext The assets context to get the asset from
24
+ * @param type The type of the asset
25
+ * @param index The index of the asset
26
+ * @param useIndexAsUniqueId If set to true, instead of the index in the array it will search for the unique id of the asset.
27
+ * @returns The asset or null if not found
28
+ */
29
+ export declare function GetFlowGraphAssetWithType<T extends FlowGraphAssetType>(assetsContext: IAssetContainer, type: T, index: number, useIndexAsUniqueId?: boolean): Nullable<AssetType<T>>;
@@ -0,0 +1,52 @@
1
+ /**
2
+ * The type of the assets that flow graph supports
3
+ */
4
+ export var FlowGraphAssetType;
5
+ (function (FlowGraphAssetType) {
6
+ FlowGraphAssetType["Animation"] = "Animation";
7
+ FlowGraphAssetType["AnimationGroup"] = "AnimationGroup";
8
+ FlowGraphAssetType["Mesh"] = "Mesh";
9
+ FlowGraphAssetType["Material"] = "Material";
10
+ FlowGraphAssetType["Camera"] = "Camera";
11
+ FlowGraphAssetType["Light"] = "Light";
12
+ // Further asset types will be added here when needed.
13
+ })(FlowGraphAssetType || (FlowGraphAssetType = {}));
14
+ /**
15
+ * Returns the asset with the given index and type from the assets context.
16
+ * @param assetsContext The assets context to get the asset from
17
+ * @param type The type of the asset
18
+ * @param index The index of the asset
19
+ * @param useIndexAsUniqueId If set to true, instead of the index in the array it will search for the unique id of the asset.
20
+ * @returns The asset or null if not found
21
+ */
22
+ export function GetFlowGraphAssetWithType(assetsContext, type, index, useIndexAsUniqueId) {
23
+ switch (type) {
24
+ case "Animation" /* FlowGraphAssetType.Animation */:
25
+ return useIndexAsUniqueId
26
+ ? (assetsContext.animations.find((a) => a.uniqueId === index) ?? null)
27
+ : (assetsContext.animations[index] ?? null);
28
+ case "AnimationGroup" /* FlowGraphAssetType.AnimationGroup */:
29
+ return useIndexAsUniqueId
30
+ ? (assetsContext.animationGroups.find((a) => a.uniqueId === index) ?? null)
31
+ : (assetsContext.animationGroups[index] ?? null);
32
+ case "Mesh" /* FlowGraphAssetType.Mesh */:
33
+ return useIndexAsUniqueId
34
+ ? (assetsContext.meshes.find((a) => a.uniqueId === index) ?? null)
35
+ : (assetsContext.meshes[index] ?? null);
36
+ case "Material" /* FlowGraphAssetType.Material */:
37
+ return useIndexAsUniqueId
38
+ ? (assetsContext.materials.find((a) => a.uniqueId === index) ?? null)
39
+ : (assetsContext.materials[index] ?? null);
40
+ case "Camera" /* FlowGraphAssetType.Camera */:
41
+ return useIndexAsUniqueId
42
+ ? (assetsContext.cameras.find((a) => a.uniqueId === index) ?? null)
43
+ : (assetsContext.cameras[index] ?? null);
44
+ case "Light" /* FlowGraphAssetType.Light */:
45
+ return useIndexAsUniqueId
46
+ ? (assetsContext.lights.find((a) => a.uniqueId === index) ?? null)
47
+ : (assetsContext.lights[index] ?? null);
48
+ default:
49
+ return null;
50
+ }
51
+ }
52
+ //# sourceMappingURL=flowGraphAssetsContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flowGraphAssetsContext.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraphAssetsContext.ts"],"names":[],"mappings":"AAS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AI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,KAAK,CAA4B,IAAI,IAAI,CAAC;gBACjG,CAAC,CAAC,CAAE,aAAa,CAAC,SAAS,CAAC,KAAK,CAA4B,IAAI,IAAI,CAAC,CAAC;QAC/E;YACI,OAAO,kBAAkB;gBACrB,CAAC,CAAC,CAAE,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,KAAK,CAA4B,IAAI,IAAI,CAAC;gBAC/F,CAAC,CAAC,CAAE,aAAa,CAAC,OAAO,CAAC,KAAK,CAA4B,IAAI,IAAI,CAAC,CAAC;QAC7E;YACI,OAAO,kBAAkB;gBACrB,CAAC,CAAC,CAAE,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,KAAK,CAA4B,IAAI,IAAI,CAAC;gBAC9F,CAAC,CAAC,CAAE,aAAa,CAAC,MAAM,CAAC,KAAK,CAA4B,IAAI,IAAI,CAAC,CAAC;QAC5E;YACI,OAAO,IAAI,CAAC;IACpB,CAAC;AACL,CAAC","sourcesContent":["import type { AnimationGroup } from \"core/Animations/animationGroup\";\nimport type { Animation } from \"core/Animations/animation\";\nimport type { Nullable } from \"core/types\";\nimport type { Mesh } from \"core/Meshes/mesh\";\nimport type { Material } from \"core/Materials/material\";\nimport type { Camera } from \"core/Cameras/camera\";\nimport type { Light } from \"core/Lights/light\";\nimport type { IAssetContainer } from \"core/IAssetContainer\";\n\n/**\n * The type of the assets that flow graph supports\n */\nexport const enum FlowGraphAssetType {\n Animation = \"Animation\",\n AnimationGroup = \"AnimationGroup\",\n Mesh = \"Mesh\",\n Material = \"Material\",\n Camera = \"Camera\",\n Light = \"Light\",\n // Further asset types will be added here when needed.\n}\n\nexport type AssetType<T extends FlowGraphAssetType> = T extends FlowGraphAssetType.Animation\n ? Animation\n : T extends FlowGraphAssetType.AnimationGroup\n ? AnimationGroup\n : T extends FlowGraphAssetType.Mesh\n ? Mesh\n : T extends FlowGraphAssetType.Material\n ? Material\n : T extends FlowGraphAssetType.Camera\n ? Camera\n : T extends FlowGraphAssetType.Light\n ? Light\n : never;\n\n/**\n * Returns the asset with the given index and type from the assets context.\n * @param assetsContext The assets context to get the asset from\n * @param type The type of the asset\n * @param index The index of the asset\n * @param useIndexAsUniqueId If set to true, instead of the index in the array it will search for the unique id of the asset.\n * @returns The asset or null if not found\n */\nexport function GetFlowGraphAssetWithType<T extends FlowGraphAssetType>(\n assetsContext: IAssetContainer,\n type: T,\n index: number,\n useIndexAsUniqueId?: boolean\n): Nullable<AssetType<T>> {\n switch (type) {\n case FlowGraphAssetType.Animation:\n return useIndexAsUniqueId\n ? ((assetsContext.animations.find((a) => a.uniqueId === index) as AssetType<typeof type>) ?? null)\n : ((assetsContext.animations[index] as AssetType<typeof type>) ?? null);\n case FlowGraphAssetType.AnimationGroup:\n return useIndexAsUniqueId\n ? ((assetsContext.animationGroups.find((a) => a.uniqueId === index) as AssetType<typeof type>) ?? null)\n : ((assetsContext.animationGroups[index] as AssetType<typeof type>) ?? null);\n case FlowGraphAssetType.Mesh:\n return useIndexAsUniqueId\n ? ((assetsContext.meshes.find((a) => a.uniqueId === index) as AssetType<typeof type>) ?? null)\n : ((assetsContext.meshes[index] as AssetType<typeof type>) ?? null);\n case FlowGraphAssetType.Material:\n return useIndexAsUniqueId\n ? ((assetsContext.materials.find((a) => a.uniqueId === index) as AssetType<typeof type>) ?? null)\n : ((assetsContext.materials[index] as AssetType<typeof type>) ?? null);\n case FlowGraphAssetType.Camera:\n return useIndexAsUniqueId\n ? ((assetsContext.cameras.find((a) => a.uniqueId === index) as AssetType<typeof type>) ?? null)\n : ((assetsContext.cameras[index] as AssetType<typeof type>) ?? null);\n case FlowGraphAssetType.Light:\n return useIndexAsUniqueId\n ? ((assetsContext.lights.find((a) => a.uniqueId === index) as AssetType<typeof type>) ?? null)\n : ((assetsContext.lights[index] as AssetType<typeof type>) ?? null);\n default:\n return null;\n }\n}\n"]}
@@ -1,22 +1,20 @@
1
1
  import type { IFlowGraphBlockConfiguration } from "./flowGraphBlock";
2
2
  import type { FlowGraphContext } from "./flowGraphContext";
3
- import { FlowGraphExecutionBlock } from "./flowGraphExecutionBlock";
3
+ import { FlowGraphExecutionBlockWithOutSignal } from "./flowGraphExecutionBlockWithOutSignal";
4
4
  import type { FlowGraphSignalConnection } from "./flowGraphSignalConnection";
5
5
  /**
6
6
  * An async execution block can start tasks that will be executed asynchronously.
7
7
  * It should also be responsible for clearing it in _cancelPendingTasks.
8
- * @experimental
9
8
  */
10
- export declare abstract class FlowGraphAsyncExecutionBlock extends FlowGraphExecutionBlock {
11
- /**
12
- * Output connection: The signal that is triggered when the synchronous execution of this block is done.
13
- */
14
- out: FlowGraphSignalConnection;
9
+ export declare abstract class FlowGraphAsyncExecutionBlock extends FlowGraphExecutionBlockWithOutSignal {
15
10
  /**
16
11
  * Output connection: The signal that is triggered when the asynchronous execution of this block is done.
17
12
  */
18
13
  done: FlowGraphSignalConnection;
19
- constructor(config?: IFlowGraphBlockConfiguration);
14
+ protected _eventsSignalOutputs: {
15
+ [eventName: string]: FlowGraphSignalConnection;
16
+ };
17
+ constructor(config?: IFlowGraphBlockConfiguration, events?: string[]);
20
18
  /**
21
19
  * @internal
22
20
  * This function can be overridden to start any
@@ -25,10 +23,19 @@ export declare abstract class FlowGraphAsyncExecutionBlock extends FlowGraphExec
25
23
  * @param context
26
24
  */
27
25
  abstract _preparePendingTasks(context: FlowGraphContext): void;
26
+ /**
27
+ * @internal
28
+ * This function can be overridden to execute any
29
+ * logic that should be executed on every frame
30
+ * while the async task is pending.
31
+ * @param context the context in which it is running
32
+ */
33
+ _executeOnTick(_context: FlowGraphContext): void;
28
34
  /**
29
35
  * @internal
30
36
  * @param context
31
37
  */
32
38
  _startPendingTasks(context: FlowGraphContext): void;
39
+ _resetAfterCanceled(context: FlowGraphContext): void;
33
40
  abstract _cancelPendingTasks(context: FlowGraphContext): void;
34
41
  }
@@ -1,22 +1,42 @@
1
- import { FlowGraphExecutionBlock } from "./flowGraphExecutionBlock.js";
1
+ import { FlowGraphExecutionBlockWithOutSignal } from "./flowGraphExecutionBlockWithOutSignal.js";
2
2
  /**
3
3
  * An async execution block can start tasks that will be executed asynchronously.
4
4
  * It should also be responsible for clearing it in _cancelPendingTasks.
5
- * @experimental
6
5
  */
7
- export class FlowGraphAsyncExecutionBlock extends FlowGraphExecutionBlock {
8
- constructor(config) {
6
+ export class FlowGraphAsyncExecutionBlock extends FlowGraphExecutionBlockWithOutSignal {
7
+ constructor(config, events) {
9
8
  super(config);
10
- this.out = this._registerSignalOutput("out");
9
+ this._eventsSignalOutputs = {};
11
10
  this.done = this._registerSignalOutput("done");
11
+ events?.forEach((eventName) => {
12
+ this._eventsSignalOutputs[eventName] = this._registerSignalOutput(eventName + "Event");
13
+ });
12
14
  }
15
+ /**
16
+ * @internal
17
+ * This function can be overridden to execute any
18
+ * logic that should be executed on every frame
19
+ * while the async task is pending.
20
+ * @param context the context in which it is running
21
+ */
22
+ _executeOnTick(_context) { }
13
23
  /**
14
24
  * @internal
15
25
  * @param context
16
26
  */
17
27
  _startPendingTasks(context) {
28
+ if (context._getExecutionVariable(this, "_initialized", false)) {
29
+ this._cancelPendingTasks(context);
30
+ this._resetAfterCanceled(context);
31
+ }
18
32
  this._preparePendingTasks(context);
19
33
  context._addPendingBlock(this);
34
+ this.out._activateSignal(context);
35
+ context._setExecutionVariable(this, "_initialized", true);
36
+ }
37
+ _resetAfterCanceled(context) {
38
+ context._deleteExecutionVariable(this, "_initialized");
39
+ context._removePendingBlock(this);
20
40
  }
21
41
  }
22
42
  //# sourceMappingURL=flowGraphAsyncExecutionBlock.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"flowGraphAsyncExecutionBlock.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraphAsyncExecutionBlock.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAGpE;;;;GAIG;AACH,MAAM,OAAgB,4BAA6B,SAAQ,uBAAuB;IAU9E,YAAY,MAAqC;QAC7C,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC;QAC7C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;IACnD,CAAC;IAUD;;;OAGG;IACI,kBAAkB,CAAC,OAAyB;QAC/C,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;QACnC,OAAO,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;CAGJ","sourcesContent":["import 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 * An async execution block can start tasks that will be executed asynchronously.\r\n * It should also be responsible for clearing it in _cancelPendingTasks.\r\n * @experimental\r\n */\r\nexport abstract class FlowGraphAsyncExecutionBlock extends FlowGraphExecutionBlock {\r\n /**\r\n * Output connection: The signal that is triggered when the synchronous execution of this block is done.\r\n */\r\n public out: FlowGraphSignalConnection;\r\n /**\r\n * Output connection: The signal that is triggered when the asynchronous execution of this block is done.\r\n */\r\n public done: FlowGraphSignalConnection;\r\n\r\n constructor(config?: IFlowGraphBlockConfiguration) {\r\n super(config);\r\n this.out = this._registerSignalOutput(\"out\");\r\n this.done = this._registerSignalOutput(\"done\");\r\n }\r\n /**\r\n * @internal\r\n * This function can be overridden to start any\r\n * pending tasks this node might have, such as\r\n * timeouts and playing animations.\r\n * @param context\r\n */\r\n public abstract _preparePendingTasks(context: FlowGraphContext): void;\r\n\r\n /**\r\n * @internal\r\n * @param context\r\n */\r\n public _startPendingTasks(context: FlowGraphContext) {\r\n this._preparePendingTasks(context);\r\n context._addPendingBlock(this);\r\n }\r\n\r\n public abstract _cancelPendingTasks(context: FlowGraphContext): void;\r\n}\r\n"]}
1
+ {"version":3,"file":"flowGraphAsyncExecutionBlock.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraphAsyncExecutionBlock.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oCAAoC,EAAE,MAAM,wCAAwC,CAAC;AAG9F;;;GAGG;AACH,MAAM,OAAgB,4BAA6B,SAAQ,oCAAoC;IAQ3F,YAAY,MAAqC,EAAE,MAAiB;QAChE,KAAK,CAAC,MAAM,CAAC,CAAC;QAHR,yBAAoB,GAAuD,EAAE,CAAC;QAIpF,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;QAC/C,MAAM,EAAE,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE;YAC1B,IAAI,CAAC,oBAAoB,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,qBAAqB,CAAC,SAAS,GAAG,OAAO,CAAC,CAAC;QAC3F,CAAC,CAAC,CAAC;IACP,CAAC;IAUD;;;;;;OAMG;IACI,cAAc,CAAC,QAA0B,IAAS,CAAC;IAE1D;;;OAGG;IACI,kBAAkB,CAAC,OAAyB;QAC/C,IAAI,OAAO,CAAC,qBAAqB,CAAC,IAAI,EAAE,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC;YAC7D,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC;YAClC,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC;QACtC,CAAC;QAED,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;QACnC,OAAO,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAC/B,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QAClC,OAAO,CAAC,qBAAqB,CAAC,IAAI,EAAE,cAAc,EAAE,IAAI,CAAC,CAAC;IAC9D,CAAC;IAEM,mBAAmB,CAAC,OAAyB;QAChD,OAAO,CAAC,wBAAwB,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;QACvD,OAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;CAGJ","sourcesContent":["import type { IFlowGraphBlockConfiguration } from \"./flowGraphBlock\";\r\nimport type { FlowGraphContext } from \"./flowGraphContext\";\r\nimport { FlowGraphExecutionBlockWithOutSignal } from \"./flowGraphExecutionBlockWithOutSignal\";\r\nimport type { FlowGraphSignalConnection } from \"./flowGraphSignalConnection\";\r\n\r\n/**\r\n * An async execution block can start tasks that will be executed asynchronously.\r\n * It should also be responsible for clearing it in _cancelPendingTasks.\r\n */\r\nexport abstract class FlowGraphAsyncExecutionBlock extends FlowGraphExecutionBlockWithOutSignal {\r\n /**\r\n * Output connection: The signal that is triggered when the asynchronous execution of this block is done.\r\n */\r\n public done: FlowGraphSignalConnection;\r\n\r\n protected _eventsSignalOutputs: { [eventName: string]: FlowGraphSignalConnection } = {};\r\n\r\n constructor(config?: IFlowGraphBlockConfiguration, events?: string[]) {\r\n super(config);\r\n this.done = this._registerSignalOutput(\"done\");\r\n events?.forEach((eventName) => {\r\n this._eventsSignalOutputs[eventName] = this._registerSignalOutput(eventName + \"Event\");\r\n });\r\n }\r\n /**\r\n * @internal\r\n * This function can be overridden to start any\r\n * pending tasks this node might have, such as\r\n * timeouts and playing animations.\r\n * @param context\r\n */\r\n public abstract _preparePendingTasks(context: FlowGraphContext): void;\r\n\r\n /**\r\n * @internal\r\n * This function can be overridden to execute any\r\n * logic that should be executed on every frame\r\n * while the async task is pending.\r\n * @param context the context in which it is running\r\n */\r\n public _executeOnTick(_context: FlowGraphContext): void {}\r\n\r\n /**\r\n * @internal\r\n * @param context\r\n */\r\n public _startPendingTasks(context: FlowGraphContext) {\r\n if (context._getExecutionVariable(this, \"_initialized\", false)) {\r\n this._cancelPendingTasks(context);\r\n this._resetAfterCanceled(context);\r\n }\r\n\r\n this._preparePendingTasks(context);\r\n context._addPendingBlock(this);\r\n this.out._activateSignal(context);\r\n context._setExecutionVariable(this, \"_initialized\", true);\r\n }\r\n\r\n public _resetAfterCanceled(context: FlowGraphContext) {\r\n context._deleteExecutionVariable(this, \"_initialized\");\r\n context._removePendingBlock(this);\r\n }\r\n\r\n public abstract _cancelPendingTasks(context: FlowGraphContext): void;\r\n}\r\n"]}