Represents a lookup table for colormaps. It is used to determine the color values from a range of data values.
Import
Lut is an add-on, and must be imported explicitly. See Installation / Addons.
import { Lut } from 'three/addons/math/Lut.js';
Code Example
const lut = new Lut( 'rainbow', 512 );
const color = lut.getColor( 0.5 );
Constructor
Lut( colormap : String, count : Number )
colormap – Sets a colormap from predefined colormaps. Available colormaps are: rainbow, cooltowarm, blackbody, grayscale. Default is rainbow.
count – Sets the number of colors used to represent the data array. Default is 32.
Properties
.lut : Array
The lookup table for the selected color map represented as an array of Colors.
.map : Array
The currently selected color map. Default is the rainbow color map.
.minV : Number
The minimum value to be represented with the lookup table. Default is 0.
.maxV : Number
The maximum value to be represented with the lookup table. Default is 1.
.n : Number
The number of colors of the current selected color map. Default is 32.
Methods
.copy ( lut : Lut ) : this this : Lut
color — Lut to copy.
Copies the given lut.
.addColorMap ( name : String, arrayOfColors : Array ) : this
name — The name of the color map.
arrayOfColors — An array of color values. Each value is an array holding a threshold and the actual color value as a hexadecimal number.
Adds a color map to this Lut instance.
.createCanvas () : HTMLCanvasElement
Creates a canvas in order to visualize the lookup table as a texture.
.getColor ( alpha : Number ) : Color
value — the data value to be displayed as a color.
Returns an instance of Color for the given data value.
.setColorMap ( colormap : String, count : Number ) : this
colormap — The name of the color map.
count — The number of colors. Default is 32.
Configure the lookup table for the given color map and number of colors.
.setMin ( minV : Number ) : this
minV — The minimum value to be represented with the lookup table
Sets this Lut with the minimum value to be represented.
.setMax ( maxV : Number ) : this
maxV — The maximum value to be represented with the lookup table.
Sets this Lut with the maximum value to be represented.
.updateCanvas ( canvas : HTMLCanvasElement ) : HTMLCanvasElement
Updates the canvas with the Lut’s data.