Intersecting Sprites with Raycaster

I want to implement a 3D interactive globe with a tag. js, and I wonder if there is a way to cross the Sprites primitive with Raycaster?

+4
source share
1 answer

If you check the source code for RayCaster on

https://github.com/mrdoob/three.js/blob/master/src/core/Raycaster.js

it would appear that the intersectObject function only checks objects that are THREE.Particle or THREE.Mesh instances, not THREE.Sprite. Perhaps this is due to the fact that sprites can be configured to use screen coordinates, and therefore the beam that is projected into your 3D scene does not make sense in this situation or if it fits into the scene, since the image of the sprite is always facing the camera , t, like your standard 3d mesh.

Perhaps you could attach PlaneGeometry or a very thin CubeGeometry to the position of your sprite, set its rotation to rotate the camera so that it is always parallel to the camera’s viewing plane, such as the sprite, and then check instead of intersecting with the grid?

+3
source

All Articles