declare module BABYLON { interface IGLTFLoaderData { json: Object; bin: ArrayBufferView; } interface IGLTFLoader { importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onError: () => void) => void; loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: () => void, onError: () => void) => void; } class GLTFFileLoader implements ISceneLoaderPluginAsync { static CreateGLTFLoaderV1: (parent: GLTFFileLoader) => IGLTFLoader; static CreateGLTFLoaderV2: (parent: GLTFFileLoader) => IGLTFLoader; static HomogeneousCoordinates: boolean; static IncrementalLoading: boolean; onTextureLoaded: (texture: BaseTexture) => void; onMaterialLoaded: (material: Material) => void; onComplete: () => void; extensions: ISceneLoaderPluginExtensions; importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onSuccess: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onError: () => void): void; loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onSuccess: () => void, onError: () => void): void; canDirectLoad(data: string): boolean; private static _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(view); } } 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?: Object; 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; } 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[]; targets?: any[]; } interface IGLTFAsset extends IGLTFChildRootProperty { copyright?: string; generator?: string; version: string; minVersion?: string; } interface IGLTFBuffer extends IGLTFChildRootProperty { uri?: string; byteLength: number; loadedData: ArrayBufferView; loadedObservable: Observable; } interface IGLTFBufferView extends IGLTFChildRootProperty { buffer: number; byteOffset?: number; byteLength: number; byteStride?: 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; } 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; }]; } interface IGLTFMesh extends IGLTFChildRootProperty { primitives: IGLTFMeshPrimitive[]; weights?: number[]; } 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; babylonSkinToBones?: { [skin: number]: Bone; }; babylonAnimationTargets?: Node[]; } interface IGLTFSampler extends IGLTFChildRootProperty { magFilter?: ETextureMagFilter; minFilter?: ETextureMinFilter; wrapS?: ETextureWrapMode; wrapT?: ETextureWrapMode; } interface IGLTFScene extends IGLTFChildRootProperty { nodes: number[]; } interface IGLTFSkin extends IGLTFChildRootProperty { inverseBindMatrices?: number; skeleton?: number; joints: number[]; index?: number; babylonSkeleton?: Skeleton; } interface IGLTFTexture extends IGLTFChildRootProperty { sampler?: number; source: number; babylonTextures?: Texture[]; blobURL?: string; } 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[]; glExtensionsUsed?: 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 { private _parent; private _gltf; private _errors; private _babylonScene; private _rootUrl; private _defaultMaterial; private _onSuccess; private _onError; private _succeeded; private _renderReady; private _renderReadyObservable; private _renderPendingCount; private _loaderPendingCount; static Extensions: { [name: string]: GLTFLoaderExtension; }; static RegisterExtension(extension: GLTFLoaderExtension): void; readonly gltf: IGLTF; readonly babylonScene: Scene; executeWhenRenderReady(func: (succeeded: boolean) => void): void; constructor(parent: GLTFFileLoader); importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onError: () => void): void; loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: () => void, onError: () => void): void; private _loadAsync(nodeNames, scene, data, rootUrl, onSuccess, onError); private _onRenderReady(); private _onLoaderComplete(); private _loadData(data); private _showMeshes(); private _startAnimations(); private _clear(); private _loadScene(nodeNames); private _loadSkin(node); private _updateBone(node, parentNode, skin, inverseBindMatrixData); private _createBone(node, skin); private _loadMesh(node); private _loadMeshData(node, mesh, babylonMesh); private _assignMaterial(multiMaterial, index, subMaterial); private _loadVertexDataAsync(primitive, onSuccess); private _createMorphTargets(node, mesh, primitive, babylonMesh); private _loadMorphTargetsData(mesh, primitive, vertexData, babylonMesh); private _loadTransform(node, babylonMesh); private _traverseNodes(indices, action, parentNode?); private _traverseNode(index, action, parentNode?); private _loadAnimations(); private _loadAnimationChannel(animation, animationIndex, channelIndex); private _loadBufferAsync(index, onSuccess); private _loadBufferViewAsync(bufferView, byteOffset, byteLength, componentType, onSuccess); private _loadAccessorAsync(accessor, onSuccess); addPendingData(data: any): void; removePendingData(data: any): void; addLoaderPendingData(data: any): void; removeLoaderPendingData(data: any): void; private _getDefaultMaterial(); private _loadMaterialMetallicRoughnessProperties(material); loadMaterial(index: number, assign: (material: Material) => void): void; createPbrMaterial(material: IGLTFMaterial): void; loadMaterialBaseProperties(material: IGLTFMaterial): void; loadMaterialAlphaProperties(material: IGLTFMaterial): void; loadTexture(textureInfo: IGLTFTextureInfo): Texture; } } 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 ForEach(view: Uint16Array | Uint32Array | Float32Array, func: (nvalue: number, index: number) => void): void; /** * 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): ETextureMinFilter; /** * Decodes a buffer view into a string * @param view: the buffer view */ static DecodeBufferToText(view: ArrayBufferView): string; } } declare module BABYLON.GLTF2 { abstract class GLTFLoaderExtension { enabled: boolean; readonly abstract name: string; protected loadMaterial(loader: GLTFLoader, material: IGLTFMaterial, assign: (material: Material) => void): boolean; static _Extensions: GLTFLoaderExtension[]; static LoadMaterial(loader: GLTFLoader, material: IGLTFMaterial, assign: (material: Material) => void): boolean; private static _ApplyExtensions(action); } } declare module BABYLON.GLTF2.Extensions { class MSFTLOD extends GLTFLoaderExtension { readonly name: string; protected loadMaterial(loader: GLTFLoader, material: IGLTFMaterial, assign: (material: Material) => void): boolean; private loadMaterialLOD(loader, material, materialLODs, lod, assign); } } declare module BABYLON.GLTF2.Extensions { class KHRMaterialsPbrSpecularGlossiness extends GLTFLoaderExtension { readonly name: string; protected loadMaterial(loader: GLTFLoader, material: IGLTFMaterial, assign: (material: Material) => void): boolean; private _loadSpecularGlossinessProperties(loader, material, properties); } }