Effects & Layers
<GraphCanvas> always renders the base graph — node discs, edge lines,
arrows, labels. On top of that base, the engine runs a small layer system
that composites extra GPU visuals into the same scene: soft halos, custom node
shapes, geographic coverage discs, markers that travel along edges, and animated
edge-flow / ripple / highlight effects.
This section is the home for all of those. Everything here is GPU-driven — work happens in shaders, not per-frame JavaScript — so effects stay cheap even on large graphs.
Three ways to add an effect
There is a deliberate ladder from "one line, already built" up to "author your own shader". Pick the lowest rung that does what you need.
| Rung | API | Use it for |
|---|---|---|
| 1. Built-in effects | api.animations.*, api.emphasis.* |
Decorate existing nodes/edges: ripples, edge flow, glow, breathe, cascade highlight, focus+context dim. Fire-and-forget. |
| 2. Batteries-included layers | api.coverage / <CoverageLayer>, api.markers / <MarkerLayer>, <MediaLayer>, <AudioSpectrumLayer>, <NodeCardLayer>, api.cards |
Coverage discs, travelling markers, pictures and video on nodes, a record drawn as the node. Each is available both as an imperative call and a declarative React component. |
| 2b. Scene layers | <ScanPlaneLayer>, <RadarSweepLayer>, <WarpTunnelLayer>, createCinematics |
Read a 3-D projection by moving through it: sweep a lit plane, sweep a beam, streak a jump. See Cinematics. |
| 3. Custom shader layers | createNodeShaderLayer, api.layers |
Author a per-node fragment shader (custom halos, shapes, glows), or mount a hand-written LayerRenderer for anything else. |
Rules of thumb:
- Want to emphasize part of an existing graph (flow, glow, ripple, dim)? → Animations & emphasis (rung 1).
- Want circles of influence on a map (signal, blast radius, catchment)? → Coverage discs (rung 2).
- Want things moving along edges (planes, packets, attacks)? → Markers (rung 2).
- Want a custom look for nodes themselves (a pulsing halo, a diamond, an SDF shape)? → Node shader layers (rung 3).
- Want a node to be a picture or a video feed? → Node media (rung 2).
- Want a node to be a whole record — header, photo, every property? → Node cards (rung 2).
- Can you not tell what is in front of what, or how far away it is? → Cinematics (rung 2b).
- Need something none of the above covers? → Authoring custom layers (rung 3).
Declarative vs imperative
Layers (rungs 2 & 3) can be driven two ways, and they are equivalent — choose whichever fits how the surrounding code is structured:
// Declarative — render a layer component as a child of <GraphCanvas>.
// The layer follows React state; it unmounts when the component unmounts.
<GraphCanvas container={el} apiRef={apiRef} nodeCloud edgeCloud>
<CoverageLayer items={discs} />
<MarkerLayer markers={planes} />
</GraphCanvas>
// Imperative — call the api after the canvas is live. Good for effects driven
// by data fetches, timers, or agent/skill code rather than React render.
api.coverage.set(discs);
api.markers.flights(schedule, { loopMs: 250000 });
Imperative calls issued before the canvas has mounted are safe — they queue and hydrate as soon as the engine is up (see the layer registry).
The layer model
Every layer — built-in or custom — is a LayerRenderer with a simple
lifecycle the engine drives:
mount(ctx)— add objects to the scene.update(config)— apply new config (idempotent).frame(dt, ctx)— optional per-frame tick (only when mounted with{ frame: true }); returntrueto request a redraw.dispose()— free GPU resources.
A layer that draws its own geometry is not clickable until it says so; both rungs 2 and 3 have a one-line way to fix that — see making a layer clickable.
Layers composite into one of three render bands, back to front:
| Band | Draws | Typical use |
|---|---|---|
underlay |
behind the nodes | coverage discs, ground glow |
overlay |
above the nodes (default) | halos, markers |
top |
above everything | selection markers, HUD-like cues |
Layers also read live node/edge opacity, so effects automatically fade in step with click-dim, focus+context, and filtering — a halo over a dimmed node dims with it. The full contract is documented in Authoring custom layers.
Effect gallery
Every effect here has a live, editable scenario in the Examples gallery:
| Scenario | Shows | Guide |
|---|---|---|
| Custom node halo | createNodeShaderLayer pulsing halo |
Node shader layers |
| Custom node shape | hideBuiltinNode + SDF diamond |
Node shader layers |
| Signal coverage | api.coverage discs + radar pulse |
Coverage discs |
| Live flights | MarkerLayer planes on a globe |
Markers |
| Cyber attacks | comet markers + impact ripples | Markers |
| Supply-chain flow | edgeFlow + edgeGlow |
Animations & emphasis |
| Supply-chain disruption | ripple shockwave + cascade | Animations & emphasis |
| Les Mis — focus & context | cascadeHighlight + focusContext |
Animations & emphasis |
| Cinematic flythrough | every shot, both overlays, both flyable layouts | Cinematics |