InSightAnalysis
A spatial analysis object for insight (line-of-sight) analysis, used to perform insight analysis on a 3D scene.
It draws a line between the viewpoint (from) and the target point (to) and checks whether the line is blocked by the model: the visible segment is colored with visibleColor, the invisible segment with invisibleColor, and the objects intersected by the insight lines can be returned (based on RayCaster ray casting, added after cross-checking the 2026 source code).
Constructor
import { InSightAnalysis } from '@maptalks/gl-layers';
const insightAnalysis = new InSightAnalysis({
lines: [
{
from: [center.x + 0.003, center.y + 0.002, 50],
to: [center.x - 0.001, center.y - 0.0005, 100]
}
],
visibleColor: [0, 1, 0, 1],
invisibleColor: [1, 0, 0, 1]
});
insightAnalysis.addTo(groupGLLayer);Details
- options* Object configuration options, the available options are as follows:
| Option | Type | Description | Default |
|---|---|---|---|
| lines | Object[] | The array of insight lines, each item is { from, to } (coordinate arrays or Coordinate, added after cross-checking the 2026 source code) | [] |
| visibleColor | Number[] | A 4-component normalized array; the color of the visible segment (green) | [0, 1, 0, 1] |
| invisibleColor | Number[] | A 4-component normalized array; the color of the invisible segment (red) | [1, 0, 0, 1] |
| excludeLayers | String[] | The list of layer ids to ignore (not involved in occlusion detection) | null |
Member Methods
addLine(inSightLine)
Adds an insight line.
Parameters:
- inSightLine Object the insight line, with the structure
{ from, to }
Returns:
- void
removeLine(inSightLine)
Removes an insight line.
Parameters:
- inSightLine Object the insight line to remove
Returns:
- void
getLines()
Gets all insight lines.
Returns:
- Object[]
setLines(lines)
Sets the array of insight lines.
Parameters:
- lines Object[] the array of insight lines, each item is
{ from, to }
Returns:
- void
clearLines()
Clears all insight lines.
Returns:
- void
getIntersetction()
Gets all objects intersected by the insight lines, with the structure [{ inSightLine, intersects: [{ data: maptalks object (such as a gltfmarker or polygon), coordinates: [{ coordinate, indices }] }] }].
Note: the method name follows the spelling
getIntersetctionin the source code (verified against the 2026 source).
Returns:
- Object[]
Methods Inherited from Analysis
addTo(groupGLLayer)
Adds the analysis object to a GroupGLLayer.
Spatial analysis objects can only be added to a GroupGLLayer; they cannot be added to other WebGL layers.
Parameters:
- groupGLLayer GroupGLLayer the GroupGLLayer
Returns:
- this
remove()
Removes the spatial analysis object from the layer.
Returns:
- void
update(name, value)
Updates options data.
Parameters:
- name String the setting name
- value any the setting value
Returns:
- void
getAnalysisType()
Gets the type of the Analysis.
Returns:
- String
getDefines()
Internal method.
Returns the defines added to the shader when the Analysis is rendered.
Returns:
- Object
renderAnalysis(meshes)
Internal method.
Renders the spatial analysis scene (implemented by each analysis subclass) and returns the uniform variables required for rendering.
Parameters:
- meshes Mesh[] the scene meshes
Returns:
- Object
enable()
Enables the analysis.
Returns:
- void
disable()
Disables the analysis.
Returns:
- void
isEnable()
Whether the analysis is enabled.
Returns:
- Boolean
getExcludeLayers()
Gets the list of layer ids excluded from the analysis (these layers are ignored during the analysis).
Returns:
- String[]
setExcludeLayers(layerIds)
Sets the list of layer ids excluded from the analysis.
Parameters:
- layerIds String[] list of layer ids
Returns:
- void
exportAnalysisMap(meshes)
Exports the analysis result image (RGBA pixel data); returns null when the analysis is not enabled.
Parameters:
- meshes Mesh[] the scene meshes
Returns:
- Uint8Array
This document has been cross-checked against the @maptalks/gl-layers 2026 source (api-notes-others.md / api-notes-vt-gl.md)