spatial-monorepo / deckgl-bridge/src / createAnimatedRoutePathSpec
Function: createAnimatedRoutePathSpec()
createAnimatedRoutePathSpec(
id,route,opts?):DeckGLLayerSpec
Defined in: packages/deckgl-bridge/src/index.ts:970
Creates a DeckGLLayerSpec for Issue #254 — AnimatedRoutePath. Renders a 3D elevated path with dashed line animation. Multi-floor routes are stored as per-floor segments in data[].
Dashing is rendered via deck.gl's PathStyleExtension — a plain PathLayer ignores dashArray/dashOffset entirely (they aren't real PathLayer props, so deck.gl silently drops them and the route rendered as a solid line). The extension's own dash props (getDashArray) only control the dash/gap ratio, not a movable phase — deck.gl has no prop that shifts a dash pattern's phase along a path. dashOffset is therefore consumed here, at spec-build time, to walk each segment's path start forward by that distance mod the dash cycle length (shiftPathStart), which produces a real, continuously-advancing dash phase using only public deck.gl props (getPath/getDashArray). dashOffset is retained on the returned spec purely as introspectable bookkeeping — it is stripped before the PathLayer is actually constructed (see toCtorProps) since it is not a deck.gl prop.
Because the phase shift is baked into data at build time, animating requires rebuilding the spec each frame — merging a bare dashOffset via updateLayer(id, { props: { dashOffset } }) alone will NOT move the dashes, since the underlying data/getPath coordinates would be left unchanged. Caller drives animation by calling createAnimatedRoutePathSpec(id, route, { ...opts, dashOffset }) again each frame and passing the result to handle.updateLayer(id, { props: nextSpec.props }) (mirrors deck.gl's own recommended "recompute layer/props every frame" animation pattern). Animation should pause when document.hidden (visibilitychange) — managed by caller.
Parameters
id
string
route
opts?
color?
[number, number, number, number]
dashGap?
number
dashLength?
number
dashOffset?
number
opacity?
number
width?
number
