THREE.Color: Unknown color # 002dff (warning / error)
I need to update the color after getting the value from dat.GUI. But this
var colored = new THREE.Color(value.replace("#","0x"));
throws this warning "THREE.Color: Unknown color 0x002dff" and "color" is not updated.
value = # 002dff (at this time it keeps changing, user input)
Edit: I know I can use this as "THREE.Color (# 002dff)", but the color changes at runtime according to user input of the controls I created with dat.GUI knowing the actual value, which might be added to the code.
PS: This was the problem replace()
. He decided.
source to share
try this ((new THREE.color ("# FF00FF")) if you want to pick a favortie color for your program Check this link http://www.rapidtables.com/web/color/RGB_Color.htm you are in photoshop and you can choose color and display the color code.
source to share
THREE.Color()
has a method .setStyle()
.
var obj;
var gui = new dat.GUI();
var props = {
color: '#002dff'
};
var colorController = gui.addColor(props, 'color');
colorController.onChange(
function(value){
// uncomment this to see it working
//var colored = new THREE.Color(value);
//console.log(colored);
obj.material.color.setStyle(value);
}
);
var sphere = new THREE.Mesh(new THREE.SphereGeometry(2, 32, 24), new THREE.MeshStandardMaterial());
sphere.material.color.setStyle("#002dff");
scene.add(sphere);
obj = sphere;
jsfiddle . three.js r85, dat.GUI 0.6.5
PS Do not use new THREE.Color()
to change existing material color, use methodssetXXXXX()
THREE.Color()
source to share