SDK JS
    Preparing search index...

    Streams an OGC 3D-Tiles gaussian-splat tileset and renders it georeferenced — a MapLibre CustomLayerInterface, added with map.addLayer and torn down with map.removeLayer. Only id and url are required (Tiles3DSplatLayerOptions): tiles decode in a worker pool ('spz' by default, 'bvc', or your own GltfSplatDecoder) and the dataset auto-grounds onto the flat map or onto 3D terrain. Nothing is fetched until the layer is added to a map.

    Requires a WebGL2 context — on WebGL1 the layer goes inert and draws nothing — and renders under the mercator projection only: under a non-affine (globe) projection it hides itself.

    import { Tiles3DSplatLayer } from '@bitruvius/sdk-maplibre';

    map.addLayer(new Tiles3DSplatLayer({ id: 'wharf', url: 'https://…/tileset.json' }));

    Implements

    Index

    Constructors

    Properties

    id: string

    A unique layer id.

    renderingMode: "3d" = ...

    Either "2d" or "3d". Defaults to "2d".

    type: "custom" = ...

    The layer's type. Must be "custom".

    Methods

    • Revert to the ungraded (full-daylight) look — the clearSun half of SunLightable (used when the geo-sun system is disabled).

      Returns void

    • The dataset attribution string this layer contributes, if any.

      Returns string | undefined

    • The dataset's camera target [lng, lat] (degrees), or null until the tileset's root center is known. Handy for driving your own flyTo.

      Returns [number, number] | null

    • The dataset's geographic footprint as [west, south, east, north] in degrees.

      Returns LayerExtent | null

      [west, south, east, north] in degrees, or null until the root resolves.

      3D Tiles declares no extent the way I3S does, so this is derived from the root bounding volume by expanding its eight corners — see extentFromObbEcef for why corners rather than a radius.

    • MapLibre CustomLayerInterface hook — invoked when the layer is added with map.addLayer; initializes GL resources and begins streaming.

      Parameters

      Returns void

    • MapLibre CustomLayerInterface hook — invoked when the layer is removed with map.removeLayer; releases GL resources and stops streaming.

      Returns void

    • Resolve a canvas point to the 3D geographic position of the frontmost rendered splat — the screen→scene primitive behind measurement and slice placement. GPU pick pass over the drawn splats' CENTERS (depth-tested, so the nearest wins), read back as the EXACT stored anchor-ENU position and converted through the layer's placement (which embeds the vertical-datum seat).

      Parameters

      • x: number

        Canvas X in CSS pixels, top-left origin (e.g. a MapLibre click event's e.point.x).

      • y: number

        Canvas Y in CSS pixels, top-left origin.

      • snapRadiusPx: number = 0

        Snap radius in CSS pixels (default 0 = exact pixel): the splat nearest the cursor within the radius wins.

      Returns PickedPosition | null

      The picked position (lng/lat degrees, height metres above the rendered ground datum, plus the cross-layer-comparable depth01), or null on a miss / before the first frame / when the GPU lacks float-color rendering.

    • Optional method called during a render frame to allow a layer to prepare resources or render into a texture.

      The layer cannot make any assumptions about the current GL state and must bind a framebuffer before rendering.

      Parameters

      Returns void

    • Working-set load fraction (0–1): ready (drawn) tiles over ready + still-pending (fetching/decoding/queued). 1 when the current view is fully resolved.

      Returns number

    • Called during a render frame allowing the layer to draw into the GL context.

      The layer can assume blending and depth state is set to allow the layer to properly blend and clip other layers. The layer cannot make any other assumptions about the current GL state.

      If the layer needs to render to a texture, it should implement the prerender method to do this and only use the render method for drawing directly into the main framebuffer.

      The blend function is set to gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA). This expects colors to be provided in premultiplied alpha form where the r, g and b values are already multiplied by the a value. If you are unable to provide colors in premultiplied form you may want to change the blend function to gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA).

      Parameters

      Returns void

    • Sample the height of the topmost splat surface at each position — the on-nadir DSM used by the volume / elevation-profile tools. Builds ONE overhead ortho frame over the points' bbox, renders the pick pass into a full grid (Tiles3DSplatRenderer.sampleDepthGrid), and converts each cell's splat centre to a height above the rendered ground datum (same frame as queryTerrainElevation).

      Parameters

      • points: readonly { lat: number; lng: number }[]

        lng/lat in degrees.

      • Optionalopts: SurfaceSampleOptions

        Optional: gridPx sets the overhead pass's long-axis resolution (default 1024; small values like 64 for cheap point probes).

      Returns (number | null)[]

      Height per point, or null where no splat surface covers the cell / the layer isn't ready.

    • Resize the resident-memory budget live (the runtime equivalent of the budget ctor option). Shrinking evicts far/out-of-view tiles down to the new ceiling on the next frame; growing lets the far LOD pyramid refill. maxSplats is bounded by the renderer's GL texture ceiling.

      Parameters

      • opts: { maxBytes?: number; maxSplats?: number }

      Returns void

    • Replace this layer's clipping planes at runtime. Planes are geographic (ClippingPlanesOptions) and survive re-anchors; null (or an empty or disabled set) removes clipping and restores byte-identical rendering.

      Parameters

      Returns void

    • Tune far-field coverage live: lodBlur (m, coarse-LOD inflate to fill voids) and minPx (screen-space minimum radius so far/sparse splats overlap into a surface).

      Parameters

      • opts: {
            coverageGe?: number;
            coverageMaxPx?: number;
            dilate?: number;
            discardPx?: number;
            geometricErrorScale?: number;
            lodBlur?: number;
            maximumAttenuation?: number;
            maxScale?: number;
            minPx?: number;
            pointAttenuation?: boolean;
            pointScale?: number;
        }

      Returns void

    • Switch the vertical-datum placement mode live — re-anchors in place (a rigid vertical shift; no re-decode / re-stream). Optionally update the geoid N that 'orthometric' uses. No-op until the tileset has loaded.

      Parameters

      Returns void

    • Toggle the dev bounding-volume wireframe overlay live.

      Parameters

      • on: boolean

      Returns void

    • Switch the render mode live: 'splats' (EWA gaussians) ↔ 'points' (each splat as a round point sized to its footprint — the point-cloud look). Same streamed geometry.

      Parameters

      • mode: "points" | "splats"

      Returns void

    • LOD distance-falloff exponent: 1 = standard SSE / Cesium-matched lean cusp (default), <1 (e.g. 0.6) refines the far field further out (richer, heavier).

      Parameters

      • pow: number

      Returns void

    • Set the screen-space-error target (px) live — lower = more detail, higher = lighter. Takes effect on the next frame's traversal.

      Parameters

      • px: number

      Returns void

    • Fade the splats over the basemap (0 = transparent, 1 = opaque).

      Parameters

      • opacity: number

      Returns void

    • Toggle cascaded sun shadows (cast + self-shadow) at runtime. Part of @bitruvius/sdk-maplibre's SunLightable, so atmo.setShadows(...) reaches the splats.

      Parameters

      • on: boolean

      Returns void

    • Adopt (or clear) the shared vector-drape atlas — satisfies the DrapeReceiver contract, so enableVectorDrape drives this layer directly. Stashed until the renderer exists.

      Parameters

      • shared: SharedDrape | null

      Returns void

    • Grade the splat scene by the environment (day/night exposure + sun tint) — satisfies @bitruvius/sdk-maplibre's SunLightable. Splats are pre-lit captures, so this is a final color grade (no directional relight / shadows).

      Parameters

      Returns void

    • Toggle degree-1 view-dependent lighting (SH). false = flatter + lighter.

      Parameters

      • on: boolean

      Returns void

    • Show/hide the splats without removing the layer (streaming continues so it's instant to bring back).

      Parameters

      • visible: boolean

      Returns void

    • Live streaming + render stats for a debug HUD / perf overlay.

      Returns EngineStats & { drawn: number; sortMs: number } | null

      The engine's EngineStats plus drawn (splats rendered last frame) and sortMs (last depth-sort time in milliseconds), or null until the engine is up.