Skip to content

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

Merged
Aymericr merged 1 commit into
mainfrom
fix/sentry-EDITOR-DJ
Jun 24, 2026
Merged

fix(editor): set GLTFExporter textureUtils for compressed-texture GLB export (Sentry EDITOR-DJ)#435
Aymericr merged 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
Scoped to GLB export in export-manager.tsx with an isolated decompress path that avoids touching the live WebGPU canvas renderer.

Overview
Fixes production GLB export failures when the scene uses KTX2/basis compressed textures, which three.js r184’s GLTFExporter refuses to process unless setTextureUtils() is configured.

Before exporter.parse, the export path now registers WebGPUTextureUtils.decompress (matching the editor’s WebGPU renderer) via exporter.setTextureUtils({ decompress: ... }). The live canvas renderer is not passed into decompress, because that helper can resize the renderer and leave the visible viewport corrupted; omitting it lets three use a disposable renderer for the blit.

STL/OBJ export behavior is unchanged; only the default GLB branch gains this hook.

Reviewed by Cursor Bugbot for commit 986995f. 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.

Comment thread packages/editor/src/components/editor/export-manager.tsx
three r184's GLTFExporter throws 'setTextureUtils() must be called' when a
scene contains KTX2/basis-compressed textures. Wire up WebGPUTextureUtils
(matching the app's WebGPURenderer) so compressed textures are decompressed
during GLB export.

decompress() is called without the live renderer on purpose: it resizes
whatever renderer it is given and never restores it, which would corrupt the
visible canvas. Omitting it lets three create and dispose its own throwaway
renderer for the blit.

Reworked from #435 (anton-pascal); switches WebGL->WebGPU utils and avoids the
live-renderer resize gotcha surfaced in review.

Co-authored-by: anton-pascal <anton@pascal.app>
@Aymericr Aymericr force-pushed the fix/sentry-EDITOR-DJ branch from 64b1c96 to 986995f Compare June 24, 2026 19:51
@Aymericr

Copy link
Copy Markdown
Contributor

Reworked from a dual review pass. Two changes vs the original:

  • Use WebGPUTextureUtils instead of WebGLTextureUtils: the app renders with THREE.WebGPURenderer, so the WebGPU texture utils are the correct match for r184.
  • Don't pass the live renderer to decompress(): both utils call renderer.setSize(w,h) and never restore it, which would corrupt the visible canvas after export. Omitting the renderer lets three spin up and dispose its own throwaway renderer for the blit.

Typecheck passes. Verifying CI before merge.

@Aymericr Aymericr merged commit 088f6c5 into main Jun 24, 2026
2 of 3 checks passed
@Aymericr Aymericr deleted the fix/sentry-EDITOR-DJ branch June 24, 2026 19:56
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.

3 participants