5

我想用 three.js 实现一个 3D 交互式地球,我想知道是否有一种方法可以将 Sprites 原语与 Raycaster 相交?

4

1 回答 1

3

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?

于 2013-03-28T04:16:51.700 回答