Z
Z
zeni1agent2019-01-21 19:38:38
JavaScript
zeni1agent, 2019-01-21 19:38:38

How to change stuff in three.js using dat.gui?

I wrote the following code to change the gender in the scene

action_floor_glass.onChange( function (opt_none) {
    if (opt_none== true){	
  geometry_floor2.visible = false; 
  geometry_floor1.visible = true; 
  }  
    if (opt_none== false){
  geometry_floor1.visible = false;
  geometry_floor2.visible = true;
  }
} );


  var plane_gam = new THREE.PlaneBufferGeometry( 2000, 2000 ) ;
 
  var glass_mat = { clipBias: 0.003, textureWidth: window.innerWidth * window.devicePixelRatio, textureHeight:  window.innerHeight * window.devicePixelRatio, color: 0x889999, recursion: 1 } ;
  
  var plane_mat = new  THREE.MeshStandardMaterial( { color: 0x808080, roughness: 0, metalness: 0 } ) ;					
        
  var  geometry_floor1 =  new THREE.Reflector(plane_gam,  glass_mat);
  geometry_floor1.rotation.x = - Math.PI / 2;
  geometry_floor1.receiveShadow = true
  geometry_floor1.visible = false;
  scene.add(  geometry_floor1 );
 			
  var  geometry_floor2 = new THREE.Mesh( plane_gam, plane_mat );
  geometry_floor2.rotation.x = - Math.PI / 2;
  geometry_floor2.receiveShadow = true;
         
  scene.add(  geometry_floor2 );

Everything works as it should.
But I'm interested in the question whether it is possible to somehow shorten this code
So that it would not change the object itself, but its properties (material)?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question