Im using PointerLockControls and i want to hit the detection of the mouse …
i have tried :
var vector = new ThreeVector3JSClass( mouse.x , mouse.y, 1 );
var cameraDirection = controls.getDirection(vector).clone();
projector.unprojectVector(cameraDirection,activeCamera );
var ray = new THREE.Raycaster(controls.getObject().position, cameraDirection.sub(controls.getObject().position).normalize());
var intersects = ray.intersectObjects(objects);
if (intersects.length>0){
console.log("Intersected object:", intersects.length);
intersects[ 0 ].object.material.color.setHex( Math.random() * 0xffffff );
}
What is ThreeVector3JSClass?
And why not to use code snippets from THREE.Raycaster()? Or from official interactive examples?
And out of curiousity, what revision of Three.js do you use?
IMHO, there are not so many people who’d like to go deep into an ancient versions of the framework just for fun and wasting time. I started with r68, but if nowadays there’s a choice between r68 and the latest one, I choose the second option, as it has many improvements.