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

Hierarchy

  • ColorUtils

Methods

  • convertLinearToSRGB<T>(source: T, target: T): T
  • Converts linear components to sRGB components.

    Type parameters

    • T

      vec3 or vec4 linear components.

  • convertSRGBToLinear<T>(source: T, target: T): T
  • Converts sRGB components to linear components.

    Type parameters

    • T

      vec3 or vec4 linear components.

  • factorToHex<T>(factor: T): number
  • Converts linear components to sRGB hexadecimal.

    Type parameters

    • T

      vec3 or vec4 linear components.

  • hexToFactor<T>(hex: number, target: T): T
  • Converts sRGB hexadecimal to linear components.

    Type parameters

    • T

      vec3 or vec4 linear components.

Function symbol, f(📦) → 📦, where the argument and output are a box labeled 'glTF'.

Made by Don McCurdy TypeDoc documentation Copyright 2020 under MIT license