new LayerLens(options)
Creates a new LayerLens instance
Parameters:
Name | Type | Description |
---|---|---|
options |
LayerLensOptions | Configuration options |
- Source:
Throws:
-
If camera is not provided
- Type
- Error
Example
```javascript // Create lens with base layer const lens = new OpenLIME.LayerLens({ camera: viewer.camera, radius: 150, borderEnable: true, borderColor: [0, 0, 0, 1] }); // Set layers lens.setBaseLayer(baseLayer); lens.setOverlayLayer(overlayLayer); // Animate lens position lens.setCenter(500, 500, 1000, 'ease-out'); // Add to viewer viewer.addLayer('lens', lens); ```
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
-
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
-
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
-
getBorderColor()
-
Gets current border color
- Source:
Returns:
RGBA color array
- Type
- Array.<number>
-
getBorderWidth()
-
Gets current border width
- Source:
Returns:
Border width in pixels
- 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:
-
getCurrentCenter()
-
Gets current lens center position
- Source:
Returns:
Center position in scene coordinates
- Type
- Object
-
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>
-
getRadius()
-
Gets current lens radius
- Source:
Returns:
Current radius in pixels
- Type
- number
-
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
-
getTargetCenter()
-
Gets target lens position for ongoing animation
- Source:
Returns:
Target position in scene coordinates
- Type
- Object
-
interpolateControls()
-
Updates control interpolation
- Inherited From:
- Overrides:
- Source:
Returns:
Whether all interpolations are complete
- Type
- boolean
-
pixelSizePerMM()
-
Gets pixel size in millimeters
- Inherited From:
- Overrides:
- Source:
Returns:
Size of one pixel in mm
- Type
- number
-
regenerateFrameBuffers(layer)
-
Sets the overlay layer (shown inside lens)
Parameters:
Name Type Description layer
Layer Overlay layer instance
- Source:
-
removeOverlayLayer()
-
Removes the overlay layer, returning to single layer mode
- Source:
-
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
-
setBaseLayer(layer)
-
Sets the base layer (shown outside lens)
Parameters:
Name Type Description layer
Layer Base layer instance
- Source:
Fires:
-
setCenter(x, y [, delayms] [, easing])
-
Sets lens center position with optional animation
Parameters:
Name Type Argument Default Description x
number X coordinate in scene space
y
number Y coordinate in scene space
delayms
number <optional>
100 Animation duration
easing
string <optional>
'linear' Animation easing function
- 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:
-
setMode(mode)
-
Sets shader visualization mode
Parameters:
Name Type Description mode
string Mode to set
- Inherited From:
- Overrides:
- Source:
Fires:
-
setOverlayLayer(layer)
-
Sets the overlay layer (shown inside lens)
Parameters:
Name Type Description layer
Layer Overlay layer instance
- Source:
-
setRadius(radius [, delayms] [, easing])
-
Sets lens radius with optional animation
Parameters:
Name Type Argument Default Description radius
number New radius in pixels
delayms
number <optional>
100 Animation duration
easing
string <optional>
'linear' Animation easing function
- Source:
-
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
-
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 and updates dashboard if present
Parameters:
Name Type Description visible
boolean Whether layer should be visible
- Inherited From:
- Overrides:
- Source:
Fires:
-
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: