babylon.glTFLoaderExtension.ts 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /// <reference path="../../../../dist/preview release/babylon.d.ts"/>
  2. module BABYLON.GLTF2 {
  3. /**
  4. * Interface for a glTF loader extension.
  5. */
  6. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  7. /**
  8. * Called after the loader state changes to LOADING.
  9. */
  10. onLoading?(): void;
  11. /**
  12. * Called after the loader state changes to READY.
  13. */
  14. onReady?(): void;
  15. /**
  16. * Define this method to modify the default behavior when loading scenes.
  17. * @param context The context when loading the asset
  18. * @param scene The glTF scene property
  19. * @returns A promise that resolves when the load is complete or null if not handled
  20. */
  21. loadSceneAsync?(context: string, scene: Loader.IScene): Nullable<Promise<void>>;
  22. /**
  23. * Define this method to modify the default behavior when loading nodes.
  24. * @param context The context when loading the asset
  25. * @param node The glTF node property
  26. * @param assign A function called synchronously after parsing the glTF properties
  27. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  28. */
  29. loadNodeAsync?(context: string, node: Loader.INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  30. /**
  31. * Define this method to modify the default behavior when loading cameras.
  32. * @param context The context when loading the asset
  33. * @param camera The glTF camera property
  34. * @param assign A function called synchronously after parsing the glTF properties
  35. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  36. */
  37. loadCameraAsync?(context: string, camera: Loader.ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  38. /**
  39. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  40. * @param context The context when loading the asset
  41. * @param primitive The glTF mesh primitive property
  42. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  43. */
  44. _loadVertexDataAsync?(context: string, primitive: Loader.IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  45. /**
  46. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  47. * @param context The context when loading the asset
  48. * @param material The glTF material property
  49. * @param assign A function called synchronously after parsing the glTF properties
  50. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  51. */
  52. _loadMaterialAsync?(context: string, material: Loader.IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  53. /**
  54. * Define this method to modify the default behavior when creating materials.
  55. * @param context The context when loading the asset
  56. * @param material The glTF material property
  57. * @param babylonDrawMode The draw mode for the Babylon material
  58. * @returns The Babylon material or null if not handled
  59. */
  60. createMaterial?(context: string, material: Loader.IMaterial, babylonDrawMode: number): Nullable<Material>;
  61. /**
  62. * Define this method to modify the default behavior when loading material properties.
  63. * @param context The context when loading the asset
  64. * @param material The glTF material property
  65. * @param babylonMaterial The Babylon material
  66. * @returns A promise that resolves when the load is complete or null if not handled
  67. */
  68. loadMaterialPropertiesAsync?(context: string, material: Loader.IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69. /**
  70. * Define this method to modify the default behavior when loading texture infos.
  71. * @param context The context when loading the asset
  72. * @param textureInfo The glTF texture info property
  73. * @param assign A function called synchronously after parsing the glTF properties
  74. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  75. */
  76. loadTextureInfoAsync?(context: string, textureInfo: Loader.ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  77. /**
  78. * Define this method to modify the default behavior when loading animations.
  79. * @param context The context when loading the asset
  80. * @param animation The glTF animation property
  81. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  82. */
  83. loadAnimationAsync?(context: string, animation: Loader.IAnimation): Nullable<Promise<AnimationGroup>>;
  84. /**
  85. * Define this method to modify the default behavior when loading uris.
  86. * @param context The context when loading the asset
  87. * @param uri The uri to load
  88. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  89. */
  90. _loadUriAsync?(context: string, uri: string): Nullable<Promise<ArrayBufferView>>;
  91. }
  92. }
  93. /**
  94. * Defines the module for the built-in glTF 2.0 loader extensions.
  95. */
  96. module BABYLON.GLTF2.Loader.Extensions {
  97. }