On mouse clicks, I project a ray to see which objects are intersected by the click. I have a bunch of Mesh objects that this works with. When I add a Sprite to the list of objects however, the Sprite is never detected.
1) Should Sprites be detected? Is there something that makes them not detectable? Is there something that I need to do to make them appear 'solid'? 2) If Sprites cannot be detected, what's the best approach to making them clickable? Add invisible cylinders around them?
Here's 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) {
It seems as though the intersectObject
method in the Raycaster class is only configured to look for collisions with THREE.Particle and THREE.Mesh. See the current source code at:
https://github.com/mrdoob/three.js/blob/master/src/core/Raycaster.js
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With