@babylonjs/serializers 5.19.0 → 5.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/OBJ/objSerializer.js +35 -39
  2. package/OBJ/objSerializer.js.map +1 -1
  3. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js +44 -52
  4. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js.map +1 -1
  5. package/glTF/2.0/Extensions/KHR_lights_punctual.js +49 -56
  6. package/glTF/2.0/Extensions/KHR_lights_punctual.js.map +1 -1
  7. package/glTF/2.0/Extensions/KHR_materials_clearcoat.js +31 -38
  8. package/glTF/2.0/Extensions/KHR_materials_clearcoat.js.map +1 -1
  9. package/glTF/2.0/Extensions/KHR_materials_ior.js +18 -25
  10. package/glTF/2.0/Extensions/KHR_materials_ior.js.map +1 -1
  11. package/glTF/2.0/Extensions/KHR_materials_iridescence.js +25 -32
  12. package/glTF/2.0/Extensions/KHR_materials_iridescence.js.map +1 -1
  13. package/glTF/2.0/Extensions/KHR_materials_sheen.js +24 -32
  14. package/glTF/2.0/Extensions/KHR_materials_sheen.js.map +1 -1
  15. package/glTF/2.0/Extensions/KHR_materials_specular.js +29 -37
  16. package/glTF/2.0/Extensions/KHR_materials_specular.js.map +1 -1
  17. package/glTF/2.0/Extensions/KHR_materials_transmission.js +29 -37
  18. package/glTF/2.0/Extensions/KHR_materials_transmission.js.map +1 -1
  19. package/glTF/2.0/Extensions/KHR_materials_unlit.js +15 -22
  20. package/glTF/2.0/Extensions/KHR_materials_unlit.js.map +1 -1
  21. package/glTF/2.0/Extensions/KHR_materials_volume.js +31 -39
  22. package/glTF/2.0/Extensions/KHR_materials_volume.js.map +1 -1
  23. package/glTF/2.0/Extensions/KHR_texture_transform.js +33 -42
  24. package/glTF/2.0/Extensions/KHR_texture_transform.js.map +1 -1
  25. package/glTF/2.0/glTFAnimation.js +171 -187
  26. package/glTF/2.0/glTFAnimation.js.map +1 -1
  27. package/glTF/2.0/glTFData.js +9 -11
  28. package/glTF/2.0/glTFData.js.map +1 -1
  29. package/glTF/2.0/glTFExporter.js +498 -544
  30. package/glTF/2.0/glTFExporter.js.map +1 -1
  31. package/glTF/2.0/glTFMaterialExporter.js +385 -423
  32. package/glTF/2.0/glTFMaterialExporter.js.map +1 -1
  33. package/glTF/2.0/glTFSerializer.js +20 -25
  34. package/glTF/2.0/glTFSerializer.js.map +1 -1
  35. package/glTF/2.0/glTFUtilities.js +45 -49
  36. package/glTF/2.0/glTFUtilities.js.map +1 -1
  37. package/glTF/2.0/shaders/textureTransform.fragment.js +7 -3
  38. package/glTF/2.0/shaders/textureTransform.fragment.js.map +1 -1
  39. package/legacy/legacy-glTF2Serializer.js +16 -16
  40. package/legacy/legacy-glTF2Serializer.js.map +1 -1
  41. package/legacy/legacy-objSerializer.js +2 -2
  42. package/legacy/legacy-objSerializer.js.map +1 -1
  43. package/legacy/legacy-stlSerializer.js +2 -2
  44. package/legacy/legacy-stlSerializer.js.map +1 -1
  45. package/package.json +3 -6
  46. package/stl/stlSerializer.js +29 -38
  47. package/stl/stlSerializer.js.map +1 -1
@@ -6,17 +6,17 @@ import { ShadowLight } from "@babylonjs/core/Lights/shadowLight.js";
6
6
  import { _Exporter } from "../glTFExporter.js";
7
7
  import { Logger } from "@babylonjs/core/Misc/logger.js";
8
8
  import { _GLTFUtilities } from "../glTFUtilities.js";
9
- var NAME = "KHR_lights_punctual";
9
+ const NAME = "KHR_lights_punctual";
10
10
  /**
11
11
  * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
12
12
  */
13
13
  // eslint-disable-next-line @typescript-eslint/naming-convention
14
- var KHR_lights_punctual = /** @class */ (function () {
14
+ export class KHR_lights_punctual {
15
15
  /**
16
16
  * @param exporter
17
17
  * @hidden
18
18
  */
19
- function KHR_lights_punctual(exporter) {
19
+ constructor(exporter) {
20
20
  /** The name of this extension. */
21
21
  this.name = NAME;
22
22
  /** Defines whether this extension is enabled. */
@@ -26,21 +26,17 @@ var KHR_lights_punctual = /** @class */ (function () {
26
26
  this._exporter = exporter;
27
27
  }
28
28
  /** @hidden */
29
- KHR_lights_punctual.prototype.dispose = function () {
29
+ dispose() {
30
30
  this._lights = null;
31
- };
32
- Object.defineProperty(KHR_lights_punctual.prototype, "wasUsed", {
33
- /** @hidden */
34
- get: function () {
35
- return !!this._lights;
36
- },
37
- enumerable: false,
38
- configurable: true
39
- });
31
+ }
32
+ /** @hidden */
33
+ get wasUsed() {
34
+ return !!this._lights;
35
+ }
40
36
  /** @hidden */
41
- KHR_lights_punctual.prototype.onExporting = function () {
37
+ onExporting() {
42
38
  this._exporter._glTF.extensions[NAME] = this._lights;
43
- };
39
+ }
44
40
  /**
45
41
  * Define this method to modify the default behavior when exporting a node
46
42
  * @param context The context when exporting the node
@@ -49,13 +45,12 @@ var KHR_lights_punctual = /** @class */ (function () {
49
45
  * @param nodeMap Node mapping of unique id to glTF node index
50
46
  * @returns nullable INode promise
51
47
  */
52
- KHR_lights_punctual.prototype.postExportNodeAsync = function (context, node, babylonNode, nodeMap) {
53
- var _this = this;
54
- return new Promise(function (resolve) {
48
+ postExportNodeAsync(context, node, babylonNode, nodeMap) {
49
+ return new Promise((resolve) => {
55
50
  if (node && babylonNode instanceof ShadowLight) {
56
- var babylonLight = babylonNode;
57
- var light = void 0;
58
- var lightType = babylonLight.getTypeID() == Light.LIGHTTYPEID_POINTLIGHT
51
+ const babylonLight = babylonNode;
52
+ let light;
53
+ const lightType = babylonLight.getTypeID() == Light.LIGHTTYPEID_POINTLIGHT
59
54
  ? "point" /* POINT */
60
55
  : babylonLight.getTypeID() == Light.LIGHTTYPEID_DIRECTIONALLIGHT
61
56
  ? "directional" /* DIRECTIONAL */
@@ -63,11 +58,11 @@ var KHR_lights_punctual = /** @class */ (function () {
63
58
  ? "spot" /* SPOT */
64
59
  : null;
65
60
  if (lightType == null) {
66
- Logger.Warn("".concat(context, ": Light ").concat(babylonLight.name, " is not supported in ").concat(NAME));
61
+ Logger.Warn(`${context}: Light ${babylonLight.name} is not supported in ${NAME}`);
67
62
  }
68
63
  else {
69
- var lightPosition = babylonLight.position.clone();
70
- var convertToRightHandedSystem = _this._exporter._convertToRightHandedSystemMap[babylonNode.uniqueId];
64
+ const lightPosition = babylonLight.position.clone();
65
+ const convertToRightHandedSystem = this._exporter._convertToRightHandedSystemMap[babylonNode.uniqueId];
71
66
  if (!lightPosition.equals(Vector3.Zero())) {
72
67
  if (convertToRightHandedSystem) {
73
68
  _GLTFUtilities._GetRightHandedPositionVector3FromRef(lightPosition);
@@ -75,11 +70,11 @@ var KHR_lights_punctual = /** @class */ (function () {
75
70
  node.translation = lightPosition.asArray();
76
71
  }
77
72
  if (lightType !== "point" /* POINT */) {
78
- var localAxis = babylonLight.direction;
79
- var yaw = -Math.atan2(localAxis.z * (_this._exporter._babylonScene.useRightHandedSystem ? -1 : 1), localAxis.x) + Math.PI / 2;
80
- var len = Math.sqrt(localAxis.x * localAxis.x + localAxis.z * localAxis.z);
81
- var pitch = -Math.atan2(localAxis.y, len);
82
- var lightRotationQuaternion = Quaternion.RotationYawPitchRoll(yaw, pitch, 0);
73
+ const localAxis = babylonLight.direction;
74
+ const yaw = -Math.atan2(localAxis.z * (this._exporter._babylonScene.useRightHandedSystem ? -1 : 1), localAxis.x) + Math.PI / 2;
75
+ const len = Math.sqrt(localAxis.x * localAxis.x + localAxis.z * localAxis.z);
76
+ const pitch = -Math.atan2(localAxis.y, len);
77
+ const lightRotationQuaternion = Quaternion.RotationYawPitchRoll(yaw, pitch, 0);
83
78
  if (convertToRightHandedSystem) {
84
79
  _GLTFUtilities._GetRightHandedQuaternionFromRef(lightRotationQuaternion);
85
80
  }
@@ -88,7 +83,7 @@ var KHR_lights_punctual = /** @class */ (function () {
88
83
  }
89
84
  }
90
85
  if (babylonLight.falloffType !== Light.FALLOFF_GLTF) {
91
- Logger.Warn("".concat(context, ": Light falloff for ").concat(babylonLight.name, " does not match the ").concat(NAME, " specification!"));
86
+ Logger.Warn(`${context}: Light falloff for ${babylonLight.name} does not match the ${NAME} specification!`);
92
87
  }
93
88
  light = {
94
89
  type: lightType,
@@ -103,7 +98,7 @@ var KHR_lights_punctual = /** @class */ (function () {
103
98
  light.range = babylonLight.range;
104
99
  }
105
100
  if (lightType === "spot" /* SPOT */) {
106
- var babylonSpotLight = babylonLight;
101
+ const babylonSpotLight = babylonLight;
107
102
  if (babylonSpotLight.angle !== Math.PI / 2.0) {
108
103
  if (light.spot == null) {
109
104
  light.spot = {};
@@ -117,50 +112,50 @@ var KHR_lights_punctual = /** @class */ (function () {
117
112
  light.spot.innerConeAngle = babylonSpotLight.innerAngle / 2.0;
118
113
  }
119
114
  }
120
- if (_this._lights == null) {
121
- _this._lights = {
115
+ if (this._lights == null) {
116
+ this._lights = {
122
117
  lights: [],
123
118
  };
124
119
  }
125
- _this._lights.lights.push(light);
126
- var lightReference = {
127
- light: _this._lights.lights.length - 1,
120
+ this._lights.lights.push(light);
121
+ const lightReference = {
122
+ light: this._lights.lights.length - 1,
128
123
  };
129
124
  // Avoid duplicating the Light's parent node if possible.
130
- var parentBabylonNode = babylonNode.parent;
125
+ const parentBabylonNode = babylonNode.parent;
131
126
  if (parentBabylonNode && parentBabylonNode.getChildren().length == 1) {
132
- var parentNode = _this._exporter._nodes[nodeMap[parentBabylonNode.uniqueId]];
127
+ const parentNode = this._exporter._nodes[nodeMap[parentBabylonNode.uniqueId]];
133
128
  if (parentNode) {
134
- var parentNodeLocalMatrix = TmpVectors.Matrix[0];
135
- var parentInvertNodeLocalMatrix = TmpVectors.Matrix[1];
136
- var parentNodeLocalTranslation = parentNode.translation
129
+ const parentNodeLocalMatrix = TmpVectors.Matrix[0];
130
+ const parentInvertNodeLocalMatrix = TmpVectors.Matrix[1];
131
+ const parentNodeLocalTranslation = parentNode.translation
137
132
  ? new Vector3(parentNode.translation[0], parentNode.translation[1], parentNode.translation[2])
138
133
  : Vector3.Zero();
139
- var parentNodeLocalRotation = parentNode.rotation
134
+ const parentNodeLocalRotation = parentNode.rotation
140
135
  ? new Quaternion(parentNode.rotation[0], parentNode.rotation[1], parentNode.rotation[2], parentNode.rotation[3])
141
136
  : Quaternion.Identity();
142
- var parentNodeLocalScale = parentNode.scale ? new Vector3(parentNode.scale[0], parentNode.scale[1], parentNode.scale[2]) : Vector3.One();
137
+ const parentNodeLocalScale = parentNode.scale ? new Vector3(parentNode.scale[0], parentNode.scale[1], parentNode.scale[2]) : Vector3.One();
143
138
  Matrix.ComposeToRef(parentNodeLocalScale, parentNodeLocalRotation, parentNodeLocalTranslation, parentNodeLocalMatrix);
144
139
  parentNodeLocalMatrix.invertToRef(parentInvertNodeLocalMatrix);
145
140
  // Convert light local matrix to local matrix relative to grandparent, facing -Z
146
- var lightLocalMatrix = TmpVectors.Matrix[2];
147
- var nodeLocalTranslation = node.translation ? new Vector3(node.translation[0], node.translation[1], node.translation[2]) : Vector3.Zero();
141
+ const lightLocalMatrix = TmpVectors.Matrix[2];
142
+ const nodeLocalTranslation = node.translation ? new Vector3(node.translation[0], node.translation[1], node.translation[2]) : Vector3.Zero();
148
143
  // Undo directional light positional offset
149
144
  if (babylonLight instanceof DirectionalLight) {
150
- nodeLocalTranslation.subtractInPlace(_this._exporter._babylonScene.useRightHandedSystem
145
+ nodeLocalTranslation.subtractInPlace(this._exporter._babylonScene.useRightHandedSystem
151
146
  ? babylonLight.direction
152
147
  : _GLTFUtilities._GetRightHandedPositionVector3(babylonLight.direction));
153
148
  }
154
- var nodeLocalRotation = _this._exporter._babylonScene.useRightHandedSystem ? Quaternion.Identity() : new Quaternion(0, 1, 0, 0);
149
+ const nodeLocalRotation = this._exporter._babylonScene.useRightHandedSystem ? Quaternion.Identity() : new Quaternion(0, 1, 0, 0);
155
150
  if (node.rotation) {
156
151
  nodeLocalRotation.multiplyInPlace(new Quaternion(node.rotation[0], node.rotation[1], node.rotation[2], node.rotation[3]));
157
152
  }
158
- var nodeLocalScale = node.scale ? new Vector3(node.scale[0], node.scale[1], node.scale[2]) : Vector3.One();
153
+ const nodeLocalScale = node.scale ? new Vector3(node.scale[0], node.scale[1], node.scale[2]) : Vector3.One();
159
154
  Matrix.ComposeToRef(nodeLocalScale, nodeLocalRotation, nodeLocalTranslation, lightLocalMatrix);
160
155
  lightLocalMatrix.multiplyToRef(parentInvertNodeLocalMatrix, lightLocalMatrix);
161
- var parentNewScale = TmpVectors.Vector3[0];
162
- var parentNewRotationQuaternion = TmpVectors.Quaternion[0];
163
- var parentNewTranslation = TmpVectors.Vector3[1];
156
+ const parentNewScale = TmpVectors.Vector3[0];
157
+ const parentNewRotationQuaternion = TmpVectors.Quaternion[0];
158
+ const parentNewTranslation = TmpVectors.Vector3[1];
164
159
  lightLocalMatrix.decompose(parentNewScale, parentNewRotationQuaternion, parentNewTranslation);
165
160
  parentNode.scale = parentNewScale.asArray();
166
161
  parentNode.rotation = parentNewRotationQuaternion.asArray();
@@ -182,9 +177,7 @@ var KHR_lights_punctual = /** @class */ (function () {
182
177
  }
183
178
  resolve(node);
184
179
  });
185
- };
186
- return KHR_lights_punctual;
187
- }());
188
- export { KHR_lights_punctual };
189
- _Exporter.RegisterExtension(NAME, function (exporter) { return new KHR_lights_punctual(exporter); });
180
+ }
181
+ }
182
+ _Exporter.RegisterExtension(NAME, (exporter) => new KHR_lights_punctual(exporter));
190
183
  //# sourceMappingURL=KHR_lights_punctual.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"KHR_lights_punctual.js","sourceRoot":"","sources":["../../../../../../../lts/serializers/generated/glTF/2.0/Extensions/KHR_lights_punctual.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,6CAA+B;AACjF,OAAO,EAAE,MAAM,EAAE,4CAA8B;AAC/C,OAAO,EAAE,KAAK,EAAE,wCAA0B;AAC1C,OAAO,EAAE,gBAAgB,EAAE,mDAAqC;AAEhE,OAAO,EAAE,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AG,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;4BAC7D,IAAM,oBAAoB,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;4BAEnD,gBAAgB,CAAC,SAAS,CAAC,cAAc,EAAE,2BAA2B,EAAE,oBAAoB,CAAC,CAAC;4BAC9F,UAAU,CAAC,KAAK,GAAG,cAAc,CAAC,OAAO,EAAE,CAAC;4BAC5C,UAAU,CAAC,QAAQ,GAAG,2BAA2B,CAAC,OAAO,EAAE,CAAC;4BAC5D,UAAU,CAAC,WAAW,GAAG,oBAAoB,CAAC,OAAO,EAAE,CAAC;4BAExD,IAAI,UAAU,CAAC,UAAU,IAAI,IAAI,EAAE;gCAC/B,UAAU,CAAC,UAAU,GAAG,EAAE,CAAC;6BAC9B;4BACD,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,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,AApMD,IAoMC;;AAED,SAAS,CAAC,iBAAiB,CAAC,IAAI,EAAE,UAAC,QAAQ,IAAK,OAAA,IAAI,mBAAmB,CAAC,QAAQ,CAAC,EAAjC,CAAiC,CAAC,CAAC","sourcesContent":["import type { SpotLight } from \"core/Lights/spotLight\";\r\nimport type { Nullable } from \"core/types\";\r\nimport { Vector3, Quaternion, TmpVectors, Matrix } from \"core/Maths/math.vector\";\r\nimport { Color3 } from \"core/Maths/math.color\";\r\nimport { Light } from \"core/Lights/light\";\r\nimport { DirectionalLight } from \"core/Lights/directionalLight\";\r\nimport type { Node } from \"core/node\";\r\nimport { ShadowLight } from \"core/Lights/shadowLight\";\r\nimport type { INode, IKHRLightsPunctual_LightReference, IKHRLightsPunctual_Light, IKHRLightsPunctual } from \"babylonjs-gltf2interface\";\r\nimport { KHRLightsPunctual_LightType } from \"babylonjs-gltf2interface\";\r\nimport type { IGLTFExporterExtensionV2 } from \"../glTFExporterExtension\";\r\nimport { _Exporter } from \"../glTFExporter\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport { _GLTFUtilities } from \"../glTFUtilities\";\r\n\r\nconst NAME = \"KHR_lights_punctual\";\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_lights_punctual implements IGLTFExporterExtensionV2 {\r\n /** The name of this extension. */\r\n public readonly name = NAME;\r\n\r\n /** Defines whether this extension is enabled. */\r\n public enabled = true;\r\n\r\n /** Defines whether this extension is required */\r\n public required = false;\r\n\r\n /** Reference to the glTF exporter */\r\n private _exporter: _Exporter;\r\n\r\n private _lights: IKHRLightsPunctual;\r\n\r\n /**\r\n * @param exporter\r\n * @hidden\r\n */\r\n constructor(exporter: _Exporter) {\r\n this._exporter = exporter;\r\n }\r\n\r\n /** @hidden */\r\n public dispose() {\r\n (this._lights as any) = null;\r\n }\r\n\r\n /** @hidden */\r\n public get wasUsed() {\r\n return !!this._lights;\r\n }\r\n\r\n /** @hidden */\r\n public onExporting(): void {\r\n this._exporter!._glTF.extensions![NAME] = this._lights;\r\n }\r\n /**\r\n * Define this method to modify the default behavior when exporting a node\r\n * @param context The context when exporting the node\r\n * @param node glTF node\r\n * @param babylonNode BabylonJS node\r\n * @param nodeMap Node mapping of unique id to glTF node index\r\n * @returns nullable INode promise\r\n */\r\n public postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: { [key: number]: number }): Promise<Nullable<INode>> {\r\n return new Promise((resolve) => {\r\n if (node && babylonNode instanceof ShadowLight) {\r\n const babylonLight: ShadowLight = babylonNode;\r\n let light: IKHRLightsPunctual_Light;\r\n\r\n const lightType =\r\n babylonLight.getTypeID() == Light.LIGHTTYPEID_POINTLIGHT\r\n ? KHRLightsPunctual_LightType.POINT\r\n : babylonLight.getTypeID() == Light.LIGHTTYPEID_DIRECTIONALLIGHT\r\n ? KHRLightsPunctual_LightType.DIRECTIONAL\r\n : babylonLight.getTypeID() == Light.LIGHTTYPEID_SPOTLIGHT\r\n ? KHRLightsPunctual_LightType.SPOT\r\n : null;\r\n if (lightType == null) {\r\n Logger.Warn(`${context}: Light ${babylonLight.name} is not supported in ${NAME}`);\r\n } else {\r\n const lightPosition = babylonLight.position.clone();\r\n const convertToRightHandedSystem = this._exporter._convertToRightHandedSystemMap[babylonNode.uniqueId];\r\n if (!lightPosition.equals(Vector3.Zero())) {\r\n if (convertToRightHandedSystem) {\r\n _GLTFUtilities._GetRightHandedPositionVector3FromRef(lightPosition);\r\n }\r\n node.translation = lightPosition.asArray();\r\n }\r\n if (lightType !== KHRLightsPunctual_LightType.POINT) {\r\n const localAxis = babylonLight.direction;\r\n const yaw = -Math.atan2(localAxis.z * (this._exporter._babylonScene.useRightHandedSystem ? -1 : 1), localAxis.x) + Math.PI / 2;\r\n const len = Math.sqrt(localAxis.x * localAxis.x + localAxis.z * localAxis.z);\r\n const pitch = -Math.atan2(localAxis.y, len);\r\n const lightRotationQuaternion = Quaternion.RotationYawPitchRoll(yaw, pitch, 0);\r\n if (convertToRightHandedSystem) {\r\n _GLTFUtilities._GetRightHandedQuaternionFromRef(lightRotationQuaternion);\r\n }\r\n if (!lightRotationQuaternion.equals(Quaternion.Identity())) {\r\n node.rotation = lightRotationQuaternion.asArray();\r\n }\r\n }\r\n\r\n if (babylonLight.falloffType !== Light.FALLOFF_GLTF) {\r\n Logger.Warn(`${context}: Light falloff for ${babylonLight.name} does not match the ${NAME} specification!`);\r\n }\r\n light = {\r\n type: lightType,\r\n };\r\n if (!babylonLight.diffuse.equals(Color3.White())) {\r\n light.color = babylonLight.diffuse.asArray();\r\n }\r\n if (babylonLight.intensity !== 1.0) {\r\n light.intensity = babylonLight.intensity;\r\n }\r\n if (babylonLight.range !== Number.MAX_VALUE) {\r\n light.range = babylonLight.range;\r\n }\r\n\r\n if (lightType === KHRLightsPunctual_LightType.SPOT) {\r\n const babylonSpotLight = babylonLight as SpotLight;\r\n if (babylonSpotLight.angle !== Math.PI / 2.0) {\r\n if (light.spot == null) {\r\n light.spot = {};\r\n }\r\n light.spot.outerConeAngle = babylonSpotLight.angle / 2.0;\r\n }\r\n if (babylonSpotLight.innerAngle !== 0) {\r\n if (light.spot == null) {\r\n light.spot = {};\r\n }\r\n light.spot.innerConeAngle = babylonSpotLight.innerAngle / 2.0;\r\n }\r\n }\r\n\r\n if (this._lights == null) {\r\n this._lights = {\r\n lights: [],\r\n };\r\n }\r\n\r\n this._lights.lights.push(light);\r\n\r\n const lightReference: IKHRLightsPunctual_LightReference = {\r\n light: this._lights.lights.length - 1,\r\n };\r\n\r\n // Avoid duplicating the Light's parent node if possible.\r\n const parentBabylonNode = babylonNode.parent;\r\n if (parentBabylonNode && parentBabylonNode.getChildren().length == 1) {\r\n const parentNode = this._exporter._nodes[nodeMap![parentBabylonNode.uniqueId]];\r\n if (parentNode) {\r\n const parentNodeLocalMatrix = TmpVectors.Matrix[0];\r\n const parentInvertNodeLocalMatrix = TmpVectors.Matrix[1];\r\n const parentNodeLocalTranslation = parentNode.translation\r\n ? new Vector3(parentNode.translation[0], parentNode.translation[1], parentNode.translation[2])\r\n : Vector3.Zero();\r\n const parentNodeLocalRotation = parentNode.rotation\r\n ? new Quaternion(parentNode.rotation[0], parentNode.rotation[1], parentNode.rotation[2], parentNode.rotation[3])\r\n : Quaternion.Identity();\r\n const parentNodeLocalScale = parentNode.scale ? new Vector3(parentNode.scale[0], parentNode.scale[1], parentNode.scale[2]) : Vector3.One();\r\n\r\n Matrix.ComposeToRef(parentNodeLocalScale, parentNodeLocalRotation, parentNodeLocalTranslation, parentNodeLocalMatrix);\r\n parentNodeLocalMatrix.invertToRef(parentInvertNodeLocalMatrix);\r\n\r\n // Convert light local matrix to local matrix relative to grandparent, facing -Z\r\n const lightLocalMatrix = TmpVectors.Matrix[2];\r\n const nodeLocalTranslation = node.translation ? new Vector3(node.translation[0], node.translation[1], node.translation[2]) : Vector3.Zero();\r\n\r\n // Undo directional light positional offset\r\n if (babylonLight instanceof DirectionalLight) {\r\n nodeLocalTranslation.subtractInPlace(\r\n this._exporter._babylonScene.useRightHandedSystem\r\n ? babylonLight.direction\r\n : _GLTFUtilities._GetRightHandedPositionVector3(babylonLight.direction)\r\n );\r\n }\r\n const nodeLocalRotation = this._exporter._babylonScene.useRightHandedSystem ? Quaternion.Identity() : new Quaternion(0, 1, 0, 0);\r\n if (node.rotation) {\r\n nodeLocalRotation.multiplyInPlace(new Quaternion(node.rotation[0], node.rotation[1], node.rotation[2], node.rotation[3]));\r\n }\r\n const nodeLocalScale = node.scale ? new Vector3(node.scale[0], node.scale[1], node.scale[2]) : Vector3.One();\r\n\r\n Matrix.ComposeToRef(nodeLocalScale, nodeLocalRotation, nodeLocalTranslation, lightLocalMatrix);\r\n lightLocalMatrix.multiplyToRef(parentInvertNodeLocalMatrix, lightLocalMatrix);\r\n const parentNewScale = TmpVectors.Vector3[0];\r\n const parentNewRotationQuaternion = TmpVectors.Quaternion[0];\r\n const parentNewTranslation = TmpVectors.Vector3[1];\r\n\r\n lightLocalMatrix.decompose(parentNewScale, parentNewRotationQuaternion, parentNewTranslation);\r\n parentNode.scale = parentNewScale.asArray();\r\n parentNode.rotation = parentNewRotationQuaternion.asArray();\r\n parentNode.translation = parentNewTranslation.asArray();\r\n\r\n if (parentNode.extensions == null) {\r\n parentNode.extensions = {};\r\n }\r\n parentNode.extensions[NAME] = lightReference;\r\n\r\n // Do not export the original node\r\n resolve(null);\r\n return;\r\n }\r\n }\r\n\r\n if (node.extensions == null) {\r\n node.extensions = {};\r\n }\r\n\r\n node.extensions[NAME] = lightReference;\r\n }\r\n }\r\n resolve(node);\r\n });\r\n }\r\n}\r\n\r\n_Exporter.RegisterExtension(NAME, (exporter) => new KHR_lights_punctual(exporter));\r\n"]}
1
+ {"version":3,"file":"KHR_lights_punctual.js","sourceRoot":"","sources":["../../../../../../../lts/serializers/generated/glTF/2.0/Extensions/KHR_lights_punctual.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,6CAA+B;AACjF,OAAO,EAAE,MAAM,EAAE,4CAA8B;AAC/C,OAAO,EAAE,KAAK,EAAE,wCAA0B;AAC1C,OAAO,EAAE,gBAAgB,EAAE,mDAAqC;AAEhE,OAAO,EAAE,WAAW,EAAE,8CAAgC;AAItD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,uCAAyB;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,MAAM,IAAI,GAAG,qBAAqB,CAAC;AAEnC;;GAEG;AACH,gEAAgE;AAChE,MAAM,OAAO,mBAAmB;IAe5B;;;OAGG;IACH,YAAY,QAAmB;QAlB/B,kCAAkC;QAClB,SAAI,GAAG,IAAI,CAAC;QAE5B,iDAAiD;QAC1C,YAAO,GAAG,IAAI,CAAC;QAEtB,iDAAiD;QAC1C,aAAQ,GAAG,KAAK,CAAC;QAYpB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC9B,CAAC;IAED,cAAc;IACP,OAAO;QACT,IAAI,CAAC,OAAe,GAAG,IAAI,CAAC;IACjC,CAAC;IAED,cAAc;IACd,IAAW,OAAO;QACd,OAAO,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC;IAC1B,CAAC;IAED,cAAc;IACP,WAAW;QACd,IAAI,CAAC,SAAU,CAAC,KAAK,CAAC,UAAW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,UAAU,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC;iBAC1C;aACJ;YACD,OAAO,CAAC,IAAI,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAED,SAAS,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC","sourcesContent":["import type { SpotLight } from \"core/Lights/spotLight\";\r\nimport type { Nullable } from \"core/types\";\r\nimport { Vector3, Quaternion, TmpVectors, Matrix } from \"core/Maths/math.vector\";\r\nimport { Color3 } from \"core/Maths/math.color\";\r\nimport { Light } from \"core/Lights/light\";\r\nimport { DirectionalLight } from \"core/Lights/directionalLight\";\r\nimport type { Node } from \"core/node\";\r\nimport { ShadowLight } from \"core/Lights/shadowLight\";\r\nimport type { INode, IKHRLightsPunctual_LightReference, IKHRLightsPunctual_Light, IKHRLightsPunctual } from \"babylonjs-gltf2interface\";\r\nimport { KHRLightsPunctual_LightType } from \"babylonjs-gltf2interface\";\r\nimport type { IGLTFExporterExtensionV2 } from \"../glTFExporterExtension\";\r\nimport { _Exporter } from \"../glTFExporter\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport { _GLTFUtilities } from \"../glTFUtilities\";\r\n\r\nconst NAME = \"KHR_lights_punctual\";\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_lights_punctual implements IGLTFExporterExtensionV2 {\r\n /** The name of this extension. */\r\n public readonly name = NAME;\r\n\r\n /** Defines whether this extension is enabled. */\r\n public enabled = true;\r\n\r\n /** Defines whether this extension is required */\r\n public required = false;\r\n\r\n /** Reference to the glTF exporter */\r\n private _exporter: _Exporter;\r\n\r\n private _lights: IKHRLightsPunctual;\r\n\r\n /**\r\n * @param exporter\r\n * @hidden\r\n */\r\n constructor(exporter: _Exporter) {\r\n this._exporter = exporter;\r\n }\r\n\r\n /** @hidden */\r\n public dispose() {\r\n (this._lights as any) = null;\r\n }\r\n\r\n /** @hidden */\r\n public get wasUsed() {\r\n return !!this._lights;\r\n }\r\n\r\n /** @hidden */\r\n public onExporting(): void {\r\n this._exporter!._glTF.extensions![NAME] = this._lights;\r\n }\r\n /**\r\n * Define this method to modify the default behavior when exporting a node\r\n * @param context The context when exporting the node\r\n * @param node glTF node\r\n * @param babylonNode BabylonJS node\r\n * @param nodeMap Node mapping of unique id to glTF node index\r\n * @returns nullable INode promise\r\n */\r\n public postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: { [key: number]: number }): Promise<Nullable<INode>> {\r\n return new Promise((resolve) => {\r\n if (node && babylonNode instanceof ShadowLight) {\r\n const babylonLight: ShadowLight = babylonNode;\r\n let light: IKHRLightsPunctual_Light;\r\n\r\n const lightType =\r\n babylonLight.getTypeID() == Light.LIGHTTYPEID_POINTLIGHT\r\n ? KHRLightsPunctual_LightType.POINT\r\n : babylonLight.getTypeID() == Light.LIGHTTYPEID_DIRECTIONALLIGHT\r\n ? KHRLightsPunctual_LightType.DIRECTIONAL\r\n : babylonLight.getTypeID() == Light.LIGHTTYPEID_SPOTLIGHT\r\n ? KHRLightsPunctual_LightType.SPOT\r\n : null;\r\n if (lightType == null) {\r\n Logger.Warn(`${context}: Light ${babylonLight.name} is not supported in ${NAME}`);\r\n } else {\r\n const lightPosition = babylonLight.position.clone();\r\n const convertToRightHandedSystem = this._exporter._convertToRightHandedSystemMap[babylonNode.uniqueId];\r\n if (!lightPosition.equals(Vector3.Zero())) {\r\n if (convertToRightHandedSystem) {\r\n _GLTFUtilities._GetRightHandedPositionVector3FromRef(lightPosition);\r\n }\r\n node.translation = lightPosition.asArray();\r\n }\r\n if (lightType !== KHRLightsPunctual_LightType.POINT) {\r\n const localAxis = babylonLight.direction;\r\n const yaw = -Math.atan2(localAxis.z * (this._exporter._babylonScene.useRightHandedSystem ? -1 : 1), localAxis.x) + Math.PI / 2;\r\n const len = Math.sqrt(localAxis.x * localAxis.x + localAxis.z * localAxis.z);\r\n const pitch = -Math.atan2(localAxis.y, len);\r\n const lightRotationQuaternion = Quaternion.RotationYawPitchRoll(yaw, pitch, 0);\r\n if (convertToRightHandedSystem) {\r\n _GLTFUtilities._GetRightHandedQuaternionFromRef(lightRotationQuaternion);\r\n }\r\n if (!lightRotationQuaternion.equals(Quaternion.Identity())) {\r\n node.rotation = lightRotationQuaternion.asArray();\r\n }\r\n }\r\n\r\n if (babylonLight.falloffType !== Light.FALLOFF_GLTF) {\r\n Logger.Warn(`${context}: Light falloff for ${babylonLight.name} does not match the ${NAME} specification!`);\r\n }\r\n light = {\r\n type: lightType,\r\n };\r\n if (!babylonLight.diffuse.equals(Color3.White())) {\r\n light.color = babylonLight.diffuse.asArray();\r\n }\r\n if (babylonLight.intensity !== 1.0) {\r\n light.intensity = babylonLight.intensity;\r\n }\r\n if (babylonLight.range !== Number.MAX_VALUE) {\r\n light.range = babylonLight.range;\r\n }\r\n\r\n if (lightType === KHRLightsPunctual_LightType.SPOT) {\r\n const babylonSpotLight = babylonLight as SpotLight;\r\n if (babylonSpotLight.angle !== Math.PI / 2.0) {\r\n if (light.spot == null) {\r\n light.spot = {};\r\n }\r\n light.spot.outerConeAngle = babylonSpotLight.angle / 2.0;\r\n }\r\n if (babylonSpotLight.innerAngle !== 0) {\r\n if (light.spot == null) {\r\n light.spot = {};\r\n }\r\n light.spot.innerConeAngle = babylonSpotLight.innerAngle / 2.0;\r\n }\r\n }\r\n\r\n if (this._lights == null) {\r\n this._lights = {\r\n lights: [],\r\n };\r\n }\r\n\r\n this._lights.lights.push(light);\r\n\r\n const lightReference: IKHRLightsPunctual_LightReference = {\r\n light: this._lights.lights.length - 1,\r\n };\r\n\r\n // Avoid duplicating the Light's parent node if possible.\r\n const parentBabylonNode = babylonNode.parent;\r\n if (parentBabylonNode && parentBabylonNode.getChildren().length == 1) {\r\n const parentNode = this._exporter._nodes[nodeMap![parentBabylonNode.uniqueId]];\r\n if (parentNode) {\r\n const parentNodeLocalMatrix = TmpVectors.Matrix[0];\r\n const parentInvertNodeLocalMatrix = TmpVectors.Matrix[1];\r\n const parentNodeLocalTranslation = parentNode.translation\r\n ? new Vector3(parentNode.translation[0], parentNode.translation[1], parentNode.translation[2])\r\n : Vector3.Zero();\r\n const parentNodeLocalRotation = parentNode.rotation\r\n ? new Quaternion(parentNode.rotation[0], parentNode.rotation[1], parentNode.rotation[2], parentNode.rotation[3])\r\n : Quaternion.Identity();\r\n const parentNodeLocalScale = parentNode.scale ? new Vector3(parentNode.scale[0], parentNode.scale[1], parentNode.scale[2]) : Vector3.One();\r\n\r\n Matrix.ComposeToRef(parentNodeLocalScale, parentNodeLocalRotation, parentNodeLocalTranslation, parentNodeLocalMatrix);\r\n parentNodeLocalMatrix.invertToRef(parentInvertNodeLocalMatrix);\r\n\r\n // Convert light local matrix to local matrix relative to grandparent, facing -Z\r\n const lightLocalMatrix = TmpVectors.Matrix[2];\r\n const nodeLocalTranslation = node.translation ? new Vector3(node.translation[0], node.translation[1], node.translation[2]) : Vector3.Zero();\r\n\r\n // Undo directional light positional offset\r\n if (babylonLight instanceof DirectionalLight) {\r\n nodeLocalTranslation.subtractInPlace(\r\n this._exporter._babylonScene.useRightHandedSystem\r\n ? babylonLight.direction\r\n : _GLTFUtilities._GetRightHandedPositionVector3(babylonLight.direction)\r\n );\r\n }\r\n const nodeLocalRotation = this._exporter._babylonScene.useRightHandedSystem ? Quaternion.Identity() : new Quaternion(0, 1, 0, 0);\r\n if (node.rotation) {\r\n nodeLocalRotation.multiplyInPlace(new Quaternion(node.rotation[0], node.rotation[1], node.rotation[2], node.rotation[3]));\r\n }\r\n const nodeLocalScale = node.scale ? new Vector3(node.scale[0], node.scale[1], node.scale[2]) : Vector3.One();\r\n\r\n Matrix.ComposeToRef(nodeLocalScale, nodeLocalRotation, nodeLocalTranslation, lightLocalMatrix);\r\n lightLocalMatrix.multiplyToRef(parentInvertNodeLocalMatrix, lightLocalMatrix);\r\n const parentNewScale = TmpVectors.Vector3[0];\r\n const parentNewRotationQuaternion = TmpVectors.Quaternion[0];\r\n const parentNewTranslation = TmpVectors.Vector3[1];\r\n\r\n lightLocalMatrix.decompose(parentNewScale, parentNewRotationQuaternion, parentNewTranslation);\r\n parentNode.scale = parentNewScale.asArray();\r\n parentNode.rotation = parentNewRotationQuaternion.asArray();\r\n parentNode.translation = parentNewTranslation.asArray();\r\n\r\n if (parentNode.extensions == null) {\r\n parentNode.extensions = {};\r\n }\r\n parentNode.extensions[NAME] = lightReference;\r\n\r\n // Do not export the original node\r\n resolve(null);\r\n return;\r\n }\r\n }\r\n\r\n if (node.extensions == null) {\r\n node.extensions = {};\r\n }\r\n\r\n node.extensions[NAME] = lightReference;\r\n }\r\n }\r\n resolve(node);\r\n });\r\n }\r\n}\r\n\r\n_Exporter.RegisterExtension(NAME, (exporter) => new KHR_lights_punctual(exporter));\r\n"]}
@@ -1,13 +1,13 @@
1
1
  import { _Exporter } from "../glTFExporter.js";
2
2
  import { PBRBaseMaterial } from "@babylonjs/core/Materials/PBR/pbrBaseMaterial.js";
3
3
  import { Tools } from "@babylonjs/core/Misc/tools.js";
4
- var NAME = "KHR_materials_clearcoat";
4
+ const NAME = "KHR_materials_clearcoat";
5
5
  /**
6
6
  * @hidden
7
7
  */
8
8
  // eslint-disable-next-line @typescript-eslint/naming-convention
9
- var KHR_materials_clearcoat = /** @class */ (function () {
10
- function KHR_materials_clearcoat(exporter) {
9
+ export class KHR_materials_clearcoat {
10
+ constructor(exporter) {
11
11
  /** Name of this extension */
12
12
  this.name = NAME;
13
13
  /** Defines whether this extension is enabled */
@@ -17,17 +17,13 @@ var KHR_materials_clearcoat = /** @class */ (function () {
17
17
  this._wasUsed = false;
18
18
  this._exporter = exporter;
19
19
  }
20
- KHR_materials_clearcoat.prototype.dispose = function () { };
21
- Object.defineProperty(KHR_materials_clearcoat.prototype, "wasUsed", {
22
- /** @hidden */
23
- get: function () {
24
- return this._wasUsed;
25
- },
26
- enumerable: false,
27
- configurable: true
28
- });
29
- KHR_materials_clearcoat.prototype.postExportMaterialAdditionalTextures = function (context, node, babylonMaterial) {
30
- var additionalTextures = [];
20
+ dispose() { }
21
+ /** @hidden */
22
+ get wasUsed() {
23
+ return this._wasUsed;
24
+ }
25
+ postExportMaterialAdditionalTextures(context, node, babylonMaterial) {
26
+ const additionalTextures = [];
31
27
  if (babylonMaterial instanceof PBRBaseMaterial) {
32
28
  if (babylonMaterial.clearCoat.isEnabled) {
33
29
  if (babylonMaterial.clearCoat.texture) {
@@ -43,49 +39,46 @@ var KHR_materials_clearcoat = /** @class */ (function () {
43
39
  }
44
40
  }
45
41
  return [];
46
- };
47
- KHR_materials_clearcoat.prototype.postExportMaterialAsync = function (context, node, babylonMaterial) {
48
- var _this = this;
49
- return new Promise(function (resolve) {
42
+ }
43
+ postExportMaterialAsync(context, node, babylonMaterial) {
44
+ return new Promise((resolve) => {
50
45
  if (babylonMaterial instanceof PBRBaseMaterial) {
51
46
  if (!babylonMaterial.clearCoat.isEnabled) {
52
47
  resolve(node);
53
48
  return;
54
49
  }
55
- _this._wasUsed = true;
50
+ this._wasUsed = true;
56
51
  node.extensions = node.extensions || {};
57
- var clearCoatTextureInfo = _this._exporter._glTFMaterialExporter._getTextureInfo(babylonMaterial.clearCoat.texture);
58
- var clearCoatTextureRoughnessInfo = void 0;
52
+ const clearCoatTextureInfo = this._exporter._glTFMaterialExporter._getTextureInfo(babylonMaterial.clearCoat.texture);
53
+ let clearCoatTextureRoughnessInfo;
59
54
  if (babylonMaterial.clearCoat.useRoughnessFromMainTexture) {
60
- clearCoatTextureRoughnessInfo = _this._exporter._glTFMaterialExporter._getTextureInfo(babylonMaterial.clearCoat.texture);
55
+ clearCoatTextureRoughnessInfo = this._exporter._glTFMaterialExporter._getTextureInfo(babylonMaterial.clearCoat.texture);
61
56
  }
62
57
  else {
63
- clearCoatTextureRoughnessInfo = _this._exporter._glTFMaterialExporter._getTextureInfo(babylonMaterial.clearCoat.textureRoughness);
58
+ clearCoatTextureRoughnessInfo = this._exporter._glTFMaterialExporter._getTextureInfo(babylonMaterial.clearCoat.textureRoughness);
64
59
  }
65
60
  if (babylonMaterial.clearCoat.isTintEnabled) {
66
- Tools.Warn("Clear Color tint is not supported for glTF export. Ignoring for: ".concat(babylonMaterial.name));
61
+ Tools.Warn(`Clear Color tint is not supported for glTF export. Ignoring for: ${babylonMaterial.name}`);
67
62
  }
68
63
  if (babylonMaterial.clearCoat.remapF0OnInterfaceChange) {
69
- Tools.Warn("Clear Color F0 remapping is not supported for glTF export. Ignoring for: ".concat(babylonMaterial.name));
64
+ Tools.Warn(`Clear Color F0 remapping is not supported for glTF export. Ignoring for: ${babylonMaterial.name}`);
70
65
  }
71
- var clearCoatNormalTextureInfo = _this._exporter._glTFMaterialExporter._getTextureInfo(babylonMaterial.clearCoat.bumpTexture);
72
- var clearCoatInfo_1 = {
66
+ const clearCoatNormalTextureInfo = this._exporter._glTFMaterialExporter._getTextureInfo(babylonMaterial.clearCoat.bumpTexture);
67
+ const clearCoatInfo = {
73
68
  clearcoatFactor: babylonMaterial.clearCoat.intensity,
74
- clearcoatTexture: clearCoatTextureInfo !== null && clearCoatTextureInfo !== void 0 ? clearCoatTextureInfo : undefined,
69
+ clearcoatTexture: clearCoatTextureInfo ?? undefined,
75
70
  clearcoatRoughnessFactor: babylonMaterial.clearCoat.roughness,
76
- clearcoatRoughnessTexture: clearCoatTextureRoughnessInfo !== null && clearCoatTextureRoughnessInfo !== void 0 ? clearCoatTextureRoughnessInfo : undefined,
77
- clearcoatNormalTexture: clearCoatNormalTextureInfo !== null && clearCoatNormalTextureInfo !== void 0 ? clearCoatNormalTextureInfo : undefined,
78
- hasTextures: function () {
79
- return clearCoatInfo_1.clearcoatTexture !== null || clearCoatInfo_1.clearcoatRoughnessTexture !== null || clearCoatInfo_1.clearcoatRoughnessTexture !== null;
71
+ clearcoatRoughnessTexture: clearCoatTextureRoughnessInfo ?? undefined,
72
+ clearcoatNormalTexture: clearCoatNormalTextureInfo ?? undefined,
73
+ hasTextures: () => {
74
+ return clearCoatInfo.clearcoatTexture !== null || clearCoatInfo.clearcoatRoughnessTexture !== null || clearCoatInfo.clearcoatRoughnessTexture !== null;
80
75
  },
81
76
  };
82
- node.extensions[NAME] = clearCoatInfo_1;
77
+ node.extensions[NAME] = clearCoatInfo;
83
78
  }
84
79
  resolve(node);
85
80
  });
86
- };
87
- return KHR_materials_clearcoat;
88
- }());
89
- export { KHR_materials_clearcoat };
90
- _Exporter.RegisterExtension(NAME, function (exporter) { return new KHR_materials_clearcoat(exporter); });
81
+ }
82
+ }
83
+ _Exporter.RegisterExtension(NAME, (exporter) => new KHR_materials_clearcoat(exporter));
91
84
  //# sourceMappingURL=KHR_materials_clearcoat.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"KHR_materials_clearcoat.js","sourceRoot":"","sources":["../../../../../../../lts/serializers/generated/glTF/2.0/Extensions/KHR_materials_clearcoat.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,eAAe,EAAE,yDAA2C;AAGrE,OAAO,EAAE,KAAK,EAAE,sCAAwB;AAExC,IAAM,IAAI,GAAG,yBAAyB,CAAC;AAEvC;;GAEG;AACH,gEAAgE;AAChE;IAcI,iCAAY,QAAmB;QAb/B,6BAA6B;QACb,SAAI,GAAG,IAAI,CAAC;QAE5B,gDAAgD;QACzC,YAAO,GAAG,IAAI,CAAC;QAEtB,iDAAiD;QAC1C,aAAQ,GAAG,KAAK,CAAC;QAIhB,aAAQ,GAAG,KAAK,CAAC;QAGrB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC9B,CAAC;IAEM,yCAAO,GAAd,cAAkB,CAAC;IAGnB,sBAAW,4CAAO;QADlB,cAAc;aACd;YACI,OAAO,IAAI,CAAC,QAAQ,CAAC;QACzB,CA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BAEF,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,AA3FD,IA2FC;;AAED,SAAS,CAAC,iBAAiB,CAAC,IAAI,EAAE,UAAC,QAAQ,IAAK,OAAA,IAAI,uBAAuB,CAAC,QAAQ,CAAC,EAArC,CAAqC,CAAC,CAAC","sourcesContent":["import type { IMaterial, IKHRMaterialsClearcoat } from \"babylonjs-gltf2interface\";\r\nimport type { IGLTFExporterExtensionV2 } from \"../glTFExporterExtension\";\r\nimport { _Exporter } from \"../glTFExporter\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport { PBRBaseMaterial } from \"core/Materials/PBR/pbrBaseMaterial\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\n\r\nimport { Tools } from \"core/Misc/tools\";\r\n\r\nconst NAME = \"KHR_materials_clearcoat\";\r\n\r\n/**\r\n * @hidden\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_materials_clearcoat implements IGLTFExporterExtensionV2 {\r\n /** Name of this extension */\r\n public readonly name = NAME;\r\n\r\n /** Defines whether this extension is enabled */\r\n public enabled = true;\r\n\r\n /** Defines whether this extension is required */\r\n public required = false;\r\n\r\n private _exporter: _Exporter;\r\n\r\n private _wasUsed = false;\r\n\r\n constructor(exporter: _Exporter) {\r\n this._exporter = exporter;\r\n }\r\n\r\n public dispose() {}\r\n\r\n /** @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) => {\r\n if (babylonMaterial instanceof PBRBaseMaterial) {\r\n if (!babylonMaterial.clearCoat.isEnabled) {\r\n resolve(node);\r\n return;\r\n }\r\n\r\n this._wasUsed = true;\r\n\r\n node.extensions = node.extensions || {};\r\n\r\n const clearCoatTextureInfo = this._exporter._glTFMaterialExporter._getTextureInfo(babylonMaterial.clearCoat.texture);\r\n let clearCoatTextureRoughnessInfo;\r\n if (babylonMaterial.clearCoat.useRoughnessFromMainTexture) {\r\n clearCoatTextureRoughnessInfo = this._exporter._glTFMaterialExporter._getTextureInfo(babylonMaterial.clearCoat.texture);\r\n } else {\r\n clearCoatTextureRoughnessInfo = this._exporter._glTFMaterialExporter._getTextureInfo(babylonMaterial.clearCoat.textureRoughness);\r\n }\r\n\r\n if (babylonMaterial.clearCoat.isTintEnabled) {\r\n Tools.Warn(`Clear Color tint is not supported for glTF export. Ignoring for: ${babylonMaterial.name}`);\r\n }\r\n\r\n if (babylonMaterial.clearCoat.remapF0OnInterfaceChange) {\r\n Tools.Warn(`Clear Color F0 remapping is not supported for glTF export. Ignoring for: ${babylonMaterial.name}`);\r\n }\r\n\r\n const clearCoatNormalTextureInfo = this._exporter._glTFMaterialExporter._getTextureInfo(babylonMaterial.clearCoat.bumpTexture);\r\n\r\n const clearCoatInfo: IKHRMaterialsClearcoat = {\r\n clearcoatFactor: babylonMaterial.clearCoat.intensity,\r\n clearcoatTexture: clearCoatTextureInfo ?? undefined,\r\n clearcoatRoughnessFactor: babylonMaterial.clearCoat.roughness,\r\n clearcoatRoughnessTexture: clearCoatTextureRoughnessInfo ?? undefined,\r\n clearcoatNormalTexture: clearCoatNormalTextureInfo ?? undefined,\r\n hasTextures: () => {\r\n return clearCoatInfo.clearcoatTexture !== null || clearCoatInfo.clearcoatRoughnessTexture !== null || clearCoatInfo.clearcoatRoughnessTexture !== null;\r\n },\r\n };\r\n\r\n node.extensions[NAME] = clearCoatInfo;\r\n }\r\n resolve(node);\r\n });\r\n }\r\n}\r\n\r\n_Exporter.RegisterExtension(NAME, (exporter) => new KHR_materials_clearcoat(exporter));\r\n"]}
1
+ {"version":3,"file":"KHR_materials_clearcoat.js","sourceRoot":"","sources":["../../../../../../../lts/serializers/generated/glTF/2.0/Extensions/KHR_materials_clearcoat.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,eAAe,EAAE,yDAA2C;AAGrE,OAAO,EAAE,KAAK,EAAE,sCAAwB;AAExC,MAAM,IAAI,GAAG,yBAAyB,CAAC;AAEvC;;GAEG;AACH,gEAAgE;AAChE,MAAM,OAAO,uBAAuB;IAchC,YAAY,QAAmB;QAb/B,6BAA6B;QACb,SAAI,GAAG,IAAI,CAAC;QAE5B,gDAAgD;QACzC,YAAO,GAAG,IAAI,CAAC;QAEtB,iDAAiD;QAC1C,aAAQ,GAAG,KAAK,CAAC;QAIhB,aAAQ,GAAG,KAAK,CAAC;QAGrB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC9B,CAAC;IAEM,OAAO,KAAI,CAAC;IAEnB,cAAc;IACd,IAAW,OAAO;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAEM,oCAAoC,CAAE,OAAe,EAAE,IAAe,EAAE,eAAyB;QACpG,MAAM,kBAAkB,GAAkB,EAAE,CAAC;QAC7C,IAAI,eAAe,YAAY,eAAe,EAAE;YAC5C,IAAI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AC","sourcesContent":["import type { IMaterial, IKHRMaterialsClearcoat } from \"babylonjs-gltf2interface\";\r\nimport type { IGLTFExporterExtensionV2 } from \"../glTFExporterExtension\";\r\nimport { _Exporter } from \"../glTFExporter\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport { PBRBaseMaterial } from \"core/Materials/PBR/pbrBaseMaterial\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\n\r\nimport { Tools } from \"core/Misc/tools\";\r\n\r\nconst NAME = \"KHR_materials_clearcoat\";\r\n\r\n/**\r\n * @hidden\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_materials_clearcoat implements IGLTFExporterExtensionV2 {\r\n /** Name of this extension */\r\n public readonly name = NAME;\r\n\r\n /** Defines whether this extension is enabled */\r\n public enabled = true;\r\n\r\n /** Defines whether this extension is required */\r\n public required = false;\r\n\r\n private _exporter: _Exporter;\r\n\r\n private _wasUsed = false;\r\n\r\n constructor(exporter: _Exporter) {\r\n this._exporter = exporter;\r\n }\r\n\r\n public dispose() {}\r\n\r\n /** @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) => {\r\n if (babylonMaterial instanceof PBRBaseMaterial) {\r\n if (!babylonMaterial.clearCoat.isEnabled) {\r\n resolve(node);\r\n return;\r\n }\r\n\r\n this._wasUsed = true;\r\n\r\n node.extensions = node.extensions || {};\r\n\r\n const clearCoatTextureInfo = this._exporter._glTFMaterialExporter._getTextureInfo(babylonMaterial.clearCoat.texture);\r\n let clearCoatTextureRoughnessInfo;\r\n if (babylonMaterial.clearCoat.useRoughnessFromMainTexture) {\r\n clearCoatTextureRoughnessInfo = this._exporter._glTFMaterialExporter._getTextureInfo(babylonMaterial.clearCoat.texture);\r\n } else {\r\n clearCoatTextureRoughnessInfo = this._exporter._glTFMaterialExporter._getTextureInfo(babylonMaterial.clearCoat.textureRoughness);\r\n }\r\n\r\n if (babylonMaterial.clearCoat.isTintEnabled) {\r\n Tools.Warn(`Clear Color tint is not supported for glTF export. Ignoring for: ${babylonMaterial.name}`);\r\n }\r\n\r\n if (babylonMaterial.clearCoat.remapF0OnInterfaceChange) {\r\n Tools.Warn(`Clear Color F0 remapping is not supported for glTF export. Ignoring for: ${babylonMaterial.name}`);\r\n }\r\n\r\n const clearCoatNormalTextureInfo = this._exporter._glTFMaterialExporter._getTextureInfo(babylonMaterial.clearCoat.bumpTexture);\r\n\r\n const clearCoatInfo: IKHRMaterialsClearcoat = {\r\n clearcoatFactor: babylonMaterial.clearCoat.intensity,\r\n clearcoatTexture: clearCoatTextureInfo ?? undefined,\r\n clearcoatRoughnessFactor: babylonMaterial.clearCoat.roughness,\r\n clearcoatRoughnessTexture: clearCoatTextureRoughnessInfo ?? undefined,\r\n clearcoatNormalTexture: clearCoatNormalTextureInfo ?? undefined,\r\n hasTextures: () => {\r\n return clearCoatInfo.clearcoatTexture !== null || clearCoatInfo.clearcoatRoughnessTexture !== null || clearCoatInfo.clearcoatRoughnessTexture !== null;\r\n },\r\n };\r\n\r\n node.extensions[NAME] = clearCoatInfo;\r\n }\r\n resolve(node);\r\n });\r\n }\r\n}\r\n\r\n_Exporter.RegisterExtension(NAME, (exporter) => new KHR_materials_clearcoat(exporter));\r\n"]}
@@ -1,12 +1,12 @@
1
1
  import { _Exporter } from "../glTFExporter.js";
2
2
  import { PBRMaterial } from "@babylonjs/core/Materials/PBR/pbrMaterial.js";
3
- var NAME = "KHR_materials_ior";
3
+ const NAME = "KHR_materials_ior";
4
4
  /**
5
5
  * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_ior/README.md)
6
6
  */
7
7
  // eslint-disable-next-line @typescript-eslint/naming-convention
8
- var KHR_materials_ior = /** @class */ (function () {
9
- function KHR_materials_ior() {
8
+ export class KHR_materials_ior {
9
+ constructor() {
10
10
  /** Name of this extension */
11
11
  this.name = NAME;
12
12
  /** Defines whether this extension is enabled */
@@ -15,28 +15,23 @@ var KHR_materials_ior = /** @class */ (function () {
15
15
  this.required = false;
16
16
  this._wasUsed = false;
17
17
  }
18
- KHR_materials_ior.prototype.dispose = function () { };
19
- Object.defineProperty(KHR_materials_ior.prototype, "wasUsed", {
20
- /** @hidden */
21
- get: function () {
22
- return this._wasUsed;
23
- },
24
- enumerable: false,
25
- configurable: true
26
- });
27
- KHR_materials_ior.prototype._isExtensionEnabled = function (mat) {
18
+ dispose() { }
19
+ /** @hidden */
20
+ get wasUsed() {
21
+ return this._wasUsed;
22
+ }
23
+ _isExtensionEnabled(mat) {
28
24
  // This extension must not be used on a material that also uses KHR_materials_unlit
29
25
  if (mat.unlit) {
30
26
  return false;
31
27
  }
32
28
  return mat.indexOfRefraction != undefined && mat.indexOfRefraction != 1.5; // 1.5 is normative default value.
33
- };
34
- KHR_materials_ior.prototype.postExportMaterialAsync = function (context, node, babylonMaterial) {
35
- var _this = this;
36
- return new Promise(function (resolve) {
37
- if (babylonMaterial instanceof PBRMaterial && _this._isExtensionEnabled(babylonMaterial)) {
38
- _this._wasUsed = true;
39
- var iorInfo = {
29
+ }
30
+ postExportMaterialAsync(context, node, babylonMaterial) {
31
+ return new Promise((resolve) => {
32
+ if (babylonMaterial instanceof PBRMaterial && this._isExtensionEnabled(babylonMaterial)) {
33
+ this._wasUsed = true;
34
+ const iorInfo = {
40
35
  ior: babylonMaterial.indexOfRefraction,
41
36
  };
42
37
  node.extensions = node.extensions || {};
@@ -44,10 +39,8 @@ var KHR_materials_ior = /** @class */ (function () {
44
39
  }
45
40
  resolve(node);
46
41
  });
47
- };
48
- return KHR_materials_ior;
49
- }());
50
- export { KHR_materials_ior };
42
+ }
43
+ }
51
44
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
52
- _Exporter.RegisterExtension(NAME, function (exporter) { return new KHR_materials_ior(); });
45
+ _Exporter.RegisterExtension(NAME, (exporter) => new KHR_materials_ior());
53
46
  //# sourceMappingURL=KHR_materials_ior.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"KHR_materials_ior.js","sourceRoot":"","sources":["../../../../../../../lts/serializers/generated/glTF/2.0/Extensions/KHR_materials_ior.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAE7D,IAAM,IAAI,GAAG,mBAAmB,CAAC;AAEjC;;GAEG;AACH,gEAAgE;AAChE;IAYI;QAXA,6BAA6B;QACb,SAAI,GAAG,IAAI,CAAC;QAE5B,gDAAgD;QACzC,YAAO,GAAG,IAAI,CAAC;QAEtB,iDAAiD;QAC1C,aAAQ,GAAG,KAAK,CAAC;QAEhB,aAAQ,GAAG,KAAK,CAAC;IAEV,CAAC;IAET,mCAAO,GAAd,cAAkB,CAAC;IAGnB,sBAAW,sCAAO;QADlB,cAAc;aACd;YACI,OAAO,IAAI,CAAC,QAAQ,CAAC;QACzB,CAAC;;;OAAA;IAEO,+CAAmB,GAA3B,UAA4B,GAAgB;QACxC,mFAAmF;QACnF,IAAI,GAAG,CAAC,KAAK,EAAE;YACX,OAAO,KAAK,CAAC;SAChB;QACD,OAAO,GAAG,CAAC,iBAAiB,IAAI,SAAS,IAAI,GAAG,CAAC,iBAAiB,IAAI,GAAG,CAAC,CAAC,kCAAkC;IACjH,CAAC;IAEM,mDAAuB,GAA9B,UAAgC,OAAe,EAAE,IAAe,EAAE,eAAyB;QAA3F,iBAaC;QAZG,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO;YACvB,IAAI,eAAe,YAAY,WAAW,IAAI,KAAI,CAAC,mBAAmB,CAAC,eAAe,CAAC,EAAE;gBACrF,KAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;gBAErB,IAAM,OAAO,GAAqB;oBAC9B,GAAG,EAAE,eAAe,CAAC,iBAAiB;iBACzC,CAAC;gBACF,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,EAAE,CAAC;gBACxC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC;aACnC;YACD,OAAO,CAAC,IAAI,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACP,CAAC;IACL,wBAAC;AAAD,CAAC,AA3CD,IA2CC;;AAED,6DAA6D;AAC7D,SAAS,CAAC,iBAAiB,CAAC,IAAI,EAAE,UAAC,QAAQ,IAAK,OAAA,IAAI,iBAAiB,EAAE,EAAvB,CAAuB,CAAC,CAAC","sourcesContent":["import type { IMaterial, IKHRMaterialsIor } from \"babylonjs-gltf2interface\";\r\nimport type { IGLTFExporterExtensionV2 } from \"../glTFExporterExtension\";\r\nimport { _Exporter } from \"../glTFExporter\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport { PBRMaterial } from \"core/Materials/PBR/pbrMaterial\";\r\n\r\nconst NAME = \"KHR_materials_ior\";\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_ior/README.md)\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_materials_ior implements IGLTFExporterExtensionV2 {\r\n /** Name of this extension */\r\n public readonly name = NAME;\r\n\r\n /** Defines whether this extension is enabled */\r\n public enabled = true;\r\n\r\n /** Defines whether this extension is required */\r\n public required = false;\r\n\r\n private _wasUsed = false;\r\n\r\n constructor() {}\r\n\r\n public dispose() {}\r\n\r\n /** @hidden */\r\n public get wasUsed() {\r\n return this._wasUsed;\r\n }\r\n\r\n private _isExtensionEnabled(mat: PBRMaterial): boolean {\r\n // This extension must not be used on a material that also uses KHR_materials_unlit\r\n if (mat.unlit) {\r\n return false;\r\n }\r\n return mat.indexOfRefraction != undefined && mat.indexOfRefraction != 1.5; // 1.5 is normative default value.\r\n }\r\n\r\n public postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial> {\r\n return new Promise((resolve) => {\r\n if (babylonMaterial instanceof PBRMaterial && this._isExtensionEnabled(babylonMaterial)) {\r\n this._wasUsed = true;\r\n\r\n const iorInfo: IKHRMaterialsIor = {\r\n ior: babylonMaterial.indexOfRefraction,\r\n };\r\n node.extensions = node.extensions || {};\r\n node.extensions[NAME] = iorInfo;\r\n }\r\n resolve(node);\r\n });\r\n }\r\n}\r\n\r\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n_Exporter.RegisterExtension(NAME, (exporter) => new KHR_materials_ior());\r\n"]}
1
+ {"version":3,"file":"KHR_materials_ior.js","sourceRoot":"","sources":["../../../../../../../lts/serializers/generated/glTF/2.0/Extensions/KHR_materials_ior.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAE7D,MAAM,IAAI,GAAG,mBAAmB,CAAC;AAEjC;;GAEG;AACH,gEAAgE;AAChE,MAAM,OAAO,iBAAiB;IAY1B;QAXA,6BAA6B;QACb,SAAI,GAAG,IAAI,CAAC;QAE5B,gDAAgD;QACzC,YAAO,GAAG,IAAI,CAAC;QAEtB,iDAAiD;QAC1C,aAAQ,GAAG,KAAK,CAAC;QAEhB,aAAQ,GAAG,KAAK,CAAC;IAEV,CAAC;IAET,OAAO,KAAI,CAAC;IAEnB,cAAc;IACd,IAAW,OAAO;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAEO,mBAAmB,CAAC,GAAgB;QACxC,mFAAmF;QACnF,IAAI,GAAG,CAAC,KAAK,EAAE;YACX,OAAO,KAAK,CAAC;SAChB;QACD,OAAO,GAAG,CAAC,iBAAiB,IAAI,SAAS,IAAI,GAAG,CAAC,iBAAiB,IAAI,GAAG,CAAC,CAAC,kCAAkC;IACjH,CAAC;IAEM,uBAAuB,CAAE,OAAe,EAAE,IAAe,EAAE,eAAyB;QACvF,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC3B,IAAI,eAAe,YAAY,WAAW,IAAI,IAAI,CAAC,mBAAmB,CAAC,eAAe,CAAC,EAAE;gBACrF,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;gBAErB,MAAM,OAAO,GAAqB;oBAC9B,GAAG,EAAE,eAAe,CAAC,iBAAiB;iBACzC,CAAC;gBACF,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,EAAE,CAAC;gBACxC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC;aACnC;YACD,OAAO,CAAC,IAAI,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAED,6DAA6D;AAC7D,SAAS,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,iBAAiB,EAAE,CAAC,CAAC","sourcesContent":["import type { IMaterial, IKHRMaterialsIor } from \"babylonjs-gltf2interface\";\r\nimport type { IGLTFExporterExtensionV2 } from \"../glTFExporterExtension\";\r\nimport { _Exporter } from \"../glTFExporter\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport { PBRMaterial } from \"core/Materials/PBR/pbrMaterial\";\r\n\r\nconst NAME = \"KHR_materials_ior\";\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_ior/README.md)\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_materials_ior implements IGLTFExporterExtensionV2 {\r\n /** Name of this extension */\r\n public readonly name = NAME;\r\n\r\n /** Defines whether this extension is enabled */\r\n public enabled = true;\r\n\r\n /** Defines whether this extension is required */\r\n public required = false;\r\n\r\n private _wasUsed = false;\r\n\r\n constructor() {}\r\n\r\n public dispose() {}\r\n\r\n /** @hidden */\r\n public get wasUsed() {\r\n return this._wasUsed;\r\n }\r\n\r\n private _isExtensionEnabled(mat: PBRMaterial): boolean {\r\n // This extension must not be used on a material that also uses KHR_materials_unlit\r\n if (mat.unlit) {\r\n return false;\r\n }\r\n return mat.indexOfRefraction != undefined && mat.indexOfRefraction != 1.5; // 1.5 is normative default value.\r\n }\r\n\r\n public postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial> {\r\n return new Promise((resolve) => {\r\n if (babylonMaterial instanceof PBRMaterial && this._isExtensionEnabled(babylonMaterial)) {\r\n this._wasUsed = true;\r\n\r\n const iorInfo: IKHRMaterialsIor = {\r\n ior: babylonMaterial.indexOfRefraction,\r\n };\r\n node.extensions = node.extensions || {};\r\n node.extensions[NAME] = iorInfo;\r\n }\r\n resolve(node);\r\n });\r\n }\r\n}\r\n\r\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n_Exporter.RegisterExtension(NAME, (exporter) => new KHR_materials_ior());\r\n"]}