@babylonjs/loaders 5.21.0 → 5.22.0
Sign up to get free protection for your applications and to get access to all the features.
- package/OBJ/mtlFileLoader.js +25 -27
- package/OBJ/mtlFileLoader.js.map +1 -1
- package/OBJ/objFileLoader.js +112 -124
- package/OBJ/objFileLoader.js.map +1 -1
- package/OBJ/solidParser.js +118 -125
- package/OBJ/solidParser.js.map +1 -1
- package/STL/stlFileLoader.js +61 -63
- package/STL/stlFileLoader.js.map +1 -1
- package/glTF/1.0/glTFBinaryExtension.js +26 -30
- package/glTF/1.0/glTFBinaryExtension.js.map +1 -1
- package/glTF/1.0/glTFLoader.js +409 -432
- package/glTF/1.0/glTFLoader.js.map +1 -1
- package/glTF/1.0/glTFLoaderUtils.js +33 -37
- package/glTF/1.0/glTFLoaderUtils.js.map +1 -1
- package/glTF/1.0/glTFMaterialsCommonExtension.js +27 -31
- package/glTF/1.0/glTFMaterialsCommonExtension.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_lights_image_based.js +48 -59
- package/glTF/2.0/Extensions/EXT_lights_image_based.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js +24 -29
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_meshopt_compression.js +13 -16
- package/glTF/2.0/Extensions/EXT_meshopt_compression.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_texture_webp.js +13 -16
- package/glTF/2.0/Extensions/EXT_texture_webp.js.map +1 -1
- package/glTF/2.0/Extensions/ExtrasAsMetadata.js +22 -26
- package/glTF/2.0/Extensions/ExtrasAsMetadata.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_animation_pointer.js +63 -76
- package/glTF/2.0/Extensions/KHR_animation_pointer.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_animation_pointer.map.js +90 -120
- package/glTF/2.0/Extensions/KHR_animation_pointer.map.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js +25 -28
- package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_lights_punctual.js +27 -30
- package/glTF/2.0/Extensions/KHR_lights_punctual.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.js +25 -28
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js +15 -18
- package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_ior.js +21 -24
- package/glTF/2.0/Extensions/KHR_materials_ior.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_iridescence.js +27 -31
- package/glTF/2.0/Extensions/KHR_materials_iridescence.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js +24 -27
- package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_sheen.js +23 -26
- package/glTF/2.0/Extensions/KHR_materials_sheen.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_specular.js +23 -26
- package/glTF/2.0/Extensions/KHR_materials_specular.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_translucency.js +20 -23
- package/glTF/2.0/Extensions/KHR_materials_translucency.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_transmission.js +82 -86
- package/glTF/2.0/Extensions/KHR_materials_transmission.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_unlit.js +19 -22
- package/glTF/2.0/Extensions/KHR_materials_unlit.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_variants.js +79 -97
- package/glTF/2.0/Extensions/KHR_materials_variants.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_volume.js +20 -23
- package/glTF/2.0/Extensions/KHR_materials_volume.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_mesh_quantization.js +6 -8
- package/glTF/2.0/Extensions/KHR_mesh_quantization.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_texture_basisu.js +13 -16
- package/glTF/2.0/Extensions/KHR_texture_basisu.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_texture_transform.js +12 -15
- package/glTF/2.0/Extensions/KHR_texture_transform.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_xmp_json_ld.js +12 -15
- package/glTF/2.0/Extensions/KHR_xmp_json_ld.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_audio_emitter.js +77 -95
- package/glTF/2.0/Extensions/MSFT_audio_emitter.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_lod.js +114 -139
- package/glTF/2.0/Extensions/MSFT_lod.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_minecraftMesh.js +12 -15
- package/glTF/2.0/Extensions/MSFT_minecraftMesh.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_sRGBFactors.js +12 -15
- package/glTF/2.0/Extensions/MSFT_sRGBFactors.js.map +1 -1
- package/glTF/2.0/glTFLoader.js +739 -823
- package/glTF/2.0/glTFLoader.js.map +1 -1
- package/glTF/glTFFileLoader.js +337 -404
- package/glTF/glTFFileLoader.js.map +1 -1
- package/glTF/glTFValidation.js +32 -39
- package/glTF/glTFValidation.js.map +1 -1
- package/legacy/legacy-glTF.js +3 -3
- package/legacy/legacy-glTF.js.map +1 -1
- package/legacy/legacy-glTF1.js +2 -2
- package/legacy/legacy-glTF1.js.map +1 -1
- package/legacy/legacy-glTF2.js +12 -12
- package/legacy/legacy-glTF2.js.map +1 -1
- package/legacy/legacy-objFileLoader.js +2 -2
- package/legacy/legacy-objFileLoader.js.map +1 -1
- package/legacy/legacy-stlFileLoader.js +2 -2
- package/legacy/legacy-stlFileLoader.js.map +1 -1
- package/package.json +3 -6
package/glTF/glTFFileLoader.js
CHANGED
@@ -68,8 +68,8 @@ export var GLTFLoaderState;
|
|
68
68
|
/**
|
69
69
|
* File loader for loading glTF files into a scene.
|
70
70
|
*/
|
71
|
-
|
72
|
-
|
71
|
+
export class GLTFFileLoader {
|
72
|
+
constructor() {
|
73
73
|
// --------------
|
74
74
|
// Common options
|
75
75
|
// --------------
|
@@ -149,7 +149,7 @@ var GLTFFileLoader = /** @class */ (function () {
|
|
149
149
|
* Function called before loading a url referenced by the asset.
|
150
150
|
* @param url
|
151
151
|
*/
|
152
|
-
this.preprocessUrlAsync =
|
152
|
+
this.preprocessUrlAsync = (url) => Promise.resolve(url);
|
153
153
|
/**
|
154
154
|
* Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
|
155
155
|
* Note that the observable is raised as soon as the mesh object is created, meaning some data may not have been setup yet for this mesh (vertex data, morph targets, material, ...)
|
@@ -227,200 +227,151 @@ var GLTFFileLoader = /** @class */ (function () {
|
|
227
227
|
/** @hidden */
|
228
228
|
this._endPerformanceCounter = this._endPerformanceCounterDisabled;
|
229
229
|
}
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
}
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
this.
|
346
|
-
}
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
this._loggingEnabled = value;
|
362
|
-
if (this._loggingEnabled) {
|
363
|
-
this._log = this._logEnabled;
|
364
|
-
}
|
365
|
-
else {
|
366
|
-
this._log = this._logDisabled;
|
367
|
-
}
|
368
|
-
},
|
369
|
-
enumerable: false,
|
370
|
-
configurable: true
|
371
|
-
});
|
372
|
-
Object.defineProperty(GLTFFileLoader.prototype, "capturePerformanceCounters", {
|
373
|
-
/**
|
374
|
-
* Defines if the loader should capture performance counters.
|
375
|
-
*/
|
376
|
-
get: function () {
|
377
|
-
return this._capturePerformanceCounters;
|
378
|
-
},
|
379
|
-
set: function (value) {
|
380
|
-
if (this._capturePerformanceCounters === value) {
|
381
|
-
return;
|
382
|
-
}
|
383
|
-
this._capturePerformanceCounters = value;
|
384
|
-
if (this._capturePerformanceCounters) {
|
385
|
-
this._startPerformanceCounter = this._startPerformanceCounterEnabled;
|
386
|
-
this._endPerformanceCounter = this._endPerformanceCounterEnabled;
|
387
|
-
}
|
388
|
-
else {
|
389
|
-
this._startPerformanceCounter = this._startPerformanceCounterDisabled;
|
390
|
-
this._endPerformanceCounter = this._endPerformanceCounterDisabled;
|
391
|
-
}
|
392
|
-
},
|
393
|
-
enumerable: false,
|
394
|
-
configurable: true
|
395
|
-
});
|
396
|
-
Object.defineProperty(GLTFFileLoader.prototype, "onValidated", {
|
397
|
-
/**
|
398
|
-
* Callback raised after a loader extension is created.
|
399
|
-
*/
|
400
|
-
set: function (callback) {
|
401
|
-
if (this._onValidatedObserver) {
|
402
|
-
this.onValidatedObservable.remove(this._onValidatedObserver);
|
403
|
-
}
|
404
|
-
this._onValidatedObserver = this.onValidatedObservable.add(callback);
|
405
|
-
},
|
406
|
-
enumerable: false,
|
407
|
-
configurable: true
|
408
|
-
});
|
230
|
+
/**
|
231
|
+
* Raised when the asset has been parsed
|
232
|
+
*/
|
233
|
+
set onParsed(callback) {
|
234
|
+
if (this._onParsedObserver) {
|
235
|
+
this.onParsedObservable.remove(this._onParsedObserver);
|
236
|
+
}
|
237
|
+
this._onParsedObserver = this.onParsedObservable.add(callback);
|
238
|
+
}
|
239
|
+
/**
|
240
|
+
* Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
|
241
|
+
* Note that the callback is called as soon as the mesh object is created, meaning some data may not have been setup yet for this mesh (vertex data, morph targets, material, ...)
|
242
|
+
*/
|
243
|
+
set onMeshLoaded(callback) {
|
244
|
+
if (this._onMeshLoadedObserver) {
|
245
|
+
this.onMeshLoadedObservable.remove(this._onMeshLoadedObserver);
|
246
|
+
}
|
247
|
+
this._onMeshLoadedObserver = this.onMeshLoadedObservable.add(callback);
|
248
|
+
}
|
249
|
+
/**
|
250
|
+
* Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
|
251
|
+
*/
|
252
|
+
set onTextureLoaded(callback) {
|
253
|
+
if (this._onTextureLoadedObserver) {
|
254
|
+
this.onTextureLoadedObservable.remove(this._onTextureLoadedObserver);
|
255
|
+
}
|
256
|
+
this._onTextureLoadedObserver = this.onTextureLoadedObservable.add(callback);
|
257
|
+
}
|
258
|
+
/**
|
259
|
+
* Callback raised when the loader creates a material after parsing the glTF properties of the material.
|
260
|
+
*/
|
261
|
+
set onMaterialLoaded(callback) {
|
262
|
+
if (this._onMaterialLoadedObserver) {
|
263
|
+
this.onMaterialLoadedObservable.remove(this._onMaterialLoadedObserver);
|
264
|
+
}
|
265
|
+
this._onMaterialLoadedObserver = this.onMaterialLoadedObservable.add(callback);
|
266
|
+
}
|
267
|
+
/**
|
268
|
+
* Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
|
269
|
+
*/
|
270
|
+
set onCameraLoaded(callback) {
|
271
|
+
if (this._onCameraLoadedObserver) {
|
272
|
+
this.onCameraLoadedObservable.remove(this._onCameraLoadedObserver);
|
273
|
+
}
|
274
|
+
this._onCameraLoadedObserver = this.onCameraLoadedObservable.add(callback);
|
275
|
+
}
|
276
|
+
/**
|
277
|
+
* Callback raised when the asset is completely loaded, immediately before the loader is disposed.
|
278
|
+
* For assets with LODs, raised when all of the LODs are complete.
|
279
|
+
* For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
|
280
|
+
*/
|
281
|
+
set onComplete(callback) {
|
282
|
+
if (this._onCompleteObserver) {
|
283
|
+
this.onCompleteObservable.remove(this._onCompleteObserver);
|
284
|
+
}
|
285
|
+
this._onCompleteObserver = this.onCompleteObservable.add(callback);
|
286
|
+
}
|
287
|
+
/**
|
288
|
+
* Callback raised when an error occurs.
|
289
|
+
*/
|
290
|
+
set onError(callback) {
|
291
|
+
if (this._onErrorObserver) {
|
292
|
+
this.onErrorObservable.remove(this._onErrorObserver);
|
293
|
+
}
|
294
|
+
this._onErrorObserver = this.onErrorObservable.add(callback);
|
295
|
+
}
|
296
|
+
/**
|
297
|
+
* Callback raised after the loader is disposed.
|
298
|
+
*/
|
299
|
+
set onDispose(callback) {
|
300
|
+
if (this._onDisposeObserver) {
|
301
|
+
this.onDisposeObservable.remove(this._onDisposeObserver);
|
302
|
+
}
|
303
|
+
this._onDisposeObserver = this.onDisposeObservable.add(callback);
|
304
|
+
}
|
305
|
+
/**
|
306
|
+
* Callback raised after a loader extension is created.
|
307
|
+
*/
|
308
|
+
set onExtensionLoaded(callback) {
|
309
|
+
if (this._onExtensionLoadedObserver) {
|
310
|
+
this.onExtensionLoadedObservable.remove(this._onExtensionLoadedObserver);
|
311
|
+
}
|
312
|
+
this._onExtensionLoadedObserver = this.onExtensionLoadedObservable.add(callback);
|
313
|
+
}
|
314
|
+
/**
|
315
|
+
* Defines if the loader logging is enabled.
|
316
|
+
*/
|
317
|
+
get loggingEnabled() {
|
318
|
+
return this._loggingEnabled;
|
319
|
+
}
|
320
|
+
set loggingEnabled(value) {
|
321
|
+
if (this._loggingEnabled === value) {
|
322
|
+
return;
|
323
|
+
}
|
324
|
+
this._loggingEnabled = value;
|
325
|
+
if (this._loggingEnabled) {
|
326
|
+
this._log = this._logEnabled;
|
327
|
+
}
|
328
|
+
else {
|
329
|
+
this._log = this._logDisabled;
|
330
|
+
}
|
331
|
+
}
|
332
|
+
/**
|
333
|
+
* Defines if the loader should capture performance counters.
|
334
|
+
*/
|
335
|
+
get capturePerformanceCounters() {
|
336
|
+
return this._capturePerformanceCounters;
|
337
|
+
}
|
338
|
+
set capturePerformanceCounters(value) {
|
339
|
+
if (this._capturePerformanceCounters === value) {
|
340
|
+
return;
|
341
|
+
}
|
342
|
+
this._capturePerformanceCounters = value;
|
343
|
+
if (this._capturePerformanceCounters) {
|
344
|
+
this._startPerformanceCounter = this._startPerformanceCounterEnabled;
|
345
|
+
this._endPerformanceCounter = this._endPerformanceCounterEnabled;
|
346
|
+
}
|
347
|
+
else {
|
348
|
+
this._startPerformanceCounter = this._startPerformanceCounterDisabled;
|
349
|
+
this._endPerformanceCounter = this._endPerformanceCounterDisabled;
|
350
|
+
}
|
351
|
+
}
|
352
|
+
/**
|
353
|
+
* Callback raised after a loader extension is created.
|
354
|
+
*/
|
355
|
+
set onValidated(callback) {
|
356
|
+
if (this._onValidatedObserver) {
|
357
|
+
this.onValidatedObservable.remove(this._onValidatedObserver);
|
358
|
+
}
|
359
|
+
this._onValidatedObserver = this.onValidatedObservable.add(callback);
|
360
|
+
}
|
409
361
|
/**
|
410
362
|
* Disposes the loader, releases resources during load, and cancels any outstanding requests.
|
411
363
|
*/
|
412
|
-
|
364
|
+
dispose() {
|
413
365
|
if (this._loader) {
|
414
366
|
this._loader.dispose();
|
415
367
|
this._loader = null;
|
416
368
|
}
|
417
|
-
for (
|
418
|
-
var request = _a[_i];
|
369
|
+
for (const request of this._requests) {
|
419
370
|
request.abort();
|
420
371
|
}
|
421
372
|
this._requests.length = 0;
|
422
373
|
delete this._progressCallback;
|
423
|
-
this.preprocessUrlAsync =
|
374
|
+
this.preprocessUrlAsync = (url) => Promise.resolve(url);
|
424
375
|
this.onMeshLoadedObservable.clear();
|
425
376
|
this.onSkinLoadedObservable.clear();
|
426
377
|
this.onTextureLoadedObservable.clear();
|
@@ -430,7 +381,7 @@ var GLTFFileLoader = /** @class */ (function () {
|
|
430
381
|
this.onExtensionLoadedObservable.clear();
|
431
382
|
this.onDisposeObservable.notifyObservers(undefined);
|
432
383
|
this.onDisposeObservable.clear();
|
433
|
-
}
|
384
|
+
}
|
434
385
|
/**
|
435
386
|
* @param scene
|
436
387
|
* @param fileOrUrl
|
@@ -440,55 +391,54 @@ var GLTFFileLoader = /** @class */ (function () {
|
|
440
391
|
* @param onError
|
441
392
|
* @hidden
|
442
393
|
*/
|
443
|
-
|
444
|
-
var _this = this;
|
394
|
+
loadFile(scene, fileOrUrl, onSuccess, onProgress, useArrayBuffer, onError) {
|
445
395
|
this._progressCallback = onProgress;
|
446
|
-
|
447
|
-
|
396
|
+
const rootUrl = fileOrUrl.name ? "file:" : Tools.GetFolderPath(fileOrUrl);
|
397
|
+
const fileName = fileOrUrl.name || Tools.GetFilename(fileOrUrl);
|
448
398
|
if (useArrayBuffer) {
|
449
399
|
if (this.useRangeRequests) {
|
450
400
|
if (this.validate) {
|
451
401
|
Logger.Warn("glTF validation is not supported when range requests are enabled");
|
452
402
|
}
|
453
|
-
|
454
|
-
abort:
|
403
|
+
const fileRequest = {
|
404
|
+
abort: () => { },
|
455
405
|
onCompleteObservable: new Observable(),
|
456
406
|
};
|
457
|
-
|
458
|
-
readAsync:
|
459
|
-
return new Promise(
|
460
|
-
|
407
|
+
const dataBuffer = {
|
408
|
+
readAsync: (byteOffset, byteLength) => {
|
409
|
+
return new Promise((resolve, reject) => {
|
410
|
+
this._loadFile(scene, fileOrUrl, (data) => {
|
461
411
|
resolve(new Uint8Array(data));
|
462
|
-
}, true,
|
412
|
+
}, true, (error) => {
|
463
413
|
reject(error);
|
464
|
-
},
|
465
|
-
webRequest.setRequestHeader("Range",
|
414
|
+
}, (webRequest) => {
|
415
|
+
webRequest.setRequestHeader("Range", `bytes=${byteOffset}-${byteOffset + byteLength - 1}`);
|
466
416
|
});
|
467
417
|
});
|
468
418
|
},
|
469
419
|
byteLength: 0,
|
470
420
|
};
|
471
|
-
this._unpackBinaryAsync(new DataReader(dataBuffer)).then(
|
472
|
-
|
421
|
+
this._unpackBinaryAsync(new DataReader(dataBuffer)).then((loaderData) => {
|
422
|
+
fileRequest.onCompleteObservable.notifyObservers(fileRequest);
|
473
423
|
onSuccess(loaderData);
|
474
|
-
}, onError ?
|
475
|
-
return
|
424
|
+
}, onError ? (error) => onError(undefined, error) : undefined);
|
425
|
+
return fileRequest;
|
476
426
|
}
|
477
|
-
return this._loadFile(scene, fileOrUrl,
|
478
|
-
|
479
|
-
|
480
|
-
readAsync:
|
427
|
+
return this._loadFile(scene, fileOrUrl, (data) => {
|
428
|
+
this._validate(scene, data, rootUrl, fileName);
|
429
|
+
this._unpackBinaryAsync(new DataReader({
|
430
|
+
readAsync: (byteOffset, byteLength) => readAsync(data, byteOffset, byteLength),
|
481
431
|
byteLength: data.byteLength,
|
482
|
-
})).then(
|
432
|
+
})).then((loaderData) => {
|
483
433
|
onSuccess(loaderData);
|
484
|
-
}, onError ?
|
434
|
+
}, onError ? (error) => onError(undefined, error) : undefined);
|
485
435
|
}, true, onError);
|
486
436
|
}
|
487
|
-
return this._loadFile(scene, fileOrUrl,
|
488
|
-
|
489
|
-
onSuccess({ json:
|
437
|
+
return this._loadFile(scene, fileOrUrl, (data) => {
|
438
|
+
this._validate(scene, data, rootUrl, fileName);
|
439
|
+
onSuccess({ json: this._parseJson(data) });
|
490
440
|
}, useArrayBuffer, onError);
|
491
|
-
}
|
441
|
+
}
|
492
442
|
/**
|
493
443
|
* @param meshesNames
|
494
444
|
* @param scene
|
@@ -498,16 +448,15 @@ var GLTFFileLoader = /** @class */ (function () {
|
|
498
448
|
* @param fileName
|
499
449
|
* @hidden
|
500
450
|
*/
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
return _this._loader.importMeshAsync(meshesNames, scene, null, data, rootUrl, onProgress, fileName);
|
451
|
+
importMeshAsync(meshesNames, scene, data, rootUrl, onProgress, fileName) {
|
452
|
+
return Promise.resolve().then(() => {
|
453
|
+
this.onParsedObservable.notifyObservers(data);
|
454
|
+
this.onParsedObservable.clear();
|
455
|
+
this._log(`Loading ${fileName || ""}`);
|
456
|
+
this._loader = this._getLoader(data);
|
457
|
+
return this._loader.importMeshAsync(meshesNames, scene, null, data, rootUrl, onProgress, fileName);
|
509
458
|
});
|
510
|
-
}
|
459
|
+
}
|
511
460
|
/**
|
512
461
|
* @param scene
|
513
462
|
* @param data
|
@@ -516,16 +465,15 @@ var GLTFFileLoader = /** @class */ (function () {
|
|
516
465
|
* @param fileName
|
517
466
|
* @hidden
|
518
467
|
*/
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
return _this._loader.loadAsync(scene, data, rootUrl, onProgress, fileName);
|
468
|
+
loadAsync(scene, data, rootUrl, onProgress, fileName) {
|
469
|
+
return Promise.resolve().then(() => {
|
470
|
+
this.onParsedObservable.notifyObservers(data);
|
471
|
+
this.onParsedObservable.clear();
|
472
|
+
this._log(`Loading ${fileName || ""}`);
|
473
|
+
this._loader = this._getLoader(data);
|
474
|
+
return this._loader.loadAsync(scene, data, rootUrl, onProgress, fileName);
|
527
475
|
});
|
528
|
-
}
|
476
|
+
}
|
529
477
|
/**
|
530
478
|
* @param scene
|
531
479
|
* @param data
|
@@ -534,29 +482,28 @@ var GLTFFileLoader = /** @class */ (function () {
|
|
534
482
|
* @param fileName
|
535
483
|
* @hidden
|
536
484
|
*/
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
_this._loader = _this._getLoader(data);
|
485
|
+
loadAssetContainerAsync(scene, data, rootUrl, onProgress, fileName) {
|
486
|
+
return Promise.resolve().then(() => {
|
487
|
+
this.onParsedObservable.notifyObservers(data);
|
488
|
+
this.onParsedObservable.clear();
|
489
|
+
this._log(`Loading ${fileName || ""}`);
|
490
|
+
this._loader = this._getLoader(data);
|
544
491
|
// Prepare the asset container.
|
545
|
-
|
492
|
+
const container = new AssetContainer(scene);
|
546
493
|
// Get materials/textures when loading to add to container
|
547
|
-
|
548
|
-
|
494
|
+
const materials = [];
|
495
|
+
this.onMaterialLoadedObservable.add((material) => {
|
549
496
|
materials.push(material);
|
550
497
|
});
|
551
|
-
|
552
|
-
|
498
|
+
const textures = [];
|
499
|
+
this.onTextureLoadedObservable.add((texture) => {
|
553
500
|
textures.push(texture);
|
554
501
|
});
|
555
|
-
|
556
|
-
|
502
|
+
const cameras = [];
|
503
|
+
this.onCameraLoadedObservable.add((camera) => {
|
557
504
|
cameras.push(camera);
|
558
505
|
});
|
559
|
-
return
|
506
|
+
return this._loader.importMeshAsync(null, scene, container, data, rootUrl, onProgress, fileName).then((result) => {
|
560
507
|
Array.prototype.push.apply(container.geometries, result.geometries);
|
561
508
|
Array.prototype.push.apply(container.meshes, result.meshes);
|
562
509
|
Array.prototype.push.apply(container.particleSystems, result.particleSystems);
|
@@ -570,79 +517,74 @@ var GLTFFileLoader = /** @class */ (function () {
|
|
570
517
|
return container;
|
571
518
|
});
|
572
519
|
});
|
573
|
-
}
|
520
|
+
}
|
574
521
|
/**
|
575
522
|
* @param data
|
576
523
|
* @hidden
|
577
524
|
*/
|
578
|
-
|
525
|
+
canDirectLoad(data) {
|
579
526
|
return ((data.indexOf("asset") !== -1 && data.indexOf("version") !== -1) ||
|
580
527
|
data.startsWith("data:base64," + GLTFFileLoader._MagicBase64Encoded) || // this is technically incorrect, but will continue to support for backcompat.
|
581
528
|
data.startsWith("data:;base64," + GLTFFileLoader._MagicBase64Encoded) ||
|
582
529
|
data.startsWith("data:application/octet-stream;base64," + GLTFFileLoader._MagicBase64Encoded) ||
|
583
530
|
data.startsWith("data:model/gltf-binary;base64," + GLTFFileLoader._MagicBase64Encoded));
|
584
|
-
}
|
531
|
+
}
|
585
532
|
/**
|
586
533
|
* @param scene
|
587
534
|
* @param data
|
588
535
|
* @hidden
|
589
536
|
*/
|
590
|
-
|
537
|
+
directLoad(scene, data) {
|
591
538
|
if (data.startsWith("base64," + GLTFFileLoader._MagicBase64Encoded) || // this is technically incorrect, but will continue to support for backcompat.
|
592
539
|
data.startsWith(";base64," + GLTFFileLoader._MagicBase64Encoded) ||
|
593
540
|
data.startsWith("application/octet-stream;base64," + GLTFFileLoader._MagicBase64Encoded) ||
|
594
541
|
data.startsWith("model/gltf-binary;base64," + GLTFFileLoader._MagicBase64Encoded)) {
|
595
|
-
|
596
|
-
this._validate(scene,
|
542
|
+
const arrayBuffer = DecodeBase64UrlToBinary(data);
|
543
|
+
this._validate(scene, arrayBuffer);
|
597
544
|
return this._unpackBinaryAsync(new DataReader({
|
598
|
-
readAsync:
|
599
|
-
byteLength:
|
545
|
+
readAsync: (byteOffset, byteLength) => readAsync(arrayBuffer, byteOffset, byteLength),
|
546
|
+
byteLength: arrayBuffer.byteLength,
|
600
547
|
}));
|
601
548
|
}
|
602
549
|
this._validate(scene, data);
|
603
550
|
return Promise.resolve({ json: this._parseJson(data) });
|
604
|
-
}
|
551
|
+
}
|
605
552
|
/** @hidden */
|
606
|
-
|
553
|
+
createPlugin() {
|
607
554
|
return new GLTFFileLoader();
|
608
|
-
}
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
},
|
616
|
-
enumerable: false,
|
617
|
-
configurable: true
|
618
|
-
});
|
555
|
+
}
|
556
|
+
/**
|
557
|
+
* The loader state or null if the loader is not active.
|
558
|
+
*/
|
559
|
+
get loaderState() {
|
560
|
+
return this._state;
|
561
|
+
}
|
619
562
|
/**
|
620
563
|
* Returns a promise that resolves when the asset is completely loaded.
|
621
564
|
* @returns a promise that resolves when the asset is completely loaded.
|
622
565
|
*/
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
_this.onCompleteObservable.addOnce(function () {
|
566
|
+
whenCompleteAsync() {
|
567
|
+
return new Promise((resolve, reject) => {
|
568
|
+
this.onCompleteObservable.addOnce(() => {
|
627
569
|
resolve();
|
628
570
|
});
|
629
|
-
|
571
|
+
this.onErrorObservable.addOnce((reason) => {
|
630
572
|
reject(reason);
|
631
573
|
});
|
632
574
|
});
|
633
|
-
}
|
575
|
+
}
|
634
576
|
/**
|
635
577
|
* @param state
|
636
578
|
* @hidden
|
637
579
|
*/
|
638
|
-
|
580
|
+
_setState(state) {
|
639
581
|
if (this._state === state) {
|
640
582
|
return;
|
641
583
|
}
|
642
584
|
this._state = state;
|
643
585
|
this.onLoaderStateChangedObservable.notifyObservers(this._state);
|
644
586
|
this._log(GLTFLoaderState[this._state]);
|
645
|
-
}
|
587
|
+
}
|
646
588
|
/**
|
647
589
|
* @param scene
|
648
590
|
* @param fileOrUrl
|
@@ -652,73 +594,68 @@ var GLTFFileLoader = /** @class */ (function () {
|
|
652
594
|
* @param onOpened
|
653
595
|
* @hidden
|
654
596
|
*/
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
_this._onProgress(event, request);
|
597
|
+
_loadFile(scene, fileOrUrl, onSuccess, useArrayBuffer, onError, onOpened) {
|
598
|
+
const request = scene._loadFile(fileOrUrl, onSuccess, (event) => {
|
599
|
+
this._onProgress(event, request);
|
659
600
|
}, true, useArrayBuffer, onError, onOpened);
|
660
|
-
request.onCompleteObservable.add(
|
661
|
-
|
601
|
+
request.onCompleteObservable.add((request) => {
|
602
|
+
this._requests.splice(this._requests.indexOf(request), 1);
|
662
603
|
});
|
663
604
|
this._requests.push(request);
|
664
605
|
return request;
|
665
|
-
}
|
666
|
-
|
606
|
+
}
|
607
|
+
_onProgress(event, request) {
|
667
608
|
if (!this._progressCallback) {
|
668
609
|
return;
|
669
610
|
}
|
670
611
|
request._lengthComputable = event.lengthComputable;
|
671
612
|
request._loaded = event.loaded;
|
672
613
|
request._total = event.total;
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
for (
|
677
|
-
|
678
|
-
if (request_1._lengthComputable === undefined || request_1._loaded === undefined || request_1._total === undefined) {
|
614
|
+
let lengthComputable = true;
|
615
|
+
let loaded = 0;
|
616
|
+
let total = 0;
|
617
|
+
for (const request of this._requests) {
|
618
|
+
if (request._lengthComputable === undefined || request._loaded === undefined || request._total === undefined) {
|
679
619
|
return;
|
680
620
|
}
|
681
|
-
lengthComputable = lengthComputable &&
|
682
|
-
loaded +=
|
683
|
-
total +=
|
621
|
+
lengthComputable = lengthComputable && request._lengthComputable;
|
622
|
+
loaded += request._loaded;
|
623
|
+
total += request._total;
|
684
624
|
}
|
685
625
|
this._progressCallback({
|
686
626
|
lengthComputable: lengthComputable,
|
687
627
|
loaded: loaded,
|
688
628
|
total: lengthComputable ? total : 0,
|
689
629
|
});
|
690
|
-
}
|
691
|
-
|
692
|
-
var _this = this;
|
693
|
-
if (rootUrl === void 0) { rootUrl = ""; }
|
694
|
-
if (fileName === void 0) { fileName = ""; }
|
630
|
+
}
|
631
|
+
_validate(scene, data, rootUrl = "", fileName = "") {
|
695
632
|
if (!this.validate) {
|
696
633
|
return;
|
697
634
|
}
|
698
635
|
this._startPerformanceCounter("Validate JSON");
|
699
|
-
GLTFValidation.ValidateAsync(data, rootUrl, fileName,
|
700
|
-
return
|
701
|
-
}).then(
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
},
|
706
|
-
|
707
|
-
Tools.Warn(
|
708
|
-
|
636
|
+
GLTFValidation.ValidateAsync(data, rootUrl, fileName, (uri) => {
|
637
|
+
return this.preprocessUrlAsync(rootUrl + uri).then((url) => scene._loadFileAsync(url, undefined, true, true));
|
638
|
+
}).then((result) => {
|
639
|
+
this._endPerformanceCounter("Validate JSON");
|
640
|
+
this.onValidatedObservable.notifyObservers(result);
|
641
|
+
this.onValidatedObservable.clear();
|
642
|
+
}, (reason) => {
|
643
|
+
this._endPerformanceCounter("Validate JSON");
|
644
|
+
Tools.Warn(`Failed to validate: ${reason.message}`);
|
645
|
+
this.onValidatedObservable.clear();
|
709
646
|
});
|
710
|
-
}
|
711
|
-
|
712
|
-
|
713
|
-
this._log(
|
714
|
-
asset.minVersion && this._log(
|
715
|
-
asset.generator && this._log(
|
716
|
-
|
647
|
+
}
|
648
|
+
_getLoader(loaderData) {
|
649
|
+
const asset = loaderData.json.asset || {};
|
650
|
+
this._log(`Asset version: ${asset.version}`);
|
651
|
+
asset.minVersion && this._log(`Asset minimum version: ${asset.minVersion}`);
|
652
|
+
asset.generator && this._log(`Asset generator: ${asset.generator}`);
|
653
|
+
const version = GLTFFileLoader._parseVersion(asset.version);
|
717
654
|
if (!version) {
|
718
655
|
throw new Error("Invalid version: " + asset.version);
|
719
656
|
}
|
720
657
|
if (asset.minVersion !== undefined) {
|
721
|
-
|
658
|
+
const minVersion = GLTFFileLoader._parseVersion(asset.minVersion);
|
722
659
|
if (!minVersion) {
|
723
660
|
throw new Error("Invalid minimum version: " + asset.minVersion);
|
724
661
|
}
|
@@ -726,113 +663,111 @@ var GLTFFileLoader = /** @class */ (function () {
|
|
726
663
|
throw new Error("Incompatible minimum version: " + asset.minVersion);
|
727
664
|
}
|
728
665
|
}
|
729
|
-
|
666
|
+
const createLoaders = {
|
730
667
|
1: GLTFFileLoader._CreateGLTF1Loader,
|
731
668
|
2: GLTFFileLoader._CreateGLTF2Loader,
|
732
669
|
};
|
733
|
-
|
670
|
+
const createLoader = createLoaders[version.major];
|
734
671
|
if (!createLoader) {
|
735
672
|
throw new Error("Unsupported version: " + asset.version);
|
736
673
|
}
|
737
674
|
return createLoader(this);
|
738
|
-
}
|
739
|
-
|
675
|
+
}
|
676
|
+
_parseJson(json) {
|
740
677
|
this._startPerformanceCounter("Parse JSON");
|
741
|
-
this._log(
|
742
|
-
|
678
|
+
this._log(`JSON length: ${json.length}`);
|
679
|
+
const parsed = JSON.parse(json);
|
743
680
|
this._endPerformanceCounter("Parse JSON");
|
744
681
|
return parsed;
|
745
|
-
}
|
746
|
-
|
747
|
-
var _this = this;
|
682
|
+
}
|
683
|
+
_unpackBinaryAsync(dataReader) {
|
748
684
|
this._startPerformanceCounter("Unpack Binary");
|
749
685
|
// Read magic + version + length + json length + json format
|
750
|
-
return dataReader.loadAsync(20).then(
|
751
|
-
|
686
|
+
return dataReader.loadAsync(20).then(() => {
|
687
|
+
const Binary = {
|
752
688
|
Magic: 0x46546c67,
|
753
689
|
};
|
754
|
-
|
690
|
+
const magic = dataReader.readUint32();
|
755
691
|
if (magic !== Binary.Magic) {
|
756
692
|
throw new RuntimeError("Unexpected magic: " + magic, ErrorCodes.GLTFLoaderUnexpectedMagicError);
|
757
693
|
}
|
758
|
-
|
759
|
-
if (
|
760
|
-
|
694
|
+
const version = dataReader.readUint32();
|
695
|
+
if (this.loggingEnabled) {
|
696
|
+
this._log(`Binary version: ${version}`);
|
761
697
|
}
|
762
|
-
|
698
|
+
const length = dataReader.readUint32();
|
763
699
|
if (dataReader.buffer.byteLength !== 0 && length !== dataReader.buffer.byteLength) {
|
764
|
-
throw new Error(
|
700
|
+
throw new Error(`Length in header does not match actual data length: ${length} != ${dataReader.buffer.byteLength}`);
|
765
701
|
}
|
766
|
-
|
702
|
+
let unpacked;
|
767
703
|
switch (version) {
|
768
704
|
case 1: {
|
769
|
-
unpacked =
|
705
|
+
unpacked = this._unpackBinaryV1Async(dataReader, length);
|
770
706
|
break;
|
771
707
|
}
|
772
708
|
case 2: {
|
773
|
-
unpacked =
|
709
|
+
unpacked = this._unpackBinaryV2Async(dataReader, length);
|
774
710
|
break;
|
775
711
|
}
|
776
712
|
default: {
|
777
713
|
throw new Error("Unsupported version: " + version);
|
778
714
|
}
|
779
715
|
}
|
780
|
-
|
716
|
+
this._endPerformanceCounter("Unpack Binary");
|
781
717
|
return unpacked;
|
782
718
|
});
|
783
|
-
}
|
784
|
-
|
785
|
-
|
719
|
+
}
|
720
|
+
_unpackBinaryV1Async(dataReader, length) {
|
721
|
+
const ContentFormat = {
|
786
722
|
JSON: 0,
|
787
723
|
};
|
788
|
-
|
789
|
-
|
724
|
+
const contentLength = dataReader.readUint32();
|
725
|
+
const contentFormat = dataReader.readUint32();
|
790
726
|
if (contentFormat !== ContentFormat.JSON) {
|
791
|
-
throw new Error(
|
727
|
+
throw new Error(`Unexpected content format: ${contentFormat}`);
|
792
728
|
}
|
793
|
-
|
794
|
-
|
729
|
+
const bodyLength = length - dataReader.byteOffset;
|
730
|
+
const data = { json: this._parseJson(dataReader.readString(contentLength)), bin: null };
|
795
731
|
if (bodyLength !== 0) {
|
796
|
-
|
732
|
+
const startByteOffset = dataReader.byteOffset;
|
797
733
|
data.bin = {
|
798
|
-
readAsync:
|
734
|
+
readAsync: (byteOffset, byteLength) => dataReader.buffer.readAsync(startByteOffset + byteOffset, byteLength),
|
799
735
|
byteLength: bodyLength,
|
800
736
|
};
|
801
737
|
}
|
802
738
|
return Promise.resolve(data);
|
803
|
-
}
|
804
|
-
|
805
|
-
|
806
|
-
var ChunkFormat = {
|
739
|
+
}
|
740
|
+
_unpackBinaryV2Async(dataReader, length) {
|
741
|
+
const ChunkFormat = {
|
807
742
|
JSON: 0x4e4f534a,
|
808
743
|
BIN: 0x004e4942,
|
809
744
|
};
|
810
745
|
// Read the JSON chunk header.
|
811
|
-
|
812
|
-
|
746
|
+
const chunkLength = dataReader.readUint32();
|
747
|
+
const chunkFormat = dataReader.readUint32();
|
813
748
|
if (chunkFormat !== ChunkFormat.JSON) {
|
814
749
|
throw new Error("First chunk format is not JSON");
|
815
750
|
}
|
816
751
|
// Bail if there are no other chunks.
|
817
752
|
if (dataReader.byteOffset + chunkLength === length) {
|
818
|
-
return dataReader.loadAsync(chunkLength).then(
|
819
|
-
return { json:
|
753
|
+
return dataReader.loadAsync(chunkLength).then(() => {
|
754
|
+
return { json: this._parseJson(dataReader.readString(chunkLength)), bin: null };
|
820
755
|
});
|
821
756
|
}
|
822
757
|
// Read the JSON chunk and the length and type of the next chunk.
|
823
|
-
return dataReader.loadAsync(chunkLength + 8).then(
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
758
|
+
return dataReader.loadAsync(chunkLength + 8).then(() => {
|
759
|
+
const data = { json: this._parseJson(dataReader.readString(chunkLength)), bin: null };
|
760
|
+
const readAsync = () => {
|
761
|
+
const chunkLength = dataReader.readUint32();
|
762
|
+
const chunkFormat = dataReader.readUint32();
|
828
763
|
switch (chunkFormat) {
|
829
764
|
case ChunkFormat.JSON: {
|
830
765
|
throw new Error("Unexpected JSON chunk");
|
831
766
|
}
|
832
767
|
case ChunkFormat.BIN: {
|
833
|
-
|
768
|
+
const startByteOffset = dataReader.byteOffset;
|
834
769
|
data.bin = {
|
835
|
-
readAsync:
|
770
|
+
readAsync: (byteOffset, byteLength) => dataReader.buffer.readAsync(startByteOffset + byteOffset, byteLength),
|
836
771
|
byteLength: chunkLength,
|
837
772
|
};
|
838
773
|
dataReader.skipBytes(chunkLength);
|
@@ -851,15 +786,15 @@ var GLTFFileLoader = /** @class */ (function () {
|
|
851
786
|
};
|
852
787
|
return readAsync();
|
853
788
|
});
|
854
|
-
}
|
855
|
-
|
789
|
+
}
|
790
|
+
static _parseVersion(version) {
|
856
791
|
if (version === "1.0" || version === "1.0.1") {
|
857
792
|
return {
|
858
793
|
major: 1,
|
859
794
|
minor: 0,
|
860
795
|
};
|
861
796
|
}
|
862
|
-
|
797
|
+
const match = (version + "").match(/^(\d+)\.(\d+)/);
|
863
798
|
if (!match) {
|
864
799
|
return null;
|
865
800
|
}
|
@@ -867,8 +802,8 @@ var GLTFFileLoader = /** @class */ (function () {
|
|
867
802
|
major: parseInt(match[1]),
|
868
803
|
minor: parseInt(match[2]),
|
869
804
|
};
|
870
|
-
}
|
871
|
-
|
805
|
+
}
|
806
|
+
static _compareVersion(a, b) {
|
872
807
|
if (a.major > b.major) {
|
873
808
|
return 1;
|
874
809
|
}
|
@@ -882,53 +817,51 @@ var GLTFFileLoader = /** @class */ (function () {
|
|
882
817
|
return -1;
|
883
818
|
}
|
884
819
|
return 0;
|
885
|
-
}
|
820
|
+
}
|
886
821
|
/**
|
887
822
|
* @param message
|
888
823
|
* @hidden
|
889
824
|
*/
|
890
|
-
|
825
|
+
_logOpen(message) {
|
891
826
|
this._log(message);
|
892
827
|
this._logIndentLevel++;
|
893
|
-
}
|
828
|
+
}
|
894
829
|
/** @hidden */
|
895
|
-
|
830
|
+
_logClose() {
|
896
831
|
--this._logIndentLevel;
|
897
|
-
}
|
898
|
-
|
899
|
-
|
900
|
-
Logger.Log(
|
901
|
-
}
|
902
|
-
|
903
|
-
|
832
|
+
}
|
833
|
+
_logEnabled(message) {
|
834
|
+
const spaces = GLTFFileLoader._logSpaces.substr(0, this._logIndentLevel * 2);
|
835
|
+
Logger.Log(`${spaces}${message}`);
|
836
|
+
}
|
837
|
+
_logDisabled(message) { }
|
838
|
+
_startPerformanceCounterEnabled(counterName) {
|
904
839
|
Tools.StartPerformanceCounter(counterName);
|
905
|
-
}
|
906
|
-
|
907
|
-
|
840
|
+
}
|
841
|
+
_startPerformanceCounterDisabled(counterName) { }
|
842
|
+
_endPerformanceCounterEnabled(counterName) {
|
908
843
|
Tools.EndPerformanceCounter(counterName);
|
909
|
-
}
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
}());
|
931
|
-
export { GLTFFileLoader };
|
844
|
+
}
|
845
|
+
_endPerformanceCounterDisabled(counterName) { }
|
846
|
+
}
|
847
|
+
// ----------
|
848
|
+
// V1 options
|
849
|
+
// ----------
|
850
|
+
/**
|
851
|
+
* Set this property to false to disable incremental loading which delays the loader from calling the success callback until after loading the meshes and shaders.
|
852
|
+
* Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
|
853
|
+
* Defaults to true.
|
854
|
+
* @hidden
|
855
|
+
*/
|
856
|
+
GLTFFileLoader.IncrementalLoading = true;
|
857
|
+
/**
|
858
|
+
* Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
|
859
|
+
* Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
|
860
|
+
* @hidden
|
861
|
+
*/
|
862
|
+
GLTFFileLoader.HomogeneousCoordinates = false;
|
863
|
+
GLTFFileLoader._MagicBase64Encoded = "Z2xURg"; // "glTF" base64 encoded (without the quotes!)
|
864
|
+
GLTFFileLoader._logSpaces = " ";
|
932
865
|
if (SceneLoader) {
|
933
866
|
SceneLoader.RegisterPlugin(new GLTFFileLoader());
|
934
867
|
}
|