hex-world
    Preparing search index...

    Function pickHexFromMeshes

    • Picks a hex cell by raycasting against the actual terrain meshes. More accurate than pickHex — especially at low camera angles and over elevated terrain — because it hits the real geometry rather than a flat plane.

      Pass chunkManager.terrainMeshes as the meshes argument. Returns null if the ray misses all meshes or the hit is outside the map bounds.

      Safe to call every frame — uses a pre-allocated intersection buffer.

      Parameters

      • clientX: number
      • clientY: number
      • domElement: HTMLElement
      • camera: Camera
      • layout: HexLayout
      • map: { width: number; height: number }
      • meshes: Mesh<
            BufferGeometry<NormalBufferAttributes, BufferGeometryEventMap>,
            Material<MaterialEventMap> | Material<MaterialEventMap>[],
            Object3DEventMap,
        >[]

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

      const cell = pickHexFromMeshes(e.clientX, e.clientY, renderer.domElement, camera, layout, map, chunkManager.terrainMeshes);
      if (cell) console.log(cell.col, cell.row);