|
@@ -1,25 +1,98 @@
|
|
|
|
|
|
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: ArrayBufferView;
|
|
|
+ bin: Nullable<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;
|
|
|
+ interface IGLTFLoader extends IDisposable {
|
|
|
+ importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onProgress: (event: ProgressEvent) => void, onError: (message: string) => void) => void;
|
|
|
+ loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: () => void, onProgress: (event: ProgressEvent) => void, onError: (message: string) => void) => void;
|
|
|
}
|
|
|
- class GLTFFileLoader implements ISceneLoaderPluginAsync {
|
|
|
+ class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
|
|
|
static CreateGLTFLoaderV1: (parent: GLTFFileLoader) => IGLTFLoader;
|
|
|
static CreateGLTFLoaderV2: (parent: GLTFFileLoader) => IGLTFLoader;
|
|
|
- static HomogeneousCoordinates: boolean;
|
|
|
+ /**
|
|
|
+ * 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.
|
|
|
+ */
|
|
|
+ onParsed: (data: 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.
|
|
|
+ */
|
|
|
+ onMeshLoaded: (mesh: AbstractMesh) => void;
|
|
|
+ /**
|
|
|
+ * Raised when the loader creates a texture after parsing the glTF properties of the texture.
|
|
|
+ */
|
|
|
onTextureLoaded: (texture: BaseTexture) => void;
|
|
|
+ /**
|
|
|
+ * Raised when the loader creates a material after parsing the glTF properties of the material.
|
|
|
+ */
|
|
|
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.
|
|
|
+ */
|
|
|
onComplete: () => void;
|
|
|
+ private _loader;
|
|
|
+ name: string;
|
|
|
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;
|
|
|
+ /**
|
|
|
+ * 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: ProgressEvent) => void, onError: (message: string) => void): void;
|
|
|
+ loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onSuccess: () => void, onProgress: (event: ProgressEvent) => void, onError: (message: string) => void): void;
|
|
|
canDirectLoad(data: string): boolean;
|
|
|
+ rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
|
|
|
+ createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
|
|
|
private static _parse(data);
|
|
|
private _getLoader(loaderData);
|
|
|
private static _parseBinary(data);
|
|
@@ -27,7 +100,7 @@ declare module BABYLON {
|
|
|
private static _parseV2(binaryReader);
|
|
|
private static _parseVersion(version);
|
|
|
private static _compareVersion(a, b);
|
|
|
- private static _decodeBufferToText(view);
|
|
|
+ private static _decodeBufferToText(buffer);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -116,7 +189,9 @@ declare module BABYLON.GLTF1 {
|
|
|
* Interfaces
|
|
|
*/
|
|
|
interface IGLTFProperty {
|
|
|
- extensions?: Object;
|
|
|
+ extensions?: {
|
|
|
+ [key: string]: any;
|
|
|
+ };
|
|
|
extras?: Object;
|
|
|
}
|
|
|
interface IGLTFChildRootProperty extends IGLTFProperty {
|
|
@@ -137,6 +212,7 @@ declare module BABYLON.GLTF1 {
|
|
|
buffer: string;
|
|
|
byteOffset: number;
|
|
|
byteLength: number;
|
|
|
+ byteStride: number;
|
|
|
target?: number;
|
|
|
}
|
|
|
interface IGLTFBuffer extends IGLTFChildRootProperty {
|
|
@@ -179,10 +255,16 @@ declare module BABYLON.GLTF1 {
|
|
|
functions: IGLTFTechniqueStatesFunctions;
|
|
|
}
|
|
|
interface IGLTFTechnique extends IGLTFChildRootProperty {
|
|
|
- parameters: Object;
|
|
|
+ parameters: {
|
|
|
+ [key: string]: IGLTFTechniqueParameter;
|
|
|
+ };
|
|
|
program: string;
|
|
|
- attributes: Object;
|
|
|
- uniforms: Object;
|
|
|
+ attributes: {
|
|
|
+ [key: string]: string;
|
|
|
+ };
|
|
|
+ uniforms: {
|
|
|
+ [key: string]: string;
|
|
|
+ };
|
|
|
states: IGLTFTechniqueStates;
|
|
|
}
|
|
|
interface IGLTFMaterial extends IGLTFChildRootProperty {
|
|
@@ -190,7 +272,9 @@ declare module BABYLON.GLTF1 {
|
|
|
values: string[];
|
|
|
}
|
|
|
interface IGLTFMeshPrimitive extends IGLTFProperty {
|
|
|
- attributes: Object;
|
|
|
+ attributes: {
|
|
|
+ [key: string]: string;
|
|
|
+ };
|
|
|
indices: string;
|
|
|
material: string;
|
|
|
mode?: number;
|
|
@@ -269,8 +353,12 @@ declare module BABYLON.GLTF1 {
|
|
|
}
|
|
|
interface IGLTFAnimation extends IGLTFChildRootProperty {
|
|
|
channels?: IGLTFAnimationChannel[];
|
|
|
- parameters?: Object;
|
|
|
- samplers?: Object;
|
|
|
+ parameters?: {
|
|
|
+ [key: string]: string;
|
|
|
+ };
|
|
|
+ samplers?: {
|
|
|
+ [key: string]: IGLTFAnimationSampler;
|
|
|
+ };
|
|
|
}
|
|
|
interface IGLTFNodeInstanceSkin {
|
|
|
skeletons: string[];
|
|
@@ -304,25 +392,61 @@ declare module BABYLON.GLTF1 {
|
|
|
* Runtime
|
|
|
*/
|
|
|
interface IGLTFRuntime {
|
|
|
- extensions: Object;
|
|
|
- accessors: Object;
|
|
|
- buffers: Object;
|
|
|
- bufferViews: Object;
|
|
|
- meshes: Object;
|
|
|
- lights: Object;
|
|
|
- cameras: Object;
|
|
|
- nodes: Object;
|
|
|
- images: Object;
|
|
|
- textures: Object;
|
|
|
- shaders: Object;
|
|
|
- programs: Object;
|
|
|
- samplers: Object;
|
|
|
- techniques: Object;
|
|
|
- materials: Object;
|
|
|
- animations: Object;
|
|
|
- skins: Object;
|
|
|
+ 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: Object;
|
|
|
+ scenes: {
|
|
|
+ [key: string]: IGLTFScene;
|
|
|
+ };
|
|
|
extensionsUsed: string[];
|
|
|
extensionsRequired?: string[];
|
|
|
buffersCount: number;
|
|
@@ -359,11 +483,11 @@ declare module BABYLON.GLTF1 {
|
|
|
*/
|
|
|
class GLTFLoaderBase {
|
|
|
static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
|
|
|
- static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: () => void, onProgress?: () => void): void;
|
|
|
- static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: () => void): void;
|
|
|
- static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: () => void): void;
|
|
|
- static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: () => void): void;
|
|
|
- static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: () => void): void;
|
|
|
+ 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
|
|
@@ -373,10 +497,11 @@ declare module BABYLON.GLTF1 {
|
|
|
[name: string]: GLTFLoaderExtension;
|
|
|
};
|
|
|
static RegisterExtension(extension: GLTFLoaderExtension): void;
|
|
|
- importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onError?: () => void, onProgress?: () => void): boolean;
|
|
|
- loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: () => void, onError: () => void): void;
|
|
|
+ dispose(): void;
|
|
|
+ importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onProgress: (event: ProgressEvent) => void, onError: (message: string) => void): boolean;
|
|
|
+ loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: () => void, onProgress: (event: ProgressEvent) => void, onError: (message: string) => void): void;
|
|
|
private _loadShadersAsync(gltfRuntime, onload);
|
|
|
- private _loadBuffersAsync(gltfRuntime, onload, onProgress?);
|
|
|
+ private _loadBuffersAsync(gltfRuntime, onLoad, onProgress?);
|
|
|
private _createNodes(gltfRuntime);
|
|
|
}
|
|
|
}
|
|
@@ -461,43 +586,43 @@ declare module BABYLON.GLTF1 {
|
|
|
* 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: () => void): boolean;
|
|
|
+ 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: () => void): boolean;
|
|
|
+ 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: () => void, onProgress?: () => void): boolean;
|
|
|
+ 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: () => void): boolean;
|
|
|
+ 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: () => void): boolean;
|
|
|
+ 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: () => void): boolean;
|
|
|
+ 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: () => void): boolean;
|
|
|
- static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: () => void): void;
|
|
|
- static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: () => void): void;
|
|
|
- static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: () => void, onProgress?: () => void): void;
|
|
|
- static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: () => void): void;
|
|
|
- static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string) => void, onError: () => void): void;
|
|
|
- static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: () => void): void;
|
|
|
+ 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);
|
|
@@ -509,10 +634,10 @@ declare module BABYLON.GLTF1 {
|
|
|
class GLTFBinaryExtension extends GLTFLoaderExtension {
|
|
|
private _bin;
|
|
|
constructor();
|
|
|
- loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: () => void): boolean;
|
|
|
- loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: () => void): boolean;
|
|
|
- loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: () => void): boolean;
|
|
|
- loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: () => void): boolean;
|
|
|
+ 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;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -520,8 +645,8 @@ declare module BABYLON.GLTF1 {
|
|
|
declare module BABYLON.GLTF1 {
|
|
|
class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
|
|
|
constructor();
|
|
|
- loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: () => void): boolean;
|
|
|
- loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: () => void): boolean;
|
|
|
+ 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);
|
|
|
}
|
|
|
}
|
|
@@ -569,7 +694,9 @@ declare module BABYLON.GLTF2 {
|
|
|
* Interfaces
|
|
|
*/
|
|
|
interface IGLTFProperty {
|
|
|
- extensions?: Object;
|
|
|
+ extensions?: {
|
|
|
+ [key: string]: any;
|
|
|
+ };
|
|
|
extras?: any;
|
|
|
}
|
|
|
interface IGLTFChildRootProperty extends IGLTFProperty {
|
|
@@ -599,6 +726,7 @@ declare module BABYLON.GLTF2 {
|
|
|
max: number[];
|
|
|
min: number[];
|
|
|
sparse?: IGLTFAccessorSparse;
|
|
|
+ index: number;
|
|
|
}
|
|
|
interface IGLTFAnimationChannel extends IGLTFProperty {
|
|
|
sampler: number;
|
|
@@ -616,7 +744,8 @@ declare module BABYLON.GLTF2 {
|
|
|
interface IGLTFAnimation extends IGLTFChildRootProperty {
|
|
|
channels: IGLTFAnimationChannel[];
|
|
|
samplers: IGLTFAnimationSampler[];
|
|
|
- targets?: any[];
|
|
|
+ index: number;
|
|
|
+ targets: any[];
|
|
|
}
|
|
|
interface IGLTFAsset extends IGLTFChildRootProperty {
|
|
|
copyright?: string;
|
|
@@ -627,14 +756,16 @@ declare module BABYLON.GLTF2 {
|
|
|
interface IGLTFBuffer extends IGLTFChildRootProperty {
|
|
|
uri?: string;
|
|
|
byteLength: number;
|
|
|
- loadedData: ArrayBufferView;
|
|
|
- loadedObservable: Observable<IGLTFBuffer>;
|
|
|
+ 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;
|
|
@@ -657,6 +788,7 @@ declare module BABYLON.GLTF2 {
|
|
|
uri?: string;
|
|
|
mimeType?: string;
|
|
|
bufferView?: number;
|
|
|
+ index: number;
|
|
|
}
|
|
|
interface IGLTFMaterialNormalTextureInfo extends IGLTFTextureInfo {
|
|
|
scale: number;
|
|
@@ -680,8 +812,8 @@ declare module BABYLON.GLTF2 {
|
|
|
alphaMode?: string;
|
|
|
alphaCutoff: number;
|
|
|
doubleSided?: boolean;
|
|
|
- index?: number;
|
|
|
- babylonMaterial?: Material;
|
|
|
+ index: number;
|
|
|
+ babylonMaterial: Material;
|
|
|
}
|
|
|
interface IGLTFMeshPrimitive extends IGLTFProperty {
|
|
|
attributes: {
|
|
@@ -690,13 +822,16 @@ declare module BABYLON.GLTF2 {
|
|
|
indices?: number;
|
|
|
material?: number;
|
|
|
mode?: EMeshPrimitiveMode;
|
|
|
- targets?: [{
|
|
|
+ targets?: {
|
|
|
[name: string]: number;
|
|
|
- }];
|
|
|
+ }[];
|
|
|
+ vertexData: VertexData;
|
|
|
+ targetsVertexData: VertexData[];
|
|
|
}
|
|
|
interface IGLTFMesh extends IGLTFChildRootProperty {
|
|
|
primitives: IGLTFMeshPrimitive[];
|
|
|
weights?: number[];
|
|
|
+ index: number;
|
|
|
}
|
|
|
interface IGLTFNode extends IGLTFChildRootProperty {
|
|
|
camera?: number;
|
|
@@ -708,12 +843,9 @@ declare module BABYLON.GLTF2 {
|
|
|
scale?: number[];
|
|
|
translation?: number[];
|
|
|
weights?: number[];
|
|
|
- index?: number;
|
|
|
- parent?: IGLTFNode;
|
|
|
- babylonMesh?: Mesh;
|
|
|
- babylonSkinToBones?: {
|
|
|
- [skin: number]: Bone;
|
|
|
- };
|
|
|
+ index: number;
|
|
|
+ parent: IGLTFNode;
|
|
|
+ babylonMesh: Mesh;
|
|
|
babylonAnimationTargets?: Node[];
|
|
|
}
|
|
|
interface IGLTFSampler extends IGLTFChildRootProperty {
|
|
@@ -721,22 +853,29 @@ declare module BABYLON.GLTF2 {
|
|
|
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;
|
|
|
+ index: number;
|
|
|
+ babylonSkeleton: Skeleton;
|
|
|
}
|
|
|
interface IGLTFTexture extends IGLTFChildRootProperty {
|
|
|
sampler?: number;
|
|
|
source: number;
|
|
|
- babylonTextures?: Texture[];
|
|
|
- blobURL?: string;
|
|
|
+ index: number;
|
|
|
+ url?: string;
|
|
|
+ dataReadyObservable?: Observable<IGLTFTexture>;
|
|
|
}
|
|
|
interface IGLTFTextureInfo {
|
|
|
index: number;
|
|
@@ -751,7 +890,6 @@ declare module BABYLON.GLTF2 {
|
|
|
cameras?: IGLTFCamera[];
|
|
|
extensionsUsed?: string[];
|
|
|
extensionsRequired?: string[];
|
|
|
- glExtensionsUsed?: string[];
|
|
|
images?: IGLTFImage[];
|
|
|
materials?: IGLTFMaterial[];
|
|
|
meshes?: IGLTFMesh[];
|
|
@@ -767,62 +905,104 @@ declare module BABYLON.GLTF2 {
|
|
|
|
|
|
declare module BABYLON.GLTF2 {
|
|
|
class GLTFLoader implements IGLTFLoader {
|
|
|
+ _gltf: IGLTF;
|
|
|
+ _babylonScene: Scene;
|
|
|
+ private _disposed;
|
|
|
private _parent;
|
|
|
- private _gltf;
|
|
|
- private _errors;
|
|
|
- private _babylonScene;
|
|
|
private _rootUrl;
|
|
|
private _defaultMaterial;
|
|
|
- private _onSuccess;
|
|
|
- private _onError;
|
|
|
+ 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;
|
|
|
- readonly gltf: IGLTF;
|
|
|
- readonly babylonScene: Scene;
|
|
|
+ private static _progressEventFactory;
|
|
|
+ private static _createProgressEventByConstructor(name, data);
|
|
|
+ private static _createProgressEventByDocument(name, data);
|
|
|
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);
|
|
|
+ dispose(): void;
|
|
|
+ importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onProgress: (event: ProgressEvent) => void, onError: (message: string) => void): void;
|
|
|
+ loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: () => void, onProgress: (event: ProgressEvent) => void, onError: (message: string) => void): void;
|
|
|
+ private _loadAsync(nodeNames, scene, data, rootUrl, onSuccess, onProgress, onError);
|
|
|
+ private _onProgress();
|
|
|
+ _executeWhenRenderReady(func: () => void): void;
|
|
|
private _onRenderReady();
|
|
|
- private _onLoaderComplete();
|
|
|
+ private _onComplete();
|
|
|
private _loadData(data);
|
|
|
- private _showMeshes();
|
|
|
+ private _getMeshes();
|
|
|
+ private _getSkeletons();
|
|
|
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 _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 _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 _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(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;
|
|
|
+ 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);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -842,27 +1022,7 @@ declare module BABYLON.GLTF2 {
|
|
|
* @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;
|
|
|
+ static ValidateUri(uri: string): boolean;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -871,9 +1031,14 @@ declare module BABYLON.GLTF2 {
|
|
|
abstract class GLTFLoaderExtension {
|
|
|
enabled: boolean;
|
|
|
readonly abstract name: string;
|
|
|
- protected loadMaterial(loader: GLTFLoader, material: IGLTFMaterial, assign: (material: Material) => void): boolean;
|
|
|
+ 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 LoadMaterial(loader: GLTFLoader, material: IGLTFMaterial, assign: (material: Material) => void): boolean;
|
|
|
+ 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);
|
|
|
}
|
|
|
}
|
|
@@ -881,9 +1046,16 @@ declare module BABYLON.GLTF2 {
|
|
|
|
|
|
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 loadMaterial(loader: GLTFLoader, material: IGLTFMaterial, assign: (material: Material) => void): boolean;
|
|
|
- private loadMaterialLOD(loader, material, materialLODs, lod, assign);
|
|
|
+ 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);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -891,7 +1063,7 @@ declare module BABYLON.GLTF2.Extensions {
|
|
|
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);
|
|
|
+ protected _loadMaterial(loader: GLTFLoader, context: string, material: IGLTFMaterial, assign: (babylonMaterial: Material, isNew: boolean) => void): boolean;
|
|
|
+ private _loadSpecularGlossinessProperties(loader, context, material, properties);
|
|
|
}
|
|
|
}
|