Skip to content

fix(editor): don't crash GLB export on a material-less renderable#443

Merged
wass08 merged 1 commit into
mainfrom
fix/glb-export-missing-material
Jun 25, 2026
Merged

fix(editor): don't crash GLB export on a material-less renderable#443
wass08 merged 1 commit into
mainfrom
fix/glb-export-missing-material

Conversation

@wass08

@wass08 wass08 commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

What does this PR do?

Fixes a GLB bake failure: Cannot read properties of undefined (reading 'isShaderMaterial').

GLTFExporter reads material.isShaderMaterial unconditionally, so any renderable (Mesh / Line / Points) with no material crashes the export. A non-Mesh renderable also slips past both the isMesh check in pruneNonRenderableMeshes and the material conversion pass, so it reaches the exporter untouched (e.g. an imported sub-model that left a mesh material-less).

pruneNonRenderableMeshes now guards it: a material-less renderable is dropped if it's a leaf, or neutralised (empty geometry + a hidden placeholder material) if it has children, so its subtree survives. This runs before material conversion, so both crash paths are covered.

It surfaced now because disabling post-processing during bake (?disable=postFx) lets these scenes load fast enough to actually reach the export.

How to test

  1. Bake a project that has a material-less renderable (repro: project_0hrQfgRZo4uiNZSo) — previously failed with the isShaderMaterial error.
  2. The bake completes and produces a valid GLB; the material-less object is omitted (or an empty transform node if it had children).
  3. Other projects export unchanged.

Screenshots / screen recording

N/A — export-internals fix, no UI.

Checklist

  • My code follows the existing code style (run bun check to verify)
  • I've tested this locally with bun dev
  • This PR targets the main branch

Note

Low Risk
Scoped to export-time scene pruning on the cloned bake tree; no auth, persistence, or live editor rendering changes.

Overview
Fixes GLB bake crashes when GLTFExporter hits a Mesh, Line, or Points object with material == null (it reads material.isShaderMaterial unconditionally). Those objects could slip past existing mesh-only pruning and the material conversion pass—e.g. material-less pieces on imported sub-models.

pruneNonRenderableMeshes now handles them before conversion: leaf renderables are removed; nodes with children are neutralised with shared EMPTY_GEOMETRY and a hidden PLACEHOLDER_MATERIAL so the subtree stays in the export tree without emitting a broken primitive.

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

Baking some projects failed with "Cannot read properties of undefined (reading
'isShaderMaterial')". GLTFExporter reads material.isShaderMaterial unconditionally,
so a renderable (Mesh / Line / Points) with no material crashes the export — and a
non-Mesh renderable slips past both the isMesh prune check and material conversion.

Guard it in pruneNonRenderableMeshes: a material-less renderable is dropped if it's
a leaf, or neutralised (empty geometry + a hidden placeholder material) if it has
children so its subtree survives. Post-FX disable now lets these scenes reach the
exporter, which is why it surfaced.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@wass08 wass08 merged commit a3aecf1 into main Jun 25, 2026
2 checks passed
@mintlify

mintlify Bot commented Jun 25, 2026

Copy link
Copy Markdown

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

Project Status Preview Updated (UTC)
pascal 🔴 Failed Jun 25, 2026, 8:54 PM

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

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