@babylonjs/serializers 5.0.0-beta.2 → 5.0.0-beta.6
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_lights_punctual.js +2 -2
- package/glTF/2.0/Extensions/KHR_lights_punctual.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.js +2 -2
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_texture_transform.js +3 -3
- package/glTF/2.0/Extensions/KHR_texture_transform.js.map +1 -1
- package/glTF/2.0/glTFAnimation.js +11 -11
- package/glTF/2.0/glTFAnimation.js.map +1 -1
- package/glTF/2.0/glTFExporter.d.ts +6 -1
- package/glTF/2.0/glTFExporter.js +69 -11
- package/glTF/2.0/glTFExporter.js.map +1 -1
- package/glTF/2.0/glTFMaterialExporter.js +4 -4
- package/glTF/2.0/glTFMaterialExporter.js.map +1 -1
- package/package.json +3 -3
|
@@ -53,7 +53,7 @@ var KHR_lights_punctual = /** @class */ (function () {
|
|
|
53
53
|
var light = void 0;
|
|
54
54
|
var lightType = (babylonLight.getTypeID() == Light.LIGHTTYPEID_POINTLIGHT ? "point" /* POINT */ : (babylonLight.getTypeID() == Light.LIGHTTYPEID_DIRECTIONALLIGHT ? "directional" /* DIRECTIONAL */ : (babylonLight.getTypeID() == Light.LIGHTTYPEID_SPOTLIGHT ? "spot" /* SPOT */ : null)));
|
|
55
55
|
if (lightType == null) {
|
|
56
|
-
Logger.Warn(context
|
|
56
|
+
Logger.Warn("".concat(context, ": Light ").concat(babylonLight.name, " is not supported in ").concat(NAME));
|
|
57
57
|
}
|
|
58
58
|
else {
|
|
59
59
|
var lightPosition = babylonLight.position.clone();
|
|
@@ -78,7 +78,7 @@ var KHR_lights_punctual = /** @class */ (function () {
|
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
if (babylonLight.falloffType !== Light.FALLOFF_GLTF) {
|
|
81
|
-
Logger.Warn(context
|
|
81
|
+
Logger.Warn("".concat(context, ": Light falloff for ").concat(babylonLight.name, " does not match the ").concat(NAME, " specification!"));
|
|
82
82
|
}
|
|
83
83
|
light = {
|
|
84
84
|
type: lightType
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KHR_lights_punctual.js","sourceRoot":"","sources":["../../../../../sourceES6/serializers/src/glTF/2.0/Extensions/KHR_lights_punctual.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAC5F,OAAO,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAC1D,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAE3E,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAGjE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD,IAAM,IAAI,GAAG,qBAAqB,CAAC;AAEnC;;GAEG;AACH;IAeI,cAAc;IACd,6BAAY,QAAmB;QAf/B,kCAAkC;QAClB,SAAI,GAAG,IAAI,CAAC;QAE5B,iDAAiD;QAC1C,YAAO,GAAG,IAAI,CAAC;QAEtB,iDAAiD;QAC1C,aAAQ,GAAG,KAAK,CAAC;QASpB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC9B,CAAC;IAED,cAAc;IACP,qCAAO,GAAd;QACK,IAAI,CAAC,OAAe,GAAG,IAAI,CAAC;IACjC,CAAC;IAGD,sBAAW,wCAAO;QADlB,cAAc;aACd;YACI,OAAO,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC;QAC1B,CAAC;;;OAAA;IAED,cAA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BAED,IAAI,IAAI,CAAC,UAAU,IAAI,IAAI,EAAE;wBACzB,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;qBACxB;oBAED,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC;iBAC1C;aACJ;YACD,OAAO,CAAC,IAAI,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACP,CAAC;IACL,0BAAC;AAAD,CAAC,AAvLD,IAuLC;;AAED,SAAS,CAAC,iBAAiB,CAAC,IAAI,EAAE,UAAC,QAAQ,IAAK,OAAA,IAAI,mBAAmB,CAAC,QAAQ,CAAC,EAAjC,CAAiC,CAAC,CAAC","sourcesContent":["import { SpotLight } from \"@babylonjs/core/Lights/spotLight\";\nimport { Nullable } from \"@babylonjs/core/types\";\nimport { Vector3, Quaternion, TmpVectors, Matrix } from \"@babylonjs/core/Maths/math.vector\";\nimport { Color3 } from \"@babylonjs/core/Maths/math.color\";\nimport { Light } from \"@babylonjs/core/Lights/light\";\nimport { DirectionalLight } from \"@babylonjs/core/Lights/directionalLight\";\nimport { Node } from \"@babylonjs/core/node\";\nimport { ShadowLight } from \"@babylonjs/core/Lights/shadowLight\";\nimport { INode } from \"babylonjs-gltf2interface\";\nimport { IGLTFExporterExtensionV2 } from \"../glTFExporterExtension\";\nimport { _Exporter } from \"../glTFExporter\";\nimport { Logger } from \"@babylonjs/core/Misc/logger\";\nimport { _GLTFUtilities } from \"../glTFUtilities\";\nimport { IKHRLightsPunctual_LightType, IKHRLightsPunctual_LightReference, IKHRLightsPunctual_Light, IKHRLightsPunctual } from \"babylonjs-gltf2interface\";\n\nconst NAME = \"KHR_lights_punctual\";\n\n/**\n * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)\n */\nexport class KHR_lights_punctual implements IGLTFExporterExtensionV2 {\n /** The name of this extension. */\n public readonly name = NAME;\n\n /** Defines whether this extension is enabled. */\n public enabled = true;\n\n /** Defines whether this extension is required */\n public required = false;\n\n /** Reference to the glTF exporter */\n private _exporter: _Exporter;\n\n private _lights: IKHRLightsPunctual;\n\n /** @hidden */\n constructor(exporter: _Exporter) {\n this._exporter = exporter;\n }\n\n /** @hidden */\n public dispose() {\n (this._lights as any) = null;\n }\n\n /** @hidden */\n public get wasUsed() {\n return !!this._lights;\n }\n\n /** @hidden */\n public onExporting(): void {\n this._exporter!._glTF.extensions![NAME] = this._lights;\n }\n /**\n * Define this method to modify the default behavior when exporting a node\n * @param context The context when exporting the node\n * @param node glTF node\n * @param babylonNode BabylonJS node\n * @param nodeMap Node mapping of unique id to glTF node index\n * @returns nullable INode promise\n */\n public postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: { [key: number]: number }): Promise<Nullable<INode>> {\n return new Promise((resolve, reject) => {\n if (node && babylonNode instanceof ShadowLight) {\n const babylonLight: ShadowLight = babylonNode;\n let light: IKHRLightsPunctual_Light;\n\n const lightType = (\n babylonLight.getTypeID() == Light.LIGHTTYPEID_POINTLIGHT ? IKHRLightsPunctual_LightType.POINT : (\n babylonLight.getTypeID() == Light.LIGHTTYPEID_DIRECTIONALLIGHT ? IKHRLightsPunctual_LightType.DIRECTIONAL : (\n babylonLight.getTypeID() == Light.LIGHTTYPEID_SPOTLIGHT ? IKHRLightsPunctual_LightType.SPOT : null\n )));\n if (lightType == null) {\n Logger.Warn(`${context}: Light ${babylonLight.name} is not supported in ${NAME}`);\n }\n else {\n const lightPosition = babylonLight.position.clone();\n let convertToRightHandedSystem = this._exporter._convertToRightHandedSystemMap[babylonNode.uniqueId];\n if (!lightPosition.equals(Vector3.Zero())) {\n if (convertToRightHandedSystem) {\n _GLTFUtilities._GetRightHandedPositionVector3FromRef(lightPosition);\n }\n node.translation = lightPosition.asArray();\n }\n if (lightType !== IKHRLightsPunctual_LightType.POINT) {\n const localAxis = babylonLight.direction;\n const yaw = -Math.atan2(localAxis.z * (this._exporter._babylonScene.useRightHandedSystem ? -1 : 1), localAxis.x) + Math.PI / 2;\n const len = Math.sqrt(localAxis.x * localAxis.x + localAxis.z * localAxis.z);\n const pitch = -Math.atan2(localAxis.y, len);\n const lightRotationQuaternion = Quaternion.RotationYawPitchRoll(yaw, pitch, 0);\n if (convertToRightHandedSystem) {\n _GLTFUtilities._GetRightHandedQuaternionFromRef(lightRotationQuaternion);\n }\n if (!lightRotationQuaternion.equals(Quaternion.Identity())) {\n node.rotation = lightRotationQuaternion.asArray();\n }\n }\n\n if (babylonLight.falloffType !== Light.FALLOFF_GLTF) {\n Logger.Warn(`${context}: Light falloff for ${babylonLight.name} does not match the ${NAME} specification!`);\n }\n light = {\n type: lightType\n };\n if (!babylonLight.diffuse.equals(Color3.White())) {\n light.color = babylonLight.diffuse.asArray();\n }\n if (babylonLight.intensity !== 1.0) {\n light.intensity = babylonLight.intensity;\n }\n if (babylonLight.range !== Number.MAX_VALUE) {\n light.range = babylonLight.range;\n }\n\n if (lightType === IKHRLightsPunctual_LightType.SPOT) {\n const babylonSpotLight = babylonLight as SpotLight;\n if (babylonSpotLight.angle !== Math.PI / 2.0) {\n if (light.spot == null) {\n light.spot = {};\n }\n light.spot.outerConeAngle = babylonSpotLight.angle / 2.0;\n }\n if (babylonSpotLight.innerAngle !== 0) {\n if (light.spot == null) {\n light.spot = {};\n }\n light.spot.innerConeAngle = babylonSpotLight.innerAngle / 2.0;\n }\n }\n\n if (this._lights == null) {\n this._lights = {\n lights: []\n };\n }\n\n this._lights.lights.push(light);\n\n const lightReference: IKHRLightsPunctual_LightReference = {\n light: this._lights.lights.length - 1\n };\n\n // Avoid duplicating the Light's parent node if possible.\n let parentBabylonNode = babylonNode.parent;\n if (parentBabylonNode && parentBabylonNode.getChildren().length == 1) {\n let parentNode = this._exporter._nodes[nodeMap![parentBabylonNode.uniqueId]];\n if (parentNode) {\n let parentNodeLocalMatrix = TmpVectors.Matrix[0];\n let parentInvertNodeLocalMatrix = TmpVectors.Matrix[1];\n let parentNodeLocalTranslation = parentNode.translation ? new Vector3(parentNode.translation[0], parentNode.translation[1], parentNode.translation[2]) : Vector3.Zero();\n let parentNodeLocalRotation = parentNode.rotation ? new Quaternion(parentNode.rotation[0], parentNode.rotation[1], parentNode.rotation[2], parentNode.rotation[3]) : Quaternion.Identity();\n let parentNodeLocalScale = parentNode.scale ? new Vector3(parentNode.scale[0], parentNode.scale[1], parentNode.scale[2]) : Vector3.One();\n\n Matrix.ComposeToRef(parentNodeLocalScale, parentNodeLocalRotation, parentNodeLocalTranslation, parentNodeLocalMatrix);\n parentNodeLocalMatrix.invertToRef(parentInvertNodeLocalMatrix);\n\n // Convert light local matrix to local matrix relative to grandparent, facing -Z\n let lightLocalMatrix = TmpVectors.Matrix[2];\n let nodeLocalTranslation = node.translation ? new Vector3(node.translation[0], node.translation[1], node.translation[2]) : Vector3.Zero();\n\n // Undo directional light positional offset\n if (babylonLight instanceof DirectionalLight) {\n nodeLocalTranslation.subtractInPlace(this._exporter._babylonScene.useRightHandedSystem ? babylonLight.direction : _GLTFUtilities._GetRightHandedPositionVector3(babylonLight.direction));\n }\n let nodeLocalRotation = this._exporter._babylonScene.useRightHandedSystem ? Quaternion.Identity() : new Quaternion(0, 1, 0, 0);\n if (node.rotation) {\n nodeLocalRotation.multiplyInPlace(new Quaternion(node.rotation[0], node.rotation[1], node.rotation[2], node.rotation[3]));\n }\n let nodeLocalScale = node.scale ? new Vector3(node.scale[0], node.scale[1], node.scale[2]) : Vector3.One();\n\n Matrix.ComposeToRef(nodeLocalScale, nodeLocalRotation, nodeLocalTranslation, lightLocalMatrix);\n lightLocalMatrix.multiplyToRef(parentInvertNodeLocalMatrix, lightLocalMatrix);\n let parentNewScale = TmpVectors.Vector3[0];\n let parentNewRotationQuaternion = TmpVectors.Quaternion[0];\n let parentNewTranslation = TmpVectors.Vector3[1];\n\n lightLocalMatrix.decompose(parentNewScale, parentNewRotationQuaternion, parentNewTranslation);\n parentNode.scale = parentNewScale.asArray();\n parentNode.rotation = parentNewRotationQuaternion.asArray();\n parentNode.translation = parentNewTranslation.asArray();\n\n if (parentNode.extensions == null) {\n parentNode.extensions = {};\n }\n parentNode.extensions[NAME] = lightReference;\n\n // Do not export the original node\n resolve(null);\n return;\n }\n }\n\n if (node.extensions == null) {\n node.extensions = {};\n }\n\n node.extensions[NAME] = lightReference;\n }\n }\n resolve(node);\n });\n }\n}\n\n_Exporter.RegisterExtension(NAME, (exporter) => new KHR_lights_punctual(exporter));"]}
|
|
1
|
+
{"version":3,"file":"KHR_lights_punctual.js","sourceRoot":"","sources":["../../../../../sourceES6/serializers/src/glTF/2.0/Extensions/KHR_lights_punctual.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAC5F,OAAO,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAC1D,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAE3E,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAGjE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD,IAAM,IAAI,GAAG,qBAAqB,CAAC;AAEnC;;GAEG;AACH;IAeI,cAAc;IACd,6BAAY,QAAmB;QAf/B,kCAAkC;QAClB,SAAI,GAAG,IAAI,CAAC;QAE5B,iDAAiD;QAC1C,YAAO,GAAG,IAAI,CAAC;QAEtB,iDAAiD;QAC1C,aAAQ,GAAG,KAAK,CAAC;QASpB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC9B,CAAC;IAED,cAAc;IACP,qCAAO,GAAd;QACK,IAAI,CAAC,OAAe,GAAG,IAAI,CAAC;IACjC,CAAC;IAGD,sBAAW,wCAAO;QADlB,cAA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AC,GAAG,cAAc,CAAC;4BAE7C,kCAAkC;4BAClC,OAAO,CAAC,IAAI,CAAC,CAAC;4BACd,OAAO;yBACV;qBACJ;oBAED,IAAI,IAAI,CAAC,UAAU,IAAI,IAAI,EAAE;wBACzB,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;qBACxB;oBAED,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC;iBAC1C;aACJ;YACD,OAAO,CAAC,IAAI,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACP,CAAC;IACL,0BAAC;AAAD,CAAC,AAvLD,IAuLC;;AAED,SAAS,CAAC,iBAAiB,CAAC,IAAI,EAAE,UAAC,QAAQ,IAAK,OAAA,IAAI,mBAAmB,CAAC,QAAQ,CAAC,EAAjC,CAAiC,CAAC,CAAC","sourcesContent":["import { SpotLight } from \"@babylonjs/core/Lights/spotLight\";\nimport { Nullable } from \"@babylonjs/core/types\";\nimport { Vector3, Quaternion, TmpVectors, Matrix } from \"@babylonjs/core/Maths/math.vector\";\nimport { Color3 } from \"@babylonjs/core/Maths/math.color\";\nimport { Light } from \"@babylonjs/core/Lights/light\";\nimport { DirectionalLight } from \"@babylonjs/core/Lights/directionalLight\";\nimport { Node } from \"@babylonjs/core/node\";\nimport { ShadowLight } from \"@babylonjs/core/Lights/shadowLight\";\nimport { INode } from \"babylonjs-gltf2interface\";\nimport { IGLTFExporterExtensionV2 } from \"../glTFExporterExtension\";\nimport { _Exporter } from \"../glTFExporter\";\nimport { Logger } from \"@babylonjs/core/Misc/logger\";\nimport { _GLTFUtilities } from \"../glTFUtilities\";\nimport { IKHRLightsPunctual_LightType, IKHRLightsPunctual_LightReference, IKHRLightsPunctual_Light, IKHRLightsPunctual } from \"babylonjs-gltf2interface\";\n\nconst NAME = \"KHR_lights_punctual\";\n\n/**\n * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)\n */\nexport class KHR_lights_punctual implements IGLTFExporterExtensionV2 {\n /** The name of this extension. */\n public readonly name = NAME;\n\n /** Defines whether this extension is enabled. */\n public enabled = true;\n\n /** Defines whether this extension is required */\n public required = false;\n\n /** Reference to the glTF exporter */\n private _exporter: _Exporter;\n\n private _lights: IKHRLightsPunctual;\n\n /** @hidden */\n constructor(exporter: _Exporter) {\n this._exporter = exporter;\n }\n\n /** @hidden */\n public dispose() {\n (this._lights as any) = null;\n }\n\n /** @hidden */\n public get wasUsed() {\n return !!this._lights;\n }\n\n /** @hidden */\n public onExporting(): void {\n this._exporter!._glTF.extensions![NAME] = this._lights;\n }\n /**\n * Define this method to modify the default behavior when exporting a node\n * @param context The context when exporting the node\n * @param node glTF node\n * @param babylonNode BabylonJS node\n * @param nodeMap Node mapping of unique id to glTF node index\n * @returns nullable INode promise\n */\n public postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: { [key: number]: number }): Promise<Nullable<INode>> {\n return new Promise((resolve, reject) => {\n if (node && babylonNode instanceof ShadowLight) {\n const babylonLight: ShadowLight = babylonNode;\n let light: IKHRLightsPunctual_Light;\n\n const lightType = (\n babylonLight.getTypeID() == Light.LIGHTTYPEID_POINTLIGHT ? IKHRLightsPunctual_LightType.POINT : (\n babylonLight.getTypeID() == Light.LIGHTTYPEID_DIRECTIONALLIGHT ? IKHRLightsPunctual_LightType.DIRECTIONAL : (\n babylonLight.getTypeID() == Light.LIGHTTYPEID_SPOTLIGHT ? IKHRLightsPunctual_LightType.SPOT : null\n )));\n if (lightType == null) {\n Logger.Warn(`${context}: Light ${babylonLight.name} is not supported in ${NAME}`);\n }\n else {\n const lightPosition = babylonLight.position.clone();\n let convertToRightHandedSystem = this._exporter._convertToRightHandedSystemMap[babylonNode.uniqueId];\n if (!lightPosition.equals(Vector3.Zero())) {\n if (convertToRightHandedSystem) {\n _GLTFUtilities._GetRightHandedPositionVector3FromRef(lightPosition);\n }\n node.translation = lightPosition.asArray();\n }\n if (lightType !== IKHRLightsPunctual_LightType.POINT) {\n const localAxis = babylonLight.direction;\n const yaw = -Math.atan2(localAxis.z * (this._exporter._babylonScene.useRightHandedSystem ? -1 : 1), localAxis.x) + Math.PI / 2;\n const len = Math.sqrt(localAxis.x * localAxis.x + localAxis.z * localAxis.z);\n const pitch = -Math.atan2(localAxis.y, len);\n const lightRotationQuaternion = Quaternion.RotationYawPitchRoll(yaw, pitch, 0);\n if (convertToRightHandedSystem) {\n _GLTFUtilities._GetRightHandedQuaternionFromRef(lightRotationQuaternion);\n }\n if (!lightRotationQuaternion.equals(Quaternion.Identity())) {\n node.rotation = lightRotationQuaternion.asArray();\n }\n }\n\n if (babylonLight.falloffType !== Light.FALLOFF_GLTF) {\n Logger.Warn(`${context}: Light falloff for ${babylonLight.name} does not match the ${NAME} specification!`);\n }\n light = {\n type: lightType\n };\n if (!babylonLight.diffuse.equals(Color3.White())) {\n light.color = babylonLight.diffuse.asArray();\n }\n if (babylonLight.intensity !== 1.0) {\n light.intensity = babylonLight.intensity;\n }\n if (babylonLight.range !== Number.MAX_VALUE) {\n light.range = babylonLight.range;\n }\n\n if (lightType === IKHRLightsPunctual_LightType.SPOT) {\n const babylonSpotLight = babylonLight as SpotLight;\n if (babylonSpotLight.angle !== Math.PI / 2.0) {\n if (light.spot == null) {\n light.spot = {};\n }\n light.spot.outerConeAngle = babylonSpotLight.angle / 2.0;\n }\n if (babylonSpotLight.innerAngle !== 0) {\n if (light.spot == null) {\n light.spot = {};\n }\n light.spot.innerConeAngle = babylonSpotLight.innerAngle / 2.0;\n }\n }\n\n if (this._lights == null) {\n this._lights = {\n lights: []\n };\n }\n\n this._lights.lights.push(light);\n\n const lightReference: IKHRLightsPunctual_LightReference = {\n light: this._lights.lights.length - 1\n };\n\n // Avoid duplicating the Light's parent node if possible.\n let parentBabylonNode = babylonNode.parent;\n if (parentBabylonNode && parentBabylonNode.getChildren().length == 1) {\n let parentNode = this._exporter._nodes[nodeMap![parentBabylonNode.uniqueId]];\n if (parentNode) {\n let parentNodeLocalMatrix = TmpVectors.Matrix[0];\n let parentInvertNodeLocalMatrix = TmpVectors.Matrix[1];\n let parentNodeLocalTranslation = parentNode.translation ? new Vector3(parentNode.translation[0], parentNode.translation[1], parentNode.translation[2]) : Vector3.Zero();\n let parentNodeLocalRotation = parentNode.rotation ? new Quaternion(parentNode.rotation[0], parentNode.rotation[1], parentNode.rotation[2], parentNode.rotation[3]) : Quaternion.Identity();\n let parentNodeLocalScale = parentNode.scale ? new Vector3(parentNode.scale[0], parentNode.scale[1], parentNode.scale[2]) : Vector3.One();\n\n Matrix.ComposeToRef(parentNodeLocalScale, parentNodeLocalRotation, parentNodeLocalTranslation, parentNodeLocalMatrix);\n parentNodeLocalMatrix.invertToRef(parentInvertNodeLocalMatrix);\n\n // Convert light local matrix to local matrix relative to grandparent, facing -Z\n let lightLocalMatrix = TmpVectors.Matrix[2];\n let nodeLocalTranslation = node.translation ? new Vector3(node.translation[0], node.translation[1], node.translation[2]) : Vector3.Zero();\n\n // Undo directional light positional offset\n if (babylonLight instanceof DirectionalLight) {\n nodeLocalTranslation.subtractInPlace(this._exporter._babylonScene.useRightHandedSystem ? babylonLight.direction : _GLTFUtilities._GetRightHandedPositionVector3(babylonLight.direction));\n }\n let nodeLocalRotation = this._exporter._babylonScene.useRightHandedSystem ? Quaternion.Identity() : new Quaternion(0, 1, 0, 0);\n if (node.rotation) {\n nodeLocalRotation.multiplyInPlace(new Quaternion(node.rotation[0], node.rotation[1], node.rotation[2], node.rotation[3]));\n }\n let nodeLocalScale = node.scale ? new Vector3(node.scale[0], node.scale[1], node.scale[2]) : Vector3.One();\n\n Matrix.ComposeToRef(nodeLocalScale, nodeLocalRotation, nodeLocalTranslation, lightLocalMatrix);\n lightLocalMatrix.multiplyToRef(parentInvertNodeLocalMatrix, lightLocalMatrix);\n let parentNewScale = TmpVectors.Vector3[0];\n let parentNewRotationQuaternion = TmpVectors.Quaternion[0];\n let parentNewTranslation = TmpVectors.Vector3[1];\n\n lightLocalMatrix.decompose(parentNewScale, parentNewRotationQuaternion, parentNewTranslation);\n parentNode.scale = parentNewScale.asArray();\n parentNode.rotation = parentNewRotationQuaternion.asArray();\n parentNode.translation = parentNewTranslation.asArray();\n\n if (parentNode.extensions == null) {\n parentNode.extensions = {};\n }\n parentNode.extensions[NAME] = lightReference;\n\n // Do not export the original node\n resolve(null);\n return;\n }\n }\n\n if (node.extensions == null) {\n node.extensions = {};\n }\n\n node.extensions[NAME] = lightReference;\n }\n }\n resolve(node);\n });\n }\n}\n\n_Exporter.RegisterExtension(NAME, (exporter) => new KHR_lights_punctual(exporter));"]}
|
|
@@ -63,10 +63,10 @@ var KHR_materials_clearcoat = /** @class */ (function () {
|
|
|
63
63
|
clearCoatTextureRoughnessInfo = _this._exporter._glTFMaterialExporter._getTextureInfo(babylonMaterial.clearCoat.textureRoughness);
|
|
64
64
|
}
|
|
65
65
|
if (babylonMaterial.clearCoat.isTintEnabled) {
|
|
66
|
-
Tools.Warn("Clear Color tint is not supported for glTF export. Ignoring for: "
|
|
66
|
+
Tools.Warn("Clear Color tint is not supported for glTF export. Ignoring for: ".concat(babylonMaterial.name));
|
|
67
67
|
}
|
|
68
68
|
if (babylonMaterial.clearCoat.remapF0OnInterfaceChange) {
|
|
69
|
-
Tools.Warn("Clear Color F0 remapping is not supported for glTF export. Ignoring for: "
|
|
69
|
+
Tools.Warn("Clear Color F0 remapping is not supported for glTF export. Ignoring for: ".concat(babylonMaterial.name));
|
|
70
70
|
}
|
|
71
71
|
var clearCoatNormalTextureInfo = _this._exporter._glTFMaterialExporter._getTextureInfo(babylonMaterial.clearCoat.bumpTexture);
|
|
72
72
|
var clearCoatInfo_1 = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KHR_materials_clearcoat.js","sourceRoot":"","sources":["../../../../../sourceES6/serializers/src/glTF/2.0/Extensions/KHR_materials_clearcoat.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAA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EM,yDAAuB,GAA9B,UAAgC,OAAe,EAAE,IAAe,EAAE,eAAyB;QAA3F,iBA6CC;QA5CG,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;YAC/B,IAAI,eAAe,YAAY,eAAe,EAAE;gBAC5C,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,SAAS,EAAE;oBACtC,OAAO,CAAC,IAAI,CAAC,CAAC;oBACd,OAAO;iBACV;gBAED,KAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;gBAErB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,EAAE,CAAC;gBAExC,IAAM,oBAAoB,GAAG,KAAI,CAAC,SAAS,CAAC,qBAAqB,CAAC,eAAe,CAAC,eAAe,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;gBACrH,IAAI,6BAA6B,SAAA,CAAC;gBAClC,IAAI,eAAe,CAAC,SAAS,CAAC,2BAA2B,EAAE;oBACvD,6BAA6B,GAAG,KAAI,CAAC,SAAS,CAAC,qBAAqB,CAAC,eAAe,CAAC,eAAe,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;iBAC3H;qBAAM;oBACH,6BAA6B,GAAG,KAAI,CAAC,SAAS,CAAC,qBAAqB,CAAC,eAAe,CAAC,eAAe,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;iBACpI;gBAED,IAAI,eAAe,CAAC,SAAS,CAAC,aAAa,EAAE;oBACzC,KAAK,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"KHR_materials_clearcoat.js","sourceRoot":"","sources":["../../../../../sourceES6/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,MAAM,+CAA+C,CAAC;AAGhF,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAEnD,IAAM,IAAI,GAA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BAAoB,cAApB,oBAAoB,GAAI,SAAS;oBACnD,wBAAwB,EAAE,eAAe,CAAC,SAAS,CAAC,SAAS;oBAC7D,yBAAyB,EAAE,6BAA6B,aAA7B,6BAA6B,cAA7B,6BAA6B,GAAI,SAAS;oBACrE,sBAAsB,EAAE,0BAA0B,aAA1B,0BAA0B,cAA1B,0BAA0B,GAAI,SAAS;oBAC/D,WAAW,EAAE;wBACT,OAAO,eAAa,CAAC,gBAAgB,KAAK,IAAI,IAAI,eAAa,CAAC,yBAAyB,KAAK,IAAI,IAAI,eAAa,CAAC,yBAAyB,KAAK,IAAI,CAAC;oBAC3J,CAAC;iBACJ,CAAC;gBAEF,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,eAAa,CAAC;aACzC;YACD,OAAO,CAAC,IAAI,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACP,CAAC;IACL,8BAAC;AAAD,CAAC,AA5FD,IA4FC;;AAED,SAAS,CAAC,iBAAiB,CAAC,IAAI,EAAE,UAAC,QAAQ,IAAK,OAAA,IAAI,uBAAuB,CAAC,QAAQ,CAAC,EAArC,CAAqC,CAAC,CAAC","sourcesContent":["import { IMaterial } from \"babylonjs-gltf2interface\";\r\nimport { IGLTFExporterExtensionV2 } from \"../glTFExporterExtension\";\r\nimport { _Exporter } from \"../glTFExporter\";\r\nimport { Material } from \"@babylonjs/core/Materials/material\";\r\nimport { PBRBaseMaterial } from \"@babylonjs/core/Materials/PBR/pbrBaseMaterial\";\r\nimport { BaseTexture } from \"@babylonjs/core/Materials/Textures/baseTexture\";\r\nimport { IKHRMaterialsClearcoat } from \"babylonjs-gltf2interface\";\r\nimport { Tools } from \"@babylonjs/core/Misc/tools\";\r\n\r\nconst NAME = \"KHR_materials_clearcoat\";\r\n\r\n/**\r\n * @hidden\r\n */\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\r\n /** @hidden */\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, reject) => {\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"]}
|
|
@@ -68,7 +68,7 @@ var KHR_texture_transform = /** @class */ (function () {
|
|
|
68
68
|
return new Promise(function (resolve, reject) {
|
|
69
69
|
var scene = babylonTexture.getScene();
|
|
70
70
|
if (!scene) {
|
|
71
|
-
reject(context
|
|
71
|
+
reject("".concat(context, ": \"scene\" is not defined for Babylon texture ").concat(babylonTexture.name, "!"));
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
74
|
var bakeTextureTransform = false;
|
|
@@ -104,9 +104,9 @@ var KHR_texture_transform = /** @class */ (function () {
|
|
|
104
104
|
KHR_texture_transform.prototype._textureTransformTextureAsync = function (babylonTexture, scene) {
|
|
105
105
|
var _this = this;
|
|
106
106
|
return new Promise(function (resolve) {
|
|
107
|
-
var proceduralTexture = new ProceduralTexture(""
|
|
107
|
+
var proceduralTexture = new ProceduralTexture("".concat(babylonTexture.name), babylonTexture.getSize(), "textureTransform", scene);
|
|
108
108
|
if (!proceduralTexture) {
|
|
109
|
-
Tools.Log("Cannot create procedural texture for "
|
|
109
|
+
Tools.Log("Cannot create procedural texture for ".concat(babylonTexture.name, "!"));
|
|
110
110
|
resolve(babylonTexture);
|
|
111
111
|
}
|
|
112
112
|
proceduralTexture.reservedDataStore = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KHR_texture_transform.js","sourceRoot":"","sources":["../../../../../sourceES6/serializers/src/glTF/2.0/Extensions/KHR_texture_transform.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAEnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kEAAkE,CAAC;AAIrG,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,IAAM,IAAI,GAAG,uBAAuB,CAAC;AAErC,OAAO,sCAAsC,CAAC;AAE9C;;GAEG;AACH;IAeI,+BAAY,QAAmB;QAdvB,sBAAiB,GAAwB,EAAE,CAAC;QAEpD,6BAA6B;QACb,SAAI,GAAG,IAAI,CAAC;QAE5B,gDAAgD;QACzC,YAAO,GAAG,IAAI,CAAC;QAEtB,iDAAiD;QAC1C,aAAQ,GAAG,KAAK,CAAC;QAExB,qCAAqC;QAC7B,aAAQ,GAAG,KAAK,CAAC;IAGzB,CAAC;IAEM,uCAAO,GAAd;QACI,KAAoB,UAAsB,EAAtB,KAAA,IAAI,CAAC,iBAAiB,EAAtB,cAAsB,EAAtB,IAAsB,EAAE;YAAvC,IAAI,OAAO,SAAA;YACZ,OAAO,CAAC,OAAO,EAAE,CAAC;SACrB;IACL,CAAC;IAGD,sBAAW,0CAAO;QADlB,cAAc;aACd;YACI,OAAO,IA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K,OAAA,IAAI,qBAAqB,CAAC,QAAQ,CAAC,EAAnC,CAAmC,CAAC,CAAC","sourcesContent":["import { ImageMimeType, ITextureInfo } from \"babylonjs-gltf2interface\";\r\nimport { Tools } from \"@babylonjs/core/Misc/tools\";\r\nimport { Texture } from \"@babylonjs/core/Materials/Textures/texture\";\r\nimport { ProceduralTexture } from \"@babylonjs/core/Materials/Textures/Procedurals/proceduralTexture\";\r\nimport { Scene } from \"@babylonjs/core/scene\";\r\n\r\nimport { IGLTFExporterExtensionV2 } from \"../glTFExporterExtension\";\r\nimport { _Exporter } from \"../glTFExporter\";\r\nimport { IKHRTextureTransform } from 'babylonjs-gltf2interface';\r\n\r\nconst NAME = \"KHR_texture_transform\";\r\n\r\nimport \"../shaders/textureTransform.fragment\";\r\n\r\n/**\r\n * @hidden\r\n */\r\nexport class KHR_texture_transform implements IGLTFExporterExtensionV2 {\r\n private _recordedTextures: ProceduralTexture[] = [];\r\n\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 /** Reference to the glTF exporter */\r\n private _wasUsed = false;\r\n\r\n constructor(exporter: _Exporter) {\r\n }\r\n\r\n public dispose() {\r\n for (var texture of this._recordedTextures) {\r\n texture.dispose();\r\n }\r\n }\r\n\r\n /** @hidden */\r\n public get wasUsed() {\r\n return this._wasUsed;\r\n }\r\n\r\n public postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void {\r\n const canUseExtension = babylonTexture && ((babylonTexture.uAng === 0 && babylonTexture.wAng === 0 && babylonTexture.vAng === 0) || (babylonTexture.uRotationCenter === 0 && babylonTexture.vRotationCenter === 0));\r\n\r\n if (canUseExtension) {\r\n let textureTransform: IKHRTextureTransform = {};\r\n let transformIsRequired = false;\r\n\r\n if (babylonTexture.uOffset !== 0 || babylonTexture.vOffset !== 0) {\r\n textureTransform.offset = [babylonTexture.uOffset, babylonTexture.vOffset];\r\n transformIsRequired = true;\r\n }\r\n\r\n if (babylonTexture.uScale !== 1 || babylonTexture.vScale !== 1) {\r\n textureTransform.scale = [babylonTexture.uScale, babylonTexture.vScale];\r\n transformIsRequired = true;\r\n }\r\n\r\n if (babylonTexture.wAng !== 0) {\r\n textureTransform.rotation = babylonTexture.wAng;\r\n transformIsRequired = true;\r\n }\r\n\r\n if (babylonTexture.coordinatesIndex !== 0) {\r\n textureTransform.texCoord = babylonTexture.coordinatesIndex;\r\n transformIsRequired = true;\r\n }\r\n\r\n if (!transformIsRequired) {\r\n return;\r\n }\r\n\r\n this._wasUsed = true;\r\n if (!textureInfo.extensions) {\r\n textureInfo.extensions = {};\r\n }\r\n textureInfo.extensions[NAME] = textureTransform;\r\n }\r\n }\r\n\r\n public preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture> {\r\n return new Promise((resolve, reject) => {\r\n const scene = babylonTexture.getScene();\r\n if (!scene) {\r\n reject(`${context}: \"scene\" is not defined for Babylon texture ${babylonTexture.name}!`);\r\n return;\r\n }\r\n\r\n let bakeTextureTransform = false;\r\n\r\n /*\r\n * The KHR_texture_transform schema only supports rotation around the origin.\r\n * the texture must be baked to preserve appearance.\r\n * see: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_texture_transform#gltf-schema-updates\r\n */\r\n if ((babylonTexture.uAng !== 0 || babylonTexture.wAng !== 0 || babylonTexture.vAng !== 0) && (babylonTexture.uRotationCenter !== 0 || babylonTexture.vRotationCenter !== 0)) {\r\n bakeTextureTransform = true;\r\n }\r\n\r\n if (!bakeTextureTransform) {\r\n resolve(babylonTexture);\r\n return;\r\n }\r\n\r\n return this._textureTransformTextureAsync(babylonTexture, scene)\r\n .then((proceduralTexture) => {\r\n resolve(proceduralTexture);\r\n })\r\n .catch((e) => {\r\n reject(e);\r\n });\r\n });\r\n }\r\n\r\n /**\r\n * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture\r\n * @param babylonTexture\r\n * @param offset\r\n * @param rotation\r\n * @param scale\r\n * @param scene\r\n */\r\n private _textureTransformTextureAsync(babylonTexture: Texture, scene: Scene): Promise<Texture> {\r\n return new Promise((resolve) => {\r\n const proceduralTexture = new ProceduralTexture(`${babylonTexture.name}`, babylonTexture.getSize(), \"textureTransform\", scene);\r\n if (!proceduralTexture) {\r\n Tools.Log(`Cannot create procedural texture for ${babylonTexture.name}!`);\r\n resolve(babylonTexture);\r\n }\r\n\r\n proceduralTexture.reservedDataStore = {\r\n hidden: true,\r\n source: babylonTexture\r\n };\r\n\r\n this._recordedTextures.push(proceduralTexture);\r\n\r\n proceduralTexture.coordinatesIndex = babylonTexture.coordinatesIndex;\r\n proceduralTexture.setTexture(\"textureSampler\", babylonTexture);\r\n proceduralTexture.setMatrix(\"textureTransformMat\", babylonTexture.getTextureMatrix());\r\n\r\n // isReady trigger creation of effect if it doesnt exist yet\r\n if (proceduralTexture.isReady()) {\r\n proceduralTexture.render();\r\n resolve(proceduralTexture);\r\n } else {\r\n proceduralTexture.getEffect().executeWhenCompiled(() => {\r\n proceduralTexture.render();\r\n resolve(proceduralTexture);\r\n });\r\n }\r\n });\r\n }\r\n}\r\n\r\n_Exporter.RegisterExtension(NAME, (exporter) => new KHR_texture_transform(exporter));"]}
|
|
1
|
+
{"version":3,"file":"KHR_texture_transform.js","sourceRoot":"","sources":["../../../../../sourceES6/serializers/src/glTF/2.0/Extensions/KHR_texture_transform.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAEnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kEAAkE,CAAC;AAIrG,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,IAAM,IAAI,GAAG,uBAAuB,CAAC;AAErC,OAAO,sCAAsC,CAAC;AAE9C;;GAEG;AACH;IAeI,+BAAY,QAAmB;QAdvB,sBAAiB,GAAwB,EAAE,CAAC;QAEpD,6B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D,IAAI,iBAAiB,CAAC,OAAO,EAAE,EAAE;gBAC7B,iBAAiB,CAAC,MAAM,EAAE,CAAC;gBAC3B,OAAO,CAAC,iBAAiB,CAAC,CAAC;aAC9B;iBAAM;gBACH,iBAAiB,CAAC,SAAS,EAAE,CAAC,mBAAmB,CAAC;oBAC9C,iBAAiB,CAAC,MAAM,EAAE,CAAC;oBAC3B,OAAO,CAAC,iBAAiB,CAAC,CAAC;gBAC/B,CAAC,CAAC,CAAC;aACN;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IACL,4BAAC;AAAD,CAAC,AA7ID,IA6IC;;AAED,SAAS,CAAC,iBAAiB,CAAC,IAAI,EAAE,UAAC,QAAQ,IAAK,OAAA,IAAI,qBAAqB,CAAC,QAAQ,CAAC,EAAnC,CAAmC,CAAC,CAAC","sourcesContent":["import { ImageMimeType, ITextureInfo } from \"babylonjs-gltf2interface\";\r\nimport { Tools } from \"@babylonjs/core/Misc/tools\";\r\nimport { Texture } from \"@babylonjs/core/Materials/Textures/texture\";\r\nimport { ProceduralTexture } from \"@babylonjs/core/Materials/Textures/Procedurals/proceduralTexture\";\r\nimport { Scene } from \"@babylonjs/core/scene\";\r\n\r\nimport { IGLTFExporterExtensionV2 } from \"../glTFExporterExtension\";\r\nimport { _Exporter } from \"../glTFExporter\";\r\nimport { IKHRTextureTransform } from 'babylonjs-gltf2interface';\r\n\r\nconst NAME = \"KHR_texture_transform\";\r\n\r\nimport \"../shaders/textureTransform.fragment\";\r\n\r\n/**\r\n * @hidden\r\n */\r\nexport class KHR_texture_transform implements IGLTFExporterExtensionV2 {\r\n private _recordedTextures: ProceduralTexture[] = [];\r\n\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 /** Reference to the glTF exporter */\r\n private _wasUsed = false;\r\n\r\n constructor(exporter: _Exporter) {\r\n }\r\n\r\n public dispose() {\r\n for (var texture of this._recordedTextures) {\r\n texture.dispose();\r\n }\r\n }\r\n\r\n /** @hidden */\r\n public get wasUsed() {\r\n return this._wasUsed;\r\n }\r\n\r\n public postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void {\r\n const canUseExtension = babylonTexture && ((babylonTexture.uAng === 0 && babylonTexture.wAng === 0 && babylonTexture.vAng === 0) || (babylonTexture.uRotationCenter === 0 && babylonTexture.vRotationCenter === 0));\r\n\r\n if (canUseExtension) {\r\n let textureTransform: IKHRTextureTransform = {};\r\n let transformIsRequired = false;\r\n\r\n if (babylonTexture.uOffset !== 0 || babylonTexture.vOffset !== 0) {\r\n textureTransform.offset = [babylonTexture.uOffset, babylonTexture.vOffset];\r\n transformIsRequired = true;\r\n }\r\n\r\n if (babylonTexture.uScale !== 1 || babylonTexture.vScale !== 1) {\r\n textureTransform.scale = [babylonTexture.uScale, babylonTexture.vScale];\r\n transformIsRequired = true;\r\n }\r\n\r\n if (babylonTexture.wAng !== 0) {\r\n textureTransform.rotation = babylonTexture.wAng;\r\n transformIsRequired = true;\r\n }\r\n\r\n if (babylonTexture.coordinatesIndex !== 0) {\r\n textureTransform.texCoord = babylonTexture.coordinatesIndex;\r\n transformIsRequired = true;\r\n }\r\n\r\n if (!transformIsRequired) {\r\n return;\r\n }\r\n\r\n this._wasUsed = true;\r\n if (!textureInfo.extensions) {\r\n textureInfo.extensions = {};\r\n }\r\n textureInfo.extensions[NAME] = textureTransform;\r\n }\r\n }\r\n\r\n public preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture> {\r\n return new Promise((resolve, reject) => {\r\n const scene = babylonTexture.getScene();\r\n if (!scene) {\r\n reject(`${context}: \"scene\" is not defined for Babylon texture ${babylonTexture.name}!`);\r\n return;\r\n }\r\n\r\n let bakeTextureTransform = false;\r\n\r\n /*\r\n * The KHR_texture_transform schema only supports rotation around the origin.\r\n * the texture must be baked to preserve appearance.\r\n * see: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_texture_transform#gltf-schema-updates\r\n */\r\n if ((babylonTexture.uAng !== 0 || babylonTexture.wAng !== 0 || babylonTexture.vAng !== 0) && (babylonTexture.uRotationCenter !== 0 || babylonTexture.vRotationCenter !== 0)) {\r\n bakeTextureTransform = true;\r\n }\r\n\r\n if (!bakeTextureTransform) {\r\n resolve(babylonTexture);\r\n return;\r\n }\r\n\r\n return this._textureTransformTextureAsync(babylonTexture, scene)\r\n .then((proceduralTexture) => {\r\n resolve(proceduralTexture);\r\n })\r\n .catch((e) => {\r\n reject(e);\r\n });\r\n });\r\n }\r\n\r\n /**\r\n * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture\r\n * @param babylonTexture\r\n * @param offset\r\n * @param rotation\r\n * @param scale\r\n * @param scene\r\n */\r\n private _textureTransformTextureAsync(babylonTexture: Texture, scene: Scene): Promise<Texture> {\r\n return new Promise((resolve) => {\r\n const proceduralTexture = new ProceduralTexture(`${babylonTexture.name}`, babylonTexture.getSize(), \"textureTransform\", scene);\r\n if (!proceduralTexture) {\r\n Tools.Log(`Cannot create procedural texture for ${babylonTexture.name}!`);\r\n resolve(babylonTexture);\r\n }\r\n\r\n proceduralTexture.reservedDataStore = {\r\n hidden: true,\r\n source: babylonTexture\r\n };\r\n\r\n this._recordedTextures.push(proceduralTexture);\r\n\r\n proceduralTexture.coordinatesIndex = babylonTexture.coordinatesIndex;\r\n proceduralTexture.setTexture(\"textureSampler\", babylonTexture);\r\n proceduralTexture.setMatrix(\"textureTransformMat\", babylonTexture.getTextureMatrix());\r\n\r\n // isReady trigger creation of effect if it doesnt exist yet\r\n if (proceduralTexture.isReady()) {\r\n proceduralTexture.render();\r\n resolve(proceduralTexture);\r\n } else {\r\n proceduralTexture.getEffect().executeWhenCompiled(() => {\r\n proceduralTexture.render();\r\n resolve(proceduralTexture);\r\n });\r\n }\r\n });\r\n }\r\n}\r\n\r\n_Exporter.RegisterExtension(NAME, (exporter) => new KHR_texture_transform(exporter));"]}
|
|
@@ -105,7 +105,7 @@ var _GLTFAnimation = /** @class */ (function () {
|
|
|
105
105
|
break;
|
|
106
106
|
}
|
|
107
107
|
default: {
|
|
108
|
-
Tools.Error("Unsupported animatable property "
|
|
108
|
+
Tools.Error("Unsupported animatable property ".concat(property[0]));
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
if (animationChannelTargetPath) {
|
|
@@ -143,7 +143,7 @@ var _GLTFAnimation = /** @class */ (function () {
|
|
|
143
143
|
samplers: [],
|
|
144
144
|
channels: []
|
|
145
145
|
};
|
|
146
|
-
_GLTFAnimation.AddAnimation(""
|
|
146
|
+
_GLTFAnimation.AddAnimation("".concat(animation.name), animation.hasRunningRuntimeAnimations ? runtimeGLTFAnimation : glTFAnimation, babylonNode, animation, animationInfo.dataAccessorType, animationInfo.animationChannelTargetPath, nodeMap, binaryWriter, bufferViews, accessors, convertToRightHandedSystem, animationInfo.useQuaternion, animationSampleRate);
|
|
147
147
|
if (glTFAnimation.samplers.length && glTFAnimation.channels.length) {
|
|
148
148
|
idleGLTFAnimations.push(glTFAnimation);
|
|
149
149
|
}
|
|
@@ -175,7 +175,7 @@ var _GLTFAnimation = /** @class */ (function () {
|
|
|
175
175
|
var morphTarget = morphTargetManager.getTarget(i);
|
|
176
176
|
for (var _i = 0, _a = morphTarget.animations; _i < _a.length; _i++) {
|
|
177
177
|
var animation = _a[_i];
|
|
178
|
-
var combinedAnimation = new Animation(""
|
|
178
|
+
var combinedAnimation = new Animation("".concat(animation.name), "influence", animation.framePerSecond, animation.dataType, animation.loopMode, animation.enableBlending);
|
|
179
179
|
var combinedAnimationKeys = [];
|
|
180
180
|
var animationKeys = animation.getKeys();
|
|
181
181
|
for (var j = 0; j < animationKeys.length; ++j) {
|
|
@@ -244,7 +244,7 @@ var _GLTFAnimation = /** @class */ (function () {
|
|
|
244
244
|
if (animationInfo) {
|
|
245
245
|
var babylonTransformNode = target instanceof TransformNode ? target : target[0];
|
|
246
246
|
var convertToRightHandedSystem = convertToRightHandedSystemMap[babylonTransformNode.uniqueId];
|
|
247
|
-
_GLTFAnimation.AddAnimation(""
|
|
247
|
+
_GLTFAnimation.AddAnimation("".concat(animation.name), glTFAnimation, babylonTransformNode, animation, animationInfo.dataAccessorType, animationInfo.animationChannelTargetPath, nodeMap, binaryWriter, bufferViews, accessors, convertToRightHandedSystem, animationInfo.useQuaternion, animationSampleRate);
|
|
248
248
|
}
|
|
249
249
|
}
|
|
250
250
|
else if (target instanceof MorphTarget || target.length === 1 && target[0] instanceof MorphTarget) {
|
|
@@ -304,7 +304,7 @@ var _GLTFAnimation = /** @class */ (function () {
|
|
|
304
304
|
var morphTargetAnimation = animationsByMorphTarget.get(morphTarget);
|
|
305
305
|
if (morphTargetAnimation) {
|
|
306
306
|
if (!combinedAnimationGroup) {
|
|
307
|
-
combinedAnimationGroup = new Animation(animationGroup.name
|
|
307
|
+
combinedAnimationGroup = new Animation("".concat(animationGroup.name, "_").concat(mesh.name, "_MorphWeightAnimation"), "influence", morphTargetAnimation.framePerSecond, Animation.ANIMATIONTYPE_FLOAT, morphTargetAnimation.loopMode, morphTargetAnimation.enableBlending);
|
|
308
308
|
}
|
|
309
309
|
animationKeys.push(morphTargetAnimation.getKeys()[i]);
|
|
310
310
|
}
|
|
@@ -322,7 +322,7 @@ var _GLTFAnimation = /** @class */ (function () {
|
|
|
322
322
|
combinedAnimationGroup.setKeys(animationKeys);
|
|
323
323
|
var animationInfo = _GLTFAnimation._DeduceAnimationInfo(combinedAnimationGroup);
|
|
324
324
|
if (animationInfo) {
|
|
325
|
-
_GLTFAnimation.AddAnimation(animationGroup.name
|
|
325
|
+
_GLTFAnimation.AddAnimation("".concat(animationGroup.name, "_").concat(mesh.name, "_MorphWeightAnimation"), glTFAnimation, mesh, combinedAnimationGroup, animationInfo.dataAccessorType, animationInfo.animationChannelTargetPath, nodeMap, binaryWriter, bufferViews, accessors, false, animationInfo.useQuaternion, animationSampleRate, morphTargetManager === null || morphTargetManager === void 0 ? void 0 : morphTargetManager.numTargets);
|
|
326
326
|
}
|
|
327
327
|
});
|
|
328
328
|
if (glTFAnimation.channels.length && glTFAnimation.samplers.length) {
|
|
@@ -366,26 +366,26 @@ var _GLTFAnimation = /** @class */ (function () {
|
|
|
366
366
|
var nodeIndex = nodeMap[babylonTransformNode.uniqueId];
|
|
367
367
|
// Creates buffer view and accessor for key frames.
|
|
368
368
|
var byteLength = animationData.inputs.length * 4;
|
|
369
|
-
bufferView = _GLTFUtilities._CreateBufferView(0, binaryWriter.getByteOffset(), byteLength, undefined, name
|
|
369
|
+
bufferView = _GLTFUtilities._CreateBufferView(0, binaryWriter.getByteOffset(), byteLength, undefined, "".concat(name, " keyframe data view"));
|
|
370
370
|
bufferViews.push(bufferView);
|
|
371
371
|
animationData.inputs.forEach(function (input) {
|
|
372
372
|
binaryWriter.setFloat32(input);
|
|
373
373
|
});
|
|
374
|
-
accessor = _GLTFUtilities._CreateAccessor(bufferViews.length - 1, name
|
|
374
|
+
accessor = _GLTFUtilities._CreateAccessor(bufferViews.length - 1, "".concat(name, " keyframes"), "SCALAR" /* SCALAR */, 5126 /* FLOAT */, animationData.inputs.length, null, [animationData.inputsMin], [animationData.inputsMax]);
|
|
375
375
|
accessors.push(accessor);
|
|
376
376
|
keyframeAccessorIndex = accessors.length - 1;
|
|
377
377
|
// create bufferview and accessor for keyed values.
|
|
378
378
|
outputLength = animationData.outputs.length;
|
|
379
379
|
byteLength = _GLTFUtilities._GetDataAccessorElementCount(dataAccessorType) * 4 * animationData.outputs.length;
|
|
380
380
|
// check for in and out tangents
|
|
381
|
-
bufferView = _GLTFUtilities._CreateBufferView(0, binaryWriter.getByteOffset(), byteLength, undefined, name
|
|
381
|
+
bufferView = _GLTFUtilities._CreateBufferView(0, binaryWriter.getByteOffset(), byteLength, undefined, "".concat(name, " data view"));
|
|
382
382
|
bufferViews.push(bufferView);
|
|
383
383
|
animationData.outputs.forEach(function (output) {
|
|
384
384
|
output.forEach(function (entry) {
|
|
385
385
|
binaryWriter.setFloat32(entry);
|
|
386
386
|
});
|
|
387
387
|
});
|
|
388
|
-
accessor = _GLTFUtilities._CreateAccessor(bufferViews.length - 1, name
|
|
388
|
+
accessor = _GLTFUtilities._CreateAccessor(bufferViews.length - 1, "".concat(name, " data"), dataAccessorType, 5126 /* FLOAT */, outputLength, null, null, null);
|
|
389
389
|
accessors.push(accessor);
|
|
390
390
|
dataAccessorIndex = accessors.length - 1;
|
|
391
391
|
// create sampler
|
|
@@ -507,7 +507,7 @@ var _GLTFAnimation = /** @class */ (function () {
|
|
|
507
507
|
break;
|
|
508
508
|
}
|
|
509
509
|
default: {
|
|
510
|
-
Tools.Error("glTFAnimation: Unsupported component type \""
|
|
510
|
+
Tools.Error("glTFAnimation: Unsupported component type \"".concat(componentName, "\" for scale animation!"));
|
|
511
511
|
}
|
|
512
512
|
}
|
|
513
513
|
}
|