@babylonjs/core 6.7.0 → 6.8.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 (412) hide show
  1. package/Actions/abstractActionManager.js.map +1 -1
  2. package/Actions/action.js.map +1 -1
  3. package/Animations/animation.js.map +1 -1
  4. package/Animations/animationGroup.d.ts +5 -0
  5. package/Animations/animationGroup.js +12 -0
  6. package/Animations/animationGroup.js.map +1 -1
  7. package/Animations/easing.js.map +1 -1
  8. package/Audio/audioSceneComponent.js.map +1 -1
  9. package/Audio/sound.js.map +1 -1
  10. package/BakedVertexAnimation/bakedVertexAnimationManager.js.map +1 -1
  11. package/Behaviors/Cameras/bouncingBehavior.js.map +1 -1
  12. package/Behaviors/Cameras/framingBehavior.js.map +1 -1
  13. package/Behaviors/Meshes/fadeInOutBehavior.js.map +1 -1
  14. package/Behaviors/Meshes/pointerDragBehavior.js.map +1 -1
  15. package/Bones/bone.js.map +1 -1
  16. package/Bones/boneIKController.js.map +1 -1
  17. package/Bones/boneLookController.js.map +1 -1
  18. package/Buffers/dataBuffer.js.map +1 -1
  19. package/Cameras/Inputs/BaseCameraMouseWheelInput.js.map +1 -1
  20. package/Cameras/Inputs/BaseCameraPointersInput.js.map +1 -1
  21. package/Cameras/Inputs/arcRotateCameraGamepadInput.js.map +1 -1
  22. package/Cameras/Inputs/arcRotateCameraKeyboardMoveInput.js.map +1 -1
  23. package/Cameras/Inputs/arcRotateCameraMouseWheelInput.js.map +1 -1
  24. package/Cameras/Inputs/arcRotateCameraPointersInput.js.map +1 -1
  25. package/Cameras/Inputs/flyCameraKeyboardInput.js.map +1 -1
  26. package/Cameras/Inputs/flyCameraMouseInput.js.map +1 -1
  27. package/Cameras/Inputs/followCameraKeyboardMoveInput.js.map +1 -1
  28. package/Cameras/Inputs/followCameraMouseWheelInput.js.map +1 -1
  29. package/Cameras/Inputs/followCameraPointersInput.js.map +1 -1
  30. package/Cameras/Inputs/freeCameraGamepadInput.js.map +1 -1
  31. package/Cameras/Inputs/freeCameraKeyboardMoveInput.js.map +1 -1
  32. package/Cameras/Inputs/freeCameraMouseInput.js.map +1 -1
  33. package/Cameras/Inputs/freeCameraTouchInput.js.map +1 -1
  34. package/Cameras/VR/vrExperienceHelper.js.map +1 -1
  35. package/Cameras/arcRotateCamera.js.map +1 -1
  36. package/Cameras/camera.js.map +1 -1
  37. package/Cameras/flyCamera.js.map +1 -1
  38. package/Cameras/followCamera.js.map +1 -1
  39. package/Cameras/freeCamera.js.map +1 -1
  40. package/Cameras/targetCamera.js.map +1 -1
  41. package/Collisions/collider.js.map +1 -1
  42. package/Compute/computeEffect.js.map +1 -1
  43. package/Compute/computeShader.js +1 -5
  44. package/Compute/computeShader.js.map +1 -1
  45. package/Culling/Octrees/octree.js.map +1 -1
  46. package/Culling/boundingBox.js.map +1 -1
  47. package/Culling/boundingInfo.js.map +1 -1
  48. package/Culling/boundingSphere.js.map +1 -1
  49. package/Culling/ray.d.ts +7 -2
  50. package/Culling/ray.js +8 -3
  51. package/Culling/ray.js.map +1 -1
  52. package/Debug/debugLayer.js +1 -9
  53. package/Debug/debugLayer.js.map +1 -1
  54. package/Debug/skeletonViewer.js.map +1 -1
  55. package/Engines/Extensions/engine.cubeTexture.js +1 -6
  56. package/Engines/Extensions/engine.cubeTexture.js.map +1 -1
  57. package/Engines/Extensions/engine.multiRender.js.map +1 -1
  58. package/Engines/Extensions/engine.multiview.d.ts +6 -1
  59. package/Engines/Extensions/engine.multiview.js +27 -7
  60. package/Engines/Extensions/engine.multiview.js.map +1 -1
  61. package/Engines/Extensions/engine.renderTarget.js +1 -6
  62. package/Engines/Extensions/engine.renderTarget.js.map +1 -1
  63. package/Engines/Extensions/engine.renderTargetCube.js +1 -9
  64. package/Engines/Extensions/engine.renderTargetCube.js.map +1 -1
  65. package/Engines/Extensions/engine.webVR.js +1 -5
  66. package/Engines/Extensions/engine.webVR.js.map +1 -1
  67. package/Engines/Native/nativeInterfaces.d.ts +1 -0
  68. package/Engines/Native/nativeInterfaces.js.map +1 -1
  69. package/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator.js +3 -0
  70. package/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator.js.map +1 -1
  71. package/Engines/Processors/Expressions/shaderDefineExpression.d.ts +37 -0
  72. package/Engines/Processors/Expressions/shaderDefineExpression.js +57 -0
  73. package/Engines/Processors/Expressions/shaderDefineExpression.js.map +1 -1
  74. package/Engines/Processors/shaderCodeInliner.js.map +1 -1
  75. package/Engines/Processors/shaderProcessor.js +34 -14
  76. package/Engines/Processors/shaderProcessor.js.map +1 -1
  77. package/Engines/WebGL/webGLRenderTargetWrapper.d.ts +19 -0
  78. package/Engines/WebGL/webGLRenderTargetWrapper.js +20 -1
  79. package/Engines/WebGL/webGLRenderTargetWrapper.js.map +1 -1
  80. package/Engines/WebGPU/Extensions/engine.cubeTexture.js +1 -7
  81. package/Engines/WebGPU/Extensions/engine.cubeTexture.js.map +1 -1
  82. package/Engines/WebGPU/Extensions/engine.renderTarget.js +1 -8
  83. package/Engines/WebGPU/Extensions/engine.renderTarget.js.map +1 -1
  84. package/Engines/WebGPU/Extensions/engine.renderTargetCube.js +1 -10
  85. package/Engines/WebGPU/Extensions/engine.renderTargetCube.js.map +1 -1
  86. package/Engines/WebGPU/webgpuCacheBindGroups.js.map +1 -1
  87. package/Engines/WebGPU/webgpuCacheRenderPipeline.js.map +1 -1
  88. package/Engines/WebGPU/webgpuCacheSampler.js +1 -6
  89. package/Engines/WebGPU/webgpuCacheSampler.js.map +1 -1
  90. package/Engines/WebGPU/webgpuShaderProcessor.js.map +1 -1
  91. package/Engines/WebGPU/webgpuTintWASM.js +1 -4
  92. package/Engines/WebGPU/webgpuTintWASM.js.map +1 -1
  93. package/Engines/engine.d.ts +8 -1
  94. package/Engines/engine.js.map +1 -1
  95. package/Engines/engineCapabilities.d.ts +2 -0
  96. package/Engines/engineCapabilities.js.map +1 -1
  97. package/Engines/nativeEngine.d.ts +2 -0
  98. package/Engines/nativeEngine.js +16 -0
  99. package/Engines/nativeEngine.js.map +1 -1
  100. package/Engines/nullEngine.js +1 -9
  101. package/Engines/nullEngine.js.map +1 -1
  102. package/Engines/thinEngine.js +7 -9
  103. package/Engines/thinEngine.js.map +1 -1
  104. package/Engines/webgpuEngine.js +3 -14
  105. package/Engines/webgpuEngine.js.map +1 -1
  106. package/Gamepads/Controllers/gearVRController.js.map +1 -1
  107. package/Gamepads/Controllers/oculusTouchController.js.map +1 -1
  108. package/Gamepads/Controllers/poseEnabledController.js.map +1 -1
  109. package/Gamepads/Controllers/windowsMotionController.js.map +1 -1
  110. package/Gamepads/gamepad.js.map +1 -1
  111. package/Gizmos/cameraGizmo.js.map +1 -1
  112. package/Gizmos/gizmo.js.map +1 -1
  113. package/Gizmos/lightGizmo.js.map +1 -1
  114. package/Gizmos/planeRotationGizmo.js.map +1 -1
  115. package/Helpers/environmentHelper.js +2 -8
  116. package/Helpers/environmentHelper.js.map +1 -1
  117. package/Helpers/textureDome.js.map +1 -1
  118. package/Inputs/scene.inputManager.js +4 -1
  119. package/Inputs/scene.inputManager.js.map +1 -1
  120. package/Layers/effectLayer.js +1 -8
  121. package/Layers/effectLayer.js.map +1 -1
  122. package/Layers/glowLayer.js +1 -12
  123. package/Layers/glowLayer.js.map +1 -1
  124. package/Layers/highlightLayer.js +1 -11
  125. package/Layers/highlightLayer.js.map +1 -1
  126. package/Legacy/legacy.js +1 -1
  127. package/Legacy/legacy.js.map +1 -1
  128. package/LensFlares/lensFlareSystem.js.map +1 -1
  129. package/Lights/Shadows/shadowGenerator.js +1 -4
  130. package/Lights/Shadows/shadowGenerator.js.map +1 -1
  131. package/Lights/directionalLight.js.map +1 -1
  132. package/Lights/hemisphericLight.js.map +1 -1
  133. package/Lights/light.js.map +1 -1
  134. package/Lights/spotLight.js.map +1 -1
  135. package/Loading/loadingScreen.js.map +1 -1
  136. package/Loading/sceneLoader.d.ts +8 -8
  137. package/Loading/sceneLoader.js +35 -19
  138. package/Loading/sceneLoader.js.map +1 -1
  139. package/Materials/Background/backgroundMaterial.js.map +1 -1
  140. package/Materials/Node/Blocks/Dual/currentScreenBlock.d.ts +1 -1
  141. package/Materials/Node/Blocks/Dual/lightBlock.js.map +1 -1
  142. package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.js.map +1 -1
  143. package/Materials/Node/Blocks/Dual/sceneDepthBlock.d.ts +1 -1
  144. package/Materials/Node/Blocks/Dual/sceneDepthBlock.js.map +1 -1
  145. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js.map +1 -1
  146. package/Materials/Node/Blocks/Fragment/heightToNormalBlock.js.map +1 -1
  147. package/Materials/Node/Blocks/Fragment/imageProcessingBlock.js.map +1 -1
  148. package/Materials/Node/Blocks/Fragment/perturbNormalBlock.js.map +1 -1
  149. package/Materials/Node/Blocks/PBR/clearCoatBlock.js.map +1 -1
  150. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js.map +1 -1
  151. package/Materials/Node/Blocks/PBR/reflectionBlock.js.map +1 -1
  152. package/Materials/Node/Blocks/PBR/refractionBlock.js.map +1 -1
  153. package/Materials/Node/Blocks/PBR/sheenBlock.js.map +1 -1
  154. package/Materials/Node/Blocks/addBlock.js +2 -0
  155. package/Materials/Node/Blocks/addBlock.js.map +1 -1
  156. package/Materials/Node/Blocks/clampBlock.js.map +1 -1
  157. package/Materials/Node/Blocks/cloudBlock.js.map +1 -1
  158. package/Materials/Node/Blocks/customBlock.d.ts +1 -0
  159. package/Materials/Node/Blocks/customBlock.js +18 -2
  160. package/Materials/Node/Blocks/customBlock.js.map +1 -1
  161. package/Materials/Node/Blocks/divideBlock.js +2 -0
  162. package/Materials/Node/Blocks/divideBlock.js.map +1 -1
  163. package/Materials/Node/Blocks/meshAttributeExistsBlock.js.map +1 -1
  164. package/Materials/Node/Blocks/multiplyBlock.js +2 -0
  165. package/Materials/Node/Blocks/multiplyBlock.js.map +1 -1
  166. package/Materials/Node/Blocks/remapBlock.js.map +1 -1
  167. package/Materials/Node/Blocks/subtractBlock.js +2 -0
  168. package/Materials/Node/Blocks/subtractBlock.js.map +1 -1
  169. package/Materials/Node/Blocks/triPlanarBlock.js.map +1 -1
  170. package/Materials/Node/Blocks/worleyNoise3DBlock.js.map +1 -1
  171. package/Materials/Node/nodeMaterial.d.ts +6 -1
  172. package/Materials/Node/nodeMaterial.js +6 -10
  173. package/Materials/Node/nodeMaterial.js.map +1 -1
  174. package/Materials/PBR/pbrAnisotropicConfiguration.js.map +1 -1
  175. package/Materials/PBR/pbrBRDFConfiguration.js.map +1 -1
  176. package/Materials/PBR/pbrBaseMaterial.js +1 -5
  177. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  178. package/Materials/PBR/pbrBaseSimpleMaterial.js.map +1 -1
  179. package/Materials/PBR/pbrClearCoatConfiguration.js.map +1 -1
  180. package/Materials/PBR/pbrIridescenceConfiguration.js.map +1 -1
  181. package/Materials/PBR/pbrMaterial.d.ts +2 -1
  182. package/Materials/PBR/pbrMaterial.js +6 -13
  183. package/Materials/PBR/pbrMaterial.js.map +1 -1
  184. package/Materials/PBR/pbrMetallicRoughnessMaterial.js.map +1 -1
  185. package/Materials/PBR/pbrSheenConfiguration.js.map +1 -1
  186. package/Materials/PBR/pbrSpecularGlossinessMaterial.js.map +1 -1
  187. package/Materials/PBR/pbrSubSurfaceConfiguration.js.map +1 -1
  188. package/Materials/Textures/Procedurals/proceduralTexture.js.map +1 -1
  189. package/Materials/Textures/baseTexture.js.map +1 -1
  190. package/Materials/Textures/cubeTexture.js.map +1 -1
  191. package/Materials/Textures/equiRectangularCubeTexture.js.map +1 -1
  192. package/Materials/Textures/hdrCubeTexture.js.map +1 -1
  193. package/Materials/Textures/htmlElementTexture.js +1 -4
  194. package/Materials/Textures/htmlElementTexture.js.map +1 -1
  195. package/Materials/Textures/internalTexture.js.map +1 -1
  196. package/Materials/Textures/renderTargetTexture.js.map +1 -1
  197. package/Materials/Textures/texture.js.map +1 -1
  198. package/Materials/Textures/videoTexture.js +9 -22
  199. package/Materials/Textures/videoTexture.js.map +1 -1
  200. package/Materials/colorCurves.js.map +1 -1
  201. package/Materials/effect.js.map +1 -1
  202. package/Materials/greasedLinePluginMaterial.d.ts +307 -0
  203. package/Materials/greasedLinePluginMaterial.js +553 -0
  204. package/Materials/greasedLinePluginMaterial.js.map +1 -0
  205. package/Materials/imageProcessingConfiguration.js.map +1 -1
  206. package/Materials/index.d.ts +1 -0
  207. package/Materials/index.js +1 -0
  208. package/Materials/index.js.map +1 -1
  209. package/Materials/material.d.ts +3 -0
  210. package/Materials/material.decalMapConfiguration.js.map +1 -1
  211. package/Materials/material.detailMapConfiguration.js.map +1 -1
  212. package/Materials/material.js +40 -5
  213. package/Materials/material.js.map +1 -1
  214. package/Materials/materialPluginBase.d.ts +2 -2
  215. package/Materials/materialPluginBase.js +2 -2
  216. package/Materials/materialPluginBase.js.map +1 -1
  217. package/Materials/materialPluginManager.d.ts +3 -2
  218. package/Materials/materialPluginManager.js +3 -1
  219. package/Materials/materialPluginManager.js.map +1 -1
  220. package/Materials/multiMaterial.js +1 -1
  221. package/Materials/multiMaterial.js.map +1 -1
  222. package/Materials/shaderMaterial.d.ts +23 -4
  223. package/Materials/shaderMaterial.js +41 -21
  224. package/Materials/shaderMaterial.js.map +1 -1
  225. package/Materials/standardMaterial.d.ts +2 -1
  226. package/Materials/standardMaterial.js +4 -1
  227. package/Materials/standardMaterial.js.map +1 -1
  228. package/Materials/uniformBuffer.js.map +1 -1
  229. package/Maths/math.vector.d.ts +2 -1
  230. package/Maths/math.vector.js +3 -2
  231. package/Maths/math.vector.js.map +1 -1
  232. package/Meshes/Builders/decalBuilder.js +4 -4
  233. package/Meshes/Builders/decalBuilder.js.map +1 -1
  234. package/Meshes/Builders/greasedLineBuilder.d.ts +105 -0
  235. package/Meshes/Builders/greasedLineBuilder.js +330 -0
  236. package/Meshes/Builders/greasedLineBuilder.js.map +1 -0
  237. package/Meshes/Builders/index.d.ts +1 -0
  238. package/Meshes/Builders/index.js +1 -0
  239. package/Meshes/Builders/index.js.map +1 -1
  240. package/Meshes/abstractMesh.d.ts +3 -2
  241. package/Meshes/abstractMesh.js +5 -3
  242. package/Meshes/abstractMesh.js.map +1 -1
  243. package/Meshes/greasedLineMesh.d.ts +189 -0
  244. package/Meshes/greasedLineMesh.js +437 -0
  245. package/Meshes/greasedLineMesh.js.map +1 -0
  246. package/Meshes/index.d.ts +1 -0
  247. package/Meshes/index.js +1 -0
  248. package/Meshes/index.js.map +1 -1
  249. package/Meshes/mesh.d.ts +4 -0
  250. package/Meshes/mesh.js +20 -10
  251. package/Meshes/mesh.js.map +1 -1
  252. package/Meshes/mesh.vertexData.js.map +1 -1
  253. package/Meshes/meshUVSpaceRenderer.js +1 -8
  254. package/Meshes/meshUVSpaceRenderer.js.map +1 -1
  255. package/Meshes/transformNode.js.map +1 -1
  256. package/Misc/basis.js.map +1 -1
  257. package/Misc/deepCopier.js +8 -2
  258. package/Misc/deepCopier.js.map +1 -1
  259. package/Misc/dumpTools.d.ts +4 -3
  260. package/Misc/dumpTools.js +5 -4
  261. package/Misc/dumpTools.js.map +1 -1
  262. package/Misc/environmentTextureTools.js +1 -1
  263. package/Misc/environmentTextureTools.js.map +1 -1
  264. package/Misc/fileTools.js +10 -10
  265. package/Misc/fileTools.js.map +1 -1
  266. package/Misc/greasedLineTools.d.ts +141 -0
  267. package/Misc/greasedLineTools.js +263 -0
  268. package/Misc/greasedLineTools.js.map +1 -0
  269. package/Misc/index.d.ts +1 -0
  270. package/Misc/index.js +1 -0
  271. package/Misc/index.js.map +1 -1
  272. package/Misc/khronosTextureContainer.js.map +1 -1
  273. package/Misc/observable.d.ts +11 -0
  274. package/Misc/observable.js +26 -1
  275. package/Misc/observable.js.map +1 -1
  276. package/Misc/sceneOptimizer.js.map +1 -1
  277. package/Misc/screenshotTools.d.ts +15 -5
  278. package/Misc/screenshotTools.js +23 -13
  279. package/Misc/screenshotTools.js.map +1 -1
  280. package/Misc/smartArray.js.map +1 -1
  281. package/Misc/tools.d.ts +21 -9
  282. package/Misc/tools.js +21 -9
  283. package/Misc/tools.js.map +1 -1
  284. package/Misc/videoRecorder.js +1 -4
  285. package/Misc/videoRecorder.js.map +1 -1
  286. package/Misc/virtualJoystick.js +1 -4
  287. package/Misc/virtualJoystick.js.map +1 -1
  288. package/Misc/webRequest.js.map +1 -1
  289. package/Morph/morphTarget.js.map +1 -1
  290. package/Morph/morphTargetManager.js.map +1 -1
  291. package/Offline/database.js.map +1 -1
  292. package/Particles/baseParticleSystem.js.map +1 -1
  293. package/Particles/gpuParticleSystem.d.ts +1 -0
  294. package/Particles/gpuParticleSystem.js +5 -8
  295. package/Particles/gpuParticleSystem.js.map +1 -1
  296. package/Particles/particle.js.map +1 -1
  297. package/Particles/particleSystem.js +1 -1
  298. package/Particles/particleSystem.js.map +1 -1
  299. package/Particles/particleSystemSet.js.map +1 -1
  300. package/Physics/physicsHelper.js +4 -4
  301. package/Physics/physicsHelper.js.map +1 -1
  302. package/Physics/physicsRaycastResult.d.ts +3 -1
  303. package/Physics/physicsRaycastResult.js +10 -1
  304. package/Physics/physicsRaycastResult.js.map +1 -1
  305. package/Physics/v1/Plugins/ammoJSPlugin.js.map +1 -1
  306. package/Physics/v1/physicsImpostor.js.map +1 -1
  307. package/Physics/v2/IPhysicsEnginePlugin.d.ts +10 -0
  308. package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -1
  309. package/Physics/v2/Plugins/havokPlugin.d.ts +3 -2
  310. package/Physics/v2/Plugins/havokPlugin.js +9 -6
  311. package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
  312. package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.js.map +1 -1
  313. package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js.map +1 -1
  314. package/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.js.map +1 -1
  315. package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.js.map +1 -1
  316. package/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.js.map +1 -1
  317. package/PostProcesses/RenderPipeline/postProcessRenderPipeline.js.map +1 -1
  318. package/PostProcesses/blackAndWhitePostProcess.js.map +1 -1
  319. package/PostProcesses/bloomMergePostProcess.js.map +1 -1
  320. package/PostProcesses/blurPostProcess.js.map +1 -1
  321. package/PostProcesses/circleOfConfusionPostProcess.js.map +1 -1
  322. package/PostProcesses/colorCorrectionPostProcess.js.map +1 -1
  323. package/PostProcesses/convolutionPostProcess.js.map +1 -1
  324. package/PostProcesses/depthOfFieldBlurPostProcess.js.map +1 -1
  325. package/PostProcesses/extractHighlightsPostProcess.js.map +1 -1
  326. package/PostProcesses/filterPostProcess.js.map +1 -1
  327. package/PostProcesses/grainPostProcess.js.map +1 -1
  328. package/PostProcesses/imageProcessingPostProcess.js.map +1 -1
  329. package/PostProcesses/motionBlurPostProcess.js.map +1 -1
  330. package/PostProcesses/postProcess.js.map +1 -1
  331. package/PostProcesses/refractionPostProcess.js.map +1 -1
  332. package/PostProcesses/screenSpaceCurvaturePostProcess.js.map +1 -1
  333. package/PostProcesses/screenSpaceReflectionPostProcess.js.map +1 -1
  334. package/PostProcesses/sharpenPostProcess.js.map +1 -1
  335. package/PostProcesses/volumetricLightScatteringPostProcess.js.map +1 -1
  336. package/Probes/reflectionProbe.js.map +1 -1
  337. package/Rendering/boundingBoxRenderer.js +2 -4
  338. package/Rendering/boundingBoxRenderer.js.map +1 -1
  339. package/Rendering/depthPeelingRenderer.js.map +1 -1
  340. package/Rendering/depthRenderer.js.map +1 -1
  341. package/Rendering/geometryBufferRenderer.js.map +1 -1
  342. package/Rendering/outlineRenderer.js.map +1 -1
  343. package/Rendering/prePassRenderer.js.map +1 -1
  344. package/Rendering/renderingGroup.js.map +1 -1
  345. package/Rendering/renderingManager.js.map +1 -1
  346. package/Rendering/subSurfaceConfiguration.js.map +1 -1
  347. package/Rendering/utilityLayerRenderer.js.map +1 -1
  348. package/Shaders/ShadersInclude/pbrBlockAlbedoOpacity.js +4 -2
  349. package/Shaders/ShadersInclude/pbrBlockAlbedoOpacity.js.map +1 -1
  350. package/Shaders/ShadersInclude/pbrDebug.js +11 -2
  351. package/Shaders/ShadersInclude/pbrDebug.js.map +1 -1
  352. package/Shaders/velocity.fragment.d.ts +5 -0
  353. package/Shaders/velocity.fragment.js +13 -0
  354. package/Shaders/velocity.fragment.js.map +1 -0
  355. package/Shaders/velocity.vertex.d.ts +7 -0
  356. package/Shaders/velocity.vertex.js +23 -0
  357. package/Shaders/velocity.vertex.js.map +1 -0
  358. package/Sprites/spriteManager.js.map +1 -1
  359. package/XR/features/WebXRAnchorSystem.js.map +1 -1
  360. package/XR/features/WebXRBackgroundRemover.js.map +1 -1
  361. package/XR/features/WebXRControllerMovement.js.map +1 -1
  362. package/XR/features/WebXRControllerPhysics.js +4 -13
  363. package/XR/features/WebXRControllerPhysics.js.map +1 -1
  364. package/XR/features/WebXRControllerPointerSelection.js.map +1 -1
  365. package/XR/features/WebXRControllerTeleportation.js.map +1 -1
  366. package/XR/features/WebXRDOMOverlay.js.map +1 -1
  367. package/XR/features/WebXRDepthSensing.js.map +1 -1
  368. package/XR/features/WebXREyeTracking.js.map +1 -1
  369. package/XR/features/WebXRFeaturePointSystem.js.map +1 -1
  370. package/XR/features/WebXRHandTracking.js +2 -8
  371. package/XR/features/WebXRHandTracking.js.map +1 -1
  372. package/XR/features/WebXRHitTest.js.map +1 -1
  373. package/XR/features/WebXRHitTestLegacy.js.map +1 -1
  374. package/XR/features/WebXRImageTracking.js.map +1 -1
  375. package/XR/features/WebXRLayers.js +18 -8
  376. package/XR/features/WebXRLayers.js.map +1 -1
  377. package/XR/features/WebXRLightEstimation.js.map +1 -1
  378. package/XR/features/WebXRMeshDetector.js.map +1 -1
  379. package/XR/features/WebXRNearInteraction.js.map +1 -1
  380. package/XR/features/WebXRPlaneDetector.js.map +1 -1
  381. package/XR/features/WebXRSpaceWarp.d.ts +138 -0
  382. package/XR/features/WebXRSpaceWarp.js +290 -0
  383. package/XR/features/WebXRSpaceWarp.js.map +1 -0
  384. package/XR/features/index.d.ts +1 -0
  385. package/XR/features/index.js +1 -0
  386. package/XR/features/index.js.map +1 -1
  387. package/XR/motionController/webXRAbstractMotionController.js +1 -4
  388. package/XR/motionController/webXRAbstractMotionController.js.map +1 -1
  389. package/XR/motionController/webXRControllerComponent.js.map +1 -1
  390. package/XR/motionController/webXRGenericMotionController.js.map +1 -1
  391. package/XR/motionController/webXRHTCViveMotionController.js.map +1 -1
  392. package/XR/motionController/webXRMicrosoftMixedRealityController.js.map +1 -1
  393. package/XR/motionController/webXROculusTouchMotionController.js.map +1 -1
  394. package/XR/webXRCamera.js.map +1 -1
  395. package/XR/webXRDefaultExperience.js +6 -28
  396. package/XR/webXRDefaultExperience.js.map +1 -1
  397. package/XR/webXRFeaturesManager.d.ts +4 -0
  398. package/XR/webXRFeaturesManager.js +5 -4
  399. package/XR/webXRFeaturesManager.js.map +1 -1
  400. package/XR/webXRInput.js +1 -6
  401. package/XR/webXRInput.js.map +1 -1
  402. package/XR/webXRSessionManager.d.ts +4 -0
  403. package/XR/webXRSessionManager.js +6 -0
  404. package/XR/webXRSessionManager.js.map +1 -1
  405. package/abstractScene.js.map +1 -1
  406. package/assetContainer.js +1 -4
  407. package/assetContainer.js.map +1 -1
  408. package/node.js.map +1 -1
  409. package/package.json +2 -4
  410. package/scene.d.ts +5 -2
  411. package/scene.js +9 -12
  412. package/scene.js.map +1 -1
@@ -0,0 +1,141 @@
1
+ import { Vector3 } from "../Maths/math.vector";
2
+ import type { AbstractMesh } from "../Meshes/abstractMesh";
3
+ /**
4
+ * Tool functions for GreasedLine
5
+ */
6
+ export declare class GreasedLineTools {
7
+ /**
8
+ * Gets mesh triangles as line positions
9
+ * @param meshes array of meshes
10
+ * @param omitZeroLengthLines do not generate a line when the distance if the vertices in the triangle equals to zero
11
+ * @returns array of arrays of points
12
+ */
13
+ static MeshesToLines(meshes: AbstractMesh[], omitZeroLengthLines?: boolean): Vector3[][];
14
+ /**
15
+ * Converts number coordinates to Vector3s
16
+ * @param points number array of x, y, z, x, y z, ... coordinates
17
+ * @returns Vector3 array
18
+ */
19
+ static ToVector3Array(points: number[]): Vector3[];
20
+ /**
21
+ * Gets a number array from a Vector3 array.
22
+ * You can you for example to convert your Vector3[] offsets to the required number[] for the offsets option.
23
+ * @param points Vector3 array
24
+ * @returns an array of x, y, z coordinates as numbers [x, y, z, x, y, z, x, y, z, ....]
25
+ */
26
+ static ToNumberArray(points: Vector3[]): number[];
27
+ /**
28
+ * Calculates the sum of points of every line and the number of points in each line.
29
+ * This function is useful when you are drawing multiple lines in one mesh and you want
30
+ * to know the counts. For example for creating an offsets table.
31
+ * @param points point array
32
+ * @returns points count info
33
+ */
34
+ static GetPointsCountInfo(points: number[][]): {
35
+ total: number;
36
+ counts: number[];
37
+ };
38
+ /**
39
+ * Gets the length of the line counting all it's segments length
40
+ * @param data array of line points
41
+ * @returns length of the line
42
+ */
43
+ static GetLineLength(data: Vector3[] | number[]): number;
44
+ /**
45
+ * Divides a segment into smaller segments.
46
+ * A segment is a part of the line between it's two points.
47
+ * @param point1 first point of the line
48
+ * @param point2 second point of the line
49
+ * @param segmentCount number of segments we want to have in the divided line
50
+ * @returns
51
+ */
52
+ static SegmentizeSegmentByCount(point1: Vector3, point2: Vector3, segmentCount: number): Vector3[];
53
+ /**
54
+ * Divides a line into segments.
55
+ * A segment is a part of the line between it's two points.
56
+ * @param what line points
57
+ * @param segmentLength length of each segment of the resulting line (distance between two line points)
58
+ * @returns line point
59
+ */
60
+ static SegmentizeLineBySegmentLength(what: Vector3[] | number[] | {
61
+ point1: Vector3;
62
+ point2: Vector3;
63
+ length: number;
64
+ }[], segmentLength: number): Vector3[];
65
+ /**
66
+ * Divides a line into segments.
67
+ * A segment is a part of the line between it's two points.
68
+ * @param what line points
69
+ * @param segmentCount number of segments
70
+ * @returns line point
71
+ */
72
+ static SegmentizeLineBySegmentCount(what: Vector3[], segmentCount: number): Vector3[];
73
+ /**
74
+ * Gets line segments.
75
+ * A segment is a part of the line between it's two points.
76
+ * @param points line points
77
+ * @returns segments information of the line segment including starting point, ending point and the distance between them
78
+ */
79
+ static GetLineSegments(points: Vector3[]): {
80
+ point1: Vector3;
81
+ point2: Vector3;
82
+ length: number;
83
+ }[];
84
+ /**
85
+ * Gets the minimum and the maximum length of a line segment in the line.
86
+ * A segment is a part of the line between it's two points.
87
+ * @param points line points
88
+ * @returns
89
+ */
90
+ static GetMinMaxSegmentLength(points: Vector3[]): {
91
+ min: number;
92
+ max: number;
93
+ };
94
+ /**
95
+ * Finds the last visible position in world space of the line according to the visibility parameter
96
+ * @param lineSegments segments of the line
97
+ * @param lineLength total length of the line
98
+ * @param visbility normalized value of visibility
99
+ * @returns world space coordinate of the last visible piece of the line
100
+ */
101
+ static GetPositionOnLineByVisibility(lineSegments: {
102
+ point1: Vector3;
103
+ point2: Vector3;
104
+ length: number;
105
+ }[], lineLength: number, visbility: number, localSpace?: boolean): Vector3;
106
+ /**
107
+ * Creates lines in a shape of circle/arc.
108
+ * A segment is a part of the line between it's two points.
109
+ * @param radiusX radiusX of the circle
110
+ * @param segments number of segments in the circle
111
+ * @param z z coordinate of the points. Defaults to 0.
112
+ * @param radiusY radiusY of the circle - you can draw an oval if using different values
113
+ * @param segmentAngle angle offset of the segments. Defaults to Math.PI * 2 / segments. Change this value to draw a part of the circle.
114
+ * @returns line points
115
+ */
116
+ static GetCircleLinePoints(radiusX: number, segments: number, z?: number, radiusY?: number, segmentAngle?: number): Vector3[];
117
+ /**
118
+ * Gets line points in a shape of a bezier curve
119
+ * @param p0 bezier point0
120
+ * @param p1 bezier point1
121
+ * @param p2 bezier point2
122
+ * @param segments number of segments in the curve
123
+ * @returns
124
+ */
125
+ static GetBezierLinePoints(p0: Vector3, p1: Vector3, p2: Vector3, segments: number): number[];
126
+ /**
127
+ *
128
+ * @param position position of the arrow cap (mainly you want to create a triangle, set widthUp and widthDown to the same value and omit widthStartUp and widthStartDown)
129
+ * @param direction direction which the arrow points to
130
+ * @param length length (size) of the arrow cap itself
131
+ * @param widthUp the arrow width above the line
132
+ * @param widthDown the arrow width belove the line
133
+ * @param widthStartUp the arrow width at the start of the arrow above the line. In most scenarios this is 0.
134
+ * @param widthStartDown the arrow width at the start of the arrow below the line. In most scenarios this is 0.
135
+ * @returns
136
+ */
137
+ static GetArrowCap(position: Vector3, direction: Vector3, length: number, widthUp: number, widthDown: number, widthStartUp?: number, widthStartDown?: number): {
138
+ points: Vector3[];
139
+ widths: number[];
140
+ };
141
+ }
@@ -0,0 +1,263 @@
1
+ import { Curve3 } from "../Maths/math.path.js";
2
+ import { VertexBuffer } from "../Buffers/buffer.js";
3
+ import { TmpVectors, Vector3 } from "../Maths/math.vector.js";
4
+ /**
5
+ * Tool functions for GreasedLine
6
+ */
7
+ export class GreasedLineTools {
8
+ /**
9
+ * Gets mesh triangles as line positions
10
+ * @param meshes array of meshes
11
+ * @param omitZeroLengthLines do not generate a line when the distance if the vertices in the triangle equals to zero
12
+ * @returns array of arrays of points
13
+ */
14
+ static MeshesToLines(meshes, omitZeroLengthLines = true) {
15
+ const points = [];
16
+ meshes.forEach((m) => {
17
+ const vertices = m.getVerticesData(VertexBuffer.PositionKind);
18
+ const indices = m.getIndices();
19
+ if (vertices && indices) {
20
+ for (let i = 0, ii = 0; i < indices.length; i++) {
21
+ const vi1 = indices[ii++] * 3;
22
+ const vi2 = indices[ii++] * 3;
23
+ const vi3 = indices[ii++] * 3;
24
+ const p1 = new Vector3(vertices[vi1], vertices[vi1 + 1], vertices[vi1 + 2]);
25
+ const p2 = new Vector3(vertices[vi2], vertices[vi2 + 1], vertices[vi2 + 2]);
26
+ const p3 = new Vector3(vertices[vi3], vertices[vi3 + 1], vertices[vi3 + 2]);
27
+ if (omitZeroLengthLines && p1.lengthSquared() + p2.lengthSquared() + p3.lengthSquared() === 0) {
28
+ continue;
29
+ }
30
+ points.push([p1, p2, p3, p1]);
31
+ }
32
+ }
33
+ });
34
+ return points;
35
+ }
36
+ /**
37
+ * Converts number coordinates to Vector3s
38
+ * @param points number array of x, y, z, x, y z, ... coordinates
39
+ * @returns Vector3 array
40
+ */
41
+ static ToVector3Array(points) {
42
+ const array = [];
43
+ for (let i = 0; i < points.length; i += 3) {
44
+ array.push(new Vector3(points[i], points[i + 1], points[i + 2]));
45
+ }
46
+ return array;
47
+ }
48
+ /**
49
+ * Gets a number array from a Vector3 array.
50
+ * You can you for example to convert your Vector3[] offsets to the required number[] for the offsets option.
51
+ * @param points Vector3 array
52
+ * @returns an array of x, y, z coordinates as numbers [x, y, z, x, y, z, x, y, z, ....]
53
+ */
54
+ static ToNumberArray(points) {
55
+ return points.flatMap((v) => [v.x, v.y, v.z]);
56
+ }
57
+ /**
58
+ * Calculates the sum of points of every line and the number of points in each line.
59
+ * This function is useful when you are drawing multiple lines in one mesh and you want
60
+ * to know the counts. For example for creating an offsets table.
61
+ * @param points point array
62
+ * @returns points count info
63
+ */
64
+ static GetPointsCountInfo(points) {
65
+ const counts = new Array(points.length);
66
+ let total = 0;
67
+ for (let n = points.length; n--;) {
68
+ counts[n] = points[n].length / 3;
69
+ total += counts[n];
70
+ }
71
+ return { total, counts };
72
+ }
73
+ /**
74
+ * Gets the length of the line counting all it's segments length
75
+ * @param data array of line points
76
+ * @returns length of the line
77
+ */
78
+ static GetLineLength(data) {
79
+ if (data.length === 0) {
80
+ return 0;
81
+ }
82
+ let points;
83
+ if (typeof data[0] === "number") {
84
+ points = GreasedLineTools.ToVector3Array(data);
85
+ }
86
+ else {
87
+ points = data;
88
+ }
89
+ const tmp = TmpVectors.Vector3[0];
90
+ let length = 0;
91
+ for (let index = 0; index < points.length - 1; index++) {
92
+ const point1 = points[index];
93
+ const point2 = points[index + 1];
94
+ length += point2.subtractToRef(point1, tmp).length();
95
+ }
96
+ return length;
97
+ }
98
+ /**
99
+ * Divides a segment into smaller segments.
100
+ * A segment is a part of the line between it's two points.
101
+ * @param point1 first point of the line
102
+ * @param point2 second point of the line
103
+ * @param segmentCount number of segments we want to have in the divided line
104
+ * @returns
105
+ */
106
+ static SegmentizeSegmentByCount(point1, point2, segmentCount) {
107
+ const dividedLinePoints = [];
108
+ const diff = point2.subtract(point1);
109
+ const divisor = TmpVectors.Vector3[0];
110
+ divisor.setAll(segmentCount);
111
+ const segmentVector = TmpVectors.Vector3[1];
112
+ diff.divideToRef(divisor, segmentVector);
113
+ let nextPoint = point1.clone();
114
+ dividedLinePoints.push(nextPoint);
115
+ for (let index = 0; index < segmentCount; index++) {
116
+ nextPoint = nextPoint.clone();
117
+ dividedLinePoints.push(nextPoint.addInPlace(segmentVector));
118
+ }
119
+ return dividedLinePoints;
120
+ }
121
+ /**
122
+ * Divides a line into segments.
123
+ * A segment is a part of the line between it's two points.
124
+ * @param what line points
125
+ * @param segmentLength length of each segment of the resulting line (distance between two line points)
126
+ * @returns line point
127
+ */
128
+ static SegmentizeLineBySegmentLength(what, segmentLength) {
129
+ const subLines = what[0] instanceof Vector3 ? GreasedLineTools.GetLineSegments(what) : what;
130
+ const points = [];
131
+ subLines.forEach((s) => {
132
+ if (s.length > segmentLength) {
133
+ const segments = GreasedLineTools.SegmentizeSegmentByCount(s.point1, s.point2, Math.ceil(s.length / segmentLength));
134
+ segments.forEach((seg) => {
135
+ points.push(seg);
136
+ });
137
+ }
138
+ else {
139
+ points.push(s.point1);
140
+ points.push(s.point2);
141
+ }
142
+ });
143
+ return points;
144
+ }
145
+ /**
146
+ * Divides a line into segments.
147
+ * A segment is a part of the line between it's two points.
148
+ * @param what line points
149
+ * @param segmentCount number of segments
150
+ * @returns line point
151
+ */
152
+ static SegmentizeLineBySegmentCount(what, segmentCount) {
153
+ const segmentLength = GreasedLineTools.GetLineLength(what) / segmentCount;
154
+ return GreasedLineTools.SegmentizeLineBySegmentLength(what, segmentLength);
155
+ }
156
+ /**
157
+ * Gets line segments.
158
+ * A segment is a part of the line between it's two points.
159
+ * @param points line points
160
+ * @returns segments information of the line segment including starting point, ending point and the distance between them
161
+ */
162
+ static GetLineSegments(points) {
163
+ const segments = [];
164
+ for (let index = 0; index < points.length - 1; index++) {
165
+ const point1 = points[index];
166
+ const point2 = points[index + 1];
167
+ const length = point2.subtract(point1).length();
168
+ segments.push({ point1, point2, length });
169
+ }
170
+ return segments;
171
+ }
172
+ /**
173
+ * Gets the minimum and the maximum length of a line segment in the line.
174
+ * A segment is a part of the line between it's two points.
175
+ * @param points line points
176
+ * @returns
177
+ */
178
+ static GetMinMaxSegmentLength(points) {
179
+ const subLines = GreasedLineTools.GetLineSegments(points);
180
+ const sorted = subLines.sort((s) => s.length);
181
+ return {
182
+ min: sorted[0].length,
183
+ max: sorted[sorted.length - 1].length,
184
+ };
185
+ }
186
+ /**
187
+ * Finds the last visible position in world space of the line according to the visibility parameter
188
+ * @param lineSegments segments of the line
189
+ * @param lineLength total length of the line
190
+ * @param visbility normalized value of visibility
191
+ * @returns world space coordinate of the last visible piece of the line
192
+ */
193
+ static GetPositionOnLineByVisibility(lineSegments, lineLength, visbility, localSpace = false) {
194
+ const lengthVisibilityRatio = lineLength * visbility;
195
+ let sumSegmentLengths = 0;
196
+ let segmentIndex = 0;
197
+ const lineSegmentsLength = lineSegments.length;
198
+ for (let i = 0; i < lineSegmentsLength; i++) {
199
+ if (lengthVisibilityRatio <= sumSegmentLengths + lineSegments[i].length) {
200
+ segmentIndex = i;
201
+ break;
202
+ }
203
+ sumSegmentLengths += lineSegments[i].length;
204
+ }
205
+ const s = (lengthVisibilityRatio - sumSegmentLengths) / lineSegments[segmentIndex].length;
206
+ lineSegments[segmentIndex].point2.subtractToRef(lineSegments[segmentIndex].point1, TmpVectors.Vector3[0]);
207
+ TmpVectors.Vector3[1] = TmpVectors.Vector3[0].multiplyByFloats(s, s, s);
208
+ if (!localSpace) {
209
+ TmpVectors.Vector3[1].addInPlace(lineSegments[segmentIndex].point1);
210
+ }
211
+ return TmpVectors.Vector3[1].clone();
212
+ }
213
+ /**
214
+ * Creates lines in a shape of circle/arc.
215
+ * A segment is a part of the line between it's two points.
216
+ * @param radiusX radiusX of the circle
217
+ * @param segments number of segments in the circle
218
+ * @param z z coordinate of the points. Defaults to 0.
219
+ * @param radiusY radiusY of the circle - you can draw an oval if using different values
220
+ * @param segmentAngle angle offset of the segments. Defaults to Math.PI * 2 / segments. Change this value to draw a part of the circle.
221
+ * @returns line points
222
+ */
223
+ static GetCircleLinePoints(radiusX, segments, z = 0, radiusY = radiusX, segmentAngle = (Math.PI * 2) / segments) {
224
+ const points = [];
225
+ for (let i = 0; i <= segments; i++) {
226
+ points.push(new Vector3(Math.cos(i * segmentAngle) * radiusX, Math.sin(i * segmentAngle) * radiusY, z));
227
+ }
228
+ return points;
229
+ }
230
+ /**
231
+ * Gets line points in a shape of a bezier curve
232
+ * @param p0 bezier point0
233
+ * @param p1 bezier point1
234
+ * @param p2 bezier point2
235
+ * @param segments number of segments in the curve
236
+ * @returns
237
+ */
238
+ static GetBezierLinePoints(p0, p1, p2, segments) {
239
+ return Curve3.CreateQuadraticBezier(p0, p1, p2, segments)
240
+ .getPoints()
241
+ .flatMap((v) => [v.x, v.y, v.z]);
242
+ }
243
+ /**
244
+ *
245
+ * @param position position of the arrow cap (mainly you want to create a triangle, set widthUp and widthDown to the same value and omit widthStartUp and widthStartDown)
246
+ * @param direction direction which the arrow points to
247
+ * @param length length (size) of the arrow cap itself
248
+ * @param widthUp the arrow width above the line
249
+ * @param widthDown the arrow width belove the line
250
+ * @param widthStartUp the arrow width at the start of the arrow above the line. In most scenarios this is 0.
251
+ * @param widthStartDown the arrow width at the start of the arrow below the line. In most scenarios this is 0.
252
+ * @returns
253
+ */
254
+ static GetArrowCap(position, direction, length, widthUp, widthDown, widthStartUp = 0, widthStartDown = 0) {
255
+ const points = [position.clone(), position.add(direction.multiplyByFloats(length, length, length))];
256
+ const widths = [widthUp, widthDown, widthStartUp, widthStartDown];
257
+ return {
258
+ points,
259
+ widths,
260
+ };
261
+ }
262
+ }
263
+ //# sourceMappingURL=greasedLineTools.js.map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zC,CAAC;IAED;;;;;;;;;;OAUG;IACI,MAAM,CAAC,WAAW,CAAC,QAAiB,EAAE,SAAkB,EAAE,MAAc,EAAE,OAAe,EAAE,SAAiB,EAAE,YAAY,GAAG,CAAC,EAAE,cAAc,GAAG,CAAC;QACrJ,MAAM,MAAM,GAAG,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;QACpG,MAAM,MAAM,GAAG,CAAC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,cAAc,CAAC,CAAC;QAElE,OAAO;YACH,MAAM;YACN,MAAM;SACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import { Curve3 } from \"../Maths/math.path\";\r\nimport { VertexBuffer } from \"../Buffers/buffer\";\r\nimport { TmpVectors, Vector3 } from \"../Maths/math.vector\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\n\r\n/**\r\n * Tool functions for GreasedLine\r\n */\r\nexport class GreasedLineTools {\r\n /**\r\n * Gets mesh triangles as line positions\r\n * @param meshes array of meshes\r\n * @param omitZeroLengthLines do not generate a line when the distance if the vertices in the triangle equals to zero\r\n * @returns array of arrays of points\r\n */\r\n public static MeshesToLines(meshes: AbstractMesh[], omitZeroLengthLines = true) {\r\n const points: Vector3[][] = [];\r\n\r\n meshes.forEach((m) => {\r\n const vertices = m.getVerticesData(VertexBuffer.PositionKind);\r\n const indices = m.getIndices();\r\n if (vertices && indices) {\r\n for (let i = 0, ii = 0; i < indices.length; i++) {\r\n const vi1 = indices[ii++] * 3;\r\n const vi2 = indices[ii++] * 3;\r\n const vi3 = indices[ii++] * 3;\r\n\r\n const p1 = new Vector3(vertices[vi1], vertices[vi1 + 1], vertices[vi1 + 2]);\r\n const p2 = new Vector3(vertices[vi2], vertices[vi2 + 1], vertices[vi2 + 2]);\r\n const p3 = new Vector3(vertices[vi3], vertices[vi3 + 1], vertices[vi3 + 2]);\r\n\r\n if (omitZeroLengthLines && p1.lengthSquared() + p2.lengthSquared() + p3.lengthSquared() === 0) {\r\n continue;\r\n }\r\n points.push([p1, p2, p3, p1]);\r\n }\r\n }\r\n });\r\n\r\n return points;\r\n }\r\n\r\n /**\r\n * Converts number coordinates to Vector3s\r\n * @param points number array of x, y, z, x, y z, ... coordinates\r\n * @returns Vector3 array\r\n */\r\n public static ToVector3Array(points: number[]) {\r\n const array: Vector3[] = [];\r\n for (let i = 0; i < points.length; i += 3) {\r\n array.push(new Vector3(points[i], points[i + 1], points[i + 2]));\r\n }\r\n return array;\r\n }\r\n\r\n /**\r\n * Gets a number array from a Vector3 array.\r\n * You can you for example to convert your Vector3[] offsets to the required number[] for the offsets option.\r\n * @param points Vector3 array\r\n * @returns an array of x, y, z coordinates as numbers [x, y, z, x, y, z, x, y, z, ....]\r\n */\r\n public static ToNumberArray(points: Vector3[]) {\r\n return points.flatMap((v) => [v.x, v.y, v.z]);\r\n }\r\n\r\n /**\r\n * Calculates the sum of points of every line and the number of points in each line.\r\n * This function is useful when you are drawing multiple lines in one mesh and you want\r\n * to know the counts. For example for creating an offsets table.\r\n * @param points point array\r\n * @returns points count info\r\n */\r\n public static GetPointsCountInfo(points: number[][]): { total: number; counts: number[] } {\r\n const counts = new Array(points.length);\r\n let total = 0;\r\n for (let n = points.length; n--; ) {\r\n counts[n] = points[n].length / 3;\r\n total += counts[n];\r\n }\r\n return { total, counts };\r\n }\r\n\r\n /**\r\n * Gets the length of the line counting all it's segments length\r\n * @param data array of line points\r\n * @returns length of the line\r\n */\r\n public static GetLineLength(data: Vector3[] | number[]): number {\r\n if (data.length === 0) {\r\n return 0;\r\n }\r\n\r\n let points: Vector3[];\r\n if (typeof data[0] === \"number\") {\r\n points = GreasedLineTools.ToVector3Array(<number[]>data);\r\n } else {\r\n points = <Vector3[]>data;\r\n }\r\n\r\n const tmp = TmpVectors.Vector3[0];\r\n let length = 0;\r\n for (let index = 0; index < points.length - 1; index++) {\r\n const point1 = points[index];\r\n const point2 = points[index + 1];\r\n length += point2.subtractToRef(point1, tmp).length();\r\n }\r\n return length;\r\n }\r\n\r\n /**\r\n * Divides a segment into smaller segments.\r\n * A segment is a part of the line between it's two points.\r\n * @param point1 first point of the line\r\n * @param point2 second point of the line\r\n * @param segmentCount number of segments we want to have in the divided line\r\n * @returns\r\n */\r\n public static SegmentizeSegmentByCount(point1: Vector3, point2: Vector3, segmentCount: number): Vector3[] {\r\n const dividedLinePoints: Vector3[] = [];\r\n const diff = point2.subtract(point1);\r\n const divisor = TmpVectors.Vector3[0];\r\n divisor.setAll(segmentCount);\r\n const segmentVector = TmpVectors.Vector3[1];\r\n diff.divideToRef(divisor, segmentVector);\r\n\r\n let nextPoint = point1.clone();\r\n dividedLinePoints.push(nextPoint);\r\n for (let index = 0; index < segmentCount; index++) {\r\n nextPoint = nextPoint.clone();\r\n dividedLinePoints.push(nextPoint.addInPlace(segmentVector));\r\n }\r\n\r\n return dividedLinePoints;\r\n }\r\n\r\n /**\r\n * Divides a line into segments.\r\n * A segment is a part of the line between it's two points.\r\n * @param what line points\r\n * @param segmentLength length of each segment of the resulting line (distance between two line points)\r\n * @returns line point\r\n */\r\n public static SegmentizeLineBySegmentLength(what: Vector3[] | number[] | { point1: Vector3; point2: Vector3; length: number }[], segmentLength: number): Vector3[] {\r\n const subLines = what[0] instanceof Vector3 ? GreasedLineTools.GetLineSegments(what as Vector3[]) : (what as { point1: Vector3; point2: Vector3; length: number }[]);\r\n const points: Vector3[] = [];\r\n subLines.forEach((s) => {\r\n if (s.length > segmentLength) {\r\n const segments = GreasedLineTools.SegmentizeSegmentByCount(s.point1, s.point2, Math.ceil(s.length / segmentLength));\r\n segments.forEach((seg) => {\r\n points.push(seg);\r\n });\r\n } else {\r\n points.push(s.point1);\r\n points.push(s.point2);\r\n }\r\n });\r\n return points;\r\n }\r\n\r\n /**\r\n * Divides a line into segments.\r\n * A segment is a part of the line between it's two points.\r\n * @param what line points\r\n * @param segmentCount number of segments\r\n * @returns line point\r\n */\r\n public static SegmentizeLineBySegmentCount(what: Vector3[], segmentCount: number): Vector3[] {\r\n const segmentLength = GreasedLineTools.GetLineLength(what) / segmentCount;\r\n return GreasedLineTools.SegmentizeLineBySegmentLength(what, segmentLength);\r\n }\r\n /**\r\n * Gets line segments.\r\n * A segment is a part of the line between it's two points.\r\n * @param points line points\r\n * @returns segments information of the line segment including starting point, ending point and the distance between them\r\n */\r\n public static GetLineSegments(points: Vector3[]): { point1: Vector3; point2: Vector3; length: number }[] {\r\n const segments = [];\r\n for (let index = 0; index < points.length - 1; index++) {\r\n const point1 = points[index];\r\n const point2 = points[index + 1];\r\n const length = point2.subtract(point1).length();\r\n segments.push({ point1, point2, length });\r\n }\r\n\r\n return segments;\r\n }\r\n\r\n /**\r\n * Gets the minimum and the maximum length of a line segment in the line.\r\n * A segment is a part of the line between it's two points.\r\n * @param points line points\r\n * @returns\r\n */\r\n public static GetMinMaxSegmentLength(points: Vector3[]): { min: number; max: number } {\r\n const subLines = GreasedLineTools.GetLineSegments(points);\r\n const sorted = subLines.sort((s) => s.length);\r\n return {\r\n min: sorted[0].length,\r\n max: sorted[sorted.length - 1].length,\r\n };\r\n }\r\n\r\n /**\r\n * Finds the last visible position in world space of the line according to the visibility parameter\r\n * @param lineSegments segments of the line\r\n * @param lineLength total length of the line\r\n * @param visbility normalized value of visibility\r\n * @returns world space coordinate of the last visible piece of the line\r\n */\r\n public static GetPositionOnLineByVisibility(lineSegments: { point1: Vector3; point2: Vector3; length: number }[], lineLength: number, visbility: number, localSpace = false) {\r\n const lengthVisibilityRatio = lineLength * visbility;\r\n let sumSegmentLengths = 0;\r\n let segmentIndex = 0;\r\n\r\n const lineSegmentsLength = lineSegments.length;\r\n for (let i = 0; i < lineSegmentsLength; i++) {\r\n if (lengthVisibilityRatio <= sumSegmentLengths + lineSegments[i].length) {\r\n segmentIndex = i;\r\n break;\r\n }\r\n sumSegmentLengths += lineSegments[i].length;\r\n }\r\n\r\n const s = (lengthVisibilityRatio - sumSegmentLengths) / lineSegments[segmentIndex].length;\r\n\r\n lineSegments[segmentIndex].point2.subtractToRef(lineSegments[segmentIndex].point1, TmpVectors.Vector3[0]);\r\n TmpVectors.Vector3[1] = TmpVectors.Vector3[0].multiplyByFloats(s, s, s);\r\n if (!localSpace) {\r\n TmpVectors.Vector3[1].addInPlace(lineSegments[segmentIndex].point1);\r\n }\r\n\r\n return TmpVectors.Vector3[1].clone();\r\n }\r\n\r\n /**\r\n * Creates lines in a shape of circle/arc.\r\n * A segment is a part of the line between it's two points.\r\n * @param radiusX radiusX of the circle\r\n * @param segments number of segments in the circle\r\n * @param z z coordinate of the points. Defaults to 0.\r\n * @param radiusY radiusY of the circle - you can draw an oval if using different values\r\n * @param segmentAngle angle offset of the segments. Defaults to Math.PI * 2 / segments. Change this value to draw a part of the circle.\r\n * @returns line points\r\n */\r\n public static GetCircleLinePoints(radiusX: number, segments: number, z = 0, radiusY = radiusX, segmentAngle = (Math.PI * 2) / segments) {\r\n const points: Vector3[] = [];\r\n for (let i = 0; i <= segments; i++) {\r\n points.push(new Vector3(Math.cos(i * segmentAngle) * radiusX, Math.sin(i * segmentAngle) * radiusY, z));\r\n }\r\n return points;\r\n }\r\n\r\n /**\r\n * Gets line points in a shape of a bezier curve\r\n * @param p0 bezier point0\r\n * @param p1 bezier point1\r\n * @param p2 bezier point2\r\n * @param segments number of segments in the curve\r\n * @returns\r\n */\r\n public static GetBezierLinePoints(p0: Vector3, p1: Vector3, p2: Vector3, segments: number) {\r\n return Curve3.CreateQuadraticBezier(p0, p1, p2, segments)\r\n .getPoints()\r\n .flatMap((v) => [v.x, v.y, v.z]);\r\n }\r\n\r\n /**\r\n *\r\n * @param position position of the arrow cap (mainly you want to create a triangle, set widthUp and widthDown to the same value and omit widthStartUp and widthStartDown)\r\n * @param direction direction which the arrow points to\r\n * @param length length (size) of the arrow cap itself\r\n * @param widthUp the arrow width above the line\r\n * @param widthDown the arrow width belove the line\r\n * @param widthStartUp the arrow width at the start of the arrow above the line. In most scenarios this is 0.\r\n * @param widthStartDown the arrow width at the start of the arrow below the line. In most scenarios this is 0.\r\n * @returns\r\n */\r\n public static GetArrowCap(position: Vector3, direction: Vector3, length: number, widthUp: number, widthDown: number, widthStartUp = 0, widthStartDown = 0) {\r\n const points = [position.clone(), position.add(direction.multiplyByFloats(length, length, length))];\r\n const widths = [widthUp, widthDown, widthStartUp, widthStartDown];\r\n\r\n return {\r\n points,\r\n widths,\r\n };\r\n }\r\n}\r\n"]}
package/Misc/index.d.ts CHANGED
@@ -62,3 +62,4 @@ export * from "./error";
62
62
  export * from "./observableCoroutine";
63
63
  export * from "./copyTextureToTexture";
64
64
  export * from "./dumpTools";
65
+ export * from "./greasedLineTools";
package/Misc/index.js CHANGED
@@ -64,4 +64,5 @@ export * from "./error.js";
64
64
  export * from "./observableCoroutine.js";
65
65
  export * from "./copyTextureToTexture.js";
66
66
  export * from "./dumpTools.js";
67
+ export * from "./greasedLineTools.js";
67
68
  //# sourceMappingURL=index.js.map
package/Misc/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../lts/core/generated/Misc/index.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,cAAc,CAAC;AAC7B,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AA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ourcesContent":["/* eslint-disable import/no-internal-modules */\r\nexport * from \"./andOrNotEvaluator\";\r\nexport * from \"./assetsManager\";\r\nexport * from \"./basis\";\r\nexport * from \"./dds\";\r\nexport * from \"./decorators\";\r\nexport * from \"./deferred\";\r\nexport * from \"./environmentTextureTools\";\r\nexport * from \"./meshExploder\";\r\nexport * from \"./filesInput\";\r\nexport * from \"./HighDynamicRange/index\";\r\nexport * from \"./khronosTextureContainer\";\r\nexport * from \"./observable\";\r\nexport * from \"./observable.extensions\";\r\nexport * from \"./performanceMonitor\";\r\nexport * from \"./sceneOptimizer\";\r\nexport * from \"./sceneSerializer\";\r\nexport * from \"./smartArray\";\r\nexport * from \"./stringDictionary\";\r\nexport * from \"./tags\";\r\nexport * from \"./textureTools\";\r\nexport * from \"./tga\";\r\nexport * from \"./tools\";\r\nexport * from \"./videoRecorder\";\r\nexport * from \"./virtualJoystick\";\r\nexport * from \"./workerPool\";\r\nexport * from \"./logger\";\r\nexport * from \"./typeStore\";\r\nexport * from \"./filesInputStore\";\r\nexport * from \"./deepCopier\";\r\nexport * from \"./pivotTools\";\r\nexport * from \"./precisionDate\";\r\nexport * from \"./screenshotTools\";\r\nexport * from \"./webRequest\";\r\nexport * from \"./iInspectable\";\r\nexport * from \"./brdfTextureTools\";\r\nexport * from \"./rgbdTextureTools\";\r\nexport * from \"./gradients\";\r\nexport * from \"./perfCounter\";\r\nexport * from \"./fileRequest\";\r\nexport * from \"./customAnimationFrameRequester\";\r\nexport * from \"./retryStrategy\";\r\nexport * from \"./interfaces/screenshotSize\";\r\nexport * from \"./interfaces/iPerfViewer\";\r\nexport * from \"./fileTools\";\r\nexport * from \"./stringTools\";\r\nexport * from \"./dataReader\";\r\nexport * from \"./minMaxReducer\";\r\nexport * from \"./depthReducer\";\r\nexport * from \"./dataStorage\";\r\nexport * from \"./sceneRecorder\";\r\nexport * from \"./khronosTextureContainer2\";\r\nexport * from \"./trajectoryClassifier\";\r\nexport * from \"./timer\";\r\nexport * from \"./copyTools\";\r\nexport * from \"./reflector\";\r\nexport * from \"./domManagement\";\r\nexport * from \"./pressureObserverWrapper\";\r\nexport * from \"./PerformanceViewer/index\";\r\nexport * from \"./coroutine\";\r\nexport * from \"./guid\";\r\nexport * from \"./error\";\r\n// eslint-disable-next-line import/export\r\nexport * from \"./observableCoroutine\";\r\nexport * from \"./copyTextureToTexture\";\r\nexport * from \"./dumpTools\";\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../lts/core/generated/Misc/index.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,cAAc,CAAC;AAC7B,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,iCAAiC,CAAC;AAChD,cAAc,iBAAiB,CAAC;AAChC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AACzC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,yCAAyC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC","sourcesContent":["/* eslint-disable import/no-internal-modules */\r\nexport * from \"./andOrNotEvaluator\";\r\nexport * from \"./assetsManager\";\r\nexport * from \"./basis\";\r\nexport * from \"./dds\";\r\nexport * from \"./decorators\";\r\nexport * from \"./deferred\";\r\nexport * from \"./environmentTextureTools\";\r\nexport * from \"./meshExploder\";\r\nexport * from \"./filesInput\";\r\nexport * from \"./HighDynamicRange/index\";\r\nexport * from \"./khronosTextureContainer\";\r\nexport * from \"./observable\";\r\nexport * from \"./observable.extensions\";\r\nexport * from \"./performanceMonitor\";\r\nexport * from \"./sceneOptimizer\";\r\nexport * from \"./sceneSerializer\";\r\nexport * from \"./smartArray\";\r\nexport * from \"./stringDictionary\";\r\nexport * from \"./tags\";\r\nexport * from \"./textureTools\";\r\nexport * from \"./tga\";\r\nexport * from \"./tools\";\r\nexport * from \"./videoRecorder\";\r\nexport * from \"./virtualJoystick\";\r\nexport * from \"./workerPool\";\r\nexport * from \"./logger\";\r\nexport * from \"./typeStore\";\r\nexport * from \"./filesInputStore\";\r\nexport * from \"./deepCopier\";\r\nexport * from \"./pivotTools\";\r\nexport * from \"./precisionDate\";\r\nexport * from \"./screenshotTools\";\r\nexport * from \"./webRequest\";\r\nexport * from \"./iInspectable\";\r\nexport * from \"./brdfTextureTools\";\r\nexport * from \"./rgbdTextureTools\";\r\nexport * from \"./gradients\";\r\nexport * from \"./perfCounter\";\r\nexport * from \"./fileRequest\";\r\nexport * from \"./customAnimationFrameRequester\";\r\nexport * from \"./retryStrategy\";\r\nexport * from \"./interfaces/screenshotSize\";\r\nexport * from \"./interfaces/iPerfViewer\";\r\nexport * from \"./fileTools\";\r\nexport * from \"./stringTools\";\r\nexport * from \"./dataReader\";\r\nexport * from \"./minMaxReducer\";\r\nexport * from \"./depthReducer\";\r\nexport * from \"./dataStorage\";\r\nexport * from \"./sceneRecorder\";\r\nexport * from \"./khronosTextureContainer2\";\r\nexport * from \"./trajectoryClassifier\";\r\nexport * from \"./timer\";\r\nexport * from \"./copyTools\";\r\nexport * from \"./reflector\";\r\nexport * from \"./domManagement\";\r\nexport * from \"./pressureObserverWrapper\";\r\nexport * from \"./PerformanceViewer/index\";\r\nexport * from \"./coroutine\";\r\nexport * from \"./guid\";\r\nexport * from \"./error\";\r\n// eslint-disable-next-line import/export\r\nexport * from \"./observableCoroutine\";\r\nexport * from \"./copyTextureToTexture\";\r\nexport * from \"./dumpTools\";\r\nexport * from \"./greasedLineTools\";\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"khronosTextureContainer.js","sourceRoot":"","sources":["../../../../lts/core/generated/Misc/khronosTextureContainer.ts"],"names":[],"mappings":"AAAA,yDAAyD;AAC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AE;YACvB,mEAAmE;YACnE,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;YACpE,IACI,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI;gBACtB,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI;gBACtB,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI;gBACtB,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI;gBACtB,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI;gBACtB,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI;gBACtB,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI;gBACtB,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI;gBACtB,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI;gBACtB,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI;gBACtB,UAAU,CAAC,EAAE,CAAC,KAAK,IAAI;gBACvB,UAAU,CAAC,EAAE,CAAC,KAAK,IAAI,EACzB;gBACE,OAAO,IAAI,CAAC;aACf;SACJ;QAED,OAAO,KAAK,CAAC;IACjB,CAAC;;AA3Mc,kCAAU,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,yEAAyE;AAElH,aAAa;AACE,qCAAa,GAAG,CAAC,CAAC,CAAC,mCAAmC;AACtD,qCAAa,GAAG,CAAC,CAAC,CAAC,mCAAmC;AACtD,8BAAM,GAAG,CAAC,CAAC,CAAC,yBAAyB;AACrC,8BAAM,GAAG,CAAC,CAAC,CAAC,yBAAyB","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport { Logger } from \"../Misc/logger\";\r\nimport type { InternalTexture } from \"../Materials/Textures/internalTexture\";\r\n\r\n/**\r\n * for description see https://www.khronos.org/opengles/sdk/tools/KTX/\r\n * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/\r\n */\r\nexport class KhronosTextureContainer {\r\n private static HEADER_LEN = 12 + 13 * 4; // identifier + header elements (not including key value meta-data pairs)\r\n\r\n // load types\r\n private static COMPRESSED_2D = 0; // uses a gl.compressedTexImage2D()\r\n private static COMPRESSED_3D = 1; // uses a gl.compressedTexImage3D()\r\n private static TEX_2D = 2; // uses a gl.texImage2D()\r\n private static TEX_3D = 3; // uses a gl.texImage3D()\r\n\r\n // elements of the header\r\n /**\r\n * Gets the openGL type\r\n */\r\n public glType: number;\r\n /**\r\n * Gets the openGL type size\r\n */\r\n public glTypeSize: number;\r\n /**\r\n * Gets the openGL format\r\n */\r\n public glFormat: number;\r\n /**\r\n * Gets the openGL internal format\r\n */\r\n public glInternalFormat: number;\r\n /**\r\n * Gets the base internal format\r\n */\r\n public glBaseInternalFormat: number;\r\n /**\r\n * Gets image width in pixel\r\n */\r\n public pixelWidth: number;\r\n /**\r\n * Gets image height in pixel\r\n */\r\n public pixelHeight: number;\r\n /**\r\n * Gets image depth in pixels\r\n */\r\n public pixelDepth: number;\r\n /**\r\n * Gets the number of array elements\r\n */\r\n public numberOfArrayElements: number;\r\n /**\r\n * Gets the number of faces\r\n */\r\n public numberOfFaces: number;\r\n /**\r\n * Gets the number of mipmap levels\r\n */\r\n public numberOfMipmapLevels: number;\r\n /**\r\n * Gets the bytes of key value data\r\n */\r\n public bytesOfKeyValueData: number;\r\n /**\r\n * Gets the load type\r\n */\r\n public loadType: number;\r\n /**\r\n * If the container has been made invalid (eg. constructor failed to correctly load array buffer)\r\n */\r\n public isInvalid = false;\r\n\r\n /**\r\n * Creates a new KhronosTextureContainer\r\n * @param data contents of the KTX container file\r\n * @param facesExpected should be either 1 or 6, based whether a cube texture or or\r\n */\r\n public constructor(\r\n /** contents of the KTX container file */\r\n public data: ArrayBufferView,\r\n facesExpected: number\r\n ) {\r\n if (!KhronosTextureContainer.IsValid(data)) {\r\n this.isInvalid = true;\r\n Logger.Error(\"texture missing KTX identifier\");\r\n return;\r\n }\r\n\r\n // load the reset of the header in native 32 bit uint\r\n const dataSize = Uint32Array.BYTES_PER_ELEMENT;\r\n const headerDataView = new DataView(this.data.buffer, this.data.byteOffset + 12, 13 * dataSize);\r\n const endianness = headerDataView.getUint32(0, true);\r\n const littleEndian = endianness === 0x04030201;\r\n\r\n this.glType = headerDataView.getUint32(1 * dataSize, littleEndian); // must be 0 for compressed textures\r\n this.glTypeSize = headerDataView.getUint32(2 * dataSize, littleEndian); // must be 1 for compressed textures\r\n this.glFormat = headerDataView.getUint32(3 * dataSize, littleEndian); // must be 0 for compressed textures\r\n this.glInternalFormat = headerDataView.getUint32(4 * dataSize, littleEndian); // the value of arg passed to gl.compressedTexImage2D(,,x,,,,)\r\n this.glBaseInternalFormat = headerDataView.getUint32(5 * dataSize, littleEndian); // specify GL_RGB, GL_RGBA, GL_ALPHA, etc (un-compressed only)\r\n this.pixelWidth = headerDataView.getUint32(6 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,x,,,)\r\n this.pixelHeight = headerDataView.getUint32(7 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,,x,,)\r\n this.pixelDepth = headerDataView.getUint32(8 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage3D(,,,,,x,,)\r\n this.numberOfArrayElements = headerDataView.getUint32(9 * dataSize, littleEndian); // used for texture arrays\r\n this.numberOfFaces = headerDataView.getUint32(10 * dataSize, littleEndian); // used for cubemap textures, should either be 1 or 6\r\n this.numberOfMipmapLevels = headerDataView.getUint32(11 * dataSize, littleEndian); // number of levels; disregard possibility of 0 for compressed textures\r\n this.bytesOfKeyValueData = headerDataView.getUint32(12 * dataSize, littleEndian); // the amount of space after the header for meta-data\r\n\r\n // Make sure we have a compressed type. Not only reduces work, but probably better to let dev know they are not compressing.\r\n if (this.glType !== 0) {\r\n Logger.Error(\"only compressed formats currently supported\");\r\n this.isInvalid = true;\r\n return;\r\n } else {\r\n // value of zero is an indication to generate mipmaps @ runtime. Not usually allowed for compressed, so disregard.\r\n this.numberOfMipmapLevels = Math.max(1, this.numberOfMipmapLevels);\r\n }\r\n\r\n if (this.pixelHeight === 0 || this.pixelDepth !== 0) {\r\n Logger.Error(\"only 2D textures currently supported\");\r\n this.isInvalid = true;\r\n return;\r\n }\r\n\r\n if (this.numberOfArrayElements !== 0) {\r\n Logger.Error(\"texture arrays not currently supported\");\r\n this.isInvalid = true;\r\n return;\r\n }\r\n\r\n if (this.numberOfFaces !== facesExpected) {\r\n Logger.Error(\"number of faces expected\" + facesExpected + \", but found \" + this.numberOfFaces);\r\n this.isInvalid = true;\r\n return;\r\n }\r\n\r\n // we now have a completely validated file, so could use existence of loadType as success\r\n // would need to make this more elaborate & adjust checks above to support more than one load type\r\n this.loadType = KhronosTextureContainer.COMPRESSED_2D;\r\n }\r\n\r\n /**\r\n * Uploads KTX content to a Babylon Texture.\r\n * It is assumed that the texture has already been created & is currently bound\r\n * @internal\r\n */\r\n public uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void {\r\n switch (this.loadType) {\r\n case KhronosTextureContainer.COMPRESSED_2D:\r\n this._upload2DCompressedLevels(texture, loadMipmaps);\r\n break;\r\n\r\n case KhronosTextureContainer.TEX_2D:\r\n case KhronosTextureContainer.COMPRESSED_3D:\r\n case KhronosTextureContainer.TEX_3D:\r\n }\r\n }\r\n\r\n private _upload2DCompressedLevels(texture: InternalTexture, loadMipmaps: boolean): void {\r\n // initialize width & height for level 1\r\n let dataOffset = KhronosTextureContainer.HEADER_LEN + this.bytesOfKeyValueData;\r\n let width = this.pixelWidth;\r\n let height = this.pixelHeight;\r\n\r\n const mipmapCount = loadMipmaps ? this.numberOfMipmapLevels : 1;\r\n for (let level = 0; level < mipmapCount; level++) {\r\n const imageSize = new Int32Array(this.data.buffer, this.data.byteOffset + dataOffset, 1)[0]; // size per face, since not supporting array cubemaps\r\n dataOffset += 4; //image data starts from next multiple of 4 offset. Each face refers to same imagesize field above.\r\n for (let face = 0; face < this.numberOfFaces; face++) {\r\n const byteArray = new Uint8Array(this.data.buffer, this.data.byteOffset + dataOffset, imageSize);\r\n\r\n const engine = texture.getEngine();\r\n engine._uploadCompressedDataToTextureDirectly(texture, texture.format, width, height, byteArray, face, level);\r\n\r\n dataOffset += imageSize; // add size of the image for the next face/mipmap\r\n dataOffset += 3 - ((imageSize + 3) % 4); // add padding for odd sized image\r\n }\r\n width = Math.max(1.0, width * 0.5);\r\n height = Math.max(1.0, height * 0.5);\r\n }\r\n }\r\n\r\n /**\r\n * Checks if the given data starts with a KTX file identifier.\r\n * @param data the data to check\r\n * @returns true if the data is a KTX file or false otherwise\r\n */\r\n public static IsValid(data: ArrayBufferView): boolean {\r\n if (data.byteLength >= 12) {\r\n // '«', 'K', 'T', 'X', ' ', '1', '1', '»', '\\r', '\\n', '\\x1A', '\\n'\r\n const identifier = new Uint8Array(data.buffer, data.byteOffset, 12);\r\n if (\r\n identifier[0] === 0xab &&\r\n identifier[1] === 0x4b &&\r\n identifier[2] === 0x54 &&\r\n identifier[3] === 0x58 &&\r\n identifier[4] === 0x20 &&\r\n identifier[5] === 0x31 &&\r\n identifier[6] === 0x31 &&\r\n identifier[7] === 0xbb &&\r\n identifier[8] === 0x0d &&\r\n identifier[9] === 0x0a &&\r\n identifier[10] === 0x1a &&\r\n identifier[11] === 0x0a\r\n ) {\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"khronosTextureContainer.js","sourceRoot":"","sources":["../../../../lts/core/generated/Misc/khronosTextureContainer.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGxC;;;GAGG;AACH,MAAM,OAAO,uBAAuB;IAmEhC;;;;OAIG;IACH;IACI,yCAAyC;IAClC,IAAqB,EAC5B,aAAqB;QADd,SAAI,GAAJ,IAAI,CAAiB;QAZhC;;WAEG;QACI,cAAS,GAAG,KAAK,CAAC;QAYrB,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC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,CAAC,CAAC,CAAC,KAAK,IAAI;gBACtB,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI;gBACtB,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI;gBACtB,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI;gBACtB,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI;gBACtB,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI;gBACtB,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI;gBACtB,UAAU,CAAC,EAAE,CAAC,KAAK,IAAI;gBACvB,UAAU,CAAC,EAAE,CAAC,KAAK,IAAI,EACzB;gBACE,OAAO,IAAI,CAAC;aACf;SACJ;QAED,OAAO,KAAK,CAAC;IACjB,CAAC;;AA3Mc,kCAAU,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,AAAd,CAAe,CAAC,yEAAyE;AAElH,aAAa;AACE,qCAAa,GAAG,CAAC,AAAJ,CAAK,CAAC,mCAAmC;AACtD,qCAAa,GAAG,CAAC,AAAJ,CAAK,CAAC,mCAAmC;AACtD,8BAAM,GAAG,CAAC,AAAJ,CAAK,CAAC,yBAAyB;AACrC,8BAAM,GAAG,CAAC,AAAJ,CAAK,CAAC,yBAAyB","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport { Logger } from \"../Misc/logger\";\r\nimport type { InternalTexture } from \"../Materials/Textures/internalTexture\";\r\n\r\n/**\r\n * for description see https://www.khronos.org/opengles/sdk/tools/KTX/\r\n * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/\r\n */\r\nexport class KhronosTextureContainer {\r\n private static HEADER_LEN = 12 + 13 * 4; // identifier + header elements (not including key value meta-data pairs)\r\n\r\n // load types\r\n private static COMPRESSED_2D = 0; // uses a gl.compressedTexImage2D()\r\n private static COMPRESSED_3D = 1; // uses a gl.compressedTexImage3D()\r\n private static TEX_2D = 2; // uses a gl.texImage2D()\r\n private static TEX_3D = 3; // uses a gl.texImage3D()\r\n\r\n // elements of the header\r\n /**\r\n * Gets the openGL type\r\n */\r\n public glType: number;\r\n /**\r\n * Gets the openGL type size\r\n */\r\n public glTypeSize: number;\r\n /**\r\n * Gets the openGL format\r\n */\r\n public glFormat: number;\r\n /**\r\n * Gets the openGL internal format\r\n */\r\n public glInternalFormat: number;\r\n /**\r\n * Gets the base internal format\r\n */\r\n public glBaseInternalFormat: number;\r\n /**\r\n * Gets image width in pixel\r\n */\r\n public pixelWidth: number;\r\n /**\r\n * Gets image height in pixel\r\n */\r\n public pixelHeight: number;\r\n /**\r\n * Gets image depth in pixels\r\n */\r\n public pixelDepth: number;\r\n /**\r\n * Gets the number of array elements\r\n */\r\n public numberOfArrayElements: number;\r\n /**\r\n * Gets the number of faces\r\n */\r\n public numberOfFaces: number;\r\n /**\r\n * Gets the number of mipmap levels\r\n */\r\n public numberOfMipmapLevels: number;\r\n /**\r\n * Gets the bytes of key value data\r\n */\r\n public bytesOfKeyValueData: number;\r\n /**\r\n * Gets the load type\r\n */\r\n public loadType: number;\r\n /**\r\n * If the container has been made invalid (eg. constructor failed to correctly load array buffer)\r\n */\r\n public isInvalid = false;\r\n\r\n /**\r\n * Creates a new KhronosTextureContainer\r\n * @param data contents of the KTX container file\r\n * @param facesExpected should be either 1 or 6, based whether a cube texture or or\r\n */\r\n public constructor(\r\n /** contents of the KTX container file */\r\n public data: ArrayBufferView,\r\n facesExpected: number\r\n ) {\r\n if (!KhronosTextureContainer.IsValid(data)) {\r\n this.isInvalid = true;\r\n Logger.Error(\"texture missing KTX identifier\");\r\n return;\r\n }\r\n\r\n // load the reset of the header in native 32 bit uint\r\n const dataSize = Uint32Array.BYTES_PER_ELEMENT;\r\n const headerDataView = new DataView(this.data.buffer, this.data.byteOffset + 12, 13 * dataSize);\r\n const endianness = headerDataView.getUint32(0, true);\r\n const littleEndian = endianness === 0x04030201;\r\n\r\n this.glType = headerDataView.getUint32(1 * dataSize, littleEndian); // must be 0 for compressed textures\r\n this.glTypeSize = headerDataView.getUint32(2 * dataSize, littleEndian); // must be 1 for compressed textures\r\n this.glFormat = headerDataView.getUint32(3 * dataSize, littleEndian); // must be 0 for compressed textures\r\n this.glInternalFormat = headerDataView.getUint32(4 * dataSize, littleEndian); // the value of arg passed to gl.compressedTexImage2D(,,x,,,,)\r\n this.glBaseInternalFormat = headerDataView.getUint32(5 * dataSize, littleEndian); // specify GL_RGB, GL_RGBA, GL_ALPHA, etc (un-compressed only)\r\n this.pixelWidth = headerDataView.getUint32(6 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,x,,,)\r\n this.pixelHeight = headerDataView.getUint32(7 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,,x,,)\r\n this.pixelDepth = headerDataView.getUint32(8 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage3D(,,,,,x,,)\r\n this.numberOfArrayElements = headerDataView.getUint32(9 * dataSize, littleEndian); // used for texture arrays\r\n this.numberOfFaces = headerDataView.getUint32(10 * dataSize, littleEndian); // used for cubemap textures, should either be 1 or 6\r\n this.numberOfMipmapLevels = headerDataView.getUint32(11 * dataSize, littleEndian); // number of levels; disregard possibility of 0 for compressed textures\r\n this.bytesOfKeyValueData = headerDataView.getUint32(12 * dataSize, littleEndian); // the amount of space after the header for meta-data\r\n\r\n // Make sure we have a compressed type. Not only reduces work, but probably better to let dev know they are not compressing.\r\n if (this.glType !== 0) {\r\n Logger.Error(\"only compressed formats currently supported\");\r\n this.isInvalid = true;\r\n return;\r\n } else {\r\n // value of zero is an indication to generate mipmaps @ runtime. Not usually allowed for compressed, so disregard.\r\n this.numberOfMipmapLevels = Math.max(1, this.numberOfMipmapLevels);\r\n }\r\n\r\n if (this.pixelHeight === 0 || this.pixelDepth !== 0) {\r\n Logger.Error(\"only 2D textures currently supported\");\r\n this.isInvalid = true;\r\n return;\r\n }\r\n\r\n if (this.numberOfArrayElements !== 0) {\r\n Logger.Error(\"texture arrays not currently supported\");\r\n this.isInvalid = true;\r\n return;\r\n }\r\n\r\n if (this.numberOfFaces !== facesExpected) {\r\n Logger.Error(\"number of faces expected\" + facesExpected + \", but found \" + this.numberOfFaces);\r\n this.isInvalid = true;\r\n return;\r\n }\r\n\r\n // we now have a completely validated file, so could use existence of loadType as success\r\n // would need to make this more elaborate & adjust checks above to support more than one load type\r\n this.loadType = KhronosTextureContainer.COMPRESSED_2D;\r\n }\r\n\r\n /**\r\n * Uploads KTX content to a Babylon Texture.\r\n * It is assumed that the texture has already been created & is currently bound\r\n * @internal\r\n */\r\n public uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void {\r\n switch (this.loadType) {\r\n case KhronosTextureContainer.COMPRESSED_2D:\r\n this._upload2DCompressedLevels(texture, loadMipmaps);\r\n break;\r\n\r\n case KhronosTextureContainer.TEX_2D:\r\n case KhronosTextureContainer.COMPRESSED_3D:\r\n case KhronosTextureContainer.TEX_3D:\r\n }\r\n }\r\n\r\n private _upload2DCompressedLevels(texture: InternalTexture, loadMipmaps: boolean): void {\r\n // initialize width & height for level 1\r\n let dataOffset = KhronosTextureContainer.HEADER_LEN + this.bytesOfKeyValueData;\r\n let width = this.pixelWidth;\r\n let height = this.pixelHeight;\r\n\r\n const mipmapCount = loadMipmaps ? this.numberOfMipmapLevels : 1;\r\n for (let level = 0; level < mipmapCount; level++) {\r\n const imageSize = new Int32Array(this.data.buffer, this.data.byteOffset + dataOffset, 1)[0]; // size per face, since not supporting array cubemaps\r\n dataOffset += 4; //image data starts from next multiple of 4 offset. Each face refers to same imagesize field above.\r\n for (let face = 0; face < this.numberOfFaces; face++) {\r\n const byteArray = new Uint8Array(this.data.buffer, this.data.byteOffset + dataOffset, imageSize);\r\n\r\n const engine = texture.getEngine();\r\n engine._uploadCompressedDataToTextureDirectly(texture, texture.format, width, height, byteArray, face, level);\r\n\r\n dataOffset += imageSize; // add size of the image for the next face/mipmap\r\n dataOffset += 3 - ((imageSize + 3) % 4); // add padding for odd sized image\r\n }\r\n width = Math.max(1.0, width * 0.5);\r\n height = Math.max(1.0, height * 0.5);\r\n }\r\n }\r\n\r\n /**\r\n * Checks if the given data starts with a KTX file identifier.\r\n * @param data the data to check\r\n * @returns true if the data is a KTX file or false otherwise\r\n */\r\n public static IsValid(data: ArrayBufferView): boolean {\r\n if (data.byteLength >= 12) {\r\n // '«', 'K', 'T', 'X', ' ', '1', '1', '»', '\\r', '\\n', '\\x1A', '\\n'\r\n const identifier = new Uint8Array(data.buffer, data.byteOffset, 12);\r\n if (\r\n identifier[0] === 0xab &&\r\n identifier[1] === 0x4b &&\r\n identifier[2] === 0x54 &&\r\n identifier[3] === 0x58 &&\r\n identifier[4] === 0x20 &&\r\n identifier[5] === 0x31 &&\r\n identifier[6] === 0x31 &&\r\n identifier[7] === 0xbb &&\r\n identifier[8] === 0x0d &&\r\n identifier[9] === 0x0a &&\r\n identifier[10] === 0x1a &&\r\n identifier[11] === 0x0a\r\n ) {\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n}\r\n"]}
@@ -68,6 +68,12 @@ export declare class Observer<T> {
68
68
  * Gets or sets a property defining that the observer as to be unregistered after the next notification
69
69
  */
70
70
  unregisterOnNextCall: boolean;
71
+ /**
72
+ * this function can be used to remove the observer from the observable.
73
+ * It will be set by the observable that the observer belongs to.
74
+ * @internal
75
+ */
76
+ _remove: Nullable<() => void>;
71
77
  /**
72
78
  * Creates a new observer
73
79
  * @param callback defines the callback to call when the observer is notified
@@ -87,6 +93,11 @@ export declare class Observer<T> {
87
93
  * Defines the current scope used to restore the JS context
88
94
  */
89
95
  scope?: any);
96
+ /**
97
+ * Remove the observer from its observable
98
+ * This can be used instead of using the observable's remove function.
99
+ */
100
+ remove(): void;
90
101
  }
91
102
  /**
92
103
  * The Observable class is a simple implementation of the Observable pattern.
@@ -60,6 +60,21 @@ export class Observer {
60
60
  * Gets or sets a property defining that the observer as to be unregistered after the next notification
61
61
  */
62
62
  this.unregisterOnNextCall = false;
63
+ /**
64
+ * this function can be used to remove the observer from the observable.
65
+ * It will be set by the observable that the observer belongs to.
66
+ * @internal
67
+ */
68
+ this._remove = null;
69
+ }
70
+ /**
71
+ * Remove the observer from its observable
72
+ * This can be used instead of using the observable's remove function.
73
+ */
74
+ remove() {
75
+ if (this._remove) {
76
+ this._remove();
77
+ }
63
78
  }
64
79
  }
65
80
  /**
@@ -150,6 +165,10 @@ export class Observable {
150
165
  this.notifyObserver(observer, this._lastNotifiedValue);
151
166
  }
152
167
  }
168
+ // attach the remove function to the observer
169
+ observer._remove = () => {
170
+ this.remove(observer);
171
+ };
153
172
  return observer;
154
173
  }
155
174
  /**
@@ -169,6 +188,7 @@ export class Observable {
169
188
  if (!observer) {
170
189
  return false;
171
190
  }
191
+ observer._remove = null;
172
192
  const index = this._observers.indexOf(observer);
173
193
  if (index !== -1) {
174
194
  this._deferUnregister(observer);
@@ -322,7 +342,12 @@ export class Observable {
322
342
  * Clear the list of observers
323
343
  */
324
344
  clear() {
325
- this._observers.length = 0;
345
+ while (this._observers.length) {
346
+ const o = this._observers.pop();
347
+ if (o) {
348
+ o._remove = null;
349
+ }
350
+ }
326
351
  this._onObserverAdded = null;
327
352
  this._numObserversMarkedAsDeleted = 0;
328
353
  this.cleanLastNotifiedState();