@babylonjs/serializers 7.34.4 → 7.35.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. package/OBJ/objSerializer.js.map +1 -1
  2. package/USDZ/usdzExporter.js.map +1 -1
  3. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js.map +1 -1
  4. package/glTF/2.0/Extensions/KHR_lights_punctual.js.map +1 -1
  5. package/glTF/2.0/Extensions/KHR_materials_anisotropy.js.map +1 -1
  6. package/glTF/2.0/Extensions/KHR_materials_clearcoat.js.map +1 -1
  7. package/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.js.map +1 -1
  8. package/glTF/2.0/Extensions/KHR_materials_dispersion.js.map +1 -1
  9. package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js.map +1 -1
  10. package/glTF/2.0/Extensions/KHR_materials_ior.js.map +1 -1
  11. package/glTF/2.0/Extensions/KHR_materials_iridescence.js.map +1 -1
  12. package/glTF/2.0/Extensions/KHR_materials_sheen.js.map +1 -1
  13. package/glTF/2.0/Extensions/KHR_materials_specular.js.map +1 -1
  14. package/glTF/2.0/Extensions/KHR_materials_transmission.js.map +1 -1
  15. package/glTF/2.0/Extensions/KHR_materials_unlit.js.map +1 -1
  16. package/glTF/2.0/Extensions/KHR_materials_volume.js.map +1 -1
  17. package/glTF/2.0/Extensions/KHR_texture_transform.js.map +1 -1
  18. package/glTF/2.0/glTFAnimation.js.map +1 -1
  19. package/glTF/2.0/glTFData.js.map +1 -1
  20. package/glTF/2.0/glTFExporter.js.map +1 -1
  21. package/glTF/2.0/glTFMaterialExporter.js.map +1 -1
  22. package/glTF/2.0/glTFSerializer.js.map +1 -1
  23. package/glTF/2.0/glTFUtilities.js.map +1 -1
  24. package/legacy/legacy-glTF2Serializer.js.map +1 -1
  25. package/legacy/legacy-objSerializer.js.map +1 -1
  26. package/legacy/legacy-stlSerializer.js.map +1 -1
  27. package/legacy/legacy-usdzSerializer.js.map +1 -1
  28. package/package.json +3 -3
  29. package/stl/stlSerializer.js.map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;;UAIE;QAEF,IAAI,CAAC,CAAC,WAAW,EAAE;YACf,MAAM,CAAC,IAAI,CAAC,wBAAwB,GAAG,OAAO,GAAG,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;SACxE;QAED,IAAI,CAAC,CAAC,cAAc,EAAE;YAClB,MAAM,CAAC,IAAI,CAAC,UAAU,GAAG,OAAO,GAAG,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;SAC7D;QAED,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/B,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport { Matrix } from \"core/Maths/math.vector\";\r\nimport { Tools } from \"core/Misc/tools\";\r\nimport type { StandardMaterial } from \"core/Materials/standardMaterial\";\r\nimport type { Geometry } from \"core/Meshes/geometry\";\r\nimport type { Mesh } from \"core/Meshes/mesh\";\r\nimport { Material } from \"core/Materials/material\";\r\n\r\n/**\r\n * Class for generating OBJ data from a Babylon scene.\r\n */\r\nexport class OBJExport {\r\n /**\r\n * Exports the geometry of a Mesh array in .OBJ file format (text)\r\n * @param meshes defines the list of meshes to serialize\r\n * @param materials defines if materials should be exported\r\n * @param matlibname defines the name of the associated mtl file\r\n * @param globalposition defines if the exported positions are globals or local to the exported mesh\r\n * @returns the OBJ content\r\n */\r\n public static OBJ(meshes: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string {\r\n const output: string[] = [];\r\n let v = 1;\r\n // keep track of uv index in case mixed meshes are passed in\r\n let textureV = 1;\r\n\r\n if (materials) {\r\n if (!matlibname) {\r\n matlibname = \"mat\";\r\n }\r\n output.push(\"mtllib \" + matlibname + \".mtl\");\r\n }\r\n for (let j = 0; j < meshes.length; j++) {\r\n const mesh = meshes[j];\r\n const objectName = mesh.name || `mesh${j}}`;\r\n output.push(`o ${objectName}`);\r\n\r\n //Uses the position of the item in the scene, to the file (this back to normal in the end)\r\n let inverseTransform: Nullable<Matrix> = null;\r\n if (globalposition) {\r\n const transform = mesh.computeWorldMatrix(true);\r\n inverseTransform = new Matrix();\r\n transform.invertToRef(inverseTransform);\r\n\r\n mesh.bakeTransformIntoVertices(transform);\r\n }\r\n\r\n //TODO: submeshes (groups)\r\n //TODO: smoothing groups (s 1, s off);\r\n if (materials) {\r\n const mat = mesh.material;\r\n\r\n if (mat) {\r\n output.push(\"usemtl \" + mat.id);\r\n }\r\n }\r\n const g: Nullable<Geometry> = mesh.geometry;\r\n\r\n if (!g) {\r\n Tools.Warn(\"No geometry is present on the mesh\");\r\n continue;\r\n }\r\n\r\n const trunkVerts = g.getVerticesData(\"position\");\r\n const trunkNormals = g.getVerticesData(\"normal\");\r\n const trunkUV = g.getVerticesData(\"uv\");\r\n const trunkFaces = g.getIndices();\r\n let currentV = 0;\r\n let currentTextureV = 0;\r\n\r\n if (!trunkVerts || !trunkFaces) {\r\n Tools.Warn(\"There are no position vertices or indices on the mesh!\");\r\n continue;\r\n }\r\n\r\n const useRightHandedSystem = meshes[0].getScene().useRightHandedSystem;\r\n const handednessSign = useRightHandedSystem ? 1 : -1;\r\n\r\n for (let i = 0; i < trunkVerts.length; i += 3) {\r\n output.push(\"v \" + trunkVerts[i] * handednessSign + \" \" + trunkVerts[i + 1] + \" \" + trunkVerts[i + 2]);\r\n currentV++;\r\n }\r\n\r\n if (trunkNormals != null) {\r\n for (let i = 0; i < trunkNormals.length; i += 3) {\r\n output.push(\"vn \" + trunkNormals[i] * handednessSign + \" \" + trunkNormals[i + 1] + \" \" + trunkNormals[i + 2]);\r\n }\r\n }\r\n if (trunkUV != null) {\r\n for (let i = 0; i < trunkUV.length; i += 2) {\r\n output.push(\"vt \" + trunkUV[i] + \" \" + trunkUV[i + 1]);\r\n currentTextureV++;\r\n }\r\n }\r\n\r\n const blanks: string[] = [\"\", \"\", \"\"];\r\n const material = mesh.material || mesh.getScene().defaultMaterial;\r\n\r\n const sideOrientation = material._getEffectiveOrientation(mesh);\r\n const [offset1, offset2] = sideOrientation === Material.ClockWiseSideOrientation ? [2, 1] : [1, 2];\r\n\r\n for (let i = 0; i < trunkFaces.length; i += 3) {\r\n const indices = [String(trunkFaces[i] + v), String(trunkFaces[i + offset1] + v), String(trunkFaces[i + offset2] + v)];\r\n const textureIndices = [String(trunkFaces[i] + textureV), String(trunkFaces[i + offset1] + textureV), String(trunkFaces[i + offset2] + textureV)];\r\n\r\n const facePositions = indices;\r\n const faceUVs = trunkUV != null ? textureIndices : blanks;\r\n const faceNormals = trunkNormals != null ? indices : blanks;\r\n\r\n output.push(\r\n \"f \" +\r\n facePositions[0] +\r\n \"/\" +\r\n faceUVs[0] +\r\n \"/\" +\r\n faceNormals[0] +\r\n \" \" +\r\n facePositions[1] +\r\n \"/\" +\r\n faceUVs[1] +\r\n \"/\" +\r\n faceNormals[1] +\r\n \" \" +\r\n facePositions[2] +\r\n \"/\" +\r\n faceUVs[2] +\r\n \"/\" +\r\n faceNormals[2]\r\n );\r\n }\r\n //back de previous matrix, to not change the original mesh in the scene\r\n if (globalposition && inverseTransform) {\r\n mesh.bakeTransformIntoVertices(inverseTransform);\r\n }\r\n v += currentV;\r\n textureV += currentTextureV;\r\n }\r\n const text: string = output.join(\"\\n\");\r\n return text;\r\n }\r\n\r\n /**\r\n * Exports the material(s) of a mesh in .MTL file format (text)\r\n * @param mesh defines the mesh to extract the material from\r\n * @returns the mtl content\r\n */\r\n //TODO: Export the materials of mesh array\r\n public static MTL(mesh: Mesh): string {\r\n const output = [];\r\n const m = <StandardMaterial>mesh.material;\r\n output.push(\"newmtl mat1\");\r\n output.push(\" Ns \" + m.specularPower.toFixed(4));\r\n output.push(\" Ni 1.5000\");\r\n output.push(\" d \" + m.alpha.toFixed(4));\r\n output.push(\" Tr 0.0000\");\r\n output.push(\" Tf 1.0000 1.0000 1.0000\");\r\n output.push(\" illum 2\");\r\n output.push(\" Ka \" + m.ambientColor.r.toFixed(4) + \" \" + m.ambientColor.g.toFixed(4) + \" \" + m.ambientColor.b.toFixed(4));\r\n output.push(\" Kd \" + m.diffuseColor.r.toFixed(4) + \" \" + m.diffuseColor.g.toFixed(4) + \" \" + m.diffuseColor.b.toFixed(4));\r\n output.push(\" Ks \" + m.specularColor.r.toFixed(4) + \" \" + m.specularColor.g.toFixed(4) + \" \" + m.specularColor.b.toFixed(4));\r\n output.push(\" Ke \" + m.emissiveColor.r.toFixed(4) + \" \" + m.emissiveColor.g.toFixed(4) + \" \" + m.emissiveColor.b.toFixed(4));\r\n\r\n //TODO: uv scale, offset, wrap\r\n //TODO: UV mirrored in Blender? second UV channel? lightMap? reflection textures?\r\n const uvscale = \"\";\r\n\r\n if (m.ambientTexture) {\r\n output.push(\" map_Ka \" + uvscale + m.ambientTexture.name);\r\n }\r\n\r\n if (m.diffuseTexture) {\r\n output.push(\" map_Kd \" + uvscale + m.diffuseTexture.name);\r\n //TODO: alpha testing, opacity in diffuse texture alpha channel (diffuseTexture.hasAlpha -> map_d)\r\n }\r\n\r\n if (m.specularTexture) {\r\n output.push(\" map_Ks \" + uvscale + m.specularTexture.name);\r\n /* TODO: glossiness = specular highlight component is in alpha channel of specularTexture. (???)\r\n if (m.useGlossinessFromSpecularMapAlpha) {\r\n output.push(\" map_Ns \"+uvscale + m.specularTexture.name);\r\n }\r\n */\r\n }\r\n\r\n /* TODO: emissive texture not in .MAT format (???)\r\n if (m.emissiveTexture) {\r\n output.push(\" map_d \"+uvscale+m.emissiveTexture.name);\r\n }\r\n */\r\n\r\n if (m.bumpTexture) {\r\n output.push(\" map_bump -imfchan z \" + uvscale + m.bumpTexture.name);\r\n }\r\n\r\n if (m.opacityTexture) {\r\n output.push(\" map_d \" + uvscale + m.opacityTexture.name);\r\n }\r\n\r\n const text = output.join(\"\\n\");\r\n return text;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"objSerializer.js","sourceRoot":"","sources":["../../../../dev/serializers/src/OBJ/objSerializer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EA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CAAC,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;YAC5D;;;;cAIE;QACN,CAAC;QAED;;;;UAIE;QAEF,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;YAChB,MAAM,CAAC,IAAI,CAAC,wBAAwB,GAAG,OAAO,GAAG,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACzE,CAAC;QAED,IAAI,CAAC,CAAC,cAAc,EAAE,CAAC;YACnB,MAAM,CAAC,IAAI,CAAC,UAAU,GAAG,OAAO,GAAG,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QAC9D,CAAC;QAED,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/B,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport { Matrix } from \"core/Maths/math.vector\";\r\nimport { Tools } from \"core/Misc/tools\";\r\nimport type { StandardMaterial } from \"core/Materials/standardMaterial\";\r\nimport type { Geometry } from \"core/Meshes/geometry\";\r\nimport type { Mesh } from \"core/Meshes/mesh\";\r\nimport { Material } from \"core/Materials/material\";\r\n\r\n/**\r\n * Class for generating OBJ data from a Babylon scene.\r\n */\r\nexport class OBJExport {\r\n /**\r\n * Exports the geometry of a Mesh array in .OBJ file format (text)\r\n * @param meshes defines the list of meshes to serialize\r\n * @param materials defines if materials should be exported\r\n * @param matlibname defines the name of the associated mtl file\r\n * @param globalposition defines if the exported positions are globals or local to the exported mesh\r\n * @returns the OBJ content\r\n */\r\n public static OBJ(meshes: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string {\r\n const output: string[] = [];\r\n let v = 1;\r\n // keep track of uv index in case mixed meshes are passed in\r\n let textureV = 1;\r\n\r\n if (materials) {\r\n if (!matlibname) {\r\n matlibname = \"mat\";\r\n }\r\n output.push(\"mtllib \" + matlibname + \".mtl\");\r\n }\r\n for (let j = 0; j < meshes.length; j++) {\r\n const mesh = meshes[j];\r\n const objectName = mesh.name || `mesh${j}}`;\r\n output.push(`o ${objectName}`);\r\n\r\n //Uses the position of the item in the scene, to the file (this back to normal in the end)\r\n let inverseTransform: Nullable<Matrix> = null;\r\n if (globalposition) {\r\n const transform = mesh.computeWorldMatrix(true);\r\n inverseTransform = new Matrix();\r\n transform.invertToRef(inverseTransform);\r\n\r\n mesh.bakeTransformIntoVertices(transform);\r\n }\r\n\r\n //TODO: submeshes (groups)\r\n //TODO: smoothing groups (s 1, s off);\r\n if (materials) {\r\n const mat = mesh.material;\r\n\r\n if (mat) {\r\n output.push(\"usemtl \" + mat.id);\r\n }\r\n }\r\n const g: Nullable<Geometry> = mesh.geometry;\r\n\r\n if (!g) {\r\n Tools.Warn(\"No geometry is present on the mesh\");\r\n continue;\r\n }\r\n\r\n const trunkVerts = g.getVerticesData(\"position\");\r\n const trunkNormals = g.getVerticesData(\"normal\");\r\n const trunkUV = g.getVerticesData(\"uv\");\r\n const trunkFaces = g.getIndices();\r\n let currentV = 0;\r\n let currentTextureV = 0;\r\n\r\n if (!trunkVerts || !trunkFaces) {\r\n Tools.Warn(\"There are no position vertices or indices on the mesh!\");\r\n continue;\r\n }\r\n\r\n const useRightHandedSystem = meshes[0].getScene().useRightHandedSystem;\r\n const handednessSign = useRightHandedSystem ? 1 : -1;\r\n\r\n for (let i = 0; i < trunkVerts.length; i += 3) {\r\n output.push(\"v \" + trunkVerts[i] * handednessSign + \" \" + trunkVerts[i + 1] + \" \" + trunkVerts[i + 2]);\r\n currentV++;\r\n }\r\n\r\n if (trunkNormals != null) {\r\n for (let i = 0; i < trunkNormals.length; i += 3) {\r\n output.push(\"vn \" + trunkNormals[i] * handednessSign + \" \" + trunkNormals[i + 1] + \" \" + trunkNormals[i + 2]);\r\n }\r\n }\r\n if (trunkUV != null) {\r\n for (let i = 0; i < trunkUV.length; i += 2) {\r\n output.push(\"vt \" + trunkUV[i] + \" \" + trunkUV[i + 1]);\r\n currentTextureV++;\r\n }\r\n }\r\n\r\n const blanks: string[] = [\"\", \"\", \"\"];\r\n const material = mesh.material || mesh.getScene().defaultMaterial;\r\n\r\n const sideOrientation = material._getEffectiveOrientation(mesh);\r\n const [offset1, offset2] = sideOrientation === Material.ClockWiseSideOrientation ? [2, 1] : [1, 2];\r\n\r\n for (let i = 0; i < trunkFaces.length; i += 3) {\r\n const indices = [String(trunkFaces[i] + v), String(trunkFaces[i + offset1] + v), String(trunkFaces[i + offset2] + v)];\r\n const textureIndices = [String(trunkFaces[i] + textureV), String(trunkFaces[i + offset1] + textureV), String(trunkFaces[i + offset2] + textureV)];\r\n\r\n const facePositions = indices;\r\n const faceUVs = trunkUV != null ? textureIndices : blanks;\r\n const faceNormals = trunkNormals != null ? indices : blanks;\r\n\r\n output.push(\r\n \"f \" +\r\n facePositions[0] +\r\n \"/\" +\r\n faceUVs[0] +\r\n \"/\" +\r\n faceNormals[0] +\r\n \" \" +\r\n facePositions[1] +\r\n \"/\" +\r\n faceUVs[1] +\r\n \"/\" +\r\n faceNormals[1] +\r\n \" \" +\r\n facePositions[2] +\r\n \"/\" +\r\n faceUVs[2] +\r\n \"/\" +\r\n faceNormals[2]\r\n );\r\n }\r\n //back de previous matrix, to not change the original mesh in the scene\r\n if (globalposition && inverseTransform) {\r\n mesh.bakeTransformIntoVertices(inverseTransform);\r\n }\r\n v += currentV;\r\n textureV += currentTextureV;\r\n }\r\n const text: string = output.join(\"\\n\");\r\n return text;\r\n }\r\n\r\n /**\r\n * Exports the material(s) of a mesh in .MTL file format (text)\r\n * @param mesh defines the mesh to extract the material from\r\n * @returns the mtl content\r\n */\r\n //TODO: Export the materials of mesh array\r\n public static MTL(mesh: Mesh): string {\r\n const output = [];\r\n const m = <StandardMaterial>mesh.material;\r\n output.push(\"newmtl mat1\");\r\n output.push(\" Ns \" + m.specularPower.toFixed(4));\r\n output.push(\" Ni 1.5000\");\r\n output.push(\" d \" + m.alpha.toFixed(4));\r\n output.push(\" Tr 0.0000\");\r\n output.push(\" Tf 1.0000 1.0000 1.0000\");\r\n output.push(\" illum 2\");\r\n output.push(\" Ka \" + m.ambientColor.r.toFixed(4) + \" \" + m.ambientColor.g.toFixed(4) + \" \" + m.ambientColor.b.toFixed(4));\r\n output.push(\" Kd \" + m.diffuseColor.r.toFixed(4) + \" \" + m.diffuseColor.g.toFixed(4) + \" \" + m.diffuseColor.b.toFixed(4));\r\n output.push(\" Ks \" + m.specularColor.r.toFixed(4) + \" \" + m.specularColor.g.toFixed(4) + \" \" + m.specularColor.b.toFixed(4));\r\n output.push(\" Ke \" + m.emissiveColor.r.toFixed(4) + \" \" + m.emissiveColor.g.toFixed(4) + \" \" + m.emissiveColor.b.toFixed(4));\r\n\r\n //TODO: uv scale, offset, wrap\r\n //TODO: UV mirrored in Blender? second UV channel? lightMap? reflection textures?\r\n const uvscale = \"\";\r\n\r\n if (m.ambientTexture) {\r\n output.push(\" map_Ka \" + uvscale + m.ambientTexture.name);\r\n }\r\n\r\n if (m.diffuseTexture) {\r\n output.push(\" map_Kd \" + uvscale + m.diffuseTexture.name);\r\n //TODO: alpha testing, opacity in diffuse texture alpha channel (diffuseTexture.hasAlpha -> map_d)\r\n }\r\n\r\n if (m.specularTexture) {\r\n output.push(\" map_Ks \" + uvscale + m.specularTexture.name);\r\n /* TODO: glossiness = specular highlight component is in alpha channel of specularTexture. (???)\r\n if (m.useGlossinessFromSpecularMapAlpha) {\r\n output.push(\" map_Ns \"+uvscale + m.specularTexture.name);\r\n }\r\n */\r\n }\r\n\r\n /* TODO: emissive texture not in .MAT format (???)\r\n if (m.emissiveTexture) {\r\n output.push(\" map_d \"+uvscale+m.emissiveTexture.name);\r\n }\r\n */\r\n\r\n if (m.bumpTexture) {\r\n output.push(\" map_bump -imfchan z \" + uvscale + m.bumpTexture.name);\r\n }\r\n\r\n if (m.opacityTexture) {\r\n output.push(\" map_d \" + uvscale + m.opacityTexture.name);\r\n }\r\n\r\n const text = output.join(\"\\n\");\r\n return text;\r\n }\r\n}\r\n"]}
@@ -1 +1 @@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,EAAE,IAAI,CAAC,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;QAE7H,KAAK,CAAC,oBAAoB,EAAE,MAAM,CAAC,GAAG,IAAI,UAAU,CAAC,WAA0B,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,iDAAiD;KAC9I;IAED,oBAAoB;IACpB,uEAAuE;IAEvE,IAAI,MAAM,GAAG,CAAC,CAAC;IAEf,KAAK,MAAM,QAAQ,IAAI,KAAK,EAAE;QAC1B,MAAM,IAAI,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC;QAC7B,IAAI,CAAC,IAAI,EAAE;YACP,SAAS;SACZ;QACD,MAAM,UAAU,GAAG,EAAE,GAAG,QAAQ,CAAC,MAAM,CAAC;QAExC,MAAM,IAAI,UAAU,CAAC;QAErB,MAAM,WAAW,GAAG,MAAM,GAAG,EAAE,CAAC;QAEhC,IAAI,WAAW,KAAK,CAAC,EAAE;YACnB,MAAM,SAAS,GAAG,EAAE,GAAG,WAAW,CAAC;YACnC,MAAM,OAAO,GAAG,IAAI,UAAU,CAAC,SAAS,CAAC,CAAC;YAE1C,gEAAgE;YAChE,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC;SAC3D;QAED,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;KACxB;IAED,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;AAC/C,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport { VertexBuffer } from \"core/Buffers/buffer\";\r\nimport type { Camera } from \"core/Cameras/camera\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport type { PBRMaterial } from \"core/Materials/PBR/pbrMaterial\";\r\nimport type { PBRMetallicRoughnessMaterial } from \"core/Materials/PBR/pbrMetallicRoughnessMaterial\";\r\nimport type { StandardMaterial } from \"core/Materials/standardMaterial\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport type { Texture } from \"core/Materials/Textures/texture\";\r\nimport { Color3 } from \"core/Maths/math.color\";\r\nimport { Matrix, Vector2 } from \"core/Maths/math.vector\";\r\nimport type { Geometry } from \"core/Meshes/geometry\";\r\nimport type { Mesh } from \"core/Meshes/mesh\";\r\nimport { DumpTools } from \"core/Misc/dumpTools\";\r\nimport { Tools } from \"core/Misc/tools\";\r\nimport type { Scene } from \"core/scene\";\r\nimport type { FloatArray, Nullable } from \"core/types\";\r\n\r\n/**\r\n * Ported from https://github.com/mrdoob/three.js/blob/master/examples/jsm/exporters/USDZExporter.js\r\n * Thanks a lot to the three.js team for their amazing work!\r\n */\r\n\r\n// FFlate access\r\ndeclare const fflate: any;\r\n\r\n/**\r\n * Options for the USDZ export\r\n */\r\nexport interface IUSDZExportOptions {\r\n /**\r\n * URL to load the fflate library from\r\n */\r\n fflateUrl?: string;\r\n /**\r\n * Include anchoring properties in the USDZ file\r\n */\r\n includeAnchoringProperties?: boolean;\r\n /**\r\n * Anchoring type (plane by default)\r\n */\r\n anchoringType?: string;\r\n /**\r\n * Plane anchoring alignment (horizontal by default)\r\n */\r\n planeAnchoringAlignment?: string;\r\n /**\r\n * Model file name (model.usda by default)\r\n */\r\n modelFileName?: string;\r\n /**\r\n * Precision to use for number (5 by default)\r\n */\r\n precision?: number;\r\n /**\r\n * Export the camera (false by default)\r\n */\r\n exportCamera?: boolean;\r\n /**\r\n * Camera sensor width (35 by default)\r\n */\r\n cameraSensorWidth?: number;\r\n}\r\n\r\nfunction BuildHeader() {\r\n return `#usda 1.0\r\n (\r\n customLayerData = {\r\n string creator = \"Babylon.js USDZExportAsync\"\r\n }\r\n defaultPrim = \"Root\"\r\n metersPerUnit = 1\r\n upAxis = \"Y\"\r\n )`;\r\n}\r\n\r\nfunction BuildSceneStart(options: IUSDZExportOptions) {\r\n const alignment =\r\n options.includeAnchoringProperties === true\r\n ? `\r\n\t\ttoken preliminary:anchoring:type = \"${options.anchoringType}\"\r\n\t\ttoken preliminary:planeAnchoring:alignment = \"${options.planeAnchoringAlignment}\"`\r\n : \"\";\r\n return `def Xform \"Root\"\r\n {\r\n def Scope \"Scenes\" (\r\n kind = \"sceneLibrary\"\r\n )\r\n {\r\n def Xform \"Scene\" (\r\n customData = {\r\n bool preliminary_collidesWithEnvironment = 0\r\n string sceneName = \"Scene\"\r\n }\r\n sceneName = \"Scene\"\r\n )\r\n {${alignment}\r\n `;\r\n}\r\n\r\nfunction BuildSceneEnd() {\r\n return `\r\n }\r\n }\r\n }`;\r\n}\r\n\r\nfunction BuildMeshVertexCount(geometry: Geometry) {\r\n const count = geometry.getIndices()?.length ? geometry.getTotalIndices() : geometry.getTotalVertices();\r\n\r\n return Array(count / 3)\r\n .fill(3)\r\n .join(\", \");\r\n}\r\n\r\nfunction BuildMeshVertexIndices(geometry: Geometry) {\r\n const index = geometry.getIndices();\r\n const array = [];\r\n\r\n if (index !== null) {\r\n for (let i = 0; i < index.length; i++) {\r\n array.push(index[i]);\r\n }\r\n } else {\r\n const length = geometry.getTotalVertices();\r\n\r\n for (let i = 0; i < length; i++) {\r\n array.push(i);\r\n }\r\n }\r\n\r\n return array.join(\", \");\r\n}\r\n\r\nfunction BuildVector3Array(attribute: FloatArray, options: IUSDZExportOptions, stride = 3) {\r\n const array = [];\r\n\r\n for (let i = 0; i < attribute.length / stride; i++) {\r\n const x = attribute[i * stride];\r\n const y = attribute[i * stride + 1];\r\n const z = attribute[i * stride + 2];\r\n\r\n array.push(`(${x.toPrecision(options.precision)}, ${y.toPrecision(options.precision)}, ${z.toPrecision(options.precision)})`);\r\n }\r\n\r\n return array.join(\", \");\r\n}\r\n\r\nfunction BuildVector2Array(attribute: FloatArray, options: IUSDZExportOptions) {\r\n const array = [];\r\n\r\n for (let i = 0; i < attribute.length / 2; i++) {\r\n const x = attribute[i * 2];\r\n const y = attribute[i * 2 + 1];\r\n\r\n array.push(`(${x.toPrecision(options.precision)}, ${(1 - y).toPrecision(options.precision)})`);\r\n }\r\n\r\n return array.join(\", \");\r\n}\r\n\r\nfunction BuildAdditionalAttributes(geometry: Geometry, options: IUSDZExportOptions) {\r\n let string = \"\";\r\n\r\n for (let i = 0; i < 4; i++) {\r\n const id = i > 0 ? i : \"\";\r\n const uvAttribute = geometry.getVerticesData(VertexBuffer.UVKind + (id ? id : \"\"));\r\n\r\n if (uvAttribute) {\r\n string += `\r\n\t\ttexCoord2f[] primvars:st${id} = [${BuildVector2Array(uvAttribute, options)}] (\r\n\t\t\tinterpolation = \"vertex\"\r\n\t\t)`;\r\n }\r\n }\r\n\r\n // vertex colors\r\n\r\n const colorAttribute = geometry.getVerticesData(VertexBuffer.ColorKind);\r\n\r\n if (colorAttribute) {\r\n string += `\r\n\tcolor3f[] primvars:displayColor = [${BuildVector3Array(colorAttribute, options, 4)}] (\r\n\t\tinterpolation = \"vertex\"\r\n\t\t)`;\r\n }\r\n\r\n return string;\r\n}\r\n\r\nfunction BuildMesh(geometry: Geometry, options: IUSDZExportOptions) {\r\n const name = \"Geometry\";\r\n const position = geometry.getVerticesData(VertexBuffer.PositionKind);\r\n const normal = geometry.getVerticesData(VertexBuffer.PositionKind);\r\n\r\n if (!position || !normal) {\r\n return;\r\n }\r\n\r\n return `\r\n\tdef Mesh \"${name}\"\r\n\t{\r\n\t\tint[] faceVertexCounts = [${BuildMeshVertexCount(geometry)}]\r\n\t\tint[] faceVertexIndices = [${BuildMeshVertexIndices(geometry)}]\r\n\t\tnormal3f[] normals = [${BuildVector3Array(normal, options)}] (\r\n\t\t\tinterpolation = \"vertex\"\r\n\t\t)\r\n\t\tpoint3f[] points = [${BuildVector3Array(position, options)}]\r\n ${BuildAdditionalAttributes(geometry, options)}\r\n\t\tuniform token subdivisionScheme = \"none\"\r\n\t}\r\n`;\r\n}\r\n\r\nfunction BuildMeshObject(geometry: Geometry, options: IUSDZExportOptions) {\r\n const mesh = BuildMesh(geometry, options);\r\n return `\r\n def \"Geometry\"\r\n {\r\n ${mesh}\r\n }\r\n `;\r\n}\r\n\r\nfunction BuildUSDFileAsString(dataToInsert: string) {\r\n let output = BuildHeader();\r\n output += dataToInsert;\r\n return fflate.strToU8(output);\r\n}\r\n\r\nfunction BuildMatrix(matrix: Matrix) {\r\n const array = matrix.m as number[];\r\n\r\n return `( ${BuildMatrixRow(array, 0)}, ${BuildMatrixRow(array, 4)}, ${BuildMatrixRow(array, 8)}, ${BuildMatrixRow(array, 12)} )`;\r\n}\r\n\r\nfunction BuildMatrixRow(array: number[], offset: number) {\r\n return `(${array[offset + 0]}, ${array[offset + 1]}, ${array[offset + 2]}, ${array[offset + 3]})`;\r\n}\r\n\r\nfunction BuildXform(mesh: Mesh) {\r\n const name = \"Object_\" + mesh.uniqueId;\r\n const matrix = mesh.getWorldMatrix().clone();\r\n\r\n if (matrix.determinant() < 0) {\r\n matrix.multiplyToRef(Matrix.Scaling(-1, 1, 1), matrix);\r\n }\r\n const transform = BuildMatrix(matrix);\r\n\r\n return `def Xform \"${name}\" (\r\n\tprepend references = @./geometries/Geometry_${mesh.geometry!.uniqueId}.usda@</Geometry>\r\n\tprepend apiSchemas = [\"MaterialBindingAPI\"]\r\n)\r\n{\r\n\tmatrix4d xformOp:transform = ${transform}\r\n\tuniform token[] xformOpOrder = [\"xformOp:transform\"]\t\r\n\r\n rel material:binding = </Materials/Material_${mesh.material!.uniqueId}>\r\n}\r\n\r\n`;\r\n}\r\n\r\nfunction BuildMaterials(materials: { [key: string]: Material }, textureToExports: { [key: string]: BaseTexture }, options: IUSDZExportOptions) {\r\n const array = [];\r\n\r\n for (const uuid in materials) {\r\n const material = materials[uuid];\r\n\r\n array.push(BuildMaterial(material, textureToExports, options));\r\n }\r\n\r\n return `\r\n def \"Materials\"\r\n{\r\n${array.join(\"\")}\r\n}\r\n\r\n`;\r\n}\r\n\r\nfunction BuildWrapping(wrapping: number) {\r\n switch (wrapping) {\r\n case Constants.TEXTURE_CLAMP_ADDRESSMODE:\r\n return \"clamp\";\r\n case Constants.TEXTURE_MIRROR_ADDRESSMODE:\r\n return \"mirror\";\r\n case Constants.TEXTURE_WRAP_ADDRESSMODE:\r\n default:\r\n return \"repeat\";\r\n }\r\n}\r\n\r\nfunction BuildColor4(color: Color3) {\r\n return `(${color.r}, ${color.g}, ${color.b}, 1.0)`;\r\n}\r\n\r\nfunction BuildVector2(vector: Vector2) {\r\n return `(${vector.x}, ${vector.y})`;\r\n}\r\n\r\nfunction BuildColor(color: Color3) {\r\n return `(${color.r}, ${color.g}, ${color.b})`;\r\n}\r\n\r\nfunction BuildTexture(\r\n texture: Texture,\r\n material: Material,\r\n mapType: string,\r\n color: Nullable<Color3>,\r\n textureToExports: { [key: string]: BaseTexture },\r\n options: IUSDZExportOptions\r\n) {\r\n const id = texture.getInternalTexture()!.uniqueId + \"_\" + texture.invertY;\r\n\r\n textureToExports[id] = texture;\r\n\r\n const uv = texture.coordinatesIndex > 0 ? \"st\" + texture.coordinatesIndex : \"st\";\r\n const repeat = new Vector2(texture.uScale, texture.vScale);\r\n const offset = new Vector2(texture.uOffset, texture.vOffset);\r\n const rotation = texture.wAng;\r\n\r\n // rotation is around the wrong point. after rotation we need to shift offset again so that we're rotating around the right spot\r\n const xRotationOffset = Math.sin(rotation);\r\n const yRotationOffset = Math.cos(rotation);\r\n\r\n // texture coordinates start in the opposite corner, need to correct\r\n offset.y = 1 - offset.y - repeat.y;\r\n\r\n offset.x += xRotationOffset * repeat.x;\r\n offset.y += (1 - yRotationOffset) * repeat.y;\r\n\r\n return `\r\n def Shader \"PrimvarReader_${mapType}\"\r\n {\r\n uniform token info:id = \"UsdPrimvarReader_float2\"\r\n float2 inputs:fallback = (0.0, 0.0)\r\n token inputs:varname = \"${uv}\"\r\n float2 outputs:result\r\n }\r\n\r\n def Shader \"Transform2d_${mapType}\"\r\n {\r\n uniform token info:id = \"UsdTransform2d\"\r\n token inputs:in.connect = </Materials/Material_${material.uniqueId}/PrimvarReader_${mapType}.outputs:result>\r\n float inputs:rotation = ${(rotation * (180 / Math.PI)).toFixed(options.precision)}\r\n float2 inputs:scale = ${BuildVector2(repeat)}\r\n float2 inputs:translation = ${BuildVector2(offset)}\r\n float2 outputs:result\r\n }\r\n\r\n def Shader \"Texture_${texture.uniqueId}_${mapType}\"\r\n {\r\n uniform token info:id = \"UsdUVTexture\"\r\n asset inputs:file = @textures/Texture_${id}.png@\r\n float2 inputs:st.connect = </Materials/Material_${material.uniqueId}/Transform2d_${mapType}.outputs:result>\r\n ${color ? \"float4 inputs:scale = \" + BuildColor4(color) : \"\"}\r\n token inputs:sourceColorSpace = \"${texture.gammaSpace ? \"raw\" : \"sRGB\"}\"\r\n token inputs:wrapS = \"${BuildWrapping(texture.wrapU)}\"\r\n token inputs:wrapT = \"${BuildWrapping(texture.wrapV)}\"\r\n float outputs:r\r\n float outputs:g\r\n float outputs:b\r\n float3 outputs:rgb\r\n ${material.needAlphaBlending() ? \"float outputs:a\" : \"\"}\r\n }`;\r\n}\r\n\r\nfunction ExtractTextureInformations(material: Material) {\r\n const className = material.getClassName();\r\n\r\n switch (className) {\r\n case \"StandardMaterial\":\r\n return {\r\n diffuseMap: (material as StandardMaterial).diffuseTexture,\r\n diffuse: (material as StandardMaterial).diffuseColor,\r\n alphaCutOff: (material as StandardMaterial).alphaCutOff,\r\n emissiveMap: (material as StandardMaterial).emissiveTexture,\r\n emissive: (material as StandardMaterial).emissiveColor,\r\n roughnessMap: null,\r\n normalMap: null,\r\n metalnessMap: null,\r\n roughness: 1,\r\n metalness: 0,\r\n aoMap: null,\r\n aoMapIntensity: 0,\r\n alphaMap: (material as StandardMaterial).opacityTexture,\r\n ior: 1,\r\n };\r\n case \"PBRMaterial\":\r\n return {\r\n diffuseMap: (material as PBRMaterial).albedoTexture,\r\n diffuse: (material as PBRMaterial).albedoColor,\r\n alphaCutOff: (material as PBRMaterial).alphaCutOff,\r\n emissiveMap: (material as PBRMaterial).emissiveTexture,\r\n emissive: (material as PBRMaterial).emissiveColor,\r\n normalMap: (material as PBRMaterial).bumpTexture,\r\n roughnessMap: (material as PBRMaterial).metallicTexture,\r\n roughnessChannel: (material as PBRMaterial).useRoughnessFromMetallicTextureAlpha ? \"a\" : \"g\",\r\n roughness: (material as PBRMaterial).roughness || 1,\r\n metalnessMap: (material as PBRMaterial).metallicTexture,\r\n metalnessChannel: (material as PBRMaterial).useMetallnessFromMetallicTextureBlue ? \"b\" : \"r\",\r\n metalness: (material as PBRMaterial).metallic || 0,\r\n aoMap: (material as PBRMaterial).ambientTexture,\r\n aoMapChannel: (material as PBRMaterial).useAmbientInGrayScale ? \"r\" : \"rgb\",\r\n aoMapIntensity: (material as PBRMaterial).ambientTextureStrength,\r\n alphaMap: (material as PBRMaterial).opacityTexture,\r\n ior: (material as PBRMaterial).indexOfRefraction,\r\n };\r\n case \"PBRMetallicRoughnessMaterial\":\r\n return {\r\n diffuseMap: (material as PBRMetallicRoughnessMaterial).baseTexture,\r\n diffuse: (material as PBRMetallicRoughnessMaterial).baseColor,\r\n alphaCutOff: (material as PBRMetallicRoughnessMaterial).alphaCutOff,\r\n emissiveMap: (material as PBRMetallicRoughnessMaterial).emissiveTexture,\r\n emissive: (material as PBRMetallicRoughnessMaterial).emissiveColor,\r\n normalMap: (material as PBRMetallicRoughnessMaterial).normalTexture,\r\n roughnessMap: (material as PBRMaterial).metallicTexture,\r\n roughnessChannel: (material as PBRMaterial).useRoughnessFromMetallicTextureAlpha ? \"a\" : \"g\",\r\n roughness: (material as PBRMetallicRoughnessMaterial).roughness || 1,\r\n metalnessMap: (material as PBRMaterial).metallicTexture,\r\n metalnessChannel: (material as PBRMaterial).useMetallnessFromMetallicTextureBlue ? \"b\" : \"r\",\r\n metalness: (material as PBRMetallicRoughnessMaterial).metallic || 0,\r\n aoMap: (material as PBRMaterial).ambientTexture,\r\n aoMapChannel: (material as PBRMaterial).useAmbientInGrayScale ? \"r\" : \"rgb\",\r\n aoMapIntensity: (material as PBRMaterial).ambientTextureStrength,\r\n alphaMap: (material as PBRMaterial).opacityTexture,\r\n ior: (material as PBRMaterial).indexOfRefraction,\r\n };\r\n default:\r\n return {\r\n diffuseMap: null,\r\n diffuse: null,\r\n emissiveMap: null,\r\n emissemissiveiveColor: null,\r\n normalMap: null,\r\n roughnessMap: null,\r\n metalnessMap: null,\r\n alphaCutOff: 0,\r\n roughness: 0,\r\n metalness: 0,\r\n aoMap: null,\r\n aoMapIntensity: 0,\r\n alphaMap: null,\r\n ior: 1,\r\n };\r\n }\r\n}\r\n\r\nfunction BuildMaterial(material: Material, textureToExports: { [key: string]: BaseTexture }, options: IUSDZExportOptions) {\r\n // https://graphics.pixar.com/usd/docs/UsdPreviewSurface-Proposal.html\r\n\r\n const pad = \"\t\t\t\";\r\n const inputs = [];\r\n const samplers = [];\r\n\r\n const {\r\n diffuseMap,\r\n diffuse,\r\n alphaCutOff,\r\n emissiveMap,\r\n emissive,\r\n normalMap,\r\n roughnessMap,\r\n roughnessChannel,\r\n roughness,\r\n metalnessMap,\r\n metalnessChannel,\r\n metalness,\r\n aoMap,\r\n aoMapChannel,\r\n aoMapIntensity,\r\n alphaMap,\r\n ior,\r\n } = ExtractTextureInformations(material);\r\n\r\n if (diffuseMap !== null) {\r\n inputs.push(`${pad}color3f inputs:diffuseColor.connect = </Materials/Material_${material.uniqueId}/Texture_${diffuseMap.uniqueId}_diffuse.outputs:rgb>`);\r\n\r\n if (material.needAlphaBlending()) {\r\n inputs.push(`${pad}float inputs:opacity.connect = </Materials/Material_${material.uniqueId}/Texture_${diffuseMap.uniqueId}_diffuse.outputs:a>`);\r\n } else if (material.needAlphaTesting()) {\r\n inputs.push(`${pad}float inputs:opacity.connect = </Materials/Material_${material.uniqueId}/Texture_${diffuseMap.uniqueId}_diffuse.outputs:a>`);\r\n inputs.push(`${pad}float inputs:opacityThreshold = ${alphaCutOff}`);\r\n }\r\n\r\n samplers.push(BuildTexture(diffuseMap as Texture, material, \"diffuse\", diffuse, textureToExports, options));\r\n } else {\r\n inputs.push(`${pad}color3f inputs:diffuseColor = ${BuildColor(diffuse || Color3.White())}`);\r\n }\r\n\r\n if (emissiveMap !== null) {\r\n inputs.push(`${pad}color3f inputs:emissiveColor.connect = </Materials/Material_${material.uniqueId}/Texture_${emissiveMap.uniqueId}_emissive.outputs:rgb>`);\r\n\r\n samplers.push(BuildTexture(emissiveMap as Texture, material, \"emissive\", emissive, textureToExports, options));\r\n } else if (emissive && emissive.toLuminance() > 0) {\r\n inputs.push(`${pad}color3f inputs:emissiveColor = ${BuildColor(emissive)}`);\r\n }\r\n\r\n if (normalMap !== null) {\r\n inputs.push(`${pad}normal3f inputs:normal.connect = </Materials/Material_${material.uniqueId}/Texture_${normalMap.uniqueId}_normal.outputs:rgb>`);\r\n\r\n samplers.push(BuildTexture(normalMap as Texture, material, \"normal\", null, textureToExports, options));\r\n }\r\n\r\n if (aoMap !== null) {\r\n inputs.push(`${pad}float inputs:occlusion.connect = </Materials/Material_${material.uniqueId}/Texture_${aoMap.uniqueId}_occlusion.outputs:${aoMapChannel}>`);\r\n\r\n samplers.push(BuildTexture(aoMap as Texture, material, \"occlusion\", new Color3(aoMapIntensity, aoMapIntensity, aoMapIntensity), textureToExports, options));\r\n }\r\n\r\n if (roughnessMap !== null) {\r\n inputs.push(`${pad}float inputs:roughness.connect = </Materials/Material_${material.uniqueId}/Texture_${roughnessMap.uniqueId}_roughness.outputs:${roughnessChannel}>`);\r\n\r\n samplers.push(BuildTexture(roughnessMap as Texture, material, \"roughness\", new Color3(roughness, roughness, roughness), textureToExports, options));\r\n } else {\r\n inputs.push(`${pad}float inputs:roughness = ${roughness}`);\r\n }\r\n\r\n if (metalnessMap !== null) {\r\n inputs.push(`${pad}float inputs:metallic.connect = </Materials/Material_${material.uniqueId}/Texture_${metalnessMap.uniqueId}_metallic.outputs:${metalnessChannel}>`);\r\n\r\n samplers.push(BuildTexture(metalnessMap as Texture, material, \"metallic\", new Color3(metalness, metalness, metalness), textureToExports, options));\r\n } else {\r\n inputs.push(`${pad}float inputs:metallic = ${metalness}`);\r\n }\r\n\r\n if (alphaMap !== null) {\r\n inputs.push(`${pad}float inputs:opacity.connect = </Materials/Material_${material.uniqueId}/Texture_${alphaMap.uniqueId}_opacity.outputs:r>`);\r\n inputs.push(`${pad}float inputs:opacityThreshold = 0.0001`);\r\n\r\n samplers.push(BuildTexture(alphaMap as Texture, material, \"opacity\", null, textureToExports, options));\r\n } else {\r\n inputs.push(`${pad}float inputs:opacity = ${material.alpha}`);\r\n }\r\n\r\n inputs.push(`${pad}float inputs:ior = ${ior}`);\r\n\r\n return `\r\n\tdef Material \"Material_${material.uniqueId}\"\r\n\t{\r\n\t\tdef Shader \"PreviewSurface\"\r\n\t\t{\r\n\t\t\tuniform token info:id = \"UsdPreviewSurface\"\r\n${inputs.join(\"\\n\")}\r\n\t\t\tint inputs:useSpecularWorkflow = 0\r\n\t\t\ttoken outputs:surface\r\n\t\t}\r\n\r\n\t\ttoken outputs:surface.connect = </Materials/Material_${material.uniqueId}/PreviewSurface.outputs:surface>\r\n\r\n${samplers.join(\"\\n\")}\r\n\r\n\t}\r\n`;\r\n}\r\n\r\nfunction BuildCamera(camera: Camera, options: IUSDZExportOptions) {\r\n const name = \"Camera_\" + camera.uniqueId;\r\n const matrix = Matrix.RotationY(Math.PI).multiply(camera.getWorldMatrix()); // work towards positive z\r\n\r\n const transform = BuildMatrix(matrix);\r\n\r\n if (camera.mode === Constants.ORTHOGRAPHIC_CAMERA) {\r\n return `def Camera \"${name}\"\r\n\t\t{\r\n\t\t\tmatrix4d xformOp:transform = ${transform}\r\n\t\t\tuniform token[] xformOpOrder = [\"xformOp:transform\"]\r\n\r\n\t\t\tfloat2 clippingRange = (${camera.minZ.toPrecision(options.precision)}, ${camera.maxZ.toPrecision(options.precision)})\r\n\t\t\tfloat horizontalAperture = ${((Math.abs(camera.orthoLeft || 1) + Math.abs(camera.orthoRight || 1)) * 10).toPrecision(options.precision)}\r\n\t\t\tfloat verticalAperture = ${((Math.abs(camera.orthoTop || 1) + Math.abs(camera.orthoBottom || 1)) * 10).toPrecision(options.precision)}\r\n\t\t\ttoken projection = \"orthographic\"\r\n\t\t}\r\n\t\r\n\t`;\r\n } else {\r\n const aspect = camera.getEngine().getAspectRatio(camera);\r\n const sensorwidth = options.cameraSensorWidth || 35;\r\n\r\n return `def Camera \"${name}\"\r\n\t\t{\r\n\t\t\tmatrix4d xformOp:transform = ${transform}\r\n\t\t\tuniform token[] xformOpOrder = [\"xformOp:transform\"]\r\n\r\n\t\t\tfloat2 clippingRange = (${camera.minZ.toPrecision(options.precision)}, ${camera.maxZ.toPrecision(options.precision)})\r\n\t\t\tfloat focalLength = ${(sensorwidth / (2 * Math.tan(camera.fov * 0.5))).toPrecision(options.precision)}\r\n token projection = \"perspective\"\r\n\t\t\tfloat horizontalAperture = ${(sensorwidth * aspect).toPrecision(options.precision)}\r\n\t\t\tfloat verticalAperture = ${(sensorwidth / aspect).toPrecision(options.precision)} \r\n\t\t}\r\n\t\r\n\t`;\r\n }\r\n}\r\n\r\n/**\r\n *\r\n * @param scene scene to export\r\n * @param options options to configure the export\r\n * @param meshPredicate predicate to filter the meshes to export\r\n * @returns a uint8 array containing the USDZ file\r\n * #H2G5XW#3 - Simple sphere\r\n * #H2G5XW#4 - Red sphere\r\n * #5N3RWK#4 - Boombox\r\n */\r\nexport async function USDZExportAsync(scene: Scene, options: Partial<IUSDZExportOptions>, meshPredicate?: (m: Mesh) => boolean): Promise<Uint8Array> {\r\n const localOptions = {\r\n fflateUrl: \"https://unpkg.com/fflate@0.8.2\",\r\n includeAnchoringProperties: true,\r\n anchoringType: \"plane\",\r\n planeAnchoringAlignment: \"horizontal\",\r\n modelFileName: \"model.usda\",\r\n precision: 5,\r\n exportCamera: false,\r\n cameraSensorWidth: 35,\r\n ...options,\r\n };\r\n\r\n // Get the fflate library\r\n if (typeof fflate === \"undefined\") {\r\n await Tools.LoadScriptAsync(localOptions.fflateUrl);\r\n }\r\n\r\n // Start the export\r\n const files: { [key: string]: any } = {};\r\n\r\n // model file should be first in USDZ archive so we init it here\r\n files[localOptions.modelFileName] = null;\r\n\r\n let output = BuildHeader();\r\n output += BuildSceneStart(localOptions);\r\n\r\n const materialToExports: { [key: string]: Material } = {};\r\n\r\n // Meshes\r\n for (const abstractMesh of scene.meshes) {\r\n if (abstractMesh.getTotalVertices() === 0) {\r\n continue;\r\n }\r\n const mesh = abstractMesh as Mesh;\r\n const geometry = mesh.geometry;\r\n const material = mesh.material;\r\n\r\n if (!material || !geometry || (meshPredicate && !meshPredicate(mesh))) {\r\n continue;\r\n }\r\n\r\n const supportedMaterials = [\"StandardMaterial\", \"PBRMaterial\", \"PBRMetallicRoughnessMaterial\"];\r\n\r\n if (supportedMaterials.indexOf(material.getClassName()) !== -1) {\r\n const geometryFileName = \"geometries/Geometry_\" + geometry.uniqueId + \".usda\";\r\n\r\n if (!(geometryFileName in files)) {\r\n const meshObject = BuildMeshObject(geometry, localOptions);\r\n files[geometryFileName] = BuildUSDFileAsString(meshObject);\r\n }\r\n\r\n if (!(material.uniqueId in materialToExports)) {\r\n materialToExports[material.uniqueId] = material;\r\n }\r\n\r\n output += BuildXform(mesh);\r\n } else {\r\n Tools.Warn(\"USDZExportAsync does not support this material type: \" + material.getClassName());\r\n }\r\n }\r\n\r\n // Camera\r\n if (scene.activeCamera && localOptions.exportCamera) {\r\n output += BuildCamera(scene.activeCamera, localOptions);\r\n }\r\n\r\n // Close scene\r\n output += BuildSceneEnd();\r\n\r\n // Materials\r\n const textureToExports: { [key: string]: BaseTexture } = {};\r\n output += BuildMaterials(materialToExports, textureToExports, localOptions);\r\n\r\n // Compress\r\n files[localOptions.modelFileName] = fflate.strToU8(output);\r\n\r\n // Textures\r\n for (const id in textureToExports) {\r\n const texture = textureToExports[id];\r\n\r\n const size = texture.getSize();\r\n const textureData = await texture.readPixels();\r\n\r\n if (!textureData) {\r\n throw new Error(\"Texture data is not available\");\r\n }\r\n\r\n const fileContent = await DumpTools.DumpDataAsync(size.width, size.height, textureData, \"image/png\", undefined, false, true);\r\n\r\n files[`textures/Texture_${id}.png`] = new Uint8Array(fileContent as ArrayBuffer).slice(); // This is to avoid getting a link and not a copy\r\n }\r\n\r\n // 64 byte alignment\r\n // https://github.com/101arrowz/fflate/issues/39#issuecomment-777263109\r\n\r\n let offset = 0;\r\n\r\n for (const filename in files) {\r\n const file = files[filename];\r\n if (!file) {\r\n continue;\r\n }\r\n const headerSize = 34 + filename.length;\r\n\r\n offset += headerSize;\r\n\r\n const offsetMod64 = offset & 63;\r\n\r\n if (offsetMod64 !== 4) {\r\n const padLength = 64 - offsetMod64;\r\n const padding = new Uint8Array(padLength);\r\n\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n files[filename] = [file, { extra: { 12345: padding } }];\r\n }\r\n\r\n offset = file.length;\r\n }\r\n\r\n return fflate.zipSync(files, { level: 0 });\r\n}\r\n"]}
1
+ {"version":3,"file":"usdzExporter.js","sourceRoot":"","sources":["../../../../dev/serializers/src/USDZ/usdzExporter.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,OAAO,EAAE,YAAY,EAAE,0CAA4B;AAEnD,OAAO,EAAE,SAAS,EAAE,6CAA+B;AAOnD,OAAO,EAAE,MAAM,EAAE,4CAA8B;AAC/C,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,6CAA+B;AAGzD,OAAO,EAAE,SAAS,EAAE,0CAA4B;AAChD,OAAO,EAAE,KAAK,EAAE,sCAAwB;AAkDxC,SAAS,WAAW;IAChB,OAAO;;;;;;;;MAQL,CAAC;AACP,CAAC;AAED,SAAS,eAAe,CAAC,OAA2B;IAChD,MAAM,SAAS,GACX,OAAO,CAAC,0BAA0B,KAAK,IAAI;QACvC,CAAC,CAAC;wCAC0B,OAAO,CAAC,aAAa;kDACX,OAAO,CAAC,uBAAuB,GAAG;QACxE,CAAC,CAAC,EAAE,CAAC;IACb,OAA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AAC,GAAG,IAAI,UAAU,CAAC,WAA0B,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,iDAAiD;IAC/I,CAAC;IAED,oBAAoB;IACpB,uEAAuE;IAEvE,IAAI,MAAM,GAAG,CAAC,CAAC;IAEf,KAAK,MAAM,QAAQ,IAAI,KAAK,EAAE,CAAC;QAC3B,MAAM,IAAI,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC;QAC7B,IAAI,CAAC,IAAI,EAAE,CAAC;YACR,SAAS;QACb,CAAC;QACD,MAAM,UAAU,GAAG,EAAE,GAAG,QAAQ,CAAC,MAAM,CAAC;QAExC,MAAM,IAAI,UAAU,CAAC;QAErB,MAAM,WAAW,GAAG,MAAM,GAAG,EAAE,CAAC;QAEhC,IAAI,WAAW,KAAK,CAAC,EAAE,CAAC;YACpB,MAAM,SAAS,GAAG,EAAE,GAAG,WAAW,CAAC;YACnC,MAAM,OAAO,GAAG,IAAI,UAAU,CAAC,SAAS,CAAC,CAAC;YAE1C,gEAAgE;YAChE,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC;QAC5D,CAAC;QAED,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IACzB,CAAC;IAED,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;AAC/C,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport { VertexBuffer } from \"core/Buffers/buffer\";\r\nimport type { Camera } from \"core/Cameras/camera\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport type { PBRMaterial } from \"core/Materials/PBR/pbrMaterial\";\r\nimport type { PBRMetallicRoughnessMaterial } from \"core/Materials/PBR/pbrMetallicRoughnessMaterial\";\r\nimport type { StandardMaterial } from \"core/Materials/standardMaterial\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport type { Texture } from \"core/Materials/Textures/texture\";\r\nimport { Color3 } from \"core/Maths/math.color\";\r\nimport { Matrix, Vector2 } from \"core/Maths/math.vector\";\r\nimport type { Geometry } from \"core/Meshes/geometry\";\r\nimport type { Mesh } from \"core/Meshes/mesh\";\r\nimport { DumpTools } from \"core/Misc/dumpTools\";\r\nimport { Tools } from \"core/Misc/tools\";\r\nimport type { Scene } from \"core/scene\";\r\nimport type { FloatArray, Nullable } from \"core/types\";\r\n\r\n/**\r\n * Ported from https://github.com/mrdoob/three.js/blob/master/examples/jsm/exporters/USDZExporter.js\r\n * Thanks a lot to the three.js team for their amazing work!\r\n */\r\n\r\n// FFlate access\r\ndeclare const fflate: any;\r\n\r\n/**\r\n * Options for the USDZ export\r\n */\r\nexport interface IUSDZExportOptions {\r\n /**\r\n * URL to load the fflate library from\r\n */\r\n fflateUrl?: string;\r\n /**\r\n * Include anchoring properties in the USDZ file\r\n */\r\n includeAnchoringProperties?: boolean;\r\n /**\r\n * Anchoring type (plane by default)\r\n */\r\n anchoringType?: string;\r\n /**\r\n * Plane anchoring alignment (horizontal by default)\r\n */\r\n planeAnchoringAlignment?: string;\r\n /**\r\n * Model file name (model.usda by default)\r\n */\r\n modelFileName?: string;\r\n /**\r\n * Precision to use for number (5 by default)\r\n */\r\n precision?: number;\r\n /**\r\n * Export the camera (false by default)\r\n */\r\n exportCamera?: boolean;\r\n /**\r\n * Camera sensor width (35 by default)\r\n */\r\n cameraSensorWidth?: number;\r\n}\r\n\r\nfunction BuildHeader() {\r\n return `#usda 1.0\r\n (\r\n customLayerData = {\r\n string creator = \"Babylon.js USDZExportAsync\"\r\n }\r\n defaultPrim = \"Root\"\r\n metersPerUnit = 1\r\n upAxis = \"Y\"\r\n )`;\r\n}\r\n\r\nfunction BuildSceneStart(options: IUSDZExportOptions) {\r\n const alignment =\r\n options.includeAnchoringProperties === true\r\n ? `\r\n\t\ttoken preliminary:anchoring:type = \"${options.anchoringType}\"\r\n\t\ttoken preliminary:planeAnchoring:alignment = \"${options.planeAnchoringAlignment}\"`\r\n : \"\";\r\n return `def Xform \"Root\"\r\n {\r\n def Scope \"Scenes\" (\r\n kind = \"sceneLibrary\"\r\n )\r\n {\r\n def Xform \"Scene\" (\r\n customData = {\r\n bool preliminary_collidesWithEnvironment = 0\r\n string sceneName = \"Scene\"\r\n }\r\n sceneName = \"Scene\"\r\n )\r\n {${alignment}\r\n `;\r\n}\r\n\r\nfunction BuildSceneEnd() {\r\n return `\r\n }\r\n }\r\n }`;\r\n}\r\n\r\nfunction BuildMeshVertexCount(geometry: Geometry) {\r\n const count = geometry.getIndices()?.length ? geometry.getTotalIndices() : geometry.getTotalVertices();\r\n\r\n return Array(count / 3)\r\n .fill(3)\r\n .join(\", \");\r\n}\r\n\r\nfunction BuildMeshVertexIndices(geometry: Geometry) {\r\n const index = geometry.getIndices();\r\n const array = [];\r\n\r\n if (index !== null) {\r\n for (let i = 0; i < index.length; i++) {\r\n array.push(index[i]);\r\n }\r\n } else {\r\n const length = geometry.getTotalVertices();\r\n\r\n for (let i = 0; i < length; i++) {\r\n array.push(i);\r\n }\r\n }\r\n\r\n return array.join(\", \");\r\n}\r\n\r\nfunction BuildVector3Array(attribute: FloatArray, options: IUSDZExportOptions, stride = 3) {\r\n const array = [];\r\n\r\n for (let i = 0; i < attribute.length / stride; i++) {\r\n const x = attribute[i * stride];\r\n const y = attribute[i * stride + 1];\r\n const z = attribute[i * stride + 2];\r\n\r\n array.push(`(${x.toPrecision(options.precision)}, ${y.toPrecision(options.precision)}, ${z.toPrecision(options.precision)})`);\r\n }\r\n\r\n return array.join(\", \");\r\n}\r\n\r\nfunction BuildVector2Array(attribute: FloatArray, options: IUSDZExportOptions) {\r\n const array = [];\r\n\r\n for (let i = 0; i < attribute.length / 2; i++) {\r\n const x = attribute[i * 2];\r\n const y = attribute[i * 2 + 1];\r\n\r\n array.push(`(${x.toPrecision(options.precision)}, ${(1 - y).toPrecision(options.precision)})`);\r\n }\r\n\r\n return array.join(\", \");\r\n}\r\n\r\nfunction BuildAdditionalAttributes(geometry: Geometry, options: IUSDZExportOptions) {\r\n let string = \"\";\r\n\r\n for (let i = 0; i < 4; i++) {\r\n const id = i > 0 ? i : \"\";\r\n const uvAttribute = geometry.getVerticesData(VertexBuffer.UVKind + (id ? id : \"\"));\r\n\r\n if (uvAttribute) {\r\n string += `\r\n\t\ttexCoord2f[] primvars:st${id} = [${BuildVector2Array(uvAttribute, options)}] (\r\n\t\t\tinterpolation = \"vertex\"\r\n\t\t)`;\r\n }\r\n }\r\n\r\n // vertex colors\r\n\r\n const colorAttribute = geometry.getVerticesData(VertexBuffer.ColorKind);\r\n\r\n if (colorAttribute) {\r\n string += `\r\n\tcolor3f[] primvars:displayColor = [${BuildVector3Array(colorAttribute, options, 4)}] (\r\n\t\tinterpolation = \"vertex\"\r\n\t\t)`;\r\n }\r\n\r\n return string;\r\n}\r\n\r\nfunction BuildMesh(geometry: Geometry, options: IUSDZExportOptions) {\r\n const name = \"Geometry\";\r\n const position = geometry.getVerticesData(VertexBuffer.PositionKind);\r\n const normal = geometry.getVerticesData(VertexBuffer.PositionKind);\r\n\r\n if (!position || !normal) {\r\n return;\r\n }\r\n\r\n return `\r\n\tdef Mesh \"${name}\"\r\n\t{\r\n\t\tint[] faceVertexCounts = [${BuildMeshVertexCount(geometry)}]\r\n\t\tint[] faceVertexIndices = [${BuildMeshVertexIndices(geometry)}]\r\n\t\tnormal3f[] normals = [${BuildVector3Array(normal, options)}] (\r\n\t\t\tinterpolation = \"vertex\"\r\n\t\t)\r\n\t\tpoint3f[] points = [${BuildVector3Array(position, options)}]\r\n ${BuildAdditionalAttributes(geometry, options)}\r\n\t\tuniform token subdivisionScheme = \"none\"\r\n\t}\r\n`;\r\n}\r\n\r\nfunction BuildMeshObject(geometry: Geometry, options: IUSDZExportOptions) {\r\n const mesh = BuildMesh(geometry, options);\r\n return `\r\n def \"Geometry\"\r\n {\r\n ${mesh}\r\n }\r\n `;\r\n}\r\n\r\nfunction BuildUSDFileAsString(dataToInsert: string) {\r\n let output = BuildHeader();\r\n output += dataToInsert;\r\n return fflate.strToU8(output);\r\n}\r\n\r\nfunction BuildMatrix(matrix: Matrix) {\r\n const array = matrix.m as number[];\r\n\r\n return `( ${BuildMatrixRow(array, 0)}, ${BuildMatrixRow(array, 4)}, ${BuildMatrixRow(array, 8)}, ${BuildMatrixRow(array, 12)} )`;\r\n}\r\n\r\nfunction BuildMatrixRow(array: number[], offset: number) {\r\n return `(${array[offset + 0]}, ${array[offset + 1]}, ${array[offset + 2]}, ${array[offset + 3]})`;\r\n}\r\n\r\nfunction BuildXform(mesh: Mesh) {\r\n const name = \"Object_\" + mesh.uniqueId;\r\n const matrix = mesh.getWorldMatrix().clone();\r\n\r\n if (matrix.determinant() < 0) {\r\n matrix.multiplyToRef(Matrix.Scaling(-1, 1, 1), matrix);\r\n }\r\n const transform = BuildMatrix(matrix);\r\n\r\n return `def Xform \"${name}\" (\r\n\tprepend references = @./geometries/Geometry_${mesh.geometry!.uniqueId}.usda@</Geometry>\r\n\tprepend apiSchemas = [\"MaterialBindingAPI\"]\r\n)\r\n{\r\n\tmatrix4d xformOp:transform = ${transform}\r\n\tuniform token[] xformOpOrder = [\"xformOp:transform\"]\t\r\n\r\n rel material:binding = </Materials/Material_${mesh.material!.uniqueId}>\r\n}\r\n\r\n`;\r\n}\r\n\r\nfunction BuildMaterials(materials: { [key: string]: Material }, textureToExports: { [key: string]: BaseTexture }, options: IUSDZExportOptions) {\r\n const array = [];\r\n\r\n for (const uuid in materials) {\r\n const material = materials[uuid];\r\n\r\n array.push(BuildMaterial(material, textureToExports, options));\r\n }\r\n\r\n return `\r\n def \"Materials\"\r\n{\r\n${array.join(\"\")}\r\n}\r\n\r\n`;\r\n}\r\n\r\nfunction BuildWrapping(wrapping: number) {\r\n switch (wrapping) {\r\n case Constants.TEXTURE_CLAMP_ADDRESSMODE:\r\n return \"clamp\";\r\n case Constants.TEXTURE_MIRROR_ADDRESSMODE:\r\n return \"mirror\";\r\n case Constants.TEXTURE_WRAP_ADDRESSMODE:\r\n default:\r\n return \"repeat\";\r\n }\r\n}\r\n\r\nfunction BuildColor4(color: Color3) {\r\n return `(${color.r}, ${color.g}, ${color.b}, 1.0)`;\r\n}\r\n\r\nfunction BuildVector2(vector: Vector2) {\r\n return `(${vector.x}, ${vector.y})`;\r\n}\r\n\r\nfunction BuildColor(color: Color3) {\r\n return `(${color.r}, ${color.g}, ${color.b})`;\r\n}\r\n\r\nfunction BuildTexture(\r\n texture: Texture,\r\n material: Material,\r\n mapType: string,\r\n color: Nullable<Color3>,\r\n textureToExports: { [key: string]: BaseTexture },\r\n options: IUSDZExportOptions\r\n) {\r\n const id = texture.getInternalTexture()!.uniqueId + \"_\" + texture.invertY;\r\n\r\n textureToExports[id] = texture;\r\n\r\n const uv = texture.coordinatesIndex > 0 ? \"st\" + texture.coordinatesIndex : \"st\";\r\n const repeat = new Vector2(texture.uScale, texture.vScale);\r\n const offset = new Vector2(texture.uOffset, texture.vOffset);\r\n const rotation = texture.wAng;\r\n\r\n // rotation is around the wrong point. after rotation we need to shift offset again so that we're rotating around the right spot\r\n const xRotationOffset = Math.sin(rotation);\r\n const yRotationOffset = Math.cos(rotation);\r\n\r\n // texture coordinates start in the opposite corner, need to correct\r\n offset.y = 1 - offset.y - repeat.y;\r\n\r\n offset.x += xRotationOffset * repeat.x;\r\n offset.y += (1 - yRotationOffset) * repeat.y;\r\n\r\n return `\r\n def Shader \"PrimvarReader_${mapType}\"\r\n {\r\n uniform token info:id = \"UsdPrimvarReader_float2\"\r\n float2 inputs:fallback = (0.0, 0.0)\r\n token inputs:varname = \"${uv}\"\r\n float2 outputs:result\r\n }\r\n\r\n def Shader \"Transform2d_${mapType}\"\r\n {\r\n uniform token info:id = \"UsdTransform2d\"\r\n token inputs:in.connect = </Materials/Material_${material.uniqueId}/PrimvarReader_${mapType}.outputs:result>\r\n float inputs:rotation = ${(rotation * (180 / Math.PI)).toFixed(options.precision)}\r\n float2 inputs:scale = ${BuildVector2(repeat)}\r\n float2 inputs:translation = ${BuildVector2(offset)}\r\n float2 outputs:result\r\n }\r\n\r\n def Shader \"Texture_${texture.uniqueId}_${mapType}\"\r\n {\r\n uniform token info:id = \"UsdUVTexture\"\r\n asset inputs:file = @textures/Texture_${id}.png@\r\n float2 inputs:st.connect = </Materials/Material_${material.uniqueId}/Transform2d_${mapType}.outputs:result>\r\n ${color ? \"float4 inputs:scale = \" + BuildColor4(color) : \"\"}\r\n token inputs:sourceColorSpace = \"${texture.gammaSpace ? \"raw\" : \"sRGB\"}\"\r\n token inputs:wrapS = \"${BuildWrapping(texture.wrapU)}\"\r\n token inputs:wrapT = \"${BuildWrapping(texture.wrapV)}\"\r\n float outputs:r\r\n float outputs:g\r\n float outputs:b\r\n float3 outputs:rgb\r\n ${material.needAlphaBlending() ? \"float outputs:a\" : \"\"}\r\n }`;\r\n}\r\n\r\nfunction ExtractTextureInformations(material: Material) {\r\n const className = material.getClassName();\r\n\r\n switch (className) {\r\n case \"StandardMaterial\":\r\n return {\r\n diffuseMap: (material as StandardMaterial).diffuseTexture,\r\n diffuse: (material as StandardMaterial).diffuseColor,\r\n alphaCutOff: (material as StandardMaterial).alphaCutOff,\r\n emissiveMap: (material as StandardMaterial).emissiveTexture,\r\n emissive: (material as StandardMaterial).emissiveColor,\r\n roughnessMap: null,\r\n normalMap: null,\r\n metalnessMap: null,\r\n roughness: 1,\r\n metalness: 0,\r\n aoMap: null,\r\n aoMapIntensity: 0,\r\n alphaMap: (material as StandardMaterial).opacityTexture,\r\n ior: 1,\r\n };\r\n case \"PBRMaterial\":\r\n return {\r\n diffuseMap: (material as PBRMaterial).albedoTexture,\r\n diffuse: (material as PBRMaterial).albedoColor,\r\n alphaCutOff: (material as PBRMaterial).alphaCutOff,\r\n emissiveMap: (material as PBRMaterial).emissiveTexture,\r\n emissive: (material as PBRMaterial).emissiveColor,\r\n normalMap: (material as PBRMaterial).bumpTexture,\r\n roughnessMap: (material as PBRMaterial).metallicTexture,\r\n roughnessChannel: (material as PBRMaterial).useRoughnessFromMetallicTextureAlpha ? \"a\" : \"g\",\r\n roughness: (material as PBRMaterial).roughness || 1,\r\n metalnessMap: (material as PBRMaterial).metallicTexture,\r\n metalnessChannel: (material as PBRMaterial).useMetallnessFromMetallicTextureBlue ? \"b\" : \"r\",\r\n metalness: (material as PBRMaterial).metallic || 0,\r\n aoMap: (material as PBRMaterial).ambientTexture,\r\n aoMapChannel: (material as PBRMaterial).useAmbientInGrayScale ? \"r\" : \"rgb\",\r\n aoMapIntensity: (material as PBRMaterial).ambientTextureStrength,\r\n alphaMap: (material as PBRMaterial).opacityTexture,\r\n ior: (material as PBRMaterial).indexOfRefraction,\r\n };\r\n case \"PBRMetallicRoughnessMaterial\":\r\n return {\r\n diffuseMap: (material as PBRMetallicRoughnessMaterial).baseTexture,\r\n diffuse: (material as PBRMetallicRoughnessMaterial).baseColor,\r\n alphaCutOff: (material as PBRMetallicRoughnessMaterial).alphaCutOff,\r\n emissiveMap: (material as PBRMetallicRoughnessMaterial).emissiveTexture,\r\n emissive: (material as PBRMetallicRoughnessMaterial).emissiveColor,\r\n normalMap: (material as PBRMetallicRoughnessMaterial).normalTexture,\r\n roughnessMap: (material as PBRMaterial).metallicTexture,\r\n roughnessChannel: (material as PBRMaterial).useRoughnessFromMetallicTextureAlpha ? \"a\" : \"g\",\r\n roughness: (material as PBRMetallicRoughnessMaterial).roughness || 1,\r\n metalnessMap: (material as PBRMaterial).metallicTexture,\r\n metalnessChannel: (material as PBRMaterial).useMetallnessFromMetallicTextureBlue ? \"b\" : \"r\",\r\n metalness: (material as PBRMetallicRoughnessMaterial).metallic || 0,\r\n aoMap: (material as PBRMaterial).ambientTexture,\r\n aoMapChannel: (material as PBRMaterial).useAmbientInGrayScale ? \"r\" : \"rgb\",\r\n aoMapIntensity: (material as PBRMaterial).ambientTextureStrength,\r\n alphaMap: (material as PBRMaterial).opacityTexture,\r\n ior: (material as PBRMaterial).indexOfRefraction,\r\n };\r\n default:\r\n return {\r\n diffuseMap: null,\r\n diffuse: null,\r\n emissiveMap: null,\r\n emissemissiveiveColor: null,\r\n normalMap: null,\r\n roughnessMap: null,\r\n metalnessMap: null,\r\n alphaCutOff: 0,\r\n roughness: 0,\r\n metalness: 0,\r\n aoMap: null,\r\n aoMapIntensity: 0,\r\n alphaMap: null,\r\n ior: 1,\r\n };\r\n }\r\n}\r\n\r\nfunction BuildMaterial(material: Material, textureToExports: { [key: string]: BaseTexture }, options: IUSDZExportOptions) {\r\n // https://graphics.pixar.com/usd/docs/UsdPreviewSurface-Proposal.html\r\n\r\n const pad = \"\t\t\t\";\r\n const inputs = [];\r\n const samplers = [];\r\n\r\n const {\r\n diffuseMap,\r\n diffuse,\r\n alphaCutOff,\r\n emissiveMap,\r\n emissive,\r\n normalMap,\r\n roughnessMap,\r\n roughnessChannel,\r\n roughness,\r\n metalnessMap,\r\n metalnessChannel,\r\n metalness,\r\n aoMap,\r\n aoMapChannel,\r\n aoMapIntensity,\r\n alphaMap,\r\n ior,\r\n } = ExtractTextureInformations(material);\r\n\r\n if (diffuseMap !== null) {\r\n inputs.push(`${pad}color3f inputs:diffuseColor.connect = </Materials/Material_${material.uniqueId}/Texture_${diffuseMap.uniqueId}_diffuse.outputs:rgb>`);\r\n\r\n if (material.needAlphaBlending()) {\r\n inputs.push(`${pad}float inputs:opacity.connect = </Materials/Material_${material.uniqueId}/Texture_${diffuseMap.uniqueId}_diffuse.outputs:a>`);\r\n } else if (material.needAlphaTesting()) {\r\n inputs.push(`${pad}float inputs:opacity.connect = </Materials/Material_${material.uniqueId}/Texture_${diffuseMap.uniqueId}_diffuse.outputs:a>`);\r\n inputs.push(`${pad}float inputs:opacityThreshold = ${alphaCutOff}`);\r\n }\r\n\r\n samplers.push(BuildTexture(diffuseMap as Texture, material, \"diffuse\", diffuse, textureToExports, options));\r\n } else {\r\n inputs.push(`${pad}color3f inputs:diffuseColor = ${BuildColor(diffuse || Color3.White())}`);\r\n }\r\n\r\n if (emissiveMap !== null) {\r\n inputs.push(`${pad}color3f inputs:emissiveColor.connect = </Materials/Material_${material.uniqueId}/Texture_${emissiveMap.uniqueId}_emissive.outputs:rgb>`);\r\n\r\n samplers.push(BuildTexture(emissiveMap as Texture, material, \"emissive\", emissive, textureToExports, options));\r\n } else if (emissive && emissive.toLuminance() > 0) {\r\n inputs.push(`${pad}color3f inputs:emissiveColor = ${BuildColor(emissive)}`);\r\n }\r\n\r\n if (normalMap !== null) {\r\n inputs.push(`${pad}normal3f inputs:normal.connect = </Materials/Material_${material.uniqueId}/Texture_${normalMap.uniqueId}_normal.outputs:rgb>`);\r\n\r\n samplers.push(BuildTexture(normalMap as Texture, material, \"normal\", null, textureToExports, options));\r\n }\r\n\r\n if (aoMap !== null) {\r\n inputs.push(`${pad}float inputs:occlusion.connect = </Materials/Material_${material.uniqueId}/Texture_${aoMap.uniqueId}_occlusion.outputs:${aoMapChannel}>`);\r\n\r\n samplers.push(BuildTexture(aoMap as Texture, material, \"occlusion\", new Color3(aoMapIntensity, aoMapIntensity, aoMapIntensity), textureToExports, options));\r\n }\r\n\r\n if (roughnessMap !== null) {\r\n inputs.push(`${pad}float inputs:roughness.connect = </Materials/Material_${material.uniqueId}/Texture_${roughnessMap.uniqueId}_roughness.outputs:${roughnessChannel}>`);\r\n\r\n samplers.push(BuildTexture(roughnessMap as Texture, material, \"roughness\", new Color3(roughness, roughness, roughness), textureToExports, options));\r\n } else {\r\n inputs.push(`${pad}float inputs:roughness = ${roughness}`);\r\n }\r\n\r\n if (metalnessMap !== null) {\r\n inputs.push(`${pad}float inputs:metallic.connect = </Materials/Material_${material.uniqueId}/Texture_${metalnessMap.uniqueId}_metallic.outputs:${metalnessChannel}>`);\r\n\r\n samplers.push(BuildTexture(metalnessMap as Texture, material, \"metallic\", new Color3(metalness, metalness, metalness), textureToExports, options));\r\n } else {\r\n inputs.push(`${pad}float inputs:metallic = ${metalness}`);\r\n }\r\n\r\n if (alphaMap !== null) {\r\n inputs.push(`${pad}float inputs:opacity.connect = </Materials/Material_${material.uniqueId}/Texture_${alphaMap.uniqueId}_opacity.outputs:r>`);\r\n inputs.push(`${pad}float inputs:opacityThreshold = 0.0001`);\r\n\r\n samplers.push(BuildTexture(alphaMap as Texture, material, \"opacity\", null, textureToExports, options));\r\n } else {\r\n inputs.push(`${pad}float inputs:opacity = ${material.alpha}`);\r\n }\r\n\r\n inputs.push(`${pad}float inputs:ior = ${ior}`);\r\n\r\n return `\r\n\tdef Material \"Material_${material.uniqueId}\"\r\n\t{\r\n\t\tdef Shader \"PreviewSurface\"\r\n\t\t{\r\n\t\t\tuniform token info:id = \"UsdPreviewSurface\"\r\n${inputs.join(\"\\n\")}\r\n\t\t\tint inputs:useSpecularWorkflow = 0\r\n\t\t\ttoken outputs:surface\r\n\t\t}\r\n\r\n\t\ttoken outputs:surface.connect = </Materials/Material_${material.uniqueId}/PreviewSurface.outputs:surface>\r\n\r\n${samplers.join(\"\\n\")}\r\n\r\n\t}\r\n`;\r\n}\r\n\r\nfunction BuildCamera(camera: Camera, options: IUSDZExportOptions) {\r\n const name = \"Camera_\" + camera.uniqueId;\r\n const matrix = Matrix.RotationY(Math.PI).multiply(camera.getWorldMatrix()); // work towards positive z\r\n\r\n const transform = BuildMatrix(matrix);\r\n\r\n if (camera.mode === Constants.ORTHOGRAPHIC_CAMERA) {\r\n return `def Camera \"${name}\"\r\n\t\t{\r\n\t\t\tmatrix4d xformOp:transform = ${transform}\r\n\t\t\tuniform token[] xformOpOrder = [\"xformOp:transform\"]\r\n\r\n\t\t\tfloat2 clippingRange = (${camera.minZ.toPrecision(options.precision)}, ${camera.maxZ.toPrecision(options.precision)})\r\n\t\t\tfloat horizontalAperture = ${((Math.abs(camera.orthoLeft || 1) + Math.abs(camera.orthoRight || 1)) * 10).toPrecision(options.precision)}\r\n\t\t\tfloat verticalAperture = ${((Math.abs(camera.orthoTop || 1) + Math.abs(camera.orthoBottom || 1)) * 10).toPrecision(options.precision)}\r\n\t\t\ttoken projection = \"orthographic\"\r\n\t\t}\r\n\t\r\n\t`;\r\n } else {\r\n const aspect = camera.getEngine().getAspectRatio(camera);\r\n const sensorwidth = options.cameraSensorWidth || 35;\r\n\r\n return `def Camera \"${name}\"\r\n\t\t{\r\n\t\t\tmatrix4d xformOp:transform = ${transform}\r\n\t\t\tuniform token[] xformOpOrder = [\"xformOp:transform\"]\r\n\r\n\t\t\tfloat2 clippingRange = (${camera.minZ.toPrecision(options.precision)}, ${camera.maxZ.toPrecision(options.precision)})\r\n\t\t\tfloat focalLength = ${(sensorwidth / (2 * Math.tan(camera.fov * 0.5))).toPrecision(options.precision)}\r\n token projection = \"perspective\"\r\n\t\t\tfloat horizontalAperture = ${(sensorwidth * aspect).toPrecision(options.precision)}\r\n\t\t\tfloat verticalAperture = ${(sensorwidth / aspect).toPrecision(options.precision)} \r\n\t\t}\r\n\t\r\n\t`;\r\n }\r\n}\r\n\r\n/**\r\n *\r\n * @param scene scene to export\r\n * @param options options to configure the export\r\n * @param meshPredicate predicate to filter the meshes to export\r\n * @returns a uint8 array containing the USDZ file\r\n * #H2G5XW#3 - Simple sphere\r\n * #H2G5XW#4 - Red sphere\r\n * #5N3RWK#4 - Boombox\r\n */\r\nexport async function USDZExportAsync(scene: Scene, options: Partial<IUSDZExportOptions>, meshPredicate?: (m: Mesh) => boolean): Promise<Uint8Array> {\r\n const localOptions = {\r\n fflateUrl: \"https://unpkg.com/fflate@0.8.2\",\r\n includeAnchoringProperties: true,\r\n anchoringType: \"plane\",\r\n planeAnchoringAlignment: \"horizontal\",\r\n modelFileName: \"model.usda\",\r\n precision: 5,\r\n exportCamera: false,\r\n cameraSensorWidth: 35,\r\n ...options,\r\n };\r\n\r\n // Get the fflate library\r\n if (typeof fflate === \"undefined\") {\r\n await Tools.LoadScriptAsync(localOptions.fflateUrl);\r\n }\r\n\r\n // Start the export\r\n const files: { [key: string]: any } = {};\r\n\r\n // model file should be first in USDZ archive so we init it here\r\n files[localOptions.modelFileName] = null;\r\n\r\n let output = BuildHeader();\r\n output += BuildSceneStart(localOptions);\r\n\r\n const materialToExports: { [key: string]: Material } = {};\r\n\r\n // Meshes\r\n for (const abstractMesh of scene.meshes) {\r\n if (abstractMesh.getTotalVertices() === 0) {\r\n continue;\r\n }\r\n const mesh = abstractMesh as Mesh;\r\n const geometry = mesh.geometry;\r\n const material = mesh.material;\r\n\r\n if (!material || !geometry || (meshPredicate && !meshPredicate(mesh))) {\r\n continue;\r\n }\r\n\r\n const supportedMaterials = [\"StandardMaterial\", \"PBRMaterial\", \"PBRMetallicRoughnessMaterial\"];\r\n\r\n if (supportedMaterials.indexOf(material.getClassName()) !== -1) {\r\n const geometryFileName = \"geometries/Geometry_\" + geometry.uniqueId + \".usda\";\r\n\r\n if (!(geometryFileName in files)) {\r\n const meshObject = BuildMeshObject(geometry, localOptions);\r\n files[geometryFileName] = BuildUSDFileAsString(meshObject);\r\n }\r\n\r\n if (!(material.uniqueId in materialToExports)) {\r\n materialToExports[material.uniqueId] = material;\r\n }\r\n\r\n output += BuildXform(mesh);\r\n } else {\r\n Tools.Warn(\"USDZExportAsync does not support this material type: \" + material.getClassName());\r\n }\r\n }\r\n\r\n // Camera\r\n if (scene.activeCamera && localOptions.exportCamera) {\r\n output += BuildCamera(scene.activeCamera, localOptions);\r\n }\r\n\r\n // Close scene\r\n output += BuildSceneEnd();\r\n\r\n // Materials\r\n const textureToExports: { [key: string]: BaseTexture } = {};\r\n output += BuildMaterials(materialToExports, textureToExports, localOptions);\r\n\r\n // Compress\r\n files[localOptions.modelFileName] = fflate.strToU8(output);\r\n\r\n // Textures\r\n for (const id in textureToExports) {\r\n const texture = textureToExports[id];\r\n\r\n const size = texture.getSize();\r\n const textureData = await texture.readPixels();\r\n\r\n if (!textureData) {\r\n throw new Error(\"Texture data is not available\");\r\n }\r\n\r\n const fileContent = await DumpTools.DumpDataAsync(size.width, size.height, textureData, \"image/png\", undefined, false, true);\r\n\r\n files[`textures/Texture_${id}.png`] = new Uint8Array(fileContent as ArrayBuffer).slice(); // This is to avoid getting a link and not a copy\r\n }\r\n\r\n // 64 byte alignment\r\n // https://github.com/101arrowz/fflate/issues/39#issuecomment-777263109\r\n\r\n let offset = 0;\r\n\r\n for (const filename in files) {\r\n const file = files[filename];\r\n if (!file) {\r\n continue;\r\n }\r\n const headerSize = 34 + filename.length;\r\n\r\n offset += headerSize;\r\n\r\n const offsetMod64 = offset & 63;\r\n\r\n if (offsetMod64 !== 4) {\r\n const padLength = 64 - offsetMod64;\r\n const padding = new Uint8Array(padLength);\r\n\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n files[filename] = [file, { extra: { 12345: padding } }];\r\n }\r\n\r\n offset = file.length;\r\n }\r\n\r\n return fflate.zipSync(files, { level: 0 });\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"EXT_mesh_gpu_instancing.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,OAAO,EAAE,IAAI,EAAE,uCAAyB;AACxC,oDAAsC;AACtC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,6CAA+B;AACzE,OAAO,EAAE,YAAY,EAAE,0CAA4B;AAEnD,MAAM,IAAI,GAAG,yBAAyB,CAAC;AAEvC;;GAEG;AACH,gEAAgE;AAChE,MAAM,OAAO,uBAAuB;IAchC,YAAY,QAAmB;QAb/B,6BAA6B;QACb,SAAI,GAAG,IAAI,CAAC;QAE5B,gDAAgD;QACzC,YAAO,GAAG,IAAI,CAAC;QAEtB,iDAAiD;QAC1C,aAAQ,GAAG,KAAK,CAAC;QAIhB,aAAQ,GAAG,KAAK,CAAC;QAGrB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC9B,CAAC;IAEM,OAAO,KAAI,CAAC;IAEnB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AM,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC;iBAC5C;gBAED,MAAM;aACT;SACJ;QACD,wBAAwB;QACxB,MAAM,EAAE,GAAgB,EAAE,MAAM,EAAE,CAAC,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,CAAC,MAAM,GAAG,YAAY,CAAC,iBAAiB,CAAC,aAAa,CAAC,EAAE,CAAC;QAC3I,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,MAAM,CAAC;QAC3D,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAErC,6BAA6B;QAC7B,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC;QACvD,MAAM,QAAQ,GAAc;YACxB,UAAU,EAAE,eAAe;YAC3B,aAAa,EAAE,aAAa;YAC5B,KAAK,EAAE,KAAK;YACZ,IAAI,EAAE,IAAI;YACV,UAAU,EAAE,aAAa,yCAA8B,IAAI,aAAa,0CAA+B;SAC1G,CAAC;QACF,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACzC,OAAO,aAAa,CAAC;IACzB,CAAC;CACJ;AAED,6DAA6D;AAC7D,SAAS,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,uBAAuB,CAAC,QAAQ,CAAC,CAAC,CAAC","sourcesContent":["import type { IBufferView, IAccessor, INode, IEXTMeshGpuInstancing } from \"babylonjs-gltf2interface\";\r\nimport { AccessorType, AccessorComponentType } from \"babylonjs-gltf2interface\";\r\nimport type { IGLTFExporterExtensionV2 } from \"../glTFExporterExtension\";\r\nimport type { _BinaryWriter } from \"../glTFExporter\";\r\nimport { _Exporter } from \"../glTFExporter\";\r\nimport type { Nullable } from \"core/types\";\r\nimport type { Node } from \"core/node\";\r\nimport { Mesh } from \"core/Meshes/mesh\";\r\nimport \"core/Meshes/thinInstanceMesh\";\r\nimport { TmpVectors, Quaternion, Vector3 } from \"core/Maths/math.vector\";\r\nimport { VertexBuffer } from \"core/Buffers/buffer\";\r\n\r\nconst NAME = \"EXT_mesh_gpu_instancing\";\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Vendor/EXT_mesh_gpu_instancing/README.md)\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class EXT_mesh_gpu_instancing implements IGLTFExporterExtensionV2 {\r\n /** Name of this extension */\r\n public readonly name = NAME;\r\n\r\n /** Defines whether this extension is enabled */\r\n public enabled = true;\r\n\r\n /** Defines whether this extension is required */\r\n public required = false;\r\n\r\n private _exporter: _Exporter;\r\n\r\n private _wasUsed = false;\r\n\r\n constructor(exporter: _Exporter) {\r\n this._exporter = exporter;\r\n }\r\n\r\n public dispose() {}\r\n\r\n /** @internal */\r\n public get wasUsed() {\r\n return this._wasUsed;\r\n }\r\n\r\n /**\r\n * After node is exported\r\n * @param context the GLTF context when loading the asset\r\n * @param node the node exported\r\n * @param babylonNode the corresponding babylon node\r\n * @param nodeMap map from babylon node id to node index\r\n * @param binaryWriter binary writer\r\n * @returns nullable promise, resolves with the node\r\n */\r\n public postExportNodeAsync(\r\n context: string,\r\n node: Nullable<INode>,\r\n babylonNode: Node,\r\n nodeMap: { [key: number]: number },\r\n binaryWriter: _BinaryWriter\r\n ): Promise<Nullable<INode>> {\r\n return new Promise((resolve) => {\r\n if (node && babylonNode instanceof Mesh) {\r\n if (babylonNode.hasThinInstances && binaryWriter) {\r\n this._wasUsed = true;\r\n\r\n const noTranslation = Vector3.Zero();\r\n const noRotation = Quaternion.Identity();\r\n const noScale = Vector3.One();\r\n\r\n // retrieve all the instance world matrix\r\n const matrix = babylonNode.thinInstanceGetWorldMatrices();\r\n\r\n const iwt = TmpVectors.Vector3[2];\r\n const iwr = TmpVectors.Quaternion[1];\r\n const iws = TmpVectors.Vector3[3];\r\n\r\n let hasAnyInstanceWorldTranslation = false;\r\n let hasAnyInstanceWorldRotation = false;\r\n let hasAnyInstanceWorldScale = false;\r\n\r\n // prepare temp buffers\r\n const translationBuffer = new Float32Array(babylonNode.thinInstanceCount * 3);\r\n const rotationBuffer = new Float32Array(babylonNode.thinInstanceCount * 4);\r\n const scaleBuffer = new Float32Array(babylonNode.thinInstanceCount * 3);\r\n\r\n let i = 0;\r\n for (const m of matrix) {\r\n m.decompose(iws, iwr, iwt);\r\n\r\n // fill the temp buffer\r\n translationBuffer.set(iwt.asArray(), i * 3);\r\n rotationBuffer.set(iwr.normalize().asArray(), i * 4); // ensure the quaternion is normalized\r\n scaleBuffer.set(iws.asArray(), i * 3);\r\n\r\n // this is where we decide if there is any transformation\r\n hasAnyInstanceWorldTranslation = hasAnyInstanceWorldTranslation || !iwt.equalsWithEpsilon(noTranslation);\r\n hasAnyInstanceWorldRotation = hasAnyInstanceWorldRotation || !iwr.equalsWithEpsilon(noRotation);\r\n hasAnyInstanceWorldScale = hasAnyInstanceWorldScale || !iws.equalsWithEpsilon(noScale);\r\n\r\n i++;\r\n }\r\n\r\n const extension: IEXTMeshGpuInstancing = {\r\n attributes: {},\r\n };\r\n\r\n // do we need to write TRANSLATION ?\r\n if (hasAnyInstanceWorldTranslation) {\r\n extension.attributes[\"TRANSLATION\"] = this._buildAccessor(\r\n translationBuffer,\r\n AccessorType.VEC3,\r\n babylonNode.thinInstanceCount,\r\n binaryWriter,\r\n AccessorComponentType.FLOAT\r\n );\r\n }\r\n // do we need to write ROTATION ?\r\n if (hasAnyInstanceWorldRotation) {\r\n const componentType = AccessorComponentType.FLOAT; // we decided to stay on FLOAT for now see https://github.com/BabylonJS/Babylon.js/pull/12495\r\n extension.attributes[\"ROTATION\"] = this._buildAccessor(rotationBuffer, AccessorType.VEC4, babylonNode.thinInstanceCount, binaryWriter, componentType);\r\n }\r\n // do we need to write SCALE ?\r\n if (hasAnyInstanceWorldScale) {\r\n extension.attributes[\"SCALE\"] = this._buildAccessor(\r\n scaleBuffer,\r\n AccessorType.VEC3,\r\n babylonNode.thinInstanceCount,\r\n binaryWriter,\r\n AccessorComponentType.FLOAT\r\n );\r\n }\r\n\r\n /* eslint-enable @typescript-eslint/naming-convention*/\r\n node.extensions = node.extensions || {};\r\n node.extensions[NAME] = extension;\r\n }\r\n }\r\n resolve(node);\r\n });\r\n }\r\n\r\n private _buildAccessor(buffer: Float32Array, type: AccessorType, count: number, binaryWriter: _BinaryWriter, componentType: AccessorComponentType): number {\r\n // write the buffer\r\n const bufferOffset = binaryWriter.getByteOffset();\r\n switch (componentType) {\r\n case AccessorComponentType.FLOAT: {\r\n for (let i = 0; i != buffer.length; i++) {\r\n binaryWriter.setFloat32(buffer[i]);\r\n }\r\n break;\r\n }\r\n case AccessorComponentType.BYTE: {\r\n for (let i = 0; i != buffer.length; i++) {\r\n binaryWriter.setByte(buffer[i] * 127);\r\n }\r\n break;\r\n }\r\n case AccessorComponentType.SHORT: {\r\n for (let i = 0; i != buffer.length; i++) {\r\n binaryWriter.setInt16(buffer[i] * 32767);\r\n }\r\n\r\n break;\r\n }\r\n }\r\n // build the buffer view\r\n const bv: IBufferView = { buffer: 0, byteOffset: bufferOffset, byteLength: buffer.length * VertexBuffer.GetTypeByteLength(componentType) };\r\n const bufferViewIndex = this._exporter._bufferViews.length;\r\n this._exporter._bufferViews.push(bv);\r\n\r\n // finally build the accessor\r\n const accessorIndex = this._exporter._accessors.length;\r\n const accessor: IAccessor = {\r\n bufferView: bufferViewIndex,\r\n componentType: componentType,\r\n count: count,\r\n type: type,\r\n normalized: componentType == AccessorComponentType.BYTE || componentType == AccessorComponentType.SHORT,\r\n };\r\n this._exporter._accessors.push(accessor);\r\n return accessorIndex;\r\n }\r\n}\r\n\r\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n_Exporter.RegisterExtension(NAME, (exporter) => new EXT_mesh_gpu_instancing(exporter));\r\n"]}
1
+ {"version":3,"file":"EXT_mesh_gpu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AErC,6BAA6B;QAC7B,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC;QACvD,MAAM,QAAQ,GAAc;YACxB,UAAU,EAAE,eAAe;YAC3B,aAAa,EAAE,aAAa;YAC5B,KAAK,EAAE,KAAK;YACZ,IAAI,EAAE,IAAI;YACV,UAAU,EAAE,aAAa,yCAA8B,IAAI,aAAa,0CAA+B;SAC1G,CAAC;QACF,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACzC,OAAO,aAAa,CAAC;IACzB,CAAC;CACJ;AAED,6DAA6D;AAC7D,SAAS,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,uBAAuB,CAAC,QAAQ,CAAC,CAAC,CAAC","sourcesContent":["import type { IBufferView, IAccessor, INode, IEXTMeshGpuInstancing } from \"babylonjs-gltf2interface\";\r\nimport { AccessorType, AccessorComponentType } from \"babylonjs-gltf2interface\";\r\nimport type { IGLTFExporterExtensionV2 } from \"../glTFExporterExtension\";\r\nimport type { _BinaryWriter } from \"../glTFExporter\";\r\nimport { _Exporter } from \"../glTFExporter\";\r\nimport type { Nullable } from \"core/types\";\r\nimport type { Node } from \"core/node\";\r\nimport { Mesh } from \"core/Meshes/mesh\";\r\nimport \"core/Meshes/thinInstanceMesh\";\r\nimport { TmpVectors, Quaternion, Vector3 } from \"core/Maths/math.vector\";\r\nimport { VertexBuffer } from \"core/Buffers/buffer\";\r\n\r\nconst NAME = \"EXT_mesh_gpu_instancing\";\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Vendor/EXT_mesh_gpu_instancing/README.md)\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class EXT_mesh_gpu_instancing implements IGLTFExporterExtensionV2 {\r\n /** Name of this extension */\r\n public readonly name = NAME;\r\n\r\n /** Defines whether this extension is enabled */\r\n public enabled = true;\r\n\r\n /** Defines whether this extension is required */\r\n public required = false;\r\n\r\n private _exporter: _Exporter;\r\n\r\n private _wasUsed = false;\r\n\r\n constructor(exporter: _Exporter) {\r\n this._exporter = exporter;\r\n }\r\n\r\n public dispose() {}\r\n\r\n /** @internal */\r\n public get wasUsed() {\r\n return this._wasUsed;\r\n }\r\n\r\n /**\r\n * After node is exported\r\n * @param context the GLTF context when loading the asset\r\n * @param node the node exported\r\n * @param babylonNode the corresponding babylon node\r\n * @param nodeMap map from babylon node id to node index\r\n * @param binaryWriter binary writer\r\n * @returns nullable promise, resolves with the node\r\n */\r\n public postExportNodeAsync(\r\n context: string,\r\n node: Nullable<INode>,\r\n babylonNode: Node,\r\n nodeMap: { [key: number]: number },\r\n binaryWriter: _BinaryWriter\r\n ): Promise<Nullable<INode>> {\r\n return new Promise((resolve) => {\r\n if (node && babylonNode instanceof Mesh) {\r\n if (babylonNode.hasThinInstances && binaryWriter) {\r\n this._wasUsed = true;\r\n\r\n const noTranslation = Vector3.Zero();\r\n const noRotation = Quaternion.Identity();\r\n const noScale = Vector3.One();\r\n\r\n // retrieve all the instance world matrix\r\n const matrix = babylonNode.thinInstanceGetWorldMatrices();\r\n\r\n const iwt = TmpVectors.Vector3[2];\r\n const iwr = TmpVectors.Quaternion[1];\r\n const iws = TmpVectors.Vector3[3];\r\n\r\n let hasAnyInstanceWorldTranslation = false;\r\n let hasAnyInstanceWorldRotation = false;\r\n let hasAnyInstanceWorldScale = false;\r\n\r\n // prepare temp buffers\r\n const translationBuffer = new Float32Array(babylonNode.thinInstanceCount * 3);\r\n const rotationBuffer = new Float32Array(babylonNode.thinInstanceCount * 4);\r\n const scaleBuffer = new Float32Array(babylonNode.thinInstanceCount * 3);\r\n\r\n let i = 0;\r\n for (const m of matrix) {\r\n m.decompose(iws, iwr, iwt);\r\n\r\n // fill the temp buffer\r\n translationBuffer.set(iwt.asArray(), i * 3);\r\n rotationBuffer.set(iwr.normalize().asArray(), i * 4); // ensure the quaternion is normalized\r\n scaleBuffer.set(iws.asArray(), i * 3);\r\n\r\n // this is where we decide if there is any transformation\r\n hasAnyInstanceWorldTranslation = hasAnyInstanceWorldTranslation || !iwt.equalsWithEpsilon(noTranslation);\r\n hasAnyInstanceWorldRotation = hasAnyInstanceWorldRotation || !iwr.equalsWithEpsilon(noRotation);\r\n hasAnyInstanceWorldScale = hasAnyInstanceWorldScale || !iws.equalsWithEpsilon(noScale);\r\n\r\n i++;\r\n }\r\n\r\n const extension: IEXTMeshGpuInstancing = {\r\n attributes: {},\r\n };\r\n\r\n // do we need to write TRANSLATION ?\r\n if (hasAnyInstanceWorldTranslation) {\r\n extension.attributes[\"TRANSLATION\"] = this._buildAccessor(\r\n translationBuffer,\r\n AccessorType.VEC3,\r\n babylonNode.thinInstanceCount,\r\n binaryWriter,\r\n AccessorComponentType.FLOAT\r\n );\r\n }\r\n // do we need to write ROTATION ?\r\n if (hasAnyInstanceWorldRotation) {\r\n const componentType = AccessorComponentType.FLOAT; // we decided to stay on FLOAT for now see https://github.com/BabylonJS/Babylon.js/pull/12495\r\n extension.attributes[\"ROTATION\"] = this._buildAccessor(rotationBuffer, AccessorType.VEC4, babylonNode.thinInstanceCount, binaryWriter, componentType);\r\n }\r\n // do we need to write SCALE ?\r\n if (hasAnyInstanceWorldScale) {\r\n extension.attributes[\"SCALE\"] = this._buildAccessor(\r\n scaleBuffer,\r\n AccessorType.VEC3,\r\n babylonNode.thinInstanceCount,\r\n binaryWriter,\r\n AccessorComponentType.FLOAT\r\n );\r\n }\r\n\r\n /* eslint-enable @typescript-eslint/naming-convention*/\r\n node.extensions = node.extensions || {};\r\n node.extensions[NAME] = extension;\r\n }\r\n }\r\n resolve(node);\r\n });\r\n }\r\n\r\n private _buildAccessor(buffer: Float32Array, type: AccessorType, count: number, binaryWriter: _BinaryWriter, componentType: AccessorComponentType): number {\r\n // write the buffer\r\n const bufferOffset = binaryWriter.getByteOffset();\r\n switch (componentType) {\r\n case AccessorComponentType.FLOAT: {\r\n for (let i = 0; i != buffer.length; i++) {\r\n binaryWriter.setFloat32(buffer[i]);\r\n }\r\n break;\r\n }\r\n case AccessorComponentType.BYTE: {\r\n for (let i = 0; i != buffer.length; i++) {\r\n binaryWriter.setByte(buffer[i] * 127);\r\n }\r\n break;\r\n }\r\n case AccessorComponentType.SHORT: {\r\n for (let i = 0; i != buffer.length; i++) {\r\n binaryWriter.setInt16(buffer[i] * 32767);\r\n }\r\n\r\n break;\r\n }\r\n }\r\n // build the buffer view\r\n const bv: IBufferView = { buffer: 0, byteOffset: bufferOffset, byteLength: buffer.length * VertexBuffer.GetTypeByteLength(componentType) };\r\n const bufferViewIndex = this._exporter._bufferViews.length;\r\n this._exporter._bufferViews.push(bv);\r\n\r\n // finally build the accessor\r\n const accessorIndex = this._exporter._accessors.length;\r\n const accessor: IAccessor = {\r\n bufferView: bufferViewIndex,\r\n componentType: componentType,\r\n count: count,\r\n type: type,\r\n normalized: componentType == AccessorComponentType.BYTE || componentType == AccessorComponentType.SHORT,\r\n };\r\n this._exporter._accessors.push(accessor);\r\n return accessorIndex;\r\n }\r\n}\r\n\r\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n_Exporter.RegisterExtension(NAME, (exporter) => new EXT_mesh_gpu_instancing(exporter));\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"KHR_lights_punctual.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/KHR_lights_punctual.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,6CAA+B;AACjF,OAAO,EAAE,MAAM,EAAE,4CAA8B;AAC/C,OAAO,EAAE,KAAK,EAAE,wCAA0B;AAE1C,OAAO,EAAE,WAAW,EAAE,8CAAgC;AAItD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,uCAAyB;AAG1C,MAAM,IAAI,GAAG,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C,UAAU,GAAK,EAAE,EAAC;oBACvB,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC;iBAC1C;aACJ;YACD,OAAO,CAAC,IAAI,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAED,SAAS,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC","sourcesContent":["import type { SpotLight } from \"core/Lights/spotLight\";\r\nimport type { Nullable } from \"core/types\";\r\nimport { Vector3, Quaternion, TmpVectors, Matrix } from \"core/Maths/math.vector\";\r\nimport { Color3 } from \"core/Maths/math.color\";\r\nimport { Light } from \"core/Lights/light\";\r\nimport type { Node } from \"core/node\";\r\nimport { ShadowLight } from \"core/Lights/shadowLight\";\r\nimport type { INode, IKHRLightsPunctual_LightReference, IKHRLightsPunctual_Light, IKHRLightsPunctual } from \"babylonjs-gltf2interface\";\r\nimport { KHRLightsPunctual_LightType } from \"babylonjs-gltf2interface\";\r\nimport type { IGLTFExporterExtensionV2 } from \"../glTFExporterExtension\";\r\nimport { _Exporter } from \"../glTFExporter\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport { _GLTFUtilities } from \"../glTFUtilities\";\r\n\r\nconst NAME = \"KHR_lights_punctual\";\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_lights_punctual implements IGLTFExporterExtensionV2 {\r\n /** The name of this extension. */\r\n public readonly name = NAME;\r\n\r\n /** Defines whether this extension is enabled. */\r\n public enabled = true;\r\n\r\n /** Defines whether this extension is required */\r\n public required = false;\r\n\r\n /** Reference to the glTF exporter */\r\n private _exporter: _Exporter;\r\n\r\n private _lights: IKHRLightsPunctual;\r\n\r\n /**\r\n * @internal\r\n */\r\n constructor(exporter: _Exporter) {\r\n this._exporter = exporter;\r\n }\r\n\r\n /** @internal */\r\n public dispose() {\r\n (this._lights as any) = null;\r\n }\r\n\r\n /** @internal */\r\n public get wasUsed() {\r\n return !!this._lights;\r\n }\r\n\r\n /** @internal */\r\n public onExporting(): void {\r\n this._exporter!._glTF.extensions![NAME] = this._lights;\r\n }\r\n /**\r\n * Define this method to modify the default behavior when exporting a node\r\n * @param context The context when exporting the node\r\n * @param node glTF node\r\n * @param babylonNode BabylonJS node\r\n * @param nodeMap Node mapping of unique id to glTF node index\r\n * @returns nullable INode promise\r\n */\r\n public postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap: { [key: number]: number }): Promise<Nullable<INode>> {\r\n return new Promise((resolve) => {\r\n if (node && babylonNode instanceof ShadowLight) {\r\n let light: IKHRLightsPunctual_Light;\r\n\r\n const lightType =\r\n babylonNode.getTypeID() == Light.LIGHTTYPEID_POINTLIGHT\r\n ? KHRLightsPunctual_LightType.POINT\r\n : babylonNode.getTypeID() == Light.LIGHTTYPEID_DIRECTIONALLIGHT\r\n ? KHRLightsPunctual_LightType.DIRECTIONAL\r\n : babylonNode.getTypeID() == Light.LIGHTTYPEID_SPOTLIGHT\r\n ? KHRLightsPunctual_LightType.SPOT\r\n : null;\r\n if (lightType == null) {\r\n Logger.Warn(`${context}: Light ${babylonNode.name} is not supported in ${NAME}`);\r\n } else {\r\n if (!babylonNode.position.equalsToFloats(0, 0, 0)) {\r\n node.translation = babylonNode.position.asArray();\r\n }\r\n if (lightType !== KHRLightsPunctual_LightType.POINT) {\r\n const localAxis = babylonNode.direction;\r\n const yaw = -Math.atan2(localAxis.z, localAxis.x) + Math.PI / 2;\r\n const len = Math.sqrt(localAxis.x * localAxis.x + localAxis.z * localAxis.z);\r\n const pitch = -Math.atan2(localAxis.y, len);\r\n const lightRotationQuaternion = Quaternion.RotationYawPitchRoll(yaw + Math.PI, pitch, 0);\r\n if (!Quaternion.IsIdentity(lightRotationQuaternion)) {\r\n node.rotation = lightRotationQuaternion.asArray();\r\n }\r\n }\r\n\r\n if (babylonNode.falloffType !== Light.FALLOFF_GLTF) {\r\n Logger.Warn(`${context}: Light falloff for ${babylonNode.name} does not match the ${NAME} specification!`);\r\n }\r\n light = {\r\n type: lightType,\r\n };\r\n if (!babylonNode.diffuse.equals(Color3.White())) {\r\n light.color = babylonNode.diffuse.asArray();\r\n }\r\n if (babylonNode.intensity !== 1.0) {\r\n light.intensity = babylonNode.intensity;\r\n }\r\n if (babylonNode.range !== Number.MAX_VALUE) {\r\n light.range = babylonNode.range;\r\n }\r\n\r\n if (lightType === KHRLightsPunctual_LightType.SPOT) {\r\n const babylonSpotLight = babylonNode as SpotLight;\r\n if (babylonSpotLight.angle !== Math.PI / 2.0) {\r\n if (light.spot == null) {\r\n light.spot = {};\r\n }\r\n light.spot.outerConeAngle = babylonSpotLight.angle / 2.0;\r\n }\r\n if (babylonSpotLight.innerAngle !== 0) {\r\n if (light.spot == null) {\r\n light.spot = {};\r\n }\r\n light.spot.innerConeAngle = babylonSpotLight.innerAngle / 2.0;\r\n }\r\n }\r\n\r\n this._lights ||= {\r\n lights: [],\r\n };\r\n\r\n this._lights.lights.push(light);\r\n\r\n const lightReference: IKHRLightsPunctual_LightReference = {\r\n light: this._lights.lights.length - 1,\r\n };\r\n\r\n // Avoid duplicating the Light's parent node if possible.\r\n const parentBabylonNode = babylonNode.parent;\r\n if (parentBabylonNode && parentBabylonNode.getChildren().length == 1) {\r\n const parentNode = this._exporter._nodes[nodeMap[parentBabylonNode.uniqueId]];\r\n if (parentNode) {\r\n const parentTranslation = Vector3.FromArrayToRef(parentNode.translation || [0, 0, 0], 0, TmpVectors.Vector3[0]);\r\n const parentRotation = Quaternion.FromArrayToRef(parentNode.rotation || [0, 0, 0, 1], 0, TmpVectors.Quaternion[0]);\r\n const parentScale = Vector3.FromArrayToRef(parentNode.scale || [1, 1, 1], 0, TmpVectors.Vector3[1]);\r\n const parentMatrix = Matrix.ComposeToRef(parentScale, parentRotation, parentTranslation, TmpVectors.Matrix[0]);\r\n\r\n const translation = Vector3.FromArrayToRef(node.translation || [0, 0, 0], 0, TmpVectors.Vector3[2]);\r\n const rotation = Quaternion.FromArrayToRef(node.rotation || [0, 0, 0, 1], 0, TmpVectors.Quaternion[1]);\r\n const matrix = Matrix.ComposeToRef(Vector3.OneReadOnly, rotation, translation, TmpVectors.Matrix[1]);\r\n\r\n parentMatrix.multiplyToRef(matrix, matrix);\r\n matrix.decompose(parentScale, parentRotation, parentTranslation);\r\n\r\n if (parentTranslation.equalsToFloats(0, 0, 0)) {\r\n delete parentNode.translation;\r\n } else {\r\n parentNode.translation = parentTranslation.asArray();\r\n }\r\n\r\n if (Quaternion.IsIdentity(parentRotation)) {\r\n delete parentNode.rotation;\r\n } else {\r\n parentNode.rotation = parentRotation.asArray();\r\n }\r\n\r\n if (parentScale.equalsToFloats(1, 1, 1)) {\r\n delete parentNode.scale;\r\n } else {\r\n parentNode.scale = parentScale.asArray();\r\n }\r\n\r\n parentNode.extensions ||= {};\r\n parentNode.extensions[NAME] = lightReference;\r\n\r\n // Do not export the original node\r\n resolve(null);\r\n return;\r\n }\r\n }\r\n\r\n node.extensions ||= {};\r\n node.extensions[NAME] = lightReference;\r\n }\r\n }\r\n resolve(node);\r\n });\r\n }\r\n}\r\n\r\n_Exporter.RegisterExtension(NAME, (exporter) => new KHR_lights_punctual(exporter));\r\n"]}
1
+ {"version":3,"file":"KHR_lights_punctual.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/KHR_lights_punctual.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,6CAA+B;AACjF,OAAO,EAAE,MAAM,EAAE,4CAA8B;AAC/C,OAAO,EAAE,KAAK,EAAE,wCAA0B;AAE1C,OAAO,EAAE,WAAW,EAAE,8CAAgC;AAItD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CA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,UAAU,CAAC,KAAK,GAAG,WAAW,CAAC,OAAO,EAAE,CAAC;4BAC7C,CAAC;4BAED,UAAU,CAAC,UAAU,KAArB,UAAU,CAAC,UAAU,GAAK,EAAE,EAAC;4BAC7B,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC;4BAE7C,kCAAkC;4BAClC,OAAO,CAAC,IAAI,CAAC,CAAC;4BACd,OAAO;wBACX,CAAC;oBACL,CAAC;oBAED,IAAI,CAAC,UAAU,KAAf,IAAI,CAAC,UAAU,GAAK,EAAE,EAAC;oBACvB,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC;gBAC3C,CAAC;YACL,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAED,SAAS,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC","sourcesContent":["import type { SpotLight } from \"core/Lights/spotLight\";\r\nimport type { Nullable } from \"core/types\";\r\nimport { Vector3, Quaternion, TmpVectors, Matrix } from \"core/Maths/math.vector\";\r\nimport { Color3 } from \"core/Maths/math.color\";\r\nimport { Light } from \"core/Lights/light\";\r\nimport type { Node } from \"core/node\";\r\nimport { ShadowLight } from \"core/Lights/shadowLight\";\r\nimport type { INode, IKHRLightsPunctual_LightReference, IKHRLightsPunctual_Light, IKHRLightsPunctual } from \"babylonjs-gltf2interface\";\r\nimport { KHRLightsPunctual_LightType } from \"babylonjs-gltf2interface\";\r\nimport type { IGLTFExporterExtensionV2 } from \"../glTFExporterExtension\";\r\nimport { _Exporter } from \"../glTFExporter\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport { _GLTFUtilities } from \"../glTFUtilities\";\r\n\r\nconst NAME = \"KHR_lights_punctual\";\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_lights_punctual implements IGLTFExporterExtensionV2 {\r\n /** The name of this extension. */\r\n public readonly name = NAME;\r\n\r\n /** Defines whether this extension is enabled. */\r\n public enabled = true;\r\n\r\n /** Defines whether this extension is required */\r\n public required = false;\r\n\r\n /** Reference to the glTF exporter */\r\n private _exporter: _Exporter;\r\n\r\n private _lights: IKHRLightsPunctual;\r\n\r\n /**\r\n * @internal\r\n */\r\n constructor(exporter: _Exporter) {\r\n this._exporter = exporter;\r\n }\r\n\r\n /** @internal */\r\n public dispose() {\r\n (this._lights as any) = null;\r\n }\r\n\r\n /** @internal */\r\n public get wasUsed() {\r\n return !!this._lights;\r\n }\r\n\r\n /** @internal */\r\n public onExporting(): void {\r\n this._exporter!._glTF.extensions![NAME] = this._lights;\r\n }\r\n /**\r\n * Define this method to modify the default behavior when exporting a node\r\n * @param context The context when exporting the node\r\n * @param node glTF node\r\n * @param babylonNode BabylonJS node\r\n * @param nodeMap Node mapping of unique id to glTF node index\r\n * @returns nullable INode promise\r\n */\r\n public postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap: { [key: number]: number }): Promise<Nullable<INode>> {\r\n return new Promise((resolve) => {\r\n if (node && babylonNode instanceof ShadowLight) {\r\n let light: IKHRLightsPunctual_Light;\r\n\r\n const lightType =\r\n babylonNode.getTypeID() == Light.LIGHTTYPEID_POINTLIGHT\r\n ? KHRLightsPunctual_LightType.POINT\r\n : babylonNode.getTypeID() == Light.LIGHTTYPEID_DIRECTIONALLIGHT\r\n ? KHRLightsPunctual_LightType.DIRECTIONAL\r\n : babylonNode.getTypeID() == Light.LIGHTTYPEID_SPOTLIGHT\r\n ? KHRLightsPunctual_LightType.SPOT\r\n : null;\r\n if (lightType == null) {\r\n Logger.Warn(`${context}: Light ${babylonNode.name} is not supported in ${NAME}`);\r\n } else {\r\n if (!babylonNode.position.equalsToFloats(0, 0, 0)) {\r\n node.translation = babylonNode.position.asArray();\r\n }\r\n if (lightType !== KHRLightsPunctual_LightType.POINT) {\r\n const localAxis = babylonNode.direction;\r\n const yaw = -Math.atan2(localAxis.z, localAxis.x) + Math.PI / 2;\r\n const len = Math.sqrt(localAxis.x * localAxis.x + localAxis.z * localAxis.z);\r\n const pitch = -Math.atan2(localAxis.y, len);\r\n const lightRotationQuaternion = Quaternion.RotationYawPitchRoll(yaw + Math.PI, pitch, 0);\r\n if (!Quaternion.IsIdentity(lightRotationQuaternion)) {\r\n node.rotation = lightRotationQuaternion.asArray();\r\n }\r\n }\r\n\r\n if (babylonNode.falloffType !== Light.FALLOFF_GLTF) {\r\n Logger.Warn(`${context}: Light falloff for ${babylonNode.name} does not match the ${NAME} specification!`);\r\n }\r\n light = {\r\n type: lightType,\r\n };\r\n if (!babylonNode.diffuse.equals(Color3.White())) {\r\n light.color = babylonNode.diffuse.asArray();\r\n }\r\n if (babylonNode.intensity !== 1.0) {\r\n light.intensity = babylonNode.intensity;\r\n }\r\n if (babylonNode.range !== Number.MAX_VALUE) {\r\n light.range = babylonNode.range;\r\n }\r\n\r\n if (lightType === KHRLightsPunctual_LightType.SPOT) {\r\n const babylonSpotLight = babylonNode as SpotLight;\r\n if (babylonSpotLight.angle !== Math.PI / 2.0) {\r\n if (light.spot == null) {\r\n light.spot = {};\r\n }\r\n light.spot.outerConeAngle = babylonSpotLight.angle / 2.0;\r\n }\r\n if (babylonSpotLight.innerAngle !== 0) {\r\n if (light.spot == null) {\r\n light.spot = {};\r\n }\r\n light.spot.innerConeAngle = babylonSpotLight.innerAngle / 2.0;\r\n }\r\n }\r\n\r\n this._lights ||= {\r\n lights: [],\r\n };\r\n\r\n this._lights.lights.push(light);\r\n\r\n const lightReference: IKHRLightsPunctual_LightReference = {\r\n light: this._lights.lights.length - 1,\r\n };\r\n\r\n // Avoid duplicating the Light's parent node if possible.\r\n const parentBabylonNode = babylonNode.parent;\r\n if (parentBabylonNode && parentBabylonNode.getChildren().length == 1) {\r\n const parentNode = this._exporter._nodes[nodeMap[parentBabylonNode.uniqueId]];\r\n if (parentNode) {\r\n const parentTranslation = Vector3.FromArrayToRef(parentNode.translation || [0, 0, 0], 0, TmpVectors.Vector3[0]);\r\n const parentRotation = Quaternion.FromArrayToRef(parentNode.rotation || [0, 0, 0, 1], 0, TmpVectors.Quaternion[0]);\r\n const parentScale = Vector3.FromArrayToRef(parentNode.scale || [1, 1, 1], 0, TmpVectors.Vector3[1]);\r\n const parentMatrix = Matrix.ComposeToRef(parentScale, parentRotation, parentTranslation, TmpVectors.Matrix[0]);\r\n\r\n const translation = Vector3.FromArrayToRef(node.translation || [0, 0, 0], 0, TmpVectors.Vector3[2]);\r\n const rotation = Quaternion.FromArrayToRef(node.rotation || [0, 0, 0, 1], 0, TmpVectors.Quaternion[1]);\r\n const matrix = Matrix.ComposeToRef(Vector3.OneReadOnly, rotation, translation, TmpVectors.Matrix[1]);\r\n\r\n parentMatrix.multiplyToRef(matrix, matrix);\r\n matrix.decompose(parentScale, parentRotation, parentTranslation);\r\n\r\n if (parentTranslation.equalsToFloats(0, 0, 0)) {\r\n delete parentNode.translation;\r\n } else {\r\n parentNode.translation = parentTranslation.asArray();\r\n }\r\n\r\n if (Quaternion.IsIdentity(parentRotation)) {\r\n delete parentNode.rotation;\r\n } else {\r\n parentNode.rotation = parentRotation.asArray();\r\n }\r\n\r\n if (parentScale.equalsToFloats(1, 1, 1)) {\r\n delete parentNode.scale;\r\n } else {\r\n parentNode.scale = parentScale.asArray();\r\n }\r\n\r\n parentNode.extensions ||= {};\r\n parentNode.extensions[NAME] = lightReference;\r\n\r\n // Do not export the original node\r\n resolve(null);\r\n return;\r\n }\r\n }\r\n\r\n node.extensions ||= {};\r\n node.extensions[NAME] = lightReference;\r\n }\r\n }\r\n resolve(node);\r\n });\r\n }\r\n}\r\n\r\n_Exporter.RegisterExtension(NAME, (exporter) => new KHR_lights_punctual(exporter));\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"KHR_materials_anisotropy.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_anisotropy.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,eAAe,EAAE,yDAA2C;AAGrE,MAAM,IAAI,GAAG,0BAA0B,CAAC;AAExC;;GAEG;AACH,gEAAgE;AAChE,MAAM,OAAO,wBAAwB;IAcjC,YAAY,QAAmB;QAb/B,6BAA6B;QACb,SAAI,GAAG,IAAI,CAAC;QAE5B,gDAAgD;QACzC,YAAO,GAAG,IAAI,CAAC;QAEtB,iDAAiD;QAC1C,aAAQ,GAAG,KAAK,CAAC;QAIhB,aAAQ,GAAG,KAAK,CAAC;QAGrB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC9B,CAAC;IAEM,OAAO,KAAI,CAAC;IAEnB,gBAAgB;IAChB,IAAW,OAAO;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAEM,oCAAoC,CAAE,OAAe,EAAE,IAAe,EAAE,eAAyB;QACpG,MAAM,kBAAkB,GAAkB,EAAE,CAAC;QAC7C,IAAI,eAAe,YAAY,eAAe,EAAE;YAC5C,IAAI,eAAe,CAAC,UAAU,CAAC,SAAS,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,MAAM,EAAE;gBAC5E,IAAI,eAAe,CAAC,UAAU,CAAC,OAAO,EAAE;oBACpC,kBAAkB,CAAC,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;iBAC/D;gBACD,OAAO,kBAAkB,CAAC;aAC7B;SACJ;QAED,OAAO,EAAE,CAAC;IACd,CAAC;IAEM,uBAAuB,CAAE,OAAe,EAAE,IAAe,EAAE,eAAyB;QACvF,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC3B,IAAI,eAAe,YAAY,eAAe,EAAE;gBAC5C,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,SAAS,IAAI,eAAe,CAAC,UAAU,CAAC,MAAM,EAAE;oBAC5E,OAAO,CAAC,IAAI,CAAC,CAAC;oBACd,OAAO;iBACV;gBAED,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;gBAErB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,EAAE,CAAC;gBAExC,MAAM,qBAAqB,GAAG,IAAI,CAAC,SAAS,CAAC,qBAAqB,CAAC,eAAe,CAAC,eAAe,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;gBAEvH,MAAM,cAAc,GAA4B;oBAC5C,kBAAkB,EAAE,eAAe,CAAC,UAAU,CAAC,SAAS;oBACxD,kBAAkB,EAAE,eAAe,CAAC,UAAU,CAAC,KAAK;oBACpD,iBAAiB,EAAE,qBAAqB,IAAI,SAAS;oBACrD,WAAW,EAAE,GAAG,EAAE;wBACd,OAAO,cAAc,CAAC,iBAAiB,KAAK,IAAI,CAAC;oBACrD,CAAC;iBACJ,CAAC;gBAEF,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC;aAC1C;YACD,OAAO,CAAC,IAAI,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAED,SAAS,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,wBAAwB,CAAC,QAAQ,CAAC,CAAC,CAAC","sourcesContent":["import type { IMaterial, IKHRMaterialsAnisotropy } from \"babylonjs-gltf2interface\";\r\nimport type { IGLTFExporterExtensionV2 } from \"../glTFExporterExtension\";\r\nimport { _Exporter } from \"../glTFExporter\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport { PBRBaseMaterial } from \"core/Materials/PBR/pbrBaseMaterial\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\n\r\nconst NAME = \"KHR_materials_anisotropy\";\r\n\r\n/**\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_materials_anisotropy implements IGLTFExporterExtensionV2 {\r\n /** Name of this extension */\r\n public readonly name = NAME;\r\n\r\n /** Defines whether this extension is enabled */\r\n public enabled = true;\r\n\r\n /** Defines whether this extension is required */\r\n public required = false;\r\n\r\n private _exporter: _Exporter;\r\n\r\n private _wasUsed = false;\r\n\r\n constructor(exporter: _Exporter) {\r\n this._exporter = exporter;\r\n }\r\n\r\n public dispose() {}\r\n\r\n /** @internal */\r\n public get wasUsed() {\r\n return this._wasUsed;\r\n }\r\n\r\n public postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[] {\r\n const additionalTextures: BaseTexture[] = [];\r\n if (babylonMaterial instanceof PBRBaseMaterial) {\r\n if (babylonMaterial.anisotropy.isEnabled && !babylonMaterial.anisotropy.legacy) {\r\n if (babylonMaterial.anisotropy.texture) {\r\n additionalTextures.push(babylonMaterial.anisotropy.texture);\r\n }\r\n return additionalTextures;\r\n }\r\n }\r\n\r\n return [];\r\n }\r\n\r\n public postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial> {\r\n return new Promise((resolve) => {\r\n if (babylonMaterial instanceof PBRBaseMaterial) {\r\n if (!babylonMaterial.anisotropy.isEnabled || babylonMaterial.anisotropy.legacy) {\r\n resolve(node);\r\n return;\r\n }\r\n\r\n this._wasUsed = true;\r\n\r\n node.extensions = node.extensions || {};\r\n\r\n const anisotropyTextureInfo = this._exporter._glTFMaterialExporter._getTextureInfo(babylonMaterial.anisotropy.texture);\r\n\r\n const anisotropyInfo: IKHRMaterialsAnisotropy = {\r\n anisotropyStrength: babylonMaterial.anisotropy.intensity,\r\n anisotropyRotation: babylonMaterial.anisotropy.angle,\r\n anisotropyTexture: anisotropyTextureInfo ?? undefined,\r\n hasTextures: () => {\r\n return anisotropyInfo.anisotropyTexture !== null;\r\n },\r\n };\r\n\r\n node.extensions[NAME] = anisotropyInfo;\r\n }\r\n resolve(node);\r\n });\r\n }\r\n}\r\n\r\n_Exporter.RegisterExtension(NAME, (exporter) => new KHR_materials_anisotropy(exporter));\r\n"]}
1
+ {"version":3,"file":"KHR_materials_anisotropy.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_anisotropy.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,eAAe,EAAE,yDAA2C;AAGrE,MAAM,IAAI,GAAG,0BAA0B,CAAC;AAExC;;GAEG;AACH,gEAAgE;AAChE,MAAM,OAAO,wBAAwB;IAcjC,YAAY,QAAmB;QAb/B,6BAA6B;QACb,SAAI,GAAG,IAAI,CAAC;QAE5B,gDAAgD;QACzC,YAAO,GAAG,IAAI,CAAC;QAEtB,iDAAiD;QAC1C,aAAQ,GAAG,KAAK,CAAC;QAIhB,aAAQ,GAAG,KAAK,CAAC;QAGrB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC9B,CAAC;IAEM,OAAO,KAAI,CAAC;IAEnB,gBAAgB;IAChB,IAAW,OAAO;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAEM,oCAAoC,CAAE,OAAe,EAAE,IAAe,EAAE,eAAyB;QACpG,MAAM,kBAAkB,GAAkB,EAAE,CAAC;QAC7C,IAAI,eAAe,YAAY,eAAe,EAAE,CAAC;YAC7C,IAAI,eAAe,CAAC,UAAU,CAAC,SAAS,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;gBAC7E,IAAI,eAAe,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;oBACrC,kBAAkB,CAAC,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;gBAChE,CAAC;gBACD,OAAO,kBAAkB,CAAC;YAC9B,CAAC;QACL,CAAC;QAED,OAAO,EAAE,CAAC;IACd,CAAC;IAEM,uBAAuB,CAAE,OAAe,EAAE,IAAe,EAAE,eAAyB;QACvF,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC3B,IAAI,eAAe,YAAY,eAAe,EAAE,CAAC;gBAC7C,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,SAAS,IAAI,eAAe,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;oBAC7E,OAAO,CAAC,IAAI,CAAC,CAAC;oBACd,OAAO;gBACX,CAAC;gBAED,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;gBAErB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,EAAE,CAAC;gBAExC,MAAM,qBAAqB,GAAG,IAAI,CAAC,SAAS,CAAC,qBAAqB,CAAC,eAAe,CAAC,eAAe,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;gBAEvH,MAAM,cAAc,GAA4B;oBAC5C,kBAAkB,EAAE,eAAe,CAAC,UAAU,CAAC,SAAS;oBACxD,kBAAkB,EAAE,eAAe,CAAC,UAAU,CAAC,KAAK;oBACpD,iBAAiB,EAAE,qBAAqB,IAAI,SAAS;oBACrD,WAAW,EAAE,GAAG,EAAE;wBACd,OAAO,cAAc,CAAC,iBAAiB,KAAK,IAAI,CAAC;oBACrD,CAAC;iBACJ,CAAC;gBAEF,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC;YAC3C,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAED,SAAS,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,wBAAwB,CAAC,QAAQ,CAAC,CAAC,CAAC","sourcesContent":["import type { IMaterial, IKHRMaterialsAnisotropy } from \"babylonjs-gltf2interface\";\r\nimport type { IGLTFExporterExtensionV2 } from \"../glTFExporterExtension\";\r\nimport { _Exporter } from \"../glTFExporter\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport { PBRBaseMaterial } from \"core/Materials/PBR/pbrBaseMaterial\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\n\r\nconst NAME = \"KHR_materials_anisotropy\";\r\n\r\n/**\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_materials_anisotropy implements IGLTFExporterExtensionV2 {\r\n /** Name of this extension */\r\n public readonly name = NAME;\r\n\r\n /** Defines whether this extension is enabled */\r\n public enabled = true;\r\n\r\n /** Defines whether this extension is required */\r\n public required = false;\r\n\r\n private _exporter: _Exporter;\r\n\r\n private _wasUsed = false;\r\n\r\n constructor(exporter: _Exporter) {\r\n this._exporter = exporter;\r\n }\r\n\r\n public dispose() {}\r\n\r\n /** @internal */\r\n public get wasUsed() {\r\n return this._wasUsed;\r\n }\r\n\r\n public postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[] {\r\n const additionalTextures: BaseTexture[] = [];\r\n if (babylonMaterial instanceof PBRBaseMaterial) {\r\n if (babylonMaterial.anisotropy.isEnabled && !babylonMaterial.anisotropy.legacy) {\r\n if (babylonMaterial.anisotropy.texture) {\r\n additionalTextures.push(babylonMaterial.anisotropy.texture);\r\n }\r\n return additionalTextures;\r\n }\r\n }\r\n\r\n return [];\r\n }\r\n\r\n public postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial> {\r\n return new Promise((resolve) => {\r\n if (babylonMaterial instanceof PBRBaseMaterial) {\r\n if (!babylonMaterial.anisotropy.isEnabled || babylonMaterial.anisotropy.legacy) {\r\n resolve(node);\r\n return;\r\n }\r\n\r\n this._wasUsed = true;\r\n\r\n node.extensions = node.extensions || {};\r\n\r\n const anisotropyTextureInfo = this._exporter._glTFMaterialExporter._getTextureInfo(babylonMaterial.anisotropy.texture);\r\n\r\n const anisotropyInfo: IKHRMaterialsAnisotropy = {\r\n anisotropyStrength: babylonMaterial.anisotropy.intensity,\r\n anisotropyRotation: babylonMaterial.anisotropy.angle,\r\n anisotropyTexture: anisotropyTextureInfo ?? undefined,\r\n hasTextures: () => {\r\n return anisotropyInfo.anisotropyTexture !== null;\r\n },\r\n };\r\n\r\n node.extensions[NAME] = anisotropyInfo;\r\n }\r\n resolve(node);\r\n });\r\n }\r\n}\r\n\r\n_Exporter.RegisterExtension(NAME, (exporter) => new KHR_materials_anisotropy(exporter));\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"KHR_materials_clearcoat.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_clearcoat.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,eAAe,EAAE,yDAA2C;AAGrE,OAAO,EAAE,KAAK,EAAE,sCAAwB;AAExC,MAAM,IAAI,GAAG,yBAAyB,CAAC;AAEvC;;GAEG;AACH,gEAAgE;AAChE,MAAM,OAAO,uBAAuB;IAchC,YAAY,QAAmB;QAb/B,6BAA6B;QACb,SAAI,GAAG,IAAI,CAAC;QAE5B,gDAAgD;QACzC,YAAO,GAAG,IAAI,CAAC;QAEtB,iDAAiD;QAC1C,aAAQ,GAAG,KAAK,CAAC;QAIhB,aAAQ,GAAG,KAAK,CAAC;QAGrB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC9B,CAAC;IAEM,OAAO,KAAI,CAAC;IAEnB,gBAAgB;IAChB,IAAW,OAAO;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAEM,oCAAoC,CAAE,OAAe,EAAE,IAAe,EAAE,eAAyB;QACpG,MAAM,kBAAkB,GAAkB,EAAE,CAAC;QAC7C,IAAI,eAAe,YAAY,eAAe,EAAE;YAC5C,IAAI,eAAe,CAAC,SAAS,CAAC,SAAS,EAAE;gBACrC,IAAI,eAAe,CAAC,SAAS,CAAC,OAAO,EAAE;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V2 } from \"../glTFExporterExtension\";\r\nimport { _Exporter } from \"../glTFExporter\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport { PBRBaseMaterial } from \"core/Materials/PBR/pbrBaseMaterial\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\n\r\nimport { Tools } from \"core/Misc/tools\";\r\n\r\nconst NAME = \"KHR_materials_clearcoat\";\r\n\r\n/**\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_materials_clearcoat implements IGLTFExporterExtensionV2 {\r\n /** Name of this extension */\r\n public readonly name = NAME;\r\n\r\n /** Defines whether this extension is enabled */\r\n public enabled = true;\r\n\r\n /** Defines whether this extension is required */\r\n public required = false;\r\n\r\n private _exporter: _Exporter;\r\n\r\n private _wasUsed = false;\r\n\r\n constructor(exporter: _Exporter) {\r\n this._exporter = exporter;\r\n }\r\n\r\n public dispose() {}\r\n\r\n /** @internal */\r\n public get wasUsed() {\r\n return this._wasUsed;\r\n }\r\n\r\n public postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[] {\r\n const additionalTextures: BaseTexture[] = [];\r\n if (babylonMaterial instanceof PBRBaseMaterial) {\r\n if (babylonMaterial.clearCoat.isEnabled) {\r\n if (babylonMaterial.clearCoat.texture) {\r\n additionalTextures.push(babylonMaterial.clearCoat.texture);\r\n }\r\n if (!babylonMaterial.clearCoat.useRoughnessFromMainTexture && babylonMaterial.clearCoat.textureRoughness) {\r\n additionalTextures.push(babylonMaterial.clearCoat.textureRoughness);\r\n }\r\n if (babylonMaterial.clearCoat.bumpTexture) {\r\n additionalTextures.push(babylonMaterial.clearCoat.bumpTexture);\r\n }\r\n return additionalTextures;\r\n }\r\n }\r\n\r\n return [];\r\n }\r\n\r\n public postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial> {\r\n return new Promise((resolve) => {\r\n if (babylonMaterial instanceof PBRBaseMaterial) {\r\n if (!babylonMaterial.clearCoat.isEnabled) {\r\n resolve(node);\r\n return;\r\n }\r\n\r\n this._wasUsed = true;\r\n\r\n node.extensions = node.extensions || {};\r\n\r\n const clearCoatTextureInfo = this._exporter._glTFMaterialExporter._getTextureInfo(babylonMaterial.clearCoat.texture);\r\n let clearCoatTextureRoughnessInfo;\r\n if (babylonMaterial.clearCoat.useRoughnessFromMainTexture) {\r\n clearCoatTextureRoughnessInfo = this._exporter._glTFMaterialExporter._getTextureInfo(babylonMaterial.clearCoat.texture);\r\n } else {\r\n clearCoatTextureRoughnessInfo = this._exporter._glTFMaterialExporter._getTextureInfo(babylonMaterial.clearCoat.textureRoughness);\r\n }\r\n\r\n if (babylonMaterial.clearCoat.isTintEnabled) {\r\n Tools.Warn(`Clear Color tint is not supported for glTF export. Ignoring for: ${babylonMaterial.name}`);\r\n }\r\n\r\n if (babylonMaterial.clearCoat.remapF0OnInterfaceChange) {\r\n Tools.Warn(`Clear Color F0 remapping is not supported for glTF export. Ignoring for: ${babylonMaterial.name}`);\r\n }\r\n\r\n const clearCoatNormalTextureInfo = this._exporter._glTFMaterialExporter._getTextureInfo(babylonMaterial.clearCoat.bumpTexture);\r\n\r\n const clearCoatInfo: IKHRMaterialsClearcoat = {\r\n clearcoatFactor: babylonMaterial.clearCoat.intensity,\r\n clearcoatTexture: clearCoatTextureInfo ?? undefined,\r\n clearcoatRoughnessFactor: babylonMaterial.clearCoat.roughness,\r\n clearcoatRoughnessTexture: clearCoatTextureRoughnessInfo ?? undefined,\r\n clearcoatNormalTexture: clearCoatNormalTextureInfo ?? undefined,\r\n hasTextures: () => {\r\n return clearCoatInfo.clearcoatTexture !== null || clearCoatInfo.clearcoatRoughnessTexture !== null || clearCoatInfo.clearcoatRoughnessTexture !== null;\r\n },\r\n };\r\n\r\n node.extensions[NAME] = clearCoatInfo;\r\n }\r\n resolve(node);\r\n });\r\n }\r\n}\r\n\r\n_Exporter.RegisterExtension(NAME, (exporter) => new KHR_materials_clearcoat(exporter));\r\n"]}
1
+ {"version":3,"file":"KHR_materials_clearcoat.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_clearcoat.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,eAAe,EAAE,yDAA2C;AAGrE,OAAO,EAAE,KAAK,EAAE,sCAAwB;AAExC,MAAM,IAAI,GAAG,yBAAyB,CAAC;AAEvC;;GAEG;AACH,gEAAgE;AAChE,MAAM,OAAO,uBAAuB;IAchC,YAAY,QAAmB;QAb/B,6BAA6B;QACb,SAAI,GAAG,IAAI,CAAC;QAE5B,gDAAgD;QACzC,YAAO,GAAG,IAAI,CAAC;QAEtB,iDAAiD;QAC1C,aAAQ,GAAG,KAAK,CAAC;QAIhB,aAAQ,GAAG,KAAK,CAAC;QAGrB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC9B,CAAC;IAEM,OAAO,KAAI,CAAC;IAEnB,gBAAgB;IAChB,IAAW,OAAO;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAEM,oCAAoC,CAAE,OAAe,EAAE,IAAe,EAAE,eAAyB;QACpG,MAAM,kBAAkB,GAAkB,EAAE,CAAC;QAC7C,IAAI,eAAe,YAAY,eAAe,EAAE,CAAC;YAC7C,IAAI,eAAe,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC;gBACtC,IAAI,eAAe,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;oBACpC,kBAAkB,CAAC,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;gBAC/D,CAAC;gBACD,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,2BAA2B,IAAI,eAAe,CAAC,SAAS,CAAC,gBAAgB,EAAE,CAAC;oBACvG,kBAAkB,CAAC,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;gBACxE,CAAC;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C;gBAED,IAAI,eAAe,CAAC,SAAS,CAAC,wBAAwB,EAAE,CAAC;oBACrD,KAAK,CAAC,IAAI,CAAC,4EAA4E,eAAe,CAAC,IAAI,EAAE,CAAC,CAAC;gBACnH,CAAC;gBAED,MAAM,0BAA0B,GAAG,IAAI,CAAC,SAAS,CAAC,qBAAqB,CAAC,eAAe,CAAC,eAAe,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;gBAE/H,MAAM,aAAa,GAA2B;oBAC1C,eAAe,EAAE,eAAe,CAAC,SAAS,CAAC,SAAS;oBACpD,gBAAgB,EAAE,oBAAoB,IAAI,SAAS;oBACnD,wBAAwB,EAAE,eAAe,CAAC,SAAS,CAAC,SAAS;oBAC7D,yBAAyB,EAAE,6BAA6B,IAAI,SAAS;oBACrE,sBAAsB,EAAE,0BAA0B,IAAI,SAAS;oBAC/D,WAAW,EAAE,GAAG,EAAE;wBACd,OAAO,aAAa,CAAC,gBAAgB,KAAK,IAAI,IAAI,aAAa,CAAC,yBAAyB,KAAK,IAAI,IAAI,aAAa,CAAC,yBAAyB,KAAK,IAAI,CAAC;oBAC3J,CAAC;iBACJ,CAAC;gBAEF,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC;YAC1C,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAED,SAAS,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,uBAAuB,CAAC,QAAQ,CAAC,CAAC,CAAC","sourcesContent":["import type { IMaterial, IKHRMaterialsClearcoat } from \"babylonjs-gltf2interface\";\r\nimport type { IGLTFExporterExtensionV2 } from \"../glTFExporterExtension\";\r\nimport { _Exporter } from \"../glTFExporter\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport { PBRBaseMaterial } from \"core/Materials/PBR/pbrBaseMaterial\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\n\r\nimport { Tools } from \"core/Misc/tools\";\r\n\r\nconst NAME = \"KHR_materials_clearcoat\";\r\n\r\n/**\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_materials_clearcoat implements IGLTFExporterExtensionV2 {\r\n /** Name of this extension */\r\n public readonly name = NAME;\r\n\r\n /** Defines whether this extension is enabled */\r\n public enabled = true;\r\n\r\n /** Defines whether this extension is required */\r\n public required = false;\r\n\r\n private _exporter: _Exporter;\r\n\r\n private _wasUsed = false;\r\n\r\n constructor(exporter: _Exporter) {\r\n this._exporter = exporter;\r\n }\r\n\r\n public dispose() {}\r\n\r\n /** @internal */\r\n public get wasUsed() {\r\n return this._wasUsed;\r\n }\r\n\r\n public postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[] {\r\n const additionalTextures: BaseTexture[] = [];\r\n if (babylonMaterial instanceof PBRBaseMaterial) {\r\n if (babylonMaterial.clearCoat.isEnabled) {\r\n if (babylonMaterial.clearCoat.texture) {\r\n additionalTextures.push(babylonMaterial.clearCoat.texture);\r\n }\r\n if (!babylonMaterial.clearCoat.useRoughnessFromMainTexture && babylonMaterial.clearCoat.textureRoughness) {\r\n additionalTextures.push(babylonMaterial.clearCoat.textureRoughness);\r\n }\r\n if (babylonMaterial.clearCoat.bumpTexture) {\r\n additionalTextures.push(babylonMaterial.clearCoat.bumpTexture);\r\n }\r\n return additionalTextures;\r\n }\r\n }\r\n\r\n return [];\r\n }\r\n\r\n public postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial> {\r\n return new Promise((resolve) => {\r\n if (babylonMaterial instanceof PBRBaseMaterial) {\r\n if (!babylonMaterial.clearCoat.isEnabled) {\r\n resolve(node);\r\n return;\r\n }\r\n\r\n this._wasUsed = true;\r\n\r\n node.extensions = node.extensions || {};\r\n\r\n const clearCoatTextureInfo = this._exporter._glTFMaterialExporter._getTextureInfo(babylonMaterial.clearCoat.texture);\r\n let clearCoatTextureRoughnessInfo;\r\n if (babylonMaterial.clearCoat.useRoughnessFromMainTexture) {\r\n clearCoatTextureRoughnessInfo = this._exporter._glTFMaterialExporter._getTextureInfo(babylonMaterial.clearCoat.texture);\r\n } else {\r\n clearCoatTextureRoughnessInfo = this._exporter._glTFMaterialExporter._getTextureInfo(babylonMaterial.clearCoat.textureRoughness);\r\n }\r\n\r\n if (babylonMaterial.clearCoat.isTintEnabled) {\r\n Tools.Warn(`Clear Color tint is not supported for glTF export. Ignoring for: ${babylonMaterial.name}`);\r\n }\r\n\r\n if (babylonMaterial.clearCoat.remapF0OnInterfaceChange) {\r\n Tools.Warn(`Clear Color F0 remapping is not supported for glTF export. Ignoring for: ${babylonMaterial.name}`);\r\n }\r\n\r\n const clearCoatNormalTextureInfo = this._exporter._glTFMaterialExporter._getTextureInfo(babylonMaterial.clearCoat.bumpTexture);\r\n\r\n const clearCoatInfo: IKHRMaterialsClearcoat = {\r\n clearcoatFactor: babylonMaterial.clearCoat.intensity,\r\n clearcoatTexture: clearCoatTextureInfo ?? undefined,\r\n clearcoatRoughnessFactor: babylonMaterial.clearCoat.roughness,\r\n clearcoatRoughnessTexture: clearCoatTextureRoughnessInfo ?? undefined,\r\n clearcoatNormalTexture: clearCoatNormalTextureInfo ?? undefined,\r\n hasTextures: () => {\r\n return clearCoatInfo.clearcoatTexture !== null || clearCoatInfo.clearcoatRoughnessTexture !== null || clearCoatInfo.clearcoatRoughnessTexture !== null;\r\n },\r\n };\r\n\r\n node.extensions[NAME] = clearCoatInfo;\r\n }\r\n resolve(node);\r\n });\r\n }\r\n}\r\n\r\n_Exporter.RegisterExtension(NAME, (exporter) => new KHR_materials_clearcoat(exporter));\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"KHR_materials_diffuse_transmission.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,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,MAAM,uBAAuB,GAAqC;oBAC9D,yBAAyB;oBACzB,0BAA0B;oBAC1B,8BAA8B;oBAC9B,+BAA+B;oBAC/B,WAAW,EAAE,GAAG,EAAE;wBACd,OAAO,IAAI,CAAC,qBAAqB,CAAC,eAAe,CAAC,CAAC;oBACvD,CAAC;iBACJ,CAAC;gBACF,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,EAAE,CAAC;gBACxC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,uBAAuB,CAAC;aACnD;YACD,OAAO,CAAC,IAAI,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAED,SAAS,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,kCAAkC,CAAC,QAAQ,CAAC,CAAC,CAAC","sourcesContent":["import type { IMaterial, IKHRMaterialsDiffuseTransmission } from \"babylonjs-gltf2interface\";\r\nimport type { IGLTFExporterExtensionV2 } from \"../glTFExporterExtension\";\r\nimport { _Exporter } from \"../glTFExporter\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport { PBRMaterial } from \"core/Materials/PBR/pbrMaterial\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\n\r\nconst NAME = \"KHR_materials_diffuse_transmission\";\r\n\r\n/**\r\n * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1825)\r\n * !!! Experimental Extension Subject to Changes !!!\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_materials_diffuse_transmission implements IGLTFExporterExtensionV2 {\r\n /** Name of this extension */\r\n public readonly name = NAME;\r\n\r\n /** Defines whether this extension is enabled */\r\n public enabled = true;\r\n\r\n /** Defines whether this extension is required */\r\n public required = false;\r\n\r\n private _exporter: _Exporter;\r\n\r\n private _wasUsed = false;\r\n\r\n constructor(exporter: _Exporter) {\r\n this._exporter = exporter;\r\n }\r\n\r\n public dispose() {}\r\n\r\n /** @internal */\r\n public get wasUsed() {\r\n return this._wasUsed;\r\n }\r\n\r\n /**\r\n * After exporting a material, deal with additional textures\r\n * @param context GLTF context of the material\r\n * @param node exported GLTF node\r\n * @param babylonMaterial corresponding babylon material\r\n * @returns array of additional textures to export\r\n */\r\n public postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[] {\r\n const additionalTextures: BaseTexture[] = [];\r\n\r\n if (babylonMaterial instanceof PBRMaterial) {\r\n if (this._isExtensionEnabled(babylonMaterial)) {\r\n if (babylonMaterial.subSurface.thicknessTexture) {\r\n additionalTextures.push(babylonMaterial.subSurface.thicknessTexture);\r\n }\r\n return additionalTextures;\r\n }\r\n }\r\n\r\n return additionalTextures;\r\n }\r\n\r\n private _isExtensionEnabled(mat: PBRMaterial): boolean {\r\n // This extension must not be used on a material that also uses KHR_materials_unlit\r\n if (mat.unlit) {\r\n return false;\r\n }\r\n const subs = mat.subSurface;\r\n if (!subs.isTranslucencyEnabled) {\r\n return false;\r\n }\r\n\r\n return (\r\n !mat.unlit &&\r\n !subs.useAlbedoToTintTranslucency &&\r\n subs.useGltfStyleTextures &&\r\n subs.volumeIndexOfRefraction === 1 &&\r\n subs.minimumThickness === 0 &&\r\n subs.maximumThickness === 0\r\n );\r\n }\r\n\r\n private _hasTexturesExtension(mat: PBRMaterial): boolean {\r\n return mat.subSurface.translucencyIntensityTexture != null || mat.subSurface.translucencyColorTexture != null;\r\n }\r\n\r\n /**\r\n * After exporting a material\r\n * @param context GLTF context of the material\r\n * @param node exported GLTF node\r\n * @param babylonMaterial corresponding babylon material\r\n * @returns promise that resolves with the updated node\r\n */\r\n public postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial> {\r\n return new Promise((resolve) => {\r\n if (babylonMaterial instanceof PBRMaterial && this._isExtensionEnabled(babylonMaterial)) {\r\n this._wasUsed = true;\r\n\r\n const subs = babylonMaterial.subSurface;\r\n\r\n const diffuseTransmissionFactor = subs.translucencyIntensity == 1 ? undefined : subs.translucencyIntensity;\r\n const diffuseTransmissionTexture = this._exporter._glTFMaterialExporter._getTextureInfo(subs.translucencyIntensityTexture) ?? undefined;\r\n const diffuseTransmissionColorFactor = !subs.translucencyColor || subs.translucencyColor.equalsFloats(1.0, 1.0, 1.0) ? undefined : subs.translucencyColor.asArray();\r\n const diffuseTransmissionColorTexture = this._exporter._glTFMaterialExporter._getTextureInfo(subs.translucencyColorTexture) ?? undefined;\r\n\r\n const diffuseTransmissionInfo: IKHRMaterialsDiffuseTransmission = {\r\n diffuseTransmissionFactor,\r\n diffuseTransmissionTexture,\r\n diffuseTransmissionColorFactor,\r\n diffuseTransmissionColorTexture,\r\n hasTextures: () => {\r\n return this._hasTexturesExtension(babylonMaterial);\r\n },\r\n };\r\n node.extensions = node.extensions || {};\r\n node.extensions[NAME] = diffuseTransmissionInfo;\r\n }\r\n resolve(node);\r\n });\r\n }\r\n}\r\n\r\n_Exporter.RegisterExtension(NAME, (exporter) => new KHR_materials_diffuse_transmission(exporter));\r\n"]}
1
+ {"version":3,"file":"KHR_materials_diffuse_transmission.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAG7D,MAAM,IAAI,GAAG,oCAAoC,CAAC;AAElD;;;GAGG;AACH,gEAAgE;AAChE,MAAM,OAAO,kCAAkC;IAc3C,YAAY,QAAmB;QAb/B,6BAA6B;QACb,SAAI,GAAG,IAAI,CAAC;QAE5B,gDAAgD;QACzC,YAAO,GAAG,IAAI,CAAC;QAEtB,iDAAiD;QAC1C,aAAQ,GAAG,KAAK,CAAC;QAIhB,aAAQ,GAAG,KAAK,CAAC;QAGrB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC9B,CAAC;IAEM,OAAO,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C,IAAI,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAED,SAAS,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,kCAAkC,CAAC,QAAQ,CAAC,CAAC,CAAC","sourcesContent":["import type { IMaterial, IKHRMaterialsDiffuseTransmission } from \"babylonjs-gltf2interface\";\r\nimport type { IGLTFExporterExtensionV2 } from \"../glTFExporterExtension\";\r\nimport { _Exporter } from \"../glTFExporter\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport { PBRMaterial } from \"core/Materials/PBR/pbrMaterial\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\n\r\nconst NAME = \"KHR_materials_diffuse_transmission\";\r\n\r\n/**\r\n * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1825)\r\n * !!! Experimental Extension Subject to Changes !!!\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_materials_diffuse_transmission implements IGLTFExporterExtensionV2 {\r\n /** Name of this extension */\r\n public readonly name = NAME;\r\n\r\n /** Defines whether this extension is enabled */\r\n public enabled = true;\r\n\r\n /** Defines whether this extension is required */\r\n public required = false;\r\n\r\n private _exporter: _Exporter;\r\n\r\n private _wasUsed = false;\r\n\r\n constructor(exporter: _Exporter) {\r\n this._exporter = exporter;\r\n }\r\n\r\n public dispose() {}\r\n\r\n /** @internal */\r\n public get wasUsed() {\r\n return this._wasUsed;\r\n }\r\n\r\n /**\r\n * After exporting a material, deal with additional textures\r\n * @param context GLTF context of the material\r\n * @param node exported GLTF node\r\n * @param babylonMaterial corresponding babylon material\r\n * @returns array of additional textures to export\r\n */\r\n public postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[] {\r\n const additionalTextures: BaseTexture[] = [];\r\n\r\n if (babylonMaterial instanceof PBRMaterial) {\r\n if (this._isExtensionEnabled(babylonMaterial)) {\r\n if (babylonMaterial.subSurface.thicknessTexture) {\r\n additionalTextures.push(babylonMaterial.subSurface.thicknessTexture);\r\n }\r\n return additionalTextures;\r\n }\r\n }\r\n\r\n return additionalTextures;\r\n }\r\n\r\n private _isExtensionEnabled(mat: PBRMaterial): boolean {\r\n // This extension must not be used on a material that also uses KHR_materials_unlit\r\n if (mat.unlit) {\r\n return false;\r\n }\r\n const subs = mat.subSurface;\r\n if (!subs.isTranslucencyEnabled) {\r\n return false;\r\n }\r\n\r\n return (\r\n !mat.unlit &&\r\n !subs.useAlbedoToTintTranslucency &&\r\n subs.useGltfStyleTextures &&\r\n subs.volumeIndexOfRefraction === 1 &&\r\n subs.minimumThickness === 0 &&\r\n subs.maximumThickness === 0\r\n );\r\n }\r\n\r\n private _hasTexturesExtension(mat: PBRMaterial): boolean {\r\n return mat.subSurface.translucencyIntensityTexture != null || mat.subSurface.translucencyColorTexture != null;\r\n }\r\n\r\n /**\r\n * After exporting a material\r\n * @param context GLTF context of the material\r\n * @param node exported GLTF node\r\n * @param babylonMaterial corresponding babylon material\r\n * @returns promise that resolves with the updated node\r\n */\r\n public postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial> {\r\n return new Promise((resolve) => {\r\n if (babylonMaterial instanceof PBRMaterial && this._isExtensionEnabled(babylonMaterial)) {\r\n this._wasUsed = true;\r\n\r\n const subs = babylonMaterial.subSurface;\r\n\r\n const diffuseTransmissionFactor = subs.translucencyIntensity == 1 ? undefined : subs.translucencyIntensity;\r\n const diffuseTransmissionTexture = this._exporter._glTFMaterialExporter._getTextureInfo(subs.translucencyIntensityTexture) ?? undefined;\r\n const diffuseTransmissionColorFactor = !subs.translucencyColor || subs.translucencyColor.equalsFloats(1.0, 1.0, 1.0) ? undefined : subs.translucencyColor.asArray();\r\n const diffuseTransmissionColorTexture = this._exporter._glTFMaterialExporter._getTextureInfo(subs.translucencyColorTexture) ?? undefined;\r\n\r\n const diffuseTransmissionInfo: IKHRMaterialsDiffuseTransmission = {\r\n diffuseTransmissionFactor,\r\n diffuseTransmissionTexture,\r\n diffuseTransmissionColorFactor,\r\n diffuseTransmissionColorTexture,\r\n hasTextures: () => {\r\n return this._hasTexturesExtension(babylonMaterial);\r\n },\r\n };\r\n node.extensions = node.extensions || {};\r\n node.extensions[NAME] = diffuseTransmissionInfo;\r\n }\r\n resolve(node);\r\n });\r\n }\r\n}\r\n\r\n_Exporter.RegisterExtension(NAME, (exporter) => new KHR_materials_diffuse_transmission(exporter));\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"KHR_materials_dispersion.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_dispersion.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAE7D,MAAM,IAAI,GAAG,0BAA0B,CAAC;AAExC;;;GAGG;AACH,gEAAgE;AAChE,MAAM,OAAO,wBAAwB;IAYjC,kBAAkB;IAClB;QAZA,6BAA6B;QACb,SAAI,GAAG,IAAI,CAAC;QAE5B,gDAAgD;QACzC,YAAO,GAAG,IAAI,CAAC;QAEtB,iDAAiD;QAC1C,aAAQ,GAAG,KAAK,CAAC;QAEhB,aAAQ,GAAG,KAAK,CAAC;IAGV,CAAC;IAEhB,cAAc;IACP,OAAO,KAAI,CAAC;IAEnB,gBAAgB;IAChB,IAAW,OAAO;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAEO,mBAAmB,CAAC,GAAgB;QACxC,mFAAmF;QACnF,IAAI,GAAG,CAAC,KAAK,EAAE;YACX,OAAO,KAAK,CAAC;SAChB;QACD,MAAM,IAAI,GAAG,GAAG,CAAC,UAAU,CAAC;QAC5B,oDAAoD;QACpD,IAAI,CAAC,IAAI,CAAC,mBAAmB,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE;YACxD,OAAO,KAAK,CAAC;SAChB;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;;;OAMG;IACI,uBAAuB,CAAE,OAAe,EAAE,IAAe,EAAE,eAAyB;QACvF,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC3B,IAAI,eAAe,YAAY,WAAW,IAAI,IAAI,CAAC,mBAAmB,CAAC,eAAe,CAAC,EAAE;gBACrF,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;gBAErB,MAAM,IAAI,GAAG,eAAe,CAAC,UAAU,CAAC;gBACxC,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;gBAEnC,MAAM,cAAc,GAA4B;oBAC5C,UAAU,EAAE,UAAU;iBACzB,CAAC;gBACF,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,EAAE,CAAC;gBACxC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC;aAC1C;YACD,OAAO,CAAC,IAAI,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAED,SAAS,CAAC,iBAAiB,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,wBAAwB,EAAE,CAAC,CAAC","sourcesContent":["import type { IMaterial, IKHRMaterialsDispersion } from \"babylonjs-gltf2interface\";\r\nimport type { IGLTFExporterExtensionV2 } from \"../glTFExporterExtension\";\r\nimport { _Exporter } from \"../glTFExporter\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport { PBRMaterial } from \"core/Materials/PBR/pbrMaterial\";\r\n\r\nconst NAME = \"KHR_materials_dispersion\";\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/87bd64a7f5e23c84b6aef2e6082069583ed0ddb4/extensions/2.0/Khronos/KHR_materials_dispersion/README.md)\r\n * @experimental\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_materials_dispersion implements IGLTFExporterExtensionV2 {\r\n /** Name of this extension */\r\n public readonly name = NAME;\r\n\r\n /** Defines whether this extension is enabled */\r\n public enabled = true;\r\n\r\n /** Defines whether this extension is required */\r\n public required = false;\r\n\r\n private _wasUsed = false;\r\n\r\n /** Constructor */\r\n constructor() {}\r\n\r\n /** Dispose */\r\n public dispose() {}\r\n\r\n /** @internal */\r\n public get wasUsed() {\r\n return this._wasUsed;\r\n }\r\n\r\n private _isExtensionEnabled(mat: PBRMaterial): boolean {\r\n // This extension must not be used on a material that also uses KHR_materials_unlit\r\n if (mat.unlit) {\r\n return false;\r\n }\r\n const subs = mat.subSurface;\r\n // this extension requires refraction to be enabled.\r\n if (!subs.isRefractionEnabled && !subs.isDispersionEnabled) {\r\n return false;\r\n }\r\n return true;\r\n }\r\n\r\n /**\r\n * After exporting a material\r\n * @param context GLTF context of the material\r\n * @param node exported GLTF node\r\n * @param babylonMaterial corresponding babylon material\r\n * @returns promise, resolves with the material\r\n */\r\n public postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial> {\r\n return new Promise((resolve) => {\r\n if (babylonMaterial instanceof PBRMaterial && this._isExtensionEnabled(babylonMaterial)) {\r\n this._wasUsed = true;\r\n\r\n const subs = babylonMaterial.subSurface;\r\n const dispersion = subs.dispersion;\r\n\r\n const dispersionInfo: IKHRMaterialsDispersion = {\r\n dispersion: dispersion,\r\n };\r\n node.extensions = node.extensions || {};\r\n node.extensions[NAME] = dispersionInfo;\r\n }\r\n resolve(node);\r\n });\r\n }\r\n}\r\n\r\n_Exporter.RegisterExtension(NAME, () => new KHR_materials_dispersion());\r\n"]}
1
+ {"version":3,"file":"KHR_materials_dispersion.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_dispersion.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAE7D,MAAM,IAAI,GAAG,0BAA0B,CAAC;AAExC;;;GAGG;AACH,gEAAgE;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YAC3C,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAED,SAAS,CAAC,iBAAiB,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,wBAAwB,EAAE,CAAC,CAAC","sourcesContent":["import type { IMaterial, IKHRMaterialsDispersion } from \"babylonjs-gltf2interface\";\r\nimport type { IGLTFExporterExtensionV2 } from \"../glTFExporterExtension\";\r\nimport { _Exporter } from \"../glTFExporter\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport { PBRMaterial } from \"core/Materials/PBR/pbrMaterial\";\r\n\r\nconst NAME = \"KHR_materials_dispersion\";\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/87bd64a7f5e23c84b6aef2e6082069583ed0ddb4/extensions/2.0/Khronos/KHR_materials_dispersion/README.md)\r\n * @experimental\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_materials_dispersion implements IGLTFExporterExtensionV2 {\r\n /** Name of this extension */\r\n public readonly name = NAME;\r\n\r\n /** Defines whether this extension is enabled */\r\n public enabled = true;\r\n\r\n /** Defines whether this extension is required */\r\n public required = false;\r\n\r\n private _wasUsed = false;\r\n\r\n /** Constructor */\r\n constructor() {}\r\n\r\n /** Dispose */\r\n public dispose() {}\r\n\r\n /** @internal */\r\n public get wasUsed() {\r\n return this._wasUsed;\r\n }\r\n\r\n private _isExtensionEnabled(mat: PBRMaterial): boolean {\r\n // This extension must not be used on a material that also uses KHR_materials_unlit\r\n if (mat.unlit) {\r\n return false;\r\n }\r\n const subs = mat.subSurface;\r\n // this extension requires refraction to be enabled.\r\n if (!subs.isRefractionEnabled && !subs.isDispersionEnabled) {\r\n return false;\r\n }\r\n return true;\r\n }\r\n\r\n /**\r\n * After exporting a material\r\n * @param context GLTF context of the material\r\n * @param node exported GLTF node\r\n * @param babylonMaterial corresponding babylon material\r\n * @returns promise, resolves with the material\r\n */\r\n public postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial> {\r\n return new Promise((resolve) => {\r\n if (babylonMaterial instanceof PBRMaterial && this._isExtensionEnabled(babylonMaterial)) {\r\n this._wasUsed = true;\r\n\r\n const subs = babylonMaterial.subSurface;\r\n const dispersion = subs.dispersion;\r\n\r\n const dispersionInfo: IKHRMaterialsDispersion = {\r\n dispersion: dispersion,\r\n };\r\n node.extensions = node.extensions || {};\r\n node.extensions[NAME] = dispersionInfo;\r\n }\r\n resolve(node);\r\n });\r\n }\r\n}\r\n\r\n_Exporter.RegisterExtension(NAME, () => new KHR_materials_dispersion());\r\n"]}