GLTFLoader.d.ts 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import {
  2. AnimationClip,
  3. Camera,
  4. Group,
  5. Loader,
  6. LoadingManager,
  7. Mesh,
  8. Object3D,
  9. Material,
  10. SkinnedMesh,
  11. Texture
  12. } from '../../../src/Three';
  13. import { DRACOLoader } from './DRACOLoader';
  14. import { DDSLoader } from './DDSLoader';
  15. import { KTX2Loader } from './KTX2Loader';
  16. export interface GLTF {
  17. animations: AnimationClip[];
  18. scene: Group;
  19. scenes: Group[];
  20. cameras: Camera[];
  21. asset: {
  22. copyright?: string;
  23. generator?: string;
  24. version?: string;
  25. minVersion?: string;
  26. extensions?: any;
  27. extras?: any;
  28. };
  29. parser: GLTFParser;
  30. userData: any;
  31. }
  32. export class GLTFLoader extends Loader {
  33. constructor( manager?: LoadingManager );
  34. dracoLoader: DRACOLoader | null;
  35. ddsLoader: DDSLoader | null;
  36. load( url: string, onLoad: ( gltf: GLTF ) => void, onProgress?: ( event: ProgressEvent ) => void, onError?: ( event: ErrorEvent ) => void ) : void;
  37. setDRACOLoader( dracoLoader: DRACOLoader ): GLTFLoader;
  38. setDDSLoader( ddsLoader: DDSLoader ): GLTFLoader;
  39. register( callback: ( parser: GLTFParser ) => GLTFLoaderPlugin ): GLTFLoader;
  40. unregister( callback: ( parser: GLTFParser ) => GLTFLoaderPlugin ): GLTFLoader;
  41. setKTX2Loader( ktx2Loader: KTX2Loader ): GLTFLoader;
  42. setMeshoptDecoder( meshoptDecoder: /* MeshoptDecoder */ any ): GLTFLoader;
  43. parse( data: ArrayBuffer | string, path: string, onLoad: ( gltf: GLTF ) => void, onError?: ( event: ErrorEvent ) => void ) : void;
  44. }
  45. export interface GLTFReference {
  46. type: 'materials'|'nodes'|'textures';
  47. index: number;
  48. }
  49. export class GLTFParser {
  50. json: any;
  51. associations: Map<Object3D|Material|Texture, GLTFReference>;
  52. getDependency: ( type: string, index: number ) => Promise<any>;
  53. getDependencies: ( type: string ) => Promise<any[]>;
  54. }
  55. export interface GLTFLoaderPlugin {
  56. loadMesh?: ( meshIndex: number ) => Promise<Group | Mesh | SkinnedMesh> | null;
  57. loadBufferView?: ( bufferViewIndex: number ) => Promise<ArrayBuffer> | null;
  58. loadMaterial?: ( materialIndex: number ) => Promise<Material> | null;
  59. loadTexture?: ( textureIndex: number ) => Promise<Texture> | null;
  60. getMaterialType?: ( materialIndex: number ) => typeof Material | null;
  61. extendMaterialParams?: ( materialIndex: number, materialParams: { [ key: string ]: any } ) => Promise<any> | null;
  62. createNodeAttachment?: ( nodeIndex: number ) => Promise<Object3D> | null;
  63. }