is there any way to switch to camera 2 from camera 1?
as
var camera1 = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 1, 10000);
camera1.position.set(100, 100, 100)
scene.add(camera1)
var camera2 = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 1, 10000);
camera2.position.set(0, 100, 0)
scene.add(camera2)
The renderer will render with the camera you pass in renderer.render( scene, camera )
.
So you could have a currentCamera
variable, pass it to renderer.render
in your render loop, and assign either camera1
or camera2
to currentCamera
when you want to switch.
var camera1 = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 1, 10000);
camera1.position.set(100, 100, 100)
scene.add(camera1)
var camera2 = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 1, 10000);
camera2.position.set(0, 100, 0)
scene.add(camera2)
//
let currentCamera = camera1;
// When you wish to switch, just do currentCamera = camera2
loop();
function loop() {
requestAnimationFrame( loop );
renderer.render( scene, currentCamera );
}