@babylonjs/loaders
Version:
The Babylon.js file loaders library is an extension you can use to load different 3D file types into a Babylon scene.
115 lines (114 loc) • 7.07 kB
TypeScript
import { IGLTFRuntime } from "./glTFLoaderInterfaces";
import { Nullable } from "@babylonjs/core/types";
import { AnimationGroup } from "@babylonjs/core/Animations/animationGroup";
import { Skeleton } from "@babylonjs/core/Bones/skeleton";
import { IParticleSystem } from "@babylonjs/core/Particles/IParticleSystem";
import { Material } from "@babylonjs/core/Materials/material";
import { Texture } from "@babylonjs/core/Materials/Textures/texture";
import { AbstractMesh } from "@babylonjs/core/Meshes/abstractMesh";
import { SceneLoaderProgressEvent } from "@babylonjs/core/Loading/sceneLoader";
import { Scene } from "@babylonjs/core/scene";
import { IGLTFLoader, GLTFLoaderState, IGLTFLoaderData } from "../glTFFileLoader";
/**
* Implementation of the base glTF spec
* @hidden
*/
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, onError: (message: string) => 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
* @hidden
*/
export declare class GLTFLoader implements IGLTFLoader {
static Extensions: {
[name: string]: GLTFLoaderExtension;
};
static RegisterExtension(extension: GLTFLoaderExtension): void;
state: Nullable<GLTFLoaderState>;
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 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, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
meshes: AbstractMesh[];
particleSystems: IParticleSystem[];
skeletons: Skeleton[];
animationGroups: AnimationGroup[];
}>;
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: SceneLoaderProgressEvent) => void): Promise<void>;
private _loadShadersAsync;
private _loadBuffersAsync;
private _createNodes;
}
/** @hidden */
export declare abstract class GLTFLoaderExtension {
private _name;
constructor(name: string);
readonly name: string;
/**
* Defines an override for loading the runtime
* Return 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
*/
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
*/
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
*/
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
*/
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
*/
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
*/
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;
}