glTFLoader.d.ts 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. import type { IGLTFRuntime } from "./glTFLoaderInterfaces";
  2. import type { Nullable } from "@babylonjs/core/types.js";
  3. import { Material } from "@babylonjs/core/Materials/material.js";
  4. import { Texture } from "@babylonjs/core/Materials/Textures/texture.js";
  5. import type { ISceneLoaderAsyncResult, ISceneLoaderProgressEvent } from "@babylonjs/core/Loading/sceneLoader.js";
  6. import type { Scene } from "@babylonjs/core/scene.js";
  7. import type { IGLTFLoader, IGLTFLoaderData } from "../glTFFileLoader";
  8. import type { AssetContainer } from "@babylonjs/core/assetContainer.js";
  9. /**
  10. * Implementation of the base glTF spec
  11. * @internal
  12. */
  13. export declare class GLTFLoaderBase {
  14. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  15. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  16. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  17. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void): void;
  18. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  19. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  20. }
  21. /**
  22. * glTF V1 Loader
  23. * @internal
  24. * @deprecated
  25. */
  26. export declare class GLTFLoader implements IGLTFLoader {
  27. static Extensions: {
  28. [name: string]: GLTFLoaderExtension;
  29. };
  30. static RegisterExtension(extension: GLTFLoaderExtension): void;
  31. dispose(): void;
  32. private _importMeshAsync;
  33. /**
  34. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  35. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  36. * @param scene the scene the meshes should be added to
  37. * @param assetContainer defines the asset container to use (can be null)
  38. * @param data gltf data containing information of the meshes in a loaded file
  39. * @param rootUrl root url to load from
  40. * @param onProgress event that fires when loading progress has occured
  41. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  42. */
  43. importMeshAsync(meshesNames: any, scene: Scene, assetContainer: Nullable<AssetContainer>, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<ISceneLoaderAsyncResult>;
  44. private _loadAsync;
  45. /**
  46. * Imports all objects from a loaded gltf file and adds them to the scene
  47. * @param scene the scene the objects should be added to
  48. * @param data gltf data containing information of the meshes in a loaded file
  49. * @param rootUrl root url to load from
  50. * @param onProgress event that fires when loading progress has occured
  51. * @returns a promise which completes when objects have been loaded to the scene
  52. */
  53. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  54. private _loadShadersAsync;
  55. private _loadBuffersAsync;
  56. private _createNodes;
  57. }
  58. /** @internal */
  59. export declare abstract class GLTFLoaderExtension {
  60. private _name;
  61. constructor(name: string);
  62. get name(): string;
  63. /**
  64. * Defines an override for loading the runtime
  65. * Return true to stop further extensions from loading the runtime
  66. * @param scene
  67. * @param data
  68. * @param rootUrl
  69. * @param onSuccess
  70. * @param onError
  71. * @returns true to stop further extensions from loading the runtime
  72. */
  73. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  74. /**
  75. * Defines an onverride for creating gltf runtime
  76. * Return true to stop further extensions from creating the runtime
  77. * @param gltfRuntime
  78. * @param onSuccess
  79. * @param onError
  80. * @returns true to stop further extensions from creating the runtime
  81. */
  82. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  83. /**
  84. * Defines an override for loading buffers
  85. * Return true to stop further extensions from loading this buffer
  86. * @param gltfRuntime
  87. * @param id
  88. * @param onSuccess
  89. * @param onError
  90. * @param onProgress
  91. * @returns true to stop further extensions from loading this buffer
  92. */
  93. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  94. /**
  95. * Defines an override for loading texture buffers
  96. * Return true to stop further extensions from loading this texture data
  97. * @param gltfRuntime
  98. * @param id
  99. * @param onSuccess
  100. * @param onError
  101. * @returns true to stop further extensions from loading this texture data
  102. */
  103. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  104. /**
  105. * Defines an override for creating textures
  106. * Return true to stop further extensions from loading this texture
  107. * @param gltfRuntime
  108. * @param id
  109. * @param buffer
  110. * @param onSuccess
  111. * @param onError
  112. * @returns true to stop further extensions from loading this texture
  113. */
  114. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  115. /**
  116. * Defines an override for loading shader strings
  117. * Return true to stop further extensions from loading this shader data
  118. * @param gltfRuntime
  119. * @param id
  120. * @param onSuccess
  121. * @param onError
  122. * @returns true to stop further extensions from loading this shader data
  123. */
  124. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  125. /**
  126. * Defines an override for loading materials
  127. * Return true to stop further extensions from loading this material
  128. * @param gltfRuntime
  129. * @param id
  130. * @param onSuccess
  131. * @param onError
  132. * @returns true to stop further extensions from loading this material
  133. */
  134. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  135. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  136. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  137. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  138. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  139. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  140. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  141. private static _LoadTextureBufferAsync;
  142. private static _CreateTextureAsync;
  143. private static _ApplyExtensions;
  144. }