|
@@ -118,6 +118,7 @@ declare module BABYLON.GLTF2 {
|
|
interface IGLTFAnimation extends IGLTFChildRootProperty {
|
|
interface IGLTFAnimation extends IGLTFChildRootProperty {
|
|
channels: IGLTFAnimationChannel[];
|
|
channels: IGLTFAnimationChannel[];
|
|
samplers: IGLTFAnimationSampler[];
|
|
samplers: IGLTFAnimationSampler[];
|
|
|
|
+ targets?: any[];
|
|
}
|
|
}
|
|
interface IGLTFAssetProfile extends IGLTFProperty {
|
|
interface IGLTFAssetProfile extends IGLTFProperty {
|
|
api?: string;
|
|
api?: string;
|
|
@@ -132,7 +133,8 @@ declare module BABYLON.GLTF2 {
|
|
interface IGLTFBuffer extends IGLTFChildRootProperty {
|
|
interface IGLTFBuffer extends IGLTFChildRootProperty {
|
|
uri?: string;
|
|
uri?: string;
|
|
byteLength: number;
|
|
byteLength: number;
|
|
- loadedBufferView: ArrayBufferView;
|
|
|
|
|
|
+ loadedData: ArrayBufferView;
|
|
|
|
+ loadedObservable: Observable<IGLTFBuffer>;
|
|
}
|
|
}
|
|
interface IGLTFBufferView extends IGLTFChildRootProperty {
|
|
interface IGLTFBufferView extends IGLTFChildRootProperty {
|
|
buffer: number;
|
|
buffer: number;
|
|
@@ -211,6 +213,7 @@ declare module BABYLON.GLTF2 {
|
|
scale?: number[];
|
|
scale?: number[];
|
|
translation?: number[];
|
|
translation?: number[];
|
|
weights?: number[];
|
|
weights?: number[];
|
|
|
|
+ index?: number;
|
|
babylonNode?: Node;
|
|
babylonNode?: Node;
|
|
}
|
|
}
|
|
interface IGLTFSampler extends IGLTFChildRootProperty {
|
|
interface IGLTFSampler extends IGLTFChildRootProperty {
|
|
@@ -231,8 +234,8 @@ declare module BABYLON.GLTF2 {
|
|
interface IGLTFTexture extends IGLTFChildRootProperty {
|
|
interface IGLTFTexture extends IGLTFChildRootProperty {
|
|
sampler?: number;
|
|
sampler?: number;
|
|
source: number;
|
|
source: number;
|
|
- babylonTextures: Texture[];
|
|
|
|
- blobURL: string;
|
|
|
|
|
|
+ babylonTextures?: Texture[];
|
|
|
|
+ blobURL?: string;
|
|
}
|
|
}
|
|
interface IGLTFTextureInfo {
|
|
interface IGLTFTextureInfo {
|
|
index: number;
|
|
index: number;
|
|
@@ -258,57 +261,58 @@ declare module BABYLON.GLTF2 {
|
|
skins?: IGLTFSkin[];
|
|
skins?: IGLTFSkin[];
|
|
textures?: IGLTFTexture[];
|
|
textures?: IGLTFTexture[];
|
|
}
|
|
}
|
|
- interface IGLTFRuntime {
|
|
|
|
- gltf: IGLTF;
|
|
|
|
- babylonScene: Scene;
|
|
|
|
- rootUrl: string;
|
|
|
|
- importOnlyMeshes: boolean;
|
|
|
|
- importMeshesNames?: string[];
|
|
|
|
- defaultMaterial?: PBRMaterial;
|
|
|
|
- }
|
|
|
|
- /**
|
|
|
|
- * Bones
|
|
|
|
- */
|
|
|
|
- interface INodeToRoot {
|
|
|
|
- bone: Bone;
|
|
|
|
- node: IGLTFNode;
|
|
|
|
- index: number;
|
|
|
|
- }
|
|
|
|
- interface IJointNode {
|
|
|
|
- node: IGLTFNode;
|
|
|
|
- index: number;
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
declare module BABYLON.GLTF2 {
|
|
declare module BABYLON.GLTF2 {
|
|
- /**
|
|
|
|
- * glTF File Loader Plugin
|
|
|
|
- */
|
|
|
|
class GLTFLoader implements IGLTFLoader {
|
|
class GLTFLoader implements IGLTFLoader {
|
|
|
|
+ private _gltf;
|
|
|
|
+ private _pendingCount;
|
|
|
|
+ private _onLoaded;
|
|
|
|
+ private _errors;
|
|
|
|
+ private _babylonScene;
|
|
|
|
+ private _rootUrl;
|
|
|
|
+ private _defaultMaterial;
|
|
static Extensions: {
|
|
static Extensions: {
|
|
[name: string]: GLTFLoaderExtension;
|
|
[name: string]: GLTFLoaderExtension;
|
|
};
|
|
};
|
|
static RegisterExtension(extension: GLTFLoaderExtension): void;
|
|
static RegisterExtension(extension: GLTFLoaderExtension): void;
|
|
- static LoadMaterial(runtime: IGLTFRuntime, index: number): IGLTFMaterial;
|
|
|
|
- static LoadCoreMaterialAsync(runtime: IGLTFRuntime, index: number, onSuccess: () => void, onError: () => void): void;
|
|
|
|
- private static _loadMetallicRoughnessMaterialPropertiesAsync(runtime, material, onSuccess, onError);
|
|
|
|
- static LoadCommonMaterialPropertiesAsync(runtime: IGLTFRuntime, material: IGLTFMaterial, onSuccess: () => void, onError: () => void): void;
|
|
|
|
- static LoadAlphaProperties(runtime: IGLTFRuntime, material: IGLTFMaterial): void;
|
|
|
|
- static LoadTextureAsync(runtime: IGLTFRuntime, textureInfo: IGLTFTextureInfo, onSuccess: (babylonTexture: Texture) => void, onError: () => void): void;
|
|
|
|
- private static _createTextureAsync(runtime, texture, texCoord, url, onSuccess, onError);
|
|
|
|
- /**
|
|
|
|
- * Import meshes
|
|
|
|
- */
|
|
|
|
- importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onError?: () => void): void;
|
|
|
|
- /**
|
|
|
|
- * Load scene
|
|
|
|
- */
|
|
|
|
|
|
+ static LoadMaterial(index: number): IGLTFMaterial;
|
|
|
|
+ static LoadCoreMaterial(index: number): Material;
|
|
|
|
+ static LoadCommonMaterialProperties(material: IGLTFMaterial): void;
|
|
|
|
+ static LoadAlphaProperties(material: IGLTFMaterial): void;
|
|
|
|
+ static LoadTexture(textureInfo: IGLTFTextureInfo): Texture;
|
|
|
|
+ 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;
|
|
loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: () => void, onError: () => void): void;
|
|
- private static _loadBuffersAsync(runtime, onSuccess, onError);
|
|
|
|
- private static _loadBufferAsync(runtime, index, onSuccess, onError);
|
|
|
|
- private static _loadMaterialsAsync(runtime, onSuccess, onError);
|
|
|
|
- private static _createRuntime(scene, data, rootUrl, importOnlyMeshes);
|
|
|
|
|
|
+ private _loadAsync(nodeNames, scene, data, rootUrl, onSuccess, onError);
|
|
|
|
+ private _loadData(data);
|
|
|
|
+ private _showMeshes();
|
|
|
|
+ private _startFirstAnimation();
|
|
|
|
+ private _clear();
|
|
|
|
+ private _loadScene(nodeNames);
|
|
|
|
+ private _loadSkin(node);
|
|
|
|
+ private _updateBone(node, parentNode, skin, inverseBindMatrixData);
|
|
|
|
+ private _loadMesh(node, parentNode);
|
|
|
|
+ private _loadMeshData(node, mesh, babylonMesh);
|
|
|
|
+ private _loadVertexDataAsync(primitive, onSuccess);
|
|
|
|
+ private _createMorphTargets(node, mesh, primitive, babylonMesh);
|
|
|
|
+ private _loadMorphTargetsData(mesh, primitive, vertexData, babylonMesh);
|
|
|
|
+ private _loadTransform(node, babylonMesh);
|
|
|
|
+ private _traverseScene(nodeNames, scene, action);
|
|
|
|
+ private _traverseNode(nodeNames, 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);
|
|
|
|
+ private _addPendingData(data);
|
|
|
|
+ private _removePendingData(data);
|
|
|
|
+ private _getDefaultMaterial();
|
|
|
|
+ private _loadMaterial(index);
|
|
|
|
+ private _loadCoreMaterial(index);
|
|
|
|
+ private _loadCommonMaterialProperties(material);
|
|
|
|
+ private _loadAlphaProperties(material);
|
|
|
|
+ private _loadTexture(textureInfo);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -343,23 +347,11 @@ declare module BABYLON.GLTF2 {
|
|
* @param mode: the filter mode value
|
|
* @param mode: the filter mode value
|
|
*/
|
|
*/
|
|
static GetTextureFilterMode(mode: number): ETextureMinFilter;
|
|
static GetTextureFilterMode(mode: number): ETextureMinFilter;
|
|
- static GetBufferFromBufferView(runtime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
|
|
|
|
- /**
|
|
|
|
- * Returns a buffer from its accessor
|
|
|
|
- * @param runtime: the GLTF runtime
|
|
|
|
- * @param accessor: the GLTF accessor
|
|
|
|
- */
|
|
|
|
- static GetBufferFromAccessor(runtime: IGLTFRuntime, accessor: IGLTFAccessor): ArrayBufferView;
|
|
|
|
/**
|
|
/**
|
|
* Decodes a buffer view into a string
|
|
* Decodes a buffer view into a string
|
|
* @param view: the buffer view
|
|
* @param view: the buffer view
|
|
*/
|
|
*/
|
|
static DecodeBufferToText(view: ArrayBufferView): string;
|
|
static DecodeBufferToText(view: ArrayBufferView): string;
|
|
- /**
|
|
|
|
- * Returns the default material of gltf.
|
|
|
|
- * @param scene: the Babylon.js scene
|
|
|
|
- */
|
|
|
|
- static GetDefaultMaterial(runtime: IGLTFRuntime): PBRMaterial;
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -370,10 +362,8 @@ declare module BABYLON.GLTF2 {
|
|
enabled: boolean;
|
|
enabled: boolean;
|
|
constructor(name: string);
|
|
constructor(name: string);
|
|
readonly name: string;
|
|
readonly name: string;
|
|
- protected postCreateRuntime(runtime: IGLTFRuntime): void;
|
|
|
|
- protected loadMaterialAsync(runtime: IGLTFRuntime, index: number, onSuccess: () => void, onError: () => void): boolean;
|
|
|
|
- static PostCreateRuntime(runtime: IGLTFRuntime): void;
|
|
|
|
- static LoadMaterialAsync(runtime: IGLTFRuntime, index: number, onSuccess: () => void, onError: () => void): void;
|
|
|
|
|
|
+ protected loadMaterial(index: number): Material;
|
|
|
|
+ static LoadMaterial(index: number): Material;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -381,6 +371,6 @@ declare module BABYLON.GLTF2 {
|
|
declare module BABYLON.GLTF2 {
|
|
declare module BABYLON.GLTF2 {
|
|
class GLTFMaterialsPbrSpecularGlossinessExtension extends GLTFLoaderExtension {
|
|
class GLTFMaterialsPbrSpecularGlossinessExtension extends GLTFLoaderExtension {
|
|
constructor();
|
|
constructor();
|
|
- protected loadMaterialAsync(runtime: IGLTFRuntime, index: number, onSuccess: () => void, onError: () => void): boolean;
|
|
|
|
|
|
+ protected loadMaterial(index: number): Material;
|
|
}
|
|
}
|
|
}
|
|
}
|