pmndrs / gltfjsx

🎮 Turns GLTFs into JSX components
https://gltf.pmnd.rs
MIT License
4.67k stars 305 forks source link

Normal attributes are removed with --transform #278

Open hichemfantar opened 8 hours ago

hichemfantar commented 8 hours ago

Need a way to override this behavior because three.js throws an error because it expects the normal attribute to be present

related https://github.com/mrdoob/three.js/pull/29462

donmccurdy commented 5 hours ago

Currently gltfjsx (via glTF Transform) will remove a normal attribute is if the geometry is either unlit (MeshBasicMaterial) or a point cloud. three.js does not in general require a normal attribute in these cases, but it sounds like you're hitting a problem with Decal geometry. That could be fixed upstream in three.js, but I think a PR here would be OK too.

If you'd like to disable that, it would be necessary to enable the keepAttributes flag here:

https://github.com/pmndrs/gltfjsx/blob/8da0e2656649f1b2611bfac013b32ed7210d7cf0/src/utils/transform.js#L74

This change would also cause unused UVs and tangents to be kept, relevant to https://github.com/pmndrs/gltfjsx/issues/235.