@codexo/exojs-physics 0.19.1 → 0.20.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/README.md +8 -73
- package/{dist/esm/debug/index.d.ts → debug.d.ts} +1 -2
- package/debug.js +1 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +17 -23
- package/dist/esm/Aabb.d.ts +0 -10
- package/dist/esm/Aabb.d.ts.map +0 -1
- package/dist/esm/Aabb.js +0 -16
- package/dist/esm/Aabb.js.map +0 -1
- package/dist/esm/Collider.d.ts +0 -107
- package/dist/esm/Collider.d.ts.map +0 -1
- package/dist/esm/Collider.js +0 -284
- package/dist/esm/Collider.js.map +0 -1
- package/dist/esm/ContactGraph.d.ts +0 -154
- package/dist/esm/ContactGraph.d.ts.map +0 -1
- package/dist/esm/ContactGraph.js +0 -383
- package/dist/esm/ContactGraph.js.map +0 -1
- package/dist/esm/ContactModifier.d.ts +0 -62
- package/dist/esm/ContactModifier.d.ts.map +0 -1
- package/dist/esm/ContactModifier.js +0 -49
- package/dist/esm/ContactModifier.js.map +0 -1
- package/dist/esm/PhysicsBody.d.ts +0 -186
- package/dist/esm/PhysicsBody.d.ts.map +0 -1
- package/dist/esm/PhysicsBody.js +0 -526
- package/dist/esm/PhysicsBody.js.map +0 -1
- package/dist/esm/PhysicsBodyComponent.d.ts +0 -45
- package/dist/esm/PhysicsBodyComponent.d.ts.map +0 -1
- package/dist/esm/PhysicsBodyComponent.js +0 -77
- package/dist/esm/PhysicsBodyComponent.js.map +0 -1
- package/dist/esm/PhysicsWorld.d.ts +0 -567
- package/dist/esm/PhysicsWorld.d.ts.map +0 -1
- package/dist/esm/PhysicsWorld.js +0 -1096
- package/dist/esm/PhysicsWorld.js.map +0 -1
- package/dist/esm/TimeStepper.d.ts +0 -40
- package/dist/esm/TimeStepper.d.ts.map +0 -1
- package/dist/esm/TimeStepper.js +0 -59
- package/dist/esm/TimeStepper.js.map +0 -1
- package/dist/esm/backend/NativePhysicsBackend.d.ts +0 -28
- package/dist/esm/backend/NativePhysicsBackend.d.ts.map +0 -1
- package/dist/esm/backend/NativePhysicsBackend.js +0 -52
- package/dist/esm/backend/NativePhysicsBackend.js.map +0 -1
- package/dist/esm/backend/PhysicsBackend.d.ts +0 -38
- package/dist/esm/backend/PhysicsBackend.d.ts.map +0 -1
- package/dist/esm/binding/BindingRegistry.d.ts +0 -48
- package/dist/esm/binding/BindingRegistry.d.ts.map +0 -1
- package/dist/esm/binding/BindingRegistry.js +0 -81
- package/dist/esm/binding/BindingRegistry.js.map +0 -1
- package/dist/esm/binding/PhysicsBinding.d.ts +0 -37
- package/dist/esm/binding/PhysicsBinding.d.ts.map +0 -1
- package/dist/esm/binding/PhysicsBinding.js +0 -54
- package/dist/esm/binding/PhysicsBinding.js.map +0 -1
- package/dist/esm/binding/nodeWorldTransform.d.ts +0 -18
- package/dist/esm/binding/nodeWorldTransform.d.ts.map +0 -1
- package/dist/esm/binding/nodeWorldTransform.js +0 -41
- package/dist/esm/binding/nodeWorldTransform.js.map +0 -1
- package/dist/esm/broadphase/AabbTreeBroadPhase.d.ts +0 -84
- package/dist/esm/broadphase/AabbTreeBroadPhase.d.ts.map +0 -1
- package/dist/esm/broadphase/AabbTreeBroadPhase.js +0 -183
- package/dist/esm/broadphase/AabbTreeBroadPhase.js.map +0 -1
- package/dist/esm/broadphase/BroadPhase.d.ts +0 -25
- package/dist/esm/broadphase/BroadPhase.d.ts.map +0 -1
- package/dist/esm/broadphase/index.d.ts +0 -3
- package/dist/esm/broadphase/index.d.ts.map +0 -1
- package/dist/esm/collision/CollisionProxy.d.ts +0 -15
- package/dist/esm/collision/CollisionProxy.d.ts.map +0 -1
- package/dist/esm/collision/Manifold.d.ts +0 -34
- package/dist/esm/collision/Manifold.d.ts.map +0 -1
- package/dist/esm/collision/Manifold.js +0 -37
- package/dist/esm/collision/Manifold.js.map +0 -1
- package/dist/esm/collision/chainAdjacency.d.ts +0 -2
- package/dist/esm/collision/chainAdjacency.d.ts.map +0 -1
- package/dist/esm/collision/chainAdjacency.js +0 -44
- package/dist/esm/collision/chainAdjacency.js.map +0 -1
- package/dist/esm/collision/dispatch.d.ts +0 -35
- package/dist/esm/collision/dispatch.d.ts.map +0 -1
- package/dist/esm/collision/dispatch.js +0 -58
- package/dist/esm/collision/dispatch.js.map +0 -1
- package/dist/esm/collision/index.d.ts +0 -5
- package/dist/esm/collision/index.d.ts.map +0 -1
- package/dist/esm/collision/narrowphase.d.ts +0 -17
- package/dist/esm/collision/narrowphase.d.ts.map +0 -1
- package/dist/esm/collision/narrowphase.js +0 -555
- package/dist/esm/collision/narrowphase.js.map +0 -1
- package/dist/esm/collision/segments.d.ts +0 -19
- package/dist/esm/collision/segments.d.ts.map +0 -1
- package/dist/esm/collision/segments.js +0 -36
- package/dist/esm/collision/segments.js.map +0 -1
- package/dist/esm/collision/sweep.d.ts +0 -35
- package/dist/esm/collision/sweep.d.ts.map +0 -1
- package/dist/esm/collision/sweep.js +0 -437
- package/dist/esm/collision/sweep.js.map +0 -1
- package/dist/esm/debug/PhysicsDebugDraw.d.ts +0 -72
- package/dist/esm/debug/PhysicsDebugDraw.d.ts.map +0 -1
- package/dist/esm/debug/PhysicsDebugDraw.js +0 -239
- package/dist/esm/debug/PhysicsDebugDraw.js.map +0 -1
- package/dist/esm/debug/index.d.ts.map +0 -1
- package/dist/esm/debug/index.js +0 -3
- package/dist/esm/events.d.ts +0 -36
- package/dist/esm/events.d.ts.map +0 -1
- package/dist/esm/index.d.ts +0 -2
- package/dist/esm/index.d.ts.map +0 -1
- package/dist/esm/index.js +0 -25
- package/dist/esm/joints/DistanceJoint.d.ts +0 -70
- package/dist/esm/joints/DistanceJoint.d.ts.map +0 -1
- package/dist/esm/joints/DistanceJoint.js +0 -167
- package/dist/esm/joints/DistanceJoint.js.map +0 -1
- package/dist/esm/joints/Joint.d.ts +0 -76
- package/dist/esm/joints/Joint.d.ts.map +0 -1
- package/dist/esm/joints/Joint.js +0 -62
- package/dist/esm/joints/Joint.js.map +0 -1
- package/dist/esm/joints/MouseJoint.d.ts +0 -55
- package/dist/esm/joints/MouseJoint.d.ts.map +0 -1
- package/dist/esm/joints/MouseJoint.js +0 -139
- package/dist/esm/joints/MouseJoint.js.map +0 -1
- package/dist/esm/joints/PrismaticJoint.d.ts +0 -84
- package/dist/esm/joints/PrismaticJoint.d.ts.map +0 -1
- package/dist/esm/joints/PrismaticJoint.js +0 -218
- package/dist/esm/joints/PrismaticJoint.js.map +0 -1
- package/dist/esm/joints/RevoluteJoint.d.ts +0 -77
- package/dist/esm/joints/RevoluteJoint.d.ts.map +0 -1
- package/dist/esm/joints/RevoluteJoint.js +0 -204
- package/dist/esm/joints/RevoluteJoint.js.map +0 -1
- package/dist/esm/joints/WeldJoint.d.ts +0 -60
- package/dist/esm/joints/WeldJoint.d.ts.map +0 -1
- package/dist/esm/joints/WeldJoint.js +0 -166
- package/dist/esm/joints/WeldJoint.js.map +0 -1
- package/dist/esm/joints/WheelJoint.d.ts +0 -91
- package/dist/esm/joints/WheelJoint.d.ts.map +0 -1
- package/dist/esm/joints/WheelJoint.js +0 -235
- package/dist/esm/joints/WheelJoint.js.map +0 -1
- package/dist/esm/math.d.ts +0 -29
- package/dist/esm/math.d.ts.map +0 -1
- package/dist/esm/math.js +0 -60
- package/dist/esm/math.js.map +0 -1
- package/dist/esm/physicsBuildInfo.d.ts +0 -16
- package/dist/esm/physicsBuildInfo.d.ts.map +0 -1
- package/dist/esm/physicsBuildInfo.js +0 -10
- package/dist/esm/physicsBuildInfo.js.map +0 -1
- package/dist/esm/public.d.ts +0 -34
- package/dist/esm/public.d.ts.map +0 -1
- package/dist/esm/query/QueryEngine.d.ts +0 -95
- package/dist/esm/query/QueryEngine.d.ts.map +0 -1
- package/dist/esm/query/QueryEngine.js +0 -512
- package/dist/esm/query/QueryEngine.js.map +0 -1
- package/dist/esm/query/SpatialIndex.d.ts +0 -34
- package/dist/esm/query/SpatialIndex.d.ts.map +0 -1
- package/dist/esm/shapes/AnyShape.d.ts +0 -14
- package/dist/esm/shapes/AnyShape.d.ts.map +0 -1
- package/dist/esm/shapes/BoxShape.d.ts +0 -12
- package/dist/esm/shapes/BoxShape.d.ts.map +0 -1
- package/dist/esm/shapes/BoxShape.js +0 -41
- package/dist/esm/shapes/BoxShape.js.map +0 -1
- package/dist/esm/shapes/CapsuleShape.d.ts +0 -30
- package/dist/esm/shapes/CapsuleShape.d.ts.map +0 -1
- package/dist/esm/shapes/CapsuleShape.js +0 -88
- package/dist/esm/shapes/CapsuleShape.js.map +0 -1
- package/dist/esm/shapes/ChainEdgeShape.d.ts +0 -2
- package/dist/esm/shapes/ChainEdgeShape.d.ts.map +0 -1
- package/dist/esm/shapes/ChainEdgeShape.js +0 -66
- package/dist/esm/shapes/ChainEdgeShape.js.map +0 -1
- package/dist/esm/shapes/ChainShape.d.ts +0 -46
- package/dist/esm/shapes/ChainShape.d.ts.map +0 -1
- package/dist/esm/shapes/ChainShape.js +0 -85
- package/dist/esm/shapes/ChainShape.js.map +0 -1
- package/dist/esm/shapes/CircleShape.d.ts +0 -14
- package/dist/esm/shapes/CircleShape.d.ts.map +0 -1
- package/dist/esm/shapes/CircleShape.js +0 -31
- package/dist/esm/shapes/CircleShape.js.map +0 -1
- package/dist/esm/shapes/PolygonShape.d.ts +0 -24
- package/dist/esm/shapes/PolygonShape.d.ts.map +0 -1
- package/dist/esm/shapes/PolygonShape.js +0 -153
- package/dist/esm/shapes/PolygonShape.js.map +0 -1
- package/dist/esm/shapes/SegmentShape.d.ts +0 -31
- package/dist/esm/shapes/SegmentShape.d.ts.map +0 -1
- package/dist/esm/shapes/SegmentShape.js +0 -62
- package/dist/esm/shapes/SegmentShape.js.map +0 -1
- package/dist/esm/shapes/Shape.d.ts +0 -37
- package/dist/esm/shapes/Shape.d.ts.map +0 -1
- package/dist/esm/shapes/Shape.js +0 -15
- package/dist/esm/shapes/Shape.js.map +0 -1
- package/dist/esm/shapes/convexParts.d.ts +0 -21
- package/dist/esm/shapes/convexParts.d.ts.map +0 -1
- package/dist/esm/shapes/convexParts.js +0 -26
- package/dist/esm/shapes/convexParts.js.map +0 -1
- package/dist/esm/shapes/decompose.d.ts +0 -2
- package/dist/esm/shapes/decompose.d.ts.map +0 -1
- package/dist/esm/shapes/decompose.js +0 -272
- package/dist/esm/shapes/decompose.js.map +0 -1
- package/dist/esm/shapes/index.d.ts +0 -9
- package/dist/esm/shapes/index.d.ts.map +0 -1
- package/dist/esm/solver/ContactSolver.d.ts +0 -94
- package/dist/esm/solver/ContactSolver.d.ts.map +0 -1
- package/dist/esm/solver/ContactSolver.js +0 -457
- package/dist/esm/solver/ContactSolver.js.map +0 -1
- package/dist/esm/solver/tolerances.d.ts +0 -2
- package/dist/esm/solver/tolerances.d.ts.map +0 -1
- package/dist/esm/solver/tolerances.js +0 -36
- package/dist/esm/solver/tolerances.js.map +0 -1
- package/dist/esm/sort.d.ts +0 -2
- package/dist/esm/sort.d.ts.map +0 -1
- package/dist/esm/sort.js +0 -44
- package/dist/esm/sort.js.map +0 -1
- package/dist/esm/types.d.ts +0 -35
- package/dist/esm/types.d.ts.map +0 -1
- package/dist/esm/types.js +0 -26
- package/dist/esm/types.js.map +0 -1
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
//#region src/ContactModifier.ts
|
|
2
|
-
/**
|
|
3
|
-
* The single reused {@link ContactModifierContext} instance. Bound to one record
|
|
4
|
-
* at a time so a step over thousands of contacts allocates nothing.
|
|
5
|
-
* @internal
|
|
6
|
-
*/
|
|
7
|
-
var MutableContactModifierContext = class {
|
|
8
|
-
colliderA;
|
|
9
|
-
colliderB;
|
|
10
|
-
bodyA;
|
|
11
|
-
bodyB;
|
|
12
|
-
normalX = 0;
|
|
13
|
-
normalY = 0;
|
|
14
|
-
pointCount = 0;
|
|
15
|
-
maxPenetration = 0;
|
|
16
|
-
enabled = true;
|
|
17
|
-
friction = 0;
|
|
18
|
-
restitution = 0;
|
|
19
|
-
/** Point this context at `record` and load its current per-step values. */
|
|
20
|
-
bind(record) {
|
|
21
|
-
const manifold = record.manifold;
|
|
22
|
-
this.colliderA = record.ownerA;
|
|
23
|
-
this.colliderB = record.ownerB;
|
|
24
|
-
this.bodyA = record.ownerA.body;
|
|
25
|
-
this.bodyB = record.ownerB.body;
|
|
26
|
-
this.normalX = manifold.normalX;
|
|
27
|
-
this.normalY = manifold.normalY;
|
|
28
|
-
this.pointCount = manifold.pointCount;
|
|
29
|
-
let deepest = 0;
|
|
30
|
-
for (let i = 0; i < manifold.pointCount; i++) {
|
|
31
|
-
const penetration = (i === 0 ? manifold.points[0] : manifold.points[1]).penetration;
|
|
32
|
-
deepest = penetration > deepest ? penetration : deepest;
|
|
33
|
-
}
|
|
34
|
-
this.maxPenetration = deepest;
|
|
35
|
-
this.enabled = record.enabled;
|
|
36
|
-
this.friction = record.friction;
|
|
37
|
-
this.restitution = record.restitution;
|
|
38
|
-
}
|
|
39
|
-
/** Write the (possibly modified) controls back onto the bound record. */
|
|
40
|
-
flush(record) {
|
|
41
|
-
record.enabled = this.enabled;
|
|
42
|
-
record.friction = this.friction;
|
|
43
|
-
record.restitution = this.restitution;
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
//#endregion
|
|
48
|
-
export { MutableContactModifierContext };
|
|
49
|
-
//# sourceMappingURL=ContactModifier.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ContactModifier.js","names":[],"sources":["../../src/ContactModifier.ts"],"sourcesContent":["import type { Collider } from './Collider';\nimport type { ContactRecord } from './ContactGraph';\nimport type { PhysicsBody } from './PhysicsBody';\n\n/**\n * A solid contact as the world's {@link ContactModifier} sees it: the pair that\n * produced it, the contact normal, and the three per-step controls the modifier\n * may change. Everything else is read-only.\n *\n * The object is reused for every contact and is only valid for the duration of\n * the callback - read what you need, write the controls, do not retain it.\n *\n * Writing a control affects this step only; the values are re-derived from the\n * two colliders before the modifier runs again.\n *\n * A chain collider is solved per edge, so a body touching several edges of one\n * chain reaches the modifier once per edge, each time with the same authored\n * collider pair. Decide from the contact's own normal and penetration rather\n * than from the pair's identity if that distinction matters.\n */\nexport interface ContactModifierContext {\n readonly colliderA: Collider;\n readonly colliderB: Collider;\n readonly bodyA: PhysicsBody;\n readonly bodyB: PhysicsBody;\n /** X of the unit contact normal, pointing from A towards B. */\n readonly normalX: number;\n /** Y of the unit contact normal, pointing from A towards B. */\n readonly normalY: number;\n /** Manifold points backing this contact: `1` for a vertex/face hit, `2` for a face/face hit. */\n readonly pointCount: number;\n /** Deepest penetration across the manifold points, in px. */\n readonly maxPenetration: number;\n /**\n * Set to `false` to skip this contact in the solver for this step. The\n * contact stays geometrically touching, so `collisionStart`/`collisionEnd`\n * still describe the real geometry; it just applies no impulse, and it does\n * not join the two bodies into one sleeping island. Its warm-start impulses\n * are dropped while it is disabled, so re-enabling it starts cold rather than\n * releasing a stale impulse.\n */\n enabled: boolean;\n /**\n * Coulomb friction for this step. Defaults to `√(a.friction × b.friction)`\n * over the two colliders.\n */\n friction: number;\n /**\n * Restitution for this step. Defaults to `max(a.restitution, b.restitution)`\n * over the two colliders.\n */\n restitution: number;\n}\n\n/**\n * Called once per solid contact per fixed step, after contact generation and\n * before the solver runs, to adjust that contact for this step - the hook\n * one-way platforms, conditional friction and per-pair material overrides are\n * built on.\n *\n * A world has at most one modifier. It runs before islands are built, so\n * disabling a contact also keeps the two bodies from sleeping as one.\n */\nexport type ContactModifier = (contact: ContactModifierContext) => void;\n\n/**\n * The single reused {@link ContactModifierContext} instance. Bound to one record\n * at a time so a step over thousands of contacts allocates nothing.\n * @internal\n */\nexport class MutableContactModifierContext implements ContactModifierContext {\n public colliderA!: Collider;\n public colliderB!: Collider;\n public bodyA!: PhysicsBody;\n public bodyB!: PhysicsBody;\n public normalX = 0;\n public normalY = 0;\n public pointCount = 0;\n public maxPenetration = 0;\n public enabled = true;\n public friction = 0;\n public restitution = 0;\n\n /** Point this context at `record` and load its current per-step values. */\n public bind(record: ContactRecord): void {\n const manifold = record.manifold;\n\n this.colliderA = record.ownerA;\n this.colliderB = record.ownerB;\n this.bodyA = record.ownerA.body;\n this.bodyB = record.ownerB.body;\n this.normalX = manifold.normalX;\n this.normalY = manifold.normalY;\n this.pointCount = manifold.pointCount;\n\n let deepest = 0;\n\n for (let i = 0; i < manifold.pointCount; i++) {\n // i < pointCount <= 2, so the point exists.\n const penetration = (i === 0 ? manifold.points[0] : manifold.points[1]).penetration;\n\n deepest = penetration > deepest ? penetration : deepest;\n }\n\n this.maxPenetration = deepest;\n this.enabled = record.enabled;\n this.friction = record.friction;\n this.restitution = record.restitution;\n }\n\n /** Write the (possibly modified) controls back onto the bound record. */\n public flush(record: ContactRecord): void {\n record.enabled = this.enabled;\n record.friction = this.friction;\n record.restitution = this.restitution;\n }\n}\n"],"mappings":";;;;;;AAsEA,IAAa,gCAAb,MAA6E;CAC3E,AAAO;CACP,AAAO;CACP,AAAO;CACP,AAAO;CACP,AAAO,UAAU;CACjB,AAAO,UAAU;CACjB,AAAO,aAAa;CACpB,AAAO,iBAAiB;CACxB,AAAO,UAAU;CACjB,AAAO,WAAW;CAClB,AAAO,cAAc;;CAGrB,AAAO,KAAK,QAA6B;EACvC,MAAM,WAAW,OAAO;EAExB,KAAK,YAAY,OAAO;EACxB,KAAK,YAAY,OAAO;EACxB,KAAK,QAAQ,OAAO,OAAO;EAC3B,KAAK,QAAQ,OAAO,OAAO;EAC3B,KAAK,UAAU,SAAS;EACxB,KAAK,UAAU,SAAS;EACxB,KAAK,aAAa,SAAS;EAE3B,IAAI,UAAU;EAEd,KAAK,IAAI,IAAI,GAAG,IAAI,SAAS,YAAY,KAAK;GAE5C,MAAM,eAAe,MAAM,IAAI,SAAS,OAAO,KAAK,SAAS,OAAO,GAAE,CAAE;GAExE,UAAU,cAAc,UAAU,cAAc;EAClD;EAEA,KAAK,iBAAiB;EACtB,KAAK,UAAU,OAAO;EACtB,KAAK,WAAW,OAAO;EACvB,KAAK,cAAc,OAAO;CAC5B;;CAGA,AAAO,MAAM,QAA6B;EACxC,OAAO,UAAU,KAAK;EACtB,OAAO,WAAW,KAAK;EACvB,OAAO,cAAc,KAAK;CAC5B;AACF"}
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import type { PointLike } from '@codexo/exojs';
|
|
2
|
-
import { Vector } from '@codexo/exojs';
|
|
3
|
-
import { Collider, type ColliderOptions } from './Collider';
|
|
4
|
-
import type { Transform } from './math';
|
|
5
|
-
import type { BodyType } from './types';
|
|
6
|
-
/** Construction options for a body. */
|
|
7
|
-
export interface BodyOptions {
|
|
8
|
-
/** Simulation role. Default `'dynamic'`. */
|
|
9
|
-
type?: BodyType;
|
|
10
|
-
/** Initial world position. Default `(0, 0)`. */
|
|
11
|
-
position?: Readonly<PointLike>;
|
|
12
|
-
/** Initial rotation in radians. Default `0`. */
|
|
13
|
-
angle?: number;
|
|
14
|
-
/** Linear damping applied to the velocity each sub-step. Default `0`. */
|
|
15
|
-
linearDamping?: number;
|
|
16
|
-
/** Angular damping applied to the angular velocity each sub-step. Default `0`. */
|
|
17
|
-
angularDamping?: number;
|
|
18
|
-
/** Per-body multiplier on world gravity (e.g. `0` to ignore gravity). Default `1`. */
|
|
19
|
-
gravityScale?: number;
|
|
20
|
-
/** When `true`, the body never rotates under contacts (infinite rotational inertia). Default `false`. */
|
|
21
|
-
fixedRotation?: boolean;
|
|
22
|
-
/** When `true`, the body's colliders are shape-cast along each step's motion (CCD) so it cannot tunnel through thin geometry. Default `false`. */
|
|
23
|
-
isBullet?: boolean;
|
|
24
|
-
/** Colliders to attach up-front. Each may be a {@link Collider} instance or its {@link ColliderOptions}. */
|
|
25
|
-
colliders?: Array<Collider | ColliderOptions>;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Internal hook the world hands to each body so colliders can be id-allocated
|
|
29
|
-
* and registered without the body importing the concrete world class.
|
|
30
|
-
*/
|
|
31
|
-
export interface BodyOwner {
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* A rigid body: a world transform plus mass properties aggregated from its
|
|
35
|
-
* colliders. Dynamic bodies integrate under gravity, accumulated forces/torque
|
|
36
|
-
* and contact impulses each fixed sub-step; static bodies never move; kinematic
|
|
37
|
-
* bodies move by their velocity only and stay immovable under contacts. Drive a
|
|
38
|
-
* body with {@link applyForce}, {@link applyTorque} and {@link applyImpulse}, or
|
|
39
|
-
* set {@link linearVelocityX}/{@link linearVelocityY}/{@link angularVelocity}
|
|
40
|
-
* directly; reposition it (teleport, no velocity) with {@link setTransform}.
|
|
41
|
-
*/
|
|
42
|
-
export declare class PhysicsBody {
|
|
43
|
-
readonly type: BodyType;
|
|
44
|
-
/** Linear damping applied to the velocity each sub-step. */
|
|
45
|
-
linearDamping: number;
|
|
46
|
-
/** Angular damping applied to the angular velocity each sub-step. */
|
|
47
|
-
angularDamping: number;
|
|
48
|
-
/** Per-body multiplier on world gravity (e.g. `0` to ignore gravity). */
|
|
49
|
-
gravityScale: number;
|
|
50
|
-
/** When `true`, rotational inertia is treated as infinite. */
|
|
51
|
-
fixedRotation: boolean;
|
|
52
|
-
/** When `true`, the body's colliders are shape-cast along each step's motion (CCD) so it cannot tunnel through thin geometry. */
|
|
53
|
-
isBullet: boolean;
|
|
54
|
-
/** Total mass (0 for static/kinematic). */
|
|
55
|
-
mass: number;
|
|
56
|
-
/** Inverse mass (`0` = immovable). */
|
|
57
|
-
invMass: number;
|
|
58
|
-
/** Rotational inertia about the centre of mass (0 for static/kinematic or fixed rotation). */
|
|
59
|
-
inertia: number;
|
|
60
|
-
/** Inverse rotational inertia (`0` = no angular response). */
|
|
61
|
-
invInertia: number;
|
|
62
|
-
/** Linear velocity X in px/s. */
|
|
63
|
-
linearVelocityX: number;
|
|
64
|
-
/** Linear velocity Y in px/s. */
|
|
65
|
-
linearVelocityY: number;
|
|
66
|
-
/** Angular velocity in rad/s. */
|
|
67
|
-
angularVelocity: number;
|
|
68
|
-
/** When `false`, this body is never put to sleep. Default `true`. */
|
|
69
|
-
allowSleep: boolean;
|
|
70
|
-
private _forceX;
|
|
71
|
-
private _forceY;
|
|
72
|
-
private _torque;
|
|
73
|
-
private _sleeping;
|
|
74
|
-
private _id;
|
|
75
|
-
private _owner;
|
|
76
|
-
private _attached;
|
|
77
|
-
private readonly _transform;
|
|
78
|
-
private _previousX;
|
|
79
|
-
private _previousY;
|
|
80
|
-
private _previousAngle;
|
|
81
|
-
private readonly _colliders;
|
|
82
|
-
private _comX;
|
|
83
|
-
private _comY;
|
|
84
|
-
private _massReady;
|
|
85
|
-
private _destroyed;
|
|
86
|
-
constructor(options?: BodyOptions);
|
|
87
|
-
/** Stable id, assigned when the body joins a world via `world.add()`; `-1` until then. */
|
|
88
|
-
get id(): number;
|
|
89
|
-
/** `true` once the body has been added to a world (guards against double-add). */
|
|
90
|
-
get attached(): boolean;
|
|
91
|
-
/** World X. */
|
|
92
|
-
get x(): number;
|
|
93
|
-
/** World Y. */
|
|
94
|
-
get y(): number;
|
|
95
|
-
/** Rotation in radians. */
|
|
96
|
-
get angle(): number;
|
|
97
|
-
/**
|
|
98
|
-
* World X at the start of the most recent fixed step. With {@link x} it
|
|
99
|
-
* brackets the last step, which is what an interpolating presentation blends
|
|
100
|
-
* between; a teleport collapses it onto {@link x}. Never read by the solver.
|
|
101
|
-
*/
|
|
102
|
-
get previousX(): number;
|
|
103
|
-
/** World Y at the start of the most recent fixed step; see {@link previousX}. */
|
|
104
|
-
get previousY(): number;
|
|
105
|
-
/**
|
|
106
|
-
* Rotation in radians at the start of the most recent fixed step; see
|
|
107
|
-
* {@link previousX}. Body angles are continuous and unbounded, never wrapped
|
|
108
|
-
* to a range, so this and {@link angle} can be blended with a plain lerp.
|
|
109
|
-
*/
|
|
110
|
-
get previousAngle(): number;
|
|
111
|
-
/** A fresh `Vector` copy of the body's world position. */
|
|
112
|
-
get position(): Vector;
|
|
113
|
-
/** The body's world transform (read-only; mutate via {@link setTransform}). */
|
|
114
|
-
get transform(): Readonly<Transform>;
|
|
115
|
-
/** The body's colliders (read-only view). */
|
|
116
|
-
get colliders(): readonly Collider[];
|
|
117
|
-
/** Centre of mass in body-local space (relative to the body origin). */
|
|
118
|
-
get centerOfMassX(): number;
|
|
119
|
-
/** Centre of mass in body-local space (relative to the body origin). */
|
|
120
|
-
get centerOfMassY(): number;
|
|
121
|
-
/**
|
|
122
|
-
* `true` when the body is ready to simulate. Static/kinematic bodies are
|
|
123
|
-
* always ready (infinite-mass semantics); a dynamic body is ready only once
|
|
124
|
-
* it has at least one positive-density collider.
|
|
125
|
-
*/
|
|
126
|
-
get isMassReady(): boolean;
|
|
127
|
-
/** `true` after the owning world has destroyed this body. */
|
|
128
|
-
get destroyed(): boolean;
|
|
129
|
-
/** `true` when the body is asleep - skipped by the integrator and solver until woken. */
|
|
130
|
-
get isSleeping(): boolean;
|
|
131
|
-
/**
|
|
132
|
-
* Attach a collider to this body. Accepts a {@link Collider} instance or its
|
|
133
|
-
* {@link ColliderOptions} (a convenience that constructs the collider for you).
|
|
134
|
-
* When the body is already in a world, the collider is id-allocated, registered,
|
|
135
|
-
* the mass model is recomputed and the world geometry synchronised immediately;
|
|
136
|
-
* on a free-standing body the collider is simply held until `world.add()`.
|
|
137
|
-
* Returns the collider.
|
|
138
|
-
*/
|
|
139
|
-
addCollider(collider: Collider | ColliderOptions): Collider;
|
|
140
|
-
/**
|
|
141
|
-
* Set the body's world transform. Resets the body's cached collider geometry
|
|
142
|
-
* immediately so subsequent queries see the new placement. Returns `this`.
|
|
143
|
-
*/
|
|
144
|
-
setTransform(position: Readonly<PointLike>, angle?: number): this;
|
|
145
|
-
/** Refresh every collider's world geometry from the current transform. */
|
|
146
|
-
synchronizeColliders(): void;
|
|
147
|
-
/** World-space centre of mass X (body origin + rotated local centre of mass). */
|
|
148
|
-
get worldCenterOfMassX(): number;
|
|
149
|
-
/** World-space centre of mass Y. */
|
|
150
|
-
get worldCenterOfMassY(): number;
|
|
151
|
-
/**
|
|
152
|
-
* Accumulate a world-space force at the centre of mass; integrated on the next
|
|
153
|
-
* sub-step and then cleared. No-op on static/kinematic bodies. Returns `this`.
|
|
154
|
-
*/
|
|
155
|
-
applyForce(forceX: number, forceY: number): this;
|
|
156
|
-
/**
|
|
157
|
-
* Accumulate a torque; integrated on the next sub-step and then cleared. No-op
|
|
158
|
-
* on static/kinematic bodies (and fixed-rotation bodies). Returns `this`.
|
|
159
|
-
*/
|
|
160
|
-
applyTorque(torque: number): this;
|
|
161
|
-
/**
|
|
162
|
-
* Apply an instantaneous world-space impulse at `(pointX, pointY)` (world space;
|
|
163
|
-
* defaults to the centre of mass), changing velocity immediately. No-op on
|
|
164
|
-
* static/kinematic bodies (infinite mass). Returns `this`.
|
|
165
|
-
*/
|
|
166
|
-
applyImpulse(impulseX: number, impulseY: number, pointX?: number, pointY?: number): this;
|
|
167
|
-
/**
|
|
168
|
-
* Wake the body if it is asleep, resetting its sleep timer. The rest of its
|
|
169
|
-
* island wakes with it on the next step (a contact to an awake body keeps the
|
|
170
|
-
* whole island awake). Returns `this`.
|
|
171
|
-
*/
|
|
172
|
-
wake(): this;
|
|
173
|
-
/** Clear the per-frame TGS delta accumulators (position, rotation and its cached cos/sin). */
|
|
174
|
-
private _resetDelta;
|
|
175
|
-
/**
|
|
176
|
-
* A dynamic body has to carry mass. Boundary geometry (a segment, a chain)
|
|
177
|
-
* reports no mass properties, and a collider may also be given zero density,
|
|
178
|
-
* so a dynamic body can end up with none at all - which the solver cannot tell
|
|
179
|
-
* apart from a static body, since both have `invMass === 0`. Rejecting it is
|
|
180
|
-
* the difference between a clear error and a body that silently stops moving.
|
|
181
|
-
*/
|
|
182
|
-
private _assertDynamicCarriesMass;
|
|
183
|
-
/** Recompute mass, centre of mass and rotational inertia from the colliders. */
|
|
184
|
-
private _recomputeMass;
|
|
185
|
-
}
|
|
186
|
-
//# sourceMappingURL=PhysicsBody.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PhysicsBody.d.ts","sourceRoot":"","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