How to do hit detection of mouse in Three.js using PointerLockControls?

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 );
}

but didnt work!

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?

ThreeVector3JSClass = THREE.Vector3;

and i use REVISION: ‘64’ of three.js

:scream:
What the reason of using of sucn an ancient revision? What profits?

using it since 2013

Now is probably a good time to upgrade then.

1 Like

can’t solve it using my current revision?

You probably can, but you’ll have to figure it out yourself. It’s unlikely anybody else will remember how to use such out of date software.

1 Like

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.

1 Like

OK THANKS :slight_smile: