How to change texture per instance in InstancedMesh?

Hello, I’m new to three.js. How does that possible if my mouse moves to the ball, it changes the texture instead of changing the color?
https://threejs.org/examples/#webgl_instancing_raycast

Because I saw the document, the methods only setColorAt and setMatrixAt can control the ball, how do I change the texture? Thanks.
https://threejs.org/docs/#api/en/objects/InstancedMesh

if you check how those methods work, you’ll see that they just alter the values in attributes, while textures end up being set via uniforms. however, you could have an attribute of indices into a texture atlas, for example. in simpler terms, it not quite possible but you can fake it.

3 Likes

Thanks, is there any sample code I can reference?

related How to set different textures on each InstancedMesh?

2 Likes

/cc

1 Like