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

    Interface SceneCanvasApi

    The imperative ref handle for <SceneCanvas> — everything on CanvasExtensionApi plus the surfaces only the scene-level canvas can provide. ingest is always populated here (the optional declaration on the base type exists for the bare-primitive handle).

    interface SceneCanvasApi {
        element: HTMLCanvasElement | null;
        hitTestExtras(
            worldX: number,
            worldY: number,
        ): { binding: AffordanceBinding; layerId: string } | null;
        ingest(
            input: File[] | IngestItem[],
            point?: { x: number; y: number },
        ): void;
        registerLayer(layer: RenderLayer<unknown>): () => void;
        requestRedraw(): void;
    }

    Hierarchy (View Summary)

    Index

    Properties

    element: HTMLCanvasElement | null

    The underlying HTMLCanvasElement. Null until the canvas mounts. Use this for screenshots, getBoundingClientRect, focus management, etc. (Replaces the pre-A2 pattern where ref.current directly was the element.)

    Methods

    • Hit-test the registered layers (topmost-first, last-registered wins) at a world-space point. Returns the id of the layer that claimed the point and whatever its hitTest resolved, or null when none did.

      <SceneCanvas> folds this into the affordanceAt thunk it hands the gesture dispatcher — ahead of the kit's own selection chrome, since registered layers draw on top — so a hit surfaces to actions as an AffordanceHit with kind layer:<id> and the binding's initialScratch as its payload. A layer's owner binds a kindOf predicate on that kind to claim the gesture; see @weasel-js/hud for the worked example.

      Parameters

      • worldX: number
      • worldY: number

      Returns { binding: AffordanceBinding; layerId: string } | null

    • Feed external content into the ingestion pipeline imperatively — the same content-handler registry that OS drop and clipboard paste hit. input may be raw File[] (e.g. from openFilePicker) or pre-normalized IngestItem[]. point is a world-space placement anchor; omitted → handlers use their point-less policy (the kit image handler centers on the viewport).

      Optional because ingestion needs the SceneCanvas action stack — the handle is always populated on <SceneCanvas> refs, absent on the bare-primitive handle.

      Parameters

      • input: File[] | IngestItem[]
      • Optionalpoint: { x: number; y: number }

      Returns void