查找表([name])

表示颜色表的查找表,用于从一个数据值的范围中确定颜色值。

代码示例

const lut = new Lut( 'rainbow', 512 ); const color = lut.getColor( 0.5 );

构造函数

[name]( [param:String colormap], [param:Number count] )

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*.

属性

[property:Array lut]

The lookup table for the selected color map represented as an array of [page:Color]s.

[property:Array map]

The currently selected color map. Default is the *rainbow* color map.

[property:Number minV]

The minimum value to be represented with the lookup table. Default is *0*.

[property:Number maxV]

The maximum value to be represented with the lookup table. Default is *1*.

[property:Number n]

The number of colors of the current selected color map. Default is *32*.

方法

[method:this copy]( [param:Lut lut] ) [param:Lut this]

color — Lut to copy.

Copies the given lut.

[method:this addColorMap]( [param:String name], [param:Array arrayOfColors] )

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 [name] instance.

[method:HTMLCanvasElement createCanvas]()

Creates a canvas in order to visualize the lookup table as a texture.

[method:Color getColor]( [param:Number alpha] )

value -- the data value to be displayed as a color.

Returns an instance of [page:Color] for the given data value.

[method:this setColorMap]( [param:String colormap], [param:Number count] )

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.

[method:this setMin]( [param:Number minV] )

minV — The minimum value to be represented with the lookup table

Sets this Lut with the minimum value to be represented.

[method:this setMax]( [param:Number maxV] )

maxV — The maximum value to be represented with the lookup table.

Sets this Lut with the maximum value to be represented.

[method:HTMLCanvasElement updateCanvas]( [param:HTMLCanvasElement canvas] )

Updates the canvas with the [name]'s data.

源码

[link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/math/Lut.js examples/jsm/math/Lut.js]