@certe/atmos-physics 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/LICENCE +674 -0
- package/README.md +152 -0
- package/dist/collider-offset.d.ts +19 -0
- package/dist/collider-offset.d.ts.map +1 -0
- package/dist/collider-offset.js +33 -0
- package/dist/collider-offset.js.map +1 -0
- package/dist/collider.d.ts +75 -0
- package/dist/collider.d.ts.map +1 -0
- package/dist/collider.js +223 -0
- package/dist/collider.js.map +1 -0
- package/dist/fixed-joint.d.ts +8 -0
- package/dist/fixed-joint.d.ts.map +1 -0
- package/dist/fixed-joint.js +10 -0
- package/dist/fixed-joint.js.map +1 -0
- package/dist/hinge-joint.d.ts +78 -0
- package/dist/hinge-joint.d.ts.map +1 -0
- package/dist/hinge-joint.js +271 -0
- package/dist/hinge-joint.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/init.d.ts +8 -0
- package/dist/init.d.ts.map +1 -0
- package/dist/init.js +98 -0
- package/dist/init.js.map +1 -0
- package/dist/joint.d.ts +52 -0
- package/dist/joint.d.ts.map +1 -0
- package/dist/joint.js +143 -0
- package/dist/joint.js.map +1 -0
- package/dist/physics-hierarchy.d.ts +8 -0
- package/dist/physics-hierarchy.d.ts.map +1 -0
- package/dist/physics-hierarchy.js +32 -0
- package/dist/physics-hierarchy.js.map +1 -0
- package/dist/physics-query.d.ts +30 -0
- package/dist/physics-query.d.ts.map +1 -0
- package/dist/physics-query.js +139 -0
- package/dist/physics-query.js.map +1 -0
- package/dist/physics-system.d.ts +17 -0
- package/dist/physics-system.d.ts.map +1 -0
- package/dist/physics-system.js +133 -0
- package/dist/physics-system.js.map +1 -0
- package/dist/physics-world.d.ts +33 -0
- package/dist/physics-world.d.ts.map +1 -0
- package/dist/physics-world.js +65 -0
- package/dist/physics-world.js.map +1 -0
- package/dist/register-builtins.d.ts +2 -0
- package/dist/register-builtins.d.ts.map +1 -0
- package/dist/register-builtins.js +84 -0
- package/dist/register-builtins.js.map +1 -0
- package/dist/rigid-body.d.ts +42 -0
- package/dist/rigid-body.d.ts.map +1 -0
- package/dist/rigid-body.js +189 -0
- package/dist/rigid-body.js.map +1 -0
- package/dist/spring-joint.d.ts +23 -0
- package/dist/spring-joint.d.ts.map +1 -0
- package/dist/spring-joint.js +26 -0
- package/dist/spring-joint.js.map +1 -0
- package/package.json +29 -0
- package/src/index.ts +26 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import RAPIER from '@dimforge/rapier3d-compat';
|
|
2
|
+
export class PhysicsWorld {
|
|
3
|
+
world;
|
|
4
|
+
fixedTimestep;
|
|
5
|
+
substeps = 1;
|
|
6
|
+
_accumulator = 0;
|
|
7
|
+
/** Time remaining after the last fixed step (for interpolation/extrapolation). */
|
|
8
|
+
get accumulator() { return this._accumulator; }
|
|
9
|
+
constructor(options = {}) {
|
|
10
|
+
const g = options.gravity ?? { x: 0, y: -9.81, z: 0 };
|
|
11
|
+
this.fixedTimestep = options.fixedTimestep ?? 1 / 60;
|
|
12
|
+
this.world = new RAPIER.World(new RAPIER.Vector3(g.x, g.y, g.z));
|
|
13
|
+
if (options.solverIterations !== undefined) {
|
|
14
|
+
this.world.numSolverIterations = options.solverIterations;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
setGravity(x, y, z) {
|
|
18
|
+
this.world.gravity = new RAPIER.Vector3(x, y, z);
|
|
19
|
+
}
|
|
20
|
+
setSolverIterations(n) {
|
|
21
|
+
this.world.numSolverIterations = n;
|
|
22
|
+
}
|
|
23
|
+
/** Advance the simulation by dt seconds using fixed timestep accumulator. Returns steps taken. */
|
|
24
|
+
step(dt) {
|
|
25
|
+
this._accumulator += dt;
|
|
26
|
+
let steps = 0;
|
|
27
|
+
const sub = Math.max(1, this.substeps);
|
|
28
|
+
while (this._accumulator >= this.fixedTimestep) {
|
|
29
|
+
const subDt = this.fixedTimestep / sub;
|
|
30
|
+
for (let s = 0; s < sub; s++) {
|
|
31
|
+
this.world.timestep = subDt;
|
|
32
|
+
this.world.step();
|
|
33
|
+
}
|
|
34
|
+
this._accumulator -= this.fixedTimestep;
|
|
35
|
+
steps++;
|
|
36
|
+
}
|
|
37
|
+
return steps;
|
|
38
|
+
}
|
|
39
|
+
createRigidBody(desc) {
|
|
40
|
+
return this.world.createRigidBody(desc);
|
|
41
|
+
}
|
|
42
|
+
createCollider(desc, body) {
|
|
43
|
+
return this.world.createCollider(desc, body);
|
|
44
|
+
}
|
|
45
|
+
removeRigidBody(body) {
|
|
46
|
+
this.world.removeRigidBody(body);
|
|
47
|
+
}
|
|
48
|
+
removeCollider(collider) {
|
|
49
|
+
this.world.removeCollider(collider, true);
|
|
50
|
+
}
|
|
51
|
+
createJoint(data, body1, body2) {
|
|
52
|
+
return this.world.createImpulseJoint(data, body1, body2, true);
|
|
53
|
+
}
|
|
54
|
+
removeJoint(joint) {
|
|
55
|
+
this.world.removeImpulseJoint(joint, true);
|
|
56
|
+
}
|
|
57
|
+
/** Reset the fixed-timestep accumulator (e.g. after pause→play). */
|
|
58
|
+
resetAccumulator() {
|
|
59
|
+
this._accumulator = 0;
|
|
60
|
+
}
|
|
61
|
+
destroy() {
|
|
62
|
+
this.world.free();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=physics-world.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"physics-world.js","sourceRoot":"","sources":["../src/physics-world.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,2BAA2B,CAAC;AAQ/C,MAAM,OAAO,YAAY;IACd,KAAK,CAAe;IAC7B,aAAa,CAAS;IACtB,QAAQ,GAAG,CAAC,CAAC;IACL,YAAY,GAAG,CAAC,CAAC;IAEzB,kFAAkF;IAClF,IAAI,WAAW,KAAa,OAAO,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;IAEvD,YAA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names":[],"mappings":"AAOA,wBAAgB,uBAAuB,IAAI,IAAI,CAgF9C"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { registerComponent } from '@certe/atmos-core';
|
|
2
|
+
import { RigidBody } from './rigid-body.js';
|
|
3
|
+
import { Collider } from './collider.js';
|
|
4
|
+
import { FixedJoint } from './fixed-joint.js';
|
|
5
|
+
import { HingeJoint } from './hinge-joint.js';
|
|
6
|
+
import { SpringJoint } from './spring-joint.js';
|
|
7
|
+
export function registerPhysicsBuiltins() {
|
|
8
|
+
registerComponent(RigidBody, {
|
|
9
|
+
name: 'RigidBody',
|
|
10
|
+
properties: [
|
|
11
|
+
{ key: 'bodyType', type: 'enum', options: ['dynamic', 'fixed', 'kinematic'] },
|
|
12
|
+
{ key: 'linearDamping', type: 'number', min: 0, max: 100, step: 0.1 },
|
|
13
|
+
{ key: 'angularDamping', type: 'number', min: 0, max: 100, step: 0.1 },
|
|
14
|
+
{ key: 'gravityScale', type: 'number', min: -10, max: 10, step: 0.1 },
|
|
15
|
+
{ key: 'interpolate', type: 'boolean' },
|
|
16
|
+
],
|
|
17
|
+
});
|
|
18
|
+
registerComponent(Collider, {
|
|
19
|
+
name: 'Collider',
|
|
20
|
+
properties: [
|
|
21
|
+
{ key: 'friction', type: 'number', min: 0, max: 2, step: 0.05 },
|
|
22
|
+
{ key: 'restitution', type: 'number', min: 0, max: 1, step: 0.05 },
|
|
23
|
+
{ key: 'density', type: 'number', min: 0.01, max: 100, step: 0.1 },
|
|
24
|
+
{ key: 'isSensor', type: 'boolean' },
|
|
25
|
+
],
|
|
26
|
+
});
|
|
27
|
+
registerComponent(FixedJoint, {
|
|
28
|
+
name: 'FixedJoint',
|
|
29
|
+
allowMultiple: true,
|
|
30
|
+
properties: [
|
|
31
|
+
{ key: 'connectedObject', type: 'gameObjectRef' },
|
|
32
|
+
{ key: 'anchor', type: 'vec3' },
|
|
33
|
+
{ key: 'autoConfigureConnectedAnchor', type: 'boolean' },
|
|
34
|
+
{ key: 'connectedAnchor', type: 'vec3',
|
|
35
|
+
visibleWhen: (c) => !c.autoConfigureConnectedAnchor },
|
|
36
|
+
],
|
|
37
|
+
});
|
|
38
|
+
registerComponent(HingeJoint, {
|
|
39
|
+
name: 'HingeJoint',
|
|
40
|
+
allowMultiple: true,
|
|
41
|
+
properties: [
|
|
42
|
+
{ key: 'connectedObject', type: 'gameObjectRef' },
|
|
43
|
+
{ key: 'anchor', type: 'vec3' },
|
|
44
|
+
{ key: 'autoConfigureConnectedAnchor', type: 'boolean' },
|
|
45
|
+
{ key: 'connectedAnchor', type: 'vec3',
|
|
46
|
+
visibleWhen: (c) => !c.autoConfigureConnectedAnchor },
|
|
47
|
+
{ key: 'axis', type: 'vec3' },
|
|
48
|
+
{ key: 'connectedAxis', type: 'vec3',
|
|
49
|
+
visibleWhen: (c) => !c.autoConfigureConnectedAxis },
|
|
50
|
+
{ key: 'autoConfigureConnectedAxis', type: 'boolean' },
|
|
51
|
+
{ key: 'limitsEnabled', type: 'boolean' },
|
|
52
|
+
{ key: 'limitMin', type: 'number', min: -Math.PI, max: 0, step: 0.01 },
|
|
53
|
+
{ key: 'limitMax', type: 'number', min: 0, max: Math.PI, step: 0.01 },
|
|
54
|
+
{ key: 'motorEnabled', type: 'boolean' },
|
|
55
|
+
{ key: 'motorMode', type: 'enum', options: ['velocity', 'position'],
|
|
56
|
+
visibleWhen: (c) => c.motorEnabled },
|
|
57
|
+
{ key: 'motorTargetVelocity', type: 'number', min: -100, max: 100, step: 0.1,
|
|
58
|
+
visibleWhen: (c) => c.motorEnabled && c.motorMode === 'velocity' },
|
|
59
|
+
{ key: 'motorMaxForce', type: 'number', min: 0, max: 10000, step: 1,
|
|
60
|
+
visibleWhen: (c) => c.motorEnabled && c.motorMode === 'velocity' },
|
|
61
|
+
{ key: 'motorTargetPosition', type: 'number', min: -Math.PI, max: Math.PI, step: 0.01,
|
|
62
|
+
visibleWhen: (c) => c.motorEnabled && c.motorMode === 'position' },
|
|
63
|
+
{ key: 'motorStiffness', type: 'number', min: 0, max: 10000, step: 1,
|
|
64
|
+
visibleWhen: (c) => c.motorEnabled && c.motorMode === 'position' },
|
|
65
|
+
{ key: 'motorDamping', type: 'number', min: 0, max: 1000, step: 0.1,
|
|
66
|
+
visibleWhen: (c) => c.motorEnabled && c.motorMode === 'position' },
|
|
67
|
+
],
|
|
68
|
+
});
|
|
69
|
+
registerComponent(SpringJoint, {
|
|
70
|
+
name: 'SpringJoint',
|
|
71
|
+
allowMultiple: true,
|
|
72
|
+
properties: [
|
|
73
|
+
{ key: 'connectedObject', type: 'gameObjectRef' },
|
|
74
|
+
{ key: 'anchor', type: 'vec3' },
|
|
75
|
+
{ key: 'autoConfigureConnectedAnchor', type: 'boolean' },
|
|
76
|
+
{ key: 'connectedAnchor', type: 'vec3',
|
|
77
|
+
visibleWhen: (c) => !c.autoConfigureConnectedAnchor },
|
|
78
|
+
{ key: 'restLength', type: 'number', min: 0, max: 100, step: 0.1 },
|
|
79
|
+
{ key: 'stiffness', type: 'number', min: 0, max: 1000, step: 1 },
|
|
80
|
+
{ key: 'damping', type: 'number', min: 0, max: 100, step: 0.1 },
|
|
81
|
+
],
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=register-builtins.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register-builtins.js","sourceRoot":"","sources":["../src/register-builtins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,UAAU,uBAAuB;IAC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EAAE;YAChE,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE;SAChE;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import RAPIER from '@dimforge/rapier3d-compat';
|
|
2
|
+
import { Component } from '@certe/atmos-core';
|
|
3
|
+
import type { PhysicsWorld } from './physics-world.js';
|
|
4
|
+
export type RigidBodyType = 'dynamic' | 'fixed' | 'kinematic';
|
|
5
|
+
export interface RigidBodyOptions {
|
|
6
|
+
type?: RigidBodyType;
|
|
7
|
+
mass?: number;
|
|
8
|
+
linearDamping?: number;
|
|
9
|
+
angularDamping?: number;
|
|
10
|
+
gravityScale?: number;
|
|
11
|
+
}
|
|
12
|
+
export declare class RigidBody extends Component {
|
|
13
|
+
body: RAPIER.RigidBody | null;
|
|
14
|
+
bodyType: RigidBodyType;
|
|
15
|
+
private _world;
|
|
16
|
+
private _linearDamping;
|
|
17
|
+
private _angularDamping;
|
|
18
|
+
private _gravityScale;
|
|
19
|
+
/** When true, Transform is extrapolated between physics steps to reduce jitter. */
|
|
20
|
+
interpolate: boolean;
|
|
21
|
+
get linearDamping(): number;
|
|
22
|
+
set linearDamping(v: number);
|
|
23
|
+
get angularDamping(): number;
|
|
24
|
+
set angularDamping(v: number);
|
|
25
|
+
get gravityScale(): number;
|
|
26
|
+
set gravityScale(v: number);
|
|
27
|
+
init(world: PhysicsWorld, options?: RigidBodyOptions): void;
|
|
28
|
+
/** Copy Rapier body transform → engine Transform (for dynamic bodies) */
|
|
29
|
+
syncToTransform(): void;
|
|
30
|
+
/** Extrapolate Transform using Rapier body position + velocity * dt. */
|
|
31
|
+
extrapolateTransform(dt: number): void;
|
|
32
|
+
/** Copy engine Transform → Rapier body (for kinematic bodies) */
|
|
33
|
+
syncFromTransform(): void;
|
|
34
|
+
/** Teleport Rapier body to match engine Transform (for external edits on dynamic bodies) */
|
|
35
|
+
teleportToTransform(): void;
|
|
36
|
+
addForce(x: number, y: number, z: number): void;
|
|
37
|
+
addImpulse(x: number, y: number, z: number): void;
|
|
38
|
+
onDestroy(): void;
|
|
39
|
+
/** Walk descendants and null out collider handles that reference this body. */
|
|
40
|
+
private _invalidateChildColliders;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=rigid-body.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rigid-body.d.ts","sourceRoot":"","sources":["../src/rigid-body.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,2BAA2B,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,OAAO,GAAG,WAAW,CAAC;AAE9D,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAOD,qBAAa,SAAU,SAAQ,SAAS;IACtC,IAAI,EAAE,MAAM,CAAC,SAAS,GAAG,IAAI,CAAQ;IACrC,QAAQ,EAAE,aAAa,CAAa;IAEpC,OAAO,CAAC,MAAM,CAA6B;IAC3C,OAAO,CAAC,cAAc,CAAK;IAC3B,OAAO,CAAC,eAAe,CAAK;IAC5B,OAAO,CAAC,aAAa,CAAK;IAE1B,mFAAmF;IACnF,WAAW,UAAS;IAEpB,IAAI,aAAa,IAAI,MAAM,CAAgC;IAC3D,IAAI,aAAa,CAAC,CAAC,EAAE,MAAM,EAG1B;IAED,IAAI,cAAc,IAAI,MAAM,CAAiC;IAC7D,IAAI,cAAc,CAAC,CAAC,EAAE,MAAM,EAG3B;IAED,IAAI,YAAY,IAAI,MAAM,CAA+B;IACzD,IAAI,YAAY,CAAC,CAAC,EAAE,MAAM,EAGzB;IAED,IAAI,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,GAAE,gBAAqB,GAAG,IAAI;IA4C/D,yEAAyE;IACzE,eAAe,IAAI,IAAI;IAUvB,wEAAwE;IACxE,oBAAoB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IA4BtC,iEAAiE;IACjE,iBAAiB,IAAI,IAAI;IAUzB,4FAA4F;IAC5F,mBAAmB,IAAI,IAAI;IAc3B,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI;IAM/C,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI;IAMjD,SAAS,IAAI,IAAI;IAUjB,+EAA+E;IAC/E,OAAO,CAAC,yBAAyB;CAYlC"}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import RAPIER from '@dimforge/rapier3d-compat';
|
|
2
|
+
import { Component } from '@certe/atmos-core';
|
|
3
|
+
// Scratch Rapier objects (reused to avoid GC pressure in hot paths)
|
|
4
|
+
const _rVec3 = new RAPIER.Vector3(0, 0, 0);
|
|
5
|
+
const _rQuat = new RAPIER.Quaternion(0, 0, 0, 1);
|
|
6
|
+
const _rZero = new RAPIER.Vector3(0, 0, 0);
|
|
7
|
+
export class RigidBody extends Component {
|
|
8
|
+
body = null;
|
|
9
|
+
bodyType = 'dynamic';
|
|
10
|
+
_world = null;
|
|
11
|
+
_linearDamping = 0;
|
|
12
|
+
_angularDamping = 0;
|
|
13
|
+
_gravityScale = 1;
|
|
14
|
+
/** When true, Transform is extrapolated between physics steps to reduce jitter. */
|
|
15
|
+
interpolate = false;
|
|
16
|
+
get linearDamping() { return this._linearDamping; }
|
|
17
|
+
set linearDamping(v) {
|
|
18
|
+
this._linearDamping = v;
|
|
19
|
+
if (this.body)
|
|
20
|
+
this.body.setLinearDamping(v);
|
|
21
|
+
}
|
|
22
|
+
get angularDamping() { return this._angularDamping; }
|
|
23
|
+
set angularDamping(v) {
|
|
24
|
+
this._angularDamping = v;
|
|
25
|
+
if (this.body)
|
|
26
|
+
this.body.setAngularDamping(v);
|
|
27
|
+
}
|
|
28
|
+
get gravityScale() { return this._gravityScale; }
|
|
29
|
+
set gravityScale(v) {
|
|
30
|
+
this._gravityScale = v;
|
|
31
|
+
if (this.body)
|
|
32
|
+
this.body.setGravityScale(v, true);
|
|
33
|
+
}
|
|
34
|
+
init(world, options = {}) {
|
|
35
|
+
this._world = world;
|
|
36
|
+
this.bodyType = options.type ?? 'dynamic';
|
|
37
|
+
const t = this.gameObject.transform;
|
|
38
|
+
const pos = t.position;
|
|
39
|
+
const rot = t.rotation;
|
|
40
|
+
let desc;
|
|
41
|
+
switch (this.bodyType) {
|
|
42
|
+
case 'dynamic':
|
|
43
|
+
desc = RAPIER.RigidBodyDesc.dynamic();
|
|
44
|
+
break;
|
|
45
|
+
case 'fixed':
|
|
46
|
+
desc = RAPIER.RigidBodyDesc.fixed();
|
|
47
|
+
break;
|
|
48
|
+
case 'kinematic':
|
|
49
|
+
desc = RAPIER.RigidBodyDesc.kinematicPositionBased();
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
desc.setTranslation(pos[0], pos[1], pos[2]);
|
|
53
|
+
desc.setRotation({ x: rot[0], y: rot[1], z: rot[2], w: rot[3] });
|
|
54
|
+
if (options.linearDamping !== undefined) {
|
|
55
|
+
this._linearDamping = options.linearDamping;
|
|
56
|
+
desc.setLinearDamping(options.linearDamping);
|
|
57
|
+
}
|
|
58
|
+
if (options.angularDamping !== undefined) {
|
|
59
|
+
this._angularDamping = options.angularDamping;
|
|
60
|
+
desc.setAngularDamping(options.angularDamping);
|
|
61
|
+
}
|
|
62
|
+
if (options.gravityScale !== undefined) {
|
|
63
|
+
this._gravityScale = options.gravityScale;
|
|
64
|
+
desc.setGravityScale(options.gravityScale);
|
|
65
|
+
}
|
|
66
|
+
this.body = world.createRigidBody(desc);
|
|
67
|
+
if (options.mass !== undefined && this.bodyType === 'dynamic') {
|
|
68
|
+
this.body.setAdditionalMass(options.mass, true);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/** Copy Rapier body transform → engine Transform (for dynamic bodies) */
|
|
72
|
+
syncToTransform() {
|
|
73
|
+
if (!this.body)
|
|
74
|
+
return;
|
|
75
|
+
const t = this.gameObject.transform;
|
|
76
|
+
const pos = this.body.translation();
|
|
77
|
+
t.setPosition(pos.x, pos.y, pos.z);
|
|
78
|
+
const rot = this.body.rotation();
|
|
79
|
+
t.setRotation(rot.x, rot.y, rot.z, rot.w);
|
|
80
|
+
}
|
|
81
|
+
/** Extrapolate Transform using Rapier body position + velocity * dt. */
|
|
82
|
+
extrapolateTransform(dt) {
|
|
83
|
+
if (!this.body)
|
|
84
|
+
return;
|
|
85
|
+
const t = this.gameObject.transform;
|
|
86
|
+
const pos = this.body.translation();
|
|
87
|
+
const lv = this.body.linvel();
|
|
88
|
+
t.setPosition(pos.x + lv.x * dt, pos.y + lv.y * dt, pos.z + lv.z * dt);
|
|
89
|
+
const rot = this.body.rotation();
|
|
90
|
+
const av = this.body.angvel();
|
|
91
|
+
// Apply angular velocity as small rotation: q' = q + 0.5 * [av, 0] * q * dt
|
|
92
|
+
const hdt = 0.5 * dt;
|
|
93
|
+
const dqx = (av.x * rot.w + av.y * rot.z - av.z * rot.y) * hdt;
|
|
94
|
+
const dqy = (-av.x * rot.z + av.y * rot.w + av.z * rot.x) * hdt;
|
|
95
|
+
const dqz = (av.x * rot.y - av.y * rot.x + av.z * rot.w) * hdt;
|
|
96
|
+
const dqw = (-av.x * rot.x - av.y * rot.y - av.z * rot.z) * hdt;
|
|
97
|
+
let rx = rot.x + dqx;
|
|
98
|
+
let ry = rot.y + dqy;
|
|
99
|
+
let rz = rot.z + dqz;
|
|
100
|
+
let rw = rot.w + dqw;
|
|
101
|
+
// Renormalize
|
|
102
|
+
const len = Math.sqrt(rx * rx + ry * ry + rz * rz + rw * rw);
|
|
103
|
+
if (len > 1e-8) {
|
|
104
|
+
const inv = 1 / len;
|
|
105
|
+
rx *= inv;
|
|
106
|
+
ry *= inv;
|
|
107
|
+
rz *= inv;
|
|
108
|
+
rw *= inv;
|
|
109
|
+
}
|
|
110
|
+
t.setRotation(rx, ry, rz, rw);
|
|
111
|
+
}
|
|
112
|
+
/** Copy engine Transform → Rapier body (for kinematic bodies) */
|
|
113
|
+
syncFromTransform() {
|
|
114
|
+
if (!this.body)
|
|
115
|
+
return;
|
|
116
|
+
const pos = this.gameObject.transform.position;
|
|
117
|
+
const rot = this.gameObject.transform.rotation;
|
|
118
|
+
_rVec3.x = pos[0];
|
|
119
|
+
_rVec3.y = pos[1];
|
|
120
|
+
_rVec3.z = pos[2];
|
|
121
|
+
this.body.setNextKinematicTranslation(_rVec3);
|
|
122
|
+
_rQuat.x = rot[0];
|
|
123
|
+
_rQuat.y = rot[1];
|
|
124
|
+
_rQuat.z = rot[2];
|
|
125
|
+
_rQuat.w = rot[3];
|
|
126
|
+
this.body.setNextKinematicRotation(_rQuat);
|
|
127
|
+
}
|
|
128
|
+
/** Teleport Rapier body to match engine Transform (for external edits on dynamic bodies) */
|
|
129
|
+
teleportToTransform() {
|
|
130
|
+
if (!this.body)
|
|
131
|
+
return;
|
|
132
|
+
const pos = this.gameObject.transform.position;
|
|
133
|
+
const rot = this.gameObject.transform.rotation;
|
|
134
|
+
_rVec3.x = pos[0];
|
|
135
|
+
_rVec3.y = pos[1];
|
|
136
|
+
_rVec3.z = pos[2];
|
|
137
|
+
this.body.setTranslation(_rVec3, true);
|
|
138
|
+
_rQuat.x = rot[0];
|
|
139
|
+
_rQuat.y = rot[1];
|
|
140
|
+
_rQuat.z = rot[2];
|
|
141
|
+
_rQuat.w = rot[3];
|
|
142
|
+
this.body.setRotation(_rQuat, true);
|
|
143
|
+
_rZero.x = 0;
|
|
144
|
+
_rZero.y = 0;
|
|
145
|
+
_rZero.z = 0;
|
|
146
|
+
this.body.setLinvel(_rZero, true);
|
|
147
|
+
this.body.setAngvel(_rZero, true);
|
|
148
|
+
this.body.wakeUp();
|
|
149
|
+
}
|
|
150
|
+
addForce(x, y, z) {
|
|
151
|
+
if (!this.body)
|
|
152
|
+
return;
|
|
153
|
+
_rVec3.x = x;
|
|
154
|
+
_rVec3.y = y;
|
|
155
|
+
_rVec3.z = z;
|
|
156
|
+
this.body.addForce(_rVec3, true);
|
|
157
|
+
}
|
|
158
|
+
addImpulse(x, y, z) {
|
|
159
|
+
if (!this.body)
|
|
160
|
+
return;
|
|
161
|
+
_rVec3.x = x;
|
|
162
|
+
_rVec3.y = y;
|
|
163
|
+
_rVec3.z = z;
|
|
164
|
+
this.body.applyImpulse(_rVec3, true);
|
|
165
|
+
}
|
|
166
|
+
onDestroy() {
|
|
167
|
+
if (this.body && this._world) {
|
|
168
|
+
// Nullify descendant collider handles before body removal
|
|
169
|
+
// (Rapier auto-removes attached colliders when a body is removed)
|
|
170
|
+
this._invalidateChildColliders(this.gameObject);
|
|
171
|
+
this._world.removeRigidBody(this.body);
|
|
172
|
+
this.body = null;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
/** Walk descendants and null out collider handles that reference this body. */
|
|
176
|
+
_invalidateChildColliders(go) {
|
|
177
|
+
for (const comp of go.getComponents()) {
|
|
178
|
+
// Duck-type: any component with collider + attachedBody pointing to this RB
|
|
179
|
+
const c = comp;
|
|
180
|
+
if ('collider' in c && 'attachedBody' in c && c['attachedBody'] === this) {
|
|
181
|
+
c['collider'] = null;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
for (const child of go.children) {
|
|
185
|
+
this._invalidateChildColliders(child);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
//# sourceMappingURL=rigid-body.js.map
|
|
@@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IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAC7B,0DAA0D;YAC1D,kEAAkE;YAClE,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAChD,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACvC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACnB,CAAC;IACH,CAAC;IAED,+EAA+E;IACvE,yBAAyB,CAAC,EAAc;QAC9C,KAAK,MAAM,IAAI,IAAI,EAAE,CAAC,aAAa,EAAE,EAAE,CAAC;YACtC,4EAA4E;YAC5E,MAAM,CAAC,GAAG,IAA0C,CAAC;YACrD,IAAI,UAAU,IAAI,CAAC,IAAI,cAAc,IAAI,CAAC,IAAI,CAAC,CAAC,cAAc,CAAC,KAAK,IAAI,EAAE,CAAC;gBACzE,CAAC,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;YACvB,CAAC;QACH,CAAC;QACD,KAAK,MAAM,KAAK,IAAI,EAAE,CAAC,QAAQ,EAAE,CAAC;YAChC,IAAI,CAAC,yBAAyB,CAAC,KAAK,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import RAPIER from '@dimforge/rapier3d-compat';
|
|
2
|
+
import { Joint } from './joint.js';
|
|
3
|
+
import type { JointOptions } from './joint.js';
|
|
4
|
+
import type { PhysicsWorld } from './physics-world.js';
|
|
5
|
+
export interface SpringJointOptions extends JointOptions {
|
|
6
|
+
restLength?: number;
|
|
7
|
+
stiffness?: number;
|
|
8
|
+
damping?: number;
|
|
9
|
+
}
|
|
10
|
+
export declare class SpringJoint extends Joint {
|
|
11
|
+
private _restLength;
|
|
12
|
+
private _stiffness;
|
|
13
|
+
private _damping;
|
|
14
|
+
get restLength(): number;
|
|
15
|
+
set restLength(v: number);
|
|
16
|
+
get stiffness(): number;
|
|
17
|
+
set stiffness(v: number);
|
|
18
|
+
get damping(): number;
|
|
19
|
+
set damping(v: number);
|
|
20
|
+
init(world: PhysicsWorld, options?: SpringJointOptions): void;
|
|
21
|
+
protected _createJointData(): RAPIER.JointData;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=spring-joint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spring-joint.d.ts","sourceRoot":"","sources":["../src/spring-joint.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,2BAA2B,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,MAAM,WAAW,kBAAmB,SAAQ,YAAY;IACtD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,WAAY,SAAQ,KAAK;IACpC,OAAO,CAAC,WAAW,CAAO;IAC1B,OAAO,CAAC,UAAU,CAAQ;IAC1B,OAAO,CAAC,QAAQ,CAAO;IAEvB,IAAI,UAAU,IAAI,MAAM,CAA6B;IACrD,IAAI,UAAU,CAAC,CAAC,EAAE,MAAM,EAAkD;IAE1E,IAAI,SAAS,IAAI,MAAM,CAA4B;IACnD,IAAI,SAAS,CAAC,CAAC,EAAE,MAAM,EAAiD;IAExE,IAAI,OAAO,IAAI,MAAM,CAA0B;IAC/C,IAAI,OAAO,CAAC,CAAC,EAAE,MAAM,EAA+C;IAEpE,IAAI,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,IAAI;IAO7D,SAAS,CAAC,gBAAgB,IAAI,MAAM,CAAC,SAAS;CAS/C"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import RAPIER from '@dimforge/rapier3d-compat';
|
|
2
|
+
import { Joint } from './joint.js';
|
|
3
|
+
export class SpringJoint extends Joint {
|
|
4
|
+
_restLength = 1.0;
|
|
5
|
+
_stiffness = 10.0;
|
|
6
|
+
_damping = 1.0;
|
|
7
|
+
get restLength() { return this._restLength; }
|
|
8
|
+
set restLength(v) { this._restLength = v; this._recreateJoint(); }
|
|
9
|
+
get stiffness() { return this._stiffness; }
|
|
10
|
+
set stiffness(v) { this._stiffness = v; this._recreateJoint(); }
|
|
11
|
+
get damping() { return this._damping; }
|
|
12
|
+
set damping(v) { this._damping = v; this._recreateJoint(); }
|
|
13
|
+
init(world, options) {
|
|
14
|
+
if (options?.restLength !== undefined)
|
|
15
|
+
this._restLength = options.restLength;
|
|
16
|
+
if (options?.stiffness !== undefined)
|
|
17
|
+
this._stiffness = options.stiffness;
|
|
18
|
+
if (options?.damping !== undefined)
|
|
19
|
+
this._damping = options.damping;
|
|
20
|
+
super.init(world, options);
|
|
21
|
+
}
|
|
22
|
+
_createJointData() {
|
|
23
|
+
return RAPIER.JointData.spring(this._restLength, this._stiffness, this._damping, this._toXYZ(this.anchor), this._toXYZ(this.connectedAnchor));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=spring-joint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spring-joint.js","sourceRoot":"","sources":["../src/spring-joint.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,2BAA2B,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAUnC,MAAM,OAAO,WAAY,SAAQ,KAAK;IAC5B,WAAW,GAAG,GAAG,CAAC;IAClB,UAAU,GAAG,IAAI,CAAC;IAClB,QAAQ,GAAG,GAAG,CAAC;IAEvB,IAAI,UAAU,KAAa,OAAO,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;IACrD,IAAI,UAAU,CAAC,CAAS,IAAI,IAAI,CAAC,WAAW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for the Atmos Engine — rigid bodies, colliders, joints",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/certesolutions-cyber/atmos.git",
|
|
8
|
+
"directory": "packages/physics"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/certesolutions-cyber/atmos",
|
|
11
|
+
"license": "GPL-3.0-or-later",
|
|
12
|
+
"keywords": ["physics", "rapier", "game-engine", "rigid-body", "collider", "atmos"],
|
|
13
|
+
"type": "module",
|
|
14
|
+
"main": "src/index.ts",
|
|
15
|
+
"types": "src/index.ts",
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"main": "dist/index.js",
|
|
18
|
+
"types": "dist/index.d.ts"
|
|
19
|
+
},
|
|
20
|
+
"files": ["dist", "!dist/__tests__", "package.json", "README.md", "LICENCE"],
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@certe/atmos-core": "^0.1.0",
|
|
23
|
+
"@certe/atmos-math": "^0.1.0",
|
|
24
|
+
"@dimforge/rapier3d-compat": "^0.14.0"
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"test": "vitest run"
|
|
28
|
+
}
|
|
29
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export { initRapier, getWasmMemory, getLockedAxesOffset } from './init.js';
|
|
2
|
+
export { PhysicsWorld } from './physics-world.js';
|
|
3
|
+
export type { PhysicsWorldOptions } from './physics-world.js';
|
|
4
|
+
export { RigidBody } from './rigid-body.js';
|
|
5
|
+
export type { RigidBodyType, RigidBodyOptions } from './rigid-body.js';
|
|
6
|
+
export { Collider } from './collider.js';
|
|
7
|
+
export type { ColliderShape, ColliderOptions } from './collider.js';
|
|
8
|
+
export { Joint } from './joint.js';
|
|
9
|
+
export type { JointOptions } from './joint.js';
|
|
10
|
+
export { FixedJoint } from './fixed-joint.js';
|
|
11
|
+
export type { FixedJointOptions } from './fixed-joint.js';
|
|
12
|
+
export { HingeJoint } from './hinge-joint.js';
|
|
13
|
+
export type { HingeJointOptions } from './hinge-joint.js';
|
|
14
|
+
export { SpringJoint } from './spring-joint.js';
|
|
15
|
+
export type { SpringJointOptions } from './spring-joint.js';
|
|
16
|
+
export { PhysicsSystem } from './physics-system.js';
|
|
17
|
+
export { registerPhysicsBuiltins } from './register-builtins.js';
|
|
18
|
+
export {
|
|
19
|
+
findAncestorComponent,
|
|
20
|
+
hasAncestorComponent,
|
|
21
|
+
hasDescendantComponent,
|
|
22
|
+
} from './physics-hierarchy.js';
|
|
23
|
+
export { computeColliderOffset } from './collider-offset.js';
|
|
24
|
+
export type { ColliderOffset } from './collider-offset.js';
|
|
25
|
+
export { Physics, invalidateColliderMap } from './physics-query.js';
|
|
26
|
+
export type { HitResult } from './physics-query.js';
|