Skip to main content

Class: Space<O, S>

physics/spaces/space.Space

Represents an infinite space filled with objects.

Type parameters

Name
O
S

Hierarchy

Constructors

constructor

โ€ข new Space<O, S>()

Type parameters

Name
O
S

Properties

objects

โ€ข objects: O[] = []

Defined in

src/physics/spaces/space.ts:8


solvers

โ€ข solvers: Object = {}

Index signature

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

Defined in

src/physics/spaces/space.ts:9

Methods

addObject

โ–ธ addObject(obj): void

Adds an object to the space.

Parameters

NameTypeDescription
objOThe object to add

Returns

void

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
cbSThe solver to add
iterationsnumberThe number of times to run the solver, per time step

Returns

void

Defined in

src/physics/spaces/space.ts:91


clearObjects

โ–ธ clearObjects(): void

Removes all objects from the space.

Returns

void

Defined in

src/physics/spaces/space.ts:41


clearSolvers

โ–ธ clearSolvers(): void

Removes all solvers from the space.

Returns

void

Defined in

src/physics/spaces/space.ts:80


getObjects

โ–ธ getObjects(): O[]

Gets all objects in the space.

Returns

O[]

All objects in the space

Defined in

src/physics/spaces/space.ts:34


getSolvers

โ–ธ getSolvers(): Object

Gets all solvers in the space.

Returns

Object

All solvers in the space

Defined in

src/physics/spaces/space.ts:73


removeObject

โ–ธ removeObject(obj): boolean

Removes an object from the space.

Parameters

NameTypeDescription
objOThe object to remove

Returns

boolean

Wether or not the object was removed

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

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

Defined in

src/physics/spaces/space.ts:112


solve

โ–ธ Abstract solve(id, ...args): void

Executes a solver on every object in the space.

Parameters

NameTypeDescription
idstringThe id of the solver to execute
...argsany-

Returns

void

Defined in

src/physics/spaces/space.ts:20