/** * WASM hit-test broad-phase backend: builds a dense viewport grid from world * AABBs and answers "which entities overlap this cell" so a pointer query scans * a handful of candidates instead of every entity in the tree. This is an * invisible accelerator — the JS depth-first walk ({@link Entity.isPointInside} * over every node) is the permanent fallback, so a caller that cannot * instantiate WASM simply keeps using it. Failure is the default state, not an * error path. * * The grid is a coarse pre-filter only: it never decides a hit by itself. * {@link candidatesAt} returns the AABB-overlapping candidates in a cell * (ascending entity index — scan from the end for topmost-first); the caller * re-checks each one against its entity's own precise `isPointInside` (so * non-rectangular hit shapes stay correct) before trusting a result. */ export declare class HitTestBackend { private readonly ex; private entityCap; private cellCap; private itemCap; private vminx; private vminy; private vmaxx; private vmaxy; private vCellStart; private vCellCount; private vItems; /** Grid geometry from the last {@link ensure} call. */ gridW: number; gridH: number; cellSize: number; constructor(instance: WebAssembly.Instance); /** The resident AABB input views (`minx/miny/maxx/maxy`), valid until the * next capacity growth. Writing here is what {@link build} reads from. */ inputView(): { minx: Float64Array; miny: Float64Array; maxx: Float64Array; maxy: Float64Array; }; /** * Size (and grow, if needed) capacity for `count` entities over * `[0,vw] x [0,vh]` at `cellSize`, and record the grid geometry * {@link candidatesAt} needs. Call this BEFORE writing AABBs into * {@link inputView} — a capacity growth detaches the previous views, so * writing first and sizing after would write into a stale buffer. */ ensure(count: number, vw: number, vh: number, cellSize: number): void; /** * Re-create the typed-array views if another backend's allocation grew the * shared linear memory and detached them (see {@link viewsStale}). Call after * {@link ensure} and before writing into {@link inputView}. */ revalidateViews(): void; /** * Run the kernel's bucketing over whatever is currently resident in * {@link inputView} (write the AABBs there, and call {@link ensure} first). * Returns `false` if the build was rejected (no `hit_init` yet) or overflowed * its item budget — the caller must not trust {@link candidatesAt} results * for this build and should fall back to the JS walk instead (never return a * wrong hit). */ runBuild(count: number, vw: number, vh: number, cellSize: number): boolean; /** * Entity indices whose AABB overlaps the cell containing `(px, py)`, in * ascending index order (scan from the end for topmost/highest-index * first), or `null` if the point falls outside the built grid. This is a * coarse candidate LIST, not a hit result — the caller must still confirm * each candidate's AABB contains the point and re-check its precise * `isPointInside`. */ candidatesAt(px: number, py: number): Int32Array | null; private growIfNeeded; /** Rebuild typed-array views after a growing `hit_init` (which detaches the * memory buffer). */ private refreshViews; } /** * Instantiate synchronously (Node/tests, or a worker). Rejected on the browser * main thread for modules >4 KB — use {@link instantiateAsync} there. Returns * `null` if compilation/instantiation throws, so callers fall back to JS. */ export declare function instantiateSync(bytes: BufferSource): HitTestBackend | null; /** * Instantiate asynchronously (browser main thread). Returns `null` on any * failure — CSP `wasm-unsafe-eval`, unsupported, corrupt/missing bytes — so the * caller keeps using the JS path. */ export declare function instantiateAsync(bytes: BufferSource): Promise; /** Anything the hit-test core can be loaded from, matching the transform * core's {@link WasmModuleSource} loading ergonomics. */ export type HitModuleSource = BufferSource | string | URL | Response | Promise; /** * Instantiate from a URL/Response using streaming compilation when the * platform supports it, falling back to fetch → arrayBuffer → instantiate when * unavailable or the response's MIME type is rejected. Returns `null` on any * failure so the caller keeps the JS path. */ export declare function instantiateStreaming(source: string | URL | Response | Promise): Promise;