Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

THREE.Color: Unknown color #002dff (warning/error)

I need to update the color after receiving the value from dat.GUI . But, this

var colored = new THREE.Color(value.replace("#","0x"));

is throwing this warning "THREE.Color: Unknown color 0x002dff" and the 'colored' isn't updating.

value = #002dff (at that time, it keeps on changing, user input)

Edit: I know I can use this as "THREE.Color( #002dff )", but the color is changing at run time according to the user input from controls I've created using dat.GUI, so I won't be knowing the actual value that can be added to the code.

PS: It was replace() which was causing the problem. It's solved.

like image 816
Utkarsh Zaveri Avatar asked Jan 04 '23 22:01

Utkarsh Zaveri


1 Answers

You have to give a hexadecimal number, not a string to the Color constructor. Try to call the parseInt function:

var colorValue = parseInt ( value.replace("#","0x"), 16 );
var colored = new THREE.Color( colorValue );
like image 143
Hellium Avatar answered Jan 06 '23 12:01

Hellium