Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support models lacking the "materials" property or primitive/material association #3279

Open
2 of 10 tasks
alexdaube opened this issue Mar 17, 2022 · 1 comment · May be fixed by #3287
Open
2 of 10 tasks

Support models lacking the "materials" property or primitive/material association #3279

alexdaube opened this issue Mar 17, 2022 · 1 comment · May be fixed by #3287

Comments

@alexdaube
Copy link
Contributor

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

Screen Shot 2022-03-16 at 9 49 06 PM

In model-viewer/src/features/scene-graph/model.ts
Screen Shot 2022-03-16 at 9 49 44 PM

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

Screen Shot 2022-03-16 at 9 55 48 PM

In model-viewer/src/features/scene-graph/nodes/primitive-node.ts
Screen Shot 2022-03-16 at 9 55 16 PM

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

  • model-viewer: v1.10.1

Browser Affected

  • Chrome, version: latest
  • Edge
  • Firefox
  • IE
  • Safari

OS

  • Android
  • iOS
  • Linux
  • MacOS
  • Windows
@elalish
Copy link
Collaborator

elalish commented Mar 17, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants