Skip to content

Instantly share code, notes, and snippets.

@sole
Forked from Ricket/gist:2044441
Created November 20, 2012 23:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sole/4121881 to your computer and use it in GitHub Desktop.
Save sole/4121881 to your computer and use it in GitHub Desktop.
Three.js mouse picking
var projector = new THREE.Projector();
var ray = projector.pickingRay( mouseCoord, camera ); // (mouse coord are in screenspace and must be [-1, 1])
var objects = ray.intersectObjects( scene.children );
if( objects.length )
{
objects[ 0 ].object; // THREE.Particule or THREE.Mesh
objects[ 0 ].face; // THREE.Face3 or THREE.Face4 (is .object is a Mesh
objects[ 0 ].point; // THREE.Vector3
}
// found at: https://github.com/mrdoob/three.js/issues/1517#issuecomment-4520401
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment