123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- import type { Nullable } from "@babylonjs/core/types.js";
- import type { Animation } from "@babylonjs/core/Animations/animation.js";
- import type { AnimationGroup } from "@babylonjs/core/Animations/animationGroup.js";
- import type { Material } from "@babylonjs/core/Materials/material.js";
- import type { Camera } from "@babylonjs/core/Cameras/camera.js";
- import type { Geometry } from "@babylonjs/core/Meshes/geometry.js";
- import type { TransformNode } from "@babylonjs/core/Meshes/transformNode.js";
- import type { BaseTexture } from "@babylonjs/core/Materials/Textures/baseTexture.js";
- import type { Mesh } from "@babylonjs/core/Meshes/mesh.js";
- import type { AbstractMesh } from "@babylonjs/core/Meshes/abstractMesh.js";
- import type { IDisposable } from "@babylonjs/core/scene.js";
- import type { IScene, INode, IMesh, ISkin, ICamera, IMeshPrimitive, IMaterial, ITextureInfo, IAnimation, ITexture, IBufferView, IBuffer, IAnimationChannel } from "./glTFLoaderInterfaces";
- import type { IGLTFLoaderExtension as IGLTFBaseLoaderExtension } from "../glTFFileLoader";
- import type { IProperty } from "babylonjs-gltf2interface";
- import type { IAnimatable } from "@babylonjs/core/Animations/animatable.interface.js";
- /**
- * Interface for a glTF loader extension.
- */
- export interface IGLTFLoaderExtension extends IGLTFBaseLoaderExtension, IDisposable {
- /**
- * Called after the loader state changes to LOADING.
- */
- onLoading?(): void;
- /**
- * Called after the loader state changes to READY.
- */
- onReady?(): void;
- /**
- * Define this method to modify the default behavior when loading scenes.
- * @param context The context when loading the asset
- * @param scene The glTF scene property
- * @returns A promise that resolves when the load is complete or null if not handled
- */
- loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
- /**
- * Define this method to modify the default behavior when loading nodes.
- * @param context The context when loading the asset
- * @param node The glTF node property
- * @param assign A function called synchronously after parsing the glTF properties
- * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
- */
- loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
- /**
- * Define this method to modify the default behavior when loading cameras.
- * @param context The context when loading the asset
- * @param camera The glTF camera property
- * @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 or null if not handled
- */
- loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
- /**
- * @internal
- * Define this method to modify the default behavior when loading vertex data for mesh primitives.
- * @param context The context when loading the asset
- * @param primitive The glTF mesh primitive property
- * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
- */
- _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
- /**
- * @internal
- * Define this method to modify the default behavior when loading data for mesh primitives.
- * @param context The context when loading the asset
- * @param name The mesh name when loading the asset
- * @param node The glTF node when loading the asset
- * @param mesh The glTF mesh when loading the asset
- * @param primitive The glTF mesh primitive property
- * @param assign A function called synchronously after parsing the glTF properties
- * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
- */
- _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
- /**
- * @internal
- * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
- * @param context The context when loading the asset
- * @param material The glTF material property
- * @param assign A function called synchronously after parsing the glTF properties
- * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
- */
- _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
- /**
- * Define this method to modify the default behavior when creating materials.
- * @param context The context when loading the asset
- * @param material The glTF material property
- * @param babylonDrawMode The draw mode for the Babylon material
- * @returns The Babylon material or null if not handled
- */
- createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
- /**
- * Define this method to modify the default behavior when loading material properties.
- * @param context The context when loading the asset
- * @param material The glTF material property
- * @param babylonMaterial The Babylon material
- * @returns A promise that resolves when the load is complete or null if not handled
- */
- loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
- /**
- * Define this method to modify the default behavior when loading texture infos.
- * @param context The context when loading the asset
- * @param textureInfo The glTF texture info property
- * @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 or null if not handled
- */
- loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
- /**
- * @internal
- * Define this method to modify the default behavior when loading textures.
- * @param context The context when loading the asset
- * @param texture The glTF texture property
- * @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 or null if not handled
- */
- _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
- /**
- * Define this method to modify the default behavior when loading animations.
- * @param context The context when loading the asset
- * @param animation The glTF animation property
- * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
- */
- loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
- /**
- * @internal
- * Define this method to modify the default behvaior when loading animation channels.
- * @param context The context when loading the asset
- * @param animationContext The context of the animation when loading the asset
- * @param animation The glTF animation property
- * @param channel The glTF animation channel property
- * @param onLoad Called for each animation loaded
- * @returns A void promise that resolves when the load is complete or null if not handled
- */
- _loadAnimationChannelAsync?(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, onLoad: (babylonAnimatable: IAnimatable, babylonAnimation: Animation) => void): Nullable<Promise<void>>;
- /**
- * @internal
- * Define this method to modify the default behavior when loading skins.
- * @param context The context when loading the asset
- * @param node The glTF node property
- * @param skin The glTF skin property
- * @returns A promise that resolves when the load is complete or null if not handled
- */
- _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
- /**
- * @internal
- * Define this method to modify the default behavior when loading uris.
- * @param context The context when loading the asset
- * @param property The glTF property associated with the uri
- * @param uri The uri to load
- * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
- */
- _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
- /**
- * Define this method to modify the default behavior when loading buffer views.
- * @param context The context when loading the asset
- * @param bufferView The glTF buffer view property
- * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
- */
- loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
- /**
- * Define this method to modify the default behavior when loading buffers.
- * @param context The context when loading the asset
- * @param buffer The glTF buffer property
- * @param byteOffset The byte offset to load
- * @param byteLength The byte length to load
- * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
- */
- loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
- }
|