Three.js: how about that add InstancdMesh.raycast ?

Created on 18 Nov 2019  Â·  6Comments  Â·  Source: mrdoob/three.js

how about that add InstancdMesh.raycast ?

At work, I used instancedmesh to improve program performance. Sometimes you need to know the ID of each instance by picking, such as this problem #17906 .
I made a demo about getting instance ID by raycast not gpu picking. In this demo, clicking the instance will rotate to indicate that it is selected.
And I have done more about the raycast of multi instance rendering of morphTargets , which seems to work well.

This is an online demo of Demo:

This is the demo code:
https://github.com/webglzhang/three.js/blob/dev/src/objects/Mesh.js
https://github.com/webglzhang/three.js/blob/dev/src/objects/InstancedMesh.js
https://github.com/webglzhang/three.js/blob/dev/examples/webgl_instancing_raycast.html

How about this case? We can discuss whether three.js needs this function. If so, I can make this pr. thanks.

All 6 comments

I think it would be great to call Mesh.raycast() in some way instead of copying it into InstancedMesh.raycast(). Do you think this is possible?

After you respond to @Mugen87, I think a PR would be nice. Be sure to avoid calling new THREE.Matrix4() inside the render loop; create one instance and reuse it.

I think it would be great to call Mesh.raycast() in some way instead of copying it into InstancedMesh.raycast(). Do you think this is possible?

This is a very good idea. I'm trying to realize it these days and see how it works.

After you respond to @Mugen87, I think a PR would be nice. Be sure to avoid calling new THREE.Matrix4() inside the render loop; create one instance and reuse it.

I will pay attention to this situation, thank you for your reminding!

@Mugen87 @WestLangley Hey, I remade the demo and further extend this approach to the deformation target. It looks good. I updated the question. How does it look?

I suggest you make a PR so it's easier to identify the diff.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

seep picture seep  Â·  3Comments

danieljack picture danieljack  Â·  3Comments

ghost picture ghost  Â·  3Comments

zsitro picture zsitro  Â·  3Comments

clawconduce picture clawconduce  Â·  3Comments