You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using v9 and I ran into an issue were a texture that I was using kept being overwritten.
Let's say I have 3 textures A, B, and C and a component with a MeshBasicMaterial. When I pass texture A to the map prop of the material, then later on B and finally C, my component seems to render the updates fine. However when I pass texture A again, I see no update.
I realized that the material kept using the same texture (A) but that the contents of it kept being overwritten with the other textures. So when using texture A again after C no change was visible because its contents were overwritten by C.
I created a pull request that doesn't copy a new texture into an existing one on a instance on prop change by checking the UUID. It fixes the issue in my case, but not sure if this is the right approach.
The text was updated successfully, but these errors were encountered:
thanks! this is really interesting! you are 100% right that this is bugged or wrong behaviour, just nobody stepped into it yet.
this is what happens currently:
map={a}, because map is originally NULL fiber will mutate material.map = a 👍
map={b}, which in fiber translates to material.map.copy(b) because both target & value constructors now match and have .copy(), the texture gets overwritten with B, so A is destroyed 😬
map={a}, which is material.map(a), it copies itself and will still show texture B 🫣
the problem is that it has destroyed the A texture, the app can never go back to that
the correct behaviour would imo be,
map = a because map is NULL 👍
map = b, bc it originally used to be NULL, we must assume an external object that we shouldn't mutate directly 👍
map = a, bc it originally used to be NULL, same as above 👍
it would now show texture A
we can probably detect if something was originally NULL ... we do something similar in the diffProps function, fiber maintains a collection of default/original values. this could tap into that and check.
I'm using v9 and I ran into an issue were a texture that I was using kept being overwritten.
Let's say I have 3 textures
A
,B
, andC
and a component with aMeshBasicMaterial
. When I pass textureA
to themap
prop of the material, then later onB
and finallyC
, my component seems to render the updates fine. However when I pass textureA
again, I see no update.I realized that the material kept using the same texture (
A
) but that the contents of it kept being overwritten with the other textures. So when using textureA
again afterC
no change was visible because its contents were overwritten byC
.I created a pull request that doesn't copy a new texture into an existing one on a instance on prop change by checking the UUID. It fixes the issue in my case, but not sure if this is the right approach.
The text was updated successfully, but these errors were encountered: