ThreeColours
A scene's colours, as Wardic animates them: in linear light, three's working space, each as three
channel keys. A colour key's target (a CSS colour, a hex number, or a three Color, copied) is read
once into its linear channels, color into colorR, colorG and colorB, which springs move as
they move x, keeping their speed through a change of target, and which the writer sets on the
Color itself. Red to blue passes #bc00bc, as three's own Color.lerp does.
A channel rests by its share of the distance it goes, as a blended key's progress does, so a move from black to a near black animates, and every colour lands in the same time.
A Batch's colours split the same way: one for every member, two stops, or a function of a member's
index, each member's colour read once. An InstancedMesh's instance's color is its instance colour.
import * as ThreeColours from "@wardic/three/ThreeColours"
ThreeColours.split(mesh, { color: "#0000ff", opacity: 1 })
// { opacity: 1, colorR: 0, colorG: 0, colorB: 1 }Type Aliases
ColourValue
type ColourValue =
| string
| number
| {
isColor: true;
};A colour key's value: a CSS colour ("#00f", "rgb(0 0 255)", "blue"), a hex number (0x0000ff), or a three Color, copied.
Variables
CHANNELS
const CHANNELS: readonly ["R", "G", "B"];The suffixes of a colour's channel keys: colorR, colorG, colorB.
Functions
isChannel()
function isChannel(key): boolean;Whether key names a colour's channel: colorR, emissiveG, uTintB.
Parameters
key
string
Returns
boolean
split()
function split(subject, target): Readonly<Record<string, unknown>>;target on subject, each colour key split into its channels.
Parameters
subject
object
target
Readonly<Record<string, unknown>>
Returns
Readonly<Record<string, unknown>>
splitBatchKeys()
function splitBatchKeys(given, keys): readonly string[];The keys of a Batch made of given (an InstancedMesh, or a list), each colour key given as its three channels.
Parameters
given
unknown
keys
readonly string[]
Returns
readonly string[]
splitCall()
function splitCall(
subject,
target,
options
): readonly [unknown, unknown];A call's target and options on subject, each colour key split into its channels: its value or
keyframes, its transitionEnd, and a colour's entry in the target's transition or the options,
which runs each of its channels without an entry of its own, whichever the target names. A target
and options with no colour come back as they are. For a Batch, subject is a member, and a value may
be two stops or a function of a member's index.
Parameters
subject
unknown
target
unknown
options
unknown
Returns
readonly [unknown, unknown]
splitConfig()
function splitConfig(subjectNow, config): Readonly<Record<string, unknown>>;A ward's config on a scene's Subject, each colour key split into its channels in linear light,
as a call's are (splitCall): each target's values, an accessor's as it's read, each variant's (a
function's as it's called), and the transition's colour entries. subjectNow is the Subject now, read
as each is split, so an accessor Subject's colours are its current one's. Every other key is as given.
Parameters
subjectNow
() => unknown
config
Readonly<Record<string, unknown>>
Returns
Readonly<Record<string, unknown>>
unitScale()
function unitScale(scale): Rule;A scene's unit scale: x, y and z at scale of Motion's units, a colour's channels by their
share of the distance, every other key at 1.
Parameters
scale
number
Returns
Rule