I have been playing around with setting up a scene and made one I like but it started initially with a template from code-sandbox, now I want to swap the glb file with my own but the shaders don’t seem to convert to the new object despite me renaming etc. Here is an example similar to my own situation, https://codesandbox.io/s/floating-diamonds-s7qmh - trying to replace diamond.glb with rupee.glb
What exactly is the issue here? as I thought gltf loader makes this process trivial (reloading coordinates etc).
Any insight would be appreciated.
Thanks.
Here is athe post i made in the react three fiber forum 
I can’t quite tell what you’re asking sorry, and for some reason I can’t see the code in your sandbox link… in threejs, a mesh has a material and a geometry. A shader is generated from the material. Are you trying to assign a new material to meshes from different glTF files, and finding that it works for some glTF files and not others?
More details might help, but a first guess would be that perhaps one file has UVs and another does not.
So, UVs are stored in the glb? as i have tested various files and some just render with their grey texture, not the shader that works on it currently.
Are you trying to assign a new material to meshes from different glTF files, and finding that it works for some glTF files and not others?
Yes
A glTF file may contain more than one mesh, or sometimes lights or cameras. If you console.log()
the gltf
variable for rupee.glb
, you’ll see that it has more objects in it:

For the diamond.glb
file you were using the 1-indexed object, but in this case that’s a light. Using ...gltf.__$[3].geometry
instead fixes the scene:
2 Likes
OMg, i see, didnt know there was so much inside the glb from blender, this finally makes sense, thanks!!