effects

Markers

Markers are billboards that travel along edges — planes on flight routes, packets on a network, attack meteors on a threat map. Each marker rides an edge from source to target, looping on a configurable duration. Markers can be icons from the built-in atlas, or shader-drawn heads (a directional dart or a glowing comet with a trailing tail).

See them live: flights on a globe, cyber attacks, following the money.

Two ways to drive markers

Declarative — <MarkerLayer> as a child of <GraphCanvas>. The marker set follows React state:

import { GraphCanvas, MarkerLayer } from '@kineviz/gl';

<GraphCanvas container={el} apiRef={apiRef} is3D nodeCloud edgeCloud map={mapConfig}>
  <MarkerLayer markers={markers} />
</GraphCanvas>

Imperative — api.markers. Good for data- or timer-driven animation outside React render:

api.markers.set(markers);                         // static set
const handle = api.markers.flights(schedule, { loopMs: 250000 }); // repeating schedule
api.markers.stop(handle);                          // stop that schedule
api.markers.clear();                               // remove everything

Marker options

interface MarkerSpec {
  edgeId: string;                  // edge the marker travels along
  key?: string;                    // stable identity (default edgeId); set when >1 marker per edge
  icon?: string;                   // atlas icon name; omitted → shape-based head
  color?: [number, number, number];// 0..1 rgb tint; default [0.5, 0.8, 1.0]
  size?: number;                   // device-px diameter; default 24
  durationMs?: number;             // time to traverse the edge once; default 4000
  phaseOffset?: number;            // 0..1 initial phase (start mid-route)
  orientToPath?: boolean;          // rotate icon to the path tangent; default false
  iconAngleOffset?: number;        // radians added to the tangent angle
  shape?: 'dart' | 'comet';        // no-icon head shape; default 'dart'
  trailLength?: number;            // 0..1 comet trail as a fraction of the path; default 0
}
  • icon vs shape — give an icon name (e.g. 'plane') to draw an atlas glyph; omit it to draw a built-in head. 'dart' is a directional triangle; 'comet' is a radially symmetric glow (white-hot core + tinted halo) meant to be paired with trailLength for meteor / threat-map looks.
  • orientToPath — rotate the glyph to face along the edge. Use iconAngleOffset to align an icon whose "forward" isn't its +x axis.
  • trailLength — a tapered, fading ribbon sampled along the actual path behind the head; on a globe it bends with the great-circle arc. Trails render for up to 256 markers per layer (extra markers draw the head only).
  • key / phaseOffset — key preserves a marker's live animation phase when you re-pass the markers array (restyle / add / remove without a jump). phaseOffset only applies the first time a marker appears, letting a fleet start spread across its routes instead of all leaving the origin at once.

Static markers

The simplest case — one or more markers looping on their edges:

api.markers.set([
  { edgeId: 'e1', icon: 'plane', orientToPath: true, durationMs: 6000 },
  { edgeId: 'e2', shape: 'comet', trailLength: 0.3, color: [1, 0.5, 0.2] },
]);

Flight schedules

For a fleet that departs and arrives over a repeating timeline — planes on a 24-hour clock, attacks over a feed — use a flight schedule. Each FlightSpec adds a departure time and transit fraction within the loop:

interface FlightSpec {
  edgeId: string;
  departT: number;     // departure phase within the loop, 0..1
  durFrac: number;     // fraction of the loop spent in transit, 0..1
  durationMs?: number; // ms to traverse the edge once
  icon?: string; shape?: 'dart' | 'comet'; trailLength?: number;
  color?: [number, number, number]; size?: number;
  orientToPath?: boolean; iconAngleOffset?: number; key?: string;
}

Hand the schedule to api.markers.flights and the engine owns the clock — computing the airborne set each frame and rendering only the markers currently in transit:

const handle = api.markers.flights(flights, { loopMs: 250000 });
// ... markers appear/disappear as departT / durFrac dictate, forever
api.markers.stop(handle);

Driving a schedule yourself

If you'd rather keep <MarkerLayer> declarative, compute the airborne set yourself with computeAirborne (exported from @kineviz/gl) and feed it to the component. This is the flights-globe pattern:

import { computeAirborne } from '@kineviz/gl';

// T is the normalized loop time (0..1); advance it on your own RAF/clock.
const markers = computeAirborne(flights, T);

<GraphCanvas /* … */>
  {markers.length > 0 && <MarkerLayer markers={markers} />}
</GraphCanvas>

See also