@babylonjs/loaders
Version:
For usage documentation please visit https://doc.babylonjs.com/features/featuresDeepDive/importers/loadingFileTypes/.
145 lines (144 loc) • 7.98 kB
TypeScript
import type { IGLTFRuntime } from "./glTFLoaderInterfaces.js";
import type { Nullable } from "@babylonjs/core/types.js";
import { Material } from "@babylonjs/core/Materials/material.js";
import { Texture } from "@babylonjs/core/Materials/Textures/texture.js";
import type { ISceneLoaderAsyncResult, ISceneLoaderProgressEvent } from "@babylonjs/core/Loading/sceneLoader.js";
import type { Scene } from "@babylonjs/core/scene.js";
import type { IGLTFLoader, IGLTFLoaderData } from "../glTFFileLoader.js";
import type { AssetContainer } from "@babylonjs/core/assetContainer.js";
/**
* Implementation of the base glTF spec
* @internal
*/
export declare class GLTFLoaderBase {
static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void): void;
static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
}
/**
* glTF V1 Loader
* @internal
* @deprecated
*/
export declare class GLTFLoader implements IGLTFLoader {
static Extensions: {
[name: string]: GLTFLoaderExtension;
};
static RegisterExtension(extension: GLTFLoaderExtension): void;
dispose(): void;
private _importMeshAsync;
/**
* Imports one or more meshes from a loaded gltf file and adds them to the scene
* @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
* @param scene the scene the meshes should be added to
* @param assetContainer defines the asset container to use (can be null)
* @param data gltf data containing information of the meshes in a loaded file
* @param rootUrl root url to load from
* @param onProgress event that fires when loading progress has occured
* @returns a promise containg the loaded meshes, particles, skeletons and animations
*/
importMeshAsync(meshesNames: any, scene: Scene, assetContainer: Nullable<AssetContainer>, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<ISceneLoaderAsyncResult>;
private _loadAsync;
/**
* Imports all objects from a loaded gltf file and adds them to the scene
* @param scene the scene the objects should be added to
* @param data gltf data containing information of the meshes in a loaded file
* @param rootUrl root url to load from
* @param onProgress event that fires when loading progress has occured
* @returns a promise which completes when objects have been loaded to the scene
*/
loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
private _loadShadersAsync;
private _loadBuffersAsync;
private _createNodes;
}
/** @internal */
export declare abstract class GLTFLoaderExtension {
private _name;
constructor(name: string);
get name(): string;
/**
* Defines an override for loading the runtime
* Return true to stop further extensions from loading the runtime
* @param scene
* @param data
* @param rootUrl
* @param onSuccess
* @param onError
* @returns true to stop further extensions from loading the runtime
*/
loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
/**
* Defines an onverride for creating gltf runtime
* Return true to stop further extensions from creating the runtime
* @param gltfRuntime
* @param onSuccess
* @param onError
* @returns true to stop further extensions from creating the runtime
*/
loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
/**
* Defines an override for loading buffers
* Return true to stop further extensions from loading this buffer
* @param gltfRuntime
* @param id
* @param onSuccess
* @param onError
* @param onProgress
* @returns true to stop further extensions from loading this buffer
*/
loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
/**
* Defines an override for loading texture buffers
* Return true to stop further extensions from loading this texture data
* @param gltfRuntime
* @param id
* @param onSuccess
* @param onError
* @returns true to stop further extensions from loading this texture data
*/
loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
/**
* Defines an override for creating textures
* Return true to stop further extensions from loading this texture
* @param gltfRuntime
* @param id
* @param buffer
* @param onSuccess
* @param onError
* @returns true to stop further extensions from loading this texture
*/
createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
/**
* Defines an override for loading shader strings
* Return true to stop further extensions from loading this shader data
* @param gltfRuntime
* @param id
* @param onSuccess
* @param onError
* @returns true to stop further extensions from loading this shader data
*/
loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
/**
* Defines an override for loading materials
* Return true to stop further extensions from loading this material
* @param gltfRuntime
* @param id
* @param onSuccess
* @param onError
* @returns true to stop further extensions from loading this material
*/
loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
private static _LoadTextureBufferAsync;
private static _CreateTextureAsync;
private static _ApplyExtensions;
}