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
Moves a capsule's footprint from
fromtowardtoin the XZ plane, stopping at the last sampled position still withinmaxStepUpof the cell it started the move standing on, rather than passing straight through a column's side the way an un-collidedCharacter3Ddoes. Sampling along the segment, not a swept-shape solver, is what stays shape-agnostic across bothcreateTileGrid3Dshapes without hex-edge-specific geometry: exactly theresolveAabbAgainstTiles-style trade-offrpg.Collision's own doc comment already makes, scaled to a grid that is not always axis-aligned.