Przeglądaj źródła

Merge pull request #20713 from FMS-Cat/types-gltfloader-plugins

types (GLTFLoader): add definitions about plugin system
Mr.doob 4 lat temu
rodzic
commit
fd4c1708b3
1 zmienionych plików z 18 dodań i 0 usunięć
  1. 18 0
      examples/jsm/loaders/GLTFLoader.d.ts

+ 18 - 0
examples/jsm/loaders/GLTFLoader.d.ts

@@ -4,8 +4,10 @@ import {
 	Group,
 	Loader,
 	LoadingManager,
+	Mesh,
 	Object3D,
 	Material,
+	SkinnedMesh,
 	Texture
 } from '../../../src/Three';
 
@@ -39,6 +41,10 @@ export class GLTFLoader extends Loader {
 	load( url: string, onLoad: ( gltf: GLTF ) => void, onProgress?: ( event: ProgressEvent ) => void, onError?: ( event: ErrorEvent ) => void ) : void;
 	setDRACOLoader( dracoLoader: DRACOLoader ): GLTFLoader;
 	setDDSLoader( ddsLoader: DDSLoader ): GLTFLoader;
+
+	register( callback: ( parser: GLTFParser ) => GLTFLoaderPlugin ): GLTFLoader;
+	unregister( callback: ( parser: GLTFParser ) => GLTFLoaderPlugin ): GLTFLoader;
+
 	setKTX2Loader( ktx2Loader: KTX2Loader ): GLTFLoader;
 	setMeshoptDecoder( meshoptDecoder: /* MeshoptDecoder */ any ): GLTFLoader;
 
@@ -61,3 +67,15 @@ export class GLTFParser {
 	getDependencies: ( type: string ) => Promise<any[]>;
 
 }
+
+export interface GLTFLoaderPlugin {
+
+	loadMesh?: ( meshIndex: number ) => Promise<Group | Mesh | SkinnedMesh> | null;
+	loadBufferView?: ( bufferViewIndex: number ) => Promise<ArrayBuffer> | null;
+	loadMaterial?: ( materialIndex: number ) => Promise<Material> | null;
+	loadTexture?: ( textureIndex: number ) => Promise<Texture> | null;
+	getMaterialType?: ( materialIndex: number ) => typeof Material | null;
+	extendMaterialParams?: ( materialIndex: number, materialParams: { [ key: string ]: any } ) => Promise<any> | null;
+	createNodeAttachment?: ( nodeIndex: number ) => Promise<Object3D> | null;
+
+}