On hover change color for instanced mesh

Hello BABYLON folks!
This is my first post here, and first of all let me thank you for this awesome engine!
I am deeply and truly amazed: Features, Docs, Forum, Community, Youtube channel, Playground, Sandbox, Inspector, Editors for all kinds of stuff. Absolutely mind-blowing. Breathtaking!

After start of my journey back in Mart 1, I finally get stuck. The problem is pretty described in topic title.
here is my solution so far (if it doesn’t render please drag camera a little)
https://playground.babylonjs.com/#XQ7IFU#2
I guess I can pinpoint the problem to single thing:
find index of instanced mesh to change data in sourcemesh vertex buffer
thanks in advance

You can use the registerInstancedBuffer method instead of handling the vertex buffer data yourself.

That way, you can access the color property of each instance right on the instance mesh itself, making everything easier:

https://playground.babylonjs.com/#XQ7IFU#3

3 Likes

Simply brilliant. Thank you.

Just to wrap this up, here is final solution
https://playground.babylonjs.com/#XQ7IFU#4

1 Like