|
@@ -112,7 +112,9 @@ module BABYLON.GLTF2 {
|
|
this._errors = [];
|
|
this._errors = [];
|
|
this._clear();
|
|
this._clear();
|
|
|
|
|
|
- this._parent.onComplete();
|
|
|
|
|
|
+ if (this._parent.onComplete) {
|
|
|
|
+ this._parent.onComplete();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
private _loadData(data: IGLTFLoaderData): void {
|
|
private _loadData(data: IGLTFLoaderData): void {
|
|
@@ -352,13 +354,11 @@ module BABYLON.GLTF2 {
|
|
this.loadMaterial(primitive.material, (babylonSubMaterial: Material) => {
|
|
this.loadMaterial(primitive.material, (babylonSubMaterial: Material) => {
|
|
if (this._renderReady) {
|
|
if (this._renderReady) {
|
|
babylonSubMaterial.forceCompilation(babylonMesh, babylonSubMaterial => {
|
|
babylonSubMaterial.forceCompilation(babylonMesh, babylonSubMaterial => {
|
|
- babylonMultiMaterial.subMaterials[i] = babylonSubMaterial;
|
|
|
|
- this._parent.onMaterialLoaded(babylonSubMaterial);
|
|
|
|
|
|
+ this._assignMaterial(babylonMultiMaterial, i, babylonSubMaterial);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
- babylonMultiMaterial.subMaterials[i] = babylonSubMaterial;
|
|
|
|
- this._parent.onMaterialLoaded(babylonSubMaterial);
|
|
|
|
|
|
+ this._assignMaterial(babylonMultiMaterial, i, babylonSubMaterial);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
@@ -375,6 +375,14 @@ module BABYLON.GLTF2 {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private _assignMaterial(multiMaterial: MultiMaterial, index: number, subMaterial: Material): void {
|
|
|
|
+ multiMaterial.subMaterials[index] = subMaterial;
|
|
|
|
+
|
|
|
|
+ if (this._parent.onMaterialLoaded) {
|
|
|
|
+ this._parent.onMaterialLoaded(subMaterial);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
private _loadVertexDataAsync(primitive: IGLTFMeshPrimitive, onSuccess: (vertexData: VertexData) => void): void {
|
|
private _loadVertexDataAsync(primitive: IGLTFMeshPrimitive, onSuccess: (vertexData: VertexData) => void): void {
|
|
var attributes = primitive.attributes;
|
|
var attributes = primitive.attributes;
|
|
if (!attributes) {
|
|
if (!attributes) {
|
|
@@ -993,7 +1001,10 @@ module BABYLON.GLTF2 {
|
|
texture.babylonTextures = texture.babylonTextures || [];
|
|
texture.babylonTextures = texture.babylonTextures || [];
|
|
texture.babylonTextures[texCoord] = babylonTexture;
|
|
texture.babylonTextures[texCoord] = babylonTexture;
|
|
|
|
|
|
- this._parent.onTextureLoaded(babylonTexture);
|
|
|
|
|
|
+ if (this._parent.onTextureLoaded) {
|
|
|
|
+ this._parent.onTextureLoaded(babylonTexture);
|
|
|
|
+ }
|
|
|
|
+
|
|
return babylonTexture;
|
|
return babylonTexture;
|
|
}
|
|
}
|
|
}
|
|
}
|