@babylonjs/loaders 7.19.1 → 7.20.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -387,12 +387,21 @@ export class GLTFLoader {
387
387
  }
388
388
  _loadExtensions() {
389
389
  for (const name in GLTFLoader._RegisteredExtensions) {
390
- const extension = GLTFLoader._RegisteredExtensions[name].factory(this);
391
- if (extension.name !== name) {
392
- Logger.Warn(`The name of the glTF loader extension instance does not match the registered name: ${extension.name} !== ${name}`);
390
+ // Don't load explicitly disabled extensions.
391
+ if (this.parent.extensionOptions[name]?.enabled === false) {
392
+ // But warn if the disabled extension is used by the model.
393
+ if (this.isExtensionUsed(name)) {
394
+ Logger.Warn(`Extension ${name} is used but has been explicitly disabled.`);
395
+ }
396
+ }
397
+ else {
398
+ const extension = GLTFLoader._RegisteredExtensions[name].factory(this);
399
+ if (extension.name !== name) {
400
+ Logger.Warn(`The name of the glTF loader extension instance does not match the registered name: ${extension.name} !== ${name}`);
401
+ }
402
+ this._extensions.push(extension);
403
+ this._parent.onExtensionLoadedObservable.notifyObservers(extension);
393
404
  }
394
- this._extensions.push(extension);
395
- this._parent.onExtensionLoadedObservable.notifyObservers(extension);
396
405
  }
397
406
  this._extensions.sort((a, b) => (a.order || Number.MAX_VALUE) - (b.order || Number.MAX_VALUE));
398
407
  this._parent.onExtensionLoadedObservable.clear();
@@ -402,6 +411,9 @@ export class GLTFLoader {
402
411
  for (const name of this._gltf.extensionsRequired) {
403
412
  const available = this._extensions.some((extension) => extension.name === name && extension.enabled);
404
413
  if (!available) {
414
+ if (this.parent.extensionOptions[name]?.enabled === false) {
415
+ throw new Error(`Required extension ${name} is disabled`);
416
+ }
405
417
  throw new Error(`Required extension ${name} is not available`);
406
418
  }
407
419
  }