Skip to content

Commit

Permalink
fix: restore STLExporter interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyJasonBennett committed Jan 15, 2024
1 parent 68f3230 commit 69ce9fa
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/exporters/STLExporter.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { BufferAttribute, InterleavedBufferAttribute, Mesh, Object3D, PlaneGeometry, SkinnedMesh, Vector3 } from 'three'

interface STLExporterOptions {
export interface STLExporterOptionsBinary {
binary: true
}

export interface STLExporterOptionsString {
binary?: false
}

export interface STLExporterOptions {
binary?: boolean
}

/**
* The official threejs build breaks on empty BufferGeometries,
* while the three-stdlib has a broken non-binary export.
* This implementation is derived from the latter, with fixes.
*/
export class STLExporter {
private binary

Expand Down Expand Up @@ -42,10 +45,9 @@ export class STLExporter {
this.normal = new Vector3()
}

parse(scene: Object3D, options: { binary: true }): DataView
parse(scene: Object3D, options: { binary: false }): string

public parse(scene: Object3D, options?: STLExporterOptions): string | DataView {
parse(scene: Object3D, options: STLExporterOptionsBinary): DataView
parse(scene: Object3D, options?: STLExporterOptionsString): string
parse(scene: Object3D, options?: STLExporterOptions): string | DataView {
this.binary = options?.binary !== undefined ? options?.binary : false

scene.traverse((object: Object3D) => {
Expand Down

0 comments on commit 69ce9fa

Please sign in to comment.