Skip to content

fix(editor): set GLTFExporter textureUtils for compressed-texture GLB export (Sentry EDITOR-DJ)#435

Open
anton-pascal wants to merge 1 commit into
mainfrom
fix/sentry-EDITOR-DJ
Open

fix(editor): set GLTFExporter textureUtils for compressed-texture GLB export (Sentry EDITOR-DJ)#435
anton-pascal wants to merge 1 commit into
mainfrom
fix/sentry-EDITOR-DJ

Conversation

@anton-pascal

@anton-pascal anton-pascal commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Sentry: MONOREPO-EDITOR-DJ (production)

THREE.GLTFExporter: setTextureUtils() must be called to process compressed textures.

Root cause

GLB export (GLTFExporter) of a scene containing compressed (KTX2/basis) textures throws under three.js r184. r184's GLTFExporter requires a textureUtils object (backed by the active WebGLRenderer) to decompress compressed textures during export. Without it, exporter.parse(..., { binary: true }) throws and the export fails.

Fix

In packages/editor/src/components/editor/export-manager.tsx:

  • Pull the active renderer via const gl = useThree((state) => state.gl).
  • Import the decompress helper: import * as WebGLTextureUtils from 'three/examples/jsm/utils/WebGLTextureUtils.js'.
  • Call exporter.setTextureUtils({ decompress: (texture, maxTextureSize) => WebGLTextureUtils.decompress(texture, maxTextureSize, gl) }) before exporter.parse(...).
  • Added gl to the useEffect dependency array.

This lets the exporter decompress KTX2/compressed textures using the live renderer, resolving the throw.

Verification

  • bun run check-types (package @pascal-app/editor): no errors introduced in export-manager.tsx. (Pre-existing, unrelated workspace dependency-version typecheck errors in other files remain and are out of scope for this fix.)
  • biome check on the touched file: clean, no fixes applied.

Do not auto-merge — opening for review only.


Note

Low Risk
Small, localized change to the GLB export path only; no auth, persistence, or broader rendering pipeline changes.

Overview
Fixes GLB export failing when the scene uses KTX2/basis compressed textures under three.js r184, which throws unless GLTFExporter has textureUtils configured.

ExportManager now reads the active WebGLRenderer from R3F (useThreegl), imports WebGLTextureUtils, and calls exporter.setTextureUtils with a decompress hook that delegates to WebGLTextureUtils.decompress(texture, maxTextureSize, gl) before parse. The export useEffect dependency list includes gl so the registered export function stays aligned with the current renderer.

Reviewed by Cursor Bugbot for commit 64b1c96. Bugbot is set up for automated code reviews on this repo. Configure here.

@mintlify

mintlify Bot commented Jun 22, 2026

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
pascal 🔴 Failed Jun 22, 2026, 4:07 AM

💡 Tip: Enable Workflows to automatically generate PRs for you.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant