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; } enum GLTFLoaderState { Loading = 0, Ready = 1, Complete = 2, } interface IGLTFLoaderExtension { enabled: boolean; } interface IGLTFLoaderExtensions { [name: string]: IGLTFLoaderExtension; } interface IGLTFLoader extends IDisposable { coordinateSystemMode: GLTFLoaderCoordinateSystemMode; animationStartMode: GLTFLoaderAnimationStartMode; compileMaterials: boolean; useClipPlane: boolean; compileShadowGenerators: boolean; onDisposeObservable: Observable; onMeshLoadedObservable: Observable; onTextureLoadedObservable: Observable; onMaterialLoadedObservable: Observable; onCompleteObservable: Observable; state: Nullable; extensions: Nullable; 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; } 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; 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; private _onMeshLoadedObserver; onMeshLoaded: (mesh: AbstractMesh) => void; /** * Raised when the loader creates a texture after parsing the glTF properties of the texture. */ readonly onTextureLoadedObservable: Observable; private _onTextureLoadedObserver; onTextureLoaded: (Texture: BaseTexture) => void; /** * Raised when the loader creates a material after parsing the glTF properties of the material. */ readonly onMaterialLoadedObservable: Observable; 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; private _onCompleteObserver; onComplete: () => void; /** * Raised when the loader is disposed. */ readonly onDisposeObservable: Observable; private _onDisposeObserver; onDispose: () => void; /** * The loader state or null if not active. */ readonly loaderState: Nullable; /** * The loader extensions or null if not active. */ readonly loaderExtensions: Nullable; 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; loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise; 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.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; } interface ILoaderAnimationChannel extends IAnimationChannel, IArrayItem { _babylonAnimationGroup: AnimationGroup; } interface ILoaderAnimationSamplerData { input: Float32Array; interpolation: AnimationSamplerInterpolation; output: Float32Array; } interface ILoaderAnimationSampler extends IAnimationSampler, IArrayItem { _data: Promise; } interface ILoaderAnimation extends IAnimation, IArrayItem { channels: ILoaderAnimationChannel[]; samplers: ILoaderAnimationSampler[]; _babylonAnimationGroup: Nullable; } interface ILoaderBuffer extends IBuffer, IArrayItem { _data?: Promise; } interface ILoaderBufferView extends IBufferView, IArrayItem { _data?: Promise; } interface ILoaderCamera extends ICamera, IArrayItem { } interface ILoaderImage extends IImage, IArrayItem { _objectURL?: Promise; } interface ILoaderMaterial extends IMaterial, IArrayItem { _babylonMaterial?: Material; _babylonMeshes?: AbstractMesh[]; _loaded?: Promise; } 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; _loaded?: Promise; } 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[]; 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; readonly onMeshLoadedObservable: Observable; readonly onTextureLoadedObservable: Observable; readonly onMaterialLoadedObservable: Observable; readonly onCompleteObservable: Observable; readonly state: Nullable; readonly extensions: IGLTFLoaderExtensions; constructor(); 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; private _loadAsync(nodes, scene, data, rootUrl, onProgress?); private _loadData(data); private _setupData(); private _createRootNode(); private _loadNodesAsync(nodes); _loadSceneAsync(context: string, scene: ILoaderScene): Promise; private _getMeshes(); private _getSkeletons(); private _startAnimations(); _loadNodeAsync(context: string, node: ILoaderNode): Promise; 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); private _loadBufferViewAsync(context, bufferView); private _loadAccessorAsync(context, accessor); private _buildArrayBuffer(typedArray, data, byteOffset, count, numComponents, byteStride?); private _getDefaultMaterial(); private _loadMaterialMetallicRoughnessPropertiesAsync(context, material); _loadMaterialAsync(context: string, material: ILoaderMaterial, babylonMesh: Mesh): Promise; _createMaterial(material: ILoaderMaterial): PBRMaterial; _loadMaterialBasePropertiesAsync(context: string, material: ILoaderMaterial): Promise; _loadMaterialAlphaProperties(context: string, material: ILoaderMaterial): void; _loadTextureAsync(context: string, textureInfo: ITextureInfo, assign: (texture: Texture) => void): Promise; private _loadSampler(context, sampler); private _loadImageAsync(context, image); _loadUriAsync(context: string, uri: string): Promise; private _onProgress(); static _GetProperty(context: string, array: ArrayLike | 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 _abortRequests(); private _releaseResources(); _applyExtensions(actionAsync: (extension: GLTFLoaderExtension) => Nullable>): Nullable>; } } declare module BABYLON.GLTF2 { abstract class GLTFLoaderExtension { enabled: boolean; protected _loader: GLTFLoader; constructor(loader: GLTFLoader); protected readonly abstract _name: string; /** Override this method to modify the default behavior for loading scenes. */ protected _loadSceneAsync(context: string, node: ILoaderScene): Nullable>; /** Override this method to modify the default behavior for loading nodes. */ protected _loadNodeAsync(context: string, node: ILoaderNode): Nullable>; /** Override this method to modify the default behavior for loading materials. */ protected _loadMaterialAsync(context: string, material: ILoaderMaterial, babylonMesh: Mesh): Nullable>; /** Override this method to modify the default behavior for loading uris. */ protected _loadUriAsync(context: string, uri: string): Nullable>; /** Helper method called by a loader extension to load an glTF extension. */ protected _loadExtensionAsync(context: string, property: IProperty, actionAsync: (context: string, extension: T) => Promise): Nullable>; /** Helper method called by the loader to allow extensions to override loading scenes. */ static _LoadSceneAsync(loader: GLTFLoader, context: string, scene: ILoaderScene): Nullable>; /** Helper method called by the loader to allow extensions to override loading nodes. */ static _LoadNodeAsync(loader: GLTFLoader, context: string, node: ILoaderNode): Nullable>; /** Helper method called by the loader to allow extensions to override loading materials. */ static _LoadMaterialAsync(loader: GLTFLoader, context: string, material: ILoaderMaterial, babylonMesh: Mesh): Nullable>; /** Helper method called by the loader to allow extensions to override loading uris. */ static _LoadUriAsync(loader: GLTFLoader, context: string, uri: string): Nullable>; } } declare module BABYLON.GLTF2.Extensions { class MSFTLOD extends GLTFLoaderExtension { private _loadingNodeLOD; private _loadNodeSignals; private _loadingMaterialLOD; private _loadMaterialSignals; protected readonly _name: string; protected _loadNodeAsync(context: string, node: ILoaderNode): Nullable>; protected _loadMaterialAsync(context: string, material: ILoaderMaterial, babylonMesh: Mesh): Nullable>; protected _loadUriAsync(context: string, uri: string): Nullable>; /** * Gets an array of LOD properties from lowest to highest. */ private static _GetLODs(context, property, array, ids); } } declare module BABYLON.GLTF2.Extensions { class KHRMaterialsPbrSpecularGlossiness extends GLTFLoaderExtension { protected readonly _name: string; protected _loadMaterialAsync(context: string, material: ILoaderMaterial, babylonMesh: Mesh): Nullable>; private _loadSpecularGlossinessPropertiesAsync(loader, context, material, properties); } } declare module BABYLON.GLTF2.Extensions { class KHRLights extends GLTFLoaderExtension { protected readonly _name: string; protected _loadSceneAsync(context: string, scene: ILoaderScene): Nullable>; protected _loadNodeAsync(context: string, node: ILoaderNode): Nullable>; private readonly _lights; } }