i have small problem in my project with getting hex color. I have simple variable with colors:
var colors = {
"C":0x000000,
"H":0xffffff,
"O":0xff0000,
...
}
I want to get my color by key in function below: (it is written in typescript)
getAtomColor(element: string) :number{
for (var key in colors) {
if (element == key) {
return colors[key];
}
}
}
Problem is with got atom color (below parameter clr), it is in integer form and function in three.js THREE.MeshLambertMaterial({color:clr}) has undefined parameters. How can I fix this problem?