new LayerHDR(options)
Creates a new LayerHDR instance.
Parameters:
Name | Type | Description |
---|---|---|
options |
LayerHDROptions | Configuration options for the HDR layer |
- Source:
Example
```javascript const hdrLayer = new OpenLIME.LayerHDR({ url: 'hdr-image.hdr', format: 'rgba16f' }); viewer.addLayer('hdr', hdrLayer); ```
Extends
Methods
-
addControl(name, value)
-
Adds a shader parameter control
Parameters:
Name Type Description name
string 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 id
string Unique identifier for the shader
shader
Shader 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 filter
Object Filter specification
- Inherited From:
- Overrides:
- Source:
Throws:
-
If no shader is set
- 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 name
Object 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 options
Object <optional>
{} Options for the new layer
Properties
Name Type Argument Description shaders
Object <optional>
Map of shaders for the new layer
defaultShader
string <optional>
ID of shader to set as active
label
string <optional>
Label for the new layer (defaults to original label)
zindex
number <optional>
Z-index for the new layer (defaults to original + 1)
visible
boolean <optional>
Layer visibility (defaults to same as original)
transform
Transform <optional>
Custom transform (defaults to copy of original)
mipmapBias
number <optional>
Custom mipmap bias (defaults to original value)
pixelSize
number <optional>
Custom pixel size (defaults to original value)
debug
boolean <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); ```
-
getAcesContrast()
-
Gets the current ACES contrast value.
- Source:
Returns:
The current ACES contrast value
- Type
- number
-
getControl(name)
-
Gets the shader parameter control corresponding to
name
Parameters:
Name Type Description name
* The name of the control. return {*} The control
- Inherited From:
- Overrides:
- Source:
-
getExposure()
-
Gets the current exposure value.
- Source:
Returns:
The current exposure value
- Type
- number
-
getHighlightCompression()
-
Gets the current highlight compression value.
- Source:
Returns:
The current highlight compression value
- Type
- number
-
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 x
number X coordinate in image space (0,0 at top-left)
y
number 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>
-
getShadowLift()
-
Gets the current shadow lift value.
- Source:
Returns:
The current shadow lift value
- Type
- number
-
getStatInfo()
-
Retrieves statistical information about the raster data.
- Source:
Returns:
An object containing statistical information (e.g., maxValue, avgLuminance)
- Type
- Object
-
getState( [stateMask])
-
Gets the current layer state
Parameters:
Name Type Argument Default Description stateMask
Object <optional>
null Optional mask to filter returned state properties
- Inherited From:
- Overrides:
- Source:
Returns:
Current state object
- Type
- Object
-
getWhitePoint()
-
Gets the current white point value.
- Source:
Returns:
The current white point value
- Type
- number
-
interpolateControls()
-
Interpolates control values and updates the shader with the current parameters.
- Overrides:
- Source:
Returns:
Whether the interpolation is 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 tile
Object Tile specification object
Properties
Name Type Argument Description index
string Unique tile identifier
url
string Base URL for tile resource
start
number <optional>
Start byte for partial content (for tarzoom)
end
number <optional>
End byte for partial content (for tarzoom)
offsets
Array.<Object> <optional>
Byte offsets for interleaved formats
callback
function 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 id
string 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 name
Object 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
-
setAcesContrast(v [, delayms] [, easing])
-
Sets the ACES contrast parameter for ACES tone mapping.
Parameters:
Name Type Argument Default Description v
number The new ACES contrast value
delayms
number <optional>
1 Delay in milliseconds for the transition
easing
string <optional>
'linear' Easing function for the transition
- Source:
-
setControl(name, value [, dt] [, easing])
-
Sets a shader control value with optional animation
Parameters:
Name Type Argument Default Description name
string Control identifier
value
* New value
dt
number <optional>
Animation duration in ms
easing
string <optional>
'linear' Easing function
- Inherited From:
- Overrides:
- Source:
Fires:
-
setExposure(v [, delayms] [, easing])
-
Sets the exposure value for exposure-based tone mapping.
Parameters:
Name Type Argument Default Description v
number The new exposure value
delayms
number <optional>
1 Delay in milliseconds for the transition
easing
string <optional>
'linear' Easing function for the transition
- Source:
-
setHighlightCompression(v [, delayms] [, easing])
-
Sets the highlight compression value for HDR tone mapping.
Parameters:
Name Type Argument Default Description v
number The new highlight compression value
delayms
number <optional>
1 Delay in milliseconds for the transition
easing
string <optional>
'linear' Easing function for the transition
- Source:
-
setMode(mode)
-
Sets shader visualization mode
Parameters:
Name Type Description mode
string Mode to set
- Inherited From:
- Overrides:
- Source:
Fires:
-
setShader(id)
-
Sets the active shader
Parameters:
Name Type Description id
string Shader identifier from registered shaders
- Inherited From:
- Overrides:
- Source:
Fires:
Throws:
-
If shader ID is not found
- Type
- Error
-
setShadowLift(v [, delayms] [, easing])
-
Sets the shadow lift value for HDR tone mapping.
Parameters:
Name Type Argument Default Description v
number The new shadow lift value
delayms
number <optional>
1 Delay in milliseconds for the transition
easing
string <optional>
'linear' Easing function for the transition
- Source:
-
setState(state [, dt] [, easing])
-
Sets the layer state with optional animation
Parameters:
Name Type Argument Default Description state
Object State object with controls and mode
dt
number <optional>
Animation duration in ms
easing
string <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 tx
Transform New transform
- Inherited From:
- Overrides:
- Source:
Fires:
- Layer#event:updateSize
-
setViewport(view)
-
Sets the layer's viewport
Parameters:
Name Type Description view
Object Viewport specification
Properties
Name Type Description x
number X position
y
number Y position
dx
number Width
dy
number Height
- Inherited From:
- Overrides:
- Source:
Fires:
-
setVisible(visible)
-
Sets layer visibility
Parameters:
Name Type Description visible
boolean Whether layer should be visible
- Inherited From:
- Overrides:
- Source:
Fires:
-
setWhitePoint(v [, delayms] [, easing])
-
Sets the white point for HDR tone mapping.
Parameters:
Name Type Argument Default Description v
number The new white point value
delayms
number <optional>
1 Delay in milliseconds for the transition
easing
string <optional>
'linear' Easing function for the transition
- Source:
-
setZindex(zindex)
-
Sets layer rendering order
Parameters:
Name Type Description zindex
number 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: