declare module BABYLON { enum GLTFLoaderCoordinateSystemMode { /** * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene. */ AUTO = 0, /** * Sets the useRightHandedSystem flag on the scene. */ FORCE_RIGHT_HANDED = 1, } enum GLTFLoaderAnimationStartMode { /** * No animation will start. */ NONE = 0, /** * The first animation will start. */ FIRST = 1, /** * All animations will start. */ ALL = 2, } interface IGLTFLoaderData { json: Object; bin: Nullable; } interface IGLTFLoaderExtension { /** * The name of this extension. */ readonly name: string; /** * Whether this extension is enabled. */ enabled: boolean; } enum GLTFLoaderState { /** * The asset is loading. */ LOADING = 0, /** * The asset is ready for rendering. */ READY = 1, /** * The asset is completely loaded. */ COMPLETE = 2, } interface IGLTFLoader extends IDisposable { coordinateSystemMode: GLTFLoaderCoordinateSystemMode; animationStartMode: GLTFLoaderAnimationStartMode; compileMaterials: boolean; useClipPlane: boolean; compileShadowGenerators: boolean; onMeshLoadedObservable: Observable; onTextureLoadedObservable: Observable; onMaterialLoadedObservable: Observable; onCompleteObservable: Observable; onDisposeObservable: Observable; onExtensionLoadedObservable: Observable; state: Nullable; importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void) => Promise<{ meshes: AbstractMesh[]; particleSystems: ParticleSystem[]; skeletons: Skeleton[]; animationGroups: AnimationGroup[]; }>; loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void) => Promise; } class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory { static CreateGLTFLoaderV1: () => IGLTFLoader; static CreateGLTFLoaderV2: () => IGLTFLoader; /** * Raised when the asset has been parsed. * The data.json property stores the glTF JSON. * The data.bin property stores the BIN chunk from a glTF binary or null if the input is not a glTF binary. */ onParsedObservable: Observable; private _onParsedObserver; onParsed: (loaderData: IGLTFLoaderData) => void; static IncrementalLoading: boolean; static HomogeneousCoordinates: boolean; /** * The coordinate system mode (AUTO, FORCE_RIGHT_HANDED). */ coordinateSystemMode: GLTFLoaderCoordinateSystemMode; /** * The animation start mode (NONE, FIRST, ALL). */ animationStartMode: GLTFLoaderAnimationStartMode; /** * Set to true to compile materials before raising the success callback. */ compileMaterials: boolean; /** * Set to true to also compile materials with clip planes. */ useClipPlane: boolean; /** * Set to true to compile shadow generators before raising the success callback. */ compileShadowGenerators: boolean; /** * Raised when the loader creates a mesh after parsing the glTF properties of the mesh. */ readonly onMeshLoadedObservable: Observable; private _onMeshLoadedObserver; onMeshLoaded: (mesh: AbstractMesh) => void; /** * Raised when the loader creates a texture after parsing the glTF properties of the texture. */ readonly onTextureLoadedObservable: Observable; private _onTextureLoadedObserver; onTextureLoaded: (texture: BaseTexture) => void; /** * Raised when the loader creates a material after parsing the glTF properties of the material. */ readonly onMaterialLoadedObservable: Observable; private _onMaterialLoadedObserver; onMaterialLoaded: (material: Material) => void; /** * Raised when the asset is completely loaded, immediately before the loader is disposed. * For assets with LODs, raised when all of the LODs are complete. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise. */ readonly onCompleteObservable: Observable; private _onCompleteObserver; onComplete: () => void; /** * Raised after the loader is disposed. */ readonly onDisposeObservable: Observable; private _onDisposeObserver; onDispose: () => void; /** * Raised after a loader extension is created. * Set additional options for a loader extension in this event. */ readonly onExtensionLoadedObservable: Observable; private _onExtensionLoadedObserver; onExtensionLoaded: (extension: IGLTFLoaderExtension) => void; /** * Returns a promise that resolves when the asset is completely loaded. * @returns A promise that resolves when the asset is completely loaded. */ whenCompleteAsync(): Promise; /** * The loader state (LOADING, READY, COMPLETE) or null if the loader is not active. */ readonly loaderState: Nullable; private _loader; name: string; extensions: ISceneLoaderPluginExtensions; /** * Disposes the loader, releases resources during load, and cancels any outstanding requests. */ dispose(): void; importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{ meshes: AbstractMesh[]; particleSystems: ParticleSystem[]; skeletons: Skeleton[]; animationGroups: AnimationGroup[]; }>; loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise; loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise; canDirectLoad(data: string): boolean; rewriteRootURL: (rootUrl: string, responseURL?: string) => string; createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync; private _parse(data); private _getLoader(loaderData); private static _parseBinary(data); private static _parseV1(binaryReader); private static _parseV2(binaryReader); private static _parseVersion(version); private static _compareVersion(a, b); private static _decodeBufferToText(buffer); } } declare module BABYLON.GLTF2 { interface IArrayItem { _index: number; } class ArrayItem { static Assign(values?: IArrayItem[]): void; } } declare module BABYLON.GLTF2 { interface ILoaderAccessor extends IAccessor, IArrayItem { _data?: Promise; _babylonVertexBuffer?: Promise; } interface ILoaderAnimationChannel extends IAnimationChannel, IArrayItem { } interface ILoaderAnimationSamplerData { input: Float32Array; interpolation: AnimationSamplerInterpolation; output: Float32Array; } interface ILoaderAnimationSampler extends IAnimationSampler, IArrayItem { _data: Promise; } interface ILoaderAnimation extends IAnimation, IArrayItem { channels: ILoaderAnimationChannel[]; samplers: ILoaderAnimationSampler[]; _babylonAnimationGroup?: AnimationGroup; } interface ILoaderBuffer extends IBuffer, IArrayItem { _data?: Promise; } interface ILoaderBufferView extends IBufferView, IArrayItem { _data?: Promise; _babylonBuffer?: Promise; } interface ILoaderCamera extends ICamera, IArrayItem { } interface ILoaderImage extends IImage, IArrayItem { _objectURL?: Promise; } interface ILoaderMaterial extends IMaterial, IArrayItem { _babylonData?: { [drawMode: number]: { material: Material; meshes: AbstractMesh[]; loaded: Promise; }; }; } interface ILoaderMesh extends IMesh, IArrayItem { primitives: ILoaderMeshPrimitive[]; } interface ILoaderMeshPrimitive extends IMeshPrimitive, IArrayItem { } interface ILoaderNode extends INode, IArrayItem { _parent: ILoaderNode; _babylonMesh?: Mesh; _primitiveBabylonMeshes?: Mesh[]; _babylonAnimationTargets?: Node[]; _numMorphTargets?: number; } interface ILoaderSamplerData { noMipMaps: boolean; samplingMode: number; wrapU: number; wrapV: number; } interface ILoaderSampler extends ISampler, IArrayItem { _data?: ILoaderSamplerData; } interface ILoaderScene extends IScene, IArrayItem { } interface ILoaderSkin extends ISkin, IArrayItem { _babylonSkeleton?: Skeleton; _loaded?: Promise; } interface ILoaderTexture extends ITexture, IArrayItem { } interface ILoaderGLTF extends IGLTF { accessors?: ILoaderAccessor[]; animations?: ILoaderAnimation[]; buffers?: ILoaderBuffer[]; bufferViews?: ILoaderBufferView[]; cameras?: ILoaderCamera[]; images?: ILoaderImage[]; materials?: ILoaderMaterial[]; meshes?: ILoaderMesh[]; nodes?: ILoaderNode[]; samplers?: ILoaderSampler[]; scenes?: ILoaderScene[]; skins?: ILoaderSkin[]; textures?: ILoaderTexture[]; } } declare module BABYLON.GLTF2 { interface MaterialConstructor { readonly prototype: T; new (name: string, scene: Scene): T; } class GLTFLoader implements IGLTFLoader { _gltf: ILoaderGLTF; _babylonScene: Scene; _completePromises: Promise[]; private _disposed; private _state; private _extensions; private _rootUrl; private _rootBabylonMesh; private _defaultSampler; private _defaultBabylonMaterials; private _progressCallback?; private _requests; private static _Names; private static _Factories; static _Register(name: string, factory: (loader: GLTFLoader) => GLTFLoaderExtension): void; coordinateSystemMode: GLTFLoaderCoordinateSystemMode; animationStartMode: GLTFLoaderAnimationStartMode; compileMaterials: boolean; useClipPlane: boolean; compileShadowGenerators: boolean; readonly onDisposeObservable: Observable; readonly onMeshLoadedObservable: Observable; readonly onTextureLoadedObservable: Observable; readonly onMaterialLoadedObservable: Observable; readonly onExtensionLoadedObservable: Observable; readonly onCompleteObservable: Observable; readonly state: Nullable; dispose(): void; importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{ meshes: AbstractMesh[]; particleSystems: ParticleSystem[]; skeletons: Skeleton[]; animationGroups: AnimationGroup[]; }>; loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise; private _loadAsync(nodes, scene, data, rootUrl, onProgress?); private _loadExtensions(); private _loadData(data); private _setupData(); private _checkExtensions(); private _createRootNode(); private _loadNodesAsync(nodes); _loadSceneAsync(context: string, scene: ILoaderScene): Promise; private _forEachPrimitive(node, callback); private _getMeshes(); private _getSkeletons(); private _getAnimationGroups(); private _startAnimations(); _loadNodeAsync(context: string, node: ILoaderNode): Promise; private _loadMeshAsync(context, node, mesh, babylonMesh); private _loadPrimitiveAsync(context, node, mesh, primitive, babylonMesh); private _loadVertexDataAsync(context, primitive, babylonMesh); private _createMorphTargets(context, node, mesh, primitive, babylonMesh); private _loadMorphTargetsAsync(context, primitive, babylonMesh, babylonGeometry); private _loadMorphTargetVertexDataAsync(context, babylonGeometry, attributes, babylonMorphTarget); private static _LoadTransform(node, babylonNode); private _loadSkinAsync(context, node, mesh, skin); private _loadSkinInverseBindMatricesDataAsync(context, skin); private _createBone(node, skin, parent, localMatrix, baseMatrix, index); private _loadBones(context, skin, inverseBindMatricesData); private _loadBone(node, skin, inverseBindMatricesData, babylonBones); private _getNodeMatrix(node); private _loadAnimationsAsync(); private _loadAnimationAsync(context, animation); private _loadAnimationChannelAsync(context, animationContext, animation, channel, babylonAnimationGroup); private _loadAnimationSamplerAsync(context, sampler); private _loadBufferAsync(context, buffer); _loadBufferViewAsync(context: string, bufferView: ILoaderBufferView): Promise; private _loadAccessorAsync(context, accessor); _loadVertexBufferViewAsync(context: string, bufferView: ILoaderBufferView, kind: string): Promise; private _loadVertexAccessorAsync(context, accessor, kind); private _getDefaultMaterial(drawMode); private _loadMaterialMetallicRoughnessPropertiesAsync(context, material, babylonMaterial); _loadMaterialAsync(context: string, material: ILoaderMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Promise; _createMaterial(type: MaterialConstructor, name: string, drawMode: number): T; _loadMaterialBasePropertiesAsync(context: string, material: ILoaderMaterial, babylonMaterial: PBRMaterial): Promise; _loadMaterialAlphaProperties(context: string, material: ILoaderMaterial, babylonMaterial: PBRMaterial): void; _loadTextureAsync(context: string, textureInfo: ITextureInfo, assign: (texture: Texture) => void): Promise; private _loadSampler(context, sampler); private _loadImageAsync(context, image); _loadUriAsync(context: string, uri: string): Promise; private _onProgress(); static _GetProperty(context: string, array: ArrayLike | undefined, index: number | undefined): T; private static _GetTextureWrapMode(context, mode); private static _GetTextureSamplingMode(context, magFilter?, minFilter?); private static _GetNumComponents(context, type); private static _ValidateUri(uri); private static _GetDrawMode(context, mode); private _compileMaterialsAsync(); private _compileShadowGeneratorsAsync(); private _clear(); _applyExtensions(actionAsync: (extension: GLTFLoaderExtension) => Nullable>): Nullable>; } } declare module BABYLON.GLTF2 { abstract class GLTFLoaderExtension implements IGLTFLoaderExtension, IDisposable { enabled: boolean; readonly abstract name: string; protected _loader: GLTFLoader; constructor(loader: GLTFLoader); dispose(): void; /** Override this method to modify the default behavior for loading scenes. */ protected _loadSceneAsync(context: string, node: ILoaderScene): Nullable>; /** Override this method to modify the default behavior for loading nodes. */ protected _loadNodeAsync(context: string, node: ILoaderNode): Nullable>; /** Override this method to modify the default behavior for loading mesh primitive vertex data. */ protected _loadVertexDataAsync(context: string, primitive: ILoaderMeshPrimitive, babylonMesh: Mesh): Nullable>; /** Override this method to modify the default behavior for loading materials. */ protected _loadMaterialAsync(context: string, material: ILoaderMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable>; /** Override this method to modify the default behavior for loading uris. */ protected _loadUriAsync(context: string, uri: string): Nullable>; /** Helper method called by a loader extension to load an glTF extension. */ protected _loadExtensionAsync(context: string, property: IProperty, actionAsync: (extensionContext: string, extension: TProperty) => Promise): Nullable>; /** Helper method called by the loader to allow extensions to override loading scenes. */ static _LoadSceneAsync(loader: GLTFLoader, context: string, scene: ILoaderScene): Nullable>; /** Helper method called by the loader to allow extensions to override loading nodes. */ static _LoadNodeAsync(loader: GLTFLoader, context: string, node: ILoaderNode): Nullable>; /** Helper method called by the loader to allow extensions to override loading mesh primitive vertex data. */ static _LoadVertexDataAsync(loader: GLTFLoader, context: string, primitive: ILoaderMeshPrimitive, babylonMesh: Mesh): Nullable>; /** Helper method called by the loader to allow extensions to override loading materials. */ static _LoadMaterialAsync(loader: GLTFLoader, context: string, material: ILoaderMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable>; /** Helper method called by the loader to allow extensions to override loading uris. */ static _LoadUriAsync(loader: GLTFLoader, context: string, uri: string): Nullable>; } } declare module BABYLON.GLTF2.Extensions { class MSFT_lod extends GLTFLoaderExtension { readonly name: string; /** * Maximum number of LODs to load, starting from the lowest LOD. */ maxLODsToLoad: number; private _loadingNodeLOD; private _loadNodeSignals; private _loadingMaterialLOD; private _loadMaterialSignals; protected _loadNodeAsync(context: string, node: ILoaderNode): Nullable>; protected _loadMaterialAsync(context: string, material: ILoaderMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable>; protected _loadUriAsync(context: string, uri: string): Nullable>; /** * Gets an array of LOD properties from lowest to highest. */ private _getLODs(context, property, array, ids); } } declare module BABYLON.GLTF2.Extensions { class KHR_draco_mesh_compression extends GLTFLoaderExtension { readonly name: string; private _dracoCompression; constructor(loader: GLTFLoader); dispose(): void; protected _loadVertexDataAsync(context: string, primitive: ILoaderMeshPrimitive, babylonMesh: Mesh): Nullable>; } } declare module BABYLON.GLTF2.Extensions { class KHR_materials_pbrSpecularGlossiness extends GLTFLoaderExtension { readonly name: string; protected _loadMaterialAsync(context: string, material: ILoaderMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable>; private _loadSpecularGlossinessPropertiesAsync(context, material, properties, babylonMaterial); } } declare module BABYLON.GLTF2.Extensions { class KHR_materials_unlit extends GLTFLoaderExtension { readonly name: string; protected _loadMaterialAsync(context: string, material: ILoaderMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable>; private _loadUnlitPropertiesAsync(context, material, babylonMaterial); } } declare module BABYLON.GLTF2.Extensions { class KHR_lights extends GLTFLoaderExtension { readonly name: string; protected _loadSceneAsync(context: string, scene: ILoaderScene): Nullable>; protected _loadNodeAsync(context: string, node: ILoaderNode): Nullable>; private readonly _lights; } }