@babylonjs/core 8.9.0 → 8.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AudioV2/abstractAudio/abstractSound.d.ts +0 -7
- package/AudioV2/abstractAudio/abstractSound.js.map +1 -1
- package/AudioV2/abstractAudio/abstractSoundSource.d.ts +6 -3
- package/AudioV2/abstractAudio/abstractSoundSource.js +1 -2
- package/AudioV2/abstractAudio/abstractSoundSource.js.map +1 -1
- package/AudioV2/webAudio/webAudioEngine.js +4 -1
- package/AudioV2/webAudio/webAudioEngine.js.map +1 -1
- package/AudioV2/webAudio/webAudioSoundSource.js +1 -1
- package/AudioV2/webAudio/webAudioSoundSource.js.map +1 -1
- package/AudioV2/webAudio/webAudioStaticSound.js +1 -1
- package/AudioV2/webAudio/webAudioStaticSound.js.map +1 -1
- package/AudioV2/webAudio/webAudioStreamingSound.js +1 -1
- package/AudioV2/webAudio/webAudioStreamingSound.js.map +1 -1
- package/Collisions/gpuPicker.d.ts +3 -0
- package/Collisions/gpuPicker.js +26 -2
- package/Collisions/gpuPicker.js.map +1 -1
- package/Engines/WebGPU/webgpuCacheBindGroups.js +4 -4
- package/Engines/WebGPU/webgpuCacheBindGroups.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/FlowGraph/Blocks/Data/Transformers/flowGraphJsonPointerParserBlock.js +16 -1
- package/FlowGraph/Blocks/Data/Transformers/flowGraphJsonPointerParserBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/csmShadowGeneratorBlock.d.ts +3 -0
- package/FrameGraph/Node/Blocks/Rendering/csmShadowGeneratorBlock.js +13 -0
- package/FrameGraph/Node/Blocks/Rendering/csmShadowGeneratorBlock.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.d.ts +7 -0
- package/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.js +17 -0
- package/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.js.map +1 -1
- package/FrameGraph/frameGraph.d.ts +2 -0
- package/FrameGraph/frameGraph.js +2 -0
- package/FrameGraph/frameGraph.js.map +1 -1
- package/Gizmos/planeRotationGizmo.js +1 -1
- package/Gizmos/planeRotationGizmo.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +2 -4
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
- package/Materials/Node/Blocks/GaussianSplatting/gaussianBlock.d.ts +8 -0
- package/Materials/Node/Blocks/GaussianSplatting/gaussianBlock.js +23 -3
- package/Materials/Node/Blocks/GaussianSplatting/gaussianBlock.js.map +1 -1
- package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.d.ts +13 -0
- package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.js +44 -0
- package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.js.map +1 -1
- package/Materials/Node/Blocks/GaussianSplatting/splatReaderBlock.js +3 -0
- package/Materials/Node/Blocks/GaussianSplatting/splatReaderBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/subSurfaceBlock.js +4 -1
- package/Materials/Node/Blocks/PBR/subSurfaceBlock.js.map +1 -1
- package/Materials/Node/nodeMaterialBuildState.d.ts +1 -1
- package/Materials/Node/nodeMaterialBuildState.js +6 -3
- package/Materials/Node/nodeMaterialBuildState.js.map +1 -1
- package/Materials/Node/nodeMaterialDefault.js +6 -1
- package/Materials/Node/nodeMaterialDefault.js.map +1 -1
- package/Materials/Textures/renderTargetTexture.d.ts +4 -4
- package/Materials/Textures/renderTargetTexture.js.map +1 -1
- package/Maths/ThinMaths/thinMath.matrix.functions.d.ts +11 -11
- package/Maths/ThinMaths/thinMath.matrix.functions.js.map +1 -1
- package/Maths/math.like.d.ts +2 -2
- package/Maths/math.like.js.map +1 -1
- package/Meshes/Builders/decalBuilder.js +3 -2
- package/Meshes/Builders/decalBuilder.js.map +1 -1
- package/Meshes/csg2.js +1 -1
- package/Meshes/csg2.js.map +1 -1
- package/Misc/minMaxReducer.js +5 -0
- package/Misc/minMaxReducer.js.map +1 -1
- package/Shaders/ShadersInclude/gaussianSplatting.js +4 -4
- package/Shaders/ShadersInclude/gaussianSplatting.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockReflectivity.js +2 -2
- package/Shaders/ShadersInclude/pbrBlockReflectivity.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockSubSurface.js +4 -4
- package/Shaders/ShadersInclude/pbrBlockSubSurface.js.map +1 -1
- package/Shaders/gaussianSplatting.vertex.js +3 -3
- package/Shaders/gaussianSplatting.vertex.js.map +1 -1
- package/Shaders/pbr.fragment.js +4 -1
- package/Shaders/pbr.fragment.js.map +1 -1
- package/Shaders/pbr.vertex.js +7 -2
- package/Shaders/pbr.vertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/gaussianSplatting.js +2 -2
- package/ShadersWGSL/ShadersInclude/gaussianSplatting.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockReflectivity.js +2 -2
- package/ShadersWGSL/ShadersInclude/pbrBlockReflectivity.js.map +1 -1
- package/ShadersWGSL/gaussianSplatting.vertex.js +3 -3
- package/ShadersWGSL/gaussianSplatting.vertex.js.map +1 -1
- package/package.json +1 -1
- package/scene.d.ts +4 -0
- package/scene.js +21 -15
- package/scene.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thinMath.matrix.functions.js","sourceRoot":"","sources":["../../../../../dev/core/src/Maths/ThinMaths/thinMath.matrix.functions.ts"],"names":[],"mappings":"AAIA,gBAAgB;AAChB,MAAM,OAAO,gBAAgB;;AACzB,gBAAgB;AACT,gCAAe,GAAG,CAAC,CAAC;AAG/B,SAAS,aAAa,CAClB,MAAkB,EAClB,EAAU,EACV,EAAU,EACV,EAAU,EACV,EAAU,EACV,EAAU,EACV,EAAU,EACV,EAAU,EACV,EAAU,EACV,EAAU,EACV,EAAU,EACV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AC,CAAC,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAC/B,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAC/B,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAC/B,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAC/B,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAC/B,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAC/B,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAC/B,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAC/B,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAC/B,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAC/B,MAAM,CAAC,EAAE,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAChC,MAAM,CAAC,EAAE,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAChC,MAAM,CAAC,EAAE,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAChC,MAAM,CAAC,EAAE,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAChC,MAAM,CAAC,EAAE,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAChC,MAAM,CAAC,EAAE,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAEhC,OAAO,IAAI,CAAC;AAChB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { IMatrixLike } from \"../math.like\";\r\nimport type { ThinMatrix } from \"./thinMath.matrix\";\r\n\r\n/** @internal */\r\nexport class MatrixManagement {\r\n /** @internal */\r\n static _UpdateFlagSeed = 0;\r\n}\r\n\r\nfunction SetMatrixData(\r\n result: ThinMatrix,\r\n m0: number,\r\n m1: number,\r\n m2: number,\r\n m3: number,\r\n m4: number,\r\n m5: number,\r\n m6: number,\r\n m7: number,\r\n m8: number,\r\n m9: number,\r\n m10: number,\r\n m11: number,\r\n m12: number,\r\n m13: number,\r\n m14: number,\r\n m15: number\r\n): void {\r\n const mat = result.asArray();\r\n mat[0] = m0;\r\n mat[1] = m1;\r\n mat[2] = m2;\r\n mat[3] = m3;\r\n mat[4] = m4;\r\n mat[5] = m5;\r\n mat[6] = m6;\r\n mat[7] = m7;\r\n mat[8] = m8;\r\n mat[9] = m9;\r\n mat[10] = m10;\r\n mat[11] = m11;\r\n mat[12] = m12;\r\n mat[13] = m13;\r\n mat[14] = m14;\r\n mat[15] = m15;\r\n\r\n MarkAsDirty(result);\r\n}\r\n\r\n/**\r\n * Marks the given matrix as dirty\r\n * @param matrix defines the matrix to mark as dirty\r\n */\r\nexport function MarkAsDirty(matrix: ThinMatrix): void {\r\n matrix.updateFlag = MatrixManagement._UpdateFlagSeed++;\r\n}\r\n\r\n/**\r\n * Sets the given matrix to the identity matrix\r\n * @param result defines the target matrix\r\n */\r\nexport function IdentityMatrixToRef(result: ThinMatrix): void {\r\n SetMatrixData(result, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0);\r\n}\r\n\r\n/**\r\n * Creates a new translation matrix.\r\n * @param x defines the x coordinate\r\n * @param y defines the y coordinate\r\n * @param z defines the z coordinate\r\n * @param result defines the target matrix\r\n */\r\nexport function TranslationMatrixToRef(x: number, y: number, z: number, result: ThinMatrix): void {\r\n SetMatrixData(result, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, x, y, z, 1.0);\r\n}\r\n\r\n/**\r\n * Creates a new scaling matrix.\r\n * @param x defines the scale factor on X axis\r\n * @param y defines the scale factor on Y axis\r\n * @param z defines the scale factor on Z axis\r\n * @param result defines the target matrix\r\n */\r\nexport function ScalingMatrixToRef(x: number, y: number, z: number, result: ThinMatrix): void {\r\n SetMatrixData(result, x, 0.0, 0.0, 0.0, 0.0, y, 0.0, 0.0, 0.0, 0.0, z, 0.0, 0.0, 0.0, 0.0, 1.0);\r\n}\r\n\r\n/**\r\n * Multiplies two matrices and stores the result in the target array.\r\n * @param a defines the first matrix\r\n * @param b defines the second matrix\r\n * @param output defines the target array\r\n * @param offset defines the offset in the target array where to store the result (0 by default)\r\n */\r\nexport function MultiplyMatricesToArray(a: IMatrixLike, b: IMatrixLike, output: Float32Array | Array<number>, offset = 0): void {\r\n const m = a.asArray();\r\n const otherM = b.asArray();\r\n const tm0 = m[0],\r\n tm1 = m[1],\r\n tm2 = m[2],\r\n tm3 = m[3];\r\n const tm4 = m[4],\r\n tm5 = m[5],\r\n tm6 = m[6],\r\n tm7 = m[7];\r\n const tm8 = m[8],\r\n tm9 = m[9],\r\n tm10 = m[10],\r\n tm11 = m[11];\r\n const tm12 = m[12],\r\n tm13 = m[13],\r\n tm14 = m[14],\r\n tm15 = m[15];\r\n\r\n const om0 = otherM[0],\r\n om1 = otherM[1],\r\n om2 = otherM[2],\r\n om3 = otherM[3];\r\n const om4 = otherM[4],\r\n om5 = otherM[5],\r\n om6 = otherM[6],\r\n om7 = otherM[7];\r\n const om8 = otherM[8],\r\n om9 = otherM[9],\r\n om10 = otherM[10],\r\n om11 = otherM[11];\r\n const om12 = otherM[12],\r\n om13 = otherM[13],\r\n om14 = otherM[14],\r\n om15 = otherM[15];\r\n output[offset] = tm0 * om0 + tm1 * om4 + tm2 * om8 + tm3 * om12;\r\n output[offset + 1] = tm0 * om1 + tm1 * om5 + tm2 * om9 + tm3 * om13;\r\n output[offset + 2] = tm0 * om2 + tm1 * om6 + tm2 * om10 + tm3 * om14;\r\n output[offset + 3] = tm0 * om3 + tm1 * om7 + tm2 * om11 + tm3 * om15;\r\n\r\n output[offset + 4] = tm4 * om0 + tm5 * om4 + tm6 * om8 + tm7 * om12;\r\n output[offset + 5] = tm4 * om1 + tm5 * om5 + tm6 * om9 + tm7 * om13;\r\n output[offset + 6] = tm4 * om2 + tm5 * om6 + tm6 * om10 + tm7 * om14;\r\n output[offset + 7] = tm4 * om3 + tm5 * om7 + tm6 * om11 + tm7 * om15;\r\n\r\n output[offset + 8] = tm8 * om0 + tm9 * om4 + tm10 * om8 + tm11 * om12;\r\n output[offset + 9] = tm8 * om1 + tm9 * om5 + tm10 * om9 + tm11 * om13;\r\n output[offset + 10] = tm8 * om2 + tm9 * om6 + tm10 * om10 + tm11 * om14;\r\n output[offset + 11] = tm8 * om3 + tm9 * om7 + tm10 * om11 + tm11 * om15;\r\n\r\n output[offset + 12] = tm12 * om0 + tm13 * om4 + tm14 * om8 + tm15 * om12;\r\n output[offset + 13] = tm12 * om1 + tm13 * om5 + tm14 * om9 + tm15 * om13;\r\n output[offset + 14] = tm12 * om2 + tm13 * om6 + tm14 * om10 + tm15 * om14;\r\n output[offset + 15] = tm12 * om3 + tm13 * om7 + tm14 * om11 + tm15 * om15;\r\n}\r\n\r\n/**\r\n * Multiplies two matrices and stores the result in a third matrix.\r\n * @param a defines the first matrix\r\n * @param b defines the second matrix\r\n * @param result defines the target matrix\r\n * @param offset defines the offset in the target matrix where to store the result (0 by default)\r\n */\r\nexport function MultiplyMatricesToRef(a: IMatrixLike, b: IMatrixLike, result: ThinMatrix, offset = 0): void {\r\n MultiplyMatricesToArray(a, b, result.asArray(), offset);\r\n MarkAsDirty(result);\r\n}\r\n\r\n/**\r\n * Populates the given matrix with the current matrix values\r\n * @param matrix defines the source matrix\r\n * @param target defines the target matrix\r\n */\r\nexport function CopyMatrixToRef(matrix: IMatrixLike, target: ThinMatrix) {\r\n CopyMatrixToArray(matrix, target.asArray());\r\n MarkAsDirty(target);\r\n}\r\n\r\n/**\r\n * Populates the given array from the starting index with the current matrix values\r\n * @param matrix defines the source matrix\r\n * @param array defines the target array\r\n * @param offset defines the offset in the target array where to start storing values\r\n */\r\nexport function CopyMatrixToArray(matrix: IMatrixLike, array: Float32Array | Array<number>, offset: number = 0) {\r\n const source = matrix.asArray();\r\n array[offset] = source[0];\r\n array[offset + 1] = source[1];\r\n array[offset + 2] = source[2];\r\n array[offset + 3] = source[3];\r\n array[offset + 4] = source[4];\r\n array[offset + 5] = source[5];\r\n array[offset + 6] = source[6];\r\n array[offset + 7] = source[7];\r\n array[offset + 8] = source[8];\r\n array[offset + 9] = source[9];\r\n array[offset + 10] = source[10];\r\n array[offset + 11] = source[11];\r\n array[offset + 12] = source[12];\r\n array[offset + 13] = source[13];\r\n array[offset + 14] = source[14];\r\n array[offset + 15] = source[15];\r\n}\r\n\r\n/**\r\n * Inverts the given matrix and stores the result in the target matrix\r\n * @param source defines the source matrix\r\n * @param target defines the target matrix\r\n * @returns true if the matrix was inverted successfully, false otherwise\r\n */\r\nexport function InvertMatrixToRef(source: IMatrixLike, target: ThinMatrix) {\r\n const result = InvertMatrixToArray(source, target.asArray());\r\n\r\n if (result) {\r\n MarkAsDirty(target);\r\n }\r\n\r\n return result;\r\n}\r\n\r\n/**\r\n * Inverts the given matrix and stores the result in the target array\r\n * @param source defines the source matrix\r\n * @param target defines the target array\r\n * @returns true if the matrix was inverted successfully, false otherwise\r\n */\r\nexport function InvertMatrixToArray(source: IMatrixLike, target: Float32Array | Array<number>) {\r\n // the inverse of a matrix is the transpose of cofactor matrix divided by the determinant\r\n const m = source.asArray();\r\n const m00 = m[0],\r\n m01 = m[1],\r\n m02 = m[2],\r\n m03 = m[3];\r\n const m10 = m[4],\r\n m11 = m[5],\r\n m12 = m[6],\r\n m13 = m[7];\r\n const m20 = m[8],\r\n m21 = m[9],\r\n m22 = m[10],\r\n m23 = m[11];\r\n const m30 = m[12],\r\n m31 = m[13],\r\n m32 = m[14],\r\n m33 = m[15];\r\n\r\n const det_22_33 = m22 * m33 - m32 * m23;\r\n const det_21_33 = m21 * m33 - m31 * m23;\r\n const det_21_32 = m21 * m32 - m31 * m22;\r\n const det_20_33 = m20 * m33 - m30 * m23;\r\n const det_20_32 = m20 * m32 - m22 * m30;\r\n const det_20_31 = m20 * m31 - m30 * m21;\r\n\r\n const cofact_00 = +(m11 * det_22_33 - m12 * det_21_33 + m13 * det_21_32);\r\n const cofact_01 = -(m10 * det_22_33 - m12 * det_20_33 + m13 * det_20_32);\r\n const cofact_02 = +(m10 * det_21_33 - m11 * det_20_33 + m13 * det_20_31);\r\n const cofact_03 = -(m10 * det_21_32 - m11 * det_20_32 + m12 * det_20_31);\r\n\r\n const det = m00 * cofact_00 + m01 * cofact_01 + m02 * cofact_02 + m03 * cofact_03;\r\n\r\n if (det === 0) {\r\n // Not invertible\r\n return false;\r\n }\r\n\r\n const detInv = 1 / det;\r\n const det_12_33 = m12 * m33 - m32 * m13;\r\n const det_11_33 = m11 * m33 - m31 * m13;\r\n const det_11_32 = m11 * m32 - m31 * m12;\r\n const det_10_33 = m10 * m33 - m30 * m13;\r\n const det_10_32 = m10 * m32 - m30 * m12;\r\n const det_10_31 = m10 * m31 - m30 * m11;\r\n const det_12_23 = m12 * m23 - m22 * m13;\r\n const det_11_23 = m11 * m23 - m21 * m13;\r\n const det_11_22 = m11 * m22 - m21 * m12;\r\n const det_10_23 = m10 * m23 - m20 * m13;\r\n const det_10_22 = m10 * m22 - m20 * m12;\r\n const det_10_21 = m10 * m21 - m20 * m11;\r\n\r\n const cofact_10 = -(m01 * det_22_33 - m02 * det_21_33 + m03 * det_21_32);\r\n const cofact_11 = +(m00 * det_22_33 - m02 * det_20_33 + m03 * det_20_32);\r\n const cofact_12 = -(m00 * det_21_33 - m01 * det_20_33 + m03 * det_20_31);\r\n const cofact_13 = +(m00 * det_21_32 - m01 * det_20_32 + m02 * det_20_31);\r\n\r\n const cofact_20 = +(m01 * det_12_33 - m02 * det_11_33 + m03 * det_11_32);\r\n const cofact_21 = -(m00 * det_12_33 - m02 * det_10_33 + m03 * det_10_32);\r\n const cofact_22 = +(m00 * det_11_33 - m01 * det_10_33 + m03 * det_10_31);\r\n const cofact_23 = -(m00 * det_11_32 - m01 * det_10_32 + m02 * det_10_31);\r\n\r\n const cofact_30 = -(m01 * det_12_23 - m02 * det_11_23 + m03 * det_11_22);\r\n const cofact_31 = +(m00 * det_12_23 - m02 * det_10_23 + m03 * det_10_22);\r\n const cofact_32 = -(m00 * det_11_23 - m01 * det_10_23 + m03 * det_10_21);\r\n const cofact_33 = +(m00 * det_11_22 - m01 * det_10_22 + m02 * det_10_21);\r\n\r\n target[0] = cofact_00 * detInv;\r\n target[1] = cofact_10 * detInv;\r\n target[2] = cofact_20 * detInv;\r\n target[3] = cofact_30 * detInv;\r\n target[4] = cofact_01 * detInv;\r\n target[5] = cofact_11 * detInv;\r\n target[6] = cofact_21 * detInv;\r\n target[7] = cofact_31 * detInv;\r\n target[8] = cofact_02 * detInv;\r\n target[9] = cofact_12 * detInv;\r\n target[10] = cofact_22 * detInv;\r\n target[11] = cofact_32 * detInv;\r\n target[12] = cofact_03 * detInv;\r\n target[13] = cofact_13 * detInv;\r\n target[14] = cofact_23 * detInv;\r\n target[15] = cofact_33 * detInv;\r\n\r\n return true;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"thinMath.matrix.functions.js","sourceRoot":"","sources":["../../../../../dev/core/src/Maths/ThinMaths/thinMath.matrix.functions.ts"],"names":[],"mappings":"AAIA,gBAAgB;AAChB,MAAM,OAAO,gBAAgB;;AACzB,gBAAgB;AACT,gCAAe,GAAG,CAAC,CAAC;AAG/B,SAAS,aAAa,CAClB,MAAmB,EACnB,EAAU,EACV,EAAU,EACV,EAAU,EACV,EAAU,EACV,EAAU,EACV,EAAU,EACV,EAAU,EACV,EAAU,EACV,EAAU,EACV,EAAU,EACV,GAAW,EACX,GAAW,EACX,GAAW,EACX,GAAW,EACX,GAAW,EACX,GAAW;IAEX,MAAM,GAAG,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;IAC7B,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;IACZ,GAAG,CAAC,CAAC,CAAC,GAAG,EA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C,GAAG,SAAS,GAAG,MAAM,CAAC;IAC/B,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAC/B,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAC/B,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAC/B,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAC/B,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAC/B,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAC/B,MAAM,CAAC,EAAE,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAChC,MAAM,CAAC,EAAE,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAChC,MAAM,CAAC,EAAE,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAChC,MAAM,CAAC,EAAE,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAChC,MAAM,CAAC,EAAE,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAChC,MAAM,CAAC,EAAE,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAEhC,OAAO,IAAI,CAAC;AAChB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { DeepImmutable } from \"core/types\";\r\nimport type { IMatrixLike } from \"../math.like\";\r\n\r\n/** @internal */\r\nexport class MatrixManagement {\r\n /** @internal */\r\n static _UpdateFlagSeed = 0;\r\n}\r\n\r\nfunction SetMatrixData(\r\n result: IMatrixLike,\r\n m0: number,\r\n m1: number,\r\n m2: number,\r\n m3: number,\r\n m4: number,\r\n m5: number,\r\n m6: number,\r\n m7: number,\r\n m8: number,\r\n m9: number,\r\n m10: number,\r\n m11: number,\r\n m12: number,\r\n m13: number,\r\n m14: number,\r\n m15: number\r\n): void {\r\n const mat = result.asArray();\r\n mat[0] = m0;\r\n mat[1] = m1;\r\n mat[2] = m2;\r\n mat[3] = m3;\r\n mat[4] = m4;\r\n mat[5] = m5;\r\n mat[6] = m6;\r\n mat[7] = m7;\r\n mat[8] = m8;\r\n mat[9] = m9;\r\n mat[10] = m10;\r\n mat[11] = m11;\r\n mat[12] = m12;\r\n mat[13] = m13;\r\n mat[14] = m14;\r\n mat[15] = m15;\r\n\r\n MarkAsDirty(result);\r\n}\r\n\r\n/**\r\n * Marks the given matrix as dirty\r\n * @param matrix defines the matrix to mark as dirty\r\n */\r\nexport function MarkAsDirty(matrix: IMatrixLike): void {\r\n matrix.updateFlag = MatrixManagement._UpdateFlagSeed++;\r\n}\r\n\r\n/**\r\n * Sets the given matrix to the identity matrix\r\n * @param result defines the target matrix\r\n */\r\nexport function IdentityMatrixToRef(result: IMatrixLike): void {\r\n SetMatrixData(result, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0);\r\n}\r\n\r\n/**\r\n * Creates a new translation matrix.\r\n * @param x defines the x coordinate\r\n * @param y defines the y coordinate\r\n * @param z defines the z coordinate\r\n * @param result defines the target matrix\r\n */\r\nexport function TranslationMatrixToRef(x: number, y: number, z: number, result: IMatrixLike): void {\r\n SetMatrixData(result, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, x, y, z, 1.0);\r\n}\r\n\r\n/**\r\n * Creates a new scaling matrix.\r\n * @param x defines the scale factor on X axis\r\n * @param y defines the scale factor on Y axis\r\n * @param z defines the scale factor on Z axis\r\n * @param result defines the target matrix\r\n */\r\nexport function ScalingMatrixToRef(x: number, y: number, z: number, result: IMatrixLike): void {\r\n SetMatrixData(result, x, 0.0, 0.0, 0.0, 0.0, y, 0.0, 0.0, 0.0, 0.0, z, 0.0, 0.0, 0.0, 0.0, 1.0);\r\n}\r\n\r\n/**\r\n * Multiplies two matrices and stores the result in the target array.\r\n * @param a defines the first matrix\r\n * @param b defines the second matrix\r\n * @param output defines the target array\r\n * @param offset defines the offset in the target array where to store the result (0 by default)\r\n */\r\nexport function MultiplyMatricesToArray(a: DeepImmutable<IMatrixLike>, b: DeepImmutable<IMatrixLike>, output: Float32Array | Array<number>, offset = 0): void {\r\n const m = a.asArray();\r\n const otherM = b.asArray();\r\n const tm0 = m[0],\r\n tm1 = m[1],\r\n tm2 = m[2],\r\n tm3 = m[3];\r\n const tm4 = m[4],\r\n tm5 = m[5],\r\n tm6 = m[6],\r\n tm7 = m[7];\r\n const tm8 = m[8],\r\n tm9 = m[9],\r\n tm10 = m[10],\r\n tm11 = m[11];\r\n const tm12 = m[12],\r\n tm13 = m[13],\r\n tm14 = m[14],\r\n tm15 = m[15];\r\n\r\n const om0 = otherM[0],\r\n om1 = otherM[1],\r\n om2 = otherM[2],\r\n om3 = otherM[3];\r\n const om4 = otherM[4],\r\n om5 = otherM[5],\r\n om6 = otherM[6],\r\n om7 = otherM[7];\r\n const om8 = otherM[8],\r\n om9 = otherM[9],\r\n om10 = otherM[10],\r\n om11 = otherM[11];\r\n const om12 = otherM[12],\r\n om13 = otherM[13],\r\n om14 = otherM[14],\r\n om15 = otherM[15];\r\n output[offset] = tm0 * om0 + tm1 * om4 + tm2 * om8 + tm3 * om12;\r\n output[offset + 1] = tm0 * om1 + tm1 * om5 + tm2 * om9 + tm3 * om13;\r\n output[offset + 2] = tm0 * om2 + tm1 * om6 + tm2 * om10 + tm3 * om14;\r\n output[offset + 3] = tm0 * om3 + tm1 * om7 + tm2 * om11 + tm3 * om15;\r\n\r\n output[offset + 4] = tm4 * om0 + tm5 * om4 + tm6 * om8 + tm7 * om12;\r\n output[offset + 5] = tm4 * om1 + tm5 * om5 + tm6 * om9 + tm7 * om13;\r\n output[offset + 6] = tm4 * om2 + tm5 * om6 + tm6 * om10 + tm7 * om14;\r\n output[offset + 7] = tm4 * om3 + tm5 * om7 + tm6 * om11 + tm7 * om15;\r\n\r\n output[offset + 8] = tm8 * om0 + tm9 * om4 + tm10 * om8 + tm11 * om12;\r\n output[offset + 9] = tm8 * om1 + tm9 * om5 + tm10 * om9 + tm11 * om13;\r\n output[offset + 10] = tm8 * om2 + tm9 * om6 + tm10 * om10 + tm11 * om14;\r\n output[offset + 11] = tm8 * om3 + tm9 * om7 + tm10 * om11 + tm11 * om15;\r\n\r\n output[offset + 12] = tm12 * om0 + tm13 * om4 + tm14 * om8 + tm15 * om12;\r\n output[offset + 13] = tm12 * om1 + tm13 * om5 + tm14 * om9 + tm15 * om13;\r\n output[offset + 14] = tm12 * om2 + tm13 * om6 + tm14 * om10 + tm15 * om14;\r\n output[offset + 15] = tm12 * om3 + tm13 * om7 + tm14 * om11 + tm15 * om15;\r\n}\r\n\r\n/**\r\n * Multiplies two matrices and stores the result in a third matrix.\r\n * @param a defines the first matrix\r\n * @param b defines the second matrix\r\n * @param result defines the target matrix\r\n * @param offset defines the offset in the target matrix where to store the result (0 by default)\r\n */\r\nexport function MultiplyMatricesToRef(a: DeepImmutable<IMatrixLike>, b: DeepImmutable<IMatrixLike>, result: IMatrixLike, offset = 0): void {\r\n MultiplyMatricesToArray(a, b, result.asArray(), offset);\r\n MarkAsDirty(result);\r\n}\r\n\r\n/**\r\n * Populates the given matrix with the current matrix values\r\n * @param matrix defines the source matrix\r\n * @param target defines the target matrix\r\n */\r\nexport function CopyMatrixToRef(matrix: DeepImmutable<IMatrixLike>, target: IMatrixLike) {\r\n CopyMatrixToArray(matrix, target.asArray());\r\n MarkAsDirty(target);\r\n}\r\n\r\n/**\r\n * Populates the given array from the starting index with the current matrix values\r\n * @param matrix defines the source matrix\r\n * @param array defines the target array\r\n * @param offset defines the offset in the target array where to start storing values\r\n */\r\nexport function CopyMatrixToArray(matrix: DeepImmutable<IMatrixLike>, array: Float32Array | Array<number>, offset: number = 0) {\r\n const source = matrix.asArray();\r\n array[offset] = source[0];\r\n array[offset + 1] = source[1];\r\n array[offset + 2] = source[2];\r\n array[offset + 3] = source[3];\r\n array[offset + 4] = source[4];\r\n array[offset + 5] = source[5];\r\n array[offset + 6] = source[6];\r\n array[offset + 7] = source[7];\r\n array[offset + 8] = source[8];\r\n array[offset + 9] = source[9];\r\n array[offset + 10] = source[10];\r\n array[offset + 11] = source[11];\r\n array[offset + 12] = source[12];\r\n array[offset + 13] = source[13];\r\n array[offset + 14] = source[14];\r\n array[offset + 15] = source[15];\r\n}\r\n\r\n/**\r\n * Inverts the given matrix and stores the result in the target matrix\r\n * @param source defines the source matrix\r\n * @param target defines the target matrix\r\n * @returns true if the matrix was inverted successfully, false otherwise\r\n */\r\nexport function InvertMatrixToRef(source: DeepImmutable<IMatrixLike>, target: IMatrixLike) {\r\n const result = InvertMatrixToArray(source, target.asArray());\r\n\r\n if (result) {\r\n MarkAsDirty(target);\r\n }\r\n\r\n return result;\r\n}\r\n\r\n/**\r\n * Inverts the given matrix and stores the result in the target array\r\n * @param source defines the source matrix\r\n * @param target defines the target array\r\n * @returns true if the matrix was inverted successfully, false otherwise\r\n */\r\nexport function InvertMatrixToArray(source: DeepImmutable<IMatrixLike>, target: Float32Array | Array<number>) {\r\n // the inverse of a matrix is the transpose of cofactor matrix divided by the determinant\r\n const m = source.asArray();\r\n const m00 = m[0],\r\n m01 = m[1],\r\n m02 = m[2],\r\n m03 = m[3];\r\n const m10 = m[4],\r\n m11 = m[5],\r\n m12 = m[6],\r\n m13 = m[7];\r\n const m20 = m[8],\r\n m21 = m[9],\r\n m22 = m[10],\r\n m23 = m[11];\r\n const m30 = m[12],\r\n m31 = m[13],\r\n m32 = m[14],\r\n m33 = m[15];\r\n\r\n const det_22_33 = m22 * m33 - m32 * m23;\r\n const det_21_33 = m21 * m33 - m31 * m23;\r\n const det_21_32 = m21 * m32 - m31 * m22;\r\n const det_20_33 = m20 * m33 - m30 * m23;\r\n const det_20_32 = m20 * m32 - m22 * m30;\r\n const det_20_31 = m20 * m31 - m30 * m21;\r\n\r\n const cofact_00 = +(m11 * det_22_33 - m12 * det_21_33 + m13 * det_21_32);\r\n const cofact_01 = -(m10 * det_22_33 - m12 * det_20_33 + m13 * det_20_32);\r\n const cofact_02 = +(m10 * det_21_33 - m11 * det_20_33 + m13 * det_20_31);\r\n const cofact_03 = -(m10 * det_21_32 - m11 * det_20_32 + m12 * det_20_31);\r\n\r\n const det = m00 * cofact_00 + m01 * cofact_01 + m02 * cofact_02 + m03 * cofact_03;\r\n\r\n if (det === 0) {\r\n // Not invertible\r\n return false;\r\n }\r\n\r\n const detInv = 1 / det;\r\n const det_12_33 = m12 * m33 - m32 * m13;\r\n const det_11_33 = m11 * m33 - m31 * m13;\r\n const det_11_32 = m11 * m32 - m31 * m12;\r\n const det_10_33 = m10 * m33 - m30 * m13;\r\n const det_10_32 = m10 * m32 - m30 * m12;\r\n const det_10_31 = m10 * m31 - m30 * m11;\r\n const det_12_23 = m12 * m23 - m22 * m13;\r\n const det_11_23 = m11 * m23 - m21 * m13;\r\n const det_11_22 = m11 * m22 - m21 * m12;\r\n const det_10_23 = m10 * m23 - m20 * m13;\r\n const det_10_22 = m10 * m22 - m20 * m12;\r\n const det_10_21 = m10 * m21 - m20 * m11;\r\n\r\n const cofact_10 = -(m01 * det_22_33 - m02 * det_21_33 + m03 * det_21_32);\r\n const cofact_11 = +(m00 * det_22_33 - m02 * det_20_33 + m03 * det_20_32);\r\n const cofact_12 = -(m00 * det_21_33 - m01 * det_20_33 + m03 * det_20_31);\r\n const cofact_13 = +(m00 * det_21_32 - m01 * det_20_32 + m02 * det_20_31);\r\n\r\n const cofact_20 = +(m01 * det_12_33 - m02 * det_11_33 + m03 * det_11_32);\r\n const cofact_21 = -(m00 * det_12_33 - m02 * det_10_33 + m03 * det_10_32);\r\n const cofact_22 = +(m00 * det_11_33 - m01 * det_10_33 + m03 * det_10_31);\r\n const cofact_23 = -(m00 * det_11_32 - m01 * det_10_32 + m02 * det_10_31);\r\n\r\n const cofact_30 = -(m01 * det_12_23 - m02 * det_11_23 + m03 * det_11_22);\r\n const cofact_31 = +(m00 * det_12_23 - m02 * det_10_23 + m03 * det_10_22);\r\n const cofact_32 = -(m00 * det_11_23 - m01 * det_10_23 + m03 * det_10_21);\r\n const cofact_33 = +(m00 * det_11_22 - m01 * det_10_22 + m02 * det_10_21);\r\n\r\n target[0] = cofact_00 * detInv;\r\n target[1] = cofact_10 * detInv;\r\n target[2] = cofact_20 * detInv;\r\n target[3] = cofact_30 * detInv;\r\n target[4] = cofact_01 * detInv;\r\n target[5] = cofact_11 * detInv;\r\n target[6] = cofact_21 * detInv;\r\n target[7] = cofact_31 * detInv;\r\n target[8] = cofact_02 * detInv;\r\n target[9] = cofact_12 * detInv;\r\n target[10] = cofact_22 * detInv;\r\n target[11] = cofact_32 * detInv;\r\n target[12] = cofact_03 * detInv;\r\n target[13] = cofact_13 * detInv;\r\n target[14] = cofact_23 * detInv;\r\n target[15] = cofact_33 * detInv;\r\n\r\n return true;\r\n}\r\n"]}
|
package/Maths/math.like.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { float, int,
|
|
1
|
+
import type { float, int, Tuple } from "../types.js";
|
|
2
2
|
/**
|
|
3
3
|
* @internal
|
|
4
4
|
*/
|
|
@@ -59,7 +59,7 @@ export interface IPlaneLike {
|
|
|
59
59
|
* @internal
|
|
60
60
|
*/
|
|
61
61
|
export interface IMatrixLike {
|
|
62
|
-
asArray():
|
|
62
|
+
asArray(): Tuple<number, 16>;
|
|
63
63
|
updateFlag: int;
|
|
64
64
|
}
|
|
65
65
|
/**
|
package/Maths/math.like.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"math.like.js","sourceRoot":"","sources":["../../../../dev/core/src/Maths/math.like.ts"],"names":[],"mappings":"","sourcesContent":["import type { float, int,
|
|
1
|
+
{"version":3,"file":"math.like.js","sourceRoot":"","sources":["../../../../dev/core/src/Maths/math.like.ts"],"names":[],"mappings":"","sourcesContent":["import type { float, int, Tuple } from \"../types\";\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface IColor3Like {\r\n r: float;\r\n g: float;\r\n b: float;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface IColor4Like extends IColor3Like {\r\n a: float;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface IVector2Like {\r\n x: float;\r\n y: float;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface IVector3Like extends IVector2Like {\r\n z: float;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface IVector3LikeInternal {\r\n _x: number;\r\n _y: number;\r\n _z: number;\r\n _isDirty?: boolean;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface IVector4Like extends IVector3Like {\r\n w: float;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface IQuaternionLike extends IVector3Like {\r\n w: float;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface IPlaneLike {\r\n normal: IVector3Like;\r\n d: float;\r\n normalize(): void;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface IMatrixLike {\r\n asArray(): Tuple<number, 16>;\r\n updateFlag: int;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface IViewportLike {\r\n x: float;\r\n y: float;\r\n width: float;\r\n height: float;\r\n}\r\n"]}
|
|
@@ -47,10 +47,11 @@ class DecalVertex {
|
|
|
47
47
|
*/
|
|
48
48
|
export function CreateDecal(name, sourceMesh, options) {
|
|
49
49
|
const hasSkeleton = !!sourceMesh.skeleton;
|
|
50
|
+
const hasMorphTargets = !!sourceMesh.morphTargetManager?.numTargets;
|
|
50
51
|
const useLocalComputation = options.localMode || hasSkeleton;
|
|
51
52
|
const indices = sourceMesh.getIndices();
|
|
52
|
-
const positions = hasSkeleton ? sourceMesh.getPositionData(true, true) : sourceMesh.getVerticesData(VertexBuffer.PositionKind);
|
|
53
|
-
const normals = hasSkeleton ? sourceMesh.getNormalsData(true, true) : sourceMesh.getVerticesData(VertexBuffer.NormalKind);
|
|
53
|
+
const positions = hasSkeleton || hasMorphTargets ? sourceMesh.getPositionData(true, true) : sourceMesh.getVerticesData(VertexBuffer.PositionKind);
|
|
54
|
+
const normals = hasSkeleton || hasMorphTargets ? sourceMesh.getNormalsData(true, true) : sourceMesh.getVerticesData(VertexBuffer.NormalKind);
|
|
54
55
|
const localPositions = useLocalComputation ? (hasSkeleton ? sourceMesh.getVerticesData(VertexBuffer.PositionKind) : positions) : null;
|
|
55
56
|
const localNormals = useLocalComputation ? (hasSkeleton ? sourceMesh.getVerticesData(VertexBuffer.NormalKind) : normals) : null;
|
|
56
57
|
const uvs = sourceMesh.getVerticesData(VertexBuffer.UVKind);
|
|
@@ -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,IAAI,EAAE,MAAM,mCAAmC,CAAC;AACzD,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,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAE9E,MAAM,MAAM,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACpC,MAAM,MAAM,GAAG,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACrC,MAAM,MAAM,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACpC,MAAM,MAAM,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACrC,MA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,CAAC;IAC3C,CAAC;IACD,IAAI,UAAU,CAAC,oBAAoB,EAAE,MAAM,KAAK,CAAC,EAAE,CAAC;QAChD,UAAU,CAAC,oBAAoB,GAAG,IAAI,CAAC;IAC3C,CAAC;IAED,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,CAAC;QACtB,KAAK,CAAC,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC;QACrC,KAAK,CAAC,MAAM,GAAG,UAAU,CAAC;IAC9B,CAAC;SAAM,CAAC;QACJ,KAAK,CAAC,QAAQ,GAAG,QAAQ,CAAC,KAAK,EAAE,CAAC;QAClC,KAAK,CAAC,QAAQ,GAAG,IAAI,OAAO,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;IACpD,CAAC;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 { Lerp } from \"../../Maths/math.scalar.functions\";\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 { useOpenGLOrientationForUV } 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], 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] = 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) {\r\n continue;\r\n }\r\n\r\n indices[index] = ind;\r\n weights[index] = 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 faceVertices[1] = extractDecalVector3(index + 1, transformMatrix);\r\n faceVertices[2] = extractDecalVector3(index + 2, transformMatrix);\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) {\r\n continue;\r\n }\r\n faceVertices = clip(faceVertices, XnAxis);\r\n if (!faceVertices) {\r\n continue;\r\n }\r\n faceVertices = clip(faceVertices, YpAxis);\r\n if (!faceVertices) {\r\n continue;\r\n }\r\n faceVertices = clip(faceVertices, YnAxis);\r\n if (!faceVertices) {\r\n continue;\r\n }\r\n faceVertices = clip(faceVertices, ZpAxis);\r\n if (!faceVertices) {\r\n continue;\r\n }\r\n faceVertices = clip(faceVertices, ZnAxis);\r\n if (!faceVertices) {\r\n continue;\r\n }\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 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 vertexData.uvs.push(0.5 + vertex.position.x / size.x);\r\n const v = 0.5 + vertex.position.y / size.y;\r\n vertexData.uvs.push(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) {\r\n vertexData.indices = null;\r\n }\r\n if (vertexData.positions.length === 0) {\r\n vertexData.positions = null;\r\n }\r\n if (vertexData.normals.length === 0) {\r\n vertexData.normals = null;\r\n }\r\n if (vertexData.uvs.length === 0) {\r\n vertexData.uvs = null;\r\n }\r\n if (vertexData.matricesIndices?.length === 0) {\r\n vertexData.matricesIndices = null;\r\n }\r\n if (vertexData.matricesWeights?.length === 0) {\r\n vertexData.matricesWeights = null;\r\n }\r\n if (vertexData.matricesIndicesExtra?.length === 0) {\r\n vertexData.matricesIndicesExtra = null;\r\n }\r\n if (vertexData.matricesWeightsExtra?.length === 0) {\r\n vertexData.matricesWeightsExtra = null;\r\n }\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,IAAI,EAAE,MAAM,mCAAmC,CAAC;AACzD,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,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAE9E,MAAM,MAAM,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACpC,MAAM,MAAM,GAAG,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACrC,MAAM,MAAM,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACpC,MAAM,MAAM,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACrC,MAAM,MAAM,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACpC,MAAM,MAAM,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAErC,gBAAg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E,CAAC;QAChD,UAAU,CAAC,oBAAoB,GAAG,IAAI,CAAC;IAC3C,CAAC;IAED,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,CAAC;QACtB,KAAK,CAAC,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC;QACrC,KAAK,CAAC,MAAM,GAAG,UAAU,CAAC;IAC9B,CAAC;SAAM,CAAC;QACJ,KAAK,CAAC,QAAQ,GAAG,QAAQ,CAAC,KAAK,EAAE,CAAC;QAClC,KAAK,CAAC,QAAQ,GAAG,IAAI,OAAO,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;IACpD,CAAC;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 { Lerp } from \"../../Maths/math.scalar.functions\";\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 { useOpenGLOrientationForUV } 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 hasMorphTargets = !!sourceMesh.morphTargetManager?.numTargets;\r\n const useLocalComputation = options.localMode || hasSkeleton;\r\n\r\n const indices = <IndicesArray>sourceMesh.getIndices();\r\n const positions = hasSkeleton || hasMorphTargets ? sourceMesh.getPositionData(true, true) : sourceMesh.getVerticesData(VertexBuffer.PositionKind);\r\n const normals = hasSkeleton || hasMorphTargets ? 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], 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] = 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) {\r\n continue;\r\n }\r\n\r\n indices[index] = ind;\r\n weights[index] = 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 faceVertices[1] = extractDecalVector3(index + 1, transformMatrix);\r\n faceVertices[2] = extractDecalVector3(index + 2, transformMatrix);\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) {\r\n continue;\r\n }\r\n faceVertices = clip(faceVertices, XnAxis);\r\n if (!faceVertices) {\r\n continue;\r\n }\r\n faceVertices = clip(faceVertices, YpAxis);\r\n if (!faceVertices) {\r\n continue;\r\n }\r\n faceVertices = clip(faceVertices, YnAxis);\r\n if (!faceVertices) {\r\n continue;\r\n }\r\n faceVertices = clip(faceVertices, ZpAxis);\r\n if (!faceVertices) {\r\n continue;\r\n }\r\n faceVertices = clip(faceVertices, ZnAxis);\r\n if (!faceVertices) {\r\n continue;\r\n }\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 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 vertexData.uvs.push(0.5 + vertex.position.x / size.x);\r\n const v = 0.5 + vertex.position.y / size.y;\r\n vertexData.uvs.push(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) {\r\n vertexData.indices = null;\r\n }\r\n if (vertexData.positions.length === 0) {\r\n vertexData.positions = null;\r\n }\r\n if (vertexData.normals.length === 0) {\r\n vertexData.normals = null;\r\n }\r\n if (vertexData.uvs.length === 0) {\r\n vertexData.uvs = null;\r\n }\r\n if (vertexData.matricesIndices?.length === 0) {\r\n vertexData.matricesIndices = null;\r\n }\r\n if (vertexData.matricesWeights?.length === 0) {\r\n vertexData.matricesWeights = null;\r\n }\r\n if (vertexData.matricesIndicesExtra?.length === 0) {\r\n vertexData.matricesIndicesExtra = null;\r\n }\r\n if (vertexData.matricesWeightsExtra?.length === 0) {\r\n vertexData.matricesWeightsExtra = null;\r\n }\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"]}
|
package/Meshes/csg2.js
CHANGED
|
@@ -343,7 +343,7 @@ export function IsCSG2Ready() {
|
|
|
343
343
|
*/
|
|
344
344
|
export async function InitializeCSG2Async(options) {
|
|
345
345
|
const localOptions = {
|
|
346
|
-
manifoldUrl: "https://unpkg.com/manifold-3d@3.0
|
|
346
|
+
manifoldUrl: "https://unpkg.com/manifold-3d@3.1.0",
|
|
347
347
|
...options,
|
|
348
348
|
};
|
|
349
349
|
if (Manifold) {
|
package/Meshes/csg2.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"csg2.js","sourceRoot":"","sources":["../../../../dev/core/src/Meshes/csg2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAG9B,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,0BAAyB;AAC1C,OAAO,EAAE,aAAa,EAAE,sCAAqC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,sBAAsB,EAAE,mCAAkC;AAGnE,OAAO,EAAE,OAAO,EAAE,gCAA+B;AAEjD;;GAEG;AACH,gEAAgE;AAChE,IAAI,QAAa,CAAC;AAElB;;GAEG;AACH,gEAAgE;AAChE,IAAI,eAAsD,CAAC;AAE3D;;GAEG;AACH,gEAAgE;AAChE,IAAI,YAAiB,CAAC;AAEtB;;GAEG;AACH,gEAAgE;AAChE,IAAI,OAAe,CAAC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from \"./mesh\";\r\nimport type { IDisposable, Scene } from \"core/scene\";\r\nimport type { IVertexDataLike } from \"./mesh.vertexData\";\r\nimport { VertexData } from \"./mesh.vertexData\";\r\nimport { VertexBuffer } from \"../Buffers/buffer\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport { MultiMaterial } from \"core/Materials/multiMaterial\";\r\nimport { SubMesh } from \"./subMesh\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport { _LoadScriptModuleAsync } from \"core/Misc/tools.internals\";\r\nimport type { FloatArray, Nullable } from \"core/types\";\r\nimport type { Matrix } from \"core/Maths/math.vector\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\n\r\n/**\r\n * Main manifold library\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nlet Manifold: any;\r\n\r\n/**\r\n * Promise to wait for the manifold library to be ready\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nlet ManifoldPromise: Promise<{ Manifold: any; Mesh: any }>;\r\n\r\n/**\r\n * Manifold mesh\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nlet ManifoldMesh: any;\r\n\r\n/**\r\n * First ID to use for materials indexing\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nlet FirstID: number;\r\n\r\n/**\r\n * Interface to customize the Manifold library import\r\n */\r\nexport interface ICSG2Options {\r\n /**\r\n * Custom manifold URL\r\n */\r\n manifoldUrl?: string;\r\n /**\r\n * Custom manifold instance\r\n */\r\n manifoldInstance: any;\r\n /**\r\n * Custom manifold mesh instance\r\n */\r\n manifoldMeshInstance: any;\r\n}\r\n\r\n/**\r\n * Interface to customize the mesh rebuild options\r\n */\r\nexport interface IMeshRebuildOptions {\r\n /**\r\n * Rebuild normals\r\n */\r\n rebuildNormals?: boolean;\r\n /**\r\n * True to center the mesh on 0,0,0\r\n */\r\n centerMesh?: boolean;\r\n /**\r\n * Defines a material to use for that mesh. When not defined the system will either reuse the one from the source or create a multimaterial if several materials were involved\r\n */\r\n materialToUse?: Material;\r\n}\r\n\r\n/**\r\n * Interface to customize the vertex data rebuild options\r\n */\r\nexport interface IVertexDataRebuildOptions {\r\n /**\r\n * Rebuild normals\r\n */\r\n rebuildNormals?: boolean;\r\n}\r\n\r\ninterface IManifoldMesh {\r\n numProp: number;\r\n vertProperties: Float32Array;\r\n triVerts: Uint32Array;\r\n runIndex: Uint32Array;\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n runOriginalID: Uint32Array;\r\n numRun: number;\r\n}\r\n\r\ninterface IManifoldVertexComponent {\r\n stride: number;\r\n kind: string;\r\n data?: FloatArray;\r\n}\r\n\r\n/**\r\n * Wrapper around the Manifold library\r\n * https://manifoldcad.org/\r\n * Use this class to perform fast boolean operations on meshes\r\n * @see [basic operations](https://playground.babylonjs.com/#IW43EB#15)\r\n * @see [skull vs box](https://playground.babylonjs.com/#JUKXQD#6218)\r\n * @see [skull vs vertex data](https://playground.babylonjs.com/#JUKXQD#6219)\r\n */\r\nexport class CSG2 implements IDisposable {\r\n private _manifold: any;\r\n private _numProp: number;\r\n private _vertexStructure: IManifoldVertexComponent[];\r\n\r\n /**\r\n * Return the size of a vertex (at least 3 for the position)\r\n */\r\n public get numProp() {\r\n return this._numProp;\r\n }\r\n\r\n private constructor(manifold: any, numProp: number, vertexStructure: IManifoldVertexComponent[]) {\r\n this._manifold = manifold;\r\n this._numProp = numProp;\r\n this._vertexStructure = vertexStructure;\r\n }\r\n\r\n private _process(operation: \"difference\" | \"intersection\" | \"union\", csg: CSG2) {\r\n if (this.numProp !== csg.numProp) {\r\n throw new Error(\"CSG must be used with geometries having the same number of properties\");\r\n }\r\n return new CSG2(Manifold[operation](this._manifold, csg._manifold), this.numProp, this._vertexStructure);\r\n }\r\n\r\n /**\r\n * Run a difference operation between two CSG\r\n * @param csg defines the CSG to use to create the difference\r\n * @returns a new csg\r\n */\r\n public subtract(csg: CSG2) {\r\n return this._process(\"difference\", csg);\r\n }\r\n\r\n /**\r\n * Run an intersection operation between two CSG\r\n * @param csg defines the CSG to use to create the intersection\r\n * @returns a new csg\r\n */\r\n public intersect(csg: CSG2) {\r\n return this._process(\"intersection\", csg);\r\n }\r\n\r\n /**\r\n * Run an union operation between two CSG\r\n * @param csg defines the CSG to use to create the union\r\n * @returns a new csg\r\n */\r\n public add(csg: CSG2) {\r\n return this._process(\"union\", csg);\r\n }\r\n\r\n /**\r\n * Print debug information about the CSG\r\n */\r\n public printDebug() {\r\n Logger.Log(\"Genus:\" + this._manifold.genus());\r\n const properties = this._manifold.getProperties();\r\n Logger.Log(\"Volume:\" + properties.volume);\r\n Logger.Log(\"surface area:\" + properties.surfaceArea);\r\n }\r\n\r\n /**\r\n * Generate a vertex data from the CSG\r\n * @param options defines the options to use to rebuild the vertex data\r\n * @returns a new vertex data\r\n */\r\n public toVertexData(options?: Partial<IVertexDataRebuildOptions>): VertexData {\r\n const localOptions = {\r\n rebuildNormals: false,\r\n ...options,\r\n };\r\n const vertexData = new VertexData();\r\n const normalComponent = this._vertexStructure.find((c) => c.kind === VertexBuffer.NormalKind);\r\n const manifoldMesh: IManifoldMesh = this._manifold.getMesh(localOptions.rebuildNormals && normalComponent ? [3, 4, 5] : undefined);\r\n\r\n vertexData.indices = manifoldMesh.triVerts.length > 65535 ? new Uint32Array(manifoldMesh.triVerts) : new Uint16Array(manifoldMesh.triVerts);\r\n\r\n for (let i = 0; i < manifoldMesh.triVerts.length; i += 3) {\r\n vertexData.indices[i] = manifoldMesh.triVerts[i + 2];\r\n vertexData.indices[i + 1] = manifoldMesh.triVerts[i + 1];\r\n vertexData.indices[i + 2] = manifoldMesh.triVerts[i];\r\n }\r\n\r\n const vertexCount = manifoldMesh.vertProperties.length / manifoldMesh.numProp;\r\n\r\n // Attributes\r\n let offset = 0;\r\n for (let componentIndex = 0; componentIndex < this._vertexStructure.length; componentIndex++) {\r\n const component = this._vertexStructure[componentIndex];\r\n\r\n const data = new Float32Array(vertexCount * component.stride);\r\n for (let i = 0; i < vertexCount; i++) {\r\n for (let strideIndex = 0; strideIndex < component.stride; strideIndex++) {\r\n data[i * component.stride + strideIndex] = manifoldMesh.vertProperties[i * manifoldMesh.numProp + offset + strideIndex];\r\n }\r\n }\r\n vertexData.set(data, component.kind);\r\n offset += component.stride;\r\n }\r\n\r\n // Rebuild mesh from vertex data\r\n return vertexData;\r\n }\r\n\r\n /**\r\n * Generate a mesh from the CSG\r\n * @param name defines the name of the mesh\r\n * @param scene defines the scene to use to create the mesh\r\n * @param options defines the options to use to rebuild the mesh\r\n * @returns a new Mesh\r\n */\r\n public toMesh(name: string, scene?: Scene, options?: Partial<IMeshRebuildOptions>): Mesh {\r\n const localOptions = {\r\n rebuildNormals: false,\r\n centerMesh: true,\r\n ...options,\r\n };\r\n const vertexData = this.toVertexData({ rebuildNormals: localOptions.rebuildNormals });\r\n const normalComponent = this._vertexStructure.find((c) => c.kind === VertexBuffer.NormalKind);\r\n const manifoldMesh: IManifoldMesh = this._manifold.getMesh(localOptions.rebuildNormals && normalComponent ? [3, 4, 5] : undefined);\r\n const vertexCount = manifoldMesh.vertProperties.length / manifoldMesh.numProp;\r\n\r\n // Rebuild mesh from vertex data\r\n const output = new Mesh(name, scene);\r\n vertexData.applyToMesh(output);\r\n\r\n // Center mesh\r\n if (localOptions.centerMesh) {\r\n const extents = output.getBoundingInfo().boundingSphere.center;\r\n output.position.set(-extents.x, -extents.y, -extents.z);\r\n output.bakeCurrentTransformIntoVertices();\r\n }\r\n\r\n // Submeshes\r\n let id = manifoldMesh.runOriginalID[0];\r\n let start = manifoldMesh.runIndex[0];\r\n let materialIndex = 0;\r\n const materials: Material[] = [];\r\n scene = output.getScene();\r\n for (let run = 0; run < manifoldMesh.numRun; ++run) {\r\n const nextID = manifoldMesh.runOriginalID[run + 1];\r\n if (nextID !== id) {\r\n const end = manifoldMesh.runIndex[run + 1];\r\n new SubMesh(materialIndex, 0, vertexCount, start, end - start, output);\r\n materials.push(scene.getMaterialByUniqueID(id - FirstID) || scene.defaultMaterial);\r\n id = nextID;\r\n start = end;\r\n materialIndex++;\r\n }\r\n }\r\n\r\n if (localOptions.materialToUse) {\r\n output.material = localOptions.materialToUse;\r\n } else {\r\n if (materials.length > 1) {\r\n const multiMaterial = new MultiMaterial(name, scene);\r\n multiMaterial.subMaterials = materials;\r\n output.material = multiMaterial;\r\n } else {\r\n if (output.subMeshes.length > 1) {\r\n // Remove the submeshes as they are not needed\r\n output._createGlobalSubMesh(true);\r\n }\r\n output.material = materials[0];\r\n }\r\n }\r\n\r\n return output;\r\n }\r\n\r\n /**\r\n * Dispose the CSG resources\r\n */\r\n public dispose() {\r\n if (this._manifold) {\r\n this._manifold.delete();\r\n this._manifold = null;\r\n }\r\n }\r\n\r\n private static _ProcessData(\r\n vertexCount: number,\r\n triVerts: Uint32Array,\r\n structure: IManifoldVertexComponent[],\r\n numProp: number,\r\n runIndex?: Uint32Array,\r\n runOriginalID?: Uint32Array\r\n ) {\r\n const vertProperties = new Float32Array(vertexCount * structure.reduce((acc, cur) => acc + cur.stride, 0));\r\n\r\n for (let i = 0; i < vertexCount; i++) {\r\n let offset = 0;\r\n for (let idx = 0; idx < structure.length; idx++) {\r\n const component = structure[idx];\r\n\r\n for (let strideIndex = 0; strideIndex < component.stride; strideIndex++) {\r\n vertProperties[i * numProp + offset + strideIndex] = component.data![i * component.stride + strideIndex];\r\n }\r\n offset += component.stride;\r\n }\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n const manifoldMesh = new ManifoldMesh({ numProp: numProp, vertProperties, triVerts, runIndex, runOriginalID });\r\n manifoldMesh.merge();\r\n\r\n let returnValue: CSG2;\r\n try {\r\n returnValue = new CSG2(new Manifold(manifoldMesh), numProp, structure);\r\n } catch (e) {\r\n throw new Error(\"Error while creating the CSG: \" + e.message);\r\n }\r\n\r\n return returnValue;\r\n }\r\n\r\n private static _Construct(data: IVertexDataLike, worldMatrix: Nullable<Matrix>, runIndex?: Uint32Array, runOriginalID?: Uint32Array) {\r\n // Create the MeshGL for I/O with Manifold library.\r\n const triVerts = new Uint32Array(data.indices!.length);\r\n\r\n // Revert order\r\n for (let i = 0; i < data.indices!.length; i += 3) {\r\n triVerts[i] = data.indices![i + 2];\r\n triVerts[i + 1] = data.indices![i + 1];\r\n triVerts[i + 2] = data.indices![i];\r\n }\r\n\r\n const tempVector3 = new Vector3();\r\n let numProp = 3;\r\n const structure: IManifoldVertexComponent[] = [{ stride: 3, kind: VertexBuffer.PositionKind }];\r\n\r\n if (!worldMatrix) {\r\n structure[0].data = data.positions!;\r\n } else {\r\n const positions = new Float32Array(data.positions!.length);\r\n for (let i = 0; i < data.positions!.length; i += 3) {\r\n Vector3.TransformCoordinatesFromFloatsToRef(data.positions![i], data.positions![i + 1], data.positions![i + 2], worldMatrix, tempVector3);\r\n tempVector3.toArray(positions, i);\r\n }\r\n structure[0].data = positions;\r\n }\r\n\r\n // Normals\r\n const sourceNormals = data.normals!;\r\n if (sourceNormals) {\r\n numProp += 3;\r\n structure.push({ stride: 3, kind: VertexBuffer.NormalKind });\r\n if (!worldMatrix) {\r\n structure[1].data = sourceNormals;\r\n } else {\r\n const normals = new Float32Array(sourceNormals.length);\r\n for (let i = 0; i < sourceNormals.length; i += 3) {\r\n Vector3.TransformNormalFromFloatsToRef(sourceNormals[i], sourceNormals[i + 1], sourceNormals[i + 2], worldMatrix, tempVector3);\r\n tempVector3.toArray(normals, i);\r\n }\r\n structure[1].data = normals;\r\n }\r\n }\r\n\r\n // UVs\r\n for (const kind of [VertexBuffer.UVKind, VertexBuffer.UV2Kind, VertexBuffer.UV3Kind, VertexBuffer.UV4Kind, VertexBuffer.UV5Kind, VertexBuffer.UV6Kind]) {\r\n const sourceUV = (data as any)[kind === VertexBuffer.UVKind ? \"uvs\" : kind];\r\n if (sourceUV) {\r\n numProp += 2;\r\n structure.push({ stride: 2, kind: kind, data: sourceUV });\r\n }\r\n }\r\n\r\n // Colors\r\n const sourceColors = data.colors;\r\n if (sourceColors) {\r\n numProp += 4;\r\n structure.push({ stride: 4, kind: VertexBuffer.ColorKind, data: sourceColors });\r\n }\r\n\r\n return this._ProcessData(data.positions!.length / 3, triVerts, structure, numProp, runIndex, runOriginalID);\r\n }\r\n\r\n /**\r\n * Create a new Constructive Solid Geometry from a vertexData\r\n * @param vertexData defines the vertexData to use to create the CSG\r\n * @returns a new CSG2 class\r\n */\r\n public static FromVertexData(vertexData: VertexData): CSG2 {\r\n const sourceVertices = vertexData.positions;\r\n const sourceIndices = vertexData.indices;\r\n\r\n if (!sourceVertices || !sourceIndices) {\r\n throw new Error(\"The vertexData must at least have positions and indices\");\r\n }\r\n\r\n return this._Construct(vertexData, null);\r\n }\r\n\r\n /**\r\n * Create a new Constructive Solid Geometry from a mesh\r\n * @param mesh defines the mesh to use to create the CSG\r\n * @param ignoreWorldMatrix defines if the world matrix should be ignored\r\n * @returns a new CSG2 class\r\n */\r\n public static FromMesh(mesh: Mesh, ignoreWorldMatrix = false): CSG2 {\r\n const sourceVertices = mesh.getVerticesData(VertexBuffer.PositionKind);\r\n const sourceIndices = mesh.getIndices();\r\n const worldMatrix = mesh.computeWorldMatrix(true);\r\n\r\n if (!sourceVertices || !sourceIndices) {\r\n throw new Error(\"The mesh must at least have positions and indices\");\r\n }\r\n\r\n // Create a triangle run for each submesh (material)\r\n const starts = [...Array(mesh.subMeshes.length)].map((_, idx) => mesh.subMeshes[idx].indexStart);\r\n\r\n // Map the materials to ID.\r\n const sourceMaterial = mesh.material || mesh.getScene().defaultMaterial;\r\n const isMultiMaterial = sourceMaterial.getClassName() === \"MultiMaterial\";\r\n const originalIDs = [...Array(mesh.subMeshes.length)].map((_, idx) => {\r\n if (isMultiMaterial) {\r\n return FirstID + (sourceMaterial as MultiMaterial).subMaterials[mesh.subMeshes[idx].materialIndex]!.uniqueId;\r\n }\r\n\r\n return FirstID + sourceMaterial.uniqueId;\r\n });\r\n\r\n // List the runs in sequence.\r\n const indices = Array.from(starts.keys());\r\n indices.sort((a, b) => starts[a] - starts[b]);\r\n const runIndex = new Uint32Array(indices.map((i) => starts[i]));\r\n const runOriginalID = new Uint32Array(indices.map((i) => originalIDs[i]));\r\n\r\n // Process\r\n const data = {\r\n positions: sourceVertices,\r\n indices: sourceIndices,\r\n normals: mesh.getVerticesData(VertexBuffer.NormalKind),\r\n colors: mesh.getVerticesData(VertexBuffer.ColorKind),\r\n uvs: mesh.getVerticesData(VertexBuffer.UVKind),\r\n uvs2: mesh.getVerticesData(VertexBuffer.UV2Kind),\r\n uvs3: mesh.getVerticesData(VertexBuffer.UV3Kind),\r\n uvs4: mesh.getVerticesData(VertexBuffer.UV4Kind),\r\n uvs5: mesh.getVerticesData(VertexBuffer.UV5Kind),\r\n uvs6: mesh.getVerticesData(VertexBuffer.UV6Kind),\r\n };\r\n return this._Construct(data, ignoreWorldMatrix ? null : worldMatrix, runIndex, runOriginalID);\r\n }\r\n}\r\n\r\n/**\r\n * Checks if the Manifold library is ready\r\n * @returns true if the Manifold library is ready\r\n */\r\nexport function IsCSG2Ready() {\r\n return Manifold !== undefined;\r\n}\r\n\r\n/**\r\n * Initialize the Manifold library\r\n * @param options defines the options to use to initialize the library\r\n */\r\nexport async function InitializeCSG2Async(options?: Partial<ICSG2Options>) {\r\n const localOptions = {\r\n manifoldUrl: \"https://unpkg.com/manifold-3d@3.0.1\",\r\n ...options,\r\n };\r\n\r\n if (Manifold) {\r\n return; // Already initialized\r\n }\r\n\r\n if (ManifoldPromise) {\r\n await ManifoldPromise;\r\n return;\r\n }\r\n\r\n if (localOptions.manifoldInstance) {\r\n Manifold = localOptions.manifoldInstance;\r\n ManifoldMesh = localOptions.manifoldMeshInstance;\r\n } else {\r\n ManifoldPromise = _LoadScriptModuleAsync(\r\n `\r\n import Module from '${localOptions.manifoldUrl}/manifold.js';\r\n const wasm = await Module();\r\n wasm.setup();\r\n const {Manifold, Mesh} = wasm;\r\n const returnedValue = {Manifold, Mesh};\r\n `\r\n );\r\n\r\n const result = await ManifoldPromise;\r\n Manifold = result.Manifold;\r\n ManifoldMesh = result.Mesh;\r\n }\r\n\r\n // Reserve IDs for materials (we consider that there will be no more than 65536 materials)\r\n FirstID = Manifold.reserveIDs(65536);\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"csg2.js","sourceRoot":"","sources":["../../../../dev/core/src/Meshes/csg2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAG9B,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,0BAAyB;AAC1C,OAAO,EAAE,aAAa,EAAE,sCAAqC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,sBAAsB,EAAE,mCAAkC;AAGnE,OAAO,EAAE,OAAO,EAAE,gCAA+B;AAEjD;;GAEG;AACH,gEAAgE;AAChE,IAAI,QAAa,CAAC;AAElB;;GAEG;AACH,gEAAgE;AAChE,IAAI,eAAsD,CAAC;AAE3D;;GAEG;AACH,gEAAgE;AAChE,IAAI,YAAiB,CAAC;AAEtB;;GAEG;AACH,gEAAgE;AAChE,IAAI,OAAe,CAAC;AAgEpB;;;;;;;GAOG;AACH,MAAM,OAAO,IAAI;IAKb;;OAEG;IACH,IAAW,OAAO;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAED,YAAoB,QAAa,EAAE,OAAe,EAAE,eAA2C;QAC3F,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,gBAAgB,GAAG,eAAe,CAAC;IAC5C,CAAC;IAEO,QAAQ,CAAC,SAAkD,EAAE,GAAS;QAC1E,IAAI,IAAI,CAAC,OAAO,KAAK,GAAG,CAAC,OAAO,EAAE,CAAC;YAC/B,MAAM,IAAI,KAAK,CAAC,uEAAu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AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,OAA+B;IACrE,MAAM,YAAY,GAAG;QACjB,WAAW,EAAE,qCAAqC;QAClD,GAAG,OAAO;KACb,CAAC;IAEF,IAAI,QAAQ,EAAE,CAAC;QACX,OAAO,CAAC,sBAAsB;IAClC,CAAC;IAED,IAAI,eAAe,EAAE,CAAC;QAClB,MAAM,eAAe,CAAC;QACtB,OAAO;IACX,CAAC;IAED,IAAI,YAAY,CAAC,gBAAgB,EAAE,CAAC;QAChC,QAAQ,GAAG,YAAY,CAAC,gBAAgB,CAAC;QACzC,YAAY,GAAG,YAAY,CAAC,oBAAoB,CAAC;IACrD,CAAC;SAAM,CAAC;QACJ,eAAe,GAAG,sBAAsB,CACpC;kCACsB,YAAY,CAAC,WAAW;;;;;SAKjD,CACA,CAAC;QAEF,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC;QACrC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;QAC3B,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC;IAC/B,CAAC;IAED,0FAA0F;IAC1F,OAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;AACzC,CAAC","sourcesContent":["import { Mesh } from \"./mesh\";\r\nimport type { IDisposable, Scene } from \"core/scene\";\r\nimport type { IVertexDataLike } from \"./mesh.vertexData\";\r\nimport { VertexData } from \"./mesh.vertexData\";\r\nimport { VertexBuffer } from \"../Buffers/buffer\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport { MultiMaterial } from \"core/Materials/multiMaterial\";\r\nimport { SubMesh } from \"./subMesh\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport { _LoadScriptModuleAsync } from \"core/Misc/tools.internals\";\r\nimport type { FloatArray, Nullable } from \"core/types\";\r\nimport type { Matrix } from \"core/Maths/math.vector\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\n\r\n/**\r\n * Main manifold library\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nlet Manifold: any;\r\n\r\n/**\r\n * Promise to wait for the manifold library to be ready\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nlet ManifoldPromise: Promise<{ Manifold: any; Mesh: any }>;\r\n\r\n/**\r\n * Manifold mesh\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nlet ManifoldMesh: any;\r\n\r\n/**\r\n * First ID to use for materials indexing\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nlet FirstID: number;\r\n\r\n/**\r\n * Interface to customize the Manifold library import\r\n */\r\nexport interface ICSG2Options {\r\n /**\r\n * Custom manifold URL\r\n */\r\n manifoldUrl?: string;\r\n /**\r\n * Custom manifold instance\r\n */\r\n manifoldInstance: any;\r\n /**\r\n * Custom manifold mesh instance\r\n */\r\n manifoldMeshInstance: any;\r\n}\r\n\r\n/**\r\n * Interface to customize the mesh rebuild options\r\n */\r\nexport interface IMeshRebuildOptions {\r\n /**\r\n * Rebuild normals\r\n */\r\n rebuildNormals?: boolean;\r\n /**\r\n * True to center the mesh on 0,0,0\r\n */\r\n centerMesh?: boolean;\r\n /**\r\n * Defines a material to use for that mesh. When not defined the system will either reuse the one from the source or create a multimaterial if several materials were involved\r\n */\r\n materialToUse?: Material;\r\n}\r\n\r\n/**\r\n * Interface to customize the vertex data rebuild options\r\n */\r\nexport interface IVertexDataRebuildOptions {\r\n /**\r\n * Rebuild normals\r\n */\r\n rebuildNormals?: boolean;\r\n}\r\n\r\ninterface IManifoldMesh {\r\n numProp: number;\r\n vertProperties: Float32Array;\r\n triVerts: Uint32Array;\r\n runIndex: Uint32Array;\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n runOriginalID: Uint32Array;\r\n numRun: number;\r\n}\r\n\r\ninterface IManifoldVertexComponent {\r\n stride: number;\r\n kind: string;\r\n data?: FloatArray;\r\n}\r\n\r\n/**\r\n * Wrapper around the Manifold library\r\n * https://manifoldcad.org/\r\n * Use this class to perform fast boolean operations on meshes\r\n * @see [basic operations](https://playground.babylonjs.com/#IW43EB#15)\r\n * @see [skull vs box](https://playground.babylonjs.com/#JUKXQD#6218)\r\n * @see [skull vs vertex data](https://playground.babylonjs.com/#JUKXQD#6219)\r\n */\r\nexport class CSG2 implements IDisposable {\r\n private _manifold: any;\r\n private _numProp: number;\r\n private _vertexStructure: IManifoldVertexComponent[];\r\n\r\n /**\r\n * Return the size of a vertex (at least 3 for the position)\r\n */\r\n public get numProp() {\r\n return this._numProp;\r\n }\r\n\r\n private constructor(manifold: any, numProp: number, vertexStructure: IManifoldVertexComponent[]) {\r\n this._manifold = manifold;\r\n this._numProp = numProp;\r\n this._vertexStructure = vertexStructure;\r\n }\r\n\r\n private _process(operation: \"difference\" | \"intersection\" | \"union\", csg: CSG2) {\r\n if (this.numProp !== csg.numProp) {\r\n throw new Error(\"CSG must be used with geometries having the same number of properties\");\r\n }\r\n return new CSG2(Manifold[operation](this._manifold, csg._manifold), this.numProp, this._vertexStructure);\r\n }\r\n\r\n /**\r\n * Run a difference operation between two CSG\r\n * @param csg defines the CSG to use to create the difference\r\n * @returns a new csg\r\n */\r\n public subtract(csg: CSG2) {\r\n return this._process(\"difference\", csg);\r\n }\r\n\r\n /**\r\n * Run an intersection operation between two CSG\r\n * @param csg defines the CSG to use to create the intersection\r\n * @returns a new csg\r\n */\r\n public intersect(csg: CSG2) {\r\n return this._process(\"intersection\", csg);\r\n }\r\n\r\n /**\r\n * Run an union operation between two CSG\r\n * @param csg defines the CSG to use to create the union\r\n * @returns a new csg\r\n */\r\n public add(csg: CSG2) {\r\n return this._process(\"union\", csg);\r\n }\r\n\r\n /**\r\n * Print debug information about the CSG\r\n */\r\n public printDebug() {\r\n Logger.Log(\"Genus:\" + this._manifold.genus());\r\n const properties = this._manifold.getProperties();\r\n Logger.Log(\"Volume:\" + properties.volume);\r\n Logger.Log(\"surface area:\" + properties.surfaceArea);\r\n }\r\n\r\n /**\r\n * Generate a vertex data from the CSG\r\n * @param options defines the options to use to rebuild the vertex data\r\n * @returns a new vertex data\r\n */\r\n public toVertexData(options?: Partial<IVertexDataRebuildOptions>): VertexData {\r\n const localOptions = {\r\n rebuildNormals: false,\r\n ...options,\r\n };\r\n const vertexData = new VertexData();\r\n const normalComponent = this._vertexStructure.find((c) => c.kind === VertexBuffer.NormalKind);\r\n const manifoldMesh: IManifoldMesh = this._manifold.getMesh(localOptions.rebuildNormals && normalComponent ? [3, 4, 5] : undefined);\r\n\r\n vertexData.indices = manifoldMesh.triVerts.length > 65535 ? new Uint32Array(manifoldMesh.triVerts) : new Uint16Array(manifoldMesh.triVerts);\r\n\r\n for (let i = 0; i < manifoldMesh.triVerts.length; i += 3) {\r\n vertexData.indices[i] = manifoldMesh.triVerts[i + 2];\r\n vertexData.indices[i + 1] = manifoldMesh.triVerts[i + 1];\r\n vertexData.indices[i + 2] = manifoldMesh.triVerts[i];\r\n }\r\n\r\n const vertexCount = manifoldMesh.vertProperties.length / manifoldMesh.numProp;\r\n\r\n // Attributes\r\n let offset = 0;\r\n for (let componentIndex = 0; componentIndex < this._vertexStructure.length; componentIndex++) {\r\n const component = this._vertexStructure[componentIndex];\r\n\r\n const data = new Float32Array(vertexCount * component.stride);\r\n for (let i = 0; i < vertexCount; i++) {\r\n for (let strideIndex = 0; strideIndex < component.stride; strideIndex++) {\r\n data[i * component.stride + strideIndex] = manifoldMesh.vertProperties[i * manifoldMesh.numProp + offset + strideIndex];\r\n }\r\n }\r\n vertexData.set(data, component.kind);\r\n offset += component.stride;\r\n }\r\n\r\n // Rebuild mesh from vertex data\r\n return vertexData;\r\n }\r\n\r\n /**\r\n * Generate a mesh from the CSG\r\n * @param name defines the name of the mesh\r\n * @param scene defines the scene to use to create the mesh\r\n * @param options defines the options to use to rebuild the mesh\r\n * @returns a new Mesh\r\n */\r\n public toMesh(name: string, scene?: Scene, options?: Partial<IMeshRebuildOptions>): Mesh {\r\n const localOptions = {\r\n rebuildNormals: false,\r\n centerMesh: true,\r\n ...options,\r\n };\r\n const vertexData = this.toVertexData({ rebuildNormals: localOptions.rebuildNormals });\r\n const normalComponent = this._vertexStructure.find((c) => c.kind === VertexBuffer.NormalKind);\r\n const manifoldMesh: IManifoldMesh = this._manifold.getMesh(localOptions.rebuildNormals && normalComponent ? [3, 4, 5] : undefined);\r\n const vertexCount = manifoldMesh.vertProperties.length / manifoldMesh.numProp;\r\n\r\n // Rebuild mesh from vertex data\r\n const output = new Mesh(name, scene);\r\n vertexData.applyToMesh(output);\r\n\r\n // Center mesh\r\n if (localOptions.centerMesh) {\r\n const extents = output.getBoundingInfo().boundingSphere.center;\r\n output.position.set(-extents.x, -extents.y, -extents.z);\r\n output.bakeCurrentTransformIntoVertices();\r\n }\r\n\r\n // Submeshes\r\n let id = manifoldMesh.runOriginalID[0];\r\n let start = manifoldMesh.runIndex[0];\r\n let materialIndex = 0;\r\n const materials: Material[] = [];\r\n scene = output.getScene();\r\n for (let run = 0; run < manifoldMesh.numRun; ++run) {\r\n const nextID = manifoldMesh.runOriginalID[run + 1];\r\n if (nextID !== id) {\r\n const end = manifoldMesh.runIndex[run + 1];\r\n new SubMesh(materialIndex, 0, vertexCount, start, end - start, output);\r\n materials.push(scene.getMaterialByUniqueID(id - FirstID) || scene.defaultMaterial);\r\n id = nextID;\r\n start = end;\r\n materialIndex++;\r\n }\r\n }\r\n\r\n if (localOptions.materialToUse) {\r\n output.material = localOptions.materialToUse;\r\n } else {\r\n if (materials.length > 1) {\r\n const multiMaterial = new MultiMaterial(name, scene);\r\n multiMaterial.subMaterials = materials;\r\n output.material = multiMaterial;\r\n } else {\r\n if (output.subMeshes.length > 1) {\r\n // Remove the submeshes as they are not needed\r\n output._createGlobalSubMesh(true);\r\n }\r\n output.material = materials[0];\r\n }\r\n }\r\n\r\n return output;\r\n }\r\n\r\n /**\r\n * Dispose the CSG resources\r\n */\r\n public dispose() {\r\n if (this._manifold) {\r\n this._manifold.delete();\r\n this._manifold = null;\r\n }\r\n }\r\n\r\n private static _ProcessData(\r\n vertexCount: number,\r\n triVerts: Uint32Array,\r\n structure: IManifoldVertexComponent[],\r\n numProp: number,\r\n runIndex?: Uint32Array,\r\n runOriginalID?: Uint32Array\r\n ) {\r\n const vertProperties = new Float32Array(vertexCount * structure.reduce((acc, cur) => acc + cur.stride, 0));\r\n\r\n for (let i = 0; i < vertexCount; i++) {\r\n let offset = 0;\r\n for (let idx = 0; idx < structure.length; idx++) {\r\n const component = structure[idx];\r\n\r\n for (let strideIndex = 0; strideIndex < component.stride; strideIndex++) {\r\n vertProperties[i * numProp + offset + strideIndex] = component.data![i * component.stride + strideIndex];\r\n }\r\n offset += component.stride;\r\n }\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n const manifoldMesh = new ManifoldMesh({ numProp: numProp, vertProperties, triVerts, runIndex, runOriginalID });\r\n manifoldMesh.merge();\r\n\r\n let returnValue: CSG2;\r\n try {\r\n returnValue = new CSG2(new Manifold(manifoldMesh), numProp, structure);\r\n } catch (e) {\r\n throw new Error(\"Error while creating the CSG: \" + e.message);\r\n }\r\n\r\n return returnValue;\r\n }\r\n\r\n private static _Construct(data: IVertexDataLike, worldMatrix: Nullable<Matrix>, runIndex?: Uint32Array, runOriginalID?: Uint32Array) {\r\n // Create the MeshGL for I/O with Manifold library.\r\n const triVerts = new Uint32Array(data.indices!.length);\r\n\r\n // Revert order\r\n for (let i = 0; i < data.indices!.length; i += 3) {\r\n triVerts[i] = data.indices![i + 2];\r\n triVerts[i + 1] = data.indices![i + 1];\r\n triVerts[i + 2] = data.indices![i];\r\n }\r\n\r\n const tempVector3 = new Vector3();\r\n let numProp = 3;\r\n const structure: IManifoldVertexComponent[] = [{ stride: 3, kind: VertexBuffer.PositionKind }];\r\n\r\n if (!worldMatrix) {\r\n structure[0].data = data.positions!;\r\n } else {\r\n const positions = new Float32Array(data.positions!.length);\r\n for (let i = 0; i < data.positions!.length; i += 3) {\r\n Vector3.TransformCoordinatesFromFloatsToRef(data.positions![i], data.positions![i + 1], data.positions![i + 2], worldMatrix, tempVector3);\r\n tempVector3.toArray(positions, i);\r\n }\r\n structure[0].data = positions;\r\n }\r\n\r\n // Normals\r\n const sourceNormals = data.normals!;\r\n if (sourceNormals) {\r\n numProp += 3;\r\n structure.push({ stride: 3, kind: VertexBuffer.NormalKind });\r\n if (!worldMatrix) {\r\n structure[1].data = sourceNormals;\r\n } else {\r\n const normals = new Float32Array(sourceNormals.length);\r\n for (let i = 0; i < sourceNormals.length; i += 3) {\r\n Vector3.TransformNormalFromFloatsToRef(sourceNormals[i], sourceNormals[i + 1], sourceNormals[i + 2], worldMatrix, tempVector3);\r\n tempVector3.toArray(normals, i);\r\n }\r\n structure[1].data = normals;\r\n }\r\n }\r\n\r\n // UVs\r\n for (const kind of [VertexBuffer.UVKind, VertexBuffer.UV2Kind, VertexBuffer.UV3Kind, VertexBuffer.UV4Kind, VertexBuffer.UV5Kind, VertexBuffer.UV6Kind]) {\r\n const sourceUV = (data as any)[kind === VertexBuffer.UVKind ? \"uvs\" : kind];\r\n if (sourceUV) {\r\n numProp += 2;\r\n structure.push({ stride: 2, kind: kind, data: sourceUV });\r\n }\r\n }\r\n\r\n // Colors\r\n const sourceColors = data.colors;\r\n if (sourceColors) {\r\n numProp += 4;\r\n structure.push({ stride: 4, kind: VertexBuffer.ColorKind, data: sourceColors });\r\n }\r\n\r\n return this._ProcessData(data.positions!.length / 3, triVerts, structure, numProp, runIndex, runOriginalID);\r\n }\r\n\r\n /**\r\n * Create a new Constructive Solid Geometry from a vertexData\r\n * @param vertexData defines the vertexData to use to create the CSG\r\n * @returns a new CSG2 class\r\n */\r\n public static FromVertexData(vertexData: VertexData): CSG2 {\r\n const sourceVertices = vertexData.positions;\r\n const sourceIndices = vertexData.indices;\r\n\r\n if (!sourceVertices || !sourceIndices) {\r\n throw new Error(\"The vertexData must at least have positions and indices\");\r\n }\r\n\r\n return this._Construct(vertexData, null);\r\n }\r\n\r\n /**\r\n * Create a new Constructive Solid Geometry from a mesh\r\n * @param mesh defines the mesh to use to create the CSG\r\n * @param ignoreWorldMatrix defines if the world matrix should be ignored\r\n * @returns a new CSG2 class\r\n */\r\n public static FromMesh(mesh: Mesh, ignoreWorldMatrix = false): CSG2 {\r\n const sourceVertices = mesh.getVerticesData(VertexBuffer.PositionKind);\r\n const sourceIndices = mesh.getIndices();\r\n const worldMatrix = mesh.computeWorldMatrix(true);\r\n\r\n if (!sourceVertices || !sourceIndices) {\r\n throw new Error(\"The mesh must at least have positions and indices\");\r\n }\r\n\r\n // Create a triangle run for each submesh (material)\r\n const starts = [...Array(mesh.subMeshes.length)].map((_, idx) => mesh.subMeshes[idx].indexStart);\r\n\r\n // Map the materials to ID.\r\n const sourceMaterial = mesh.material || mesh.getScene().defaultMaterial;\r\n const isMultiMaterial = sourceMaterial.getClassName() === \"MultiMaterial\";\r\n const originalIDs = [...Array(mesh.subMeshes.length)].map((_, idx) => {\r\n if (isMultiMaterial) {\r\n return FirstID + (sourceMaterial as MultiMaterial).subMaterials[mesh.subMeshes[idx].materialIndex]!.uniqueId;\r\n }\r\n\r\n return FirstID + sourceMaterial.uniqueId;\r\n });\r\n\r\n // List the runs in sequence.\r\n const indices = Array.from(starts.keys());\r\n indices.sort((a, b) => starts[a] - starts[b]);\r\n const runIndex = new Uint32Array(indices.map((i) => starts[i]));\r\n const runOriginalID = new Uint32Array(indices.map((i) => originalIDs[i]));\r\n\r\n // Process\r\n const data = {\r\n positions: sourceVertices,\r\n indices: sourceIndices,\r\n normals: mesh.getVerticesData(VertexBuffer.NormalKind),\r\n colors: mesh.getVerticesData(VertexBuffer.ColorKind),\r\n uvs: mesh.getVerticesData(VertexBuffer.UVKind),\r\n uvs2: mesh.getVerticesData(VertexBuffer.UV2Kind),\r\n uvs3: mesh.getVerticesData(VertexBuffer.UV3Kind),\r\n uvs4: mesh.getVerticesData(VertexBuffer.UV4Kind),\r\n uvs5: mesh.getVerticesData(VertexBuffer.UV5Kind),\r\n uvs6: mesh.getVerticesData(VertexBuffer.UV6Kind),\r\n };\r\n return this._Construct(data, ignoreWorldMatrix ? null : worldMatrix, runIndex, runOriginalID);\r\n }\r\n}\r\n\r\n/**\r\n * Checks if the Manifold library is ready\r\n * @returns true if the Manifold library is ready\r\n */\r\nexport function IsCSG2Ready() {\r\n return Manifold !== undefined;\r\n}\r\n\r\n/**\r\n * Initialize the Manifold library\r\n * @param options defines the options to use to initialize the library\r\n */\r\nexport async function InitializeCSG2Async(options?: Partial<ICSG2Options>) {\r\n const localOptions = {\r\n manifoldUrl: \"https://unpkg.com/manifold-3d@3.1.0\",\r\n ...options,\r\n };\r\n\r\n if (Manifold) {\r\n return; // Already initialized\r\n }\r\n\r\n if (ManifoldPromise) {\r\n await ManifoldPromise;\r\n return;\r\n }\r\n\r\n if (localOptions.manifoldInstance) {\r\n Manifold = localOptions.manifoldInstance;\r\n ManifoldMesh = localOptions.manifoldMeshInstance;\r\n } else {\r\n ManifoldPromise = _LoadScriptModuleAsync(\r\n `\r\n import Module from '${localOptions.manifoldUrl}/manifold.js';\r\n const wasm = await Module();\r\n wasm.setup();\r\n const {Manifold, Mesh} = wasm;\r\n const returnedValue = {Manifold, Mesh};\r\n `\r\n );\r\n\r\n const result = await ManifoldPromise;\r\n Manifold = result.Manifold;\r\n ManifoldMesh = result.Mesh;\r\n }\r\n\r\n // Reserve IDs for materials (we consider that there will be no more than 65536 materials)\r\n FirstID = Manifold.reserveIDs(65536);\r\n}\r\n"]}
|