Skip to main content

Class: DynamicsSpace

physics/spaces/dynamics.DynamicsSpace

Represents an infinite space containing RigidBodys.

Can be used to update objects dynamics.

Hierarchy

Constructors

constructor

โ€ข new DynamicsSpace(gravity)

Creates a DynamicsSpace instance.

Parameters

NameType
gravityvec2

Overrides

Space.constructor

Defined in

src/physics/spaces/dynamics.ts:17

Properties

gravity

โ€ข gravity: vec2

Defined in

src/physics/spaces/dynamics.ts:12


objects

โ€ข objects: RigidBody[] = []

Inherited from

Space.objects

Defined in

src/physics/spaces/space.ts:8


solvers

โ€ข solvers: Object = {}

Index signature

โ–ช [index: string]: { cb: S ; iterations: number }

Inherited from

Space.solvers

Defined in

src/physics/spaces/space.ts:9

Methods

addObject

โ–ธ addObject(obj): void

Adds an object to the space.

Parameters

NameTypeDescription
objRigidBodyThe object to add

Returns

void

Inherited from

Space.addObject

Defined in

src/physics/spaces/space.ts:50


addSolver

โ–ธ addSolver(id, cb, iterations): void

Adds a solver to the space.

Parameters

NameTypeDescription
idstringThe solver's identifier
cbDynamicsSolverThe solver to add
iterationsnumberThe number of times to run the solver, per time step

Returns

void

Inherited from

Space.addSolver

Defined in

src/physics/spaces/space.ts:91


clearObjects

โ–ธ clearObjects(): void

Removes all objects from the space.

Returns

void

Inherited from

Space.clearObjects

Defined in

src/physics/spaces/space.ts:41


clearSolvers

โ–ธ clearSolvers(): void

Removes all solvers from the space.

Returns

void

Inherited from

Space.clearSolvers

Defined in

src/physics/spaces/space.ts:80


getObjects

โ–ธ getObjects(): RigidBody[]

Gets all objects in the space.

Returns

RigidBody[]

All objects in the space

Inherited from

Space.getObjects

Defined in

src/physics/spaces/space.ts:34


getSolvers

โ–ธ getSolvers(): Object

Gets all solvers in the space.

Returns

Object

All solvers in the space

Inherited from

Space.getSolvers

Defined in

src/physics/spaces/space.ts:73


removeObject

โ–ธ removeObject(obj): boolean

Removes an object from the space.

Parameters

NameTypeDescription
objRigidBodyThe object to remove

Returns

boolean

Wether or not the object was removed

Inherited from

Space.removeObject

Defined in

src/physics/spaces/space.ts:60


removeSolver

โ–ธ removeSolver(id): boolean

Removes a solver from the space.

Parameters

NameTypeDescription
idstringThe id of the solver to remove

Returns

boolean

Wether or not the solver was removed

Inherited from

Space.removeSolver

Defined in

src/physics/spaces/space.ts:101


setSolverIterations

โ–ธ setSolverIterations(id, iterations): void

Sets the number of iterations a solver should run.

Parameters

NameTypeDescription
idstringThe id of the solver to update
iterationsnumberThe new number of iterations

Returns

void

Inherited from

Space.setSolverIterations

Defined in

src/physics/spaces/space.ts:112


solve

โ–ธ solve(id, delta): void

Executes a solver on every object in the space.

Parameters

NameTypeDescription
idstringThe id of the solver to execute
deltanumber-

Returns

void

Overrides

Space.solve

Defined in

src/physics/spaces/dynamics.ts:28