Answers for "use dat.gui to look around with camera"

0

use dat.gui to look around with camera

function initGui(){
  const controls = {
    get near(){return testPerspectiveCamera.near;},
    set near(value){
      testPerspectiveCamera.near = value;
      testPerspectiveCamera.updateProjectionMatrix();
      testPerspectiveCameraHelper.update();
    },
    get far(){return testPerspectiveCamera.far;},
    set far(value){
      testPerspectiveCamera.far = value;
      testPerspectiveCamera.updateProjectionMatrix();
      testPerspectiveCameraHelper.update();
    },
    get aspect(){return testPerspectiveCamera.aspect;},
    set aspect(value){
      testPerspectiveCamera.aspect = value;
      testPerspectiveCamera.updateProjectionMatrix();
      testPerspectiveCameraHelper.update();
    },
    get fov(){return testPerspectiveCamera.fov;},
    set fov(value){
      testPerspectiveCamera.fov = value;
      testPerspectiveCamera.updateProjectionMatrix();
      testPerspectiveCameraHelper.update();
    },
    get positionX(){return testPerspectiveCamera.position.x;},
    set positionX(value){
      testPerspectiveCamera.position.x = value;
      scene.updateMatrixWorld();                         //?
      testPerspectiveCamera.updateProjectionMatrix();    //?
      testPerspectiveCameraHelper.update();              //?
    }
  };
  const gui = new dat.GUI();
  const perspectiveCameraFolder  = gui.addFolder('testPerspectiveCamera');
  perspectiveCameraFolder.add(controls, 'near', 0, 50);
  perspectiveCameraFolder.add(controls, 'far', 0, 200);
  perspectiveCameraFolder.add(controls, 'aspect', 0, 4);
  perspectiveCameraFolder.add(controls, 'fov', 0, 100);
  perspectiveCameraFolder.add(controls, 'positionX', -LIMIT, LIMIT);
}
Posted by: Guest on October-24-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language