-
Hi guys, I've got a question: Is it possible to animate the scaling of a particular instance in an instancedMesh? I can't just scale the whole mesh since that affects all instances. I know the transforms of all instances are found in instanceMatrix. Right now I've managed to change the scale by using .setMatrixAt() and updating the transform matrix for that instance, but that increases the size instantly. Check out the example here: https://codesandbox.io/s/instance-scale-gk5k8?file=/src/App.js |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
of course. you can use lerp. for this to work you need useframe and you need a mutable data representation. here's an example: https://codesandbox.io/s/instanced-vertex-colors-8fo01?file=/src/index.js your code seems way too complex. you dont need to raycast, events are inbuilt in r3f and you can have them on instanced meshes as well. you get the INDEX of the instance in the event data as "instanceId" |
Beta Was this translation helpful? Give feedback.
of course. you can use lerp. for this to work you need useframe and you need a mutable data representation.
here's an example: https://codesandbox.io/s/instanced-vertex-colors-8fo01?file=/src/index.js
your code seems way too complex. you dont need to raycast, events are inbuilt in r3f and you can have them on instanced meshes as well. you get the INDEX of the instance in the event data as "instanceId"