Editor: Fix crash when geometry lacks position attribute. #31334
+10
−3
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.
This patch prevents a runtime error in Viewport.Info.js that occurs when importing a GLB file containing geometries without a position attribute. Previously, the code assumed all geometries had a position, leading to:
Viewport.Info.js:64 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'count')
at Viewport.Info.js:64:47
at Mesh.traverseVisible (three.core.js:14211:3)
at Object3D.traverseVisible (three.core.js:14217:18)
at Group.traverseVisible (three.core.js:14217:18)
at update (Viewport.Info.js:56:11)
at h.execute (signals.min.js:9:20)
at e.dispatch (signals.min.js:13:106)
at e.dispatch (signals.min.js:8:368)
at Editor.addObject (Editor.js:194:28)
at AddObjectCommand.execute (AddObjectCommand.js:29:15)
Such cases are valid in glTF and occur with point clouds, line geometries, or custom data-only meshes.
Fixes included:
Introduced a null check before accessing geometry.attributes.position.
Ensured vertex and triangle counts are calculated only if position is defined.
Used a local positionAttr variable consistently to avoid repeated access.
This change improves Editor robustness by allowing valid, non-standard GLB files to load without crashing, and maintains accurate scene statistics when available.