12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211 |
- /// <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;
- 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;
- /**
- * 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 IGLTFLoader extends IDisposable {
- 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>;
- importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onProgress?: (event: SceneLoaderProgressEvent) => void, onError?: (message: string, exception?: any) => void) => void;
- loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: () => void, onProgress?: (event: SceneLoaderProgressEvent) => void, onError?: (message: string, exception?: any) => void) => 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.
- */
- onMeshLoadedObservable: Observable<AbstractMesh>;
- private _onMeshLoadedObserver;
- onMeshLoaded: (mesh: AbstractMesh) => void;
- /**
- * Raised when the loader creates a texture after parsing the glTF properties of the texture.
- */
- onTextureLoadedObservable: Observable<BaseTexture>;
- private _onTextureLoadedObserver;
- onTextureLoaded: (Texture: BaseTexture) => void;
- /**
- * Raised when the loader creates a material after parsing the glTF properties of the material.
- */
- 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.
- */
- onCompleteObservable: Observable<GLTFFileLoader>;
- private _onCompleteObserver;
- onComplete: () => void;
- /**
- * Raised when the loader is disposed.
- */
- onDisposeObservable: Observable<GLTFFileLoader>;
- private _onDisposeObserver;
- onDispose: () => void;
- 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, onSuccess?: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onProgress?: (event: SceneLoaderProgressEvent) => void, onError?: (message: string, exception?: any) => void): void;
- loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onSuccess?: () => void, onProgress?: (event: SceneLoaderProgressEvent) => void, onError?: (message: string, exception?: any) => void): void;
- 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>;
- dispose(): void;
- importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onProgress: (event: SceneLoaderProgressEvent) => void, onError: (message: string) => void): boolean;
- loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: () => void, onProgress: (event: SceneLoaderProgressEvent) => void, onError: (message: string) => void): 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;
- /**
- * If the uri is a base64 string
- * @param uri: the uri to test
- */
- static IsBase64(uri: string): boolean;
- /**
- * Decode the base64 uri
- * @param uri: the uri to decode
- */
- static DecodeBase64(uri: string): ArrayBuffer;
- /**
- * 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 {
- /**
- * Enums
- */
- enum EComponentType {
- BYTE = 5120,
- UNSIGNED_BYTE = 5121,
- SHORT = 5122,
- UNSIGNED_SHORT = 5123,
- UNSIGNED_INT = 5125,
- FLOAT = 5126,
- }
- enum EMeshPrimitiveMode {
- POINTS = 0,
- LINES = 1,
- LINE_LOOP = 2,
- LINE_STRIP = 3,
- TRIANGLES = 4,
- TRIANGLE_STRIP = 5,
- TRIANGLE_FAN = 6,
- }
- enum ETextureMagFilter {
- NEAREST = 9728,
- LINEAR = 9729,
- }
- enum ETextureMinFilter {
- NEAREST = 9728,
- LINEAR = 9729,
- NEAREST_MIPMAP_NEAREST = 9984,
- LINEAR_MIPMAP_NEAREST = 9985,
- NEAREST_MIPMAP_LINEAR = 9986,
- LINEAR_MIPMAP_LINEAR = 9987,
- }
- enum ETextureWrapMode {
- CLAMP_TO_EDGE = 33071,
- MIRRORED_REPEAT = 33648,
- REPEAT = 10497,
- }
- /**
- * Interfaces
- */
- interface IGLTFProperty {
- extensions?: {
- [key: string]: any;
- };
- extras?: any;
- }
- interface IGLTFChildRootProperty extends IGLTFProperty {
- name?: string;
- }
- interface IGLTFAccessorSparseIndices extends IGLTFProperty {
- bufferView: number;
- byteOffset?: number;
- componentType: EComponentType;
- }
- interface IGLTFAccessorSparseValues extends IGLTFProperty {
- bufferView: number;
- byteOffset?: number;
- }
- interface IGLTFAccessorSparse extends IGLTFProperty {
- count: number;
- indices: IGLTFAccessorSparseIndices;
- values: IGLTFAccessorSparseValues;
- }
- interface IGLTFAccessor extends IGLTFChildRootProperty {
- bufferView?: number;
- byteOffset?: number;
- componentType: EComponentType;
- normalized?: boolean;
- count: number;
- type: string;
- max: number[];
- min: number[];
- sparse?: IGLTFAccessorSparse;
- index: number;
- }
- interface IGLTFAnimationChannel extends IGLTFProperty {
- sampler: number;
- target: IGLTFAnimationChannelTarget;
- }
- interface IGLTFAnimationChannelTarget extends IGLTFProperty {
- node: number;
- path: string;
- }
- interface IGLTFAnimationSampler extends IGLTFProperty {
- input: number;
- interpolation?: string;
- output: number;
- }
- interface IGLTFAnimation extends IGLTFChildRootProperty {
- channels: IGLTFAnimationChannel[];
- samplers: IGLTFAnimationSampler[];
- index: number;
- targets: any[];
- }
- interface IGLTFAsset extends IGLTFChildRootProperty {
- copyright?: string;
- generator?: string;
- version: string;
- minVersion?: string;
- }
- interface IGLTFBuffer extends IGLTFChildRootProperty {
- uri?: string;
- byteLength: number;
- index: number;
- loadedData?: ArrayBufferView;
- loadedObservable?: Observable<IGLTFBuffer>;
- }
- interface IGLTFBufferView extends IGLTFChildRootProperty {
- buffer: number;
- byteOffset?: number;
- byteLength: number;
- byteStride?: number;
- index: number;
- }
- interface IGLTFCameraOrthographic extends IGLTFProperty {
- xmag: number;
- ymag: number;
- zfar: number;
- znear: number;
- }
- interface IGLTFCameraPerspective extends IGLTFProperty {
- aspectRatio: number;
- yfov: number;
- zfar: number;
- znear: number;
- }
- interface IGLTFCamera extends IGLTFChildRootProperty {
- orthographic?: IGLTFCameraOrthographic;
- perspective?: IGLTFCameraPerspective;
- type: string;
- }
- interface IGLTFImage extends IGLTFChildRootProperty {
- uri?: string;
- mimeType?: string;
- bufferView?: number;
- index: number;
- }
- interface IGLTFMaterialNormalTextureInfo extends IGLTFTextureInfo {
- scale: number;
- }
- interface IGLTFMaterialOcclusionTextureInfo extends IGLTFTextureInfo {
- strength: number;
- }
- interface IGLTFMaterialPbrMetallicRoughness {
- baseColorFactor: number[];
- baseColorTexture: IGLTFTextureInfo;
- metallicFactor: number;
- roughnessFactor: number;
- metallicRoughnessTexture: IGLTFTextureInfo;
- }
- interface IGLTFMaterial extends IGLTFChildRootProperty {
- pbrMetallicRoughness?: IGLTFMaterialPbrMetallicRoughness;
- normalTexture?: IGLTFMaterialNormalTextureInfo;
- occlusionTexture?: IGLTFMaterialOcclusionTextureInfo;
- emissiveTexture?: IGLTFTextureInfo;
- emissiveFactor?: number[];
- alphaMode?: string;
- alphaCutoff: number;
- doubleSided?: boolean;
- index: number;
- babylonMaterial: Material;
- }
- interface IGLTFMeshPrimitive extends IGLTFProperty {
- attributes: {
- [name: string]: number;
- };
- indices?: number;
- material?: number;
- mode?: EMeshPrimitiveMode;
- targets?: {
- [name: string]: number;
- }[];
- vertexData: VertexData;
- targetsVertexData: VertexData[];
- }
- interface IGLTFMesh extends IGLTFChildRootProperty {
- primitives: IGLTFMeshPrimitive[];
- weights?: number[];
- index: number;
- hasVertexAlpha: boolean;
- }
- interface IGLTFNode extends IGLTFChildRootProperty {
- camera?: number;
- children?: number[];
- skin?: number;
- matrix?: number[];
- mesh?: number;
- rotation?: number[];
- scale?: number[];
- translation?: number[];
- weights?: number[];
- index: number;
- parent: IGLTFNode;
- babylonMesh: Mesh;
- babylonAnimationTargets?: Node[];
- }
- interface IGLTFSampler extends IGLTFChildRootProperty {
- magFilter?: ETextureMagFilter;
- minFilter?: ETextureMinFilter;
- wrapS?: ETextureWrapMode;
- wrapT?: ETextureWrapMode;
- index: number;
- noMipMaps: boolean;
- samplingMode: number;
- wrapU: number;
- wrapV: number;
- }
- interface IGLTFScene extends IGLTFChildRootProperty {
- nodes: number[];
- index: number;
- }
- interface IGLTFSkin extends IGLTFChildRootProperty {
- inverseBindMatrices?: number;
- skeleton?: number;
- joints: number[];
- index: number;
- babylonSkeleton: Skeleton;
- }
- interface IGLTFTexture extends IGLTFChildRootProperty {
- sampler?: number;
- source: number;
- index: number;
- url?: string;
- dataReadyObservable?: Observable<IGLTFTexture>;
- }
- interface IGLTFTextureInfo {
- index: number;
- texCoord?: number;
- }
- interface IGLTF extends IGLTFProperty {
- accessors?: IGLTFAccessor[];
- animations?: IGLTFAnimation[];
- asset: IGLTFAsset;
- buffers?: IGLTFBuffer[];
- bufferViews?: IGLTFBufferView[];
- cameras?: IGLTFCamera[];
- extensionsUsed?: string[];
- extensionsRequired?: string[];
- images?: IGLTFImage[];
- materials?: IGLTFMaterial[];
- meshes?: IGLTFMesh[];
- nodes?: IGLTFNode[];
- samplers?: IGLTFSampler[];
- scene?: number;
- scenes?: IGLTFScene[];
- skins?: IGLTFSkin[];
- textures?: IGLTFTexture[];
- }
- }
- declare module BABYLON.GLTF2 {
- class GLTFLoader implements IGLTFLoader {
- _gltf: IGLTF;
- _babylonScene: Scene;
- private _disposed;
- private _rootUrl;
- private _defaultMaterial;
- private _defaultSampler;
- private _rootNode;
- private _successCallback?;
- private _progressCallback?;
- private _errorCallback?;
- private _renderReady;
- private _requests;
- private _renderReadyObservable;
- private _renderPendingCount;
- private _loaderPendingCount;
- private _loaderTrackers;
- 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>;
- dispose(): void;
- importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onProgress?: (event: SceneLoaderProgressEvent) => void, onError?: (message: string, exception?: any) => void): void;
- loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: () => void, onProgress?: (event: SceneLoaderProgressEvent) => void, onError?: (message: string, exception?: any) => void): void;
- private _loadAsync(nodeNames, scene, data, rootUrl, onSuccess?, onProgress?, onError?);
- private _onProgress();
- _executeWhenRenderReady(func: () => void): void;
- private _onRenderReady();
- private _onComplete();
- private _loadData(data);
- private _getMeshes();
- private _getSkeletons();
- private _startAnimations();
- private _loadDefaultScene(nodeNames);
- private _loadScene(context, scene, nodeNames);
- _loadNode(context: string, node: IGLTFNode): void;
- private _loadMesh(context, node, mesh);
- private _loadAllVertexDataAsync(context, mesh, onSuccess);
- /**
- * Converts a data bufferview into a Float4 Texture Coordinate Array, based on the accessor component type
- * @param {ArrayBufferView} data
- * @param {IGLTFAccessor} accessor
- */
- private _convertToFloat4TextureCoordArray(context, data, accessor);
- /**
- * Converts a data bufferview into a Float4 Color Array, based on the accessor component type
- * @param {ArrayBufferView} data
- * @param {IGLTFAccessor} accessor
- */
- private _convertToFloat4ColorArray(context, data, accessor);
- private _loadVertexDataAsync(context, mesh, primitive, onSuccess);
- private _createMorphTargets(context, node, mesh);
- private _loadMorphTargets(context, node, mesh);
- private _loadAllMorphTargetVertexDataAsync(context, node, mesh, onSuccess);
- private _loadMorphTargetVertexDataAsync(context, vertexData, attributes, onSuccess);
- private _loadTransform(node);
- private _loadSkinAsync(context, skin, onSuccess);
- private _createBone(node, skin, parent, localMatrix, baseMatrix, index);
- private _loadBones(context, skin, inverseBindMatrixData);
- private _loadBone(node, skin, inverseBindMatrixData, babylonBones);
- private _getNodeMatrix(node);
- private _traverseNodes(context, indices, action, parentNode);
- _traverseNode(context: string, node: IGLTFNode, action: (node: IGLTFNode, parentNode: IGLTFNode) => boolean, parentNode: IGLTFNode): void;
- private _loadAnimations();
- private _loadAnimation(context, animation);
- private _loadAnimationChannel(animation, channelContext, channel, samplerContext, sampler);
- private _loadBufferAsync(context, buffer, onSuccess);
- private _loadBufferViewAsync(context, bufferView, onSuccess);
- private _loadAccessorAsync(context, accessor, onSuccess);
- private _buildArrayBuffer<T>(typedArray, data, byteOffset, count, numComponents, byteStride?);
- _addPendingData(data: any): void;
- _removePendingData(data: any): void;
- _addLoaderPendingData(data: any): void;
- _removeLoaderPendingData(data: any): void;
- _whenAction(action: () => void, onComplete: () => void): void;
- private _getDefaultMaterial();
- private _loadMaterialMetallicRoughnessProperties(context, material);
- _loadMaterial(context: string, material: IGLTFMaterial, assign: (babylonMaterial: Material, isNew: boolean) => void): void;
- _createPbrMaterial(material: IGLTFMaterial): void;
- _loadMaterialBaseProperties(context: string, material: IGLTFMaterial): void;
- _loadMaterialAlphaProperties(context: string, material: IGLTFMaterial, colorFactor: number[]): void;
- _loadTexture(context: string, texture: IGLTFTexture, coordinatesIndex?: number): Texture;
- private _loadSampler(context, sampler);
- private _loadImageAsync(context, image, onSuccess);
- _loadUriAsync(context: string, uri: string, onSuccess: (data: ArrayBufferView) => void): void;
- _tryCatchOnError(handler: () => void): void;
- private static _AssignIndices(array?);
- static _GetProperty<T extends IGLTFProperty>(array?: ArrayLike<T>, index?: number): Nullable<T>;
- private static _GetTextureWrapMode(context, mode?);
- private static _GetTextureSamplingMode(context, magFilter?, minFilter?);
- private static _GetNumComponents(context, type);
- private _compileMaterialAsync(babylonMaterial, babylonMesh, onSuccess);
- private _compileMaterialsAsync(onSuccess);
- private _compileShadowGeneratorsAsync(onSuccess);
- private _abortRequests();
- private _releaseResources();
- }
- }
- declare module BABYLON.GLTF2 {
- /**
- * Utils functions for GLTF
- */
- class GLTFUtils {
- /**
- * If the uri is a base64 string
- * @param uri: the uri to test
- */
- static IsBase64(uri: string): boolean;
- /**
- * Decode the base64 uri
- * @param uri: the uri to decode
- */
- static DecodeBase64(uri: string): ArrayBuffer;
- static ValidateUri(uri: string): boolean;
- }
- }
- declare module BABYLON.GLTF2 {
- abstract class GLTFLoaderExtension {
- enabled: boolean;
- readonly abstract name: string;
- protected _traverseNode(loader: GLTFLoader, context: string, node: IGLTFNode, action: (node: IGLTFNode, parentNode: IGLTFNode) => boolean, parentNode: IGLTFNode): boolean;
- protected _loadNode(loader: GLTFLoader, context: string, node: IGLTFNode): boolean;
- protected _loadMaterial(loader: GLTFLoader, context: string, material: IGLTFMaterial, assign: (babylonMaterial: Material, isNew: boolean) => void): boolean;
- protected _loadExtension<T>(context: string, property: IGLTFProperty, action: (context: string, extension: T, onComplete: () => void) => void): boolean;
- static _Extensions: GLTFLoaderExtension[];
- static TraverseNode(loader: GLTFLoader, context: string, node: IGLTFNode, action: (node: IGLTFNode, parentNode: IGLTFNode) => boolean, parentNode: IGLTFNode): boolean;
- static LoadNode(loader: GLTFLoader, context: string, node: IGLTFNode): boolean;
- static LoadMaterial(loader: GLTFLoader, context: string, material: IGLTFMaterial, assign: (babylonMaterial: Material, isNew: boolean) => void): boolean;
- private static _ApplyExtensions(action);
- }
- }
- declare module BABYLON.GLTF2.Extensions {
- class MSFTLOD extends GLTFLoaderExtension {
- /**
- * Specify the minimal delay between LODs in ms (default = 250)
- */
- Delay: number;
- readonly name: string;
- protected _traverseNode(loader: GLTFLoader, context: string, node: IGLTFNode, action: (node: IGLTFNode, parentNode: IGLTFNode) => boolean, parentNode: IGLTFNode): boolean;
- protected _loadNode(loader: GLTFLoader, context: string, node: IGLTFNode): boolean;
- private _loadNodeLOD(loader, context, nodes, index, onComplete);
- protected _loadMaterial(loader: GLTFLoader, context: string, material: IGLTFMaterial, assign: (babylonMaterial: Material, isNew: boolean) => void): boolean;
- private _loadMaterialLOD(loader, context, materials, index, assign, onComplete);
- }
- }
- declare module BABYLON.GLTF2.Extensions {
- class KHRMaterialsPbrSpecularGlossiness extends GLTFLoaderExtension {
- readonly name: string;
- protected _loadMaterial(loader: GLTFLoader, context: string, material: IGLTFMaterial, assign: (babylonMaterial: Material, isNew: boolean) => void): boolean;
- private _loadSpecularGlossinessProperties(loader, context, material, properties);
- }
- }
|