API Docs for: 0.3.0
Show:

Narrowphase Class

Narrowphase. Creates contacts and friction given shapes and transforms.

Constructor

Narrowphase

()

Methods

circleCapsule

(
  • bi
  • si
  • xi
  • ai
  • bj
  • sj
  • xj
  • aj
)

Circle/capsule Narrowphase

Parameters:

circleCircle

(
  • bi
  • si
  • xi
  • ai
  • bj
  • sj
  • xj
  • aj
)

Circle/circle Narrowphase

Parameters:

circleConvex

(
  • bi
  • si
  • xi
  • ai
  • bj
  • sj
  • xj
  • aj
)

Circle/convex Narrowphase

Parameters:

circleLine

(
  • bi
  • si
  • xi
  • ai
  • bj
  • sj
  • xj
  • aj
  • justTest
  • lineRadius
  • circleRadius
)

Circle/line Narrowphase

Parameters:

  • bi Body
  • si Circle
  • xi Array
  • ai Number
  • bj Body
  • sj Line
  • xj Array
  • aj Number
  • justTest Boolean

    If set to true, this function will return the result (intersection or not) without adding equations.

  • lineRadius Number

    Radius to add to the line. Can be used to test Capsules.

  • circleRadius Number

    If set, this value overrides the circle shape radius.

circleParticle

(
  • bi
  • si
  • xi
  • ai
  • bj
  • sj
  • xj
  • aj
)

Circle/Particle Narrowphase

Parameters:

circlePlane

(
  • bi
  • si
  • xi
  • bj
  • sj
  • xj
  • aj
)

Creates ContactEquations and FrictionEquations for a collision.

Parameters:

  • bi Body

    The first body that should be connected to the equations.

  • si Circle

    The circle shape participating in the collision.

  • xi Array

    Extra offset to take into account for the Shape, in addition to the one in circleBody.position. Will not be rotated by circleBody.angle (maybe it should, for sake of homogenity?). Set to null if none.

  • bj Body

    The second body that should be connected to the equations.

  • sj Plane

    The Plane shape that is participating

  • xj Array

    Extra offset for the plane shape.

  • aj Number

    Extra angle to apply to the plane

convexConvex

(
  • bi
  • si
  • xi
  • ai
  • bj
  • sj
  • xj
  • aj
)

Convex/convex Narrowphase.See this article for more info.

Parameters:

convexPlane

(
  • bi
  • si
  • xi
  • ai
  • bj
  • sj
  • xj
  • aj
)

Convex/Plane Narrowphase

Parameters:

createContactEquation

(
  • bodyA
  • bodyB
)
ContactEquation

Creates a ContactEquation, either by reusing an existing object or creating a new one.

Parameters:

Returns:

createFrictionEquation

(
  • bodyA
  • bodyB
)
FrictionEquation

Creates a FrictionEquation, either by reusing an existing object or creating a new one.

Parameters:

Returns:

createFrictionFromContact

(
  • contactEquation
)
FrictionEquation

Creates a FrictionEquation given the data in the ContactEquation. Uses same offset vectors ri and rj, but the tangent vector will be constructed from the collision normal.

Parameters:

Returns:

findSeparatingAxis

(
  • c1
  • offset1
  • angle1
  • c2
  • offset2
  • angle2
  • sepAxis
)
Boolean static

Find a separating axis between the shapes, that maximizes the separating distance between them.

Parameters:

  • c1 Convex
  • offset1 Array
  • angle1 Number
  • c2 Convex
  • offset2 Array
  • angle2 Number
  • sepAxis Array

    The resulting axis

Returns:

Boolean:

Whether the axis could be found.

getClosestEdge

(
  • c
  • angle
  • axis
  • flip
)
Number static

Get the edge that has a normal closest to an axis.

Parameters:

  • c Convex
  • angle Number
  • axis Array
  • flip Boolean

Returns:

Number:

Index of the edge that is closest. This index and the next spans the resulting edge. Returns -1 if failed.

particleConvex

(
  • bi
  • si
  • xi
  • ai
  • bj
  • sj
  • xj
  • aj
)

Particle/convex Narrowphase

Parameters:

particlePlane

(
  • bi
  • si
  • xi
  • ai
  • bj
  • sj
  • xj
  • aj
)

Narrowphase for particle vs plane

Parameters:

  • bi Body

    The particle body

  • si Particle

    Particle shape

  • xi Array

    World position for the particle

  • ai Number

    World angle for the particle

  • bj Body

    Plane body

  • sj Plane

    Plane shape

  • xj Array

    World position for the plane

  • aj Number

    World angle for the plane

planeLine

(
  • bi
  • si
  • xi
  • ai
  • bj
  • sj
  • xj
  • aj
)

Plane/line Narrowphase

Parameters:

projectConvexOntoAxis

(
  • convexShape
  • convexOffset
  • convexAngle
  • worldAxis
  • result
)
static

Project a Convex onto a world-oriented axis

Parameters:

  • convexShape Convex
  • convexOffset Array
  • convexAngle Number
  • worldAxis Array
  • result Array

reset

()

Throws away the old equatons and gets ready to create new