@babylonjs/core 5.52.0 → 5.53.1

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 (168) hide show
  1. package/Animations/animatable.js +1 -1
  2. package/Animations/animatable.js.map +1 -1
  3. package/Animations/animationGroup.js +8 -1
  4. package/Animations/animationGroup.js.map +1 -1
  5. package/Collisions/pickingInfo.d.ts +2 -1
  6. package/Collisions/pickingInfo.js +4 -3
  7. package/Collisions/pickingInfo.js.map +1 -1
  8. package/DeviceInput/eventFactory.js +4 -0
  9. package/DeviceInput/eventFactory.js.map +1 -1
  10. package/DeviceInput/webDeviceInputSystem.js +17 -9
  11. package/DeviceInput/webDeviceInputSystem.js.map +1 -1
  12. package/Engines/Extensions/engine.cubeTexture.js +3 -0
  13. package/Engines/Extensions/engine.cubeTexture.js.map +1 -1
  14. package/Engines/Extensions/engine.multiRender.js +74 -19
  15. package/Engines/Extensions/engine.multiRender.js.map +1 -1
  16. package/Engines/Extensions/engine.renderTarget.js +2 -5
  17. package/Engines/Extensions/engine.renderTarget.js.map +1 -1
  18. package/Engines/WebGL/webGLHardwareTexture.d.ts +3 -1
  19. package/Engines/WebGL/webGLHardwareTexture.js +19 -7
  20. package/Engines/WebGL/webGLHardwareTexture.js.map +1 -1
  21. package/Engines/WebGL/webGLRenderTargetWrapper.d.ts +14 -1
  22. package/Engines/WebGL/webGLRenderTargetWrapper.js +76 -6
  23. package/Engines/WebGL/webGLRenderTargetWrapper.js.map +1 -1
  24. package/Engines/WebGPU/Extensions/engine.multiRender.js +20 -0
  25. package/Engines/WebGPU/Extensions/engine.multiRender.js.map +1 -1
  26. package/Engines/WebGPU/Extensions/engine.renderTarget.js +3 -1
  27. package/Engines/WebGPU/Extensions/engine.renderTarget.js.map +1 -1
  28. package/Engines/WebGPU/webgpuConstants.d.ts +22 -7
  29. package/Engines/WebGPU/webgpuConstants.js +24 -8
  30. package/Engines/WebGPU/webgpuConstants.js.map +1 -1
  31. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.d.ts +0 -3
  32. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js +20 -53
  33. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js.map +1 -1
  34. package/Engines/WebGPU/webgpuTextureHelper.d.ts +3 -2
  35. package/Engines/WebGPU/webgpuTextureHelper.js +33 -14
  36. package/Engines/WebGPU/webgpuTextureHelper.js.map +1 -1
  37. package/Engines/WebGPU/webgpuTintWASM.d.ts +3 -2
  38. package/Engines/WebGPU/webgpuTintWASM.js +10 -8
  39. package/Engines/WebGPU/webgpuTintWASM.js.map +1 -1
  40. package/Engines/constants.d.ts +12 -0
  41. package/Engines/constants.js +12 -0
  42. package/Engines/constants.js.map +1 -1
  43. package/Engines/engine.d.ts +130 -72
  44. package/Engines/engine.js +5 -0
  45. package/Engines/engine.js.map +1 -1
  46. package/Engines/nativeEngine.d.ts +1 -0
  47. package/Engines/nativeEngine.js +16 -5
  48. package/Engines/nativeEngine.js.map +1 -1
  49. package/Engines/renderTargetWrapper.d.ts +28 -4
  50. package/Engines/renderTargetWrapper.js +107 -10
  51. package/Engines/renderTargetWrapper.js.map +1 -1
  52. package/Engines/thinEngine.d.ts +6 -6
  53. package/Engines/thinEngine.js +29 -21
  54. package/Engines/thinEngine.js.map +1 -1
  55. package/Engines/webgpuEngine.d.ts +25 -8
  56. package/Engines/webgpuEngine.js +112 -48
  57. package/Engines/webgpuEngine.js.map +1 -1
  58. package/Inputs/scene.inputManager.js +5 -12
  59. package/Inputs/scene.inputManager.js.map +1 -1
  60. package/Materials/PBR/pbrAnisotropicConfiguration.js +0 -1
  61. package/Materials/PBR/pbrAnisotropicConfiguration.js.map +1 -1
  62. package/Materials/PBR/pbrBaseMaterial.js +3 -0
  63. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  64. package/Materials/Textures/Filtering/hdrFiltering.js +4 -0
  65. package/Materials/Textures/Filtering/hdrFiltering.js.map +1 -1
  66. package/Materials/Textures/internalTexture.d.ts +4 -0
  67. package/Materials/Textures/internalTexture.js.map +1 -1
  68. package/Materials/Textures/multiRenderTarget.d.ts +40 -0
  69. package/Materials/Textures/multiRenderTarget.js +143 -4
  70. package/Materials/Textures/multiRenderTarget.js.map +1 -1
  71. package/Materials/Textures/renderTargetTexture.d.ts +4 -0
  72. package/Materials/Textures/renderTargetTexture.js +10 -2
  73. package/Materials/Textures/renderTargetTexture.js.map +1 -1
  74. package/Materials/Textures/texture.d.ts +4 -2
  75. package/Materials/Textures/texture.js +1 -0
  76. package/Materials/Textures/texture.js.map +1 -1
  77. package/Materials/Textures/textureCreationOptions.d.ts +4 -0
  78. package/Materials/Textures/textureCreationOptions.js.map +1 -1
  79. package/Materials/materialPluginBase.d.ts +3 -2
  80. package/Materials/materialPluginBase.js.map +1 -1
  81. package/Materials/materialPluginManager.js +13 -3
  82. package/Materials/materialPluginManager.js.map +1 -1
  83. package/Materials/uniformBuffer.d.ts +2 -0
  84. package/Materials/uniformBuffer.js +4 -0
  85. package/Materials/uniformBuffer.js.map +1 -1
  86. package/Maths/math.frustum.d.ts +8 -1
  87. package/Maths/math.frustum.js +14 -0
  88. package/Maths/math.frustum.js.map +1 -1
  89. package/Meshes/instancedMesh.d.ts +2 -1
  90. package/Meshes/instancedMesh.js +3 -2
  91. package/Meshes/instancedMesh.js.map +1 -1
  92. package/Meshes/mesh.d.ts +10 -5
  93. package/Meshes/mesh.js +40 -16
  94. package/Meshes/mesh.js.map +1 -1
  95. package/Misc/filesInput.d.ts +5 -2
  96. package/Misc/filesInput.js +39 -20
  97. package/Misc/filesInput.js.map +1 -1
  98. package/Misc/interfaces/screenshotSize.d.ts +17 -3
  99. package/Misc/interfaces/screenshotSize.js.map +1 -1
  100. package/Misc/sceneOptimizer.js +3 -0
  101. package/Misc/sceneOptimizer.js.map +1 -1
  102. package/Misc/screenshotTools.d.ts +2 -2
  103. package/Misc/screenshotTools.js +49 -9
  104. package/Misc/screenshotTools.js.map +1 -1
  105. package/Misc/textureTools.d.ts +1 -1
  106. package/Misc/textureTools.js +4 -2
  107. package/Misc/textureTools.js.map +1 -1
  108. package/Physics/v2/physicsAggregate.js +3 -3
  109. package/Physics/v2/physicsAggregate.js.map +1 -1
  110. package/Physics/v2/physicsBody.d.ts +27 -16
  111. package/Physics/v2/physicsBody.js +31 -16
  112. package/Physics/v2/physicsBody.js.map +1 -1
  113. package/Physics/v2/physicsConstraint.d.ts +6 -6
  114. package/Physics/v2/physicsConstraint.js +6 -6
  115. package/Physics/v2/physicsConstraint.js.map +1 -1
  116. package/Physics/v2/physicsShape.d.ts +7 -7
  117. package/Physics/v2/physicsShape.js +7 -7
  118. package/Physics/v2/physicsShape.js.map +1 -1
  119. package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.js +1 -0
  120. package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.js.map +1 -1
  121. package/PostProcesses/RenderPipeline/postProcessRenderPipelineManager.d.ts +5 -0
  122. package/PostProcesses/RenderPipeline/postProcessRenderPipelineManager.js +7 -0
  123. package/PostProcesses/RenderPipeline/postProcessRenderPipelineManager.js.map +1 -1
  124. package/PostProcesses/depthOfFieldMergePostProcess.d.ts +0 -23
  125. package/PostProcesses/depthOfFieldMergePostProcess.js +0 -5
  126. package/PostProcesses/depthOfFieldMergePostProcess.js.map +1 -1
  127. package/PostProcesses/postProcess.js +1 -0
  128. package/PostProcesses/postProcess.js.map +1 -1
  129. package/Probes/reflectionProbe.js +1 -0
  130. package/Probes/reflectionProbe.js.map +1 -1
  131. package/Rendering/depthPeelingRenderer.js +3 -1
  132. package/Rendering/depthPeelingRenderer.js.map +1 -1
  133. package/Rendering/fluidRenderer/fluidRenderer.js +1 -1
  134. package/Rendering/fluidRenderer/fluidRenderer.js.map +1 -1
  135. package/Rendering/fluidRenderer/fluidRenderingDepthTextureCopy.js +2 -1
  136. package/Rendering/fluidRenderer/fluidRenderingDepthTextureCopy.js.map +1 -1
  137. package/Rendering/fluidRenderer/fluidRenderingTextures.js +2 -0
  138. package/Rendering/fluidRenderer/fluidRenderingTextures.js.map +1 -1
  139. package/Shaders/default.fragment.js +1 -1
  140. package/Shaders/default.fragment.js.map +1 -1
  141. package/Shaders/depthOfFieldMerge.fragment.js +10 -5
  142. package/Shaders/depthOfFieldMerge.fragment.js.map +1 -1
  143. package/Shaders/fluidRenderingRender.fragment.js +3 -3
  144. package/Shaders/fluidRenderingRender.fragment.js.map +1 -1
  145. package/Shaders/motionBlur.fragment.js +8 -2
  146. package/Shaders/motionBlur.fragment.js.map +1 -1
  147. package/Shaders/screenSpaceReflection2.fragment.js +11 -4
  148. package/Shaders/screenSpaceReflection2.fragment.js.map +1 -1
  149. package/Shaders/screenSpaceReflection2Blur.fragment.js +6 -1
  150. package/Shaders/screenSpaceReflection2Blur.fragment.js.map +1 -1
  151. package/Shaders/ssao2.fragment.js +1 -0
  152. package/Shaders/ssao2.fragment.js.map +1 -1
  153. package/ShadersWGSL/ShadersInclude/bakedVertexAnimation.js +9 -9
  154. package/ShadersWGSL/ShadersInclude/bakedVertexAnimation.js.map +1 -1
  155. package/ShadersWGSL/ShadersInclude/bonesVertex.js +16 -16
  156. package/ShadersWGSL/ShadersInclude/bonesVertex.js.map +1 -1
  157. package/ShadersWGSL/ShadersInclude/clipPlaneFragment.js +6 -6
  158. package/ShadersWGSL/ShadersInclude/clipPlaneFragment.js.map +1 -1
  159. package/ShadersWGSL/ShadersInclude/clipPlaneVertex.js +6 -6
  160. package/ShadersWGSL/ShadersInclude/clipPlaneVertex.js.map +1 -1
  161. package/ShadersWGSL/ShadersInclude/instancesVertex.js +1 -1
  162. package/ShadersWGSL/ShadersInclude/instancesVertex.js.map +1 -1
  163. package/ShadersWGSL/ShadersInclude/morphTargetsVertex.js +8 -8
  164. package/ShadersWGSL/ShadersInclude/morphTargetsVertex.js.map +1 -1
  165. package/XR/features/WebXRControllerTeleportation.d.ts +9 -0
  166. package/XR/features/WebXRControllerTeleportation.js +28 -4
  167. package/XR/features/WebXRControllerTeleportation.js.map +1 -1
  168. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"math.frustum.js","sourceRoot":"","sources":["../../../../lts/core/generated/Maths/math.frustum.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAErC;;GAEG;AACH,MAAM,OAAO,OAAO;IAChB;;;;OAIG;IACI,MAAM,CAAC,SAAS,CAAC,SAAgC;QACpD,MAAM,aAAa,GAAG,EAAE,CAAC;QACzB,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,KAAK,EAAE,EAAE;YACpC,aAAa,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;SACrD;QACD,OAAO,CAAC,cAAc,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;QACjD,OAAO,aAAa,CAAC;IACzB,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,iBAAiB,CAAC,SAAgC,EAAE,YAAmB;QACjF,MAAM,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC;QACtB,YAAY,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACpC,YAAY,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACpC,YAAY,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;QACtC,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;QAC/B,YAAY,CAAC,SAAS,EAAE,CAAC;IAC7B,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,gBAAgB,CAAC,SAAgC,EAAE,YAAmB;QACh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G,CAAC,CAAC,CAAC,CAAC,CAAC;QACpC,YAAY,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACrC,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;QAC/B,YAAY,CAAC,SAAS,EAAE,CAAC;IAC7B,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,cAAc,CAAC,SAAgC,EAAE,aAAsB;QACjF,OAAO;QACP,OAAO,CAAC,iBAAiB,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;QAEvD,MAAM;QACN,OAAO,CAAC,gBAAgB,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;QAEtD,OAAO;QACP,OAAO,CAAC,iBAAiB,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;QAEvD,QAAQ;QACR,OAAO,CAAC,kBAAkB,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;QAExD,MAAM;QACN,OAAO,CAAC,gBAAgB,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;QAEtD,SAAS;QACT,OAAO,CAAC,mBAAmB,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7D,CAAC;CACJ","sourcesContent":["import type { Matrix } from \"./math.vector\";\r\nimport type { DeepImmutable } from \"../types\";\r\nimport { Plane } from \"./math.plane\";\r\n\r\n/**\r\n * Represents a camera frustum\r\n */\r\nexport class Frustum {\r\n /**\r\n * Gets the planes representing the frustum\r\n * @param transform matrix to be applied to the returned planes\r\n * @returns a new array of 6 Frustum planes computed by the given transformation matrix.\r\n */\r\n public static GetPlanes(transform: DeepImmutable<Matrix>): Plane[] {\r\n const frustumPlanes = [];\r\n for (let index = 0; index < 6; index++) {\r\n frustumPlanes.push(new Plane(0.0, 0.0, 0.0, 0.0));\r\n }\r\n Frustum.GetPlanesToRef(transform, frustumPlanes);\r\n return frustumPlanes;\r\n }\r\n\r\n /**\r\n * Gets the near frustum plane transformed by the transform matrix\r\n * @param transform transformation matrix to be applied to the resulting frustum plane\r\n * @param frustumPlane the resulting frustum plane\r\n */\r\n public static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void {\r\n const m = transform.m;\r\n frustumPlane.normal.x = m[3] + m[2];\r\n frustumPlane.normal.y = m[7] + m[6];\r\n frustumPlane.normal.z = m[11] + m[10];\r\n frustumPlane.d = m[15] + m[14];\r\n frustumPlane.normalize();\r\n }\r\n\r\n /**\r\n * Gets the far frustum plane transformed by the transform matrix\r\n * @param transform transformation matrix to be applied to the resulting frustum plane\r\n * @param frustumPlane the resulting frustum plane\r\n */\r\n public static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void {\r\n const m = transform.m;\r\n frustumPlane.normal.x = m[3] - m[2];\r\n frustumPlane.normal.y = m[7] - m[6];\r\n frustumPlane.normal.z = m[11] - m[10];\r\n frustumPlane.d = m[15] - m[14];\r\n frustumPlane.normalize();\r\n }\r\n\r\n /**\r\n * Gets the left frustum plane transformed by the transform matrix\r\n * @param transform transformation matrix to be applied to the resulting frustum plane\r\n * @param frustumPlane the resulting frustum plane\r\n */\r\n public static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void {\r\n const m = transform.m;\r\n frustumPlane.normal.x = m[3] + m[0];\r\n frustumPlane.normal.y = m[7] + m[4];\r\n frustumPlane.normal.z = m[11] + m[8];\r\n frustumPlane.d = m[15] + m[12];\r\n frustumPlane.normalize();\r\n }\r\n\r\n /**\r\n * Gets the right frustum plane transformed by the transform matrix\r\n * @param transform transformation matrix to be applied to the resulting frustum plane\r\n * @param frustumPlane the resulting frustum plane\r\n */\r\n public static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void {\r\n const m = transform.m;\r\n frustumPlane.normal.x = m[3] - m[0];\r\n frustumPlane.normal.y = m[7] - m[4];\r\n frustumPlane.normal.z = m[11] - m[8];\r\n frustumPlane.d = m[15] - m[12];\r\n frustumPlane.normalize();\r\n }\r\n\r\n /**\r\n * Gets the top frustum plane transformed by the transform matrix\r\n * @param transform transformation matrix to be applied to the resulting frustum plane\r\n * @param frustumPlane the resulting frustum plane\r\n */\r\n public static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void {\r\n const m = transform.m;\r\n frustumPlane.normal.x = m[3] - m[1];\r\n frustumPlane.normal.y = m[7] - m[5];\r\n frustumPlane.normal.z = m[11] - m[9];\r\n frustumPlane.d = m[15] - m[13];\r\n frustumPlane.normalize();\r\n }\r\n\r\n /**\r\n * Gets the bottom frustum plane transformed by the transform matrix\r\n * @param transform transformation matrix to be applied to the resulting frustum plane\r\n * @param frustumPlane the resulting frustum plane\r\n */\r\n public static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void {\r\n const m = transform.m;\r\n frustumPlane.normal.x = m[3] + m[1];\r\n frustumPlane.normal.y = m[7] + m[5];\r\n frustumPlane.normal.z = m[11] + m[9];\r\n frustumPlane.d = m[15] + m[13];\r\n frustumPlane.normalize();\r\n }\r\n\r\n /**\r\n * Sets the given array \"frustumPlanes\" with the 6 Frustum planes computed by the given transformation matrix.\r\n * @param transform transformation matrix to be applied to the resulting frustum planes\r\n * @param frustumPlanes the resulting frustum planes\r\n */\r\n public static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void {\r\n // Near\r\n Frustum.GetNearPlaneToRef(transform, frustumPlanes[0]);\r\n\r\n // Far\r\n Frustum.GetFarPlaneToRef(transform, frustumPlanes[1]);\r\n\r\n // Left\r\n Frustum.GetLeftPlaneToRef(transform, frustumPlanes[2]);\r\n\r\n // Right\r\n Frustum.GetRightPlaneToRef(transform, frustumPlanes[3]);\r\n\r\n // Top\r\n Frustum.GetTopPlaneToRef(transform, frustumPlanes[4]);\r\n\r\n // Bottom\r\n Frustum.GetBottomPlaneToRef(transform, frustumPlanes[5]);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"math.frustum.js","sourceRoot":"","sources":["../../../../lts/core/generated/Maths/math.frustum.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAErC;;GAEG;AACH,MAAM,OAAO,OAAO;IAChB;;;;OAIG;IACI,MAAM,CAAC,SAAS,CAAC,SAAgC;QACpD,MAAM,aAAa,GAAG,EAAE,CAAC;QACzB,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,KAAK,EAAE,EAAE;YACpC,aAAa,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;SACrD;QACD,OAAO,CAAC,cAAc,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;QACjD,OAAO,aAAa,CAAC;IACzB,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,iBAAiB,CAAC,SAAgC,EAAE,YAAmB;QACjF,MAAM,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC;QACtB,YAAY,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACpC,YAAY,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACpC,YAAY,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;QACtC,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;QAC/B,YAAY,CAAC,SAAS,EAAE,CAA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3C,OAAO,KAAK,CAAC;aAChB;SACJ;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ","sourcesContent":["import type { Matrix, Vector3 } from \"./math.vector\";\r\nimport type { DeepImmutable } from \"../types\";\r\nimport { Plane } from \"./math.plane\";\r\n\r\n/**\r\n * Represents a camera frustum\r\n */\r\nexport class Frustum {\r\n /**\r\n * Gets the planes representing the frustum\r\n * @param transform matrix to be applied to the returned planes\r\n * @returns a new array of 6 Frustum planes computed by the given transformation matrix.\r\n */\r\n public static GetPlanes(transform: DeepImmutable<Matrix>): Plane[] {\r\n const frustumPlanes = [];\r\n for (let index = 0; index < 6; index++) {\r\n frustumPlanes.push(new Plane(0.0, 0.0, 0.0, 0.0));\r\n }\r\n Frustum.GetPlanesToRef(transform, frustumPlanes);\r\n return frustumPlanes;\r\n }\r\n\r\n /**\r\n * Gets the near frustum plane transformed by the transform matrix\r\n * @param transform transformation matrix to be applied to the resulting frustum plane\r\n * @param frustumPlane the resulting frustum plane\r\n */\r\n public static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void {\r\n const m = transform.m;\r\n frustumPlane.normal.x = m[3] + m[2];\r\n frustumPlane.normal.y = m[7] + m[6];\r\n frustumPlane.normal.z = m[11] + m[10];\r\n frustumPlane.d = m[15] + m[14];\r\n frustumPlane.normalize();\r\n }\r\n\r\n /**\r\n * Gets the far frustum plane transformed by the transform matrix\r\n * @param transform transformation matrix to be applied to the resulting frustum plane\r\n * @param frustumPlane the resulting frustum plane\r\n */\r\n public static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void {\r\n const m = transform.m;\r\n frustumPlane.normal.x = m[3] - m[2];\r\n frustumPlane.normal.y = m[7] - m[6];\r\n frustumPlane.normal.z = m[11] - m[10];\r\n frustumPlane.d = m[15] - m[14];\r\n frustumPlane.normalize();\r\n }\r\n\r\n /**\r\n * Gets the left frustum plane transformed by the transform matrix\r\n * @param transform transformation matrix to be applied to the resulting frustum plane\r\n * @param frustumPlane the resulting frustum plane\r\n */\r\n public static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void {\r\n const m = transform.m;\r\n frustumPlane.normal.x = m[3] + m[0];\r\n frustumPlane.normal.y = m[7] + m[4];\r\n frustumPlane.normal.z = m[11] + m[8];\r\n frustumPlane.d = m[15] + m[12];\r\n frustumPlane.normalize();\r\n }\r\n\r\n /**\r\n * Gets the right frustum plane transformed by the transform matrix\r\n * @param transform transformation matrix to be applied to the resulting frustum plane\r\n * @param frustumPlane the resulting frustum plane\r\n */\r\n public static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void {\r\n const m = transform.m;\r\n frustumPlane.normal.x = m[3] - m[0];\r\n frustumPlane.normal.y = m[7] - m[4];\r\n frustumPlane.normal.z = m[11] - m[8];\r\n frustumPlane.d = m[15] - m[12];\r\n frustumPlane.normalize();\r\n }\r\n\r\n /**\r\n * Gets the top frustum plane transformed by the transform matrix\r\n * @param transform transformation matrix to be applied to the resulting frustum plane\r\n * @param frustumPlane the resulting frustum plane\r\n */\r\n public static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void {\r\n const m = transform.m;\r\n frustumPlane.normal.x = m[3] - m[1];\r\n frustumPlane.normal.y = m[7] - m[5];\r\n frustumPlane.normal.z = m[11] - m[9];\r\n frustumPlane.d = m[15] - m[13];\r\n frustumPlane.normalize();\r\n }\r\n\r\n /**\r\n * Gets the bottom frustum plane transformed by the transform matrix\r\n * @param transform transformation matrix to be applied to the resulting frustum plane\r\n * @param frustumPlane the resulting frustum plane\r\n */\r\n public static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void {\r\n const m = transform.m;\r\n frustumPlane.normal.x = m[3] + m[1];\r\n frustumPlane.normal.y = m[7] + m[5];\r\n frustumPlane.normal.z = m[11] + m[9];\r\n frustumPlane.d = m[15] + m[13];\r\n frustumPlane.normalize();\r\n }\r\n\r\n /**\r\n * Sets the given array \"frustumPlanes\" with the 6 Frustum planes computed by the given transformation matrix.\r\n * @param transform transformation matrix to be applied to the resulting frustum planes\r\n * @param frustumPlanes the resulting frustum planes\r\n */\r\n public static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void {\r\n // Near\r\n Frustum.GetNearPlaneToRef(transform, frustumPlanes[0]);\r\n\r\n // Far\r\n Frustum.GetFarPlaneToRef(transform, frustumPlanes[1]);\r\n\r\n // Left\r\n Frustum.GetLeftPlaneToRef(transform, frustumPlanes[2]);\r\n\r\n // Right\r\n Frustum.GetRightPlaneToRef(transform, frustumPlanes[3]);\r\n\r\n // Top\r\n Frustum.GetTopPlaneToRef(transform, frustumPlanes[4]);\r\n\r\n // Bottom\r\n Frustum.GetBottomPlaneToRef(transform, frustumPlanes[5]);\r\n }\r\n\r\n /**\r\n * Tests if a point is located between the frustum planes.\r\n * @param point defines the point to test\r\n * @param frustumPlanes defines the frustum planes to test\r\n * @returns true if the point is located between the frustum planes\r\n */\r\n public static IsPointInFrustum(point: Vector3, frustumPlanes: Array<DeepImmutable<Plane>>): boolean {\r\n for (let i = 0; i < 6; i++) {\r\n if (frustumPlanes[i].dotCoordinate(point) < 0) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n}\r\n"]}
@@ -84,9 +84,10 @@ export declare class InstancedMesh extends AbstractMesh {
84
84
  * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
85
85
  * @param kind kind of verticies to retrieve (eg. positions, normals, uvs, etc.)
86
86
  * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
87
+ * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
87
88
  * @returns a float array or a Float32Array of the requested kind of data : positions, normals, uvs, etc.
88
89
  */
89
- getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
90
+ getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
90
91
  /**
91
92
  * Sets the vertex data of the mesh geometry for the requested `kind`.
92
93
  * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
@@ -142,10 +142,11 @@ export class InstancedMesh extends AbstractMesh {
142
142
  * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
143
143
  * @param kind kind of verticies to retrieve (eg. positions, normals, uvs, etc.)
144
144
  * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
145
+ * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
145
146
  * @returns a float array or a Float32Array of the requested kind of data : positions, normals, uvs, etc.
146
147
  */
147
- getVerticesData(kind, copyWhenShared) {
148
- return this._sourceMesh.getVerticesData(kind, copyWhenShared);
148
+ getVerticesData(kind, copyWhenShared, forceCopy) {
149
+ return this._sourceMesh.getVerticesData(kind, copyWhenShared, forceCopy);
149
150
  }
150
151
  /**
151
152
  * Sets the vertex data of the mesh geometry for the requested `kind`.
@@ -1 +1 @@
1
- {"version":3,"file":"instancedMesh.js","sourceRoot":"","sources":["../../../../lts/core/generated/Meshes/instancedMesh.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGxC,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAGtC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,IAAI,CAAC,qBAAqB,GAAG,CAAC,IAAY,EAAE,IAAU,EAAiB,EAAE;IACrE,MAAM,QAAQ,GAAG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;KACV;IAED,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,4BAA4B,CAAC,kBAAkB,EAAE;QACrE,IAAI,CAAC,SAAS,EAAE,CAAC,wBAAwB,CAAC,IAAI,CAAC,4BAA4B,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC;KACzG;IAED,IAAI,CAAC,4BAA4B,CAAC,kBAAkB,GAAG,EAAE,CAAC;AAC9D,CAAC,CAAC;AAEF,IAAI,CAAC,SAAS,CAAC,4BAA4B,GAAG;IAC1C,IAAI,IAAI,CAAC,oBAAoB,CAAC,eAAe,EAAE;QAC3C,IAAI,CAAC,oBAAoB,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC;QACpD,IAAI,CAAC,oBAAoB,CAAC,eAAe,GAAG,IAAI,CAAC;KACpD;IAED,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE;QAC1B,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;KAC/B;IAED,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,gBAAgB,EAAE;QACtC,IAAI,IAAI,CAAC,4BAA4B,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE;YACvD,IAAI,CAAC,4BAA4B,CAAC,aAAa,CAAC,IAAI,CAAE,CAAC,OAAO,EAAE,CAAC;SACpE;KACJ;IAED,IAAI,CAAC,oCAAoC,EAAE,CAAC;IAE5C,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAC;AAC/B,CAAC,CAAC","sourcesContent":["import type { Nullable, FloatArray, IndicesArray } from \"../types\";\r\nimport type { Vector3 } from \"../Maths/math.vector\";\r\nimport { Matrix, TmpVectors } from \"../Maths/math.vector\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport type { Node } from \"../node\";\r\nimport { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport { Mesh } from \"../Meshes/mesh\";\r\nimport type { Material } from \"../Materials/material\";\r\nimport type { Skeleton } from \"../Bones/skeleton\";\r\nimport { DeepCopier } from \"../Misc/deepCopier\";\r\nimport { TransformNode } from \"./transformNode\";\r\nimport type { Light } from \"../Lights/light\";\r\nimport { VertexBuffer } from \"../Buffers/buffer\";\r\n\r\nMesh._instancedMeshFactory = (name: string, mesh: Mesh): InstancedMesh => {\r\n const instance = new InstancedMesh(name, mesh);\r\n\r\n if (mesh.instancedBuffers) {\r\n instance.instancedBuffers = {};\r\n\r\n for (const key in mesh.instancedBuffers) {\r\n instance.instancedBuffers[key] = mesh.instancedBuffers[key];\r\n }\r\n }\r\n\r\n return instance;\r\n};\r\n\r\n/**\r\n * Creates an instance based on a source mesh.\r\n */\r\nexport class InstancedMesh extends AbstractMesh {\r\n private _sourceMesh: Mesh;\r\n private _currentLOD: Mesh;\r\n private _billboardWorldMatrix: Matrix;\r\n\r\n /** @internal */\r\n public _indexInSourceMeshInstanceArray = -1;\r\n /** @internal */\r\n public _distanceToCamera: number = 0;\r\n /** @internal */\r\n public _previousWorldMatrix: Nullable<Matrix>;\r\n\r\n constructor(name: string, source: Mesh) {\r\n super(name, source.getScene());\r\n\r\n source.addInstance(this);\r\n\r\n this._sourceMesh = source;\r\n\r\n this._unIndexed = source._unIndexed;\r\n\r\n this.position.copyFrom(source.position);\r\n this.rotation.copyFrom(source.rotation);\r\n this.scaling.copyFrom(source.scaling);\r\n\r\n if (source.rotationQuaternion) {\r\n this.rotationQuaternion = source.rotationQuaternion.clone();\r\n }\r\n\r\n this.animations = source.animations.slice();\r\n for (const range of source.getAnimationRanges()) {\r\n if (range != null) {\r\n this.createAnimationRange(range.name, range.from, range.to);\r\n }\r\n }\r\n\r\n this.infiniteDistance = source.infiniteDistance;\r\n\r\n this.setPivotMatrix(source.getPivotMatrix());\r\n\r\n this.refreshBoundingInfo(true, true);\r\n this._syncSubMeshes();\r\n }\r\n\r\n /**\r\n * Returns the string \"InstancedMesh\".\r\n */\r\n public getClassName(): string {\r\n return \"InstancedMesh\";\r\n }\r\n\r\n /** Gets the list of lights affecting that mesh */\r\n public get lightSources(): Light[] {\r\n return this._sourceMesh._lightSources;\r\n }\r\n\r\n public _resyncLightSources(): void {\r\n // Do nothing as all the work will be done by source mesh\r\n }\r\n\r\n public _resyncLightSource(): void {\r\n // Do nothing as all the work will be done by source mesh\r\n }\r\n\r\n public _removeLightSource(): void {\r\n // Do nothing as all the work will be done by source mesh\r\n }\r\n\r\n // Methods\r\n /**\r\n * If the source mesh receives shadows\r\n */\r\n public get receiveShadows(): boolean {\r\n return this._sourceMesh.receiveShadows;\r\n }\r\n\r\n /**\r\n * The material of the source mesh\r\n */\r\n public get material(): Nullable<Material> {\r\n return this._sourceMesh.material;\r\n }\r\n\r\n /**\r\n * Visibility of the source mesh\r\n */\r\n public get visibility(): number {\r\n return this._sourceMesh.visibility;\r\n }\r\n\r\n /**\r\n * Skeleton of the source mesh\r\n */\r\n public get skeleton(): Nullable<Skeleton> {\r\n return this._sourceMesh.skeleton;\r\n }\r\n\r\n /**\r\n * Rendering ground id of the source mesh\r\n */\r\n public get renderingGroupId(): number {\r\n return this._sourceMesh.renderingGroupId;\r\n }\r\n\r\n public set renderingGroupId(value: number) {\r\n if (!this._sourceMesh || value === this._sourceMesh.renderingGroupId) {\r\n return;\r\n }\r\n\r\n //no-op with warning\r\n Logger.Warn(\"Note - setting renderingGroupId of an instanced mesh has no effect on the scene\");\r\n }\r\n\r\n /**\r\n * Returns the total number of vertices (integer).\r\n */\r\n public getTotalVertices(): number {\r\n return this._sourceMesh ? this._sourceMesh.getTotalVertices() : 0;\r\n }\r\n\r\n /**\r\n * Returns a positive integer : the total number of indices in this mesh geometry.\r\n * @returns the number of indices or zero if the mesh has no geometry.\r\n */\r\n public getTotalIndices(): number {\r\n return this._sourceMesh.getTotalIndices();\r\n }\r\n\r\n /**\r\n * The source mesh of the instance\r\n */\r\n public get sourceMesh(): Mesh {\r\n return this._sourceMesh;\r\n }\r\n\r\n /**\r\n * Creates a new InstancedMesh object from the mesh model.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/copies/instances\r\n * @param name defines the name of the new instance\r\n * @returns a new InstancedMesh\r\n */\r\n public createInstance(name: string): InstancedMesh {\r\n return this._sourceMesh.createInstance(name);\r\n }\r\n\r\n /**\r\n * Is this node ready to be used/rendered\r\n * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)\r\n * @returns {boolean} is it ready\r\n */\r\n public isReady(completeCheck = false): boolean {\r\n return this._sourceMesh.isReady(completeCheck, true);\r\n }\r\n\r\n /**\r\n * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.\r\n * @param kind kind of verticies to retrieve (eg. positions, normals, uvs, etc.)\r\n * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.\r\n * @returns a float array or a Float32Array of the requested kind of data : positions, normals, uvs, etc.\r\n */\r\n public getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray> {\r\n return this._sourceMesh.getVerticesData(kind, copyWhenShared);\r\n }\r\n\r\n /**\r\n * Sets the vertex data of the mesh geometry for the requested `kind`.\r\n * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.\r\n * The `data` are either a numeric array either a Float32Array.\r\n * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initially none) or updater.\r\n * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).\r\n * Note that a new underlying VertexBuffer object is created each call.\r\n * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.\r\n *\r\n * Possible `kind` values :\r\n * - VertexBuffer.PositionKind\r\n * - VertexBuffer.UVKind\r\n * - VertexBuffer.UV2Kind\r\n * - VertexBuffer.UV3Kind\r\n * - VertexBuffer.UV4Kind\r\n * - VertexBuffer.UV5Kind\r\n * - VertexBuffer.UV6Kind\r\n * - VertexBuffer.ColorKind\r\n * - VertexBuffer.MatricesIndicesKind\r\n * - VertexBuffer.MatricesIndicesExtraKind\r\n * - VertexBuffer.MatricesWeightsKind\r\n * - VertexBuffer.MatricesWeightsExtraKind\r\n *\r\n * Returns the Mesh.\r\n * @param kind\r\n * @param data\r\n * @param updatable\r\n * @param stride\r\n */\r\n public setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh {\r\n if (this.sourceMesh) {\r\n this.sourceMesh.setVerticesData(kind, data, updatable, stride);\r\n }\r\n return this.sourceMesh;\r\n }\r\n\r\n /**\r\n * Updates the existing vertex data of the mesh geometry for the requested `kind`.\r\n * If the mesh has no geometry, it is simply returned as it is.\r\n * The `data` are either a numeric array either a Float32Array.\r\n * No new underlying VertexBuffer object is created.\r\n * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.\r\n * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.\r\n *\r\n * Possible `kind` values :\r\n * - VertexBuffer.PositionKind\r\n * - VertexBuffer.UVKind\r\n * - VertexBuffer.UV2Kind\r\n * - VertexBuffer.UV3Kind\r\n * - VertexBuffer.UV4Kind\r\n * - VertexBuffer.UV5Kind\r\n * - VertexBuffer.UV6Kind\r\n * - VertexBuffer.ColorKind\r\n * - VertexBuffer.MatricesIndicesKind\r\n * - VertexBuffer.MatricesIndicesExtraKind\r\n * - VertexBuffer.MatricesWeightsKind\r\n * - VertexBuffer.MatricesWeightsExtraKind\r\n *\r\n * Returns the Mesh.\r\n * @param kind\r\n * @param data\r\n * @param updateExtends\r\n * @param makeItUnique\r\n */\r\n public updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh {\r\n if (this.sourceMesh) {\r\n this.sourceMesh.updateVerticesData(kind, data, updateExtends, makeItUnique);\r\n }\r\n return this.sourceMesh;\r\n }\r\n\r\n /**\r\n * Sets the mesh indices.\r\n * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).\r\n * If the mesh has no geometry, a new Geometry object is created and set to the mesh.\r\n * This method creates a new index buffer each call.\r\n * Returns the Mesh.\r\n * @param indices\r\n * @param totalVertices\r\n */\r\n public setIndices(indices: IndicesArray, totalVertices: Nullable<number> = null): Mesh {\r\n if (this.sourceMesh) {\r\n this.sourceMesh.setIndices(indices, totalVertices);\r\n }\r\n return this.sourceMesh;\r\n }\r\n\r\n /**\r\n * Boolean : True if the mesh owns the requested kind of data.\r\n * @param kind\r\n */\r\n public isVerticesDataPresent(kind: string): boolean {\r\n return this._sourceMesh.isVerticesDataPresent(kind);\r\n }\r\n\r\n /**\r\n * Returns an array of indices (IndicesArray).\r\n */\r\n public getIndices(): Nullable<IndicesArray> {\r\n return this._sourceMesh.getIndices();\r\n }\r\n\r\n public get _positions(): Nullable<Vector3[]> {\r\n return this._sourceMesh._positions;\r\n }\r\n\r\n /**\r\n * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.\r\n * This means the mesh underlying bounding box and sphere are recomputed.\r\n * @param applySkeleton defines whether to apply the skeleton before computing the bounding info\r\n * @param applyMorph defines whether to apply the morph target before computing the bounding info\r\n * @returns the current mesh\r\n */\r\n public refreshBoundingInfo(applySkeleton: boolean = false, applyMorph: boolean = false): InstancedMesh {\r\n if (this.hasBoundingInfo && this.getBoundingInfo().isLocked) {\r\n return this;\r\n }\r\n\r\n const bias = this._sourceMesh.geometry ? this._sourceMesh.geometry.boundingBias : null;\r\n this._refreshBoundingInfo(this._sourceMesh._getPositionData(applySkeleton, applyMorph), bias);\r\n return this;\r\n }\r\n\r\n /** @internal */\r\n public _preActivate(): InstancedMesh {\r\n if (this._currentLOD) {\r\n this._currentLOD._preActivate();\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _activate(renderId: number, intermediateRendering: boolean): boolean {\r\n super._activate(renderId, intermediateRendering);\r\n\r\n if (!this._sourceMesh.subMeshes) {\r\n Logger.Warn(\"Instances should only be created for meshes with geometry.\");\r\n }\r\n\r\n if (this._currentLOD) {\r\n const differentSign = this._currentLOD._getWorldMatrixDeterminant() >= 0 !== this._getWorldMatrixDeterminant() >= 0;\r\n if (differentSign) {\r\n this._internalAbstractMeshDataInfo._actAsRegularMesh = true;\r\n return true;\r\n }\r\n this._internalAbstractMeshDataInfo._actAsRegularMesh = false;\r\n\r\n this._currentLOD._registerInstanceForRenderId(this, renderId);\r\n\r\n if (intermediateRendering) {\r\n if (!this._currentLOD._internalAbstractMeshDataInfo._isActiveIntermediate) {\r\n this._currentLOD._internalAbstractMeshDataInfo._onlyForInstancesIntermediate = true;\r\n return true;\r\n }\r\n } else {\r\n if (!this._currentLOD._internalAbstractMeshDataInfo._isActive) {\r\n this._currentLOD._internalAbstractMeshDataInfo._onlyForInstances = true;\r\n return true;\r\n }\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n /** @internal */\r\n public _postActivate(): void {\r\n if (this._sourceMesh.edgesShareWithInstances && this._sourceMesh._edgesRenderer && this._sourceMesh._edgesRenderer.isEnabled && this._sourceMesh._renderingGroup) {\r\n // we are using the edge renderer of the source mesh\r\n this._sourceMesh._renderingGroup._edgesRenderers.pushNoDuplicate(this._sourceMesh._edgesRenderer);\r\n this._sourceMesh._edgesRenderer.customInstances.push(this.getWorldMatrix());\r\n } else if (this._edgesRenderer && this._edgesRenderer.isEnabled && this._sourceMesh._renderingGroup) {\r\n // we are using the edge renderer defined for this instance\r\n this._sourceMesh._renderingGroup._edgesRenderers.push(this._edgesRenderer);\r\n }\r\n }\r\n\r\n public getWorldMatrix(): Matrix {\r\n if (this._currentLOD && this._currentLOD.billboardMode !== TransformNode.BILLBOARDMODE_NONE && this._currentLOD._masterMesh !== this) {\r\n if (!this._billboardWorldMatrix) {\r\n this._billboardWorldMatrix = new Matrix();\r\n }\r\n const tempMaster = this._currentLOD._masterMesh;\r\n this._currentLOD._masterMesh = this;\r\n TmpVectors.Vector3[7].copyFrom(this._currentLOD.position);\r\n this._currentLOD.position.set(0, 0, 0);\r\n this._billboardWorldMatrix.copyFrom(this._currentLOD.computeWorldMatrix(true));\r\n this._currentLOD.position.copyFrom(TmpVectors.Vector3[7]);\r\n this._currentLOD._masterMesh = tempMaster;\r\n return this._billboardWorldMatrix;\r\n }\r\n\r\n return super.getWorldMatrix();\r\n }\r\n\r\n public get isAnInstance(): boolean {\r\n return true;\r\n }\r\n\r\n /**\r\n * Returns the current associated LOD AbstractMesh.\r\n * @param camera\r\n */\r\n public getLOD(camera: Camera): AbstractMesh {\r\n if (!camera) {\r\n return this;\r\n }\r\n\r\n const sourceMeshLODLevels = this.sourceMesh.getLODLevels();\r\n if (!sourceMeshLODLevels || sourceMeshLODLevels.length === 0) {\r\n this._currentLOD = this.sourceMesh;\r\n } else {\r\n const boundingInfo = this.getBoundingInfo();\r\n this._currentLOD = <Mesh>this.sourceMesh.getLOD(camera, boundingInfo.boundingSphere);\r\n }\r\n\r\n return this._currentLOD;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _preActivateForIntermediateRendering(renderId: number): Mesh {\r\n return <Mesh>this.sourceMesh._preActivateForIntermediateRendering(renderId);\r\n }\r\n\r\n /** @internal */\r\n public _syncSubMeshes(): InstancedMesh {\r\n this.releaseSubMeshes();\r\n if (this._sourceMesh.subMeshes) {\r\n for (let index = 0; index < this._sourceMesh.subMeshes.length; index++) {\r\n this._sourceMesh.subMeshes[index].clone(this, this._sourceMesh);\r\n }\r\n }\r\n return this;\r\n }\r\n\r\n /** @internal */\r\n public _generatePointsArray(): boolean {\r\n return this._sourceMesh._generatePointsArray();\r\n }\r\n\r\n /** @internal */\r\n public _updateBoundingInfo(): AbstractMesh {\r\n if (this.hasBoundingInfo) {\r\n this.getBoundingInfo().update(this.worldMatrixFromCache);\r\n } else {\r\n this.buildBoundingInfo(this.absolutePosition, this.absolutePosition, this.worldMatrixFromCache);\r\n }\r\n this._updateSubMeshesBoundingInfo(this.worldMatrixFromCache);\r\n return this;\r\n }\r\n\r\n /**\r\n * Creates a new InstancedMesh from the current mesh.\r\n *\r\n * Returns the clone.\r\n * @param name the cloned mesh name\r\n * @param newParent the optional Node to parent the clone to.\r\n * @param doNotCloneChildren if `true` the model children aren't cloned.\r\n * @param newSourceMesh if set this mesh will be used as the source mesh instead of ths instance's one\r\n * @returns the clone\r\n */\r\n public clone(name: string, newParent: Nullable<Node> = null, doNotCloneChildren?: boolean, newSourceMesh?: Mesh): InstancedMesh {\r\n const result = (newSourceMesh || this._sourceMesh).createInstance(name);\r\n\r\n // Deep copy\r\n DeepCopier.DeepCopy(\r\n this,\r\n result,\r\n [\r\n \"name\",\r\n \"subMeshes\",\r\n \"uniqueId\",\r\n \"parent\",\r\n \"lightSources\",\r\n \"receiveShadows\",\r\n \"material\",\r\n \"visibility\",\r\n \"skeleton\",\r\n \"sourceMesh\",\r\n \"isAnInstance\",\r\n \"facetNb\",\r\n \"isFacetDataEnabled\",\r\n \"isBlocked\",\r\n \"useBones\",\r\n \"hasInstances\",\r\n \"collider\",\r\n \"edgesRenderer\",\r\n \"forward\",\r\n \"up\",\r\n \"right\",\r\n \"absolutePosition\",\r\n \"absoluteScaling\",\r\n \"absoluteRotationQuaternion\",\r\n \"isWorldMatrixFrozen\",\r\n \"nonUniformScaling\",\r\n \"behaviors\",\r\n \"worldMatrixFromCache\",\r\n \"hasThinInstances\",\r\n \"hasBoundingInfo\",\r\n ],\r\n []\r\n );\r\n\r\n // Bounding info\r\n this.refreshBoundingInfo();\r\n\r\n // Parent\r\n if (newParent) {\r\n result.parent = newParent;\r\n }\r\n\r\n if (!doNotCloneChildren) {\r\n // Children\r\n for (let index = 0; index < this.getScene().meshes.length; index++) {\r\n const mesh = this.getScene().meshes[index];\r\n\r\n if (mesh.parent === this) {\r\n mesh.clone(mesh.name, result);\r\n }\r\n }\r\n }\r\n\r\n result.computeWorldMatrix(true);\r\n\r\n this.onClonedObservable.notifyObservers(result);\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Disposes the InstancedMesh.\r\n * Returns nothing.\r\n * @param doNotRecurse\r\n * @param disposeMaterialAndTextures\r\n */\r\n public dispose(doNotRecurse?: boolean, disposeMaterialAndTextures = false): void {\r\n // Remove from mesh\r\n this._sourceMesh.removeInstance(this);\r\n super.dispose(doNotRecurse, disposeMaterialAndTextures);\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _serializeAsParent(serializationObject: any) {\r\n super._serializeAsParent(serializationObject);\r\n\r\n serializationObject.parentId = this._sourceMesh.uniqueId;\r\n serializationObject.parentInstanceIndex = this._indexInSourceMeshInstanceArray;\r\n }\r\n\r\n /**\r\n * Instantiate (when possible) or clone that node with its hierarchy\r\n * @param newParent defines the new parent to use for the instance (or clone)\r\n * @param options defines options to configure how copy is done\r\n * @param options.doNotInstantiate defines if the model must be instantiated or just cloned\r\n * @param options.newSourcedMesh newSourcedMesh the new source mesh for the instance (or clone)\r\n * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created\r\n * @returns an instance (or a clone) of the current node with its hierarchy\r\n */\r\n public instantiateHierarchy(\r\n newParent: Nullable<TransformNode> = null,\r\n options?: { doNotInstantiate: boolean | ((node: TransformNode) => boolean); newSourcedMesh?: Mesh },\r\n onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void\r\n ): Nullable<TransformNode> {\r\n const clone = this.clone(\"Clone of \" + (this.name || this.id), newParent || this.parent, true, options && options.newSourcedMesh);\r\n\r\n if (clone) {\r\n if (onNewNodeCreated) {\r\n onNewNodeCreated(this, clone);\r\n }\r\n }\r\n\r\n for (const child of this.getChildTransformNodes(true)) {\r\n child.instantiateHierarchy(clone, options, onNewNodeCreated);\r\n }\r\n\r\n return clone;\r\n }\r\n}\r\n\r\ndeclare module \"./mesh\" {\r\n export interface Mesh {\r\n /**\r\n * Register a custom buffer that will be instanced\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/copies/instances#custom-buffers\r\n * @param kind defines the buffer kind\r\n * @param stride defines the stride in floats\r\n */\r\n registerInstancedBuffer(kind: string, stride: number): void;\r\n\r\n /**\r\n * Invalidate VertexArrayObjects belonging to the mesh (but not to the Geometry of the mesh).\r\n */\r\n _invalidateInstanceVertexArrayObject(): void;\r\n\r\n /**\r\n * true to use the edge renderer for all instances of this mesh\r\n */\r\n edgesShareWithInstances: boolean;\r\n\r\n /** @internal */\r\n _userInstancedBuffersStorage: {\r\n data: { [key: string]: Float32Array };\r\n sizes: { [key: string]: number };\r\n vertexBuffers: { [key: string]: Nullable<VertexBuffer> };\r\n strides: { [key: string]: number };\r\n vertexArrayObjects?: { [key: string]: WebGLVertexArrayObject };\r\n };\r\n }\r\n}\r\n\r\ndeclare module \"./abstractMesh\" {\r\n export interface AbstractMesh {\r\n /**\r\n * Object used to store instanced buffers defined by user\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/copies/instances#custom-buffers\r\n */\r\n instancedBuffers: { [key: string]: any };\r\n }\r\n}\r\n\r\nMesh.prototype.registerInstancedBuffer = function (kind: string, stride: number): void {\r\n // Remove existing one\r\n this._userInstancedBuffersStorage?.vertexBuffers[kind]?.dispose();\r\n\r\n // Creates the instancedBuffer field if not present\r\n if (!this.instancedBuffers) {\r\n this.instancedBuffers = {};\r\n\r\n for (const instance of this.instances) {\r\n instance.instancedBuffers = {};\r\n }\r\n\r\n if (!this._userInstancedBuffersStorage) {\r\n this._userInstancedBuffersStorage = {\r\n data: {},\r\n vertexBuffers: {},\r\n strides: {},\r\n sizes: {},\r\n vertexArrayObjects: this.getEngine().getCaps().vertexArrayObject ? {} : undefined,\r\n };\r\n }\r\n }\r\n\r\n // Creates an empty property for this kind\r\n this.instancedBuffers[kind] = null;\r\n\r\n this._userInstancedBuffersStorage.strides[kind] = stride;\r\n this._userInstancedBuffersStorage.sizes[kind] = stride * 32; // Initial size\r\n this._userInstancedBuffersStorage.data[kind] = new Float32Array(this._userInstancedBuffersStorage.sizes[kind]);\r\n this._userInstancedBuffersStorage.vertexBuffers[kind] = new VertexBuffer(this.getEngine(), this._userInstancedBuffersStorage.data[kind], kind, true, false, stride, true);\r\n\r\n for (const instance of this.instances) {\r\n instance.instancedBuffers[kind] = null;\r\n }\r\n\r\n this._invalidateInstanceVertexArrayObject();\r\n\r\n this._markSubMeshesAsAttributesDirty();\r\n};\r\n\r\nMesh.prototype._processInstancedBuffers = function (visibleInstances: Nullable<InstancedMesh[]>, renderSelf: boolean) {\r\n const instanceCount = visibleInstances ? visibleInstances.length : 0;\r\n\r\n for (const kind in this.instancedBuffers) {\r\n let size = this._userInstancedBuffersStorage.sizes[kind];\r\n const stride = this._userInstancedBuffersStorage.strides[kind];\r\n\r\n // Resize if required\r\n const expectedSize = (instanceCount + 1) * stride;\r\n\r\n while (size < expectedSize) {\r\n size *= 2;\r\n }\r\n\r\n if (this._userInstancedBuffersStorage.data[kind].length != size) {\r\n this._userInstancedBuffersStorage.data[kind] = new Float32Array(size);\r\n this._userInstancedBuffersStorage.sizes[kind] = size;\r\n if (this._userInstancedBuffersStorage.vertexBuffers[kind]) {\r\n this._userInstancedBuffersStorage.vertexBuffers[kind]!.dispose();\r\n this._userInstancedBuffersStorage.vertexBuffers[kind] = null;\r\n }\r\n }\r\n\r\n const data = this._userInstancedBuffersStorage.data[kind];\r\n\r\n // Update data buffer\r\n let offset = 0;\r\n if (renderSelf) {\r\n const value = this.instancedBuffers[kind];\r\n\r\n if (value.toArray) {\r\n value.toArray(data, offset);\r\n } else if (value.copyToArray) {\r\n value.copyToArray(data, offset);\r\n } else {\r\n data[offset] = value;\r\n }\r\n\r\n offset += stride;\r\n }\r\n\r\n for (let instanceIndex = 0; instanceIndex < instanceCount; instanceIndex++) {\r\n const instance = visibleInstances![instanceIndex]!;\r\n\r\n const value = instance.instancedBuffers[kind];\r\n\r\n if (value.toArray) {\r\n value.toArray(data, offset);\r\n } else if (value.copyToArray) {\r\n value.copyToArray(data, offset);\r\n } else {\r\n data[offset] = value;\r\n }\r\n\r\n offset += stride;\r\n }\r\n\r\n // Update vertex buffer\r\n if (!this._userInstancedBuffersStorage.vertexBuffers[kind]) {\r\n this._userInstancedBuffersStorage.vertexBuffers[kind] = new VertexBuffer(\r\n this.getEngine(),\r\n this._userInstancedBuffersStorage.data[kind],\r\n kind,\r\n true,\r\n false,\r\n stride,\r\n true\r\n );\r\n this._invalidateInstanceVertexArrayObject();\r\n } else {\r\n this._userInstancedBuffersStorage.vertexBuffers[kind]!.updateDirectly(data, 0);\r\n }\r\n }\r\n};\r\n\r\nMesh.prototype._invalidateInstanceVertexArrayObject = function () {\r\n if (!this._userInstancedBuffersStorage || this._userInstancedBuffersStorage.vertexArrayObjects === undefined) {\r\n return;\r\n }\r\n\r\n for (const kind in this._userInstancedBuffersStorage.vertexArrayObjects) {\r\n this.getEngine().releaseVertexArrayObject(this._userInstancedBuffersStorage.vertexArrayObjects[kind]);\r\n }\r\n\r\n this._userInstancedBuffersStorage.vertexArrayObjects = {};\r\n};\r\n\r\nMesh.prototype._disposeInstanceSpecificData = function () {\r\n if (this._instanceDataStorage.instancesBuffer) {\r\n this._instanceDataStorage.instancesBuffer.dispose();\r\n this._instanceDataStorage.instancesBuffer = null;\r\n }\r\n\r\n while (this.instances.length) {\r\n this.instances[0].dispose();\r\n }\r\n\r\n for (const kind in this.instancedBuffers) {\r\n if (this._userInstancedBuffersStorage.vertexBuffers[kind]) {\r\n this._userInstancedBuffersStorage.vertexBuffers[kind]!.dispose();\r\n }\r\n }\r\n\r\n this._invalidateInstanceVertexArrayObject();\r\n\r\n this.instancedBuffers = {};\r\n};\r\n"]}
1
+ {"version":3,"file":"instancedMesh.js","sourceRoot":"","sources":["../../../../lts/core/generated/Meshes/instancedMesh.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGxC,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AA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FloatArray, IndicesArray } from \"../types\";\r\nimport type { Vector3 } from \"../Maths/math.vector\";\r\nimport { Matrix, TmpVectors } from \"../Maths/math.vector\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport type { Node } from \"../node\";\r\nimport { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport { Mesh } from \"../Meshes/mesh\";\r\nimport type { Material } from \"../Materials/material\";\r\nimport type { Skeleton } from \"../Bones/skeleton\";\r\nimport { DeepCopier } from \"../Misc/deepCopier\";\r\nimport { TransformNode } from \"./transformNode\";\r\nimport type { Light } from \"../Lights/light\";\r\nimport { VertexBuffer } from \"../Buffers/buffer\";\r\n\r\nMesh._instancedMeshFactory = (name: string, mesh: Mesh): InstancedMesh => {\r\n const instance = new InstancedMesh(name, mesh);\r\n\r\n if (mesh.instancedBuffers) {\r\n instance.instancedBuffers = {};\r\n\r\n for (const key in mesh.instancedBuffers) {\r\n instance.instancedBuffers[key] = mesh.instancedBuffers[key];\r\n }\r\n }\r\n\r\n return instance;\r\n};\r\n\r\n/**\r\n * Creates an instance based on a source mesh.\r\n */\r\nexport class InstancedMesh extends AbstractMesh {\r\n private _sourceMesh: Mesh;\r\n private _currentLOD: Mesh;\r\n private _billboardWorldMatrix: Matrix;\r\n\r\n /** @internal */\r\n public _indexInSourceMeshInstanceArray = -1;\r\n /** @internal */\r\n public _distanceToCamera: number = 0;\r\n /** @internal */\r\n public _previousWorldMatrix: Nullable<Matrix>;\r\n\r\n constructor(name: string, source: Mesh) {\r\n super(name, source.getScene());\r\n\r\n source.addInstance(this);\r\n\r\n this._sourceMesh = source;\r\n\r\n this._unIndexed = source._unIndexed;\r\n\r\n this.position.copyFrom(source.position);\r\n this.rotation.copyFrom(source.rotation);\r\n this.scaling.copyFrom(source.scaling);\r\n\r\n if (source.rotationQuaternion) {\r\n this.rotationQuaternion = source.rotationQuaternion.clone();\r\n }\r\n\r\n this.animations = source.animations.slice();\r\n for (const range of source.getAnimationRanges()) {\r\n if (range != null) {\r\n this.createAnimationRange(range.name, range.from, range.to);\r\n }\r\n }\r\n\r\n this.infiniteDistance = source.infiniteDistance;\r\n\r\n this.setPivotMatrix(source.getPivotMatrix());\r\n\r\n this.refreshBoundingInfo(true, true);\r\n this._syncSubMeshes();\r\n }\r\n\r\n /**\r\n * Returns the string \"InstancedMesh\".\r\n */\r\n public getClassName(): string {\r\n return \"InstancedMesh\";\r\n }\r\n\r\n /** Gets the list of lights affecting that mesh */\r\n public get lightSources(): Light[] {\r\n return this._sourceMesh._lightSources;\r\n }\r\n\r\n public _resyncLightSources(): void {\r\n // Do nothing as all the work will be done by source mesh\r\n }\r\n\r\n public _resyncLightSource(): void {\r\n // Do nothing as all the work will be done by source mesh\r\n }\r\n\r\n public _removeLightSource(): void {\r\n // Do nothing as all the work will be done by source mesh\r\n }\r\n\r\n // Methods\r\n /**\r\n * If the source mesh receives shadows\r\n */\r\n public get receiveShadows(): boolean {\r\n return this._sourceMesh.receiveShadows;\r\n }\r\n\r\n /**\r\n * The material of the source mesh\r\n */\r\n public get material(): Nullable<Material> {\r\n return this._sourceMesh.material;\r\n }\r\n\r\n /**\r\n * Visibility of the source mesh\r\n */\r\n public get visibility(): number {\r\n return this._sourceMesh.visibility;\r\n }\r\n\r\n /**\r\n * Skeleton of the source mesh\r\n */\r\n public get skeleton(): Nullable<Skeleton> {\r\n return this._sourceMesh.skeleton;\r\n }\r\n\r\n /**\r\n * Rendering ground id of the source mesh\r\n */\r\n public get renderingGroupId(): number {\r\n return this._sourceMesh.renderingGroupId;\r\n }\r\n\r\n public set renderingGroupId(value: number) {\r\n if (!this._sourceMesh || value === this._sourceMesh.renderingGroupId) {\r\n return;\r\n }\r\n\r\n //no-op with warning\r\n Logger.Warn(\"Note - setting renderingGroupId of an instanced mesh has no effect on the scene\");\r\n }\r\n\r\n /**\r\n * Returns the total number of vertices (integer).\r\n */\r\n public getTotalVertices(): number {\r\n return this._sourceMesh ? this._sourceMesh.getTotalVertices() : 0;\r\n }\r\n\r\n /**\r\n * Returns a positive integer : the total number of indices in this mesh geometry.\r\n * @returns the number of indices or zero if the mesh has no geometry.\r\n */\r\n public getTotalIndices(): number {\r\n return this._sourceMesh.getTotalIndices();\r\n }\r\n\r\n /**\r\n * The source mesh of the instance\r\n */\r\n public get sourceMesh(): Mesh {\r\n return this._sourceMesh;\r\n }\r\n\r\n /**\r\n * Creates a new InstancedMesh object from the mesh model.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/copies/instances\r\n * @param name defines the name of the new instance\r\n * @returns a new InstancedMesh\r\n */\r\n public createInstance(name: string): InstancedMesh {\r\n return this._sourceMesh.createInstance(name);\r\n }\r\n\r\n /**\r\n * Is this node ready to be used/rendered\r\n * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)\r\n * @returns {boolean} is it ready\r\n */\r\n public isReady(completeCheck = false): boolean {\r\n return this._sourceMesh.isReady(completeCheck, true);\r\n }\r\n\r\n /**\r\n * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.\r\n * @param kind kind of verticies to retrieve (eg. positions, normals, uvs, etc.)\r\n * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.\r\n * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is\r\n * @returns a float array or a Float32Array of the requested kind of data : positions, normals, uvs, etc.\r\n */\r\n public getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray> {\r\n return this._sourceMesh.getVerticesData(kind, copyWhenShared, forceCopy);\r\n }\r\n\r\n /**\r\n * Sets the vertex data of the mesh geometry for the requested `kind`.\r\n * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.\r\n * The `data` are either a numeric array either a Float32Array.\r\n * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initially none) or updater.\r\n * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).\r\n * Note that a new underlying VertexBuffer object is created each call.\r\n * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.\r\n *\r\n * Possible `kind` values :\r\n * - VertexBuffer.PositionKind\r\n * - VertexBuffer.UVKind\r\n * - VertexBuffer.UV2Kind\r\n * - VertexBuffer.UV3Kind\r\n * - VertexBuffer.UV4Kind\r\n * - VertexBuffer.UV5Kind\r\n * - VertexBuffer.UV6Kind\r\n * - VertexBuffer.ColorKind\r\n * - VertexBuffer.MatricesIndicesKind\r\n * - VertexBuffer.MatricesIndicesExtraKind\r\n * - VertexBuffer.MatricesWeightsKind\r\n * - VertexBuffer.MatricesWeightsExtraKind\r\n *\r\n * Returns the Mesh.\r\n * @param kind\r\n * @param data\r\n * @param updatable\r\n * @param stride\r\n */\r\n public setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh {\r\n if (this.sourceMesh) {\r\n this.sourceMesh.setVerticesData(kind, data, updatable, stride);\r\n }\r\n return this.sourceMesh;\r\n }\r\n\r\n /**\r\n * Updates the existing vertex data of the mesh geometry for the requested `kind`.\r\n * If the mesh has no geometry, it is simply returned as it is.\r\n * The `data` are either a numeric array either a Float32Array.\r\n * No new underlying VertexBuffer object is created.\r\n * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.\r\n * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.\r\n *\r\n * Possible `kind` values :\r\n * - VertexBuffer.PositionKind\r\n * - VertexBuffer.UVKind\r\n * - VertexBuffer.UV2Kind\r\n * - VertexBuffer.UV3Kind\r\n * - VertexBuffer.UV4Kind\r\n * - VertexBuffer.UV5Kind\r\n * - VertexBuffer.UV6Kind\r\n * - VertexBuffer.ColorKind\r\n * - VertexBuffer.MatricesIndicesKind\r\n * - VertexBuffer.MatricesIndicesExtraKind\r\n * - VertexBuffer.MatricesWeightsKind\r\n * - VertexBuffer.MatricesWeightsExtraKind\r\n *\r\n * Returns the Mesh.\r\n * @param kind\r\n * @param data\r\n * @param updateExtends\r\n * @param makeItUnique\r\n */\r\n public updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh {\r\n if (this.sourceMesh) {\r\n this.sourceMesh.updateVerticesData(kind, data, updateExtends, makeItUnique);\r\n }\r\n return this.sourceMesh;\r\n }\r\n\r\n /**\r\n * Sets the mesh indices.\r\n * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).\r\n * If the mesh has no geometry, a new Geometry object is created and set to the mesh.\r\n * This method creates a new index buffer each call.\r\n * Returns the Mesh.\r\n * @param indices\r\n * @param totalVertices\r\n */\r\n public setIndices(indices: IndicesArray, totalVertices: Nullable<number> = null): Mesh {\r\n if (this.sourceMesh) {\r\n this.sourceMesh.setIndices(indices, totalVertices);\r\n }\r\n return this.sourceMesh;\r\n }\r\n\r\n /**\r\n * Boolean : True if the mesh owns the requested kind of data.\r\n * @param kind\r\n */\r\n public isVerticesDataPresent(kind: string): boolean {\r\n return this._sourceMesh.isVerticesDataPresent(kind);\r\n }\r\n\r\n /**\r\n * Returns an array of indices (IndicesArray).\r\n */\r\n public getIndices(): Nullable<IndicesArray> {\r\n return this._sourceMesh.getIndices();\r\n }\r\n\r\n public get _positions(): Nullable<Vector3[]> {\r\n return this._sourceMesh._positions;\r\n }\r\n\r\n /**\r\n * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.\r\n * This means the mesh underlying bounding box and sphere are recomputed.\r\n * @param applySkeleton defines whether to apply the skeleton before computing the bounding info\r\n * @param applyMorph defines whether to apply the morph target before computing the bounding info\r\n * @returns the current mesh\r\n */\r\n public refreshBoundingInfo(applySkeleton: boolean = false, applyMorph: boolean = false): InstancedMesh {\r\n if (this.hasBoundingInfo && this.getBoundingInfo().isLocked) {\r\n return this;\r\n }\r\n\r\n const bias = this._sourceMesh.geometry ? this._sourceMesh.geometry.boundingBias : null;\r\n this._refreshBoundingInfo(this._sourceMesh._getPositionData(applySkeleton, applyMorph), bias);\r\n return this;\r\n }\r\n\r\n /** @internal */\r\n public _preActivate(): InstancedMesh {\r\n if (this._currentLOD) {\r\n this._currentLOD._preActivate();\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _activate(renderId: number, intermediateRendering: boolean): boolean {\r\n super._activate(renderId, intermediateRendering);\r\n\r\n if (!this._sourceMesh.subMeshes) {\r\n Logger.Warn(\"Instances should only be created for meshes with geometry.\");\r\n }\r\n\r\n if (this._currentLOD) {\r\n const differentSign = this._currentLOD._getWorldMatrixDeterminant() >= 0 !== this._getWorldMatrixDeterminant() >= 0;\r\n if (differentSign) {\r\n this._internalAbstractMeshDataInfo._actAsRegularMesh = true;\r\n return true;\r\n }\r\n this._internalAbstractMeshDataInfo._actAsRegularMesh = false;\r\n\r\n this._currentLOD._registerInstanceForRenderId(this, renderId);\r\n\r\n if (intermediateRendering) {\r\n if (!this._currentLOD._internalAbstractMeshDataInfo._isActiveIntermediate) {\r\n this._currentLOD._internalAbstractMeshDataInfo._onlyForInstancesIntermediate = true;\r\n return true;\r\n }\r\n } else {\r\n if (!this._currentLOD._internalAbstractMeshDataInfo._isActive) {\r\n this._currentLOD._internalAbstractMeshDataInfo._onlyForInstances = true;\r\n return true;\r\n }\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n /** @internal */\r\n public _postActivate(): void {\r\n if (this._sourceMesh.edgesShareWithInstances && this._sourceMesh._edgesRenderer && this._sourceMesh._edgesRenderer.isEnabled && this._sourceMesh._renderingGroup) {\r\n // we are using the edge renderer of the source mesh\r\n this._sourceMesh._renderingGroup._edgesRenderers.pushNoDuplicate(this._sourceMesh._edgesRenderer);\r\n this._sourceMesh._edgesRenderer.customInstances.push(this.getWorldMatrix());\r\n } else if (this._edgesRenderer && this._edgesRenderer.isEnabled && this._sourceMesh._renderingGroup) {\r\n // we are using the edge renderer defined for this instance\r\n this._sourceMesh._renderingGroup._edgesRenderers.push(this._edgesRenderer);\r\n }\r\n }\r\n\r\n public getWorldMatrix(): Matrix {\r\n if (this._currentLOD && this._currentLOD.billboardMode !== TransformNode.BILLBOARDMODE_NONE && this._currentLOD._masterMesh !== this) {\r\n if (!this._billboardWorldMatrix) {\r\n this._billboardWorldMatrix = new Matrix();\r\n }\r\n const tempMaster = this._currentLOD._masterMesh;\r\n this._currentLOD._masterMesh = this;\r\n TmpVectors.Vector3[7].copyFrom(this._currentLOD.position);\r\n this._currentLOD.position.set(0, 0, 0);\r\n this._billboardWorldMatrix.copyFrom(this._currentLOD.computeWorldMatrix(true));\r\n this._currentLOD.position.copyFrom(TmpVectors.Vector3[7]);\r\n this._currentLOD._masterMesh = tempMaster;\r\n return this._billboardWorldMatrix;\r\n }\r\n\r\n return super.getWorldMatrix();\r\n }\r\n\r\n public get isAnInstance(): boolean {\r\n return true;\r\n }\r\n\r\n /**\r\n * Returns the current associated LOD AbstractMesh.\r\n * @param camera\r\n */\r\n public getLOD(camera: Camera): AbstractMesh {\r\n if (!camera) {\r\n return this;\r\n }\r\n\r\n const sourceMeshLODLevels = this.sourceMesh.getLODLevels();\r\n if (!sourceMeshLODLevels || sourceMeshLODLevels.length === 0) {\r\n this._currentLOD = this.sourceMesh;\r\n } else {\r\n const boundingInfo = this.getBoundingInfo();\r\n this._currentLOD = <Mesh>this.sourceMesh.getLOD(camera, boundingInfo.boundingSphere);\r\n }\r\n\r\n return this._currentLOD;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _preActivateForIntermediateRendering(renderId: number): Mesh {\r\n return <Mesh>this.sourceMesh._preActivateForIntermediateRendering(renderId);\r\n }\r\n\r\n /** @internal */\r\n public _syncSubMeshes(): InstancedMesh {\r\n this.releaseSubMeshes();\r\n if (this._sourceMesh.subMeshes) {\r\n for (let index = 0; index < this._sourceMesh.subMeshes.length; index++) {\r\n this._sourceMesh.subMeshes[index].clone(this, this._sourceMesh);\r\n }\r\n }\r\n return this;\r\n }\r\n\r\n /** @internal */\r\n public _generatePointsArray(): boolean {\r\n return this._sourceMesh._generatePointsArray();\r\n }\r\n\r\n /** @internal */\r\n public _updateBoundingInfo(): AbstractMesh {\r\n if (this.hasBoundingInfo) {\r\n this.getBoundingInfo().update(this.worldMatrixFromCache);\r\n } else {\r\n this.buildBoundingInfo(this.absolutePosition, this.absolutePosition, this.worldMatrixFromCache);\r\n }\r\n this._updateSubMeshesBoundingInfo(this.worldMatrixFromCache);\r\n return this;\r\n }\r\n\r\n /**\r\n * Creates a new InstancedMesh from the current mesh.\r\n *\r\n * Returns the clone.\r\n * @param name the cloned mesh name\r\n * @param newParent the optional Node to parent the clone to.\r\n * @param doNotCloneChildren if `true` the model children aren't cloned.\r\n * @param newSourceMesh if set this mesh will be used as the source mesh instead of ths instance's one\r\n * @returns the clone\r\n */\r\n public clone(name: string, newParent: Nullable<Node> = null, doNotCloneChildren?: boolean, newSourceMesh?: Mesh): InstancedMesh {\r\n const result = (newSourceMesh || this._sourceMesh).createInstance(name);\r\n\r\n // Deep copy\r\n DeepCopier.DeepCopy(\r\n this,\r\n result,\r\n [\r\n \"name\",\r\n \"subMeshes\",\r\n \"uniqueId\",\r\n \"parent\",\r\n \"lightSources\",\r\n \"receiveShadows\",\r\n \"material\",\r\n \"visibility\",\r\n \"skeleton\",\r\n \"sourceMesh\",\r\n \"isAnInstance\",\r\n \"facetNb\",\r\n \"isFacetDataEnabled\",\r\n \"isBlocked\",\r\n \"useBones\",\r\n \"hasInstances\",\r\n \"collider\",\r\n \"edgesRenderer\",\r\n \"forward\",\r\n \"up\",\r\n \"right\",\r\n \"absolutePosition\",\r\n \"absoluteScaling\",\r\n \"absoluteRotationQuaternion\",\r\n \"isWorldMatrixFrozen\",\r\n \"nonUniformScaling\",\r\n \"behaviors\",\r\n \"worldMatrixFromCache\",\r\n \"hasThinInstances\",\r\n \"hasBoundingInfo\",\r\n ],\r\n []\r\n );\r\n\r\n // Bounding info\r\n this.refreshBoundingInfo();\r\n\r\n // Parent\r\n if (newParent) {\r\n result.parent = newParent;\r\n }\r\n\r\n if (!doNotCloneChildren) {\r\n // Children\r\n for (let index = 0; index < this.getScene().meshes.length; index++) {\r\n const mesh = this.getScene().meshes[index];\r\n\r\n if (mesh.parent === this) {\r\n mesh.clone(mesh.name, result);\r\n }\r\n }\r\n }\r\n\r\n result.computeWorldMatrix(true);\r\n\r\n this.onClonedObservable.notifyObservers(result);\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Disposes the InstancedMesh.\r\n * Returns nothing.\r\n * @param doNotRecurse\r\n * @param disposeMaterialAndTextures\r\n */\r\n public dispose(doNotRecurse?: boolean, disposeMaterialAndTextures = false): void {\r\n // Remove from mesh\r\n this._sourceMesh.removeInstance(this);\r\n super.dispose(doNotRecurse, disposeMaterialAndTextures);\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _serializeAsParent(serializationObject: any) {\r\n super._serializeAsParent(serializationObject);\r\n\r\n serializationObject.parentId = this._sourceMesh.uniqueId;\r\n serializationObject.parentInstanceIndex = this._indexInSourceMeshInstanceArray;\r\n }\r\n\r\n /**\r\n * Instantiate (when possible) or clone that node with its hierarchy\r\n * @param newParent defines the new parent to use for the instance (or clone)\r\n * @param options defines options to configure how copy is done\r\n * @param options.doNotInstantiate defines if the model must be instantiated or just cloned\r\n * @param options.newSourcedMesh newSourcedMesh the new source mesh for the instance (or clone)\r\n * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created\r\n * @returns an instance (or a clone) of the current node with its hierarchy\r\n */\r\n public instantiateHierarchy(\r\n newParent: Nullable<TransformNode> = null,\r\n options?: { doNotInstantiate: boolean | ((node: TransformNode) => boolean); newSourcedMesh?: Mesh },\r\n onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void\r\n ): Nullable<TransformNode> {\r\n const clone = this.clone(\"Clone of \" + (this.name || this.id), newParent || this.parent, true, options && options.newSourcedMesh);\r\n\r\n if (clone) {\r\n if (onNewNodeCreated) {\r\n onNewNodeCreated(this, clone);\r\n }\r\n }\r\n\r\n for (const child of this.getChildTransformNodes(true)) {\r\n child.instantiateHierarchy(clone, options, onNewNodeCreated);\r\n }\r\n\r\n return clone;\r\n }\r\n}\r\n\r\ndeclare module \"./mesh\" {\r\n export interface Mesh {\r\n /**\r\n * Register a custom buffer that will be instanced\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/copies/instances#custom-buffers\r\n * @param kind defines the buffer kind\r\n * @param stride defines the stride in floats\r\n */\r\n registerInstancedBuffer(kind: string, stride: number): void;\r\n\r\n /**\r\n * Invalidate VertexArrayObjects belonging to the mesh (but not to the Geometry of the mesh).\r\n */\r\n _invalidateInstanceVertexArrayObject(): void;\r\n\r\n /**\r\n * true to use the edge renderer for all instances of this mesh\r\n */\r\n edgesShareWithInstances: boolean;\r\n\r\n /** @internal */\r\n _userInstancedBuffersStorage: {\r\n data: { [key: string]: Float32Array };\r\n sizes: { [key: string]: number };\r\n vertexBuffers: { [key: string]: Nullable<VertexBuffer> };\r\n strides: { [key: string]: number };\r\n vertexArrayObjects?: { [key: string]: WebGLVertexArrayObject };\r\n };\r\n }\r\n}\r\n\r\ndeclare module \"./abstractMesh\" {\r\n export interface AbstractMesh {\r\n /**\r\n * Object used to store instanced buffers defined by user\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/copies/instances#custom-buffers\r\n */\r\n instancedBuffers: { [key: string]: any };\r\n }\r\n}\r\n\r\nMesh.prototype.registerInstancedBuffer = function (kind: string, stride: number): void {\r\n // Remove existing one\r\n this._userInstancedBuffersStorage?.vertexBuffers[kind]?.dispose();\r\n\r\n // Creates the instancedBuffer field if not present\r\n if (!this.instancedBuffers) {\r\n this.instancedBuffers = {};\r\n\r\n for (const instance of this.instances) {\r\n instance.instancedBuffers = {};\r\n }\r\n\r\n if (!this._userInstancedBuffersStorage) {\r\n this._userInstancedBuffersStorage = {\r\n data: {},\r\n vertexBuffers: {},\r\n strides: {},\r\n sizes: {},\r\n vertexArrayObjects: this.getEngine().getCaps().vertexArrayObject ? {} : undefined,\r\n };\r\n }\r\n }\r\n\r\n // Creates an empty property for this kind\r\n this.instancedBuffers[kind] = null;\r\n\r\n this._userInstancedBuffersStorage.strides[kind] = stride;\r\n this._userInstancedBuffersStorage.sizes[kind] = stride * 32; // Initial size\r\n this._userInstancedBuffersStorage.data[kind] = new Float32Array(this._userInstancedBuffersStorage.sizes[kind]);\r\n this._userInstancedBuffersStorage.vertexBuffers[kind] = new VertexBuffer(this.getEngine(), this._userInstancedBuffersStorage.data[kind], kind, true, false, stride, true);\r\n\r\n for (const instance of this.instances) {\r\n instance.instancedBuffers[kind] = null;\r\n }\r\n\r\n this._invalidateInstanceVertexArrayObject();\r\n\r\n this._markSubMeshesAsAttributesDirty();\r\n};\r\n\r\nMesh.prototype._processInstancedBuffers = function (visibleInstances: Nullable<InstancedMesh[]>, renderSelf: boolean) {\r\n const instanceCount = visibleInstances ? visibleInstances.length : 0;\r\n\r\n for (const kind in this.instancedBuffers) {\r\n let size = this._userInstancedBuffersStorage.sizes[kind];\r\n const stride = this._userInstancedBuffersStorage.strides[kind];\r\n\r\n // Resize if required\r\n const expectedSize = (instanceCount + 1) * stride;\r\n\r\n while (size < expectedSize) {\r\n size *= 2;\r\n }\r\n\r\n if (this._userInstancedBuffersStorage.data[kind].length != size) {\r\n this._userInstancedBuffersStorage.data[kind] = new Float32Array(size);\r\n this._userInstancedBuffersStorage.sizes[kind] = size;\r\n if (this._userInstancedBuffersStorage.vertexBuffers[kind]) {\r\n this._userInstancedBuffersStorage.vertexBuffers[kind]!.dispose();\r\n this._userInstancedBuffersStorage.vertexBuffers[kind] = null;\r\n }\r\n }\r\n\r\n const data = this._userInstancedBuffersStorage.data[kind];\r\n\r\n // Update data buffer\r\n let offset = 0;\r\n if (renderSelf) {\r\n const value = this.instancedBuffers[kind];\r\n\r\n if (value.toArray) {\r\n value.toArray(data, offset);\r\n } else if (value.copyToArray) {\r\n value.copyToArray(data, offset);\r\n } else {\r\n data[offset] = value;\r\n }\r\n\r\n offset += stride;\r\n }\r\n\r\n for (let instanceIndex = 0; instanceIndex < instanceCount; instanceIndex++) {\r\n const instance = visibleInstances![instanceIndex]!;\r\n\r\n const value = instance.instancedBuffers[kind];\r\n\r\n if (value.toArray) {\r\n value.toArray(data, offset);\r\n } else if (value.copyToArray) {\r\n value.copyToArray(data, offset);\r\n } else {\r\n data[offset] = value;\r\n }\r\n\r\n offset += stride;\r\n }\r\n\r\n // Update vertex buffer\r\n if (!this._userInstancedBuffersStorage.vertexBuffers[kind]) {\r\n this._userInstancedBuffersStorage.vertexBuffers[kind] = new VertexBuffer(\r\n this.getEngine(),\r\n this._userInstancedBuffersStorage.data[kind],\r\n kind,\r\n true,\r\n false,\r\n stride,\r\n true\r\n );\r\n this._invalidateInstanceVertexArrayObject();\r\n } else {\r\n this._userInstancedBuffersStorage.vertexBuffers[kind]!.updateDirectly(data, 0);\r\n }\r\n }\r\n};\r\n\r\nMesh.prototype._invalidateInstanceVertexArrayObject = function () {\r\n if (!this._userInstancedBuffersStorage || this._userInstancedBuffersStorage.vertexArrayObjects === undefined) {\r\n return;\r\n }\r\n\r\n for (const kind in this._userInstancedBuffersStorage.vertexArrayObjects) {\r\n this.getEngine().releaseVertexArrayObject(this._userInstancedBuffersStorage.vertexArrayObjects[kind]);\r\n }\r\n\r\n this._userInstancedBuffersStorage.vertexArrayObjects = {};\r\n};\r\n\r\nMesh.prototype._disposeInstanceSpecificData = function () {\r\n if (this._instanceDataStorage.instancesBuffer) {\r\n this._instanceDataStorage.instancesBuffer.dispose();\r\n this._instanceDataStorage.instancesBuffer = null;\r\n }\r\n\r\n while (this.instances.length) {\r\n this.instances[0].dispose();\r\n }\r\n\r\n for (const kind in this.instancedBuffers) {\r\n if (this._userInstancedBuffersStorage.vertexBuffers[kind]) {\r\n this._userInstancedBuffersStorage.vertexBuffers[kind]!.dispose();\r\n }\r\n }\r\n\r\n this._invalidateInstanceVertexArrayObject();\r\n\r\n this.instancedBuffers = {};\r\n};\r\n"]}
package/Meshes/mesh.d.ts CHANGED
@@ -404,9 +404,10 @@ export declare class Mesh extends AbstractMesh implements IGetSetVerticesData {
404
404
  * - VertexBuffer.MatricesWeightsExtraKind
405
405
  * @param copyWhenShared defines a boolean indicating that if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one
406
406
  * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
407
+ * @param bypassInstanceData defines a boolean indicating that the function should not take into account the instance data (applies only if the mesh has instances). Default: false
407
408
  * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
408
409
  */
409
- getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
410
+ getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean, bypassInstanceData?: boolean): Nullable<FloatArray>;
410
411
  /**
411
412
  * Returns the mesh VertexBuffer object from the requested `kind`
412
413
  * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
@@ -423,9 +424,10 @@ export declare class Mesh extends AbstractMesh implements IGetSetVerticesData {
423
424
  * - VertexBuffer.MatricesIndicesExtraKind
424
425
  * - VertexBuffer.MatricesWeightsKind
425
426
  * - VertexBuffer.MatricesWeightsExtraKind
427
+ * @param bypassInstanceData defines a boolean indicating that the function should not take into account the instance data (applies only if the mesh has instances). Default: false
426
428
  * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
427
429
  */
428
- getVertexBuffer(kind: string): Nullable<VertexBuffer>;
430
+ getVertexBuffer(kind: string, bypassInstanceData?: boolean): Nullable<VertexBuffer>;
429
431
  /**
430
432
  * Tests if a specific vertex buffer is associated with this mesh
431
433
  * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
@@ -442,9 +444,10 @@ export declare class Mesh extends AbstractMesh implements IGetSetVerticesData {
442
444
  * - VertexBuffer.MatricesIndicesExtraKind
443
445
  * - VertexBuffer.MatricesWeightsKind
444
446
  * - VertexBuffer.MatricesWeightsExtraKind
447
+ * @param bypassInstanceData defines a boolean indicating that the function should not take into account the instance data (applies only if the mesh has instances). Default: false
445
448
  * @returns a boolean
446
449
  */
447
- isVerticesDataPresent(kind: string): boolean;
450
+ isVerticesDataPresent(kind: string, bypassInstanceData?: boolean): boolean;
448
451
  /**
449
452
  * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
450
453
  * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
@@ -460,14 +463,16 @@ export declare class Mesh extends AbstractMesh implements IGetSetVerticesData {
460
463
  * - VertexBuffer.MatricesIndicesExtraKind
461
464
  * - VertexBuffer.MatricesWeightsKind
462
465
  * - VertexBuffer.MatricesWeightsExtraKind
466
+ * @param bypassInstanceData defines a boolean indicating that the function should not take into account the instance data (applies only if the mesh has instances). Default: false
463
467
  * @returns a boolean
464
468
  */
465
- isVertexBufferUpdatable(kind: string): boolean;
469
+ isVertexBufferUpdatable(kind: string, bypassInstanceData?: boolean): boolean;
466
470
  /**
467
471
  * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
472
+ * @param bypassInstanceData defines a boolean indicating that the function should not take into account the instance data (applies only if the mesh has instances). Default: false
468
473
  * @returns an array of strings
469
474
  */
470
- getVerticesDataKinds(): string[];
475
+ getVerticesDataKinds(bypassInstanceData?: boolean): string[];
471
476
  /**
472
477
  * Returns a positive integer : the total number of indices in this mesh geometry.
473
478
  * @returns the numner of indices or zero if the mesh has no geometry.
package/Meshes/mesh.js CHANGED
@@ -422,10 +422,17 @@ export class Mesh extends AbstractMesh {
422
422
  // Physics clone
423
423
  if (scene.getPhysicsEngine) {
424
424
  const physicsEngine = scene.getPhysicsEngine();
425
- if (clonePhysicsImpostor && physicsEngine && physicsEngine.getPluginVersion() === 1) {
426
- const impostor = physicsEngine.getImpostorForPhysicsObject(source);
427
- if (impostor) {
428
- this.physicsImpostor = impostor.clone(this);
425
+ if (clonePhysicsImpostor && physicsEngine) {
426
+ if (physicsEngine.getPluginVersion() === 1) {
427
+ const impostor = physicsEngine.getImpostorForPhysicsObject(source);
428
+ if (impostor) {
429
+ this.physicsImpostor = impostor.clone(this);
430
+ }
431
+ }
432
+ else if (physicsEngine.getPluginVersion() === 2) {
433
+ if (source.physicsBody) {
434
+ source.physicsBody.clone(this);
435
+ }
429
436
  }
430
437
  }
431
438
  }
@@ -716,14 +723,18 @@ export class Mesh extends AbstractMesh {
716
723
  * - VertexBuffer.MatricesWeightsExtraKind
717
724
  * @param copyWhenShared defines a boolean indicating that if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one
718
725
  * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
726
+ * @param bypassInstanceData defines a boolean indicating that the function should not take into account the instance data (applies only if the mesh has instances). Default: false
719
727
  * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
720
728
  */
721
- getVerticesData(kind, copyWhenShared, forceCopy) {
729
+ getVerticesData(kind, copyWhenShared, forceCopy, bypassInstanceData) {
722
730
  var _a, _b;
723
731
  if (!this._geometry) {
724
732
  return null;
725
733
  }
726
- let data = (_b = (_a = this._userInstancedBuffersStorage) === null || _a === void 0 ? void 0 : _a.vertexBuffers[kind]) === null || _b === void 0 ? void 0 : _b.getFloatData(this._geometry.getTotalVertices(), forceCopy || (copyWhenShared && this._geometry.meshes.length !== 1));
734
+ let data = bypassInstanceData
735
+ ? undefined
736
+ : (_b = (_a = this._userInstancedBuffersStorage) === null || _a === void 0 ? void 0 : _a.vertexBuffers[kind]) === null || _b === void 0 ? void 0 : _b.getFloatData(this.instances.length + 1, // +1 because the master mesh is not included in the instances array
737
+ forceCopy || (copyWhenShared && this._geometry.meshes.length !== 1));
727
738
  if (!data) {
728
739
  data = this._geometry.getVerticesData(kind, copyWhenShared, forceCopy);
729
740
  }
@@ -745,14 +756,15 @@ export class Mesh extends AbstractMesh {
745
756
  * - VertexBuffer.MatricesIndicesExtraKind
746
757
  * - VertexBuffer.MatricesWeightsKind
747
758
  * - VertexBuffer.MatricesWeightsExtraKind
759
+ * @param bypassInstanceData defines a boolean indicating that the function should not take into account the instance data (applies only if the mesh has instances). Default: false
748
760
  * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
749
761
  */
750
- getVertexBuffer(kind) {
762
+ getVertexBuffer(kind, bypassInstanceData) {
751
763
  var _a, _b;
752
764
  if (!this._geometry) {
753
765
  return null;
754
766
  }
755
- return (_b = (_a = this._userInstancedBuffersStorage) === null || _a === void 0 ? void 0 : _a.vertexBuffers[kind]) !== null && _b !== void 0 ? _b : this._geometry.getVertexBuffer(kind);
767
+ return (_b = (bypassInstanceData ? undefined : (_a = this._userInstancedBuffersStorage) === null || _a === void 0 ? void 0 : _a.vertexBuffers[kind])) !== null && _b !== void 0 ? _b : this._geometry.getVertexBuffer(kind);
756
768
  }
757
769
  /**
758
770
  * Tests if a specific vertex buffer is associated with this mesh
@@ -770,9 +782,10 @@ export class Mesh extends AbstractMesh {
770
782
  * - VertexBuffer.MatricesIndicesExtraKind
771
783
  * - VertexBuffer.MatricesWeightsKind
772
784
  * - VertexBuffer.MatricesWeightsExtraKind
785
+ * @param bypassInstanceData defines a boolean indicating that the function should not take into account the instance data (applies only if the mesh has instances). Default: false
773
786
  * @returns a boolean
774
787
  */
775
- isVerticesDataPresent(kind) {
788
+ isVerticesDataPresent(kind, bypassInstanceData) {
776
789
  var _a;
777
790
  if (!this._geometry) {
778
791
  if (this._delayInfo) {
@@ -780,7 +793,7 @@ export class Mesh extends AbstractMesh {
780
793
  }
781
794
  return false;
782
795
  }
783
- return ((_a = this._userInstancedBuffersStorage) === null || _a === void 0 ? void 0 : _a.vertexBuffers[kind]) !== undefined || this._geometry.isVerticesDataPresent(kind);
796
+ return (!bypassInstanceData && ((_a = this._userInstancedBuffersStorage) === null || _a === void 0 ? void 0 : _a.vertexBuffers[kind]) !== undefined) || this._geometry.isVerticesDataPresent(kind);
784
797
  }
785
798
  /**
786
799
  * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
@@ -797,23 +810,31 @@ export class Mesh extends AbstractMesh {
797
810
  * - VertexBuffer.MatricesIndicesExtraKind
798
811
  * - VertexBuffer.MatricesWeightsKind
799
812
  * - VertexBuffer.MatricesWeightsExtraKind
813
+ * @param bypassInstanceData defines a boolean indicating that the function should not take into account the instance data (applies only if the mesh has instances). Default: false
800
814
  * @returns a boolean
801
815
  */
802
- isVertexBufferUpdatable(kind) {
803
- var _a, _b;
816
+ isVertexBufferUpdatable(kind, bypassInstanceData) {
817
+ var _a;
804
818
  if (!this._geometry) {
805
819
  if (this._delayInfo) {
806
820
  return this._delayInfo.indexOf(kind) !== -1;
807
821
  }
808
822
  return false;
809
823
  }
810
- return ((_b = (_a = this._userInstancedBuffersStorage) === null || _a === void 0 ? void 0 : _a.vertexBuffers[kind]) === null || _b === void 0 ? void 0 : _b.isUpdatable()) || this._geometry.isVertexBufferUpdatable(kind);
824
+ if (!bypassInstanceData) {
825
+ const buffer = (_a = this._userInstancedBuffersStorage) === null || _a === void 0 ? void 0 : _a.vertexBuffers[kind];
826
+ if (buffer) {
827
+ return buffer.isUpdatable();
828
+ }
829
+ }
830
+ return this._geometry.isVertexBufferUpdatable(kind);
811
831
  }
812
832
  /**
813
833
  * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
834
+ * @param bypassInstanceData defines a boolean indicating that the function should not take into account the instance data (applies only if the mesh has instances). Default: false
814
835
  * @returns an array of strings
815
836
  */
816
- getVerticesDataKinds() {
837
+ getVerticesDataKinds(bypassInstanceData) {
817
838
  if (!this._geometry) {
818
839
  const result = new Array();
819
840
  if (this._delayInfo) {
@@ -824,9 +845,11 @@ export class Mesh extends AbstractMesh {
824
845
  return result;
825
846
  }
826
847
  const kinds = this._geometry.getVerticesDataKinds();
827
- if (this._userInstancedBuffersStorage) {
848
+ if (!bypassInstanceData && this._userInstancedBuffersStorage) {
828
849
  for (const kind in this._userInstancedBuffersStorage.vertexBuffers) {
829
- kinds.push(kind);
850
+ if (kinds.indexOf(kind) === -1) {
851
+ kinds.push(kind);
852
+ }
830
853
  }
831
854
  }
832
855
  return kinds;
@@ -2285,6 +2308,7 @@ export class Mesh extends AbstractMesh {
2285
2308
  }
2286
2309
  }
2287
2310
  internalDataInfo._source = null;
2311
+ this._instanceDataStorage.visibleInstances = {};
2288
2312
  // Instances
2289
2313
  this._disposeInstanceSpecificData();
2290
2314
  // Thin instances