I have a color module I use for representing colors of most types. It would be trivial for it to have a Three.Color object which is simply an object with three r, g, b properties.
But the Three.Color has a prototype with several methods.
So the question is: can I use a plain {r:xx, g:xx, b:xx} object wherever Three needs a color? Or would it be best (avoid conversions) if I actually use a new Three.Color() instead.
I guess the answer to your question depends on your case. The Three.js renderer uses attributes like .isColor
to do lots of checks, so passing an object with just {r, g, b}
values isn't going to work in lots of situations when the engine checks what type of object it's dealing with.
Also, if you set your renderer to handle gamma color-correction, it's going to require .convertLinearToGamma
. Plus probably several other occasions that I can't think of, so I think it's best if you just create a THREE.Color
from the get-go to avoid running into lots of unwanted behavior in the future.