Note that standard method of specifying color in three.js is with a hexadecimal triplet, and that method is used throughout the rest of the documentation. When all arguments are defined then r is the red component, g is the green component and b is the blue component of the color. When only r is defined:
It can be a hexadecimal triplet representing the color (recommended). It can be an another Color instance. It can be a CSS-style string. For example:
'rgb(250, 0,0)', 'rgb(100%,0%,0%)', 'hsl(0, 100%, 50%)', '#ff0000', '#f00', 'red'
If arguments g and b are defined, the red component of the color. If they are not defined, it can be a hexadecimal triplet (recommended), a CSS-style string, or another Color instance.
If it is defined, the green component of the color.
If it is defined, the blue component of the color.
List of X11 color names.
Blue channel value between 0 and 1. Default is 1.
Green channel value between 0 and 1. Default is 1.
Red channel value between 0 and 1. Default is 1.
Converts this color from gamma space to linear space by taking .r, .g and .b to the power of gammaFactor.
Default is 2.0.
Converts this color from linear space to gamma space by taking .r, .g and .b to the power of 1 / gammaFactor.
Default is 2.0.
Copies the given color into this color, and then converts this color from gamma space to linear space by taking .r, .g and .b to the power of gammaFactor.
Copies the given color into this color, and then converts this color from linear space to gamma space by taking .r, .g and .b to the power of 1 / gammaFactor.
Sets this color's components from the attribute.
The source attribute.
index in the attribute.
Returns the hexadecimal value of this color.
Returns the hexadecimal value of this color as a string (for example, 'FFFFFF').
Returns the value of this color as a CSS style string. Example: 'rgb(255,0,0)'.
Linearly interpolates this color's HSL values toward the HSL values of the passed argument. It differs from the classic .lerp by not interpolating straight from one color to the other, but instead going through all the hues in between those two colors. The alpha argument can be thought of as the ratio between the two colors, where 0.0 is this color and 1.0 is the first argument.
See the Constructor above for full details of what value can be. Delegates to .copy, .setStyle, or .setHex depending on input type.
Value to set this color to.
Sets this color from a color name. Faster than .setStyle method if you don't need the other CSS-style formats. For convenience, the list of names is exposed in Color.NAMES as a hash: Color.NAMES.aliceblue // returns 0xF0F8FF
color name ( from X11 color names ).
Sets this color from a CSS-style string. For example, "rgb(250, 0,0)", "rgb(100%, 0%, 0%)", "hsl(0, 100%, 50%)", "#ff0000", "#f00", or "red" ( or any X11 color name - all 140 color names are supported ). Translucent colors such as "rgba(255, 0, 0, 0.5)" and "hsla(0, 100%, 50%, 0.5)" are also accepted, but the alpha-channel coordinate will be discarded. Note that for X11 color names, multiple words such as Dark Orange become the string 'darkorange'.
color as a CSS-style string.
Returns an array [red, green, blue], or copies red, green and blue into the provided array.
An optional array to store the color to.
An optional offset into the array.
Returns an array of the form [ r, g, b ].
Generated using TypeDoc
Class representing a color.
A Color can be initialised in any of the following ways: See the ngx3js docs page for details.
Examples
misc / exporter / collada | webgl / camera / logarithmicdepthbuffer | webgl / clipping / advanced | webgl / framebuffer / texture | webgl / geometry / colors
Code Example
const color = new THREE.Color( 0xff0000 );