My point is not moving under the mouse pointer in orthographic mode. In perspective camera it is working perfectly while not in the orthographic mode Below is the image that what is happening. Image
I have tried the things in this link Orthographic camera and selecting objects with raycast
The code I am trying.
// var mouse = new THREE.Vector2();
// mouse.x = ( event.clientX /
viewer.renderer.domElement.clientWidth ) * 2 - 1;
// mouse.y = - ( event.clientY /
viewer.renderer.domElement.clientHeight ) * 2 + 1;
var vector = new THREE.Vector3( scope.mouse.x, scope.mouse.y, 0.5);
//console.log("mouse values ",scope.mouse.x, scope.mouse.y);
//console.log(scope.scene.cameraP)
let camera = scope.scene.getActiveCamera()
vector.unproject(camera);
console.log(vector)
var direction = vector.sub(camera.position).normalize();
var ray = new THREE.Ray(camera.position, direction);
var pointClouds = [];
scope.scene.referenceFrame.traverse(function(object){
if(object instanceof Potree.PointCloudOctree || object instanceof Potree.PointCloudArena4D){
pointClouds.push(object);
}
});
var closestPoint = null;
var closestPointDistance = null;
for(var i = 0; i < pointClouds.length; i++){
var pointcloud = pointClouds[i];
var point = pointcloud.pick(scope.renderer, scope.scene.cameraP, ray);
if(!point){
continue;
}
var distance = viewer.scene.getActiveCamere().position.distanceTo(point.position);
console.log(distance)
if(!closestPoint || distance < closestPointDistance){
closestPoint = point;
closestPointDistance = distance;
}
}
return closestPoint ? closestPoint : null;
};
Here getActivecamera() is a function which switches between Perspective camera and Orthographic camera.
Below is the image what I want. Image Please Help I am stuck for the last 3 week in this.