Answer the question
In order to leave comments, you need to log in
How to disable a setting using dat.GUI in three.js?
I wrote this code
var option_default = function() {
this.cam_four = false ;
};
var option_array = new option_default();
var opt_none ;
var gui = new dat.GUI({ autoPlace: false });
var action_cam_four = gui.add(option_array, "cam_four");
action_cam_four.onFinishChange( function (opt_none) {
if (opt_none== true){
camera = new THREE.ArrayCamera( cameras );
}
if (opt_none== false){
cameras.enabled = true
}
} );
var camera = new THREE.PerspectiveCamera(65, window.innerWidth / window.innerHeight, 0.1, 1000 ); // создание камеры с значениями по умолчанию
camera.position.z= 1; camera.position.x= 0; camera.position.y= 0.5; // изменеия позиций камеры
var AMOUNT = 2;
var SIZE = 1 / AMOUNT;
var cameras = [];
for ( var y = 0; y < AMOUNT; y ++ ) {
for ( var x = 0; x < AMOUNT; x ++ ) {
var subcamera = new THREE.PerspectiveCamera(65, window.innerWidth / window.innerHeight, 0.1, 1000 );
subcamera.bounds = new THREE.Vector4( x / AMOUNT, y / AMOUNT, SIZE, SIZE );
cameras.push( subcamera );
}}
cameras[2].position.z = 3 ; cameras[2].position.x = 0; cameras[2].position.y = 1.5 ;
cameras[2].updateMatrixWorld();
cameras[1].position.z = 3 ; cameras[1].position.x = 0 ; cameras[1].position.y = 0 ;
cameras[1].updateMatrixWorld();
cameras[0].position.z = 0 ; cameras[0].position.x = 3 ; cameras[0].position.y = 0 ;
cameras[0].updateMatrixWorld();
cameras[3].position.z = 0 ; cameras[3].position.x = 0 ; cameras[3].position.y = 3 ;
cameras[3].updateMatrixWorld();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question