I want a point to move next to the cursor. The problem is that I have OrbitControls implemented to system. I’ve tried to use:
const vec = new Vector3();
const pos = new Vector3();
vec.set(
(event.clientX / window.innerWidth) * 2 - 1,
-(event.clientY / window.innerHeight) * 2 + 1,
-1
);
vec.unproject(camera);
vec.sub(camera.position).normalize();
const vectorDistance = -camera.position.z / vec.z;
pos.copy(camera.position).add(vec.multiplyScalar(vectorDistance));
tempPoint.position.set(pos.x, pos.y, pos.z);
But there is a problem with z coordinate of mouse.