@babylonjs/serializers 8.7.1 → 8.8.1
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/USDZ/usdzExporter.js +2 -0
- package/USDZ/usdzExporter.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_materials_diffuse_roughness.js +1 -0
- package/glTF/2.0/Extensions/EXT_materials_diffuse_roughness.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js +2 -2
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js +2 -0
- package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js.map +1 -1
- 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_emissive_strength.js +2 -2
- package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_sheen.js +2 -2
- package/glTF/2.0/Extensions/KHR_materials_sheen.js.map +1 -1
- package/glTF/2.0/glTFExporter.js +11 -3
- package/glTF/2.0/glTFExporter.js.map +1 -1
- package/glTF/2.0/glTFMaterialExporter.js +13 -10
- package/glTF/2.0/glTFMaterialExporter.js.map +1 -1
- package/package.json +3 -3
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"KHR_materials_sheen.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_sheen.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAG7D,MAAM,IAAI,GAAG,qBAAqB,CAAC;AAEnC;;GAEG;AACH,gEAAgE;AAChE,MAAM,OAAO,mBAAmB;IAc5B,YAAY,QAAsB;QAblC,6BAA6B;QACb,SAAI,GAAG,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,EAAE,CAAC;oBAChC,SAAS,CAAC,iBAAiB,GAAG,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,cAAc,CAAC,eAAe,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,SAAS,CAAC;gBAC9H,CAAC;gBAED,IAAI,eAAe,CAAC,KAAK,CAAC,gBAAgB,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,2BAA2B,EAAE,CAAC;oBAC/F,SAAS,CAAC,qBAAqB,GAAG,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,cAAc,CAAC,eAAe,CAAC,KAAK,CAAC,gBAAgB,CAAC,IAAI,SAAS,CAAC;gBAC3I,CAAC;qBAAM,IAAI,eAAe,CAAC,KAAK,CAAC,OAAO,IAAI,eAAe,CAAC,KAAK,CAAC,2BAA2B,EAAE,CAAC;oBAC5F,SAAS,CAAC,qBAAqB,GAAG,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,cAAc,CAAC,eAAe,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,SAAS,CAAC;gBAClI,CAAC;gBAED,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC;YACtC,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAED,YAAY,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC","sourcesContent":["import type { IMaterial, IKHRMaterialsSheen } from \"babylonjs-gltf2interface\";\r\nimport type { IGLTFExporterExtensionV2 } from \"../glTFExporterExtension\";\r\nimport { GLTFExporter } from \"../glTFExporter\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport { PBRMaterial } from \"core/Materials/PBR/pbrMaterial\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\n\r\nconst NAME = \"KHR_materials_sheen\";\r\n\r\n/**\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_materials_sheen 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 private _exporter: GLTFExporter;\r\n\r\n constructor(exporter: GLTFExporter) {\r\n this._exporter = exporter;\r\n }\r\n\r\n public dispose() {}\r\n\r\n /** @internal */\r\n public get wasUsed() {\r\n return this._wasUsed;\r\n }\r\n\r\n public postExportMaterialAdditionalTextures(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[] {\r\n if (babylonMaterial instanceof PBRMaterial) {\r\n if (babylonMaterial.sheen.isEnabled && babylonMaterial.sheen.texture) {\r\n return [babylonMaterial.sheen.texture];\r\n }\r\n }\r\n\r\n return [];\r\n }\r\n\r\n public async postExportMaterialAsync(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial> {\r\n return await new Promise((resolve) => {\r\n if (babylonMaterial instanceof PBRMaterial) {\r\n if (!babylonMaterial.sheen.isEnabled) {\r\n resolve(node);\r\n return;\r\n }\r\n\r\n this._wasUsed = true;\r\n\r\n if (node.extensions == null) {\r\n node.extensions = {};\r\n }\r\n const sheenInfo: IKHRMaterialsSheen = {\r\n sheenColorFactor: babylonMaterial.sheen.color.asArray(),\r\n sheenRoughnessFactor: babylonMaterial.sheen.roughness ?? 0,\r\n };\r\n\r\n if (sheenInfo.sheenColorTexture !== null || sheenInfo.sheenRoughnessTexture !== null) {\r\n this._exporter._materialNeedsUVsSet.add(babylonMaterial);\r\n }\r\n\r\n if (babylonMaterial.sheen.texture) {\r\n sheenInfo.sheenColorTexture = this._exporter._materialExporter.getTextureInfo(babylonMaterial.sheen.texture) ?? undefined;\r\n }\r\n\r\n if (babylonMaterial.sheen.textureRoughness && !babylonMaterial.sheen.useRoughnessFromMainTexture) {\r\n sheenInfo.sheenRoughnessTexture = this._exporter._materialExporter.getTextureInfo(babylonMaterial.sheen.textureRoughness) ?? undefined;\r\n } else if (babylonMaterial.sheen.texture && babylonMaterial.sheen.useRoughnessFromMainTexture) {\r\n sheenInfo.sheenRoughnessTexture = this._exporter._materialExporter.getTextureInfo(babylonMaterial.sheen.texture) ?? undefined;\r\n }\r\n\r\n node.extensions[NAME] = sheenInfo;\r\n }\r\n resolve(node);\r\n });\r\n }\r\n}\r\n\r\nGLTFExporter.RegisterExtension(NAME, (exporter) => new KHR_materials_sheen(exporter));\r\n"]}
|
package/glTF/2.0/glTFExporter.js
CHANGED
@@ -129,7 +129,7 @@ class ExporterState {
|
|
129
129
|
}
|
130
130
|
/** @internal */
|
131
131
|
export class GLTFExporter {
|
132
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
132
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/promise-function-async
|
133
133
|
_ApplyExtension(node, extensions, index, actionAsync) {
|
134
134
|
if (index >= extensions.length) {
|
135
135
|
return Promise.resolve(node);
|
@@ -138,9 +138,10 @@ export class GLTFExporter {
|
|
138
138
|
if (!currentPromise) {
|
139
139
|
return this._ApplyExtension(node, extensions, index + 1, actionAsync);
|
140
140
|
}
|
141
|
-
|
141
|
+
// eslint-disable-next-line github/no-then
|
142
|
+
return currentPromise.then(async (newNode) => (newNode ? await this._ApplyExtension(newNode, extensions, index + 1, actionAsync) : null));
|
142
143
|
}
|
143
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
144
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/promise-function-async
|
144
145
|
_ApplyExtensions(node, actionAsync) {
|
145
146
|
const extensions = [];
|
146
147
|
for (const name of GLTFExporter._ExtensionNames) {
|
@@ -148,15 +149,18 @@ export class GLTFExporter {
|
|
148
149
|
}
|
149
150
|
return this._ApplyExtension(node, extensions, 0, actionAsync);
|
150
151
|
}
|
152
|
+
// eslint-disable-next-line no-restricted-syntax, @typescript-eslint/promise-function-async
|
151
153
|
_extensionsPreExportTextureAsync(context, babylonTexture, mimeType) {
|
152
154
|
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
153
155
|
return this._ApplyExtensions(babylonTexture, (extension, node) => extension.preExportTextureAsync && extension.preExportTextureAsync(context, node, mimeType));
|
154
156
|
}
|
157
|
+
// eslint-disable-next-line no-restricted-syntax, @typescript-eslint/promise-function-async
|
155
158
|
_extensionsPostExportNodeAsync(context, node, babylonNode, nodeMap, convertToRightHanded) {
|
156
159
|
return this._ApplyExtensions(node,
|
157
160
|
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
158
161
|
(extension, node) => extension.postExportNodeAsync && extension.postExportNodeAsync(context, node, babylonNode, nodeMap, convertToRightHanded, this._bufferManager));
|
159
162
|
}
|
163
|
+
// eslint-disable-next-line no-restricted-syntax, @typescript-eslint/promise-function-async
|
160
164
|
_extensionsPostExportMaterialAsync(context, material, babylonMaterial) {
|
161
165
|
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
162
166
|
return this._ApplyExtensions(material, (extension, node) => extension.postExportMaterialAsync && extension.postExportMaterialAsync(context, node, babylonMaterial));
|
@@ -191,6 +195,7 @@ export class GLTFExporter {
|
|
191
195
|
for (const name of GLTFExporter._ExtensionNames) {
|
192
196
|
const extension = this._extensions[name];
|
193
197
|
if (extension.preGenerateBinaryAsync) {
|
198
|
+
// eslint-disable-next-line no-await-in-loop
|
194
199
|
await extension.preGenerateBinaryAsync(this._bufferManager);
|
195
200
|
}
|
196
201
|
}
|
@@ -672,6 +677,7 @@ export class GLTFExporter {
|
|
672
677
|
const nodes = new Array();
|
673
678
|
this._exportBuffers(babylonRootNodes, state);
|
674
679
|
for (const babylonNode of babylonRootNodes) {
|
680
|
+
// eslint-disable-next-line no-await-in-loop
|
675
681
|
await this._exportNodeAsync(babylonNode, nodes, state);
|
676
682
|
}
|
677
683
|
return nodes;
|
@@ -903,6 +909,7 @@ export class GLTFExporter {
|
|
903
909
|
// Begin processing child nodes once parent has been added to the node list
|
904
910
|
const children = node ? [] : parentNodeChildren;
|
905
911
|
for (const babylonChildNode of babylonNode.getChildren()) {
|
912
|
+
// eslint-disable-next-line no-await-in-loop
|
906
913
|
await this._exportNodeAsync(babylonChildNode, children, state);
|
907
914
|
}
|
908
915
|
if (node && children.length) {
|
@@ -1125,6 +1132,7 @@ export class GLTFExporter {
|
|
1125
1132
|
}
|
1126
1133
|
else {
|
1127
1134
|
// Material
|
1135
|
+
// eslint-disable-next-line no-await-in-loop
|
1128
1136
|
await this._exportMaterialAsync(babylonMaterial, vertexBuffers, subMesh, primitive);
|
1129
1137
|
}
|
1130
1138
|
// Index buffer
|