Open DennisSmolek opened 2 months ago
Have you seen the discussion in #2498? There's some work we can do upstream still. No. 2 was my kneejerk suggestion since we can do it here with uuid/name to find collisions.
Have you seen the discussion in #2498? There's some work we can do upstream still. No. 2 was my kneejerk suggestion since we can do it here with uuid/name to find collisions.
I forgot I was even a part of that thread lol.
I didn't even consider what happens when meshes in an object have the same material name but are different.
I think the issue has to get resolved and updated on the GLTF and then Threejs side before a permanent solution goes into place but I think we should also do something in the meantime.
Right now what happens if someone uses a material named phong1SG
it would simply ignore the second and third versions of this.
So adding phong1SG-2
wouldn't hurt anything backwards compatibility wise.
Part of me wonders Isn't the "correct" way to handle this (especially in gltfJSX) just to respect the original materials array?
Load materials[0]
instead of materials['phong1SG']
? In the GLTF Json itself that's how it identifies the material.
When working on setting up loading material variants I kept finding that useGLTF was only returning a single material when the gltf has three different ones:
The reason for this is that
useGLTF
usesuseLoader
which uses thebuildGraph
util.buildGraph
has a section specifically for materials where traverses the object and set's the materials based on the material name property.This means that in the case of
phong1SG
it hits the first result only and skips the rest.The issue is material name is often optional. Some software just adds the name 'material' or 'undefined' as the material name. Or in the case of variants, names all the variants the same material name.
I think there are 3 paths:
materialName-alt
or even fancier an index:materialName-3
This keeps it human readable but maintains uniqueness.My vote is 2 or 3. 2 is better for devs that have a system of simply listing materials from the material object without having to build logic to parse a potential array.