@onerjs/core 8.53.5 → 8.53.6

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 (841) hide show
  1. package/Animations/animationGroup.d.ts +0 -1
  2. package/Animations/animationGroup.js +0 -1
  3. package/Animations/animationGroup.js.map +1 -1
  4. package/Animations/animationGroup.pure.js +2 -0
  5. package/Animations/animationGroup.pure.js.map +1 -1
  6. package/Animations/runtimeAnimation.js +11 -0
  7. package/Animations/runtimeAnimation.js.map +1 -1
  8. package/Audio/audioSceneComponent.pure.js +1 -1
  9. package/AudioV2/abstractAudio/abstractSound.d.ts +2 -1
  10. package/AudioV2/abstractAudio/abstractSound.js +7 -2
  11. package/AudioV2/abstractAudio/abstractSound.js.map +1 -1
  12. package/AudioV2/abstractAudio/abstractSoundInstance.d.ts +3 -1
  13. package/AudioV2/abstractAudio/abstractSoundInstance.js.map +1 -1
  14. package/AudioV2/abstractAudio/staticSound.d.ts +6 -0
  15. package/AudioV2/abstractAudio/staticSound.js +17 -1
  16. package/AudioV2/abstractAudio/staticSound.js.map +1 -1
  17. package/AudioV2/abstractAudio/staticSoundInstance.d.ts +4 -2
  18. package/AudioV2/abstractAudio/staticSoundInstance.js.map +1 -1
  19. package/AudioV2/abstractAudio/streamingSound.d.ts +6 -0
  20. package/AudioV2/abstractAudio/streamingSound.js +9 -1
  21. package/AudioV2/abstractAudio/streamingSound.js.map +1 -1
  22. package/AudioV2/webAudio/webAudioStaticSound.d.ts +7 -1
  23. package/AudioV2/webAudio/webAudioStaticSound.js +56 -8
  24. package/AudioV2/webAudio/webAudioStaticSound.js.map +1 -1
  25. package/AudioV2/webAudio/webAudioStreamingSound.d.ts +3 -1
  26. package/AudioV2/webAudio/webAudioStreamingSound.js +16 -4
  27. package/AudioV2/webAudio/webAudioStreamingSound.js.map +1 -1
  28. package/BakedVertexAnimation/bakedVertexAnimationManager.d.ts +2 -2
  29. package/BakedVertexAnimation/bakedVertexAnimationManager.js +151 -121
  30. package/BakedVertexAnimation/bakedVertexAnimationManager.js.map +1 -1
  31. package/Behaviors/Cameras/interpolatingBehavior.d.ts +17 -2
  32. package/Behaviors/Cameras/interpolatingBehavior.js +53 -23
  33. package/Behaviors/Cameras/interpolatingBehavior.js.map +1 -1
  34. package/Bones/bone.pure.js +3 -3
  35. package/Buffers/buffer.pure.js +0 -12
  36. package/Buffers/buffer.pure.js.map +1 -1
  37. package/Cameras/Inputs/BaseCameraMouseWheelInput.js +141 -126
  38. package/Cameras/Inputs/BaseCameraMouseWheelInput.js.map +1 -1
  39. package/Cameras/Inputs/BaseCameraPointersInput.d.ts +2 -1
  40. package/Cameras/Inputs/BaseCameraPointersInput.js +290 -277
  41. package/Cameras/Inputs/BaseCameraPointersInput.js.map +1 -1
  42. package/Cameras/Inputs/arcRotateCameraGamepadInput.js +115 -102
  43. package/Cameras/Inputs/arcRotateCameraGamepadInput.js.map +1 -1
  44. package/Cameras/Inputs/arcRotateCameraKeyboardMoveInput.d.ts +3 -0
  45. package/Cameras/Inputs/arcRotateCameraKeyboardMoveInput.js +334 -273
  46. package/Cameras/Inputs/arcRotateCameraKeyboardMoveInput.js.map +1 -1
  47. package/Cameras/Inputs/arcRotateCameraMouseWheelInput.js +273 -258
  48. package/Cameras/Inputs/arcRotateCameraMouseWheelInput.js.map +1 -1
  49. package/Cameras/Inputs/arcRotateCameraPointersInput.js +237 -213
  50. package/Cameras/Inputs/arcRotateCameraPointersInput.js.map +1 -1
  51. package/Cameras/Inputs/flyCameraKeyboardInput.js +199 -168
  52. package/Cameras/Inputs/flyCameraKeyboardInput.js.map +1 -1
  53. package/Cameras/Inputs/flyCameraMouseInput.js +243 -229
  54. package/Cameras/Inputs/flyCameraMouseInput.js.map +1 -1
  55. package/Cameras/Inputs/followCameraKeyboardMoveInput.js +311 -266
  56. package/Cameras/Inputs/followCameraKeyboardMoveInput.js.map +1 -1
  57. package/Cameras/Inputs/followCameraMouseWheelInput.js +139 -119
  58. package/Cameras/Inputs/followCameraMouseWheelInput.js.map +1 -1
  59. package/Cameras/Inputs/followCameraPointersInput.js +239 -203
  60. package/Cameras/Inputs/followCameraPointersInput.js.map +1 -1
  61. package/Cameras/Inputs/freeCameraGamepadInput.js +127 -114
  62. package/Cameras/Inputs/freeCameraGamepadInput.js.map +1 -1
  63. package/Cameras/Inputs/freeCameraKeyboardMoveInput.js +278 -244
  64. package/Cameras/Inputs/freeCameraKeyboardMoveInput.js.map +1 -1
  65. package/Cameras/Inputs/freeCameraMouseInput.js +216 -202
  66. package/Cameras/Inputs/freeCameraMouseInput.js.map +1 -1
  67. package/Cameras/Inputs/freeCameraMouseWheelInput.js +368 -353
  68. package/Cameras/Inputs/freeCameraMouseWheelInput.js.map +1 -1
  69. package/Cameras/Inputs/freeCameraTouchInput.js +185 -172
  70. package/Cameras/Inputs/freeCameraTouchInput.js.map +1 -1
  71. package/Cameras/Inputs/geospatialCameraKeyboardInput.d.ts +2 -0
  72. package/Cameras/Inputs/geospatialCameraKeyboardInput.js +291 -246
  73. package/Cameras/Inputs/geospatialCameraKeyboardInput.js.map +1 -1
  74. package/Cameras/Inputs/geospatialCameraPointersInput.d.ts +11 -1
  75. package/Cameras/Inputs/geospatialCameraPointersInput.js +18 -2
  76. package/Cameras/Inputs/geospatialCameraPointersInput.js.map +1 -1
  77. package/Cameras/Inputs/orbitCameraPointersInput.js +112 -96
  78. package/Cameras/Inputs/orbitCameraPointersInput.js.map +1 -1
  79. package/Cameras/VR/vrExperienceHelper.d.ts +0 -2
  80. package/Cameras/VR/vrExperienceHelper.js +0 -2
  81. package/Cameras/VR/vrExperienceHelper.js.map +1 -1
  82. package/Cameras/VR/vrExperienceHelper.pure.js +5 -0
  83. package/Cameras/VR/vrExperienceHelper.pure.js.map +1 -1
  84. package/Cameras/arcRotateCamera.pure.js +1559 -1479
  85. package/Cameras/arcRotateCamera.pure.js.map +1 -1
  86. package/Cameras/camera.pure.js +1225 -1178
  87. package/Cameras/camera.pure.js.map +1 -1
  88. package/Cameras/flyCamera.pure.js +369 -351
  89. package/Cameras/flyCamera.pure.js.map +1 -1
  90. package/Cameras/followCamera.pure.js +229 -192
  91. package/Cameras/followCamera.pure.js.map +1 -1
  92. package/Cameras/freeCamera.pure.js +373 -351
  93. package/Cameras/freeCamera.pure.js.map +1 -1
  94. package/Cameras/geospatialCamera.pure.d.ts +30 -7
  95. package/Cameras/geospatialCamera.pure.js +502 -457
  96. package/Cameras/geospatialCamera.pure.js.map +1 -1
  97. package/Cameras/geospatialCameraMovement.js +2 -2
  98. package/Cameras/geospatialCameraMovement.js.map +1 -1
  99. package/Cameras/targetCamera.pure.d.ts +7 -0
  100. package/Cameras/targetCamera.pure.js +550 -509
  101. package/Cameras/targetCamera.pure.js.map +1 -1
  102. package/Cameras/universalCamera.pure.js +98 -85
  103. package/Cameras/universalCamera.pure.js.map +1 -1
  104. package/Collisions/gpuPicker.d.ts +111 -4
  105. package/Collisions/gpuPicker.js +696 -119
  106. package/Collisions/gpuPicker.js.map +1 -1
  107. package/Compute/computeShader.pure.js +372 -355
  108. package/Compute/computeShader.pure.js.map +1 -1
  109. package/Culling/Helper/transformFeedbackBoundingHelper.pure.js +2 -2
  110. package/Decorators/nodeDecorator.d.ts +11 -1
  111. package/Decorators/nodeDecorator.js +43 -6
  112. package/Decorators/nodeDecorator.js.map +1 -1
  113. package/Engines/AbstractEngine/abstractEngine.loadFile.pure.js +8 -0
  114. package/Engines/AbstractEngine/abstractEngine.loadFile.pure.js.map +1 -1
  115. package/Engines/Native/nativeHelpers.js +15 -0
  116. package/Engines/Native/nativeHelpers.js.map +1 -1
  117. package/Engines/Native/nativeInterfaces.d.ts +7 -2
  118. package/Engines/Native/nativeInterfaces.js.map +1 -1
  119. package/Engines/Native/nativeRenderTargetWrapper.d.ts +5 -0
  120. package/Engines/Native/nativeRenderTargetWrapper.js +35 -1
  121. package/Engines/Native/nativeRenderTargetWrapper.js.map +1 -1
  122. package/Engines/Processors/shaderProcessor.js +5 -3
  123. package/Engines/Processors/shaderProcessor.js.map +1 -1
  124. package/Engines/WebGPU/Extensions/engine.videoTexture.pure.js +16 -3
  125. package/Engines/WebGPU/Extensions/engine.videoTexture.pure.js.map +1 -1
  126. package/Engines/WebGPU/webgpuClearQuad.pure.js +7 -1
  127. package/Engines/WebGPU/webgpuClearQuad.pure.js.map +1 -1
  128. package/Engines/abstractEngine.functions.d.ts +8 -2
  129. package/Engines/abstractEngine.functions.js +12 -4
  130. package/Engines/abstractEngine.functions.js.map +1 -1
  131. package/Engines/abstractEngine.pure.d.ts +20 -1
  132. package/Engines/abstractEngine.pure.js +21 -134
  133. package/Engines/abstractEngine.pure.js.map +1 -1
  134. package/Engines/engine.d.ts +208 -0
  135. package/Engines/engine.pure.js +0 -15
  136. package/Engines/engine.pure.js.map +1 -1
  137. package/Engines/nullEngine.pure.d.ts +66 -0
  138. package/Engines/nullEngine.pure.js +97 -0
  139. package/Engines/nullEngine.pure.js.map +1 -1
  140. package/Engines/thinEngine.pure.d.ts +0 -13
  141. package/Engines/thinEngine.pure.js +4 -23
  142. package/Engines/thinEngine.pure.js.map +1 -1
  143. package/Engines/thinNativeEngine.d.ts +0 -1
  144. package/Engines/thinNativeEngine.js +0 -1
  145. package/Engines/thinNativeEngine.js.map +1 -1
  146. package/Engines/thinNativeEngine.pure.d.ts +27 -0
  147. package/Engines/thinNativeEngine.pure.js +383 -17
  148. package/Engines/thinNativeEngine.pure.js.map +1 -1
  149. package/Engines/webgpuEngine.d.ts +1 -0
  150. package/Engines/webgpuEngine.js +1 -0
  151. package/Engines/webgpuEngine.js.map +1 -1
  152. package/Engines/webgpuEngine.pure.d.ts +9 -0
  153. package/Engines/webgpuEngine.pure.js +7 -0
  154. package/Engines/webgpuEngine.pure.js.map +1 -1
  155. package/FlowGraph/flowGraph.js +9 -0
  156. package/FlowGraph/flowGraph.js.map +1 -1
  157. package/FlowGraph/flowGraphContext.js +597 -584
  158. package/FlowGraph/flowGraphContext.js.map +1 -1
  159. package/FlowGraph/flowGraphDataConnection.pure.d.ts +14 -0
  160. package/FlowGraph/flowGraphDataConnection.pure.js +38 -1
  161. package/FlowGraph/flowGraphDataConnection.pure.js.map +1 -1
  162. package/FlowGraph/serialization.d.ts +11 -0
  163. package/FlowGraph/serialization.js +11 -1
  164. package/FlowGraph/serialization.js.map +1 -1
  165. package/FrameGraph/Node/Blocks/Layers/glowLayerBlock.pure.js +182 -170
  166. package/FrameGraph/Node/Blocks/Layers/glowLayerBlock.pure.js.map +1 -1
  167. package/FrameGraph/Node/Blocks/Layers/highlightLayerBlock.pure.js +196 -184
  168. package/FrameGraph/Node/Blocks/Layers/highlightLayerBlock.pure.js.map +1 -1
  169. package/FrameGraph/Node/Blocks/Layers/selectionOutlineLayerBlock.pure.js +222 -210
  170. package/FrameGraph/Node/Blocks/Layers/selectionOutlineLayerBlock.pure.js.map +1 -1
  171. package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js +123 -111
  172. package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js.map +1 -1
  173. package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.js +158 -146
  174. package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.js.map +1 -1
  175. package/FrameGraph/Node/Blocks/PostProcesses/blackAndWhitePostProcessBlock.pure.js +63 -51
  176. package/FrameGraph/Node/Blocks/PostProcesses/blackAndWhitePostProcessBlock.pure.js.map +1 -1
  177. package/FrameGraph/Node/Blocks/PostProcesses/bloomPostProcessBlock.pure.js +122 -110
  178. package/FrameGraph/Node/Blocks/PostProcesses/bloomPostProcessBlock.pure.js.map +1 -1
  179. package/FrameGraph/Node/Blocks/PostProcesses/blurPostProcessBlock.pure.js +76 -64
  180. package/FrameGraph/Node/Blocks/PostProcesses/blurPostProcessBlock.pure.js.map +1 -1
  181. package/FrameGraph/Node/Blocks/PostProcesses/chromaticAberrationPostProcessBlock.pure.js +89 -77
  182. package/FrameGraph/Node/Blocks/PostProcesses/chromaticAberrationPostProcessBlock.pure.js.map +1 -1
  183. package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.pure.js +134 -122
  184. package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.pure.js.map +1 -1
  185. package/FrameGraph/Node/Blocks/PostProcesses/colorCorrectionPostProcessBlock.pure.js +58 -46
  186. package/FrameGraph/Node/Blocks/PostProcesses/colorCorrectionPostProcessBlock.pure.js.map +1 -1
  187. package/FrameGraph/Node/Blocks/PostProcesses/convolutionPostProcessBlock.pure.js +107 -95
  188. package/FrameGraph/Node/Blocks/PostProcesses/convolutionPostProcessBlock.pure.js.map +1 -1
  189. package/FrameGraph/Node/Blocks/PostProcesses/depthOfFieldPostProcessBlock.pure.js +181 -169
  190. package/FrameGraph/Node/Blocks/PostProcesses/depthOfFieldPostProcessBlock.pure.js.map +1 -1
  191. package/FrameGraph/Node/Blocks/PostProcesses/extractHighlightsPostProcessBlock.pure.js +63 -51
  192. package/FrameGraph/Node/Blocks/PostProcesses/extractHighlightsPostProcessBlock.pure.js.map +1 -1
  193. package/FrameGraph/Node/Blocks/PostProcesses/filterPostProcessBlock.pure.js +63 -51
  194. package/FrameGraph/Node/Blocks/PostProcesses/filterPostProcessBlock.pure.js.map +1 -1
  195. package/FrameGraph/Node/Blocks/PostProcesses/grainPostProcessBlock.pure.js +76 -64
  196. package/FrameGraph/Node/Blocks/PostProcesses/grainPostProcessBlock.pure.js.map +1 -1
  197. package/FrameGraph/Node/Blocks/PostProcesses/imageProcessingPostProcessBlock.pure.js +246 -234
  198. package/FrameGraph/Node/Blocks/PostProcesses/imageProcessingPostProcessBlock.pure.js.map +1 -1
  199. package/FrameGraph/Node/Blocks/PostProcesses/motionBlurPostProcessBlock.pure.js +108 -96
  200. package/FrameGraph/Node/Blocks/PostProcesses/motionBlurPostProcessBlock.pure.js.map +1 -1
  201. package/FrameGraph/Node/Blocks/PostProcesses/screenSpaceCurvaturePostProcessBlock.pure.js +87 -75
  202. package/FrameGraph/Node/Blocks/PostProcesses/screenSpaceCurvaturePostProcessBlock.pure.js.map +1 -1
  203. package/FrameGraph/Node/Blocks/PostProcesses/sharpenPostProcessBlock.pure.js +76 -64
  204. package/FrameGraph/Node/Blocks/PostProcesses/sharpenPostProcessBlock.pure.js.map +1 -1
  205. package/FrameGraph/Node/Blocks/PostProcesses/ssao2PostProcessBlock.pure.js +313 -301
  206. package/FrameGraph/Node/Blocks/PostProcesses/ssao2PostProcessBlock.pure.js.map +1 -1
  207. package/FrameGraph/Node/Blocks/PostProcesses/ssrPostProcessBlock.pure.js +502 -490
  208. package/FrameGraph/Node/Blocks/PostProcesses/ssrPostProcessBlock.pure.js.map +1 -1
  209. package/FrameGraph/Node/Blocks/PostProcesses/taaPostProcessBlock.pure.js +147 -135
  210. package/FrameGraph/Node/Blocks/PostProcesses/taaPostProcessBlock.pure.js.map +1 -1
  211. package/FrameGraph/Node/Blocks/PostProcesses/tonemapPostProcessBlock.pure.js +90 -78
  212. package/FrameGraph/Node/Blocks/PostProcesses/tonemapPostProcessBlock.pure.js.map +1 -1
  213. package/FrameGraph/Node/Blocks/PostProcesses/volumetricLightingBlock.pure.js +179 -167
  214. package/FrameGraph/Node/Blocks/PostProcesses/volumetricLightingBlock.pure.js.map +1 -1
  215. package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js +462 -451
  216. package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js.map +1 -1
  217. package/FrameGraph/Node/Blocks/Rendering/baseShadowGeneratorBlock.js +265 -253
  218. package/FrameGraph/Node/Blocks/Rendering/baseShadowGeneratorBlock.js.map +1 -1
  219. package/FrameGraph/Node/Blocks/Rendering/csmShadowGeneratorBlock.pure.js +204 -192
  220. package/FrameGraph/Node/Blocks/Rendering/csmShadowGeneratorBlock.pure.js.map +1 -1
  221. package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.pure.js +611 -550
  222. package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.pure.js.map +1 -1
  223. package/FrameGraph/Node/Blocks/Rendering/iblShadowsRendererBlock.pure.js +320 -308
  224. package/FrameGraph/Node/Blocks/Rendering/iblShadowsRendererBlock.pure.js.map +1 -1
  225. package/FrameGraph/Node/Blocks/Rendering/utilityLayerRendererBlock.pure.js +87 -75
  226. package/FrameGraph/Node/Blocks/Rendering/utilityLayerRendererBlock.pure.js.map +1 -1
  227. package/FrameGraph/Node/Blocks/Textures/clearBlock.pure.js +154 -142
  228. package/FrameGraph/Node/Blocks/Textures/clearBlock.pure.js.map +1 -1
  229. package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.pure.js +150 -138
  230. package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.pure.js.map +1 -1
  231. package/FrameGraph/Node/Blocks/inputBlock.pure.js +270 -256
  232. package/FrameGraph/Node/Blocks/inputBlock.pure.js.map +1 -1
  233. package/FrameGraph/Node/Blocks/lightingVolumeBlock.pure.js +95 -83
  234. package/FrameGraph/Node/Blocks/lightingVolumeBlock.pure.js.map +1 -1
  235. package/FrameGraph/Node/nodeRenderGraph.js +715 -693
  236. package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
  237. package/FrameGraph/Node/nodeRenderGraphBlock.js +548 -533
  238. package/FrameGraph/Node/nodeRenderGraphBlock.js.map +1 -1
  239. package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsAccumulationTask.d.ts +2 -2
  240. package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsAccumulationTask.js +43 -51
  241. package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsAccumulationTask.js.map +1 -1
  242. package/FrameGraph/Tasks/Rendering/iblShadowsRendererTask.d.ts +0 -1
  243. package/FrameGraph/Tasks/Rendering/iblShadowsRendererTask.js +0 -1
  244. package/FrameGraph/Tasks/Rendering/iblShadowsRendererTask.js.map +1 -1
  245. package/FrameGraph/Tasks/Rendering/iblShadowsRendererTask.pure.d.ts +0 -1
  246. package/FrameGraph/Tasks/Rendering/iblShadowsRendererTask.pure.js +66 -35
  247. package/FrameGraph/Tasks/Rendering/iblShadowsRendererTask.pure.js.map +1 -1
  248. package/Helpers/environmentHelper.js +2 -2
  249. package/Helpers/environmentHelper.js.map +1 -1
  250. package/Layers/effectLayer.js +529 -519
  251. package/Layers/effectLayer.js.map +1 -1
  252. package/Layers/glowLayer.pure.js +428 -413
  253. package/Layers/glowLayer.pure.js.map +1 -1
  254. package/Layers/highlightLayer.pure.js +473 -458
  255. package/Layers/highlightLayer.pure.js.map +1 -1
  256. package/Layers/selectionOutlineLayer.pure.js +360 -345
  257. package/Layers/selectionOutlineLayer.pure.js.map +1 -1
  258. package/Lights/Clustered/clusteredLightContainer.pure.d.ts +1 -1
  259. package/Lights/Clustered/clusteredLightContainer.pure.js +583 -558
  260. package/Lights/Clustered/clusteredLightContainer.pure.js.map +1 -1
  261. package/Lights/Shadows/shadowGenerator.js +6 -1
  262. package/Lights/Shadows/shadowGenerator.js.map +1 -1
  263. package/Lights/areaLight.pure.js +61 -39
  264. package/Lights/areaLight.pure.js.map +1 -1
  265. package/Lights/directionalLight.pure.js +308 -284
  266. package/Lights/directionalLight.pure.js.map +1 -1
  267. package/Lights/hemisphericLight.pure.js +123 -104
  268. package/Lights/hemisphericLight.pure.js.map +1 -1
  269. package/Lights/light.d.ts +5 -3
  270. package/Lights/light.js +869 -827
  271. package/Lights/light.js.map +1 -1
  272. package/Lights/pointLight.pure.js +185 -174
  273. package/Lights/pointLight.pure.js.map +1 -1
  274. package/Lights/rectAreaLight.pure.d.ts +17 -0
  275. package/Lights/rectAreaLight.pure.js +238 -159
  276. package/Lights/rectAreaLight.pure.js.map +1 -1
  277. package/Lights/shadowLight.js +280 -268
  278. package/Lights/shadowLight.js.map +1 -1
  279. package/Lights/spotLight.pure.js +460 -427
  280. package/Lights/spotLight.pure.js.map +1 -1
  281. package/Loading/Plugins/babylonFileLoader.pure.js +17 -5
  282. package/Loading/Plugins/babylonFileLoader.pure.js.map +1 -1
  283. package/Loading/sceneLoader.d.ts +5 -1
  284. package/Loading/sceneLoader.js +299 -402
  285. package/Loading/sceneLoader.js.map +1 -1
  286. package/Materials/Background/backgroundMaterial.pure.d.ts +18 -18
  287. package/Materials/Background/backgroundMaterial.pure.js +949 -794
  288. package/Materials/Background/backgroundMaterial.pure.js.map +1 -1
  289. package/Materials/GaussianSplatting/gaussianSplattingGpuPickingMaterialPlugin.pure.d.ts +15 -0
  290. package/Materials/GaussianSplatting/gaussianSplattingGpuPickingMaterialPlugin.pure.js +34 -1
  291. package/Materials/GaussianSplatting/gaussianSplattingGpuPickingMaterialPlugin.pure.js.map +1 -1
  292. package/Materials/GaussianSplatting/gaussianSplattingMaterial.pure.d.ts +9 -0
  293. package/Materials/GaussianSplatting/gaussianSplattingMaterial.pure.js +26 -2
  294. package/Materials/GaussianSplatting/gaussianSplattingMaterial.pure.js.map +1 -1
  295. package/Materials/GaussianSplatting/gaussianSplattingSolidColorMaterialPlugin.pure.d.ts +2 -1
  296. package/Materials/GaussianSplatting/gaussianSplattingSolidColorMaterialPlugin.pure.js +169 -149
  297. package/Materials/GaussianSplatting/gaussianSplattingSolidColorMaterialPlugin.pure.js.map +1 -1
  298. package/Materials/Node/Blocks/Dual/imageSourceBlock.pure.js +1 -1
  299. package/Materials/Node/Blocks/Dual/lightBlock.pure.js +442 -429
  300. package/Materials/Node/Blocks/Dual/lightBlock.pure.js.map +1 -1
  301. package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.pure.js +396 -383
  302. package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.pure.js.map +1 -1
  303. package/Materials/Node/Blocks/Dual/sceneDepthBlock.pure.js +237 -220
  304. package/Materials/Node/Blocks/Dual/sceneDepthBlock.pure.js.map +1 -1
  305. package/Materials/Node/Blocks/Dual/textureBlock.pure.js +1 -1
  306. package/Materials/Node/Blocks/Fragment/ambientOcclusionBlock.pure.js +150 -133
  307. package/Materials/Node/Blocks/Fragment/ambientOcclusionBlock.pure.js.map +1 -1
  308. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.pure.js +265 -250
  309. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.pure.js.map +1 -1
  310. package/Materials/Node/Blocks/Fragment/heightToNormalBlock.pure.js +159 -142
  311. package/Materials/Node/Blocks/Fragment/heightToNormalBlock.pure.js.map +1 -1
  312. package/Materials/Node/Blocks/Fragment/imageProcessingBlock.pure.js +214 -201
  313. package/Materials/Node/Blocks/Fragment/imageProcessingBlock.pure.js.map +1 -1
  314. package/Materials/Node/Blocks/Fragment/perturbNormalBlock.pure.js +419 -400
  315. package/Materials/Node/Blocks/Fragment/perturbNormalBlock.pure.js.map +1 -1
  316. package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.pure.js +3 -1
  317. package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.pure.js.map +1 -1
  318. package/Materials/Node/Blocks/PBR/clearCoatBlock.pure.js +302 -289
  319. package/Materials/Node/Blocks/PBR/clearCoatBlock.pure.js.map +1 -1
  320. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.pure.js +1327 -1272
  321. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.pure.js.map +1 -1
  322. package/Materials/Node/Blocks/PBR/reflectionBlock.pure.js +352 -337
  323. package/Materials/Node/Blocks/PBR/reflectionBlock.pure.js.map +1 -1
  324. package/Materials/Node/Blocks/PBR/refractionBlock.pure.js +297 -277
  325. package/Materials/Node/Blocks/PBR/refractionBlock.pure.js.map +1 -1
  326. package/Materials/Node/Blocks/PBR/sheenBlock.pure.js +146 -131
  327. package/Materials/Node/Blocks/PBR/sheenBlock.pure.js.map +1 -1
  328. package/Materials/Node/Blocks/PBR/subSurfaceBlock.pure.js +158 -145
  329. package/Materials/Node/Blocks/PBR/subSurfaceBlock.pure.js.map +1 -1
  330. package/Materials/Node/Blocks/clampBlock.pure.js +92 -77
  331. package/Materials/Node/Blocks/clampBlock.pure.js.map +1 -1
  332. package/Materials/Node/Blocks/cloudBlock.pure.js +145 -132
  333. package/Materials/Node/Blocks/cloudBlock.pure.js.map +1 -1
  334. package/Materials/Node/Blocks/conditionalBlock.pure.js +182 -169
  335. package/Materials/Node/Blocks/conditionalBlock.pure.js.map +1 -1
  336. package/Materials/Node/Blocks/curveBlock.pure.js +259 -246
  337. package/Materials/Node/Blocks/curveBlock.pure.js.map +1 -1
  338. package/Materials/Node/Blocks/debugBlock.pure.js +119 -106
  339. package/Materials/Node/Blocks/debugBlock.pure.js.map +1 -1
  340. package/Materials/Node/Blocks/loopBlock.pure.js +123 -110
  341. package/Materials/Node/Blocks/loopBlock.pure.js.map +1 -1
  342. package/Materials/Node/Blocks/meshAttributeExistsBlock.pure.js +185 -172
  343. package/Materials/Node/Blocks/meshAttributeExistsBlock.pure.js.map +1 -1
  344. package/Materials/Node/Blocks/remapBlock.pure.js +127 -112
  345. package/Materials/Node/Blocks/remapBlock.pure.js.map +1 -1
  346. package/Materials/Node/Blocks/transformBlock.pure.js +196 -185
  347. package/Materials/Node/Blocks/transformBlock.pure.js.map +1 -1
  348. package/Materials/Node/Blocks/triPlanarBlock.pure.js +451 -438
  349. package/Materials/Node/Blocks/triPlanarBlock.pure.js.map +1 -1
  350. package/Materials/Node/Blocks/trigonometryBlock.pure.js +184 -171
  351. package/Materials/Node/Blocks/trigonometryBlock.pure.js.map +1 -1
  352. package/Materials/Node/Blocks/waveBlock.pure.js +97 -84
  353. package/Materials/Node/Blocks/waveBlock.pure.js.map +1 -1
  354. package/Materials/Node/Blocks/worleyNoise3DBlock.pure.js +276 -263
  355. package/Materials/Node/Blocks/worleyNoise3DBlock.pure.js.map +1 -1
  356. package/Materials/Node/nodeMaterial.pure.js +1765 -1737
  357. package/Materials/Node/nodeMaterial.pure.js.map +1 -1
  358. package/Materials/Node/nodeMaterialBuildState.d.ts +3 -3
  359. package/Materials/PBR/openpbrMaterial.pure.d.ts +102 -102
  360. package/Materials/PBR/openpbrMaterial.pure.js +3115 -2243
  361. package/Materials/PBR/openpbrMaterial.pure.js.map +1 -1
  362. package/Materials/PBR/pbrAnisotropicConfiguration.d.ts +3 -3
  363. package/Materials/PBR/pbrAnisotropicConfiguration.js +255 -227
  364. package/Materials/PBR/pbrAnisotropicConfiguration.js.map +1 -1
  365. package/Materials/PBR/pbrBRDFConfiguration.d.ts +9 -9
  366. package/Materials/PBR/pbrBRDFConfiguration.js +203 -155
  367. package/Materials/PBR/pbrBRDFConfiguration.js.map +1 -1
  368. package/Materials/PBR/pbrBaseMaterial.pure.d.ts +1 -1
  369. package/Materials/PBR/pbrBaseMaterial.pure.js +1751 -1736
  370. package/Materials/PBR/pbrBaseMaterial.pure.js.map +1 -1
  371. package/Materials/PBR/pbrBaseSimpleMaterial.d.ts +13 -13
  372. package/Materials/PBR/pbrBaseSimpleMaterial.js +205 -117
  373. package/Materials/PBR/pbrBaseSimpleMaterial.js.map +1 -1
  374. package/Materials/PBR/pbrClearCoatConfiguration.d.ts +9 -9
  375. package/Materials/PBR/pbrClearCoatConfiguration.js +464 -406
  376. package/Materials/PBR/pbrClearCoatConfiguration.js.map +1 -1
  377. package/Materials/PBR/pbrIridescenceConfiguration.d.ts +3 -3
  378. package/Materials/PBR/pbrIridescenceConfiguration.js +271 -239
  379. package/Materials/PBR/pbrIridescenceConfiguration.js.map +1 -1
  380. package/Materials/PBR/pbrMaterial.pure.d.ts +66 -66
  381. package/Materials/PBR/pbrMaterial.pure.js +1041 -685
  382. package/Materials/PBR/pbrMaterial.pure.js.map +1 -1
  383. package/Materials/PBR/pbrMetallicRoughnessMaterial.pure.d.ts +5 -5
  384. package/Materials/PBR/pbrMetallicRoughnessMaterial.pure.js +176 -115
  385. package/Materials/PBR/pbrMetallicRoughnessMaterial.pure.js.map +1 -1
  386. package/Materials/PBR/pbrSheenConfiguration.d.ts +7 -7
  387. package/Materials/PBR/pbrSheenConfiguration.js +314 -270
  388. package/Materials/PBR/pbrSheenConfiguration.js.map +1 -1
  389. package/Materials/PBR/pbrSpecularGlossinessMaterial.pure.d.ts +5 -5
  390. package/Materials/PBR/pbrSpecularGlossinessMaterial.pure.js +172 -117
  391. package/Materials/PBR/pbrSpecularGlossinessMaterial.pure.js.map +1 -1
  392. package/Materials/PBR/pbrSubSurfaceConfiguration.d.ts +16 -16
  393. package/Materials/PBR/pbrSubSurfaceConfiguration.js +864 -764
  394. package/Materials/PBR/pbrSubSurfaceConfiguration.js.map +1 -1
  395. package/Materials/Textures/HTML/htmlInCanvasPolyfill.d.ts +43 -0
  396. package/Materials/Textures/HTML/htmlInCanvasPolyfill.js +64 -0
  397. package/Materials/Textures/HTML/htmlInCanvasPolyfill.js.map +1 -0
  398. package/Materials/Textures/HTML/htmlInteractionManager.d.ts +69 -0
  399. package/Materials/Textures/HTML/htmlInteractionManager.js +130 -0
  400. package/Materials/Textures/HTML/htmlInteractionManager.js.map +1 -0
  401. package/Materials/Textures/HTML/htmlRaycastInteractionManager.d.ts +84 -0
  402. package/Materials/Textures/HTML/htmlRaycastInteractionManager.js +246 -0
  403. package/Materials/Textures/HTML/htmlRaycastInteractionManager.js.map +1 -0
  404. package/Materials/Textures/HTML/htmlTexture.d.ts +148 -0
  405. package/Materials/Textures/HTML/htmlTexture.js +455 -0
  406. package/Materials/Textures/HTML/htmlTexture.js.map +1 -0
  407. package/Materials/Textures/HTML/index.d.ts +4 -0
  408. package/Materials/Textures/HTML/index.js +5 -0
  409. package/Materials/Textures/HTML/index.js.map +1 -0
  410. package/Materials/Textures/HTML/pure.d.ts +5 -0
  411. package/Materials/Textures/HTML/pure.js +6 -0
  412. package/Materials/Textures/HTML/pure.js.map +1 -0
  413. package/Materials/Textures/Procedurals/proceduralTexture.pure.js +671 -643
  414. package/Materials/Textures/Procedurals/proceduralTexture.pure.js.map +1 -1
  415. package/Materials/Textures/baseTexture.pure.js +880 -825
  416. package/Materials/Textures/baseTexture.pure.js.map +1 -1
  417. package/Materials/Textures/cubeTexture.d.ts +0 -1
  418. package/Materials/Textures/cubeTexture.js +0 -1
  419. package/Materials/Textures/cubeTexture.js.map +1 -1
  420. package/Materials/Textures/cubeTexture.pure.js +368 -333
  421. package/Materials/Textures/cubeTexture.pure.js.map +1 -1
  422. package/Materials/Textures/dynamicTexture.d.ts +0 -1
  423. package/Materials/Textures/dynamicTexture.js +0 -1
  424. package/Materials/Textures/dynamicTexture.js.map +1 -1
  425. package/Materials/Textures/dynamicTexture.pure.js +2 -0
  426. package/Materials/Textures/dynamicTexture.pure.js.map +1 -1
  427. package/Materials/Textures/htmlElementTexture.d.ts +0 -2
  428. package/Materials/Textures/htmlElementTexture.js +0 -2
  429. package/Materials/Textures/htmlElementTexture.js.map +1 -1
  430. package/Materials/Textures/htmlElementTexture.pure.js +4 -0
  431. package/Materials/Textures/htmlElementTexture.pure.js.map +1 -1
  432. package/Materials/Textures/index.d.ts +1 -0
  433. package/Materials/Textures/index.js +1 -1
  434. package/Materials/Textures/index.js.map +1 -1
  435. package/Materials/Textures/multiRenderTarget.d.ts +0 -1
  436. package/Materials/Textures/multiRenderTarget.js +0 -1
  437. package/Materials/Textures/multiRenderTarget.js.map +1 -1
  438. package/Materials/Textures/multiRenderTarget.pure.js +2 -0
  439. package/Materials/Textures/multiRenderTarget.pure.js.map +1 -1
  440. package/Materials/Textures/pure.d.ts +1 -0
  441. package/Materials/Textures/pure.js +1 -0
  442. package/Materials/Textures/pure.js.map +1 -1
  443. package/Materials/Textures/texture.pure.js +961 -923
  444. package/Materials/Textures/texture.pure.js.map +1 -1
  445. package/Materials/Textures/videoTexture.pure.d.ts +3 -0
  446. package/Materials/Textures/videoTexture.pure.js +450 -401
  447. package/Materials/Textures/videoTexture.pure.js.map +1 -1
  448. package/Materials/colorCurves.pure.js +510 -477
  449. package/Materials/colorCurves.pure.js.map +1 -1
  450. package/Materials/effect.pure.js +0 -7
  451. package/Materials/effect.pure.js.map +1 -1
  452. package/Materials/imageProcessing.js +12 -4
  453. package/Materials/imageProcessing.js.map +1 -1
  454. package/Materials/imageProcessingConfiguration.pure.js +647 -587
  455. package/Materials/imageProcessingConfiguration.pure.js.map +1 -1
  456. package/Materials/material.decalMapConfiguration.pure.d.ts +2 -2
  457. package/Materials/material.decalMapConfiguration.pure.js +149 -130
  458. package/Materials/material.decalMapConfiguration.pure.js.map +1 -1
  459. package/Materials/material.detailMapConfiguration.d.ts +3 -3
  460. package/Materials/material.detailMapConfiguration.js +213 -175
  461. package/Materials/material.detailMapConfiguration.js.map +1 -1
  462. package/Materials/material.pure.js +1815 -1721
  463. package/Materials/material.pure.js.map +1 -1
  464. package/Materials/materialPluginBase.pure.js +270 -249
  465. package/Materials/materialPluginBase.pure.js.map +1 -1
  466. package/Materials/materialPluginManager.pure.js +18 -8
  467. package/Materials/materialPluginManager.pure.js.map +1 -1
  468. package/Materials/materialStencilState.js +211 -200
  469. package/Materials/materialStencilState.js.map +1 -1
  470. package/Materials/meshDebugPluginMaterial.pure.d.ts +2 -2
  471. package/Materials/meshDebugPluginMaterial.pure.js +397 -275
  472. package/Materials/meshDebugPluginMaterial.pure.js.map +1 -1
  473. package/Materials/standardMaterial.pure.d.ts +32 -32
  474. package/Materials/standardMaterial.pure.js +1804 -1394
  475. package/Materials/standardMaterial.pure.js.map +1 -1
  476. package/Maths/math.color.pure.js +5 -5
  477. package/Maths/math.functions.js +38 -30
  478. package/Maths/math.functions.js.map +1 -1
  479. package/Maths/math.vector.pure.js +25 -25
  480. package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.js +18 -8
  481. package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.js.map +1 -1
  482. package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.d.ts +86 -1
  483. package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js +255 -104
  484. package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js.map +1 -1
  485. package/Meshes/GaussianSplatting/gaussianSplattingSortWorker.d.ts +39 -0
  486. package/Meshes/GaussianSplatting/gaussianSplattingSortWorker.js +322 -0
  487. package/Meshes/GaussianSplatting/gaussianSplattingSortWorker.js.map +1 -0
  488. package/Meshes/GreasedLine/greasedLineMesh.pure.js +4 -4
  489. package/Meshes/GreasedLine/greasedLineRibbonMesh.pure.js +3 -3
  490. package/Meshes/Node/Blocks/Instances/instantiateBaseBlock.js +107 -94
  491. package/Meshes/Node/Blocks/Instances/instantiateBaseBlock.js.map +1 -1
  492. package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.pure.js +276 -263
  493. package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.pure.js.map +1 -1
  494. package/Meshes/Node/Blocks/Instances/instantiateOnVerticesBlock.pure.js +247 -232
  495. package/Meshes/Node/Blocks/Instances/instantiateOnVerticesBlock.pure.js.map +1 -1
  496. package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.pure.js +299 -284
  497. package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.pure.js.map +1 -1
  498. package/Meshes/Node/Blocks/Set/aggregatorBlock.pure.js +196 -181
  499. package/Meshes/Node/Blocks/Set/aggregatorBlock.pure.js.map +1 -1
  500. package/Meshes/Node/Blocks/Set/latticeBlock.pure.js +198 -179
  501. package/Meshes/Node/Blocks/Set/latticeBlock.pure.js.map +1 -1
  502. package/Meshes/Node/Blocks/Set/setColorsBlock.pure.js +151 -138
  503. package/Meshes/Node/Blocks/Set/setColorsBlock.pure.js.map +1 -1
  504. package/Meshes/Node/Blocks/Set/setMaterialIDBlock.pure.js +107 -94
  505. package/Meshes/Node/Blocks/Set/setMaterialIDBlock.pure.js.map +1 -1
  506. package/Meshes/Node/Blocks/Set/setNormalsBlock.pure.js +138 -125
  507. package/Meshes/Node/Blocks/Set/setNormalsBlock.pure.js.map +1 -1
  508. package/Meshes/Node/Blocks/Set/setPositionsBlock.pure.js +213 -200
  509. package/Meshes/Node/Blocks/Set/setPositionsBlock.pure.js.map +1 -1
  510. package/Meshes/Node/Blocks/Set/setTangentsBlock.pure.js +138 -125
  511. package/Meshes/Node/Blocks/Set/setTangentsBlock.pure.js.map +1 -1
  512. package/Meshes/Node/Blocks/Set/setUVsBlock.pure.js +179 -164
  513. package/Meshes/Node/Blocks/Set/setUVsBlock.pure.js.map +1 -1
  514. package/Meshes/Node/Blocks/Sources/boxBlock.pure.js +183 -170
  515. package/Meshes/Node/Blocks/Sources/boxBlock.pure.js.map +1 -1
  516. package/Meshes/Node/Blocks/Sources/capsuleBlock.pure.js +125 -112
  517. package/Meshes/Node/Blocks/Sources/capsuleBlock.pure.js.map +1 -1
  518. package/Meshes/Node/Blocks/Sources/cylinderBlock.pure.js +153 -140
  519. package/Meshes/Node/Blocks/Sources/cylinderBlock.pure.js.map +1 -1
  520. package/Meshes/Node/Blocks/Sources/discBlock.pure.js +112 -99
  521. package/Meshes/Node/Blocks/Sources/discBlock.pure.js.map +1 -1
  522. package/Meshes/Node/Blocks/Sources/gridBlock.pure.js +133 -120
  523. package/Meshes/Node/Blocks/Sources/gridBlock.pure.js.map +1 -1
  524. package/Meshes/Node/Blocks/Sources/icoSphereBlock.pure.js +128 -115
  525. package/Meshes/Node/Blocks/Sources/icoSphereBlock.pure.js.map +1 -1
  526. package/Meshes/Node/Blocks/Sources/meshBlock.pure.js +116 -103
  527. package/Meshes/Node/Blocks/Sources/meshBlock.pure.js.map +1 -1
  528. package/Meshes/Node/Blocks/Sources/planeBlock.pure.js +160 -147
  529. package/Meshes/Node/Blocks/Sources/planeBlock.pure.js.map +1 -1
  530. package/Meshes/Node/Blocks/Sources/sphereBlock.pure.js +144 -131
  531. package/Meshes/Node/Blocks/Sources/sphereBlock.pure.js.map +1 -1
  532. package/Meshes/Node/Blocks/Sources/torusBlock.pure.js +112 -99
  533. package/Meshes/Node/Blocks/Sources/torusBlock.pure.js.map +1 -1
  534. package/Meshes/Node/Blocks/Textures/geometryTextureFetchBlock.pure.js +200 -185
  535. package/Meshes/Node/Blocks/Textures/geometryTextureFetchBlock.pure.js.map +1 -1
  536. package/Meshes/Node/Blocks/bevelBlock.pure.js +111 -98
  537. package/Meshes/Node/Blocks/bevelBlock.pure.js.map +1 -1
  538. package/Meshes/Node/Blocks/booleanGeometryBlock.pure.js +182 -165
  539. package/Meshes/Node/Blocks/booleanGeometryBlock.pure.js.map +1 -1
  540. package/Meshes/Node/Blocks/cleanGeometryBlock.pure.js +89 -76
  541. package/Meshes/Node/Blocks/cleanGeometryBlock.pure.js.map +1 -1
  542. package/Meshes/Node/Blocks/conditionBlock.pure.js +184 -169
  543. package/Meshes/Node/Blocks/conditionBlock.pure.js.map +1 -1
  544. package/Meshes/Node/Blocks/extrudeGeometryBlock.pure.js +270 -255
  545. package/Meshes/Node/Blocks/extrudeGeometryBlock.pure.js.map +1 -1
  546. package/Meshes/Node/Blocks/geometryCollectionBlock.pure.js +172 -159
  547. package/Meshes/Node/Blocks/geometryCollectionBlock.pure.js.map +1 -1
  548. package/Meshes/Node/Blocks/geometryCurveBlock.pure.js +230 -217
  549. package/Meshes/Node/Blocks/geometryCurveBlock.pure.js.map +1 -1
  550. package/Meshes/Node/Blocks/geometryEaseBlock.pure.js +256 -245
  551. package/Meshes/Node/Blocks/geometryEaseBlock.pure.js.map +1 -1
  552. package/Meshes/Node/Blocks/geometryOptimizeBlock.pure.js +206 -189
  553. package/Meshes/Node/Blocks/geometryOptimizeBlock.pure.js.map +1 -1
  554. package/Meshes/Node/Blocks/geometryTransformBlock.pure.js +166 -153
  555. package/Meshes/Node/Blocks/geometryTransformBlock.pure.js.map +1 -1
  556. package/Meshes/Node/Blocks/geometryTrigonometryBlock.pure.js +221 -208
  557. package/Meshes/Node/Blocks/geometryTrigonometryBlock.pure.js.map +1 -1
  558. package/Meshes/Node/Blocks/mappingBlock.pure.js +150 -137
  559. package/Meshes/Node/Blocks/mappingBlock.pure.js.map +1 -1
  560. package/Meshes/Node/Blocks/mathBlock.pure.js +269 -256
  561. package/Meshes/Node/Blocks/mathBlock.pure.js.map +1 -1
  562. package/Meshes/Node/Blocks/mergeGeometryBlock.pure.js +141 -128
  563. package/Meshes/Node/Blocks/mergeGeometryBlock.pure.js.map +1 -1
  564. package/Meshes/Node/Blocks/randomBlock.pure.js +161 -148
  565. package/Meshes/Node/Blocks/randomBlock.pure.js.map +1 -1
  566. package/Meshes/Node/Blocks/subdivideBlock.pure.js +102 -87
  567. package/Meshes/Node/Blocks/subdivideBlock.pure.js.map +1 -1
  568. package/Meshes/Node/nodeGeometry.js +560 -538
  569. package/Meshes/Node/nodeGeometry.js.map +1 -1
  570. package/Meshes/Node/nodeGeometryBlock.js +473 -458
  571. package/Meshes/Node/nodeGeometryBlock.js.map +1 -1
  572. package/Meshes/abstractMesh.pure.js +2218 -2207
  573. package/Meshes/abstractMesh.pure.js.map +1 -1
  574. package/Meshes/geometry.js +30 -15
  575. package/Meshes/geometry.js.map +1 -1
  576. package/Meshes/mesh.pure.js +26 -14
  577. package/Meshes/mesh.pure.js.map +1 -1
  578. package/Meshes/mesh.vertexData.js +1665 -1655
  579. package/Meshes/mesh.vertexData.js.map +1 -1
  580. package/Meshes/transformNode.pure.js +1400 -1372
  581. package/Meshes/transformNode.pure.js.map +1 -1
  582. package/Misc/decorators.d.ts +34 -19
  583. package/Misc/decorators.functions.d.ts +33 -2
  584. package/Misc/decorators.functions.js +114 -35
  585. package/Misc/decorators.functions.js.map +1 -1
  586. package/Misc/decorators.js +96 -68
  587. package/Misc/decorators.js.map +1 -1
  588. package/Misc/decorators.serialization.js +47 -40
  589. package/Misc/decorators.serialization.js.map +1 -1
  590. package/Misc/decorators.serializationUtilities.d.ts +24 -0
  591. package/Misc/decorators.serializationUtilities.js +20 -0
  592. package/Misc/decorators.serializationUtilities.js.map +1 -0
  593. package/Misc/dumpTools.pure.js +43 -33
  594. package/Misc/dumpTools.pure.js.map +1 -1
  595. package/Misc/fileTools.pure.js +8 -0
  596. package/Misc/fileTools.pure.js.map +1 -1
  597. package/Misc/observable.pure.js +0 -7
  598. package/Misc/observable.pure.js.map +1 -1
  599. package/Misc/snapshotRenderingHelper.d.ts +4 -1
  600. package/Misc/snapshotRenderingHelper.js.map +1 -1
  601. package/Misc/symbolMetadataPolyfill.d.ts +11 -0
  602. package/Misc/symbolMetadataPolyfill.js +22 -0
  603. package/Misc/symbolMetadataPolyfill.js.map +1 -0
  604. package/Misc/tools.pure.js +2 -2
  605. package/Misc/tools.pure.js.map +1 -1
  606. package/Morph/morphTarget.js +382 -365
  607. package/Morph/morphTarget.js.map +1 -1
  608. package/Particles/Node/Blocks/Conditions/particleConditionBlock.pure.js +160 -145
  609. package/Particles/Node/Blocks/Conditions/particleConditionBlock.pure.js.map +1 -1
  610. package/Particles/Node/Blocks/Emitters/coneShapeBlock.pure.js +187 -174
  611. package/Particles/Node/Blocks/Emitters/coneShapeBlock.pure.js.map +1 -1
  612. package/Particles/Node/Blocks/Emitters/meshShapeBlock.pure.js +238 -219
  613. package/Particles/Node/Blocks/Emitters/meshShapeBlock.pure.js.map +1 -1
  614. package/Particles/Node/Blocks/Emitters/setupSpriteSheetBlock.pure.js +140 -115
  615. package/Particles/Node/Blocks/Emitters/setupSpriteSheetBlock.pure.js.map +1 -1
  616. package/Particles/Node/Blocks/Emitters/sphereShapeBlock.pure.js +157 -144
  617. package/Particles/Node/Blocks/Emitters/sphereShapeBlock.pure.js.map +1 -1
  618. package/Particles/Node/Blocks/Triggers/particleTriggerBlock.pure.js +133 -119
  619. package/Particles/Node/Blocks/Triggers/particleTriggerBlock.pure.js.map +1 -1
  620. package/Particles/Node/Blocks/Update/alignAngleBlock.pure.js +93 -80
  621. package/Particles/Node/Blocks/Update/alignAngleBlock.pure.js.map +1 -1
  622. package/Particles/Node/Blocks/particleDebugBlock.pure.js +117 -105
  623. package/Particles/Node/Blocks/particleDebugBlock.pure.js.map +1 -1
  624. package/Particles/Node/Blocks/particleFloatToIntBlock.pure.js +105 -92
  625. package/Particles/Node/Blocks/particleFloatToIntBlock.pure.js.map +1 -1
  626. package/Particles/Node/Blocks/particleGradientValueBlock.pure.js +82 -69
  627. package/Particles/Node/Blocks/particleGradientValueBlock.pure.js.map +1 -1
  628. package/Particles/Node/Blocks/particleLocalVariableBlock.pure.js +113 -101
  629. package/Particles/Node/Blocks/particleLocalVariableBlock.pure.js.map +1 -1
  630. package/Particles/Node/Blocks/particleMathBlock.pure.js +278 -265
  631. package/Particles/Node/Blocks/particleMathBlock.pure.js.map +1 -1
  632. package/Particles/Node/Blocks/particleNumberMathBlock.pure.js +155 -142
  633. package/Particles/Node/Blocks/particleNumberMathBlock.pure.js.map +1 -1
  634. package/Particles/Node/Blocks/particleRandomBlock.pure.js +156 -143
  635. package/Particles/Node/Blocks/particleRandomBlock.pure.js.map +1 -1
  636. package/Particles/Node/Blocks/particleTrigonometryBlock.pure.js +217 -204
  637. package/Particles/Node/Blocks/particleTrigonometryBlock.pure.js.map +1 -1
  638. package/Particles/Node/Blocks/particleVectorMathBlock.pure.js +106 -93
  639. package/Particles/Node/Blocks/particleVectorMathBlock.pure.js.map +1 -1
  640. package/Particles/Node/Blocks/systemBlock.pure.js +366 -330
  641. package/Particles/Node/Blocks/systemBlock.pure.js.map +1 -1
  642. package/Particles/Node/nodeParticleBlock.js +339 -324
  643. package/Particles/Node/nodeParticleBlock.js.map +1 -1
  644. package/Particles/Node/nodeParticleSystemSet.js +494 -473
  645. package/Particles/Node/nodeParticleSystemSet.js.map +1 -1
  646. package/Particles/gpuParticleSystem.d.ts +0 -1
  647. package/Particles/gpuParticleSystem.js +0 -1
  648. package/Particles/gpuParticleSystem.js.map +1 -1
  649. package/Particles/gpuParticleSystem.pure.d.ts +4 -3
  650. package/Particles/gpuParticleSystem.pure.js +27 -16
  651. package/Particles/gpuParticleSystem.pure.js.map +1 -1
  652. package/Particles/particleSystem.pure.js +57 -2
  653. package/Particles/particleSystem.pure.js.map +1 -1
  654. package/Particles/thinParticleSystem.d.ts +0 -1
  655. package/Particles/thinParticleSystem.js +0 -1
  656. package/Particles/thinParticleSystem.js.map +1 -1
  657. package/Particles/thinParticleSystem.pure.js +2 -0
  658. package/Particles/thinParticleSystem.pure.js.map +1 -1
  659. package/Particles/webgl2ParticleSystem.pure.js +2 -0
  660. package/Particles/webgl2ParticleSystem.pure.js.map +1 -1
  661. package/Physics/v1/physicsImpostor.pure.js +4 -4
  662. package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.pure.js +675 -656
  663. package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.pure.js.map +1 -1
  664. package/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.d.ts +0 -1
  665. package/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.js +0 -1
  666. package/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.js.map +1 -1
  667. package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.pure.js +521 -486
  668. package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.pure.js.map +1 -1
  669. package/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.d.ts +0 -1
  670. package/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.js +0 -1
  671. package/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.js.map +1 -1
  672. package/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.pure.js +241 -220
  673. package/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.pure.js.map +1 -1
  674. package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.pure.js +852 -835
  675. package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.pure.js.map +1 -1
  676. package/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.pure.js +1135 -1073
  677. package/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.pure.js.map +1 -1
  678. package/PostProcesses/RenderPipeline/Pipelines/taaRenderingPipeline.pure.js +319 -303
  679. package/PostProcesses/RenderPipeline/Pipelines/taaRenderingPipeline.pure.js.map +1 -1
  680. package/PostProcesses/RenderPipeline/postProcessRenderPipeline.js +212 -199
  681. package/PostProcesses/RenderPipeline/postProcessRenderPipeline.js.map +1 -1
  682. package/PostProcesses/blackAndWhitePostProcess.pure.js +67 -55
  683. package/PostProcesses/blackAndWhitePostProcess.pure.js.map +1 -1
  684. package/PostProcesses/bloomMergePostProcess.pure.js +74 -62
  685. package/PostProcesses/bloomMergePostProcess.pure.js.map +1 -1
  686. package/PostProcesses/blurPostProcess.pure.js +127 -115
  687. package/PostProcesses/blurPostProcess.pure.js.map +1 -1
  688. package/PostProcesses/chromaticAberrationPostProcess.pure.js +130 -118
  689. package/PostProcesses/chromaticAberrationPostProcess.pure.js.map +1 -1
  690. package/PostProcesses/circleOfConfusionPostProcess.pure.js +115 -104
  691. package/PostProcesses/circleOfConfusionPostProcess.pure.js.map +1 -1
  692. package/PostProcesses/colorCorrectionPostProcess.pure.js +55 -43
  693. package/PostProcesses/colorCorrectionPostProcess.pure.js.map +1 -1
  694. package/PostProcesses/convolutionPostProcess.pure.js +96 -84
  695. package/PostProcesses/convolutionPostProcess.pure.js.map +1 -1
  696. package/PostProcesses/extractHighlightsPostProcess.pure.js +68 -57
  697. package/PostProcesses/extractHighlightsPostProcess.pure.js.map +1 -1
  698. package/PostProcesses/filterPostProcess.pure.js +66 -54
  699. package/PostProcesses/filterPostProcess.pure.js.map +1 -1
  700. package/PostProcesses/fxaaPostProcess.pure.js.map +1 -1
  701. package/PostProcesses/grainPostProcess.pure.js +82 -70
  702. package/PostProcesses/grainPostProcess.pure.js.map +1 -1
  703. package/PostProcesses/imageProcessingPostProcess.js +334 -322
  704. package/PostProcesses/imageProcessingPostProcess.js.map +1 -1
  705. package/PostProcesses/motionBlurPostProcess.pure.js +246 -235
  706. package/PostProcesses/motionBlurPostProcess.pure.js.map +1 -1
  707. package/PostProcesses/passPostProcess.pure.js +75 -63
  708. package/PostProcesses/passPostProcess.pure.js.map +1 -1
  709. package/PostProcesses/postProcess.pure.js +899 -835
  710. package/PostProcesses/postProcess.pure.js.map +1 -1
  711. package/PostProcesses/refractionPostProcess.pure.js +114 -87
  712. package/PostProcesses/refractionPostProcess.pure.js.map +1 -1
  713. package/PostProcesses/screenSpaceCurvaturePostProcess.pure.js +108 -96
  714. package/PostProcesses/screenSpaceCurvaturePostProcess.pure.js.map +1 -1
  715. package/PostProcesses/screenSpaceReflectionPostProcess.pure.js +241 -220
  716. package/PostProcesses/screenSpaceReflectionPostProcess.pure.js.map +1 -1
  717. package/PostProcesses/sharpenPostProcess.pure.js +86 -74
  718. package/PostProcesses/sharpenPostProcess.pure.js.map +1 -1
  719. package/PostProcesses/tonemapPostProcess.pure.js +82 -70
  720. package/PostProcesses/tonemapPostProcess.pure.js.map +1 -1
  721. package/PostProcesses/volumetricLightScatteringPostProcess.pure.js +500 -465
  722. package/PostProcesses/volumetricLightScatteringPostProcess.pure.js.map +1 -1
  723. package/PostProcesses/vrMultiviewToSingleviewPostProcess.d.ts +0 -1
  724. package/PostProcesses/vrMultiviewToSingleviewPostProcess.js +0 -1
  725. package/PostProcesses/vrMultiviewToSingleviewPostProcess.js.map +1 -1
  726. package/PostProcesses/vrMultiviewToSingleviewPostProcess.pure.js +2 -0
  727. package/PostProcesses/vrMultiviewToSingleviewPostProcess.pure.js.map +1 -1
  728. package/Probes/reflectionProbe.pure.js +238 -224
  729. package/Probes/reflectionProbe.pure.js.map +1 -1
  730. package/Rendering/GlobalIllumination/giRSMManager.pure.d.ts +1 -1
  731. package/Rendering/GlobalIllumination/giRSMManager.pure.js +138 -105
  732. package/Rendering/GlobalIllumination/giRSMManager.pure.js.map +1 -1
  733. package/Rendering/IBLShadows/iblShadowsPluginMaterial.pure.d.ts +1 -1
  734. package/Rendering/IBLShadows/iblShadowsPluginMaterial.pure.js +155 -138
  735. package/Rendering/IBLShadows/iblShadowsPluginMaterial.pure.js.map +1 -1
  736. package/Rendering/IBLShadows/iblShadowsRenderPipeline.d.ts +0 -2
  737. package/Rendering/IBLShadows/iblShadowsRenderPipeline.js +0 -2
  738. package/Rendering/IBLShadows/iblShadowsRenderPipeline.js.map +1 -1
  739. package/Rendering/IBLShadows/iblShadowsRenderPipeline.pure.js +5 -0
  740. package/Rendering/IBLShadows/iblShadowsRenderPipeline.pure.js.map +1 -1
  741. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.d.ts +0 -1
  742. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js +0 -1
  743. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js.map +1 -1
  744. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.pure.d.ts +1 -0
  745. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.pure.js +34 -0
  746. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.pure.js.map +1 -1
  747. package/Rendering/edgesRenderer.pure.js.map +1 -1
  748. package/Rendering/prePassRenderer.d.ts +0 -2
  749. package/Rendering/prePassRenderer.js +0 -2
  750. package/Rendering/prePassRenderer.js.map +1 -1
  751. package/Rendering/prePassRenderer.pure.js +2 -0
  752. package/Rendering/prePassRenderer.pure.js.map +1 -1
  753. package/Rendering/reflectiveShadowMap.pure.d.ts +1 -1
  754. package/Rendering/reflectiveShadowMap.pure.js +151 -130
  755. package/Rendering/reflectiveShadowMap.pure.js.map +1 -1
  756. package/Rendering/thinDepthPeelingRenderer.d.ts +0 -1
  757. package/Rendering/thinDepthPeelingRenderer.js +0 -1
  758. package/Rendering/thinDepthPeelingRenderer.js.map +1 -1
  759. package/Shaders/ShadersInclude/gaussianSplatting.js +1 -0
  760. package/Shaders/ShadersInclude/gaussianSplatting.js.map +1 -1
  761. package/Shaders/ShadersInclude/openpbrEnvironmentLighting.js +35 -5
  762. package/Shaders/ShadersInclude/openpbrEnvironmentLighting.js.map +1 -1
  763. package/Shaders/gaussianSplatting.fragment.js +17 -1
  764. package/Shaders/gaussianSplatting.fragment.js.map +1 -1
  765. package/Shaders/gaussianSplatting.vertex.js +1 -1
  766. package/Shaders/gaussianSplatting.vertex.js.map +1 -1
  767. package/Shaders/gaussianSplattingDepth.vertex.js +1 -1
  768. package/Shaders/gaussianSplattingDepth.vertex.js.map +1 -1
  769. package/Shaders/picking.fragment.js +39 -3
  770. package/Shaders/picking.fragment.js.map +1 -1
  771. package/ShadersWGSL/ShadersInclude/gaussianSplatting.js +3 -1
  772. package/ShadersWGSL/ShadersInclude/gaussianSplatting.js.map +1 -1
  773. package/ShadersWGSL/ShadersInclude/helperFunctions.js +2 -2
  774. package/ShadersWGSL/ShadersInclude/helperFunctions.js.map +1 -1
  775. package/ShadersWGSL/ShadersInclude/openpbrEnvironmentLighting.js +39 -7
  776. package/ShadersWGSL/ShadersInclude/openpbrEnvironmentLighting.js.map +1 -1
  777. package/ShadersWGSL/ShadersInclude/openpbrIblFunctions.js +4 -3
  778. package/ShadersWGSL/ShadersInclude/openpbrIblFunctions.js.map +1 -1
  779. package/ShadersWGSL/gaussianSplatting.fragment.js +14 -1
  780. package/ShadersWGSL/gaussianSplatting.fragment.js.map +1 -1
  781. package/ShadersWGSL/gaussianSplatting.vertex.js +2 -2
  782. package/ShadersWGSL/gaussianSplatting.vertex.js.map +1 -1
  783. package/ShadersWGSL/gaussianSplattingDepth.vertex.js +2 -2
  784. package/ShadersWGSL/gaussianSplattingDepth.vertex.js.map +1 -1
  785. package/ShadersWGSL/lightingVolume.compute.js +2 -2
  786. package/ShadersWGSL/lightingVolume.compute.js.map +1 -1
  787. package/ShadersWGSL/picking.fragment.js +22 -1
  788. package/ShadersWGSL/picking.fragment.js.map +1 -1
  789. package/XR/features/Layers/WebXRCompositionLayer.d.ts +3 -2
  790. package/XR/features/Layers/WebXRCompositionLayer.js +2 -2
  791. package/XR/features/Layers/WebXRCompositionLayer.js.map +1 -1
  792. package/XR/features/Layers/WebXRWebGPUCompositionLayer.d.ts +59 -0
  793. package/XR/features/Layers/WebXRWebGPUCompositionLayer.js +120 -0
  794. package/XR/features/Layers/WebXRWebGPUCompositionLayer.js.map +1 -0
  795. package/XR/features/Layers/WebXRWebGPUProjectionLayer.d.ts +25 -0
  796. package/XR/features/Layers/WebXRWebGPUProjectionLayer.js +69 -0
  797. package/XR/features/Layers/WebXRWebGPUProjectionLayer.js.map +1 -0
  798. package/XR/features/WebXRLayers.pure.d.ts +8 -0
  799. package/XR/features/WebXRLayers.pure.js +43 -6
  800. package/XR/features/WebXRLayers.pure.js.map +1 -1
  801. package/XR/native/nativeXRRenderTarget.d.ts +2 -2
  802. package/XR/native/nativeXRRenderTarget.js +2 -2
  803. package/XR/native/nativeXRRenderTarget.js.map +1 -1
  804. package/XR/webXRExperienceHelper.js +10 -1
  805. package/XR/webXRExperienceHelper.js.map +1 -1
  806. package/XR/webXRGraphicsBinding.d.ts +90 -0
  807. package/XR/webXRGraphicsBinding.js +85 -0
  808. package/XR/webXRGraphicsBinding.js.map +1 -0
  809. package/XR/webXRLayerRenderTargetTexture.d.ts +24 -0
  810. package/XR/webXRLayerRenderTargetTexture.js +30 -0
  811. package/XR/webXRLayerRenderTargetTexture.js.map +1 -0
  812. package/XR/webXRManagedOutputCanvas.d.ts +14 -0
  813. package/XR/webXRManagedOutputCanvas.js +24 -5
  814. package/XR/webXRManagedOutputCanvas.js.map +1 -1
  815. package/XR/webXRRenderTargetTextureProvider.d.ts +25 -4
  816. package/XR/webXRRenderTargetTextureProvider.js +33 -35
  817. package/XR/webXRRenderTargetTextureProvider.js.map +1 -1
  818. package/XR/webXRSessionManager.d.ts +11 -0
  819. package/XR/webXRSessionManager.js +37 -0
  820. package/XR/webXRSessionManager.js.map +1 -1
  821. package/XR/webXRTypes.d.ts +9 -6
  822. package/XR/webXRTypes.js.map +1 -1
  823. package/XR/webXRWebGLLayer.d.ts +2 -2
  824. package/XR/webXRWebGLLayer.js +2 -2
  825. package/XR/webXRWebGLLayer.js.map +1 -1
  826. package/XR/webXRWebGLRenderTargetTextureProvider.d.ts +12 -0
  827. package/XR/webXRWebGLRenderTargetTextureProvider.js +58 -0
  828. package/XR/webXRWebGLRenderTargetTextureProvider.js.map +1 -0
  829. package/XR/webXRWebGPURenderTargetTextureProvider.d.ts +69 -0
  830. package/XR/webXRWebGPURenderTargetTextureProvider.js +148 -0
  831. package/XR/webXRWebGPURenderTargetTextureProvider.js.map +1 -0
  832. package/index.d.ts +1 -0
  833. package/index.js +1 -0
  834. package/index.js.map +1 -1
  835. package/node.js +878 -845
  836. package/node.js.map +1 -1
  837. package/package.json +8 -14
  838. package/scene.pure.d.ts +12 -0
  839. package/scene.pure.js +36 -0
  840. package/scene.pure.js.map +1 -1
  841. package/tslib.es6.js +304 -150
@@ -1,4 +1,4 @@
1
- import { __decorate } from "../tslib.es6.js";
1
+ import { __esDecorate, __runInitializers } from "../tslib.es6.js";
2
2
  import { Vector3, Vector4, TmpVectors } from "../Maths/math.vector.pure.js";
3
3
  import { VertexBuffer, VertexBufferDeduceStride } from "../Buffers/buffer.pure.js";
4
4
  import { _WarnImport } from "../Misc/devTools.js";
@@ -14,1707 +14,1717 @@ export class VertexDataMaterialInfo {
14
14
  /**
15
15
  * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
16
16
  */
17
- export class VertexData {
18
- /**
19
- * Creates a new VertexData
20
- */
21
- constructor() {
22
- /**
23
- * Gets the unique ID of this vertex Data
24
- */
25
- this.uniqueId = 0;
26
- /**
27
- * Metadata used to store contextual values
28
- */
29
- this.metadata = {};
30
- this._applyTo = makeSyncFunction(this._applyToCoroutine.bind(this));
31
- this.uniqueId = VertexData._UniqueIdGenerator;
32
- VertexData._UniqueIdGenerator++;
33
- }
34
- /**
35
- * Uses the passed data array to set the set the values for the specified kind of data
36
- * @param data a linear array of floating numbers
37
- * @param kind the type of data that is being set, eg positions, colors etc
38
- */
39
- set(data, kind) {
40
- if (!data.length) {
41
- Logger.Warn(`Setting vertex data kind '${kind}' with an empty array`);
42
- }
43
- switch (kind) {
44
- case VertexBuffer.PositionKind:
45
- this.positions = data;
46
- break;
47
- case VertexBuffer.NormalKind:
48
- this.normals = data;
49
- break;
50
- case VertexBuffer.TangentKind:
51
- this.tangents = data;
52
- break;
53
- case VertexBuffer.UVKind:
54
- this.uvs = data;
55
- break;
56
- case VertexBuffer.UV2Kind:
57
- this.uvs2 = data;
58
- break;
59
- case VertexBuffer.UV3Kind:
60
- this.uvs3 = data;
61
- break;
62
- case VertexBuffer.UV4Kind:
63
- this.uvs4 = data;
64
- break;
65
- case VertexBuffer.UV5Kind:
66
- this.uvs5 = data;
67
- break;
68
- case VertexBuffer.UV6Kind:
69
- this.uvs6 = data;
70
- break;
71
- case VertexBuffer.ColorKind:
72
- this.colors = data;
73
- break;
74
- case VertexBuffer.MatricesIndicesKind:
75
- this.matricesIndices = data;
76
- break;
77
- case VertexBuffer.MatricesWeightsKind:
78
- this.matricesWeights = data;
79
- break;
80
- case VertexBuffer.MatricesIndicesExtraKind:
81
- this.matricesIndicesExtra = data;
82
- break;
83
- case VertexBuffer.MatricesWeightsExtraKind:
84
- this.matricesWeightsExtra = data;
85
- break;
86
- }
87
- }
88
- /**
89
- * Associates the vertexData to the passed Mesh.
90
- * Sets it as updatable or not (default `false`)
91
- * @param mesh the mesh the vertexData is applied to
92
- * @param updatable when used and having the value true allows new data to update the vertexData
93
- * @returns the VertexData
94
- */
95
- applyToMesh(mesh, updatable) {
96
- this._applyTo(mesh, updatable, false);
97
- return this;
98
- }
99
- /**
100
- * Associates the vertexData to the passed Geometry.
101
- * Sets it as updatable or not (default `false`)
102
- * @param geometry the geometry the vertexData is applied to
103
- * @param updatable when used and having the value true allows new data to update the vertexData
104
- * @returns VertexData
105
- */
106
- applyToGeometry(geometry, updatable) {
107
- this._applyTo(geometry, updatable, false);
108
- return this;
109
- }
110
- /**
111
- * Updates the associated mesh
112
- * @param mesh the mesh to be updated
113
- * @returns VertexData
114
- */
115
- updateMesh(mesh) {
116
- this._update(mesh);
117
- return this;
118
- }
119
- /**
120
- * Updates the associated geometry
121
- * @param geometry the geometry to be updated
122
- * @returns VertexData.
123
- */
124
- updateGeometry(geometry) {
125
- this._update(geometry);
126
- return this;
127
- }
128
- /**
129
- * @internal
130
- */
131
- *_applyToCoroutine(meshOrGeometry, updatable = false, isAsync) {
132
- if (this.positions) {
133
- meshOrGeometry.setVerticesData(VertexBuffer.PositionKind, this.positions, updatable);
134
- if (isAsync) {
135
- yield;
136
- }
137
- }
138
- if (this.normals) {
139
- meshOrGeometry.setVerticesData(VertexBuffer.NormalKind, this.normals, updatable);
140
- if (isAsync) {
141
- yield;
142
- }
143
- }
144
- if (this.tangents) {
145
- meshOrGeometry.setVerticesData(VertexBuffer.TangentKind, this.tangents, updatable);
146
- if (isAsync) {
147
- yield;
148
- }
149
- }
150
- if (this.uvs) {
151
- meshOrGeometry.setVerticesData(VertexBuffer.UVKind, this.uvs, updatable);
152
- if (isAsync) {
153
- yield;
154
- }
155
- }
156
- if (this.uvs2) {
157
- meshOrGeometry.setVerticesData(VertexBuffer.UV2Kind, this.uvs2, updatable);
158
- if (isAsync) {
159
- yield;
160
- }
161
- }
162
- if (this.uvs3) {
163
- meshOrGeometry.setVerticesData(VertexBuffer.UV3Kind, this.uvs3, updatable);
164
- if (isAsync) {
165
- yield;
166
- }
167
- }
168
- if (this.uvs4) {
169
- meshOrGeometry.setVerticesData(VertexBuffer.UV4Kind, this.uvs4, updatable);
170
- if (isAsync) {
171
- yield;
172
- }
173
- }
174
- if (this.uvs5) {
175
- meshOrGeometry.setVerticesData(VertexBuffer.UV5Kind, this.uvs5, updatable);
176
- if (isAsync) {
177
- yield;
178
- }
179
- }
180
- if (this.uvs6) {
181
- meshOrGeometry.setVerticesData(VertexBuffer.UV6Kind, this.uvs6, updatable);
182
- if (isAsync) {
183
- yield;
184
- }
185
- }
186
- if (this.colors) {
187
- const stride = this.positions && this.colors.length === this.positions.length ? 3 : 4;
188
- meshOrGeometry.setVerticesData(VertexBuffer.ColorKind, this.colors, updatable, stride);
189
- if (this.hasVertexAlpha && meshOrGeometry.hasVertexAlpha !== undefined) {
190
- meshOrGeometry.hasVertexAlpha = true;
191
- }
192
- if (isAsync) {
193
- yield;
194
- }
195
- }
196
- if (this.matricesIndices) {
197
- meshOrGeometry.setVerticesData(VertexBuffer.MatricesIndicesKind, this.matricesIndices, updatable);
198
- if (isAsync) {
199
- yield;
200
- }
201
- }
202
- if (this.matricesWeights) {
203
- meshOrGeometry.setVerticesData(VertexBuffer.MatricesWeightsKind, this.matricesWeights, updatable);
204
- if (isAsync) {
205
- yield;
206
- }
207
- }
208
- if (this.matricesIndicesExtra) {
209
- meshOrGeometry.setVerticesData(VertexBuffer.MatricesIndicesExtraKind, this.matricesIndicesExtra, updatable);
210
- if (isAsync) {
211
- yield;
212
- }
213
- }
214
- if (this.matricesWeightsExtra) {
215
- meshOrGeometry.setVerticesData(VertexBuffer.MatricesWeightsExtraKind, this.matricesWeightsExtra, updatable);
216
- if (isAsync) {
217
- yield;
218
- }
219
- }
220
- if (this.indices) {
221
- meshOrGeometry.setIndices(this.indices, null, updatable);
222
- if (isAsync) {
223
- yield;
224
- }
225
- }
226
- else {
227
- meshOrGeometry.setIndices([], null);
228
- }
229
- if (meshOrGeometry.subMeshes && this.materialInfos && this.materialInfos.length > 1) {
230
- const mesh = meshOrGeometry;
231
- mesh.subMeshes = [];
232
- for (const matInfo of this.materialInfos) {
233
- new SubMesh(matInfo.materialIndex, matInfo.verticesStart, matInfo.verticesCount, matInfo.indexStart, matInfo.indexCount, mesh);
234
- }
235
- }
236
- return this;
237
- }
238
- _update(meshOrGeometry, updateExtends, makeItUnique) {
239
- if (this.positions) {
240
- meshOrGeometry.updateVerticesData(VertexBuffer.PositionKind, this.positions, updateExtends, makeItUnique);
241
- }
242
- if (this.normals) {
243
- meshOrGeometry.updateVerticesData(VertexBuffer.NormalKind, this.normals, updateExtends, makeItUnique);
244
- }
245
- if (this.tangents) {
246
- meshOrGeometry.updateVerticesData(VertexBuffer.TangentKind, this.tangents, updateExtends, makeItUnique);
247
- }
248
- if (this.uvs) {
249
- meshOrGeometry.updateVerticesData(VertexBuffer.UVKind, this.uvs, updateExtends, makeItUnique);
250
- }
251
- if (this.uvs2) {
252
- meshOrGeometry.updateVerticesData(VertexBuffer.UV2Kind, this.uvs2, updateExtends, makeItUnique);
253
- }
254
- if (this.uvs3) {
255
- meshOrGeometry.updateVerticesData(VertexBuffer.UV3Kind, this.uvs3, updateExtends, makeItUnique);
256
- }
257
- if (this.uvs4) {
258
- meshOrGeometry.updateVerticesData(VertexBuffer.UV4Kind, this.uvs4, updateExtends, makeItUnique);
259
- }
260
- if (this.uvs5) {
261
- meshOrGeometry.updateVerticesData(VertexBuffer.UV5Kind, this.uvs5, updateExtends, makeItUnique);
262
- }
263
- if (this.uvs6) {
264
- meshOrGeometry.updateVerticesData(VertexBuffer.UV6Kind, this.uvs6, updateExtends, makeItUnique);
265
- }
266
- if (this.colors) {
267
- meshOrGeometry.updateVerticesData(VertexBuffer.ColorKind, this.colors, updateExtends, makeItUnique);
268
- }
269
- if (this.matricesIndices) {
270
- meshOrGeometry.updateVerticesData(VertexBuffer.MatricesIndicesKind, this.matricesIndices, updateExtends, makeItUnique);
271
- }
272
- if (this.matricesWeights) {
273
- meshOrGeometry.updateVerticesData(VertexBuffer.MatricesWeightsKind, this.matricesWeights, updateExtends, makeItUnique);
274
- }
275
- if (this.matricesIndicesExtra) {
276
- meshOrGeometry.updateVerticesData(VertexBuffer.MatricesIndicesExtraKind, this.matricesIndicesExtra, updateExtends, makeItUnique);
277
- }
278
- if (this.matricesWeightsExtra) {
279
- meshOrGeometry.updateVerticesData(VertexBuffer.MatricesWeightsExtraKind, this.matricesWeightsExtra, updateExtends, makeItUnique);
280
- }
281
- if (this.indices) {
282
- meshOrGeometry.setIndices(this.indices, null);
283
- }
284
- return this;
285
- }
286
- static _TransformVector3Coordinates(coordinates, transformation, offset = 0, length = coordinates.length) {
287
- const coordinate = TmpVectors.Vector3[0];
288
- const transformedCoordinate = TmpVectors.Vector3[1];
289
- for (let index = offset; index < offset + length; index += 3) {
290
- Vector3.FromArrayToRef(coordinates, index, coordinate);
291
- Vector3.TransformCoordinatesToRef(coordinate, transformation, transformedCoordinate);
292
- coordinates[index] = transformedCoordinate.x;
293
- coordinates[index + 1] = transformedCoordinate.y;
294
- coordinates[index + 2] = transformedCoordinate.z;
295
- }
296
- }
297
- static _TransformVector3Normals(normals, transformation, offset = 0, length = normals.length) {
298
- const normal = TmpVectors.Vector3[0];
299
- const transformedNormal = TmpVectors.Vector3[1];
300
- for (let index = offset; index < offset + length; index += 3) {
301
- Vector3.FromArrayToRef(normals, index, normal);
302
- Vector3.TransformNormalToRef(normal, transformation, transformedNormal);
303
- normals[index] = transformedNormal.x;
304
- normals[index + 1] = transformedNormal.y;
305
- normals[index + 2] = transformedNormal.z;
306
- }
307
- }
308
- static _TransformVector4Normals(normals, transformation, offset = 0, length = normals.length) {
309
- const normal = TmpVectors.Vector4[0];
310
- const transformedNormal = TmpVectors.Vector4[1];
311
- for (let index = offset; index < offset + length; index += 4) {
312
- Vector4.FromArrayToRef(normals, index, normal);
313
- Vector4.TransformNormalToRef(normal, transformation, transformedNormal);
314
- normals[index] = transformedNormal.x;
315
- normals[index + 1] = transformedNormal.y;
316
- normals[index + 2] = transformedNormal.z;
317
- normals[index + 3] = transformedNormal.w;
318
- }
319
- }
320
- static _FlipFaces(indices, offset = 0, length = indices.length) {
321
- for (let index = offset; index < offset + length; index += 3) {
322
- const tmp = indices[index + 1];
323
- indices[index + 1] = indices[index + 2];
324
- indices[index + 2] = tmp;
325
- }
326
- }
327
- /**
328
- * Transforms each position and each normal of the vertexData according to the passed Matrix
329
- * @param matrix the transforming matrix
330
- * @returns the VertexData
331
- */
332
- transform(matrix) {
333
- const flip = matrix.determinant() < 0;
334
- if (this.positions) {
335
- VertexData._TransformVector3Coordinates(this.positions, matrix);
336
- }
337
- if (this.normals) {
338
- VertexData._TransformVector3Normals(this.normals, matrix);
339
- }
340
- if (this.tangents) {
341
- VertexData._TransformVector4Normals(this.tangents, matrix);
342
- }
343
- if (flip && this.indices) {
344
- VertexData._FlipFaces(this.indices);
345
- }
346
- return this;
347
- }
348
- /**
349
- * Generates an array of vertex data where each vertex data only has one material info
350
- * @returns An array of VertexData
351
- */
352
- // eslint-disable-next-line @typescript-eslint/naming-convention
353
- splitBasedOnMaterialID() {
354
- if (!this.materialInfos || this.materialInfos.length < 2) {
355
- return [this];
356
- }
357
- const result = [];
358
- for (const materialInfo of this.materialInfos) {
359
- const vertexData = new VertexData();
360
- if (this.positions) {
361
- vertexData.positions = this.positions.slice(materialInfo.verticesStart * 3, (materialInfo.verticesCount + materialInfo.verticesStart) * 3);
362
- }
363
- if (this.normals) {
364
- vertexData.normals = this.normals.slice(materialInfo.verticesStart * 3, (materialInfo.verticesCount + materialInfo.verticesStart) * 3);
365
- }
366
- if (this.tangents) {
367
- vertexData.tangents = this.tangents.slice(materialInfo.verticesStart * 4, (materialInfo.verticesCount + materialInfo.verticesStart) * 4);
368
- }
369
- if (this.colors) {
370
- vertexData.colors = this.colors.slice(materialInfo.verticesStart * 4, (materialInfo.verticesCount + materialInfo.verticesStart) * 4);
371
- }
372
- if (this.uvs) {
373
- vertexData.uvs = this.uvs.slice(materialInfo.verticesStart * 2, (materialInfo.verticesCount + materialInfo.verticesStart) * 2);
374
- }
375
- if (this.uvs2) {
376
- vertexData.uvs2 = this.uvs2.slice(materialInfo.verticesStart * 2, (materialInfo.verticesCount + materialInfo.verticesStart) * 2);
377
- }
378
- if (this.uvs3) {
379
- vertexData.uvs3 = this.uvs3.slice(materialInfo.verticesStart * 2, (materialInfo.verticesCount + materialInfo.verticesStart) * 2);
380
- }
381
- if (this.uvs4) {
382
- vertexData.uvs4 = this.uvs4.slice(materialInfo.verticesStart * 2, (materialInfo.verticesCount + materialInfo.verticesStart) * 2);
383
- }
384
- if (this.uvs5) {
385
- vertexData.uvs5 = this.uvs5.slice(materialInfo.verticesStart * 2, (materialInfo.verticesCount + materialInfo.verticesStart) * 2);
386
- }
387
- if (this.uvs6) {
388
- vertexData.uvs6 = this.uvs6.slice(materialInfo.verticesStart * 2, (materialInfo.verticesCount + materialInfo.verticesStart) * 2);
389
- }
390
- if (this.matricesIndices) {
391
- vertexData.matricesIndices = this.matricesIndices.slice(materialInfo.verticesStart * 4, (materialInfo.verticesCount + materialInfo.verticesStart) * 4);
392
- }
393
- if (this.matricesIndicesExtra) {
394
- vertexData.matricesIndicesExtra = this.matricesIndicesExtra.slice(materialInfo.verticesStart * 4, (materialInfo.verticesCount + materialInfo.verticesStart) * 4);
395
- }
396
- if (this.matricesWeights) {
397
- vertexData.matricesWeights = this.matricesWeights.slice(materialInfo.verticesStart * 4, (materialInfo.verticesCount + materialInfo.verticesStart) * 4);
17
+ let VertexData = (() => {
18
+ var _a;
19
+ let _staticExtraInitializers = [];
20
+ let _static__TransformVector3Coordinates_decorators;
21
+ let _static__TransformVector3Normals_decorators;
22
+ let _static__TransformVector4Normals_decorators;
23
+ let _static__FlipFaces_decorators;
24
+ return _a = class VertexData {
25
+ /**
26
+ * Creates a new VertexData
27
+ */
28
+ constructor() {
29
+ /**
30
+ * Gets the unique ID of this vertex Data
31
+ */
32
+ this.uniqueId = 0;
33
+ /**
34
+ * Metadata used to store contextual values
35
+ */
36
+ this.metadata = {};
37
+ this._applyTo = makeSyncFunction(this._applyToCoroutine.bind(this));
38
+ this.uniqueId = _a._UniqueIdGenerator;
39
+ _a._UniqueIdGenerator++;
40
+ }
41
+ /**
42
+ * Uses the passed data array to set the set the values for the specified kind of data
43
+ * @param data a linear array of floating numbers
44
+ * @param kind the type of data that is being set, eg positions, colors etc
45
+ */
46
+ set(data, kind) {
47
+ if (!data.length) {
48
+ Logger.Warn(`Setting vertex data kind '${kind}' with an empty array`);
49
+ }
50
+ switch (kind) {
51
+ case VertexBuffer.PositionKind:
52
+ this.positions = data;
53
+ break;
54
+ case VertexBuffer.NormalKind:
55
+ this.normals = data;
56
+ break;
57
+ case VertexBuffer.TangentKind:
58
+ this.tangents = data;
59
+ break;
60
+ case VertexBuffer.UVKind:
61
+ this.uvs = data;
62
+ break;
63
+ case VertexBuffer.UV2Kind:
64
+ this.uvs2 = data;
65
+ break;
66
+ case VertexBuffer.UV3Kind:
67
+ this.uvs3 = data;
68
+ break;
69
+ case VertexBuffer.UV4Kind:
70
+ this.uvs4 = data;
71
+ break;
72
+ case VertexBuffer.UV5Kind:
73
+ this.uvs5 = data;
74
+ break;
75
+ case VertexBuffer.UV6Kind:
76
+ this.uvs6 = data;
77
+ break;
78
+ case VertexBuffer.ColorKind:
79
+ this.colors = data;
80
+ break;
81
+ case VertexBuffer.MatricesIndicesKind:
82
+ this.matricesIndices = data;
83
+ break;
84
+ case VertexBuffer.MatricesWeightsKind:
85
+ this.matricesWeights = data;
86
+ break;
87
+ case VertexBuffer.MatricesIndicesExtraKind:
88
+ this.matricesIndicesExtra = data;
89
+ break;
90
+ case VertexBuffer.MatricesWeightsExtraKind:
91
+ this.matricesWeightsExtra = data;
92
+ break;
93
+ }
398
94
  }
399
- if (this.matricesWeightsExtra) {
400
- vertexData.matricesWeightsExtra = this.matricesWeightsExtra.slice(materialInfo.verticesStart * 4, (materialInfo.verticesCount + materialInfo.verticesStart) * 4);
95
+ /**
96
+ * Associates the vertexData to the passed Mesh.
97
+ * Sets it as updatable or not (default `false`)
98
+ * @param mesh the mesh the vertexData is applied to
99
+ * @param updatable when used and having the value true allows new data to update the vertexData
100
+ * @returns the VertexData
101
+ */
102
+ applyToMesh(mesh, updatable) {
103
+ this._applyTo(mesh, updatable, false);
104
+ return this;
105
+ }
106
+ /**
107
+ * Associates the vertexData to the passed Geometry.
108
+ * Sets it as updatable or not (default `false`)
109
+ * @param geometry the geometry the vertexData is applied to
110
+ * @param updatable when used and having the value true allows new data to update the vertexData
111
+ * @returns VertexData
112
+ */
113
+ applyToGeometry(geometry, updatable) {
114
+ this._applyTo(geometry, updatable, false);
115
+ return this;
116
+ }
117
+ /**
118
+ * Updates the associated mesh
119
+ * @param mesh the mesh to be updated
120
+ * @returns VertexData
121
+ */
122
+ updateMesh(mesh) {
123
+ this._update(mesh);
124
+ return this;
125
+ }
126
+ /**
127
+ * Updates the associated geometry
128
+ * @param geometry the geometry to be updated
129
+ * @returns VertexData.
130
+ */
131
+ updateGeometry(geometry) {
132
+ this._update(geometry);
133
+ return this;
134
+ }
135
+ /**
136
+ * @internal
137
+ */
138
+ *_applyToCoroutine(meshOrGeometry, updatable = false, isAsync) {
139
+ if (this.positions) {
140
+ meshOrGeometry.setVerticesData(VertexBuffer.PositionKind, this.positions, updatable);
141
+ if (isAsync) {
142
+ yield;
143
+ }
144
+ }
145
+ if (this.normals) {
146
+ meshOrGeometry.setVerticesData(VertexBuffer.NormalKind, this.normals, updatable);
147
+ if (isAsync) {
148
+ yield;
149
+ }
150
+ }
151
+ if (this.tangents) {
152
+ meshOrGeometry.setVerticesData(VertexBuffer.TangentKind, this.tangents, updatable);
153
+ if (isAsync) {
154
+ yield;
155
+ }
156
+ }
157
+ if (this.uvs) {
158
+ meshOrGeometry.setVerticesData(VertexBuffer.UVKind, this.uvs, updatable);
159
+ if (isAsync) {
160
+ yield;
161
+ }
162
+ }
163
+ if (this.uvs2) {
164
+ meshOrGeometry.setVerticesData(VertexBuffer.UV2Kind, this.uvs2, updatable);
165
+ if (isAsync) {
166
+ yield;
167
+ }
168
+ }
169
+ if (this.uvs3) {
170
+ meshOrGeometry.setVerticesData(VertexBuffer.UV3Kind, this.uvs3, updatable);
171
+ if (isAsync) {
172
+ yield;
173
+ }
174
+ }
175
+ if (this.uvs4) {
176
+ meshOrGeometry.setVerticesData(VertexBuffer.UV4Kind, this.uvs4, updatable);
177
+ if (isAsync) {
178
+ yield;
179
+ }
180
+ }
181
+ if (this.uvs5) {
182
+ meshOrGeometry.setVerticesData(VertexBuffer.UV5Kind, this.uvs5, updatable);
183
+ if (isAsync) {
184
+ yield;
185
+ }
186
+ }
187
+ if (this.uvs6) {
188
+ meshOrGeometry.setVerticesData(VertexBuffer.UV6Kind, this.uvs6, updatable);
189
+ if (isAsync) {
190
+ yield;
191
+ }
192
+ }
193
+ if (this.colors) {
194
+ const stride = this.positions && this.colors.length === this.positions.length ? 3 : 4;
195
+ meshOrGeometry.setVerticesData(VertexBuffer.ColorKind, this.colors, updatable, stride);
196
+ if (this.hasVertexAlpha && meshOrGeometry.hasVertexAlpha !== undefined) {
197
+ meshOrGeometry.hasVertexAlpha = true;
198
+ }
199
+ if (isAsync) {
200
+ yield;
201
+ }
202
+ }
203
+ if (this.matricesIndices) {
204
+ meshOrGeometry.setVerticesData(VertexBuffer.MatricesIndicesKind, this.matricesIndices, updatable);
205
+ if (isAsync) {
206
+ yield;
207
+ }
208
+ }
209
+ if (this.matricesWeights) {
210
+ meshOrGeometry.setVerticesData(VertexBuffer.MatricesWeightsKind, this.matricesWeights, updatable);
211
+ if (isAsync) {
212
+ yield;
213
+ }
214
+ }
215
+ if (this.matricesIndicesExtra) {
216
+ meshOrGeometry.setVerticesData(VertexBuffer.MatricesIndicesExtraKind, this.matricesIndicesExtra, updatable);
217
+ if (isAsync) {
218
+ yield;
219
+ }
220
+ }
221
+ if (this.matricesWeightsExtra) {
222
+ meshOrGeometry.setVerticesData(VertexBuffer.MatricesWeightsExtraKind, this.matricesWeightsExtra, updatable);
223
+ if (isAsync) {
224
+ yield;
225
+ }
226
+ }
227
+ if (this.indices) {
228
+ meshOrGeometry.setIndices(this.indices, null, updatable);
229
+ if (isAsync) {
230
+ yield;
231
+ }
232
+ }
233
+ else {
234
+ meshOrGeometry.setIndices([], null);
235
+ }
236
+ if (meshOrGeometry.subMeshes && this.materialInfos && this.materialInfos.length > 1) {
237
+ const mesh = meshOrGeometry;
238
+ mesh.subMeshes = [];
239
+ for (const matInfo of this.materialInfos) {
240
+ new SubMesh(matInfo.materialIndex, matInfo.verticesStart, matInfo.verticesCount, matInfo.indexStart, matInfo.indexCount, mesh);
241
+ }
242
+ }
243
+ return this;
401
244
  }
402
- if (this.indices) {
403
- vertexData.indices = [];
404
- for (let index = materialInfo.indexStart; index < materialInfo.indexStart + materialInfo.indexCount; index++) {
405
- vertexData.indices.push(this.indices[index] - materialInfo.verticesStart);
245
+ _update(meshOrGeometry, updateExtends, makeItUnique) {
246
+ if (this.positions) {
247
+ meshOrGeometry.updateVerticesData(VertexBuffer.PositionKind, this.positions, updateExtends, makeItUnique);
248
+ }
249
+ if (this.normals) {
250
+ meshOrGeometry.updateVerticesData(VertexBuffer.NormalKind, this.normals, updateExtends, makeItUnique);
251
+ }
252
+ if (this.tangents) {
253
+ meshOrGeometry.updateVerticesData(VertexBuffer.TangentKind, this.tangents, updateExtends, makeItUnique);
254
+ }
255
+ if (this.uvs) {
256
+ meshOrGeometry.updateVerticesData(VertexBuffer.UVKind, this.uvs, updateExtends, makeItUnique);
257
+ }
258
+ if (this.uvs2) {
259
+ meshOrGeometry.updateVerticesData(VertexBuffer.UV2Kind, this.uvs2, updateExtends, makeItUnique);
260
+ }
261
+ if (this.uvs3) {
262
+ meshOrGeometry.updateVerticesData(VertexBuffer.UV3Kind, this.uvs3, updateExtends, makeItUnique);
263
+ }
264
+ if (this.uvs4) {
265
+ meshOrGeometry.updateVerticesData(VertexBuffer.UV4Kind, this.uvs4, updateExtends, makeItUnique);
266
+ }
267
+ if (this.uvs5) {
268
+ meshOrGeometry.updateVerticesData(VertexBuffer.UV5Kind, this.uvs5, updateExtends, makeItUnique);
269
+ }
270
+ if (this.uvs6) {
271
+ meshOrGeometry.updateVerticesData(VertexBuffer.UV6Kind, this.uvs6, updateExtends, makeItUnique);
272
+ }
273
+ if (this.colors) {
274
+ meshOrGeometry.updateVerticesData(VertexBuffer.ColorKind, this.colors, updateExtends, makeItUnique);
275
+ }
276
+ if (this.matricesIndices) {
277
+ meshOrGeometry.updateVerticesData(VertexBuffer.MatricesIndicesKind, this.matricesIndices, updateExtends, makeItUnique);
278
+ }
279
+ if (this.matricesWeights) {
280
+ meshOrGeometry.updateVerticesData(VertexBuffer.MatricesWeightsKind, this.matricesWeights, updateExtends, makeItUnique);
281
+ }
282
+ if (this.matricesIndicesExtra) {
283
+ meshOrGeometry.updateVerticesData(VertexBuffer.MatricesIndicesExtraKind, this.matricesIndicesExtra, updateExtends, makeItUnique);
284
+ }
285
+ if (this.matricesWeightsExtra) {
286
+ meshOrGeometry.updateVerticesData(VertexBuffer.MatricesWeightsExtraKind, this.matricesWeightsExtra, updateExtends, makeItUnique);
287
+ }
288
+ if (this.indices) {
289
+ meshOrGeometry.setIndices(this.indices, null);
290
+ }
291
+ return this;
292
+ }
293
+ static _TransformVector3Coordinates(coordinates, transformation, offset = 0, length = coordinates.length) {
294
+ const coordinate = TmpVectors.Vector3[0];
295
+ const transformedCoordinate = TmpVectors.Vector3[1];
296
+ for (let index = offset; index < offset + length; index += 3) {
297
+ Vector3.FromArrayToRef(coordinates, index, coordinate);
298
+ Vector3.TransformCoordinatesToRef(coordinate, transformation, transformedCoordinate);
299
+ coordinates[index] = transformedCoordinate.x;
300
+ coordinates[index + 1] = transformedCoordinate.y;
301
+ coordinates[index + 2] = transformedCoordinate.z;
406
302
  }
407
303
  }
408
- const newMaterialInfo = new VertexDataMaterialInfo();
409
- newMaterialInfo.indexStart = 0;
410
- newMaterialInfo.indexCount = vertexData.indices ? vertexData.indices.length : 0;
411
- newMaterialInfo.materialIndex = materialInfo.materialIndex;
412
- newMaterialInfo.verticesStart = 0;
413
- newMaterialInfo.verticesCount = (vertexData.positions ? vertexData.positions.length : 0) / 3;
414
- vertexData.materialInfos = [newMaterialInfo];
415
- result.push(vertexData);
416
- }
417
- return result;
418
- }
419
- /**
420
- * Merges the passed VertexData into the current one
421
- * @param others the VertexData to be merged into the current one
422
- * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
423
- * @param forceCloneIndices defines a boolean indicating if indices are forced to be cloned
424
- * @param mergeMaterialIds defines a boolean indicating if we need to merge the material infos
425
- * @param enableCompletion defines a boolean indicating if the vertex data should be completed to be compatible
426
- * @returns the modified VertexData
427
- */
428
- merge(others, use32BitsIndices = false, forceCloneIndices = false, mergeMaterialIds = false, enableCompletion = false) {
429
- const vertexDatas = Array.isArray(others)
430
- ? others.map((other) => {
431
- return { vertexData: other };
432
- })
433
- : [{ vertexData: others }];
434
- return runCoroutineSync(this._mergeCoroutine(undefined, vertexDatas, use32BitsIndices, false, forceCloneIndices, mergeMaterialIds, enableCompletion));
435
- }
436
- /**
437
- * @internal
438
- */
439
- *_mergeCoroutine(transform, vertexDatas, use32BitsIndices = false, isAsync, forceCloneIndices, mergeMaterialIds = false, enableCompletion = false) {
440
- this._validate();
441
- let others = vertexDatas.map((vertexData) => vertexData.vertexData);
442
- // eslint-disable-next-line @typescript-eslint/no-this-alias
443
- let root = this;
444
- if (enableCompletion) {
445
- // First let's make sure we have the max set of attributes on the main vertex data
446
- for (const other of others) {
447
- if (!other) {
448
- continue;
449
- }
450
- other._validate();
451
- if (!this.normals && other.normals) {
452
- this.normals = new Float32Array(this.positions.length);
453
- }
454
- if (!this.tangents && other.tangents) {
455
- this.tangents = new Float32Array((this.positions.length / 3) * 4);
456
- }
457
- if (!this.uvs && other.uvs) {
458
- this.uvs = new Float32Array((this.positions.length / 3) * 2);
459
- }
460
- if (!this.uvs2 && other.uvs2) {
461
- this.uvs2 = new Float32Array((this.positions.length / 3) * 2);
462
- }
463
- if (!this.uvs3 && other.uvs3) {
464
- this.uvs3 = new Float32Array((this.positions.length / 3) * 2);
465
- }
466
- if (!this.uvs4 && other.uvs4) {
467
- this.uvs4 = new Float32Array((this.positions.length / 3) * 2);
468
- }
469
- if (!this.uvs5 && other.uvs5) {
470
- this.uvs5 = new Float32Array((this.positions.length / 3) * 2);
471
- }
472
- if (!this.uvs6 && other.uvs6) {
473
- this.uvs6 = new Float32Array((this.positions.length / 3) * 2);
474
- }
475
- if (!this.colors && other.colors) {
476
- this.colors = new Float32Array((this.positions.length / 3) * 4);
477
- this.colors.fill(1); // Set to white by default
478
- }
479
- if (!this.matricesIndices && other.matricesIndices) {
480
- this.matricesIndices = new Float32Array((this.positions.length / 3) * 4);
481
- }
482
- if (!this.matricesWeights && other.matricesWeights) {
483
- this.matricesWeights = new Float32Array((this.positions.length / 3) * 4);
484
- }
485
- if (!this.matricesIndicesExtra && other.matricesIndicesExtra) {
486
- this.matricesIndicesExtra = new Float32Array((this.positions.length / 3) * 4);
487
- }
488
- if (!this.matricesWeightsExtra && other.matricesWeightsExtra) {
489
- this.matricesWeightsExtra = new Float32Array((this.positions.length / 3) * 4);
304
+ static _TransformVector3Normals(normals, transformation, offset = 0, length = normals.length) {
305
+ const normal = TmpVectors.Vector3[0];
306
+ const transformedNormal = TmpVectors.Vector3[1];
307
+ for (let index = offset; index < offset + length; index += 3) {
308
+ Vector3.FromArrayToRef(normals, index, normal);
309
+ Vector3.TransformNormalToRef(normal, transformation, transformedNormal);
310
+ normals[index] = transformedNormal.x;
311
+ normals[index + 1] = transformedNormal.y;
312
+ normals[index + 2] = transformedNormal.z;
490
313
  }
491
314
  }
492
- }
493
- for (const other of others) {
494
- if (!other) {
495
- continue;
315
+ static _TransformVector4Normals(normals, transformation, offset = 0, length = normals.length) {
316
+ const normal = TmpVectors.Vector4[0];
317
+ const transformedNormal = TmpVectors.Vector4[1];
318
+ for (let index = offset; index < offset + length; index += 4) {
319
+ Vector4.FromArrayToRef(normals, index, normal);
320
+ Vector4.TransformNormalToRef(normal, transformation, transformedNormal);
321
+ normals[index] = transformedNormal.x;
322
+ normals[index + 1] = transformedNormal.y;
323
+ normals[index + 2] = transformedNormal.z;
324
+ normals[index + 3] = transformedNormal.w;
325
+ }
496
326
  }
497
- if (!enableCompletion) {
498
- other._validate();
499
- if (!this.normals !== !other.normals ||
500
- !this.tangents !== !other.tangents ||
501
- !this.uvs !== !other.uvs ||
502
- !this.uvs2 !== !other.uvs2 ||
503
- !this.uvs3 !== !other.uvs3 ||
504
- !this.uvs4 !== !other.uvs4 ||
505
- !this.uvs5 !== !other.uvs5 ||
506
- !this.uvs6 !== !other.uvs6 ||
507
- !this.colors !== !other.colors ||
508
- !this.matricesIndices !== !other.matricesIndices ||
509
- !this.matricesWeights !== !other.matricesWeights ||
510
- !this.matricesIndicesExtra !== !other.matricesIndicesExtra ||
511
- !this.matricesWeightsExtra !== !other.matricesWeightsExtra) {
512
- throw new Error("Cannot merge vertex data that do not have the same set of attributes");
327
+ static _FlipFaces(indices, offset = 0, length = indices.length) {
328
+ for (let index = offset; index < offset + length; index += 3) {
329
+ const tmp = indices[index + 1];
330
+ indices[index + 1] = indices[index + 2];
331
+ indices[index + 2] = tmp;
513
332
  }
514
333
  }
515
- else {
516
- // Align the others with main set of attributes
517
- if (this.normals && !other.normals) {
518
- other.normals = new Float32Array(other.positions.length);
334
+ /**
335
+ * Transforms each position and each normal of the vertexData according to the passed Matrix
336
+ * @param matrix the transforming matrix
337
+ * @returns the VertexData
338
+ */
339
+ transform(matrix) {
340
+ const flip = matrix.determinant() < 0;
341
+ if (this.positions) {
342
+ _a._TransformVector3Coordinates(this.positions, matrix);
519
343
  }
520
- if (this.tangents && !other.tangents) {
521
- other.tangents = new Float32Array((other.positions.length / 3) * 4);
344
+ if (this.normals) {
345
+ _a._TransformVector3Normals(this.normals, matrix);
522
346
  }
523
- if (this.uvs && !other.uvs) {
524
- other.uvs = new Float32Array((other.positions.length / 3) * 2);
347
+ if (this.tangents) {
348
+ _a._TransformVector4Normals(this.tangents, matrix);
525
349
  }
526
- if (this.uvs2 && !other.uvs2) {
527
- other.uvs2 = new Float32Array((other.positions.length / 3) * 2);
350
+ if (flip && this.indices) {
351
+ _a._FlipFaces(this.indices);
528
352
  }
529
- if (this.uvs3 && !other.uvs3) {
530
- other.uvs3 = new Float32Array((other.positions.length / 3) * 2);
353
+ return this;
354
+ }
355
+ /**
356
+ * Generates an array of vertex data where each vertex data only has one material info
357
+ * @returns An array of VertexData
358
+ */
359
+ // eslint-disable-next-line @typescript-eslint/naming-convention
360
+ splitBasedOnMaterialID() {
361
+ if (!this.materialInfos || this.materialInfos.length < 2) {
362
+ return [this];
531
363
  }
532
- if (this.uvs4 && !other.uvs4) {
533
- other.uvs4 = new Float32Array((other.positions.length / 3) * 2);
364
+ const result = [];
365
+ for (const materialInfo of this.materialInfos) {
366
+ const vertexData = new _a();
367
+ if (this.positions) {
368
+ vertexData.positions = this.positions.slice(materialInfo.verticesStart * 3, (materialInfo.verticesCount + materialInfo.verticesStart) * 3);
369
+ }
370
+ if (this.normals) {
371
+ vertexData.normals = this.normals.slice(materialInfo.verticesStart * 3, (materialInfo.verticesCount + materialInfo.verticesStart) * 3);
372
+ }
373
+ if (this.tangents) {
374
+ vertexData.tangents = this.tangents.slice(materialInfo.verticesStart * 4, (materialInfo.verticesCount + materialInfo.verticesStart) * 4);
375
+ }
376
+ if (this.colors) {
377
+ vertexData.colors = this.colors.slice(materialInfo.verticesStart * 4, (materialInfo.verticesCount + materialInfo.verticesStart) * 4);
378
+ }
379
+ if (this.uvs) {
380
+ vertexData.uvs = this.uvs.slice(materialInfo.verticesStart * 2, (materialInfo.verticesCount + materialInfo.verticesStart) * 2);
381
+ }
382
+ if (this.uvs2) {
383
+ vertexData.uvs2 = this.uvs2.slice(materialInfo.verticesStart * 2, (materialInfo.verticesCount + materialInfo.verticesStart) * 2);
384
+ }
385
+ if (this.uvs3) {
386
+ vertexData.uvs3 = this.uvs3.slice(materialInfo.verticesStart * 2, (materialInfo.verticesCount + materialInfo.verticesStart) * 2);
387
+ }
388
+ if (this.uvs4) {
389
+ vertexData.uvs4 = this.uvs4.slice(materialInfo.verticesStart * 2, (materialInfo.verticesCount + materialInfo.verticesStart) * 2);
390
+ }
391
+ if (this.uvs5) {
392
+ vertexData.uvs5 = this.uvs5.slice(materialInfo.verticesStart * 2, (materialInfo.verticesCount + materialInfo.verticesStart) * 2);
393
+ }
394
+ if (this.uvs6) {
395
+ vertexData.uvs6 = this.uvs6.slice(materialInfo.verticesStart * 2, (materialInfo.verticesCount + materialInfo.verticesStart) * 2);
396
+ }
397
+ if (this.matricesIndices) {
398
+ vertexData.matricesIndices = this.matricesIndices.slice(materialInfo.verticesStart * 4, (materialInfo.verticesCount + materialInfo.verticesStart) * 4);
399
+ }
400
+ if (this.matricesIndicesExtra) {
401
+ vertexData.matricesIndicesExtra = this.matricesIndicesExtra.slice(materialInfo.verticesStart * 4, (materialInfo.verticesCount + materialInfo.verticesStart) * 4);
402
+ }
403
+ if (this.matricesWeights) {
404
+ vertexData.matricesWeights = this.matricesWeights.slice(materialInfo.verticesStart * 4, (materialInfo.verticesCount + materialInfo.verticesStart) * 4);
405
+ }
406
+ if (this.matricesWeightsExtra) {
407
+ vertexData.matricesWeightsExtra = this.matricesWeightsExtra.slice(materialInfo.verticesStart * 4, (materialInfo.verticesCount + materialInfo.verticesStart) * 4);
408
+ }
409
+ if (this.indices) {
410
+ vertexData.indices = [];
411
+ for (let index = materialInfo.indexStart; index < materialInfo.indexStart + materialInfo.indexCount; index++) {
412
+ vertexData.indices.push(this.indices[index] - materialInfo.verticesStart);
413
+ }
414
+ }
415
+ const newMaterialInfo = new VertexDataMaterialInfo();
416
+ newMaterialInfo.indexStart = 0;
417
+ newMaterialInfo.indexCount = vertexData.indices ? vertexData.indices.length : 0;
418
+ newMaterialInfo.materialIndex = materialInfo.materialIndex;
419
+ newMaterialInfo.verticesStart = 0;
420
+ newMaterialInfo.verticesCount = (vertexData.positions ? vertexData.positions.length : 0) / 3;
421
+ vertexData.materialInfos = [newMaterialInfo];
422
+ result.push(vertexData);
534
423
  }
535
- if (this.uvs5 && !other.uvs5) {
536
- other.uvs5 = new Float32Array((other.positions.length / 3) * 2);
424
+ return result;
425
+ }
426
+ /**
427
+ * Merges the passed VertexData into the current one
428
+ * @param others the VertexData to be merged into the current one
429
+ * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
430
+ * @param forceCloneIndices defines a boolean indicating if indices are forced to be cloned
431
+ * @param mergeMaterialIds defines a boolean indicating if we need to merge the material infos
432
+ * @param enableCompletion defines a boolean indicating if the vertex data should be completed to be compatible
433
+ * @returns the modified VertexData
434
+ */
435
+ merge(others, use32BitsIndices = false, forceCloneIndices = false, mergeMaterialIds = false, enableCompletion = false) {
436
+ const vertexDatas = Array.isArray(others)
437
+ ? others.map((other) => {
438
+ return { vertexData: other };
439
+ })
440
+ : [{ vertexData: others }];
441
+ return runCoroutineSync(this._mergeCoroutine(undefined, vertexDatas, use32BitsIndices, false, forceCloneIndices, mergeMaterialIds, enableCompletion));
442
+ }
443
+ /**
444
+ * @internal
445
+ */
446
+ *_mergeCoroutine(transform, vertexDatas, use32BitsIndices = false, isAsync, forceCloneIndices, mergeMaterialIds = false, enableCompletion = false) {
447
+ this._validate();
448
+ let others = vertexDatas.map((vertexData) => vertexData.vertexData);
449
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
450
+ let root = this;
451
+ if (enableCompletion) {
452
+ // First let's make sure we have the max set of attributes on the main vertex data
453
+ for (const other of others) {
454
+ if (!other) {
455
+ continue;
456
+ }
457
+ other._validate();
458
+ if (!this.normals && other.normals) {
459
+ this.normals = new Float32Array(this.positions.length);
460
+ }
461
+ if (!this.tangents && other.tangents) {
462
+ this.tangents = new Float32Array((this.positions.length / 3) * 4);
463
+ }
464
+ if (!this.uvs && other.uvs) {
465
+ this.uvs = new Float32Array((this.positions.length / 3) * 2);
466
+ }
467
+ if (!this.uvs2 && other.uvs2) {
468
+ this.uvs2 = new Float32Array((this.positions.length / 3) * 2);
469
+ }
470
+ if (!this.uvs3 && other.uvs3) {
471
+ this.uvs3 = new Float32Array((this.positions.length / 3) * 2);
472
+ }
473
+ if (!this.uvs4 && other.uvs4) {
474
+ this.uvs4 = new Float32Array((this.positions.length / 3) * 2);
475
+ }
476
+ if (!this.uvs5 && other.uvs5) {
477
+ this.uvs5 = new Float32Array((this.positions.length / 3) * 2);
478
+ }
479
+ if (!this.uvs6 && other.uvs6) {
480
+ this.uvs6 = new Float32Array((this.positions.length / 3) * 2);
481
+ }
482
+ if (!this.colors && other.colors) {
483
+ this.colors = new Float32Array((this.positions.length / 3) * 4);
484
+ this.colors.fill(1); // Set to white by default
485
+ }
486
+ if (!this.matricesIndices && other.matricesIndices) {
487
+ this.matricesIndices = new Float32Array((this.positions.length / 3) * 4);
488
+ }
489
+ if (!this.matricesWeights && other.matricesWeights) {
490
+ this.matricesWeights = new Float32Array((this.positions.length / 3) * 4);
491
+ }
492
+ if (!this.matricesIndicesExtra && other.matricesIndicesExtra) {
493
+ this.matricesIndicesExtra = new Float32Array((this.positions.length / 3) * 4);
494
+ }
495
+ if (!this.matricesWeightsExtra && other.matricesWeightsExtra) {
496
+ this.matricesWeightsExtra = new Float32Array((this.positions.length / 3) * 4);
497
+ }
498
+ }
537
499
  }
538
- if (this.uvs6 && !other.uvs6) {
539
- other.uvs6 = new Float32Array((other.positions.length / 3) * 2);
500
+ for (const other of others) {
501
+ if (!other) {
502
+ continue;
503
+ }
504
+ if (!enableCompletion) {
505
+ other._validate();
506
+ if (!this.normals !== !other.normals ||
507
+ !this.tangents !== !other.tangents ||
508
+ !this.uvs !== !other.uvs ||
509
+ !this.uvs2 !== !other.uvs2 ||
510
+ !this.uvs3 !== !other.uvs3 ||
511
+ !this.uvs4 !== !other.uvs4 ||
512
+ !this.uvs5 !== !other.uvs5 ||
513
+ !this.uvs6 !== !other.uvs6 ||
514
+ !this.colors !== !other.colors ||
515
+ !this.matricesIndices !== !other.matricesIndices ||
516
+ !this.matricesWeights !== !other.matricesWeights ||
517
+ !this.matricesIndicesExtra !== !other.matricesIndicesExtra ||
518
+ !this.matricesWeightsExtra !== !other.matricesWeightsExtra) {
519
+ throw new Error("Cannot merge vertex data that do not have the same set of attributes");
520
+ }
521
+ }
522
+ else {
523
+ // Align the others with main set of attributes
524
+ if (this.normals && !other.normals) {
525
+ other.normals = new Float32Array(other.positions.length);
526
+ }
527
+ if (this.tangents && !other.tangents) {
528
+ other.tangents = new Float32Array((other.positions.length / 3) * 4);
529
+ }
530
+ if (this.uvs && !other.uvs) {
531
+ other.uvs = new Float32Array((other.positions.length / 3) * 2);
532
+ }
533
+ if (this.uvs2 && !other.uvs2) {
534
+ other.uvs2 = new Float32Array((other.positions.length / 3) * 2);
535
+ }
536
+ if (this.uvs3 && !other.uvs3) {
537
+ other.uvs3 = new Float32Array((other.positions.length / 3) * 2);
538
+ }
539
+ if (this.uvs4 && !other.uvs4) {
540
+ other.uvs4 = new Float32Array((other.positions.length / 3) * 2);
541
+ }
542
+ if (this.uvs5 && !other.uvs5) {
543
+ other.uvs5 = new Float32Array((other.positions.length / 3) * 2);
544
+ }
545
+ if (this.uvs6 && !other.uvs6) {
546
+ other.uvs6 = new Float32Array((other.positions.length / 3) * 2);
547
+ }
548
+ if (this.colors && !other.colors) {
549
+ other.colors = new Float32Array((other.positions.length / 3) * 4);
550
+ other.colors.fill(1); // Set to white by default
551
+ }
552
+ if (this.matricesIndices && !other.matricesIndices) {
553
+ other.matricesIndices = new Float32Array((other.positions.length / 3) * 4);
554
+ }
555
+ if (this.matricesWeights && !other.matricesWeights) {
556
+ other.matricesWeights = new Float32Array((other.positions.length / 3) * 4);
557
+ }
558
+ if (this.matricesIndicesExtra && !other.matricesIndicesExtra) {
559
+ other.matricesIndicesExtra = new Float32Array((other.positions.length / 3) * 4);
560
+ }
561
+ if (this.matricesWeightsExtra && !other.matricesWeightsExtra) {
562
+ other.matricesWeightsExtra = new Float32Array((other.positions.length / 3) * 4);
563
+ }
564
+ }
540
565
  }
541
- if (this.colors && !other.colors) {
542
- other.colors = new Float32Array((other.positions.length / 3) * 4);
543
- other.colors.fill(1); // Set to white by default
566
+ if (mergeMaterialIds) {
567
+ // Merge material infos
568
+ let materialIndex;
569
+ let indexOffset = 0;
570
+ let vertexOffset = 0;
571
+ const materialInfos = [];
572
+ let currentMaterialInfo = null;
573
+ const vertexDataList = [];
574
+ // We need to split vertexData with more than one materialInfo
575
+ for (const split of this.splitBasedOnMaterialID()) {
576
+ vertexDataList.push({ vertexData: split, transform: transform });
577
+ }
578
+ for (const data of vertexDatas) {
579
+ if (!data.vertexData) {
580
+ continue;
581
+ }
582
+ for (const split of data.vertexData.splitBasedOnMaterialID()) {
583
+ vertexDataList.push({ vertexData: split, transform: data.transform });
584
+ }
585
+ }
586
+ // Sort by material IDs
587
+ vertexDataList.sort((a, b) => {
588
+ const matInfoA = a.vertexData.materialInfos ? a.vertexData.materialInfos[0].materialIndex : 0;
589
+ const matInfoB = b.vertexData.materialInfos ? b.vertexData.materialInfos[0].materialIndex : 0;
590
+ if (matInfoA > matInfoB) {
591
+ return 1;
592
+ }
593
+ if (matInfoA === matInfoB) {
594
+ return 0;
595
+ }
596
+ return -1;
597
+ });
598
+ // Build the new material info
599
+ for (const vertexDataSource of vertexDataList) {
600
+ const vertexData = vertexDataSource.vertexData;
601
+ if (vertexData.materialInfos) {
602
+ materialIndex = vertexData.materialInfos[0].materialIndex;
603
+ }
604
+ else {
605
+ materialIndex = 0;
606
+ }
607
+ if (currentMaterialInfo && currentMaterialInfo.materialIndex === materialIndex) {
608
+ currentMaterialInfo.indexCount += vertexData.indices.length;
609
+ currentMaterialInfo.verticesCount += vertexData.positions.length / 3;
610
+ }
611
+ else {
612
+ const materialInfo = new VertexDataMaterialInfo();
613
+ materialInfo.materialIndex = materialIndex;
614
+ materialInfo.indexStart = indexOffset;
615
+ materialInfo.indexCount = vertexData.indices.length;
616
+ materialInfo.verticesStart = vertexOffset;
617
+ materialInfo.verticesCount = vertexData.positions.length / 3;
618
+ materialInfos.push(materialInfo);
619
+ currentMaterialInfo = materialInfo;
620
+ }
621
+ indexOffset += vertexData.indices.length;
622
+ vertexOffset += vertexData.positions.length / 3;
623
+ }
624
+ // Extract sorted values
625
+ const first = vertexDataList.splice(0, 1)[0];
626
+ root = first.vertexData;
627
+ transform = first.transform;
628
+ others = vertexDataList.map((v) => v.vertexData);
629
+ vertexDatas = vertexDataList;
630
+ this.materialInfos = materialInfos;
544
631
  }
545
- if (this.matricesIndices && !other.matricesIndices) {
546
- other.matricesIndices = new Float32Array((other.positions.length / 3) * 4);
632
+ // Merge geometries
633
+ const totalIndices = others.reduce((indexSum, vertexData) => indexSum + (vertexData.indices?.length ?? 0), root.indices?.length ?? 0);
634
+ const sliceIndices = forceCloneIndices || others.some((vertexData) => vertexData.indices === root.indices);
635
+ let indices = sliceIndices ? root.indices?.slice() : root.indices;
636
+ if (totalIndices > 0) {
637
+ let indicesOffset = indices?.length ?? 0;
638
+ if (!indices) {
639
+ indices = new Array(totalIndices);
640
+ }
641
+ if (indices.length !== totalIndices) {
642
+ if (Array.isArray(indices)) {
643
+ indices.length = totalIndices;
644
+ }
645
+ else {
646
+ const temp = use32BitsIndices || indices instanceof Uint32Array ? new Uint32Array(totalIndices) : new Uint16Array(totalIndices);
647
+ temp.set(indices);
648
+ indices = temp;
649
+ }
650
+ if (transform && transform.determinant() < 0) {
651
+ _a._FlipFaces(indices, 0, indicesOffset);
652
+ }
653
+ }
654
+ let positionsOffset = root.positions ? root.positions.length / 3 : 0;
655
+ for (const { vertexData: other, transform } of vertexDatas) {
656
+ if (other.indices) {
657
+ for (let index = 0; index < other.indices.length; index++) {
658
+ indices[indicesOffset + index] = other.indices[index] + positionsOffset;
659
+ }
660
+ if (transform && transform.determinant() < 0) {
661
+ _a._FlipFaces(indices, indicesOffset, other.indices.length);
662
+ }
663
+ // The call to _validate already checked for positions
664
+ positionsOffset += other.positions.length / 3;
665
+ indicesOffset += other.indices.length;
666
+ if (isAsync) {
667
+ yield;
668
+ }
669
+ }
670
+ }
547
671
  }
548
- if (this.matricesWeights && !other.matricesWeights) {
549
- other.matricesWeights = new Float32Array((other.positions.length / 3) * 4);
672
+ this.indices = indices;
673
+ this.positions = _a._MergeElement(VertexBuffer.PositionKind, root.positions, transform, vertexDatas.map((other) => [other.vertexData.positions, other.transform]));
674
+ if (isAsync) {
675
+ yield;
550
676
  }
551
- if (this.matricesIndicesExtra && !other.matricesIndicesExtra) {
552
- other.matricesIndicesExtra = new Float32Array((other.positions.length / 3) * 4);
677
+ if (root.normals) {
678
+ this.normals = _a._MergeElement(VertexBuffer.NormalKind, root.normals, transform, vertexDatas.map((other) => [other.vertexData.normals, other.transform]));
679
+ if (isAsync) {
680
+ yield;
681
+ }
553
682
  }
554
- if (this.matricesWeightsExtra && !other.matricesWeightsExtra) {
555
- other.matricesWeightsExtra = new Float32Array((other.positions.length / 3) * 4);
683
+ if (root.tangents) {
684
+ this.tangents = _a._MergeElement(VertexBuffer.TangentKind, root.tangents, transform, vertexDatas.map((other) => [other.vertexData.tangents, other.transform]));
685
+ if (isAsync) {
686
+ yield;
687
+ }
556
688
  }
557
- }
558
- }
559
- if (mergeMaterialIds) {
560
- // Merge material infos
561
- let materialIndex;
562
- let indexOffset = 0;
563
- let vertexOffset = 0;
564
- const materialInfos = [];
565
- let currentMaterialInfo = null;
566
- const vertexDataList = [];
567
- // We need to split vertexData with more than one materialInfo
568
- for (const split of this.splitBasedOnMaterialID()) {
569
- vertexDataList.push({ vertexData: split, transform: transform });
570
- }
571
- for (const data of vertexDatas) {
572
- if (!data.vertexData) {
573
- continue;
689
+ if (root.uvs) {
690
+ this.uvs = _a._MergeElement(VertexBuffer.UVKind, root.uvs, transform, vertexDatas.map((other) => [other.vertexData.uvs, other.transform]));
691
+ if (isAsync) {
692
+ yield;
693
+ }
574
694
  }
575
- for (const split of data.vertexData.splitBasedOnMaterialID()) {
576
- vertexDataList.push({ vertexData: split, transform: data.transform });
695
+ if (root.uvs2) {
696
+ this.uvs2 = _a._MergeElement(VertexBuffer.UV2Kind, root.uvs2, transform, vertexDatas.map((other) => [other.vertexData.uvs2, other.transform]));
697
+ if (isAsync) {
698
+ yield;
699
+ }
577
700
  }
578
- }
579
- // Sort by material IDs
580
- vertexDataList.sort((a, b) => {
581
- const matInfoA = a.vertexData.materialInfos ? a.vertexData.materialInfos[0].materialIndex : 0;
582
- const matInfoB = b.vertexData.materialInfos ? b.vertexData.materialInfos[0].materialIndex : 0;
583
- if (matInfoA > matInfoB) {
584
- return 1;
585
- }
586
- if (matInfoA === matInfoB) {
587
- return 0;
588
- }
589
- return -1;
590
- });
591
- // Build the new material info
592
- for (const vertexDataSource of vertexDataList) {
593
- const vertexData = vertexDataSource.vertexData;
594
- if (vertexData.materialInfos) {
595
- materialIndex = vertexData.materialInfos[0].materialIndex;
701
+ if (root.uvs3) {
702
+ this.uvs3 = _a._MergeElement(VertexBuffer.UV3Kind, root.uvs3, transform, vertexDatas.map((other) => [other.vertexData.uvs3, other.transform]));
703
+ if (isAsync) {
704
+ yield;
705
+ }
596
706
  }
597
- else {
598
- materialIndex = 0;
707
+ if (root.uvs4) {
708
+ this.uvs4 = _a._MergeElement(VertexBuffer.UV4Kind, root.uvs4, transform, vertexDatas.map((other) => [other.vertexData.uvs4, other.transform]));
709
+ if (isAsync) {
710
+ yield;
711
+ }
599
712
  }
600
- if (currentMaterialInfo && currentMaterialInfo.materialIndex === materialIndex) {
601
- currentMaterialInfo.indexCount += vertexData.indices.length;
602
- currentMaterialInfo.verticesCount += vertexData.positions.length / 3;
713
+ if (root.uvs5) {
714
+ this.uvs5 = _a._MergeElement(VertexBuffer.UV5Kind, root.uvs5, transform, vertexDatas.map((other) => [other.vertexData.uvs5, other.transform]));
715
+ if (isAsync) {
716
+ yield;
717
+ }
603
718
  }
604
- else {
605
- const materialInfo = new VertexDataMaterialInfo();
606
- materialInfo.materialIndex = materialIndex;
607
- materialInfo.indexStart = indexOffset;
608
- materialInfo.indexCount = vertexData.indices.length;
609
- materialInfo.verticesStart = vertexOffset;
610
- materialInfo.verticesCount = vertexData.positions.length / 3;
611
- materialInfos.push(materialInfo);
612
- currentMaterialInfo = materialInfo;
613
- }
614
- indexOffset += vertexData.indices.length;
615
- vertexOffset += vertexData.positions.length / 3;
616
- }
617
- // Extract sorted values
618
- const first = vertexDataList.splice(0, 1)[0];
619
- root = first.vertexData;
620
- transform = first.transform;
621
- others = vertexDataList.map((v) => v.vertexData);
622
- vertexDatas = vertexDataList;
623
- this.materialInfos = materialInfos;
624
- }
625
- // Merge geometries
626
- const totalIndices = others.reduce((indexSum, vertexData) => indexSum + (vertexData.indices?.length ?? 0), root.indices?.length ?? 0);
627
- const sliceIndices = forceCloneIndices || others.some((vertexData) => vertexData.indices === root.indices);
628
- let indices = sliceIndices ? root.indices?.slice() : root.indices;
629
- if (totalIndices > 0) {
630
- let indicesOffset = indices?.length ?? 0;
631
- if (!indices) {
632
- indices = new Array(totalIndices);
633
- }
634
- if (indices.length !== totalIndices) {
635
- if (Array.isArray(indices)) {
636
- indices.length = totalIndices;
719
+ if (root.uvs6) {
720
+ this.uvs6 = _a._MergeElement(VertexBuffer.UV6Kind, root.uvs6, transform, vertexDatas.map((other) => [other.vertexData.uvs6, other.transform]));
721
+ if (isAsync) {
722
+ yield;
723
+ }
637
724
  }
638
- else {
639
- const temp = use32BitsIndices || indices instanceof Uint32Array ? new Uint32Array(totalIndices) : new Uint16Array(totalIndices);
640
- temp.set(indices);
641
- indices = temp;
725
+ if (root.colors) {
726
+ this.colors = _a._MergeElement(VertexBuffer.ColorKind, root.colors, transform, vertexDatas.map((other) => [other.vertexData.colors, other.transform]));
727
+ if (root.hasVertexAlpha !== undefined || vertexDatas.some((other) => other.vertexData.hasVertexAlpha !== undefined)) {
728
+ this.hasVertexAlpha = root.hasVertexAlpha || vertexDatas.some((other) => other.vertexData.hasVertexAlpha);
729
+ }
730
+ if (isAsync) {
731
+ yield;
732
+ }
642
733
  }
643
- if (transform && transform.determinant() < 0) {
644
- VertexData._FlipFaces(indices, 0, indicesOffset);
734
+ if (root.matricesIndices) {
735
+ this.matricesIndices = _a._MergeElement(VertexBuffer.MatricesIndicesKind, root.matricesIndices, transform, vertexDatas.map((other) => [other.vertexData.matricesIndices, other.transform]));
736
+ if (isAsync) {
737
+ yield;
738
+ }
645
739
  }
646
- }
647
- let positionsOffset = root.positions ? root.positions.length / 3 : 0;
648
- for (const { vertexData: other, transform } of vertexDatas) {
649
- if (other.indices) {
650
- for (let index = 0; index < other.indices.length; index++) {
651
- indices[indicesOffset + index] = other.indices[index] + positionsOffset;
652
- }
653
- if (transform && transform.determinant() < 0) {
654
- VertexData._FlipFaces(indices, indicesOffset, other.indices.length);
655
- }
656
- // The call to _validate already checked for positions
657
- positionsOffset += other.positions.length / 3;
658
- indicesOffset += other.indices.length;
740
+ if (root.matricesWeights) {
741
+ this.matricesWeights = _a._MergeElement(VertexBuffer.MatricesWeightsKind, root.matricesWeights, transform, vertexDatas.map((other) => [other.vertexData.matricesWeights, other.transform]));
659
742
  if (isAsync) {
660
743
  yield;
661
744
  }
662
745
  }
746
+ if (root.matricesIndicesExtra) {
747
+ this.matricesIndicesExtra = _a._MergeElement(VertexBuffer.MatricesIndicesExtraKind, root.matricesIndicesExtra, transform, vertexDatas.map((other) => [other.vertexData.matricesIndicesExtra, other.transform]));
748
+ if (isAsync) {
749
+ yield;
750
+ }
751
+ }
752
+ if (root.matricesWeightsExtra) {
753
+ this.matricesWeightsExtra = _a._MergeElement(VertexBuffer.MatricesWeightsExtraKind, root.matricesWeightsExtra, transform, vertexDatas.map((other) => [other.vertexData.matricesWeightsExtra, other.transform]));
754
+ }
755
+ return this;
663
756
  }
664
- }
665
- this.indices = indices;
666
- this.positions = VertexData._MergeElement(VertexBuffer.PositionKind, root.positions, transform, vertexDatas.map((other) => [other.vertexData.positions, other.transform]));
667
- if (isAsync) {
668
- yield;
669
- }
670
- if (root.normals) {
671
- this.normals = VertexData._MergeElement(VertexBuffer.NormalKind, root.normals, transform, vertexDatas.map((other) => [other.vertexData.normals, other.transform]));
672
- if (isAsync) {
673
- yield;
674
- }
675
- }
676
- if (root.tangents) {
677
- this.tangents = VertexData._MergeElement(VertexBuffer.TangentKind, root.tangents, transform, vertexDatas.map((other) => [other.vertexData.tangents, other.transform]));
678
- if (isAsync) {
679
- yield;
680
- }
681
- }
682
- if (root.uvs) {
683
- this.uvs = VertexData._MergeElement(VertexBuffer.UVKind, root.uvs, transform, vertexDatas.map((other) => [other.vertexData.uvs, other.transform]));
684
- if (isAsync) {
685
- yield;
686
- }
687
- }
688
- if (root.uvs2) {
689
- this.uvs2 = VertexData._MergeElement(VertexBuffer.UV2Kind, root.uvs2, transform, vertexDatas.map((other) => [other.vertexData.uvs2, other.transform]));
690
- if (isAsync) {
691
- yield;
692
- }
693
- }
694
- if (root.uvs3) {
695
- this.uvs3 = VertexData._MergeElement(VertexBuffer.UV3Kind, root.uvs3, transform, vertexDatas.map((other) => [other.vertexData.uvs3, other.transform]));
696
- if (isAsync) {
697
- yield;
698
- }
699
- }
700
- if (root.uvs4) {
701
- this.uvs4 = VertexData._MergeElement(VertexBuffer.UV4Kind, root.uvs4, transform, vertexDatas.map((other) => [other.vertexData.uvs4, other.transform]));
702
- if (isAsync) {
703
- yield;
704
- }
705
- }
706
- if (root.uvs5) {
707
- this.uvs5 = VertexData._MergeElement(VertexBuffer.UV5Kind, root.uvs5, transform, vertexDatas.map((other) => [other.vertexData.uvs5, other.transform]));
708
- if (isAsync) {
709
- yield;
710
- }
711
- }
712
- if (root.uvs6) {
713
- this.uvs6 = VertexData._MergeElement(VertexBuffer.UV6Kind, root.uvs6, transform, vertexDatas.map((other) => [other.vertexData.uvs6, other.transform]));
714
- if (isAsync) {
715
- yield;
716
- }
717
- }
718
- if (root.colors) {
719
- this.colors = VertexData._MergeElement(VertexBuffer.ColorKind, root.colors, transform, vertexDatas.map((other) => [other.vertexData.colors, other.transform]));
720
- if (root.hasVertexAlpha !== undefined || vertexDatas.some((other) => other.vertexData.hasVertexAlpha !== undefined)) {
721
- this.hasVertexAlpha = root.hasVertexAlpha || vertexDatas.some((other) => other.vertexData.hasVertexAlpha);
722
- }
723
- if (isAsync) {
724
- yield;
725
- }
726
- }
727
- if (root.matricesIndices) {
728
- this.matricesIndices = VertexData._MergeElement(VertexBuffer.MatricesIndicesKind, root.matricesIndices, transform, vertexDatas.map((other) => [other.vertexData.matricesIndices, other.transform]));
729
- if (isAsync) {
730
- yield;
731
- }
732
- }
733
- if (root.matricesWeights) {
734
- this.matricesWeights = VertexData._MergeElement(VertexBuffer.MatricesWeightsKind, root.matricesWeights, transform, vertexDatas.map((other) => [other.vertexData.matricesWeights, other.transform]));
735
- if (isAsync) {
736
- yield;
737
- }
738
- }
739
- if (root.matricesIndicesExtra) {
740
- this.matricesIndicesExtra = VertexData._MergeElement(VertexBuffer.MatricesIndicesExtraKind, root.matricesIndicesExtra, transform, vertexDatas.map((other) => [other.vertexData.matricesIndicesExtra, other.transform]));
741
- if (isAsync) {
742
- yield;
743
- }
744
- }
745
- if (root.matricesWeightsExtra) {
746
- this.matricesWeightsExtra = VertexData._MergeElement(VertexBuffer.MatricesWeightsExtraKind, root.matricesWeightsExtra, transform, vertexDatas.map((other) => [other.vertexData.matricesWeightsExtra, other.transform]));
747
- }
748
- return this;
749
- }
750
- static _MergeElement(kind, source, transform, others) {
751
- const nonNullOthers = others.filter((other) => other[0] !== null && other[0] !== undefined);
752
- // If there is no source to copy and no other non-null sources then skip this element.
753
- if (!source && nonNullOthers.length == 0) {
754
- return source;
755
- }
756
- if (!source) {
757
- return this._MergeElement(kind, nonNullOthers[0][0], nonNullOthers[0][1], nonNullOthers.slice(1));
758
- }
759
- const len = nonNullOthers.reduce((sumLen, elements) => sumLen + elements[0].length, source.length);
760
- const transformRange = kind === VertexBuffer.PositionKind
761
- ? VertexData._TransformVector3Coordinates
762
- : kind === VertexBuffer.NormalKind
763
- ? VertexData._TransformVector3Normals
764
- : kind === VertexBuffer.TangentKind
765
- ? VertexData._TransformVector4Normals
766
- : () => { };
767
- if (source instanceof Float32Array) {
768
- // use non-loop method when the source is Float32Array
769
- const ret32 = new Float32Array(len);
770
- ret32.set(source);
771
- transform && transformRange(ret32, transform, 0, source.length);
772
- let offset = source.length;
773
- for (const [vertexData, transform] of nonNullOthers) {
774
- ret32.set(vertexData, offset);
775
- transform && transformRange(ret32, transform, offset, vertexData.length);
776
- offset += vertexData.length;
777
- }
778
- return ret32;
779
- }
780
- else {
781
- // don't use concat as it is super slow, just loop for other cases
782
- const ret = new Array(len);
783
- for (let i = 0; i < source.length; i++) {
784
- ret[i] = source[i];
785
- }
786
- transform && transformRange(ret, transform, 0, source.length);
787
- let offset = source.length;
788
- for (const [vertexData, transform] of nonNullOthers) {
789
- for (let i = 0; i < vertexData.length; i++) {
790
- ret[offset + i] = vertexData[i];
791
- }
792
- transform && transformRange(ret, transform, offset, vertexData.length);
793
- offset += vertexData.length;
794
- }
795
- return ret;
796
- }
797
- }
798
- _validate() {
799
- if (!this.positions) {
800
- throw new RuntimeError("Positions are required", ErrorCodes.MeshInvalidPositionsError);
801
- }
802
- const getElementCount = (kind, values) => {
803
- const stride = VertexBufferDeduceStride(kind);
804
- if (values.length % stride !== 0) {
805
- throw new Error("The " + kind + "s array count must be a multiple of " + stride);
806
- }
807
- return values.length / stride;
808
- };
809
- const positionsElementCount = getElementCount(VertexBuffer.PositionKind, this.positions);
810
- const validateElementCount = (kind, values) => {
811
- const elementCount = getElementCount(kind, values);
812
- if (elementCount !== positionsElementCount) {
813
- throw new Error("The " + kind + "s element count (" + elementCount + ") does not match the positions count (" + positionsElementCount + ")");
757
+ static _MergeElement(kind, source, transform, others) {
758
+ const nonNullOthers = others.filter((other) => other[0] !== null && other[0] !== undefined);
759
+ // If there is no source to copy and no other non-null sources then skip this element.
760
+ if (!source && nonNullOthers.length == 0) {
761
+ return source;
762
+ }
763
+ if (!source) {
764
+ return this._MergeElement(kind, nonNullOthers[0][0], nonNullOthers[0][1], nonNullOthers.slice(1));
765
+ }
766
+ const len = nonNullOthers.reduce((sumLen, elements) => sumLen + elements[0].length, source.length);
767
+ const transformRange = kind === VertexBuffer.PositionKind
768
+ ? _a._TransformVector3Coordinates
769
+ : kind === VertexBuffer.NormalKind
770
+ ? _a._TransformVector3Normals
771
+ : kind === VertexBuffer.TangentKind
772
+ ? _a._TransformVector4Normals
773
+ : () => { };
774
+ if (source instanceof Float32Array) {
775
+ // use non-loop method when the source is Float32Array
776
+ const ret32 = new Float32Array(len);
777
+ ret32.set(source);
778
+ transform && transformRange(ret32, transform, 0, source.length);
779
+ let offset = source.length;
780
+ for (const [vertexData, transform] of nonNullOthers) {
781
+ ret32.set(vertexData, offset);
782
+ transform && transformRange(ret32, transform, offset, vertexData.length);
783
+ offset += vertexData.length;
784
+ }
785
+ return ret32;
786
+ }
787
+ else {
788
+ // don't use concat as it is super slow, just loop for other cases
789
+ const ret = new Array(len);
790
+ for (let i = 0; i < source.length; i++) {
791
+ ret[i] = source[i];
792
+ }
793
+ transform && transformRange(ret, transform, 0, source.length);
794
+ let offset = source.length;
795
+ for (const [vertexData, transform] of nonNullOthers) {
796
+ for (let i = 0; i < vertexData.length; i++) {
797
+ ret[offset + i] = vertexData[i];
798
+ }
799
+ transform && transformRange(ret, transform, offset, vertexData.length);
800
+ offset += vertexData.length;
801
+ }
802
+ return ret;
803
+ }
814
804
  }
815
- };
816
- if (this.normals) {
817
- validateElementCount(VertexBuffer.NormalKind, this.normals);
818
- }
819
- if (this.tangents) {
820
- validateElementCount(VertexBuffer.TangentKind, this.tangents);
821
- }
822
- if (this.uvs) {
823
- validateElementCount(VertexBuffer.UVKind, this.uvs);
824
- }
825
- if (this.uvs2) {
826
- validateElementCount(VertexBuffer.UV2Kind, this.uvs2);
827
- }
828
- if (this.uvs3) {
829
- validateElementCount(VertexBuffer.UV3Kind, this.uvs3);
830
- }
831
- if (this.uvs4) {
832
- validateElementCount(VertexBuffer.UV4Kind, this.uvs4);
833
- }
834
- if (this.uvs5) {
835
- validateElementCount(VertexBuffer.UV5Kind, this.uvs5);
836
- }
837
- if (this.uvs6) {
838
- validateElementCount(VertexBuffer.UV6Kind, this.uvs6);
839
- }
840
- if (this.colors) {
841
- validateElementCount(VertexBuffer.ColorKind, this.colors);
842
- }
843
- if (this.matricesIndices) {
844
- validateElementCount(VertexBuffer.MatricesIndicesKind, this.matricesIndices);
845
- }
846
- if (this.matricesWeights) {
847
- validateElementCount(VertexBuffer.MatricesWeightsKind, this.matricesWeights);
848
- }
849
- if (this.matricesIndicesExtra) {
850
- validateElementCount(VertexBuffer.MatricesIndicesExtraKind, this.matricesIndicesExtra);
851
- }
852
- if (this.matricesWeightsExtra) {
853
- validateElementCount(VertexBuffer.MatricesWeightsExtraKind, this.matricesWeightsExtra);
854
- }
855
- }
856
- /**
857
- * Clone the current vertex data
858
- * @returns a copy of the current data
859
- */
860
- clone() {
861
- const serializationObject = this.serialize();
862
- return VertexData.Parse(serializationObject);
863
- }
864
- /**
865
- * Serializes the VertexData
866
- * @returns a serialized object
867
- */
868
- serialize() {
869
- const serializationObject = {};
870
- if (this.positions) {
871
- serializationObject.positions = Array.from(this.positions);
872
- }
873
- if (this.normals) {
874
- serializationObject.normals = Array.from(this.normals);
875
- }
876
- if (this.tangents) {
877
- serializationObject.tangents = Array.from(this.tangents);
878
- }
879
- if (this.uvs) {
880
- serializationObject.uvs = Array.from(this.uvs);
881
- }
882
- if (this.uvs2) {
883
- serializationObject.uvs2 = Array.from(this.uvs2);
884
- }
885
- if (this.uvs3) {
886
- serializationObject.uvs3 = Array.from(this.uvs3);
887
- }
888
- if (this.uvs4) {
889
- serializationObject.uvs4 = Array.from(this.uvs4);
890
- }
891
- if (this.uvs5) {
892
- serializationObject.uvs5 = Array.from(this.uvs5);
893
- }
894
- if (this.uvs6) {
895
- serializationObject.uvs6 = Array.from(this.uvs6);
896
- }
897
- if (this.colors) {
898
- serializationObject.colors = Array.from(this.colors);
899
- serializationObject.hasVertexAlpha = this.hasVertexAlpha;
900
- }
901
- if (this.matricesIndices) {
902
- serializationObject.matricesIndices = Array.from(this.matricesIndices);
903
- serializationObject.matricesIndicesExpanded = true;
904
- }
905
- if (this.matricesWeights) {
906
- serializationObject.matricesWeights = Array.from(this.matricesWeights);
907
- }
908
- if (this.matricesIndicesExtra) {
909
- serializationObject.matricesIndicesExtra = Array.from(this.matricesIndicesExtra);
910
- serializationObject.matricesIndicesExtraExpanded = true;
911
- }
912
- if (this.matricesWeightsExtra) {
913
- serializationObject.matricesWeightsExtra = Array.from(this.matricesWeightsExtra);
914
- }
915
- serializationObject.indices = this.indices ? Array.from(this.indices) : [];
916
- if (this.materialInfos) {
917
- serializationObject.materialInfos = [];
918
- for (const materialInfo of this.materialInfos) {
919
- const materialInfoSerializationObject = {
920
- indexStart: materialInfo.indexStart,
921
- indexCount: materialInfo.indexCount,
922
- materialIndex: materialInfo.materialIndex,
923
- verticesStart: materialInfo.verticesStart,
924
- verticesCount: materialInfo.verticesCount,
805
+ _validate() {
806
+ if (!this.positions) {
807
+ throw new RuntimeError("Positions are required", ErrorCodes.MeshInvalidPositionsError);
808
+ }
809
+ const getElementCount = (kind, values) => {
810
+ const stride = VertexBufferDeduceStride(kind);
811
+ if (values.length % stride !== 0) {
812
+ throw new Error("The " + kind + "s array count must be a multiple of " + stride);
813
+ }
814
+ return values.length / stride;
925
815
  };
926
- serializationObject.materialInfos.push(materialInfoSerializationObject);
927
- }
928
- }
929
- return serializationObject;
930
- }
931
- // Statics
932
- /**
933
- * Extracts the vertexData from a mesh
934
- * @param mesh the mesh from which to extract the VertexData
935
- * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
936
- * @param forceCopy indicating that the VertexData must be cloned, optional, default false
937
- * @returns the object VertexData associated to the passed mesh
938
- */
939
- static ExtractFromMesh(mesh, copyWhenShared, forceCopy) {
940
- return VertexData._ExtractFrom(mesh, copyWhenShared, forceCopy);
941
- }
942
- /**
943
- * Extracts the vertexData from the geometry
944
- * @param geometry the geometry from which to extract the VertexData
945
- * @param copyWhenShared defines if the VertexData must be cloned when the geometry is shared between multiple meshes, optional, default false
946
- * @param forceCopy indicating that the VertexData must be cloned, optional, default false
947
- * @returns the object VertexData associated to the passed mesh
948
- */
949
- static ExtractFromGeometry(geometry, copyWhenShared, forceCopy) {
950
- return VertexData._ExtractFrom(geometry, copyWhenShared, forceCopy);
951
- }
952
- static _ExtractFrom(meshOrGeometry, copyWhenShared, forceCopy) {
953
- const result = new VertexData();
954
- if (meshOrGeometry.isVerticesDataPresent(VertexBuffer.PositionKind)) {
955
- result.positions = meshOrGeometry.getVerticesData(VertexBuffer.PositionKind, copyWhenShared, forceCopy);
956
- }
957
- if (meshOrGeometry.isVerticesDataPresent(VertexBuffer.NormalKind)) {
958
- result.normals = meshOrGeometry.getVerticesData(VertexBuffer.NormalKind, copyWhenShared, forceCopy);
959
- }
960
- if (meshOrGeometry.isVerticesDataPresent(VertexBuffer.TangentKind)) {
961
- result.tangents = meshOrGeometry.getVerticesData(VertexBuffer.TangentKind, copyWhenShared, forceCopy);
962
- }
963
- if (meshOrGeometry.isVerticesDataPresent(VertexBuffer.UVKind)) {
964
- result.uvs = meshOrGeometry.getVerticesData(VertexBuffer.UVKind, copyWhenShared, forceCopy);
965
- }
966
- if (meshOrGeometry.isVerticesDataPresent(VertexBuffer.UV2Kind)) {
967
- result.uvs2 = meshOrGeometry.getVerticesData(VertexBuffer.UV2Kind, copyWhenShared, forceCopy);
968
- }
969
- if (meshOrGeometry.isVerticesDataPresent(VertexBuffer.UV3Kind)) {
970
- result.uvs3 = meshOrGeometry.getVerticesData(VertexBuffer.UV3Kind, copyWhenShared, forceCopy);
971
- }
972
- if (meshOrGeometry.isVerticesDataPresent(VertexBuffer.UV4Kind)) {
973
- result.uvs4 = meshOrGeometry.getVerticesData(VertexBuffer.UV4Kind, copyWhenShared, forceCopy);
974
- }
975
- if (meshOrGeometry.isVerticesDataPresent(VertexBuffer.UV5Kind)) {
976
- result.uvs5 = meshOrGeometry.getVerticesData(VertexBuffer.UV5Kind, copyWhenShared, forceCopy);
977
- }
978
- if (meshOrGeometry.isVerticesDataPresent(VertexBuffer.UV6Kind)) {
979
- result.uvs6 = meshOrGeometry.getVerticesData(VertexBuffer.UV6Kind, copyWhenShared, forceCopy);
980
- }
981
- if (meshOrGeometry.isVerticesDataPresent(VertexBuffer.ColorKind)) {
982
- const geometry = meshOrGeometry.geometry || meshOrGeometry;
983
- const vertexBuffer = geometry.getVertexBuffer(VertexBuffer.ColorKind);
984
- const colors = geometry.getVerticesData(VertexBuffer.ColorKind, copyWhenShared, forceCopy);
985
- if (vertexBuffer.getSize() === 3) {
986
- const newColors = new Float32Array((colors.length * 4) / 3);
987
- for (let i = 0, j = 0; i < colors.length; i += 3, j += 4) {
988
- newColors[j] = colors[i];
989
- newColors[j + 1] = colors[i + 1];
990
- newColors[j + 2] = colors[i + 2];
991
- newColors[j + 3] = 1;
992
- }
993
- result.colors = newColors;
994
- }
995
- else if (vertexBuffer.getSize() === 4) {
996
- result.colors = colors;
997
- }
998
- else {
999
- throw new Error(`Unexpected number of color components: ${vertexBuffer.getSize()}`);
1000
- }
1001
- }
1002
- if (meshOrGeometry.isVerticesDataPresent(VertexBuffer.MatricesIndicesKind)) {
1003
- result.matricesIndices = meshOrGeometry.getVerticesData(VertexBuffer.MatricesIndicesKind, copyWhenShared, forceCopy);
1004
- }
1005
- if (meshOrGeometry.isVerticesDataPresent(VertexBuffer.MatricesWeightsKind)) {
1006
- result.matricesWeights = meshOrGeometry.getVerticesData(VertexBuffer.MatricesWeightsKind, copyWhenShared, forceCopy);
1007
- }
1008
- if (meshOrGeometry.isVerticesDataPresent(VertexBuffer.MatricesIndicesExtraKind)) {
1009
- result.matricesIndicesExtra = meshOrGeometry.getVerticesData(VertexBuffer.MatricesIndicesExtraKind, copyWhenShared, forceCopy);
1010
- }
1011
- if (meshOrGeometry.isVerticesDataPresent(VertexBuffer.MatricesWeightsExtraKind)) {
1012
- result.matricesWeightsExtra = meshOrGeometry.getVerticesData(VertexBuffer.MatricesWeightsExtraKind, copyWhenShared, forceCopy);
1013
- }
1014
- result.indices = meshOrGeometry.getIndices(copyWhenShared, forceCopy);
1015
- return result;
1016
- }
1017
- /**
1018
- * Creates the VertexData for a Ribbon
1019
- * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
1020
- * * pathArray array of paths, each of which an array of successive Vector3
1021
- * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
1022
- * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
1023
- * * offset a positive integer, only used when pathArray contains a single path (offset = 10 means the point 1 is joined to the point 11), default rounded half size of the pathArray length
1024
- * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
1025
- * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
1026
- * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
1027
- * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
1028
- * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
1029
- * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
1030
- * @returns the VertexData of the ribbon
1031
- * @deprecated use CreateRibbonVertexData instead
1032
- */
1033
- static CreateRibbon(options) {
1034
- throw _WarnImport("ribbonBuilder");
1035
- }
1036
- /**
1037
- * Creates the VertexData for a box
1038
- * @param options an object used to set the following optional parameters for the box, required but can be empty
1039
- * * size sets the width, height and depth of the box to the value of size, optional default 1
1040
- * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
1041
- * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
1042
- * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
1043
- * * faceUV an array of 6 Vector4 elements used to set different images to each box side
1044
- * * faceColors an array of 6 Color3 elements used to set different colors to each box side
1045
- * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
1046
- * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
1047
- * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
1048
- * @returns the VertexData of the box
1049
- * @deprecated Please use CreateBoxVertexData from the BoxBuilder file instead
1050
- */
1051
- static CreateBox(options) {
1052
- throw _WarnImport("boxBuilder");
1053
- }
1054
- /**
1055
- * Creates the VertexData for a tiled box
1056
- * @param options an object used to set the following optional parameters for the box, required but can be empty
1057
- * - `pattern` sets the pattern
1058
- * - `width` sets the width
1059
- * - `height` sets the height
1060
- * - `depth` sets the depth
1061
- * - `tileSize` sets the tile size
1062
- * - `tileWidth` sets the tile width
1063
- * - `tileHeight` sets the tile height
1064
- * - `alignHorizontal` sets the horizontal alignment
1065
- * - `alignVertical` sets the vertical alignment
1066
- * - `faceUV` an array of 6 Vector4 elements used to set different images to each box side
1067
- * - `faceColors` an array of 6 Color3 elements used to set different colors to each box side
1068
- * - `sideOrientation` optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
1069
- * @returns the VertexData of the box
1070
- * @deprecated Please use CreateTiledBoxVertexData instead
1071
- */
1072
- static CreateTiledBox(options) {
1073
- throw _WarnImport("tiledBoxBuilder");
1074
- }
1075
- /**
1076
- * Creates the VertexData for a tiled plane
1077
- * @param options an object used to set the following optional parameters for the box, required but can be empty
1078
- * * pattern a limited pattern arrangement depending on the number
1079
- * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
1080
- * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
1081
- * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
1082
- * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
1083
- * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
1084
- * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
1085
- * @returns the VertexData of the tiled plane
1086
- * @deprecated use CreateTiledPlaneVertexData instead
1087
- */
1088
- static CreateTiledPlane(options) {
1089
- throw _WarnImport("tiledPlaneBuilder");
1090
- }
1091
- /**
1092
- * Creates the VertexData for an ellipsoid, defaults to a sphere
1093
- * @param options an object used to set the following optional parameters for the box, required but can be empty
1094
- * * segments sets the number of horizontal strips optional, default 32
1095
- * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
1096
- * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
1097
- * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
1098
- * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
1099
- * * arc a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the circumference (latitude) given by the arc value, optional, default 1
1100
- * * slice a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the height (latitude) given by the arc value, optional, default 1
1101
- * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
1102
- * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
1103
- * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
1104
- * @returns the VertexData of the ellipsoid
1105
- * @deprecated use CreateSphereVertexData instead
1106
- */
1107
- static CreateSphere(options) {
1108
- throw _WarnImport("sphereBuilder");
1109
- }
1110
- /**
1111
- * Creates the VertexData for a cylinder, cone or prism
1112
- * @param options an object used to set the following optional parameters for the box, required but can be empty
1113
- * * height sets the height (y direction) of the cylinder, optional, default 2
1114
- * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
1115
- * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
1116
- * * diameter sets the diameter of the top and bottom of the cone, optional default 1
1117
- * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
1118
- * * `subdivisions` the number of rings along the cylinder height, optional, default 1
1119
- * * arc a number from 0 to 1, to create an unclosed cylinder based on the fraction of the circumference given by the arc value, optional, default 1
1120
- * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
1121
- * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
1122
- * * hasRings when true makes each subdivision independently treated as a face for faceUV and faceColors, optional, default false
1123
- * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
1124
- * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
1125
- * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
1126
- * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
1127
- * @returns the VertexData of the cylinder, cone or prism
1128
- * @deprecated please use CreateCylinderVertexData instead
1129
- */
1130
- static CreateCylinder(options) {
1131
- throw _WarnImport("cylinderBuilder");
1132
- }
1133
- /**
1134
- * Creates the VertexData for a torus
1135
- * @param options an object used to set the following optional parameters for the box, required but can be empty
1136
- * * diameter the diameter of the torus, optional default 1
1137
- * * thickness the diameter of the tube forming the torus, optional default 0.5
1138
- * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
1139
- * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
1140
- * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
1141
- * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
1142
- * @returns the VertexData of the torus
1143
- * @deprecated use CreateTorusVertexData instead
1144
- */
1145
- static CreateTorus(options) {
1146
- throw _WarnImport("torusBuilder");
1147
- }
1148
- /**
1149
- * Creates the VertexData of the LineSystem
1150
- * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
1151
- * - lines an array of lines, each line being an array of successive Vector3
1152
- * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
1153
- * @returns the VertexData of the LineSystem
1154
- * @deprecated use CreateLineSystemVertexData instead
1155
- */
1156
- static CreateLineSystem(options) {
1157
- throw _WarnImport("linesBuilder");
1158
- }
1159
- /**
1160
- * Create the VertexData for a DashedLines
1161
- * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
1162
- * - points an array successive Vector3
1163
- * - dashSize the size of the dashes relative to the dash number, optional, default 3
1164
- * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
1165
- * - dashNb the intended total number of dashes, optional, default 200
1166
- * @returns the VertexData for the DashedLines
1167
- * @deprecated use CreateDashedLinesVertexData instead
1168
- */
1169
- static CreateDashedLines(options) {
1170
- throw _WarnImport("linesBuilder");
1171
- }
1172
- /**
1173
- * Creates the VertexData for a Ground
1174
- * @param options an object used to set the following optional parameters for the Ground, required but can be empty
1175
- * - width the width (x direction) of the ground, optional, default 1
1176
- * - height the height (z direction) of the ground, optional, default 1
1177
- * - subdivisions the number of subdivisions per side, optional, default 1
1178
- * @returns the VertexData of the Ground
1179
- * @deprecated Please use CreateGroundVertexData instead
1180
- */
1181
- static CreateGround(options) {
1182
- throw _WarnImport("groundBuilder");
1183
- }
1184
- /**
1185
- * Creates the VertexData for a TiledGround by subdividing the ground into tiles
1186
- * @param options an object used to set the following optional parameters for the Ground, required but can be empty
1187
- * * xmin the ground minimum X coordinate, optional, default -1
1188
- * * zmin the ground minimum Z coordinate, optional, default -1
1189
- * * xmax the ground maximum X coordinate, optional, default 1
1190
- * * zmax the ground maximum Z coordinate, optional, default 1
1191
- * * subdivisions a javascript object `\{w: positive integer, h: positive integer\}`, `w` and `h` are the numbers of subdivisions on the ground width and height creating 'tiles', default `\{w: 6, h: 6\}`
1192
- * * precision a javascript object `\{w: positive integer, h: positive integer\}`, `w` and `h` are the numbers of subdivisions on the tile width and height, default `\{w: 2, h: 2\}`
1193
- * @returns the VertexData of the TiledGround
1194
- * @deprecated use CreateTiledGroundVertexData instead
1195
- */
1196
- static CreateTiledGround(options) {
1197
- throw _WarnImport("groundBuilder");
1198
- }
1199
- /**
1200
- * Creates the VertexData of the Ground designed from a heightmap
1201
- * @param options an object used to set the following parameters for the Ground, required and provided by CreateGroundFromHeightMap
1202
- * * width the width (x direction) of the ground
1203
- * * height the height (z direction) of the ground
1204
- * * subdivisions the number of subdivisions per side
1205
- * * minHeight the minimum altitude on the ground, optional, default 0
1206
- * * maxHeight the maximum altitude on the ground, optional default 1
1207
- * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
1208
- * * buffer the array holding the image color data
1209
- * * bufferWidth the width of image
1210
- * * bufferHeight the height of image
1211
- * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
1212
- * @returns the VertexData of the Ground designed from a heightmap
1213
- * @deprecated use CreateGroundFromHeightMapVertexData instead
1214
- */
1215
- static CreateGroundFromHeightMap(options) {
1216
- throw _WarnImport("groundBuilder");
1217
- }
1218
- /**
1219
- * Creates the VertexData for a Plane
1220
- * @param options an object used to set the following optional parameters for the plane, required but can be empty
1221
- * * size sets the width and height of the plane to the value of size, optional default 1
1222
- * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
1223
- * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
1224
- * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
1225
- * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
1226
- * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
1227
- * @returns the VertexData of the box
1228
- * @deprecated use CreatePlaneVertexData instead
1229
- */
1230
- static CreatePlane(options) {
1231
- throw _WarnImport("planeBuilder");
1232
- }
1233
- /**
1234
- * Creates the VertexData of the Disc or regular Polygon
1235
- * @param options an object used to set the following optional parameters for the disc, required but can be empty
1236
- * * radius the radius of the disc, optional default 0.5
1237
- * * tessellation the number of polygon sides, optional, default 64
1238
- * * arc a number from 0 to 1, to create an unclosed polygon based on the fraction of the circumference given by the arc value, optional, default 1
1239
- * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
1240
- * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
1241
- * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
1242
- * @returns the VertexData of the box
1243
- * @deprecated use CreateDiscVertexData instead
1244
- */
1245
- static CreateDisc(options) {
1246
- throw _WarnImport("discBuilder");
1247
- }
1248
- /**
1249
- * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
1250
- * All parameters are provided by CreatePolygon as needed
1251
- * @param polygon a mesh built from polygonTriangulation.build()
1252
- * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
1253
- * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
1254
- * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
1255
- * @param frontUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
1256
- * @param backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
1257
- * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
1258
- * @returns the VertexData of the Polygon
1259
- * @deprecated use CreatePolygonVertexData instead
1260
- */
1261
- static CreatePolygon(polygon, sideOrientation, fUV, fColors, frontUVs, backUVs, wrap) {
1262
- throw _WarnImport("polygonBuilder");
1263
- }
1264
- /**
1265
- * Creates the VertexData of the IcoSphere
1266
- * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
1267
- * * radius the radius of the IcoSphere, optional default 1
1268
- * * radiusX allows stretching in the x direction, optional, default radius
1269
- * * radiusY allows stretching in the y direction, optional, default radius
1270
- * * radiusZ allows stretching in the z direction, optional, default radius
1271
- * * flat when true creates a flat shaded mesh, optional, default true
1272
- * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
1273
- * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
1274
- * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
1275
- * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
1276
- * @returns the VertexData of the IcoSphere
1277
- * @deprecated use CreateIcoSphereVertexData instead
1278
- */
1279
- static CreateIcoSphere(options) {
1280
- throw _WarnImport("icoSphereBuilder");
1281
- }
1282
- // inspired from // http://stemkoski.github.io/Three.js/Polyhedra.html
1283
- /**
1284
- * Creates the VertexData for a Polyhedron
1285
- * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
1286
- * * type provided types are:
1287
- * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
1288
- * * 9 : Pentagonal Pyramid (J2), 10 : Triangular Dipyramid (J12), 11 : Pentagonal Dipyramid (J13), 12 : Elongated Square Dipyramid (J15), 13 : Elongated Pentagonal Dipyramid (J16), 14 : Elongated Pentagonal Cupola (J20)
1289
- * * size the size of the IcoSphere, optional default 1
1290
- * * sizeX allows stretching in the x direction, optional, default size
1291
- * * sizeY allows stretching in the y direction, optional, default size
1292
- * * sizeZ allows stretching in the z direction, optional, default size
1293
- * * custom a number that overwrites the type to create from an extended set of polyhedron from https://www.babylonjs-playground.com/#21QRSK#15 with minimised editor
1294
- * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
1295
- * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
1296
- * * flat when true creates a flat shaded mesh, optional, default true
1297
- * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
1298
- * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
1299
- * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
1300
- * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
1301
- * @returns the VertexData of the Polyhedron
1302
- * @deprecated use CreatePolyhedronVertexData instead
1303
- */
1304
- static CreatePolyhedron(options) {
1305
- throw _WarnImport("polyhedronBuilder");
1306
- }
1307
- /**
1308
- * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
1309
- * @param options an object used to set the following optional parameters for the capsule, required but can be empty
1310
- * @returns the VertexData of the Capsule
1311
- * @deprecated Please use CreateCapsuleVertexData from the capsuleBuilder file instead
1312
- */
1313
- static CreateCapsule(options = {
1314
- orientation: Vector3.Up(),
1315
- subdivisions: 2,
1316
- tessellation: 16,
1317
- height: 1,
1318
- radius: 0.25,
1319
- capSubdivisions: 6,
1320
- }) {
1321
- throw _WarnImport("capsuleBuilder");
1322
- }
1323
- // based on http://code.google.com/p/away3d/source/browse/trunk/fp10/Away3D/src/away3d/primitives/TorusKnot.as?spec=svn2473&r=2473
1324
- /**
1325
- * Creates the VertexData for a TorusKnot
1326
- * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
1327
- * * radius the radius of the torus knot, optional, default 2
1328
- * * tube the thickness of the tube, optional, default 0.5
1329
- * * radialSegments the number of sides on each tube segments, optional, default 32
1330
- * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
1331
- * * p the number of windings around the z axis, optional, default 2
1332
- * * q the number of windings around the x axis, optional, default 3
1333
- * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
1334
- * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
1335
- * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
1336
- * @returns the VertexData of the Torus Knot
1337
- * @deprecated use CreateTorusKnotVertexData instead
1338
- */
1339
- static CreateTorusKnot(options) {
1340
- throw _WarnImport("torusKnotBuilder");
1341
- }
1342
- // Tools
1343
- /**
1344
- * Compute normals for given positions and indices
1345
- * @param positions an array of vertex positions, [...., x, y, z, ......]
1346
- * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
1347
- * @param normals an array of vertex normals, [...., x, y, z, ......]
1348
- * @param options an object used to set the following optional parameters for the TorusKnot, optional
1349
- * * facetNormals : optional array of facet normals (vector3)
1350
- * * facetPositions : optional array of facet positions (vector3)
1351
- * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
1352
- * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
1353
- * * bInfo : optional bounding info, required for facetPartitioning computation
1354
- * * bbSize : optional bounding box size data, required for facetPartitioning computation
1355
- * * subDiv : optional partitioning data about subdivisions on each axis (int), required for facetPartitioning computation
1356
- * * useRightHandedSystem: optional boolean to for right handed system computation
1357
- * * depthSort : optional boolean to enable the facet depth sort computation
1358
- * * distanceTo : optional Vector3 to compute the facet depth from this location
1359
- * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
1360
- */
1361
- static ComputeNormals(positions, indices, normals, options) {
1362
- // temporary scalar variables
1363
- let index; // facet index
1364
- let p1p2x; // p1p2 vector x coordinate
1365
- let p1p2y; // p1p2 vector y coordinate
1366
- let p1p2z; // p1p2 vector z coordinate
1367
- let p3p2x; // p3p2 vector x coordinate
1368
- let p3p2y; // p3p2 vector y coordinate
1369
- let p3p2z; // p3p2 vector z coordinate
1370
- let faceNormalx; // facet normal x coordinate
1371
- let faceNormaly; // facet normal y coordinate
1372
- let faceNormalz; // facet normal z coordinate
1373
- let length; // facet normal length before normalization
1374
- let v1x; // vector1 x index in the positions array
1375
- let v1y; // vector1 y index in the positions array
1376
- let v1z; // vector1 z index in the positions array
1377
- let v2x; // vector2 x index in the positions array
1378
- let v2y; // vector2 y index in the positions array
1379
- let v2z; // vector2 z index in the positions array
1380
- let v3x; // vector3 x index in the positions array
1381
- let v3y; // vector3 y index in the positions array
1382
- let v3z; // vector3 z index in the positions array
1383
- let computeFacetNormals = false;
1384
- let computeFacetPositions = false;
1385
- let computeFacetPartitioning = false;
1386
- let computeDepthSort = false;
1387
- let faceNormalSign = 1;
1388
- let ratio = 0;
1389
- let distanceTo = null;
1390
- if (options) {
1391
- computeFacetNormals = options.facetNormals ? true : false;
1392
- computeFacetPositions = options.facetPositions ? true : false;
1393
- computeFacetPartitioning = options.facetPartitioning ? true : false;
1394
- faceNormalSign = options.useRightHandedSystem === true ? -1 : 1;
1395
- ratio = options.ratio || 0;
1396
- computeDepthSort = options.depthSort ? true : false;
1397
- distanceTo = options.distanceTo;
1398
- if (computeDepthSort) {
1399
- if (distanceTo === undefined) {
1400
- distanceTo = Vector3.Zero();
816
+ const positionsElementCount = getElementCount(VertexBuffer.PositionKind, this.positions);
817
+ const validateElementCount = (kind, values) => {
818
+ const elementCount = getElementCount(kind, values);
819
+ if (elementCount !== positionsElementCount) {
820
+ throw new Error("The " + kind + "s element count (" + elementCount + ") does not match the positions count (" + positionsElementCount + ")");
821
+ }
822
+ };
823
+ if (this.normals) {
824
+ validateElementCount(VertexBuffer.NormalKind, this.normals);
825
+ }
826
+ if (this.tangents) {
827
+ validateElementCount(VertexBuffer.TangentKind, this.tangents);
828
+ }
829
+ if (this.uvs) {
830
+ validateElementCount(VertexBuffer.UVKind, this.uvs);
831
+ }
832
+ if (this.uvs2) {
833
+ validateElementCount(VertexBuffer.UV2Kind, this.uvs2);
834
+ }
835
+ if (this.uvs3) {
836
+ validateElementCount(VertexBuffer.UV3Kind, this.uvs3);
837
+ }
838
+ if (this.uvs4) {
839
+ validateElementCount(VertexBuffer.UV4Kind, this.uvs4);
840
+ }
841
+ if (this.uvs5) {
842
+ validateElementCount(VertexBuffer.UV5Kind, this.uvs5);
843
+ }
844
+ if (this.uvs6) {
845
+ validateElementCount(VertexBuffer.UV6Kind, this.uvs6);
846
+ }
847
+ if (this.colors) {
848
+ validateElementCount(VertexBuffer.ColorKind, this.colors);
849
+ }
850
+ if (this.matricesIndices) {
851
+ validateElementCount(VertexBuffer.MatricesIndicesKind, this.matricesIndices);
852
+ }
853
+ if (this.matricesWeights) {
854
+ validateElementCount(VertexBuffer.MatricesWeightsKind, this.matricesWeights);
855
+ }
856
+ if (this.matricesIndicesExtra) {
857
+ validateElementCount(VertexBuffer.MatricesIndicesExtraKind, this.matricesIndicesExtra);
858
+ }
859
+ if (this.matricesWeightsExtra) {
860
+ validateElementCount(VertexBuffer.MatricesWeightsExtraKind, this.matricesWeightsExtra);
1401
861
  }
1402
862
  }
1403
- }
1404
- // facetPartitioning reinit if needed
1405
- let xSubRatio = 0;
1406
- let ySubRatio = 0;
1407
- let zSubRatio = 0;
1408
- let subSq = 0;
1409
- if (computeFacetPartitioning && options && options.bbSize) {
1410
- //let bbSizeMax = options.bbSize.x > options.bbSize.y ? options.bbSize.x : options.bbSize.y;
1411
- //bbSizeMax = bbSizeMax > options.bbSize.z ? bbSizeMax : options.bbSize.z;
1412
- xSubRatio = (options.subDiv.X * ratio) / options.bbSize.x;
1413
- ySubRatio = (options.subDiv.Y * ratio) / options.bbSize.y;
1414
- zSubRatio = (options.subDiv.Z * ratio) / options.bbSize.z;
1415
- subSq = options.subDiv.max * options.subDiv.max;
1416
- options.facetPartitioning.length = 0;
1417
- }
1418
- // reset the normals
1419
- for (index = 0; index < positions.length; index++) {
1420
- normals[index] = 0.0;
1421
- }
1422
- // Loop : 1 indice triplet = 1 facet
1423
- const nbFaces = (indices.length / 3) | 0;
1424
- for (index = 0; index < nbFaces; index++) {
1425
- // get the indexes of the coordinates of each vertex of the facet
1426
- v1x = indices[index * 3] * 3;
1427
- v1y = v1x + 1;
1428
- v1z = v1x + 2;
1429
- v2x = indices[index * 3 + 1] * 3;
1430
- v2y = v2x + 1;
1431
- v2z = v2x + 2;
1432
- v3x = indices[index * 3 + 2] * 3;
1433
- v3y = v3x + 1;
1434
- v3z = v3x + 2;
1435
- p1p2x = positions[v1x] - positions[v2x]; // compute two vectors per facet : p1p2 and p3p2
1436
- p1p2y = positions[v1y] - positions[v2y];
1437
- p1p2z = positions[v1z] - positions[v2z];
1438
- p3p2x = positions[v3x] - positions[v2x];
1439
- p3p2y = positions[v3y] - positions[v2y];
1440
- p3p2z = positions[v3z] - positions[v2z];
1441
- // compute the face normal with the cross product
1442
- faceNormalx = faceNormalSign * (p1p2y * p3p2z - p1p2z * p3p2y);
1443
- faceNormaly = faceNormalSign * (p1p2z * p3p2x - p1p2x * p3p2z);
1444
- faceNormalz = faceNormalSign * (p1p2x * p3p2y - p1p2y * p3p2x);
1445
- // normalize this normal and store it in the array facetData
1446
- length = Math.sqrt(faceNormalx * faceNormalx + faceNormaly * faceNormaly + faceNormalz * faceNormalz);
1447
- length = length === 0 ? 1.0 : length;
1448
- faceNormalx /= length;
1449
- faceNormaly /= length;
1450
- faceNormalz /= length;
1451
- if (computeFacetNormals && options) {
1452
- options.facetNormals[index].x = faceNormalx;
1453
- options.facetNormals[index].y = faceNormaly;
1454
- options.facetNormals[index].z = faceNormalz;
1455
- }
1456
- if (computeFacetPositions && options) {
1457
- // compute and the facet barycenter coordinates in the array facetPositions
1458
- options.facetPositions[index].x = (positions[v1x] + positions[v2x] + positions[v3x]) / 3.0;
1459
- options.facetPositions[index].y = (positions[v1y] + positions[v2y] + positions[v3y]) / 3.0;
1460
- options.facetPositions[index].z = (positions[v1z] + positions[v2z] + positions[v3z]) / 3.0;
1461
- }
1462
- if (computeFacetPartitioning && options) {
1463
- // store the facet indexes in arrays in the main facetPartitioning array :
1464
- // compute each facet vertex (+ facet barycenter) index in the partiniong array
1465
- const ox = Math.floor((options.facetPositions[index].x - options.bInfo.minimum.x * ratio) * xSubRatio);
1466
- const oy = Math.floor((options.facetPositions[index].y - options.bInfo.minimum.y * ratio) * ySubRatio);
1467
- const oz = Math.floor((options.facetPositions[index].z - options.bInfo.minimum.z * ratio) * zSubRatio);
1468
- const b1x = Math.floor((positions[v1x] - options.bInfo.minimum.x * ratio) * xSubRatio);
1469
- const b1y = Math.floor((positions[v1y] - options.bInfo.minimum.y * ratio) * ySubRatio);
1470
- const b1z = Math.floor((positions[v1z] - options.bInfo.minimum.z * ratio) * zSubRatio);
1471
- const b2x = Math.floor((positions[v2x] - options.bInfo.minimum.x * ratio) * xSubRatio);
1472
- const b2y = Math.floor((positions[v2y] - options.bInfo.minimum.y * ratio) * ySubRatio);
1473
- const b2z = Math.floor((positions[v2z] - options.bInfo.minimum.z * ratio) * zSubRatio);
1474
- const b3x = Math.floor((positions[v3x] - options.bInfo.minimum.x * ratio) * xSubRatio);
1475
- const b3y = Math.floor((positions[v3y] - options.bInfo.minimum.y * ratio) * ySubRatio);
1476
- const b3z = Math.floor((positions[v3z] - options.bInfo.minimum.z * ratio) * zSubRatio);
1477
- const blockIdxV1 = b1x + options.subDiv.max * b1y + subSq * b1z;
1478
- const blockIdxV2 = b2x + options.subDiv.max * b2y + subSq * b2z;
1479
- const blockIdxV3 = b3x + options.subDiv.max * b3y + subSq * b3z;
1480
- const blockIdxV4 = ox + options.subDiv.max * oy + subSq * oz;
1481
- options.facetPartitioning[blockIdxV4] = options.facetPartitioning[blockIdxV4] ? options.facetPartitioning[blockIdxV4] : [];
1482
- options.facetPartitioning[blockIdxV1] = options.facetPartitioning[blockIdxV1] ? options.facetPartitioning[blockIdxV1] : [];
1483
- options.facetPartitioning[blockIdxV2] = options.facetPartitioning[blockIdxV2] ? options.facetPartitioning[blockIdxV2] : [];
1484
- options.facetPartitioning[blockIdxV3] = options.facetPartitioning[blockIdxV3] ? options.facetPartitioning[blockIdxV3] : [];
1485
- // push each facet index in each block containing the vertex
1486
- options.facetPartitioning[blockIdxV1].push(index);
1487
- if (blockIdxV2 != blockIdxV1) {
1488
- options.facetPartitioning[blockIdxV2].push(index);
1489
- }
1490
- if (!(blockIdxV3 == blockIdxV2 || blockIdxV3 == blockIdxV1)) {
1491
- options.facetPartitioning[blockIdxV3].push(index);
1492
- }
1493
- if (!(blockIdxV4 == blockIdxV1 || blockIdxV4 == blockIdxV2 || blockIdxV4 == blockIdxV3)) {
1494
- options.facetPartitioning[blockIdxV4].push(index);
863
+ /**
864
+ * Clone the current vertex data
865
+ * @returns a copy of the current data
866
+ */
867
+ clone() {
868
+ const serializationObject = this.serialize();
869
+ return _a.Parse(serializationObject);
870
+ }
871
+ /**
872
+ * Serializes the VertexData
873
+ * @returns a serialized object
874
+ */
875
+ serialize() {
876
+ const serializationObject = {};
877
+ if (this.positions) {
878
+ serializationObject.positions = Array.from(this.positions);
879
+ }
880
+ if (this.normals) {
881
+ serializationObject.normals = Array.from(this.normals);
882
+ }
883
+ if (this.tangents) {
884
+ serializationObject.tangents = Array.from(this.tangents);
885
+ }
886
+ if (this.uvs) {
887
+ serializationObject.uvs = Array.from(this.uvs);
888
+ }
889
+ if (this.uvs2) {
890
+ serializationObject.uvs2 = Array.from(this.uvs2);
891
+ }
892
+ if (this.uvs3) {
893
+ serializationObject.uvs3 = Array.from(this.uvs3);
894
+ }
895
+ if (this.uvs4) {
896
+ serializationObject.uvs4 = Array.from(this.uvs4);
897
+ }
898
+ if (this.uvs5) {
899
+ serializationObject.uvs5 = Array.from(this.uvs5);
900
+ }
901
+ if (this.uvs6) {
902
+ serializationObject.uvs6 = Array.from(this.uvs6);
903
+ }
904
+ if (this.colors) {
905
+ serializationObject.colors = Array.from(this.colors);
906
+ serializationObject.hasVertexAlpha = this.hasVertexAlpha;
907
+ }
908
+ if (this.matricesIndices) {
909
+ serializationObject.matricesIndices = Array.from(this.matricesIndices);
910
+ serializationObject.matricesIndicesExpanded = true;
911
+ }
912
+ if (this.matricesWeights) {
913
+ serializationObject.matricesWeights = Array.from(this.matricesWeights);
914
+ }
915
+ if (this.matricesIndicesExtra) {
916
+ serializationObject.matricesIndicesExtra = Array.from(this.matricesIndicesExtra);
917
+ serializationObject.matricesIndicesExtraExpanded = true;
918
+ }
919
+ if (this.matricesWeightsExtra) {
920
+ serializationObject.matricesWeightsExtra = Array.from(this.matricesWeightsExtra);
921
+ }
922
+ serializationObject.indices = this.indices ? Array.from(this.indices) : [];
923
+ if (this.materialInfos) {
924
+ serializationObject.materialInfos = [];
925
+ for (const materialInfo of this.materialInfos) {
926
+ const materialInfoSerializationObject = {
927
+ indexStart: materialInfo.indexStart,
928
+ indexCount: materialInfo.indexCount,
929
+ materialIndex: materialInfo.materialIndex,
930
+ verticesStart: materialInfo.verticesStart,
931
+ verticesCount: materialInfo.verticesCount,
932
+ };
933
+ serializationObject.materialInfos.push(materialInfoSerializationObject);
934
+ }
935
+ }
936
+ return serializationObject;
937
+ }
938
+ // Statics
939
+ /**
940
+ * Extracts the vertexData from a mesh
941
+ * @param mesh the mesh from which to extract the VertexData
942
+ * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
943
+ * @param forceCopy indicating that the VertexData must be cloned, optional, default false
944
+ * @returns the object VertexData associated to the passed mesh
945
+ */
946
+ static ExtractFromMesh(mesh, copyWhenShared, forceCopy) {
947
+ return _a._ExtractFrom(mesh, copyWhenShared, forceCopy);
948
+ }
949
+ /**
950
+ * Extracts the vertexData from the geometry
951
+ * @param geometry the geometry from which to extract the VertexData
952
+ * @param copyWhenShared defines if the VertexData must be cloned when the geometry is shared between multiple meshes, optional, default false
953
+ * @param forceCopy indicating that the VertexData must be cloned, optional, default false
954
+ * @returns the object VertexData associated to the passed mesh
955
+ */
956
+ static ExtractFromGeometry(geometry, copyWhenShared, forceCopy) {
957
+ return _a._ExtractFrom(geometry, copyWhenShared, forceCopy);
958
+ }
959
+ static _ExtractFrom(meshOrGeometry, copyWhenShared, forceCopy) {
960
+ const result = new _a();
961
+ if (meshOrGeometry.isVerticesDataPresent(VertexBuffer.PositionKind)) {
962
+ result.positions = meshOrGeometry.getVerticesData(VertexBuffer.PositionKind, copyWhenShared, forceCopy);
963
+ }
964
+ if (meshOrGeometry.isVerticesDataPresent(VertexBuffer.NormalKind)) {
965
+ result.normals = meshOrGeometry.getVerticesData(VertexBuffer.NormalKind, copyWhenShared, forceCopy);
966
+ }
967
+ if (meshOrGeometry.isVerticesDataPresent(VertexBuffer.TangentKind)) {
968
+ result.tangents = meshOrGeometry.getVerticesData(VertexBuffer.TangentKind, copyWhenShared, forceCopy);
969
+ }
970
+ if (meshOrGeometry.isVerticesDataPresent(VertexBuffer.UVKind)) {
971
+ result.uvs = meshOrGeometry.getVerticesData(VertexBuffer.UVKind, copyWhenShared, forceCopy);
972
+ }
973
+ if (meshOrGeometry.isVerticesDataPresent(VertexBuffer.UV2Kind)) {
974
+ result.uvs2 = meshOrGeometry.getVerticesData(VertexBuffer.UV2Kind, copyWhenShared, forceCopy);
975
+ }
976
+ if (meshOrGeometry.isVerticesDataPresent(VertexBuffer.UV3Kind)) {
977
+ result.uvs3 = meshOrGeometry.getVerticesData(VertexBuffer.UV3Kind, copyWhenShared, forceCopy);
978
+ }
979
+ if (meshOrGeometry.isVerticesDataPresent(VertexBuffer.UV4Kind)) {
980
+ result.uvs4 = meshOrGeometry.getVerticesData(VertexBuffer.UV4Kind, copyWhenShared, forceCopy);
981
+ }
982
+ if (meshOrGeometry.isVerticesDataPresent(VertexBuffer.UV5Kind)) {
983
+ result.uvs5 = meshOrGeometry.getVerticesData(VertexBuffer.UV5Kind, copyWhenShared, forceCopy);
984
+ }
985
+ if (meshOrGeometry.isVerticesDataPresent(VertexBuffer.UV6Kind)) {
986
+ result.uvs6 = meshOrGeometry.getVerticesData(VertexBuffer.UV6Kind, copyWhenShared, forceCopy);
987
+ }
988
+ if (meshOrGeometry.isVerticesDataPresent(VertexBuffer.ColorKind)) {
989
+ const geometry = meshOrGeometry.geometry || meshOrGeometry;
990
+ const vertexBuffer = geometry.getVertexBuffer(VertexBuffer.ColorKind);
991
+ const colors = geometry.getVerticesData(VertexBuffer.ColorKind, copyWhenShared, forceCopy);
992
+ if (vertexBuffer.getSize() === 3) {
993
+ const newColors = new Float32Array((colors.length * 4) / 3);
994
+ for (let i = 0, j = 0; i < colors.length; i += 3, j += 4) {
995
+ newColors[j] = colors[i];
996
+ newColors[j + 1] = colors[i + 1];
997
+ newColors[j + 2] = colors[i + 2];
998
+ newColors[j + 3] = 1;
999
+ }
1000
+ result.colors = newColors;
1001
+ }
1002
+ else if (vertexBuffer.getSize() === 4) {
1003
+ result.colors = colors;
1004
+ }
1005
+ else {
1006
+ throw new Error(`Unexpected number of color components: ${vertexBuffer.getSize()}`);
1007
+ }
1008
+ }
1009
+ if (meshOrGeometry.isVerticesDataPresent(VertexBuffer.MatricesIndicesKind)) {
1010
+ result.matricesIndices = meshOrGeometry.getVerticesData(VertexBuffer.MatricesIndicesKind, copyWhenShared, forceCopy);
1011
+ }
1012
+ if (meshOrGeometry.isVerticesDataPresent(VertexBuffer.MatricesWeightsKind)) {
1013
+ result.matricesWeights = meshOrGeometry.getVerticesData(VertexBuffer.MatricesWeightsKind, copyWhenShared, forceCopy);
1014
+ }
1015
+ if (meshOrGeometry.isVerticesDataPresent(VertexBuffer.MatricesIndicesExtraKind)) {
1016
+ result.matricesIndicesExtra = meshOrGeometry.getVerticesData(VertexBuffer.MatricesIndicesExtraKind, copyWhenShared, forceCopy);
1017
+ }
1018
+ if (meshOrGeometry.isVerticesDataPresent(VertexBuffer.MatricesWeightsExtraKind)) {
1019
+ result.matricesWeightsExtra = meshOrGeometry.getVerticesData(VertexBuffer.MatricesWeightsExtraKind, copyWhenShared, forceCopy);
1020
+ }
1021
+ result.indices = meshOrGeometry.getIndices(copyWhenShared, forceCopy);
1022
+ return result;
1023
+ }
1024
+ /**
1025
+ * Creates the VertexData for a Ribbon
1026
+ * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
1027
+ * * pathArray array of paths, each of which an array of successive Vector3
1028
+ * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
1029
+ * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
1030
+ * * offset a positive integer, only used when pathArray contains a single path (offset = 10 means the point 1 is joined to the point 11), default rounded half size of the pathArray length
1031
+ * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
1032
+ * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
1033
+ * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
1034
+ * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
1035
+ * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
1036
+ * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
1037
+ * @returns the VertexData of the ribbon
1038
+ * @deprecated use CreateRibbonVertexData instead
1039
+ */
1040
+ static CreateRibbon(options) {
1041
+ throw _WarnImport("ribbonBuilder");
1042
+ }
1043
+ /**
1044
+ * Creates the VertexData for a box
1045
+ * @param options an object used to set the following optional parameters for the box, required but can be empty
1046
+ * * size sets the width, height and depth of the box to the value of size, optional default 1
1047
+ * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
1048
+ * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
1049
+ * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
1050
+ * * faceUV an array of 6 Vector4 elements used to set different images to each box side
1051
+ * * faceColors an array of 6 Color3 elements used to set different colors to each box side
1052
+ * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
1053
+ * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
1054
+ * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
1055
+ * @returns the VertexData of the box
1056
+ * @deprecated Please use CreateBoxVertexData from the BoxBuilder file instead
1057
+ */
1058
+ static CreateBox(options) {
1059
+ throw _WarnImport("boxBuilder");
1060
+ }
1061
+ /**
1062
+ * Creates the VertexData for a tiled box
1063
+ * @param options an object used to set the following optional parameters for the box, required but can be empty
1064
+ * - `pattern` sets the pattern
1065
+ * - `width` sets the width
1066
+ * - `height` sets the height
1067
+ * - `depth` sets the depth
1068
+ * - `tileSize` sets the tile size
1069
+ * - `tileWidth` sets the tile width
1070
+ * - `tileHeight` sets the tile height
1071
+ * - `alignHorizontal` sets the horizontal alignment
1072
+ * - `alignVertical` sets the vertical alignment
1073
+ * - `faceUV` an array of 6 Vector4 elements used to set different images to each box side
1074
+ * - `faceColors` an array of 6 Color3 elements used to set different colors to each box side
1075
+ * - `sideOrientation` optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
1076
+ * @returns the VertexData of the box
1077
+ * @deprecated Please use CreateTiledBoxVertexData instead
1078
+ */
1079
+ static CreateTiledBox(options) {
1080
+ throw _WarnImport("tiledBoxBuilder");
1081
+ }
1082
+ /**
1083
+ * Creates the VertexData for a tiled plane
1084
+ * @param options an object used to set the following optional parameters for the box, required but can be empty
1085
+ * * pattern a limited pattern arrangement depending on the number
1086
+ * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
1087
+ * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
1088
+ * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
1089
+ * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
1090
+ * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
1091
+ * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
1092
+ * @returns the VertexData of the tiled plane
1093
+ * @deprecated use CreateTiledPlaneVertexData instead
1094
+ */
1095
+ static CreateTiledPlane(options) {
1096
+ throw _WarnImport("tiledPlaneBuilder");
1097
+ }
1098
+ /**
1099
+ * Creates the VertexData for an ellipsoid, defaults to a sphere
1100
+ * @param options an object used to set the following optional parameters for the box, required but can be empty
1101
+ * * segments sets the number of horizontal strips optional, default 32
1102
+ * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
1103
+ * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
1104
+ * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
1105
+ * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
1106
+ * * arc a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the circumference (latitude) given by the arc value, optional, default 1
1107
+ * * slice a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the height (latitude) given by the arc value, optional, default 1
1108
+ * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
1109
+ * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
1110
+ * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
1111
+ * @returns the VertexData of the ellipsoid
1112
+ * @deprecated use CreateSphereVertexData instead
1113
+ */
1114
+ static CreateSphere(options) {
1115
+ throw _WarnImport("sphereBuilder");
1116
+ }
1117
+ /**
1118
+ * Creates the VertexData for a cylinder, cone or prism
1119
+ * @param options an object used to set the following optional parameters for the box, required but can be empty
1120
+ * * height sets the height (y direction) of the cylinder, optional, default 2
1121
+ * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
1122
+ * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
1123
+ * * diameter sets the diameter of the top and bottom of the cone, optional default 1
1124
+ * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
1125
+ * * `subdivisions` the number of rings along the cylinder height, optional, default 1
1126
+ * * arc a number from 0 to 1, to create an unclosed cylinder based on the fraction of the circumference given by the arc value, optional, default 1
1127
+ * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
1128
+ * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
1129
+ * * hasRings when true makes each subdivision independently treated as a face for faceUV and faceColors, optional, default false
1130
+ * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
1131
+ * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
1132
+ * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
1133
+ * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
1134
+ * @returns the VertexData of the cylinder, cone or prism
1135
+ * @deprecated please use CreateCylinderVertexData instead
1136
+ */
1137
+ static CreateCylinder(options) {
1138
+ throw _WarnImport("cylinderBuilder");
1139
+ }
1140
+ /**
1141
+ * Creates the VertexData for a torus
1142
+ * @param options an object used to set the following optional parameters for the box, required but can be empty
1143
+ * * diameter the diameter of the torus, optional default 1
1144
+ * * thickness the diameter of the tube forming the torus, optional default 0.5
1145
+ * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
1146
+ * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
1147
+ * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
1148
+ * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
1149
+ * @returns the VertexData of the torus
1150
+ * @deprecated use CreateTorusVertexData instead
1151
+ */
1152
+ static CreateTorus(options) {
1153
+ throw _WarnImport("torusBuilder");
1154
+ }
1155
+ /**
1156
+ * Creates the VertexData of the LineSystem
1157
+ * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
1158
+ * - lines an array of lines, each line being an array of successive Vector3
1159
+ * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
1160
+ * @returns the VertexData of the LineSystem
1161
+ * @deprecated use CreateLineSystemVertexData instead
1162
+ */
1163
+ static CreateLineSystem(options) {
1164
+ throw _WarnImport("linesBuilder");
1165
+ }
1166
+ /**
1167
+ * Create the VertexData for a DashedLines
1168
+ * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
1169
+ * - points an array successive Vector3
1170
+ * - dashSize the size of the dashes relative to the dash number, optional, default 3
1171
+ * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
1172
+ * - dashNb the intended total number of dashes, optional, default 200
1173
+ * @returns the VertexData for the DashedLines
1174
+ * @deprecated use CreateDashedLinesVertexData instead
1175
+ */
1176
+ static CreateDashedLines(options) {
1177
+ throw _WarnImport("linesBuilder");
1178
+ }
1179
+ /**
1180
+ * Creates the VertexData for a Ground
1181
+ * @param options an object used to set the following optional parameters for the Ground, required but can be empty
1182
+ * - width the width (x direction) of the ground, optional, default 1
1183
+ * - height the height (z direction) of the ground, optional, default 1
1184
+ * - subdivisions the number of subdivisions per side, optional, default 1
1185
+ * @returns the VertexData of the Ground
1186
+ * @deprecated Please use CreateGroundVertexData instead
1187
+ */
1188
+ static CreateGround(options) {
1189
+ throw _WarnImport("groundBuilder");
1190
+ }
1191
+ /**
1192
+ * Creates the VertexData for a TiledGround by subdividing the ground into tiles
1193
+ * @param options an object used to set the following optional parameters for the Ground, required but can be empty
1194
+ * * xmin the ground minimum X coordinate, optional, default -1
1195
+ * * zmin the ground minimum Z coordinate, optional, default -1
1196
+ * * xmax the ground maximum X coordinate, optional, default 1
1197
+ * * zmax the ground maximum Z coordinate, optional, default 1
1198
+ * * subdivisions a javascript object `\{w: positive integer, h: positive integer\}`, `w` and `h` are the numbers of subdivisions on the ground width and height creating 'tiles', default `\{w: 6, h: 6\}`
1199
+ * * precision a javascript object `\{w: positive integer, h: positive integer\}`, `w` and `h` are the numbers of subdivisions on the tile width and height, default `\{w: 2, h: 2\}`
1200
+ * @returns the VertexData of the TiledGround
1201
+ * @deprecated use CreateTiledGroundVertexData instead
1202
+ */
1203
+ static CreateTiledGround(options) {
1204
+ throw _WarnImport("groundBuilder");
1205
+ }
1206
+ /**
1207
+ * Creates the VertexData of the Ground designed from a heightmap
1208
+ * @param options an object used to set the following parameters for the Ground, required and provided by CreateGroundFromHeightMap
1209
+ * * width the width (x direction) of the ground
1210
+ * * height the height (z direction) of the ground
1211
+ * * subdivisions the number of subdivisions per side
1212
+ * * minHeight the minimum altitude on the ground, optional, default 0
1213
+ * * maxHeight the maximum altitude on the ground, optional default 1
1214
+ * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
1215
+ * * buffer the array holding the image color data
1216
+ * * bufferWidth the width of image
1217
+ * * bufferHeight the height of image
1218
+ * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
1219
+ * @returns the VertexData of the Ground designed from a heightmap
1220
+ * @deprecated use CreateGroundFromHeightMapVertexData instead
1221
+ */
1222
+ static CreateGroundFromHeightMap(options) {
1223
+ throw _WarnImport("groundBuilder");
1224
+ }
1225
+ /**
1226
+ * Creates the VertexData for a Plane
1227
+ * @param options an object used to set the following optional parameters for the plane, required but can be empty
1228
+ * * size sets the width and height of the plane to the value of size, optional default 1
1229
+ * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
1230
+ * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
1231
+ * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
1232
+ * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
1233
+ * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
1234
+ * @returns the VertexData of the box
1235
+ * @deprecated use CreatePlaneVertexData instead
1236
+ */
1237
+ static CreatePlane(options) {
1238
+ throw _WarnImport("planeBuilder");
1239
+ }
1240
+ /**
1241
+ * Creates the VertexData of the Disc or regular Polygon
1242
+ * @param options an object used to set the following optional parameters for the disc, required but can be empty
1243
+ * * radius the radius of the disc, optional default 0.5
1244
+ * * tessellation the number of polygon sides, optional, default 64
1245
+ * * arc a number from 0 to 1, to create an unclosed polygon based on the fraction of the circumference given by the arc value, optional, default 1
1246
+ * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
1247
+ * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
1248
+ * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
1249
+ * @returns the VertexData of the box
1250
+ * @deprecated use CreateDiscVertexData instead
1251
+ */
1252
+ static CreateDisc(options) {
1253
+ throw _WarnImport("discBuilder");
1254
+ }
1255
+ /**
1256
+ * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
1257
+ * All parameters are provided by CreatePolygon as needed
1258
+ * @param polygon a mesh built from polygonTriangulation.build()
1259
+ * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
1260
+ * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
1261
+ * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
1262
+ * @param frontUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
1263
+ * @param backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
1264
+ * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
1265
+ * @returns the VertexData of the Polygon
1266
+ * @deprecated use CreatePolygonVertexData instead
1267
+ */
1268
+ static CreatePolygon(polygon, sideOrientation, fUV, fColors, frontUVs, backUVs, wrap) {
1269
+ throw _WarnImport("polygonBuilder");
1270
+ }
1271
+ /**
1272
+ * Creates the VertexData of the IcoSphere
1273
+ * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
1274
+ * * radius the radius of the IcoSphere, optional default 1
1275
+ * * radiusX allows stretching in the x direction, optional, default radius
1276
+ * * radiusY allows stretching in the y direction, optional, default radius
1277
+ * * radiusZ allows stretching in the z direction, optional, default radius
1278
+ * * flat when true creates a flat shaded mesh, optional, default true
1279
+ * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
1280
+ * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
1281
+ * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
1282
+ * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
1283
+ * @returns the VertexData of the IcoSphere
1284
+ * @deprecated use CreateIcoSphereVertexData instead
1285
+ */
1286
+ static CreateIcoSphere(options) {
1287
+ throw _WarnImport("icoSphereBuilder");
1288
+ }
1289
+ // inspired from // http://stemkoski.github.io/Three.js/Polyhedra.html
1290
+ /**
1291
+ * Creates the VertexData for a Polyhedron
1292
+ * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
1293
+ * * type provided types are:
1294
+ * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
1295
+ * * 9 : Pentagonal Pyramid (J2), 10 : Triangular Dipyramid (J12), 11 : Pentagonal Dipyramid (J13), 12 : Elongated Square Dipyramid (J15), 13 : Elongated Pentagonal Dipyramid (J16), 14 : Elongated Pentagonal Cupola (J20)
1296
+ * * size the size of the IcoSphere, optional default 1
1297
+ * * sizeX allows stretching in the x direction, optional, default size
1298
+ * * sizeY allows stretching in the y direction, optional, default size
1299
+ * * sizeZ allows stretching in the z direction, optional, default size
1300
+ * * custom a number that overwrites the type to create from an extended set of polyhedron from https://www.babylonjs-playground.com/#21QRSK#15 with minimised editor
1301
+ * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
1302
+ * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
1303
+ * * flat when true creates a flat shaded mesh, optional, default true
1304
+ * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
1305
+ * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
1306
+ * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
1307
+ * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
1308
+ * @returns the VertexData of the Polyhedron
1309
+ * @deprecated use CreatePolyhedronVertexData instead
1310
+ */
1311
+ static CreatePolyhedron(options) {
1312
+ throw _WarnImport("polyhedronBuilder");
1313
+ }
1314
+ /**
1315
+ * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
1316
+ * @param options an object used to set the following optional parameters for the capsule, required but can be empty
1317
+ * @returns the VertexData of the Capsule
1318
+ * @deprecated Please use CreateCapsuleVertexData from the capsuleBuilder file instead
1319
+ */
1320
+ static CreateCapsule(options = {
1321
+ orientation: Vector3.Up(),
1322
+ subdivisions: 2,
1323
+ tessellation: 16,
1324
+ height: 1,
1325
+ radius: 0.25,
1326
+ capSubdivisions: 6,
1327
+ }) {
1328
+ throw _WarnImport("capsuleBuilder");
1329
+ }
1330
+ // based on http://code.google.com/p/away3d/source/browse/trunk/fp10/Away3D/src/away3d/primitives/TorusKnot.as?spec=svn2473&r=2473
1331
+ /**
1332
+ * Creates the VertexData for a TorusKnot
1333
+ * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
1334
+ * * radius the radius of the torus knot, optional, default 2
1335
+ * * tube the thickness of the tube, optional, default 0.5
1336
+ * * radialSegments the number of sides on each tube segments, optional, default 32
1337
+ * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
1338
+ * * p the number of windings around the z axis, optional, default 2
1339
+ * * q the number of windings around the x axis, optional, default 3
1340
+ * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
1341
+ * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
1342
+ * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
1343
+ * @returns the VertexData of the Torus Knot
1344
+ * @deprecated use CreateTorusKnotVertexData instead
1345
+ */
1346
+ static CreateTorusKnot(options) {
1347
+ throw _WarnImport("torusKnotBuilder");
1348
+ }
1349
+ // Tools
1350
+ /**
1351
+ * Compute normals for given positions and indices
1352
+ * @param positions an array of vertex positions, [...., x, y, z, ......]
1353
+ * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
1354
+ * @param normals an array of vertex normals, [...., x, y, z, ......]
1355
+ * @param options an object used to set the following optional parameters for the TorusKnot, optional
1356
+ * * facetNormals : optional array of facet normals (vector3)
1357
+ * * facetPositions : optional array of facet positions (vector3)
1358
+ * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
1359
+ * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
1360
+ * * bInfo : optional bounding info, required for facetPartitioning computation
1361
+ * * bbSize : optional bounding box size data, required for facetPartitioning computation
1362
+ * * subDiv : optional partitioning data about subdivisions on each axis (int), required for facetPartitioning computation
1363
+ * * useRightHandedSystem: optional boolean to for right handed system computation
1364
+ * * depthSort : optional boolean to enable the facet depth sort computation
1365
+ * * distanceTo : optional Vector3 to compute the facet depth from this location
1366
+ * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
1367
+ */
1368
+ static ComputeNormals(positions, indices, normals, options) {
1369
+ // temporary scalar variables
1370
+ let index; // facet index
1371
+ let p1p2x; // p1p2 vector x coordinate
1372
+ let p1p2y; // p1p2 vector y coordinate
1373
+ let p1p2z; // p1p2 vector z coordinate
1374
+ let p3p2x; // p3p2 vector x coordinate
1375
+ let p3p2y; // p3p2 vector y coordinate
1376
+ let p3p2z; // p3p2 vector z coordinate
1377
+ let faceNormalx; // facet normal x coordinate
1378
+ let faceNormaly; // facet normal y coordinate
1379
+ let faceNormalz; // facet normal z coordinate
1380
+ let length; // facet normal length before normalization
1381
+ let v1x; // vector1 x index in the positions array
1382
+ let v1y; // vector1 y index in the positions array
1383
+ let v1z; // vector1 z index in the positions array
1384
+ let v2x; // vector2 x index in the positions array
1385
+ let v2y; // vector2 y index in the positions array
1386
+ let v2z; // vector2 z index in the positions array
1387
+ let v3x; // vector3 x index in the positions array
1388
+ let v3y; // vector3 y index in the positions array
1389
+ let v3z; // vector3 z index in the positions array
1390
+ let computeFacetNormals = false;
1391
+ let computeFacetPositions = false;
1392
+ let computeFacetPartitioning = false;
1393
+ let computeDepthSort = false;
1394
+ let faceNormalSign = 1;
1395
+ let ratio = 0;
1396
+ let distanceTo = null;
1397
+ if (options) {
1398
+ computeFacetNormals = options.facetNormals ? true : false;
1399
+ computeFacetPositions = options.facetPositions ? true : false;
1400
+ computeFacetPartitioning = options.facetPartitioning ? true : false;
1401
+ faceNormalSign = options.useRightHandedSystem === true ? -1 : 1;
1402
+ ratio = options.ratio || 0;
1403
+ computeDepthSort = options.depthSort ? true : false;
1404
+ distanceTo = options.distanceTo;
1405
+ if (computeDepthSort) {
1406
+ if (distanceTo === undefined) {
1407
+ distanceTo = Vector3.Zero();
1408
+ }
1409
+ }
1410
+ }
1411
+ // facetPartitioning reinit if needed
1412
+ let xSubRatio = 0;
1413
+ let ySubRatio = 0;
1414
+ let zSubRatio = 0;
1415
+ let subSq = 0;
1416
+ if (computeFacetPartitioning && options && options.bbSize) {
1417
+ //let bbSizeMax = options.bbSize.x > options.bbSize.y ? options.bbSize.x : options.bbSize.y;
1418
+ //bbSizeMax = bbSizeMax > options.bbSize.z ? bbSizeMax : options.bbSize.z;
1419
+ xSubRatio = (options.subDiv.X * ratio) / options.bbSize.x;
1420
+ ySubRatio = (options.subDiv.Y * ratio) / options.bbSize.y;
1421
+ zSubRatio = (options.subDiv.Z * ratio) / options.bbSize.z;
1422
+ subSq = options.subDiv.max * options.subDiv.max;
1423
+ options.facetPartitioning.length = 0;
1424
+ }
1425
+ // reset the normals
1426
+ for (index = 0; index < positions.length; index++) {
1427
+ normals[index] = 0.0;
1428
+ }
1429
+ // Loop : 1 indice triplet = 1 facet
1430
+ const nbFaces = (indices.length / 3) | 0;
1431
+ for (index = 0; index < nbFaces; index++) {
1432
+ // get the indexes of the coordinates of each vertex of the facet
1433
+ v1x = indices[index * 3] * 3;
1434
+ v1y = v1x + 1;
1435
+ v1z = v1x + 2;
1436
+ v2x = indices[index * 3 + 1] * 3;
1437
+ v2y = v2x + 1;
1438
+ v2z = v2x + 2;
1439
+ v3x = indices[index * 3 + 2] * 3;
1440
+ v3y = v3x + 1;
1441
+ v3z = v3x + 2;
1442
+ p1p2x = positions[v1x] - positions[v2x]; // compute two vectors per facet : p1p2 and p3p2
1443
+ p1p2y = positions[v1y] - positions[v2y];
1444
+ p1p2z = positions[v1z] - positions[v2z];
1445
+ p3p2x = positions[v3x] - positions[v2x];
1446
+ p3p2y = positions[v3y] - positions[v2y];
1447
+ p3p2z = positions[v3z] - positions[v2z];
1448
+ // compute the face normal with the cross product
1449
+ faceNormalx = faceNormalSign * (p1p2y * p3p2z - p1p2z * p3p2y);
1450
+ faceNormaly = faceNormalSign * (p1p2z * p3p2x - p1p2x * p3p2z);
1451
+ faceNormalz = faceNormalSign * (p1p2x * p3p2y - p1p2y * p3p2x);
1452
+ // normalize this normal and store it in the array facetData
1453
+ length = Math.sqrt(faceNormalx * faceNormalx + faceNormaly * faceNormaly + faceNormalz * faceNormalz);
1454
+ length = length === 0 ? 1.0 : length;
1455
+ faceNormalx /= length;
1456
+ faceNormaly /= length;
1457
+ faceNormalz /= length;
1458
+ if (computeFacetNormals && options) {
1459
+ options.facetNormals[index].x = faceNormalx;
1460
+ options.facetNormals[index].y = faceNormaly;
1461
+ options.facetNormals[index].z = faceNormalz;
1462
+ }
1463
+ if (computeFacetPositions && options) {
1464
+ // compute and the facet barycenter coordinates in the array facetPositions
1465
+ options.facetPositions[index].x = (positions[v1x] + positions[v2x] + positions[v3x]) / 3.0;
1466
+ options.facetPositions[index].y = (positions[v1y] + positions[v2y] + positions[v3y]) / 3.0;
1467
+ options.facetPositions[index].z = (positions[v1z] + positions[v2z] + positions[v3z]) / 3.0;
1468
+ }
1469
+ if (computeFacetPartitioning && options) {
1470
+ // store the facet indexes in arrays in the main facetPartitioning array :
1471
+ // compute each facet vertex (+ facet barycenter) index in the partiniong array
1472
+ const ox = Math.floor((options.facetPositions[index].x - options.bInfo.minimum.x * ratio) * xSubRatio);
1473
+ const oy = Math.floor((options.facetPositions[index].y - options.bInfo.minimum.y * ratio) * ySubRatio);
1474
+ const oz = Math.floor((options.facetPositions[index].z - options.bInfo.minimum.z * ratio) * zSubRatio);
1475
+ const b1x = Math.floor((positions[v1x] - options.bInfo.minimum.x * ratio) * xSubRatio);
1476
+ const b1y = Math.floor((positions[v1y] - options.bInfo.minimum.y * ratio) * ySubRatio);
1477
+ const b1z = Math.floor((positions[v1z] - options.bInfo.minimum.z * ratio) * zSubRatio);
1478
+ const b2x = Math.floor((positions[v2x] - options.bInfo.minimum.x * ratio) * xSubRatio);
1479
+ const b2y = Math.floor((positions[v2y] - options.bInfo.minimum.y * ratio) * ySubRatio);
1480
+ const b2z = Math.floor((positions[v2z] - options.bInfo.minimum.z * ratio) * zSubRatio);
1481
+ const b3x = Math.floor((positions[v3x] - options.bInfo.minimum.x * ratio) * xSubRatio);
1482
+ const b3y = Math.floor((positions[v3y] - options.bInfo.minimum.y * ratio) * ySubRatio);
1483
+ const b3z = Math.floor((positions[v3z] - options.bInfo.minimum.z * ratio) * zSubRatio);
1484
+ const blockIdxV1 = b1x + options.subDiv.max * b1y + subSq * b1z;
1485
+ const blockIdxV2 = b2x + options.subDiv.max * b2y + subSq * b2z;
1486
+ const blockIdxV3 = b3x + options.subDiv.max * b3y + subSq * b3z;
1487
+ const blockIdxV4 = ox + options.subDiv.max * oy + subSq * oz;
1488
+ options.facetPartitioning[blockIdxV4] = options.facetPartitioning[blockIdxV4] ? options.facetPartitioning[blockIdxV4] : [];
1489
+ options.facetPartitioning[blockIdxV1] = options.facetPartitioning[blockIdxV1] ? options.facetPartitioning[blockIdxV1] : [];
1490
+ options.facetPartitioning[blockIdxV2] = options.facetPartitioning[blockIdxV2] ? options.facetPartitioning[blockIdxV2] : [];
1491
+ options.facetPartitioning[blockIdxV3] = options.facetPartitioning[blockIdxV3] ? options.facetPartitioning[blockIdxV3] : [];
1492
+ // push each facet index in each block containing the vertex
1493
+ options.facetPartitioning[blockIdxV1].push(index);
1494
+ if (blockIdxV2 != blockIdxV1) {
1495
+ options.facetPartitioning[blockIdxV2].push(index);
1496
+ }
1497
+ if (!(blockIdxV3 == blockIdxV2 || blockIdxV3 == blockIdxV1)) {
1498
+ options.facetPartitioning[blockIdxV3].push(index);
1499
+ }
1500
+ if (!(blockIdxV4 == blockIdxV1 || blockIdxV4 == blockIdxV2 || blockIdxV4 == blockIdxV3)) {
1501
+ options.facetPartitioning[blockIdxV4].push(index);
1502
+ }
1503
+ }
1504
+ if (computeDepthSort && options && options.facetPositions) {
1505
+ const dsf = options.depthSortedFacets[index];
1506
+ dsf.ind = index * 3;
1507
+ dsf.sqDistance = Vector3.DistanceSquared(options.facetPositions[index], distanceTo);
1508
+ }
1509
+ // compute the normals anyway
1510
+ normals[v1x] += faceNormalx; // accumulate all the normals per face
1511
+ normals[v1y] += faceNormaly;
1512
+ normals[v1z] += faceNormalz;
1513
+ normals[v2x] += faceNormalx;
1514
+ normals[v2y] += faceNormaly;
1515
+ normals[v2z] += faceNormalz;
1516
+ normals[v3x] += faceNormalx;
1517
+ normals[v3y] += faceNormaly;
1518
+ normals[v3z] += faceNormalz;
1519
+ }
1520
+ // last normalization of each normal
1521
+ for (index = 0; index < normals.length / 3; index++) {
1522
+ faceNormalx = normals[index * 3];
1523
+ faceNormaly = normals[index * 3 + 1];
1524
+ faceNormalz = normals[index * 3 + 2];
1525
+ length = Math.sqrt(faceNormalx * faceNormalx + faceNormaly * faceNormaly + faceNormalz * faceNormalz);
1526
+ length = length === 0 ? 1.0 : length;
1527
+ faceNormalx /= length;
1528
+ faceNormaly /= length;
1529
+ faceNormalz /= length;
1530
+ normals[index * 3] = faceNormalx;
1531
+ normals[index * 3 + 1] = faceNormaly;
1532
+ normals[index * 3 + 2] = faceNormalz;
1495
1533
  }
1496
1534
  }
1497
- if (computeDepthSort && options && options.facetPositions) {
1498
- const dsf = options.depthSortedFacets[index];
1499
- dsf.ind = index * 3;
1500
- dsf.sqDistance = Vector3.DistanceSquared(options.facetPositions[index], distanceTo);
1535
+ /**
1536
+ * @internal
1537
+ */
1538
+ static _ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs, backUVs) {
1539
+ const li = indices.length;
1540
+ const ln = normals.length;
1541
+ let i;
1542
+ let n;
1543
+ sideOrientation = sideOrientation || _a.DEFAULTSIDE;
1544
+ switch (sideOrientation) {
1545
+ case _a.FRONTSIDE:
1546
+ // nothing changed
1547
+ break;
1548
+ case _a.BACKSIDE:
1549
+ // indices
1550
+ for (i = 0; i < li; i += 3) {
1551
+ const tmp = indices[i];
1552
+ indices[i] = indices[i + 2];
1553
+ indices[i + 2] = tmp;
1554
+ }
1555
+ // normals
1556
+ for (n = 0; n < ln; n++) {
1557
+ normals[n] = -normals[n];
1558
+ }
1559
+ break;
1560
+ case _a.DOUBLESIDE: {
1561
+ // positions
1562
+ const lp = positions.length;
1563
+ const l = lp / 3;
1564
+ for (let p = 0; p < lp; p++) {
1565
+ positions[lp + p] = positions[p];
1566
+ }
1567
+ // indices
1568
+ for (i = 0; i < li; i += 3) {
1569
+ indices[i + li] = indices[i + 2] + l;
1570
+ indices[i + 1 + li] = indices[i + 1] + l;
1571
+ indices[i + 2 + li] = indices[i] + l;
1572
+ }
1573
+ // normals
1574
+ for (n = 0; n < ln; n++) {
1575
+ normals[ln + n] = -normals[n];
1576
+ }
1577
+ // uvs
1578
+ const lu = uvs.length;
1579
+ let u;
1580
+ for (u = 0; u < lu; u++) {
1581
+ uvs[u + lu] = uvs[u];
1582
+ }
1583
+ frontUVs = frontUVs ? frontUVs : new Vector4(0.0, 0.0, 1.0, 1.0);
1584
+ backUVs = backUVs ? backUVs : new Vector4(0.0, 0.0, 1.0, 1.0);
1585
+ u = 0;
1586
+ for (i = 0; i < lu / 2; i++) {
1587
+ uvs[u] = frontUVs.x + (frontUVs.z - frontUVs.x) * uvs[u];
1588
+ uvs[u + 1] = frontUVs.y + (frontUVs.w - frontUVs.y) * uvs[u + 1];
1589
+ uvs[u + lu] = backUVs.x + (backUVs.z - backUVs.x) * uvs[u + lu];
1590
+ uvs[u + lu + 1] = backUVs.y + (backUVs.w - backUVs.y) * uvs[u + lu + 1];
1591
+ u += 2;
1592
+ }
1593
+ break;
1594
+ }
1595
+ }
1501
1596
  }
1502
- // compute the normals anyway
1503
- normals[v1x] += faceNormalx; // accumulate all the normals per face
1504
- normals[v1y] += faceNormaly;
1505
- normals[v1z] += faceNormalz;
1506
- normals[v2x] += faceNormalx;
1507
- normals[v2y] += faceNormaly;
1508
- normals[v2z] += faceNormalz;
1509
- normals[v3x] += faceNormalx;
1510
- normals[v3y] += faceNormaly;
1511
- normals[v3z] += faceNormalz;
1512
- }
1513
- // last normalization of each normal
1514
- for (index = 0; index < normals.length / 3; index++) {
1515
- faceNormalx = normals[index * 3];
1516
- faceNormaly = normals[index * 3 + 1];
1517
- faceNormalz = normals[index * 3 + 2];
1518
- length = Math.sqrt(faceNormalx * faceNormalx + faceNormaly * faceNormaly + faceNormalz * faceNormalz);
1519
- length = length === 0 ? 1.0 : length;
1520
- faceNormalx /= length;
1521
- faceNormaly /= length;
1522
- faceNormalz /= length;
1523
- normals[index * 3] = faceNormalx;
1524
- normals[index * 3 + 1] = faceNormaly;
1525
- normals[index * 3 + 2] = faceNormalz;
1526
- }
1527
- }
1528
- /**
1529
- * @internal
1530
- */
1531
- static _ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs, backUVs) {
1532
- const li = indices.length;
1533
- const ln = normals.length;
1534
- let i;
1535
- let n;
1536
- sideOrientation = sideOrientation || VertexData.DEFAULTSIDE;
1537
- switch (sideOrientation) {
1538
- case VertexData.FRONTSIDE:
1539
- // nothing changed
1540
- break;
1541
- case VertexData.BACKSIDE:
1542
- // indices
1543
- for (i = 0; i < li; i += 3) {
1544
- const tmp = indices[i];
1545
- indices[i] = indices[i + 2];
1546
- indices[i + 2] = tmp;
1597
+ /**
1598
+ * Creates a VertexData from serialized data
1599
+ * @param parsedVertexData the parsed data from an imported file
1600
+ * @returns a VertexData
1601
+ */
1602
+ static Parse(parsedVertexData) {
1603
+ const vertexData = new _a();
1604
+ // positions
1605
+ const positions = parsedVertexData.positions;
1606
+ if (positions) {
1607
+ vertexData.set(positions, VertexBuffer.PositionKind);
1547
1608
  }
1548
1609
  // normals
1549
- for (n = 0; n < ln; n++) {
1550
- normals[n] = -normals[n];
1610
+ const normals = parsedVertexData.normals;
1611
+ if (normals) {
1612
+ vertexData.set(normals, VertexBuffer.NormalKind);
1551
1613
  }
1552
- break;
1553
- case VertexData.DOUBLESIDE: {
1554
- // positions
1555
- const lp = positions.length;
1556
- const l = lp / 3;
1557
- for (let p = 0; p < lp; p++) {
1558
- positions[lp + p] = positions[p];
1614
+ // tangents
1615
+ const tangents = parsedVertexData.tangents;
1616
+ if (tangents) {
1617
+ vertexData.set(tangents, VertexBuffer.TangentKind);
1618
+ }
1619
+ // uvs
1620
+ const uvs = parsedVertexData.uvs;
1621
+ if (uvs) {
1622
+ vertexData.set(uvs, VertexBuffer.UVKind);
1623
+ }
1624
+ // uv2s
1625
+ const uvs2 = parsedVertexData.uvs2;
1626
+ if (uvs2) {
1627
+ vertexData.set(uvs2, VertexBuffer.UV2Kind);
1628
+ }
1629
+ // uv3s
1630
+ const uvs3 = parsedVertexData.uvs3;
1631
+ if (uvs3) {
1632
+ vertexData.set(uvs3, VertexBuffer.UV3Kind);
1633
+ }
1634
+ // uv4s
1635
+ const uvs4 = parsedVertexData.uvs4;
1636
+ if (uvs4) {
1637
+ vertexData.set(uvs4, VertexBuffer.UV4Kind);
1638
+ }
1639
+ // uv5s
1640
+ const uvs5 = parsedVertexData.uvs5;
1641
+ if (uvs5) {
1642
+ vertexData.set(uvs5, VertexBuffer.UV5Kind);
1643
+ }
1644
+ // uv6s
1645
+ const uvs6 = parsedVertexData.uvs6;
1646
+ if (uvs6) {
1647
+ vertexData.set(uvs6, VertexBuffer.UV6Kind);
1648
+ }
1649
+ // colors
1650
+ const colors = parsedVertexData.colors;
1651
+ if (colors) {
1652
+ vertexData.set(Color4.CheckColors4(colors, positions.length / 3), VertexBuffer.ColorKind);
1653
+ if (parsedVertexData.hasVertexAlpha !== undefined) {
1654
+ vertexData.hasVertexAlpha = parsedVertexData.hasVertexAlpha;
1655
+ }
1656
+ }
1657
+ // matricesIndices
1658
+ const matricesIndices = parsedVertexData.matricesIndices;
1659
+ if (matricesIndices) {
1660
+ vertexData.set(matricesIndices, VertexBuffer.MatricesIndicesKind);
1661
+ }
1662
+ // matricesWeights
1663
+ const matricesWeights = parsedVertexData.matricesWeights;
1664
+ if (matricesWeights) {
1665
+ vertexData.set(matricesWeights, VertexBuffer.MatricesWeightsKind);
1559
1666
  }
1560
1667
  // indices
1561
- for (i = 0; i < li; i += 3) {
1562
- indices[i + li] = indices[i + 2] + l;
1563
- indices[i + 1 + li] = indices[i + 1] + l;
1564
- indices[i + 2 + li] = indices[i] + l;
1668
+ const indices = parsedVertexData.indices;
1669
+ if (indices) {
1670
+ vertexData.indices = indices;
1565
1671
  }
1566
- // normals
1567
- for (n = 0; n < ln; n++) {
1568
- normals[ln + n] = -normals[n];
1672
+ // MaterialInfos
1673
+ const materialInfos = parsedVertexData.materialInfos;
1674
+ if (materialInfos) {
1675
+ vertexData.materialInfos = [];
1676
+ for (const materialInfoFromJSON of materialInfos) {
1677
+ const materialInfo = new VertexDataMaterialInfo();
1678
+ materialInfo.indexCount = materialInfoFromJSON.indexCount;
1679
+ materialInfo.indexStart = materialInfoFromJSON.indexStart;
1680
+ materialInfo.verticesCount = materialInfoFromJSON.verticesCount;
1681
+ materialInfo.verticesStart = materialInfoFromJSON.verticesStart;
1682
+ materialInfo.materialIndex = materialInfoFromJSON.materialIndex;
1683
+ vertexData.materialInfos.push(materialInfo);
1684
+ }
1569
1685
  }
1570
- // uvs
1571
- const lu = uvs.length;
1572
- let u;
1573
- for (u = 0; u < lu; u++) {
1574
- uvs[u + lu] = uvs[u];
1575
- }
1576
- frontUVs = frontUVs ? frontUVs : new Vector4(0.0, 0.0, 1.0, 1.0);
1577
- backUVs = backUVs ? backUVs : new Vector4(0.0, 0.0, 1.0, 1.0);
1578
- u = 0;
1579
- for (i = 0; i < lu / 2; i++) {
1580
- uvs[u] = frontUVs.x + (frontUVs.z - frontUVs.x) * uvs[u];
1581
- uvs[u + 1] = frontUVs.y + (frontUVs.w - frontUVs.y) * uvs[u + 1];
1582
- uvs[u + lu] = backUVs.x + (backUVs.z - backUVs.x) * uvs[u + lu];
1583
- uvs[u + lu + 1] = backUVs.y + (backUVs.w - backUVs.y) * uvs[u + lu + 1];
1584
- u += 2;
1585
- }
1586
- break;
1587
- }
1588
- }
1589
- }
1590
- /**
1591
- * Creates a VertexData from serialized data
1592
- * @param parsedVertexData the parsed data from an imported file
1593
- * @returns a VertexData
1594
- */
1595
- static Parse(parsedVertexData) {
1596
- const vertexData = new VertexData();
1597
- // positions
1598
- const positions = parsedVertexData.positions;
1599
- if (positions) {
1600
- vertexData.set(positions, VertexBuffer.PositionKind);
1601
- }
1602
- // normals
1603
- const normals = parsedVertexData.normals;
1604
- if (normals) {
1605
- vertexData.set(normals, VertexBuffer.NormalKind);
1606
- }
1607
- // tangents
1608
- const tangents = parsedVertexData.tangents;
1609
- if (tangents) {
1610
- vertexData.set(tangents, VertexBuffer.TangentKind);
1611
- }
1612
- // uvs
1613
- const uvs = parsedVertexData.uvs;
1614
- if (uvs) {
1615
- vertexData.set(uvs, VertexBuffer.UVKind);
1616
- }
1617
- // uv2s
1618
- const uvs2 = parsedVertexData.uvs2;
1619
- if (uvs2) {
1620
- vertexData.set(uvs2, VertexBuffer.UV2Kind);
1621
- }
1622
- // uv3s
1623
- const uvs3 = parsedVertexData.uvs3;
1624
- if (uvs3) {
1625
- vertexData.set(uvs3, VertexBuffer.UV3Kind);
1626
- }
1627
- // uv4s
1628
- const uvs4 = parsedVertexData.uvs4;
1629
- if (uvs4) {
1630
- vertexData.set(uvs4, VertexBuffer.UV4Kind);
1631
- }
1632
- // uv5s
1633
- const uvs5 = parsedVertexData.uvs5;
1634
- if (uvs5) {
1635
- vertexData.set(uvs5, VertexBuffer.UV5Kind);
1636
- }
1637
- // uv6s
1638
- const uvs6 = parsedVertexData.uvs6;
1639
- if (uvs6) {
1640
- vertexData.set(uvs6, VertexBuffer.UV6Kind);
1641
- }
1642
- // colors
1643
- const colors = parsedVertexData.colors;
1644
- if (colors) {
1645
- vertexData.set(Color4.CheckColors4(colors, positions.length / 3), VertexBuffer.ColorKind);
1646
- if (parsedVertexData.hasVertexAlpha !== undefined) {
1647
- vertexData.hasVertexAlpha = parsedVertexData.hasVertexAlpha;
1648
- }
1649
- }
1650
- // matricesIndices
1651
- const matricesIndices = parsedVertexData.matricesIndices;
1652
- if (matricesIndices) {
1653
- vertexData.set(matricesIndices, VertexBuffer.MatricesIndicesKind);
1654
- }
1655
- // matricesWeights
1656
- const matricesWeights = parsedVertexData.matricesWeights;
1657
- if (matricesWeights) {
1658
- vertexData.set(matricesWeights, VertexBuffer.MatricesWeightsKind);
1659
- }
1660
- // indices
1661
- const indices = parsedVertexData.indices;
1662
- if (indices) {
1663
- vertexData.indices = indices;
1664
- }
1665
- // MaterialInfos
1666
- const materialInfos = parsedVertexData.materialInfos;
1667
- if (materialInfos) {
1668
- vertexData.materialInfos = [];
1669
- for (const materialInfoFromJSON of materialInfos) {
1670
- const materialInfo = new VertexDataMaterialInfo();
1671
- materialInfo.indexCount = materialInfoFromJSON.indexCount;
1672
- materialInfo.indexStart = materialInfoFromJSON.indexStart;
1673
- materialInfo.verticesCount = materialInfoFromJSON.verticesCount;
1674
- materialInfo.verticesStart = materialInfoFromJSON.verticesStart;
1675
- materialInfo.materialIndex = materialInfoFromJSON.materialIndex;
1676
- vertexData.materialInfos.push(materialInfo);
1677
- }
1678
- }
1679
- return vertexData;
1680
- }
1681
- /**
1682
- * Applies VertexData created from the imported parameters to the geometry
1683
- * @param parsedVertexData the parsed data from an imported file
1684
- * @param geometry the geometry to apply the VertexData to
1685
- */
1686
- static ImportVertexData(parsedVertexData, geometry) {
1687
- const vertexData = VertexData.Parse(parsedVertexData);
1688
- geometry.setAllVerticesData(vertexData, parsedVertexData.updatable);
1689
- }
1690
- }
1691
- /**
1692
- * Mesh side orientation : usually the external or front surface
1693
- */
1694
- VertexData.FRONTSIDE = 0;
1695
- /**
1696
- * Mesh side orientation : usually the internal or back surface
1697
- */
1698
- VertexData.BACKSIDE = 1;
1699
- /**
1700
- * Mesh side orientation : both internal and external or front and back surfaces
1701
- */
1702
- VertexData.DOUBLESIDE = 2;
1703
- /**
1704
- * Mesh side orientation : by default, `FRONTSIDE`
1705
- */
1706
- VertexData.DEFAULTSIDE = 0;
1707
- VertexData._UniqueIdGenerator = 0;
1708
- __decorate([
1709
- nativeOverride.filter((...args) => !Array.isArray(args[0]))
1710
- ], VertexData, "_TransformVector3Coordinates", null);
1711
- __decorate([
1712
- nativeOverride.filter((...args) => !Array.isArray(args[0]))
1713
- ], VertexData, "_TransformVector3Normals", null);
1714
- __decorate([
1715
- nativeOverride.filter((...args) => !Array.isArray(args[0]))
1716
- ], VertexData, "_TransformVector4Normals", null);
1717
- __decorate([
1718
- nativeOverride.filter((...args) => !Array.isArray(args[0]))
1719
- ], VertexData, "_FlipFaces", null);
1686
+ return vertexData;
1687
+ }
1688
+ /**
1689
+ * Applies VertexData created from the imported parameters to the geometry
1690
+ * @param parsedVertexData the parsed data from an imported file
1691
+ * @param geometry the geometry to apply the VertexData to
1692
+ */
1693
+ static ImportVertexData(parsedVertexData, geometry) {
1694
+ const vertexData = _a.Parse(parsedVertexData);
1695
+ geometry.setAllVerticesData(vertexData, parsedVertexData.updatable);
1696
+ }
1697
+ },
1698
+ (() => {
1699
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
1700
+ _static__TransformVector3Coordinates_decorators = [nativeOverride.filter((...args) => !Array.isArray(args[0]))];
1701
+ _static__TransformVector3Normals_decorators = [nativeOverride.filter((...args) => !Array.isArray(args[0]))];
1702
+ _static__TransformVector4Normals_decorators = [nativeOverride.filter((...args) => !Array.isArray(args[0]))];
1703
+ _static__FlipFaces_decorators = [nativeOverride.filter((...args) => !Array.isArray(args[0]))];
1704
+ __esDecorate(_a, null, _static__TransformVector3Coordinates_decorators, { kind: "method", name: "_TransformVector3Coordinates", static: true, private: false, access: { has: obj => "_TransformVector3Coordinates" in obj, get: obj => obj._TransformVector3Coordinates }, metadata: _metadata }, null, _staticExtraInitializers);
1705
+ __esDecorate(_a, null, _static__TransformVector3Normals_decorators, { kind: "method", name: "_TransformVector3Normals", static: true, private: false, access: { has: obj => "_TransformVector3Normals" in obj, get: obj => obj._TransformVector3Normals }, metadata: _metadata }, null, _staticExtraInitializers);
1706
+ __esDecorate(_a, null, _static__TransformVector4Normals_decorators, { kind: "method", name: "_TransformVector4Normals", static: true, private: false, access: { has: obj => "_TransformVector4Normals" in obj, get: obj => obj._TransformVector4Normals }, metadata: _metadata }, null, _staticExtraInitializers);
1707
+ __esDecorate(_a, null, _static__FlipFaces_decorators, { kind: "method", name: "_FlipFaces", static: true, private: false, access: { has: obj => "_FlipFaces" in obj, get: obj => obj._FlipFaces }, metadata: _metadata }, null, _staticExtraInitializers);
1708
+ if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
1709
+ })(),
1710
+ /**
1711
+ * Mesh side orientation : usually the external or front surface
1712
+ */
1713
+ _a.FRONTSIDE = (__runInitializers(_a, _staticExtraInitializers), 0),
1714
+ /**
1715
+ * Mesh side orientation : usually the internal or back surface
1716
+ */
1717
+ _a.BACKSIDE = 1,
1718
+ /**
1719
+ * Mesh side orientation : both internal and external or front and back surfaces
1720
+ */
1721
+ _a.DOUBLESIDE = 2,
1722
+ /**
1723
+ * Mesh side orientation : by default, `FRONTSIDE`
1724
+ */
1725
+ _a.DEFAULTSIDE = 0,
1726
+ _a._UniqueIdGenerator = 0,
1727
+ _a;
1728
+ })();
1729
+ export { VertexData };
1720
1730
  //# sourceMappingURL=mesh.vertexData.js.map