SweptAABB

Continuous Swept AABB collision detection to prevent tunneling of fast-moving projectiles and actors through thin walls or across long timesteps.

Constructor

new SweptAABB()

Methods

(static) sweepAgainstObstacles(movingBox, dx, dy, staticObstacles) → {Object}

Cast moving box against multiple obstacles and find the earliest impact.

Parameters:
NameTypeDescription
movingBoxObject
dxnumber
dynumber
staticObstaclesArray.<Object>
Returns:
Type: 
Object

(static) sweepBoxAgainstBox(movingBox, dx, dy, staticBox) → {Object}

Compute swept AABB collision between a moving box and a static target box. Uses Minkowski sum raycast against the expanded target box.

Parameters:
NameTypeDescription
movingBoxObject

Moving entity bounds { left, right, top, bottom }

dxnumber

Displacement in X

dynumber

Displacement in Y

staticBoxObject

Obstacle bounds { left, right, top, bottom }

Returns:

{ hit: boolean, toi: number, normal: {x: number, y: number}, contactPoint: {x: number, y: number} }

Type: 
Object