@babylonjs/core 7.16.0 → 7.16.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.
- package/Animations/animationGroup.d.ts +1 -0
- package/Animations/animationGroup.js +4 -1
- package/Animations/animationGroup.js.map +1 -1
- package/Collisions/gpuPicker.js +1 -1
- package/Collisions/gpuPicker.js.map +1 -1
- package/Compute/computeEffect.js +1 -1
- package/Compute/computeEffect.js.map +1 -1
- package/Engines/WebGPU/webgpuShaderProcessorsWGSL.d.ts +32 -0
- package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js +32 -0
- package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/engine.d.ts +1993 -1993
- package/Engines/nativeEngine.d.ts +7 -0
- package/Engines/nativeEngine.js +24 -1
- package/Engines/nativeEngine.js.map +1 -1
- package/Engines/thinEngine.js +2 -2
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.js +3 -3
- package/Engines/webgpuEngine.js.map +1 -1
- package/Materials/Node/Blocks/Dual/clipPlanesBlock.js +6 -6
- package/Materials/Node/Blocks/Dual/clipPlanesBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.js +4 -7
- package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/textureBlock.js +1 -1
- package/Materials/Node/Blocks/Dual/textureBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/anisotropyBlock.js +4 -4
- package/Materials/Node/Blocks/PBR/anisotropyBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/clearCoatBlock.js +46 -40
- package/Materials/Node/Blocks/PBR/clearCoatBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/iridescenceBlock.d.ts +2 -1
- package/Materials/Node/Blocks/PBR/iridescenceBlock.js +10 -9
- package/Materials/Node/Blocks/PBR/iridescenceBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.d.ts +1 -0
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js +85 -69
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/reflectionBlock.js +54 -38
- package/Materials/Node/Blocks/PBR/reflectionBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/refractionBlock.js +2 -2
- package/Materials/Node/Blocks/PBR/refractionBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/sheenBlock.d.ts +2 -1
- package/Materials/Node/Blocks/PBR/sheenBlock.js +40 -32
- package/Materials/Node/Blocks/PBR/sheenBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/subSurfaceBlock.js +53 -45
- package/Materials/Node/Blocks/PBR/subSurfaceBlock.js.map +1 -1
- package/Materials/Node/nodeMaterial.d.ts +2 -1
- package/Materials/Node/nodeMaterial.js +4 -1
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Materials/Node/nodeMaterialBuildState.d.ts +1 -0
- package/Materials/Node/nodeMaterialBuildState.js +12 -3
- package/Materials/Node/nodeMaterialBuildState.js.map +1 -1
- package/Materials/effect.js +2 -2
- package/Materials/effect.js.map +1 -1
- package/Meshes/Builders/decalBuilder.js +12 -12
- package/Meshes/Builders/decalBuilder.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.d.ts +10 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +50 -11
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
- package/Meshes/Node/nodeGeometry.d.ts +6 -0
- package/Meshes/Node/nodeGeometry.js +7 -0
- package/Meshes/Node/nodeGeometry.js.map +1 -1
- package/Meshes/mesh.d.ts +1 -0
- package/Meshes/mesh.js +138 -134
- package/Meshes/mesh.js.map +1 -1
- package/Meshes/subMesh.js +1 -1
- package/Meshes/subMesh.js.map +1 -1
- package/Misc/khronosTextureContainer2.js +1 -1
- package/Misc/khronosTextureContainer2.js.map +1 -1
- package/Rendering/GlobalIllumination/giRSMManager.js +1 -1
- package/Rendering/GlobalIllumination/giRSMManager.js.map +1 -1
- package/Rendering/edgesRenderer.js +1 -1
- package/Rendering/edgesRenderer.js.map +1 -1
- package/Rendering/fluidRenderer/fluidRenderingTargetRenderer.js +1 -1
- package/Rendering/fluidRenderer/fluidRenderingTargetRenderer.js.map +1 -1
- package/Shaders/ShadersInclude/lightFragment.js +3 -3
- package/Shaders/ShadersInclude/lightFragment.js.map +1 -1
- package/Shaders/ShadersInclude/lightsFragmentFunctions.js +1 -1
- package/Shaders/ShadersInclude/lightsFragmentFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockAlbedoOpacity.js +13 -14
- package/Shaders/ShadersInclude/pbrBlockAlbedoOpacity.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockAlphaFresnel.js +4 -5
- package/Shaders/ShadersInclude/pbrBlockAlphaFresnel.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockAmbientOcclusion.js +4 -5
- package/Shaders/ShadersInclude/pbrBlockAmbientOcclusion.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockAnisotropic.js +4 -5
- package/Shaders/ShadersInclude/pbrBlockAnisotropic.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockClearcoat.js +34 -35
- package/Shaders/ShadersInclude/pbrBlockClearcoat.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockIridescence.js +10 -11
- package/Shaders/ShadersInclude/pbrBlockIridescence.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockReflection.js +23 -24
- package/Shaders/ShadersInclude/pbrBlockReflection.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockReflectivity.js +12 -13
- package/Shaders/ShadersInclude/pbrBlockReflectivity.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockSheen.js +31 -32
- package/Shaders/ShadersInclude/pbrBlockSheen.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockSubSurface.js +43 -44
- package/Shaders/ShadersInclude/pbrBlockSubSurface.js.map +1 -1
- package/Shaders/ShadersInclude/pbrDirectLightingFunctions.js +1 -1
- package/Shaders/ShadersInclude/pbrDirectLightingFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions.js +1 -1
- package/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions.js.map +1 -1
- package/Shaders/pbr.fragment.js +143 -153
- package/Shaders/pbr.fragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/bumpFragmentMainFunctions.js +3 -3
- package/ShadersWGSL/ShadersInclude/bumpFragmentMainFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/decalFragment.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/decalFragment.js +18 -0
- package/ShadersWGSL/ShadersInclude/decalFragment.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/depthPrePass.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/depthPrePass.js +12 -0
- package/ShadersWGSL/ShadersInclude/depthPrePass.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/harmonicsFunctions.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/harmonicsFunctions.js +24 -0
- package/ShadersWGSL/ShadersInclude/harmonicsFunctions.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/hdrFilteringFunctions.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/hdrFilteringFunctions.js +39 -0
- package/ShadersWGSL/ShadersInclude/hdrFilteringFunctions.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/helperFunctions.js +6 -2
- package/ShadersWGSL/ShadersInclude/helperFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/imageProcessingFunctions.js +2 -2
- package/ShadersWGSL/ShadersInclude/imageProcessingFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/importanceSampling.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/importanceSampling.js +12 -0
- package/ShadersWGSL/ShadersInclude/importanceSampling.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/lightFragment.js +3 -3
- package/ShadersWGSL/ShadersInclude/lightFragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/lightsFragmentFunctions.js +1 -1
- package/ShadersWGSL/ShadersInclude/lightsFragmentFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBRDFFunctions.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/pbrBRDFFunctions.js +139 -0
- package/ShadersWGSL/ShadersInclude/pbrBRDFFunctions.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockAlbedoOpacity.d.ts +6 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockAlbedoOpacity.js +81 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockAlbedoOpacity.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockAlphaFresnel.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockAlphaFresnel.js +37 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockAlphaFresnel.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockAmbientOcclusion.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockAmbientOcclusion.js +35 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockAmbientOcclusion.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockAnisotropic.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockAnisotropic.js +46 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockAnisotropic.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockClearcoat.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockClearcoat.js +267 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockClearcoat.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockDirectLighting.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockDirectLighting.js +24 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockDirectLighting.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockFinalColorComposition.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockFinalColorComposition.js +51 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockFinalColorComposition.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockFinalLitComponents.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockFinalLitComponents.js +96 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockFinalLitComponents.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockFinalUnlitComponents.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockFinalUnlitComponents.js +26 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockFinalUnlitComponents.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockGeometryInfo.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockGeometryInfo.js +33 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockGeometryInfo.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockImageProcessing.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockImageProcessing.js +20 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockImageProcessing.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockIridescence.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockIridescence.js +51 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockIridescence.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockLightmapInit.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockLightmapInit.js +19 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockLightmapInit.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockNormalFinal.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockNormalFinal.js +19 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockNormalFinal.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockReflectance.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockReflectance.js +30 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockReflectance.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockReflectance0.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockReflectance0.js +18 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockReflectance0.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockReflection.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockReflection.js +277 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockReflection.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockReflectivity.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockReflectivity.js +120 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockReflectivity.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockSheen.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockSheen.js +195 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockSheen.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockSubSurface.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockSubSurface.js +425 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockSubSurface.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/pbrDebug.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/pbrDebug.js +193 -0
- package/ShadersWGSL/ShadersInclude/pbrDebug.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingFalloffFunctions.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingFalloffFunctions.js +43 -0
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingFalloffFunctions.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js +68 -0
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingSetupFunctions.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingSetupFunctions.js +30 -0
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingSetupFunctions.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/pbrHelperFunctions.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/pbrHelperFunctions.js +41 -0
- package/ShadersWGSL/ShadersInclude/pbrHelperFunctions.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/pbrIBLFunctions.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/pbrIBLFunctions.js +23 -0
- package/ShadersWGSL/ShadersInclude/pbrIBLFunctions.js.map +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decalBuilder.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Builders/decalBuilder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGhD,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAEzE,MAAM,MAAM,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACpC,MAAM,MAAM,GAAG,IAAI,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CAAC;QAClC,KAAK,CAAC,QAAQ,GAAG,IAAI,OAAO,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;KACnD;IAED,KAAK,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAC/B,KAAK,CAAC,mBAAmB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAEtC,OAAO,KAAK,CAAC;AACjB,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IACxB,gEAAgE;IAChE,WAAW;CACd,CAAC;AAEF,IAAI,CAAC,WAAW,GAAG,CAAC,IAAY,EAAE,UAAwB,EAAE,QAAiB,EAAE,MAAe,EAAE,IAAa,EAAE,KAAa,EAAQ,EAAE;IAClI,MAAM,OAAO,GAAG;QACZ,QAAQ;QACR,MAAM;QACN,IAAI;QACJ,KAAK;KACR,CAAC;IAEF,OAAO,WAAW,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;AAClD,CAAC,CAAC","sourcesContent":["import type { Nullable, IndicesArray, FloatArray } from \"../../types\";\r\nimport { Vector3, Matrix, Vector2, TmpVectors } from \"../../Maths/math.vector\";\r\nimport { Scalar } from \"../../Maths/math.scalar\";\r\nimport { Mesh } from \"../mesh\";\r\nimport { VertexBuffer } from \"../../Buffers/buffer\";\r\nimport { VertexData } from \"../mesh.vertexData\";\r\nimport type { AbstractMesh } from \"../abstractMesh\";\r\nimport type { Camera } from \"../../Cameras/camera\";\r\nimport { CompatibilityOptions } from \"../../Compat/compatibilityOptions\";\r\n\r\nconst xpAxis = new Vector3(1, 0, 0);\r\nconst xnAxis = new Vector3(-1, 0, 0);\r\nconst ypAxis = new Vector3(0, 1, 0);\r\nconst ynAxis = new Vector3(0, -1, 0);\r\nconst zpAxis = new Vector3(0, 0, 1);\r\nconst znAxis = new Vector3(0, 0, -1);\r\n\r\n/** @internal */\r\nclass DecalVertex {\r\n constructor(\r\n public position: Vector3 = Vector3.Zero(),\r\n public normal: Vector3 = Vector3.Up(),\r\n public uv: Vector2 = Vector2.Zero(),\r\n public vertexIdx: number = 0,\r\n public vertexIdxForBones: number = 0,\r\n public localPositionOverride: Nullable<number[]> = null,\r\n public localNormalOverride: Nullable<number[]> = null,\r\n public matrixIndicesOverride: Nullable<number[]> = null,\r\n public matrixWeightsOverride: Nullable<number[]> = null\r\n ) {}\r\n public clone(): DecalVertex {\r\n return new DecalVertex(\r\n this.position.clone(),\r\n this.normal.clone(),\r\n this.uv.clone(),\r\n this.vertexIdx,\r\n this.vertexIdxForBones,\r\n this.localPositionOverride?.slice(),\r\n this.localNormalOverride?.slice(),\r\n this.matrixIndicesOverride?.slice(),\r\n this.matrixWeightsOverride?.slice()\r\n );\r\n }\r\n}\r\n\r\n/**\r\n * Creates a decal mesh.\r\n * A decal is a mesh usually applied as a model onto the surface of another mesh. So don't forget the parameter `sourceMesh` depicting the decal\r\n * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates\r\n * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates\r\n * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling\r\n * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal\r\n * * The parameter `captureUVS` defines if we need to capture the uvs or compute them\r\n * * The parameter `cullBackFaces` defines if the back faces should be removed from the decal mesh\r\n * * The parameter `localMode` defines that the computations should be done with the local mesh coordinates instead of the world space coordinates.\r\n * * Use this mode if you want the decal to be parented to the sourceMesh and move/rotate with it.\r\n * Note: Meshes with morph targets are not supported!\r\n * @param name defines the name of the mesh\r\n * @param sourceMesh defines the mesh where the decal must be applied\r\n * @param options defines the options used to create the mesh\r\n * @returns the decal mesh\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/decals\r\n */\r\nexport function CreateDecal(\r\n name: string,\r\n sourceMesh: AbstractMesh,\r\n options: { position?: Vector3; normal?: Vector3; size?: Vector3; angle?: number; captureUVS?: boolean; cullBackFaces?: boolean; localMode?: boolean }\r\n): Mesh {\r\n const hasSkeleton = !!sourceMesh.skeleton;\r\n const useLocalComputation = options.localMode || hasSkeleton;\r\n\r\n const indices = <IndicesArray>sourceMesh.getIndices();\r\n const positions = hasSkeleton ? sourceMesh.getPositionData(true, true) : sourceMesh.getVerticesData(VertexBuffer.PositionKind);\r\n const normals = hasSkeleton ? sourceMesh.getNormalsData(true, true) : sourceMesh.getVerticesData(VertexBuffer.NormalKind);\r\n const localPositions = useLocalComputation ? (hasSkeleton ? sourceMesh.getVerticesData(VertexBuffer.PositionKind) : positions) : null;\r\n const localNormals = useLocalComputation ? (hasSkeleton ? sourceMesh.getVerticesData(VertexBuffer.NormalKind) : normals) : null;\r\n const uvs = sourceMesh.getVerticesData(VertexBuffer.UVKind);\r\n const matIndices = hasSkeleton ? sourceMesh.getVerticesData(VertexBuffer.MatricesIndicesKind) : null;\r\n const matWeights = hasSkeleton ? sourceMesh.getVerticesData(VertexBuffer.MatricesWeightsKind) : null;\r\n const matIndicesExtra = hasSkeleton ? sourceMesh.getVerticesData(VertexBuffer.MatricesIndicesExtraKind) : null;\r\n const matWeightsExtra = hasSkeleton ? sourceMesh.getVerticesData(VertexBuffer.MatricesWeightsExtraKind) : null;\r\n\r\n const position = options.position || Vector3.Zero();\r\n let normal = options.normal || Vector3.Up();\r\n const size = options.size || Vector3.One();\r\n const angle = options.angle || 0;\r\n\r\n // Getting correct rotation\r\n if (!normal) {\r\n const target = new Vector3(0, 0, 1);\r\n const camera = <Camera>sourceMesh.getScene().activeCamera;\r\n const cameraWorldTarget = Vector3.TransformCoordinates(target, camera.getWorldMatrix());\r\n\r\n normal = camera.globalPosition.subtract(cameraWorldTarget);\r\n }\r\n\r\n const yaw = -Math.atan2(normal.z, normal.x) - Math.PI / 2;\r\n const len = Math.sqrt(normal.x * normal.x + normal.z * normal.z);\r\n const pitch = Math.atan2(normal.y, len);\r\n\r\n const vertexData = new VertexData();\r\n vertexData.indices = [];\r\n vertexData.positions = [];\r\n vertexData.normals = [];\r\n vertexData.uvs = [];\r\n vertexData.matricesIndices = hasSkeleton ? [] : null;\r\n vertexData.matricesWeights = hasSkeleton ? [] : null;\r\n vertexData.matricesIndicesExtra = matIndicesExtra ? [] : null;\r\n vertexData.matricesWeightsExtra = matWeightsExtra ? [] : null;\r\n\r\n let currentVertexDataIndex = 0;\r\n\r\n const extractDecalVector3 = (indexId: number, transformMatrix: Matrix): DecalVertex => {\r\n const result = new DecalVertex();\r\n if (!indices || !positions || !normals) {\r\n return result;\r\n }\r\n\r\n const vertexId = indices[indexId];\r\n\r\n result.vertexIdx = vertexId * 3;\r\n result.vertexIdxForBones = vertexId * 4;\r\n\r\n // Send vector to decal local world\r\n result.position = new Vector3(positions[vertexId * 3], positions[vertexId * 3 + 1], positions[vertexId * 3 + 2]);\r\n Vector3.TransformCoordinatesToRef(result.position, transformMatrix, result.position);\r\n\r\n // Get normal\r\n result.normal = new Vector3(normals[vertexId * 3], normals[vertexId * 3 + 1], normals[vertexId * 3 + 2]);\r\n Vector3.TransformNormalToRef(result.normal, transformMatrix, result.normal);\r\n\r\n if (options.captureUVS && uvs) {\r\n const v = uvs[vertexId * 2 + 1];\r\n result.uv = new Vector2(uvs[vertexId * 2], CompatibilityOptions.UseOpenGLOrientationForUV ? 1 - v : v);\r\n }\r\n\r\n return result;\r\n };\r\n\r\n const emptyArray = [0, 0, 0, 0];\r\n\r\n // Inspired by https://github.com/mrdoob/three.js/blob/eee231960882f6f3b6113405f524956145148146/examples/js/geometries/DecalGeometry.js\r\n const clip = (vertices: DecalVertex[], axis: Vector3): Nullable<DecalVertex[]> => {\r\n if (vertices.length === 0) {\r\n return vertices;\r\n }\r\n\r\n const clipSize = 0.5 * Math.abs(Vector3.Dot(size, axis));\r\n\r\n const indexOf = (arr: FloatArray | number[], val: number, start: number, num: number) => {\r\n for (let i = 0; i < num; ++i) {\r\n if (arr[start + i] === val) {\r\n return start + i;\r\n }\r\n }\r\n return -1;\r\n };\r\n\r\n const clipVertices = (v0: DecalVertex, v1: DecalVertex): DecalVertex => {\r\n const clipFactor = Vector3.GetClipFactor(v0.position, v1.position, axis, clipSize);\r\n\r\n let indices = emptyArray;\r\n let weights = emptyArray;\r\n\r\n if (matIndices && matWeights) {\r\n const mat0Index = v0.matrixIndicesOverride ? 0 : v0.vertexIdxForBones;\r\n const v0Indices = v0.matrixIndicesOverride ?? matIndices;\r\n const v0Weights = v0.matrixWeightsOverride ?? matWeights;\r\n\r\n const mat1Index = v1.matrixIndicesOverride ? 0 : v1.vertexIdxForBones;\r\n const v1Indices = v1.matrixIndicesOverride ?? matIndices;\r\n const v1Weights = v1.matrixWeightsOverride ?? matWeights;\r\n\r\n indices = [0, 0, 0, 0];\r\n weights = [0, 0, 0, 0];\r\n\r\n let index = 0;\r\n for (let i = 0; i < 4; ++i) {\r\n if (v0Weights[mat0Index + i] > 0) {\r\n const idx = indexOf(v1Indices, v0Indices[mat0Index + i], mat1Index, 4);\r\n indices[index] = v0Indices[mat0Index + i];\r\n weights[index] = Scalar.Lerp(v0Weights[mat0Index + i], idx >= 0 ? v1Weights[idx] : 0, clipFactor);\r\n index++;\r\n }\r\n }\r\n\r\n for (let i = 0; i < 4 && index < 4; ++i) {\r\n const ind = v1Indices[mat1Index + i];\r\n if (indexOf(v0Indices, ind, mat0Index, 4) !== -1) continue;\r\n\r\n indices[index] = ind;\r\n weights[index] = Scalar.Lerp(0, v1Weights[mat1Index + i], clipFactor);\r\n index++;\r\n }\r\n\r\n const sumw = weights[0] + weights[1] + weights[2] + weights[3];\r\n\r\n weights[0] /= sumw;\r\n weights[1] /= sumw;\r\n weights[2] /= sumw;\r\n weights[3] /= sumw;\r\n }\r\n\r\n const v0LocalPositionX = v0.localPositionOverride ? v0.localPositionOverride[0] : localPositions?.[v0.vertexIdx] ?? 0;\r\n const v0LocalPositionY = v0.localPositionOverride ? v0.localPositionOverride[1] : localPositions?.[v0.vertexIdx + 1] ?? 0;\r\n const v0LocalPositionZ = v0.localPositionOverride ? v0.localPositionOverride[2] : localPositions?.[v0.vertexIdx + 2] ?? 0;\r\n\r\n const v1LocalPositionX = v1.localPositionOverride ? v1.localPositionOverride[0] : localPositions?.[v1.vertexIdx] ?? 0;\r\n const v1LocalPositionY = v1.localPositionOverride ? v1.localPositionOverride[1] : localPositions?.[v1.vertexIdx + 1] ?? 0;\r\n const v1LocalPositionZ = v1.localPositionOverride ? v1.localPositionOverride[2] : localPositions?.[v1.vertexIdx + 2] ?? 0;\r\n\r\n const v0LocalNormalX = v0.localNormalOverride ? v0.localNormalOverride[0] : localNormals?.[v0.vertexIdx] ?? 0;\r\n const v0LocalNormalY = v0.localNormalOverride ? v0.localNormalOverride[1] : localNormals?.[v0.vertexIdx + 1] ?? 0;\r\n const v0LocalNormalZ = v0.localNormalOverride ? v0.localNormalOverride[2] : localNormals?.[v0.vertexIdx + 2] ?? 0;\r\n\r\n const v1LocalNormalX = v1.localNormalOverride ? v1.localNormalOverride[0] : localNormals?.[v1.vertexIdx] ?? 0;\r\n const v1LocalNormalY = v1.localNormalOverride ? v1.localNormalOverride[1] : localNormals?.[v1.vertexIdx + 1] ?? 0;\r\n const v1LocalNormalZ = v1.localNormalOverride ? v1.localNormalOverride[2] : localNormals?.[v1.vertexIdx + 2] ?? 0;\r\n\r\n const interpNormalX = v0LocalNormalX + (v1LocalNormalX - v0LocalNormalX) * clipFactor;\r\n const interpNormalY = v0LocalNormalY + (v1LocalNormalY - v0LocalNormalY) * clipFactor;\r\n const interpNormalZ = v0LocalNormalZ + (v1LocalNormalZ - v0LocalNormalZ) * clipFactor;\r\n\r\n const norm = Math.sqrt(interpNormalX * interpNormalX + interpNormalY * interpNormalY + interpNormalZ * interpNormalZ);\r\n\r\n return new DecalVertex(\r\n Vector3.Lerp(v0.position, v1.position, clipFactor),\r\n Vector3.Lerp(v0.normal, v1.normal, clipFactor).normalize(),\r\n Vector2.Lerp(v0.uv, v1.uv, clipFactor),\r\n -1,\r\n -1,\r\n localPositions\r\n ? [\r\n v0LocalPositionX + (v1LocalPositionX - v0LocalPositionX) * clipFactor,\r\n v0LocalPositionY + (v1LocalPositionY - v0LocalPositionY) * clipFactor,\r\n v0LocalPositionZ + (v1LocalPositionZ - v0LocalPositionZ) * clipFactor,\r\n ]\r\n : null,\r\n localNormals ? [interpNormalX / norm, interpNormalY / norm, interpNormalZ / norm] : null,\r\n indices,\r\n weights\r\n );\r\n };\r\n\r\n let clipResult: Nullable<DecalVertex[]> = null;\r\n\r\n if (vertices.length > 3) {\r\n clipResult = [] as DecalVertex[];\r\n }\r\n\r\n for (let index = 0; index < vertices.length; index += 3) {\r\n let total = 0;\r\n let nV1: Nullable<DecalVertex> = null;\r\n let nV2: Nullable<DecalVertex> = null;\r\n let nV3: Nullable<DecalVertex> = null;\r\n let nV4: Nullable<DecalVertex> = null;\r\n\r\n const d1 = Vector3.Dot(vertices[index].position, axis) - clipSize;\r\n const d2 = Vector3.Dot(vertices[index + 1].position, axis) - clipSize;\r\n const d3 = Vector3.Dot(vertices[index + 2].position, axis) - clipSize;\r\n\r\n const v1Out = d1 > 0;\r\n const v2Out = d2 > 0;\r\n const v3Out = d3 > 0;\r\n\r\n total = (v1Out ? 1 : 0) + (v2Out ? 1 : 0) + (v3Out ? 1 : 0);\r\n\r\n switch (total) {\r\n case 0:\r\n if (vertices.length > 3) {\r\n clipResult!.push(vertices[index]);\r\n clipResult!.push(vertices[index + 1]);\r\n clipResult!.push(vertices[index + 2]);\r\n } else {\r\n clipResult = vertices;\r\n }\r\n break;\r\n case 1:\r\n clipResult = clipResult ?? new Array<DecalVertex>();\r\n if (v1Out) {\r\n nV1 = vertices[index + 1];\r\n nV2 = vertices[index + 2];\r\n nV3 = clipVertices(vertices[index], nV1);\r\n nV4 = clipVertices(vertices[index], nV2);\r\n }\r\n\r\n if (v2Out) {\r\n nV1 = vertices[index];\r\n nV2 = vertices[index + 2];\r\n nV3 = clipVertices(vertices[index + 1], nV1);\r\n nV4 = clipVertices(vertices[index + 1], nV2);\r\n\r\n clipResult.push(nV3);\r\n clipResult.push(nV2.clone());\r\n clipResult.push(nV1.clone());\r\n\r\n clipResult.push(nV2.clone());\r\n clipResult.push(nV3.clone());\r\n clipResult.push(nV4);\r\n break;\r\n }\r\n if (v3Out) {\r\n nV1 = vertices[index];\r\n nV2 = vertices[index + 1];\r\n nV3 = clipVertices(vertices[index + 2], nV1);\r\n nV4 = clipVertices(vertices[index + 2], nV2);\r\n }\r\n\r\n if (nV1 && nV2 && nV3 && nV4) {\r\n clipResult.push(nV1.clone());\r\n clipResult.push(nV2.clone());\r\n clipResult.push(nV3);\r\n\r\n clipResult.push(nV4);\r\n clipResult.push(nV3.clone());\r\n clipResult.push(nV2.clone());\r\n }\r\n break;\r\n case 2:\r\n clipResult = clipResult ?? new Array<DecalVertex>();\r\n if (!v1Out) {\r\n nV1 = vertices[index].clone();\r\n nV2 = clipVertices(nV1, vertices[index + 1]);\r\n nV3 = clipVertices(nV1, vertices[index + 2]);\r\n clipResult.push(nV1);\r\n clipResult.push(nV2);\r\n clipResult.push(nV3);\r\n }\r\n if (!v2Out) {\r\n nV1 = vertices[index + 1].clone();\r\n nV2 = clipVertices(nV1, vertices[index + 2]);\r\n nV3 = clipVertices(nV1, vertices[index]);\r\n clipResult.push(nV1);\r\n clipResult.push(nV2);\r\n clipResult.push(nV3);\r\n }\r\n if (!v3Out) {\r\n nV1 = vertices[index + 2].clone();\r\n nV2 = clipVertices(nV1, vertices[index]);\r\n nV3 = clipVertices(nV1, vertices[index + 1]);\r\n clipResult.push(nV1);\r\n clipResult.push(nV2);\r\n clipResult.push(nV3);\r\n }\r\n break;\r\n case 3:\r\n break;\r\n }\r\n }\r\n\r\n return clipResult;\r\n };\r\n\r\n const sourceMeshAsMesh = sourceMesh instanceof Mesh ? sourceMesh : null;\r\n const matrixData = sourceMeshAsMesh?._thinInstanceDataStorage.matrixData;\r\n\r\n const numMatrices = sourceMeshAsMesh?.thinInstanceCount || 1;\r\n const thinInstanceMatrix = TmpVectors.Matrix[0];\r\n\r\n thinInstanceMatrix.copyFrom(Matrix.IdentityReadOnly);\r\n\r\n for (let m = 0; m < numMatrices; ++m) {\r\n if (sourceMeshAsMesh?.hasThinInstances && matrixData) {\r\n const ofst = m * 16;\r\n\r\n thinInstanceMatrix.setRowFromFloats(0, matrixData[ofst + 0], matrixData[ofst + 1], matrixData[ofst + 2], matrixData[ofst + 3]);\r\n thinInstanceMatrix.setRowFromFloats(1, matrixData[ofst + 4], matrixData[ofst + 5], matrixData[ofst + 6], matrixData[ofst + 7]);\r\n thinInstanceMatrix.setRowFromFloats(2, matrixData[ofst + 8], matrixData[ofst + 9], matrixData[ofst + 10], matrixData[ofst + 11]);\r\n thinInstanceMatrix.setRowFromFloats(3, matrixData[ofst + 12], matrixData[ofst + 13], matrixData[ofst + 14], matrixData[ofst + 15]);\r\n }\r\n\r\n // Matrix\r\n const decalWorldMatrix = Matrix.RotationYawPitchRoll(yaw, pitch, angle).multiply(Matrix.Translation(position.x, position.y, position.z));\r\n const inverseDecalWorldMatrix = Matrix.Invert(decalWorldMatrix);\r\n const meshWorldMatrix = sourceMesh.getWorldMatrix();\r\n const transformMatrix = thinInstanceMatrix.multiply(meshWorldMatrix).multiply(inverseDecalWorldMatrix);\r\n\r\n const oneFaceVertices = new Array<DecalVertex>(3);\r\n\r\n for (let index = 0; index < indices.length; index += 3) {\r\n let faceVertices: Nullable<DecalVertex[]> = oneFaceVertices;\r\n\r\n faceVertices[0] = extractDecalVector3(index, transformMatrix);\r\n if (useLocalComputation) {\r\n faceVertices[1] = extractDecalVector3(index + 2, transformMatrix);\r\n faceVertices[2] = extractDecalVector3(index + 1, transformMatrix);\r\n } else {\r\n faceVertices[1] = extractDecalVector3(index + 1, transformMatrix);\r\n faceVertices[2] = extractDecalVector3(index + 2, transformMatrix);\r\n }\r\n\r\n if (options.cullBackFaces) {\r\n // If all the normals of the vertices of the face are pointing away from the view direction we discard the face.\r\n // As computations are done in the decal coordinate space, the viewDirection is (0,0,1), so when dot(vertexNormal, -viewDirection) <= 0 the vertex is culled\r\n if (-faceVertices[0].normal.z <= 0 && -faceVertices[1].normal.z <= 0 && -faceVertices[2].normal.z <= 0) {\r\n continue;\r\n }\r\n }\r\n\r\n // Clip\r\n faceVertices = clip(faceVertices, xpAxis);\r\n if (!faceVertices) continue;\r\n faceVertices = clip(faceVertices, xnAxis);\r\n if (!faceVertices) continue;\r\n faceVertices = clip(faceVertices, ypAxis);\r\n if (!faceVertices) continue;\r\n faceVertices = clip(faceVertices, ynAxis);\r\n if (!faceVertices) continue;\r\n faceVertices = clip(faceVertices, zpAxis);\r\n if (!faceVertices) continue;\r\n faceVertices = clip(faceVertices, znAxis);\r\n if (!faceVertices) continue;\r\n\r\n // Add UVs and get back to world\r\n for (let vIndex = 0; vIndex < faceVertices.length; vIndex++) {\r\n const vertex = faceVertices[vIndex];\r\n\r\n //TODO check for Int32Array | Uint32Array | Uint16Array\r\n (<number[]>vertexData.indices).push(currentVertexDataIndex);\r\n if (useLocalComputation) {\r\n if (vertex.localPositionOverride) {\r\n vertexData.positions[currentVertexDataIndex * 3] = vertex.localPositionOverride[0];\r\n vertexData.positions[currentVertexDataIndex * 3 + 1] = vertex.localPositionOverride[1];\r\n vertexData.positions[currentVertexDataIndex * 3 + 2] = vertex.localPositionOverride[2];\r\n } else if (localPositions) {\r\n vertexData.positions[currentVertexDataIndex * 3] = localPositions[vertex.vertexIdx];\r\n vertexData.positions[currentVertexDataIndex * 3 + 1] = localPositions[vertex.vertexIdx + 1];\r\n vertexData.positions[currentVertexDataIndex * 3 + 2] = localPositions[vertex.vertexIdx + 2];\r\n }\r\n if (vertex.localNormalOverride) {\r\n vertexData.normals[currentVertexDataIndex * 3] = vertex.localNormalOverride[0];\r\n vertexData.normals[currentVertexDataIndex * 3 + 1] = vertex.localNormalOverride[1];\r\n vertexData.normals[currentVertexDataIndex * 3 + 2] = vertex.localNormalOverride[2];\r\n } else if (localNormals) {\r\n vertexData.normals[currentVertexDataIndex * 3] = localNormals[vertex.vertexIdx];\r\n vertexData.normals[currentVertexDataIndex * 3 + 1] = localNormals[vertex.vertexIdx + 1];\r\n vertexData.normals[currentVertexDataIndex * 3 + 2] = localNormals[vertex.vertexIdx + 2];\r\n }\r\n } else {\r\n vertex.position.toArray(vertexData.positions, currentVertexDataIndex * 3);\r\n vertex.normal.toArray(vertexData.normals, currentVertexDataIndex * 3);\r\n }\r\n if (vertexData.matricesIndices && vertexData.matricesWeights) {\r\n if (vertex.matrixIndicesOverride) {\r\n vertexData.matricesIndices[currentVertexDataIndex * 4] = vertex.matrixIndicesOverride[0];\r\n vertexData.matricesIndices[currentVertexDataIndex * 4 + 1] = vertex.matrixIndicesOverride[1];\r\n vertexData.matricesIndices[currentVertexDataIndex * 4 + 2] = vertex.matrixIndicesOverride[2];\r\n vertexData.matricesIndices[currentVertexDataIndex * 4 + 3] = vertex.matrixIndicesOverride[3];\r\n } else {\r\n if (matIndices) {\r\n vertexData.matricesIndices[currentVertexDataIndex * 4] = matIndices[vertex.vertexIdxForBones];\r\n vertexData.matricesIndices[currentVertexDataIndex * 4 + 1] = matIndices[vertex.vertexIdxForBones + 1];\r\n vertexData.matricesIndices[currentVertexDataIndex * 4 + 2] = matIndices[vertex.vertexIdxForBones + 2];\r\n vertexData.matricesIndices[currentVertexDataIndex * 4 + 3] = matIndices[vertex.vertexIdxForBones + 3];\r\n }\r\n if (matIndicesExtra && vertexData.matricesIndicesExtra) {\r\n vertexData.matricesIndicesExtra[currentVertexDataIndex * 4] = matIndicesExtra[vertex.vertexIdxForBones];\r\n vertexData.matricesIndicesExtra[currentVertexDataIndex * 4 + 1] = matIndicesExtra[vertex.vertexIdxForBones + 1];\r\n vertexData.matricesIndicesExtra[currentVertexDataIndex * 4 + 2] = matIndicesExtra[vertex.vertexIdxForBones + 2];\r\n vertexData.matricesIndicesExtra[currentVertexDataIndex * 4 + 3] = matIndicesExtra[vertex.vertexIdxForBones + 3];\r\n }\r\n }\r\n if (vertex.matrixWeightsOverride) {\r\n vertexData.matricesWeights[currentVertexDataIndex * 4] = vertex.matrixWeightsOverride[0];\r\n vertexData.matricesWeights[currentVertexDataIndex * 4 + 1] = vertex.matrixWeightsOverride[1];\r\n vertexData.matricesWeights[currentVertexDataIndex * 4 + 2] = vertex.matrixWeightsOverride[2];\r\n vertexData.matricesWeights[currentVertexDataIndex * 4 + 3] = vertex.matrixWeightsOverride[3];\r\n } else {\r\n if (matWeights) {\r\n vertexData.matricesWeights[currentVertexDataIndex * 4] = matWeights[vertex.vertexIdxForBones];\r\n vertexData.matricesWeights[currentVertexDataIndex * 4 + 1] = matWeights[vertex.vertexIdxForBones + 1];\r\n vertexData.matricesWeights[currentVertexDataIndex * 4 + 2] = matWeights[vertex.vertexIdxForBones + 2];\r\n vertexData.matricesWeights[currentVertexDataIndex * 4 + 3] = matWeights[vertex.vertexIdxForBones + 3];\r\n }\r\n if (matWeightsExtra && vertexData.matricesWeightsExtra) {\r\n vertexData.matricesWeightsExtra[currentVertexDataIndex * 4] = matWeightsExtra[vertex.vertexIdxForBones];\r\n vertexData.matricesWeightsExtra[currentVertexDataIndex * 4 + 1] = matWeightsExtra[vertex.vertexIdxForBones + 1];\r\n vertexData.matricesWeightsExtra[currentVertexDataIndex * 4 + 2] = matWeightsExtra[vertex.vertexIdxForBones + 2];\r\n vertexData.matricesWeightsExtra[currentVertexDataIndex * 4 + 3] = matWeightsExtra[vertex.vertexIdxForBones + 3];\r\n }\r\n }\r\n }\r\n\r\n if (!options.captureUVS) {\r\n (<number[]>vertexData.uvs).push(0.5 + vertex.position.x / size.x);\r\n const v = 0.5 + vertex.position.y / size.y;\r\n (<number[]>vertexData.uvs).push(CompatibilityOptions.UseOpenGLOrientationForUV ? 1 - v : v);\r\n } else {\r\n vertex.uv.toArray(vertexData.uvs, currentVertexDataIndex * 2);\r\n }\r\n currentVertexDataIndex++;\r\n }\r\n }\r\n }\r\n\r\n // Avoid the \"Setting vertex data kind 'XXX' with an empty array\" warning when calling vertexData.applyToMesh\r\n if (vertexData.indices.length === 0) vertexData.indices = null;\r\n if (vertexData.positions.length === 0) vertexData.positions = null;\r\n if (vertexData.normals.length === 0) vertexData.normals = null;\r\n if (vertexData.uvs.length === 0) vertexData.uvs = null;\r\n if (vertexData.matricesIndices?.length === 0) vertexData.matricesIndices = null;\r\n if (vertexData.matricesWeights?.length === 0) vertexData.matricesWeights = null;\r\n if (vertexData.matricesIndicesExtra?.length === 0) vertexData.matricesIndicesExtra = null;\r\n if (vertexData.matricesWeightsExtra?.length === 0) vertexData.matricesWeightsExtra = null;\r\n\r\n // Return mesh\r\n const decal = new Mesh(name, sourceMesh.getScene());\r\n vertexData.applyToMesh(decal);\r\n\r\n if (useLocalComputation) {\r\n decal.skeleton = sourceMesh.skeleton;\r\n decal.parent = sourceMesh;\r\n } else {\r\n decal.position = position.clone();\r\n decal.rotation = new Vector3(pitch, yaw, angle);\r\n }\r\n\r\n decal.computeWorldMatrix(true);\r\n decal.refreshBoundingInfo(true, true);\r\n\r\n return decal;\r\n}\r\n\r\n/**\r\n * Class containing static functions to help procedurally build meshes\r\n * @deprecated use the function directly from the module\r\n */\r\nexport const DecalBuilder = {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n CreateDecal,\r\n};\r\n\r\nMesh.CreateDecal = (name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh => {\r\n const options = {\r\n position,\r\n normal,\r\n size,\r\n angle,\r\n };\r\n\r\n return CreateDecal(name, sourceMesh, options);\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"decalBuilder.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Builders/decalBuilder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO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,KAAK,CAAC;QAAE,UAAU,CAAC,oBAAoB,GAAG,IAAI,CAAC;IAE1F,cAAc;IACd,MAAM,KAAK,GAAG,IAAI,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAC;IACpD,UAAU,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IAE9B,IAAI,mBAAmB,EAAE;QACrB,KAAK,CAAC,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC;QACrC,KAAK,CAAC,MAAM,GAAG,UAAU,CAAC;KAC7B;SAAM;QACH,KAAK,CAAC,QAAQ,GAAG,QAAQ,CAAC,KAAK,EAAE,CAAC;QAClC,KAAK,CAAC,QAAQ,GAAG,IAAI,OAAO,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;KACnD;IAED,KAAK,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAC/B,KAAK,CAAC,mBAAmB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAEtC,OAAO,KAAK,CAAC;AACjB,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IACxB,gEAAgE;IAChE,WAAW;CACd,CAAC;AAEF,IAAI,CAAC,WAAW,GAAG,CAAC,IAAY,EAAE,UAAwB,EAAE,QAAiB,EAAE,MAAe,EAAE,IAAa,EAAE,KAAa,EAAQ,EAAE;IAClI,MAAM,OAAO,GAAG;QACZ,QAAQ;QACR,MAAM;QACN,IAAI;QACJ,KAAK;KACR,CAAC;IAEF,OAAO,WAAW,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;AAClD,CAAC,CAAC","sourcesContent":["import type { Nullable, IndicesArray, FloatArray } from \"../../types\";\r\nimport { Vector3, Matrix, Vector2, TmpVectors } from \"../../Maths/math.vector\";\r\nimport { Scalar } from \"../../Maths/math.scalar\";\r\nimport { Mesh } from \"../mesh\";\r\nimport { VertexBuffer } from \"../../Buffers/buffer\";\r\nimport { VertexData } from \"../mesh.vertexData\";\r\nimport type { AbstractMesh } from \"../abstractMesh\";\r\nimport type { Camera } from \"../../Cameras/camera\";\r\nimport { CompatibilityOptions } from \"../../Compat/compatibilityOptions\";\r\n\r\nconst xpAxis = new Vector3(1, 0, 0);\r\nconst xnAxis = new Vector3(-1, 0, 0);\r\nconst ypAxis = new Vector3(0, 1, 0);\r\nconst ynAxis = new Vector3(0, -1, 0);\r\nconst zpAxis = new Vector3(0, 0, 1);\r\nconst znAxis = new Vector3(0, 0, -1);\r\n\r\n/** @internal */\r\nclass DecalVertex {\r\n constructor(\r\n public position: Vector3 = Vector3.Zero(),\r\n public normal: Vector3 = Vector3.Up(),\r\n public uv: Vector2 = Vector2.Zero(),\r\n public vertexIdx: number = 0,\r\n public vertexIdxForBones: number = 0,\r\n public localPositionOverride: Nullable<number[]> = null,\r\n public localNormalOverride: Nullable<number[]> = null,\r\n public matrixIndicesOverride: Nullable<number[]> = null,\r\n public matrixWeightsOverride: Nullable<number[]> = null\r\n ) {}\r\n public clone(): DecalVertex {\r\n return new DecalVertex(\r\n this.position.clone(),\r\n this.normal.clone(),\r\n this.uv.clone(),\r\n this.vertexIdx,\r\n this.vertexIdxForBones,\r\n this.localPositionOverride?.slice(),\r\n this.localNormalOverride?.slice(),\r\n this.matrixIndicesOverride?.slice(),\r\n this.matrixWeightsOverride?.slice()\r\n );\r\n }\r\n}\r\n\r\n/**\r\n * Creates a decal mesh.\r\n * A decal is a mesh usually applied as a model onto the surface of another mesh. So don't forget the parameter `sourceMesh` depicting the decal\r\n * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates\r\n * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates\r\n * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling\r\n * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal\r\n * * The parameter `captureUVS` defines if we need to capture the uvs or compute them\r\n * * The parameter `cullBackFaces` defines if the back faces should be removed from the decal mesh\r\n * * The parameter `localMode` defines that the computations should be done with the local mesh coordinates instead of the world space coordinates.\r\n * * Use this mode if you want the decal to be parented to the sourceMesh and move/rotate with it.\r\n * Note: Meshes with morph targets are not supported!\r\n * @param name defines the name of the mesh\r\n * @param sourceMesh defines the mesh where the decal must be applied\r\n * @param options defines the options used to create the mesh\r\n * @returns the decal mesh\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/decals\r\n */\r\nexport function CreateDecal(\r\n name: string,\r\n sourceMesh: AbstractMesh,\r\n options: { position?: Vector3; normal?: Vector3; size?: Vector3; angle?: number; captureUVS?: boolean; cullBackFaces?: boolean; localMode?: boolean }\r\n): Mesh {\r\n const hasSkeleton = !!sourceMesh.skeleton;\r\n const useLocalComputation = options.localMode || hasSkeleton;\r\n\r\n const indices = <IndicesArray>sourceMesh.getIndices();\r\n const positions = hasSkeleton ? sourceMesh.getPositionData(true, true) : sourceMesh.getVerticesData(VertexBuffer.PositionKind);\r\n const normals = hasSkeleton ? sourceMesh.getNormalsData(true, true) : sourceMesh.getVerticesData(VertexBuffer.NormalKind);\r\n const localPositions = useLocalComputation ? (hasSkeleton ? sourceMesh.getVerticesData(VertexBuffer.PositionKind) : positions) : null;\r\n const localNormals = useLocalComputation ? (hasSkeleton ? sourceMesh.getVerticesData(VertexBuffer.NormalKind) : normals) : null;\r\n const uvs = sourceMesh.getVerticesData(VertexBuffer.UVKind);\r\n const matIndices = hasSkeleton ? sourceMesh.getVerticesData(VertexBuffer.MatricesIndicesKind) : null;\r\n const matWeights = hasSkeleton ? sourceMesh.getVerticesData(VertexBuffer.MatricesWeightsKind) : null;\r\n const matIndicesExtra = hasSkeleton ? sourceMesh.getVerticesData(VertexBuffer.MatricesIndicesExtraKind) : null;\r\n const matWeightsExtra = hasSkeleton ? sourceMesh.getVerticesData(VertexBuffer.MatricesWeightsExtraKind) : null;\r\n\r\n const position = options.position || Vector3.Zero();\r\n let normal = options.normal || Vector3.Up();\r\n const size = options.size || Vector3.One();\r\n const angle = options.angle || 0;\r\n\r\n // Getting correct rotation\r\n if (!normal) {\r\n const target = new Vector3(0, 0, 1);\r\n const camera = <Camera>sourceMesh.getScene().activeCamera;\r\n const cameraWorldTarget = Vector3.TransformCoordinates(target, camera.getWorldMatrix());\r\n\r\n normal = camera.globalPosition.subtract(cameraWorldTarget);\r\n }\r\n\r\n const yaw = -Math.atan2(normal.z, normal.x) - Math.PI / 2;\r\n const len = Math.sqrt(normal.x * normal.x + normal.z * normal.z);\r\n const pitch = Math.atan2(normal.y, len);\r\n\r\n const vertexData = new VertexData();\r\n vertexData.indices = [];\r\n vertexData.positions = [];\r\n vertexData.normals = [];\r\n vertexData.uvs = [];\r\n vertexData.matricesIndices = hasSkeleton ? [] : null;\r\n vertexData.matricesWeights = hasSkeleton ? [] : null;\r\n vertexData.matricesIndicesExtra = matIndicesExtra ? [] : null;\r\n vertexData.matricesWeightsExtra = matWeightsExtra ? [] : null;\r\n\r\n let currentVertexDataIndex = 0;\r\n\r\n const extractDecalVector3 = (indexId: number, transformMatrix: Matrix): DecalVertex => {\r\n const result = new DecalVertex();\r\n if (!indices || !positions || !normals) {\r\n return result;\r\n }\r\n\r\n const vertexId = indices[indexId];\r\n\r\n result.vertexIdx = vertexId * 3;\r\n result.vertexIdxForBones = vertexId * 4;\r\n\r\n // Send vector to decal local world\r\n result.position = new Vector3(positions[vertexId * 3], positions[vertexId * 3 + 1], positions[vertexId * 3 + 2]);\r\n Vector3.TransformCoordinatesToRef(result.position, transformMatrix, result.position);\r\n\r\n // Get normal\r\n result.normal = new Vector3(normals[vertexId * 3], normals[vertexId * 3 + 1], normals[vertexId * 3 + 2]);\r\n Vector3.TransformNormalToRef(result.normal, transformMatrix, result.normal);\r\n\r\n if (options.captureUVS && uvs) {\r\n const v = uvs[vertexId * 2 + 1];\r\n result.uv = new Vector2(uvs[vertexId * 2], CompatibilityOptions.UseOpenGLOrientationForUV ? 1 - v : v);\r\n }\r\n\r\n return result;\r\n };\r\n\r\n const emptyArray = [0, 0, 0, 0];\r\n\r\n // Inspired by https://github.com/mrdoob/three.js/blob/eee231960882f6f3b6113405f524956145148146/examples/js/geometries/DecalGeometry.js\r\n const clip = (vertices: DecalVertex[], axis: Vector3): Nullable<DecalVertex[]> => {\r\n if (vertices.length === 0) {\r\n return vertices;\r\n }\r\n\r\n const clipSize = 0.5 * Math.abs(Vector3.Dot(size, axis));\r\n\r\n const indexOf = (arr: FloatArray | number[], val: number, start: number, num: number) => {\r\n for (let i = 0; i < num; ++i) {\r\n if (arr[start + i] === val) {\r\n return start + i;\r\n }\r\n }\r\n return -1;\r\n };\r\n\r\n const clipVertices = (v0: DecalVertex, v1: DecalVertex): DecalVertex => {\r\n const clipFactor = Vector3.GetClipFactor(v0.position, v1.position, axis, clipSize);\r\n\r\n let indices = emptyArray;\r\n let weights = emptyArray;\r\n\r\n if (matIndices && matWeights) {\r\n const mat0Index = v0.matrixIndicesOverride ? 0 : v0.vertexIdxForBones;\r\n const v0Indices = v0.matrixIndicesOverride ?? matIndices;\r\n const v0Weights = v0.matrixWeightsOverride ?? matWeights;\r\n\r\n const mat1Index = v1.matrixIndicesOverride ? 0 : v1.vertexIdxForBones;\r\n const v1Indices = v1.matrixIndicesOverride ?? matIndices;\r\n const v1Weights = v1.matrixWeightsOverride ?? matWeights;\r\n\r\n indices = [0, 0, 0, 0];\r\n weights = [0, 0, 0, 0];\r\n\r\n let index = 0;\r\n for (let i = 0; i < 4; ++i) {\r\n if (v0Weights[mat0Index + i] > 0) {\r\n const idx = indexOf(v1Indices, v0Indices[mat0Index + i], mat1Index, 4);\r\n indices[index] = v0Indices[mat0Index + i];\r\n weights[index] = Scalar.Lerp(v0Weights[mat0Index + i], idx >= 0 ? v1Weights[idx] : 0, clipFactor);\r\n index++;\r\n }\r\n }\r\n\r\n for (let i = 0; i < 4 && index < 4; ++i) {\r\n const ind = v1Indices[mat1Index + i];\r\n if (indexOf(v0Indices, ind, mat0Index, 4) !== -1) continue;\r\n\r\n indices[index] = ind;\r\n weights[index] = Scalar.Lerp(0, v1Weights[mat1Index + i], clipFactor);\r\n index++;\r\n }\r\n\r\n const sumw = weights[0] + weights[1] + weights[2] + weights[3];\r\n\r\n weights[0] /= sumw;\r\n weights[1] /= sumw;\r\n weights[2] /= sumw;\r\n weights[3] /= sumw;\r\n }\r\n\r\n const v0LocalPositionX = v0.localPositionOverride ? v0.localPositionOverride[0] : (localPositions?.[v0.vertexIdx] ?? 0);\r\n const v0LocalPositionY = v0.localPositionOverride ? v0.localPositionOverride[1] : (localPositions?.[v0.vertexIdx + 1] ?? 0);\r\n const v0LocalPositionZ = v0.localPositionOverride ? v0.localPositionOverride[2] : (localPositions?.[v0.vertexIdx + 2] ?? 0);\r\n\r\n const v1LocalPositionX = v1.localPositionOverride ? v1.localPositionOverride[0] : (localPositions?.[v1.vertexIdx] ?? 0);\r\n const v1LocalPositionY = v1.localPositionOverride ? v1.localPositionOverride[1] : (localPositions?.[v1.vertexIdx + 1] ?? 0);\r\n const v1LocalPositionZ = v1.localPositionOverride ? v1.localPositionOverride[2] : (localPositions?.[v1.vertexIdx + 2] ?? 0);\r\n\r\n const v0LocalNormalX = v0.localNormalOverride ? v0.localNormalOverride[0] : (localNormals?.[v0.vertexIdx] ?? 0);\r\n const v0LocalNormalY = v0.localNormalOverride ? v0.localNormalOverride[1] : (localNormals?.[v0.vertexIdx + 1] ?? 0);\r\n const v0LocalNormalZ = v0.localNormalOverride ? v0.localNormalOverride[2] : (localNormals?.[v0.vertexIdx + 2] ?? 0);\r\n\r\n const v1LocalNormalX = v1.localNormalOverride ? v1.localNormalOverride[0] : (localNormals?.[v1.vertexIdx] ?? 0);\r\n const v1LocalNormalY = v1.localNormalOverride ? v1.localNormalOverride[1] : (localNormals?.[v1.vertexIdx + 1] ?? 0);\r\n const v1LocalNormalZ = v1.localNormalOverride ? v1.localNormalOverride[2] : (localNormals?.[v1.vertexIdx + 2] ?? 0);\r\n\r\n const interpNormalX = v0LocalNormalX + (v1LocalNormalX - v0LocalNormalX) * clipFactor;\r\n const interpNormalY = v0LocalNormalY + (v1LocalNormalY - v0LocalNormalY) * clipFactor;\r\n const interpNormalZ = v0LocalNormalZ + (v1LocalNormalZ - v0LocalNormalZ) * clipFactor;\r\n\r\n const norm = Math.sqrt(interpNormalX * interpNormalX + interpNormalY * interpNormalY + interpNormalZ * interpNormalZ);\r\n\r\n return new DecalVertex(\r\n Vector3.Lerp(v0.position, v1.position, clipFactor),\r\n Vector3.Lerp(v0.normal, v1.normal, clipFactor).normalize(),\r\n Vector2.Lerp(v0.uv, v1.uv, clipFactor),\r\n -1,\r\n -1,\r\n localPositions\r\n ? [\r\n v0LocalPositionX + (v1LocalPositionX - v0LocalPositionX) * clipFactor,\r\n v0LocalPositionY + (v1LocalPositionY - v0LocalPositionY) * clipFactor,\r\n v0LocalPositionZ + (v1LocalPositionZ - v0LocalPositionZ) * clipFactor,\r\n ]\r\n : null,\r\n localNormals ? [interpNormalX / norm, interpNormalY / norm, interpNormalZ / norm] : null,\r\n indices,\r\n weights\r\n );\r\n };\r\n\r\n let clipResult: Nullable<DecalVertex[]> = null;\r\n\r\n if (vertices.length > 3) {\r\n clipResult = [] as DecalVertex[];\r\n }\r\n\r\n for (let index = 0; index < vertices.length; index += 3) {\r\n let total = 0;\r\n let nV1: Nullable<DecalVertex> = null;\r\n let nV2: Nullable<DecalVertex> = null;\r\n let nV3: Nullable<DecalVertex> = null;\r\n let nV4: Nullable<DecalVertex> = null;\r\n\r\n const d1 = Vector3.Dot(vertices[index].position, axis) - clipSize;\r\n const d2 = Vector3.Dot(vertices[index + 1].position, axis) - clipSize;\r\n const d3 = Vector3.Dot(vertices[index + 2].position, axis) - clipSize;\r\n\r\n const v1Out = d1 > 0;\r\n const v2Out = d2 > 0;\r\n const v3Out = d3 > 0;\r\n\r\n total = (v1Out ? 1 : 0) + (v2Out ? 1 : 0) + (v3Out ? 1 : 0);\r\n\r\n switch (total) {\r\n case 0:\r\n if (vertices.length > 3) {\r\n clipResult!.push(vertices[index]);\r\n clipResult!.push(vertices[index + 1]);\r\n clipResult!.push(vertices[index + 2]);\r\n } else {\r\n clipResult = vertices;\r\n }\r\n break;\r\n case 1:\r\n clipResult = clipResult ?? new Array<DecalVertex>();\r\n if (v1Out) {\r\n nV1 = vertices[index + 1];\r\n nV2 = vertices[index + 2];\r\n nV3 = clipVertices(vertices[index], nV1);\r\n nV4 = clipVertices(vertices[index], nV2);\r\n }\r\n\r\n if (v2Out) {\r\n nV1 = vertices[index];\r\n nV2 = vertices[index + 2];\r\n nV3 = clipVertices(vertices[index + 1], nV1);\r\n nV4 = clipVertices(vertices[index + 1], nV2);\r\n\r\n clipResult.push(nV3);\r\n clipResult.push(nV2.clone());\r\n clipResult.push(nV1.clone());\r\n\r\n clipResult.push(nV2.clone());\r\n clipResult.push(nV3.clone());\r\n clipResult.push(nV4);\r\n break;\r\n }\r\n if (v3Out) {\r\n nV1 = vertices[index];\r\n nV2 = vertices[index + 1];\r\n nV3 = clipVertices(vertices[index + 2], nV1);\r\n nV4 = clipVertices(vertices[index + 2], nV2);\r\n }\r\n\r\n if (nV1 && nV2 && nV3 && nV4) {\r\n clipResult.push(nV1.clone());\r\n clipResult.push(nV2.clone());\r\n clipResult.push(nV3);\r\n\r\n clipResult.push(nV4);\r\n clipResult.push(nV3.clone());\r\n clipResult.push(nV2.clone());\r\n }\r\n break;\r\n case 2:\r\n clipResult = clipResult ?? new Array<DecalVertex>();\r\n if (!v1Out) {\r\n nV1 = vertices[index].clone();\r\n nV2 = clipVertices(nV1, vertices[index + 1]);\r\n nV3 = clipVertices(nV1, vertices[index + 2]);\r\n clipResult.push(nV1);\r\n clipResult.push(nV2);\r\n clipResult.push(nV3);\r\n }\r\n if (!v2Out) {\r\n nV1 = vertices[index + 1].clone();\r\n nV2 = clipVertices(nV1, vertices[index + 2]);\r\n nV3 = clipVertices(nV1, vertices[index]);\r\n clipResult.push(nV1);\r\n clipResult.push(nV2);\r\n clipResult.push(nV3);\r\n }\r\n if (!v3Out) {\r\n nV1 = vertices[index + 2].clone();\r\n nV2 = clipVertices(nV1, vertices[index]);\r\n nV3 = clipVertices(nV1, vertices[index + 1]);\r\n clipResult.push(nV1);\r\n clipResult.push(nV2);\r\n clipResult.push(nV3);\r\n }\r\n break;\r\n case 3:\r\n break;\r\n }\r\n }\r\n\r\n return clipResult;\r\n };\r\n\r\n const sourceMeshAsMesh = sourceMesh instanceof Mesh ? sourceMesh : null;\r\n const matrixData = sourceMeshAsMesh?._thinInstanceDataStorage.matrixData;\r\n\r\n const numMatrices = sourceMeshAsMesh?.thinInstanceCount || 1;\r\n const thinInstanceMatrix = TmpVectors.Matrix[0];\r\n\r\n thinInstanceMatrix.copyFrom(Matrix.IdentityReadOnly);\r\n\r\n for (let m = 0; m < numMatrices; ++m) {\r\n if (sourceMeshAsMesh?.hasThinInstances && matrixData) {\r\n const ofst = m * 16;\r\n\r\n thinInstanceMatrix.setRowFromFloats(0, matrixData[ofst + 0], matrixData[ofst + 1], matrixData[ofst + 2], matrixData[ofst + 3]);\r\n thinInstanceMatrix.setRowFromFloats(1, matrixData[ofst + 4], matrixData[ofst + 5], matrixData[ofst + 6], matrixData[ofst + 7]);\r\n thinInstanceMatrix.setRowFromFloats(2, matrixData[ofst + 8], matrixData[ofst + 9], matrixData[ofst + 10], matrixData[ofst + 11]);\r\n thinInstanceMatrix.setRowFromFloats(3, matrixData[ofst + 12], matrixData[ofst + 13], matrixData[ofst + 14], matrixData[ofst + 15]);\r\n }\r\n\r\n // Matrix\r\n const decalWorldMatrix = Matrix.RotationYawPitchRoll(yaw, pitch, angle).multiply(Matrix.Translation(position.x, position.y, position.z));\r\n const inverseDecalWorldMatrix = Matrix.Invert(decalWorldMatrix);\r\n const meshWorldMatrix = sourceMesh.getWorldMatrix();\r\n const transformMatrix = thinInstanceMatrix.multiply(meshWorldMatrix).multiply(inverseDecalWorldMatrix);\r\n\r\n const oneFaceVertices = new Array<DecalVertex>(3);\r\n\r\n for (let index = 0; index < indices.length; index += 3) {\r\n let faceVertices: Nullable<DecalVertex[]> = oneFaceVertices;\r\n\r\n faceVertices[0] = extractDecalVector3(index, transformMatrix);\r\n if (useLocalComputation) {\r\n faceVertices[1] = extractDecalVector3(index + 2, transformMatrix);\r\n faceVertices[2] = extractDecalVector3(index + 1, transformMatrix);\r\n } else {\r\n faceVertices[1] = extractDecalVector3(index + 1, transformMatrix);\r\n faceVertices[2] = extractDecalVector3(index + 2, transformMatrix);\r\n }\r\n\r\n if (options.cullBackFaces) {\r\n // If all the normals of the vertices of the face are pointing away from the view direction we discard the face.\r\n // As computations are done in the decal coordinate space, the viewDirection is (0,0,1), so when dot(vertexNormal, -viewDirection) <= 0 the vertex is culled\r\n if (-faceVertices[0].normal.z <= 0 && -faceVertices[1].normal.z <= 0 && -faceVertices[2].normal.z <= 0) {\r\n continue;\r\n }\r\n }\r\n\r\n // Clip\r\n faceVertices = clip(faceVertices, xpAxis);\r\n if (!faceVertices) continue;\r\n faceVertices = clip(faceVertices, xnAxis);\r\n if (!faceVertices) continue;\r\n faceVertices = clip(faceVertices, ypAxis);\r\n if (!faceVertices) continue;\r\n faceVertices = clip(faceVertices, ynAxis);\r\n if (!faceVertices) continue;\r\n faceVertices = clip(faceVertices, zpAxis);\r\n if (!faceVertices) continue;\r\n faceVertices = clip(faceVertices, znAxis);\r\n if (!faceVertices) continue;\r\n\r\n // Add UVs and get back to world\r\n for (let vIndex = 0; vIndex < faceVertices.length; vIndex++) {\r\n const vertex = faceVertices[vIndex];\r\n\r\n //TODO check for Int32Array | Uint32Array | Uint16Array\r\n (<number[]>vertexData.indices).push(currentVertexDataIndex);\r\n if (useLocalComputation) {\r\n if (vertex.localPositionOverride) {\r\n vertexData.positions[currentVertexDataIndex * 3] = vertex.localPositionOverride[0];\r\n vertexData.positions[currentVertexDataIndex * 3 + 1] = vertex.localPositionOverride[1];\r\n vertexData.positions[currentVertexDataIndex * 3 + 2] = vertex.localPositionOverride[2];\r\n } else if (localPositions) {\r\n vertexData.positions[currentVertexDataIndex * 3] = localPositions[vertex.vertexIdx];\r\n vertexData.positions[currentVertexDataIndex * 3 + 1] = localPositions[vertex.vertexIdx + 1];\r\n vertexData.positions[currentVertexDataIndex * 3 + 2] = localPositions[vertex.vertexIdx + 2];\r\n }\r\n if (vertex.localNormalOverride) {\r\n vertexData.normals[currentVertexDataIndex * 3] = vertex.localNormalOverride[0];\r\n vertexData.normals[currentVertexDataIndex * 3 + 1] = vertex.localNormalOverride[1];\r\n vertexData.normals[currentVertexDataIndex * 3 + 2] = vertex.localNormalOverride[2];\r\n } else if (localNormals) {\r\n vertexData.normals[currentVertexDataIndex * 3] = localNormals[vertex.vertexIdx];\r\n vertexData.normals[currentVertexDataIndex * 3 + 1] = localNormals[vertex.vertexIdx + 1];\r\n vertexData.normals[currentVertexDataIndex * 3 + 2] = localNormals[vertex.vertexIdx + 2];\r\n }\r\n } else {\r\n vertex.position.toArray(vertexData.positions, currentVertexDataIndex * 3);\r\n vertex.normal.toArray(vertexData.normals, currentVertexDataIndex * 3);\r\n }\r\n if (vertexData.matricesIndices && vertexData.matricesWeights) {\r\n if (vertex.matrixIndicesOverride) {\r\n vertexData.matricesIndices[currentVertexDataIndex * 4] = vertex.matrixIndicesOverride[0];\r\n vertexData.matricesIndices[currentVertexDataIndex * 4 + 1] = vertex.matrixIndicesOverride[1];\r\n vertexData.matricesIndices[currentVertexDataIndex * 4 + 2] = vertex.matrixIndicesOverride[2];\r\n vertexData.matricesIndices[currentVertexDataIndex * 4 + 3] = vertex.matrixIndicesOverride[3];\r\n } else {\r\n if (matIndices) {\r\n vertexData.matricesIndices[currentVertexDataIndex * 4] = matIndices[vertex.vertexIdxForBones];\r\n vertexData.matricesIndices[currentVertexDataIndex * 4 + 1] = matIndices[vertex.vertexIdxForBones + 1];\r\n vertexData.matricesIndices[currentVertexDataIndex * 4 + 2] = matIndices[vertex.vertexIdxForBones + 2];\r\n vertexData.matricesIndices[currentVertexDataIndex * 4 + 3] = matIndices[vertex.vertexIdxForBones + 3];\r\n }\r\n if (matIndicesExtra && vertexData.matricesIndicesExtra) {\r\n vertexData.matricesIndicesExtra[currentVertexDataIndex * 4] = matIndicesExtra[vertex.vertexIdxForBones];\r\n vertexData.matricesIndicesExtra[currentVertexDataIndex * 4 + 1] = matIndicesExtra[vertex.vertexIdxForBones + 1];\r\n vertexData.matricesIndicesExtra[currentVertexDataIndex * 4 + 2] = matIndicesExtra[vertex.vertexIdxForBones + 2];\r\n vertexData.matricesIndicesExtra[currentVertexDataIndex * 4 + 3] = matIndicesExtra[vertex.vertexIdxForBones + 3];\r\n }\r\n }\r\n if (vertex.matrixWeightsOverride) {\r\n vertexData.matricesWeights[currentVertexDataIndex * 4] = vertex.matrixWeightsOverride[0];\r\n vertexData.matricesWeights[currentVertexDataIndex * 4 + 1] = vertex.matrixWeightsOverride[1];\r\n vertexData.matricesWeights[currentVertexDataIndex * 4 + 2] = vertex.matrixWeightsOverride[2];\r\n vertexData.matricesWeights[currentVertexDataIndex * 4 + 3] = vertex.matrixWeightsOverride[3];\r\n } else {\r\n if (matWeights) {\r\n vertexData.matricesWeights[currentVertexDataIndex * 4] = matWeights[vertex.vertexIdxForBones];\r\n vertexData.matricesWeights[currentVertexDataIndex * 4 + 1] = matWeights[vertex.vertexIdxForBones + 1];\r\n vertexData.matricesWeights[currentVertexDataIndex * 4 + 2] = matWeights[vertex.vertexIdxForBones + 2];\r\n vertexData.matricesWeights[currentVertexDataIndex * 4 + 3] = matWeights[vertex.vertexIdxForBones + 3];\r\n }\r\n if (matWeightsExtra && vertexData.matricesWeightsExtra) {\r\n vertexData.matricesWeightsExtra[currentVertexDataIndex * 4] = matWeightsExtra[vertex.vertexIdxForBones];\r\n vertexData.matricesWeightsExtra[currentVertexDataIndex * 4 + 1] = matWeightsExtra[vertex.vertexIdxForBones + 1];\r\n vertexData.matricesWeightsExtra[currentVertexDataIndex * 4 + 2] = matWeightsExtra[vertex.vertexIdxForBones + 2];\r\n vertexData.matricesWeightsExtra[currentVertexDataIndex * 4 + 3] = matWeightsExtra[vertex.vertexIdxForBones + 3];\r\n }\r\n }\r\n }\r\n\r\n if (!options.captureUVS) {\r\n (<number[]>vertexData.uvs).push(0.5 + vertex.position.x / size.x);\r\n const v = 0.5 + vertex.position.y / size.y;\r\n (<number[]>vertexData.uvs).push(CompatibilityOptions.UseOpenGLOrientationForUV ? 1 - v : v);\r\n } else {\r\n vertex.uv.toArray(vertexData.uvs, currentVertexDataIndex * 2);\r\n }\r\n currentVertexDataIndex++;\r\n }\r\n }\r\n }\r\n\r\n // Avoid the \"Setting vertex data kind 'XXX' with an empty array\" warning when calling vertexData.applyToMesh\r\n if (vertexData.indices.length === 0) vertexData.indices = null;\r\n if (vertexData.positions.length === 0) vertexData.positions = null;\r\n if (vertexData.normals.length === 0) vertexData.normals = null;\r\n if (vertexData.uvs.length === 0) vertexData.uvs = null;\r\n if (vertexData.matricesIndices?.length === 0) vertexData.matricesIndices = null;\r\n if (vertexData.matricesWeights?.length === 0) vertexData.matricesWeights = null;\r\n if (vertexData.matricesIndicesExtra?.length === 0) vertexData.matricesIndicesExtra = null;\r\n if (vertexData.matricesWeightsExtra?.length === 0) vertexData.matricesWeightsExtra = null;\r\n\r\n // Return mesh\r\n const decal = new Mesh(name, sourceMesh.getScene());\r\n vertexData.applyToMesh(decal);\r\n\r\n if (useLocalComputation) {\r\n decal.skeleton = sourceMesh.skeleton;\r\n decal.parent = sourceMesh;\r\n } else {\r\n decal.position = position.clone();\r\n decal.rotation = new Vector3(pitch, yaw, angle);\r\n }\r\n\r\n decal.computeWorldMatrix(true);\r\n decal.refreshBoundingInfo(true, true);\r\n\r\n return decal;\r\n}\r\n\r\n/**\r\n * Class containing static functions to help procedurally build meshes\r\n * @deprecated use the function directly from the module\r\n */\r\nexport const DecalBuilder = {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n CreateDecal,\r\n};\r\n\r\nMesh.CreateDecal = (name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh => {\r\n const options = {\r\n position,\r\n normal,\r\n size,\r\n angle,\r\n };\r\n\r\n return CreateDecal(name, sourceMesh, options);\r\n};\r\n"]}
|
|
@@ -15,11 +15,12 @@ export declare class GaussianSplattingMesh extends Mesh {
|
|
|
15
15
|
private _material;
|
|
16
16
|
private _depthMix;
|
|
17
17
|
private _canPostToWorker;
|
|
18
|
-
private
|
|
18
|
+
private _lastModelViewMatrix;
|
|
19
19
|
private _covariancesATexture;
|
|
20
20
|
private _covariancesBTexture;
|
|
21
21
|
private _centersTexture;
|
|
22
22
|
private _colorsTexture;
|
|
23
|
+
private _splatPositions;
|
|
23
24
|
/**
|
|
24
25
|
* Gets the covariancesA texture
|
|
25
26
|
*/
|
|
@@ -86,7 +87,15 @@ export declare class GaussianSplattingMesh extends Mesh {
|
|
|
86
87
|
* @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
|
|
87
88
|
*/
|
|
88
89
|
dispose(doNotRecurse?: boolean): void;
|
|
90
|
+
private _copyTextures;
|
|
91
|
+
/**
|
|
92
|
+
* Returns a new Mesh object generated from the current mesh properties.
|
|
93
|
+
* @param name is a string, the name given to the new mesh
|
|
94
|
+
* @returns a new Gaussian Splatting Mesh
|
|
95
|
+
*/
|
|
96
|
+
clone(name?: string): GaussianSplattingMesh;
|
|
89
97
|
private static _CreateWorker;
|
|
90
98
|
private _loadData;
|
|
99
|
+
private _instanciateWorker;
|
|
91
100
|
private _getTextureSize;
|
|
92
101
|
}
|
|
@@ -53,6 +53,7 @@ export class GaussianSplattingMesh extends Mesh {
|
|
|
53
53
|
this._covariancesBTexture = null;
|
|
54
54
|
this._centersTexture = null;
|
|
55
55
|
this._colorsTexture = null;
|
|
56
|
+
this._splatPositions = null;
|
|
56
57
|
const vertexData = new VertexData();
|
|
57
58
|
vertexData.positions = [-2, -2, 0, 2, -2, 0, 2, 2, 0, -2, 2, 0];
|
|
58
59
|
vertexData.indices = [0, 1, 2, 0, 2, 3];
|
|
@@ -60,7 +61,7 @@ export class GaussianSplattingMesh extends Mesh {
|
|
|
60
61
|
this.subMeshes = [];
|
|
61
62
|
new SubMesh(0, 0, 4, 0, 6, this);
|
|
62
63
|
this.setEnabled(false);
|
|
63
|
-
this.
|
|
64
|
+
this._lastModelViewMatrix = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
|
64
65
|
if (url) {
|
|
65
66
|
this.loadFileAsync(url);
|
|
66
67
|
}
|
|
@@ -94,11 +95,15 @@ export class GaussianSplattingMesh extends Mesh {
|
|
|
94
95
|
const frameId = this.getScene().getFrameId();
|
|
95
96
|
if (frameId !== this._frameIdLastUpdate && this._worker && this._scene.activeCamera && this._canPostToWorker) {
|
|
96
97
|
this.getWorldMatrix().multiplyToRef(this._scene.activeCamera.getViewMatrix(), this._modelViewMatrix);
|
|
97
|
-
|
|
98
|
+
TmpVectors.Vector3[0].set(this._lastModelViewMatrix[8], this._lastModelViewMatrix[9], this._lastModelViewMatrix[10]);
|
|
99
|
+
TmpVectors.Vector3[1].set(this._modelViewMatrix.m[8], this._modelViewMatrix.m[9], this._modelViewMatrix.m[10]);
|
|
100
|
+
TmpVectors.Vector3[0].normalize();
|
|
101
|
+
TmpVectors.Vector3[1].normalize();
|
|
102
|
+
const dot = Vector3.Dot(TmpVectors.Vector3[0], TmpVectors.Vector3[1]);
|
|
98
103
|
if (Math.abs(dot - 1) >= 0.01) {
|
|
99
104
|
this._frameIdLastUpdate = frameId;
|
|
100
105
|
this._canPostToWorker = false;
|
|
101
|
-
this.
|
|
106
|
+
this._lastModelViewMatrix = this._modelViewMatrix.m.slice(0);
|
|
102
107
|
this._worker.postMessage({ view: this._modelViewMatrix.m, depthMix: this._depthMix, useRightHandedSystem: this._scene.useRightHandedSystem }, [
|
|
103
108
|
this._depthMix.buffer,
|
|
104
109
|
]);
|
|
@@ -278,6 +283,32 @@ export class GaussianSplattingMesh extends Mesh {
|
|
|
278
283
|
this._worker = null;
|
|
279
284
|
super.dispose(doNotRecurse);
|
|
280
285
|
}
|
|
286
|
+
_copyTextures(source) {
|
|
287
|
+
this._covariancesATexture = source.covariancesATexture?.clone();
|
|
288
|
+
this._covariancesBTexture = source.covariancesBTexture?.clone();
|
|
289
|
+
this._centersTexture = source.centersTexture?.clone();
|
|
290
|
+
this._colorsTexture = source.colorsTexture?.clone();
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Returns a new Mesh object generated from the current mesh properties.
|
|
294
|
+
* @param name is a string, the name given to the new mesh
|
|
295
|
+
* @returns a new Gaussian Splatting Mesh
|
|
296
|
+
*/
|
|
297
|
+
clone(name = "") {
|
|
298
|
+
const newGS = new GaussianSplattingMesh(name, undefined, this.getScene());
|
|
299
|
+
newGS._copySource(this);
|
|
300
|
+
newGS.makeGeometryUnique();
|
|
301
|
+
newGS._vertexCount = this._vertexCount;
|
|
302
|
+
newGS._copyTextures(this);
|
|
303
|
+
newGS._modelViewMatrix = Matrix.Identity();
|
|
304
|
+
newGS._splatPositions = this._splatPositions;
|
|
305
|
+
newGS._instanciateWorker();
|
|
306
|
+
const binfo = this.getBoundingInfo();
|
|
307
|
+
newGS.getBoundingInfo().reConstruct(binfo.minimum, binfo.maximum, this.getWorldMatrix());
|
|
308
|
+
newGS.forcedInstanceCount = newGS._vertexCount;
|
|
309
|
+
newGS.setEnabled(true);
|
|
310
|
+
return newGS;
|
|
311
|
+
}
|
|
281
312
|
_loadData(data) {
|
|
282
313
|
if (!data.byteLength) {
|
|
283
314
|
return;
|
|
@@ -290,7 +321,7 @@ export class GaussianSplattingMesh extends Mesh {
|
|
|
290
321
|
this._vertexCount = vertexCount;
|
|
291
322
|
const textureSize = this._getTextureSize(vertexCount);
|
|
292
323
|
const textureLength = textureSize.x * textureSize.y;
|
|
293
|
-
|
|
324
|
+
this._splatPositions = new Float32Array(3 * textureLength);
|
|
294
325
|
const covA = new Float32Array(3 * textureLength);
|
|
295
326
|
const covB = new Float32Array(3 * textureLength);
|
|
296
327
|
const matrixRotation = TmpVectors.Matrix[0];
|
|
@@ -302,9 +333,9 @@ export class GaussianSplattingMesh extends Mesh {
|
|
|
302
333
|
const x = fBuffer[8 * i + 0];
|
|
303
334
|
const y = -fBuffer[8 * i + 1];
|
|
304
335
|
const z = fBuffer[8 * i + 2];
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
336
|
+
this._splatPositions[3 * i + 0] = x;
|
|
337
|
+
this._splatPositions[3 * i + 1] = y;
|
|
338
|
+
this._splatPositions[3 * i + 2] = z;
|
|
308
339
|
minimum.minimizeInPlaceFromFloats(x, y, z);
|
|
309
340
|
maximum.maximizeInPlaceFromFloats(x, y, z);
|
|
310
341
|
quaternion.set((uBuffer[32 * i + 28 + 1] - 128) / 128, (uBuffer[32 * i + 28 + 2] - 128) / 128, (uBuffer[32 * i + 28 + 3] - 128) / 128, -(uBuffer[32 * i + 28 + 0] - 128) / 128);
|
|
@@ -323,8 +354,6 @@ export class GaussianSplattingMesh extends Mesh {
|
|
|
323
354
|
binfo.reConstruct(minimum, maximum, this.getWorldMatrix());
|
|
324
355
|
this.forcedInstanceCount = this._vertexCount;
|
|
325
356
|
this.setEnabled(true);
|
|
326
|
-
const splatIndex = new Float32Array(this._vertexCount * 1);
|
|
327
|
-
this.thinInstanceSetBuffer("splatIndex", splatIndex, 1, false);
|
|
328
357
|
// Update the material
|
|
329
358
|
const createTextureFromData = (data, width, height, format) => {
|
|
330
359
|
return new RawTexture(data, width, height, format, this._scene, false, false, 2, 1);
|
|
@@ -349,14 +378,24 @@ export class GaussianSplattingMesh extends Mesh {
|
|
|
349
378
|
}
|
|
350
379
|
this._covariancesATexture = createTextureFromData(convertRgbToRgba(covA), textureSize.x, textureSize.y, 5);
|
|
351
380
|
this._covariancesBTexture = createTextureFromData(convertRgbToRgba(covB), textureSize.x, textureSize.y, 5);
|
|
352
|
-
this._centersTexture = createTextureFromData(convertRgbToRgba(
|
|
381
|
+
this._centersTexture = createTextureFromData(convertRgbToRgba(this._splatPositions), textureSize.x, textureSize.y, 5);
|
|
353
382
|
this._colorsTexture = createTextureFromData(colorArray, textureSize.x, textureSize.y, 5);
|
|
383
|
+
this._instanciateWorker();
|
|
384
|
+
}
|
|
385
|
+
_instanciateWorker() {
|
|
386
|
+
if (!this._vertexCount) {
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
const splatIndex = new Float32Array(this._vertexCount);
|
|
390
|
+
this.thinInstanceSetBuffer("splatIndex", splatIndex, 1, false);
|
|
354
391
|
// Start the worker thread
|
|
355
392
|
this._worker?.terminate();
|
|
356
393
|
this._worker = new Worker(URL.createObjectURL(new Blob(["(", GaussianSplattingMesh._CreateWorker.toString(), ")(self)"], {
|
|
357
394
|
type: "application/javascript",
|
|
358
395
|
})));
|
|
359
|
-
this._depthMix = new BigInt64Array(
|
|
396
|
+
this._depthMix = new BigInt64Array(this._vertexCount);
|
|
397
|
+
const positions = Float32Array.from(this._splatPositions);
|
|
398
|
+
const vertexCount = this._vertexCount;
|
|
360
399
|
this._worker.postMessage({ positions, vertexCount }, [positions.buffer]);
|
|
361
400
|
this._worker.onmessage = (e) => {
|
|
362
401
|
this._depthMix = e.data.depthMix;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gaussianSplattingMesh.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/GaussianSplatting/gaussianSplattingMesh.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,4BAAwB;AACxC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,mCAA+B;AAC1F,OAAO,EAAE,MAAM,EAAE,6BAAyB;AAC1C,OAAO,EAAE,yBAAyB,EAAE,uEAAmE;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,IAAI,YAAY,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;YAE7C,OAAO;YACP,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,EAAE,CAAC,EAAE,EAAE;gBAClC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;aACtB;YAED,IAAI,WAAW,GAAG,CAAC,CAAC,CAAC;YACrB,IAAI,CAAC,CAAC,IAAI,CAAC,oBAAoB,EAAE;gBAC7B,WAAW,GAAG,CAAC,CAAC;aACnB;YAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,EAAE,CAAC,EAAE,EAAE;gBAClC,QAAQ,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC;aAC/J;YAED,QAAQ,CAAC,IAAI,EAAE,CAAC;YAEhB,IAAI,CAAC,WAAW,CAAC,EAAE,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;SACrD;IACL,CAAC,CAAC;AACN,CAAC,AA5C2B,CA4C1B","sourcesContent":["import type { Scene } from \"core/scene\";\r\nimport type { DeepImmutable, FloatArray, Nullable } from \"core/types\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport { SubMesh } from \"../subMesh\";\r\nimport type { AbstractMesh } from \"../abstractMesh\";\r\nimport { Mesh } from \"../mesh\";\r\nimport { VertexData } from \"../mesh.vertexData\";\r\nimport { Tools } from \"core/Misc/tools\";\r\nimport { Matrix, TmpVectors, Vector2, Vector3, Quaternion } from \"core/Maths/math.vector\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport { GaussianSplattingMaterial } from \"core/Materials/GaussianSplatting/gaussianSplattingMaterial\";\r\nimport { RawTexture } from \"core/Materials/Textures/rawTexture\";\r\nimport { Constants } from \"core/Engines/constants\";\r\n\r\n/**\r\n * Class used to render a gaussian splatting mesh\r\n */\r\nexport class GaussianSplattingMesh extends Mesh {\r\n private _vertexCount = 0;\r\n private _worker: Nullable<Worker> = null;\r\n private _frameIdLastUpdate = -1;\r\n private _modelViewMatrix = Matrix.Identity();\r\n private _material: Nullable<GaussianSplattingMaterial> = null;\r\n private _depthMix: BigInt64Array;\r\n private _canPostToWorker = true;\r\n private _lastProj: DeepImmutable<FloatArray>;\r\n private _covariancesATexture: Nullable<BaseTexture> = null;\r\n private _covariancesBTexture: Nullable<BaseTexture> = null;\r\n private _centersTexture: Nullable<BaseTexture> = null;\r\n private _colorsTexture: Nullable<BaseTexture> = null;\r\n\r\n /**\r\n * Gets the covariancesA texture\r\n */\r\n public get covariancesATexture() {\r\n return this._covariancesATexture;\r\n }\r\n\r\n /**\r\n * Gets the covariancesB texture\r\n */\r\n public get covariancesBTexture() {\r\n return this._covariancesBTexture;\r\n }\r\n\r\n /**\r\n * Gets the centers texture\r\n */\r\n public get centersTexture() {\r\n return this._centersTexture;\r\n }\r\n\r\n /**\r\n * Gets the colors texture\r\n */\r\n public get colorsTexture() {\r\n return this._colorsTexture;\r\n }\r\n\r\n /**\r\n * Creates a new gaussian splatting mesh\r\n * @param name defines the name of the mesh\r\n * @param url defines the url to load from (optional)\r\n * @param scene defines the hosting scene (optional)\r\n */\r\n constructor(name: string, url: Nullable<string> = null, scene: Nullable<Scene> = null) {\r\n super(name, scene);\r\n\r\n const vertexData = new VertexData();\r\n\r\n vertexData.positions = [-2, -2, 0, 2, -2, 0, 2, 2, 0, -2, 2, 0];\r\n vertexData.indices = [0, 1, 2, 0, 2, 3];\r\n vertexData.applyToMesh(this);\r\n\r\n this.subMeshes = [];\r\n new SubMesh(0, 0, 4, 0, 6, this);\r\n\r\n this.setEnabled(false);\r\n\r\n this._lastProj = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];\r\n\r\n if (url) {\r\n this.loadFileAsync(url);\r\n }\r\n }\r\n\r\n /**\r\n * Returns the class name\r\n * @returns \"GaussianSplattingMesh\"\r\n */\r\n public override getClassName(): string {\r\n return \"GaussianSplattingMesh\";\r\n }\r\n\r\n /**\r\n * Returns the total number of vertices (splats) within the mesh\r\n * @returns the total number of vertices\r\n */\r\n public override getTotalVertices(): number {\r\n return this._vertexCount;\r\n }\r\n\r\n /**\r\n * Triggers the draw call for the mesh. Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager\r\n * @param subMesh defines the subMesh to render\r\n * @param enableAlphaMode defines if alpha mode can be changed\r\n * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering\r\n * @returns the current mesh\r\n */\r\n public override render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh {\r\n if (!this.material) {\r\n this._material = new GaussianSplattingMaterial(this.name + \"_material\", this._scene);\r\n this.material = this._material;\r\n }\r\n\r\n const frameId = this.getScene().getFrameId();\r\n if (frameId !== this._frameIdLastUpdate && this._worker && this._scene.activeCamera && this._canPostToWorker) {\r\n this.getWorldMatrix().multiplyToRef(this._scene.activeCamera.getViewMatrix(), this._modelViewMatrix);\r\n\r\n const dot = this._lastProj[2] * this._modelViewMatrix.m[2] + this._lastProj[6] * this._modelViewMatrix.m[6] + this._lastProj[10] * this._modelViewMatrix.m[10];\r\n if (Math.abs(dot - 1) >= 0.01) {\r\n this._frameIdLastUpdate = frameId;\r\n this._canPostToWorker = false;\r\n this._lastProj = this._modelViewMatrix.m.slice(0);\r\n this._worker.postMessage({ view: this._modelViewMatrix.m, depthMix: this._depthMix, useRightHandedSystem: this._scene.useRightHandedSystem }, [\r\n this._depthMix.buffer,\r\n ]);\r\n }\r\n }\r\n\r\n return super.render(subMesh, enableAlphaMode, effectiveMeshReplacement);\r\n }\r\n\r\n /**\r\n * Code from https://github.com/dylanebert/gsplat.js/blob/main/src/loaders/PLYLoader.ts Under MIT license\r\n * Converts a .ply data array buffer to splat\r\n * if data array buffer is not ply, returns the original buffer\r\n * @param data the .ply data to load\r\n * @returns the loaded splat buffer\r\n */\r\n public static ConvertPLYToSplat(data: ArrayBuffer): ArrayBuffer {\r\n const ubuf = new Uint8Array(data);\r\n const header = new TextDecoder().decode(ubuf.slice(0, 1024 * 10));\r\n const headerEnd = \"end_header\\n\";\r\n const headerEndIndex = header.indexOf(headerEnd);\r\n if (headerEndIndex < 0 || !header) {\r\n return data;\r\n }\r\n const vertexCount = parseInt(/element vertex (\\d+)\\n/.exec(header)![1]);\r\n\r\n let rowOffset = 0;\r\n const offsets: Record<string, number> = {\r\n double: 8,\r\n int: 4,\r\n uint: 4,\r\n float: 4,\r\n short: 2,\r\n ushort: 2,\r\n uchar: 1,\r\n };\r\n\r\n type PlyProperty = {\r\n name: string;\r\n type: string;\r\n offset: number;\r\n };\r\n const properties: PlyProperty[] = [];\r\n const filtered = header\r\n .slice(0, headerEndIndex)\r\n .split(\"\\n\")\r\n .filter((k) => k.startsWith(\"property \"));\r\n for (const prop of filtered) {\r\n const [, type, name] = prop.split(\" \");\r\n properties.push({ name, type, offset: rowOffset });\r\n if (offsets[type]) {\r\n rowOffset += offsets[type];\r\n } else {\r\n Logger.Error(`Unsupported property type: ${type}. Are you sure it's a valid Gaussian Splatting file?`);\r\n return new ArrayBuffer(0);\r\n }\r\n }\r\n\r\n const rowLength = 3 * 4 + 3 * 4 + 4 + 4;\r\n const SH_C0 = 0.28209479177387814;\r\n\r\n const dataView = new DataView(data, headerEndIndex + headerEnd.length);\r\n const buffer = new ArrayBuffer(rowLength * vertexCount);\r\n const q = new Quaternion();\r\n\r\n for (let i = 0; i < vertexCount; i++) {\r\n const position = new Float32Array(buffer, i * rowLength, 3);\r\n const scale = new Float32Array(buffer, i * rowLength + 12, 3);\r\n const rgba = new Uint8ClampedArray(buffer, i * rowLength + 24, 4);\r\n const rot = new Uint8ClampedArray(buffer, i * rowLength + 28, 4);\r\n\r\n let r0: number = 255;\r\n let r1: number = 0;\r\n let r2: number = 0;\r\n let r3: number = 0;\r\n\r\n for (let propertyIndex = 0; propertyIndex < properties.length; propertyIndex++) {\r\n const property = properties[propertyIndex];\r\n let value;\r\n switch (property.type) {\r\n case \"float\":\r\n value = dataView.getFloat32(property.offset + i * rowOffset, true);\r\n break;\r\n case \"int\":\r\n value = dataView.getInt32(property.offset + i * rowOffset, true);\r\n break;\r\n default:\r\n throw new Error(`Unsupported property type: ${property.type}`);\r\n }\r\n\r\n switch (property.name) {\r\n case \"x\":\r\n position[0] = value;\r\n break;\r\n case \"y\":\r\n position[1] = value;\r\n break;\r\n case \"z\":\r\n position[2] = value;\r\n break;\r\n case \"scale_0\":\r\n scale[0] = Math.exp(value);\r\n break;\r\n case \"scale_1\":\r\n scale[1] = Math.exp(value);\r\n break;\r\n case \"scale_2\":\r\n scale[2] = Math.exp(value);\r\n break;\r\n case \"red\":\r\n rgba[0] = value;\r\n break;\r\n case \"green\":\r\n rgba[1] = value;\r\n break;\r\n case \"blue\":\r\n rgba[2] = value;\r\n break;\r\n case \"f_dc_0\":\r\n rgba[0] = (0.5 + SH_C0 * value) * 255;\r\n break;\r\n case \"f_dc_1\":\r\n rgba[1] = (0.5 + SH_C0 * value) * 255;\r\n break;\r\n case \"f_dc_2\":\r\n rgba[2] = (0.5 + SH_C0 * value) * 255;\r\n break;\r\n case \"f_dc_3\":\r\n rgba[3] = (0.5 + SH_C0 * value) * 255;\r\n break;\r\n case \"opacity\":\r\n rgba[3] = (1 / (1 + Math.exp(-value))) * 255;\r\n break;\r\n case \"rot_0\":\r\n r0 = value;\r\n break;\r\n case \"rot_1\":\r\n r1 = value;\r\n break;\r\n case \"rot_2\":\r\n r2 = value;\r\n break;\r\n case \"rot_3\":\r\n r3 = value;\r\n break;\r\n }\r\n }\r\n\r\n q.set(r1, r2, r3, r0);\r\n q.normalize();\r\n rot[0] = q.w * 128 + 128;\r\n rot[1] = q.x * 128 + 128;\r\n rot[2] = q.y * 128 + 128;\r\n rot[3] = q.z * 128 + 128;\r\n }\r\n\r\n return buffer;\r\n }\r\n\r\n /**\r\n * Loads a .splat Gaussian Splatting array buffer asynchronously\r\n * @param data arraybuffer containing splat file\r\n * @returns a promise that resolves when the operation is complete\r\n */\r\n\r\n public loadDataAsync(data: ArrayBuffer): Promise<void> {\r\n return Promise.resolve(this._loadData(data));\r\n }\r\n\r\n /**\r\n * Loads a .splat Gaussian or .ply Splatting file asynchronously\r\n * @param url path to the splat file to load\r\n * @returns a promise that resolves when the operation is complete\r\n */\r\n public loadFileAsync(url: string): Promise<void> {\r\n return Tools.LoadFileAsync(url, true).then((data) => {\r\n this._loadData(GaussianSplattingMesh.ConvertPLYToSplat(data));\r\n });\r\n }\r\n\r\n /**\r\n * Releases resources associated with this mesh.\r\n * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)\r\n */\r\n public override dispose(doNotRecurse?: boolean): void {\r\n this._covariancesATexture?.dispose();\r\n this._covariancesBTexture?.dispose();\r\n this._centersTexture?.dispose();\r\n this._colorsTexture?.dispose();\r\n\r\n this._covariancesATexture = null;\r\n this._covariancesBTexture = null;\r\n this._centersTexture = null;\r\n this._colorsTexture = null;\r\n\r\n this._material?.dispose(false, true);\r\n this._material = null;\r\n\r\n this._worker?.terminate();\r\n this._worker = null;\r\n\r\n super.dispose(doNotRecurse);\r\n }\r\n\r\n private static _CreateWorker = function (self: Worker) {\r\n let vertexCount = 0;\r\n let positions: Float32Array;\r\n let depthMix: BigInt64Array;\r\n let indices: Uint32Array;\r\n let floatMix: Float32Array;\r\n\r\n self.onmessage = (e: any) => {\r\n // updated on init\r\n if (e.data.positions) {\r\n positions = e.data.positions;\r\n vertexCount = e.data.vertexCount;\r\n }\r\n // udpate on view changed\r\n else {\r\n const viewProj = e.data.view;\r\n if (!positions || !viewProj) {\r\n // Sanity check, it shouldn't happen!\r\n throw new Error(\"positions or view is not defined!\");\r\n }\r\n\r\n depthMix = e.data.depthMix;\r\n indices = new Uint32Array(depthMix.buffer);\r\n floatMix = new Float32Array(depthMix.buffer);\r\n\r\n // Sort\r\n for (let j = 0; j < vertexCount; j++) {\r\n indices[2 * j] = j;\r\n }\r\n\r\n let depthFactor = -1;\r\n if (e.data.useRightHandedSystem) {\r\n depthFactor = 1;\r\n }\r\n\r\n for (let j = 0; j < vertexCount; j++) {\r\n floatMix[2 * j + 1] = 10000 + (viewProj[2] * positions[3 * j + 0] + viewProj[6] * positions[3 * j + 1] + viewProj[10] * positions[3 * j + 2]) * depthFactor;\r\n }\r\n\r\n depthMix.sort();\r\n\r\n self.postMessage({ depthMix }, [depthMix.buffer]);\r\n }\r\n };\r\n };\r\n\r\n private _loadData(data: ArrayBuffer): void {\r\n if (!data.byteLength) {\r\n return;\r\n }\r\n // Parse the data\r\n const uBuffer = new Uint8Array(data);\r\n const fBuffer = new Float32Array(uBuffer.buffer);\r\n\r\n const rowLength = 3 * 4 + 3 * 4 + 4 + 4;\r\n const vertexCount = uBuffer.length / rowLength;\r\n\r\n this._vertexCount = vertexCount;\r\n\r\n const textureSize = this._getTextureSize(vertexCount);\r\n const textureLength = textureSize.x * textureSize.y;\r\n\r\n const positions = new Float32Array(3 * textureLength);\r\n const covA = new Float32Array(3 * textureLength);\r\n const covB = new Float32Array(3 * textureLength);\r\n\r\n const matrixRotation = TmpVectors.Matrix[0];\r\n const matrixScale = TmpVectors.Matrix[1];\r\n const quaternion = TmpVectors.Quaternion[0];\r\n\r\n const minimum = new Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);\r\n const maximum = new Vector3(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);\r\n\r\n for (let i = 0; i < vertexCount; i++) {\r\n const x = fBuffer[8 * i + 0];\r\n const y = -fBuffer[8 * i + 1];\r\n const z = fBuffer[8 * i + 2];\r\n\r\n positions[3 * i + 0] = x;\r\n positions[3 * i + 1] = y;\r\n positions[3 * i + 2] = z;\r\n\r\n minimum.minimizeInPlaceFromFloats(x, y, z);\r\n maximum.maximizeInPlaceFromFloats(x, y, z);\r\n\r\n quaternion.set(\r\n (uBuffer[32 * i + 28 + 1] - 128) / 128,\r\n (uBuffer[32 * i + 28 + 2] - 128) / 128,\r\n (uBuffer[32 * i + 28 + 3] - 128) / 128,\r\n -(uBuffer[32 * i + 28 + 0] - 128) / 128\r\n );\r\n quaternion.toRotationMatrix(matrixRotation);\r\n\r\n Matrix.ScalingToRef(fBuffer[8 * i + 3 + 0] * 2, fBuffer[8 * i + 3 + 1] * 2, fBuffer[8 * i + 3 + 2] * 2, matrixScale);\r\n\r\n const M = matrixRotation.multiplyToRef(matrixScale, TmpVectors.Matrix[0]).m;\r\n\r\n covA[i * 3 + 0] = M[0] * M[0] + M[1] * M[1] + M[2] * M[2];\r\n covA[i * 3 + 1] = M[0] * M[4] + M[1] * M[5] + M[2] * M[6];\r\n covA[i * 3 + 2] = M[0] * M[8] + M[1] * M[9] + M[2] * M[10];\r\n covB[i * 3 + 0] = M[4] * M[4] + M[5] * M[5] + M[6] * M[6];\r\n covB[i * 3 + 1] = M[4] * M[8] + M[5] * M[9] + M[6] * M[10];\r\n covB[i * 3 + 2] = M[8] * M[8] + M[9] * M[9] + M[10] * M[10];\r\n }\r\n\r\n // Update the mesh\r\n const binfo = this.getBoundingInfo();\r\n binfo.reConstruct(minimum, maximum, this.getWorldMatrix());\r\n\r\n this.forcedInstanceCount = this._vertexCount;\r\n this.setEnabled(true);\r\n\r\n const splatIndex = new Float32Array(this._vertexCount * 1);\r\n\r\n this.thinInstanceSetBuffer(\"splatIndex\", splatIndex, 1, false);\r\n\r\n // Update the material\r\n const createTextureFromData = (data: Float32Array, width: number, height: number, format: number) => {\r\n return new RawTexture(data, width, height, format, this._scene, false, false, Constants.TEXTURE_BILINEAR_SAMPLINGMODE, Constants.TEXTURETYPE_FLOAT);\r\n };\r\n\r\n const convertRgbToRgba = (rgb: Float32Array) => {\r\n const count = rgb.length / 3;\r\n const rgba = new Float32Array(count * 4);\r\n for (let i = 0; i < count; ++i) {\r\n rgba[i * 4 + 0] = rgb[i * 3 + 0];\r\n rgba[i * 4 + 1] = rgb[i * 3 + 1];\r\n rgba[i * 4 + 2] = rgb[i * 3 + 2];\r\n rgba[i * 4 + 3] = 1.0;\r\n }\r\n return rgba;\r\n };\r\n\r\n const colorArray = new Float32Array(textureSize.x * textureSize.y * 4);\r\n for (let i = 0; i < this._vertexCount; ++i) {\r\n colorArray[i * 4 + 0] = uBuffer[32 * i + 24 + 0] / 255;\r\n colorArray[i * 4 + 1] = uBuffer[32 * i + 24 + 1] / 255;\r\n colorArray[i * 4 + 2] = uBuffer[32 * i + 24 + 2] / 255;\r\n colorArray[i * 4 + 3] = uBuffer[32 * i + 24 + 3] / 255;\r\n }\r\n\r\n this._covariancesATexture = createTextureFromData(convertRgbToRgba(covA), textureSize.x, textureSize.y, Constants.TEXTUREFORMAT_RGBA);\r\n this._covariancesBTexture = createTextureFromData(convertRgbToRgba(covB), textureSize.x, textureSize.y, Constants.TEXTUREFORMAT_RGBA);\r\n this._centersTexture = createTextureFromData(convertRgbToRgba(positions), textureSize.x, textureSize.y, Constants.TEXTUREFORMAT_RGBA);\r\n this._colorsTexture = createTextureFromData(colorArray, textureSize.x, textureSize.y, Constants.TEXTUREFORMAT_RGBA);\r\n\r\n // Start the worker thread\r\n this._worker?.terminate();\r\n this._worker = new Worker(\r\n URL.createObjectURL(\r\n new Blob([\"(\", GaussianSplattingMesh._CreateWorker.toString(), \")(self)\"], {\r\n type: \"application/javascript\",\r\n })\r\n )\r\n );\r\n\r\n this._depthMix = new BigInt64Array(vertexCount);\r\n\r\n this._worker.postMessage({ positions, vertexCount }, [positions.buffer]);\r\n\r\n this._worker.onmessage = (e) => {\r\n this._depthMix = e.data.depthMix;\r\n const indexMix = new Uint32Array(e.data.depthMix.buffer);\r\n for (let j = 0; j < this._vertexCount; j++) {\r\n splatIndex[j] = indexMix[2 * j];\r\n }\r\n this.thinInstanceBufferUpdated(\"splatIndex\");\r\n this._canPostToWorker = true;\r\n };\r\n }\r\n\r\n private _getTextureSize(length: number): Vector2 {\r\n const engine = this._scene.getEngine();\r\n const width = engine.getCaps().maxTextureSize;\r\n\r\n let height = 1;\r\n\r\n if (engine.version === 1 && !engine.isWebGPU) {\r\n while (width * height < length) {\r\n height *= 2;\r\n }\r\n } else {\r\n height = Math.ceil(length / width);\r\n }\r\n\r\n if (height > width) {\r\n Logger.Error(\"GaussianSplatting texture size: (\" + width + \", \" + height + \"), maxTextureSize: \" + width);\r\n height = width;\r\n }\r\n\r\n return new Vector2(width, height);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"gaussianSplattingMesh.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/GaussianSplatting/gaussianSplattingMesh.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,4BAAwB;AACxC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,mCAA+B;AAC1F,OAAO,EAAE,MAAM,EAAE,6BAAyB;AAC1C,OAAO,EAAE,yBAAyB,EAAE,uEAAmE;AACvG,OAAO,EAAE,UAAU,EAAE,+CAA2C;AAChE,OAAO,EAAE,SAAS,EAAE,mCAA+B;AAEnD;;GAEG;AACH,MAAM,OAAO,qBAAsB,SAAQ,IAAI;IAe3C;;OAEG;IACH,IAAW,mBAAmB;QAC1B,OAAO,IAAI,CAAC,oBAAoB,CAAC;IACrC,CAA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W,CAAC;aAC/J;YAED,QAAQ,CAAC,IAAI,EAAE,CAAC;YAEhB,IAAI,CAAC,WAAW,CAAC,EAAE,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;SACrD;IACL,CAAC,CAAC;AACN,CAAC,AA5C2B,CA4C1B","sourcesContent":["import type { Scene } from \"core/scene\";\r\nimport type { DeepImmutable, FloatArray, Nullable } from \"core/types\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport { SubMesh } from \"../subMesh\";\r\nimport type { AbstractMesh } from \"../abstractMesh\";\r\nimport { Mesh } from \"../mesh\";\r\nimport { VertexData } from \"../mesh.vertexData\";\r\nimport { Tools } from \"core/Misc/tools\";\r\nimport { Matrix, TmpVectors, Vector2, Vector3, Quaternion } from \"core/Maths/math.vector\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport { GaussianSplattingMaterial } from \"core/Materials/GaussianSplatting/gaussianSplattingMaterial\";\r\nimport { RawTexture } from \"core/Materials/Textures/rawTexture\";\r\nimport { Constants } from \"core/Engines/constants\";\r\n\r\n/**\r\n * Class used to render a gaussian splatting mesh\r\n */\r\nexport class GaussianSplattingMesh extends Mesh {\r\n private _vertexCount = 0;\r\n private _worker: Nullable<Worker> = null;\r\n private _frameIdLastUpdate = -1;\r\n private _modelViewMatrix = Matrix.Identity();\r\n private _material: Nullable<GaussianSplattingMaterial> = null;\r\n private _depthMix: BigInt64Array;\r\n private _canPostToWorker = true;\r\n private _lastModelViewMatrix: DeepImmutable<FloatArray>;\r\n private _covariancesATexture: Nullable<BaseTexture> = null;\r\n private _covariancesBTexture: Nullable<BaseTexture> = null;\r\n private _centersTexture: Nullable<BaseTexture> = null;\r\n private _colorsTexture: Nullable<BaseTexture> = null;\r\n private _splatPositions: Nullable<Float32Array> = null;\r\n\r\n /**\r\n * Gets the covariancesA texture\r\n */\r\n public get covariancesATexture() {\r\n return this._covariancesATexture;\r\n }\r\n\r\n /**\r\n * Gets the covariancesB texture\r\n */\r\n public get covariancesBTexture() {\r\n return this._covariancesBTexture;\r\n }\r\n\r\n /**\r\n * Gets the centers texture\r\n */\r\n public get centersTexture() {\r\n return this._centersTexture;\r\n }\r\n\r\n /**\r\n * Gets the colors texture\r\n */\r\n public get colorsTexture() {\r\n return this._colorsTexture;\r\n }\r\n\r\n /**\r\n * Creates a new gaussian splatting mesh\r\n * @param name defines the name of the mesh\r\n * @param url defines the url to load from (optional)\r\n * @param scene defines the hosting scene (optional)\r\n */\r\n constructor(name: string, url: Nullable<string> = null, scene: Nullable<Scene> = null) {\r\n super(name, scene);\r\n\r\n const vertexData = new VertexData();\r\n\r\n vertexData.positions = [-2, -2, 0, 2, -2, 0, 2, 2, 0, -2, 2, 0];\r\n vertexData.indices = [0, 1, 2, 0, 2, 3];\r\n vertexData.applyToMesh(this);\r\n\r\n this.subMeshes = [];\r\n new SubMesh(0, 0, 4, 0, 6, this);\r\n\r\n this.setEnabled(false);\r\n\r\n this._lastModelViewMatrix = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];\r\n\r\n if (url) {\r\n this.loadFileAsync(url);\r\n }\r\n }\r\n\r\n /**\r\n * Returns the class name\r\n * @returns \"GaussianSplattingMesh\"\r\n */\r\n public override getClassName(): string {\r\n return \"GaussianSplattingMesh\";\r\n }\r\n\r\n /**\r\n * Returns the total number of vertices (splats) within the mesh\r\n * @returns the total number of vertices\r\n */\r\n public override getTotalVertices(): number {\r\n return this._vertexCount;\r\n }\r\n\r\n /**\r\n * Triggers the draw call for the mesh. Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager\r\n * @param subMesh defines the subMesh to render\r\n * @param enableAlphaMode defines if alpha mode can be changed\r\n * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering\r\n * @returns the current mesh\r\n */\r\n public override render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh {\r\n if (!this.material) {\r\n this._material = new GaussianSplattingMaterial(this.name + \"_material\", this._scene);\r\n this.material = this._material;\r\n }\r\n\r\n const frameId = this.getScene().getFrameId();\r\n if (frameId !== this._frameIdLastUpdate && this._worker && this._scene.activeCamera && this._canPostToWorker) {\r\n this.getWorldMatrix().multiplyToRef(this._scene.activeCamera.getViewMatrix(), this._modelViewMatrix);\r\n TmpVectors.Vector3[0].set(this._lastModelViewMatrix[8], this._lastModelViewMatrix[9], this._lastModelViewMatrix[10]);\r\n TmpVectors.Vector3[1].set(this._modelViewMatrix.m[8], this._modelViewMatrix.m[9], this._modelViewMatrix.m[10]);\r\n TmpVectors.Vector3[0].normalize();\r\n TmpVectors.Vector3[1].normalize();\r\n\r\n const dot = Vector3.Dot(TmpVectors.Vector3[0], TmpVectors.Vector3[1]);\r\n if (Math.abs(dot - 1) >= 0.01) {\r\n this._frameIdLastUpdate = frameId;\r\n this._canPostToWorker = false;\r\n this._lastModelViewMatrix = this._modelViewMatrix.m.slice(0);\r\n this._worker.postMessage({ view: this._modelViewMatrix.m, depthMix: this._depthMix, useRightHandedSystem: this._scene.useRightHandedSystem }, [\r\n this._depthMix.buffer,\r\n ]);\r\n }\r\n }\r\n\r\n return super.render(subMesh, enableAlphaMode, effectiveMeshReplacement);\r\n }\r\n\r\n /**\r\n * Code from https://github.com/dylanebert/gsplat.js/blob/main/src/loaders/PLYLoader.ts Under MIT license\r\n * Converts a .ply data array buffer to splat\r\n * if data array buffer is not ply, returns the original buffer\r\n * @param data the .ply data to load\r\n * @returns the loaded splat buffer\r\n */\r\n public static ConvertPLYToSplat(data: ArrayBuffer): ArrayBuffer {\r\n const ubuf = new Uint8Array(data);\r\n const header = new TextDecoder().decode(ubuf.slice(0, 1024 * 10));\r\n const headerEnd = \"end_header\\n\";\r\n const headerEndIndex = header.indexOf(headerEnd);\r\n if (headerEndIndex < 0 || !header) {\r\n return data;\r\n }\r\n const vertexCount = parseInt(/element vertex (\\d+)\\n/.exec(header)![1]);\r\n\r\n let rowOffset = 0;\r\n const offsets: Record<string, number> = {\r\n double: 8,\r\n int: 4,\r\n uint: 4,\r\n float: 4,\r\n short: 2,\r\n ushort: 2,\r\n uchar: 1,\r\n };\r\n\r\n type PlyProperty = {\r\n name: string;\r\n type: string;\r\n offset: number;\r\n };\r\n const properties: PlyProperty[] = [];\r\n const filtered = header\r\n .slice(0, headerEndIndex)\r\n .split(\"\\n\")\r\n .filter((k) => k.startsWith(\"property \"));\r\n for (const prop of filtered) {\r\n const [, type, name] = prop.split(\" \");\r\n properties.push({ name, type, offset: rowOffset });\r\n if (offsets[type]) {\r\n rowOffset += offsets[type];\r\n } else {\r\n Logger.Error(`Unsupported property type: ${type}. Are you sure it's a valid Gaussian Splatting file?`);\r\n return new ArrayBuffer(0);\r\n }\r\n }\r\n\r\n const rowLength = 3 * 4 + 3 * 4 + 4 + 4;\r\n const SH_C0 = 0.28209479177387814;\r\n\r\n const dataView = new DataView(data, headerEndIndex + headerEnd.length);\r\n const buffer = new ArrayBuffer(rowLength * vertexCount);\r\n const q = new Quaternion();\r\n\r\n for (let i = 0; i < vertexCount; i++) {\r\n const position = new Float32Array(buffer, i * rowLength, 3);\r\n const scale = new Float32Array(buffer, i * rowLength + 12, 3);\r\n const rgba = new Uint8ClampedArray(buffer, i * rowLength + 24, 4);\r\n const rot = new Uint8ClampedArray(buffer, i * rowLength + 28, 4);\r\n\r\n let r0: number = 255;\r\n let r1: number = 0;\r\n let r2: number = 0;\r\n let r3: number = 0;\r\n\r\n for (let propertyIndex = 0; propertyIndex < properties.length; propertyIndex++) {\r\n const property = properties[propertyIndex];\r\n let value;\r\n switch (property.type) {\r\n case \"float\":\r\n value = dataView.getFloat32(property.offset + i * rowOffset, true);\r\n break;\r\n case \"int\":\r\n value = dataView.getInt32(property.offset + i * rowOffset, true);\r\n break;\r\n default:\r\n throw new Error(`Unsupported property type: ${property.type}`);\r\n }\r\n\r\n switch (property.name) {\r\n case \"x\":\r\n position[0] = value;\r\n break;\r\n case \"y\":\r\n position[1] = value;\r\n break;\r\n case \"z\":\r\n position[2] = value;\r\n break;\r\n case \"scale_0\":\r\n scale[0] = Math.exp(value);\r\n break;\r\n case \"scale_1\":\r\n scale[1] = Math.exp(value);\r\n break;\r\n case \"scale_2\":\r\n scale[2] = Math.exp(value);\r\n break;\r\n case \"red\":\r\n rgba[0] = value;\r\n break;\r\n case \"green\":\r\n rgba[1] = value;\r\n break;\r\n case \"blue\":\r\n rgba[2] = value;\r\n break;\r\n case \"f_dc_0\":\r\n rgba[0] = (0.5 + SH_C0 * value) * 255;\r\n break;\r\n case \"f_dc_1\":\r\n rgba[1] = (0.5 + SH_C0 * value) * 255;\r\n break;\r\n case \"f_dc_2\":\r\n rgba[2] = (0.5 + SH_C0 * value) * 255;\r\n break;\r\n case \"f_dc_3\":\r\n rgba[3] = (0.5 + SH_C0 * value) * 255;\r\n break;\r\n case \"opacity\":\r\n rgba[3] = (1 / (1 + Math.exp(-value))) * 255;\r\n break;\r\n case \"rot_0\":\r\n r0 = value;\r\n break;\r\n case \"rot_1\":\r\n r1 = value;\r\n break;\r\n case \"rot_2\":\r\n r2 = value;\r\n break;\r\n case \"rot_3\":\r\n r3 = value;\r\n break;\r\n }\r\n }\r\n\r\n q.set(r1, r2, r3, r0);\r\n q.normalize();\r\n rot[0] = q.w * 128 + 128;\r\n rot[1] = q.x * 128 + 128;\r\n rot[2] = q.y * 128 + 128;\r\n rot[3] = q.z * 128 + 128;\r\n }\r\n\r\n return buffer;\r\n }\r\n\r\n /**\r\n * Loads a .splat Gaussian Splatting array buffer asynchronously\r\n * @param data arraybuffer containing splat file\r\n * @returns a promise that resolves when the operation is complete\r\n */\r\n\r\n public loadDataAsync(data: ArrayBuffer): Promise<void> {\r\n return Promise.resolve(this._loadData(data));\r\n }\r\n\r\n /**\r\n * Loads a .splat Gaussian or .ply Splatting file asynchronously\r\n * @param url path to the splat file to load\r\n * @returns a promise that resolves when the operation is complete\r\n */\r\n public loadFileAsync(url: string): Promise<void> {\r\n return Tools.LoadFileAsync(url, true).then((data) => {\r\n this._loadData(GaussianSplattingMesh.ConvertPLYToSplat(data));\r\n });\r\n }\r\n\r\n /**\r\n * Releases resources associated with this mesh.\r\n * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)\r\n */\r\n public override dispose(doNotRecurse?: boolean): void {\r\n this._covariancesATexture?.dispose();\r\n this._covariancesBTexture?.dispose();\r\n this._centersTexture?.dispose();\r\n this._colorsTexture?.dispose();\r\n\r\n this._covariancesATexture = null;\r\n this._covariancesBTexture = null;\r\n this._centersTexture = null;\r\n this._colorsTexture = null;\r\n\r\n this._material?.dispose(false, true);\r\n this._material = null;\r\n\r\n this._worker?.terminate();\r\n this._worker = null;\r\n\r\n super.dispose(doNotRecurse);\r\n }\r\n\r\n private _copyTextures(source: GaussianSplattingMesh): void {\r\n this._covariancesATexture = source.covariancesATexture?.clone()!;\r\n this._covariancesBTexture = source.covariancesBTexture?.clone()!;\r\n this._centersTexture = source.centersTexture?.clone()!;\r\n this._colorsTexture = source.colorsTexture?.clone()!;\r\n }\r\n\r\n /**\r\n * Returns a new Mesh object generated from the current mesh properties.\r\n * @param name is a string, the name given to the new mesh\r\n * @returns a new Gaussian Splatting Mesh\r\n */\r\n public override clone(name: string = \"\"): GaussianSplattingMesh {\r\n const newGS = new GaussianSplattingMesh(name, undefined, this.getScene());\r\n newGS._copySource(this);\r\n newGS.makeGeometryUnique();\r\n newGS._vertexCount = this._vertexCount;\r\n newGS._copyTextures(this);\r\n newGS._modelViewMatrix = Matrix.Identity();\r\n newGS._splatPositions = this._splatPositions;\r\n newGS._instanciateWorker();\r\n\r\n const binfo = this.getBoundingInfo();\r\n newGS.getBoundingInfo().reConstruct(binfo.minimum, binfo.maximum, this.getWorldMatrix());\r\n\r\n newGS.forcedInstanceCount = newGS._vertexCount;\r\n newGS.setEnabled(true);\r\n return newGS;\r\n }\r\n\r\n private static _CreateWorker = function (self: Worker) {\r\n let vertexCount = 0;\r\n let positions: Float32Array;\r\n let depthMix: BigInt64Array;\r\n let indices: Uint32Array;\r\n let floatMix: Float32Array;\r\n\r\n self.onmessage = (e: any) => {\r\n // updated on init\r\n if (e.data.positions) {\r\n positions = e.data.positions;\r\n vertexCount = e.data.vertexCount;\r\n }\r\n // udpate on view changed\r\n else {\r\n const viewProj = e.data.view;\r\n if (!positions || !viewProj) {\r\n // Sanity check, it shouldn't happen!\r\n throw new Error(\"positions or view is not defined!\");\r\n }\r\n\r\n depthMix = e.data.depthMix;\r\n indices = new Uint32Array(depthMix.buffer);\r\n floatMix = new Float32Array(depthMix.buffer);\r\n\r\n // Sort\r\n for (let j = 0; j < vertexCount; j++) {\r\n indices[2 * j] = j;\r\n }\r\n\r\n let depthFactor = -1;\r\n if (e.data.useRightHandedSystem) {\r\n depthFactor = 1;\r\n }\r\n\r\n for (let j = 0; j < vertexCount; j++) {\r\n floatMix[2 * j + 1] = 10000 + (viewProj[2] * positions[3 * j + 0] + viewProj[6] * positions[3 * j + 1] + viewProj[10] * positions[3 * j + 2]) * depthFactor;\r\n }\r\n\r\n depthMix.sort();\r\n\r\n self.postMessage({ depthMix }, [depthMix.buffer]);\r\n }\r\n };\r\n };\r\n\r\n private _loadData(data: ArrayBuffer): void {\r\n if (!data.byteLength) {\r\n return;\r\n }\r\n // Parse the data\r\n const uBuffer = new Uint8Array(data);\r\n const fBuffer = new Float32Array(uBuffer.buffer);\r\n\r\n const rowLength = 3 * 4 + 3 * 4 + 4 + 4;\r\n const vertexCount = uBuffer.length / rowLength;\r\n\r\n this._vertexCount = vertexCount;\r\n\r\n const textureSize = this._getTextureSize(vertexCount);\r\n const textureLength = textureSize.x * textureSize.y;\r\n\r\n this._splatPositions = new Float32Array(3 * textureLength);\r\n const covA = new Float32Array(3 * textureLength);\r\n const covB = new Float32Array(3 * textureLength);\r\n\r\n const matrixRotation = TmpVectors.Matrix[0];\r\n const matrixScale = TmpVectors.Matrix[1];\r\n const quaternion = TmpVectors.Quaternion[0];\r\n\r\n const minimum = new Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);\r\n const maximum = new Vector3(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);\r\n\r\n for (let i = 0; i < vertexCount; i++) {\r\n const x = fBuffer[8 * i + 0];\r\n const y = -fBuffer[8 * i + 1];\r\n const z = fBuffer[8 * i + 2];\r\n\r\n this._splatPositions[3 * i + 0] = x;\r\n this._splatPositions[3 * i + 1] = y;\r\n this._splatPositions[3 * i + 2] = z;\r\n\r\n minimum.minimizeInPlaceFromFloats(x, y, z);\r\n maximum.maximizeInPlaceFromFloats(x, y, z);\r\n\r\n quaternion.set(\r\n (uBuffer[32 * i + 28 + 1] - 128) / 128,\r\n (uBuffer[32 * i + 28 + 2] - 128) / 128,\r\n (uBuffer[32 * i + 28 + 3] - 128) / 128,\r\n -(uBuffer[32 * i + 28 + 0] - 128) / 128\r\n );\r\n quaternion.toRotationMatrix(matrixRotation);\r\n\r\n Matrix.ScalingToRef(fBuffer[8 * i + 3 + 0] * 2, fBuffer[8 * i + 3 + 1] * 2, fBuffer[8 * i + 3 + 2] * 2, matrixScale);\r\n\r\n const M = matrixRotation.multiplyToRef(matrixScale, TmpVectors.Matrix[0]).m;\r\n\r\n covA[i * 3 + 0] = M[0] * M[0] + M[1] * M[1] + M[2] * M[2];\r\n covA[i * 3 + 1] = M[0] * M[4] + M[1] * M[5] + M[2] * M[6];\r\n covA[i * 3 + 2] = M[0] * M[8] + M[1] * M[9] + M[2] * M[10];\r\n covB[i * 3 + 0] = M[4] * M[4] + M[5] * M[5] + M[6] * M[6];\r\n covB[i * 3 + 1] = M[4] * M[8] + M[5] * M[9] + M[6] * M[10];\r\n covB[i * 3 + 2] = M[8] * M[8] + M[9] * M[9] + M[10] * M[10];\r\n }\r\n\r\n // Update the mesh\r\n const binfo = this.getBoundingInfo();\r\n binfo.reConstruct(minimum, maximum, this.getWorldMatrix());\r\n\r\n this.forcedInstanceCount = this._vertexCount;\r\n this.setEnabled(true);\r\n\r\n // Update the material\r\n const createTextureFromData = (data: Float32Array, width: number, height: number, format: number) => {\r\n return new RawTexture(data, width, height, format, this._scene, false, false, Constants.TEXTURE_BILINEAR_SAMPLINGMODE, Constants.TEXTURETYPE_FLOAT);\r\n };\r\n\r\n const convertRgbToRgba = (rgb: Float32Array) => {\r\n const count = rgb.length / 3;\r\n const rgba = new Float32Array(count * 4);\r\n for (let i = 0; i < count; ++i) {\r\n rgba[i * 4 + 0] = rgb[i * 3 + 0];\r\n rgba[i * 4 + 1] = rgb[i * 3 + 1];\r\n rgba[i * 4 + 2] = rgb[i * 3 + 2];\r\n rgba[i * 4 + 3] = 1.0;\r\n }\r\n return rgba;\r\n };\r\n\r\n const colorArray = new Float32Array(textureSize.x * textureSize.y * 4);\r\n for (let i = 0; i < this._vertexCount; ++i) {\r\n colorArray[i * 4 + 0] = uBuffer[32 * i + 24 + 0] / 255;\r\n colorArray[i * 4 + 1] = uBuffer[32 * i + 24 + 1] / 255;\r\n colorArray[i * 4 + 2] = uBuffer[32 * i + 24 + 2] / 255;\r\n colorArray[i * 4 + 3] = uBuffer[32 * i + 24 + 3] / 255;\r\n }\r\n\r\n this._covariancesATexture = createTextureFromData(convertRgbToRgba(covA), textureSize.x, textureSize.y, Constants.TEXTUREFORMAT_RGBA);\r\n this._covariancesBTexture = createTextureFromData(convertRgbToRgba(covB), textureSize.x, textureSize.y, Constants.TEXTUREFORMAT_RGBA);\r\n this._centersTexture = createTextureFromData(convertRgbToRgba(this._splatPositions), textureSize.x, textureSize.y, Constants.TEXTUREFORMAT_RGBA);\r\n this._colorsTexture = createTextureFromData(colorArray, textureSize.x, textureSize.y, Constants.TEXTUREFORMAT_RGBA);\r\n\r\n this._instanciateWorker();\r\n }\r\n\r\n private _instanciateWorker(): void {\r\n if (!this._vertexCount) {\r\n return;\r\n }\r\n const splatIndex = new Float32Array(this._vertexCount);\r\n\r\n this.thinInstanceSetBuffer(\"splatIndex\", splatIndex, 1, false);\r\n\r\n // Start the worker thread\r\n this._worker?.terminate();\r\n this._worker = new Worker(\r\n URL.createObjectURL(\r\n new Blob([\"(\", GaussianSplattingMesh._CreateWorker.toString(), \")(self)\"], {\r\n type: \"application/javascript\",\r\n })\r\n )\r\n );\r\n\r\n this._depthMix = new BigInt64Array(this._vertexCount);\r\n const positions = Float32Array.from(this._splatPositions!);\r\n const vertexCount = this._vertexCount;\r\n\r\n this._worker.postMessage({ positions, vertexCount }, [positions.buffer]);\r\n\r\n this._worker.onmessage = (e) => {\r\n this._depthMix = e.data.depthMix;\r\n const indexMix = new Uint32Array(e.data.depthMix.buffer);\r\n for (let j = 0; j < this._vertexCount; j++) {\r\n splatIndex[j] = indexMix[2 * j];\r\n }\r\n this.thinInstanceBufferUpdated(\"splatIndex\");\r\n this._canPostToWorker = true;\r\n };\r\n }\r\n\r\n private _getTextureSize(length: number): Vector2 {\r\n const engine = this._scene.getEngine();\r\n const width = engine.getCaps().maxTextureSize;\r\n\r\n let height = 1;\r\n\r\n if (engine.version === 1 && !engine.isWebGPU) {\r\n while (width * height < length) {\r\n height *= 2;\r\n }\r\n } else {\r\n height = Math.ceil(length / width);\r\n }\r\n\r\n if (height > width) {\r\n Logger.Error(\"GaussianSplatting texture size: (\" + width + \", \" + height + \"), maxTextureSize: \" + width);\r\n height = width;\r\n }\r\n\r\n return new Vector2(width, height);\r\n }\r\n}\r\n"]}
|