hex-world
    Preparing search index...

    Class HexPicker

    Robust per-frame hex picking with a fallback chain:

    1. Mesh pick — raycast against real terrain geometry (most accurate).
    2. Flat-plane fallback — plane pick at y=0 so hover survives the window while newly-panned-to chunks are still building.
    3. Water-surface re-pick — terrain geometry for liquid cells sits at seabed depth, so at an angle the ray maps to the wrong surface cell; re-pick against the per-cell water surface plane.
    4. Last-elevation retry — elevated tiles at the map edge sit above y=0, so the flat-plane pick can land out of bounds; retry at the last valid cell's elevation.
    5. Short hold — keep the last valid cell for a few frames while the cursor is over the canvas, so the hover doesn't flicker at chunk seams.

    Call pick once per frame with the current pointer position.

    const picker = new HexPicker({
    camera, domElement: renderer.domElement, layout,
    map: () => api.map,
    meshes: () => api.chunks.terrainMeshes,
    isWater: t => waterTerrainSet.has(t),
    });
    // per frame:
    const cell = picker.pick(mouseX, mouseY);
    Index

    Constructors

    Accessors

    Methods

    Constructors

    Accessors

    • get hoveredCell(): { col: number; row: number } | null

      The most recent valid pick, or null. Survives up to holdFrames misses.

      Returns { col: number; row: number } | null

    • get holding(): boolean

      True while the last result was a held-over cell rather than a hit — the pointer is off the terrain and the hold is counting down. A caller that skips picks while nothing moves must keep calling pick while this is set, or the hold never expires.

      Returns boolean

    Methods

    • Run the full fallback chain for the given pointer position. Returns the picked cell, or null if nothing is under the cursor.

      Parameters

      • clientX: number
      • clientY: number

      Returns { col: number; row: number } | null