new LayerMultispectral(options)
Creates a new LayerMultispectral instance
Parameters:
| Name | Type | Description |
|---|---|---|
options |
LayerMultispectralOptions | Configuration options |
- Source:
Throws:
-
-
If rasters options is not empty (rasters are created automatically)
- Type
- Error
-
-
-
If url to info.json is not provided
- Type
- Error
-
-
-
If presets option is not provided
- Type
- Error
-
Example
// Create multispectral layer with deepzoom layout
const msLayer = new OpenLIME.Layer({
type: 'multispectral',
url: 'path/to/info.json',
layout: 'deepzoom',
defaultMode: 'rgb',
presets: 'path/to/presets.json'
});
// Add to viewer
viewer.addLayer('ms', msLayer);
// Apply a preset CTW
msLayer.applyPreset('falseColor');
Extends
Methods
-
addControl(name, value)
-
Adds a shader parameter control
Parameters:
Name Type Description namestring Control identifier
value* Initial value
- Inherited From:
- Overrides:
- Source:
Throws:
-
If control already exists
- Type
- Error
-
addShader(id, shader)
-
Adds a shader to the layer's available shaders
Parameters:
Name Type Description idstring Unique identifier for the shader
shaderShader Shader instance to add
- Inherited From:
- Overrides:
- Source:
Throws:
-
If shader with the same id already exists
- Type
- Error
Returns:
This layer instance for method chaining
- Type
- Layer
Example
```javascript const customShader = new OpenLIME.Shader({...}); layer.addShader('custom', customShader); layer.setShader('custom'); ``` -
addShaderFilter(filter)
-
Adds a filter to the current shader
Parameters:
Name Type Description filterObject Filter specification
- Inherited From:
- Overrides:
- Source:
Throws:
-
If no shader is set
- Type
- Error
-
applyPreset(presetName)
-
Applies a preset CTW from the presets library
Loads and applies a predefined set of CTW coefficients for specialized visualization (e.g., false color, vegetation analysis).
Parameters:
Name Type Description presetNamestring Name of the preset
- Source:
Throws:
-
If preset doesn't exist
- Type
- Error
-
boundingBox()
-
Gets layer bounding box in scene coordinates
- Inherited From:
- Overrides:
- Source:
Returns:
Bounding box
- Type
- BoundingBox
-
clearShaderFilters(name)
-
Removes all filters from the current shader
Parameters:
Name Type Description nameObject Filter name
- Inherited From:
- Overrides:
- Source:
Throws:
-
If no shader is set
- Type
- Error
-
derive( [options])
-
Creates a new Layer that shares tiles with this layer but uses a different shader. This method allows efficient creation of derivative layers that share the same source textures, which is useful for applying different visual effects to the same image data without duplicating resources.
Parameters:
Name Type Argument Default Description optionsObject <optional>
{} Options for the new layer
Properties
Name Type Argument Description shadersObject <optional>
Map of shaders for the new layer
defaultShaderstring <optional>
ID of shader to set as active
labelstring <optional>
Label for the new layer (defaults to original label)
zindexnumber <optional>
Z-index for the new layer (defaults to original + 1)
visibleboolean <optional>
Layer visibility (defaults to same as original)
transformTransform <optional>
Custom transform (defaults to copy of original)
mipmapBiasnumber <optional>
Custom mipmap bias (defaults to original value)
pixelSizenumber <optional>
Custom pixel size (defaults to original value)
debugboolean <optional>
Debug mode flag (defaults to original value)
- Inherited From:
- Overrides:
- Source:
Returns:
A new layer sharing textures with this one
- Type
- Layer
Example
```javascript // Create a derived layer with edge detection shader const enhancedShader = new OpenLIME.ShaderEdgeDetection(); const derivedLayer = originalLayer.derive({ label: 'Edge Detection', shaders: { 'edge': enhancedShader }, defaultShader: 'edge', zindex: 10 }); viewer.addLayer('edges', derivedLayer); ``` or ```javascript const enhancedShader = new OpenLIME.ShaderEdgeDetection(); const derivedLayer = layer.derive({ label: 'Enhanced Image' }); derivedLayer.addShader('enhanced', enhancedShader); derivedLayer.setShader('enhanced'); viewer.addLayer('Enhanced Image', derivedLayer); ``` -
getAvailablePresets()
-
Gets available presets
Returns the names of all available preset CTW configurations.
- Source:
Returns:
Array of preset names
- Type
- Array.<string>
-
getBandCount()
-
Gets the number of spectral bands
Returns the count of spectral planes in the multispectral dataset.
- Source:
Returns:
Number of bands
- Type
- number
-
getControl(name)
-
Gets the shader parameter control corresponding to
nameParameters:
Name Type Description name* The name of the control. return {*} The control
- Inherited From:
- Overrides:
- Source:
-
getMode()
-
Gets the current shader visualization mode
- Inherited From:
- Overrides:
- Source:
Returns:
Current mode or null if no shader
- Type
- string | null
-
getModes()
-
Gets available shader modes
- Inherited From:
- Overrides:
- Source:
Returns:
Array of available modes
- Type
- Array.<string>
-
getPixelValues(x, y)
-
Gets pixel values for a specific pixel location Works with both single images and tiled formats
Parameters:
Name Type Description xnumber X coordinate in image space (0,0 at top-left)
ynumber Y coordinate in image space (0,0 at top-left)
- Inherited From:
- Overrides:
- Source:
Returns:
Array containing RGBA values for each raster at the specified pixel
- Type
- Array.<Uint8Array>
-
getPreset(presetName)
-
Gets a preset CTW configuration by name
Retrieves the preset's red, green, and blue CTW arrays from the presets collection.
Parameters:
Name Type Description presetNamestring Name of the preset
- Source:
Returns:
Object with red, green, blue arrays or null if not found
- Type
- Object | null
-
getSpectrum(x, y)
-
Gets spectrum data for a specific pixel
For tiled formats, this method finds the appropriate tiles and reads the spectral values.
Parameters:
Name Type Description xnumber X coordinate in image space
ynumber Y coordinate in image space
- Source:
Returns:
Array of spectral values (0-100)
- Type
- Array.<number>
-
getSpectrum(x, y)
-
Gets spectrum data for a specific pixel
Uses the improved getPixelValues method from the base Layer class to obtain spectral values across all bands.
Parameters:
Name Type Description xnumber X coordinate in image space
ynumber Y coordinate in image space
- Source:
Returns:
Array of spectral values (0-100)
- Type
- Array.<number>
-
getState( [stateMask])
-
Gets the current layer state
Parameters:
Name Type Argument Default Description stateMaskObject <optional>
null Optional mask to filter returned state properties
- Inherited From:
- Overrides:
- Source:
Returns:
Current state object
- Type
- Object
-
getWavelengths()
-
Gets the wavelength array for spectral bands
Returns the wavelength values (in nm) for each spectral band.
- Source:
Returns:
Array of wavelengths
- Type
- Array.<number>
-
info()
-
Gets info
- Source:
Returns:
Object with info on multispectral dataset or null if not found
- Type
- Object | null
-
interpolateControls()
-
Updates control interpolation
- Inherited From:
- Overrides:
- Source:
Returns:
Whether all interpolations are complete
- Type
- boolean
-
<async> loadTile(tile, callback)
-
Loads and processes a single image tile with optimized resource management. Implements request batching, concurrent loading, and proper error handling.
Parameters:
Name Type Description tileObject Tile specification object
Properties
Name Type Argument Description indexstring Unique tile identifier
urlstring Base URL for tile resource
startnumber <optional>
Start byte for partial content (for tarzoom)
endnumber <optional>
End byte for partial content (for tarzoom)
offsetsArray.<Object> <optional>
Byte offsets for interleaved formats
callbackfunction Completion callback(error, size)
- Inherited From:
- Overrides:
- Source:
Throws:
-
If tile is already in processing queue
- Type
- Error
Returns:
- Type
- Promise.<void>
-
pixelSizePerMM()
-
Gets pixel size in millimeters
- Inherited From:
- Overrides:
- Source:
Returns:
Size of one pixel in mm
- Type
- number
-
removeShader(id)
-
Removes a shader from the layer's available shaders
Parameters:
Name Type Description idstring Identifier of the shader to remove
- Inherited From:
- Overrides:
- Source:
Throws:
-
If shader with the specified id doesn't exist
- Type
- Error
Returns:
This layer instance for method chaining
- Type
- Layer
Example
```javascript // Remove a shader that's no longer needed layer.removeShader('oldEffect'); ``` -
removeShaderFilter(name)
-
Removes a filter from the current shader
Parameters:
Name Type Description nameObject Filter name
- Inherited From:
- Overrides:
- Source:
Throws:
-
If no shader is set
- Type
- Error
-
scale()
-
Gets layer scale
- Inherited From:
- Overrides:
- Source:
Returns:
Current scale value
- Type
- number
-
setCTW(redCTW, greenCTW, blueCTW)
-
Sets Color Twist Weights coefficients manually
CTW coefficients define how spectral bands are combined to create RGB visualization. Each array contains weights for each spectral band.
Parameters:
Name Type Description redCTWFloat32Array Red channel coefficients
greenCTWFloat32Array Green channel coefficients
blueCTWFloat32Array Blue channel coefficients
- Source:
Throws:
-
If arrays have incorrect length
- Type
- Error
-
setControl(name, value [, dt] [, easing])
-
Sets a shader control value with optional animation
Parameters:
Name Type Argument Default Description namestring Control identifier
value* New value
dtnumber <optional>
Animation duration in ms
easingstring <optional>
'linear' Easing function
- Inherited From:
- Overrides:
- Source:
Fires:
-
setMode(mode)
-
Sets the visualization mode
Changes how multispectral data is visualized:
- 'rgb': Uses CTW coefficients to create RGB visualization
- 'single_band': Shows a single spectral band
Parameters:
Name Type Description modestring Mode name ('rgb', 'single_band')
- Overrides:
- Source:
-
setShader(id)
-
Sets the active shader
Parameters:
Name Type Description idstring Shader identifier from registered shaders
- Inherited From:
- Overrides:
- Source:
Fires:
Throws:
-
If shader ID is not found
- Type
- Error
-
setSingleBand(bandIndex [, channel])
-
Sets single band visualization
Displays a single spectral band on a specific output channel.
Parameters:
Name Type Argument Default Description bandIndexnumber Index of band to visualize
channelnumber <optional>
0 Output channel (0=all/gray, 1=R, 2=G, 3=B)
- Source:
-
setState(state [, dt] [, easing])
-
Sets the layer state with optional animation
Parameters:
Name Type Argument Default Description stateObject State object with controls and mode
dtnumber <optional>
Animation duration in ms
easingstring <optional>
'linear' Easing function ('linear'|'ease-out'|'ease-in-out')
- Inherited From:
- Overrides:
- Source:
-
setTransform(tx)
-
Sets the layer's transform
Parameters:
Name Type Description txTransform New transform
- Inherited From:
- Overrides:
- Source:
Fires:
- Layer#event:updateSize
-
setViewport(view)
-
Sets the layer's viewport
Parameters:
Name Type Description viewObject Viewport specification
Properties
Name Type Description xnumber X position
ynumber Y position
dxnumber Width
dynumber Height
- Inherited From:
- Overrides:
- Source:
Fires:
-
setVisible(visible)
-
Sets layer visibility
Parameters:
Name Type Description visibleboolean Whether layer should be visible
- Inherited From:
- Overrides:
- Source:
Fires:
-
setZindex(zindex)
-
Sets layer rendering order
Parameters:
Name Type Description zindexnumber Stack order value
- Inherited From:
- Overrides:
- Source:
Fires:
Events
-
ready
-
The event is fired when a layer is initialized.
- Inherited From:
- Overrides:
- Source:
-
update
-
The event is fired if a redraw is needed.
- Inherited From:
- Overrides:
- Source: