Is there a way to switch to a camera once an object with a perspective camera is loaded? I have an avatar object that contains a perspective camera and I want to use it either directly upon loading or switch to it afterwards. I've tried using orbit controls but haven't had success:
const fAddSc = function ( obj ) {
// Add the loaded object to the scene
let cam = obj.getObjectByName("PerspectiveCamera 1");
camera = new THREE.PerspectiveCamera(cam.fov, window.innerWidth / window.innerHeight, cam.near, cam.far);
camera.position.copy(cam.position);
camera.rotation.copy(cam.rotation);
obj.position.x=0;
obj.position.z=-4;
obj.position.y=0.5;
scene.add(obj);
const controls = new OrbitControls(camera, renderer.domElement);
controls.enabled = true;
console.log(controls);
console.log(scene.activeCamera);
};
I am using:
import * as THREE from 'three'
import OrbitControls from 'orbit-controls-es6';
Any help would be appreciated, thank you!