I'm currently facing a small issue with retrieving hex colors in my project. I have a simple variable that stores colors:
var colors = {
"C":0x000000,
"H":0xffffff,
"O":0xff0000,
...
}
The goal is to retrieve the color by key using the function below (written in TypeScript):
getAtomColor(element: string) :number{
for (var key in colors) {
if (element == key) {
return colors[key];
}
}
}
The issue arises when passing the atom color (represented as parameter clr) in integer form, resulting in undefined parameters in the `THREE.MeshLambertMaterial({color:clr})` function from three.js. How can I address this problem?