Skip to content

1681-engine / index / PhysicsWorldOptions

Interface: PhysicsWorldOptions ​

Defined in: src/physics/PhysicsWorldOptions.ts:4

Tuning for a PhysicsWorld; every field has a default fit for a platformer in pixels.

Extends ​

Properties ​

allowSleep? ​

ts
optional allowSleep?: boolean;

Defined in: src/physics/PhysicsWorldOptions.ts:21

Let bodies at rest stop being simulated until something touches them (default false).


cellSize? ​

ts
optional cellSize?: number;

Defined in: src/physics/PhysicsWorldOptions.ts:9

Broad-phase cell size, px (default 64): about the size of a typical body or a few tiles.


contactMargin? ​

ts
optional contactMargin?: number;

Defined in: src/physics/PhysicsWorldOptions.ts:17

Gap (px) at which a pair already counts as touching (default 0.5).


correction? ​

ts
optional correction?: number;

Defined in: src/physics/ContactSolver.ts:11

Share of the remaining overlap removed per position iteration.

Inherited from ​

SolverSettings.correction


gravityX? ​

ts
optional gravityX?: number;

Defined in: src/physics/PhysicsWorldOptions.ts:6

Px/s² (default 0, 980: y grows downwards, so positive y falls).


gravityY? ​

ts
optional gravityY?: number;

Defined in: src/physics/PhysicsWorldOptions.ts:7


groundNormal? ​

ts
optional groundNormal?: number;

Defined in: src/physics/PhysicsWorldOptions.ts:19

A contact normal with an upward share above this grounds a body (default 0.7, ground up to ~45°).


maxCorrection? ​

ts
optional maxCorrection?: number;

Defined in: src/physics/ContactSolver.ts:13

The most one position iteration moves a pair apart (px), so a deep overlap is undone over a few steps, not flung.

Inherited from ​

SolverSettings.maxCorrection


maxSpeed? ​

ts
optional maxSpeed?: number;

Defined in: src/physics/PhysicsWorldOptions.ts:15

No body moves faster than this, px/s (default 4000): the bound that makes the sub-steps above enough.


maxSubsteps? ​

ts
optional maxSubsteps?: number;

Defined in: src/physics/PhysicsWorldOptions.ts:13

A step is split so no body moves more than its own smallest half size per sub-step, up to this many (default 16).


positionIterations? ​

ts
optional positionIterations?: number;

Defined in: src/physics/PhysicsWorldOptions.ts:11


restitutionThreshold? ​

ts
optional restitutionThreshold?: number;

Defined in: src/physics/ContactSolver.ts:7

Approach speed (px/s) below which nothing bounces, so a resting body does not hop on gravity's own step.

Inherited from ​

SolverSettings.restitutionThreshold


sleepSpeed? ​

ts
optional sleepSpeed?: number;

Defined in: src/physics/PhysicsWorldOptions.ts:22


sleepTime? ​

ts
optional sleepTime?: number;

Defined in: src/physics/PhysicsWorldOptions.ts:23


slop? ​

ts
optional slop?: number;

Defined in: src/physics/ContactSolver.ts:9

Overlap (px) left alone by position correction: a little keeps resting contacts alive and steady.

Inherited from ​

SolverSettings.slop


velocityIterations? ​

ts
optional velocityIterations?: number;

Defined in: src/physics/PhysicsWorldOptions.ts:10

Released under the MIT License.