@babylonjs/loaders 7.8.0 → 7.8.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -602,8 +602,10 @@ export class GLTFFileLoader {
602
602
  const request = scene._loadFile(fileOrUrl, onSuccess, (event) => {
603
603
  this._onProgress(event, request);
604
604
  }, true, useArrayBuffer, onError, onOpened);
605
- request.onCompleteObservable.add((request) => {
606
- this._requests.splice(this._requests.indexOf(request), 1);
605
+ request.onCompleteObservable.add(() => {
606
+ // Force the length computable to be true since we can guarantee the data is loaded.
607
+ request._lengthComputable = true;
608
+ request._total = request._loaded;
607
609
  });
608
610
  this._requests.push(request);
609
611
  return request;
@@ -1 +1 @@
1
- {"version":3,"file":"glTFFileLoader.js","sourceRoot":"","sources":["../../../../dev/loaders/src/glTF/glTFFileLoader.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,2CAA6B;AAClD,OAAO,EAAE,KAAK,EAAE,sCAAwB;AAaxC,OAAO,EAAE,WAAW,EAAE,+CAAiC;AACvD,OAAO,EAAE,cAAc,EAAE,0CAA4B;AAIrD,OAAO,EAAE,MAAM,EAAE,uCAAyB;AAE1C,OAAO,EAAE,UAAU,EAAE,2CAA6B;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,uBAAuB,EAAE,0CAA4B;AAC9D,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,sCAAwB;AAU3D,SAAS,SAAS,CAAC,WAAwB,EAAE,UAAkB,EAAE,UAAkB;IAC/E,IAAI;QACA,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,UAAU,CAAC,WAAW,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC;KAC/E;IAAC,OAAO,CAAC,EAAE;QACR,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;KAC5B;AACL,CAAC;AAED,SAAS,aAAa,CAAC,eAAgC,EAAE,UAAkB,EAAE,UAAkB;IAC3F,IAAI;QACA,IAAI,UAAU,GA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CAAC,eAAe,EAAE,CAAC;IAC3B,CAAC;IAED,gBAAgB;IACT,SAAS;QACZ,EAAE,IAAI,CAAC,eAAe,CAAC;IAC3B,CAAC;IAEO,WAAW,CAAC,OAAe;QAC/B,MAAM,MAAM,GAAG,cAAc,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,eAAe,GAAG,CAAC,CAAC,CAAC;QAC7E,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,GAAG,OAAO,EAAE,CAAC,CAAC;IACtC,CAAC;IAEO,YAAY,CAAC,OAAe,IAAS,CAAC;IAUtC,+BAA+B,CAAC,WAAmB;QACvD,KAAK,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC;IAC/C,CAAC;IAEO,gCAAgC,CAAC,WAAmB,IAAS,CAAC;IAE9D,6BAA6B,CAAC,WAAmB;QACrD,KAAK,CAAC,qBAAqB,CAAC,WAAW,CAAC,CAAC;IAC7C,CAAC;IAEO,8BAA8B,CAAC,WAAmB,IAAS,CAAC;;AA7/BpE,aAAa;AACb,aAAa;AACb,aAAa;AAEb;;;;;GAKG;AACW,iCAAkB,GAAG,IAAI,AAAP,CAAQ;AAExC;;;;GAIG;AACW,qCAAsB,GAAG,KAAK,AAAR,CAAS;AAiU9B,kCAAmB,GAAG,QAAQ,AAAX,CAAY,CAAC,8CAA8C;AA8nBrE,yBAAU,GAAG,kCAAkC,AAArC,CAAsC;AAgD5E,IAAI,WAAW,EAAE;IACb,WAAW,CAAC,cAAc,CAAC,IAAI,cAAc,EAAE,CAAC,CAAC;CACpD","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\r\n/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type * as GLTF2 from \"babylonjs-gltf2interface\";\r\nimport type { Nullable } from \"core/types\";\r\nimport type { Observer } from \"core/Misc/observable\";\r\nimport { Observable } from \"core/Misc/observable\";\r\nimport { Tools } from \"core/Misc/tools\";\r\nimport type { Camera } from \"core/Cameras/camera\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport type { AbstractMesh } from \"core/Meshes/abstractMesh\";\r\nimport type {\r\n ISceneLoaderPluginFactory,\r\n ISceneLoaderPlugin,\r\n ISceneLoaderPluginAsync,\r\n ISceneLoaderProgressEvent,\r\n ISceneLoaderPluginExtensions,\r\n ISceneLoaderAsyncResult,\r\n} from \"core/Loading/sceneLoader\";\r\nimport { SceneLoader } from \"core/Loading/sceneLoader\";\r\nimport { AssetContainer } from \"core/assetContainer\";\r\nimport type { Scene, IDisposable } from \"core/scene\";\r\nimport type { WebRequest } from \"core/Misc/webRequest\";\r\nimport type { IFileRequest } from \"core/Misc/fileRequest\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport type { IDataBuffer } from \"core/Misc/dataReader\";\r\nimport { DataReader } from \"core/Misc/dataReader\";\r\nimport { GLTFValidation } from \"./glTFValidation\";\r\nimport type { LoadFileError } from \"core/Misc/fileTools\";\r\nimport { DecodeBase64UrlToBinary } from \"core/Misc/fileTools\";\r\nimport { RuntimeError, ErrorCodes } from \"core/Misc/error\";\r\nimport type { TransformNode } from \"core/Meshes/transformNode\";\r\nimport type { MorphTargetManager } from \"core/Morph/morphTargetManager\";\r\n\r\ninterface IFileRequestInfo extends IFileRequest {\r\n _lengthComputable?: boolean;\r\n _loaded?: number;\r\n _total?: number;\r\n}\r\n\r\nfunction readAsync(arrayBuffer: ArrayBuffer, byteOffset: number, byteLength: number): Promise<Uint8Array> {\r\n try {\r\n return Promise.resolve(new Uint8Array(arrayBuffer, byteOffset, byteLength));\r\n } catch (e) {\r\n return Promise.reject(e);\r\n }\r\n}\r\n\r\nfunction readViewAsync(arrayBufferView: ArrayBufferView, byteOffset: number, byteLength: number): Promise<Uint8Array> {\r\n try {\r\n if (byteOffset < 0 || byteOffset >= arrayBufferView.byteLength) {\r\n throw new RangeError(\"Offset is out of range.\");\r\n }\r\n\r\n if (byteOffset + byteLength > arrayBufferView.byteLength) {\r\n throw new RangeError(\"Length is out of range.\");\r\n }\r\n\r\n return Promise.resolve(new Uint8Array(arrayBufferView.buffer, arrayBufferView.byteOffset + byteOffset, byteLength));\r\n } catch (e) {\r\n return Promise.reject(e);\r\n }\r\n}\r\n\r\n/**\r\n * Mode that determines the coordinate system to use.\r\n */\r\nexport enum GLTFLoaderCoordinateSystemMode {\r\n /**\r\n * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.\r\n */\r\n AUTO,\r\n\r\n /**\r\n * Sets the useRightHandedSystem flag on the scene.\r\n */\r\n FORCE_RIGHT_HANDED,\r\n}\r\n\r\n/**\r\n * Mode that determines what animations will start.\r\n */\r\nexport enum GLTFLoaderAnimationStartMode {\r\n /**\r\n * No animation will start.\r\n */\r\n NONE,\r\n\r\n /**\r\n * The first animation will start.\r\n */\r\n FIRST,\r\n\r\n /**\r\n * All animations will start.\r\n */\r\n ALL,\r\n}\r\n\r\n/**\r\n * Interface that contains the data for the glTF asset.\r\n */\r\nexport interface IGLTFLoaderData {\r\n /**\r\n * The object that represents the glTF JSON.\r\n */\r\n json: Object;\r\n\r\n /**\r\n * The BIN chunk of a binary glTF.\r\n */\r\n bin: Nullable<IDataBuffer>;\r\n}\r\n\r\n/**\r\n * Interface for extending the loader.\r\n */\r\nexport interface IGLTFLoaderExtension {\r\n /**\r\n * The name of this extension.\r\n */\r\n readonly name: string;\r\n\r\n /**\r\n * Defines whether this extension is enabled.\r\n */\r\n enabled: boolean;\r\n\r\n /**\r\n * Defines the order of this extension.\r\n * The loader sorts the extensions using these values when loading.\r\n */\r\n order?: number;\r\n}\r\n\r\n/**\r\n * Loader state.\r\n */\r\nexport enum GLTFLoaderState {\r\n /**\r\n * The asset is loading.\r\n */\r\n LOADING,\r\n\r\n /**\r\n * The asset is ready for rendering.\r\n */\r\n READY,\r\n\r\n /**\r\n * The asset is completely loaded.\r\n */\r\n COMPLETE,\r\n}\r\n\r\n/** @internal */\r\nexport interface IGLTFLoader extends IDisposable {\r\n importMeshAsync: (\r\n meshesNames: any,\r\n scene: Scene,\r\n container: Nullable<AssetContainer>,\r\n data: IGLTFLoaderData,\r\n rootUrl: string,\r\n onProgress?: (event: ISceneLoaderProgressEvent) => void,\r\n fileName?: string\r\n ) => Promise<ISceneLoaderAsyncResult>;\r\n loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;\r\n}\r\n\r\n/**\r\n * File loader for loading glTF files into a scene.\r\n */\r\nexport class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {\r\n /** @internal */\r\n public static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;\r\n\r\n /** @internal */\r\n public static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;\r\n\r\n // --------------\r\n // Common options\r\n // --------------\r\n\r\n /**\r\n * Raised when the asset has been parsed\r\n */\r\n public onParsedObservable = new Observable<IGLTFLoaderData>();\r\n\r\n private _onParsedObserver: Nullable<Observer<IGLTFLoaderData>>;\r\n\r\n /**\r\n * Raised when the asset has been parsed\r\n */\r\n public set onParsed(callback: (loaderData: IGLTFLoaderData) => void) {\r\n if (this._onParsedObserver) {\r\n this.onParsedObservable.remove(this._onParsedObserver);\r\n }\r\n this._onParsedObserver = this.onParsedObservable.add(callback);\r\n }\r\n\r\n // ----------\r\n // V1 options\r\n // ----------\r\n\r\n /**\r\n * 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.\r\n * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.\r\n * Defaults to true.\r\n * @internal\r\n */\r\n public static IncrementalLoading = true;\r\n\r\n /**\r\n * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.\r\n * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.\r\n * @internal\r\n */\r\n public static HomogeneousCoordinates = false;\r\n\r\n // ----------\r\n // V2 options\r\n // ----------\r\n\r\n /**\r\n * The coordinate system mode. Defaults to AUTO.\r\n */\r\n public coordinateSystemMode = GLTFLoaderCoordinateSystemMode.AUTO;\r\n\r\n /**\r\n * The animation start mode. Defaults to FIRST.\r\n */\r\n public animationStartMode = GLTFLoaderAnimationStartMode.FIRST;\r\n\r\n /**\r\n * Defines if the loader should compile materials before raising the success callback. Defaults to false.\r\n */\r\n public compileMaterials = false;\r\n\r\n /**\r\n * Defines if the loader should also compile materials with clip planes. Defaults to false.\r\n */\r\n public useClipPlane = false;\r\n\r\n /**\r\n * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.\r\n */\r\n public compileShadowGenerators = false;\r\n\r\n /**\r\n * Defines if the Alpha blended materials are only applied as coverage.\r\n * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.\r\n * If true, no extra effects are applied to transparent pixels.\r\n */\r\n public transparencyAsCoverage = false;\r\n\r\n /**\r\n * Defines if the loader should use range requests when load binary glTF files from HTTP.\r\n * Enabling will disable offline support and glTF validator.\r\n * Defaults to false.\r\n */\r\n public useRangeRequests = false;\r\n\r\n /**\r\n * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.\r\n */\r\n public createInstances = true;\r\n\r\n /**\r\n * Defines if the loader should always compute the bounding boxes of meshes and not use the min/max values from the position accessor. Defaults to false.\r\n */\r\n public alwaysComputeBoundingBox = false;\r\n\r\n /**\r\n * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.\r\n */\r\n public loadAllMaterials = false;\r\n\r\n /**\r\n * If true, load only the materials defined in the file. Defaults to false.\r\n */\r\n public loadOnlyMaterials = false;\r\n\r\n /**\r\n * If true, do not load any materials defined in the file. Defaults to false.\r\n */\r\n public skipMaterials = false;\r\n\r\n /**\r\n * If true, load the color (gamma encoded) textures into sRGB buffers (if supported by the GPU), which will yield more accurate results when sampling the texture. Defaults to true.\r\n */\r\n public useSRGBBuffers = true;\r\n\r\n /**\r\n * When loading glTF animations, which are defined in seconds, target them to this FPS. Defaults to 60.\r\n */\r\n public targetFps = 60;\r\n\r\n /**\r\n * Defines if the loader should always compute the nearest common ancestor of the skeleton joints instead of using `skin.skeleton`. Defaults to false.\r\n * Set this to true if loading assets with invalid `skin.skeleton` values.\r\n */\r\n public alwaysComputeSkeletonRootNode = false;\r\n\r\n /**\r\n * Function called before loading a url referenced by the asset.\r\n * @param url url referenced by the asset\r\n * @returns Async url to load\r\n */\r\n public preprocessUrlAsync = (url: string) => Promise.resolve(url);\r\n\r\n /**\r\n * Defines the node to use as the root of the hierarchy when loading the scene (default: undefined). If not defined, a root node will be automatically created.\r\n * You can also pass null if you don't want a root node to be created.\r\n */\r\n public customRootNode?: Nullable<TransformNode>;\r\n\r\n /**\r\n * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.\r\n * 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, ...)\r\n */\r\n public readonly onMeshLoadedObservable = new Observable<AbstractMesh>();\r\n\r\n private _onMeshLoadedObserver: Nullable<Observer<AbstractMesh>>;\r\n\r\n /**\r\n * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.\r\n * 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, ...)\r\n */\r\n public set onMeshLoaded(callback: (mesh: AbstractMesh) => void) {\r\n if (this._onMeshLoadedObserver) {\r\n this.onMeshLoadedObservable.remove(this._onMeshLoadedObserver);\r\n }\r\n this._onMeshLoadedObserver = this.onMeshLoadedObservable.add(callback);\r\n }\r\n\r\n /**\r\n * Callback raised when the loader creates a skin after parsing the glTF properties of the skin node.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/importers/glTF/glTFSkinning#ignoring-the-transform-of-the-skinned-mesh\r\n * @param node - the transform node that corresponds to the original glTF skin node used for animations\r\n * @param skinnedNode - the transform node that is the skinned mesh itself or the parent of the skinned meshes\r\n */\r\n public readonly onSkinLoadedObservable = new Observable<{ node: TransformNode; skinnedNode: TransformNode }>();\r\n\r\n /**\r\n * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.\r\n */\r\n public readonly onTextureLoadedObservable = new Observable<BaseTexture>();\r\n\r\n private _onTextureLoadedObserver: Nullable<Observer<BaseTexture>>;\r\n\r\n /**\r\n * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.\r\n */\r\n public set onTextureLoaded(callback: (texture: BaseTexture) => void) {\r\n if (this._onTextureLoadedObserver) {\r\n this.onTextureLoadedObservable.remove(this._onTextureLoadedObserver);\r\n }\r\n this._onTextureLoadedObserver = this.onTextureLoadedObservable.add(callback);\r\n }\r\n\r\n /**\r\n * Observable raised when the loader creates a material after parsing the glTF properties of the material.\r\n */\r\n public readonly onMaterialLoadedObservable = new Observable<Material>();\r\n\r\n private _onMaterialLoadedObserver: Nullable<Observer<Material>>;\r\n\r\n /**\r\n * Callback raised when the loader creates a material after parsing the glTF properties of the material.\r\n */\r\n public set onMaterialLoaded(callback: (material: Material) => void) {\r\n if (this._onMaterialLoadedObserver) {\r\n this.onMaterialLoadedObservable.remove(this._onMaterialLoadedObserver);\r\n }\r\n this._onMaterialLoadedObserver = this.onMaterialLoadedObservable.add(callback);\r\n }\r\n\r\n /**\r\n * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.\r\n */\r\n public readonly onCameraLoadedObservable = new Observable<Camera>();\r\n\r\n private _onCameraLoadedObserver: Nullable<Observer<Camera>>;\r\n\r\n /**\r\n * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.\r\n */\r\n public set onCameraLoaded(callback: (camera: Camera) => void) {\r\n if (this._onCameraLoadedObserver) {\r\n this.onCameraLoadedObservable.remove(this._onCameraLoadedObserver);\r\n }\r\n this._onCameraLoadedObserver = this.onCameraLoadedObservable.add(callback);\r\n }\r\n\r\n /**\r\n * Observable raised when the asset is completely loaded, immediately before the loader is disposed.\r\n * For assets with LODs, raised when all of the LODs are complete.\r\n * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.\r\n */\r\n public readonly onCompleteObservable = new Observable<void>();\r\n\r\n private _onCompleteObserver: Nullable<Observer<void>>;\r\n\r\n /**\r\n * Callback raised when the asset is completely loaded, immediately before the loader is disposed.\r\n * For assets with LODs, raised when all of the LODs are complete.\r\n * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.\r\n */\r\n public set onComplete(callback: () => void) {\r\n if (this._onCompleteObserver) {\r\n this.onCompleteObservable.remove(this._onCompleteObserver);\r\n }\r\n this._onCompleteObserver = this.onCompleteObservable.add(callback);\r\n }\r\n\r\n /**\r\n * Observable raised when an error occurs.\r\n */\r\n public readonly onErrorObservable = new Observable<any>();\r\n\r\n private _onErrorObserver: Nullable<Observer<any>>;\r\n\r\n /**\r\n * Callback raised when an error occurs.\r\n */\r\n public set onError(callback: (reason: any) => void) {\r\n if (this._onErrorObserver) {\r\n this.onErrorObservable.remove(this._onErrorObserver);\r\n }\r\n this._onErrorObserver = this.onErrorObservable.add(callback);\r\n }\r\n\r\n /**\r\n * Observable raised after the loader is disposed.\r\n */\r\n public readonly onDisposeObservable = new Observable<void>();\r\n\r\n private _onDisposeObserver: Nullable<Observer<void>>;\r\n\r\n /**\r\n * Callback raised after the loader is disposed.\r\n */\r\n public set onDispose(callback: () => void) {\r\n if (this._onDisposeObserver) {\r\n this.onDisposeObservable.remove(this._onDisposeObserver);\r\n }\r\n this._onDisposeObserver = this.onDisposeObservable.add(callback);\r\n }\r\n\r\n /**\r\n * Observable raised after a loader extension is created.\r\n * Set additional options for a loader extension in this event.\r\n */\r\n public readonly onExtensionLoadedObservable = new Observable<IGLTFLoaderExtension>();\r\n\r\n private _onExtensionLoadedObserver: Nullable<Observer<IGLTFLoaderExtension>>;\r\n\r\n /**\r\n * Callback raised after a loader extension is created.\r\n */\r\n public set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void) {\r\n if (this._onExtensionLoadedObserver) {\r\n this.onExtensionLoadedObservable.remove(this._onExtensionLoadedObserver);\r\n }\r\n this._onExtensionLoadedObserver = this.onExtensionLoadedObservable.add(callback);\r\n }\r\n\r\n /**\r\n * Defines if the loader logging is enabled.\r\n */\r\n public get loggingEnabled(): boolean {\r\n return this._loggingEnabled;\r\n }\r\n\r\n public set loggingEnabled(value: boolean) {\r\n if (this._loggingEnabled === value) {\r\n return;\r\n }\r\n\r\n this._loggingEnabled = value;\r\n\r\n if (this._loggingEnabled) {\r\n this._log = this._logEnabled;\r\n } else {\r\n this._log = this._logDisabled;\r\n }\r\n }\r\n\r\n /**\r\n * Defines if the loader should capture performance counters.\r\n */\r\n public get capturePerformanceCounters(): boolean {\r\n return this._capturePerformanceCounters;\r\n }\r\n\r\n public set capturePerformanceCounters(value: boolean) {\r\n if (this._capturePerformanceCounters === value) {\r\n return;\r\n }\r\n\r\n this._capturePerformanceCounters = value;\r\n\r\n if (this._capturePerformanceCounters) {\r\n this._startPerformanceCounter = this._startPerformanceCounterEnabled;\r\n this._endPerformanceCounter = this._endPerformanceCounterEnabled;\r\n } else {\r\n this._startPerformanceCounter = this._startPerformanceCounterDisabled;\r\n this._endPerformanceCounter = this._endPerformanceCounterDisabled;\r\n }\r\n }\r\n\r\n /**\r\n * Defines if the loader should validate the asset.\r\n */\r\n public validate = false;\r\n\r\n /**\r\n * Observable raised after validation when validate is set to true. The event data is the result of the validation.\r\n */\r\n public readonly onValidatedObservable = new Observable<GLTF2.IGLTFValidationResults>();\r\n\r\n private _onValidatedObserver: Nullable<Observer<GLTF2.IGLTFValidationResults>>;\r\n\r\n /**\r\n * Callback raised after a loader extension is created.\r\n */\r\n public set onValidated(callback: (results: GLTF2.IGLTFValidationResults) => void) {\r\n if (this._onValidatedObserver) {\r\n this.onValidatedObservable.remove(this._onValidatedObserver);\r\n }\r\n this._onValidatedObserver = this.onValidatedObservable.add(callback);\r\n }\r\n\r\n private _loader: Nullable<IGLTFLoader> = null;\r\n private _state: Nullable<GLTFLoaderState> = null;\r\n private _progressCallback?: (event: ISceneLoaderProgressEvent) => void;\r\n private _requests = new Array<IFileRequestInfo>();\r\n\r\n private static _MagicBase64Encoded = \"Z2xURg\"; // \"glTF\" base64 encoded (without the quotes!)\r\n\r\n /**\r\n * Name of the loader (\"gltf\")\r\n */\r\n public name = \"gltf\";\r\n\r\n /** @internal */\r\n public extensions: ISceneLoaderPluginExtensions = {\r\n \".gltf\": { isBinary: false },\r\n \".glb\": { isBinary: true },\r\n };\r\n\r\n /**\r\n * Disposes the loader, releases resources during load, and cancels any outstanding requests.\r\n */\r\n public dispose(): void {\r\n if (this._loader) {\r\n this._loader.dispose();\r\n this._loader = null;\r\n }\r\n\r\n for (const request of this._requests) {\r\n request.abort();\r\n }\r\n\r\n this._requests.length = 0;\r\n\r\n delete this._progressCallback;\r\n\r\n this.preprocessUrlAsync = (url) => Promise.resolve(url);\r\n\r\n this.onMeshLoadedObservable.clear();\r\n this.onSkinLoadedObservable.clear();\r\n this.onTextureLoadedObservable.clear();\r\n this.onMaterialLoadedObservable.clear();\r\n this.onCameraLoadedObservable.clear();\r\n this.onCompleteObservable.clear();\r\n this.onExtensionLoadedObservable.clear();\r\n\r\n this.onDisposeObservable.notifyObservers(undefined);\r\n this.onDisposeObservable.clear();\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public loadFile(\r\n scene: Scene,\r\n fileOrUrl: File | string | ArrayBufferView,\r\n rootUrl: string,\r\n onSuccess: (data: any, responseURL?: string) => void,\r\n onProgress?: (ev: ISceneLoaderProgressEvent) => void,\r\n useArrayBuffer?: boolean,\r\n onError?: (request?: WebRequest, exception?: LoadFileError) => void,\r\n name?: string\r\n ): Nullable<IFileRequest> {\r\n if (ArrayBuffer.isView(fileOrUrl)) {\r\n this._loadBinary(scene, fileOrUrl as ArrayBufferView, rootUrl, onSuccess, onError, name);\r\n return null;\r\n }\r\n\r\n this._progressCallback = onProgress;\r\n\r\n const fileName = (fileOrUrl as File).name || Tools.GetFilename(fileOrUrl as string);\r\n\r\n if (useArrayBuffer) {\r\n if (this.useRangeRequests) {\r\n if (this.validate) {\r\n Logger.Warn(\"glTF validation is not supported when range requests are enabled\");\r\n }\r\n\r\n const fileRequest: IFileRequest = {\r\n abort: () => {},\r\n onCompleteObservable: new Observable<IFileRequest>(),\r\n };\r\n\r\n const dataBuffer = {\r\n readAsync: (byteOffset: number, byteLength: number) => {\r\n return new Promise<ArrayBufferView>((resolve, reject) => {\r\n this._loadFile(\r\n scene,\r\n fileOrUrl as File | string,\r\n (data) => {\r\n resolve(new Uint8Array(data as ArrayBuffer));\r\n },\r\n true,\r\n (error) => {\r\n reject(error);\r\n },\r\n (webRequest) => {\r\n webRequest.setRequestHeader(\"Range\", `bytes=${byteOffset}-${byteOffset + byteLength - 1}`);\r\n }\r\n );\r\n });\r\n },\r\n byteLength: 0,\r\n };\r\n\r\n this._unpackBinaryAsync(new DataReader(dataBuffer)).then(\r\n (loaderData) => {\r\n fileRequest.onCompleteObservable.notifyObservers(fileRequest);\r\n onSuccess(loaderData);\r\n },\r\n onError ? (error) => onError(undefined, error) : undefined\r\n );\r\n\r\n return fileRequest;\r\n }\r\n\r\n return this._loadFile(\r\n scene,\r\n fileOrUrl as File | string,\r\n (data) => {\r\n this._validate(scene, new Uint8Array(data as ArrayBuffer, 0, (data as ArrayBuffer).byteLength), rootUrl, fileName);\r\n this._unpackBinaryAsync(\r\n new DataReader({\r\n readAsync: (byteOffset, byteLength) => readAsync(data as ArrayBuffer, byteOffset, byteLength),\r\n byteLength: (data as ArrayBuffer).byteLength,\r\n })\r\n ).then(\r\n (loaderData) => {\r\n onSuccess(loaderData);\r\n },\r\n onError ? (error) => onError(undefined, error) : undefined\r\n );\r\n },\r\n true,\r\n onError\r\n );\r\n } else {\r\n return this._loadFile(\r\n scene,\r\n fileOrUrl,\r\n (data) => {\r\n this._validate(scene, data as string, rootUrl, fileName);\r\n onSuccess({ json: this._parseJson(data as string) });\r\n },\r\n false,\r\n onError\r\n );\r\n }\r\n }\r\n\r\n private _loadBinary(\r\n scene: Scene,\r\n data: ArrayBufferView,\r\n rootUrl: string,\r\n onSuccess: (data: any, responseURL?: string) => void,\r\n onError?: (request?: WebRequest, exception?: LoadFileError) => void,\r\n fileName?: string\r\n ): void {\r\n this._validate(scene, new Uint8Array(data.buffer, data.byteOffset, data.byteLength), rootUrl, fileName);\r\n this._unpackBinaryAsync(\r\n new DataReader({\r\n readAsync: (byteOffset, byteLength) => readViewAsync(data, byteOffset, byteLength),\r\n byteLength: data.byteLength,\r\n })\r\n ).then(\r\n (loaderData) => {\r\n onSuccess(loaderData);\r\n },\r\n onError ? (error) => onError(undefined, error) : undefined\r\n );\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public importMeshAsync(\r\n meshesNames: any,\r\n scene: Scene,\r\n data: any,\r\n rootUrl: string,\r\n onProgress?: (event: ISceneLoaderProgressEvent) => void,\r\n fileName?: string\r\n ): Promise<ISceneLoaderAsyncResult> {\r\n return Promise.resolve().then(() => {\r\n this.onParsedObservable.notifyObservers(data);\r\n this.onParsedObservable.clear();\r\n\r\n this._log(`Loading ${fileName || \"\"}`);\r\n this._loader = this._getLoader(data);\r\n return this._loader.importMeshAsync(meshesNames, scene, null, data, rootUrl, onProgress, fileName);\r\n });\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void> {\r\n return Promise.resolve().then(() => {\r\n this.onParsedObservable.notifyObservers(data);\r\n this.onParsedObservable.clear();\r\n\r\n this._log(`Loading ${fileName || \"\"}`);\r\n this._loader = this._getLoader(data);\r\n return this._loader.loadAsync(scene, data, rootUrl, onProgress, fileName);\r\n });\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer> {\r\n return Promise.resolve().then(() => {\r\n this.onParsedObservable.notifyObservers(data);\r\n this.onParsedObservable.clear();\r\n\r\n this._log(`Loading ${fileName || \"\"}`);\r\n this._loader = this._getLoader(data);\r\n\r\n // Prepare the asset container.\r\n const container = new AssetContainer(scene);\r\n\r\n // Get materials/textures when loading to add to container\r\n const materials: Array<Material> = [];\r\n this.onMaterialLoadedObservable.add((material) => {\r\n materials.push(material);\r\n });\r\n const textures: Array<BaseTexture> = [];\r\n this.onTextureLoadedObservable.add((texture) => {\r\n textures.push(texture);\r\n });\r\n const cameras: Array<Camera> = [];\r\n this.onCameraLoadedObservable.add((camera) => {\r\n cameras.push(camera);\r\n });\r\n\r\n const morphTargetManagers: Array<MorphTargetManager> = [];\r\n this.onMeshLoadedObservable.add((mesh) => {\r\n if (mesh.morphTargetManager) {\r\n morphTargetManagers.push(mesh.morphTargetManager);\r\n }\r\n });\r\n\r\n return this._loader.importMeshAsync(null, scene, container, data, rootUrl, onProgress, fileName).then((result) => {\r\n Array.prototype.push.apply(container.geometries, result.geometries);\r\n Array.prototype.push.apply(container.meshes, result.meshes);\r\n Array.prototype.push.apply(container.particleSystems, result.particleSystems);\r\n Array.prototype.push.apply(container.skeletons, result.skeletons);\r\n Array.prototype.push.apply(container.animationGroups, result.animationGroups);\r\n Array.prototype.push.apply(container.materials, materials);\r\n Array.prototype.push.apply(container.textures, textures);\r\n Array.prototype.push.apply(container.lights, result.lights);\r\n Array.prototype.push.apply(container.transformNodes, result.transformNodes);\r\n Array.prototype.push.apply(container.cameras, cameras);\r\n Array.prototype.push.apply(container.morphTargetManagers, morphTargetManagers);\r\n return container;\r\n });\r\n });\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public canDirectLoad(data: string): boolean {\r\n return (\r\n (data.indexOf(\"asset\") !== -1 && data.indexOf(\"version\") !== -1) ||\r\n data.startsWith(\"data:base64,\" + GLTFFileLoader._MagicBase64Encoded) || // this is technically incorrect, but will continue to support for backcompat.\r\n data.startsWith(\"data:;base64,\" + GLTFFileLoader._MagicBase64Encoded) ||\r\n data.startsWith(\"data:application/octet-stream;base64,\" + GLTFFileLoader._MagicBase64Encoded) ||\r\n data.startsWith(\"data:model/gltf-binary;base64,\" + GLTFFileLoader._MagicBase64Encoded)\r\n );\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public directLoad(scene: Scene, data: string): Promise<any> {\r\n if (\r\n data.startsWith(\"base64,\" + GLTFFileLoader._MagicBase64Encoded) || // this is technically incorrect, but will continue to support for backcompat.\r\n data.startsWith(\";base64,\" + GLTFFileLoader._MagicBase64Encoded) ||\r\n data.startsWith(\"application/octet-stream;base64,\" + GLTFFileLoader._MagicBase64Encoded) ||\r\n data.startsWith(\"model/gltf-binary;base64,\" + GLTFFileLoader._MagicBase64Encoded)\r\n ) {\r\n const arrayBuffer = DecodeBase64UrlToBinary(data);\r\n\r\n this._validate(scene, new Uint8Array(arrayBuffer, 0, arrayBuffer.byteLength));\r\n return this._unpackBinaryAsync(\r\n new DataReader({\r\n readAsync: (byteOffset, byteLength) => readAsync(arrayBuffer, byteOffset, byteLength),\r\n byteLength: arrayBuffer.byteLength,\r\n })\r\n );\r\n }\r\n\r\n this._validate(scene, data);\r\n return Promise.resolve({ json: this._parseJson(data) });\r\n }\r\n\r\n /**\r\n * The callback that allows custom handling of the root url based on the response url.\r\n * @param rootUrl the original root url\r\n * @param responseURL the response url if available\r\n * @returns the new root url\r\n */\r\n public rewriteRootURL?(rootUrl: string, responseURL?: string): string;\r\n\r\n /** @internal */\r\n public createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync {\r\n return new GLTFFileLoader();\r\n }\r\n\r\n /**\r\n * The loader state or null if the loader is not active.\r\n */\r\n public get loaderState(): Nullable<GLTFLoaderState> {\r\n return this._state;\r\n }\r\n\r\n /**\r\n * Observable raised when the loader state changes.\r\n */\r\n public onLoaderStateChangedObservable = new Observable<Nullable<GLTFLoaderState>>();\r\n\r\n /**\r\n * Returns a promise that resolves when the asset is completely loaded.\r\n * @returns a promise that resolves when the asset is completely loaded.\r\n */\r\n public whenCompleteAsync(): Promise<void> {\r\n return new Promise((resolve, reject) => {\r\n this.onCompleteObservable.addOnce(() => {\r\n resolve();\r\n });\r\n this.onErrorObservable.addOnce((reason) => {\r\n reject(reason);\r\n });\r\n });\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _setState(state: GLTFLoaderState): void {\r\n if (this._state === state) {\r\n return;\r\n }\r\n\r\n this._state = state;\r\n this.onLoaderStateChangedObservable.notifyObservers(this._state);\r\n this._log(GLTFLoaderState[this._state]);\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _loadFile(\r\n scene: Scene,\r\n fileOrUrl: File | string,\r\n onSuccess: (data: string | ArrayBuffer) => void,\r\n useArrayBuffer?: boolean,\r\n onError?: (request?: WebRequest) => void,\r\n onOpened?: (request: WebRequest) => void\r\n ): IFileRequest {\r\n const request = scene._loadFile(\r\n fileOrUrl,\r\n onSuccess,\r\n (event) => {\r\n this._onProgress(event, request);\r\n },\r\n true,\r\n useArrayBuffer,\r\n onError,\r\n onOpened\r\n ) as IFileRequestInfo;\r\n request.onCompleteObservable.add((request) => {\r\n this._requests.splice(this._requests.indexOf(request), 1);\r\n });\r\n this._requests.push(request);\r\n return request;\r\n }\r\n\r\n private _onProgress(event: ProgressEvent, request: IFileRequestInfo): void {\r\n if (!this._progressCallback) {\r\n return;\r\n }\r\n\r\n request._lengthComputable = event.lengthComputable;\r\n request._loaded = event.loaded;\r\n request._total = event.total;\r\n\r\n let lengthComputable = true;\r\n let loaded = 0;\r\n let total = 0;\r\n for (const request of this._requests) {\r\n if (request._lengthComputable === undefined || request._loaded === undefined || request._total === undefined) {\r\n return;\r\n }\r\n\r\n lengthComputable = lengthComputable && request._lengthComputable;\r\n loaded += request._loaded;\r\n total += request._total;\r\n }\r\n\r\n this._progressCallback({\r\n lengthComputable: lengthComputable,\r\n loaded: loaded,\r\n total: lengthComputable ? total : 0,\r\n });\r\n }\r\n\r\n private _validate(scene: Scene, data: string | Uint8Array, rootUrl = \"\", fileName = \"\"): void {\r\n if (!this.validate) {\r\n return;\r\n }\r\n\r\n this._startPerformanceCounter(\"Validate JSON\");\r\n GLTFValidation.ValidateAsync(data, rootUrl, fileName, (uri) => {\r\n return this.preprocessUrlAsync(rootUrl + uri).then((url) => {\r\n return scene._loadFileAsync(url, undefined, true, true).then((data) => {\r\n return new Uint8Array(data, 0, data.byteLength);\r\n });\r\n });\r\n }).then(\r\n (result) => {\r\n this._endPerformanceCounter(\"Validate JSON\");\r\n this.onValidatedObservable.notifyObservers(result);\r\n this.onValidatedObservable.clear();\r\n },\r\n (reason) => {\r\n this._endPerformanceCounter(\"Validate JSON\");\r\n Tools.Warn(`Failed to validate: ${reason.message}`);\r\n this.onValidatedObservable.clear();\r\n }\r\n );\r\n }\r\n\r\n private _getLoader(loaderData: IGLTFLoaderData): IGLTFLoader {\r\n const asset = (<any>loaderData.json).asset || {};\r\n\r\n this._log(`Asset version: ${asset.version}`);\r\n asset.minVersion && this._log(`Asset minimum version: ${asset.minVersion}`);\r\n asset.generator && this._log(`Asset generator: ${asset.generator}`);\r\n\r\n const version = GLTFFileLoader._parseVersion(asset.version);\r\n if (!version) {\r\n throw new Error(\"Invalid version: \" + asset.version);\r\n }\r\n\r\n if (asset.minVersion !== undefined) {\r\n const minVersion = GLTFFileLoader._parseVersion(asset.minVersion);\r\n if (!minVersion) {\r\n throw new Error(\"Invalid minimum version: \" + asset.minVersion);\r\n }\r\n\r\n if (GLTFFileLoader._compareVersion(minVersion, { major: 2, minor: 0 }) > 0) {\r\n throw new Error(\"Incompatible minimum version: \" + asset.minVersion);\r\n }\r\n }\r\n\r\n const createLoaders: { [key: number]: (parent: GLTFFileLoader) => IGLTFLoader } = {\r\n 1: GLTFFileLoader._CreateGLTF1Loader,\r\n 2: GLTFFileLoader._CreateGLTF2Loader,\r\n };\r\n\r\n const createLoader = createLoaders[version.major];\r\n if (!createLoader) {\r\n throw new Error(\"Unsupported version: \" + asset.version);\r\n }\r\n\r\n return createLoader(this);\r\n }\r\n\r\n private _parseJson(json: string): Object {\r\n this._startPerformanceCounter(\"Parse JSON\");\r\n this._log(`JSON length: ${json.length}`);\r\n const parsed = JSON.parse(json);\r\n this._endPerformanceCounter(\"Parse JSON\");\r\n return parsed;\r\n }\r\n\r\n private _unpackBinaryAsync(dataReader: DataReader): Promise<IGLTFLoaderData> {\r\n this._startPerformanceCounter(\"Unpack Binary\");\r\n\r\n // Read magic + version + length + json length + json format\r\n return dataReader.loadAsync(20).then(() => {\r\n const Binary = {\r\n Magic: 0x46546c67,\r\n };\r\n\r\n const magic = dataReader.readUint32();\r\n if (magic !== Binary.Magic) {\r\n throw new RuntimeError(\"Unexpected magic: \" + magic, ErrorCodes.GLTFLoaderUnexpectedMagicError);\r\n }\r\n\r\n const version = dataReader.readUint32();\r\n\r\n if (this.loggingEnabled) {\r\n this._log(`Binary version: ${version}`);\r\n }\r\n\r\n const length = dataReader.readUint32();\r\n if (!this.useRangeRequests && length !== dataReader.buffer.byteLength) {\r\n Logger.Warn(`Length in header does not match actual data length: ${length} != ${dataReader.buffer.byteLength}`);\r\n }\r\n\r\n let unpacked: Promise<IGLTFLoaderData>;\r\n switch (version) {\r\n case 1: {\r\n unpacked = this._unpackBinaryV1Async(dataReader, length);\r\n break;\r\n }\r\n case 2: {\r\n unpacked = this._unpackBinaryV2Async(dataReader, length);\r\n break;\r\n }\r\n default: {\r\n throw new Error(\"Unsupported version: \" + version);\r\n }\r\n }\r\n\r\n this._endPerformanceCounter(\"Unpack Binary\");\r\n\r\n return unpacked;\r\n });\r\n }\r\n\r\n private _unpackBinaryV1Async(dataReader: DataReader, length: number): Promise<IGLTFLoaderData> {\r\n const ContentFormat = {\r\n JSON: 0,\r\n };\r\n\r\n const contentLength = dataReader.readUint32();\r\n const contentFormat = dataReader.readUint32();\r\n\r\n if (contentFormat !== ContentFormat.JSON) {\r\n throw new Error(`Unexpected content format: ${contentFormat}`);\r\n }\r\n\r\n const bodyLength = length - dataReader.byteOffset;\r\n\r\n const data: IGLTFLoaderData = { json: this._parseJson(dataReader.readString(contentLength)), bin: null };\r\n if (bodyLength !== 0) {\r\n const startByteOffset = dataReader.byteOffset;\r\n data.bin = {\r\n readAsync: (byteOffset, byteLength) => dataReader.buffer.readAsync(startByteOffset + byteOffset, byteLength),\r\n byteLength: bodyLength,\r\n };\r\n }\r\n\r\n return Promise.resolve(data);\r\n }\r\n\r\n private _unpackBinaryV2Async(dataReader: DataReader, length: number): Promise<IGLTFLoaderData> {\r\n const ChunkFormat = {\r\n JSON: 0x4e4f534a,\r\n BIN: 0x004e4942,\r\n };\r\n\r\n // Read the JSON chunk header.\r\n const chunkLength = dataReader.readUint32();\r\n const chunkFormat = dataReader.readUint32();\r\n if (chunkFormat !== ChunkFormat.JSON) {\r\n throw new Error(\"First chunk format is not JSON\");\r\n }\r\n\r\n // Bail if there are no other chunks.\r\n if (dataReader.byteOffset + chunkLength === length) {\r\n return dataReader.loadAsync(chunkLength).then(() => {\r\n return { json: this._parseJson(dataReader.readString(chunkLength)), bin: null };\r\n });\r\n }\r\n\r\n // Read the JSON chunk and the length and type of the next chunk.\r\n return dataReader.loadAsync(chunkLength + 8).then(() => {\r\n const data: IGLTFLoaderData = { json: this._parseJson(dataReader.readString(chunkLength)), bin: null };\r\n\r\n const readAsync = (): Promise<IGLTFLoaderData> => {\r\n const chunkLength = dataReader.readUint32();\r\n const chunkFormat = dataReader.readUint32();\r\n\r\n switch (chunkFormat) {\r\n case ChunkFormat.JSON: {\r\n throw new Error(\"Unexpected JSON chunk\");\r\n }\r\n case ChunkFormat.BIN: {\r\n const startByteOffset = dataReader.byteOffset;\r\n data.bin = {\r\n readAsync: (byteOffset, byteLength) => dataReader.buffer.readAsync(startByteOffset + byteOffset, byteLength),\r\n byteLength: chunkLength,\r\n };\r\n dataReader.skipBytes(chunkLength);\r\n break;\r\n }\r\n default: {\r\n // ignore unrecognized chunkFormat\r\n dataReader.skipBytes(chunkLength);\r\n break;\r\n }\r\n }\r\n\r\n if (dataReader.byteOffset !== length) {\r\n return dataReader.loadAsync(8).then(readAsync);\r\n }\r\n\r\n return Promise.resolve(data);\r\n };\r\n\r\n return readAsync();\r\n });\r\n }\r\n\r\n private static _parseVersion(version: string): Nullable<{ major: number; minor: number }> {\r\n if (version === \"1.0\" || version === \"1.0.1\") {\r\n return {\r\n major: 1,\r\n minor: 0,\r\n };\r\n }\r\n\r\n const match = (version + \"\").match(/^(\\d+)\\.(\\d+)/);\r\n if (!match) {\r\n return null;\r\n }\r\n\r\n return {\r\n major: parseInt(match[1]),\r\n minor: parseInt(match[2]),\r\n };\r\n }\r\n\r\n private static _compareVersion(a: { major: number; minor: number }, b: { major: number; minor: number }): number {\r\n if (a.major > b.major) {\r\n return 1;\r\n }\r\n if (a.major < b.major) {\r\n return -1;\r\n }\r\n if (a.minor > b.minor) {\r\n return 1;\r\n }\r\n if (a.minor < b.minor) {\r\n return -1;\r\n }\r\n return 0;\r\n }\r\n\r\n private static readonly _logSpaces = \" \";\r\n private _logIndentLevel = 0;\r\n private _loggingEnabled = false;\r\n\r\n /** @internal */\r\n public _log = this._logDisabled;\r\n\r\n /**\r\n * @internal\r\n */\r\n public _logOpen(message: string): void {\r\n this._log(message);\r\n this._logIndentLevel++;\r\n }\r\n\r\n /** @internal */\r\n public _logClose(): void {\r\n --this._logIndentLevel;\r\n }\r\n\r\n private _logEnabled(message: string): void {\r\n const spaces = GLTFFileLoader._logSpaces.substr(0, this._logIndentLevel * 2);\r\n Logger.Log(`${spaces}${message}`);\r\n }\r\n\r\n private _logDisabled(message: string): void {}\r\n\r\n private _capturePerformanceCounters = false;\r\n\r\n /** @internal */\r\n public _startPerformanceCounter = this._startPerformanceCounterDisabled;\r\n\r\n /** @internal */\r\n public _endPerformanceCounter = this._endPerformanceCounterDisabled;\r\n\r\n private _startPerformanceCounterEnabled(counterName: string): void {\r\n Tools.StartPerformanceCounter(counterName);\r\n }\r\n\r\n private _startPerformanceCounterDisabled(counterName: string): void {}\r\n\r\n private _endPerformanceCounterEnabled(counterName: string): void {\r\n Tools.EndPerformanceCounter(counterName);\r\n }\r\n\r\n private _endPerformanceCounterDisabled(counterName: string): void {}\r\n}\r\n\r\nif (SceneLoader) {\r\n SceneLoader.RegisterPlugin(new GLTFFileLoader());\r\n}\r\n"]}
1
+ {"version":3,"file":"glTFFileLoader.js","sourceRoot":"","sources":["../../../../dev/loaders/src/glTF/glTFFileLoader.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,2CAA6B;AAClD,OAAO,EAAE,KAAK,EAAE,sCAAwB;AAaxC,OAAO,EAAE,WAAW,EAAE,+CAAiC;AACvD,OAAO,EAAE,cAAc,EAAE,0CAA4B;AAIrD,OAAO,EAAE,MAAM,EAAE,uCAAyB;AAE1C,OAAO,EAAE,UAAU,EAAE,2CAA6B;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,uBAAuB,EAAE,0CAA4B;AAC9D,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,sCAAwB;AAU3D,SAAS,SAAS,CAAC,WAAwB,EAAE,UAAkB,EAAE,UAAkB;IAC/E,IAAI;QACA,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,UAAU,CAAC,WAAW,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC;KAC/E;IAAC,OAAO,CAAC,EAAE;QACR,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;KAC5B;AACL,CAAC;AAED,SAAS,aAAa,CAAC,eAAgC,EAAE,UAAkB,EAAE,UAAkB;IAC3F,IAAI;QACA,IAAI,UAAU,GAAG,CAAC,IAAI,UAAU,IAAI,eAAe,CAAC,UAAU,EAAE;YAC5D,MAAM,IAAI,UAAU,CAAC,yBAAyB,CAAC,CAAC;SACnD;QAED,IAAI,UAAU,GAAG,UAAU,GAAG,eAAe,CAAC,UAAU,EAAE;YACtD,MAAM,IAAI,UAAU,CAAC,yBAAyB,CAAC,CAAC;SACnD;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AAC,CAAC;QAC7E,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,GAAG,OAAO,EAAE,CAAC,CAAC;IACtC,CAAC;IAEO,YAAY,CAAC,OAAe,IAAS,CAAC;IAUtC,+BAA+B,CAAC,WAAmB;QACvD,KAAK,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC;IAC/C,CAAC;IAEO,gCAAgC,CAAC,WAAmB,IAAS,CAAC;IAE9D,6BAA6B,CAAC,WAAmB;QACrD,KAAK,CAAC,qBAAqB,CAAC,WAAW,CAAC,CAAC;IAC7C,CAAC;IAEO,8BAA8B,CAAC,WAAmB,IAAS,CAAC;;AA//BpE,aAAa;AACb,aAAa;AACb,aAAa;AAEb;;;;;GAKG;AACW,iCAAkB,GAAG,IAAI,AAAP,CAAQ;AAExC;;;;GAIG;AACW,qCAAsB,GAAG,KAAK,AAAR,CAAS;AAiU9B,kCAAmB,GAAG,QAAQ,AAAX,CAAY,CAAC,8CAA8C;AAgoBrE,yBAAU,GAAG,kCAAkC,AAArC,CAAsC;AAgD5E,IAAI,WAAW,EAAE;IACb,WAAW,CAAC,cAAc,CAAC,IAAI,cAAc,EAAE,CAAC,CAAC;CACpD","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\r\n/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type * as GLTF2 from \"babylonjs-gltf2interface\";\r\nimport type { Nullable } from \"core/types\";\r\nimport type { Observer } from \"core/Misc/observable\";\r\nimport { Observable } from \"core/Misc/observable\";\r\nimport { Tools } from \"core/Misc/tools\";\r\nimport type { Camera } from \"core/Cameras/camera\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport type { AbstractMesh } from \"core/Meshes/abstractMesh\";\r\nimport type {\r\n ISceneLoaderPluginFactory,\r\n ISceneLoaderPlugin,\r\n ISceneLoaderPluginAsync,\r\n ISceneLoaderProgressEvent,\r\n ISceneLoaderPluginExtensions,\r\n ISceneLoaderAsyncResult,\r\n} from \"core/Loading/sceneLoader\";\r\nimport { SceneLoader } from \"core/Loading/sceneLoader\";\r\nimport { AssetContainer } from \"core/assetContainer\";\r\nimport type { Scene, IDisposable } from \"core/scene\";\r\nimport type { WebRequest } from \"core/Misc/webRequest\";\r\nimport type { IFileRequest } from \"core/Misc/fileRequest\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport type { IDataBuffer } from \"core/Misc/dataReader\";\r\nimport { DataReader } from \"core/Misc/dataReader\";\r\nimport { GLTFValidation } from \"./glTFValidation\";\r\nimport type { LoadFileError } from \"core/Misc/fileTools\";\r\nimport { DecodeBase64UrlToBinary } from \"core/Misc/fileTools\";\r\nimport { RuntimeError, ErrorCodes } from \"core/Misc/error\";\r\nimport type { TransformNode } from \"core/Meshes/transformNode\";\r\nimport type { MorphTargetManager } from \"core/Morph/morphTargetManager\";\r\n\r\ninterface IFileRequestInfo extends IFileRequest {\r\n _lengthComputable?: boolean;\r\n _loaded?: number;\r\n _total?: number;\r\n}\r\n\r\nfunction readAsync(arrayBuffer: ArrayBuffer, byteOffset: number, byteLength: number): Promise<Uint8Array> {\r\n try {\r\n return Promise.resolve(new Uint8Array(arrayBuffer, byteOffset, byteLength));\r\n } catch (e) {\r\n return Promise.reject(e);\r\n }\r\n}\r\n\r\nfunction readViewAsync(arrayBufferView: ArrayBufferView, byteOffset: number, byteLength: number): Promise<Uint8Array> {\r\n try {\r\n if (byteOffset < 0 || byteOffset >= arrayBufferView.byteLength) {\r\n throw new RangeError(\"Offset is out of range.\");\r\n }\r\n\r\n if (byteOffset + byteLength > arrayBufferView.byteLength) {\r\n throw new RangeError(\"Length is out of range.\");\r\n }\r\n\r\n return Promise.resolve(new Uint8Array(arrayBufferView.buffer, arrayBufferView.byteOffset + byteOffset, byteLength));\r\n } catch (e) {\r\n return Promise.reject(e);\r\n }\r\n}\r\n\r\n/**\r\n * Mode that determines the coordinate system to use.\r\n */\r\nexport enum GLTFLoaderCoordinateSystemMode {\r\n /**\r\n * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.\r\n */\r\n AUTO,\r\n\r\n /**\r\n * Sets the useRightHandedSystem flag on the scene.\r\n */\r\n FORCE_RIGHT_HANDED,\r\n}\r\n\r\n/**\r\n * Mode that determines what animations will start.\r\n */\r\nexport enum GLTFLoaderAnimationStartMode {\r\n /**\r\n * No animation will start.\r\n */\r\n NONE,\r\n\r\n /**\r\n * The first animation will start.\r\n */\r\n FIRST,\r\n\r\n /**\r\n * All animations will start.\r\n */\r\n ALL,\r\n}\r\n\r\n/**\r\n * Interface that contains the data for the glTF asset.\r\n */\r\nexport interface IGLTFLoaderData {\r\n /**\r\n * The object that represents the glTF JSON.\r\n */\r\n json: Object;\r\n\r\n /**\r\n * The BIN chunk of a binary glTF.\r\n */\r\n bin: Nullable<IDataBuffer>;\r\n}\r\n\r\n/**\r\n * Interface for extending the loader.\r\n */\r\nexport interface IGLTFLoaderExtension {\r\n /**\r\n * The name of this extension.\r\n */\r\n readonly name: string;\r\n\r\n /**\r\n * Defines whether this extension is enabled.\r\n */\r\n enabled: boolean;\r\n\r\n /**\r\n * Defines the order of this extension.\r\n * The loader sorts the extensions using these values when loading.\r\n */\r\n order?: number;\r\n}\r\n\r\n/**\r\n * Loader state.\r\n */\r\nexport enum GLTFLoaderState {\r\n /**\r\n * The asset is loading.\r\n */\r\n LOADING,\r\n\r\n /**\r\n * The asset is ready for rendering.\r\n */\r\n READY,\r\n\r\n /**\r\n * The asset is completely loaded.\r\n */\r\n COMPLETE,\r\n}\r\n\r\n/** @internal */\r\nexport interface IGLTFLoader extends IDisposable {\r\n importMeshAsync: (\r\n meshesNames: any,\r\n scene: Scene,\r\n container: Nullable<AssetContainer>,\r\n data: IGLTFLoaderData,\r\n rootUrl: string,\r\n onProgress?: (event: ISceneLoaderProgressEvent) => void,\r\n fileName?: string\r\n ) => Promise<ISceneLoaderAsyncResult>;\r\n loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;\r\n}\r\n\r\n/**\r\n * File loader for loading glTF files into a scene.\r\n */\r\nexport class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {\r\n /** @internal */\r\n public static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;\r\n\r\n /** @internal */\r\n public static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;\r\n\r\n // --------------\r\n // Common options\r\n // --------------\r\n\r\n /**\r\n * Raised when the asset has been parsed\r\n */\r\n public onParsedObservable = new Observable<IGLTFLoaderData>();\r\n\r\n private _onParsedObserver: Nullable<Observer<IGLTFLoaderData>>;\r\n\r\n /**\r\n * Raised when the asset has been parsed\r\n */\r\n public set onParsed(callback: (loaderData: IGLTFLoaderData) => void) {\r\n if (this._onParsedObserver) {\r\n this.onParsedObservable.remove(this._onParsedObserver);\r\n }\r\n this._onParsedObserver = this.onParsedObservable.add(callback);\r\n }\r\n\r\n // ----------\r\n // V1 options\r\n // ----------\r\n\r\n /**\r\n * 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.\r\n * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.\r\n * Defaults to true.\r\n * @internal\r\n */\r\n public static IncrementalLoading = true;\r\n\r\n /**\r\n * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.\r\n * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.\r\n * @internal\r\n */\r\n public static HomogeneousCoordinates = false;\r\n\r\n // ----------\r\n // V2 options\r\n // ----------\r\n\r\n /**\r\n * The coordinate system mode. Defaults to AUTO.\r\n */\r\n public coordinateSystemMode = GLTFLoaderCoordinateSystemMode.AUTO;\r\n\r\n /**\r\n * The animation start mode. Defaults to FIRST.\r\n */\r\n public animationStartMode = GLTFLoaderAnimationStartMode.FIRST;\r\n\r\n /**\r\n * Defines if the loader should compile materials before raising the success callback. Defaults to false.\r\n */\r\n public compileMaterials = false;\r\n\r\n /**\r\n * Defines if the loader should also compile materials with clip planes. Defaults to false.\r\n */\r\n public useClipPlane = false;\r\n\r\n /**\r\n * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.\r\n */\r\n public compileShadowGenerators = false;\r\n\r\n /**\r\n * Defines if the Alpha blended materials are only applied as coverage.\r\n * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.\r\n * If true, no extra effects are applied to transparent pixels.\r\n */\r\n public transparencyAsCoverage = false;\r\n\r\n /**\r\n * Defines if the loader should use range requests when load binary glTF files from HTTP.\r\n * Enabling will disable offline support and glTF validator.\r\n * Defaults to false.\r\n */\r\n public useRangeRequests = false;\r\n\r\n /**\r\n * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.\r\n */\r\n public createInstances = true;\r\n\r\n /**\r\n * Defines if the loader should always compute the bounding boxes of meshes and not use the min/max values from the position accessor. Defaults to false.\r\n */\r\n public alwaysComputeBoundingBox = false;\r\n\r\n /**\r\n * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.\r\n */\r\n public loadAllMaterials = false;\r\n\r\n /**\r\n * If true, load only the materials defined in the file. Defaults to false.\r\n */\r\n public loadOnlyMaterials = false;\r\n\r\n /**\r\n * If true, do not load any materials defined in the file. Defaults to false.\r\n */\r\n public skipMaterials = false;\r\n\r\n /**\r\n * If true, load the color (gamma encoded) textures into sRGB buffers (if supported by the GPU), which will yield more accurate results when sampling the texture. Defaults to true.\r\n */\r\n public useSRGBBuffers = true;\r\n\r\n /**\r\n * When loading glTF animations, which are defined in seconds, target them to this FPS. Defaults to 60.\r\n */\r\n public targetFps = 60;\r\n\r\n /**\r\n * Defines if the loader should always compute the nearest common ancestor of the skeleton joints instead of using `skin.skeleton`. Defaults to false.\r\n * Set this to true if loading assets with invalid `skin.skeleton` values.\r\n */\r\n public alwaysComputeSkeletonRootNode = false;\r\n\r\n /**\r\n * Function called before loading a url referenced by the asset.\r\n * @param url url referenced by the asset\r\n * @returns Async url to load\r\n */\r\n public preprocessUrlAsync = (url: string) => Promise.resolve(url);\r\n\r\n /**\r\n * Defines the node to use as the root of the hierarchy when loading the scene (default: undefined). If not defined, a root node will be automatically created.\r\n * You can also pass null if you don't want a root node to be created.\r\n */\r\n public customRootNode?: Nullable<TransformNode>;\r\n\r\n /**\r\n * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.\r\n * 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, ...)\r\n */\r\n public readonly onMeshLoadedObservable = new Observable<AbstractMesh>();\r\n\r\n private _onMeshLoadedObserver: Nullable<Observer<AbstractMesh>>;\r\n\r\n /**\r\n * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.\r\n * 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, ...)\r\n */\r\n public set onMeshLoaded(callback: (mesh: AbstractMesh) => void) {\r\n if (this._onMeshLoadedObserver) {\r\n this.onMeshLoadedObservable.remove(this._onMeshLoadedObserver);\r\n }\r\n this._onMeshLoadedObserver = this.onMeshLoadedObservable.add(callback);\r\n }\r\n\r\n /**\r\n * Callback raised when the loader creates a skin after parsing the glTF properties of the skin node.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/importers/glTF/glTFSkinning#ignoring-the-transform-of-the-skinned-mesh\r\n * @param node - the transform node that corresponds to the original glTF skin node used for animations\r\n * @param skinnedNode - the transform node that is the skinned mesh itself or the parent of the skinned meshes\r\n */\r\n public readonly onSkinLoadedObservable = new Observable<{ node: TransformNode; skinnedNode: TransformNode }>();\r\n\r\n /**\r\n * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.\r\n */\r\n public readonly onTextureLoadedObservable = new Observable<BaseTexture>();\r\n\r\n private _onTextureLoadedObserver: Nullable<Observer<BaseTexture>>;\r\n\r\n /**\r\n * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.\r\n */\r\n public set onTextureLoaded(callback: (texture: BaseTexture) => void) {\r\n if (this._onTextureLoadedObserver) {\r\n this.onTextureLoadedObservable.remove(this._onTextureLoadedObserver);\r\n }\r\n this._onTextureLoadedObserver = this.onTextureLoadedObservable.add(callback);\r\n }\r\n\r\n /**\r\n * Observable raised when the loader creates a material after parsing the glTF properties of the material.\r\n */\r\n public readonly onMaterialLoadedObservable = new Observable<Material>();\r\n\r\n private _onMaterialLoadedObserver: Nullable<Observer<Material>>;\r\n\r\n /**\r\n * Callback raised when the loader creates a material after parsing the glTF properties of the material.\r\n */\r\n public set onMaterialLoaded(callback: (material: Material) => void) {\r\n if (this._onMaterialLoadedObserver) {\r\n this.onMaterialLoadedObservable.remove(this._onMaterialLoadedObserver);\r\n }\r\n this._onMaterialLoadedObserver = this.onMaterialLoadedObservable.add(callback);\r\n }\r\n\r\n /**\r\n * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.\r\n */\r\n public readonly onCameraLoadedObservable = new Observable<Camera>();\r\n\r\n private _onCameraLoadedObserver: Nullable<Observer<Camera>>;\r\n\r\n /**\r\n * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.\r\n */\r\n public set onCameraLoaded(callback: (camera: Camera) => void) {\r\n if (this._onCameraLoadedObserver) {\r\n this.onCameraLoadedObservable.remove(this._onCameraLoadedObserver);\r\n }\r\n this._onCameraLoadedObserver = this.onCameraLoadedObservable.add(callback);\r\n }\r\n\r\n /**\r\n * Observable raised when the asset is completely loaded, immediately before the loader is disposed.\r\n * For assets with LODs, raised when all of the LODs are complete.\r\n * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.\r\n */\r\n public readonly onCompleteObservable = new Observable<void>();\r\n\r\n private _onCompleteObserver: Nullable<Observer<void>>;\r\n\r\n /**\r\n * Callback raised when the asset is completely loaded, immediately before the loader is disposed.\r\n * For assets with LODs, raised when all of the LODs are complete.\r\n * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.\r\n */\r\n public set onComplete(callback: () => void) {\r\n if (this._onCompleteObserver) {\r\n this.onCompleteObservable.remove(this._onCompleteObserver);\r\n }\r\n this._onCompleteObserver = this.onCompleteObservable.add(callback);\r\n }\r\n\r\n /**\r\n * Observable raised when an error occurs.\r\n */\r\n public readonly onErrorObservable = new Observable<any>();\r\n\r\n private _onErrorObserver: Nullable<Observer<any>>;\r\n\r\n /**\r\n * Callback raised when an error occurs.\r\n */\r\n public set onError(callback: (reason: any) => void) {\r\n if (this._onErrorObserver) {\r\n this.onErrorObservable.remove(this._onErrorObserver);\r\n }\r\n this._onErrorObserver = this.onErrorObservable.add(callback);\r\n }\r\n\r\n /**\r\n * Observable raised after the loader is disposed.\r\n */\r\n public readonly onDisposeObservable = new Observable<void>();\r\n\r\n private _onDisposeObserver: Nullable<Observer<void>>;\r\n\r\n /**\r\n * Callback raised after the loader is disposed.\r\n */\r\n public set onDispose(callback: () => void) {\r\n if (this._onDisposeObserver) {\r\n this.onDisposeObservable.remove(this._onDisposeObserver);\r\n }\r\n this._onDisposeObserver = this.onDisposeObservable.add(callback);\r\n }\r\n\r\n /**\r\n * Observable raised after a loader extension is created.\r\n * Set additional options for a loader extension in this event.\r\n */\r\n public readonly onExtensionLoadedObservable = new Observable<IGLTFLoaderExtension>();\r\n\r\n private _onExtensionLoadedObserver: Nullable<Observer<IGLTFLoaderExtension>>;\r\n\r\n /**\r\n * Callback raised after a loader extension is created.\r\n */\r\n public set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void) {\r\n if (this._onExtensionLoadedObserver) {\r\n this.onExtensionLoadedObservable.remove(this._onExtensionLoadedObserver);\r\n }\r\n this._onExtensionLoadedObserver = this.onExtensionLoadedObservable.add(callback);\r\n }\r\n\r\n /**\r\n * Defines if the loader logging is enabled.\r\n */\r\n public get loggingEnabled(): boolean {\r\n return this._loggingEnabled;\r\n }\r\n\r\n public set loggingEnabled(value: boolean) {\r\n if (this._loggingEnabled === value) {\r\n return;\r\n }\r\n\r\n this._loggingEnabled = value;\r\n\r\n if (this._loggingEnabled) {\r\n this._log = this._logEnabled;\r\n } else {\r\n this._log = this._logDisabled;\r\n }\r\n }\r\n\r\n /**\r\n * Defines if the loader should capture performance counters.\r\n */\r\n public get capturePerformanceCounters(): boolean {\r\n return this._capturePerformanceCounters;\r\n }\r\n\r\n public set capturePerformanceCounters(value: boolean) {\r\n if (this._capturePerformanceCounters === value) {\r\n return;\r\n }\r\n\r\n this._capturePerformanceCounters = value;\r\n\r\n if (this._capturePerformanceCounters) {\r\n this._startPerformanceCounter = this._startPerformanceCounterEnabled;\r\n this._endPerformanceCounter = this._endPerformanceCounterEnabled;\r\n } else {\r\n this._startPerformanceCounter = this._startPerformanceCounterDisabled;\r\n this._endPerformanceCounter = this._endPerformanceCounterDisabled;\r\n }\r\n }\r\n\r\n /**\r\n * Defines if the loader should validate the asset.\r\n */\r\n public validate = false;\r\n\r\n /**\r\n * Observable raised after validation when validate is set to true. The event data is the result of the validation.\r\n */\r\n public readonly onValidatedObservable = new Observable<GLTF2.IGLTFValidationResults>();\r\n\r\n private _onValidatedObserver: Nullable<Observer<GLTF2.IGLTFValidationResults>>;\r\n\r\n /**\r\n * Callback raised after a loader extension is created.\r\n */\r\n public set onValidated(callback: (results: GLTF2.IGLTFValidationResults) => void) {\r\n if (this._onValidatedObserver) {\r\n this.onValidatedObservable.remove(this._onValidatedObserver);\r\n }\r\n this._onValidatedObserver = this.onValidatedObservable.add(callback);\r\n }\r\n\r\n private _loader: Nullable<IGLTFLoader> = null;\r\n private _state: Nullable<GLTFLoaderState> = null;\r\n private _progressCallback?: (event: ISceneLoaderProgressEvent) => void;\r\n private _requests = new Array<IFileRequestInfo>();\r\n\r\n private static _MagicBase64Encoded = \"Z2xURg\"; // \"glTF\" base64 encoded (without the quotes!)\r\n\r\n /**\r\n * Name of the loader (\"gltf\")\r\n */\r\n public name = \"gltf\";\r\n\r\n /** @internal */\r\n public extensions: ISceneLoaderPluginExtensions = {\r\n \".gltf\": { isBinary: false },\r\n \".glb\": { isBinary: true },\r\n };\r\n\r\n /**\r\n * Disposes the loader, releases resources during load, and cancels any outstanding requests.\r\n */\r\n public dispose(): void {\r\n if (this._loader) {\r\n this._loader.dispose();\r\n this._loader = null;\r\n }\r\n\r\n for (const request of this._requests) {\r\n request.abort();\r\n }\r\n\r\n this._requests.length = 0;\r\n\r\n delete this._progressCallback;\r\n\r\n this.preprocessUrlAsync = (url) => Promise.resolve(url);\r\n\r\n this.onMeshLoadedObservable.clear();\r\n this.onSkinLoadedObservable.clear();\r\n this.onTextureLoadedObservable.clear();\r\n this.onMaterialLoadedObservable.clear();\r\n this.onCameraLoadedObservable.clear();\r\n this.onCompleteObservable.clear();\r\n this.onExtensionLoadedObservable.clear();\r\n\r\n this.onDisposeObservable.notifyObservers(undefined);\r\n this.onDisposeObservable.clear();\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public loadFile(\r\n scene: Scene,\r\n fileOrUrl: File | string | ArrayBufferView,\r\n rootUrl: string,\r\n onSuccess: (data: any, responseURL?: string) => void,\r\n onProgress?: (ev: ISceneLoaderProgressEvent) => void,\r\n useArrayBuffer?: boolean,\r\n onError?: (request?: WebRequest, exception?: LoadFileError) => void,\r\n name?: string\r\n ): Nullable<IFileRequest> {\r\n if (ArrayBuffer.isView(fileOrUrl)) {\r\n this._loadBinary(scene, fileOrUrl as ArrayBufferView, rootUrl, onSuccess, onError, name);\r\n return null;\r\n }\r\n\r\n this._progressCallback = onProgress;\r\n\r\n const fileName = (fileOrUrl as File).name || Tools.GetFilename(fileOrUrl as string);\r\n\r\n if (useArrayBuffer) {\r\n if (this.useRangeRequests) {\r\n if (this.validate) {\r\n Logger.Warn(\"glTF validation is not supported when range requests are enabled\");\r\n }\r\n\r\n const fileRequest: IFileRequest = {\r\n abort: () => {},\r\n onCompleteObservable: new Observable<IFileRequest>(),\r\n };\r\n\r\n const dataBuffer = {\r\n readAsync: (byteOffset: number, byteLength: number) => {\r\n return new Promise<ArrayBufferView>((resolve, reject) => {\r\n this._loadFile(\r\n scene,\r\n fileOrUrl as File | string,\r\n (data) => {\r\n resolve(new Uint8Array(data as ArrayBuffer));\r\n },\r\n true,\r\n (error) => {\r\n reject(error);\r\n },\r\n (webRequest) => {\r\n webRequest.setRequestHeader(\"Range\", `bytes=${byteOffset}-${byteOffset + byteLength - 1}`);\r\n }\r\n );\r\n });\r\n },\r\n byteLength: 0,\r\n };\r\n\r\n this._unpackBinaryAsync(new DataReader(dataBuffer)).then(\r\n (loaderData) => {\r\n fileRequest.onCompleteObservable.notifyObservers(fileRequest);\r\n onSuccess(loaderData);\r\n },\r\n onError ? (error) => onError(undefined, error) : undefined\r\n );\r\n\r\n return fileRequest;\r\n }\r\n\r\n return this._loadFile(\r\n scene,\r\n fileOrUrl as File | string,\r\n (data) => {\r\n this._validate(scene, new Uint8Array(data as ArrayBuffer, 0, (data as ArrayBuffer).byteLength), rootUrl, fileName);\r\n this._unpackBinaryAsync(\r\n new DataReader({\r\n readAsync: (byteOffset, byteLength) => readAsync(data as ArrayBuffer, byteOffset, byteLength),\r\n byteLength: (data as ArrayBuffer).byteLength,\r\n })\r\n ).then(\r\n (loaderData) => {\r\n onSuccess(loaderData);\r\n },\r\n onError ? (error) => onError(undefined, error) : undefined\r\n );\r\n },\r\n true,\r\n onError\r\n );\r\n } else {\r\n return this._loadFile(\r\n scene,\r\n fileOrUrl,\r\n (data) => {\r\n this._validate(scene, data as string, rootUrl, fileName);\r\n onSuccess({ json: this._parseJson(data as string) });\r\n },\r\n false,\r\n onError\r\n );\r\n }\r\n }\r\n\r\n private _loadBinary(\r\n scene: Scene,\r\n data: ArrayBufferView,\r\n rootUrl: string,\r\n onSuccess: (data: any, responseURL?: string) => void,\r\n onError?: (request?: WebRequest, exception?: LoadFileError) => void,\r\n fileName?: string\r\n ): void {\r\n this._validate(scene, new Uint8Array(data.buffer, data.byteOffset, data.byteLength), rootUrl, fileName);\r\n this._unpackBinaryAsync(\r\n new DataReader({\r\n readAsync: (byteOffset, byteLength) => readViewAsync(data, byteOffset, byteLength),\r\n byteLength: data.byteLength,\r\n })\r\n ).then(\r\n (loaderData) => {\r\n onSuccess(loaderData);\r\n },\r\n onError ? (error) => onError(undefined, error) : undefined\r\n );\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public importMeshAsync(\r\n meshesNames: any,\r\n scene: Scene,\r\n data: any,\r\n rootUrl: string,\r\n onProgress?: (event: ISceneLoaderProgressEvent) => void,\r\n fileName?: string\r\n ): Promise<ISceneLoaderAsyncResult> {\r\n return Promise.resolve().then(() => {\r\n this.onParsedObservable.notifyObservers(data);\r\n this.onParsedObservable.clear();\r\n\r\n this._log(`Loading ${fileName || \"\"}`);\r\n this._loader = this._getLoader(data);\r\n return this._loader.importMeshAsync(meshesNames, scene, null, data, rootUrl, onProgress, fileName);\r\n });\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void> {\r\n return Promise.resolve().then(() => {\r\n this.onParsedObservable.notifyObservers(data);\r\n this.onParsedObservable.clear();\r\n\r\n this._log(`Loading ${fileName || \"\"}`);\r\n this._loader = this._getLoader(data);\r\n return this._loader.loadAsync(scene, data, rootUrl, onProgress, fileName);\r\n });\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer> {\r\n return Promise.resolve().then(() => {\r\n this.onParsedObservable.notifyObservers(data);\r\n this.onParsedObservable.clear();\r\n\r\n this._log(`Loading ${fileName || \"\"}`);\r\n this._loader = this._getLoader(data);\r\n\r\n // Prepare the asset container.\r\n const container = new AssetContainer(scene);\r\n\r\n // Get materials/textures when loading to add to container\r\n const materials: Array<Material> = [];\r\n this.onMaterialLoadedObservable.add((material) => {\r\n materials.push(material);\r\n });\r\n const textures: Array<BaseTexture> = [];\r\n this.onTextureLoadedObservable.add((texture) => {\r\n textures.push(texture);\r\n });\r\n const cameras: Array<Camera> = [];\r\n this.onCameraLoadedObservable.add((camera) => {\r\n cameras.push(camera);\r\n });\r\n\r\n const morphTargetManagers: Array<MorphTargetManager> = [];\r\n this.onMeshLoadedObservable.add((mesh) => {\r\n if (mesh.morphTargetManager) {\r\n morphTargetManagers.push(mesh.morphTargetManager);\r\n }\r\n });\r\n\r\n return this._loader.importMeshAsync(null, scene, container, data, rootUrl, onProgress, fileName).then((result) => {\r\n Array.prototype.push.apply(container.geometries, result.geometries);\r\n Array.prototype.push.apply(container.meshes, result.meshes);\r\n Array.prototype.push.apply(container.particleSystems, result.particleSystems);\r\n Array.prototype.push.apply(container.skeletons, result.skeletons);\r\n Array.prototype.push.apply(container.animationGroups, result.animationGroups);\r\n Array.prototype.push.apply(container.materials, materials);\r\n Array.prototype.push.apply(container.textures, textures);\r\n Array.prototype.push.apply(container.lights, result.lights);\r\n Array.prototype.push.apply(container.transformNodes, result.transformNodes);\r\n Array.prototype.push.apply(container.cameras, cameras);\r\n Array.prototype.push.apply(container.morphTargetManagers, morphTargetManagers);\r\n return container;\r\n });\r\n });\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public canDirectLoad(data: string): boolean {\r\n return (\r\n (data.indexOf(\"asset\") !== -1 && data.indexOf(\"version\") !== -1) ||\r\n data.startsWith(\"data:base64,\" + GLTFFileLoader._MagicBase64Encoded) || // this is technically incorrect, but will continue to support for backcompat.\r\n data.startsWith(\"data:;base64,\" + GLTFFileLoader._MagicBase64Encoded) ||\r\n data.startsWith(\"data:application/octet-stream;base64,\" + GLTFFileLoader._MagicBase64Encoded) ||\r\n data.startsWith(\"data:model/gltf-binary;base64,\" + GLTFFileLoader._MagicBase64Encoded)\r\n );\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public directLoad(scene: Scene, data: string): Promise<any> {\r\n if (\r\n data.startsWith(\"base64,\" + GLTFFileLoader._MagicBase64Encoded) || // this is technically incorrect, but will continue to support for backcompat.\r\n data.startsWith(\";base64,\" + GLTFFileLoader._MagicBase64Encoded) ||\r\n data.startsWith(\"application/octet-stream;base64,\" + GLTFFileLoader._MagicBase64Encoded) ||\r\n data.startsWith(\"model/gltf-binary;base64,\" + GLTFFileLoader._MagicBase64Encoded)\r\n ) {\r\n const arrayBuffer = DecodeBase64UrlToBinary(data);\r\n\r\n this._validate(scene, new Uint8Array(arrayBuffer, 0, arrayBuffer.byteLength));\r\n return this._unpackBinaryAsync(\r\n new DataReader({\r\n readAsync: (byteOffset, byteLength) => readAsync(arrayBuffer, byteOffset, byteLength),\r\n byteLength: arrayBuffer.byteLength,\r\n })\r\n );\r\n }\r\n\r\n this._validate(scene, data);\r\n return Promise.resolve({ json: this._parseJson(data) });\r\n }\r\n\r\n /**\r\n * The callback that allows custom handling of the root url based on the response url.\r\n * @param rootUrl the original root url\r\n * @param responseURL the response url if available\r\n * @returns the new root url\r\n */\r\n public rewriteRootURL?(rootUrl: string, responseURL?: string): string;\r\n\r\n /** @internal */\r\n public createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync {\r\n return new GLTFFileLoader();\r\n }\r\n\r\n /**\r\n * The loader state or null if the loader is not active.\r\n */\r\n public get loaderState(): Nullable<GLTFLoaderState> {\r\n return this._state;\r\n }\r\n\r\n /**\r\n * Observable raised when the loader state changes.\r\n */\r\n public onLoaderStateChangedObservable = new Observable<Nullable<GLTFLoaderState>>();\r\n\r\n /**\r\n * Returns a promise that resolves when the asset is completely loaded.\r\n * @returns a promise that resolves when the asset is completely loaded.\r\n */\r\n public whenCompleteAsync(): Promise<void> {\r\n return new Promise((resolve, reject) => {\r\n this.onCompleteObservable.addOnce(() => {\r\n resolve();\r\n });\r\n this.onErrorObservable.addOnce((reason) => {\r\n reject(reason);\r\n });\r\n });\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _setState(state: GLTFLoaderState): void {\r\n if (this._state === state) {\r\n return;\r\n }\r\n\r\n this._state = state;\r\n this.onLoaderStateChangedObservable.notifyObservers(this._state);\r\n this._log(GLTFLoaderState[this._state]);\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _loadFile(\r\n scene: Scene,\r\n fileOrUrl: File | string,\r\n onSuccess: (data: string | ArrayBuffer) => void,\r\n useArrayBuffer?: boolean,\r\n onError?: (request?: WebRequest) => void,\r\n onOpened?: (request: WebRequest) => void\r\n ): IFileRequest {\r\n const request = scene._loadFile(\r\n fileOrUrl,\r\n onSuccess,\r\n (event) => {\r\n this._onProgress(event, request);\r\n },\r\n true,\r\n useArrayBuffer,\r\n onError,\r\n onOpened\r\n ) as IFileRequestInfo;\r\n request.onCompleteObservable.add(() => {\r\n // Force the length computable to be true since we can guarantee the data is loaded.\r\n request._lengthComputable = true;\r\n request._total = request._loaded;\r\n });\r\n this._requests.push(request);\r\n return request;\r\n }\r\n\r\n private _onProgress(event: ProgressEvent, request: IFileRequestInfo): void {\r\n if (!this._progressCallback) {\r\n return;\r\n }\r\n\r\n request._lengthComputable = event.lengthComputable;\r\n request._loaded = event.loaded;\r\n request._total = event.total;\r\n\r\n let lengthComputable = true;\r\n let loaded = 0;\r\n let total = 0;\r\n for (const request of this._requests) {\r\n if (request._lengthComputable === undefined || request._loaded === undefined || request._total === undefined) {\r\n return;\r\n }\r\n\r\n lengthComputable = lengthComputable && request._lengthComputable;\r\n loaded += request._loaded;\r\n total += request._total;\r\n }\r\n\r\n this._progressCallback({\r\n lengthComputable: lengthComputable,\r\n loaded: loaded,\r\n total: lengthComputable ? total : 0,\r\n });\r\n }\r\n\r\n private _validate(scene: Scene, data: string | Uint8Array, rootUrl = \"\", fileName = \"\"): void {\r\n if (!this.validate) {\r\n return;\r\n }\r\n\r\n this._startPerformanceCounter(\"Validate JSON\");\r\n GLTFValidation.ValidateAsync(data, rootUrl, fileName, (uri) => {\r\n return this.preprocessUrlAsync(rootUrl + uri).then((url) => {\r\n return scene._loadFileAsync(url, undefined, true, true).then((data) => {\r\n return new Uint8Array(data, 0, data.byteLength);\r\n });\r\n });\r\n }).then(\r\n (result) => {\r\n this._endPerformanceCounter(\"Validate JSON\");\r\n this.onValidatedObservable.notifyObservers(result);\r\n this.onValidatedObservable.clear();\r\n },\r\n (reason) => {\r\n this._endPerformanceCounter(\"Validate JSON\");\r\n Tools.Warn(`Failed to validate: ${reason.message}`);\r\n this.onValidatedObservable.clear();\r\n }\r\n );\r\n }\r\n\r\n private _getLoader(loaderData: IGLTFLoaderData): IGLTFLoader {\r\n const asset = (<any>loaderData.json).asset || {};\r\n\r\n this._log(`Asset version: ${asset.version}`);\r\n asset.minVersion && this._log(`Asset minimum version: ${asset.minVersion}`);\r\n asset.generator && this._log(`Asset generator: ${asset.generator}`);\r\n\r\n const version = GLTFFileLoader._parseVersion(asset.version);\r\n if (!version) {\r\n throw new Error(\"Invalid version: \" + asset.version);\r\n }\r\n\r\n if (asset.minVersion !== undefined) {\r\n const minVersion = GLTFFileLoader._parseVersion(asset.minVersion);\r\n if (!minVersion) {\r\n throw new Error(\"Invalid minimum version: \" + asset.minVersion);\r\n }\r\n\r\n if (GLTFFileLoader._compareVersion(minVersion, { major: 2, minor: 0 }) > 0) {\r\n throw new Error(\"Incompatible minimum version: \" + asset.minVersion);\r\n }\r\n }\r\n\r\n const createLoaders: { [key: number]: (parent: GLTFFileLoader) => IGLTFLoader } = {\r\n 1: GLTFFileLoader._CreateGLTF1Loader,\r\n 2: GLTFFileLoader._CreateGLTF2Loader,\r\n };\r\n\r\n const createLoader = createLoaders[version.major];\r\n if (!createLoader) {\r\n throw new Error(\"Unsupported version: \" + asset.version);\r\n }\r\n\r\n return createLoader(this);\r\n }\r\n\r\n private _parseJson(json: string): Object {\r\n this._startPerformanceCounter(\"Parse JSON\");\r\n this._log(`JSON length: ${json.length}`);\r\n const parsed = JSON.parse(json);\r\n this._endPerformanceCounter(\"Parse JSON\");\r\n return parsed;\r\n }\r\n\r\n private _unpackBinaryAsync(dataReader: DataReader): Promise<IGLTFLoaderData> {\r\n this._startPerformanceCounter(\"Unpack Binary\");\r\n\r\n // Read magic + version + length + json length + json format\r\n return dataReader.loadAsync(20).then(() => {\r\n const Binary = {\r\n Magic: 0x46546c67,\r\n };\r\n\r\n const magic = dataReader.readUint32();\r\n if (magic !== Binary.Magic) {\r\n throw new RuntimeError(\"Unexpected magic: \" + magic, ErrorCodes.GLTFLoaderUnexpectedMagicError);\r\n }\r\n\r\n const version = dataReader.readUint32();\r\n\r\n if (this.loggingEnabled) {\r\n this._log(`Binary version: ${version}`);\r\n }\r\n\r\n const length = dataReader.readUint32();\r\n if (!this.useRangeRequests && length !== dataReader.buffer.byteLength) {\r\n Logger.Warn(`Length in header does not match actual data length: ${length} != ${dataReader.buffer.byteLength}`);\r\n }\r\n\r\n let unpacked: Promise<IGLTFLoaderData>;\r\n switch (version) {\r\n case 1: {\r\n unpacked = this._unpackBinaryV1Async(dataReader, length);\r\n break;\r\n }\r\n case 2: {\r\n unpacked = this._unpackBinaryV2Async(dataReader, length);\r\n break;\r\n }\r\n default: {\r\n throw new Error(\"Unsupported version: \" + version);\r\n }\r\n }\r\n\r\n this._endPerformanceCounter(\"Unpack Binary\");\r\n\r\n return unpacked;\r\n });\r\n }\r\n\r\n private _unpackBinaryV1Async(dataReader: DataReader, length: number): Promise<IGLTFLoaderData> {\r\n const ContentFormat = {\r\n JSON: 0,\r\n };\r\n\r\n const contentLength = dataReader.readUint32();\r\n const contentFormat = dataReader.readUint32();\r\n\r\n if (contentFormat !== ContentFormat.JSON) {\r\n throw new Error(`Unexpected content format: ${contentFormat}`);\r\n }\r\n\r\n const bodyLength = length - dataReader.byteOffset;\r\n\r\n const data: IGLTFLoaderData = { json: this._parseJson(dataReader.readString(contentLength)), bin: null };\r\n if (bodyLength !== 0) {\r\n const startByteOffset = dataReader.byteOffset;\r\n data.bin = {\r\n readAsync: (byteOffset, byteLength) => dataReader.buffer.readAsync(startByteOffset + byteOffset, byteLength),\r\n byteLength: bodyLength,\r\n };\r\n }\r\n\r\n return Promise.resolve(data);\r\n }\r\n\r\n private _unpackBinaryV2Async(dataReader: DataReader, length: number): Promise<IGLTFLoaderData> {\r\n const ChunkFormat = {\r\n JSON: 0x4e4f534a,\r\n BIN: 0x004e4942,\r\n };\r\n\r\n // Read the JSON chunk header.\r\n const chunkLength = dataReader.readUint32();\r\n const chunkFormat = dataReader.readUint32();\r\n if (chunkFormat !== ChunkFormat.JSON) {\r\n throw new Error(\"First chunk format is not JSON\");\r\n }\r\n\r\n // Bail if there are no other chunks.\r\n if (dataReader.byteOffset + chunkLength === length) {\r\n return dataReader.loadAsync(chunkLength).then(() => {\r\n return { json: this._parseJson(dataReader.readString(chunkLength)), bin: null };\r\n });\r\n }\r\n\r\n // Read the JSON chunk and the length and type of the next chunk.\r\n return dataReader.loadAsync(chunkLength + 8).then(() => {\r\n const data: IGLTFLoaderData = { json: this._parseJson(dataReader.readString(chunkLength)), bin: null };\r\n\r\n const readAsync = (): Promise<IGLTFLoaderData> => {\r\n const chunkLength = dataReader.readUint32();\r\n const chunkFormat = dataReader.readUint32();\r\n\r\n switch (chunkFormat) {\r\n case ChunkFormat.JSON: {\r\n throw new Error(\"Unexpected JSON chunk\");\r\n }\r\n case ChunkFormat.BIN: {\r\n const startByteOffset = dataReader.byteOffset;\r\n data.bin = {\r\n readAsync: (byteOffset, byteLength) => dataReader.buffer.readAsync(startByteOffset + byteOffset, byteLength),\r\n byteLength: chunkLength,\r\n };\r\n dataReader.skipBytes(chunkLength);\r\n break;\r\n }\r\n default: {\r\n // ignore unrecognized chunkFormat\r\n dataReader.skipBytes(chunkLength);\r\n break;\r\n }\r\n }\r\n\r\n if (dataReader.byteOffset !== length) {\r\n return dataReader.loadAsync(8).then(readAsync);\r\n }\r\n\r\n return Promise.resolve(data);\r\n };\r\n\r\n return readAsync();\r\n });\r\n }\r\n\r\n private static _parseVersion(version: string): Nullable<{ major: number; minor: number }> {\r\n if (version === \"1.0\" || version === \"1.0.1\") {\r\n return {\r\n major: 1,\r\n minor: 0,\r\n };\r\n }\r\n\r\n const match = (version + \"\").match(/^(\\d+)\\.(\\d+)/);\r\n if (!match) {\r\n return null;\r\n }\r\n\r\n return {\r\n major: parseInt(match[1]),\r\n minor: parseInt(match[2]),\r\n };\r\n }\r\n\r\n private static _compareVersion(a: { major: number; minor: number }, b: { major: number; minor: number }): number {\r\n if (a.major > b.major) {\r\n return 1;\r\n }\r\n if (a.major < b.major) {\r\n return -1;\r\n }\r\n if (a.minor > b.minor) {\r\n return 1;\r\n }\r\n if (a.minor < b.minor) {\r\n return -1;\r\n }\r\n return 0;\r\n }\r\n\r\n private static readonly _logSpaces = \" \";\r\n private _logIndentLevel = 0;\r\n private _loggingEnabled = false;\r\n\r\n /** @internal */\r\n public _log = this._logDisabled;\r\n\r\n /**\r\n * @internal\r\n */\r\n public _logOpen(message: string): void {\r\n this._log(message);\r\n this._logIndentLevel++;\r\n }\r\n\r\n /** @internal */\r\n public _logClose(): void {\r\n --this._logIndentLevel;\r\n }\r\n\r\n private _logEnabled(message: string): void {\r\n const spaces = GLTFFileLoader._logSpaces.substr(0, this._logIndentLevel * 2);\r\n Logger.Log(`${spaces}${message}`);\r\n }\r\n\r\n private _logDisabled(message: string): void {}\r\n\r\n private _capturePerformanceCounters = false;\r\n\r\n /** @internal */\r\n public _startPerformanceCounter = this._startPerformanceCounterDisabled;\r\n\r\n /** @internal */\r\n public _endPerformanceCounter = this._endPerformanceCounterDisabled;\r\n\r\n private _startPerformanceCounterEnabled(counterName: string): void {\r\n Tools.StartPerformanceCounter(counterName);\r\n }\r\n\r\n private _startPerformanceCounterDisabled(counterName: string): void {}\r\n\r\n private _endPerformanceCounterEnabled(counterName: string): void {\r\n Tools.EndPerformanceCounter(counterName);\r\n }\r\n\r\n private _endPerformanceCounterDisabled(counterName: string): void {}\r\n}\r\n\r\nif (SceneLoader) {\r\n SceneLoader.RegisterPlugin(new GLTFFileLoader());\r\n}\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babylonjs/loaders",
3
- "version": "7.8.0",
3
+ "version": "7.8.2",
4
4
  "main": "index.js",
5
5
  "module": "index.js",
6
6
  "types": "index.d.ts",
@@ -18,10 +18,10 @@
18
18
  "postcompile": "build-tools -c add-js-to-es6"
19
19
  },
20
20
  "devDependencies": {
21
- "@babylonjs/core": "^7.8.0",
21
+ "@babylonjs/core": "^7.8.2",
22
22
  "@dev/build-tools": "^1.0.0",
23
23
  "@lts/loaders": "^1.0.0",
24
- "babylonjs-gltf2interface": "^7.8.0"
24
+ "babylonjs-gltf2interface": "^7.8.2"
25
25
  },
26
26
  "peerDependencies": {
27
27
  "@babylonjs/core": "^7.0.0",