I'm looking to add separate buttons on my website, where each button triggers the camera to move to a different position within the scene. How can I achieve this? Currently, I have set up a system where pressing a button leads to a sequence of predefined camera positions, but I want each button to move the camera independently to specific spots in the scene.
Below is the code snippet I'm currently working with:
camera.position.set(100, 0, 400);
function render() {
requestAnimationFrame(render);
renderer.render(scene, camera);
TWEEN.update();
}
function moveCam() {
var pos1 = new TWEEN.Tween(camera.position).to({ y: 300 }, 3000).easing(TWEEN.Easing.Quadratic.InOut);
var pos2 = new TWEEN.Tween(camera.position).to({ x: -400 }, 4000).easing(TWEEN.Easing.Quadratic.InOut);
var pos3 = new TWEEN.Tween(camera.position).to({ y: -10 }, 4000).easing(TWEEN.Easing.Quadratic.InOut);
var rot1 = new TWEEN.Tween(camera.rotation).to({ y: -1 }, 4000).easing(TWEEN.Easing.Quadratic.InOut);
var pos4 = new TWEEN.Tween(camera.position).to({ x: 600 }, 6000).easing(TWEEN.Easing.Quadratic.InOut);
var pos5 = new TWEEN.Tween(camera.position).to({ y: -400 }, 2000).easing(TWEEN.Easing.Quadratic.InOut);
var rot2 = new TWEEN.Tween(camera.rotation).to({ y: -5 }, 2000).easing(TWEEN.Easing.Quadratic.InOut);
var pos6 = new TWEEN.Tween(camera.position).to({ z: 10 }, 5000).easing(TWEEN.Easing.Quadratic.InOut);
var rot3 = new TWEEN.Tween(camera.rotation).to({ y: 0 }, 2000).easing(TWEEN.Easing.Quadratic.InOut);
pos1.start();
pos1.chain(pos2);
pos2.chain(pos3, rot1)
rot1.chain(pos4)
pos4.chain(pos5, rot2)
rot2.chain(pos6)
pos6.chain(rot3)