Skip to content

Commit b4d9f3f

Browse files
committed
fix: resolve type errors in export-system for tsc --build
- Cast scene.clone() to Scene for GLTFExporter compatibility - Cast DataView.buffer to ArrayBuffer for STL Blob construction - Add THREE import for Object3D type in traverse callback
1 parent f2f362e commit b4d9f3f

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

packages/viewer/src/systems/export/export-system.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import { useThree } from '@react-three/fiber'
44
import { useEffect } from 'react'
5+
import type { Scene } from 'three'
6+
import * as THREE from 'three'
57
import { STLExporter } from 'three/examples/jsm/exporters/STLExporter.js'
68
import { GLTFExporter } from 'three/examples/jsm/exporters/GLTFExporter.js'
79
import { OBJExporter } from 'three/examples/jsm/exporters/OBJExporter.js'
@@ -30,8 +32,8 @@ export const ExportSystem = () => {
3032
const filename = `pascal-export-${date}`
3133

3234
// Clone scene and strip editor-only objects (layer 1 = EDITOR_LAYER)
33-
const exportRoot = scene.clone(true)
34-
const toRemove: typeof exportRoot[] = []
35+
const exportRoot = scene.clone(true) as Scene
36+
const toRemove: THREE.Object3D[] = []
3537
exportRoot.traverse((obj) => {
3638
if (obj.layers.isEnabled(EDITOR_LAYER)) {
3739
toRemove.push(obj)
@@ -55,7 +57,7 @@ export const ExportSystem = () => {
5557
} else if (format === 'stl') {
5658
const exporter = new STLExporter()
5759
const result = exporter.parse(exportRoot, { binary: true }) as DataView
58-
downloadBlob(new Blob([result], { type: 'model/stl' }), `${filename}.stl`)
60+
downloadBlob(new Blob([result.buffer as ArrayBuffer], { type: 'model/stl' }), `${filename}.stl`)
5961
} else if (format === 'obj') {
6062
const exporter = new OBJExporter()
6163
const result = exporter.parse(exportRoot)

0 commit comments

Comments
 (0)