@onerjs/serializers 9.0.2 → 9.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/glTF/2.0/Extensions/KHR_materials_anisotropy.pure.js +12 -10
- package/glTF/2.0/Extensions/KHR_materials_anisotropy.pure.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_coat.pure.js +11 -9
- package/glTF/2.0/Extensions/KHR_materials_coat.pure.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_scatter.d.ts +5 -0
- package/glTF/2.0/Extensions/KHR_materials_scatter.js +8 -0
- package/glTF/2.0/Extensions/KHR_materials_scatter.js.map +1 -0
- package/glTF/2.0/Extensions/KHR_materials_scatter.pure.d.ts +120 -0
- package/glTF/2.0/Extensions/KHR_materials_scatter.pure.js +396 -0
- package/glTF/2.0/Extensions/KHR_materials_scatter.pure.js.map +1 -0
- package/glTF/2.0/Extensions/KHR_materials_transmission.pure.d.ts +2 -0
- package/glTF/2.0/Extensions/KHR_materials_transmission.pure.js +141 -39
- package/glTF/2.0/Extensions/KHR_materials_transmission.pure.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_volume.pure.js +2 -48
- package/glTF/2.0/Extensions/KHR_materials_volume.pure.js.map +1 -1
- package/glTF/2.0/Extensions/index.d.ts +1 -1
- package/glTF/2.0/Extensions/index.js +1 -1
- package/glTF/2.0/Extensions/index.js.map +1 -1
- package/glTF/2.0/Extensions/pure.d.ts +1 -1
- package/glTF/2.0/Extensions/pure.js +1 -1
- package/glTF/2.0/Extensions/pure.js.map +1 -1
- package/glTF/2.0/glTFExporter.d.ts +6 -0
- package/glTF/2.0/glTFExporter.js +9 -0
- package/glTF/2.0/glTFExporter.js.map +1 -1
- package/glTF/2.0/glTFMaterialExporter.d.ts +2 -1
- package/glTF/2.0/glTFMaterialExporter.js +68 -31
- package/glTF/2.0/glTFMaterialExporter.js.map +1 -1
- package/glTF/2.0/glTFUtilities.d.ts +37 -1
- package/glTF/2.0/glTFUtilities.js +99 -0
- package/glTF/2.0/glTFUtilities.js.map +1 -1
- package/package.json +2 -2
- package/glTF/2.0/Extensions/KHR_materials_volume_scatter.d.ts +0 -5
- package/glTF/2.0/Extensions/KHR_materials_volume_scatter.js +0 -8
- package/glTF/2.0/Extensions/KHR_materials_volume_scatter.js.map +0 -1
- package/glTF/2.0/Extensions/KHR_materials_volume_scatter.pure.d.ts +0 -45
- package/glTF/2.0/Extensions/KHR_materials_volume_scatter.pure.js +0 -145
- package/glTF/2.0/Extensions/KHR_materials_volume_scatter.pure.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glTFUtilities.js","sourceRoot":"","sources":["../../../../../dev/serializers/src/glTF/2.0/glTFUtilities.ts"],"names":[],"mappings":"AAGA,OAAO,EAAgB,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAC/F,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAEhE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAG5D,iCAAiC;AACjC,MAAM,CAAC,MAAM,kBAAkB,GAAG,OAAO,CAAC,YAAY,CAAC;AACvD,MAAM,CAAC,MAAM,eAAe,GAAG,UAAU,CAAC,QAAQ,EAA+B,CAAC;AAClF,MAAM,CAAC,MAAM,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC;AAChD,MAAM,gCAAgC,GAAG,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pF,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAChD,MAAM,YAAY,GAAG,aAAa,CAAC,GAAc,CAAC,CAAC;QACnD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,cAAc,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC,IAAI,KAAK,KAAK,YAAY,EAAE,CAAC;YACzH,OAAO,MAAM,CAAC,GAAc,CAAC,CAAC;QAClC,CAAC;IACL,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC;AAED,SAAS,cAAc,CAAC,MAAiB,EAAE,MAAiB;IACxD,OAAO,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AAC1F,CAAC","sourcesContent":["/* eslint-disable jsdoc/require-jsdoc */\r\nimport { type INode, AccessorType, MeshPrimitiveMode } from \"babylonjs-gltf2interface\";\r\nimport { type FloatArray, type DataArray, type IndicesArray, type DeepImmutable } from \"core/types\";\r\nimport { type Vector4, Quaternion, TmpVectors, Matrix, Vector3 } from \"core/Maths/math.vector\";\r\nimport { VertexBuffer } from \"core/Buffers/buffer\";\r\nimport { Material } from \"core/Materials/material\";\r\nimport { TransformNode } from \"core/Meshes/transformNode\";\r\nimport { type AbstractMesh } from \"core/Meshes/abstractMesh\";\r\nimport { EnumerateFloatValues } from \"core/Buffers/bufferUtils\";\r\nimport { type Node } from \"core/node\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport { TargetCamera } from \"core/Cameras/targetCamera\";\r\nimport { type ShadowLight } from \"core/Lights/shadowLight\";\r\nimport { Epsilon } from \"core/Maths/math.constants\";\r\nimport { ConvertHandednessMatrix } from \"../../exportUtils\";\r\nimport { type AreaLight } from \"core/Lights/areaLight\";\r\n\r\n// Default values for comparison.\r\nexport const DefaultTranslation = Vector3.ZeroReadOnly;\r\nexport const DefaultRotation = Quaternion.Identity() as DeepImmutable<Quaternion>;\r\nexport const DefaultScale = Vector3.OneReadOnly;\r\nconst DefaultLoaderCameraParentScaleLh = new Vector3(-1, 1, 1) as DeepImmutable<Vector3>;\r\n\r\n/**\r\n * Get the information necessary for enumerating a vertex buffer.\r\n * @param vertexBuffer the vertex buffer to enumerate\r\n * @param meshes the meshes that use the vertex buffer\r\n * @returns the information necessary to enumerate the vertex buffer\r\n */\r\nexport function GetVertexBufferInfo(vertexBuffer: VertexBuffer, meshes: AbstractMesh[]) {\r\n const { byteOffset, byteStride, type, normalized } = vertexBuffer;\r\n const componentCount = vertexBuffer.getSize();\r\n const totalVertices = meshes.reduce((max, current) => {\r\n return current.getTotalVertices() > max ? current.getTotalVertices() : max;\r\n }, -Number.MAX_VALUE); // Get the max total vertices count, to ensure we capture the full range of vertex data used by the meshes.\r\n const count = totalVertices * componentCount;\r\n const kind = vertexBuffer.getKind();\r\n\r\n return { byteOffset, byteStride, componentCount, type, count, normalized, totalVertices, kind };\r\n}\r\n\r\nexport function GetAccessorElementCount(accessorType: AccessorType): number {\r\n switch (accessorType) {\r\n case AccessorType.MAT2:\r\n return 4;\r\n case AccessorType.MAT3:\r\n return 9;\r\n case AccessorType.MAT4:\r\n return 16;\r\n case AccessorType.SCALAR:\r\n return 1;\r\n case AccessorType.VEC2:\r\n return 2;\r\n case AccessorType.VEC3:\r\n return 3;\r\n case AccessorType.VEC4:\r\n return 4;\r\n }\r\n}\r\n\r\nexport function FloatsNeed16BitInteger(floatArray: FloatArray): boolean {\r\n return floatArray.some((value) => value >= 256);\r\n}\r\n\r\nexport function IsStandardVertexAttribute(type: string): boolean {\r\n switch (type) {\r\n case VertexBuffer.PositionKind:\r\n case VertexBuffer.NormalKind:\r\n case VertexBuffer.TangentKind:\r\n case VertexBuffer.ColorKind:\r\n case VertexBuffer.MatricesIndicesKind:\r\n case VertexBuffer.MatricesIndicesExtraKind:\r\n case VertexBuffer.MatricesWeightsKind:\r\n case VertexBuffer.MatricesWeightsExtraKind:\r\n case VertexBuffer.UVKind:\r\n case VertexBuffer.UV2Kind:\r\n case VertexBuffer.UV3Kind:\r\n case VertexBuffer.UV4Kind:\r\n case VertexBuffer.UV5Kind:\r\n case VertexBuffer.UV6Kind:\r\n return true;\r\n }\r\n return false;\r\n}\r\n\r\nexport function GetAccessorType(kind: string, hasVertexColorAlpha: boolean): AccessorType {\r\n if (kind == VertexBuffer.ColorKind) {\r\n return hasVertexColorAlpha ? AccessorType.VEC4 : AccessorType.VEC3;\r\n }\r\n\r\n switch (kind) {\r\n case VertexBuffer.PositionKind:\r\n case VertexBuffer.NormalKind:\r\n return AccessorType.VEC3;\r\n case VertexBuffer.TangentKind:\r\n case VertexBuffer.MatricesIndicesKind:\r\n case VertexBuffer.MatricesIndicesExtraKind:\r\n case VertexBuffer.MatricesWeightsKind:\r\n case VertexBuffer.MatricesWeightsExtraKind:\r\n return AccessorType.VEC4;\r\n case VertexBuffer.UVKind:\r\n case VertexBuffer.UV2Kind:\r\n case VertexBuffer.UV3Kind:\r\n case VertexBuffer.UV4Kind:\r\n case VertexBuffer.UV5Kind:\r\n case VertexBuffer.UV6Kind:\r\n return AccessorType.VEC2;\r\n }\r\n\r\n throw new Error(`Unknown kind ${kind}`);\r\n}\r\n\r\nexport function GetAttributeType(kind: string): string {\r\n switch (kind) {\r\n case VertexBuffer.PositionKind:\r\n return \"POSITION\";\r\n case VertexBuffer.NormalKind:\r\n return \"NORMAL\";\r\n case VertexBuffer.TangentKind:\r\n return \"TANGENT\";\r\n case VertexBuffer.ColorKind:\r\n return \"COLOR_0\";\r\n case VertexBuffer.UVKind:\r\n return \"TEXCOORD_0\";\r\n case VertexBuffer.UV2Kind:\r\n return \"TEXCOORD_1\";\r\n case VertexBuffer.UV3Kind:\r\n return \"TEXCOORD_2\";\r\n case VertexBuffer.UV4Kind:\r\n return \"TEXCOORD_3\";\r\n case VertexBuffer.UV5Kind:\r\n return \"TEXCOORD_4\";\r\n case VertexBuffer.UV6Kind:\r\n return \"TEXCOORD_5\";\r\n case VertexBuffer.MatricesIndicesKind:\r\n return \"JOINTS_0\";\r\n case VertexBuffer.MatricesIndicesExtraKind:\r\n return \"JOINTS_1\";\r\n case VertexBuffer.MatricesWeightsKind:\r\n return \"WEIGHTS_0\";\r\n case VertexBuffer.MatricesWeightsExtraKind:\r\n return \"WEIGHTS_1\";\r\n }\r\n\r\n throw new Error(`Unknown kind: ${kind}`);\r\n}\r\n\r\nexport function GetPrimitiveMode(fillMode: number): MeshPrimitiveMode {\r\n switch (fillMode) {\r\n case Material.TriangleFillMode:\r\n return MeshPrimitiveMode.TRIANGLES;\r\n case Material.TriangleStripDrawMode:\r\n return MeshPrimitiveMode.TRIANGLE_STRIP;\r\n case Material.TriangleFanDrawMode:\r\n return MeshPrimitiveMode.TRIANGLE_FAN;\r\n case Material.PointListDrawMode:\r\n case Material.PointFillMode:\r\n return MeshPrimitiveMode.POINTS;\r\n case Material.LineLoopDrawMode:\r\n return MeshPrimitiveMode.LINE_LOOP;\r\n case Material.LineListDrawMode:\r\n return MeshPrimitiveMode.LINES;\r\n case Material.LineStripDrawMode:\r\n return MeshPrimitiveMode.LINE_STRIP;\r\n }\r\n\r\n throw new Error(`Unknown fill mode: ${fillMode}`);\r\n}\r\n\r\nexport function IsTriangleFillMode(fillMode: number): boolean {\r\n switch (fillMode) {\r\n case Material.TriangleFillMode:\r\n case Material.TriangleStripDrawMode:\r\n case Material.TriangleFanDrawMode:\r\n return true;\r\n }\r\n\r\n return false;\r\n}\r\n\r\nexport function NormalizeTangent(tangent: Vector4 | Vector3) {\r\n const length = Math.sqrt(tangent.x * tangent.x + tangent.y * tangent.y + tangent.z * tangent.z);\r\n if (length > 0) {\r\n tangent.x /= length;\r\n tangent.y /= length;\r\n tangent.z /= length;\r\n }\r\n}\r\n\r\nexport function ConvertToRightHandedPosition(value: Vector3): Vector3 {\r\n value.x *= -1;\r\n return value;\r\n}\r\n\r\n/** @internal */\r\nexport function ConvertToRightHandedTransformMatrix(matrix: Matrix): Matrix {\r\n ConvertHandednessMatrix.invertToRef(TmpVectors.Matrix[0]).multiplyToRef(matrix, matrix).multiplyToRef(ConvertHandednessMatrix, matrix);\r\n return matrix;\r\n}\r\n\r\n/**\r\n * Converts, in-place, a left-handed quaternion to a right-handed quaternion via a change of basis.\r\n * @param value the unit quaternion to convert\r\n * @returns the converted quaternion\r\n */\r\nexport function ConvertToRightHandedRotation(value: Quaternion): Quaternion {\r\n /**\r\n * This is the simplified version of the following equation:\r\n * q' = to_quaternion(M * to_matrix(q) * M^-1)\r\n * where M is the conversion matrix `convertHandednessMatrix`,\r\n * q is the input quaternion, and q' is the converted quaternion.\r\n * Reference: https://d3cw3dd2w32x2b.cloudfront.net/wp-content/uploads/2015/01/matrix-to-quat.pdf\r\n */\r\n if (value.x * value.x + value.y * value.y > 0.5) {\r\n const absX = Math.abs(value.x);\r\n const absY = Math.abs(value.y);\r\n if (absX > absY) {\r\n const sign = Math.sign(value.x);\r\n value.x = absX;\r\n value.y *= -sign;\r\n value.z *= -sign;\r\n value.w *= sign;\r\n } else {\r\n const sign = Math.sign(value.y);\r\n value.x *= -sign;\r\n value.y = absY;\r\n value.z *= sign;\r\n value.w *= -sign;\r\n }\r\n } else {\r\n const absZ = Math.abs(value.z);\r\n const absW = Math.abs(value.w);\r\n if (absZ > absW) {\r\n const sign = Math.sign(value.z);\r\n value.x *= -sign;\r\n value.y *= sign;\r\n value.z = absZ;\r\n value.w *= -sign;\r\n } else {\r\n const sign = Math.sign(value.w);\r\n value.x *= sign;\r\n value.y *= -sign;\r\n value.z *= -sign;\r\n value.w = absW;\r\n }\r\n }\r\n\r\n return value;\r\n}\r\n\r\n/**\r\n * Pre-multiplies a 180-degree Y rotation to the quaternion, in order to match glTF's flipped forward direction for cameras.\r\n * @param rotation Target camera rotation.\r\n */\r\nexport function Rotate180Y(rotation: Quaternion): void {\r\n // Simplified from: rotation * (0, 1, 0, 0).\r\n rotation.copyFromFloats(-rotation.z, rotation.w, rotation.x, -rotation.y);\r\n}\r\n\r\n/**\r\n * Collapses GLTF parent and node into a single node, ignoring scaling.\r\n * This is useful for removing nodes that were added by the GLTF importer.\r\n * @param node Original GLTF node (Light or Camera).\r\n * @param parentNode Target parent node.\r\n */\r\nexport function CollapseChildIntoParent(node: INode, parentNode: INode): void {\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 parentMatrix = Matrix.ComposeToRef(DefaultScale, 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(DefaultScale, rotation, translation, TmpVectors.Matrix[1]);\r\n\r\n parentMatrix.multiplyToRef(matrix, matrix);\r\n matrix.decompose(undefined, parentRotation, parentTranslation);\r\n\r\n if (parentTranslation.equalsWithEpsilon(DefaultTranslation, Epsilon)) {\r\n delete parentNode.translation;\r\n } else {\r\n parentNode.translation = parentTranslation.asArray();\r\n }\r\n\r\n if (parentRotation.equalsWithEpsilon(DefaultRotation, Epsilon)) {\r\n delete parentNode.rotation;\r\n } else {\r\n parentNode.rotation = parentRotation.asArray();\r\n }\r\n\r\n if (parentNode.scale) {\r\n delete parentNode.scale;\r\n }\r\n}\r\n\r\n/**\r\n * Checks whether a camera or light node is candidate for collapsing with its parent node.\r\n * This is useful for roundtrips, as the glTF Importer parents a new node to\r\n * lights and cameras to store their original transformation information.\r\n * @param babylonNode Babylon light or camera node.\r\n * @param parentBabylonNode Target Babylon parent node.\r\n * @returns True if the two nodes can be merged, false otherwise.\r\n */\r\nexport function IsChildCollapsible(babylonNode: ShadowLight | TargetCamera | AreaLight, parentBabylonNode: Node): boolean {\r\n if (!(parentBabylonNode instanceof TransformNode)) {\r\n return false;\r\n }\r\n\r\n // Verify child is the only descendant\r\n const isOnlyDescendant = parentBabylonNode.getChildren().length === 1 && babylonNode.getChildren().length === 0 && babylonNode.parent === parentBabylonNode;\r\n if (!isOnlyDescendant) {\r\n return false;\r\n }\r\n\r\n // Verify parent has the expected scaling, determined by the node type and scene's coordinate system.\r\n const scene = babylonNode.getScene();\r\n const expectedScale = babylonNode instanceof TargetCamera && !scene.useRightHandedSystem ? DefaultLoaderCameraParentScaleLh : DefaultScale;\r\n\r\n if (!parentBabylonNode.scaling.equalsWithEpsilon(expectedScale, Epsilon)) {\r\n Logger.Warn(`Cannot collapse node ${babylonNode.name} into parent node ${parentBabylonNode.name} with modified scaling.`);\r\n return false;\r\n }\r\n\r\n return true;\r\n}\r\n\r\n/**\r\n * Converts an IndicesArray into either a Uint32Array or Uint16Array.\r\n * If the `start` and `count` parameters specify a subset of the array, a new view is created.\r\n * If the input is a number[], the data is copied into a new buffer.\r\n * @param indices input array to be converted\r\n * @param start starting index\r\n * @param count number of indices\r\n * @param is32Bits whether the output should be Uint32Array (true) or Uint16Array (false) when indices is an `Array`\r\n * @returns a Uint32Array or Uint16Array\r\n * @internal\r\n */\r\nexport function IndicesArrayToTypedSubarray(indices: IndicesArray, start: number, count: number, is32Bits: boolean): Uint32Array | Uint16Array {\r\n let processedIndices = indices;\r\n if (start !== 0 || count !== indices.length) {\r\n processedIndices = Array.isArray(indices) ? indices.slice(start, start + count) : indices.subarray(start, start + count);\r\n }\r\n\r\n // If Int32Array, cast the indices (which should all be positive) to Uint32Array\r\n if (processedIndices instanceof Int32Array) {\r\n return new Uint32Array(processedIndices.buffer, processedIndices.byteOffset, processedIndices.length);\r\n }\r\n\r\n if (Array.isArray(processedIndices)) {\r\n return is32Bits ? new Uint32Array(processedIndices) : new Uint16Array(processedIndices);\r\n }\r\n\r\n return processedIndices;\r\n}\r\n\r\nexport function DataArrayToUint8Array(data: DataArray): Uint8Array {\r\n if (data instanceof Array) {\r\n const floatData = new Float32Array(data);\r\n return new Uint8Array(floatData.buffer, floatData.byteOffset, floatData.byteLength);\r\n }\r\n\r\n return ArrayBuffer.isView(data) ? new Uint8Array(data.buffer, data.byteOffset, data.byteLength) : new Uint8Array(data);\r\n}\r\n\r\nexport function GetMinMax(data: DataArray, vertexBuffer: VertexBuffer, start: number, count: number): { min: number[]; max: number[] } {\r\n const { byteOffset, byteStride, type, normalized } = vertexBuffer;\r\n const size = vertexBuffer.getSize();\r\n const min = new Array<number>(size).fill(Infinity);\r\n const max = new Array<number>(size).fill(-Infinity);\r\n EnumerateFloatValues(data, byteOffset + start * byteStride, byteStride, size, type, count * size, normalized, (values) => {\r\n for (let i = 0; i < size; i++) {\r\n min[i] = Math.min(min[i], values[i]);\r\n max[i] = Math.max(max[i], values[i]);\r\n }\r\n });\r\n\r\n return { min, max };\r\n}\r\n\r\n/**\r\n * Removes, in-place, object properties which have the same value as the default value.\r\n * Useful for avoiding unnecessary properties in the glTF JSON.\r\n * @param object the object to omit default values from\r\n * @param defaultValues a partial object with default values\r\n * @returns object with default values omitted\r\n */\r\nexport function OmitDefaultValues<T extends object>(object: T, defaultValues: Partial<T>): T {\r\n for (const [key, value] of Object.entries(object)) {\r\n const defaultValue = defaultValues[key as keyof T];\r\n if ((Array.isArray(value) && Array.isArray(defaultValue) && AreArraysEqual(value, defaultValue)) || value === defaultValue) {\r\n delete object[key as keyof T];\r\n }\r\n }\r\n return object;\r\n}\r\n\r\nfunction AreArraysEqual(array1: unknown[], array2: unknown[]): boolean {\r\n return array1.length === array2.length && array1.every((val, i) => val === array2[i]);\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"glTFUtilities.js","sourceRoot":"","sources":["../../../../../dev/serializers/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C,GAAG,GAAG,QAAQ,CAAC,kBAAkB,CAAC,GAAG,QAAQ,CAAC,gBAAgB,CAAC;IACvG,MAAM,6CAA6C,GAAG,8BAA8B,GAAG,QAAQ,CAAC,kBAAkB,CAAC;IACnH,MAAM,yDAAyD,GAAG,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,6CAA6C,EAAE,IAAI,CAAC,CAAC;IACtI,MAAM,WAAW,GAAG,QAAQ,CAAC,kBAAkB,GAAG,yDAAyD,CAAC;IAC5G,MAAM,aAAa,GAAG,8BAA8B,GAAG,yDAAyD,CAAC;IAEjH,OAAO;QACH,gBAAgB,EAAE,4BAA4B,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,WAAW,GAAG,0BAA0B,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC;QAC7H,mBAAmB,EAAE,+BAA+B,GAAG,WAAW,GAAG,6BAA6B,GAAG,aAAa;KACrH,CAAC;AACN,CAAC;AAED,SAAS,cAAc,CAAC,MAAiB,EAAE,MAAiB;IACxD,OAAO,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AAC1F,CAAC","sourcesContent":["/* eslint-disable jsdoc/require-jsdoc */\r\nimport { type INode, AccessorType, MeshPrimitiveMode } from \"babylonjs-gltf2interface\";\r\nimport { type FloatArray, type DataArray, type IndicesArray, type DeepImmutable, type Nullable } from \"core/types\";\r\nimport { type Vector4, Quaternion, TmpVectors, Matrix, Vector3 } from \"core/Maths/math.vector\";\r\nimport { VertexBuffer } from \"core/Buffers/buffer\";\r\nimport { Material } from \"core/Materials/material\";\r\nimport { TransformNode } from \"core/Meshes/transformNode\";\r\nimport { type AbstractMesh } from \"core/Meshes/abstractMesh\";\r\nimport { EnumerateFloatValues } from \"core/Buffers/bufferUtils\";\r\nimport { type Node } from \"core/node\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport { TargetCamera } from \"core/Cameras/targetCamera\";\r\nimport { type ShadowLight } from \"core/Lights/shadowLight\";\r\nimport { Epsilon } from \"core/Maths/math.constants\";\r\nimport { ConvertHandednessMatrix } from \"../../exportUtils\";\r\nimport { type AreaLight } from \"core/Lights/areaLight\";\r\nimport { type BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport { type Texture } from \"core/Materials/Textures/texture\";\r\nimport { type OpenPBRMaterial } from \"core/Materials/PBR/openpbrMaterial.pure\";\r\n\r\n// Default values for comparison.\r\nexport const DefaultTranslation = Vector3.ZeroReadOnly;\r\nexport const DefaultRotation = Quaternion.Identity() as DeepImmutable<Quaternion>;\r\nexport const DefaultScale = Vector3.OneReadOnly;\r\nconst DefaultLoaderCameraParentScaleLh = new Vector3(-1, 1, 1) as DeepImmutable<Vector3>;\r\n\r\n/**\r\n * Get the information necessary for enumerating a vertex buffer.\r\n * @param vertexBuffer the vertex buffer to enumerate\r\n * @param meshes the meshes that use the vertex buffer\r\n * @returns the information necessary to enumerate the vertex buffer\r\n */\r\nexport function GetVertexBufferInfo(vertexBuffer: VertexBuffer, meshes: AbstractMesh[]) {\r\n const { byteOffset, byteStride, type, normalized } = vertexBuffer;\r\n const componentCount = vertexBuffer.getSize();\r\n const totalVertices = meshes.reduce((max, current) => {\r\n return current.getTotalVertices() > max ? current.getTotalVertices() : max;\r\n }, -Number.MAX_VALUE); // Get the max total vertices count, to ensure we capture the full range of vertex data used by the meshes.\r\n const count = totalVertices * componentCount;\r\n const kind = vertexBuffer.getKind();\r\n\r\n return { byteOffset, byteStride, componentCount, type, count, normalized, totalVertices, kind };\r\n}\r\n\r\nexport function GetAccessorElementCount(accessorType: AccessorType): number {\r\n switch (accessorType) {\r\n case AccessorType.MAT2:\r\n return 4;\r\n case AccessorType.MAT3:\r\n return 9;\r\n case AccessorType.MAT4:\r\n return 16;\r\n case AccessorType.SCALAR:\r\n return 1;\r\n case AccessorType.VEC2:\r\n return 2;\r\n case AccessorType.VEC3:\r\n return 3;\r\n case AccessorType.VEC4:\r\n return 4;\r\n }\r\n}\r\n\r\nexport function FloatsNeed16BitInteger(floatArray: FloatArray): boolean {\r\n return floatArray.some((value) => value >= 256);\r\n}\r\n\r\nexport function IsStandardVertexAttribute(type: string): boolean {\r\n switch (type) {\r\n case VertexBuffer.PositionKind:\r\n case VertexBuffer.NormalKind:\r\n case VertexBuffer.TangentKind:\r\n case VertexBuffer.ColorKind:\r\n case VertexBuffer.MatricesIndicesKind:\r\n case VertexBuffer.MatricesIndicesExtraKind:\r\n case VertexBuffer.MatricesWeightsKind:\r\n case VertexBuffer.MatricesWeightsExtraKind:\r\n case VertexBuffer.UVKind:\r\n case VertexBuffer.UV2Kind:\r\n case VertexBuffer.UV3Kind:\r\n case VertexBuffer.UV4Kind:\r\n case VertexBuffer.UV5Kind:\r\n case VertexBuffer.UV6Kind:\r\n return true;\r\n }\r\n return false;\r\n}\r\n\r\nexport function GetAccessorType(kind: string, hasVertexColorAlpha: boolean): AccessorType {\r\n if (kind == VertexBuffer.ColorKind) {\r\n return hasVertexColorAlpha ? AccessorType.VEC4 : AccessorType.VEC3;\r\n }\r\n\r\n switch (kind) {\r\n case VertexBuffer.PositionKind:\r\n case VertexBuffer.NormalKind:\r\n return AccessorType.VEC3;\r\n case VertexBuffer.TangentKind:\r\n case VertexBuffer.MatricesIndicesKind:\r\n case VertexBuffer.MatricesIndicesExtraKind:\r\n case VertexBuffer.MatricesWeightsKind:\r\n case VertexBuffer.MatricesWeightsExtraKind:\r\n return AccessorType.VEC4;\r\n case VertexBuffer.UVKind:\r\n case VertexBuffer.UV2Kind:\r\n case VertexBuffer.UV3Kind:\r\n case VertexBuffer.UV4Kind:\r\n case VertexBuffer.UV5Kind:\r\n case VertexBuffer.UV6Kind:\r\n return AccessorType.VEC2;\r\n }\r\n\r\n throw new Error(`Unknown kind ${kind}`);\r\n}\r\n\r\nexport function GetAttributeType(kind: string): string {\r\n switch (kind) {\r\n case VertexBuffer.PositionKind:\r\n return \"POSITION\";\r\n case VertexBuffer.NormalKind:\r\n return \"NORMAL\";\r\n case VertexBuffer.TangentKind:\r\n return \"TANGENT\";\r\n case VertexBuffer.ColorKind:\r\n return \"COLOR_0\";\r\n case VertexBuffer.UVKind:\r\n return \"TEXCOORD_0\";\r\n case VertexBuffer.UV2Kind:\r\n return \"TEXCOORD_1\";\r\n case VertexBuffer.UV3Kind:\r\n return \"TEXCOORD_2\";\r\n case VertexBuffer.UV4Kind:\r\n return \"TEXCOORD_3\";\r\n case VertexBuffer.UV5Kind:\r\n return \"TEXCOORD_4\";\r\n case VertexBuffer.UV6Kind:\r\n return \"TEXCOORD_5\";\r\n case VertexBuffer.MatricesIndicesKind:\r\n return \"JOINTS_0\";\r\n case VertexBuffer.MatricesIndicesExtraKind:\r\n return \"JOINTS_1\";\r\n case VertexBuffer.MatricesWeightsKind:\r\n return \"WEIGHTS_0\";\r\n case VertexBuffer.MatricesWeightsExtraKind:\r\n return \"WEIGHTS_1\";\r\n }\r\n\r\n throw new Error(`Unknown kind: ${kind}`);\r\n}\r\n\r\nexport function GetPrimitiveMode(fillMode: number): MeshPrimitiveMode {\r\n switch (fillMode) {\r\n case Material.TriangleFillMode:\r\n return MeshPrimitiveMode.TRIANGLES;\r\n case Material.TriangleStripDrawMode:\r\n return MeshPrimitiveMode.TRIANGLE_STRIP;\r\n case Material.TriangleFanDrawMode:\r\n return MeshPrimitiveMode.TRIANGLE_FAN;\r\n case Material.PointListDrawMode:\r\n case Material.PointFillMode:\r\n return MeshPrimitiveMode.POINTS;\r\n case Material.LineLoopDrawMode:\r\n return MeshPrimitiveMode.LINE_LOOP;\r\n case Material.LineListDrawMode:\r\n return MeshPrimitiveMode.LINES;\r\n case Material.LineStripDrawMode:\r\n return MeshPrimitiveMode.LINE_STRIP;\r\n }\r\n\r\n throw new Error(`Unknown fill mode: ${fillMode}`);\r\n}\r\n\r\nexport function IsTriangleFillMode(fillMode: number): boolean {\r\n switch (fillMode) {\r\n case Material.TriangleFillMode:\r\n case Material.TriangleStripDrawMode:\r\n case Material.TriangleFanDrawMode:\r\n return true;\r\n }\r\n\r\n return false;\r\n}\r\n\r\nexport function NormalizeTangent(tangent: Vector4 | Vector3) {\r\n const length = Math.sqrt(tangent.x * tangent.x + tangent.y * tangent.y + tangent.z * tangent.z);\r\n if (length > 0) {\r\n tangent.x /= length;\r\n tangent.y /= length;\r\n tangent.z /= length;\r\n }\r\n}\r\n\r\nexport function ConvertToRightHandedPosition(value: Vector3): Vector3 {\r\n value.x *= -1;\r\n return value;\r\n}\r\n\r\n/** @internal */\r\nexport function ConvertToRightHandedTransformMatrix(matrix: Matrix): Matrix {\r\n ConvertHandednessMatrix.invertToRef(TmpVectors.Matrix[0]).multiplyToRef(matrix, matrix).multiplyToRef(ConvertHandednessMatrix, matrix);\r\n return matrix;\r\n}\r\n\r\n/**\r\n * Converts, in-place, a left-handed quaternion to a right-handed quaternion via a change of basis.\r\n * @param value the unit quaternion to convert\r\n * @returns the converted quaternion\r\n */\r\nexport function ConvertToRightHandedRotation(value: Quaternion): Quaternion {\r\n /**\r\n * This is the simplified version of the following equation:\r\n * q' = to_quaternion(M * to_matrix(q) * M^-1)\r\n * where M is the conversion matrix `convertHandednessMatrix`,\r\n * q is the input quaternion, and q' is the converted quaternion.\r\n * Reference: https://d3cw3dd2w32x2b.cloudfront.net/wp-content/uploads/2015/01/matrix-to-quat.pdf\r\n */\r\n if (value.x * value.x + value.y * value.y > 0.5) {\r\n const absX = Math.abs(value.x);\r\n const absY = Math.abs(value.y);\r\n if (absX > absY) {\r\n const sign = Math.sign(value.x);\r\n value.x = absX;\r\n value.y *= -sign;\r\n value.z *= -sign;\r\n value.w *= sign;\r\n } else {\r\n const sign = Math.sign(value.y);\r\n value.x *= -sign;\r\n value.y = absY;\r\n value.z *= sign;\r\n value.w *= -sign;\r\n }\r\n } else {\r\n const absZ = Math.abs(value.z);\r\n const absW = Math.abs(value.w);\r\n if (absZ > absW) {\r\n const sign = Math.sign(value.z);\r\n value.x *= -sign;\r\n value.y *= sign;\r\n value.z = absZ;\r\n value.w *= -sign;\r\n } else {\r\n const sign = Math.sign(value.w);\r\n value.x *= sign;\r\n value.y *= -sign;\r\n value.z *= -sign;\r\n value.w = absW;\r\n }\r\n }\r\n\r\n return value;\r\n}\r\n\r\n/**\r\n * Pre-multiplies a 180-degree Y rotation to the quaternion, in order to match glTF's flipped forward direction for cameras.\r\n * @param rotation Target camera rotation.\r\n */\r\nexport function Rotate180Y(rotation: Quaternion): void {\r\n // Simplified from: rotation * (0, 1, 0, 0).\r\n rotation.copyFromFloats(-rotation.z, rotation.w, rotation.x, -rotation.y);\r\n}\r\n\r\n/**\r\n * Collapses GLTF parent and node into a single node, ignoring scaling.\r\n * This is useful for removing nodes that were added by the GLTF importer.\r\n * @param node Original GLTF node (Light or Camera).\r\n * @param parentNode Target parent node.\r\n */\r\nexport function CollapseChildIntoParent(node: INode, parentNode: INode): void {\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 parentMatrix = Matrix.ComposeToRef(DefaultScale, 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(DefaultScale, rotation, translation, TmpVectors.Matrix[1]);\r\n\r\n parentMatrix.multiplyToRef(matrix, matrix);\r\n matrix.decompose(undefined, parentRotation, parentTranslation);\r\n\r\n if (parentTranslation.equalsWithEpsilon(DefaultTranslation, Epsilon)) {\r\n delete parentNode.translation;\r\n } else {\r\n parentNode.translation = parentTranslation.asArray();\r\n }\r\n\r\n if (parentRotation.equalsWithEpsilon(DefaultRotation, Epsilon)) {\r\n delete parentNode.rotation;\r\n } else {\r\n parentNode.rotation = parentRotation.asArray();\r\n }\r\n\r\n if (parentNode.scale) {\r\n delete parentNode.scale;\r\n }\r\n}\r\n\r\n/**\r\n * Checks whether a camera or light node is candidate for collapsing with its parent node.\r\n * This is useful for roundtrips, as the glTF Importer parents a new node to\r\n * lights and cameras to store their original transformation information.\r\n * @param babylonNode Babylon light or camera node.\r\n * @param parentBabylonNode Target Babylon parent node.\r\n * @returns True if the two nodes can be merged, false otherwise.\r\n */\r\nexport function IsChildCollapsible(babylonNode: ShadowLight | TargetCamera | AreaLight, parentBabylonNode: Node): boolean {\r\n if (!(parentBabylonNode instanceof TransformNode)) {\r\n return false;\r\n }\r\n\r\n // Verify child is the only descendant\r\n const isOnlyDescendant = parentBabylonNode.getChildren().length === 1 && babylonNode.getChildren().length === 0 && babylonNode.parent === parentBabylonNode;\r\n if (!isOnlyDescendant) {\r\n return false;\r\n }\r\n\r\n // Verify parent has the expected scaling, determined by the node type and scene's coordinate system.\r\n const scene = babylonNode.getScene();\r\n const expectedScale = babylonNode instanceof TargetCamera && !scene.useRightHandedSystem ? DefaultLoaderCameraParentScaleLh : DefaultScale;\r\n\r\n if (!parentBabylonNode.scaling.equalsWithEpsilon(expectedScale, Epsilon)) {\r\n Logger.Warn(`Cannot collapse node ${babylonNode.name} into parent node ${parentBabylonNode.name} with modified scaling.`);\r\n return false;\r\n }\r\n\r\n return true;\r\n}\r\n\r\n/**\r\n * Converts an IndicesArray into either a Uint32Array or Uint16Array.\r\n * If the `start` and `count` parameters specify a subset of the array, a new view is created.\r\n * If the input is a number[], the data is copied into a new buffer.\r\n * @param indices input array to be converted\r\n * @param start starting index\r\n * @param count number of indices\r\n * @param is32Bits whether the output should be Uint32Array (true) or Uint16Array (false) when indices is an `Array`\r\n * @returns a Uint32Array or Uint16Array\r\n * @internal\r\n */\r\nexport function IndicesArrayToTypedSubarray(indices: IndicesArray, start: number, count: number, is32Bits: boolean): Uint32Array | Uint16Array {\r\n let processedIndices = indices;\r\n if (start !== 0 || count !== indices.length) {\r\n processedIndices = Array.isArray(indices) ? indices.slice(start, start + count) : indices.subarray(start, start + count);\r\n }\r\n\r\n // If Int32Array, cast the indices (which should all be positive) to Uint32Array\r\n if (processedIndices instanceof Int32Array) {\r\n return new Uint32Array(processedIndices.buffer, processedIndices.byteOffset, processedIndices.length);\r\n }\r\n\r\n if (Array.isArray(processedIndices)) {\r\n return is32Bits ? new Uint32Array(processedIndices) : new Uint16Array(processedIndices);\r\n }\r\n\r\n return processedIndices;\r\n}\r\n\r\nexport function DataArrayToUint8Array(data: DataArray): Uint8Array {\r\n if (data instanceof Array) {\r\n const floatData = new Float32Array(data);\r\n return new Uint8Array(floatData.buffer, floatData.byteOffset, floatData.byteLength);\r\n }\r\n\r\n return ArrayBuffer.isView(data) ? new Uint8Array(data.buffer, data.byteOffset, data.byteLength) : new Uint8Array(data);\r\n}\r\n\r\nexport function GetMinMax(data: DataArray, vertexBuffer: VertexBuffer, start: number, count: number): { min: number[]; max: number[] } {\r\n const { byteOffset, byteStride, type, normalized } = vertexBuffer;\r\n const size = vertexBuffer.getSize();\r\n const min = new Array<number>(size).fill(Infinity);\r\n const max = new Array<number>(size).fill(-Infinity);\r\n EnumerateFloatValues(data, byteOffset + start * byteStride, byteStride, size, type, count * size, normalized, (values) => {\r\n for (let i = 0; i < size; i++) {\r\n min[i] = Math.min(min[i], values[i]);\r\n max[i] = Math.max(max[i], values[i]);\r\n }\r\n });\r\n\r\n return { min, max };\r\n}\r\n\r\n/**\r\n * Removes, in-place, object properties which have the same value as the default value.\r\n * Useful for avoiding unnecessary properties in the glTF JSON.\r\n * @param object the object to omit default values from\r\n * @param defaultValues a partial object with default values\r\n * @returns object with default values omitted\r\n */\r\nexport function OmitDefaultValues<T extends object>(object: T, defaultValues: Partial<T>): T {\r\n for (const [key, value] of Object.entries(object)) {\r\n const defaultValue = defaultValues[key as keyof T];\r\n if ((Array.isArray(value) && Array.isArray(defaultValue) && AreArraysEqual(value, defaultValue)) || value === defaultValue) {\r\n delete object[key as keyof T];\r\n }\r\n }\r\n return object;\r\n}\r\n\r\n/**\r\n * Copies the sampling parameters (UV set, wrap modes and UV transform) used to reference a texture in glTF.\r\n * @param from The texture to copy the sampling parameters from\r\n * @param to The texture to copy the sampling parameters to\r\n */\r\nexport function CopyTextureSampling(from: BaseTexture, to: Texture): void {\r\n const source = from as Texture;\r\n to.coordinatesIndex = from.coordinatesIndex;\r\n to.wrapU = from.wrapU;\r\n to.wrapV = from.wrapV;\r\n to.uOffset = source.uOffset ?? 0;\r\n to.vOffset = source.vOffset ?? 0;\r\n to.uScale = source.uScale ?? 1;\r\n to.vScale = source.vScale ?? 1;\r\n to.uAng = source.uAng ?? 0;\r\n to.vAng = source.vAng ?? 0;\r\n to.wAng = source.wAng ?? 0;\r\n to.uRotationCenter = source.uRotationCenter ?? 0.5;\r\n to.vRotationCenter = source.vRotationCenter ?? 0.5;\r\n to.wRotationCenter = source.wRotationCenter ?? 0.5;\r\n to.homogeneousRotationInUVTransform = source.homogeneousRotationInUVTransform ?? false;\r\n}\r\n\r\n/**\r\n * Generate a key identifying a texture's image data together with its sampling state (UV set, wrap modes and\r\n * UV transform). A merge with shared sampling copies or bakes this state, so its result can only be reused for\r\n * inputs that are sampled identically.\r\n * @param texture The texture to generate a key for\r\n * @param missing The key to use when there is no texture\r\n * @returns A key for the texture and its sampling state\r\n */\r\nexport function GetSampledTextureKey(texture: Nullable<BaseTexture>, missing: string): string {\r\n const internalTexture = texture?.getInternalTexture();\r\n if (!texture || !internalTexture) {\r\n return missing;\r\n }\r\n return `${internalTexture.uniqueId}:${texture.coordinatesIndex}:${texture.wrapU}:${texture.wrapV}:${texture.getTextureMatrix().asArray().join(\",\")}`;\r\n}\r\n\r\n/**\r\n * Lower bound on transmission color channels before taking -log(), matching the renderer's `Epsilon`\r\n * (openpbrVolumeFunctions) and the glTF loader, so a zero channel maps to a finite extinction.\r\n */\r\nexport const MinTransmissionColor = 1e-7;\r\n\r\n/**\r\n * Computes the KHR_materials_volume attenuation exported for a volumetric OpenPBR material, blending the\r\n * transmission and subsurface slabs. The transmission extinction is the renderer's: absorption is shifted to be\r\n * non-negative using the (untextured) transmission scatter factor, since glTF attenuation can't be textured.\r\n * @param material The OpenPBR material\r\n * @param transmissionVolume Whether the transmission slab contributes a volume\r\n * @param subsurfaceVolume Whether the subsurface slab contributes a volume\r\n * @returns The exported attenuation color and distance\r\n */\r\nexport function GetOpenPBRVolumeAttenuation(\r\n material: OpenPBRMaterial,\r\n transmissionVolume: boolean,\r\n subsurfaceVolume: boolean\r\n): { attenuationColor: number[]; attenuationDistance: number } {\r\n let transmissionAttenuationDistance;\r\n const transmissionAttenuationColor = [1, 1, 1];\r\n if (transmissionVolume && material.transmissionDepth > 0) {\r\n const invDepth = 1.0 / material.transmissionDepth;\r\n let transmissionExtinctionCoefficient = new Vector3(\r\n -Math.log(Math.max(material.transmissionColor.r, MinTransmissionColor)) * invDepth,\r\n -Math.log(Math.max(material.transmissionColor.g, MinTransmissionColor)) * invDepth,\r\n -Math.log(Math.max(material.transmissionColor.b, MinTransmissionColor)) * invDepth\r\n );\r\n const transmissionScatteringCoefficient = new Vector3(\r\n material.transmissionScatter.r * invDepth,\r\n material.transmissionScatter.g * invDepth,\r\n material.transmissionScatter.b * invDepth\r\n );\r\n const transmissionAbsorptionCoefficient = transmissionExtinctionCoefficient.subtract(transmissionScatteringCoefficient);\r\n const minCoeff = Math.min(transmissionAbsorptionCoefficient.x, transmissionAbsorptionCoefficient.y, transmissionAbsorptionCoefficient.z);\r\n if (minCoeff < 0) {\r\n transmissionAbsorptionCoefficient.x = transmissionAbsorptionCoefficient.x - minCoeff;\r\n transmissionAbsorptionCoefficient.y = transmissionAbsorptionCoefficient.y - minCoeff;\r\n transmissionAbsorptionCoefficient.z = transmissionAbsorptionCoefficient.z - minCoeff;\r\n }\r\n transmissionExtinctionCoefficient = transmissionAbsorptionCoefficient.add(transmissionScatteringCoefficient);\r\n const maxCoeff = Math.max(transmissionExtinctionCoefficient.x, transmissionExtinctionCoefficient.y, transmissionExtinctionCoefficient.z);\r\n transmissionAttenuationDistance = 1.0 / maxCoeff;\r\n transmissionAttenuationColor[0] = Math.exp(-transmissionExtinctionCoefficient.x * transmissionAttenuationDistance);\r\n transmissionAttenuationColor[1] = Math.exp(-transmissionExtinctionCoefficient.y * transmissionAttenuationDistance);\r\n transmissionAttenuationColor[2] = Math.exp(-transmissionExtinctionCoefficient.z * transmissionAttenuationDistance);\r\n } else {\r\n // transmissionDepth == 0\r\n transmissionAttenuationDistance = Number.MAX_VALUE;\r\n }\r\n let subsurfaceAttenuationDistance = 1;\r\n const subsurfaceAttenuationColor = [1, 1, 1];\r\n if (subsurfaceVolume) {\r\n const r = material.subsurfaceRadius;\r\n const radiusScale = material.subsurfaceRadiusScale;\r\n const mfp = new Vector3(radiusScale.r, radiusScale.g, radiusScale.b).multiplyByFloats(r, r, r);\r\n const extinctionCoeff = new Vector3(1.0 / Math.max(mfp.x, 1e-6), 1.0 / Math.max(mfp.y, 1e-6), 1.0 / Math.max(mfp.z, 1e-6));\r\n const maxCoeff = Math.max(extinctionCoeff.x, extinctionCoeff.y, extinctionCoeff.z);\r\n subsurfaceAttenuationDistance = 1.0 / maxCoeff;\r\n subsurfaceAttenuationColor[0] = Math.exp(-extinctionCoeff.x * subsurfaceAttenuationDistance);\r\n subsurfaceAttenuationColor[1] = Math.exp(-extinctionCoeff.y * subsurfaceAttenuationDistance);\r\n subsurfaceAttenuationColor[2] = Math.exp(-extinctionCoeff.z * subsurfaceAttenuationDistance);\r\n }\r\n\r\n const subsurfaceFractionOfDielectric = (1.0 - material.transmissionWeight) * material.subsurfaceWeight;\r\n const subsurfaceAndTransmissionFractionOfDielectric = subsurfaceFractionOfDielectric + material.transmissionWeight;\r\n const reciprocalOfSubsurfaceAndTransmissionFractionOfDielectric = 1.0 / Math.max(subsurfaceAndTransmissionFractionOfDielectric, 1e-6);\r\n const transWeight = material.transmissionWeight * reciprocalOfSubsurfaceAndTransmissionFractionOfDielectric;\r\n const subsurfWeight = subsurfaceFractionOfDielectric * reciprocalOfSubsurfaceAndTransmissionFractionOfDielectric;\r\n\r\n return {\r\n attenuationColor: transmissionAttenuationColor.map((c, i) => c * transWeight + subsurfaceAttenuationColor[i] * subsurfWeight),\r\n attenuationDistance: transmissionAttenuationDistance * transWeight + subsurfaceAttenuationDistance * subsurfWeight,\r\n };\r\n}\r\n\r\nfunction AreArraysEqual(array1: unknown[], array2: unknown[]): boolean {\r\n return array1.length === array2.length && array1.every((val, i) => val === array2[i]);\r\n}\r\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onerjs/serializers",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.3",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"module": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"postcompile": "build-tools -c add-js-to-es6"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@onerjs/core": "9.0.
|
|
21
|
+
"@onerjs/core": "9.0.3",
|
|
22
22
|
"@dev/build-tools": "^1.0.0",
|
|
23
23
|
"@dev/serializers": "^1.0.0",
|
|
24
24
|
"babylonjs-gltf2interface": "^9.32.0"
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Re-exports the pure implementation and applies the runtime registration side effect.
|
|
3
|
-
* Import "./KHR_materials_volume_scatter.pure" for tree-shakeable, side-effect-free usage.
|
|
4
|
-
*/
|
|
5
|
-
export * from "./KHR_materials_volume_scatter.pure.js";
|
|
6
|
-
import { RegisterKHR_materials_volume_scatter } from "./KHR_materials_volume_scatter.pure.js";
|
|
7
|
-
RegisterKHR_materials_volume_scatter();
|
|
8
|
-
//# sourceMappingURL=KHR_materials_volume_scatter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"KHR_materials_volume_scatter.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_volume_scatter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,qCAAqC,CAAC;AAEpD,OAAO,EAAE,oCAAoC,EAAE,MAAM,qCAAqC,CAAC;AAC3F,oCAAoC,EAAE,CAAC","sourcesContent":["/**\r\n * Re-exports the pure implementation and applies the runtime registration side effect.\r\n * Import \"./KHR_materials_volume_scatter.pure\" for tree-shakeable, side-effect-free usage.\r\n */\r\nexport * from \"./KHR_materials_volume_scatter.pure\";\r\n\r\nimport { RegisterKHR_materials_volume_scatter } from \"./KHR_materials_volume_scatter.pure\";\r\nRegisterKHR_materials_volume_scatter();\r\n"]}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { type IMaterial } from "babylonjs-gltf2interface";
|
|
2
|
-
import { type IGLTFExporterExtensionV2 } from "../glTFExporterExtension.js";
|
|
3
|
-
import { GLTFExporter } from "../glTFExporter.js";
|
|
4
|
-
import { type Material } from "@onerjs/core/Materials/material.js";
|
|
5
|
-
import { type BaseTexture } from "@onerjs/core/Materials/Textures/baseTexture.js";
|
|
6
|
-
/**
|
|
7
|
-
* TODO: In-progress specification
|
|
8
|
-
* [Specification](https://github.com/KhronosGroup/glTF/blob/7ea427ed55d44427e83c0a6d1c87068b1a4151c5/extensions/2.0/Khronos/KHR_materials_volume_scatter/README.md)
|
|
9
|
-
*/
|
|
10
|
-
export declare class KHR_materials_volume_scatter implements IGLTFExporterExtensionV2 {
|
|
11
|
-
/** Name of this extension */
|
|
12
|
-
readonly name = "KHR_materials_volume_scatter";
|
|
13
|
-
/** Defines whether this extension is enabled */
|
|
14
|
-
enabled: boolean;
|
|
15
|
-
/** Defines whether this extension is required */
|
|
16
|
-
required: boolean;
|
|
17
|
-
private _exporter;
|
|
18
|
-
private _wasUsed;
|
|
19
|
-
constructor(exporter: GLTFExporter);
|
|
20
|
-
dispose(): void;
|
|
21
|
-
/** @internal */
|
|
22
|
-
get wasUsed(): boolean;
|
|
23
|
-
/**
|
|
24
|
-
* After exporting a material, deal with additional textures
|
|
25
|
-
* @param context GLTF context of the material
|
|
26
|
-
* @param node exported GLTF node
|
|
27
|
-
* @param babylonMaterial corresponding babylon material
|
|
28
|
-
* @returns array of additional textures to export
|
|
29
|
-
*/
|
|
30
|
-
postExportMaterialAdditionalTexturesAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<BaseTexture[]>;
|
|
31
|
-
private _isExtensionEnabled;
|
|
32
|
-
/**
|
|
33
|
-
* After exporting a material
|
|
34
|
-
* @param context GLTF context of the material
|
|
35
|
-
* @param node exported GLTF node
|
|
36
|
-
* @param babylonMaterial corresponding babylon material
|
|
37
|
-
* @returns promise that resolves with the updated node
|
|
38
|
-
*/
|
|
39
|
-
postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Registers the KHR_materials_volume_scatter glTF serializer extension with the {@link GLTFExporter}.
|
|
43
|
-
* Safe to call multiple times; only the first call has an effect.
|
|
44
|
-
*/
|
|
45
|
-
export declare function RegisterKHR_materials_volume_scatter(): void;
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import { GLTFExporter } from "../glTFExporter.js";
|
|
2
|
-
import { OpenPBRMaterial } from "@onerjs/core/Materials/PBR/openpbrMaterial.pure.js";
|
|
3
|
-
import { Color3 } from "@onerjs/core/Maths/math.color.pure.js";
|
|
4
|
-
import { Vector3 } from "@onerjs/core/Maths/math.vector.pure.js";
|
|
5
|
-
const NAME = "KHR_materials_volume_scatter";
|
|
6
|
-
function SingleScatterToMultiScatterAlbedo(singleScatter) {
|
|
7
|
-
const s = new Vector3(Math.sqrt(1.0 - singleScatter.x), Math.sqrt(1.0 - singleScatter.y), Math.sqrt(1.0 - singleScatter.z));
|
|
8
|
-
const ones = new Vector3(1.0, 1.0, 1.0);
|
|
9
|
-
const t = ones.subtract(s);
|
|
10
|
-
const p = ones.subtract(new Vector3(0.139, 0.139, 0.139).multiplyInPlace(s));
|
|
11
|
-
const k = ones.add(new Vector3(1.17, 1.17, 1.17).multiplyInPlace(s));
|
|
12
|
-
return t.multiplyInPlace(p).divideInPlace(k);
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* TODO: In-progress specification
|
|
16
|
-
* [Specification](https://github.com/KhronosGroup/glTF/blob/7ea427ed55d44427e83c0a6d1c87068b1a4151c5/extensions/2.0/Khronos/KHR_materials_volume_scatter/README.md)
|
|
17
|
-
*/
|
|
18
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
19
|
-
export class KHR_materials_volume_scatter {
|
|
20
|
-
constructor(exporter) {
|
|
21
|
-
/** Name of this extension */
|
|
22
|
-
this.name = NAME;
|
|
23
|
-
/** Defines whether this extension is enabled */
|
|
24
|
-
this.enabled = true;
|
|
25
|
-
/** Defines whether this extension is required */
|
|
26
|
-
this.required = false;
|
|
27
|
-
this._wasUsed = false;
|
|
28
|
-
this._exporter = exporter;
|
|
29
|
-
}
|
|
30
|
-
dispose() { }
|
|
31
|
-
/** @internal */
|
|
32
|
-
get wasUsed() {
|
|
33
|
-
return this._wasUsed;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* After exporting a material, deal with additional textures
|
|
37
|
-
* @param context GLTF context of the material
|
|
38
|
-
* @param node exported GLTF node
|
|
39
|
-
* @param babylonMaterial corresponding babylon material
|
|
40
|
-
* @returns array of additional textures to export
|
|
41
|
-
*/
|
|
42
|
-
async postExportMaterialAdditionalTexturesAsync(context, node, babylonMaterial) {
|
|
43
|
-
const additionalTextures = [];
|
|
44
|
-
if (babylonMaterial instanceof OpenPBRMaterial) {
|
|
45
|
-
if (babylonMaterial.transmissionWeight > 0) {
|
|
46
|
-
if (babylonMaterial.transmissionScatterTexture) {
|
|
47
|
-
additionalTextures.push(babylonMaterial.transmissionScatterTexture);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
if (babylonMaterial.subsurfaceWeight > 0) {
|
|
51
|
-
if (babylonMaterial.subsurfaceColorTexture) {
|
|
52
|
-
additionalTextures.push(babylonMaterial.subsurfaceColorTexture);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return additionalTextures;
|
|
57
|
-
}
|
|
58
|
-
_isExtensionEnabled(mat) {
|
|
59
|
-
// This extension must not be used on a material that also uses KHR_materials_unlit
|
|
60
|
-
if (mat.unlit) {
|
|
61
|
-
return false;
|
|
62
|
-
}
|
|
63
|
-
const transmissionVolume = mat.transmissionWeight > 0 && !mat.geometryThinWalled && mat.transmissionDepth > 0;
|
|
64
|
-
const transmissionScatter = transmissionVolume && !mat.transmissionScatter.equals(Color3.Black());
|
|
65
|
-
const subsurfaceVolume = mat.subsurfaceWeight > 0 && !mat.geometryThinWalled;
|
|
66
|
-
if (transmissionScatter || subsurfaceVolume) {
|
|
67
|
-
return true;
|
|
68
|
-
}
|
|
69
|
-
return false;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* After exporting a material
|
|
73
|
-
* @param context GLTF context of the material
|
|
74
|
-
* @param node exported GLTF node
|
|
75
|
-
* @param babylonMaterial corresponding babylon material
|
|
76
|
-
* @returns promise that resolves with the updated node
|
|
77
|
-
*/
|
|
78
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
79
|
-
postExportMaterialAsync(context, node, babylonMaterial) {
|
|
80
|
-
return new Promise((resolve) => {
|
|
81
|
-
if (babylonMaterial instanceof OpenPBRMaterial && this._isExtensionEnabled(babylonMaterial)) {
|
|
82
|
-
this._wasUsed = true;
|
|
83
|
-
// If both transmission and subsurface volumes exist, combine them.
|
|
84
|
-
let transmissionMultiscatterColor = Vector3.Zero();
|
|
85
|
-
let transmissionScatterAnisotropy = 0;
|
|
86
|
-
if (babylonMaterial.transmissionWeight > 0) {
|
|
87
|
-
// In OpenPBR 1.2, the transmission_scatter_color represents the single scatter albedo.
|
|
88
|
-
const ssAlbedo = new Vector3(babylonMaterial.transmissionScatter.r, babylonMaterial.transmissionScatter.g, babylonMaterial.transmissionScatter.b);
|
|
89
|
-
transmissionMultiscatterColor = SingleScatterToMultiScatterAlbedo(ssAlbedo);
|
|
90
|
-
transmissionScatterAnisotropy = babylonMaterial.transmissionScatterAnisotropy;
|
|
91
|
-
}
|
|
92
|
-
const subsurfaceMultiscatterColor = Vector3.Zero();
|
|
93
|
-
let subsurfaceScatterAnisotropy = 0;
|
|
94
|
-
if (babylonMaterial.subsurfaceWeight > 0) {
|
|
95
|
-
subsurfaceMultiscatterColor.set(babylonMaterial.subsurfaceColor.r, babylonMaterial.subsurfaceColor.g, babylonMaterial.subsurfaceColor.b);
|
|
96
|
-
subsurfaceScatterAnisotropy = babylonMaterial.subsurfaceScatterAnisotropy;
|
|
97
|
-
}
|
|
98
|
-
const subsurfaceFractionOfDielectric = (1.0 - babylonMaterial.transmissionWeight) * babylonMaterial.subsurfaceWeight;
|
|
99
|
-
const subsurfaceAndTransmissionFractionOfDielectric = subsurfaceFractionOfDielectric + babylonMaterial.transmissionWeight;
|
|
100
|
-
const reciprocalOfSubsurfaceAndTransmissionFractionOfDielectric = 1.0 / Math.max(subsurfaceAndTransmissionFractionOfDielectric, 1e-6);
|
|
101
|
-
const transWeight = babylonMaterial.transmissionWeight * reciprocalOfSubsurfaceAndTransmissionFractionOfDielectric;
|
|
102
|
-
const subsurfWeight = subsurfaceFractionOfDielectric * reciprocalOfSubsurfaceAndTransmissionFractionOfDielectric;
|
|
103
|
-
const multiscatterColor = transmissionMultiscatterColor
|
|
104
|
-
.multiplyByFloats(transWeight, transWeight, transWeight)
|
|
105
|
-
.addInPlace(subsurfaceMultiscatterColor.multiplyByFloats(subsurfWeight, subsurfWeight, subsurfWeight));
|
|
106
|
-
const volumeInfo = {
|
|
107
|
-
multiscatterColorFactor: multiscatterColor.asArray(),
|
|
108
|
-
scatterAnisotropy: transmissionScatterAnisotropy * transWeight + subsurfaceScatterAnisotropy * subsurfWeight,
|
|
109
|
-
};
|
|
110
|
-
if (babylonMaterial.subsurfaceWeight > 0 && babylonMaterial.subsurfaceColorTexture) {
|
|
111
|
-
this._exporter._materialNeedsUVsSet.add(babylonMaterial);
|
|
112
|
-
const subsurfaceScatterTexture = this._exporter._materialExporter.getTextureInfo(babylonMaterial.subsurfaceColorTexture);
|
|
113
|
-
if (subsurfaceScatterTexture) {
|
|
114
|
-
volumeInfo.multiscatterColorTexture = subsurfaceScatterTexture;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
else if (babylonMaterial.transmissionWeight > 0 && babylonMaterial.transmissionScatterTexture) {
|
|
118
|
-
this._exporter._materialNeedsUVsSet.add(babylonMaterial);
|
|
119
|
-
// TODO - the transmission_scatter texture represents the single scatter albedo, not the multiscatter color. Convert it before exporting.
|
|
120
|
-
const transmissionTexture = this._exporter._materialExporter.getTextureInfo(babylonMaterial.transmissionScatterTexture);
|
|
121
|
-
if (transmissionTexture) {
|
|
122
|
-
volumeInfo.multiscatterColorTexture = transmissionTexture;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
node.extensions = node.extensions || {};
|
|
126
|
-
node.extensions[NAME] = volumeInfo;
|
|
127
|
-
}
|
|
128
|
-
resolve(node);
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
let _Registered = false;
|
|
133
|
-
/**
|
|
134
|
-
* Registers the KHR_materials_volume_scatter glTF serializer extension with the {@link GLTFExporter}.
|
|
135
|
-
* Safe to call multiple times; only the first call has an effect.
|
|
136
|
-
*/
|
|
137
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
138
|
-
export function RegisterKHR_materials_volume_scatter() {
|
|
139
|
-
if (_Registered) {
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
_Registered = true;
|
|
143
|
-
GLTFExporter.RegisterExtension(NAME, (exporter) => new KHR_materials_volume_scatter(exporter), 101);
|
|
144
|
-
}
|
|
145
|
-
//# sourceMappingURL=KHR_materials_volume_scatter.pure.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"KHR_materials_volume_scatter.pure.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_volume_scatter.pure.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAE1E,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAEtD,MAAM,IAAI,GAAG,8BAA8B,CAAC;AAE5C,SAAS,iCAAiC,CAAC,aAAsB;IAC7D,MAAM,CAAC,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,aAAa,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,aAAa,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5H,MAAM,IAAI,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IACxC,MAAM,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC3B,MAAM,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7E,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,C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terialsVolumeScatter } from \"babylonjs-gltf2interface\";\r\nimport { type IGLTFExporterExtensionV2 } from \"../glTFExporterExtension\";\r\nimport { GLTFExporter } from \"../glTFExporter\";\r\nimport { type Material } from \"core/Materials/material\";\r\nimport { OpenPBRMaterial } from \"core/Materials/PBR/openpbrMaterial.pure\";\r\nimport { type BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport { Color3 } from \"core/Maths/math.color.pure\";\r\nimport { Vector3 } from \"core/Maths/math.vector.pure\";\r\n\r\nconst NAME = \"KHR_materials_volume_scatter\";\r\n\r\nfunction SingleScatterToMultiScatterAlbedo(singleScatter: Vector3): Vector3 {\r\n const s = new Vector3(Math.sqrt(1.0 - singleScatter.x), Math.sqrt(1.0 - singleScatter.y), Math.sqrt(1.0 - singleScatter.z));\r\n const ones = new Vector3(1.0, 1.0, 1.0);\r\n const t = ones.subtract(s);\r\n const p = ones.subtract(new Vector3(0.139, 0.139, 0.139).multiplyInPlace(s));\r\n const k = ones.add(new Vector3(1.17, 1.17, 1.17).multiplyInPlace(s));\r\n\r\n return t.multiplyInPlace(p).divideInPlace(k);\r\n}\r\n\r\n/**\r\n * TODO: In-progress specification\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/7ea427ed55d44427e83c0a6d1c87068b1a4151c5/extensions/2.0/Khronos/KHR_materials_volume_scatter/README.md)\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_materials_volume_scatter 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: GLTFExporter;\r\n\r\n private _wasUsed = false;\r\n\r\n constructor(exporter: GLTFExporter) {\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 async postExportMaterialAdditionalTexturesAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<BaseTexture[]> {\r\n const additionalTextures: BaseTexture[] = [];\r\n\r\n if (babylonMaterial instanceof OpenPBRMaterial) {\r\n if (babylonMaterial.transmissionWeight > 0) {\r\n if (babylonMaterial.transmissionScatterTexture) {\r\n additionalTextures.push(babylonMaterial.transmissionScatterTexture);\r\n }\r\n }\r\n if (babylonMaterial.subsurfaceWeight > 0) {\r\n if (babylonMaterial.subsurfaceColorTexture) {\r\n additionalTextures.push(babylonMaterial.subsurfaceColorTexture);\r\n }\r\n }\r\n }\r\n\r\n return additionalTextures;\r\n }\r\n\r\n private _isExtensionEnabled(mat: OpenPBRMaterial): 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 transmissionVolume = mat.transmissionWeight > 0 && !mat.geometryThinWalled && mat.transmissionDepth > 0;\r\n const transmissionScatter = transmissionVolume && !mat.transmissionScatter.equals(Color3.Black());\r\n const subsurfaceVolume = mat.subsurfaceWeight > 0 && !mat.geometryThinWalled;\r\n if (transmissionScatter || subsurfaceVolume) {\r\n return true;\r\n }\r\n return false;\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 // eslint-disable-next-line no-restricted-syntax\r\n public postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial> {\r\n return new Promise((resolve) => {\r\n if (babylonMaterial instanceof OpenPBRMaterial && this._isExtensionEnabled(babylonMaterial)) {\r\n this._wasUsed = true;\r\n\r\n // If both transmission and subsurface volumes exist, combine them.\r\n let transmissionMultiscatterColor = Vector3.Zero();\r\n let transmissionScatterAnisotropy = 0;\r\n if (babylonMaterial.transmissionWeight > 0) {\r\n // In OpenPBR 1.2, the transmission_scatter_color represents the single scatter albedo.\r\n const ssAlbedo = new Vector3(babylonMaterial.transmissionScatter.r, babylonMaterial.transmissionScatter.g, babylonMaterial.transmissionScatter.b);\r\n transmissionMultiscatterColor = SingleScatterToMultiScatterAlbedo(ssAlbedo);\r\n transmissionScatterAnisotropy = babylonMaterial.transmissionScatterAnisotropy;\r\n }\r\n\r\n const subsurfaceMultiscatterColor = Vector3.Zero();\r\n let subsurfaceScatterAnisotropy = 0;\r\n if (babylonMaterial.subsurfaceWeight > 0) {\r\n subsurfaceMultiscatterColor.set(babylonMaterial.subsurfaceColor.r, babylonMaterial.subsurfaceColor.g, babylonMaterial.subsurfaceColor.b);\r\n subsurfaceScatterAnisotropy = babylonMaterial.subsurfaceScatterAnisotropy;\r\n }\r\n\r\n const subsurfaceFractionOfDielectric = (1.0 - babylonMaterial.transmissionWeight) * babylonMaterial.subsurfaceWeight;\r\n const subsurfaceAndTransmissionFractionOfDielectric = subsurfaceFractionOfDielectric + babylonMaterial.transmissionWeight;\r\n const reciprocalOfSubsurfaceAndTransmissionFractionOfDielectric = 1.0 / Math.max(subsurfaceAndTransmissionFractionOfDielectric, 1e-6);\r\n const transWeight = babylonMaterial.transmissionWeight * reciprocalOfSubsurfaceAndTransmissionFractionOfDielectric;\r\n const subsurfWeight = subsurfaceFractionOfDielectric * reciprocalOfSubsurfaceAndTransmissionFractionOfDielectric;\r\n\r\n const multiscatterColor = transmissionMultiscatterColor\r\n .multiplyByFloats(transWeight, transWeight, transWeight)\r\n .addInPlace(subsurfaceMultiscatterColor.multiplyByFloats(subsurfWeight, subsurfWeight, subsurfWeight));\r\n\r\n const volumeInfo: IKHRMaterialsVolumeScatter = {\r\n multiscatterColorFactor: multiscatterColor.asArray(),\r\n scatterAnisotropy: transmissionScatterAnisotropy * transWeight + subsurfaceScatterAnisotropy * subsurfWeight,\r\n };\r\n\r\n if (babylonMaterial.subsurfaceWeight > 0 && babylonMaterial.subsurfaceColorTexture) {\r\n this._exporter._materialNeedsUVsSet.add(babylonMaterial);\r\n const subsurfaceScatterTexture = this._exporter._materialExporter.getTextureInfo(babylonMaterial.subsurfaceColorTexture);\r\n if (subsurfaceScatterTexture) {\r\n volumeInfo.multiscatterColorTexture = subsurfaceScatterTexture;\r\n }\r\n } else if (babylonMaterial.transmissionWeight > 0 && babylonMaterial.transmissionScatterTexture) {\r\n this._exporter._materialNeedsUVsSet.add(babylonMaterial);\r\n // TODO - the transmission_scatter texture represents the single scatter albedo, not the multiscatter color. Convert it before exporting.\r\n const transmissionTexture = this._exporter._materialExporter.getTextureInfo(babylonMaterial.transmissionScatterTexture);\r\n if (transmissionTexture) {\r\n volumeInfo.multiscatterColorTexture = transmissionTexture;\r\n }\r\n }\r\n\r\n node.extensions = node.extensions || {};\r\n node.extensions[NAME] = volumeInfo;\r\n }\r\n resolve(node);\r\n });\r\n }\r\n}\r\n\r\nlet _Registered = false;\r\n/**\r\n * Registers the KHR_materials_volume_scatter glTF serializer extension with the {@link GLTFExporter}.\r\n * Safe to call multiple times; only the first call has an effect.\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function RegisterKHR_materials_volume_scatter(): void {\r\n if (_Registered) {\r\n return;\r\n }\r\n _Registered = true;\r\n\r\n GLTFExporter.RegisterExtension(NAME, (exporter) => new KHR_materials_volume_scatter(exporter), 101);\r\n}\r\n"]}
|