API Docs for: 0.5.0
Show:

Narrowphase Class

Narrowphase. Creates contacts and friction given shapes and transforms.

Constructor

Narrowphase

()

Methods

capsuleCapsule

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

Capsule/capsule narrowphase

Parameters:

capsulePlane

() deprecated

Defined in src/collision/Narrowphase.js:1416

Deprecated: Use .planeCapsule() instead!

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:

circleHeightfield

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

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

collidedLastStep

(
  • bi
  • bj
)
Boolean

Check if the bodies were in contact since the last reset().

Parameters:

Returns:

Boolean:

convexCapsule

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

Convex/capsule narrowphase

Parameters:

convexConvex

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

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

Parameters:

convexLine

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

Convex/line narrowphase

Parameters:

convexPlane

() deprecated

Defined in src/collision/Narrowphase.js:1271

Deprecated: Use .planeConvex() instead!

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.

lineCapsule

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

Capsule/line narrowphase

Parameters:

lineLine

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

Line/line narrowphase

Parameters:

lineRectangle

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

Line/rectangle narrowphase

Parameters:

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

planeConvex

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

Plane/Convex Narrowphase

Parameters:

planeLine

(
  • planeBody
  • planeShape
  • planeOffset
  • planeAngle
  • lineBody
  • lineShape
  • lineOffset
  • lineAngle
)

Plane/line Narrowphase

Parameters:

  • planeBody Body
  • planeShape Plane
  • planeOffset Array
  • planeAngle Number
  • lineBody Body
  • lineShape Line
  • lineOffset Array
  • lineAngle Number

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

(
  • world
)

Throws away the old equations and gets ready to create new

Parameters:

Properties

contactEquations

Array

enableFriction

Boolean

Whether to make friction equations in the upcoming contacts.

frictionCoefficient

Number

The friction value to use in the upcoming friction equations.

frictionEquations

Array

frictionRelaxation

Number

The relaxation value to use in the next friction equations.

frictionStiffness

Number

The stiffness value to use in the next friction equations.

restitution

Number

The restitution value to use in the next contact equations.

slipForce

Number

The friction slip force to use when creating friction equations.

stiffness

Number

The stiffness value to use in the next contact equations.

stiffness

Number

The stiffness value to use in the next contact equations.

surfaceVelocity

Number

Will be the .relativeVelocity in each produced FrictionEquation.