Intersect Sprites with Raycaster

后端 未结 1 1768
抹茶落季
抹茶落季 2021-01-18 17:23

I want to realize a 3D interactive globe with three.js and I wonder if there is a way to intersect over Sprites primitive with the Raycaster?

相关标签:
1条回答
  • 2021-01-18 17:40

    If you check the source code for RayCaster at

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

    it would appear that the intersectObject function only checks objects that are instances of THREE.Particle or THREE.Mesh, not THREE.Sprite. Possibly this is because sprites could be set to use screen coordinates, and so a ray that projects into your 3d scene wouldn't make sense in this situation, or if placed in the scene as the sprite image always faces the camera, it doesn't act like your standard 3d mesh.

    Perhaps you could attach a PlaneGeometry or a very thin CubeGeometry to the position of your sprite, set its rotation to the rotation of the camera so that it is always parallel to the view plane of the camera like the sprite is, and then check for intersections with the mesh instead?

    0 讨论(0)
提交回复
热议问题