Commit 4f67fd3
Editor: Fix crash when geometry lacks position attribute. (#31334)
* Fix crash when geometry lacks position attribute in Viewport.Info
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.
* Update Viewport.Info.js
---------
Co-authored-by: Michael Herzog <michael.herzog@human-interactive.org>1 parent e9277b2 commit 4f67fd3
1 file changed
Lines changed: 10 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| 63 | + | |
63 | 64 | | |
64 | | - | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
65 | 72 | | |
66 | 73 | | |
67 | 74 | | |
68 | 75 | | |
69 | 76 | | |
70 | 77 | | |
71 | 78 | | |
72 | | - | |
| 79 | + | |
73 | 80 | | |
74 | | - | |
| 81 | + | |
75 | 82 | | |
76 | 83 | | |
77 | 84 | | |
| |||
0 commit comments