@margoengine/physics2d 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/body.d.ts ADDED
@@ -0,0 +1,376 @@
1
+ import type { Kernel } from './kernel.js';
2
+ import { type CoefficientCombineRule2D, describeShape, type ActiveHooks2D, type ColliderOptions2D, type Described, type ShapeOptions2D, type Vec2D } from './shapes.js';
3
+ /** How a body moves: `dynamic` (simulated), `fixed`, or kinematic (driven by position or by velocity). */
4
+ export type BodyType2D = 'dynamic' | 'fixed' | 'kinematicPosition' | 'kinematicVelocity';
5
+ /** Anything with a position and a rotation in world units and radians: a `Sprite` from `@margoengine/sprites` fits. */
6
+ export interface SpriteLike {
7
+ x: number;
8
+ y: number;
9
+ rotation: number;
10
+ /** With `rect`, the default collider is a box of that size around the pivot. */
11
+ readonly rect?: readonly [number, number, number, number];
12
+ readonly pivotX?: number;
13
+ readonly pivotY?: number;
14
+ readonly scaleX?: number;
15
+ readonly scaleY?: number;
16
+ }
17
+ /** Options for adding a body; every field has a default. */
18
+ export interface BodyOptions2D {
19
+ /** Default 'dynamic'. */
20
+ type?: BodyType2D;
21
+ /** World2D position. Defaults to the sprite's position, or [0, 0]. */
22
+ position?: Vec2D;
23
+ /** Radians, clockwise on screen. Defaults to the sprite's rotation, or 0. */
24
+ rotation?: number;
25
+ /** One or more colliders. Without any, a box fitted to the sprite's `rect`, else none. */
26
+ colliders?: ColliderOptions2D | readonly ColliderOptions2D[];
27
+ linearVelocity?: Vec2D;
28
+ angularVelocity?: number;
29
+ linearDamping?: number;
30
+ angularDamping?: number;
31
+ gravityScale?: number;
32
+ /** Continuous collision detection for fast bodies. */
33
+ ccd?: boolean;
34
+ /**
35
+ * Soft CCD: how far ahead, in world units, the body's contacts reach, so the solver holds a fast body at what it would
36
+ * hit one step on; set it to about the body's speed times the step. Default 0: the world's own margin, 0.02 m.
37
+ */
38
+ softCcd?: number;
39
+ canSleep?: boolean;
40
+ lockRotation?: boolean;
41
+ /**
42
+ * In a contact with a body of lower dominance, this body acts as if it had infinite mass. Integers from -127 to 127,
43
+ * default 0.
44
+ */
45
+ dominance?: number;
46
+ /**
47
+ * Holds the body's translation on an axis: `true` locks both, `[x, y]` picks. The body stays where it is on a locked
48
+ * axis and moves freely on the other (it still turns unless `lockRotation`).
49
+ */
50
+ lockTranslation?: boolean | readonly [boolean, boolean];
51
+ /** Mass in kilograms added to what the colliders weigh; the body turns as a heavier body of the same build. Default 0. */
52
+ additionalMass?: number;
53
+ userData?: unknown;
54
+ }
55
+ /** @internal What a body needs from its world. */
56
+ export interface BodyOwner2D {
57
+ readonly kernel: Kernel;
58
+ readonly handle: number;
59
+ readonly scale: number;
60
+ addCollider(body: Body2D, options: ColliderOptions2D): Collider2D;
61
+ removeCollider(collider: Collider2D): void;
62
+ removeBody(body: Body2D): void;
63
+ lockTranslation(body: Body2D, x: boolean, y: boolean): void;
64
+ retype(body: Body2D, type: BodyType2D): void;
65
+ }
66
+ /**
67
+ * A collider: one or more kernel shapes (a concave polygon or a polyline is several) on a body, with the settings that
68
+ * can change after it exists. Positions are in world units.
69
+ */
70
+ export declare class Collider2D {
71
+ private readonly owner;
72
+ readonly body: Body2D;
73
+ private readonly settings;
74
+ private offset;
75
+ private turn;
76
+ /** The kernel shapes this collider is made of. @internal */
77
+ readonly shapes: number[];
78
+ /** The shape as the kernel was given it, for the queries a character controller makes. @internal */
79
+ described: Described | null;
80
+ /** The options it was made with (its shape and settings), to describe it again where it moves. @internal */
81
+ options: ColliderOptions2D | null;
82
+ private removed;
83
+ private enabled;
84
+ private savedGroups;
85
+ /** @internal */
86
+ constructor(owner: BodyOwner2D, body: Body2D, shapes: number[], settings: Uint32Array, offset: readonly [number, number], turn: number);
87
+ /** The kernel's handle of its first shape: unique among live colliders. */
88
+ get handle(): number;
89
+ /** The body this collider is on. */
90
+ parent(): Body2D;
91
+ get isRemoved(): boolean;
92
+ /** @internal */
93
+ markRemoved(): void;
94
+ private push;
95
+ /**
96
+ * Changes the collider's outline after it is made (Rapier's `setShape`): any one convex outline a collider takes
97
+ * (`circle`, `box`, `capsule`, `segment`, `triangle`, a convex `polygon`), placed at the collider's own offset and
98
+ * turn. Its material, density, filtering and flags stay; the body's mass follows the new area, and the next step builds
99
+ * its contacts from the new outline (a pair already touching stays one: no collision event from the change alone).
100
+ * @throws RangeError for an outline of several kernel shapes (a concave polygon, polyline, trimesh, heightfield, compound
101
+ * or voxels) or a collider made of several; MargoError (state) once the collider was removed.
102
+ */
103
+ setShape(shape: ShapeOptions2D): void;
104
+ isSensor(): boolean;
105
+ /** A sensor reports overlaps (`intersectionstart`) and pushes nothing. It also senses fixed and kinematic bodies. */
106
+ setSensor(sensor: boolean): void;
107
+ /**
108
+ * Which questions `Physics2D.hooks` is asked about this collider's pairs (Rapier's `setActiveHooks`): `filterPair` for a pair of
109
+ * solids, `filterIntersection` for a pair with a sensor in it, `modifyContact` for a touching contact. An omitted key is turned off.
110
+ */
111
+ setActiveHooks(hooks: ActiveHooks2D): void;
112
+ /** The questions the hooks are asked about this collider's pairs, as {@link Collider2D.setActiveHooks} sets them. */
113
+ get activeHooks(): Required<ActiveHooks2D>;
114
+ setFriction(value: number): void;
115
+ setRestitution(value: number): void;
116
+ /** How a contact combines this collider's friction with the other's (Rapier's `setFrictionCombineRule`). */
117
+ setFrictionCombineRule(rule: CoefficientCombineRule2D): void;
118
+ frictionCombineRule(): CoefficientCombineRule2D;
119
+ /** How a contact combines this collider's restitution with the other's (Rapier's `setRestitutionCombineRule`). */
120
+ setRestitutionCombineRule(rule: CoefficientCombineRule2D): void;
121
+ restitutionCombineRule(): CoefficientCombineRule2D;
122
+ setDensity(value: number): void;
123
+ /**
124
+ * Gives the collider a mass of its own, kilograms, whatever its outline's area (Rapier's `setMass`): its centre of mass
125
+ * stays the outline's and its inertia is the outline's at that mass, and it holds through `setShape`. A collider of
126
+ * several kernel shapes shares it among them by area. `setDensity` takes it back to its density.
127
+ * @throws RangeError for a mass below 0 or not finite.
128
+ */
129
+ setMass(kilograms: number): void;
130
+ /**
131
+ * Gives the collider its mass, centre of mass and inertia outright (Rapier's `setMassProperties`): `mass` in kilograms,
132
+ * `centre` in the collider's own frame (world units) and `inertia` in kg m^2 in world units about that centre. They hold
133
+ * through `setShape` and a move on the body; `setDensity` or `setMass` replaces them.
134
+ * @throws RangeError for a number that is not finite, or a mass or inertia below 0.
135
+ */
136
+ setMassProperties(mass: number, centre?: Vec2D, inertia?: number): void;
137
+ /** The collider's mass, kilograms: from its density, or as set. */
138
+ mass(): number;
139
+ /** The mass properties given outright, kept so a move on the body takes their centre with it. */
140
+ private massProps;
141
+ private live;
142
+ /**
143
+ * Which kinds of body pair this collider takes part in, as the bits of `activeCollisionTypes` (Rapier's
144
+ * `setActiveCollisionTypes`): 1 dynamic with dynamic, 2 dynamic with kinematic, 4 dynamic with fixed (the default 7),
145
+ * 8 kinematic with kinematic, 16 kinematic with fixed, 32 fixed with fixed. A sensor sees all six (63).
146
+ */
147
+ setActiveCollisionTypes(types: number): void;
148
+ /** The pair kinds this collider takes part in, as {@link Collider2D.setActiveCollisionTypes} reads them. */
149
+ activeCollisionTypes(): number;
150
+ /**
151
+ * Chooses which events this collider asks for, Rapier's `setActiveEvents`: `collision` for `contactstart`,
152
+ * `contactend` and the intersection events, `contactForce` for `contactforce` (past `setContactForceEventThreshold`).
153
+ * What you leave out stays.
154
+ */
155
+ setActiveEvents(events: {
156
+ collision?: boolean;
157
+ contactForce?: boolean;
158
+ }): void;
159
+ /** Which events this collider asks for. */
160
+ activeEvents(): {
161
+ collision: boolean;
162
+ contactForce: boolean;
163
+ };
164
+ /** The newtons a contact's force must pass to raise a `contactforce` event (Rapier's `setContactForceEventThreshold`); it also asks for the event. */
165
+ /** Rapier's `setContactSkin`: the gap, world units, the solver holds this collider off what it touches (0 for none). */
166
+ setContactSkin(distance: number): void;
167
+ contactSkin(): number;
168
+ setContactForceEventThreshold(newtons: number): void;
169
+ /** Packed interaction groups, see `interactionGroups`. */
170
+ setCollisionGroups(groups: number): void;
171
+ setSolverGroups(groups: number): void;
172
+ /** A disabled collider meets nothing, reports nothing and is skipped by queries; its mass still counts. */
173
+ setEnabled(enabled: boolean): void;
174
+ get isEnabled(): boolean;
175
+ /** The collider's centre in world units, at the body's latest step. */
176
+ translation(): [number, number];
177
+ /** The collider's rotation in radians, at the body's latest step. */
178
+ rotation(): number;
179
+ /** Its position on its body, world units in the body's frame (Rapier's `translationWrtParent`). */
180
+ translationWrtParent(): [number, number];
181
+ /** Its rotation on its body, radians (Rapier's `rotationWrtParent`). */
182
+ rotationWrtParent(): number;
183
+ /** Moves it on its body to `offset`, world units in the body's frame (Rapier's `setTranslationWrtParent`). */
184
+ setTranslationWrtParent(offset: Vec2D): void;
185
+ /** Turns it on its body to `angle` radians (Rapier's `setRotationWrtParent`). */
186
+ setRotationWrtParent(angle: number): void;
187
+ /**
188
+ * Moves the collider's kernel shapes from where they are on the body to `offset` and `turn`: each turns by the
189
+ * difference of the angles and shifts by the new offset less the old one turned. The body's mass and centre of mass
190
+ * follow, and its contacts are built again from where it went.
191
+ */
192
+ private place;
193
+ /** Removes the collider from its body. */
194
+ remove(): void;
195
+ }
196
+ /** A rigid body in the kernel, bound to an optional sprite. Positions are in world units, y down. */
197
+ export declare class Body2D {
198
+ private readonly owner;
199
+ /** The kernel's handle. @internal */
200
+ readonly handle: number;
201
+ readonly sprite: SpriteLike | null;
202
+ private kind;
203
+ /** The colliders on this body. */
204
+ readonly colliders: Collider2D[];
205
+ userData: unknown;
206
+ /** @internal previous (0..2) and current (3..5) step poses: x, y, angle. */
207
+ readonly pose: Float64Array<ArrayBuffer>;
208
+ /** @internal */
209
+ dirty: boolean;
210
+ private removed;
211
+ private extraMass;
212
+ /** @internal */
213
+ constructor(owner: BodyOwner2D,
214
+ /** The kernel's handle. @internal */
215
+ handle: number, sprite: SpriteLike | null, kind: BodyType2D);
216
+ /** @internal Stores the current pose as the newest step. */
217
+ snapshot(): void;
218
+ /** @internal */
219
+ store(x: number, y: number, c: number, s: number, k: number): void;
220
+ /** How the body moves: `dynamic`, `fixed`, `kinematicPosition` or `kinematicVelocity`. */
221
+ get type(): BodyType2D;
222
+ /**
223
+ * Changes how the body moves. A dynamic body is weighed again from its colliders; a fixed body stops. A body locked on an
224
+ * axis keeps its lock only while it is dynamic or kinematic.
225
+ */
226
+ setType(type: BodyType2D): this;
227
+ /** @internal Damping, gravity scale, sleep permission, ccd and dominance as the kernel holds them. */
228
+ params: {
229
+ linearDamping: number;
230
+ angularDamping: number;
231
+ gravityScale: number;
232
+ canSleep: boolean;
233
+ ccd: boolean;
234
+ dominance: number;
235
+ };
236
+ private setParams;
237
+ get linearDamping(): number;
238
+ set linearDamping(value: number);
239
+ get angularDamping(): number;
240
+ set angularDamping(value: number);
241
+ get gravityScale(): number;
242
+ set gravityScale(value: number);
243
+ get canSleep(): boolean;
244
+ set canSleep(value: boolean);
245
+ /** Continuous collision for a fast body. */
246
+ get ccd(): boolean;
247
+ set ccd(value: boolean);
248
+ /** Soft CCD reach in world units, see `BodyOptions2D.softCcd`. */
249
+ get softCcd(): number;
250
+ set softCcd(value: number);
251
+ private soft;
252
+ get dominance(): number;
253
+ set dominance(value: number);
254
+ private check;
255
+ private get k();
256
+ get isRemoved(): boolean;
257
+ /** @internal */
258
+ markRemoved(): void;
259
+ /** Position at the latest step. */
260
+ get position(): [number, number];
261
+ /** Rotation at the latest step, radians. */
262
+ get rotation(): number;
263
+ /** Moves the body now with no interpolation sweep. For a kinematic position body, use `moveTo`. */
264
+ teleport(position: Vec2D, rotation?: number): this;
265
+ /** Sets where a kinematic position body should be after the next step. */
266
+ moveTo(position: Vec2D, rotation?: number): this;
267
+ private read;
268
+ /** Velocity in world units per second. */
269
+ get linearVelocity(): [number, number];
270
+ set linearVelocity(value: Vec2D);
271
+ /** Radians per second. */
272
+ get angularVelocity(): number;
273
+ set angularVelocity(value: number);
274
+ /** Impulse in kernel units (kilogram metres per second); a body of mass m gains impulse / m metres per second. */
275
+ applyImpulse(impulse: Vec2D): this;
276
+ /** Impulse applied at a world point (world units), which also spins the body. */
277
+ applyImpulseAtPoint(impulse: Vec2D, point: Vec2D): this;
278
+ applyTorqueImpulse(torque: number): this;
279
+ /** Force in kernel units (newtons), held until `resetForces`: it acts every step. */
280
+ applyForce(force: Vec2D): this;
281
+ /** A torque held until `resetForces`. */
282
+ applyTorque(torque: number): this;
283
+ /** A force held until `resetForces`, applied at a world point: it pushes the body and turns it by the arm from the centre of mass. */
284
+ applyForceAtPoint(force: Vec2D, point: Vec2D): this;
285
+ /** Clears the torque that acts every step and keeps the force; `resetForces` clears both. */
286
+ resetTorques(): this;
287
+ /** Clears the forces and torques that act every step. */
288
+ resetForces(): this;
289
+ get mass(): number;
290
+ /**
291
+ * Moment of inertia about the centre of mass, in kilogram square world units (Rapier's `principalInertia`): what turns the
292
+ * body as `mass` is what moves it. 0 for a fixed or kinematic body.
293
+ */
294
+ get inertia(): number;
295
+ /** @internal The added mass a restored snapshot carries. */
296
+ restoreAdditionalMass(value: number): void;
297
+ /** Mass added to what the colliders weigh, in kilograms. */
298
+ get additionalMass(): number;
299
+ set additionalMass(value: number);
300
+ /**
301
+ * Whether the body is in the simulation (default true). Disabled, it keeps its pose and velocity, moves and wakes nothing, touches
302
+ * nothing (its contacts end), is found by no query, and its joints rest; enabled again, it goes on with the velocity it had. Rapier's
303
+ * `setEnabled`: its API reference says only that a collider disabled is "excluded from all collision detection and physics", and
304
+ * says nothing of a body's, so this follows what Rapier 2D does when run (the body's colliders read disabled, nothing touches
305
+ * them, the pose and velocity stay, the body goes on at that velocity when enabled), and what the 3D kernel's disabled body does.
306
+ */
307
+ get enabled(): boolean;
308
+ set enabled(value: boolean);
309
+ /**
310
+ * The most the body may turn at, in radians a second (default 0: no limit). Rapier caps every body's spin by default to keep its
311
+ * continuous collision reliable, and its `allowFastRotation` lifts the cap; here a fast spinner with `ccd` set is swept along its turn
312
+ * (it is stopped by a thin wall at 2000 rad/s, `kernel/tests/ccd.rs`), so there is no default cap and `allowFastRotation` has nothing to
313
+ * lift. Set this to cap a body as Rapier does. Applied each substep before the solve.
314
+ * @throws RangeError for a speed below 0 or not finite.
315
+ */
316
+ set maxAngularSpeed(value: number);
317
+ get maxAngularSpeed(): number;
318
+ /**
319
+ * Solver passes the body's island takes beyond the world's, each substep (default 0). Rapier's `additional_pgs_iterations` (its `additional_solver_iterations` is extra substeps, `additionalSolverIterations` here): a stack
320
+ * that must stay stiff under a heavy load, or a ring of joints that needs to close, asks for more passes without raising every island's
321
+ * cost. The island runs the most any of its awake bodies asks for, over its own contacts and joints only; no other island is touched,
322
+ * and with no body asking the step is bit for bit what it was. The extra passes visit the contacts one at a time. A stack of 20 boxes
323
+ * under a box 100 times as heavy is still creeping to rest after two seconds at one pass; with 16 more it has arrived.
324
+ * @throws RangeError for a number that is not a whole number of 0 or more (up to 4,294,967,295).
325
+ */
326
+ set additionalPgsIterations(value: number);
327
+ get additionalPgsIterations(): number;
328
+ /**
329
+ * Substeps the body's island takes beyond the world's, each step (default 0): Rapier's `additional_solver_iterations`, `num_solver_iterations`
330
+ * plus the most any body of the island asks for. The island is solved with that many substeps, each shorter, as a world set to that count
331
+ * would solve it; the other islands are not touched, and a kinematic body ends the step where the world's own count leaves it. (Extra
332
+ * passes in each substep are {@link Body2D.additionalPgsIterations}.)
333
+ * @throws RangeError for a number that is not a whole number of 0 or more (up to 4,294,967,295).
334
+ */
335
+ set additionalSolverIterations(value: number);
336
+ get additionalSolverIterations(): number;
337
+ /** The centre of mass in world units, as of the last step. */
338
+ get centerOfMass(): [number, number];
339
+ /**
340
+ * Adds a solid to what the colliders weigh, as it is and not in proportion (Rapier's `setAdditionalMassProperties`): `mass` in
341
+ * kilograms with its centre at `centre` in the body's frame (world units) and `inertia` in kg m^2 (in the body's world units, as
342
+ * the colliders' are) about that centre. It joins the colliders' mass by the parallel axis theorem about the combined centre of
343
+ * mass. A mass and an inertia of 0 take it away; {@link Body2D.additionalMass} stays as the share-in-proportion kind.
344
+ * @throws RangeError for a number that is not finite, or a mass or inertia below 0.
345
+ */
346
+ setAdditionalMassProperties(mass: number, centre?: Vec2D, inertia?: number): this;
347
+ get sleeping(): boolean;
348
+ wakeUp(): this;
349
+ /** Puts the body to sleep now; a contact or a call to `wakeUp` wakes it. */
350
+ sleep(): this;
351
+ /**
352
+ * Locks the body's translation on the x axis, the y axis or both (default both); `lockTranslation(false)` frees it. The
353
+ * lock holds the body at its position now, with an exact constraint; `teleport` moves the lock with the body.
354
+ */
355
+ lockTranslation(x?: boolean, y?: boolean): this;
356
+ /**
357
+ * Stops the body turning, or lets it turn again: `lockRotation()` holds its angle and takes its spin away. Rapier's
358
+ * `lockRotations`. The `lockRotation` option of `addBody` does the same at creation.
359
+ */
360
+ lockRotation(locked?: boolean): this;
361
+ /** True while the body's rotation is locked. */
362
+ get rotationLocked(): boolean;
363
+ /** @internal */
364
+ turnLocked: boolean;
365
+ /** Which axes are locked, [x, y]. */
366
+ get translationLocked(): [boolean, boolean];
367
+ /** @internal The kernel handle of the joint that holds the lock, or -1. */
368
+ lockJoint: number;
369
+ private locked;
370
+ /** Adds a collider. */
371
+ addCollider(options: ColliderOptions2D): Collider2D;
372
+ /** Removes the body, its colliders and its joints from the world. */
373
+ remove(): void;
374
+ }
375
+ /** @internal */
376
+ export { describeShape };
@@ -0,0 +1,86 @@
1
+ import type { Body2D } from './body.js';
2
+ import type { Physics2D, QueryFilter2D } from './physics.js';
3
+ import type { Vec2D } from './shapes.js';
4
+ /** Options of a character controller; every field has a default. */
5
+ export interface CharacterOptions2D {
6
+ /** Gap kept between the character and what it touches, world units (default 0.5). */
7
+ offset?: number;
8
+ /** Which way is up. Default [0, -1] (screen up). */
9
+ up?: Vec2D;
10
+ /**
11
+ * Step over ledges up to `maxHeight` high, with at least `minWidth` of free room across the top, and onto dynamic bodies too unless
12
+ * `includeDynamic` is false (default true, as Rapier's `includeDynamicBodies`).
13
+ */
14
+ autostep?: {
15
+ maxHeight: number;
16
+ minWidth: number;
17
+ includeDynamic?: boolean;
18
+ };
19
+ /** Steepest slope it can climb, radians (default 45 degrees). */
20
+ maxSlopeClimbAngle?: number;
21
+ /** Slopes steeper than this slide it down, radians (default 30 degrees). */
22
+ minSlopeSlideAngle?: number;
23
+ /** Stick to the ground when walking down slopes or steps up to this distance, world units. */
24
+ snapToGround?: number;
25
+ /** Slide along walls instead of stopping (default true). */
26
+ slide?: boolean;
27
+ /** Push dynamic bodies it walks into (default false). */
28
+ pushDynamic?: boolean;
29
+ /** Mass used when pushing, in kilograms. */
30
+ mass?: number;
31
+ /**
32
+ * Which colliders the character meets, like a scene query's filter: `groups`, `excludeFixed`, `excludeKinematic`, `excludeDynamic`,
33
+ * `predicate`, `excludeCollider` (Rapier's `filterFlags`, `filterGroups` and `filterPredicate`). The character's own body is always
34
+ * left out, and sensors unless `excludeSensors` is false. A filter given to `move` replaces this one for that move.
35
+ */
36
+ filter?: QueryFilter2D;
37
+ }
38
+ /** What one `move` did. */
39
+ export interface CharacterMoveResult2D {
40
+ /** The movement that was applied, world units. */
41
+ movement: [number, number];
42
+ grounded: boolean;
43
+ /** Number of contacts the move hit. */
44
+ collisions: number;
45
+ /** What the move hit, in order: the collider, the surface normal pointing out of it and the contact point. */
46
+ hits: Array<{
47
+ collider: import('./body.js').Collider2D;
48
+ body: Body2D;
49
+ normal: [number, number];
50
+ point: [number, number];
51
+ }>;
52
+ }
53
+ /**
54
+ * Moves a kinematic position body around obstacles. Call `move` once per fixed step (from `beforestep`).
55
+ *
56
+ * The algorithm is the one the Rapier user guide describes for its kinematic character controller, built on the shape
57
+ * cast of the kernel: the character slides along what it hits keeping `offset` away from it, climbs slopes up to
58
+ * `maxSlopeClimbAngle` keeping its horizontal speed, slides down slopes steeper than `minSlopeSlideAngle`, steps over
59
+ * ledges (`autostep`) and sticks to the ground on the way down (`snapToGround`).
60
+ */
61
+ export declare class CharacterController2D {
62
+ private readonly physics;
63
+ readonly body: Body2D;
64
+ private readonly options;
65
+ private readonly onDispose;
66
+ private readonly up;
67
+ private readonly offset;
68
+ private readonly climb;
69
+ private readonly slideAngle;
70
+ private disposed;
71
+ /** @internal */
72
+ constructor(physics: Physics2D, body: Body2D, options: CharacterOptions2D, onDispose: (controller: CharacterController2D) => void);
73
+ /** Casts the character's shape from `at` (metres) along the unit `dir` for `max`; the nearest hit that is not itself. */
74
+ private cast;
75
+ /** The filter of the move under way: the caller's, with the character's own body left out. */
76
+ private filter;
77
+ private filterFor;
78
+ /** Computes the movement for `delta` (world units) and sets the body's next position; `filter` replaces the controller's for this move. */
79
+ move(delta: Vec2D, filter?: QueryFilter2D): CharacterMoveResult2D;
80
+ /** Tries to climb a ledge in the way of `rest`: up by at most `maxHeight`, across by at least `minWidth`, down onto ground. */
81
+ private step;
82
+ /** Pushes a dynamic body the character walks into, with the character's mass behind the movement. */
83
+ private pushDynamic;
84
+ dispose(): void;
85
+ [Symbol.dispose]: () => void;
86
+ }
@@ -0,0 +1,2 @@
1
+ /** Milliseconds on a clock that only goes forward. */
2
+ export declare const clock: () => number;
@@ -0,0 +1,15 @@
1
+ export { Physics2D } from './physics.js';
2
+ export type { Physics2DOptions, Physics2DSolverOptions, Physics2DLoadOptions, KernelWasmSource, ContactForceEvent2D, DebugColour2D, DebugLines2D, DebugStyle2D, Physics2DHooks, ProjectedPoint2D, ContactPair2D, ContactChange2D, Physics2DEventMap, CollisionEvent2D, CollisionEventType2D, QueryFilter2D, RaycastOptions2D, Hit2D, CastHit2D, ShapeCastHit2D, ShapeCastOptions2D, } from './physics.js';
3
+ export { Body2D, Collider2D } from './body.js';
4
+ export type { BodyOptions2D, BodyType2D, SpriteLike } from './body.js';
5
+ export { Joint2D } from './joint.js';
6
+ export type { JointOptions2D, MotorOptions2D } from './joint.js';
7
+ export { Articulation2D } from './articulation.js';
8
+ export type { ArticulationLink2D, LinkPose2D, IKOptions2D } from './articulation.js';
9
+ export { PidController2D } from './pid.js';
10
+ export { CharacterController2D } from './character.js';
11
+ export type { CharacterOptions2D, CharacterMoveResult2D } from './character.js';
12
+ export { CoefficientCombineRule2D, interactionGroups } from './shapes.js';
13
+ export type { ActiveHooks2D, ColliderOptions2D, ColliderSettings2D, ShapeOptions2D, Vec2D } from './shapes.js';
14
+ export { tileMapColliders } from './tilemap.js';
15
+ export type { TileMapSource, TileMapBodyOptions, TileShape } from './tilemap.js';