@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.
- package/OBJ/objSerializer.js +35 -39
- package/OBJ/objSerializer.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js +44 -52
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_lights_punctual.js +49 -56
- package/glTF/2.0/Extensions/KHR_lights_punctual.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.js +31 -38
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_ior.js +18 -25
- package/glTF/2.0/Extensions/KHR_materials_ior.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_iridescence.js +25 -32
- package/glTF/2.0/Extensions/KHR_materials_iridescence.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_sheen.js +24 -32
- package/glTF/2.0/Extensions/KHR_materials_sheen.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_specular.js +29 -37
- package/glTF/2.0/Extensions/KHR_materials_specular.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_transmission.js +29 -37
- package/glTF/2.0/Extensions/KHR_materials_transmission.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_unlit.js +15 -22
- package/glTF/2.0/Extensions/KHR_materials_unlit.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_volume.js +31 -39
- package/glTF/2.0/Extensions/KHR_materials_volume.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_texture_transform.js +33 -42
- package/glTF/2.0/Extensions/KHR_texture_transform.js.map +1 -1
- package/glTF/2.0/glTFAnimation.js +171 -187
- package/glTF/2.0/glTFAnimation.js.map +1 -1
- package/glTF/2.0/glTFData.js +9 -11
- package/glTF/2.0/glTFData.js.map +1 -1
- package/glTF/2.0/glTFExporter.js +498 -544
- package/glTF/2.0/glTFExporter.js.map +1 -1
- package/glTF/2.0/glTFMaterialExporter.js +385 -423
- package/glTF/2.0/glTFMaterialExporter.js.map +1 -1
- package/glTF/2.0/glTFSerializer.js +20 -25
- package/glTF/2.0/glTFSerializer.js.map +1 -1
- package/glTF/2.0/glTFUtilities.js +45 -49
- package/glTF/2.0/glTFUtilities.js.map +1 -1
- package/glTF/2.0/shaders/textureTransform.fragment.js +7 -3
- package/glTF/2.0/shaders/textureTransform.fragment.js.map +1 -1
- package/legacy/legacy-glTF2Serializer.js +16 -16
- package/legacy/legacy-glTF2Serializer.js.map +1 -1
- package/legacy/legacy-objSerializer.js +2 -2
- package/legacy/legacy-objSerializer.js.map +1 -1
- package/legacy/legacy-stlSerializer.js +2 -2
- package/legacy/legacy-stlSerializer.js.map +1 -1
- package/package.json +3 -6
- package/stl/stlSerializer.js +29 -38
- package/stl/stlSerializer.js.map +1 -1
@@ -1,4 +1,3 @@
|
|
1
|
-
import { __awaiter, __generator } from "tslib";
|
2
1
|
import { Vector2 } from "@babylonjs/core/Maths/math.vector.js";
|
3
2
|
import { Color3 } from "@babylonjs/core/Maths/math.color.js";
|
4
3
|
import { Scalar } from "@babylonjs/core/Maths/math.scalar.js";
|
@@ -11,8 +10,8 @@ import { Constants } from "@babylonjs/core/Engines/constants.js";
|
|
11
10
|
* Utility methods for working with glTF material conversion properties. This class should only be used internally
|
12
11
|
* @hidden
|
13
12
|
*/
|
14
|
-
|
15
|
-
|
13
|
+
export class _GLTFMaterialExporter {
|
14
|
+
constructor(exporter) {
|
16
15
|
/**
|
17
16
|
* Mapping to store textures
|
18
17
|
*/
|
@@ -26,47 +25,46 @@ var _GLTFMaterialExporter = /** @class */ (function () {
|
|
26
25
|
* @param color2 second color to compare to
|
27
26
|
* @param epsilon threshold value
|
28
27
|
*/
|
29
|
-
|
28
|
+
static _FuzzyEquals(color1, color2, epsilon) {
|
30
29
|
return Scalar.WithinEpsilon(color1.r, color2.r, epsilon) && Scalar.WithinEpsilon(color1.g, color2.g, epsilon) && Scalar.WithinEpsilon(color1.b, color2.b, epsilon);
|
31
|
-
}
|
30
|
+
}
|
32
31
|
/**
|
33
32
|
* Gets the materials from a Babylon scene and converts them to glTF materials
|
34
33
|
* @param exportMaterials
|
35
34
|
* @param mimeType texture mime type
|
36
35
|
* @param hasTextureCoords specifies if texture coordinates are present on the material
|
37
36
|
*/
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
exportMaterials.forEach(function (material) {
|
37
|
+
_convertMaterialsToGLTFAsync(exportMaterials, mimeType, hasTextureCoords) {
|
38
|
+
const promises = [];
|
39
|
+
exportMaterials.forEach((material) => {
|
42
40
|
if (material.getClassName() === "StandardMaterial") {
|
43
|
-
promises.push(
|
41
|
+
promises.push(this._convertStandardMaterialAsync(material, mimeType, hasTextureCoords));
|
44
42
|
}
|
45
43
|
else if (material.getClassName().indexOf("PBR") !== -1) {
|
46
|
-
promises.push(
|
44
|
+
promises.push(this._convertPBRMaterialAsync(material, mimeType, hasTextureCoords));
|
47
45
|
}
|
48
46
|
else {
|
49
|
-
Tools.Warn(
|
47
|
+
Tools.Warn(`Unsupported material type: ${material.name}`);
|
50
48
|
}
|
51
49
|
});
|
52
|
-
return Promise.all(promises).then(
|
50
|
+
return Promise.all(promises).then(() => {
|
53
51
|
/* do nothing */
|
54
52
|
});
|
55
|
-
}
|
53
|
+
}
|
56
54
|
/**
|
57
55
|
* Makes a copy of the glTF material without the texture parameters
|
58
56
|
* @param originalMaterial original glTF material
|
59
57
|
* @returns glTF material without texture parameters
|
60
58
|
*/
|
61
|
-
|
62
|
-
|
59
|
+
_stripTexturesFromMaterial(originalMaterial) {
|
60
|
+
const newMaterial = {};
|
63
61
|
if (originalMaterial) {
|
64
62
|
newMaterial.name = originalMaterial.name;
|
65
63
|
newMaterial.doubleSided = originalMaterial.doubleSided;
|
66
64
|
newMaterial.alphaMode = originalMaterial.alphaMode;
|
67
65
|
newMaterial.alphaCutoff = originalMaterial.alphaCutoff;
|
68
66
|
newMaterial.emissiveFactor = originalMaterial.emissiveFactor;
|
69
|
-
|
67
|
+
const originalPBRMetallicRoughness = originalMaterial.pbrMetallicRoughness;
|
70
68
|
if (originalPBRMetallicRoughness) {
|
71
69
|
newMaterial.pbrMetallicRoughness = {};
|
72
70
|
newMaterial.pbrMetallicRoughness.baseColorFactor = originalPBRMetallicRoughness.baseColorFactor;
|
@@ -75,53 +73,52 @@ var _GLTFMaterialExporter = /** @class */ (function () {
|
|
75
73
|
}
|
76
74
|
}
|
77
75
|
return newMaterial;
|
78
|
-
}
|
76
|
+
}
|
79
77
|
/**
|
80
78
|
* Specifies if the material has any texture parameters present
|
81
79
|
* @param material glTF Material
|
82
80
|
* @returns boolean specifying if texture parameters are present
|
83
81
|
*/
|
84
|
-
|
85
|
-
var _a;
|
82
|
+
_hasTexturesPresent(material) {
|
86
83
|
if (material.emissiveTexture || material.normalTexture || material.occlusionTexture) {
|
87
84
|
return true;
|
88
85
|
}
|
89
|
-
|
86
|
+
const pbrMat = material.pbrMetallicRoughness;
|
90
87
|
if (pbrMat) {
|
91
88
|
if (pbrMat.baseColorTexture || pbrMat.metallicRoughnessTexture) {
|
92
89
|
return true;
|
93
90
|
}
|
94
91
|
}
|
95
92
|
if (material.extensions) {
|
96
|
-
for (
|
97
|
-
|
93
|
+
for (const extension in material.extensions) {
|
94
|
+
const extensionObject = material.extensions[extension];
|
98
95
|
if (extensionObject) {
|
99
|
-
return
|
96
|
+
return extensionObject.hasTextures?.();
|
100
97
|
}
|
101
98
|
}
|
102
99
|
}
|
103
100
|
return false;
|
104
|
-
}
|
105
|
-
|
101
|
+
}
|
102
|
+
_getTextureInfo(babylonTexture) {
|
106
103
|
if (babylonTexture) {
|
107
|
-
|
104
|
+
const textureUid = babylonTexture.uid;
|
108
105
|
if (textureUid in this._textureMap) {
|
109
106
|
return this._textureMap[textureUid];
|
110
107
|
}
|
111
108
|
}
|
112
109
|
return null;
|
113
|
-
}
|
110
|
+
}
|
114
111
|
/**
|
115
112
|
* Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
|
116
113
|
* @param babylonStandardMaterial
|
117
114
|
* @returns glTF Metallic Roughness Material representation
|
118
115
|
*/
|
119
|
-
|
116
|
+
_convertToGLTFPBRMetallicRoughness(babylonStandardMaterial) {
|
120
117
|
// Defines a cubic bezier curve where x is specular power and y is roughness
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
118
|
+
const P0 = new Vector2(0, 1);
|
119
|
+
const P1 = new Vector2(0, 0.1);
|
120
|
+
const P2 = new Vector2(0, 0.1);
|
121
|
+
const P3 = new Vector2(1300, 0.1);
|
125
122
|
/**
|
126
123
|
* Given the control points, solve for x based on a given t for a cubic bezier curve
|
127
124
|
* @param t a value between 0 and 1
|
@@ -145,20 +142,20 @@ var _GLTFMaterialExporter = /** @class */ (function () {
|
|
145
142
|
// Given P0.x = 0, P1.x = 0, P2.x = 0
|
146
143
|
// x = t * t * t * P3.x
|
147
144
|
// t = (x / P3.x)^(1/3)
|
148
|
-
|
145
|
+
const t = Math.pow(specularPower / P3.x, 0.333333);
|
149
146
|
return cubicBezierCurve(t, P0.y, P1.y, P2.y, P3.y);
|
150
147
|
}
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
148
|
+
const diffuse = babylonStandardMaterial.diffuseColor.toLinearSpace().scale(0.5);
|
149
|
+
const opacity = babylonStandardMaterial.alpha;
|
150
|
+
const specularPower = Scalar.Clamp(babylonStandardMaterial.specularPower, 0, _GLTFMaterialExporter._MaxSpecularPower);
|
151
|
+
const roughness = solveForRoughness(specularPower);
|
152
|
+
const glTFPbrMetallicRoughness = {
|
156
153
|
baseColorFactor: [diffuse.r, diffuse.g, diffuse.b, opacity],
|
157
154
|
metallicFactor: 0,
|
158
155
|
roughnessFactor: roughness,
|
159
156
|
};
|
160
157
|
return glTFPbrMetallicRoughness;
|
161
|
-
}
|
158
|
+
}
|
162
159
|
/**
|
163
160
|
* Computes the metallic factor
|
164
161
|
* @param diffuse diffused value
|
@@ -166,23 +163,23 @@ var _GLTFMaterialExporter = /** @class */ (function () {
|
|
166
163
|
* @param oneMinusSpecularStrength one minus the specular strength
|
167
164
|
* @returns metallic value
|
168
165
|
*/
|
169
|
-
|
166
|
+
static _SolveMetallic(diffuse, specular, oneMinusSpecularStrength) {
|
170
167
|
if (specular < this._DielectricSpecular.r) {
|
171
168
|
this._DielectricSpecular;
|
172
169
|
return 0;
|
173
170
|
}
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
171
|
+
const a = this._DielectricSpecular.r;
|
172
|
+
const b = (diffuse * oneMinusSpecularStrength) / (1.0 - this._DielectricSpecular.r) + specular - 2.0 * this._DielectricSpecular.r;
|
173
|
+
const c = this._DielectricSpecular.r - specular;
|
174
|
+
const D = b * b - 4.0 * a * c;
|
178
175
|
return Scalar.Clamp((-b + Math.sqrt(D)) / (2.0 * a), 0, 1);
|
179
|
-
}
|
176
|
+
}
|
180
177
|
/**
|
181
178
|
* Sets the glTF alpha mode to a glTF material from the Babylon Material
|
182
179
|
* @param glTFMaterial glTF material
|
183
180
|
* @param babylonMaterial Babylon material
|
184
181
|
*/
|
185
|
-
|
182
|
+
static _SetAlphaMode(glTFMaterial, babylonMaterial) {
|
186
183
|
if (babylonMaterial.needAlphaBlending()) {
|
187
184
|
glTFMaterial.alphaMode = "BLEND" /* BLEND */;
|
188
185
|
}
|
@@ -190,19 +187,19 @@ var _GLTFMaterialExporter = /** @class */ (function () {
|
|
190
187
|
glTFMaterial.alphaMode = "MASK" /* MASK */;
|
191
188
|
glTFMaterial.alphaCutoff = babylonMaterial.alphaCutOff;
|
192
189
|
}
|
193
|
-
}
|
190
|
+
}
|
194
191
|
/**
|
195
192
|
* Converts a Babylon Standard Material to a glTF Material
|
196
193
|
* @param babylonStandardMaterial BJS Standard Material
|
197
194
|
* @param mimeType mime type to use for the textures
|
198
195
|
* @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
|
199
196
|
*/
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
197
|
+
_convertStandardMaterialAsync(babylonStandardMaterial, mimeType, hasTextureCoords) {
|
198
|
+
const materialMap = this._exporter._materialMap;
|
199
|
+
const materials = this._exporter._materials;
|
200
|
+
const promises = [];
|
201
|
+
const glTFPbrMetallicRoughness = this._convertToGLTFPBRMetallicRoughness(babylonStandardMaterial);
|
202
|
+
const glTFMaterial = { name: babylonStandardMaterial.name };
|
206
203
|
if (babylonStandardMaterial.backFaceCulling != null && !babylonStandardMaterial.backFaceCulling) {
|
207
204
|
if (!babylonStandardMaterial.twoSidedLighting) {
|
208
205
|
Tools.Warn(babylonStandardMaterial.name + ": Back-face culling disabled and two-sided lighting disabled is not supported in glTF.");
|
@@ -211,14 +208,14 @@ var _GLTFMaterialExporter = /** @class */ (function () {
|
|
211
208
|
}
|
212
209
|
if (hasTextureCoords) {
|
213
210
|
if (babylonStandardMaterial.diffuseTexture) {
|
214
|
-
promises.push(this._exportTextureAsync(babylonStandardMaterial.diffuseTexture, mimeType).then(
|
211
|
+
promises.push(this._exportTextureAsync(babylonStandardMaterial.diffuseTexture, mimeType).then((glTFTexture) => {
|
215
212
|
if (glTFTexture) {
|
216
213
|
glTFPbrMetallicRoughness.baseColorTexture = glTFTexture;
|
217
214
|
}
|
218
215
|
}));
|
219
216
|
}
|
220
217
|
if (babylonStandardMaterial.bumpTexture) {
|
221
|
-
promises.push(this._exportTextureAsync(babylonStandardMaterial.bumpTexture, mimeType).then(
|
218
|
+
promises.push(this._exportTextureAsync(babylonStandardMaterial.bumpTexture, mimeType).then((glTFTexture) => {
|
222
219
|
if (glTFTexture) {
|
223
220
|
glTFMaterial.normalTexture = glTFTexture;
|
224
221
|
if (babylonStandardMaterial.bumpTexture != null && babylonStandardMaterial.bumpTexture.level !== 1) {
|
@@ -229,16 +226,16 @@ var _GLTFMaterialExporter = /** @class */ (function () {
|
|
229
226
|
}
|
230
227
|
if (babylonStandardMaterial.emissiveTexture) {
|
231
228
|
glTFMaterial.emissiveFactor = [1.0, 1.0, 1.0];
|
232
|
-
promises.push(this._exportTextureAsync(babylonStandardMaterial.emissiveTexture, mimeType).then(
|
229
|
+
promises.push(this._exportTextureAsync(babylonStandardMaterial.emissiveTexture, mimeType).then((glTFEmissiveTexture) => {
|
233
230
|
if (glTFEmissiveTexture) {
|
234
231
|
glTFMaterial.emissiveTexture = glTFEmissiveTexture;
|
235
232
|
}
|
236
233
|
}));
|
237
234
|
}
|
238
235
|
if (babylonStandardMaterial.ambientTexture) {
|
239
|
-
promises.push(this._exportTextureAsync(babylonStandardMaterial.ambientTexture, mimeType).then(
|
236
|
+
promises.push(this._exportTextureAsync(babylonStandardMaterial.ambientTexture, mimeType).then((glTFTexture) => {
|
240
237
|
if (glTFTexture) {
|
241
|
-
|
238
|
+
const occlusionTexture = {
|
242
239
|
index: glTFTexture.index,
|
243
240
|
};
|
244
241
|
glTFMaterial.occlusionTexture = occlusionTexture;
|
@@ -263,31 +260,29 @@ var _GLTFMaterialExporter = /** @class */ (function () {
|
|
263
260
|
materials.push(glTFMaterial);
|
264
261
|
materialMap[babylonStandardMaterial.uniqueId] = materials.length - 1;
|
265
262
|
return this._finishMaterial(promises, glTFMaterial, babylonStandardMaterial, mimeType);
|
266
|
-
}
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
for (var _i = 0, textures_1 = textures; _i < textures_1.length; _i++) {
|
273
|
-
var texture = textures_1[_i];
|
263
|
+
}
|
264
|
+
_finishMaterial(promises, glTFMaterial, babylonMaterial, mimeType) {
|
265
|
+
return Promise.all(promises).then(() => {
|
266
|
+
const textures = this._exporter._extensionsPostExportMaterialAdditionalTextures("exportMaterial", glTFMaterial, babylonMaterial);
|
267
|
+
let tasks = null;
|
268
|
+
for (const texture of textures) {
|
274
269
|
if (!tasks) {
|
275
270
|
tasks = [];
|
276
271
|
}
|
277
|
-
tasks.push(
|
272
|
+
tasks.push(this._exportTextureAsync(texture, mimeType));
|
278
273
|
}
|
279
274
|
if (!tasks) {
|
280
275
|
tasks = [Promise.resolve(null)];
|
281
276
|
}
|
282
|
-
return Promise.all(tasks).then(
|
283
|
-
|
277
|
+
return Promise.all(tasks).then(() => {
|
278
|
+
const extensionWork = this._exporter._extensionsPostExportMaterialAsync("exportMaterial", glTFMaterial, babylonMaterial);
|
284
279
|
if (!extensionWork) {
|
285
280
|
return glTFMaterial;
|
286
281
|
}
|
287
|
-
return extensionWork.then(
|
282
|
+
return extensionWork.then(() => glTFMaterial);
|
288
283
|
});
|
289
284
|
});
|
290
|
-
}
|
285
|
+
}
|
291
286
|
/**
|
292
287
|
* Converts an image typed array buffer to a base64 image
|
293
288
|
* @param buffer typed array buffer
|
@@ -296,33 +291,20 @@ var _GLTFMaterialExporter = /** @class */ (function () {
|
|
296
291
|
* @param mimeType mimetype of the image
|
297
292
|
* @returns base64 image string
|
298
293
|
*/
|
299
|
-
|
300
|
-
var _this = this;
|
294
|
+
_createBase64FromCanvasAsync(buffer, width, height, mimeType) {
|
301
295
|
// eslint-disable-next-line no-async-promise-executor
|
302
|
-
return new Promise(
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
return [4 /*yield*/, engine._readTexturePixels(tempTexture, width, height)];
|
315
|
-
case 2:
|
316
|
-
data = _a.sent();
|
317
|
-
return [4 /*yield*/, Tools.DumpDataAsync(width, height, data, mimeType, undefined, true, false)];
|
318
|
-
case 3:
|
319
|
-
base64 = _a.sent();
|
320
|
-
resolve(base64);
|
321
|
-
return [2 /*return*/];
|
322
|
-
}
|
323
|
-
});
|
324
|
-
}); });
|
325
|
-
};
|
296
|
+
return new Promise(async (resolve) => {
|
297
|
+
const textureType = Constants.TEXTURETYPE_UNSIGNED_INT;
|
298
|
+
const hostingScene = this._exporter._babylonScene;
|
299
|
+
const engine = hostingScene.getEngine();
|
300
|
+
// Create a temporary texture with the texture buffer data
|
301
|
+
const tempTexture = engine.createRawTexture(buffer, width, height, Constants.TEXTUREFORMAT_RGBA, false, true, Texture.NEAREST_SAMPLINGMODE, null, textureType);
|
302
|
+
await TextureTools.ApplyPostProcess("pass", tempTexture, hostingScene, textureType, Constants.TEXTURE_NEAREST_SAMPLINGMODE, Constants.TEXTUREFORMAT_RGBA);
|
303
|
+
const data = await engine._readTexturePixels(tempTexture, width, height);
|
304
|
+
const base64 = await Tools.DumpDataAsync(width, height, data, mimeType, undefined, true, false);
|
305
|
+
resolve(base64);
|
306
|
+
});
|
307
|
+
}
|
326
308
|
/**
|
327
309
|
* Generates a white texture based on the specified width and height
|
328
310
|
* @param width width of the texture in pixels
|
@@ -330,14 +312,14 @@ var _GLTFMaterialExporter = /** @class */ (function () {
|
|
330
312
|
* @param scene babylonjs scene
|
331
313
|
* @returns white texture
|
332
314
|
*/
|
333
|
-
|
334
|
-
|
335
|
-
for (
|
315
|
+
_createWhiteTexture(width, height, scene) {
|
316
|
+
const data = new Uint8Array(width * height * 4);
|
317
|
+
for (let i = 0; i < data.length; i = i + 4) {
|
336
318
|
data[i] = data[i + 1] = data[i + 2] = data[i + 3] = 0xff;
|
337
319
|
}
|
338
|
-
|
320
|
+
const rawTexture = RawTexture.CreateRGBATexture(data, width, height, scene);
|
339
321
|
return rawTexture;
|
340
|
-
}
|
322
|
+
}
|
341
323
|
/**
|
342
324
|
* Resizes the two source textures to the same dimensions. If a texture is null, a default white texture is generated. If both textures are null, returns null
|
343
325
|
* @param texture1 first texture to resize
|
@@ -345,11 +327,11 @@ var _GLTFMaterialExporter = /** @class */ (function () {
|
|
345
327
|
* @param scene babylonjs scene
|
346
328
|
* @returns resized textures or null
|
347
329
|
*/
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
330
|
+
_resizeTexturesToSameDimensions(texture1, texture2, scene) {
|
331
|
+
const texture1Size = texture1 ? texture1.getSize() : { width: 0, height: 0 };
|
332
|
+
const texture2Size = texture2 ? texture2.getSize() : { width: 0, height: 0 };
|
333
|
+
let resizedTexture1;
|
334
|
+
let resizedTexture2;
|
353
335
|
if (texture1Size.width < texture2Size.width) {
|
354
336
|
if (texture1 && texture1 instanceof Texture) {
|
355
337
|
resizedTexture1 = TextureTools.CreateResizedCopy(texture1, texture2Size.width, texture2Size.height, true);
|
@@ -376,18 +358,18 @@ var _GLTFMaterialExporter = /** @class */ (function () {
|
|
376
358
|
texture1: resizedTexture1,
|
377
359
|
texture2: resizedTexture2,
|
378
360
|
};
|
379
|
-
}
|
361
|
+
}
|
380
362
|
/**
|
381
363
|
* Converts an array of pixels to a Float32Array
|
382
364
|
* Throws an error if the pixel format is not supported
|
383
365
|
* @param pixels - array buffer containing pixel values
|
384
366
|
* @returns Float32 of pixels
|
385
367
|
*/
|
386
|
-
|
368
|
+
_convertPixelArrayToFloat32(pixels) {
|
387
369
|
if (pixels instanceof Uint8Array) {
|
388
|
-
|
389
|
-
|
390
|
-
for (
|
370
|
+
const length = pixels.length;
|
371
|
+
const buffer = new Float32Array(pixels.length);
|
372
|
+
for (let i = 0; i < length; ++i) {
|
391
373
|
buffer[i] = pixels[i] / 255;
|
392
374
|
}
|
393
375
|
return buffer;
|
@@ -398,7 +380,7 @@ var _GLTFMaterialExporter = /** @class */ (function () {
|
|
398
380
|
else {
|
399
381
|
throw new Error("Unsupported pixel format!");
|
400
382
|
}
|
401
|
-
}
|
383
|
+
}
|
402
384
|
/**
|
403
385
|
* Convert Specular Glossiness Textures to Metallic Roughness
|
404
386
|
* See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
|
@@ -409,174 +391,165 @@ var _GLTFMaterialExporter = /** @class */ (function () {
|
|
409
391
|
* @param mimeType the mime type to use for the texture
|
410
392
|
* @returns pbr metallic roughness interface or null
|
411
393
|
*/
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
maxMetallic = Math.max(maxMetallic, metallicRoughness.metallic);
|
474
|
-
maxRoughness = Math.max(maxRoughness, metallicRoughness.roughness);
|
475
|
-
baseColorBuffer[offset] = metallicRoughness.baseColor.r * 255;
|
476
|
-
baseColorBuffer[offset + 1] = metallicRoughness.baseColor.g * 255;
|
477
|
-
baseColorBuffer[offset + 2] = metallicRoughness.baseColor.b * 255;
|
478
|
-
baseColorBuffer[offset + 3] = resizedTextures.texture1.hasAlpha ? diffuseBuffer[offset + 3] * 255 : 255;
|
479
|
-
metallicRoughnessBuffer[offset] = 0;
|
480
|
-
metallicRoughnessBuffer[offset + 1] = metallicRoughness.roughness * 255;
|
481
|
-
metallicRoughnessBuffer[offset + 2] = metallicRoughness.metallic * 255;
|
482
|
-
metallicRoughnessBuffer[offset + 3] = 255;
|
483
|
-
}
|
484
|
-
}
|
485
|
-
metallicRoughnessFactors_1 = {
|
486
|
-
baseColor: maxBaseColor,
|
487
|
-
metallic: maxMetallic,
|
488
|
-
roughness: maxRoughness,
|
489
|
-
};
|
490
|
-
writeOutMetallicRoughnessTexture = false;
|
491
|
-
writeOutBaseColorTexture = false;
|
492
|
-
for (h = 0; h < height; ++h) {
|
493
|
-
for (w = 0; w < width; ++w) {
|
494
|
-
destinationOffset = (width * h + w) * strideSize;
|
495
|
-
baseColorBuffer[destinationOffset] /= metallicRoughnessFactors_1.baseColor.r > _GLTFMaterialExporter._Epsilon ? metallicRoughnessFactors_1.baseColor.r : 1;
|
496
|
-
baseColorBuffer[destinationOffset + 1] /= metallicRoughnessFactors_1.baseColor.g > _GLTFMaterialExporter._Epsilon ? metallicRoughnessFactors_1.baseColor.g : 1;
|
497
|
-
baseColorBuffer[destinationOffset + 2] /= metallicRoughnessFactors_1.baseColor.b > _GLTFMaterialExporter._Epsilon ? metallicRoughnessFactors_1.baseColor.b : 1;
|
498
|
-
linearBaseColorPixel = Color3.FromInts(baseColorBuffer[destinationOffset], baseColorBuffer[destinationOffset + 1], baseColorBuffer[destinationOffset + 2]);
|
499
|
-
sRGBBaseColorPixel = linearBaseColorPixel.toGammaSpace();
|
500
|
-
baseColorBuffer[destinationOffset] = sRGBBaseColorPixel.r * 255;
|
501
|
-
baseColorBuffer[destinationOffset + 1] = sRGBBaseColorPixel.g * 255;
|
502
|
-
baseColorBuffer[destinationOffset + 2] = sRGBBaseColorPixel.b * 255;
|
503
|
-
if (!_GLTFMaterialExporter._FuzzyEquals(sRGBBaseColorPixel, Color3.White(), _GLTFMaterialExporter._Epsilon)) {
|
504
|
-
writeOutBaseColorTexture = true;
|
505
|
-
}
|
506
|
-
metallicRoughnessBuffer[destinationOffset + 1] /=
|
507
|
-
metallicRoughnessFactors_1.roughness > _GLTFMaterialExporter._Epsilon ? metallicRoughnessFactors_1.roughness : 1;
|
508
|
-
metallicRoughnessBuffer[destinationOffset + 2] /= metallicRoughnessFactors_1.metallic > _GLTFMaterialExporter._Epsilon ? metallicRoughnessFactors_1.metallic : 1;
|
509
|
-
metallicRoughnessPixel = Color3.FromInts(255, metallicRoughnessBuffer[destinationOffset + 1], metallicRoughnessBuffer[destinationOffset + 2]);
|
510
|
-
if (!_GLTFMaterialExporter._FuzzyEquals(metallicRoughnessPixel, Color3.White(), _GLTFMaterialExporter._Epsilon)) {
|
511
|
-
writeOutMetallicRoughnessTexture = true;
|
512
|
-
}
|
513
|
-
}
|
514
|
-
}
|
515
|
-
if (writeOutMetallicRoughnessTexture) {
|
516
|
-
promise = this._createBase64FromCanvasAsync(metallicRoughnessBuffer, width, height, mimeType).then(function (metallicRoughnessBase64) {
|
517
|
-
metallicRoughnessFactors_1.metallicRoughnessTextureBase64 = metallicRoughnessBase64;
|
518
|
-
});
|
519
|
-
promises.push(promise);
|
520
|
-
}
|
521
|
-
if (writeOutBaseColorTexture) {
|
522
|
-
promise = this._createBase64FromCanvasAsync(baseColorBuffer, width, height, mimeType).then(function (baseColorBase64) {
|
523
|
-
metallicRoughnessFactors_1.baseColorTextureBase64 = baseColorBase64;
|
524
|
-
});
|
525
|
-
promises.push(promise);
|
526
|
-
}
|
527
|
-
return [2 /*return*/, Promise.all(promises).then(function () {
|
528
|
-
return metallicRoughnessFactors_1;
|
529
|
-
})];
|
530
|
-
case 3: return [2 /*return*/, Promise.reject("_ConvertSpecularGlossinessTexturesToMetallicRoughness: Scene from textures is missing!")];
|
394
|
+
async _convertSpecularGlossinessTexturesToMetallicRoughnessAsync(diffuseTexture, specularGlossinessTexture, factors, mimeType) {
|
395
|
+
const promises = [];
|
396
|
+
if (!(diffuseTexture || specularGlossinessTexture)) {
|
397
|
+
return Promise.reject("_ConvertSpecularGlosinessTexturesToMetallicRoughness: diffuse and specular glossiness textures are not defined!");
|
398
|
+
}
|
399
|
+
const scene = diffuseTexture ? diffuseTexture.getScene() : specularGlossinessTexture ? specularGlossinessTexture.getScene() : null;
|
400
|
+
if (scene) {
|
401
|
+
const resizedTextures = this._resizeTexturesToSameDimensions(diffuseTexture, specularGlossinessTexture, scene);
|
402
|
+
const diffuseSize = resizedTextures.texture1?.getSize();
|
403
|
+
let diffuseBuffer;
|
404
|
+
let specularGlossinessBuffer;
|
405
|
+
const width = diffuseSize.width;
|
406
|
+
const height = diffuseSize.height;
|
407
|
+
const diffusePixels = await resizedTextures.texture1.readPixels();
|
408
|
+
const specularPixels = await resizedTextures.texture2.readPixels();
|
409
|
+
if (diffusePixels) {
|
410
|
+
diffuseBuffer = this._convertPixelArrayToFloat32(diffusePixels);
|
411
|
+
}
|
412
|
+
else {
|
413
|
+
return Promise.reject("Failed to retrieve pixels from diffuse texture!");
|
414
|
+
}
|
415
|
+
if (specularPixels) {
|
416
|
+
specularGlossinessBuffer = this._convertPixelArrayToFloat32(specularPixels);
|
417
|
+
}
|
418
|
+
else {
|
419
|
+
return Promise.reject("Failed to retrieve pixels from specular glossiness texture!");
|
420
|
+
}
|
421
|
+
const byteLength = specularGlossinessBuffer.byteLength;
|
422
|
+
const metallicRoughnessBuffer = new Uint8Array(byteLength);
|
423
|
+
const baseColorBuffer = new Uint8Array(byteLength);
|
424
|
+
const strideSize = 4;
|
425
|
+
const maxBaseColor = Color3.Black();
|
426
|
+
let maxMetallic = 0;
|
427
|
+
let maxRoughness = 0;
|
428
|
+
for (let h = 0; h < height; ++h) {
|
429
|
+
for (let w = 0; w < width; ++w) {
|
430
|
+
const offset = (width * h + w) * strideSize;
|
431
|
+
const diffuseColor = new Color3(diffuseBuffer[offset], diffuseBuffer[offset + 1], diffuseBuffer[offset + 2]).toLinearSpace().multiply(factors.diffuseColor);
|
432
|
+
const specularColor = new Color3(specularGlossinessBuffer[offset], specularGlossinessBuffer[offset + 1], specularGlossinessBuffer[offset + 2])
|
433
|
+
.toLinearSpace()
|
434
|
+
.multiply(factors.specularColor);
|
435
|
+
const glossiness = specularGlossinessBuffer[offset + 3] * factors.glossiness;
|
436
|
+
const specularGlossiness = {
|
437
|
+
diffuseColor: diffuseColor,
|
438
|
+
specularColor: specularColor,
|
439
|
+
glossiness: glossiness,
|
440
|
+
};
|
441
|
+
const metallicRoughness = this._convertSpecularGlossinessToMetallicRoughness(specularGlossiness);
|
442
|
+
maxBaseColor.r = Math.max(maxBaseColor.r, metallicRoughness.baseColor.r);
|
443
|
+
maxBaseColor.g = Math.max(maxBaseColor.g, metallicRoughness.baseColor.g);
|
444
|
+
maxBaseColor.b = Math.max(maxBaseColor.b, metallicRoughness.baseColor.b);
|
445
|
+
maxMetallic = Math.max(maxMetallic, metallicRoughness.metallic);
|
446
|
+
maxRoughness = Math.max(maxRoughness, metallicRoughness.roughness);
|
447
|
+
baseColorBuffer[offset] = metallicRoughness.baseColor.r * 255;
|
448
|
+
baseColorBuffer[offset + 1] = metallicRoughness.baseColor.g * 255;
|
449
|
+
baseColorBuffer[offset + 2] = metallicRoughness.baseColor.b * 255;
|
450
|
+
baseColorBuffer[offset + 3] = resizedTextures.texture1.hasAlpha ? diffuseBuffer[offset + 3] * 255 : 255;
|
451
|
+
metallicRoughnessBuffer[offset] = 0;
|
452
|
+
metallicRoughnessBuffer[offset + 1] = metallicRoughness.roughness * 255;
|
453
|
+
metallicRoughnessBuffer[offset + 2] = metallicRoughness.metallic * 255;
|
454
|
+
metallicRoughnessBuffer[offset + 3] = 255;
|
531
455
|
}
|
456
|
+
}
|
457
|
+
// Retrieves the metallic roughness factors from the maximum texture values.
|
458
|
+
const metallicRoughnessFactors = {
|
459
|
+
baseColor: maxBaseColor,
|
460
|
+
metallic: maxMetallic,
|
461
|
+
roughness: maxRoughness,
|
462
|
+
};
|
463
|
+
let writeOutMetallicRoughnessTexture = false;
|
464
|
+
let writeOutBaseColorTexture = false;
|
465
|
+
for (let h = 0; h < height; ++h) {
|
466
|
+
for (let w = 0; w < width; ++w) {
|
467
|
+
const destinationOffset = (width * h + w) * strideSize;
|
468
|
+
baseColorBuffer[destinationOffset] /= metallicRoughnessFactors.baseColor.r > _GLTFMaterialExporter._Epsilon ? metallicRoughnessFactors.baseColor.r : 1;
|
469
|
+
baseColorBuffer[destinationOffset + 1] /= metallicRoughnessFactors.baseColor.g > _GLTFMaterialExporter._Epsilon ? metallicRoughnessFactors.baseColor.g : 1;
|
470
|
+
baseColorBuffer[destinationOffset + 2] /= metallicRoughnessFactors.baseColor.b > _GLTFMaterialExporter._Epsilon ? metallicRoughnessFactors.baseColor.b : 1;
|
471
|
+
const linearBaseColorPixel = Color3.FromInts(baseColorBuffer[destinationOffset], baseColorBuffer[destinationOffset + 1], baseColorBuffer[destinationOffset + 2]);
|
472
|
+
const sRGBBaseColorPixel = linearBaseColorPixel.toGammaSpace();
|
473
|
+
baseColorBuffer[destinationOffset] = sRGBBaseColorPixel.r * 255;
|
474
|
+
baseColorBuffer[destinationOffset + 1] = sRGBBaseColorPixel.g * 255;
|
475
|
+
baseColorBuffer[destinationOffset + 2] = sRGBBaseColorPixel.b * 255;
|
476
|
+
if (!_GLTFMaterialExporter._FuzzyEquals(sRGBBaseColorPixel, Color3.White(), _GLTFMaterialExporter._Epsilon)) {
|
477
|
+
writeOutBaseColorTexture = true;
|
478
|
+
}
|
479
|
+
metallicRoughnessBuffer[destinationOffset + 1] /=
|
480
|
+
metallicRoughnessFactors.roughness > _GLTFMaterialExporter._Epsilon ? metallicRoughnessFactors.roughness : 1;
|
481
|
+
metallicRoughnessBuffer[destinationOffset + 2] /= metallicRoughnessFactors.metallic > _GLTFMaterialExporter._Epsilon ? metallicRoughnessFactors.metallic : 1;
|
482
|
+
const metallicRoughnessPixel = Color3.FromInts(255, metallicRoughnessBuffer[destinationOffset + 1], metallicRoughnessBuffer[destinationOffset + 2]);
|
483
|
+
if (!_GLTFMaterialExporter._FuzzyEquals(metallicRoughnessPixel, Color3.White(), _GLTFMaterialExporter._Epsilon)) {
|
484
|
+
writeOutMetallicRoughnessTexture = true;
|
485
|
+
}
|
486
|
+
}
|
487
|
+
}
|
488
|
+
if (writeOutMetallicRoughnessTexture) {
|
489
|
+
const promise = this._createBase64FromCanvasAsync(metallicRoughnessBuffer, width, height, mimeType).then((metallicRoughnessBase64) => {
|
490
|
+
metallicRoughnessFactors.metallicRoughnessTextureBase64 = metallicRoughnessBase64;
|
491
|
+
});
|
492
|
+
promises.push(promise);
|
493
|
+
}
|
494
|
+
if (writeOutBaseColorTexture) {
|
495
|
+
const promise = this._createBase64FromCanvasAsync(baseColorBuffer, width, height, mimeType).then((baseColorBase64) => {
|
496
|
+
metallicRoughnessFactors.baseColorTextureBase64 = baseColorBase64;
|
497
|
+
});
|
498
|
+
promises.push(promise);
|
499
|
+
}
|
500
|
+
return Promise.all(promises).then(() => {
|
501
|
+
return metallicRoughnessFactors;
|
532
502
|
});
|
533
|
-
}
|
534
|
-
|
503
|
+
}
|
504
|
+
else {
|
505
|
+
return Promise.reject("_ConvertSpecularGlossinessTexturesToMetallicRoughness: Scene from textures is missing!");
|
506
|
+
}
|
507
|
+
}
|
535
508
|
/**
|
536
509
|
* Converts specular glossiness material properties to metallic roughness
|
537
510
|
* @param specularGlossiness interface with specular glossiness material properties
|
538
511
|
* @returns interface with metallic roughness material properties
|
539
512
|
*/
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
513
|
+
_convertSpecularGlossinessToMetallicRoughness(specularGlossiness) {
|
514
|
+
const diffusePerceivedBrightness = this._getPerceivedBrightness(specularGlossiness.diffuseColor);
|
515
|
+
const specularPerceivedBrightness = this._getPerceivedBrightness(specularGlossiness.specularColor);
|
516
|
+
const oneMinusSpecularStrength = 1 - this._getMaxComponent(specularGlossiness.specularColor);
|
517
|
+
const metallic = _GLTFMaterialExporter._SolveMetallic(diffusePerceivedBrightness, specularPerceivedBrightness, oneMinusSpecularStrength);
|
518
|
+
const baseColorFromDiffuse = specularGlossiness.diffuseColor.scale(oneMinusSpecularStrength / (1.0 - _GLTFMaterialExporter._DielectricSpecular.r) / Math.max(1 - metallic, _GLTFMaterialExporter._Epsilon));
|
519
|
+
const baseColorFromSpecular = specularGlossiness.specularColor
|
547
520
|
.subtract(_GLTFMaterialExporter._DielectricSpecular.scale(1 - metallic))
|
548
521
|
.scale(1 / Math.max(metallic, _GLTFMaterialExporter._Epsilon));
|
549
|
-
|
522
|
+
let baseColor = Color3.Lerp(baseColorFromDiffuse, baseColorFromSpecular, metallic * metallic);
|
550
523
|
baseColor = baseColor.clampToRef(0, 1, baseColor);
|
551
|
-
|
524
|
+
const metallicRoughness = {
|
552
525
|
baseColor: baseColor,
|
553
526
|
metallic: metallic,
|
554
527
|
roughness: 1 - specularGlossiness.glossiness,
|
555
528
|
};
|
556
529
|
return metallicRoughness;
|
557
|
-
}
|
530
|
+
}
|
558
531
|
/**
|
559
532
|
* Calculates the surface reflectance, independent of lighting conditions
|
560
533
|
* @param color Color source to calculate brightness from
|
561
534
|
* @returns number representing the perceived brightness, or zero if color is undefined
|
562
535
|
*/
|
563
|
-
|
536
|
+
_getPerceivedBrightness(color) {
|
564
537
|
if (color) {
|
565
538
|
return Math.sqrt(0.299 * color.r * color.r + 0.587 * color.g * color.g + 0.114 * color.b * color.b);
|
566
539
|
}
|
567
540
|
return 0;
|
568
|
-
}
|
541
|
+
}
|
569
542
|
/**
|
570
543
|
* Returns the maximum color component value
|
571
544
|
* @param color
|
572
545
|
* @returns maximum color component value, or zero if color is null or undefined
|
573
546
|
*/
|
574
|
-
|
547
|
+
_getMaxComponent(color) {
|
575
548
|
if (color) {
|
576
549
|
return Math.max(color.r, Math.max(color.g, color.b));
|
577
550
|
}
|
578
551
|
return 0;
|
579
|
-
}
|
552
|
+
}
|
580
553
|
/**
|
581
554
|
* Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
|
582
555
|
* @param babylonPBRMaterial BJS PBR Metallic Roughness Material
|
@@ -585,41 +558,41 @@ var _GLTFMaterialExporter = /** @class */ (function () {
|
|
585
558
|
* @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
|
586
559
|
* @returns glTF PBR Metallic Roughness factors
|
587
560
|
*/
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
561
|
+
_convertMetalRoughFactorsToMetallicRoughnessAsync(babylonPBRMaterial, mimeType, glTFPbrMetallicRoughness, hasTextureCoords) {
|
562
|
+
const promises = [];
|
563
|
+
const baseColor = babylonPBRMaterial._albedoColor;
|
564
|
+
const metallic = babylonPBRMaterial._metallic;
|
565
|
+
const roughness = babylonPBRMaterial._roughness;
|
566
|
+
const metallicRoughness = {
|
594
567
|
baseColor: baseColor,
|
595
568
|
metallic: metallic,
|
596
569
|
roughness: roughness,
|
597
570
|
};
|
598
571
|
if (hasTextureCoords) {
|
599
|
-
|
572
|
+
const albedoTexture = babylonPBRMaterial._albedoTexture;
|
600
573
|
if (albedoTexture) {
|
601
|
-
promises.push(this._exportTextureAsync(babylonPBRMaterial._albedoTexture, mimeType).then(
|
574
|
+
promises.push(this._exportTextureAsync(babylonPBRMaterial._albedoTexture, mimeType).then((glTFTexture) => {
|
602
575
|
if (glTFTexture) {
|
603
576
|
glTFPbrMetallicRoughness.baseColorTexture = glTFTexture;
|
604
577
|
}
|
605
578
|
}));
|
606
579
|
}
|
607
|
-
|
580
|
+
const metallicTexture = babylonPBRMaterial._metallicTexture;
|
608
581
|
if (metallicTexture) {
|
609
|
-
promises.push(this._exportTextureAsync(metallicTexture, mimeType).then(
|
582
|
+
promises.push(this._exportTextureAsync(metallicTexture, mimeType).then((glTFTexture) => {
|
610
583
|
if (glTFTexture) {
|
611
584
|
glTFPbrMetallicRoughness.metallicRoughnessTexture = glTFTexture;
|
612
585
|
}
|
613
586
|
}));
|
614
587
|
}
|
615
588
|
}
|
616
|
-
return Promise.all(promises).then(
|
589
|
+
return Promise.all(promises).then(() => {
|
617
590
|
return metallicRoughness;
|
618
591
|
});
|
619
|
-
}
|
620
|
-
|
621
|
-
|
622
|
-
|
592
|
+
}
|
593
|
+
_getGLTFTextureSampler(texture) {
|
594
|
+
const sampler = this._getGLTFTextureWrapModesSampler(texture);
|
595
|
+
const samplingMode = texture instanceof Texture ? texture.samplingMode : null;
|
623
596
|
if (samplingMode != null) {
|
624
597
|
switch (samplingMode) {
|
625
598
|
case Texture.LINEAR_LINEAR: {
|
@@ -685,8 +658,8 @@ var _GLTFMaterialExporter = /** @class */ (function () {
|
|
685
658
|
}
|
686
659
|
}
|
687
660
|
return sampler;
|
688
|
-
}
|
689
|
-
|
661
|
+
}
|
662
|
+
_getGLTFTextureWrapMode(wrapMode) {
|
690
663
|
switch (wrapMode) {
|
691
664
|
case Texture.WRAP_ADDRESSMODE: {
|
692
665
|
return 10497 /* REPEAT */;
|
@@ -698,20 +671,20 @@ var _GLTFMaterialExporter = /** @class */ (function () {
|
|
698
671
|
return 33648 /* MIRRORED_REPEAT */;
|
699
672
|
}
|
700
673
|
default: {
|
701
|
-
Tools.Error(
|
674
|
+
Tools.Error(`Unsupported Texture Wrap Mode ${wrapMode}!`);
|
702
675
|
return 10497 /* REPEAT */;
|
703
676
|
}
|
704
677
|
}
|
705
|
-
}
|
706
|
-
|
707
|
-
|
708
|
-
|
678
|
+
}
|
679
|
+
_getGLTFTextureWrapModesSampler(texture) {
|
680
|
+
const wrapS = this._getGLTFTextureWrapMode(texture instanceof Texture ? texture.wrapU : Texture.WRAP_ADDRESSMODE);
|
681
|
+
const wrapT = this._getGLTFTextureWrapMode(texture instanceof Texture ? texture.wrapV : Texture.WRAP_ADDRESSMODE);
|
709
682
|
if (wrapS === 10497 /* REPEAT */ && wrapT === 10497 /* REPEAT */) {
|
710
683
|
// default wrapping mode in glTF, so omitting
|
711
684
|
return {};
|
712
685
|
}
|
713
686
|
return { wrapS: wrapS, wrapT: wrapT };
|
714
|
-
}
|
687
|
+
}
|
715
688
|
/**
|
716
689
|
* Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
|
717
690
|
* @param babylonPBRMaterial BJS PBR Metallic Roughness Material
|
@@ -720,43 +693,42 @@ var _GLTFMaterialExporter = /** @class */ (function () {
|
|
720
693
|
* @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
|
721
694
|
* @returns glTF PBR Metallic Roughness factors
|
722
695
|
*/
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
var specGloss = {
|
696
|
+
_convertSpecGlossFactorsToMetallicRoughnessAsync(babylonPBRMaterial, mimeType, glTFPbrMetallicRoughness, hasTextureCoords) {
|
697
|
+
return Promise.resolve().then(() => {
|
698
|
+
const samplers = this._exporter._samplers;
|
699
|
+
const textures = this._exporter._textures;
|
700
|
+
const diffuseColor = babylonPBRMaterial._albedoColor;
|
701
|
+
const specularColor = babylonPBRMaterial._reflectivityColor;
|
702
|
+
const glossiness = babylonPBRMaterial._microSurface;
|
703
|
+
const specGloss = {
|
732
704
|
diffuseColor: diffuseColor,
|
733
705
|
specularColor: specularColor,
|
734
706
|
glossiness: glossiness,
|
735
707
|
};
|
736
|
-
|
737
|
-
|
738
|
-
|
708
|
+
let samplerIndex = null;
|
709
|
+
const albedoTexture = babylonPBRMaterial._albedoTexture;
|
710
|
+
const reflectivityTexture = babylonPBRMaterial._reflectivityTexture;
|
739
711
|
if (albedoTexture) {
|
740
|
-
|
712
|
+
const sampler = this._getGLTFTextureSampler(albedoTexture);
|
741
713
|
if (sampler.magFilter != null && sampler.minFilter != null && sampler.wrapS != null && sampler.wrapT != null) {
|
742
714
|
samplers.push(sampler);
|
743
715
|
samplerIndex = samplers.length - 1;
|
744
716
|
}
|
745
717
|
}
|
746
|
-
|
718
|
+
const useMicrosurfaceFromReflectivityMapAlpha = babylonPBRMaterial._useMicroSurfaceFromReflectivityMapAlpha;
|
747
719
|
if (reflectivityTexture && !useMicrosurfaceFromReflectivityMapAlpha) {
|
748
720
|
return Promise.reject("_ConvertPBRMaterial: Glossiness values not included in the reflectivity texture are currently not supported");
|
749
721
|
}
|
750
722
|
if ((albedoTexture || reflectivityTexture) && hasTextureCoords) {
|
751
|
-
return
|
723
|
+
return this._convertSpecularGlossinessTexturesToMetallicRoughnessAsync(albedoTexture, reflectivityTexture, specGloss, mimeType).then((metallicRoughnessFactors) => {
|
752
724
|
if (metallicRoughnessFactors.baseColorTextureBase64) {
|
753
|
-
|
725
|
+
const glTFBaseColorTexture = this._getTextureInfoFromBase64(metallicRoughnessFactors.baseColorTextureBase64, "bjsBaseColorTexture_" + textures.length + ".png", mimeType, albedoTexture ? albedoTexture.coordinatesIndex : null, samplerIndex);
|
754
726
|
if (glTFBaseColorTexture) {
|
755
727
|
glTFPbrMetallicRoughness.baseColorTexture = glTFBaseColorTexture;
|
756
728
|
}
|
757
729
|
}
|
758
730
|
if (metallicRoughnessFactors.metallicRoughnessTextureBase64) {
|
759
|
-
|
731
|
+
const glTFMRColorTexture = this._getTextureInfoFromBase64(metallicRoughnessFactors.metallicRoughnessTextureBase64, "bjsMetallicRoughnessTexture_" + textures.length + ".png", mimeType, reflectivityTexture ? reflectivityTexture.coordinatesIndex : null, samplerIndex);
|
760
732
|
if (glTFMRColorTexture) {
|
761
733
|
glTFPbrMetallicRoughness.metallicRoughnessTexture = glTFMRColorTexture;
|
762
734
|
}
|
@@ -765,43 +737,42 @@ var _GLTFMaterialExporter = /** @class */ (function () {
|
|
765
737
|
});
|
766
738
|
}
|
767
739
|
else {
|
768
|
-
return
|
740
|
+
return this._convertSpecularGlossinessToMetallicRoughness(specGloss);
|
769
741
|
}
|
770
742
|
});
|
771
|
-
}
|
743
|
+
}
|
772
744
|
/**
|
773
745
|
* Converts a Babylon PBR Base Material to a glTF Material
|
774
746
|
* @param babylonPBRMaterial BJS PBR Base Material
|
775
747
|
* @param mimeType mime type to use for the textures
|
776
748
|
* @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
|
777
749
|
*/
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
var glTFMaterial = {
|
750
|
+
_convertPBRMaterialAsync(babylonPBRMaterial, mimeType, hasTextureCoords) {
|
751
|
+
const glTFPbrMetallicRoughness = {};
|
752
|
+
const glTFMaterial = {
|
782
753
|
name: babylonPBRMaterial.name,
|
783
754
|
};
|
784
|
-
|
755
|
+
const useMetallicRoughness = babylonPBRMaterial.isMetallicWorkflow();
|
785
756
|
if (useMetallicRoughness) {
|
786
|
-
|
787
|
-
|
757
|
+
const albedoColor = babylonPBRMaterial._albedoColor;
|
758
|
+
const alpha = babylonPBRMaterial.alpha;
|
788
759
|
if (albedoColor) {
|
789
760
|
glTFPbrMetallicRoughness.baseColorFactor = [albedoColor.r, albedoColor.g, albedoColor.b, alpha];
|
790
761
|
}
|
791
|
-
return this._convertMetalRoughFactorsToMetallicRoughnessAsync(babylonPBRMaterial, mimeType, glTFPbrMetallicRoughness, hasTextureCoords).then(
|
792
|
-
return
|
762
|
+
return this._convertMetalRoughFactorsToMetallicRoughnessAsync(babylonPBRMaterial, mimeType, glTFPbrMetallicRoughness, hasTextureCoords).then((metallicRoughness) => {
|
763
|
+
return this._setMetallicRoughnessPbrMaterial(metallicRoughness, babylonPBRMaterial, glTFMaterial, glTFPbrMetallicRoughness, mimeType, hasTextureCoords);
|
793
764
|
});
|
794
765
|
}
|
795
766
|
else {
|
796
|
-
return this._convertSpecGlossFactorsToMetallicRoughnessAsync(babylonPBRMaterial, mimeType, glTFPbrMetallicRoughness, hasTextureCoords).then(
|
797
|
-
return
|
767
|
+
return this._convertSpecGlossFactorsToMetallicRoughnessAsync(babylonPBRMaterial, mimeType, glTFPbrMetallicRoughness, hasTextureCoords).then((metallicRoughness) => {
|
768
|
+
return this._setMetallicRoughnessPbrMaterial(metallicRoughness, babylonPBRMaterial, glTFMaterial, glTFPbrMetallicRoughness, mimeType, hasTextureCoords);
|
798
769
|
});
|
799
770
|
}
|
800
|
-
}
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
771
|
+
}
|
772
|
+
_setMetallicRoughnessPbrMaterial(metallicRoughness, babylonPBRMaterial, glTFMaterial, glTFPbrMetallicRoughness, mimeType, hasTextureCoords) {
|
773
|
+
const materialMap = this._exporter._materialMap;
|
774
|
+
const materials = this._exporter._materials;
|
775
|
+
const promises = [];
|
805
776
|
if (metallicRoughness) {
|
806
777
|
_GLTFMaterialExporter._SetAlphaMode(glTFMaterial, babylonPBRMaterial);
|
807
778
|
if (!(_GLTFMaterialExporter._FuzzyEquals(metallicRoughness.baseColor, Color3.White(), _GLTFMaterialExporter._Epsilon) &&
|
@@ -821,28 +792,28 @@ var _GLTFMaterialExporter = /** @class */ (function () {
|
|
821
792
|
glTFMaterial.doubleSided = true;
|
822
793
|
}
|
823
794
|
if (hasTextureCoords) {
|
824
|
-
|
825
|
-
if (
|
826
|
-
|
795
|
+
const bumpTexture = babylonPBRMaterial._bumpTexture;
|
796
|
+
if (bumpTexture) {
|
797
|
+
const promise = this._exportTextureAsync(bumpTexture, mimeType).then((glTFTexture) => {
|
827
798
|
if (glTFTexture) {
|
828
799
|
glTFMaterial.normalTexture = glTFTexture;
|
829
|
-
if (
|
830
|
-
glTFMaterial.normalTexture.scale =
|
800
|
+
if (bumpTexture.level !== 1) {
|
801
|
+
glTFMaterial.normalTexture.scale = bumpTexture.level;
|
831
802
|
}
|
832
803
|
}
|
833
804
|
});
|
834
805
|
promises.push(promise);
|
835
806
|
}
|
836
|
-
|
807
|
+
const ambientTexture = babylonPBRMaterial._ambientTexture;
|
837
808
|
if (ambientTexture) {
|
838
|
-
|
809
|
+
const promise = this._exportTextureAsync(ambientTexture, mimeType).then((glTFTexture) => {
|
839
810
|
if (glTFTexture) {
|
840
|
-
|
811
|
+
const occlusionTexture = {
|
841
812
|
index: glTFTexture.index,
|
842
813
|
texCoord: glTFTexture.texCoord,
|
843
814
|
};
|
844
815
|
glTFMaterial.occlusionTexture = occlusionTexture;
|
845
|
-
|
816
|
+
const ambientTextureStrength = babylonPBRMaterial._ambientTextureStrength;
|
846
817
|
if (ambientTextureStrength) {
|
847
818
|
occlusionTexture.strength = ambientTextureStrength;
|
848
819
|
}
|
@@ -850,9 +821,9 @@ var _GLTFMaterialExporter = /** @class */ (function () {
|
|
850
821
|
});
|
851
822
|
promises.push(promise);
|
852
823
|
}
|
853
|
-
|
824
|
+
const emissiveTexture = babylonPBRMaterial._emissiveTexture;
|
854
825
|
if (emissiveTexture) {
|
855
|
-
|
826
|
+
const promise = this._exportTextureAsync(emissiveTexture, mimeType).then((glTFTexture) => {
|
856
827
|
if (glTFTexture) {
|
857
828
|
glTFMaterial.emissiveTexture = glTFTexture;
|
858
829
|
}
|
@@ -860,7 +831,7 @@ var _GLTFMaterialExporter = /** @class */ (function () {
|
|
860
831
|
promises.push(promise);
|
861
832
|
}
|
862
833
|
}
|
863
|
-
|
834
|
+
const emissiveColor = babylonPBRMaterial._emissiveColor;
|
864
835
|
if (!_GLTFMaterialExporter._FuzzyEquals(emissiveColor, Color3.Black(), _GLTFMaterialExporter._Epsilon)) {
|
865
836
|
glTFMaterial.emissiveFactor = emissiveColor.asArray();
|
866
837
|
}
|
@@ -869,91 +840,84 @@ var _GLTFMaterialExporter = /** @class */ (function () {
|
|
869
840
|
materialMap[babylonPBRMaterial.uniqueId] = materials.length - 1;
|
870
841
|
}
|
871
842
|
return this._finishMaterial(promises, glTFMaterial, babylonPBRMaterial, mimeType);
|
872
|
-
}
|
873
|
-
|
874
|
-
|
843
|
+
}
|
844
|
+
_getPixelsFromTexture(babylonTexture) {
|
845
|
+
const pixels = babylonTexture.textureType === Constants.TEXTURETYPE_UNSIGNED_INT
|
875
846
|
? babylonTexture.readPixels()
|
876
847
|
: babylonTexture.readPixels();
|
877
848
|
return pixels;
|
878
|
-
}
|
849
|
+
}
|
879
850
|
/**
|
880
851
|
* Extracts a texture from a Babylon texture into file data and glTF data
|
881
852
|
* @param babylonTexture Babylon texture to extract
|
882
853
|
* @param mimeType Mime Type of the babylonTexture
|
883
854
|
* @return glTF texture info, or null if the texture format is not supported
|
884
855
|
*/
|
885
|
-
|
886
|
-
|
887
|
-
var extensionPromise = this._exporter._extensionsPreExportTextureAsync("exporter", babylonTexture, mimeType);
|
856
|
+
_exportTextureAsync(babylonTexture, mimeType) {
|
857
|
+
const extensionPromise = this._exporter._extensionsPreExportTextureAsync("exporter", babylonTexture, mimeType);
|
888
858
|
if (!extensionPromise) {
|
889
859
|
return this._exportTextureInfoAsync(babylonTexture, mimeType);
|
890
860
|
}
|
891
|
-
return extensionPromise.then(
|
861
|
+
return extensionPromise.then((texture) => {
|
892
862
|
if (!texture) {
|
893
|
-
return
|
863
|
+
return this._exportTextureInfoAsync(babylonTexture, mimeType);
|
894
864
|
}
|
895
|
-
return
|
865
|
+
return this._exportTextureInfoAsync(texture, mimeType);
|
896
866
|
});
|
897
|
-
}
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
return [2 /*return*/, this._textureMap[textureUid]];
|
909
|
-
case 1: return [4 /*yield*/, this._getPixelsFromTexture(babylonTexture)];
|
910
|
-
case 2:
|
911
|
-
pixels = _a.sent();
|
912
|
-
if (!pixels) {
|
913
|
-
return [2 /*return*/, null];
|
914
|
-
}
|
915
|
-
samplers = this._exporter._samplers;
|
916
|
-
sampler = this._getGLTFTextureSampler(babylonTexture);
|
917
|
-
samplerIndex_1 = null;
|
918
|
-
foundSamplerIndex = null;
|
919
|
-
for (i = 0; i < samplers.length; ++i) {
|
920
|
-
s = samplers[i];
|
921
|
-
if (s.minFilter === sampler.minFilter && s.magFilter === sampler.magFilter && s.wrapS === sampler.wrapS && s.wrapT === sampler.wrapT) {
|
922
|
-
foundSamplerIndex = i;
|
923
|
-
break;
|
924
|
-
}
|
925
|
-
}
|
926
|
-
if (foundSamplerIndex == null) {
|
927
|
-
samplers.push(sampler);
|
928
|
-
samplerIndex_1 = samplers.length - 1;
|
929
|
-
}
|
930
|
-
else {
|
931
|
-
samplerIndex_1 = foundSamplerIndex;
|
932
|
-
}
|
933
|
-
size = babylonTexture.getSize();
|
934
|
-
// Preserve texture mime type if defined
|
935
|
-
if (babylonTexture.mimeType) {
|
936
|
-
switch (babylonTexture.mimeType) {
|
937
|
-
case "image/jpeg":
|
938
|
-
mimeType = "image/jpeg" /* JPEG */;
|
939
|
-
break;
|
940
|
-
case "image/png":
|
941
|
-
mimeType = "image/png" /* PNG */;
|
942
|
-
break;
|
943
|
-
}
|
944
|
-
}
|
945
|
-
return [2 /*return*/, this._createBase64FromCanvasAsync(pixels, size.width, size.height, mimeType).then(function (base64Data) {
|
946
|
-
var textureInfo = _this._getTextureInfoFromBase64(base64Data, babylonTexture.name.replace(/\.\/|\/|\.\\|\\/g, "_"), mimeType, babylonTexture.coordinatesIndex, samplerIndex_1);
|
947
|
-
if (textureInfo) {
|
948
|
-
_this._textureMap[textureUid] = textureInfo;
|
949
|
-
_this._exporter._extensionsPostExportTextures("linkTextureInfo", textureInfo, babylonTexture);
|
950
|
-
}
|
951
|
-
return textureInfo;
|
952
|
-
})];
|
867
|
+
}
|
868
|
+
_exportTextureInfoAsync(babylonTexture, mimeType) {
|
869
|
+
return Promise.resolve().then(async () => {
|
870
|
+
const textureUid = babylonTexture.uid;
|
871
|
+
if (textureUid in this._textureMap) {
|
872
|
+
return this._textureMap[textureUid];
|
873
|
+
}
|
874
|
+
else {
|
875
|
+
const pixels = await this._getPixelsFromTexture(babylonTexture);
|
876
|
+
if (!pixels) {
|
877
|
+
return null;
|
953
878
|
}
|
954
|
-
|
955
|
-
|
956
|
-
|
879
|
+
const samplers = this._exporter._samplers;
|
880
|
+
const sampler = this._getGLTFTextureSampler(babylonTexture);
|
881
|
+
let samplerIndex = null;
|
882
|
+
// if a pre-existing sampler with identical parameters exists, then reuse the previous sampler
|
883
|
+
let foundSamplerIndex = null;
|
884
|
+
for (let i = 0; i < samplers.length; ++i) {
|
885
|
+
const s = samplers[i];
|
886
|
+
if (s.minFilter === sampler.minFilter && s.magFilter === sampler.magFilter && s.wrapS === sampler.wrapS && s.wrapT === sampler.wrapT) {
|
887
|
+
foundSamplerIndex = i;
|
888
|
+
break;
|
889
|
+
}
|
890
|
+
}
|
891
|
+
if (foundSamplerIndex == null) {
|
892
|
+
samplers.push(sampler);
|
893
|
+
samplerIndex = samplers.length - 1;
|
894
|
+
}
|
895
|
+
else {
|
896
|
+
samplerIndex = foundSamplerIndex;
|
897
|
+
}
|
898
|
+
const size = babylonTexture.getSize();
|
899
|
+
// Preserve texture mime type if defined
|
900
|
+
if (babylonTexture.mimeType) {
|
901
|
+
switch (babylonTexture.mimeType) {
|
902
|
+
case "image/jpeg":
|
903
|
+
mimeType = "image/jpeg" /* JPEG */;
|
904
|
+
break;
|
905
|
+
case "image/png":
|
906
|
+
mimeType = "image/png" /* PNG */;
|
907
|
+
break;
|
908
|
+
}
|
909
|
+
}
|
910
|
+
return this._createBase64FromCanvasAsync(pixels, size.width, size.height, mimeType).then((base64Data) => {
|
911
|
+
const textureInfo = this._getTextureInfoFromBase64(base64Data, babylonTexture.name.replace(/\.\/|\/|\.\\|\\/g, "_"), mimeType, babylonTexture.coordinatesIndex, samplerIndex);
|
912
|
+
if (textureInfo) {
|
913
|
+
this._textureMap[textureUid] = textureInfo;
|
914
|
+
this._exporter._extensionsPostExportTextures("linkTextureInfo", textureInfo, babylonTexture);
|
915
|
+
}
|
916
|
+
return textureInfo;
|
917
|
+
});
|
918
|
+
}
|
919
|
+
});
|
920
|
+
}
|
957
921
|
/**
|
958
922
|
* Builds a texture from base64 string
|
959
923
|
* @param base64Texture base64 texture string
|
@@ -963,39 +927,39 @@ var _GLTFMaterialExporter = /** @class */ (function () {
|
|
963
927
|
* @param samplerIndex
|
964
928
|
* @returns glTF texture info, or null if the texture format is not supported
|
965
929
|
*/
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
930
|
+
_getTextureInfoFromBase64(base64Texture, baseTextureName, mimeType, texCoordIndex, samplerIndex) {
|
931
|
+
const textures = this._exporter._textures;
|
932
|
+
const images = this._exporter._images;
|
933
|
+
const imageData = this._exporter._imageData;
|
934
|
+
let textureInfo = null;
|
935
|
+
const glTFTexture = {
|
972
936
|
source: images.length,
|
973
937
|
name: baseTextureName,
|
974
938
|
};
|
975
939
|
if (samplerIndex != null) {
|
976
940
|
glTFTexture.sampler = samplerIndex;
|
977
941
|
}
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
for (
|
942
|
+
const binStr = atob(base64Texture.split(",")[1]);
|
943
|
+
const arrBuff = new ArrayBuffer(binStr.length);
|
944
|
+
const arr = new Uint8Array(arrBuff);
|
945
|
+
for (let i = 0, length = binStr.length; i < length; ++i) {
|
982
946
|
arr[i] = binStr.charCodeAt(i);
|
983
947
|
}
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
948
|
+
const imageValues = { data: arr, mimeType: mimeType };
|
949
|
+
const extension = mimeType === "image/jpeg" /* JPEG */ ? ".jpeg" : ".png";
|
950
|
+
let textureName = baseTextureName + extension;
|
951
|
+
const originalTextureName = textureName;
|
988
952
|
if (textureName in imageData) {
|
989
|
-
textureName =
|
953
|
+
textureName = `${baseTextureName}_${Tools.RandomId()}${extension}`;
|
990
954
|
}
|
991
955
|
imageData[textureName] = imageValues;
|
992
956
|
if (mimeType === "image/jpeg" /* JPEG */ || mimeType === "image/png" /* PNG */) {
|
993
|
-
|
957
|
+
const glTFImage = {
|
994
958
|
name: baseTextureName,
|
995
959
|
uri: textureName,
|
996
960
|
};
|
997
|
-
|
998
|
-
for (
|
961
|
+
let foundIndex = null;
|
962
|
+
for (let i = 0; i < images.length; ++i) {
|
999
963
|
if (images[i].uri === originalTextureName) {
|
1000
964
|
foundIndex = i;
|
1001
965
|
break;
|
@@ -1017,23 +981,21 @@ var _GLTFMaterialExporter = /** @class */ (function () {
|
|
1017
981
|
}
|
1018
982
|
}
|
1019
983
|
else {
|
1020
|
-
Tools.Error(
|
984
|
+
Tools.Error(`Unsupported texture mime type ${mimeType}`);
|
1021
985
|
}
|
1022
986
|
return textureInfo;
|
1023
|
-
}
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
1027
|
-
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
1031
|
-
|
1032
|
-
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1037
|
-
}());
|
1038
|
-
export { _GLTFMaterialExporter };
|
987
|
+
}
|
988
|
+
}
|
989
|
+
/**
|
990
|
+
* Represents the dielectric specular values for R, G and B
|
991
|
+
*/
|
992
|
+
_GLTFMaterialExporter._DielectricSpecular = new Color3(0.04, 0.04, 0.04);
|
993
|
+
/**
|
994
|
+
* Allows the maximum specular power to be defined for material calculations
|
995
|
+
*/
|
996
|
+
_GLTFMaterialExporter._MaxSpecularPower = 1024;
|
997
|
+
/**
|
998
|
+
* Numeric tolerance value
|
999
|
+
*/
|
1000
|
+
_GLTFMaterialExporter._Epsilon = 1e-6;
|
1039
1001
|
//# sourceMappingURL=glTFMaterialExporter.js.map
|