or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

carto.mdcore-engine.mdeffects.mdextensions.mdindex.mdjson-config.mdlayers.mdmap-integration.mdreact.mdviews.mdwidgets.md
tile.json

core-engine.mddocs/

Core Rendering Engine

The foundational WebGL/WebGPU rendering system providing the main Deck class, layer management, views, viewports, controllers, and shader modules.

Capabilities

Deck Class

The main class for creating and managing deck.gl visualizations. Handles WebGL context, layer rendering, user interactions, and view state management.

/**
 * Main deck.gl visualization class
 * Creates and manages WebGL context, layers, views, and interactions
 */
class Deck {
  constructor(props: DeckProps);
  setProps(props: Partial<DeckProps>): void;
  finalize(): void;
  redraw(): void;
  pickObject(opts: PickObjectOptions): PickingInfo | null;
  pickMultipleObjects(opts: PickMultipleObjectsOptions): PickingInfo[];
  getCanvas(): HTMLCanvasElement | null;
}

interface DeckProps {
  /** Target DOM element or element ID for rendering */
  container?: HTMLElement | string;
  /** Canvas element to render into */
  canvas?: HTMLCanvasElement | string;
  /** Canvas width in pixels */
  width?: number;
  /** Canvas height in pixels */
  height?: number;
  /** Initial view state when not controlled */
  initialViewState?: ViewState;
  /** Controlled view state */
  viewState?: ViewState;
  /** Array of view instances */
  views?: View[];
  /** Array of layer instances to render */
  layers?: Layer[];
  /** Array of effect instances */
  effects?: Effect[];
  /** Enable/disable built-in controller or provide custom controller */
  controller?: boolean | ControllerProps;
  /** Called when view state changes */
  onViewStateChange?: (params: ViewStateChangeParameters) => void;
  /** Called on hover events */
  onHover?: (info: PickingInfo, event: Event) => boolean | void;
  /** Called on click events */
  onClick?: (info: PickingInfo, event: Event) => boolean | void;
  /** Called on drag start */
  onDragStart?: (info: PickingInfo, event: Event) => boolean | void;
  /** Called during drag */
  onDrag?: (info: PickingInfo, event: Event) => boolean | void;
  /** Called on drag end */
  onDragEnd?: (info: PickingInfo, event: Event) => boolean | void;
  /** Called when deck instance is loaded */
  onLoad?: () => void;
  /** Called on errors */
  onError?: (error: Error) => void;
  /** Enable debug mode */
  debug?: boolean;
  /** Draw picking colors for debugging */
  drawPickingColors?: boolean;
  /** Enable animation loop */
  _animate?: boolean;
}

interface PickObjectOptions {
  /** X coordinate in pixels */
  x: number;
  /** Y coordinate in pixels */
  y: number;
  /** Search radius in pixels */
  radius?: number;
  /** Layer IDs to include in picking */
  layerIds?: string[];
  /** View ID for multi-view setups */
  viewId?: string;
}

interface PickMultipleObjectsOptions extends PickObjectOptions {
  /** Maximum number of objects to return */
  depth?: number;
}

Usage Example:

import { Deck, ScatterplotLayer } from "deck.gl";

const deck = new Deck({
  container: 'map-container',
  initialViewState: {
    longitude: -122.4,
    latitude: 37.8,
    zoom: 10
  },
  controller: true,
  layers: [
    new ScatterplotLayer({
      id: 'points',
      data: myDataArray,
      getPosition: d => d.coordinates,
      getRadius: 100,
      getFillColor: [255, 0, 0]
    })
  ],
  onHover: (info) => {
    console.log('Hovered object:', info.object);
  }
});

Layer Base Class

Abstract base class for all deck.gl layers providing common layer functionality.

/**
 * Base class for all deck.gl layers
 * Provides common layer lifecycle and property management
 */
abstract class Layer<DataT = any, PropsT = LayerProps<DataT>> {
  constructor(props: PropsT);
  /** Update layer properties */
  setProps(props: Partial<PropsT>): void;
  /** Handle picking events - override in subclasses */
  getPickingInfo(params: GetPickingInfoParams): PickingInfo;
  /** Create a clone of this layer with optional property overrides */
  clone(props?: Partial<PropsT>): Layer<DataT, PropsT>;
  /** Get the current props */
  props: PropsT;
  /** Get the layer ID */
  id: string;
}

interface LayerProps<DataT = any> {
  /** Unique layer identifier */
  id: string;
  /** Data array to visualize */
  data?: DataT;
  /** Layer visibility */
  visible?: boolean;
  /** Layer opacity (0-1) */
  opacity?: number;
  /** Enable picking for this layer */
  pickable?: boolean;
  /** Hover event handler */
  onHover?: (info: PickingInfo, event: Event) => boolean | void;
  /** Click event handler */
  onClick?: (info: PickingInfo, event: Event) => boolean | void;
  /** Drag start event handler */
  onDragStart?: (info: PickingInfo, event: Event) => boolean | void;
  /** Drag event handler */
  onDrag?: (info: PickingInfo, event: Event) => boolean | void;
  /** Drag end event handler */
  onDragEnd?: (info: PickingInfo, event: Event) => boolean | void;
  /** Coordinate system for layer data */
  coordinateSystem?: CoordinateSystem;
  /** Coordinate origin for relative coordinates */
  coordinateOrigin?: Position;
  /** Array of layer extensions */
  extensions?: LayerExtension[];
  /** Object specifying when to update attributes */
  updateTriggers?: {[key: string]: any};
  /** Layer ID to render before (for ordering) */
  beforeId?: string;
  /** Blending operation */
  operation?: Operation;
}

interface GetPickingInfoParams {
  info: PickingInfo;
  mode: string;
  sourceLayer?: Layer;
}

CompositeLayer Base Class

Base class for layers that contain other layers, enabling complex visualization patterns.

/**
 * Base class for layers that contain other sub-layers
 * Enables complex visualization patterns by composing multiple layers
 */
abstract class CompositeLayer<DataT = any, PropsT = CompositeLayerProps<DataT>> extends Layer<DataT, PropsT> {
  constructor(props: PropsT);
  /** Override to return array of sub-layers */
  abstract renderLayers(): Layer[];
  /** Get all sub-layers */
  getSubLayers(): Layer[];
}

interface CompositeLayerProps<DataT = any> extends LayerProps<DataT> {
  /** Additional composite layer specific props */
}

Viewport Classes

Viewport classes handle coordinate transformations and camera projections.

/**
 * Base viewport class handling coordinate transformations
 */
abstract class Viewport {
  constructor(props: ViewportProps);
  /** Project world coordinates to screen coordinates */
  project(lngLat: Position, options?: ProjectOptions): [number, number];
  /** Unproject screen coordinates to world coordinates */
  unproject(xy: [number, number], options?: UnprojectOptions): Position;
  /** Get view matrix */
  getViewMatrix(): number[];
  /** Get projection matrix */
  getProjectionMatrix(): number[];
  /** Get view-projection matrix */
  getViewProjectionMatrix(): number[];
}

/**
 * Web Mercator projection viewport for map-like visualizations
 */
class WebMercatorViewport extends Viewport {
  constructor(props?: WebMercatorViewportProps);
}

/**
 * Orbit camera viewport for 3D object examination
 */
class OrbitViewport extends Viewport {
  constructor(props?: OrbitViewportProps);
}

/**
 * First person camera viewport for immersive experiences
 */
class FirstPersonViewport extends Viewport {
  constructor(props?: FirstPersonViewportProps);
}

/**
 * Orthographic projection viewport for technical drawings
 */
class OrthographicViewport extends Viewport {
  constructor(props?: OrthographicViewportProps);
}

interface ViewportProps {
  width: number;
  height: number;
  [key: string]: any;
}

Controller Classes

Controller classes handle user input for camera manipulation.

/**
 * Base controller class for handling user input
 */
abstract class Controller {
  constructor(props?: ControllerProps);
  /** Handle input events */
  handleEvent(event: Event): boolean;
  /** Set controller properties */
  setProps(props: Partial<ControllerProps>): void;
}

/**
 * Map-style controller supporting pan, zoom, rotate
 */
class MapController extends Controller {
  constructor(props?: MapControllerProps);
}

/**
 * Orbit controller for 3D object examination
 */
class OrbitController extends Controller {
  constructor(props?: OrbitControllerProps);
}

/**
 * First person controller for immersive navigation
 */
class FirstPersonController extends Controller {
  constructor(props?: FirstPersonControllerProps);
}

/**
 * Orthographic controller for technical drawings
 */
class OrthographicController extends Controller {
  constructor(props?: OrthographicControllerProps);
}

interface ControllerProps {
  /** Enable drag to pan */
  dragPan?: boolean;
  /** Enable drag to rotate */
  dragRotate?: boolean;
  /** Enable scroll to zoom */
  scrollZoom?: boolean;
  /** Enable touch to zoom */
  touchZoom?: boolean;
  /** Enable touch to rotate */
  touchRotate?: boolean;
  /** Enable double-click to zoom */
  doubleClickZoom?: boolean;
  /** Enable keyboard navigation */
  keyboard?: boolean;
}

Attribute Management

System for managing GPU attributes and buffers.

/**
 * Represents a single GPU attribute
 */
class Attribute {
  constructor(device: Device, options: AttributeOptions);
  /** Update attribute data */
  setData(options: AttributeSetDataOptions): void;
  /** Get attribute value at index */
  getValue(index: number): any;
  /** Get the underlying GPU buffer */
  getBuffer(): Buffer;
}

/**
 * Manages multiple attributes for a layer
 */
class AttributeManager {
  constructor(device: Device, options?: AttributeManagerOptions);
  /** Add an attribute */
  add(attributes: {[key: string]: AttributeOptions}): void;
  /** Remove an attribute */
  remove(attributeNames: string[]): void;
  /** Update attributes with new data */
  update(options: AttributeUpdateOptions): void;
  /** Get an attribute by name */
  getAttribute(name: string): Attribute;
}

interface AttributeOptions {
  /** Number of components per vertex */
  size: number;
  /** Data type of components */
  type?: number;
  /** Accessor function to extract data */
  accessor?: string | AccessorFunction;
  /** Default value when data is missing */
  defaultValue?: number[];
  /** Update frequency hint */
  update?: string;
}

Constants

/** Library version string */
const VERSION: string;

/** Coordinate system constants */
enum COORDINATE_SYSTEM {
  LNGLAT = 1,
  METER_OFFSETS = 2,
  LNGLAT_OFFSETS = 3,
  CARTESIAN = 0
}

/** Unit type constants */
enum UNIT {
  METERS = 'meters',
  COMMON = 'common',
  PIXELS = 'pixels'
}

/** Operation constants for blending */
enum OPERATION {
  DRAW = 0,
  MASK = 1,
  TERRAIN = 2
}

Utility Functions

/** Logging utility */
function log(level: number, message: string, ...args: any[]): void;

/** Assertion utility */
function assert(condition: any, message?: string): void;

/** Create iterable from data */
function createIterable(data: any): Iterable<any>;

/** Get low part of 64-bit float */
function fp64LowPart(x: number): number;

/** Get shader assembler */
function getShaderAssembler(): any;