|
@@ -1,9 +1,9 @@
|
|
|
-/// <reference path="../../../../dist/preview release/babylon.d.ts"/>
|
|
|
+import { IFileRequest, Buffer, Animation, Scene, Nullable, Mesh, Material, SceneLoaderProgressEvent, Tools, AbstractMesh, IParticleSystem, Skeleton, AnimationGroup, Geometry, VertexBuffer, MorphTargetManager, MorphTarget, TransformNode, Vector3, Quaternion, Matrix, Bone, Camera, FreeCamera, IAnimationKey, AnimationKeyInterpolation, IndicesArray, PBRMaterial, Color3, BaseTexture, Deferred, Texture, LoadFileError } from "babylonjs";
|
|
|
+import { IProperty, AccessorType, CameraType, AnimationChannelTargetPath, AnimationSamplerInterpolation, AccessorComponentType, MaterialAlphaMode, TextureMinFilter, TextureWrapMode, TextureMagFilter, MeshPrimitiveMode } from "babylonjs-gltf2interface";
|
|
|
+import { _IAnimationSamplerData, IGLTF, ISampler, INode, IScene, IMesh, IAccessor, ISkin, ICamera, IAnimation, IAnimationChannel, IAnimationSampler, IBuffer, IBufferView, IMaterialPbrMetallicRoughness, IMaterial, ITextureInfo, ITexture, IImage, IMeshPrimitive, IArrayItem as IArrItem, _ISamplerData } from "./glTFLoaderInterfaces";
|
|
|
+import { IGLTFLoaderExtension } from "./glTFLoaderExtension";
|
|
|
+import { IGLTFLoader, GLTFFileLoader, GLTFLoaderState, IGLTFLoaderData, GLTFLoaderCoordinateSystemMode, GLTFLoaderAnimationStartMode } from "../glTFFileLoader";
|
|
|
|
|
|
-/**
|
|
|
- * Defines the module for importing and exporting glTF 2.0 assets
|
|
|
- */
|
|
|
-module BABYLON.GLTF2 {
|
|
|
interface IFileRequestInfo extends IFileRequest {
|
|
|
_lengthComputable?: boolean;
|
|
|
_loaded?: number;
|
|
@@ -37,7 +37,7 @@ module BABYLON.GLTF2 {
|
|
|
* Assign an `index` field to each item of the given array.
|
|
|
* @param array The array of items
|
|
|
*/
|
|
|
- public static Assign(array?: Loader.IArrayItem[]): void {
|
|
|
+ public static Assign(array?: IArrItem[]): void {
|
|
|
if (array) {
|
|
|
for (let index = 0; index < array.length; index++) {
|
|
|
array[index].index = index;
|
|
@@ -51,7 +51,7 @@ module BABYLON.GLTF2 {
|
|
|
*/
|
|
|
export class GLTFLoader implements IGLTFLoader {
|
|
|
/** The glTF object parsed from the JSON. */
|
|
|
- public gltf: Loader.IGLTF;
|
|
|
+ public gltf: IGLTF;
|
|
|
|
|
|
/** The Babylon scene when loading the asset. */
|
|
|
public babylonScene: Scene;
|
|
@@ -71,7 +71,7 @@ module BABYLON.GLTF2 {
|
|
|
private _progressCallback?: (event: SceneLoaderProgressEvent) => void;
|
|
|
private _requests = new Array<IFileRequestInfo>();
|
|
|
|
|
|
- private static readonly _DefaultSampler: Loader.ISampler = { index: -1 };
|
|
|
+ private static readonly _DefaultSampler: ISampler = { index: -1 };
|
|
|
|
|
|
private static _ExtensionNames = new Array<string>();
|
|
|
private static _ExtensionFactories: { [name: string]: (loader: GLTFLoader) => IGLTFLoaderExtension } = {};
|
|
@@ -297,7 +297,7 @@ module BABYLON.GLTF2 {
|
|
|
}
|
|
|
|
|
|
private _loadData(data: IGLTFLoaderData): void {
|
|
|
- this.gltf = data.json as Loader.IGLTF;
|
|
|
+ this.gltf = data.json as IGLTF;
|
|
|
this._setupData();
|
|
|
|
|
|
if (data.bin) {
|
|
@@ -376,11 +376,11 @@ module BABYLON.GLTF2 {
|
|
|
this.log(GLTFLoaderState[this._state]);
|
|
|
}
|
|
|
|
|
|
- private _createRootNode(): Loader.INode {
|
|
|
+ private _createRootNode(): INode {
|
|
|
this._rootBabylonMesh = new Mesh("__root__", this.babylonScene);
|
|
|
this._rootBabylonMesh.setEnabled(false);
|
|
|
|
|
|
- const rootNode: Loader.INode = {
|
|
|
+ const rootNode: INode = {
|
|
|
_babylonTransformNode: this._rootBabylonMesh,
|
|
|
index: -1
|
|
|
};
|
|
@@ -413,7 +413,7 @@ module BABYLON.GLTF2 {
|
|
|
* @param scene The glTF scene property
|
|
|
* @returns A promise that resolves when the load is complete
|
|
|
*/
|
|
|
- public loadSceneAsync(context: string, scene: Loader.IScene): Promise<void> {
|
|
|
+ public loadSceneAsync(context: string, scene: IScene): Promise<void> {
|
|
|
const extensionPromise = this._extensionsLoadSceneAsync(context, scene);
|
|
|
if (extensionPromise) {
|
|
|
return extensionPromise;
|
|
@@ -439,7 +439,7 @@ module BABYLON.GLTF2 {
|
|
|
return Promise.all(promises).then(() => { });
|
|
|
}
|
|
|
|
|
|
- private _forEachPrimitive(node: Loader.INode, callback: (babylonMesh: AbstractMesh) => void): void {
|
|
|
+ private _forEachPrimitive(node: INode, callback: (babylonMesh: AbstractMesh) => void): void {
|
|
|
if (node._primitiveBabylonMeshes) {
|
|
|
for (const babylonMesh of node._primitiveBabylonMeshes) {
|
|
|
callback(babylonMesh);
|
|
@@ -532,7 +532,7 @@ module BABYLON.GLTF2 {
|
|
|
* @param assign A function called synchronously after parsing the glTF properties
|
|
|
* @returns A promise that resolves with the loaded Babylon mesh when the load is complete
|
|
|
*/
|
|
|
- public loadNodeAsync(context: string, node: Loader.INode, assign: (babylonTransformNode: TransformNode) => void = () => { }): Promise<TransformNode> {
|
|
|
+ public loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void = () => { }): Promise<TransformNode> {
|
|
|
const extensionPromise = this._extensionsLoadNodeAsync(context, node, assign);
|
|
|
if (extensionPromise) {
|
|
|
return extensionPromise;
|
|
@@ -596,7 +596,7 @@ module BABYLON.GLTF2 {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- private _loadMeshAsync(context: string, node: Loader.INode, mesh: Loader.IMesh, assign: (babylonTransformNode: TransformNode) => void): Promise<TransformNode> {
|
|
|
+ private _loadMeshAsync(context: string, node: INode, mesh: IMesh, assign: (babylonTransformNode: TransformNode) => void): Promise<TransformNode> {
|
|
|
const primitives = mesh.primitives;
|
|
|
if (!primitives || !primitives.length) {
|
|
|
throw new Error(`${context}: Primitives are missing`);
|
|
@@ -644,7 +644,7 @@ module BABYLON.GLTF2 {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- private _loadMeshPrimitiveAsync(context: string, name: string, node: Loader.INode, mesh: Loader.IMesh, primitive: Loader.IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh> {
|
|
|
+ private _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh> {
|
|
|
this.logOpen(`${context}`);
|
|
|
|
|
|
const canInstance = (node.skin == undefined && !mesh.primitives[0].targets);
|
|
@@ -673,7 +673,7 @@ module BABYLON.GLTF2 {
|
|
|
if (primitive.material == undefined) {
|
|
|
let babylonMaterial = this._defaultBabylonMaterialData[babylonDrawMode];
|
|
|
if (!babylonMaterial) {
|
|
|
- babylonMaterial = this._createDefaultMaterial("__gltf_default", babylonDrawMode);
|
|
|
+ babylonMaterial = this._createDefaultMaterial("__GLTFLoader._default", babylonDrawMode);
|
|
|
this._parent.onMaterialLoadedObservable.notifyObservers(babylonMaterial);
|
|
|
this._defaultBabylonMaterialData[babylonDrawMode] = babylonMaterial;
|
|
|
}
|
|
@@ -709,7 +709,7 @@ module BABYLON.GLTF2 {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- private _loadVertexDataAsync(context: string, primitive: Loader.IMeshPrimitive, babylonMesh: Mesh): Promise<Geometry> {
|
|
|
+ private _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Promise<Geometry> {
|
|
|
const extensionPromise = this._extensionsLoadVertexDataAsync(context, primitive, babylonMesh);
|
|
|
if (extensionPromise) {
|
|
|
return extensionPromise;
|
|
@@ -734,7 +734,7 @@ module BABYLON.GLTF2 {
|
|
|
}));
|
|
|
}
|
|
|
|
|
|
- const loadAttribute = (attribute: string, kind: string, callback?: (accessor: Loader.IAccessor) => void) => {
|
|
|
+ const loadAttribute = (attribute: string, kind: string, callback?: (accessor: IAccessor) => void) => {
|
|
|
if (attributes[attribute] == undefined) {
|
|
|
return;
|
|
|
}
|
|
@@ -772,7 +772,7 @@ module BABYLON.GLTF2 {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- private _createMorphTargets(context: string, node: Loader.INode, mesh: Loader.IMesh, primitive: Loader.IMeshPrimitive, babylonMesh: Mesh): void {
|
|
|
+ private _createMorphTargets(context: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, babylonMesh: Mesh): void {
|
|
|
if (!primitive.targets) {
|
|
|
return;
|
|
|
}
|
|
@@ -792,7 +792,7 @@ module BABYLON.GLTF2 {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private _loadMorphTargetsAsync(context: string, primitive: Loader.IMeshPrimitive, babylonMesh: Mesh, babylonGeometry: Geometry): Promise<void> {
|
|
|
+ private _loadMorphTargetsAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh, babylonGeometry: Geometry): Promise<void> {
|
|
|
if (!primitive.targets) {
|
|
|
return Promise.resolve();
|
|
|
}
|
|
@@ -859,7 +859,7 @@ module BABYLON.GLTF2 {
|
|
|
return Promise.all(promises).then(() => { });
|
|
|
}
|
|
|
|
|
|
- private static _LoadTransform(node: Loader.INode, babylonNode: TransformNode): void {
|
|
|
+ private static _LoadTransform(node: INode, babylonNode: TransformNode): void {
|
|
|
// Ignore the TRS of skinned nodes.
|
|
|
// See https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins (second implementation note)
|
|
|
if (node.skin != undefined) {
|
|
@@ -885,7 +885,7 @@ module BABYLON.GLTF2 {
|
|
|
babylonNode.scaling = scaling;
|
|
|
}
|
|
|
|
|
|
- private _loadSkinAsync(context: string, node: Loader.INode, skin: Loader.ISkin): Promise<void> {
|
|
|
+ private _loadSkinAsync(context: string, node: INode, skin: ISkin): Promise<void> {
|
|
|
const assignSkeleton = (skeleton: Skeleton) => {
|
|
|
this._forEachPrimitive(node, (babylonMesh) => {
|
|
|
babylonMesh.skeleton = skeleton;
|
|
@@ -916,7 +916,7 @@ module BABYLON.GLTF2 {
|
|
|
return promise;
|
|
|
}
|
|
|
|
|
|
- private _loadBones(context: string, skin: Loader.ISkin, babylonSkeleton: Skeleton): void {
|
|
|
+ private _loadBones(context: string, skin: ISkin, babylonSkeleton: Skeleton): void {
|
|
|
const babylonBones: { [index: number]: Bone } = {};
|
|
|
for (const index of skin.joints) {
|
|
|
const node = ArrayItem.Get(`${context}/joints/${index}`, this.gltf.nodes, index);
|
|
@@ -924,7 +924,7 @@ module BABYLON.GLTF2 {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private _loadBone(node: Loader.INode, skin: Loader.ISkin, babylonSkeleton: Skeleton, babylonBones: { [index: number]: Bone }): Bone {
|
|
|
+ private _loadBone(node: INode, skin: ISkin, babylonSkeleton: Skeleton, babylonBones: { [index: number]: Bone }): Bone {
|
|
|
let babylonBone = babylonBones[node.index];
|
|
|
if (babylonBone) {
|
|
|
return babylonBone;
|
|
@@ -946,7 +946,7 @@ module BABYLON.GLTF2 {
|
|
|
return babylonBone;
|
|
|
}
|
|
|
|
|
|
- private _loadSkinInverseBindMatricesDataAsync(context: string, skin: Loader.ISkin): Promise<Nullable<Float32Array>> {
|
|
|
+ private _loadSkinInverseBindMatricesDataAsync(context: string, skin: ISkin): Promise<Nullable<Float32Array>> {
|
|
|
if (skin.inverseBindMatrices == undefined) {
|
|
|
return Promise.resolve(null);
|
|
|
}
|
|
@@ -974,7 +974,7 @@ module BABYLON.GLTF2 {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private _getNodeMatrix(node: Loader.INode): Matrix {
|
|
|
+ private _getNodeMatrix(node: INode): Matrix {
|
|
|
return node.matrix ?
|
|
|
Matrix.FromArray(node.matrix) :
|
|
|
Matrix.Compose(
|
|
@@ -990,7 +990,7 @@ module BABYLON.GLTF2 {
|
|
|
* @param assign A function called synchronously after parsing the glTF properties
|
|
|
* @returns A promise that resolves with the loaded Babylon camera when the load is complete
|
|
|
*/
|
|
|
- public loadCameraAsync(context: string, camera: Loader.ICamera, assign: (babylonCamera: Camera) => void = () => { }): Promise<Camera> {
|
|
|
+ public loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void = () => { }): Promise<Camera> {
|
|
|
const extensionPromise = this._extensionsLoadCameraAsync(context, camera, assign);
|
|
|
if (extensionPromise) {
|
|
|
return extensionPromise;
|
|
@@ -1065,7 +1065,7 @@ module BABYLON.GLTF2 {
|
|
|
* @param animation The glTF animation property
|
|
|
* @returns A promise that resolves with the loaded Babylon animation group when the load is complete
|
|
|
*/
|
|
|
- public loadAnimationAsync(context: string, animation: Loader.IAnimation): Promise<AnimationGroup> {
|
|
|
+ public loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup> {
|
|
|
const promise = this._extensionsLoadAnimationAsync(context, animation);
|
|
|
if (promise) {
|
|
|
return promise;
|
|
@@ -1089,7 +1089,7 @@ module BABYLON.GLTF2 {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- private _loadAnimationChannelAsync(context: string, animationContext: string, animation: Loader.IAnimation, channel: Loader.IAnimationChannel, babylonAnimationGroup: AnimationGroup): Promise<void> {
|
|
|
+ private _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup): Promise<void> {
|
|
|
if (channel.target.node == undefined) {
|
|
|
return Promise.resolve();
|
|
|
}
|
|
@@ -1251,7 +1251,7 @@ module BABYLON.GLTF2 {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- private _loadAnimationSamplerAsync(context: string, sampler: Loader.IAnimationSampler): Promise<Loader._IAnimationSamplerData> {
|
|
|
+ private _loadAnimationSamplerAsync(context: string, sampler: IAnimationSampler): Promise<_IAnimationSamplerData> {
|
|
|
if (sampler._data) {
|
|
|
return sampler._data;
|
|
|
}
|
|
@@ -1284,7 +1284,7 @@ module BABYLON.GLTF2 {
|
|
|
return sampler._data;
|
|
|
}
|
|
|
|
|
|
- private _loadBufferAsync(context: string, buffer: Loader.IBuffer): Promise<ArrayBufferView> {
|
|
|
+ private _loadBufferAsync(context: string, buffer: IBuffer): Promise<ArrayBufferView> {
|
|
|
if (buffer._data) {
|
|
|
return buffer._data;
|
|
|
}
|
|
@@ -1304,7 +1304,7 @@ module BABYLON.GLTF2 {
|
|
|
* @param bufferView The glTF buffer view property
|
|
|
* @returns A promise that resolves with the loaded data when the load is complete
|
|
|
*/
|
|
|
- public loadBufferViewAsync(context: string, bufferView: Loader.IBufferView): Promise<ArrayBufferView> {
|
|
|
+ public loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView> {
|
|
|
if (bufferView._data) {
|
|
|
return bufferView._data;
|
|
|
}
|
|
@@ -1322,7 +1322,7 @@ module BABYLON.GLTF2 {
|
|
|
return bufferView._data;
|
|
|
}
|
|
|
|
|
|
- private _loadIndicesAccessorAsync(context: string, accessor: Loader.IAccessor): Promise<IndicesArray> {
|
|
|
+ private _loadIndicesAccessorAsync(context: string, accessor: IAccessor): Promise<IndicesArray> {
|
|
|
if (accessor.type !== AccessorType.SCALAR) {
|
|
|
throw new Error(`${context}/type: Invalid value ${accessor.type}`);
|
|
|
}
|
|
@@ -1345,7 +1345,7 @@ module BABYLON.GLTF2 {
|
|
|
return accessor._data as Promise<IndicesArray>;
|
|
|
}
|
|
|
|
|
|
- private _loadFloatAccessorAsync(context: string, accessor: Loader.IAccessor): Promise<Float32Array> {
|
|
|
+ private _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array> {
|
|
|
// TODO: support normalized and stride
|
|
|
|
|
|
if (accessor.componentType !== AccessorComponentType.FLOAT) {
|
|
@@ -1397,7 +1397,7 @@ module BABYLON.GLTF2 {
|
|
|
return accessor._data as Promise<Float32Array>;
|
|
|
}
|
|
|
|
|
|
- private _loadVertexBufferViewAsync(bufferView: Loader.IBufferView, kind: string): Promise<Buffer> {
|
|
|
+ private _loadVertexBufferViewAsync(bufferView: IBufferView, kind: string): Promise<Buffer> {
|
|
|
if (bufferView._babylonBuffer) {
|
|
|
return bufferView._babylonBuffer;
|
|
|
}
|
|
@@ -1409,7 +1409,7 @@ module BABYLON.GLTF2 {
|
|
|
return bufferView._babylonBuffer;
|
|
|
}
|
|
|
|
|
|
- private _loadVertexAccessorAsync(context: string, accessor: Loader.IAccessor, kind: string): Promise<VertexBuffer> {
|
|
|
+ private _loadVertexAccessorAsync(context: string, accessor: IAccessor, kind: string): Promise<VertexBuffer> {
|
|
|
if (accessor._babylonVertexBuffer) {
|
|
|
return accessor._babylonVertexBuffer;
|
|
|
}
|
|
@@ -1438,7 +1438,7 @@ module BABYLON.GLTF2 {
|
|
|
return accessor._babylonVertexBuffer;
|
|
|
}
|
|
|
|
|
|
- private _loadMaterialMetallicRoughnessPropertiesAsync(context: string, properties: Loader.IMaterialPbrMetallicRoughness, babylonMaterial: Material): Promise<void> {
|
|
|
+ private _loadMaterialMetallicRoughnessPropertiesAsync(context: string, properties: IMaterialPbrMetallicRoughness, babylonMaterial: Material): Promise<void> {
|
|
|
if (!(babylonMaterial instanceof PBRMaterial)) {
|
|
|
throw new Error(`${context}: Material type not supported`);
|
|
|
}
|
|
@@ -1480,7 +1480,7 @@ module BABYLON.GLTF2 {
|
|
|
}
|
|
|
|
|
|
/** @hidden */
|
|
|
- public _loadMaterialAsync(context: string, material: Loader.IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void = () => { }): Promise<Material> {
|
|
|
+ public _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void = () => { }): Promise<Material> {
|
|
|
const extensionPromise = this._extensionsLoadMaterialAsync(context, material, babylonMesh, babylonDrawMode, assign);
|
|
|
if (extensionPromise) {
|
|
|
return extensionPromise;
|
|
@@ -1543,7 +1543,7 @@ module BABYLON.GLTF2 {
|
|
|
* @param babylonDrawMode The draw mode for the Babylon material
|
|
|
* @returns The Babylon material
|
|
|
*/
|
|
|
- public createMaterial(context: string, material: Loader.IMaterial, babylonDrawMode: number): Material {
|
|
|
+ public createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material {
|
|
|
const extensionPromise = this._extensionsCreateMaterial(context, material, babylonDrawMode);
|
|
|
if (extensionPromise) {
|
|
|
return extensionPromise;
|
|
@@ -1562,7 +1562,7 @@ module BABYLON.GLTF2 {
|
|
|
* @param babylonMaterial The Babylon material
|
|
|
* @returns A promise that resolves when the load is complete
|
|
|
*/
|
|
|
- public loadMaterialPropertiesAsync(context: string, material: Loader.IMaterial, babylonMaterial: Material): Promise<void> {
|
|
|
+ public loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void> {
|
|
|
const extensionPromise = this._extensionsLoadMaterialPropertiesAsync(context, material, babylonMaterial);
|
|
|
if (extensionPromise) {
|
|
|
return extensionPromise;
|
|
@@ -1588,7 +1588,7 @@ module BABYLON.GLTF2 {
|
|
|
* @param babylonMaterial The Babylon material
|
|
|
* @returns A promise that resolves when the load is complete
|
|
|
*/
|
|
|
- public loadMaterialBasePropertiesAsync(context: string, material: Loader.IMaterial, babylonMaterial: Material): Promise<void> {
|
|
|
+ public loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void> {
|
|
|
if (!(babylonMaterial instanceof PBRMaterial)) {
|
|
|
throw new Error(`${context}: Material type not supported`);
|
|
|
}
|
|
@@ -1643,7 +1643,7 @@ module BABYLON.GLTF2 {
|
|
|
* @param material The glTF material property
|
|
|
* @param babylonMaterial The Babylon material
|
|
|
*/
|
|
|
- public loadMaterialAlphaProperties(context: string, material: Loader.IMaterial, babylonMaterial: Material): void {
|
|
|
+ public loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void {
|
|
|
if (!(babylonMaterial instanceof PBRMaterial)) {
|
|
|
throw new Error(`${context}: Material type not supported`);
|
|
|
}
|
|
@@ -1683,7 +1683,7 @@ module BABYLON.GLTF2 {
|
|
|
* @param assign A function called synchronously after parsing the glTF properties
|
|
|
* @returns A promise that resolves with the loaded Babylon texture when the load is complete
|
|
|
*/
|
|
|
- public loadTextureInfoAsync(context: string, textureInfo: Loader.ITextureInfo, assign: (babylonTexture: BaseTexture) => void = () => { }): Promise<BaseTexture> {
|
|
|
+ public loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void = () => { }): Promise<BaseTexture> {
|
|
|
const extensionPromise = this._extensionsLoadTextureInfoAsync(context, textureInfo, assign);
|
|
|
if (extensionPromise) {
|
|
|
return extensionPromise;
|
|
@@ -1705,7 +1705,7 @@ module BABYLON.GLTF2 {
|
|
|
return promise;
|
|
|
}
|
|
|
|
|
|
- private _loadTextureAsync(context: string, texture: Loader.ITexture, assign: (babylonTexture: BaseTexture) => void = () => { }): Promise<BaseTexture> {
|
|
|
+ private _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void = () => { }): Promise<BaseTexture> {
|
|
|
const promises = new Array<Promise<any>>();
|
|
|
|
|
|
this.logOpen(`${context} ${texture.name || ""}`);
|
|
@@ -1744,7 +1744,7 @@ module BABYLON.GLTF2 {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- private _loadSampler(context: string, sampler: Loader.ISampler): Loader._ISamplerData {
|
|
|
+ private _loadSampler(context: string, sampler: ISampler): _ISamplerData {
|
|
|
if (!sampler._data) {
|
|
|
sampler._data = {
|
|
|
noMipMaps: (sampler.minFilter === TextureMinFilter.NEAREST || sampler.minFilter === TextureMinFilter.LINEAR),
|
|
@@ -1763,7 +1763,7 @@ module BABYLON.GLTF2 {
|
|
|
* @param image The glTF image property
|
|
|
* @returns A promise that resolves with the loaded data when the load is complete
|
|
|
*/
|
|
|
- public loadImageAsync(context: string, image: Loader.IImage): Promise<ArrayBufferView> {
|
|
|
+ public loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView> {
|
|
|
if (!image._data) {
|
|
|
this.logOpen(`${context} ${image.name || ""}`);
|
|
|
|
|
@@ -1890,7 +1890,7 @@ module BABYLON.GLTF2 {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private static _GetTextureSamplingMode(context: string, sampler: Loader.ISampler): number {
|
|
|
+ private static _GetTextureSamplingMode(context: string, sampler: ISampler): number {
|
|
|
// Set defaults if undefined
|
|
|
const magFilter = sampler.magFilter == undefined ? TextureMagFilter.LINEAR : sampler.magFilter;
|
|
|
const minFilter = sampler.minFilter == undefined ? TextureMinFilter.LINEAR_MIPMAP_LINEAR : sampler.minFilter;
|
|
@@ -2074,39 +2074,39 @@ module BABYLON.GLTF2 {
|
|
|
this._forEachExtensions((extension) => extension.onReady && extension.onReady());
|
|
|
}
|
|
|
|
|
|
- private _extensionsLoadSceneAsync(context: string, scene: Loader.IScene): Nullable<Promise<void>> {
|
|
|
+ private _extensionsLoadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>> {
|
|
|
return this._applyExtensions(scene, (extension) => extension.loadSceneAsync && extension.loadSceneAsync(context, scene));
|
|
|
}
|
|
|
|
|
|
- private _extensionsLoadNodeAsync(context: string, node: Loader.INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>> {
|
|
|
+ private _extensionsLoadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>> {
|
|
|
return this._applyExtensions(node, (extension) => extension.loadNodeAsync && extension.loadNodeAsync(context, node, assign));
|
|
|
}
|
|
|
|
|
|
- private _extensionsLoadCameraAsync(context: string, camera: Loader.ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>> {
|
|
|
+ private _extensionsLoadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>> {
|
|
|
return this._applyExtensions(camera, (extension) => extension.loadCameraAsync && extension.loadCameraAsync(context, camera, assign));
|
|
|
}
|
|
|
|
|
|
- private _extensionsLoadVertexDataAsync(context: string, primitive: Loader.IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>> {
|
|
|
+ private _extensionsLoadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>> {
|
|
|
return this._applyExtensions(primitive, (extension) => extension._loadVertexDataAsync && extension._loadVertexDataAsync(context, primitive, babylonMesh));
|
|
|
}
|
|
|
|
|
|
- private _extensionsLoadMaterialAsync(context: string, material: Loader.IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>> {
|
|
|
+ private _extensionsLoadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>> {
|
|
|
return this._applyExtensions(material, (extension) => extension._loadMaterialAsync && extension._loadMaterialAsync(context, material, babylonMesh, babylonDrawMode, assign));
|
|
|
}
|
|
|
|
|
|
- private _extensionsCreateMaterial(context: string, material: Loader.IMaterial, babylonDrawMode: number): Nullable<Material> {
|
|
|
+ private _extensionsCreateMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material> {
|
|
|
return this._applyExtensions({}, (extension) => extension.createMaterial && extension.createMaterial(context, material, babylonDrawMode));
|
|
|
}
|
|
|
|
|
|
- private _extensionsLoadMaterialPropertiesAsync(context: string, material: Loader.IMaterial, babylonMaterial: Material): Nullable<Promise<void>> {
|
|
|
+ private _extensionsLoadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>> {
|
|
|
return this._applyExtensions(material, (extension) => extension.loadMaterialPropertiesAsync && extension.loadMaterialPropertiesAsync(context, material, babylonMaterial));
|
|
|
}
|
|
|
|
|
|
- private _extensionsLoadTextureInfoAsync(context: string, textureInfo: Loader.ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>> {
|
|
|
+ private _extensionsLoadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>> {
|
|
|
return this._applyExtensions(textureInfo, (extension) => extension.loadTextureInfoAsync && extension.loadTextureInfoAsync(context, textureInfo, assign));
|
|
|
}
|
|
|
|
|
|
- private _extensionsLoadAnimationAsync(context: string, animation: Loader.IAnimation): Nullable<Promise<AnimationGroup>> {
|
|
|
+ private _extensionsLoadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>> {
|
|
|
return this._applyExtensions(animation, (extension) => extension.loadAnimationAsync && extension.loadAnimationAsync(context, animation));
|
|
|
}
|
|
|
|
|
@@ -2200,5 +2200,4 @@ module BABYLON.GLTF2 {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- GLTFFileLoader._CreateGLTFLoaderV2 = (parent) => new GLTFLoader(parent);
|
|
|
-}
|
|
|
+ GLTFFileLoader._CreateGLTF2Loader = (parent) => new GLTFLoader(parent);
|