You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have point cloud scans that yield models without any materials once converted to GLTF/GLB.
These models visually load, but then, break the code at a few places. This brought me to investigate further the situation.
As far as I can tell, I have encountered 2 situations where the code breaks with these unconventional files.
Case 1: File with no "materials" property in the GLTF
In model-viewer/src/features/scene-graph/model.ts
Suggestion: Don't use the ! syntax in gltf.materials!.entries() and do a null check instead gltf.materials?.entries() ?? []
Case 2: File with the "materials" property in the GLTF but no material associated in the mesh primitives
In model-viewer/src/features/scene-graph/nodes/primitive-node.ts
This is another case where I seem to be the only one having to deal with bizarre GLTF structures 😆 . I will open a PR for this if that is ok with you guys.
Version
model-viewer: v1.10.1
Browser Affected
Chrome, version: latest
Edge
Firefox
IE
Safari
OS
Android
iOS
Linux
MacOS
Windows
The text was updated successfully, but these errors were encountered:
Thank you! A PR would be great, since you have the files to test. You may want to add a simple test case as well. We don't have much in the way of point cloud users, so I'm not surprised this is having some trouble.
Description
I have point cloud scans that yield models without any materials once converted to GLTF/GLB.
These models visually load, but then, break the code at a few places. This brought me to investigate further the situation.
As far as I can tell, I have encountered 2 situations where the code breaks with these unconventional files.
Case 1: File with no "materials" property in the GLTF
In
model-viewer/src/features/scene-graph/model.ts
Suggestion: Don't use the
!
syntax ingltf.materials!.entries()
and do a null check insteadgltf.materials?.entries() ?? []
Case 2: File with the "materials" property in the GLTF but no material associated in the mesh primitives
In
model-viewer/src/features/scene-graph/nodes/primitive-node.ts
Suggestion: Simple null check
materialMappings?.materials != null
This is another case where I seem to be the only one having to deal with bizarre GLTF structures 😆 . I will open a PR for this if that is ok with you guys.
Version
Browser Affected
OS
The text was updated successfully, but these errors were encountered: