@babylonjs/core 6.19.0 → 6.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (253) hide show
  1. package/Actions/actionManager.js +2 -2
  2. package/Actions/actionManager.js.map +1 -1
  3. package/Animations/runtimeAnimation.js +2 -2
  4. package/Animations/runtimeAnimation.js.map +1 -1
  5. package/Cameras/Inputs/BaseCameraPointersInput.d.ts +4 -4
  6. package/Cameras/Inputs/BaseCameraPointersInput.js +4 -6
  7. package/Cameras/Inputs/BaseCameraPointersInput.js.map +1 -1
  8. package/Cameras/Inputs/arcRotateCameraPointersInput.d.ts +3 -2
  9. package/Cameras/Inputs/arcRotateCameraPointersInput.js +3 -2
  10. package/Cameras/Inputs/arcRotateCameraPointersInput.js.map +1 -1
  11. package/Cameras/Inputs/flyCameraMouseInput.js +2 -7
  12. package/Cameras/Inputs/flyCameraMouseInput.js.map +1 -1
  13. package/Cameras/Inputs/freeCameraKeyboardMoveInput.js +2 -7
  14. package/Cameras/Inputs/freeCameraKeyboardMoveInput.js.map +1 -1
  15. package/Cameras/Inputs/freeCameraMouseInput.js +4 -14
  16. package/Cameras/Inputs/freeCameraMouseInput.js.map +1 -1
  17. package/Cameras/Inputs/freeCameraTouchInput.js +2 -1
  18. package/Cameras/Inputs/freeCameraTouchInput.js.map +1 -1
  19. package/Cameras/arcRotateCamera.js +2 -7
  20. package/Cameras/arcRotateCamera.js.map +1 -1
  21. package/Cameras/camera.d.ts +2 -0
  22. package/Cameras/camera.js +8 -0
  23. package/Cameras/camera.js.map +1 -1
  24. package/Compute/computeShader.d.ts +15 -0
  25. package/Compute/computeShader.js +39 -0
  26. package/Compute/computeShader.js.map +1 -1
  27. package/Debug/physicsViewer.d.ts +33 -0
  28. package/Debug/physicsViewer.js +205 -0
  29. package/Debug/physicsViewer.js.map +1 -1
  30. package/Engines/Extensions/engine.computeShader.d.ts +2 -1
  31. package/Engines/Extensions/engine.computeShader.js +1 -0
  32. package/Engines/Extensions/engine.computeShader.js.map +1 -1
  33. package/Engines/WebGPU/webgpuComputeContext.js +15 -0
  34. package/Engines/WebGPU/webgpuComputeContext.js.map +1 -1
  35. package/Engines/thinEngine.js +2 -2
  36. package/Engines/thinEngine.js.map +1 -1
  37. package/FlowGraph/Blocks/Data/flowGraphAddBlock.d.ts +23 -0
  38. package/FlowGraph/Blocks/Data/flowGraphAddBlock.js +18 -0
  39. package/FlowGraph/Blocks/Data/flowGraphAddBlock.js.map +1 -0
  40. package/FlowGraph/Blocks/Data/flowGraphConditionalDataBlock.d.ts +30 -0
  41. package/FlowGraph/Blocks/Data/flowGraphConditionalDataBlock.js +22 -0
  42. package/FlowGraph/Blocks/Data/flowGraphConditionalDataBlock.js.map +1 -0
  43. package/FlowGraph/Blocks/Data/flowGraphGetVariableBlock.d.ts +33 -0
  44. package/FlowGraph/Blocks/Data/flowGraphGetVariableBlock.js +30 -0
  45. package/FlowGraph/Blocks/Data/flowGraphGetVariableBlock.js.map +1 -0
  46. package/FlowGraph/Blocks/Data/index.d.ts +3 -1
  47. package/FlowGraph/Blocks/Data/index.js +3 -1
  48. package/FlowGraph/Blocks/Data/index.js.map +1 -1
  49. package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.d.ts +12 -10
  50. package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.js +25 -29
  51. package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.js.map +1 -1
  52. package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.d.ts +25 -0
  53. package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js +31 -0
  54. package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js.map +1 -0
  55. package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.d.ts +3 -7
  56. package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.js +11 -11
  57. package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.js.map +1 -1
  58. package/FlowGraph/Blocks/Event/index.d.ts +1 -0
  59. package/FlowGraph/Blocks/Event/index.js +1 -0
  60. package/FlowGraph/Blocks/Event/index.js.map +1 -1
  61. package/FlowGraph/Blocks/Execution/flowGraphConditionalBlock.d.ts +24 -0
  62. package/FlowGraph/Blocks/Execution/flowGraphConditionalBlock.js +23 -0
  63. package/FlowGraph/Blocks/Execution/flowGraphConditionalBlock.js.map +1 -0
  64. package/FlowGraph/Blocks/Execution/flowGraphForLoopBlock.d.ts +10 -13
  65. package/FlowGraph/Blocks/Execution/flowGraphForLoopBlock.js +28 -22
  66. package/FlowGraph/Blocks/Execution/flowGraphForLoopBlock.js.map +1 -1
  67. package/FlowGraph/Blocks/Execution/flowGraphLogBlock.d.ts +5 -5
  68. package/FlowGraph/Blocks/Execution/flowGraphLogBlock.js +8 -6
  69. package/FlowGraph/Blocks/Execution/flowGraphLogBlock.js.map +1 -1
  70. package/FlowGraph/Blocks/Execution/flowGraphPlayAnimationBlock.d.ts +56 -0
  71. package/FlowGraph/Blocks/Execution/flowGraphPlayAnimationBlock.js +66 -0
  72. package/FlowGraph/Blocks/Execution/flowGraphPlayAnimationBlock.js.map +1 -0
  73. package/FlowGraph/Blocks/Execution/flowGraphSendCustomEventBlock.d.ts +18 -0
  74. package/FlowGraph/Blocks/Execution/flowGraphSendCustomEventBlock.js +19 -0
  75. package/FlowGraph/Blocks/Execution/flowGraphSendCustomEventBlock.js.map +1 -0
  76. package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.d.ts +26 -0
  77. package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js +36 -0
  78. package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js.map +1 -0
  79. package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.d.ts +23 -0
  80. package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.js +25 -0
  81. package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.js.map +1 -0
  82. package/FlowGraph/Blocks/Execution/flowGraphStopAnimationBlock.d.ts +16 -0
  83. package/FlowGraph/Blocks/Execution/flowGraphStopAnimationBlock.js +18 -0
  84. package/FlowGraph/Blocks/Execution/flowGraphStopAnimationBlock.js.map +1 -0
  85. package/FlowGraph/Blocks/Execution/flowGraphTimerBlock.d.ts +32 -0
  86. package/FlowGraph/Blocks/Execution/flowGraphTimerBlock.js +62 -0
  87. package/FlowGraph/Blocks/Execution/flowGraphTimerBlock.js.map +1 -0
  88. package/FlowGraph/Blocks/Execution/index.d.ts +7 -0
  89. package/FlowGraph/Blocks/Execution/index.js +7 -0
  90. package/FlowGraph/Blocks/Execution/index.js.map +1 -1
  91. package/FlowGraph/flowGraph.d.ts +42 -12
  92. package/FlowGraph/flowGraph.js +37 -23
  93. package/FlowGraph/flowGraph.js.map +1 -1
  94. package/FlowGraph/flowGraphAsyncExecutionBlock.d.ts +29 -0
  95. package/FlowGraph/flowGraphAsyncExecutionBlock.js +21 -0
  96. package/FlowGraph/flowGraphAsyncExecutionBlock.js.map +1 -0
  97. package/FlowGraph/flowGraphBlock.d.ts +9 -11
  98. package/FlowGraph/flowGraphBlock.js +12 -8
  99. package/FlowGraph/flowGraphBlock.js.map +1 -1
  100. package/FlowGraph/flowGraphConnection.d.ts +17 -7
  101. package/FlowGraph/flowGraphConnection.js +26 -9
  102. package/FlowGraph/flowGraphConnection.js.map +1 -1
  103. package/FlowGraph/flowGraphContext.d.ts +102 -0
  104. package/FlowGraph/flowGraphContext.js +111 -0
  105. package/FlowGraph/flowGraphContext.js.map +1 -0
  106. package/FlowGraph/flowGraphCustomEvent.d.ts +5 -0
  107. package/FlowGraph/flowGraphCustomEvent.js +2 -0
  108. package/FlowGraph/flowGraphCustomEvent.js.map +1 -0
  109. package/FlowGraph/flowGraphDataConnection.d.ts +10 -2
  110. package/FlowGraph/flowGraphDataConnection.js +16 -8
  111. package/FlowGraph/flowGraphDataConnection.js.map +1 -1
  112. package/FlowGraph/flowGraphEventBlock.d.ts +5 -12
  113. package/FlowGraph/flowGraphEventBlock.js +5 -5
  114. package/FlowGraph/flowGraphEventBlock.js.map +1 -1
  115. package/FlowGraph/flowGraphEventCoordinator.d.ts +23 -0
  116. package/FlowGraph/flowGraphEventCoordinator.js +37 -0
  117. package/FlowGraph/flowGraphEventCoordinator.js.map +1 -0
  118. package/FlowGraph/flowGraphExecutionBlock.d.ts +5 -5
  119. package/FlowGraph/flowGraphExecutionBlock.js +3 -3
  120. package/FlowGraph/flowGraphExecutionBlock.js.map +1 -1
  121. package/FlowGraph/flowGraphRichTypes.d.ts +28 -0
  122. package/FlowGraph/flowGraphRichTypes.js +43 -0
  123. package/FlowGraph/flowGraphRichTypes.js.map +1 -0
  124. package/FlowGraph/flowGraphSignalConnection.d.ts +7 -1
  125. package/FlowGraph/flowGraphSignalConnection.js +11 -4
  126. package/FlowGraph/flowGraphSignalConnection.js.map +1 -1
  127. package/FlowGraph/flowGraphVariableDefinitions.d.ts +12 -0
  128. package/FlowGraph/flowGraphVariableDefinitions.js +22 -0
  129. package/FlowGraph/flowGraphVariableDefinitions.js.map +1 -0
  130. package/FlowGraph/flowGraphWithOnDoneExecutionBlock.d.ts +10 -2
  131. package/FlowGraph/flowGraphWithOnDoneExecutionBlock.js +8 -2
  132. package/FlowGraph/flowGraphWithOnDoneExecutionBlock.js.map +1 -1
  133. package/FlowGraph/index.d.ts +3 -0
  134. package/FlowGraph/index.js +3 -0
  135. package/FlowGraph/index.js.map +1 -1
  136. package/Materials/Node/nodeMaterial.d.ts +2 -1
  137. package/Materials/Node/nodeMaterial.js +26 -2
  138. package/Materials/Node/nodeMaterial.js.map +1 -1
  139. package/Materials/PBR/pbrBaseMaterial.d.ts +1 -0
  140. package/Materials/PBR/pbrBaseMaterial.js +1 -0
  141. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  142. package/Materials/Textures/videoTexture.d.ts +5 -0
  143. package/Materials/Textures/videoTexture.js +6 -0
  144. package/Materials/Textures/videoTexture.js.map +1 -1
  145. package/Materials/materialHelper.js +1 -0
  146. package/Materials/materialHelper.js.map +1 -1
  147. package/Materials/standardMaterial.d.ts +1 -0
  148. package/Materials/standardMaterial.js +1 -0
  149. package/Materials/standardMaterial.js.map +1 -1
  150. package/Materials/uniformBuffer.d.ts +7 -0
  151. package/Materials/uniformBuffer.js +8 -0
  152. package/Materials/uniformBuffer.js.map +1 -1
  153. package/Maths/math.vector.d.ts +5 -0
  154. package/Maths/math.vector.js +7 -0
  155. package/Maths/math.vector.js.map +1 -1
  156. package/Meshes/Node/Blocks/Instances/instantiateBlock.d.ts +11 -5
  157. package/Meshes/Node/Blocks/Instances/instantiateBlock.js +20 -10
  158. package/Meshes/Node/Blocks/Instances/instantiateBlock.js.map +1 -1
  159. package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.d.ts +15 -9
  160. package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.js +20 -11
  161. package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.js.map +1 -1
  162. package/Meshes/Node/Blocks/Instances/instantiateOnVerticesBlock.d.ts +15 -9
  163. package/Meshes/Node/Blocks/Instances/instantiateOnVerticesBlock.js +20 -11
  164. package/Meshes/Node/Blocks/Instances/instantiateOnVerticesBlock.js.map +1 -1
  165. package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.d.ts +15 -9
  166. package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.js +20 -11
  167. package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.js.map +1 -1
  168. package/Meshes/Node/Blocks/Set/setColorsBlock.d.ts +12 -0
  169. package/Meshes/Node/Blocks/Set/setColorsBlock.js +62 -27
  170. package/Meshes/Node/Blocks/Set/setColorsBlock.js.map +1 -1
  171. package/Meshes/Node/Blocks/Set/setMaterialIDBlock.d.ts +7 -0
  172. package/Meshes/Node/Blocks/Set/setMaterialIDBlock.js +19 -0
  173. package/Meshes/Node/Blocks/Set/setMaterialIDBlock.js.map +1 -1
  174. package/Meshes/Node/Blocks/Set/setNormalsBlock.d.ts +12 -0
  175. package/Meshes/Node/Blocks/Set/setNormalsBlock.js +62 -27
  176. package/Meshes/Node/Blocks/Set/setNormalsBlock.js.map +1 -1
  177. package/Meshes/Node/Blocks/Set/setPositionsBlock.d.ts +12 -0
  178. package/Meshes/Node/Blocks/Set/setPositionsBlock.js +54 -19
  179. package/Meshes/Node/Blocks/Set/setPositionsBlock.js.map +1 -1
  180. package/Meshes/Node/Blocks/Set/setTangentsBlock.d.ts +12 -0
  181. package/Meshes/Node/Blocks/Set/setTangentsBlock.js +62 -27
  182. package/Meshes/Node/Blocks/Set/setTangentsBlock.js.map +1 -1
  183. package/Meshes/Node/Blocks/Set/setUVsBlock.d.ts +5 -0
  184. package/Meshes/Node/Blocks/Set/setUVsBlock.js +65 -46
  185. package/Meshes/Node/Blocks/Set/setUVsBlock.js.map +1 -1
  186. package/Meshes/Node/Blocks/debugBlock.js +5 -1
  187. package/Meshes/Node/Blocks/debugBlock.js.map +1 -1
  188. package/Meshes/Node/Blocks/geometryInputBlock.js +1 -0
  189. package/Meshes/Node/Blocks/geometryInputBlock.js.map +1 -1
  190. package/Meshes/Node/Blocks/intFloatConverterBlock.js +2 -2
  191. package/Meshes/Node/Blocks/intFloatConverterBlock.js.map +1 -1
  192. package/Meshes/Node/Blocks/mapRangeBlock.js +8 -1
  193. package/Meshes/Node/Blocks/mapRangeBlock.js.map +1 -1
  194. package/Meshes/Node/Blocks/mathBlock.js +1 -0
  195. package/Meshes/Node/Blocks/mathBlock.js.map +1 -1
  196. package/Meshes/Node/Blocks/matrixComposeBlock.d.ts +30 -0
  197. package/Meshes/Node/Blocks/matrixComposeBlock.js +55 -0
  198. package/Meshes/Node/Blocks/matrixComposeBlock.js.map +1 -0
  199. package/Meshes/Node/Enums/nodeGeometryContextualSources.d.ts +3 -1
  200. package/Meshes/Node/Enums/nodeGeometryContextualSources.js +2 -0
  201. package/Meshes/Node/Enums/nodeGeometryContextualSources.js.map +1 -1
  202. package/Meshes/Node/Interfaces/nodeGeometryInstancingContext.d.ts +10 -0
  203. package/Meshes/Node/Interfaces/nodeGeometryInstancingContext.js +2 -0
  204. package/Meshes/Node/Interfaces/nodeGeometryInstancingContext.js.map +1 -0
  205. package/Meshes/Node/index.d.ts +1 -0
  206. package/Meshes/Node/index.js +1 -0
  207. package/Meshes/Node/index.js.map +1 -1
  208. package/Meshes/Node/nodeGeometry.js +2 -2
  209. package/Meshes/Node/nodeGeometry.js.map +1 -1
  210. package/Meshes/Node/nodeGeometryBuildState.d.ts +5 -0
  211. package/Meshes/Node/nodeGeometryBuildState.js +20 -0
  212. package/Meshes/Node/nodeGeometryBuildState.js.map +1 -1
  213. package/Meshes/abstractMesh.js +4 -1
  214. package/Meshes/abstractMesh.js.map +1 -1
  215. package/Meshes/geometry.js +10 -10
  216. package/Meshes/geometry.js.map +1 -1
  217. package/Meshes/mesh.js +7 -5
  218. package/Meshes/mesh.js.map +1 -1
  219. package/Misc/PerformanceViewer/performanceViewerCollectionStrategies.js +2 -1
  220. package/Misc/PerformanceViewer/performanceViewerCollectionStrategies.js.map +1 -1
  221. package/Misc/dumpTools.js +3 -2
  222. package/Misc/dumpTools.js.map +1 -1
  223. package/Misc/equirectangularCapture.d.ts +39 -0
  224. package/Misc/equirectangularCapture.js +56 -0
  225. package/Misc/equirectangularCapture.js.map +1 -0
  226. package/Misc/index.d.ts +1 -0
  227. package/Misc/index.js +1 -0
  228. package/Misc/index.js.map +1 -1
  229. package/Particles/solidParticleSystem.d.ts +4 -0
  230. package/Particles/solidParticleSystem.js +16 -1
  231. package/Particles/solidParticleSystem.js.map +1 -1
  232. package/Physics/v2/IPhysicsEnginePlugin.d.ts +10 -0
  233. package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -1
  234. package/Physics/v2/Plugins/havokPlugin.d.ts +8 -1
  235. package/Physics/v2/Plugins/havokPlugin.js +34 -0
  236. package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
  237. package/Physics/v2/physicsConstraint.d.ts +11 -1
  238. package/Physics/v2/physicsConstraint.js +7 -0
  239. package/Physics/v2/physicsConstraint.js.map +1 -1
  240. package/Rendering/prePassRenderer.d.ts +6 -0
  241. package/Rendering/prePassRenderer.js +14 -0
  242. package/Rendering/prePassRenderer.js.map +1 -1
  243. package/Shaders/default.fragment.js +4 -0
  244. package/Shaders/default.fragment.js.map +1 -1
  245. package/Shaders/equirectangularPanorama.fragment.d.ts +5 -0
  246. package/Shaders/equirectangularPanorama.fragment.js +17 -0
  247. package/Shaders/equirectangularPanorama.fragment.js.map +1 -0
  248. package/Shaders/pbr.fragment.js +4 -0
  249. package/Shaders/pbr.fragment.js.map +1 -1
  250. package/package.json +1 -1
  251. package/FlowGraph/Blocks/Data/flowGraphBinaryOpBlocks.d.ts +0 -34
  252. package/FlowGraph/Blocks/Data/flowGraphBinaryOpBlocks.js +0 -29
  253. package/FlowGraph/Blocks/Data/flowGraphBinaryOpBlocks.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"instantiateOnVerticesBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Meshes/Node/Blocks/Instances/instantiateOnVerticesBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,8CAA8C,CAAC;AAIrG,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AACtG,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAG3D;;GAEG;AACH,MAAM,OAAO,0BAA2B,SAAQ,iBAAiB;IAmB7D;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QApBR,sBAAiB,GAAwC,IAAI,CAAC;QAEtE;;;WAGG;QAEI,o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NodeGeometryBlock } from \"../../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../../nodeGeometryBlockConnectionPoint\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../../Enums/nodeGeometryConnectionPointTypes\";\r\nimport type { NodeGeometryBuildState } from \"../../nodeGeometryBuildState\";\r\nimport type { INodeGeometryExecutionContext } from \"../../Interfaces/nodeGeometryExecutionContext\";\r\nimport type { VertexData } from \"../../../mesh.vertexData\";\r\nimport { Vector3 } from \"../../../../Maths/math.vector\";\r\nimport { PropertyTypeForEdition, editableInPropertyPage } from \"../../../../Decorators/nodeDecorator\";\r\nimport { Epsilon } from \"../../../../Maths/math.constants\";\r\nimport type { Nullable } from \"../../../../types\";\r\n\r\n/**\r\n * Block used to instance geometry on every vertex of a geometry\r\n */\r\nexport class InstantiateOnVerticesBlock extends NodeGeometryBlock implements INodeGeometryExecutionContext {\r\n private _vertexData: VertexData;\r\n private _currentIndex: number;\r\n private _currentLoopIndex: number;\r\n private _indexTranslation: Nullable<{ [key: number]: number }> = null;\r\n\r\n /**\r\n * Gets or sets a boolean indicating that this block can evaluate context\r\n * Build performance is improved when this value is set to false as the system will cache values instead of reevaluating everything per context change\r\n */\r\n @editableInPropertyPage(\"Evaluate context\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { notifiers: { rebuild: true } })\r\n public evaluateContext = true;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if the block should remove duplicated positions\r\n */\r\n @editableInPropertyPage(\"Remove duplicated positions\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { notifiers: { update: true } })\r\n public removeDuplicatedPositions = true;\r\n\r\n /**\r\n * Create a new InstantiateOnVerticesBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"geometry\", NodeGeometryBlockConnectionPointTypes.Geometry);\r\n this.registerInput(\"instance\", NodeGeometryBlockConnectionPointTypes.Geometry, true);\r\n this.registerInput(\"rotation\", NodeGeometryBlockConnectionPointTypes.Vector3, true, Vector3.Zero());\r\n this.registerInput(\"scaling\", NodeGeometryBlockConnectionPointTypes.Vector3, true, Vector3.One());\r\n this.registerInput(\"matrix\", NodeGeometryBlockConnectionPointTypes.Matrix, true);\r\n this.registerInput(\"density\", NodeGeometryBlockConnectionPointTypes.Float, true, 1, 0, 1);\r\n\r\n this.scaling.acceptedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Float);\r\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.Geometry);\r\n }\r\n\r\n /**\r\n * Gets the current index in the current flow\r\n * @returns the current index\r\n */\r\n public getExecutionIndex(): number {\r\n return this._indexTranslation ? this._indexTranslation[this._currentIndex] : this._currentIndex;\r\n }\r\n\r\n /**\r\n * Gets the current loop index in the current flow\r\n * @returns the current loop index\r\n */\r\n public getExecutionLoopIndex(): number {\r\n return this._currentLoopIndex;\r\n }\r\n\r\n /**\r\n * Gets the current face index in the current flow\r\n * @returns the current face index\r\n */\r\n public getExecutionFaceIndex(): number {\r\n return 0;\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public getClassName() {\r\n return \"InstantiateOnVerticesBlock\";\r\n }\r\n\r\n /**\r\n * Gets the geometry input component\r\n */\r\n public get geometry(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the instance input component\r\n */\r\n public get instance(): NodeGeometryConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the rotation input component\r\n */\r\n public get rotation(): NodeGeometryConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the scaling input component\r\n */\r\n public get scaling(): NodeGeometryConnectionPoint {\r\n return this._inputs[3];\r\n }\r\n\r\n /**\r\n * Gets the matrix input component\r\n */\r\n public get matrix(): NodeGeometryConnectionPoint {\r\n return this._inputs[4];\r\n }\r\n /**\r\n * Gets the density input component\r\n */\r\n public get density(): NodeGeometryConnectionPoint {\r\n return this._inputs[5];\r\n }\r\n\r\n /**\r\n * Gets the geometry output component\r\n */\r\n public get output(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n protected _buildBlock(state: NodeGeometryBuildState) {\r\n const func = (state: NodeGeometryBuildState) => {\r\n state.executionContext = this;\r\n\r\n this._vertexData = this.geometry.getConnectedValue(state);\r\n state.geometryContext = this._vertexData;\r\n\r\n if (!this._vertexData || !this._vertexData.positions || !this.instance.isConnected) {\r\n state.executionContext = null;\r\n state.geometryContext = null;\r\n this.output._storedValue = null;\r\n return;\r\n }\r\n\r\n // Processing\r\n let vertexCount = this._vertexData.positions.length / 3;\r\n const additionalVertexData: VertexData[] = [];\r\n const currentPosition = new Vector3();\r\n const alreadyDone = new Array<number>();\r\n let vertices = this._vertexData.positions;\r\n this._currentLoopIndex = 0;\r\n\r\n if (this.removeDuplicatedPositions) {\r\n this._indexTranslation = {};\r\n for (this._currentIndex = 0; this._currentIndex < vertexCount; this._currentIndex++) {\r\n const x = vertices[this._currentIndex * 3];\r\n const y = vertices[this._currentIndex * 3 + 1];\r\n const z = vertices[this._currentIndex * 3 + 2];\r\n let found = false;\r\n for (let index = 0; index < alreadyDone.length; index += 3) {\r\n if (Math.abs(alreadyDone[index] - x) < Epsilon && Math.abs(alreadyDone[index + 1] - y) < Epsilon && Math.abs(alreadyDone[index + 2] - z) < Epsilon) {\r\n found = true;\r\n break;\r\n }\r\n }\r\n\r\n if (found) {\r\n continue;\r\n }\r\n this._indexTranslation[alreadyDone.length / 3] = this._currentIndex;\r\n alreadyDone.push(x, y, z);\r\n }\r\n\r\n vertices = alreadyDone;\r\n vertexCount = vertices.length / 3;\r\n } else {\r\n this._indexTranslation = null;\r\n }\r\n\r\n for (this._currentIndex = 0; this._currentIndex < vertexCount; this._currentIndex++) {\r\n const instanceGeometry = this.instance.getConnectedValue(state) as VertexData;\r\n\r\n if (!instanceGeometry || !instanceGeometry.positions || instanceGeometry.positions.length === 0) {\r\n continue;\r\n }\r\n\r\n const density = this.density.getConnectedValue(state);\r\n\r\n if (density < 1) {\r\n if (Math.random() > density) {\r\n continue;\r\n }\r\n }\r\n\r\n currentPosition.fromArray(vertices, this._currentIndex * 3);\r\n\r\n // Clone the instance\r\n const clone = instanceGeometry.clone();\r\n\r\n // Transform\r\n if (this.matrix.isConnected) {\r\n const transform = this.matrix.getConnectedValue(state);\r\n state._instantiateWithMatrix(clone, transform, additionalVertexData);\r\n } else {\r\n const scaling = state.adaptInput(this.scaling, NodeGeometryBlockConnectionPointTypes.Vector3, Vector3.OneReadOnly);\r\n const rotation = this.rotation.getConnectedValue(state) || Vector3.ZeroReadOnly;\r\n state._instantiate(clone, currentPosition, rotation, scaling, additionalVertexData);\r\n }\r\n this._currentLoopIndex++;\r\n }\r\n\r\n // Merge\r\n if (additionalVertexData.length) {\r\n if (additionalVertexData.length === 1) {\r\n this._vertexData = additionalVertexData[0];\r\n } else {\r\n // We do not merge the main one as user can use a merge node if wanted\r\n const main = additionalVertexData.splice(0, 1)[0];\r\n this._vertexData = main.merge(additionalVertexData, true, false, true, true);\r\n }\r\n }\r\n\r\n return this._vertexData;\r\n };\r\n\r\n // Storage\r\n if (this.evaluateContext) {\r\n this.output._storedFunction = func;\r\n } else {\r\n this.output._storedValue = func(state);\r\n }\r\n }\r\n\r\n protected _dumpPropertiesCode() {\r\n let codeString = super._dumpPropertiesCode() + `${this._codeVariableName}.removeDuplicatedPositions = ${this.removeDuplicatedPositions ? \"true\" : \"false\"};\\n`;\r\n codeString += `${this._codeVariableName}.evaluateContext = ${this.evaluateContext ? \"true\" : \"false\"};\\n`;\r\n return codeString;\r\n }\r\n\r\n /**\r\n * Serializes this block in a JSON representation\r\n * @returns the serialized block object\r\n */\r\n public serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.removeDuplicatedPositions = this.removeDuplicatedPositions;\r\n serializationObject.evaluateContext = this.evaluateContext;\r\n\r\n return serializationObject;\r\n }\r\n\r\n public _deserialize(serializationObject: any) {\r\n super._deserialize(serializationObject);\r\n\r\n this.removeDuplicatedPositions = serializationObject.removeDuplicatedPositions;\r\n if (serializationObject.evaluateContext !== undefined) {\r\n this.evaluateContext = serializationObject.evaluateContext;\r\n }\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.InstantiateOnVerticesBlock\", InstantiateOnVerticesBlock);\r\n"]}
1
+ {"version":3,"file":"instantiateOnVerticesBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Meshes/Node/Blocks/Instances/instantiateOnVerticesBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,8CAA8C,CAAC;AAIrG,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AACtG,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAI3D;;GAEG;AACH,MAAM,OAAO,0BAA2B,SAAQ,iBAAiB;IAmB7D;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QApBR,sBAAiB,GAAwC,IAAI,CAAC;QAEtE;;;WAGG;QAEI,oBAAe,GAAG,IAAI,CAAC;QAE9B;;WAEG;QAEI,8BAAyB,GAAG,IAAI,CAAC;QASpC,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,qCAAqC,CAAC,QAAQ,CAAC,CAAC;QAC/E,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,qCAAqC,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QACrF,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,qCAAqC,CAAC,KAAK,EAAE,IAAI,EAAE,C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C,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,KAAK,CAAC;QAC/J,UAAU,IAAI,GAAG,IAAI,CAAC,iBAAiB,sBAAsB,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,KAAK,CAAC;QAC1G,OAAO,UAAU,CAAC;IACtB,CAAC;IAED;;;OAGG;IACI,SAAS;QACZ,MAAM,mBAAmB,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;QAE9C,mBAAmB,CAAC,yBAAyB,GAAG,IAAI,CAAC,yBAAyB,CAAC;QAC/E,mBAAmB,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;QAE3D,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAEM,YAAY,CAAC,mBAAwB;QACxC,KAAK,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAAC;QAExC,IAAI,CAAC,yBAAyB,GAAG,mBAAmB,CAAC,yBAAyB,CAAC;QAC/E,IAAI,mBAAmB,CAAC,eAAe,KAAK,SAAS,EAAE;YACnD,IAAI,CAAC,eAAe,GAAG,mBAAmB,CAAC,eAAe,CAAC;SAC9D;IACL,CAAC;CACJ;AAvPU;IADN,sBAAsB,CAAC,kBAAkB,EAAE,sBAAsB,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;mEAC3F;AAMvB;IADN,sBAAsB,CAAC,6BAA6B,EAAE,sBAAsB,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC;6EAC3F;AAmP5C,aAAa,CAAC,oCAAoC,EAAE,0BAA0B,CAAC,CAAC","sourcesContent":["import { NodeGeometryBlock } from \"../../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../../nodeGeometryBlockConnectionPoint\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../../Enums/nodeGeometryConnectionPointTypes\";\r\nimport type { NodeGeometryBuildState } from \"../../nodeGeometryBuildState\";\r\nimport type { INodeGeometryExecutionContext } from \"../../Interfaces/nodeGeometryExecutionContext\";\r\nimport type { VertexData } from \"../../../mesh.vertexData\";\r\nimport { Vector3 } from \"../../../../Maths/math.vector\";\r\nimport { PropertyTypeForEdition, editableInPropertyPage } from \"../../../../Decorators/nodeDecorator\";\r\nimport { Epsilon } from \"../../../../Maths/math.constants\";\r\nimport type { Nullable } from \"../../../../types\";\r\nimport type { INodeGeometryInstancingContext } from \"../../Interfaces/nodeGeometryInstancingContext\";\r\n\r\n/**\r\n * Block used to instance geometry on every vertex of a geometry\r\n */\r\nexport class InstantiateOnVerticesBlock extends NodeGeometryBlock implements INodeGeometryExecutionContext, INodeGeometryInstancingContext {\r\n private _vertexData: VertexData;\r\n private _currentIndex: number;\r\n private _currentLoopIndex: number;\r\n private _indexTranslation: Nullable<{ [key: number]: number }> = null;\r\n\r\n /**\r\n * Gets or sets a boolean indicating that this block can evaluate context\r\n * Build performance is improved when this value is set to false as the system will cache values instead of reevaluating everything per context change\r\n */\r\n @editableInPropertyPage(\"Evaluate context\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { notifiers: { rebuild: true } })\r\n public evaluateContext = true;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if the block should remove duplicated positions\r\n */\r\n @editableInPropertyPage(\"Remove duplicated positions\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { notifiers: { update: true } })\r\n public removeDuplicatedPositions = true;\r\n\r\n /**\r\n * Create a new InstantiateOnVerticesBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"geometry\", NodeGeometryBlockConnectionPointTypes.Geometry);\r\n this.registerInput(\"instance\", NodeGeometryBlockConnectionPointTypes.Geometry, true);\r\n this.registerInput(\"density\", NodeGeometryBlockConnectionPointTypes.Float, true, 1, 0, 1);\r\n this.registerInput(\"matrix\", NodeGeometryBlockConnectionPointTypes.Matrix, true);\r\n this.registerInput(\"rotation\", NodeGeometryBlockConnectionPointTypes.Vector3, true, Vector3.Zero());\r\n this.registerInput(\"scaling\", NodeGeometryBlockConnectionPointTypes.Vector3, true, Vector3.One());\r\n\r\n this.scaling.acceptedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Float);\r\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.Geometry);\r\n }\r\n\r\n /**\r\n * Gets the current instance index in the current flow\r\n * @returns the current index\r\n */\r\n public getInstanceIndex(): number {\r\n return this._currentLoopIndex;\r\n }\r\n\r\n /**\r\n * Gets the current index in the current flow\r\n * @returns the current index\r\n */\r\n public getExecutionIndex(): number {\r\n return this._indexTranslation ? this._indexTranslation[this._currentIndex] : this._currentIndex;\r\n }\r\n\r\n /**\r\n * Gets the current loop index in the current flow\r\n * @returns the current loop index\r\n */\r\n public getExecutionLoopIndex(): number {\r\n return this._currentLoopIndex;\r\n }\r\n\r\n /**\r\n * Gets the current face index in the current flow\r\n * @returns the current face index\r\n */\r\n public getExecutionFaceIndex(): number {\r\n return 0;\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public getClassName() {\r\n return \"InstantiateOnVerticesBlock\";\r\n }\r\n\r\n /**\r\n * Gets the geometry input component\r\n */\r\n public get geometry(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the instance input component\r\n */\r\n public get instance(): NodeGeometryConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the density input component\r\n */\r\n public get density(): NodeGeometryConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the matrix input component\r\n */\r\n public get matrix(): NodeGeometryConnectionPoint {\r\n return this._inputs[3];\r\n }\r\n\r\n /**\r\n * Gets the rotation input component\r\n */\r\n public get rotation(): NodeGeometryConnectionPoint {\r\n return this._inputs[4];\r\n }\r\n\r\n /**\r\n * Gets the scaling input component\r\n */\r\n public get scaling(): NodeGeometryConnectionPoint {\r\n return this._inputs[5];\r\n }\r\n\r\n /**\r\n * Gets the geometry output component\r\n */\r\n public get output(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n protected _buildBlock(state: NodeGeometryBuildState) {\r\n const func = (state: NodeGeometryBuildState) => {\r\n state.executionContext = this;\r\n state.instancingContext = this;\r\n\r\n this._vertexData = this.geometry.getConnectedValue(state);\r\n state.geometryContext = this._vertexData;\r\n\r\n if (!this._vertexData || !this._vertexData.positions || !this.instance.isConnected) {\r\n state.executionContext = null;\r\n state.geometryContext = null;\r\n state.instancingContext = null;\r\n this.output._storedValue = null;\r\n return;\r\n }\r\n\r\n // Processing\r\n let vertexCount = this._vertexData.positions.length / 3;\r\n const additionalVertexData: VertexData[] = [];\r\n const currentPosition = new Vector3();\r\n const alreadyDone = new Array<number>();\r\n let vertices = this._vertexData.positions;\r\n this._currentLoopIndex = 0;\r\n\r\n if (this.removeDuplicatedPositions) {\r\n this._indexTranslation = {};\r\n for (this._currentIndex = 0; this._currentIndex < vertexCount; this._currentIndex++) {\r\n const x = vertices[this._currentIndex * 3];\r\n const y = vertices[this._currentIndex * 3 + 1];\r\n const z = vertices[this._currentIndex * 3 + 2];\r\n let found = false;\r\n for (let index = 0; index < alreadyDone.length; index += 3) {\r\n if (Math.abs(alreadyDone[index] - x) < Epsilon && Math.abs(alreadyDone[index + 1] - y) < Epsilon && Math.abs(alreadyDone[index + 2] - z) < Epsilon) {\r\n found = true;\r\n break;\r\n }\r\n }\r\n\r\n if (found) {\r\n continue;\r\n }\r\n this._indexTranslation[alreadyDone.length / 3] = this._currentIndex;\r\n alreadyDone.push(x, y, z);\r\n }\r\n\r\n vertices = alreadyDone;\r\n vertexCount = vertices.length / 3;\r\n } else {\r\n this._indexTranslation = null;\r\n }\r\n\r\n for (this._currentIndex = 0; this._currentIndex < vertexCount; this._currentIndex++) {\r\n const instanceGeometry = this.instance.getConnectedValue(state) as VertexData;\r\n\r\n if (!instanceGeometry || !instanceGeometry.positions || instanceGeometry.positions.length === 0) {\r\n continue;\r\n }\r\n\r\n const density = this.density.getConnectedValue(state);\r\n\r\n if (density < 1) {\r\n if (Math.random() > density) {\r\n continue;\r\n }\r\n }\r\n\r\n currentPosition.fromArray(vertices, this._currentIndex * 3);\r\n\r\n // Clone the instance\r\n const clone = instanceGeometry.clone();\r\n\r\n // Transform\r\n if (this.matrix.isConnected) {\r\n const transform = this.matrix.getConnectedValue(state);\r\n state._instantiateWithPositionAndMatrix(clone, currentPosition, transform, additionalVertexData);\r\n } else {\r\n const scaling = state.adaptInput(this.scaling, NodeGeometryBlockConnectionPointTypes.Vector3, Vector3.OneReadOnly);\r\n const rotation = this.rotation.getConnectedValue(state) || Vector3.ZeroReadOnly;\r\n state._instantiate(clone, currentPosition, rotation, scaling, additionalVertexData);\r\n }\r\n this._currentLoopIndex++;\r\n }\r\n\r\n // Merge\r\n if (additionalVertexData.length) {\r\n if (additionalVertexData.length === 1) {\r\n this._vertexData = additionalVertexData[0];\r\n } else {\r\n // We do not merge the main one as user can use a merge node if wanted\r\n const main = additionalVertexData.splice(0, 1)[0];\r\n this._vertexData = main.merge(additionalVertexData, true, false, true, true);\r\n }\r\n }\r\n\r\n return this._vertexData;\r\n };\r\n\r\n // Storage\r\n if (this.evaluateContext) {\r\n this.output._storedFunction = func;\r\n } else {\r\n this.output._storedValue = func(state);\r\n }\r\n }\r\n\r\n protected _dumpPropertiesCode() {\r\n let codeString = super._dumpPropertiesCode() + `${this._codeVariableName}.removeDuplicatedPositions = ${this.removeDuplicatedPositions ? \"true\" : \"false\"};\\n`;\r\n codeString += `${this._codeVariableName}.evaluateContext = ${this.evaluateContext ? \"true\" : \"false\"};\\n`;\r\n return codeString;\r\n }\r\n\r\n /**\r\n * Serializes this block in a JSON representation\r\n * @returns the serialized block object\r\n */\r\n public serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.removeDuplicatedPositions = this.removeDuplicatedPositions;\r\n serializationObject.evaluateContext = this.evaluateContext;\r\n\r\n return serializationObject;\r\n }\r\n\r\n public _deserialize(serializationObject: any) {\r\n super._deserialize(serializationObject);\r\n\r\n this.removeDuplicatedPositions = serializationObject.removeDuplicatedPositions;\r\n if (serializationObject.evaluateContext !== undefined) {\r\n this.evaluateContext = serializationObject.evaluateContext;\r\n }\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.InstantiateOnVerticesBlock\", InstantiateOnVerticesBlock);\r\n"]}
@@ -3,10 +3,11 @@ import type { NodeGeometryConnectionPoint } from "../../nodeGeometryBlockConnect
3
3
  import type { NodeGeometryBuildState } from "../../nodeGeometryBuildState";
4
4
  import type { INodeGeometryExecutionContext } from "../../Interfaces/nodeGeometryExecutionContext";
5
5
  import { Vector3 } from "../../../../Maths/math.vector";
6
+ import type { INodeGeometryInstancingContext } from "../../Interfaces/nodeGeometryInstancingContext";
6
7
  /**
7
8
  * Block used to instance geometry inside a geometry
8
9
  */
9
- export declare class InstantiateOnVolumeBlock extends NodeGeometryBlock implements INodeGeometryExecutionContext {
10
+ export declare class InstantiateOnVolumeBlock extends NodeGeometryBlock implements INodeGeometryExecutionContext, INodeGeometryInstancingContext {
10
11
  private _vertexData;
11
12
  private _currentLoopIndex;
12
13
  private _currentPosition;
@@ -23,6 +24,11 @@ export declare class InstantiateOnVolumeBlock extends NodeGeometryBlock implemen
23
24
  * @param name defines the block name
24
25
  */
25
26
  constructor(name: string);
27
+ /**
28
+ * Gets the current instance index in the current flow
29
+ * @returns the current index
30
+ */
31
+ getInstanceIndex(): number;
26
32
  /**
27
33
  * Gets the current index in the current flow
28
34
  * @returns the current index
@@ -56,14 +62,6 @@ export declare class InstantiateOnVolumeBlock extends NodeGeometryBlock implemen
56
62
  * Gets the instance input component
57
63
  */
58
64
  get instance(): NodeGeometryConnectionPoint;
59
- /**
60
- * Gets the rotation input component
61
- */
62
- get rotation(): NodeGeometryConnectionPoint;
63
- /**
64
- * Gets the scaling input component
65
- */
66
- get scaling(): NodeGeometryConnectionPoint;
67
65
  /**
68
66
  * Gets the matrix input component
69
67
  */
@@ -72,6 +70,14 @@ export declare class InstantiateOnVolumeBlock extends NodeGeometryBlock implemen
72
70
  * Gets the count input component
73
71
  */
74
72
  get count(): NodeGeometryConnectionPoint;
73
+ /**
74
+ * Gets the rotation input component
75
+ */
76
+ get rotation(): NodeGeometryConnectionPoint;
77
+ /**
78
+ * Gets the scaling input component
79
+ */
80
+ get scaling(): NodeGeometryConnectionPoint;
75
81
  /**
76
82
  * Gets the geometry output component
77
83
  */
@@ -27,13 +27,20 @@ export class InstantiateOnVolumeBlock extends NodeGeometryBlock {
27
27
  this.evaluateContext = true;
28
28
  this.registerInput("geometry", NodeGeometryBlockConnectionPointTypes.Geometry);
29
29
  this.registerInput("instance", NodeGeometryBlockConnectionPointTypes.Geometry, true);
30
+ this.registerInput("count", NodeGeometryBlockConnectionPointTypes.Int, true, 256);
31
+ this.registerInput("matrix", NodeGeometryBlockConnectionPointTypes.Matrix, true);
30
32
  this.registerInput("rotation", NodeGeometryBlockConnectionPointTypes.Vector3, true, Vector3.Zero());
31
33
  this.registerInput("scaling", NodeGeometryBlockConnectionPointTypes.Vector3, true, Vector3.One());
32
- this.registerInput("matrix", NodeGeometryBlockConnectionPointTypes.Matrix, true);
33
- this.registerInput("count", NodeGeometryBlockConnectionPointTypes.Int, true, 256);
34
34
  this.scaling.acceptedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Float);
35
35
  this.registerOutput("output", NodeGeometryBlockConnectionPointTypes.Geometry);
36
36
  }
37
+ /**
38
+ * Gets the current instance index in the current flow
39
+ * @returns the current index
40
+ */
41
+ getInstanceIndex() {
42
+ return this._currentLoopIndex;
43
+ }
37
44
  /**
38
45
  * Gets the current index in the current flow
39
46
  * @returns the current index
@@ -82,27 +89,27 @@ export class InstantiateOnVolumeBlock extends NodeGeometryBlock {
82
89
  return this._inputs[1];
83
90
  }
84
91
  /**
85
- * Gets the rotation input component
92
+ * Gets the matrix input component
86
93
  */
87
- get rotation() {
94
+ get matrix() {
88
95
  return this._inputs[2];
89
96
  }
90
97
  /**
91
- * Gets the scaling input component
98
+ * Gets the count input component
92
99
  */
93
- get scaling() {
100
+ get count() {
94
101
  return this._inputs[3];
95
102
  }
96
103
  /**
97
- * Gets the matrix input component
104
+ * Gets the rotation input component
98
105
  */
99
- get matrix() {
106
+ get rotation() {
100
107
  return this._inputs[4];
101
108
  }
102
109
  /**
103
- * Gets the count input component
110
+ * Gets the scaling input component
104
111
  */
105
- get count() {
112
+ get scaling() {
106
113
  return this._inputs[5];
107
114
  }
108
115
  /**
@@ -114,11 +121,13 @@ export class InstantiateOnVolumeBlock extends NodeGeometryBlock {
114
121
  _buildBlock(state) {
115
122
  const func = (state) => {
116
123
  state.executionContext = this;
124
+ state.instancingContext = this;
117
125
  this._vertexData = this.geometry.getConnectedValue(state);
118
126
  state.geometryContext = this._vertexData;
119
127
  if (!this._vertexData || !this._vertexData.positions || !this._vertexData.indices || !this.instance.isConnected) {
120
128
  state.executionContext = null;
121
129
  state.geometryContext = null;
130
+ state.instancingContext = null;
122
131
  this.output._storedValue = null;
123
132
  return;
124
133
  }
@@ -160,7 +169,7 @@ export class InstantiateOnVolumeBlock extends NodeGeometryBlock {
160
169
  const clone = instanceGeometry.clone();
161
170
  if (this.matrix.isConnected) {
162
171
  const transform = this.matrix.getConnectedValue(state);
163
- state._instantiateWithMatrix(clone, transform, additionalVertexData);
172
+ state._instantiateWithPositionAndMatrix(clone, this._currentPosition, transform, additionalVertexData);
164
173
  }
165
174
  else {
166
175
  const scaling = state.adaptInput(this.scaling, NodeGeometryBlockConnectionPointTypes.Vector3, Vector3.OneReadOnly);
@@ -1 +1 @@
1
- {"version":3,"file":"instantiateOnVolumeBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.ts"],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CAAC;IAEM,YAAY,CAAC,mBAAwB;QACxC,KAAK,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAAC;QAExC,IAAI,mBAAmB,CAAC,eAAe,KAAK,SAAS,EAAE;YACnD,IAAI,CAAC,eAAe,GAAG,mBAAmB,CAAC,eAAe,CAAC;SAC9D;IACL,CAAC;CACJ;AAlOU;IADN,sBAAsB,CAAC,kBAAkB,EAAE,sBAAsB,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;iEAC3F;AAoOlC,aAAa,CAAC,kCAAkC,EAAE,wBAAwB,CAAC,CAAC","sourcesContent":["import { NodeGeometryBlock } from \"../../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../../nodeGeometryBlockConnectionPoint\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../../Enums/nodeGeometryConnectionPointTypes\";\r\nimport type { NodeGeometryBuildState } from \"../../nodeGeometryBuildState\";\r\nimport type { INodeGeometryExecutionContext } from \"../../Interfaces/nodeGeometryExecutionContext\";\r\nimport type { VertexData } from \"../../../mesh.vertexData\";\r\nimport { Vector3 } from \"../../../../Maths/math.vector\";\r\nimport { PropertyTypeForEdition, editableInPropertyPage } from \"../../../../Decorators/nodeDecorator\";\r\nimport type { Nullable } from \"../../../../types\";\r\nimport { Ray } from \"../../../../Culling/ray\";\r\nimport { extractMinAndMax } from \"../../../../Maths/math.functions\";\r\n\r\n/**\r\n * Block used to instance geometry inside a geometry\r\n */\r\nexport class InstantiateOnVolumeBlock extends NodeGeometryBlock implements INodeGeometryExecutionContext {\r\n private _vertexData: VertexData;\r\n private _currentLoopIndex: number;\r\n private _currentPosition = new Vector3();\r\n private _vertex0 = new Vector3();\r\n private _vertex1 = new Vector3();\r\n private _vertex2 = new Vector3();\r\n\r\n /**\r\n * Gets or sets a boolean indicating that this block can evaluate context\r\n * Build performance is improved when this value is set to false as the system will cache values instead of reevaluating everything per context change\r\n */\r\n @editableInPropertyPage(\"Evaluate context\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { notifiers: { rebuild: true } })\r\n public evaluateContext = true;\r\n\r\n /**\r\n * Create a new InstantiateOnVolumeBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"geometry\", NodeGeometryBlockConnectionPointTypes.Geometry);\r\n this.registerInput(\"instance\", NodeGeometryBlockConnectionPointTypes.Geometry, true);\r\n this.registerInput(\"rotation\", NodeGeometryBlockConnectionPointTypes.Vector3, true, Vector3.Zero());\r\n this.registerInput(\"scaling\", NodeGeometryBlockConnectionPointTypes.Vector3, true, Vector3.One());\r\n this.registerInput(\"matrix\", NodeGeometryBlockConnectionPointTypes.Matrix, true);\r\n this.registerInput(\"count\", NodeGeometryBlockConnectionPointTypes.Int, true, 256);\r\n\r\n this.scaling.acceptedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Float);\r\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.Geometry);\r\n }\r\n\r\n /**\r\n * Gets the current index in the current flow\r\n * @returns the current index\r\n */\r\n public getExecutionIndex(): number {\r\n return 0;\r\n }\r\n\r\n /**\r\n * Gets the current face index in the current flow\r\n * @returns the current face index\r\n */\r\n public getExecutionFaceIndex(): number {\r\n return 0;\r\n }\r\n\r\n /**\r\n * Gets the current loop index in the current flow\r\n * @returns the current loop index\r\n */\r\n public getExecutionLoopIndex(): number {\r\n return this._currentLoopIndex;\r\n }\r\n\r\n /**\r\n * Gets the value associated with a contextual positions\r\n * @returns the value associated with the source\r\n */\r\n public getOverridePositionsContextualValue() {\r\n return this._currentPosition;\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public getClassName() {\r\n return \"InstantiateOnVolumeBlock\";\r\n }\r\n\r\n /**\r\n * Gets the geometry input component\r\n */\r\n public get geometry(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the instance input component\r\n */\r\n public get instance(): NodeGeometryConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the rotation input component\r\n */\r\n public get rotation(): NodeGeometryConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the scaling input component\r\n */\r\n public get scaling(): NodeGeometryConnectionPoint {\r\n return this._inputs[3];\r\n }\r\n\r\n /**\r\n * Gets the matrix input component\r\n */\r\n public get matrix(): NodeGeometryConnectionPoint {\r\n return this._inputs[4];\r\n }\r\n\r\n /**\r\n * Gets the count input component\r\n */\r\n public get count(): NodeGeometryConnectionPoint {\r\n return this._inputs[5];\r\n }\r\n\r\n /**\r\n * Gets the geometry output component\r\n */\r\n public get output(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n protected _buildBlock(state: NodeGeometryBuildState) {\r\n const func = (state: NodeGeometryBuildState) => {\r\n state.executionContext = this;\r\n\r\n this._vertexData = this.geometry.getConnectedValue(state);\r\n state.geometryContext = this._vertexData;\r\n\r\n if (!this._vertexData || !this._vertexData.positions || !this._vertexData.indices || !this.instance.isConnected) {\r\n state.executionContext = null;\r\n state.geometryContext = null;\r\n this.output._storedValue = null;\r\n return;\r\n }\r\n\r\n // Processing\r\n let instanceGeometry: Nullable<VertexData> = null;\r\n const instanceCount = this.count.getConnectedValue(state);\r\n const additionalVertexData: VertexData[] = [];\r\n const boundingInfo = extractMinAndMax(this._vertexData.positions!, 0, this._vertexData.positions!.length / 3);\r\n const min = boundingInfo.minimum;\r\n const max = boundingInfo.maximum;\r\n const direction = new Vector3(1, 0, 0);\r\n const faceCount = this._vertexData.indices.length / 3;\r\n this._currentLoopIndex = 0;\r\n\r\n for (let index = 0; index < instanceCount; index++) {\r\n this._currentPosition.set(Math.random() * (max.x - min.x) + min.x, Math.random() * (max.y - min.y) + min.y, Math.random() * (max.z - min.z) + min.z);\r\n\r\n // Cast a ray from the random point in an arbitrary direction\r\n const ray = new Ray(this._currentPosition, direction);\r\n\r\n let intersectionCount = 0;\r\n for (let currentFaceIndex = 0; currentFaceIndex < faceCount; currentFaceIndex++) {\r\n // Extract face vertices\r\n this._vertex0.fromArray(this._vertexData.positions!, this._vertexData.indices![currentFaceIndex * 3] * 3);\r\n this._vertex1.fromArray(this._vertexData.positions!, this._vertexData.indices![currentFaceIndex * 3 + 1] * 3);\r\n this._vertex2.fromArray(this._vertexData.positions!, this._vertexData.indices![currentFaceIndex * 3 + 2] * 3);\r\n\r\n const currentIntersectInfo = ray.intersectsTriangle(this._vertex0, this._vertex1, this._vertex2);\r\n\r\n if (currentIntersectInfo && currentIntersectInfo.distance > 0) {\r\n intersectionCount++;\r\n }\r\n }\r\n\r\n if (intersectionCount % 2 === 0) {\r\n // We are outside, try again\r\n index--;\r\n continue;\r\n }\r\n\r\n // Clone the instance\r\n instanceGeometry = this.instance.getConnectedValue(state) as VertexData;\r\n\r\n if (!instanceGeometry || !instanceGeometry.positions || instanceGeometry.positions.length === 0) {\r\n continue;\r\n }\r\n const clone = instanceGeometry!.clone();\r\n\r\n if (this.matrix.isConnected) {\r\n const transform = this.matrix.getConnectedValue(state);\r\n state._instantiateWithMatrix(clone, transform, additionalVertexData);\r\n } else {\r\n const scaling = state.adaptInput(this.scaling, NodeGeometryBlockConnectionPointTypes.Vector3, Vector3.OneReadOnly);\r\n const rotation = this.rotation.getConnectedValue(state) || Vector3.ZeroReadOnly;\r\n state._instantiate(clone, this._currentPosition, rotation, scaling, additionalVertexData);\r\n }\r\n this._currentLoopIndex++;\r\n }\r\n\r\n // Merge\r\n if (additionalVertexData.length) {\r\n if (additionalVertexData.length === 1) {\r\n this._vertexData = additionalVertexData[0];\r\n } else {\r\n // We do not merge the main one as user can use a merge node if wanted\r\n const main = additionalVertexData.splice(0, 1)[0];\r\n this._vertexData = main.merge(additionalVertexData, true, false, true, true);\r\n }\r\n }\r\n\r\n return this._vertexData;\r\n };\r\n\r\n // Storage\r\n\r\n if (this.evaluateContext) {\r\n this.output._storedFunction = func;\r\n } else {\r\n this.output._storedValue = func(state);\r\n }\r\n }\r\n\r\n protected _dumpPropertiesCode() {\r\n const codeString = super._dumpPropertiesCode() + `${this._codeVariableName}.evaluateContext = ${this.evaluateContext ? \"true\" : \"false\"};\\n`;\r\n return codeString;\r\n }\r\n\r\n /**\r\n * Serializes this block in a JSON representation\r\n * @returns the serialized block object\r\n */\r\n public serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.evaluateContext = this.evaluateContext;\r\n\r\n return serializationObject;\r\n }\r\n\r\n public _deserialize(serializationObject: any) {\r\n super._deserialize(serializationObject);\r\n\r\n if (serializationObject.evaluateContext !== undefined) {\r\n this.evaluateContext = serializationObject.evaluateContext;\r\n }\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.InstantiateOnVolumeBlock\", InstantiateOnVolumeBlock);\r\n"]}
1
+ {"version":3,"file":"instantiateOnVolumeBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,8CAA8C,CAAC;AAIrG,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAEtG,OAAO,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAGpE;;GAEG;AACH,MAAM,OAAO,wBAAyB,SAAQ,iBAAiB;IAe3D;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAjB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AAI,EAAE,EAAE,CAAC;iEAC3F;AA8OlC,aAAa,CAAC,kCAAkC,EAAE,wBAAwB,CAAC,CAAC","sourcesContent":["import { NodeGeometryBlock } from \"../../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../../nodeGeometryBlockConnectionPoint\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../../Enums/nodeGeometryConnectionPointTypes\";\r\nimport type { NodeGeometryBuildState } from \"../../nodeGeometryBuildState\";\r\nimport type { INodeGeometryExecutionContext } from \"../../Interfaces/nodeGeometryExecutionContext\";\r\nimport type { VertexData } from \"../../../mesh.vertexData\";\r\nimport { Vector3 } from \"../../../../Maths/math.vector\";\r\nimport { PropertyTypeForEdition, editableInPropertyPage } from \"../../../../Decorators/nodeDecorator\";\r\nimport type { Nullable } from \"../../../../types\";\r\nimport { Ray } from \"../../../../Culling/ray\";\r\nimport { extractMinAndMax } from \"../../../../Maths/math.functions\";\r\nimport type { INodeGeometryInstancingContext } from \"../../Interfaces/nodeGeometryInstancingContext\";\r\n\r\n/**\r\n * Block used to instance geometry inside a geometry\r\n */\r\nexport class InstantiateOnVolumeBlock extends NodeGeometryBlock implements INodeGeometryExecutionContext, INodeGeometryInstancingContext {\r\n private _vertexData: VertexData;\r\n private _currentLoopIndex: number;\r\n private _currentPosition = new Vector3();\r\n private _vertex0 = new Vector3();\r\n private _vertex1 = new Vector3();\r\n private _vertex2 = new Vector3();\r\n\r\n /**\r\n * Gets or sets a boolean indicating that this block can evaluate context\r\n * Build performance is improved when this value is set to false as the system will cache values instead of reevaluating everything per context change\r\n */\r\n @editableInPropertyPage(\"Evaluate context\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { notifiers: { rebuild: true } })\r\n public evaluateContext = true;\r\n\r\n /**\r\n * Create a new InstantiateOnVolumeBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"geometry\", NodeGeometryBlockConnectionPointTypes.Geometry);\r\n this.registerInput(\"instance\", NodeGeometryBlockConnectionPointTypes.Geometry, true);\r\n this.registerInput(\"count\", NodeGeometryBlockConnectionPointTypes.Int, true, 256);\r\n this.registerInput(\"matrix\", NodeGeometryBlockConnectionPointTypes.Matrix, true);\r\n this.registerInput(\"rotation\", NodeGeometryBlockConnectionPointTypes.Vector3, true, Vector3.Zero());\r\n this.registerInput(\"scaling\", NodeGeometryBlockConnectionPointTypes.Vector3, true, Vector3.One());\r\n\r\n this.scaling.acceptedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Float);\r\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.Geometry);\r\n }\r\n\r\n /**\r\n * Gets the current instance index in the current flow\r\n * @returns the current index\r\n */\r\n public getInstanceIndex(): number {\r\n return this._currentLoopIndex;\r\n }\r\n\r\n /**\r\n * Gets the current index in the current flow\r\n * @returns the current index\r\n */\r\n public getExecutionIndex(): number {\r\n return 0;\r\n }\r\n\r\n /**\r\n * Gets the current face index in the current flow\r\n * @returns the current face index\r\n */\r\n public getExecutionFaceIndex(): number {\r\n return 0;\r\n }\r\n\r\n /**\r\n * Gets the current loop index in the current flow\r\n * @returns the current loop index\r\n */\r\n public getExecutionLoopIndex(): number {\r\n return this._currentLoopIndex;\r\n }\r\n\r\n /**\r\n * Gets the value associated with a contextual positions\r\n * @returns the value associated with the source\r\n */\r\n public getOverridePositionsContextualValue() {\r\n return this._currentPosition;\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public getClassName() {\r\n return \"InstantiateOnVolumeBlock\";\r\n }\r\n\r\n /**\r\n * Gets the geometry input component\r\n */\r\n public get geometry(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the instance input component\r\n */\r\n public get instance(): NodeGeometryConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the matrix input component\r\n */\r\n public get matrix(): NodeGeometryConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the count input component\r\n */\r\n public get count(): NodeGeometryConnectionPoint {\r\n return this._inputs[3];\r\n }\r\n\r\n /**\r\n * Gets the rotation input component\r\n */\r\n public get rotation(): NodeGeometryConnectionPoint {\r\n return this._inputs[4];\r\n }\r\n\r\n /**\r\n * Gets the scaling input component\r\n */\r\n public get scaling(): NodeGeometryConnectionPoint {\r\n return this._inputs[5];\r\n }\r\n\r\n /**\r\n * Gets the geometry output component\r\n */\r\n public get output(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n protected _buildBlock(state: NodeGeometryBuildState) {\r\n const func = (state: NodeGeometryBuildState) => {\r\n state.executionContext = this;\r\n state.instancingContext = this;\r\n\r\n this._vertexData = this.geometry.getConnectedValue(state);\r\n state.geometryContext = this._vertexData;\r\n\r\n if (!this._vertexData || !this._vertexData.positions || !this._vertexData.indices || !this.instance.isConnected) {\r\n state.executionContext = null;\r\n state.geometryContext = null;\r\n state.instancingContext = null;\r\n this.output._storedValue = null;\r\n return;\r\n }\r\n\r\n // Processing\r\n let instanceGeometry: Nullable<VertexData> = null;\r\n const instanceCount = this.count.getConnectedValue(state);\r\n const additionalVertexData: VertexData[] = [];\r\n const boundingInfo = extractMinAndMax(this._vertexData.positions!, 0, this._vertexData.positions!.length / 3);\r\n const min = boundingInfo.minimum;\r\n const max = boundingInfo.maximum;\r\n const direction = new Vector3(1, 0, 0);\r\n const faceCount = this._vertexData.indices.length / 3;\r\n this._currentLoopIndex = 0;\r\n\r\n for (let index = 0; index < instanceCount; index++) {\r\n this._currentPosition.set(Math.random() * (max.x - min.x) + min.x, Math.random() * (max.y - min.y) + min.y, Math.random() * (max.z - min.z) + min.z);\r\n\r\n // Cast a ray from the random point in an arbitrary direction\r\n const ray = new Ray(this._currentPosition, direction);\r\n\r\n let intersectionCount = 0;\r\n for (let currentFaceIndex = 0; currentFaceIndex < faceCount; currentFaceIndex++) {\r\n // Extract face vertices\r\n this._vertex0.fromArray(this._vertexData.positions!, this._vertexData.indices![currentFaceIndex * 3] * 3);\r\n this._vertex1.fromArray(this._vertexData.positions!, this._vertexData.indices![currentFaceIndex * 3 + 1] * 3);\r\n this._vertex2.fromArray(this._vertexData.positions!, this._vertexData.indices![currentFaceIndex * 3 + 2] * 3);\r\n\r\n const currentIntersectInfo = ray.intersectsTriangle(this._vertex0, this._vertex1, this._vertex2);\r\n\r\n if (currentIntersectInfo && currentIntersectInfo.distance > 0) {\r\n intersectionCount++;\r\n }\r\n }\r\n\r\n if (intersectionCount % 2 === 0) {\r\n // We are outside, try again\r\n index--;\r\n continue;\r\n }\r\n\r\n // Clone the instance\r\n instanceGeometry = this.instance.getConnectedValue(state) as VertexData;\r\n\r\n if (!instanceGeometry || !instanceGeometry.positions || instanceGeometry.positions.length === 0) {\r\n continue;\r\n }\r\n const clone = instanceGeometry!.clone();\r\n\r\n if (this.matrix.isConnected) {\r\n const transform = this.matrix.getConnectedValue(state);\r\n state._instantiateWithPositionAndMatrix(clone, this._currentPosition, transform, additionalVertexData);\r\n } else {\r\n const scaling = state.adaptInput(this.scaling, NodeGeometryBlockConnectionPointTypes.Vector3, Vector3.OneReadOnly);\r\n const rotation = this.rotation.getConnectedValue(state) || Vector3.ZeroReadOnly;\r\n state._instantiate(clone, this._currentPosition, rotation, scaling, additionalVertexData);\r\n }\r\n this._currentLoopIndex++;\r\n }\r\n\r\n // Merge\r\n if (additionalVertexData.length) {\r\n if (additionalVertexData.length === 1) {\r\n this._vertexData = additionalVertexData[0];\r\n } else {\r\n // We do not merge the main one as user can use a merge node if wanted\r\n const main = additionalVertexData.splice(0, 1)[0];\r\n this._vertexData = main.merge(additionalVertexData, true, false, true, true);\r\n }\r\n }\r\n\r\n return this._vertexData;\r\n };\r\n\r\n // Storage\r\n\r\n if (this.evaluateContext) {\r\n this.output._storedFunction = func;\r\n } else {\r\n this.output._storedValue = func(state);\r\n }\r\n }\r\n\r\n protected _dumpPropertiesCode() {\r\n const codeString = super._dumpPropertiesCode() + `${this._codeVariableName}.evaluateContext = ${this.evaluateContext ? \"true\" : \"false\"};\\n`;\r\n return codeString;\r\n }\r\n\r\n /**\r\n * Serializes this block in a JSON representation\r\n * @returns the serialized block object\r\n */\r\n public serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.evaluateContext = this.evaluateContext;\r\n\r\n return serializationObject;\r\n }\r\n\r\n public _deserialize(serializationObject: any) {\r\n super._deserialize(serializationObject);\r\n\r\n if (serializationObject.evaluateContext !== undefined) {\r\n this.evaluateContext = serializationObject.evaluateContext;\r\n }\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.InstantiateOnVolumeBlock\", InstantiateOnVolumeBlock);\r\n"]}
@@ -8,6 +8,11 @@ import type { INodeGeometryExecutionContext } from "../../Interfaces/nodeGeometr
8
8
  export declare class SetColorsBlock extends NodeGeometryBlock implements INodeGeometryExecutionContext {
9
9
  private _vertexData;
10
10
  private _currentIndex;
11
+ /**
12
+ * Gets or sets a boolean indicating that this block can evaluate context
13
+ * Build performance is improved when this value is set to false as the system will cache values instead of reevaluating everything per context change
14
+ */
15
+ evaluateContext: boolean;
11
16
  /**
12
17
  * Create a new SetColorsBlock
13
18
  * @param name defines the block name
@@ -46,4 +51,11 @@ export declare class SetColorsBlock extends NodeGeometryBlock implements INodeGe
46
51
  */
47
52
  get output(): NodeGeometryConnectionPoint;
48
53
  protected _buildBlock(state: NodeGeometryBuildState): void;
54
+ protected _dumpPropertiesCode(): string;
55
+ /**
56
+ * Serializes this block in a JSON representation
57
+ * @returns the serialized block object
58
+ */
59
+ serialize(): any;
60
+ _deserialize(serializationObject: any): void;
49
61
  }
@@ -1,6 +1,8 @@
1
+ import { __decorate } from "../../../../tslib.es6.js";
1
2
  import { NodeGeometryBlock } from "../../nodeGeometryBlock.js";
2
3
  import { RegisterClass } from "../../../../Misc/typeStore.js";
3
4
  import { NodeGeometryBlockConnectionPointTypes } from "../../Enums/nodeGeometryConnectionPointTypes.js";
5
+ import { PropertyTypeForEdition, editableInPropertyPage } from "../../../../Decorators/nodeDecorator.js";
4
6
  /**
5
7
  * Block used to set colors for a geometry
6
8
  */
@@ -11,6 +13,11 @@ export class SetColorsBlock extends NodeGeometryBlock {
11
13
  */
12
14
  constructor(name) {
13
15
  super(name);
16
+ /**
17
+ * Gets or sets a boolean indicating that this block can evaluate context
18
+ * Build performance is improved when this value is set to false as the system will cache values instead of reevaluating everything per context change
19
+ */
20
+ this.evaluateContext = true;
14
21
  this.registerInput("geometry", NodeGeometryBlockConnectionPointTypes.Geometry);
15
22
  this.registerInput("colors", NodeGeometryBlockConnectionPointTypes.Vector4);
16
23
  this.registerOutput("output", NodeGeometryBlockConnectionPointTypes.Geometry);
@@ -62,37 +69,65 @@ export class SetColorsBlock extends NodeGeometryBlock {
62
69
  return this._outputs[0];
63
70
  }
64
71
  _buildBlock(state) {
65
- state.executionContext = this;
66
- this._vertexData = this.geometry.getConnectedValue(state);
67
- state.geometryContext = this._vertexData;
68
- if (!this._vertexData || !this._vertexData.positions) {
69
- state.executionContext = null;
70
- state.geometryContext = null;
71
- this.output._storedValue = null;
72
- return;
73
- }
74
- if (!this.colors.isConnected) {
75
- state.executionContext = null;
76
- state.geometryContext = null;
77
- this.output._storedValue = this._vertexData;
78
- return;
72
+ const func = (state) => {
73
+ state.executionContext = this;
74
+ this._vertexData = this.geometry.getConnectedValue(state);
75
+ state.geometryContext = this._vertexData;
76
+ if (!this._vertexData || !this._vertexData.positions) {
77
+ state.executionContext = null;
78
+ state.geometryContext = null;
79
+ this.output._storedValue = null;
80
+ return;
81
+ }
82
+ if (!this.colors.isConnected) {
83
+ state.executionContext = null;
84
+ state.geometryContext = null;
85
+ this.output._storedValue = this._vertexData;
86
+ return;
87
+ }
88
+ if (!this._vertexData.colors) {
89
+ this._vertexData.colors = [];
90
+ }
91
+ // Processing
92
+ const vertexCount = this._vertexData.positions.length / 3;
93
+ for (this._currentIndex = 0; this._currentIndex < vertexCount; this._currentIndex++) {
94
+ const tempVector4 = this.colors.getConnectedValue(state);
95
+ if (tempVector4) {
96
+ tempVector4.toArray(this._vertexData.colors, this._currentIndex * 4);
97
+ }
98
+ }
99
+ // Storage
100
+ return this._vertexData;
101
+ };
102
+ if (this.evaluateContext) {
103
+ this.output._storedFunction = func;
79
104
  }
80
- if (!this._vertexData.colors) {
81
- this._vertexData.colors = [];
105
+ else {
106
+ this.output._storedValue = func(state);
82
107
  }
83
- // Processing
84
- const vertexCount = this._vertexData.positions.length / 3;
85
- for (this._currentIndex = 0; this._currentIndex < vertexCount; this._currentIndex++) {
86
- const tempVector4 = this.colors.getConnectedValue(state);
87
- if (tempVector4) {
88
- tempVector4.toArray(this._vertexData.colors, this._currentIndex * 4);
89
- }
108
+ }
109
+ _dumpPropertiesCode() {
110
+ const codeString = super._dumpPropertiesCode() + `${this._codeVariableName}.evaluateContext = ${this.evaluateContext ? "true" : "false"};\n`;
111
+ return codeString;
112
+ }
113
+ /**
114
+ * Serializes this block in a JSON representation
115
+ * @returns the serialized block object
116
+ */
117
+ serialize() {
118
+ const serializationObject = super.serialize();
119
+ serializationObject.evaluateContext = this.evaluateContext;
120
+ return serializationObject;
121
+ }
122
+ _deserialize(serializationObject) {
123
+ super._deserialize(serializationObject);
124
+ if (serializationObject.evaluateContext !== undefined) {
125
+ this.evaluateContext = serializationObject.evaluateContext;
90
126
  }
91
- // Storage
92
- this.output._storedValue = this._vertexData;
93
- state.executionContext = null;
94
- state.geometryContext = null;
95
127
  }
96
128
  }
129
+ __decorate([
130
+ editableInPropertyPage("Evaluate context", PropertyTypeForEdition.Boolean, "ADVANCED", { notifiers: { rebuild: true } })
131
+ ], SetColorsBlock.prototype, "evaluateContext", void 0);
97
132
  RegisterClass("BABYLON.SetColorsBlock", SetColorsBlock);
98
133
  //# sourceMappingURL=setColorsBlock.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"setColorsBlock.js","sourceRoot":"","sources":["../../../../../../../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KAAK,CAAC,gBAAgB,GAAG,IAAI,CAAC;QAC9B,KAAK,CAAC,eAAe,GAAG,IAAI,CAAC;IACjC,CAAC;CACJ;AAED,aAAa,CAAC,wBAAwB,EAAE,cAAc,CAAC,CAAC","sourcesContent":["import { NodeGeometryBlock } from \"../../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../../nodeGeometryBlockConnectionPoint\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../../Enums/nodeGeometryConnectionPointTypes\";\r\nimport type { NodeGeometryBuildState } from \"../../nodeGeometryBuildState\";\r\nimport type { INodeGeometryExecutionContext } from \"../../Interfaces/nodeGeometryExecutionContext\";\r\nimport type { VertexData } from \"../../../mesh.vertexData\";\r\nimport type { Vector4 } from \"../../../../Maths/math.vector\";\r\n\r\n/**\r\n * Block used to set colors for a geometry\r\n */\r\nexport class SetColorsBlock extends NodeGeometryBlock implements INodeGeometryExecutionContext {\r\n private _vertexData: VertexData;\r\n private _currentIndex: number;\r\n\r\n /**\r\n * Create a new SetColorsBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"geometry\", NodeGeometryBlockConnectionPointTypes.Geometry);\r\n this.registerInput(\"colors\", NodeGeometryBlockConnectionPointTypes.Vector4);\r\n\r\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.Geometry);\r\n }\r\n\r\n /**\r\n * Gets the current index in the current flow\r\n * @returns the current index\r\n */\r\n public getExecutionIndex(): number {\r\n return this._currentIndex;\r\n }\r\n\r\n /**\r\n * Gets the current loop index in the current flow\r\n * @returns the current loop index\r\n */\r\n public getExecutionLoopIndex(): number {\r\n return this._currentIndex;\r\n }\r\n\r\n /**\r\n * Gets the current face index in the current flow\r\n * @returns the current face index\r\n */\r\n public getExecutionFaceIndex(): number {\r\n return 0;\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public getClassName() {\r\n return \"SetColorsBlock\";\r\n }\r\n\r\n /**\r\n * Gets the geometry input component\r\n */\r\n public get geometry(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the colors input component\r\n */\r\n public get colors(): NodeGeometryConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the geometry output component\r\n */\r\n public get output(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n protected _buildBlock(state: NodeGeometryBuildState) {\r\n state.executionContext = this;\r\n\r\n this._vertexData = this.geometry.getConnectedValue(state);\r\n state.geometryContext = this._vertexData;\r\n\r\n if (!this._vertexData || !this._vertexData.positions) {\r\n state.executionContext = null;\r\n state.geometryContext = null;\r\n this.output._storedValue = null;\r\n return;\r\n }\r\n\r\n if (!this.colors.isConnected) {\r\n state.executionContext = null;\r\n state.geometryContext = null;\r\n this.output._storedValue = this._vertexData;\r\n return;\r\n }\r\n\r\n if (!this._vertexData.colors) {\r\n this._vertexData.colors = [];\r\n }\r\n\r\n // Processing\r\n const vertexCount = this._vertexData.positions.length / 3;\r\n for (this._currentIndex = 0; this._currentIndex < vertexCount; this._currentIndex++) {\r\n const tempVector4 = this.colors.getConnectedValue(state) as Vector4;\r\n if (tempVector4) {\r\n tempVector4.toArray(this._vertexData.colors, this._currentIndex * 4);\r\n }\r\n }\r\n\r\n // Storage\r\n this.output._storedValue = this._vertexData;\r\n state.executionContext = null;\r\n state.geometryContext = null;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.SetColorsBlock\", SetColorsBlock);\r\n"]}
1
+ {"version":3,"file":"setColorsBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Meshes/Node/Blocks/Set/setColorsBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D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I,CAAC,eAAe,EAAE;YACtB,IAAI,CAAC,MAAM,CAAC,eAAe,GAAG,IAAI,CAAC;SACtC;aAAM;YACH,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;SAC1C;IACL,CAAC;IAES,mBAAmB;QACzB,MAAM,UAAU,GAAG,KAAK,CAAC,mBAAmB,EAAE,GAAG,GAAG,IAAI,CAAC,iBAAiB,sBAAsB,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,KAAK,CAAC;QAC7I,OAAO,UAAU,CAAC;IACtB,CAAC;IAED;;;OAGG;IACI,SAAS;QACZ,MAAM,mBAAmB,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;QAE9C,mBAAmB,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;QAE3D,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAEM,YAAY,CAAC,mBAAwB;QACxC,KAAK,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAAC;QAExC,IAAI,mBAAmB,CAAC,eAAe,KAAK,SAAS,EAAE;YACnD,IAAI,CAAC,eAAe,GAAG,mBAAmB,CAAC,eAAe,CAAC;SAC9D;IACL,CAAC;CACJ;AAzIU;IADN,sBAAsB,CAAC,kBAAkB,EAAE,sBAAsB,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;uDAC3F;AA2IlC,aAAa,CAAC,wBAAwB,EAAE,cAAc,CAAC,CAAC","sourcesContent":["import { NodeGeometryBlock } from \"../../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../../nodeGeometryBlockConnectionPoint\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../../Enums/nodeGeometryConnectionPointTypes\";\r\nimport type { NodeGeometryBuildState } from \"../../nodeGeometryBuildState\";\r\nimport type { INodeGeometryExecutionContext } from \"../../Interfaces/nodeGeometryExecutionContext\";\r\nimport type { VertexData } from \"../../../mesh.vertexData\";\r\nimport type { Vector4 } from \"../../../../Maths/math.vector\";\r\nimport { PropertyTypeForEdition, editableInPropertyPage } from \"core/Decorators/nodeDecorator\";\r\n\r\n/**\r\n * Block used to set colors for a geometry\r\n */\r\nexport class SetColorsBlock extends NodeGeometryBlock implements INodeGeometryExecutionContext {\r\n private _vertexData: VertexData;\r\n private _currentIndex: number;\r\n\r\n /**\r\n * Gets or sets a boolean indicating that this block can evaluate context\r\n * Build performance is improved when this value is set to false as the system will cache values instead of reevaluating everything per context change\r\n */\r\n @editableInPropertyPage(\"Evaluate context\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { notifiers: { rebuild: true } })\r\n public evaluateContext = true;\r\n\r\n /**\r\n * Create a new SetColorsBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"geometry\", NodeGeometryBlockConnectionPointTypes.Geometry);\r\n this.registerInput(\"colors\", NodeGeometryBlockConnectionPointTypes.Vector4);\r\n\r\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.Geometry);\r\n }\r\n\r\n /**\r\n * Gets the current index in the current flow\r\n * @returns the current index\r\n */\r\n public getExecutionIndex(): number {\r\n return this._currentIndex;\r\n }\r\n\r\n /**\r\n * Gets the current loop index in the current flow\r\n * @returns the current loop index\r\n */\r\n public getExecutionLoopIndex(): number {\r\n return this._currentIndex;\r\n }\r\n\r\n /**\r\n * Gets the current face index in the current flow\r\n * @returns the current face index\r\n */\r\n public getExecutionFaceIndex(): number {\r\n return 0;\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public getClassName() {\r\n return \"SetColorsBlock\";\r\n }\r\n\r\n /**\r\n * Gets the geometry input component\r\n */\r\n public get geometry(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the colors input component\r\n */\r\n public get colors(): NodeGeometryConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the geometry output component\r\n */\r\n public get output(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n protected _buildBlock(state: NodeGeometryBuildState) {\r\n const func = (state: NodeGeometryBuildState) => {\r\n state.executionContext = this;\r\n\r\n this._vertexData = this.geometry.getConnectedValue(state);\r\n state.geometryContext = this._vertexData;\r\n\r\n if (!this._vertexData || !this._vertexData.positions) {\r\n state.executionContext = null;\r\n state.geometryContext = null;\r\n this.output._storedValue = null;\r\n return;\r\n }\r\n\r\n if (!this.colors.isConnected) {\r\n state.executionContext = null;\r\n state.geometryContext = null;\r\n this.output._storedValue = this._vertexData;\r\n return;\r\n }\r\n\r\n if (!this._vertexData.colors) {\r\n this._vertexData.colors = [];\r\n }\r\n\r\n // Processing\r\n const vertexCount = this._vertexData.positions.length / 3;\r\n for (this._currentIndex = 0; this._currentIndex < vertexCount; this._currentIndex++) {\r\n const tempVector4 = this.colors.getConnectedValue(state) as Vector4;\r\n if (tempVector4) {\r\n tempVector4.toArray(this._vertexData.colors, this._currentIndex * 4);\r\n }\r\n }\r\n\r\n // Storage\r\n return this._vertexData;\r\n };\r\n\r\n if (this.evaluateContext) {\r\n this.output._storedFunction = func;\r\n } else {\r\n this.output._storedValue = func(state);\r\n }\r\n }\r\n\r\n protected _dumpPropertiesCode() {\r\n const codeString = super._dumpPropertiesCode() + `${this._codeVariableName}.evaluateContext = ${this.evaluateContext ? \"true\" : \"false\"};\\n`;\r\n return codeString;\r\n }\r\n\r\n /**\r\n * Serializes this block in a JSON representation\r\n * @returns the serialized block object\r\n */\r\n public serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.evaluateContext = this.evaluateContext;\r\n\r\n return serializationObject;\r\n }\r\n\r\n public _deserialize(serializationObject: any) {\r\n super._deserialize(serializationObject);\r\n\r\n if (serializationObject.evaluateContext !== undefined) {\r\n this.evaluateContext = serializationObject.evaluateContext;\r\n }\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.SetColorsBlock\", SetColorsBlock);\r\n"]}
@@ -33,4 +33,11 @@ export declare class SetMaterialIDBlock extends NodeGeometryBlock {
33
33
  */
34
34
  get output(): NodeGeometryConnectionPoint;
35
35
  protected _buildBlock(state: NodeGeometryBuildState): void;
36
+ protected _dumpPropertiesCode(): string;
37
+ /**
38
+ * Serializes this block in a JSON representation
39
+ * @returns the serialized block object
40
+ */
41
+ serialize(): any;
42
+ _deserialize(serializationObject: any): void;
36
43
  }
@@ -76,6 +76,25 @@ export class SetMaterialIDBlock extends NodeGeometryBlock {
76
76
  this.output._storedValue = func(state);
77
77
  }
78
78
  }
79
+ _dumpPropertiesCode() {
80
+ const codeString = super._dumpPropertiesCode() + `${this._codeVariableName}.evaluateContext = ${this.evaluateContext ? "true" : "false"};\n`;
81
+ return codeString;
82
+ }
83
+ /**
84
+ * Serializes this block in a JSON representation
85
+ * @returns the serialized block object
86
+ */
87
+ serialize() {
88
+ const serializationObject = super.serialize();
89
+ serializationObject.evaluateContext = this.evaluateContext;
90
+ return serializationObject;
91
+ }
92
+ _deserialize(serializationObject) {
93
+ super._deserialize(serializationObject);
94
+ if (serializationObject.evaluateContext !== undefined) {
95
+ this.evaluateContext = serializationObject.evaluateContext;
96
+ }
97
+ }
79
98
  }
80
99
  __decorate([
81
100
  editableInPropertyPage("Evaluate context", PropertyTypeForEdition.Boolean, "ADVANCED", { notifiers: { rebuild: true } })
@@ -1 +1 @@
1
- {"version":3,"file":"setMaterialIDBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Meshes/Node/Blocks/Set/setMaterialIDBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,8CAA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AAI,GAAG,CAAC,KAA6B,EAAE,EAAE;YAC3C,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,KAAK,CAAe,CAAC;YACxE,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU,CAAC,OAAO,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE;gBAC7D,OAAO,UAAU,CAAC;aACrB;YAED,MAAM,YAAY,GAAG,IAAI,sBAAsB,EAAE,CAAC;YAClD,YAAY,CAAC,aAAa,GAAG,IAAI,CAAC,EAAE,CAAC,iBAAiB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAClE,YAAY,CAAC,UAAU,GAAG,CAAC,CAAC;YAC5B,YAAY,CAAC,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC;YACpD,YAAY,CAAC,aAAa,GAAG,CAAC,CAAC;YAC/B,YAAY,CAAC,aAAa,GAAG,UAAU,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;YAE7D,UAAU,CAAC,aAAa,GAAG,CAAC,YAAY,CAAC,CAAC;YAE1C,OAAO,UAAU,CAAC;QACtB,CAAC,CAAC;QAEF,IAAI,IAAI,CAAC,eAAe,EAAE;YACtB,IAAI,CAAC,MAAM,CAAC,eAAe,GAAG,IAAI,CAAC;SACtC;aAAM;YACH,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;SAC1C;IACL,CAAC;CACJ;AA5EU;IADN,sBAAsB,CAAC,kBAAkB,EAAE,sBAAsB,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;2DAC3F;AA8ElC,aAAa,CAAC,4BAA4B,EAAE,kBAAkB,CAAC,CAAC","sourcesContent":["import { NodeGeometryBlock } from \"../../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../../nodeGeometryBlockConnectionPoint\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../../Enums/nodeGeometryConnectionPointTypes\";\r\nimport { VertexDataMaterialInfo, type VertexData } from \"../../../../Meshes/mesh.vertexData\";\r\nimport { PropertyTypeForEdition, editableInPropertyPage } from \"../../../../Decorators/nodeDecorator\";\r\nimport type { NodeGeometryBuildState } from \"../../nodeGeometryBuildState\";\r\n\r\n/**\r\n * Block used to affect a material ID to a geometry\r\n */\r\nexport class SetMaterialIDBlock extends NodeGeometryBlock {\r\n /**\r\n * Gets or sets a boolean indicating that this block can evaluate context\r\n * Build performance is improved when this value is set to false as the system will cache values instead of reevaluating everything per context change\r\n */\r\n @editableInPropertyPage(\"Evaluate context\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { notifiers: { rebuild: true } })\r\n public evaluateContext = true;\r\n\r\n /**\r\n * Create a new SetMaterialIDBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"geometry\", NodeGeometryBlockConnectionPointTypes.Geometry);\r\n this.registerInput(\"id\", NodeGeometryBlockConnectionPointTypes.Int, true, 0);\r\n\r\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.Geometry);\r\n this.id.acceptedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Float);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public getClassName() {\r\n return \"SetMaterialIDBlock\";\r\n }\r\n\r\n /**\r\n * Gets the geometry input component\r\n */\r\n public get geometry(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the id input component\r\n */\r\n public get id(): NodeGeometryConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the geometry output component\r\n */\r\n public get output(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n protected _buildBlock(state: NodeGeometryBuildState) {\r\n if (!this.geometry.isConnected) {\r\n this.output._storedFunction = null;\r\n this.output._storedValue = null;\r\n return;\r\n }\r\n\r\n const func = (state: NodeGeometryBuildState) => {\r\n const vertexData = this.geometry.getConnectedValue(state) as VertexData;\r\n if (!vertexData || !vertexData.indices || !vertexData.positions) {\r\n return vertexData;\r\n }\r\n\r\n const materialInfo = new VertexDataMaterialInfo();\r\n materialInfo.materialIndex = this.id.getConnectedValue(state) | 0;\r\n materialInfo.indexStart = 0;\r\n materialInfo.indexCount = vertexData.indices.length;\r\n materialInfo.verticesStart = 0;\r\n materialInfo.verticesCount = vertexData.positions.length / 3;\r\n\r\n vertexData.materialInfos = [materialInfo];\r\n\r\n return vertexData;\r\n };\r\n\r\n if (this.evaluateContext) {\r\n this.output._storedFunction = func;\r\n } else {\r\n this.output._storedValue = func(state);\r\n }\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.SetMaterialIDBlock\", SetMaterialIDBlock);\r\n"]}
1
+ {"version":3,"file":"setMaterialIDBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Meshes/Node/Blocks/Set/setMaterialIDBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,8CAA8C,CAAC;AACrG,OAAO,EAAE,sBAAsB,EAAmB,MAAM,oCAAoC,CAAC;AAC7F,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAGtG;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,iBAAiB;IAQrD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAZhB;;;WAGG;QAEI,oBAAe,GAAG,IAAI,CAAC;QAS1B,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,qCAAqC,CAAC,QAAQ,CAAC,CAA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E,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;2DAC3F;AAuGlC,aAAa,CAAC,4BAA4B,EAAE,kBAAkB,CAAC,CAAC","sourcesContent":["import { NodeGeometryBlock } from \"../../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../../nodeGeometryBlockConnectionPoint\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../../Enums/nodeGeometryConnectionPointTypes\";\r\nimport { VertexDataMaterialInfo, type VertexData } from \"../../../../Meshes/mesh.vertexData\";\r\nimport { PropertyTypeForEdition, editableInPropertyPage } from \"../../../../Decorators/nodeDecorator\";\r\nimport type { NodeGeometryBuildState } from \"../../nodeGeometryBuildState\";\r\n\r\n/**\r\n * Block used to affect a material ID to a geometry\r\n */\r\nexport class SetMaterialIDBlock extends NodeGeometryBlock {\r\n /**\r\n * Gets or sets a boolean indicating that this block can evaluate context\r\n * Build performance is improved when this value is set to false as the system will cache values instead of reevaluating everything per context change\r\n */\r\n @editableInPropertyPage(\"Evaluate context\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { notifiers: { rebuild: true } })\r\n public evaluateContext = true;\r\n\r\n /**\r\n * Create a new SetMaterialIDBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"geometry\", NodeGeometryBlockConnectionPointTypes.Geometry);\r\n this.registerInput(\"id\", NodeGeometryBlockConnectionPointTypes.Int, true, 0);\r\n\r\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.Geometry);\r\n this.id.acceptedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Float);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public getClassName() {\r\n return \"SetMaterialIDBlock\";\r\n }\r\n\r\n /**\r\n * Gets the geometry input component\r\n */\r\n public get geometry(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the id input component\r\n */\r\n public get id(): NodeGeometryConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the geometry output component\r\n */\r\n public get output(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n protected _buildBlock(state: NodeGeometryBuildState) {\r\n if (!this.geometry.isConnected) {\r\n this.output._storedFunction = null;\r\n this.output._storedValue = null;\r\n return;\r\n }\r\n\r\n const func = (state: NodeGeometryBuildState) => {\r\n const vertexData = this.geometry.getConnectedValue(state) as VertexData;\r\n if (!vertexData || !vertexData.indices || !vertexData.positions) {\r\n return vertexData;\r\n }\r\n\r\n const materialInfo = new VertexDataMaterialInfo();\r\n materialInfo.materialIndex = this.id.getConnectedValue(state) | 0;\r\n materialInfo.indexStart = 0;\r\n materialInfo.indexCount = vertexData.indices.length;\r\n materialInfo.verticesStart = 0;\r\n materialInfo.verticesCount = vertexData.positions.length / 3;\r\n\r\n vertexData.materialInfos = [materialInfo];\r\n\r\n return vertexData;\r\n };\r\n\r\n if (this.evaluateContext) {\r\n this.output._storedFunction = func;\r\n } else {\r\n this.output._storedValue = func(state);\r\n }\r\n }\r\n\r\n protected _dumpPropertiesCode() {\r\n const codeString = super._dumpPropertiesCode() + `${this._codeVariableName}.evaluateContext = ${this.evaluateContext ? \"true\" : \"false\"};\\n`;\r\n return codeString;\r\n }\r\n\r\n /**\r\n * Serializes this block in a JSON representation\r\n * @returns the serialized block object\r\n */\r\n public serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.evaluateContext = this.evaluateContext;\r\n\r\n return serializationObject;\r\n }\r\n\r\n public _deserialize(serializationObject: any) {\r\n super._deserialize(serializationObject);\r\n\r\n if (serializationObject.evaluateContext !== undefined) {\r\n this.evaluateContext = serializationObject.evaluateContext;\r\n }\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.SetMaterialIDBlock\", SetMaterialIDBlock);\r\n"]}
@@ -8,6 +8,11 @@ import type { INodeGeometryExecutionContext } from "../../Interfaces/nodeGeometr
8
8
  export declare class SetNormalsBlock extends NodeGeometryBlock implements INodeGeometryExecutionContext {
9
9
  private _vertexData;
10
10
  private _currentIndex;
11
+ /**
12
+ * Gets or sets a boolean indicating that this block can evaluate context
13
+ * Build performance is improved when this value is set to false as the system will cache values instead of reevaluating everything per context change
14
+ */
15
+ evaluateContext: boolean;
11
16
  /**
12
17
  * Create a new SetNormalsBlock
13
18
  * @param name defines the block name
@@ -46,4 +51,11 @@ export declare class SetNormalsBlock extends NodeGeometryBlock implements INodeG
46
51
  */
47
52
  get output(): NodeGeometryConnectionPoint;
48
53
  protected _buildBlock(state: NodeGeometryBuildState): void;
54
+ protected _dumpPropertiesCode(): string;
55
+ /**
56
+ * Serializes this block in a JSON representation
57
+ * @returns the serialized block object
58
+ */
59
+ serialize(): any;
60
+ _deserialize(serializationObject: any): void;
49
61
  }