mwg API
    Preparing search index...

    Function cellAt

    • The integer grid cell nearest world position (x, z) - the inverse of gridPoint3D. Nearest-cell rounding, not an exact point-in-hexagon test for the hex shape: consistent with rpg.Collision's own choice of simple axis sweeps over a full polygon solver, since every tile a capsule actually stands on is far larger than the rounding error near an edge.

      Parameters

      • shape: GridShape3D
      • x: number
      • z: number
      • tileSize: number = 1

      Returns { x: number; y: number }

      import { cellAt } from '@datamoc/mwg/3d';

      console.log(cellAt('square', 3.4, 1.6, 2)); // { x: 2, y: 1 }