I’m trying to make an interface for the camera for easy management. I created buttons, began to change the location of the camera, for some reason it does not work, here is the code.
I’m trying to adjust the change of the camera location using the button, but alas, it does not change the location. It draws the buttons, does not give out errors, but it does not change the location of the camera either.
Here is the code :
...
camera = new THREE.PerspectiveCamera( 60, window.innerWidth / window.innerHeight, 1, 1000 );
camera.position.set( 400, 200, 0 );
...
...
var controls2 = new function () {
this.pozishon = 0;
if (this.pozishon==1) {
camera.position.set( 400, 200, 0 );
}
if(this.pozishon==2) {
camera.position.set( 0, 200, 400 );
}
if(this.pozishon==3 ) {
// camera.lookAt(new THREE.Vector3(0,0,0));
//camera.position.set( 400, 400, 0 );
camera.position.set( 400, -1800, 800);
camera.lookAt( 400, 400, 0 );
camera.up.set( 0, 0, 1 );
camera.updateProjectionMatrix();
}
};
gui = new GUI( { title: 'меню' } );
const geometryFolder = gui.addFolder("камера");
geometryFolder.add(controls2, "pozishon", { 'прямо': 1, 'верх':2, 'бок': 3 }).name("камера");
//geometryFolder.add(controls, 'rotationSpeed', 0, 0.5);
//geometryFolder.add(controls, 'bouncingSpeed', 0, 0.5);
const primitiveFolder = gui.addFolder("примитивы");
...