fix(editor): don't crash GLB export on a material-less renderable#443
Merged
Conversation
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>
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes a GLB bake failure:
Cannot read properties of undefined (reading 'isShaderMaterial').GLTFExporterreadsmaterial.isShaderMaterialunconditionally, so any renderable (Mesh / Line / Points) with no material crashes the export. A non-Mesh renderable also slips past both theisMeshcheck inpruneNonRenderableMeshesand the material conversion pass, so it reaches the exporter untouched (e.g. an imported sub-model that left a mesh material-less).pruneNonRenderableMeshesnow 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
project_0hrQfgRZo4uiNZSo) — previously failed with theisShaderMaterialerror.Screenshots / screen recording
N/A — export-internals fix, no UI.
Checklist
bun checkto verify)bun devmainbranchNote
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
GLTFExporterhits a Mesh, Line, or Points object withmaterial == null(it readsmaterial.isShaderMaterialunconditionally). Those objects could slip past existing mesh-only pruning and the material conversion pass—e.g. material-less pieces on imported sub-models.pruneNonRenderableMeshesnow handles them before conversion: leaf renderables are removed; nodes with children are neutralised with sharedEMPTY_GEOMETRYand a hiddenPLACEHOLDER_MATERIALso 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.