Hey there, I've encountered an issue when switching between a perspective camera and an orthographic camera. My objective is to seamlessly transition between these two camera types while maintaining the camera's position and orientation intact. Take a look at the relevant code snippet (line 98):
let display = gui.addFolder("Display");
display.add(guiOptions.display,"orthographicCamera").name("Orthographic Camera").onChange(function(){
var position=camera.position;
var target=controls.target;
var quaternion=camera.quaternion;
if (guiOptions.display.orthographicCamera){
camera = new THREE.OrthographicCamera(
window.innerWidth / - (zoom / scaleFactor),
window.innerWidth / (zoom / scaleFactor),
window.innerHeight / (zoom / scaleFactor),
window.innerHeight / - (zoom / scaleFactor),
-500, 1000);
}
else{
camera = new THREE.PerspectiveCamera( 115, window.innerWidth / window.innerHeight, 0.000001, 10000 );
}
camera.position.set(position.x,position.y,position.z);
camera.quaternion.set(quaternion._x,quaternion._y,quaternion._z,quaternion._w);
controls=new THREE.TrackballControls(camera,renderer.domElement);
controls.dynamicDampingFactor = .15;
controls.target=target;
});
I'm facing an issue where transitioning from a perspective camera to an orthographic one results in a different orientation for certain camera rotations. Initially, I thought it was related to the quaternion attribute, but resetting it didn't yield any changes.
I'm currently stuck on resolving this problem. Any assistance would be greatly appreciated, thank you in advance!
EDIT: I managed to solve the issue, but I am occupied at the moment. I'll update with my solution later on.