Skip to main content

Variable: CutlineBbox

const CutlineBbox: object

Defined in: cutline-bbox.ts:51

A shader module that discards fragments whose position falls outside a Web Mercator (EPSG:3857) axis-aligned bbox.

Intended for rendering rasters with a "map collar" (e.g. USGS historical topographic maps) where the valid data area is described as a bbox but the raw pixels include surrounding metadata.

Only supports rendering in a WebMercatorViewport. The caller is responsible for enforcing this in application code; the module itself does not have viewport access.

This module assumes the layer's mesh positions attribute is in EPSG:3857 meters — the convention used by COGLayer / RasterLayer in Web Mercator rendering mode. It injects a vertex shader varying that passes each vertex's 3857 meters through to the fragment shader, and compares against a uniform bbox also in 3857 meters. This avoids deck.gl's common space and its viewport-anchored precision translation, which would otherwise cause the test to drift at higher zoom levels.

Type Declaration

fs

readonly fs: "uniform cutlineBboxUniforms {\n vec4 bbox;\n} cutlineBbox;\n" = uniformBlock

getUniforms

readonly getUniforms: (props) => { bbox: [number, number, number, number]; } | { bbox?: undefined; }

Parameters

props

Partial<CutlineBboxProps>

Returns

{ bbox: [number, number, number, number]; } | { bbox?: undefined; }

inject

readonly inject: object

inject.fs:#decl

readonly fs:#decl: "in vec2 v_cutlineBboxMercator;"

inject.fs:#main-start

readonly fs:#main-start: "\n {\n if (v_cutlineBboxMercator.x < cutlineBbox.bbox.x ||\n v_cutlineBboxMercator.x > cutlineBbox.bbox.z ||\n v_cutlineBboxMercator.y < cutlineBbox.bbox.y ||\n v_cutlineBboxMercator.y > cutlineBbox.bbox.w) {\n discard;\n }\n }\n "

inject.vs:#decl

readonly vs:#decl: "out vec2 v_cutlineBboxMercator;"

inject.vs:#main-start

readonly vs:#main-start: "\n v_cutlineBboxMercator = positions.xy;\n "

name

readonly name: "cutlineBbox" = MODULE_NAME

uniformTypes

readonly uniformTypes: object

uniformTypes.bbox

readonly bbox: "vec4<f32>" = "vec4<f32>"