How to set a color with dat.gui in one object the Three js
I wanna choose the color with the dialog some like Box 3 in this example
How to make this?
I make the following function to change the color with a chooser color
function cambiarColor( obj )
{
var gui = new dat.GUI();
var Configuracion=function(){
this.color = "#ffae23";
}
var conf = new Configuracion();
var controlador = gui.addColor( conf, 'color');
controlador.onChange( function( colorValue )
{
//the return value by the chooser is like as: #ffff so
//remove the # and replace by 0x
colorValue=colorValue.replace( '#','0x' );
//create a Color
var colorObject = new THREE.Color( colorValue ) ;
//set the color in the object
obj.material.color = colorObject;
});
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With