|
@@ -19,6 +19,9 @@ module BABYLON.GLTF2 {
|
|
/** Override this method to modify the default behavior for loading nodes. */
|
|
/** Override this method to modify the default behavior for loading nodes. */
|
|
protected _loadNodeAsync(context: string, node: ILoaderNode): Nullable<Promise<void>> { return null; }
|
|
protected _loadNodeAsync(context: string, node: ILoaderNode): Nullable<Promise<void>> { return null; }
|
|
|
|
|
|
|
|
+ /** Override this method to modify the default behavior for loading mesh primitive vertex data. */
|
|
|
|
+ protected _loadVertexDataAsync(context: string, primitive: ILoaderMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<VertexData>> { return null; }
|
|
|
|
+
|
|
/** Override this method to modify the default behavior for loading materials. */
|
|
/** Override this method to modify the default behavior for loading materials. */
|
|
protected _loadMaterialAsync(context: string, material: ILoaderMaterial, babylonMesh: Mesh): Nullable<Promise<void>> { return null; }
|
|
protected _loadMaterialAsync(context: string, material: ILoaderMaterial, babylonMesh: Mesh): Nullable<Promise<void>> { return null; }
|
|
|
|
|
|
@@ -28,14 +31,14 @@ module BABYLON.GLTF2 {
|
|
// #endregion
|
|
// #endregion
|
|
|
|
|
|
/** Helper method called by a loader extension to load an glTF extension. */
|
|
/** Helper method called by a loader extension to load an glTF extension. */
|
|
- protected _loadExtensionAsync<T>(context: string, property: IProperty, actionAsync: (context: string, extension: T) => Promise<void>): Nullable<Promise<void>> {
|
|
|
|
|
|
+ protected _loadExtensionAsync<TProperty, TResult = void>(context: string, property: IProperty, actionAsync: (context: string, extension: TProperty) => Promise<TResult>): Nullable<Promise<TResult>> {
|
|
if (!property.extensions) {
|
|
if (!property.extensions) {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
const extensions = property.extensions;
|
|
const extensions = property.extensions;
|
|
|
|
|
|
- const extension = extensions[this.name] as T;
|
|
|
|
|
|
+ const extension = extensions[this.name] as TProperty;
|
|
if (!extension) {
|
|
if (!extension) {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
@@ -43,9 +46,11 @@ module BABYLON.GLTF2 {
|
|
// Clear out the extension before executing the action to avoid recursing into the same property.
|
|
// Clear out the extension before executing the action to avoid recursing into the same property.
|
|
delete extensions[this.name];
|
|
delete extensions[this.name];
|
|
|
|
|
|
- return actionAsync(context + "/extensions/" + this.name, extension).then(() => {
|
|
|
|
|
|
+ return actionAsync(context + "/extensions/" + this.name, extension).then(result => {
|
|
// Restore the extension after completing the action.
|
|
// Restore the extension after completing the action.
|
|
extensions[this.name] = extension;
|
|
extensions[this.name] = extension;
|
|
|
|
+
|
|
|
|
+ return result;
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
@@ -59,6 +64,11 @@ module BABYLON.GLTF2 {
|
|
return loader._applyExtensions(extension => extension._loadNodeAsync(context, node));
|
|
return loader._applyExtensions(extension => extension._loadNodeAsync(context, node));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /** Helper method called by the loader to allow extensions to override loading mesh primitive vertex data. */
|
|
|
|
+ public static _LoadVertexDataAsync(loader: GLTFLoader, context: string, primitive: ILoaderMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<VertexData>> {
|
|
|
|
+ return loader._applyExtensions(extension => extension._loadVertexDataAsync(context, primitive, babylonMesh));
|
|
|
|
+ }
|
|
|
|
+
|
|
/** Helper method called by the loader to allow extensions to override loading materials. */
|
|
/** Helper method called by the loader to allow extensions to override loading materials. */
|
|
public static _LoadMaterialAsync(loader: GLTFLoader, context: string, material: ILoaderMaterial, babylonMesh: Mesh): Nullable<Promise<void>> {
|
|
public static _LoadMaterialAsync(loader: GLTFLoader, context: string, material: ILoaderMaterial, babylonMesh: Mesh): Nullable<Promise<void>> {
|
|
return loader._applyExtensions(extension => extension._loadMaterialAsync(context, material, babylonMesh));
|
|
return loader._applyExtensions(extension => extension._loadMaterialAsync(context, material, babylonMesh));
|