API Docs for: 0.7.1
Show:

IslandManager Class

Splits the system of bodies and equations into independent islands

Constructor

IslandManager

(
  • [options]
)

Parameters:

  • [options] Object optional

Methods

addEquation

(
  • eq
)

Add an equation to be solved.

Parameters:

addEquations

(
  • eqs
)

Add equations. Same as .addEquation, but this time the argument is an array of Equations

Parameters:

  • eqs Array

bfs

(
  • root
  • bds
  • eqs
)

Runs the search algorithm, starting at a root node. The resulting bodies and equations will be stored in the provided arrays.

Parameters:

  • root IslandNode

    The node to start from

  • bds Array

    An array to append resulting Bodies to.

  • eqs Array

    An array to append resulting Equations to.

emit

(
  • event
)
EventEmitter

Emit an event.

Parameters:

  • event Object
    • type String

Returns:

EventEmitter:

The self object, for chainability.

getUnvisitedNode

(
  • nodes
)
IslandNode | Boolean static

Get an unvisited node from a list of nodes.

Parameters:

  • nodes Array

Returns:

IslandNode | Boolean:

The node if found, else false.

has

(
  • type
  • listener
)
Boolean

Check if an event listener is added

Parameters:

  • type String
  • listener Function

Returns:

Boolean:

off

(
  • type
  • listener
)
EventEmitter

Remove an event listener

Parameters:

  • type String
  • listener Function

Returns:

EventEmitter:

The self object, for chainability.

on

(
  • type
  • listener
)
EventEmitter

Add an event listener

Parameters:

  • type String
  • listener Function

Returns:

EventEmitter:

The self object, for chainability.

removeAllEquations

()

Remove all currently added equations.

removeEquation

(
  • eq
)

Remove an equation.

Parameters:

solve

(
  • dt
  • world
)

Method to be implemented in each subclass

Parameters:

solveIsland

(
  • dt
  • island
)

Solves all constraints in an island.

Parameters:

sortEquations

()

Sort all equations using the .equationSortFunction. Should be called by subclasses before solving.

split

(
  • world
)
Array

Split the world into independent islands. The result is stored in .islands.

Parameters:

Returns:

Array:

The generated islands

visit

(
  • node
  • bds
  • eqs
)

Visit a node.

Parameters:

Properties

equations

Array

Inherited from Solver but overwritten in src/world/IslandManager.js:32

The equations to split. Manually fill this array before running .split().

equationSortFunction

Function | Boolean

Function that is used to sort all equations before each solve.

islandPool

IslandPool

islands

Array

The resulting Islands.

nodePool

IslandNodePool

nodes

Array

The resulting graph nodes.

queue

Array private

The node queue, used when traversing the graph of nodes.