return string on color.getHex()?
See original GitHub issueHello,
First of all I’m absolutely loving Three.js, so thank you !
So I think getHex() doesn’t quite do what I was expecting as it returns a decimal value.
For instance after using setHex(0xFFFFFF)
getHex returns “16777215” which you have to process with toString(16) to get “FFFFFF” I’d suggest adding it in the prototype it would probably be more intuitive.
Cheers
Issue Analytics
- State:
- Created 11 years ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
Using a HEX value from a color picker for three.js as a string
You can use the Color class (reference) from three.js. For example: var color = new THREE.Color("#FFA6A6"); // "FFA6A6" won't work! color.
Read more >Color – three.js docs
Sets this color's components from the attribute. # .getHex ( colorSpace : string = SRGBColorSpace ) : Integer. Returns the hexadecimal value of...
Read more >hex() / Reference / Processing.org
Converts an int, byte, char, or color to a String containing the equivalent hexadecimal notation. For example, the color value produced by color(0,...
Read more >How to get hex code from color dialog always - MSDN
If you then want it as hex then use ToString("x8") to convert to a hex string of size 8. var colorString = colorDlg.Color.ToArgb()....
Read more >RGB to HEX
Convert RGB color codes to HEX HTML format for use in web design and CSS. Also converts RGBA to HEX.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

In the editor we’re using
'#' + color.getHex().toString(16)and seems to work fine.Yes, but then isn’t it weird to name the function
getHex()when it doesn’t actually return an hexadecimal value ? In case anybody is wondering the good solution to get the hexadecimal value should be :('000000'+color.getHex().toString(16)).slice(-6)to make sure eventual starting 0s are included.