Color
new Color(color?)
RGB color stored as linear floats (0–1). Accepts a hex number, CSS string, or another Color. The renderer works internally in HSL16 - use Color as the input/output boundary.
Differs from THREE.js
No color name strings or texture sRGB conversion. Static helpers toRGB and fromHsl16 have no THREE equivalent.
Properties
| Name | Type | Description |
|---|---|---|
r | number | Red channel, 0–1. |
g | number | Green channel, 0–1. |
b | number | Blue channel, 0–1. |
hex | number | Packed 24-bit integer (read-only). |
hexString | string | #rrggbb CSS string (read-only). |
hsl | { h, s, l } | HSL representation with all components normalised to 0–1 (read-only). |
Methods
| Method | Description |
|---|---|
set(...args): this | Sets the color from a hex number, CSS string, or r/g/b triplet. |
setHSL(h: number, s: number, l: number): this | Sets from normalised HSL values (0–1). |
copy(color: Color): this | Copies r/g/b from another Color. |
clone(): Color | Returns a new Color with the same values. |
Color.toRGB(color: ColorValue): { r, g, b } | Static helper. Returns 0–255 integer RGB for any ColorValue. |
Color.fromHsl16(value: number): Color | Static helper. Creates a Color from a packed HSL16 integer. |