Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion packages/editor/src/components/editor/export-manager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ import type { Mesh, Object3D } from 'three'
import { GLTFExporter } from 'three/examples/jsm/exporters/GLTFExporter.js'
import { OBJExporter } from 'three/examples/jsm/exporters/OBJExporter.js'
import { STLExporter } from 'three/examples/jsm/exporters/STLExporter.js'
import * as WebGLTextureUtils from 'three/examples/jsm/utils/WebGLTextureUtils.js'

export function ExportManager() {
const scene = useThree((state) => state.scene)
const gl = useThree((state) => state.gl)
const setExportScene = useViewer((state) => state.setExportScene)

useEffect(() => {
Expand Down Expand Up @@ -43,6 +45,14 @@ export function ExportManager() {
// Default: GLB export (existing behavior)
const exporter = new GLTFExporter()

// Compressed (KTX2/basis) textures must be decompressed during export.
// three r184's GLTFExporter requires textureUtils (backed by the active
// WebGLRenderer) or it throws "setTextureUtils() must be called".
exporter.setTextureUtils({
decompress: (texture, maxTextureSize) =>
WebGLTextureUtils.decompress(texture, maxTextureSize, gl),
})

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong texture utils for WebGPU

High Severity

The GLB exporter is configured to use WebGLTextureUtils.decompress with the gl renderer. However, the Viewer uses WebGPURenderer, and WebGLTextureUtils is WebGL-specific. This mismatch can cause compressed (KTX2) textures to fail or mis-decompress during GLB export.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 64b1c96. Configure here.


return new Promise<void>((resolve, reject) => {
exporter.parse(
exportScene,
Expand All @@ -65,7 +75,7 @@ export function ExportManager() {
return () => {
setExportScene(null)
}
}, [scene, setExportScene])
}, [scene, gl, setExportScene])

return null
}
Expand Down
Loading