RayCaster is not working with InstancedBufferGeometry

Hi Sir,

When I use Buffer Geometry RayCaster gives intersected Objects.But When I use InstancedBufferGeometry RayCaster is not Working.Is their any alternative ?

Thanks and Regards
Raman

Raycasting with InstancedBufferGeometry is not supported by three.js. This implementation is usually not generic but depends on the particular application. So according to the actual instanced attribute data, you need a slightly different logic.

I am Wrking on Cadd Software.so i need to add n no objects dynamically. 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. Is it Possible To Do That . We have Choose InstancdBufferGeometry for Perfomance Purpose , Earliar We were Using BufferGeometry Which lags in Perfomance. Please Help Me With Any Example.

Maybe this PR helps you further. It was never merge because the code was somewhat messed up.

hi sir,
my geometry is created by InstancedBufferGeometry and task is apply vertex point snapping on this geometry vertices so how to it

You might want to migrate your code to the new InstancedMesh class which provides raycasting support. Check out the official example to see InstancedMesh in action.

https://threejs.org/examples/webgl_instancing_raycast

But sir when is use THREE.InstancedMesh in place of THREE.mesh then show error

"Attempted import error: 'InstancedMesh' is not exported from 'three' (imported as 'THREE')"

THREE.InstancedMesh was added in R109. It seems you are using a lower version.

thank you so much sir
sir my senior suggest this example for do vertex point snapping on InstancedBufferGeometry

https://threejs.org/examples/?q=inter#webgl_interactive_instances_gpu

I want to know from you , by this example i will achieve success or not in my task and this example i not understand so which i use InstancedMesh or this Example
please give me help sir please

What version of three.js are you using? If it’s a recent version then it should be easy to update to the latest version and then you can use InstancedMesh.

1 Like

thank you sir, but if i use InstancedMesh then can i perform raycasting on object of InstancedBufferGeometry ?

Yes, if you are using the InstancedMesh “setMatrixAt” method to assign each instance’s position (as opposed to a custom shader).

how to get vertices of instanceduffergeometry object and how to done vertex point snapping task in instancedbuffergeometry object Please provide example