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])


  • ColorUtils



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

Made by Don McCurdy TypeDoc documentation Copyright 2023, MIT license