weasel API - v0.8.0
    Preparing search index...

    Interface RenderLayer<TData>

    A single named render sub-layer within a canvas renderer.

    interface RenderLayer<TData> {
        alwaysOn?: boolean;
        defaultVisible?: boolean;
        draw: (data: TData, view: View, dims: Dims) => DrawCommand[];
        hitTest?: (
            worldX: number,
            worldY: number,
            data: TData,
            view: View,
            dims: Dims,
            isVisible?: (id: string) => boolean,
        ) => AffordanceBinding<unknown> | null;
        id: string;
        label: string;
        onUncapturedLeave?: () => void;
        onUncapturedMove?: (
            worldX: number,
            worldY: number,
            evt: PointerEvent,
            view: View,
            dims: Dims,
        ) => void;
        space?: "world" | "screen";
    }

    Type Parameters

    • TData

      The data object passed to each draw call.

    Index

    Properties

    alwaysOn?: boolean

    When true, the layer is always drawn regardless of the visibility map. Useful for layers that must never be hidden (e.g. base grid).

    defaultVisible?: boolean

    Whether the layer is shown when no explicit visibility entry exists. Defaults to true when absent.

    draw: (data: TData, view: View, dims: Dims) => DrawCommand[]

    Emit a DrawCommand tree for the GL backend to dispatch.

    For world-space layers (the default), emit commands in WORLD COORDS — drawLayers automatically wraps them in { kind: 'group', transform: viewToMat3(view), ... } before handing them to the renderer. Do NOT apply the view transform yourself.

    For screen-space layers (space: 'screen'), emit commands in CSS-pixel coords directly; drawLayers passes them through unchanged. If part of a screen-space layer's output needs to track the view, wrap that subset manually with viewToMat3(view).

    hitTest?: (
        worldX: number,
        worldY: number,
        data: TData,
        view: View,
        dims: Dims,
        isVisible?: (id: string) => boolean,
    ) => AffordanceBinding<unknown> | null

    Optional hit-test for consumer-attached layers.

    Only layers registered through CanvasExtensionApi.registerLayer are hit-tested: hitTestExtras walks them last-registered-first on pointerdown, and <SceneCanvas> folds the result into its affordanceAt thunk ahead of the kit's own selection chrome. First non-null result wins; null means "I don't claim this hit, try the next layer."

    Layers that reach the draw stack some other way — a Tool.overlay, an entry in the layers map — are painted but never hit-tested, so defining hitTest on one has no effect. (The kit's own chrome doesn't need it: it goes through buildAffordanceAt.)

    Coordinates are world-space. The data arg is the layer's configured data slot (same as draw); view and dims mirror draw's arguments.

    Type Declaration

      • (
            worldX: number,
            worldY: number,
            data: TData,
            view: View,
            dims: Dims,
            isVisible?: (id: string) => boolean,
        ): AffordanceBinding<unknown> | null
      • Parameters

        • worldX: number
        • worldY: number
        • data: TData
        • view: View
        • dims: Dims
        • OptionalisVisible: (id: string) => boolean

          Chrome-caps visibility predicate. When supplied, the layer must not return a hit from any chrome element whose id reports false. Absent → every element is hittable.

        Returns AffordanceBinding<unknown> | null

    id: string

    Unique identifier used in visibility maps and ordering arrays.

    label: string

    Human-readable name for UI toggles.

    onUncapturedLeave?: () => void

    Called when the cursor leaves the canvas element. Lets layers clear any hover state they're holding.

    onUncapturedMove?: (
        worldX: number,
        worldY: number,
        evt: PointerEvent,
        view: View,
        dims: Dims,
    ) => void

    Called on every pointermove when no gesture is currently captured. Lets layers (e.g. HUD widgets) track hover state without participating in the drag pipeline. Coords are world-space; the layer is responsible for any further conversion (e.g. world→screen for screen-space layers) and for its own throttling.

    space?: "world" | "screen"

    Coordinate space the layer draws in.

    • 'world' (default): the layer's draw returns world-space commands; drawLayers wraps them in a kind: 'group' with viewToMat3(view) automatically.
    • 'screen': the layer's draw returns screen-space (CSS-pixel) commands; drawLayers passes them through unchanged. World-anchored chrome inside a screen-space layer must call worldToScreen or wrap the relevant subset with viewToMat3(view) manually.