Class: DynamicsSpace
physics/spaces/dynamics.DynamicsSpace
Represents an infinite space containing RigidBodys.
Can be used to update objects dynamics.
Hierarchy
Space
<RigidBody
,DynamicsSolver
>โณ
DynamicsSpace
Constructors
constructor
โข new DynamicsSpace(gravity
)
Creates a DynamicsSpace instance.
Parameters
Name | Type |
---|---|
gravity | vec2 |
Overrides
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
Defined in
src/physics/spaces/space.ts:8
solvers
โข solvers: Object
= {}
Index signature
โช [index: string
]: { cb
: S
; iterations
: number
}
Inherited from
Defined in
src/physics/spaces/space.ts:9
Methods
addObject
โธ addObject(obj
): void
Adds an object to the space.
Parameters
Name | Type | Description |
---|---|---|
obj | RigidBody | The object to add |
Returns
void
Inherited from
Defined in
src/physics/spaces/space.ts:50
addSolver
โธ addSolver(id
, cb
, iterations
): void
Adds a solver to the space.
Parameters
Name | Type | Description |
---|---|---|
id | string | The solver's identifier |
cb | DynamicsSolver | The solver to add |
iterations | number | The number of times to run the solver, per time step |
Returns
void
Inherited from
Defined in
src/physics/spaces/space.ts:91
clearObjects
โธ clearObjects(): void
Removes all objects from the space.
Returns
void
Inherited from
Defined in
src/physics/spaces/space.ts:41
clearSolvers
โธ clearSolvers(): void
Removes all solvers from the space.
Returns
void
Inherited from
Defined in
src/physics/spaces/space.ts:80
getObjects
โธ getObjects(): RigidBody
[]
Gets all objects in the space.
Returns
All objects in the space
Inherited from
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
Defined in
src/physics/spaces/space.ts:73
removeObject
โธ removeObject(obj
): boolean
Removes an object from the space.
Parameters
Name | Type | Description |
---|---|---|
obj | RigidBody | The object to remove |
Returns
boolean
Wether or not the object was removed
Inherited from
Defined in
src/physics/spaces/space.ts:60
removeSolver
โธ removeSolver(id
): boolean
Removes a solver from the space.
Parameters
Name | Type | Description |
---|---|---|
id | string | The id of the solver to remove |
Returns
boolean
Wether or not the solver was removed
Inherited from
Defined in
src/physics/spaces/space.ts:101
setSolverIterations
โธ setSolverIterations(id
, iterations
): void
Sets the number of iterations a solver should run.
Parameters
Name | Type | Description |
---|---|---|
id | string | The id of the solver to update |
iterations | number | The new number of iterations |
Returns
void
Inherited from
Defined in
src/physics/spaces/space.ts:112
solve
โธ solve(id
, delta
): void
Executes a solver on every object in the space.
Parameters
Name | Type | Description |
---|---|---|
id | string | The id of the solver to execute |
delta | number | - |
Returns
void
Overrides
Defined in
src/physics/spaces/dynamics.ts:28