Skip to content

Conversation

@AlexRynas
Copy link
Contributor

@AlexRynas AlexRynas commented Jun 30, 2025

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.

AlexRynas and others added 2 commits June 30, 2025 10:41
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.
@Mugen87 Mugen87 changed the title Fix crash when geometry lacks position attribute in Viewport.Info Editor: Fix crash when geometry lacks position attribute. Jun 30, 2025
@Mugen87 Mugen87 added this to the r179 milestone Jun 30, 2025
@Mugen87 Mugen87 merged commit 4f67fd3 into mrdoob:dev Jun 30, 2025
10 of 11 checks passed
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.

2 participants