does it matter? would love to have a final verdict somewhere. debug tools show 1 shader, but there are x classes with their own uuid’s, will they really all refer to the same and it’s something nobody needs to worry about?
once upon a time there was heated discussion on github over a case where uuids were causing a major memory leak because of the way javascript stores strings internally (mrdoob responded that uuids are critical for people who wish to merge their jsons (I dont think I ever saw a single person who was doing that) and since every change that removed the leak also made uuids slower, the original code will stay) iirc this was the very same discussion that got @munrocket banned.
Sounds like drama, but odd that this doesn’t seem to be documented. there’s a little about the material cache key but not enough to know if it becomes a problem if you have multiple instances of the same shader material.
Thanks for the replies:) so if i’m declaring a THREE.MeshStandardMaterial once and apply it to every mesh they do not update if im changing the texture…
This is my Code right now thats working:
I have alot of meshes where i need the texture on so it would be the best way to declare it once. But as i mentioned the texture doesnt update with correct lighting. (OFL_ZA is a prop in my component)
this document describes all the constructs and properties that require a recompile, texture is one of them three.js docs
i think it requires needsUpdate on the material according to that document.
btw, something else, useEffect fires after react has rendered and after threejs has rendered out on the screen. this can result in flash of un-styled content (FOUC). useLayoutEffect fires after react but before threejs, it hasn’t rendered yet.
i changed the r3f meshStandardMaterial to the THREE.MeshStandardMaterial in the material property. now it looks like this: (the lower left part is as i had it, not washed out. The frame around is implemented like the code above)
nothing odd, people who run into problems always write to github tickets, not to documentation files the issue about uuids is here if you want to read it. but the point is, even though a large number of js objects instances might not translate into a large number of webgl objects 3js creates, you can still run into other unrelated issue, so they cant give you the definite answer that you want.