ColorUtils

Common utilities for working with colors in vec3, vec4, or hexadecimal form.

Provides methods to convert linear components (vec3, vec4) to sRGB hex values. All colors in the glTF specification, excluding color textures, are linear. Hexadecimal values, in sRGB colorspace, are accessible through helper functions in the API as a convenience.

// Hex (sRGB) to factor (linear).
const factor = ColorUtils.hexToFactor(0xFFCCCC, []);

// Factor (linear) to hex (sRGB).
const hex = ColorUtils.factorToHex([1, .25, .25])

Static methods

  • convertSRGBToLinear(source: T, target: T): T
  • convertLinearToSRGB(source: T, target: T): T
  • factorToHex(factor: T): number
  • hexToFactor(hex: number, target: T): T
Function symbol, where the argument and output are a box labeled 'glTF'.

Made by Don McCurdy. Documentation built with greendoc and published under Creative Commons Attribution 3.0.