Select particular instance from InstanceBufferGeometry

Hi Sir ,
I am Using InstancedBufferGeometry in order to Draw 10000 Lines. I want to Get Each Instance Line From That 10000 Line .So that i can Select, Rotate and Translate each Instance Separetaly and dynamically. Can i Get single Instance Using RayCaster.Is it Possible To Do That . We have Choose InstancdBufferGeometry for Perfomance Purpose , Earliar We were Using BufferGeometry Which lags in Perfomance.

Thanks and Regards
Deepak

Hey Deepak.

No, you can’t use Raycaster with InstancedBufferGeometry. I have recently solved a similar problem.

You can solve this by overriding mesh.raycast logic for your instances mesh. Presumably you have a Float32Array with your vertex positions for each line, and there’s a raycast implementation for Line, the logic from which you can probably reuse.

I ended up doing a similar thing, but creating an array of Box3s for the space containing each of the objects that I was instancing, then iterating over those boxes inside the raycast function. You end up not having some of the information that raycast returns - uv, etc. But, if you don’t use that info in your handler function, that shouldn’t be a problem.

Good luck!