Detecting rays crossing a sprite

When I click the mouse, I project a ray to see which objects intersect with a click. I have a bunch of Mesh objects this works with. When I add Sprite to the list of objects, Sprite is never detected.

1) Should sprites be detected? Is there something that makes them undetectable? Is there anything I need to do to make them appear “solid”? 2) If sprites cannot be detected, what is the best approach to make them clickable? Add invisible cylinders around them?

Here is some partial code that works with Mesh.

var containerPosition = $container.position();
var vector = new THREE.Vector3(((event.clientX - containerPosition.left) / scene.WIDTH) * 2 - 1, - ((event.clientY - containerPosition.top) / scene.HEIGHT) * 2 + 1, 0.5);
new THREE.Projector().unprojectVector(vector, scene.camera);
var ray = new THREE.Ray(scene.camera.position, vector.subSelf(scene.camera.position).normalize());
var intersects = ray.intersectObjects(scene.solidObjects);
if (intersects.length > 0) {
+5
source share
1 answer

, intersectObject Raycaster THREE.Particle THREE.Mesh. . :

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

+2

All Articles