Color code with decimals

I am trying to figure out how to change colors on a model.
I am looking at the Material/Texture example on Viewer API - Examples - Sketchfab

There is code that shows: m.channels.EmitColor.color = [0.0, 0.0, 1.0];

What is the decimals for? I am trying to change colors by using rgb values but I get an error without the decimal and I get black if I try [255.0, 0.0, 0.0].

How do I set the correct colors?

Thank you

Internally color values range between 0 and 1. Red is [1,0,0] and blue is [0,0,1] for instance. So you just need to convert your RGB values to arrays into that format.
Keep in mind that you might need to do a gamma conversion too. I use this code to convert RGB values

let oldColor = [128, 255, 0]
let newColor = [0, 0, 0]
for (let n = 0; n < oldColor.length; n++) {
  newColor[n] = oldColor[n] / 255 // without gamma conversion
  newColor[n] = Math.pow(oldColor[n] / 255, 2.2) // with gamma conversion
}
2 Likes