Skip to content

Commit

Permalink
fix (GLTFExporter): add register / unregister
Browse files Browse the repository at this point in the history
add GLTFWriter and GLTFExporterPlugin
The interfaces of GLTFWriter is not exhaustive yet

See: https://github.com/mrdoob/three.js/blob/c7d06c02e302ab9c20fe8b33eade4b61c6712654/examples/jsm/exporters/GLTFExporter.js#L69-L91
  • Loading branch information
0b5vr committed Apr 25, 2022
1 parent 75c5f60 commit ed8a6f9
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion types/three/examples/jsm/exporters/GLTFExporter.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Object3D, AnimationClip } from '../../../src/Three';
import { Object3D, AnimationClip, Texture, Material, Mesh } from '../../../src/Three';

export interface GLTFExporterOptions {
/**
Expand Down Expand Up @@ -50,6 +50,9 @@ export interface GLTFExporterOptions {
export class GLTFExporter {
constructor();

register(callback: (writer: GLTFWriter) => GLTFExporterPlugin): this;
unregister(callback: (writer: GLTFWriter) => GLTFExporterPlugin): this;

/**
* Generates a .gltf (JSON) or .glb (binary) output from the input (Scenes or Objects)
*
Expand Down Expand Up @@ -93,3 +96,31 @@ export class GLTFExporter {
options?: GLTFExporterOptions,
): Promise<ArrayBuffer | { [key: string]: any }>;
}

export class GLTFWriter {
constructor();

setPlugins(plugins: GLTFExporterPlugin[]);

/**
* Parse scenes and generate GLTF output
*
* @param input Scene or Array of THREE.Scenes
* @param onDone Callback on completed
* @param options options
*/
write(
input: Object3D | Object3D[],
onDone: (gltf: ArrayBuffer | { [key: string]: any }) => void,
options?: GLTFExporterOptions,
): Promise<void>;
}

export interface GLTFExporterPlugin {
writeTexture?: (map: Texture, textureDef: { [key: string]: any }) => void;
writeMaterial?: (material: Material, materialDef: { [key: string]: any }) => void;
writeMesh?: (mesh: Mesh, meshDef: { [key: string]: any }) => void;
writeNode?: (object: Object3D, nodeDef: { [key: string]: any }) => void;
beforeParse?: (input: Object3D | Object3D[]) => void;
afterParse?: (input: Object3D | Object3D[]) => void;
}

0 comments on commit ed8a6f9

Please sign in to comment.