@babylonjs/loaders 6.30.0 → 6.32.0
Sign up to get free protection for your applications and to get access to all the features.
@@ -180,6 +180,8 @@ class TransmissionHelper {
|
|
180
180
|
this._opaqueRenderTarget.lodGenerationScale = this._options.lodGenerationScale;
|
181
181
|
this._opaqueRenderTarget.lodGenerationOffset = this._options.lodGenerationOffset;
|
182
182
|
this._opaqueRenderTarget.samples = this._options.samples;
|
183
|
+
this._opaqueRenderTarget.renderSprites = true;
|
184
|
+
this._opaqueRenderTarget.renderParticles = true;
|
183
185
|
let sceneImageProcessingapplyByPostProcess;
|
184
186
|
let saveSceneEnvIntensity;
|
185
187
|
this._opaqueRenderTarget.onBeforeBindObservable.add((opaqueRenderTarget) => {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"KHR_materials_transmission.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_transmission.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAK7D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAK3C,OAAO,EAAE,mBAAmB,EAAE,kEAAoD;AAElF,OAAO,EAAE,UAAU,EAAE,2CAA6B;AAClD,OAAO,EAAE,SAAS,EAAE,6CAA+B;AACnD,OAAO,EAAE,KAAK,EAAE,sCAAwB;AAgDxC;;GAEG;AACH,MAAM,kBAAkB;IACpB;;OAEG;IACK,MAAM,CAAC,kBAAkB;QAC7B,OAAO;YACH,UAAU,EAAE,IAAI;YAChB,OAAO,EAAE,CAAC;YACV,kBAAkB,EAAE,CAAC;YACrB,mBAAmB,EAAE,CAAC,CAAC;YACvB,uBAAuB,EAAE,SAAS,CAAC,sBAAsB;YACzD,eAAe,EAAE,IAAI;SACxB,CAAC;IACN,CAAC;IAoBD;;;;OAIG;IACH,YAAY,OAA4C,EAAE,KAAY;QAhB9D,wBAAmB,GAAkC,IAAI,CAAC;QAC1D,uBAAkB,GAAmB,EAAE,CAAC;QACxC,4BAAuB,GAAmB,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C,WAAW,CAAC,UAAU,CAAC,gBAAgB,GAAG,GAAG,CAAC;QAC9C,IAAI,SAAS,CAAC,mBAAmB,EAAE;YAC9B,SAAS,CAAC,mBAAoC,CAAC,YAAY,GAAG,IAAI,CAAC;YACpE,OAAO,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,GAAG,OAAO,sBAAsB,EAAE,SAAS,CAAC,mBAAmB,EAAE,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC,OAAoB,EAAE,EAAE;gBAC/I,WAAW,CAAC,UAAU,CAAC,0BAA0B,GAAG,OAAO,CAAC;gBAC5D,WAAW,CAAC,UAAU,CAAC,oBAAoB,GAAG,IAAI,CAAC;YACvD,CAAC,CAAC,CAAC;SACN;aAAM;YACH,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;SAC5B;IACL,CAAC;CACJ;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,0BAA0B,CAAC,MAAM,CAAC,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport { PBRMaterial } from \"core/Materials/PBR/pbrMaterial\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport type { IMaterial, ITextureInfo } from \"../glTFLoaderInterfaces\";\r\nimport type { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader } from \"../glTFLoader\";\r\nimport type { IKHRMaterialsTransmission } from \"babylonjs-gltf2interface\";\r\nimport type { Scene } from \"core/scene\";\r\nimport type { AbstractMesh } from \"core/Meshes/abstractMesh\";\r\nimport type { Texture } from \"core/Materials/Textures/texture\";\r\nimport { RenderTargetTexture } from \"core/Materials/Textures/renderTargetTexture\";\r\nimport type { Observer } from \"core/Misc/observable\";\r\nimport { Observable } from \"core/Misc/observable\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport { Tools } from \"core/Misc/tools\";\r\nimport type { Color4 } from \"core/Maths/math.color\";\r\n\r\ninterface ITransmissionHelperHolder {\r\n /**\r\n * @internal\r\n */\r\n _transmissionHelper: TransmissionHelper | undefined;\r\n}\r\n\r\ninterface ITransmissionHelperOptions {\r\n /**\r\n * The size of the render buffers (default: 1024)\r\n */\r\n renderSize: number;\r\n\r\n /**\r\n * The number of samples to use when generating the render target texture for opaque meshes (default: 4)\r\n */\r\n samples: number;\r\n\r\n /**\r\n * Scale to apply when selecting the LOD level to sample the refraction texture (default: 1)\r\n */\r\n lodGenerationScale: number;\r\n\r\n /**\r\n * Offset to apply when selecting the LOD level to sample the refraction texture (default: -4)\r\n */\r\n lodGenerationOffset: number;\r\n\r\n /**\r\n * Type of the refraction render target texture (default: TEXTURETYPE_HALF_FLOAT)\r\n */\r\n renderTargetTextureType: number;\r\n\r\n /**\r\n * Defines if the mipmaps for the refraction render target texture must be generated (default: true)\r\n */\r\n generateMipmaps: boolean;\r\n\r\n /**\r\n * Clear color of the opaque texture. If not provided, use the scene clear color (which will be converted to linear space).\r\n * If provided, should be in linear space\r\n */\r\n clearColor?: Color4;\r\n}\r\n\r\n/**\r\n * A class to handle setting up the rendering of opaque objects to be shown through transmissive objects.\r\n */\r\nclass TransmissionHelper {\r\n /**\r\n * Creates the default options for the helper.\r\n */\r\n private static _GetDefaultOptions(): ITransmissionHelperOptions {\r\n return {\r\n renderSize: 1024,\r\n samples: 4,\r\n lodGenerationScale: 1,\r\n lodGenerationOffset: -4,\r\n renderTargetTextureType: Constants.TEXTURETYPE_HALF_FLOAT,\r\n generateMipmaps: true,\r\n };\r\n }\r\n\r\n /**\r\n * Stores the creation options.\r\n */\r\n private readonly _scene: Scene & ITransmissionHelperHolder;\r\n\r\n private _options: ITransmissionHelperOptions;\r\n\r\n private _opaqueRenderTarget: Nullable<RenderTargetTexture> = null;\r\n private _opaqueMeshesCache: AbstractMesh[] = [];\r\n private _transparentMeshesCache: AbstractMesh[] = [];\r\n private _materialObservers: { [id: string]: Nullable<Observer<AbstractMesh>> } = {};\r\n\r\n /**\r\n * This observable will be notified with any error during the creation of the environment,\r\n * mainly texture creation errors.\r\n */\r\n public onErrorObservable: Observable<{ message?: string; exception?: any }>;\r\n\r\n /**\r\n * constructor\r\n * @param options Defines the options we want to customize the helper\r\n * @param scene The scene to add the material to\r\n */\r\n constructor(options: Partial<ITransmissionHelperOptions>, scene: Scene) {\r\n this._options = {\r\n ...TransmissionHelper._GetDefaultOptions(),\r\n ...options,\r\n };\r\n this._scene = scene as any;\r\n this._scene._transmissionHelper = this;\r\n\r\n this.onErrorObservable = new Observable();\r\n this._scene.onDisposeObservable.addOnce(() => {\r\n this.dispose();\r\n });\r\n\r\n this._parseScene();\r\n this._setupRenderTargets();\r\n }\r\n\r\n /**\r\n * Updates the background according to the new options\r\n * @param options\r\n */\r\n public updateOptions(options: Partial<ITransmissionHelperOptions>) {\r\n // First check if any options are actually being changed. If not, exit.\r\n const newValues = Object.keys(options).filter((key: string) => (this._options as any)[key] !== (options as any)[key]);\r\n if (!newValues.length) {\r\n return;\r\n }\r\n\r\n const newOptions = {\r\n ...this._options,\r\n ...options,\r\n };\r\n\r\n const oldOptions = this._options;\r\n this._options = newOptions;\r\n\r\n // If size changes, recreate everything\r\n if (\r\n newOptions.renderSize !== oldOptions.renderSize ||\r\n newOptions.renderTargetTextureType !== oldOptions.renderTargetTextureType ||\r\n newOptions.generateMipmaps !== oldOptions.generateMipmaps ||\r\n !this._opaqueRenderTarget\r\n ) {\r\n this._setupRenderTargets();\r\n } else {\r\n this._opaqueRenderTarget.samples = newOptions.samples;\r\n this._opaqueRenderTarget.lodGenerationScale = newOptions.lodGenerationScale;\r\n this._opaqueRenderTarget.lodGenerationOffset = newOptions.lodGenerationOffset;\r\n }\r\n }\r\n\r\n /**\r\n * Gets the opaque render target texture or null if not available.\r\n */\r\n public getOpaqueTarget(): Nullable<Texture> {\r\n return this._opaqueRenderTarget;\r\n }\r\n\r\n private _shouldRenderAsTransmission(material: Nullable<Material>): boolean {\r\n if (!material) {\r\n return false;\r\n }\r\n if (material instanceof PBRMaterial && material.subSurface.isRefractionEnabled) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n private _addMesh(mesh: AbstractMesh): void {\r\n this._materialObservers[mesh.uniqueId] = mesh.onMaterialChangedObservable.add(this._onMeshMaterialChanged.bind(this));\r\n\r\n // we need to defer the processing because _addMesh may be called as part as an instance mesh creation, in which case some\r\n // internal properties are not setup yet, like _sourceMesh (needed when doing mesh.material below)\r\n Tools.SetImmediate(() => {\r\n if (this._shouldRenderAsTransmission(mesh.material)) {\r\n (mesh.material as PBRMaterial).refractionTexture = this._opaqueRenderTarget;\r\n if (this._transparentMeshesCache.indexOf(mesh) === -1) {\r\n this._transparentMeshesCache.push(mesh);\r\n }\r\n } else {\r\n if (this._opaqueMeshesCache.indexOf(mesh) === -1) {\r\n this._opaqueMeshesCache.push(mesh);\r\n }\r\n }\r\n });\r\n }\r\n\r\n private _removeMesh(mesh: AbstractMesh): void {\r\n mesh.onMaterialChangedObservable.remove(this._materialObservers[mesh.uniqueId]);\r\n delete this._materialObservers[mesh.uniqueId];\r\n let idx = this._transparentMeshesCache.indexOf(mesh);\r\n if (idx !== -1) {\r\n this._transparentMeshesCache.splice(idx, 1);\r\n }\r\n idx = this._opaqueMeshesCache.indexOf(mesh);\r\n if (idx !== -1) {\r\n this._opaqueMeshesCache.splice(idx, 1);\r\n }\r\n }\r\n\r\n private _parseScene(): void {\r\n this._scene.meshes.forEach(this._addMesh.bind(this));\r\n // Listen for when a mesh is added to the scene and add it to our cache lists.\r\n this._scene.onNewMeshAddedObservable.add(this._addMesh.bind(this));\r\n // Listen for when a mesh is removed from to the scene and remove it from our cache lists.\r\n this._scene.onMeshRemovedObservable.add(this._removeMesh.bind(this));\r\n }\r\n\r\n // When one of the meshes in the scene has its material changed, make sure that it's in the correct cache list.\r\n private _onMeshMaterialChanged(mesh: AbstractMesh) {\r\n const transparentIdx = this._transparentMeshesCache.indexOf(mesh);\r\n const opaqueIdx = this._opaqueMeshesCache.indexOf(mesh);\r\n\r\n // If the material is transparent, make sure that it's added to the transparent list and removed from the opaque list\r\n const useTransmission = this._shouldRenderAsTransmission(mesh.material);\r\n if (useTransmission) {\r\n if (mesh.material instanceof PBRMaterial) {\r\n mesh.material.subSurface.refractionTexture = this._opaqueRenderTarget;\r\n }\r\n if (opaqueIdx !== -1) {\r\n this._opaqueMeshesCache.splice(opaqueIdx, 1);\r\n this._transparentMeshesCache.push(mesh);\r\n } else if (transparentIdx === -1) {\r\n this._transparentMeshesCache.push(mesh);\r\n }\r\n // If the material is opaque, make sure that it's added to the opaque list and removed from the transparent list\r\n } else {\r\n if (transparentIdx !== -1) {\r\n this._transparentMeshesCache.splice(transparentIdx, 1);\r\n this._opaqueMeshesCache.push(mesh);\r\n } else if (opaqueIdx === -1) {\r\n this._opaqueMeshesCache.push(mesh);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n * Check if the opaque render target has not been disposed and can still be used.\r\n * @returns\r\n */\r\n public _isRenderTargetValid() {\r\n return this._opaqueRenderTarget?.getInternalTexture() !== null;\r\n }\r\n\r\n /**\r\n * @internal\r\n * Setup the render targets according to the specified options.\r\n */\r\n public _setupRenderTargets(): void {\r\n if (this._opaqueRenderTarget) {\r\n this._opaqueRenderTarget.dispose();\r\n }\r\n this._opaqueRenderTarget = new RenderTargetTexture(\r\n \"opaqueSceneTexture\",\r\n this._options.renderSize,\r\n this._scene,\r\n this._options.generateMipmaps,\r\n undefined,\r\n this._options.renderTargetTextureType\r\n );\r\n this._opaqueRenderTarget.ignoreCameraViewport = true;\r\n this._opaqueRenderTarget.renderList = this._opaqueMeshesCache;\r\n this._opaqueRenderTarget.clearColor = this._options.clearColor?.clone() ?? this._scene.clearColor.clone();\r\n this._opaqueRenderTarget.gammaSpace = false;\r\n this._opaqueRenderTarget.lodGenerationScale = this._options.lodGenerationScale;\r\n this._opaqueRenderTarget.lodGenerationOffset = this._options.lodGenerationOffset;\r\n this._opaqueRenderTarget.samples = this._options.samples;\r\n\r\n let sceneImageProcessingapplyByPostProcess: boolean;\r\n\r\n let saveSceneEnvIntensity: number;\r\n this._opaqueRenderTarget.onBeforeBindObservable.add((opaqueRenderTarget) => {\r\n saveSceneEnvIntensity = this._scene.environmentIntensity;\r\n this._scene.environmentIntensity = 1.0;\r\n sceneImageProcessingapplyByPostProcess = this._scene.imageProcessingConfiguration.applyByPostProcess;\r\n if (!this._options.clearColor) {\r\n this._scene.clearColor.toLinearSpaceToRef(opaqueRenderTarget.clearColor, this._scene.getEngine().useExactSrgbConversions);\r\n } else {\r\n opaqueRenderTarget.clearColor.copyFrom(this._options.clearColor);\r\n }\r\n // we do not use the applyByPostProcess setter to avoid flagging all the materials as \"image processing dirty\"!\r\n this._scene.imageProcessingConfiguration._applyByPostProcess = true;\r\n });\r\n this._opaqueRenderTarget.onAfterUnbindObservable.add(() => {\r\n this._scene.environmentIntensity = saveSceneEnvIntensity;\r\n this._scene.imageProcessingConfiguration._applyByPostProcess = sceneImageProcessingapplyByPostProcess;\r\n });\r\n\r\n this._transparentMeshesCache.forEach((mesh: AbstractMesh) => {\r\n if (this._shouldRenderAsTransmission(mesh.material)) {\r\n (mesh.material as PBRMaterial).refractionTexture = this._opaqueRenderTarget;\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Dispose all the elements created by the Helper.\r\n */\r\n public dispose(): void {\r\n this._scene._transmissionHelper = undefined;\r\n if (this._opaqueRenderTarget) {\r\n this._opaqueRenderTarget.dispose();\r\n this._opaqueRenderTarget = null;\r\n }\r\n this._transparentMeshesCache = [];\r\n this._opaqueMeshesCache = [];\r\n }\r\n}\r\n\r\nconst NAME = \"KHR_materials_transmission\";\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_transmission/README.md)\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_materials_transmission implements IGLTFLoaderExtension {\r\n /**\r\n * The name of this extension.\r\n */\r\n public readonly name = NAME;\r\n\r\n /**\r\n * Defines whether this extension is enabled.\r\n */\r\n public enabled: boolean;\r\n\r\n /**\r\n * Defines a number that determines the order the extensions are applied.\r\n */\r\n public order = 175;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /**\r\n * @internal\r\n */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = this._loader.isExtensionUsed(NAME);\r\n if (this.enabled) {\r\n loader.parent.transparencyAsCoverage = true;\r\n }\r\n }\r\n\r\n /** @internal */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>> {\r\n return GLTFLoader.LoadExtensionAsync<IKHRMaterialsTransmission>(context, material, this.name, (extensionContext, extension) => {\r\n const promises = new Array<Promise<any>>();\r\n promises.push(this._loader.loadMaterialBasePropertiesAsync(context, material, babylonMaterial));\r\n promises.push(this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));\r\n promises.push(this._loadTransparentPropertiesAsync(extensionContext, material, babylonMaterial, extension));\r\n return Promise.all(promises).then(() => {});\r\n });\r\n }\r\n\r\n private _loadTransparentPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material, extension: IKHRMaterialsTransmission): Promise<void> {\r\n if (!(babylonMaterial instanceof PBRMaterial)) {\r\n throw new Error(`${context}: Material type not supported`);\r\n }\r\n const pbrMaterial = babylonMaterial as PBRMaterial;\r\n\r\n // Enables \"refraction\" texture which represents transmitted light.\r\n pbrMaterial.subSurface.isRefractionEnabled = true;\r\n\r\n // Since this extension models thin-surface transmission only, we must make IOR = 1.0\r\n pbrMaterial.subSurface.volumeIndexOfRefraction = 1.0;\r\n\r\n // Albedo colour will tint transmission.\r\n pbrMaterial.subSurface.useAlbedoToTintRefraction = true;\r\n\r\n if (extension.transmissionFactor !== undefined) {\r\n pbrMaterial.subSurface.refractionIntensity = extension.transmissionFactor;\r\n const scene = pbrMaterial.getScene() as unknown as ITransmissionHelperHolder;\r\n if (pbrMaterial.subSurface.refractionIntensity && !scene._transmissionHelper) {\r\n new TransmissionHelper({}, pbrMaterial.getScene());\r\n } else if (pbrMaterial.subSurface.refractionIntensity && !scene._transmissionHelper?._isRenderTargetValid()) {\r\n // If the render target is not valid, recreate it.\r\n scene._transmissionHelper?._setupRenderTargets();\r\n }\r\n } else {\r\n pbrMaterial.subSurface.refractionIntensity = 0.0;\r\n pbrMaterial.subSurface.isRefractionEnabled = false;\r\n return Promise.resolve();\r\n }\r\n\r\n pbrMaterial.subSurface.minimumThickness = 0.0;\r\n pbrMaterial.subSurface.maximumThickness = 0.0;\r\n if (extension.transmissionTexture) {\r\n (extension.transmissionTexture as ITextureInfo).nonColorData = true;\r\n return this._loader.loadTextureInfoAsync(`${context}/transmissionTexture`, extension.transmissionTexture, undefined).then((texture: BaseTexture) => {\r\n pbrMaterial.subSurface.refractionIntensityTexture = texture;\r\n pbrMaterial.subSurface.useGltfStyleTextures = true;\r\n });\r\n } else {\r\n return Promise.resolve();\r\n }\r\n }\r\n}\r\n\r\nGLTFLoader.RegisterExtension(NAME, (loader) => new KHR_materials_transmission(loader));\r\n"]}
|
1
|
+
{"version":3,"file":"KHR_materials_transmission.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_transmission.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAK7D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAK3C,OAAO,EAAE,mBAAmB,EAAE,kEAAoD;AAElF,OAAO,EAAE,UAAU,EAAE,2CAA6B;AAClD,OAAO,EAAE,SAAS,EAAE,6CAA+B;AACnD,OAAO,EAAE,KAAK,EAAE,sCAAwB;AAgDxC;;GAEG;AACH,MAAM,kBAAkB;IACpB;;OAEG;IACK,MAAM,CAAC,kBAAkB;QAC7B,OAAO;YACH,UAAU,EAAE,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I,WAAW,CAAC,UAAU,CAAC,mBAAmB,IAAI,CAAC,CAAA,MAAA,KAAK,CAAC,mBAAmB,0CAAE,oBAAoB,EAAE,CAAA,EAAE;gBACzG,kDAAkD;gBAClD,MAAA,KAAK,CAAC,mBAAmB,0CAAE,mBAAmB,EAAE,CAAC;aACpD;SACJ;aAAM;YACH,WAAW,CAAC,UAAU,CAAC,mBAAmB,GAAG,GAAG,CAAC;YACjD,WAAW,CAAC,UAAU,CAAC,mBAAmB,GAAG,KAAK,CAAC;YACnD,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;SAC5B;QAED,WAAW,CAAC,UAAU,CAAC,gBAAgB,GAAG,GAAG,CAAC;QAC9C,WAAW,CAAC,UAAU,CAAC,gBAAgB,GAAG,GAAG,CAAC;QAC9C,IAAI,SAAS,CAAC,mBAAmB,EAAE;YAC9B,SAAS,CAAC,mBAAoC,CAAC,YAAY,GAAG,IAAI,CAAC;YACpE,OAAO,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,GAAG,OAAO,sBAAsB,EAAE,SAAS,CAAC,mBAAmB,EAAE,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC,OAAoB,EAAE,EAAE;gBAC/I,WAAW,CAAC,UAAU,CAAC,0BAA0B,GAAG,OAAO,CAAC;gBAC5D,WAAW,CAAC,UAAU,CAAC,oBAAoB,GAAG,IAAI,CAAC;YACvD,CAAC,CAAC,CAAC;SACN;aAAM;YACH,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;SAC5B;IACL,CAAC;CACJ;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,0BAA0B,CAAC,MAAM,CAAC,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport { PBRMaterial } from \"core/Materials/PBR/pbrMaterial\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport type { IMaterial, ITextureInfo } from \"../glTFLoaderInterfaces\";\r\nimport type { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader } from \"../glTFLoader\";\r\nimport type { IKHRMaterialsTransmission } from \"babylonjs-gltf2interface\";\r\nimport type { Scene } from \"core/scene\";\r\nimport type { AbstractMesh } from \"core/Meshes/abstractMesh\";\r\nimport type { Texture } from \"core/Materials/Textures/texture\";\r\nimport { RenderTargetTexture } from \"core/Materials/Textures/renderTargetTexture\";\r\nimport type { Observer } from \"core/Misc/observable\";\r\nimport { Observable } from \"core/Misc/observable\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport { Tools } from \"core/Misc/tools\";\r\nimport type { Color4 } from \"core/Maths/math.color\";\r\n\r\ninterface ITransmissionHelperHolder {\r\n /**\r\n * @internal\r\n */\r\n _transmissionHelper: TransmissionHelper | undefined;\r\n}\r\n\r\ninterface ITransmissionHelperOptions {\r\n /**\r\n * The size of the render buffers (default: 1024)\r\n */\r\n renderSize: number;\r\n\r\n /**\r\n * The number of samples to use when generating the render target texture for opaque meshes (default: 4)\r\n */\r\n samples: number;\r\n\r\n /**\r\n * Scale to apply when selecting the LOD level to sample the refraction texture (default: 1)\r\n */\r\n lodGenerationScale: number;\r\n\r\n /**\r\n * Offset to apply when selecting the LOD level to sample the refraction texture (default: -4)\r\n */\r\n lodGenerationOffset: number;\r\n\r\n /**\r\n * Type of the refraction render target texture (default: TEXTURETYPE_HALF_FLOAT)\r\n */\r\n renderTargetTextureType: number;\r\n\r\n /**\r\n * Defines if the mipmaps for the refraction render target texture must be generated (default: true)\r\n */\r\n generateMipmaps: boolean;\r\n\r\n /**\r\n * Clear color of the opaque texture. If not provided, use the scene clear color (which will be converted to linear space).\r\n * If provided, should be in linear space\r\n */\r\n clearColor?: Color4;\r\n}\r\n\r\n/**\r\n * A class to handle setting up the rendering of opaque objects to be shown through transmissive objects.\r\n */\r\nclass TransmissionHelper {\r\n /**\r\n * Creates the default options for the helper.\r\n */\r\n private static _GetDefaultOptions(): ITransmissionHelperOptions {\r\n return {\r\n renderSize: 1024,\r\n samples: 4,\r\n lodGenerationScale: 1,\r\n lodGenerationOffset: -4,\r\n renderTargetTextureType: Constants.TEXTURETYPE_HALF_FLOAT,\r\n generateMipmaps: true,\r\n };\r\n }\r\n\r\n /**\r\n * Stores the creation options.\r\n */\r\n private readonly _scene: Scene & ITransmissionHelperHolder;\r\n\r\n private _options: ITransmissionHelperOptions;\r\n\r\n private _opaqueRenderTarget: Nullable<RenderTargetTexture> = null;\r\n private _opaqueMeshesCache: AbstractMesh[] = [];\r\n private _transparentMeshesCache: AbstractMesh[] = [];\r\n private _materialObservers: { [id: string]: Nullable<Observer<AbstractMesh>> } = {};\r\n\r\n /**\r\n * This observable will be notified with any error during the creation of the environment,\r\n * mainly texture creation errors.\r\n */\r\n public onErrorObservable: Observable<{ message?: string; exception?: any }>;\r\n\r\n /**\r\n * constructor\r\n * @param options Defines the options we want to customize the helper\r\n * @param scene The scene to add the material to\r\n */\r\n constructor(options: Partial<ITransmissionHelperOptions>, scene: Scene) {\r\n this._options = {\r\n ...TransmissionHelper._GetDefaultOptions(),\r\n ...options,\r\n };\r\n this._scene = scene as any;\r\n this._scene._transmissionHelper = this;\r\n\r\n this.onErrorObservable = new Observable();\r\n this._scene.onDisposeObservable.addOnce(() => {\r\n this.dispose();\r\n });\r\n\r\n this._parseScene();\r\n this._setupRenderTargets();\r\n }\r\n\r\n /**\r\n * Updates the background according to the new options\r\n * @param options\r\n */\r\n public updateOptions(options: Partial<ITransmissionHelperOptions>) {\r\n // First check if any options are actually being changed. If not, exit.\r\n const newValues = Object.keys(options).filter((key: string) => (this._options as any)[key] !== (options as any)[key]);\r\n if (!newValues.length) {\r\n return;\r\n }\r\n\r\n const newOptions = {\r\n ...this._options,\r\n ...options,\r\n };\r\n\r\n const oldOptions = this._options;\r\n this._options = newOptions;\r\n\r\n // If size changes, recreate everything\r\n if (\r\n newOptions.renderSize !== oldOptions.renderSize ||\r\n newOptions.renderTargetTextureType !== oldOptions.renderTargetTextureType ||\r\n newOptions.generateMipmaps !== oldOptions.generateMipmaps ||\r\n !this._opaqueRenderTarget\r\n ) {\r\n this._setupRenderTargets();\r\n } else {\r\n this._opaqueRenderTarget.samples = newOptions.samples;\r\n this._opaqueRenderTarget.lodGenerationScale = newOptions.lodGenerationScale;\r\n this._opaqueRenderTarget.lodGenerationOffset = newOptions.lodGenerationOffset;\r\n }\r\n }\r\n\r\n /**\r\n * Gets the opaque render target texture or null if not available.\r\n */\r\n public getOpaqueTarget(): Nullable<Texture> {\r\n return this._opaqueRenderTarget;\r\n }\r\n\r\n private _shouldRenderAsTransmission(material: Nullable<Material>): boolean {\r\n if (!material) {\r\n return false;\r\n }\r\n if (material instanceof PBRMaterial && material.subSurface.isRefractionEnabled) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n private _addMesh(mesh: AbstractMesh): void {\r\n this._materialObservers[mesh.uniqueId] = mesh.onMaterialChangedObservable.add(this._onMeshMaterialChanged.bind(this));\r\n\r\n // we need to defer the processing because _addMesh may be called as part as an instance mesh creation, in which case some\r\n // internal properties are not setup yet, like _sourceMesh (needed when doing mesh.material below)\r\n Tools.SetImmediate(() => {\r\n if (this._shouldRenderAsTransmission(mesh.material)) {\r\n (mesh.material as PBRMaterial).refractionTexture = this._opaqueRenderTarget;\r\n if (this._transparentMeshesCache.indexOf(mesh) === -1) {\r\n this._transparentMeshesCache.push(mesh);\r\n }\r\n } else {\r\n if (this._opaqueMeshesCache.indexOf(mesh) === -1) {\r\n this._opaqueMeshesCache.push(mesh);\r\n }\r\n }\r\n });\r\n }\r\n\r\n private _removeMesh(mesh: AbstractMesh): void {\r\n mesh.onMaterialChangedObservable.remove(this._materialObservers[mesh.uniqueId]);\r\n delete this._materialObservers[mesh.uniqueId];\r\n let idx = this._transparentMeshesCache.indexOf(mesh);\r\n if (idx !== -1) {\r\n this._transparentMeshesCache.splice(idx, 1);\r\n }\r\n idx = this._opaqueMeshesCache.indexOf(mesh);\r\n if (idx !== -1) {\r\n this._opaqueMeshesCache.splice(idx, 1);\r\n }\r\n }\r\n\r\n private _parseScene(): void {\r\n this._scene.meshes.forEach(this._addMesh.bind(this));\r\n // Listen for when a mesh is added to the scene and add it to our cache lists.\r\n this._scene.onNewMeshAddedObservable.add(this._addMesh.bind(this));\r\n // Listen for when a mesh is removed from to the scene and remove it from our cache lists.\r\n this._scene.onMeshRemovedObservable.add(this._removeMesh.bind(this));\r\n }\r\n\r\n // When one of the meshes in the scene has its material changed, make sure that it's in the correct cache list.\r\n private _onMeshMaterialChanged(mesh: AbstractMesh) {\r\n const transparentIdx = this._transparentMeshesCache.indexOf(mesh);\r\n const opaqueIdx = this._opaqueMeshesCache.indexOf(mesh);\r\n\r\n // If the material is transparent, make sure that it's added to the transparent list and removed from the opaque list\r\n const useTransmission = this._shouldRenderAsTransmission(mesh.material);\r\n if (useTransmission) {\r\n if (mesh.material instanceof PBRMaterial) {\r\n mesh.material.subSurface.refractionTexture = this._opaqueRenderTarget;\r\n }\r\n if (opaqueIdx !== -1) {\r\n this._opaqueMeshesCache.splice(opaqueIdx, 1);\r\n this._transparentMeshesCache.push(mesh);\r\n } else if (transparentIdx === -1) {\r\n this._transparentMeshesCache.push(mesh);\r\n }\r\n // If the material is opaque, make sure that it's added to the opaque list and removed from the transparent list\r\n } else {\r\n if (transparentIdx !== -1) {\r\n this._transparentMeshesCache.splice(transparentIdx, 1);\r\n this._opaqueMeshesCache.push(mesh);\r\n } else if (opaqueIdx === -1) {\r\n this._opaqueMeshesCache.push(mesh);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n * Check if the opaque render target has not been disposed and can still be used.\r\n * @returns\r\n */\r\n public _isRenderTargetValid() {\r\n return this._opaqueRenderTarget?.getInternalTexture() !== null;\r\n }\r\n\r\n /**\r\n * @internal\r\n * Setup the render targets according to the specified options.\r\n */\r\n public _setupRenderTargets(): void {\r\n if (this._opaqueRenderTarget) {\r\n this._opaqueRenderTarget.dispose();\r\n }\r\n this._opaqueRenderTarget = new RenderTargetTexture(\r\n \"opaqueSceneTexture\",\r\n this._options.renderSize,\r\n this._scene,\r\n this._options.generateMipmaps,\r\n undefined,\r\n this._options.renderTargetTextureType\r\n );\r\n this._opaqueRenderTarget.ignoreCameraViewport = true;\r\n this._opaqueRenderTarget.renderList = this._opaqueMeshesCache;\r\n this._opaqueRenderTarget.clearColor = this._options.clearColor?.clone() ?? this._scene.clearColor.clone();\r\n this._opaqueRenderTarget.gammaSpace = false;\r\n this._opaqueRenderTarget.lodGenerationScale = this._options.lodGenerationScale;\r\n this._opaqueRenderTarget.lodGenerationOffset = this._options.lodGenerationOffset;\r\n this._opaqueRenderTarget.samples = this._options.samples;\r\n this._opaqueRenderTarget.renderSprites = true;\r\n this._opaqueRenderTarget.renderParticles = true;\r\n\r\n let sceneImageProcessingapplyByPostProcess: boolean;\r\n\r\n let saveSceneEnvIntensity: number;\r\n this._opaqueRenderTarget.onBeforeBindObservable.add((opaqueRenderTarget) => {\r\n saveSceneEnvIntensity = this._scene.environmentIntensity;\r\n this._scene.environmentIntensity = 1.0;\r\n sceneImageProcessingapplyByPostProcess = this._scene.imageProcessingConfiguration.applyByPostProcess;\r\n if (!this._options.clearColor) {\r\n this._scene.clearColor.toLinearSpaceToRef(opaqueRenderTarget.clearColor, this._scene.getEngine().useExactSrgbConversions);\r\n } else {\r\n opaqueRenderTarget.clearColor.copyFrom(this._options.clearColor);\r\n }\r\n // we do not use the applyByPostProcess setter to avoid flagging all the materials as \"image processing dirty\"!\r\n this._scene.imageProcessingConfiguration._applyByPostProcess = true;\r\n });\r\n this._opaqueRenderTarget.onAfterUnbindObservable.add(() => {\r\n this._scene.environmentIntensity = saveSceneEnvIntensity;\r\n this._scene.imageProcessingConfiguration._applyByPostProcess = sceneImageProcessingapplyByPostProcess;\r\n });\r\n\r\n this._transparentMeshesCache.forEach((mesh: AbstractMesh) => {\r\n if (this._shouldRenderAsTransmission(mesh.material)) {\r\n (mesh.material as PBRMaterial).refractionTexture = this._opaqueRenderTarget;\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Dispose all the elements created by the Helper.\r\n */\r\n public dispose(): void {\r\n this._scene._transmissionHelper = undefined;\r\n if (this._opaqueRenderTarget) {\r\n this._opaqueRenderTarget.dispose();\r\n this._opaqueRenderTarget = null;\r\n }\r\n this._transparentMeshesCache = [];\r\n this._opaqueMeshesCache = [];\r\n }\r\n}\r\n\r\nconst NAME = \"KHR_materials_transmission\";\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_transmission/README.md)\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_materials_transmission implements IGLTFLoaderExtension {\r\n /**\r\n * The name of this extension.\r\n */\r\n public readonly name = NAME;\r\n\r\n /**\r\n * Defines whether this extension is enabled.\r\n */\r\n public enabled: boolean;\r\n\r\n /**\r\n * Defines a number that determines the order the extensions are applied.\r\n */\r\n public order = 175;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /**\r\n * @internal\r\n */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = this._loader.isExtensionUsed(NAME);\r\n if (this.enabled) {\r\n loader.parent.transparencyAsCoverage = true;\r\n }\r\n }\r\n\r\n /** @internal */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>> {\r\n return GLTFLoader.LoadExtensionAsync<IKHRMaterialsTransmission>(context, material, this.name, (extensionContext, extension) => {\r\n const promises = new Array<Promise<any>>();\r\n promises.push(this._loader.loadMaterialBasePropertiesAsync(context, material, babylonMaterial));\r\n promises.push(this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));\r\n promises.push(this._loadTransparentPropertiesAsync(extensionContext, material, babylonMaterial, extension));\r\n return Promise.all(promises).then(() => {});\r\n });\r\n }\r\n\r\n private _loadTransparentPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material, extension: IKHRMaterialsTransmission): Promise<void> {\r\n if (!(babylonMaterial instanceof PBRMaterial)) {\r\n throw new Error(`${context}: Material type not supported`);\r\n }\r\n const pbrMaterial = babylonMaterial as PBRMaterial;\r\n\r\n // Enables \"refraction\" texture which represents transmitted light.\r\n pbrMaterial.subSurface.isRefractionEnabled = true;\r\n\r\n // Since this extension models thin-surface transmission only, we must make IOR = 1.0\r\n pbrMaterial.subSurface.volumeIndexOfRefraction = 1.0;\r\n\r\n // Albedo colour will tint transmission.\r\n pbrMaterial.subSurface.useAlbedoToTintRefraction = true;\r\n\r\n if (extension.transmissionFactor !== undefined) {\r\n pbrMaterial.subSurface.refractionIntensity = extension.transmissionFactor;\r\n const scene = pbrMaterial.getScene() as unknown as ITransmissionHelperHolder;\r\n if (pbrMaterial.subSurface.refractionIntensity && !scene._transmissionHelper) {\r\n new TransmissionHelper({}, pbrMaterial.getScene());\r\n } else if (pbrMaterial.subSurface.refractionIntensity && !scene._transmissionHelper?._isRenderTargetValid()) {\r\n // If the render target is not valid, recreate it.\r\n scene._transmissionHelper?._setupRenderTargets();\r\n }\r\n } else {\r\n pbrMaterial.subSurface.refractionIntensity = 0.0;\r\n pbrMaterial.subSurface.isRefractionEnabled = false;\r\n return Promise.resolve();\r\n }\r\n\r\n pbrMaterial.subSurface.minimumThickness = 0.0;\r\n pbrMaterial.subSurface.maximumThickness = 0.0;\r\n if (extension.transmissionTexture) {\r\n (extension.transmissionTexture as ITextureInfo).nonColorData = true;\r\n return this._loader.loadTextureInfoAsync(`${context}/transmissionTexture`, extension.transmissionTexture, undefined).then((texture: BaseTexture) => {\r\n pbrMaterial.subSurface.refractionIntensityTexture = texture;\r\n pbrMaterial.subSurface.useGltfStyleTextures = true;\r\n });\r\n } else {\r\n return Promise.resolve();\r\n }\r\n }\r\n}\r\n\r\nGLTFLoader.RegisterExtension(NAME, (loader) => new KHR_materials_transmission(loader));\r\n"]}
|
package/glTF/glTFFileLoader.d.ts
CHANGED
@@ -327,10 +327,7 @@ export declare class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAs
|
|
327
327
|
* @internal
|
328
328
|
*/
|
329
329
|
loadFile(scene: Scene, fileOrUrl: File | string | ArrayBufferView, rootUrl: string, onSuccess: (data: any, responseURL?: string) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void, name?: string): Nullable<IFileRequest>;
|
330
|
-
|
331
|
-
* @internal
|
332
|
-
*/
|
333
|
-
_loadBinary(scene: Scene, data: ArrayBufferView, rootUrl: string, onSuccess: (data: any, responseURL?: string) => void, onError?: (request?: WebRequest, exception?: LoadFileError) => void, fileName?: string): void;
|
330
|
+
private _loadBinary;
|
334
331
|
/**
|
335
332
|
* @internal
|
336
333
|
*/
|
package/glTF/glTFFileLoader.js
CHANGED
@@ -17,8 +17,11 @@ function readAsync(arrayBuffer, byteOffset, byteLength) {
|
|
17
17
|
}
|
18
18
|
function readViewAsync(arrayBufferView, byteOffset, byteLength) {
|
19
19
|
try {
|
20
|
-
if (
|
21
|
-
throw new
|
20
|
+
if (byteOffset < 0 || byteOffset >= arrayBufferView.byteLength) {
|
21
|
+
throw new RangeError("Offset is out of range.");
|
22
|
+
}
|
23
|
+
if (byteOffset + byteLength > arrayBufferView.byteLength) {
|
24
|
+
throw new RangeError("Length is out of range.");
|
22
25
|
}
|
23
26
|
return Promise.resolve(new Uint8Array(arrayBufferView.buffer, arrayBufferView.byteOffset + byteOffset, byteLength));
|
24
27
|
}
|
@@ -447,9 +450,6 @@ export class GLTFFileLoader {
|
|
447
450
|
onSuccess({ json: this._parseJson(data) });
|
448
451
|
}, useArrayBuffer, onError);
|
449
452
|
}
|
450
|
-
/**
|
451
|
-
* @internal
|
452
|
-
*/
|
453
453
|
_loadBinary(scene, data, rootUrl, onSuccess, onError, fileName) {
|
454
454
|
this._validate(scene, data, rootUrl, fileName);
|
455
455
|
this._unpackBinaryAsync(new DataReader({
|
@@ -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,IAAK,eAA8B,CAAC,UAAU,GAAG,UAAU,GAAG,eAAe,CAAC,UAAU,EAAE;YACtF,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;SAClD;QAED,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,UAAU,CAAC,eAAe,CAAC,MAAM,EAAG,eAA8B,CAAC,UAAU,GAAG,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC;KACvI;IAAC,OAAO,CAAC,EAAE;QACR,OAAO,OAAO,CAAC,MAAM,CAAC,CA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;AAExC;;;;GAIG;AACW,qCAAsB,GAAG,KAAK,AAAR,CAAS;AA0T9B,kCAAmB,GAAG,QAAQ,AAAX,CAAY,CAAC,8CAA8C;AA6nBrE,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 ((arrayBufferView as Uint8Array).byteOffset + byteLength > arrayBufferView.byteLength) {\r\n throw new Error(\"Array length out of bounds.\");\r\n }\r\n\r\n return Promise.resolve(new Uint8Array(arrayBufferView.buffer, (arrayBufferView as Uint8Array).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\r\n */\r\n public preprocessUrlAsync = (url: string) => Promise.resolve(url);\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), 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 }\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), rootUrl, fileName);\r\n onSuccess({ json: this._parseJson(data as string) });\r\n },\r\n useArrayBuffer,\r\n onError\r\n );\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n _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, data, 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));\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 | ArrayBufferView, 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) => scene._loadFileAsync(url, undefined, true, true) as Promise<ArrayBuffer>);\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,UA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O,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;;AAl/BpE,aAAa;AACb,aAAa;AACb,aAAa;AAEb;;;;;GAKG;AACW,iCAAkB,GAAG,IAAI,AAAP,CAAQ;AAExC;;;;GAIG;AACW,qCAAsB,GAAG,KAAK,AAAR,CAAS;AA0T9B,kCAAmB,GAAG,QAAQ,AAAX,CAAY,CAAC,8CAA8C;AA0nBrE,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\r\n */\r\n public preprocessUrlAsync = (url: string) => Promise.resolve(url);\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), 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 }\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), rootUrl, fileName);\r\n onSuccess({ json: this._parseJson(data as string) });\r\n },\r\n useArrayBuffer,\r\n onError\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, data, 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));\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 | ArrayBufferView, 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) => scene._loadFileAsync(url, undefined, true, true) as Promise<ArrayBuffer>);\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": "6.
|
3
|
+
"version": "6.32.0",
|
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": "^6.
|
21
|
+
"@babylonjs/core": "^6.32.0",
|
22
22
|
"@dev/build-tools": "^1.0.0",
|
23
23
|
"@lts/loaders": "^1.0.0",
|
24
|
-
"babylonjs-gltf2interface": "^6.
|
24
|
+
"babylonjs-gltf2interface": "^6.32.0"
|
25
25
|
},
|
26
26
|
"peerDependencies": {
|
27
27
|
"@babylonjs/core": "^6.0.0",
|