123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095 |
- /// <reference types="babylonjs"/>
- declare module 'babylonjs-loaders' {
- export = BABYLON;
- }
- declare module BABYLON {
- class STLFileLoader implements ISceneLoaderPlugin {
- solidPattern: RegExp;
- facetsPattern: RegExp;
- normalPattern: RegExp;
- vertexPattern: RegExp;
- name: string;
- extensions: ISceneLoaderPluginExtensions;
- importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<ParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
- load(scene: Scene, data: any, rootUrl: string): boolean;
- loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
- private isBinary(data);
- private parseBinary(mesh, data);
- private parseASCII(mesh, solidData);
- }
- }
- declare module BABYLON {
- /**
- * Class reading and parsing the MTL file bundled with the obj file.
- */
- class MTLFileLoader {
- materials: BABYLON.StandardMaterial[];
- /**
- * This function will read the mtl file and create each material described inside
- * This function could be improve by adding :
- * -some component missing (Ni, Tf...)
- * -including the specific options available
- *
- * @param scene
- * @param data
- * @param rootUrl
- */
- parseMTL(scene: BABYLON.Scene, data: string, rootUrl: string): void;
- /**
- * Gets the texture for the material.
- *
- * If the material is imported from input file,
- * We sanitize the url to ensure it takes the textre from aside the material.
- *
- * @param rootUrl The root url to load from
- * @param value The value stored in the mtl
- * @return The Texture
- */
- private static _getTexture(rootUrl, value, scene);
- }
- class OBJFileLoader implements ISceneLoaderPlugin {
- static OPTIMIZE_WITH_UV: boolean;
- name: string;
- extensions: string;
- obj: RegExp;
- group: RegExp;
- mtllib: RegExp;
- usemtl: RegExp;
- smooth: RegExp;
- vertexPattern: RegExp;
- normalPattern: RegExp;
- uvPattern: RegExp;
- facePattern1: RegExp;
- facePattern2: RegExp;
- facePattern3: RegExp;
- facePattern4: RegExp;
- /**
- * Calls synchronously the MTL file attached to this obj.
- * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
- * Without this function materials are not displayed in the first frame (but displayed after).
- * In consequence it is impossible to get material information in your HTML file
- *
- * @param url The URL of the MTL file
- * @param rootUrl
- * @param onSuccess Callback function to be called when the MTL file is loaded
- * @private
- */
- private _loadMTL(url, rootUrl, onSuccess);
- importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<ParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
- load(scene: Scene, data: string, rootUrl: string): boolean;
- loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
- /**
- * Read the OBJ file and create an Array of meshes.
- * Each mesh contains all information given by the OBJ and the MTL file.
- * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
- *
- * @param meshesNames
- * @param scene BABYLON.Scene The scene where are displayed the data
- * @param data String The content of the obj file
- * @param rootUrl String The path to the folder
- * @returns Array<AbstractMesh>
- * @private
- */
- private _parseSolid(meshesNames, scene, data, rootUrl);
- }
- }
- 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<ArrayBufferView>;
- }
- interface IGLTFLoaderExtension {
- /**
- * The name of this extension.
- */
- readonly name: string;
- /**
- * Whether this extension is enabled.
- */
- enabled: boolean;
- }
- enum GLTFLoaderState {
- Loading = 0,
- Ready = 1,
- Complete = 2,
- }
- interface IGLTFLoader extends IDisposable {
- coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
- animationStartMode: GLTFLoaderAnimationStartMode;
- compileMaterials: boolean;
- useClipPlane: boolean;
- compileShadowGenerators: boolean;
- onMeshLoadedObservable: Observable<AbstractMesh>;
- onTextureLoadedObservable: Observable<BaseTexture>;
- onMaterialLoadedObservable: Observable<Material>;
- onCompleteObservable: Observable<IGLTFLoader>;
- onDisposeObservable: Observable<IGLTFLoader>;
- onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
- state: Nullable<GLTFLoaderState>;
- importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void) => Promise<{
- meshes: AbstractMesh[];
- particleSystems: ParticleSystem[];
- skeletons: Skeleton[];
- }>;
- loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void) => Promise<void>;
- }
- 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<IGLTFLoaderData>;
- 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<AbstractMesh>;
- private _onMeshLoadedObserver;
- onMeshLoaded: (mesh: AbstractMesh) => void;
- /**
- * Raised when the loader creates a texture after parsing the glTF properties of the texture.
- */
- readonly onTextureLoadedObservable: Observable<BaseTexture>;
- private _onTextureLoadedObserver;
- onTextureLoaded: (Texture: BaseTexture) => void;
- /**
- * Raised when the loader creates a material after parsing the glTF properties of the material.
- */
- readonly onMaterialLoadedObservable: Observable<Material>;
- 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 onSuccess.
- */
- readonly onCompleteObservable: Observable<GLTFFileLoader>;
- private _onCompleteObserver;
- onComplete: () => void;
- /**
- * Raised when the loader is disposed.
- */
- readonly onDisposeObservable: Observable<GLTFFileLoader>;
- private _onDisposeObserver;
- onDispose: () => void;
- /**
- * Raised after a loader extension is created.
- * Set additional options for a loader extension in this event.
- */
- readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
- private _onExtensionLoadedObserver;
- onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
- /**
- * The loader state or null if not active.
- */
- readonly loaderState: Nullable<GLTFLoaderState>;
- 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[];
- }>;
- loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
- loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<AssetContainer>;
- 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.GLTF1 {
- /**
- * Enums
- */
- enum EComponentType {
- BYTE = 5120,
- UNSIGNED_BYTE = 5121,
- SHORT = 5122,
- UNSIGNED_SHORT = 5123,
- FLOAT = 5126,
- }
- enum EShaderType {
- FRAGMENT = 35632,
- VERTEX = 35633,
- }
- enum EParameterType {
- BYTE = 5120,
- UNSIGNED_BYTE = 5121,
- SHORT = 5122,
- UNSIGNED_SHORT = 5123,
- INT = 5124,
- UNSIGNED_INT = 5125,
- FLOAT = 5126,
- FLOAT_VEC2 = 35664,
- FLOAT_VEC3 = 35665,
- FLOAT_VEC4 = 35666,
- INT_VEC2 = 35667,
- INT_VEC3 = 35668,
- INT_VEC4 = 35669,
- BOOL = 35670,
- BOOL_VEC2 = 35671,
- BOOL_VEC3 = 35672,
- BOOL_VEC4 = 35673,
- FLOAT_MAT2 = 35674,
- FLOAT_MAT3 = 35675,
- FLOAT_MAT4 = 35676,
- SAMPLER_2D = 35678,
- }
- enum ETextureWrapMode {
- CLAMP_TO_EDGE = 33071,
- MIRRORED_REPEAT = 33648,
- REPEAT = 10497,
- }
- enum ETextureFilterType {
- NEAREST = 9728,
- LINEAR = 9728,
- NEAREST_MIPMAP_NEAREST = 9984,
- LINEAR_MIPMAP_NEAREST = 9985,
- NEAREST_MIPMAP_LINEAR = 9986,
- LINEAR_MIPMAP_LINEAR = 9987,
- }
- enum ETextureFormat {
- ALPHA = 6406,
- RGB = 6407,
- RGBA = 6408,
- LUMINANCE = 6409,
- LUMINANCE_ALPHA = 6410,
- }
- enum ECullingType {
- FRONT = 1028,
- BACK = 1029,
- FRONT_AND_BACK = 1032,
- }
- enum EBlendingFunction {
- ZERO = 0,
- ONE = 1,
- SRC_COLOR = 768,
- ONE_MINUS_SRC_COLOR = 769,
- DST_COLOR = 774,
- ONE_MINUS_DST_COLOR = 775,
- SRC_ALPHA = 770,
- ONE_MINUS_SRC_ALPHA = 771,
- DST_ALPHA = 772,
- ONE_MINUS_DST_ALPHA = 773,
- CONSTANT_COLOR = 32769,
- ONE_MINUS_CONSTANT_COLOR = 32770,
- CONSTANT_ALPHA = 32771,
- ONE_MINUS_CONSTANT_ALPHA = 32772,
- SRC_ALPHA_SATURATE = 776,
- }
- /**
- * Interfaces
- */
- interface IGLTFProperty {
- extensions?: {
- [key: string]: any;
- };
- extras?: Object;
- }
- interface IGLTFChildRootProperty extends IGLTFProperty {
- name?: string;
- }
- interface IGLTFAccessor extends IGLTFChildRootProperty {
- bufferView: string;
- byteOffset: number;
- byteStride: number;
- count: number;
- type: string;
- componentType: EComponentType;
- max?: number[];
- min?: number[];
- name?: string;
- }
- interface IGLTFBufferView extends IGLTFChildRootProperty {
- buffer: string;
- byteOffset: number;
- byteLength: number;
- byteStride: number;
- target?: number;
- }
- interface IGLTFBuffer extends IGLTFChildRootProperty {
- uri: string;
- byteLength?: number;
- type?: string;
- }
- interface IGLTFShader extends IGLTFChildRootProperty {
- uri: string;
- type: EShaderType;
- }
- interface IGLTFProgram extends IGLTFChildRootProperty {
- attributes: string[];
- fragmentShader: string;
- vertexShader: string;
- }
- interface IGLTFTechniqueParameter {
- type: number;
- count?: number;
- semantic?: string;
- node?: string;
- value?: number | boolean | string | Array<any>;
- source?: string;
- babylonValue?: any;
- }
- interface IGLTFTechniqueCommonProfile {
- lightingModel: string;
- texcoordBindings: Object;
- parameters?: Array<any>;
- }
- interface IGLTFTechniqueStatesFunctions {
- blendColor?: number[];
- blendEquationSeparate?: number[];
- blendFuncSeparate?: number[];
- colorMask: boolean[];
- cullFace: number[];
- }
- interface IGLTFTechniqueStates {
- enable: number[];
- functions: IGLTFTechniqueStatesFunctions;
- }
- interface IGLTFTechnique extends IGLTFChildRootProperty {
- parameters: {
- [key: string]: IGLTFTechniqueParameter;
- };
- program: string;
- attributes: {
- [key: string]: string;
- };
- uniforms: {
- [key: string]: string;
- };
- states: IGLTFTechniqueStates;
- }
- interface IGLTFMaterial extends IGLTFChildRootProperty {
- technique?: string;
- values: string[];
- }
- interface IGLTFMeshPrimitive extends IGLTFProperty {
- attributes: {
- [key: string]: string;
- };
- indices: string;
- material: string;
- mode?: number;
- }
- interface IGLTFMesh extends IGLTFChildRootProperty {
- primitives: IGLTFMeshPrimitive[];
- }
- interface IGLTFImage extends IGLTFChildRootProperty {
- uri: string;
- }
- interface IGLTFSampler extends IGLTFChildRootProperty {
- magFilter?: number;
- minFilter?: number;
- wrapS?: number;
- wrapT?: number;
- }
- interface IGLTFTexture extends IGLTFChildRootProperty {
- sampler: string;
- source: string;
- format?: ETextureFormat;
- internalFormat?: ETextureFormat;
- target?: number;
- type?: number;
- babylonTexture?: Texture;
- }
- interface IGLTFAmbienLight {
- color?: number[];
- }
- interface IGLTFDirectionalLight {
- color?: number[];
- }
- interface IGLTFPointLight {
- color?: number[];
- constantAttenuation?: number;
- linearAttenuation?: number;
- quadraticAttenuation?: number;
- }
- interface IGLTFSpotLight {
- color?: number[];
- constantAttenuation?: number;
- fallOfAngle?: number;
- fallOffExponent?: number;
- linearAttenuation?: number;
- quadraticAttenuation?: number;
- }
- interface IGLTFLight extends IGLTFChildRootProperty {
- type: string;
- }
- interface IGLTFCameraOrthographic {
- xmag: number;
- ymag: number;
- zfar: number;
- znear: number;
- }
- interface IGLTFCameraPerspective {
- aspectRatio: number;
- yfov: number;
- zfar: number;
- znear: number;
- }
- interface IGLTFCamera extends IGLTFChildRootProperty {
- type: string;
- }
- interface IGLTFAnimationChannelTarget {
- id: string;
- path: string;
- }
- interface IGLTFAnimationChannel {
- sampler: string;
- target: IGLTFAnimationChannelTarget;
- }
- interface IGLTFAnimationSampler {
- input: string;
- output: string;
- interpolation?: string;
- }
- interface IGLTFAnimation extends IGLTFChildRootProperty {
- channels?: IGLTFAnimationChannel[];
- parameters?: {
- [key: string]: string;
- };
- samplers?: {
- [key: string]: IGLTFAnimationSampler;
- };
- }
- interface IGLTFNodeInstanceSkin {
- skeletons: string[];
- skin: string;
- meshes: string[];
- }
- interface IGLTFSkins extends IGLTFChildRootProperty {
- bindShapeMatrix: number[];
- inverseBindMatrices: string;
- jointNames: string[];
- babylonSkeleton?: Skeleton;
- }
- interface IGLTFNode extends IGLTFChildRootProperty {
- camera?: string;
- children: string[];
- skin?: string;
- jointName?: string;
- light?: string;
- matrix: number[];
- mesh?: string;
- meshes?: string[];
- rotation?: number[];
- scale?: number[];
- translation?: number[];
- babylonNode?: Node;
- }
- interface IGLTFScene extends IGLTFChildRootProperty {
- nodes: string[];
- }
- /**
- * Runtime
- */
- interface IGLTFRuntime {
- extensions: {
- [key: string]: any;
- };
- accessors: {
- [key: string]: IGLTFAccessor;
- };
- buffers: {
- [key: string]: IGLTFBuffer;
- };
- bufferViews: {
- [key: string]: IGLTFBufferView;
- };
- meshes: {
- [key: string]: IGLTFMesh;
- };
- lights: {
- [key: string]: IGLTFLight;
- };
- cameras: {
- [key: string]: IGLTFCamera;
- };
- nodes: {
- [key: string]: IGLTFNode;
- };
- images: {
- [key: string]: IGLTFImage;
- };
- textures: {
- [key: string]: IGLTFTexture;
- };
- shaders: {
- [key: string]: IGLTFShader;
- };
- programs: {
- [key: string]: IGLTFProgram;
- };
- samplers: {
- [key: string]: IGLTFSampler;
- };
- techniques: {
- [key: string]: IGLTFTechnique;
- };
- materials: {
- [key: string]: IGLTFMaterial;
- };
- animations: {
- [key: string]: IGLTFAnimation;
- };
- skins: {
- [key: string]: IGLTFSkins;
- };
- currentScene?: Object;
- scenes: {
- [key: string]: IGLTFScene;
- };
- extensionsUsed: string[];
- extensionsRequired?: string[];
- buffersCount: number;
- shaderscount: number;
- scene: Scene;
- rootUrl: string;
- loadedBufferCount: number;
- loadedBufferViews: {
- [name: string]: ArrayBufferView;
- };
- loadedShaderCount: number;
- importOnlyMeshes: boolean;
- importMeshesNames?: string[];
- dummyNodes: Node[];
- }
- /**
- * Bones
- */
- interface INodeToRoot {
- bone: Bone;
- node: IGLTFNode;
- id: string;
- }
- interface IJointNode {
- node: IGLTFNode;
- id: string;
- }
- }
- declare module BABYLON.GLTF1 {
- /**
- * Implementation of the base glTF spec
- */
- 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) => void, onError: (message: string) => void): void;
- static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
- }
- /**
- * glTF V1 Loader
- */
- class GLTFLoader implements IGLTFLoader {
- static Extensions: {
- [name: string]: GLTFLoaderExtension;
- };
- static RegisterExtension(extension: GLTFLoaderExtension): void;
- coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
- animationStartMode: GLTFLoaderAnimationStartMode;
- compileMaterials: boolean;
- useClipPlane: boolean;
- compileShadowGenerators: boolean;
- onDisposeObservable: Observable<IGLTFLoader>;
- onMeshLoadedObservable: Observable<AbstractMesh>;
- onTextureLoadedObservable: Observable<BaseTexture>;
- onMaterialLoadedObservable: Observable<Material>;
- onCompleteObservable: Observable<IGLTFLoader>;
- onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
- state: Nullable<GLTFLoaderState>;
- dispose(): void;
- private _importMeshAsync(meshesNames, scene, data, rootUrl, onSuccess, onProgress, onError);
- importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress: (event: SceneLoaderProgressEvent) => void): Promise<{
- meshes: AbstractMesh[];
- particleSystems: ParticleSystem[];
- skeletons: Skeleton[];
- }>;
- private _loadAsync(scene, data, rootUrl, onSuccess, onProgress, onError);
- loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress: (event: SceneLoaderProgressEvent) => void): Promise<void>;
- private _loadShadersAsync(gltfRuntime, onload);
- private _loadBuffersAsync(gltfRuntime, onLoad, onProgress?);
- private _createNodes(gltfRuntime);
- }
- }
- declare module BABYLON.GLTF1 {
- /**
- * Utils functions for GLTF
- */
- class GLTFUtils {
- /**
- * Sets the given "parameter" matrix
- * @param scene: the {BABYLON.Scene} object
- * @param source: the source node where to pick the matrix
- * @param parameter: the GLTF technique parameter
- * @param uniformName: the name of the shader's uniform
- * @param shaderMaterial: the shader material
- */
- static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
- /**
- * Sets the given "parameter" matrix
- * @param shaderMaterial: the shader material
- * @param uniform: the name of the shader's uniform
- * @param value: the value of the uniform
- * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
- */
- static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
- /**
- * Returns the wrap mode of the texture
- * @param mode: the mode value
- */
- static GetWrapMode(mode: number): number;
- /**
- * Returns the byte stride giving an accessor
- * @param accessor: the GLTF accessor objet
- */
- static GetByteStrideFromType(accessor: IGLTFAccessor): number;
- /**
- * Returns the texture filter mode giving a mode value
- * @param mode: the filter mode value
- */
- static GetTextureFilterMode(mode: number): ETextureFilterType;
- static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
- /**
- * Returns a buffer from its accessor
- * @param gltfRuntime: the GLTF runtime
- * @param accessor: the GLTF accessor
- */
- static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
- /**
- * Decodes a buffer view into a string
- * @param view: the buffer view
- */
- static DecodeBufferToText(view: ArrayBufferView): string;
- /**
- * Returns the default material of gltf. Related to
- * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
- * @param scene: the Babylon.js scene
- */
- static GetDefaultMaterial(scene: Scene): ShaderMaterial;
- private static _DefaultMaterial;
- }
- }
- declare module BABYLON.GLTF1 {
- 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) => void, onError: (message: string) => void): void;
- static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
- private static LoadTextureBufferAsync(gltfRuntime, id, onSuccess, onError);
- private static CreateTextureAsync(gltfRuntime, id, buffer, onSuccess, onError);
- private static ApplyExtensions(func, defaultFunc);
- }
- }
- declare module BABYLON.GLTF1 {
- class GLTFBinaryExtension extends GLTFLoaderExtension {
- private _bin;
- constructor();
- loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
- loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
- loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
- loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
- }
- }
- declare module BABYLON.GLTF1 {
- class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
- constructor();
- loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
- loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
- private _loadTexture(gltfRuntime, id, material, propertyPath, onError);
- }
- }
- declare module BABYLON.GLTF2 {
- interface TypedArray extends ArrayBufferView {
- [index: number]: number;
- }
- interface IArrayItem {
- _index: number;
- }
- class ArrayItem {
- static Assign(values?: IArrayItem[]): void;
- }
- }
- declare module BABYLON.GLTF2 {
- interface ILoaderAccessor extends IAccessor, IArrayItem {
- _data?: Promise<TypedArray>;
- }
- interface ILoaderAnimationChannel extends IAnimationChannel, IArrayItem {
- _babylonAnimationGroup: AnimationGroup;
- }
- interface ILoaderAnimationSamplerData {
- input: Float32Array;
- interpolation: AnimationSamplerInterpolation;
- output: Float32Array;
- }
- interface ILoaderAnimationSampler extends IAnimationSampler, IArrayItem {
- _data: Promise<ILoaderAnimationSamplerData>;
- }
- interface ILoaderAnimation extends IAnimation, IArrayItem {
- channels: ILoaderAnimationChannel[];
- samplers: ILoaderAnimationSampler[];
- _babylonAnimationGroup: Nullable<AnimationGroup>;
- }
- interface ILoaderBuffer extends IBuffer, IArrayItem {
- _data?: Promise<ArrayBufferView>;
- }
- interface ILoaderBufferView extends IBufferView, IArrayItem {
- _data?: Promise<ArrayBufferView>;
- }
- interface ILoaderCamera extends ICamera, IArrayItem {
- }
- interface ILoaderImage extends IImage, IArrayItem {
- _objectURL?: Promise<string>;
- }
- interface ILoaderMaterial extends IMaterial, IArrayItem {
- _babylonMaterial?: Material;
- _babylonMeshes?: AbstractMesh[];
- _loaded?: Promise<void>;
- }
- 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: Nullable<Skeleton>;
- _loaded?: Promise<void>;
- }
- 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 {
- class GLTFLoader implements IGLTFLoader {
- _gltf: ILoaderGLTF;
- _babylonScene: Scene;
- _completePromises: Promise<void>[];
- private _disposed;
- private _state;
- private _extensions;
- private _rootUrl;
- private _rootBabylonMesh;
- private _defaultSampler;
- 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<IGLTFLoader>;
- readonly onMeshLoadedObservable: Observable<AbstractMesh>;
- readonly onTextureLoadedObservable: Observable<BaseTexture>;
- readonly onMaterialLoadedObservable: Observable<Material>;
- readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
- readonly onCompleteObservable: Observable<IGLTFLoader>;
- readonly state: Nullable<GLTFLoaderState>;
- dispose(): void;
- importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
- meshes: AbstractMesh[];
- particleSystems: ParticleSystem[];
- skeletons: Skeleton[];
- }>;
- loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
- private _loadAsync(nodes, scene, data, rootUrl, onProgress?);
- private _loadExtensions();
- private _loadData(data);
- private _setupData();
- private _createRootNode();
- private _loadNodesAsync(nodes);
- _loadSceneAsync(context: string, scene: ILoaderScene): Promise<void>;
- private _getMeshes();
- private _getSkeletons();
- private _startAnimations();
- _loadNodeAsync(context: string, node: ILoaderNode): Promise<void>;
- private _loadMeshAsync(context, node, mesh);
- private _loadPrimitiveAsync(context, node, mesh, primitive);
- private _loadVertexDataAsync(context, primitive, babylonMesh);
- private _createMorphTargets(context, node, mesh, primitive, babylonMesh);
- private _loadMorphTargetsAsync(context, primitive, babylonMesh, babylonVertexData);
- private _loadMorphTargetVertexDataAsync(context, babylonVertexData, attributes, babylonMorphTarget);
- private static _ConvertToFloat32Array(context, accessor, data);
- private static _ConvertVec3ToVec4(context, data);
- 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<ArrayBufferView>;
- private _loadAccessorAsync(context, accessor);
- private _buildArrayBuffer<T>(typedArray, data, byteOffset, count, numComponents, byteStride?);
- private _getDefaultMaterial();
- private _loadMaterialMetallicRoughnessPropertiesAsync(context, material);
- _loadMaterialAsync(context: string, material: ILoaderMaterial, babylonMesh: Mesh): Promise<void>;
- _createMaterial(material: ILoaderMaterial): PBRMaterial;
- _loadMaterialBasePropertiesAsync(context: string, material: ILoaderMaterial): Promise<void>;
- _loadMaterialAlphaProperties(context: string, material: ILoaderMaterial): void;
- _loadTextureAsync(context: string, textureInfo: ITextureInfo, assign: (texture: Texture) => void): Promise<void>;
- private _loadSampler(context, sampler);
- private _loadImageAsync(context, image);
- _loadUriAsync(context: string, uri: string): Promise<ArrayBufferView>;
- private _onProgress();
- static _GetProperty<T>(context: string, array: ArrayLike<T> | 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 _compileMaterialsAsync();
- private _compileShadowGeneratorsAsync();
- private _clear();
- _applyExtensions<T>(actionAsync: (extension: GLTFLoaderExtension) => Nullable<Promise<T>>): Nullable<Promise<T>>;
- }
- }
- declare module BABYLON.GLTF2 {
- abstract class GLTFLoaderExtension implements IGLTFLoaderExtension {
- enabled: boolean;
- readonly abstract name: string;
- protected _loader: GLTFLoader;
- constructor(loader: GLTFLoader);
- /** Override this method to modify the default behavior for loading scenes. */
- protected _loadSceneAsync(context: string, node: ILoaderScene): Nullable<Promise<void>>;
- /** Override this method to modify the default behavior for loading nodes. */
- protected _loadNodeAsync(context: string, node: ILoaderNode): Nullable<Promise<void>>;
- /** Override this method to modify the default behavior for loading mesh primitive vertex data. */
- protected _loadVertexDataAsync(context: string, primitive: ILoaderMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<VertexData>>;
- /** Override this method to modify the default behavior for loading materials. */
- protected _loadMaterialAsync(context: string, material: ILoaderMaterial, babylonMesh: Mesh): Nullable<Promise<void>>;
- /** Override this method to modify the default behavior for loading uris. */
- protected _loadUriAsync(context: string, uri: string): Nullable<Promise<ArrayBufferView>>;
- /** Helper method called by a loader extension to load an glTF extension. */
- protected _loadExtensionAsync<TProperty, TResult = void>(context: string, property: IProperty, actionAsync: (context: string, extension: TProperty) => Promise<TResult>): Nullable<Promise<TResult>>;
- /** Helper method called by the loader to allow extensions to override loading scenes. */
- static _LoadSceneAsync(loader: GLTFLoader, context: string, scene: ILoaderScene): Nullable<Promise<void>>;
- /** Helper method called by the loader to allow extensions to override loading nodes. */
- static _LoadNodeAsync(loader: GLTFLoader, context: string, node: ILoaderNode): Nullable<Promise<void>>;
- /** 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<Promise<VertexData>>;
- /** Helper method called by the loader to allow extensions to override loading materials. */
- static _LoadMaterialAsync(loader: GLTFLoader, context: string, material: ILoaderMaterial, babylonMesh: Mesh): Nullable<Promise<void>>;
- /** Helper method called by the loader to allow extensions to override loading uris. */
- static _LoadUriAsync(loader: GLTFLoader, context: string, uri: string): Nullable<Promise<ArrayBufferView>>;
- }
- }
- 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<Promise<void>>;
- protected _loadMaterialAsync(context: string, material: ILoaderMaterial, babylonMesh: Mesh): Nullable<Promise<void>>;
- protected _loadUriAsync(context: string, uri: string): Nullable<Promise<ArrayBufferView>>;
- /**
- * Gets an array of LOD properties from lowest to highest.
- */
- private _getLODs<T>(context, property, array, ids);
- }
- }
- declare module BABYLON.GLTF2.Extensions {
- class KHR_draco_mesh_compression extends GLTFLoaderExtension {
- readonly name: string;
- protected _loadVertexDataAsync(context: string, primitive: ILoaderMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<VertexData>>;
- }
- }
- declare module BABYLON.GLTF2.Extensions {
- class KHR_materials_pbrSpecularGlossiness extends GLTFLoaderExtension {
- readonly name: string;
- protected _loadMaterialAsync(context: string, material: ILoaderMaterial, babylonMesh: Mesh): Nullable<Promise<void>>;
- private _loadSpecularGlossinessPropertiesAsync(loader, context, material, properties);
- }
- }
- declare module BABYLON.GLTF2.Extensions {
- class KHR_lights extends GLTFLoaderExtension {
- readonly name: string;
- protected _loadSceneAsync(context: string, scene: ILoaderScene): Nullable<Promise<void>>;
- protected _loadNodeAsync(context: string, node: ILoaderNode): Nullable<Promise<void>>;
- private readonly _lights;
- }
- }
|