vpenades / SharpGLTF

glTF reader and writer for .NET Standard
MIT License
467 stars 75 forks source link

Null Reference when calling MeshPrimitive.Material #63

Closed thatcosmonaut closed 4 years ago

thatcosmonaut commented 4 years ago

Hello, first off, thanks for the excellent library.

I am having an issue obtaining a reference to a material from a mesh primitive.

To reproduce:

vpenades commented 4 years ago

Yes, this is fine.

As stupid as it sounds, glTF specification allow primitives without a material being assigned to them.

So you always need to check for null before using the material. If you find a null material you must interpret it as a "default" material.

thatcosmonaut commented 4 years ago

Well, that's unfortunate. Thanks for the clarification!