Introducing a new way to review your PRs.

Read the announcement

visgl / deck.gl

WebGL2 powered visualization framework

View on GitHub

23 documents · Updated Nov 20, 2026

docs / data-and-visualization-extensions

Data and visualization extensions

The optional data and visualization packages extend the core deck.gl runtime without changing its main rendering model. They turn serialized configuration into runtime values, connect CARTO data and map descriptions to deck.gl layers, and add reusable behavior such as filtering, masking, terrain placement, collision control, and path and fill styling.

Extension boundary

The extension boundary separates the core runtime from capabilities that not every application needs. Each package supplies a public entry point and works with core layer contracts, so an application can add one capability without adopting the others. The published CARTO and extensions packages provide both module and CommonJS entry points for different host applications.

Package roles

The three packages address different parts of the visualization path:

PackageSystem roleResult for an application
@deck.gl/jsonConverts declarative JSON into runtime props and configured objectsA serialized layer or view description can drive a deck.gl visualization
@deck.gl/cartoConnects CARTO sources, map descriptions, tiles, and styles to deck.glCARTO data can become ready-to-render layers and basemaps
@deck.gl/extensionsAdds reusable capabilities to compatible layersA layer can gain extra behavior without a new layer type

These packages are optional. The core runtime still owns layer state, rendering, and interaction after the packages produce layers or layer props.

References: modules/…/package.json• L1-51 modules/…/package.json• L1-80 modules/…/package.json• L1-55

Declarative JSON configuration

The JSON subsystem provides a declarative input path for deck.gl layers, views, and their properties. It resolves names and expressions in a JSON document against application-provided catalogs, then returns values that the normal runtime can use.

Configuration translation

JSONConverter accepts a JSON string or object and walks its values recursively. A configured type becomes a class or React component instance, a configured function reference becomes a function result, and special string forms become accessors, constants, or enumerated values.

The configuration catalogs define what serialized names are allowed to become. This keeps the JSON format separate from the JavaScript objects that execute it and lets a wrapper register its own classes, functions, constants, and enums.

flowchart LR
  A[JSON document] --> B[JSON converter]
  B --> C[Configured classes and components]
  B --> D[Accessors and function results]
  B --> E[Constants and enum values]
  C --> F[Deck layer or view props]
  D --> F
  E --> F
  F --> G[Core visualization runtime]

The converter supports small expressions for data access. It does not allow function-call syntax in those expressions, which keeps expression evaluation limited to the supplied data rather than arbitrary global behavior.

See the JSON specification for the document forms and value rules.

References: modules/…/json-converter.ts• L15-43 modules/…/json-converter.ts• L89-169 modules/…/json-configuration.ts• L23-45 modules/…/parse-expression-string.ts• L30-63

CARTO data access

The CARTO subsystem connects CARTO data services to deck.gl's layer model. It accepts CARTO source definitions or map descriptions, obtains the data or tile metadata needed by a layer, and exposes the result as deck.gl layer instances. The package supports both module import and CommonJS require use, so the same data path can serve modern and older host applications.

Source and layer flow

The package covers several geospatial source shapes. Query and table sources can feed data-driven layers, while tileset sources support tiled vector, raster, H3, and quadbin views. The package also exposes helpers for CARTO basemap styles and for converting map descriptions into deck.gl basemap and layer properties.

When an application calls fetchMap, the CARTO client returns layer descriptors. The deck.gl wrapper maps each supported descriptor type to a matching layer class, so the result is ready to add to a Deck instance. A lower-level use can keep the descriptors and call LayerFactory when it needs to control layer creation.

Quadbin cells use the same tile-space model as the CARTO tile source. The integration converts a cell into a tile offset and scale, then converts its covered tile area into world bounds or a geographic polygon. This gives tiled analysis layers a consistent cell position when they build clusters or heatmaps.

sequenceDiagram
  participant App as Application
  participant Carto as CARTO services
  participant Integration as CARTO integration
  participant Core as Core runtime

  App->>Integration: Request map or define source
  Integration->>Carto: Fetch map, tiles, or data
  Carto-->>Integration: Descriptors, tile metadata, or records
  Integration->>Integration: Map data to deck.gl layer types
  Integration-->>App: Layer instances and basemap props
  App->>Core: Add layers to the visualization
  Core-->>App: Rendered CARTO data

The layer family also supports two tiled analysis paths. Cluster layers combine visible H3 or quadbin cells into viewport-aware point summaries. Heatmap layers turn weighted H3 or quadbin cells into a density view with a configurable color range. They normalize cell weights by cell resolution and adjust the displayed maximum as the viewport changes, so density remains comparable across tile levels. These paths preserve the deck.gl layer contract while hiding tile loading and cell aggregation from the application.

Heatmap palettes follow the color value convention used by the active Deck instance. The layer rebuilds its palette when either the colors or that convention changes, so normalized color arrays and byte color arrays produce the same intended visual scale.

Vector tile rendering accepts CARTO's native binary tiles and MVT tiles. Native sources can keep geometry and properties in separate tile requests, while the integration combines them before rendering. Tile decoding can run in workers, and the package keeps a CommonJS decoder path for hosts that cannot use the module-only decoder export.

Vector tile rendering provides a point-label path for primary and secondary labels. It can reserve label space for collision checks while keeping the visible text background separate. In native tile mode, the integration clips geometry sublayers to the tile bounds and passes compatible extensions to those sublayers. Automatic labels are created as a later sublayer when enabled.

See the CARTO integration page for source types, map loading, tile behavior, and the Python CARTO boundary.

References: modules/…/package.json• L26-80 modules/…/build-cjs.mjs• L5-25 modules/…/fetch-map.ts• L25-71 modules/…/quadbin-utils.ts• L10-29 modules/…/vector-tile-layer.ts• L74-95 modules/…/vector-tile-layer.ts• L99-132 modules/…/vector-tile-layer.ts• L164-235 modules/…/cluster-tile-layer.ts• L283-319 modules/…/heatmap-tile-layer.ts• L194-253 modules/…/heatmap-tile-layer.ts• L270-375 modules/…/heatmap-tile-layer.ts• L393-414 modules/…/carto-vector-tile-loader.ts• L32-45 modules/…/cartoVectorTile.ts• L5-8 modules/…/utils.ts• L42-46

Composable layer capabilities

The extensions subsystem lets an application attach a capability to a compatible layer through the layer's extensions property. An extension participates in the layer lifecycle and can add props, shader behavior, GPU work, or a shared effect while the layer keeps its original data and rendering role.

The extension surface has matching shader paths for WebGL and WebGPU. This keeps the same layer-level capability available across the two rendering backends without changing the data contract of the host layer.

Pointer brushing shows or hides objects near the current pointer. Numeric and category filtering applies hard or soft rules to object data and can report how many objects remain visible. Both capabilities add the data needed by the layer and apply the final visibility decision during rendering.

Data filtering can also count the objects that pass its rules. The count is produced by a separate aggregation pass and reported through the layer callback. WebGPU may return it after the draw has finished, so results from an older filter or data state are discarded.

Collision filtering handles overlap between layers that share a collision group. It builds a shared collision map for each group, then lets participating layers use that map during normal drawing and picking. The map is refreshed when the view, layer bounds, loading state, or transitions change.

Path styling supports dashed lines and line offsets on path geometry. It also supports dash treatment for scatterplot outlines and text backgrounds. Path dashes can use width, pixel, meter, or common-space units. Whole-path dash mode keeps the dash phase continuous across rendered segments and needs readable path data or supplied dash metrics. The legacy Fp64Extension adds high-precision projection for supported longitude and latitude layers, but it is deprecated.

Fill styling supports image-atlas patterns and procedural hatch, cross-hatch, and dot patterns. These capabilities leave the underlying layer responsible for its data and geometry.

Procedural fill patterns are described by named JSON-like definitions. The extension validates those definitions, packs them into a GPU-readable pattern description, and evaluates the shapes in the shader. This avoids a required image atlas for the supported pattern types while keeping pattern selection a per-object layer property. The packed data uses a backend-safe texture form so the same pattern rules work in WebGL and WebGPU.

The package includes capabilities for these broad needs:

Capability groupVisualization need
Brushing and data filteringShow data near the pointer or within numeric and category rules
Path and fill stylingAdd dashed, offset, or patterned visual treatment
Masking and clippingLimit visible objects to a mask or clip region
Collision handlingHide overlapping objects and control which objects take priority
Terrain and precisionPlace objects on terrain or use higher coordinate precision

Compatibility is part of the contract. An extension can ignore a layer that does not support its geometry or required data. Masking, collision filtering, and terrain also coordinate shared effects with the deck instance. They use flat common-space bounds for their render regions. Globe views use separate spherical-coordinate handling where required.

Clipping limits either whole instances or their rendered geometry to rectangular bounds. The extension chooses the mode from the layer shape unless the application sets it. Instance clipping follows the layer's source position transform, while geometry clipping uses a continuous flat projection and handles wrapped world copies around the bounds center. The WebGPU path receives the same mode and bounds contract as the other rendering path.

Masking uses one or more visible layers as named mask sources. A mask effect renders those sources into shared channels, then compatible layers use a channel by maskId to show or hide their instances or geometry. The effect supports up to four mask channels and does not support globe views. On WebGPU, the mask pass clears only the selected channel before it draws, so updating one mask does not erase the other active channels.

Terrain coordinates terrain and draped layers through shared height-map or cover textures. A terrain pass can write elevation, while other layers can read that elevation or use the terrain cover as their visual surface. TerrainExtension fits either layer anchors or layer geometry to that surface. Its automatic mode uses anchor-based offset fitting for anchored or extruded layers and geometry-based drape fitting for other layers. WebGPU supports the anchor-based offset mode and rejects drape mode.

The projection helpers provide one flat common-space contract for these spatial effects. They convert layer bounds and viewport bounds consistently across source coordinate systems, handle antimeridian bounds, and avoid intersecting flat layer bounds directly with spherical globe bounds. Globe views use separate spherical-coordinate handling where required. This includes conversion of meter offsets through the globe tangent plane before shared effects use flat common space.

See Layer extensions for the extension lifecycle and the capability-specific behavior.

References: modules/…/layer-extension.ts• L11-80 modules/…/brushing-extension.ts• L11-95 modules/…/shader-module.ts• L97-170 modules/…/data-filter-extension.ts• L25-35 modules/…/data-filter-extension.ts• L134-157 modules/…/data-filter-extension.ts• L160-184 modules/…/data-filter-extension.ts• L187-212 modules/…/data-filter-extension.ts• L244-339 modules/…/shader-plugin.ts• L42-105 modules/…/collision-filter-effect.ts• L26-107 modules/…/collision-filter-effect.ts• L127-175 modules/…/shader-module.ts• L147-189 modules/…/path-style-extension.ts• L33-57 modules/…/path-style-extension.ts• L219-237 modules/…/path-style-extension.ts• L311-373 modules/…/path-style-extension.ts• L397-427 modules/…/shaders.wgsl.ts• L34-168 modules/…/fill-style-extension.ts• L118-145 modules/…/fill-style-extension.ts• L226-245 modules/…/procedural-pattern.ts• L37-53 modules/…/shader-module.wgsl.ts• L7-25 modules/…/float-parameter-texture.ts• L7-25 modules/…/clip-extension.ts• L34-85 modules/…/shader-module.ts• L67-129 modules/…/clip-extension.ts• L83-117 modules/…/mask-effect.ts• L78-210 modules/…/mask-pass.ts• L30-118 modules/…/shader-module.ts• L9-16 modules/…/masked-color-clear.ts• L21-54 modules/…/terrain-extension.ts• L15-20 modules/…/terrain-extension.ts• L30-76 modules/…/shader-module.ts• L36-49 modules/…/shader-module.ts• L101-145 modules/…/projection-utils.ts• L39-79

Combined data path

The optional subsystems meet at the core layer boundary. JSON can describe the layer and its props, CARTO can supply the data and layer class, and extensions can add behavior before the core runtime renders the final layer.

Runtime relationship

An application can use these paths separately or together. For example, a JSON catalog can register a CARTO layer class and an extension class, while a CARTO map fetch can create layers that use the same extension capabilities directly.

flowchart TB
  J[Declarative JSON] --> N[Runtime props and objects]
  C[CARTO sources or map] --> L[CARTO layer instances]
  N --> L
  L --> X[Optional layer extensions]
  X --> R[Core layer lifecycle]
  R --> V[GPU visualization and interaction]

This relationship keeps data access, configuration, and layer behavior distinct. The core runtime receives ordinary layer objects at the end of the path, regardless of which optional subsystem created or enhanced them.

References: modules/…/index.ts• L7-17 modules/…/fetch-map.ts• L25-71 modules/…/layer-props.ts• L201-207 modules/…/layer.ts• L1005-1016

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep serialized @@type and @@function names aligned with the catalogs registered by JSON consumers. A name mismatch changes a usable object into a warning and a null result.
  • Keep CARTO descriptor types aligned with LayerFactory and with the source and tile data shapes expected by the matching layer classes.
  • Keep vector tile format detection aligned with coordinate-system handling, geometry and property tile merging, sublayer clipping, and automatic-label creation.
  • Keep H3 and quadbin tile schemes aligned across cell-to-tile conversion, polygon bounds, cluster aggregation, heatmap density scaling, tile resolution, and source metadata.
  • Keep heatmap color-range data, Deck color conventions, cell-resolution normalization, maximum-density reporting, and zoom-level transitions aligned. A change to palette packing or density scaling can alter both the visual result and any consumer of onMaxDensityChange.
  • Keep extension default props, extension options, and the layer types that consume them aligned. A capability can appear valid at the prop level but have no effect on an incompatible layer.
  • Keep GLSL and WGSL shader inputs, uniforms, visibility hooks, coordinate rules, and picking behavior aligned for every extension. A backend can otherwise render a different result while the layer API remains unchanged.
  • Keep brushing attributes aligned with the target mode used by the shader. Pointer redraws must remain connected to the active deck event source.
  • Keep data-filter attribute sizes, category maps, filter bit masks, and optional item-count aggregation aligned. Changes to one category channel can silently change which objects pass.
  • Keep filtered-item count buffers, readback formats, and stale-result checks aligned across WebGL and WebGPU. A change can report the wrong count or report an old count after a new filter update.
  • Keep collision groups, collision-map lifetime, viewport updates, and picking behavior aligned. A group change can silently make layers share the wrong overlap map or skip collision updates.
  • Keep clip bounds in the same source and common spaces used by instance and geometry clipping. Changes to coordinate transforms must cover tile-local geometry, antimeridian wrapping, and WebGPU mode selection.
  • Keep mask channel allocation, per-channel clearing, mask layer ids, coordinate conversion, and cached render bounds aligned. Globe views must continue to avoid flat-bound intersection.
  • Keep terrain mode values aligned between terrain effects, texture bindings, flat bounds, globe position conversion, and renderer support. WebGPU must continue to select or enforce the supported offset mode while height-map and cover passes keep their distinct render roles.
  • Keep fill pattern names aligned with the atlas mapping or procedural pattern mapping. Keep the atlas or generated pattern data available to the layer that uses the fill capability.
  • Keep procedural pattern definitions aligned with the shader's supported pattern types and value limits. Invalid definitions fail while the pattern data is prepared.
  • Keep the procedural pattern texture format and WGSL bit-cast path aligned with the packed float records. A texture-type change can make valid pattern parameters unreadable on one backend.
  • Keep path dash unit values aligned between the public option mapping and the shader branches. Changes to path-mode metrics must also preserve the data contract for CPU-readable geometry or supplied dash offsets.
  • Keep path dash and offset coordinate stages ordered consistently across GLSL and WGSL. Both features change the same path coordinates and must not depend on extension merge order.
  • Keep Fp64Extension coordinate checks aligned with the project64 module. It is a deprecated path for supported longitude and latitude coordinate systems, not a general precision mode.
  • Keep flat common-space projection rules aligned between CPU bounds helpers, GPU projection behavior, source coordinate transforms, and mask, terrain, or clipping render regions. Globe viewport bounds are spherical and must not be intersected directly with flat layer bounds.
  • Keep CARTO access-token handling aligned across map requests, tile requests, and any new source or loader path.
  • Keep basemap output shapes compatible with the host map integration that consumes the returned basemap props.
  • Keep the package's import and CommonJS entry points aligned with the bundled synchronous decoder path. A loader subpath that works only for one module system can break CARTO tile access for that host.
  • Keep packed tile array types and compression flags aligned between CARTO tile schemas and the typed-array decoder. A mismatch can turn valid raster or spatial data into unusable layer input.
  • Keep point-label defaults, collision extensions, and automatic-label sublayer props aligned. A label change can affect both visible text and the space reserved for collision checks.

Important failure modes

TriggerConsequenceGuard
JSON names a class or function that is not in its configuration catalogConversion logs a warning and returns null for that valueRegister every type and function used by the document
A JSON expression contains a function callConversion throws instead of producing an accessorUse data-only property and value expressions
CARTO returns a descriptor type with no layer mappingfetchMap throws because no deck.gl layer class is availableAdd the mapping and its matching layer support before using the descriptor
A CARTO request lacks a valid access tokenData or tiles cannot be fetched from the protected sourcePass the token through the source or tile configuration
A quadbin cell is converted with the wrong tile scale or vertical originCluster or heatmap geometry is placed in the wrong geographic areaKeep quadbin tile coordinates, the 512-unit tile space, coverage, and world-to-geographic conversion aligned
A native vector tile has invalid geometry or property tile URLsThe tile cannot produce the expected combined layer dataPreserve valid geometry and property tile templates together
A tile scheme changes without updating cluster or heatmap handlingH3 or quadbin cells use the wrong position, resolution, or density rulesKeep source metadata and the selected tile layer in step
Heatmap palette packing or density normalization changes without matching Deck color conventions and color scalingThe same data can use the wrong colors or appear too bright, too dim, or inconsistent between tile levelsKeep palette encoding, cell resolution, maximum-density reporting, and the heatmap color domain in the same contract
A fill pattern name has no atlas or procedural mappingThe pattern has no usable frame or pattern record and does not render as intendedDefine every value returned by getFillPattern in the selected mapping
A procedural pattern has an unsupported type or invalid size, gap, angle, or skewPattern texture creation throws and the layer cannot use the procedural patternUse one of the supported pattern shapes and valid finite values
A procedural pattern texture is read with the wrong backend formatPattern parameters become corrupted or the pattern becomes blank on one rendering backendKeep the packed record format, texture format, and shader load path aligned
Path-mode dashes use GPU-only getPath data without precomputed dash offsetsDash metrics cannot be calculated and path styling throwsProvide readable path data or data.attributes.instanceDashOffsets
A dash unit is mapped differently in the shader and public optionDash lengths change between modes or rendering backendsKeep DashUnits and both shader branches in the same order
Clip bounds use a coordinate space that does not match the layer source or rendered geometryInstances or geometry are clipped in the wrong placeApply the layer source transform for instance mode and the flat common projection for geometry mode
A globe viewport's spherical bounds are intersected directly with flat layer boundsMask or terrain render regions can be wrong or omit visible dataConvert layer bounds to flat common space and use globe-specific bounds handling
A mask layer id is empty or does not match a valid mask layerMasking is disabled and a warning can be loggedCreate the mask layer first and use the same id
More than four mask sources are activeAdditional mask sources are not assigned a mask channelLimit the active mask sources to four
A WebGPU mask clear resets the full color attachment instead of only the selected channelUpdating one mask can erase other active mask channelsClear the selected channel with a masked draw inside the mask render pass
Fp64Extension is used with an unsupported coordinate systemShader setup throws instead of enabling legacy 64-bit projectionUse the extension only with its supported longitude and latitude coordinate systems
An extension is used on an unsupported layer typeThe layer renders without that extension's capabilityCheck the extension's supported geometry and layer contract
WebGPU selects terrain drape modeTerrain setup throws because WebGPU supports anchor-based offset fitting onlySet terrainDrawMode: "offset" or let the extension infer the supported mode
A collision group changes without a collision-map refreshOverlapping objects can remain visible or valid objects can stay hiddenRefresh the group map after viewport, bounds, loading, transition, or layer changes
A filtered-item count readback completes after a newer filter or data updateThe callback can expose an old countDiscard readback results whose layer state or count version is no longer current
A CommonJS host cannot resolve the synchronous compression decoderCARTO package loading or packed tile decoding fails before renderingKeep the CommonJS bundle alias and package export in step with the decoder entry point
A packed tile declares a type or compression mode that the decoder does not supportRaster or spatial values fail to decode or have the wrong typed representationUse the schema's supported type and compression contract
A point-label size or offset change is not reflected in collision paddingLabels can overlap or collision checks can hide the wrong labelsUpdate the visible and collision label paths together

Key files

FileWhy to read it
modules/…/json-converter.tsShows how declarative JSON becomes runtime values and props
modules/…/json-configuration.tsDefines the catalogs and hooks that connect JSON names to runtime objects
modules/…/fetch-map.tsShows how CARTO map descriptors become deck.gl layers
modules/…/index.tsDefines the public CARTO layer, source, styling, and map-loading surface
modules/…/quadbin-utils.tsDefines the quadbin tile-to-world coordinate boundary used by CARTO spatial layers
modules/…/vector-tile-layer.tsShows the CARTO vector tile path, format split, sublayer clipping, and automatic labels
modules/…/cluster-tile-layer.tsShows how H3 and quadbin tiles become viewport-aware cluster layers
modules/…/heatmap-tile-layer.tsShows how tiled cell weights become a density visualization
modules/…/package.jsonDefines the CARTO package entry points and host-package contract
modules/…/build-cjs.mjsShows how the CommonJS package path keeps synchronous tile decoding available
modules/…/carto-vector-tile-loader.tsDefines the packed vector tile decoding boundary
modules/…/index.tsLists the reusable layer capabilities exposed by the extensions package
modules/…/brushing-extension.tsIllustrates pointer-driven visibility for compatible layers
modules/…/data-filter-extension.tsIllustrates numeric and category filtering with optional visible-item counts
modules/…/shader-plugin.tsShows how filtering inputs and backend shader hooks form one layer capability
modules/…/collision-filter-effect.tsShows how shared collision maps control overlap across compatible layers
modules/…/fp64-extension.tsShows the deprecated precision extension and its coordinate-system boundary
modules/…/path-style-extension.tsIllustrates dashed and offset styling for compatible path-like layers
modules/…/shaders.wgsl.tsShows the WebGPU path-style contract for dashes and offsets
modules/…/fill-style-extension.tsIllustrates atlas-based and procedural pattern styling for compatible fill layers
modules/…/procedural-pattern.tsDefines the supported procedural fill pattern shapes and validation boundary
modules/…/shader-module.wgsl.tsShows the WebGPU pattern rendering path
modules/…/float-parameter-texture.tsDefines the cross-backend texture boundary for packed pattern parameters
modules/…/clip-extension.tsIllustrates rectangular clipping for instances and geometry across coordinate spaces
modules/…/shader-module.tsDefines the shared GLSL and WGSL clipping behavior and world-wrap handling
modules/…/mask-extension.tsIllustrates how a layer selects and applies a named mask
modules/…/mask-pass.tsShows how mask channels are rendered and cleared across GPU backends
modules/…/masked-color-clear.tsDefines the WebGPU draw used to clear one mask channel without changing the others
modules/…/terrain-effect.tsShows how terrain height maps and cover textures affect layer rendering
modules/…/terrain-extension.tsDefines terrain fitting modes and the WebGPU mode boundary
modules/…/projection-utils.tsDefines the common-space bounds used by mask, terrain, and clipping effects across source coordinate systems and flat or globe views
modules/…/layer-extension.tsDefines the lifecycle boundary shared by all layer extensions
modules/…/clip-extension.tsDefines the WebGPU clipping contract shared with the extension
modules/…/point-label-layer.tsShows how CARTO point labels combine visible text with collision-aware label space
modules/…/fast-pbf.tsShows the shared typed-array and gzip decode boundary for packed CARTO tile data