mwg API
    Preparing search index...

    Function resolveCapsuleAgainstGrid

    • Moves a capsule's footprint from from toward to in the XZ plane, stopping at the last sampled position still within maxStepUp of the cell it started the move standing on, rather than passing straight through a column's side the way an un-collided Character3D does. Sampling along the segment, not a swept-shape solver, is what stays shape-agnostic across both createTileGrid3D shapes without hex-edge-specific geometry: exactly the resolveAabbAgainstTiles-style trade-off rpg.Collision's own doc comment already makes, scaled to a grid that is not always axis-aligned.

      Parameters

      Returns CapsuleGridMoveResult

      import { buildHeightIndex, resolveCapsuleAgainstGrid } from '@datamoc/mwg/3d';

      const heights = buildHeightIndex([
      { x: 0, y: 0 },
      { x: 1, y: 0 },
      { x: 2, y: 0, height: 3 },
      ]);
      //a step of 3 levels is more than the capsule can climb, so it stops on the cell before the column
      const moved = resolveCapsuleAgainstGrid({ x: 0, z: 0 }, { x: 2, z: 0 }, { shape: 'square', heights, maxStepUp: 1 });
      console.log(moved.blocked, moved.x < 1.5); // true true