使用 dat.GUI 选择颜色设置三个 js 中的一个对象的颜色

Cri*_* A. 4 javascript three.js dat.gui

如何在一个对象中使用dat.gui设置颜色三个 js

我想使用对话框选择颜色,例如本例中的 Box 3

怎么做这个?

Cri*_* A. 5

我使用以下函数来使用选择器颜色更改颜色

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;
    });
}
Run Code Online (Sandbox Code Playgroud)