@rapierphysicsplugin/client 1.0.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.
Files changed (83) hide show
  1. package/dist/__tests__/clock-sync.test.d.ts +2 -0
  2. package/dist/__tests__/clock-sync.test.d.ts.map +1 -0
  3. package/dist/__tests__/clock-sync.test.js +63 -0
  4. package/dist/__tests__/clock-sync.test.js.map +1 -0
  5. package/dist/__tests__/interpolator.test.d.ts +2 -0
  6. package/dist/__tests__/interpolator.test.d.ts.map +1 -0
  7. package/dist/__tests__/interpolator.test.js +82 -0
  8. package/dist/__tests__/interpolator.test.js.map +1 -0
  9. package/dist/__tests__/state-reconciler.test.d.ts +2 -0
  10. package/dist/__tests__/state-reconciler.test.d.ts.map +1 -0
  11. package/dist/__tests__/state-reconciler.test.js +86 -0
  12. package/dist/__tests__/state-reconciler.test.js.map +1 -0
  13. package/dist/clock-sync.d.ts +17 -0
  14. package/dist/clock-sync.d.ts.map +1 -0
  15. package/dist/clock-sync.js +63 -0
  16. package/dist/clock-sync.js.map +1 -0
  17. package/dist/index.d.ts +10 -0
  18. package/dist/index.d.ts.map +1 -0
  19. package/dist/index.js +8 -0
  20. package/dist/index.js.map +1 -0
  21. package/dist/input-manager.d.ts +18 -0
  22. package/dist/input-manager.d.ts.map +1 -0
  23. package/dist/input-manager.js +62 -0
  24. package/dist/input-manager.js.map +1 -0
  25. package/dist/interpolator.d.ts +35 -0
  26. package/dist/interpolator.d.ts.map +1 -0
  27. package/dist/interpolator.js +198 -0
  28. package/dist/interpolator.js.map +1 -0
  29. package/dist/networked-rapier-plugin.d.ts +82 -0
  30. package/dist/networked-rapier-plugin.d.ts.map +1 -0
  31. package/dist/networked-rapier-plugin.js +698 -0
  32. package/dist/networked-rapier-plugin.js.map +1 -0
  33. package/dist/rapier-body-ops.d.ts +27 -0
  34. package/dist/rapier-body-ops.d.ts.map +1 -0
  35. package/dist/rapier-body-ops.js +208 -0
  36. package/dist/rapier-body-ops.js.map +1 -0
  37. package/dist/rapier-collision-ops.d.ts +6 -0
  38. package/dist/rapier-collision-ops.d.ts.map +1 -0
  39. package/dist/rapier-collision-ops.js +200 -0
  40. package/dist/rapier-collision-ops.js.map +1 -0
  41. package/dist/rapier-constraint-ops.d.ts +29 -0
  42. package/dist/rapier-constraint-ops.d.ts.map +1 -0
  43. package/dist/rapier-constraint-ops.js +286 -0
  44. package/dist/rapier-constraint-ops.js.map +1 -0
  45. package/dist/rapier-plugin.d.ts +145 -0
  46. package/dist/rapier-plugin.d.ts.map +1 -0
  47. package/dist/rapier-plugin.js +263 -0
  48. package/dist/rapier-plugin.js.map +1 -0
  49. package/dist/rapier-shape-ops.d.ts +21 -0
  50. package/dist/rapier-shape-ops.d.ts.map +1 -0
  51. package/dist/rapier-shape-ops.js +314 -0
  52. package/dist/rapier-shape-ops.js.map +1 -0
  53. package/dist/rapier-types.d.ts +58 -0
  54. package/dist/rapier-types.d.ts.map +1 -0
  55. package/dist/rapier-types.js +4 -0
  56. package/dist/rapier-types.js.map +1 -0
  57. package/dist/state-reconciler.d.ts +28 -0
  58. package/dist/state-reconciler.d.ts.map +1 -0
  59. package/dist/state-reconciler.js +119 -0
  60. package/dist/state-reconciler.js.map +1 -0
  61. package/dist/sync-client.d.ts +110 -0
  62. package/dist/sync-client.d.ts.map +1 -0
  63. package/dist/sync-client.js +514 -0
  64. package/dist/sync-client.js.map +1 -0
  65. package/package.json +21 -0
  66. package/src/__tests__/clock-sync.test.ts +72 -0
  67. package/src/__tests__/interpolator.test.ts +98 -0
  68. package/src/__tests__/state-reconciler.test.ts +102 -0
  69. package/src/clock-sync.ts +77 -0
  70. package/src/index.ts +9 -0
  71. package/src/input-manager.ts +72 -0
  72. package/src/interpolator.ts +256 -0
  73. package/src/networked-rapier-plugin.ts +909 -0
  74. package/src/rapier-body-ops.ts +251 -0
  75. package/src/rapier-collision-ops.ts +229 -0
  76. package/src/rapier-constraint-ops.ts +327 -0
  77. package/src/rapier-plugin.ts +364 -0
  78. package/src/rapier-shape-ops.ts +369 -0
  79. package/src/rapier-types.ts +60 -0
  80. package/src/state-reconciler.ts +151 -0
  81. package/src/sync-client.ts +640 -0
  82. package/tsconfig.json +12 -0
  83. package/tsconfig.tsbuildinfo +1 -0
@@ -0,0 +1,263 @@
1
+ import { Vector3, Observable, } from '@babylonjs/core';
2
+ import { processCollisionEvents, injectCollisionEvents } from './rapier-collision-ops.js';
3
+ import * as bodyOps from './rapier-body-ops.js';
4
+ import * as shapeOps from './rapier-shape-ops.js';
5
+ import * as constraintOps from './rapier-constraint-ops.js';
6
+ export class RapierPlugin {
7
+ constructor(rapier, gravity) {
8
+ this.name = 'RapierPlugin';
9
+ this.onCollisionObservable = new Observable();
10
+ this.onCollisionEndedObservable = new Observable();
11
+ this.onTriggerCollisionObservable = new Observable();
12
+ this.bodyToRigidBody = new Map();
13
+ this.bodyToColliders = new Map();
14
+ this.shapeToColliderDesc = new Map();
15
+ this.shapeTypeMap = new Map();
16
+ this.shapeMaterialMap = new Map();
17
+ this.shapeDensityMap = new Map();
18
+ this.shapeFilterMembership = new Map();
19
+ this.shapeFilterCollide = new Map();
20
+ this.bodyCollisionObservables = new Map();
21
+ this.bodyCollisionEndedObservables = new Map();
22
+ this.constraintToJoint = new Map();
23
+ this.constraintBodies = new Map();
24
+ this.constraintAxisState = new Map();
25
+ this.constraintEnabled = new Map();
26
+ this.constraintDescriptors = new Map();
27
+ this.collisionCallbackEnabled = new Set();
28
+ this.collisionEndedCallbackEnabled = new Set();
29
+ this.triggerShapes = new Set();
30
+ this.bodyIdToPhysicsBody = new Map();
31
+ this.maxLinearVelocity = 200;
32
+ this.maxAngularVelocity = 200;
33
+ this.bodyToShape = new Map();
34
+ this.shapeToBody = new Map();
35
+ this.compoundChildren = new Map();
36
+ this.bodyEventMask = new Map();
37
+ this.colliderHandleToBody = new Map();
38
+ this.rapier = rapier;
39
+ const g = gravity ?? new Vector3(0, -9.81, 0);
40
+ this.world = new rapier.World(new rapier.Vector3(g.x, g.y, g.z));
41
+ this.eventQueue = new rapier.EventQueue(false);
42
+ }
43
+ // --- Core ---
44
+ getPluginVersion() { return 2; }
45
+ setGravity(gravity) {
46
+ this.world.gravity = new this.rapier.Vector3(gravity.x, gravity.y, gravity.z);
47
+ }
48
+ setTimeStep(timeStep) { this.world.timestep = timeStep; }
49
+ getTimeStep() { return this.world.timestep; }
50
+ setVelocityLimits(maxLinearVelocity, maxAngularVelocity) {
51
+ this.maxLinearVelocity = maxLinearVelocity;
52
+ this.maxAngularVelocity = maxAngularVelocity;
53
+ }
54
+ getMaxLinearVelocity() { return this.maxLinearVelocity; }
55
+ getMaxAngularVelocity() { return this.maxAngularVelocity; }
56
+ executeStep(_delta, bodies) {
57
+ this.world.step(this.eventQueue);
58
+ processCollisionEvents(this, this.eventQueue);
59
+ for (const body of bodies) {
60
+ this.sync(body);
61
+ }
62
+ }
63
+ // --- Body lifecycle ---
64
+ initBody(body, motionType, position, orientation) {
65
+ bodyOps.initBody(this, body, motionType, position, orientation);
66
+ }
67
+ initBodyInstances(_body, _motionType, _mesh) { }
68
+ updateBodyInstances(_body, _mesh) { }
69
+ removeBody(body) { this.disposeBody(body); }
70
+ disposeBody(body) { bodyOps.disposeBody(this, body); }
71
+ sync(body) { bodyOps.syncBody(this, body); }
72
+ syncTransform(body, transformNode) { bodyOps.syncTransform(this, body, transformNode); }
73
+ // --- Shape management ---
74
+ initShape(shape, type, options) {
75
+ shapeOps.initShape(this, shape, type, options);
76
+ }
77
+ setShape(body, shape) { shapeOps.setShape(this, body, shape); }
78
+ getShape(body) { return this.bodyToShape.get(body) ?? null; }
79
+ getShapeType(shape) { return this.shapeTypeMap.get(shape); }
80
+ disposeShape(shape) { shapeOps.disposeShape(this, shape); }
81
+ // --- Shape filtering ---
82
+ setShapeFilterMembershipMask(shape, membershipMask) { shapeOps.setShapeFilterMembershipMask(this, shape, membershipMask); }
83
+ getShapeFilterMembershipMask(shape) { return shapeOps.getShapeFilterMembershipMask(this, shape); }
84
+ setShapeFilterCollideMask(shape, collideMask) { shapeOps.setShapeFilterCollideMask(this, shape, collideMask); }
85
+ getShapeFilterCollideMask(shape) { return shapeOps.getShapeFilterCollideMask(this, shape); }
86
+ // --- Shape material ---
87
+ setMaterial(shape, material) { shapeOps.setMaterial(this, shape, material); }
88
+ getMaterial(shape) { return shapeOps.getMaterial(this, shape); }
89
+ setDensity(shape, density) { shapeOps.setDensity(this, shape, density); }
90
+ getDensity(shape) { return shapeOps.getDensity(this, shape); }
91
+ // --- Compound shapes ---
92
+ addChild(shape, newChild, translation, rotation, scale) {
93
+ shapeOps.addChild(this, shape, newChild, translation, rotation, scale);
94
+ }
95
+ removeChild(shape, childIndex) { shapeOps.removeChild(this, shape, childIndex); }
96
+ getNumChildren(shape) { return shapeOps.getNumChildren(this, shape); }
97
+ // --- Bounding box ---
98
+ getBoundingBox(shape) { return shapeOps.getBoundingBox(this, shape); }
99
+ getBodyBoundingBox(body) { return shapeOps.getBodyBoundingBox(this, body); }
100
+ // --- Triggers & collision callbacks ---
101
+ setTrigger(shape, isTrigger) { shapeOps.setTrigger(this, shape, isTrigger); }
102
+ setCollisionCallbackEnabled(body, enabled, _instanceIndex) {
103
+ if (enabled) {
104
+ this.collisionCallbackEnabled.add(body);
105
+ }
106
+ else {
107
+ this.collisionCallbackEnabled.delete(body);
108
+ }
109
+ }
110
+ setCollisionEndedCallbackEnabled(body, enabled, _instanceIndex) {
111
+ if (enabled) {
112
+ this.collisionEndedCallbackEnabled.add(body);
113
+ }
114
+ else {
115
+ this.collisionEndedCallbackEnabled.delete(body);
116
+ }
117
+ }
118
+ // --- Event mask ---
119
+ setEventMask(body, eventMask, _instanceIndex) { this.bodyEventMask.set(body, eventMask); }
120
+ getEventMask(body, _instanceIndex) { return this.bodyEventMask.get(body) ?? 0; }
121
+ // --- Motion type ---
122
+ setMotionType(body, motionType, _instanceIndex) { bodyOps.setMotionType(this, body, motionType); }
123
+ getMotionType(body, _instanceIndex) { return bodyOps.getMotionType(this, body); }
124
+ // --- Mass properties ---
125
+ computeMassProperties(body, _instanceIndex) { return bodyOps.computeMassProperties(this, body); }
126
+ setMassProperties(body, massProps, _instanceIndex) { bodyOps.setMassProperties(this, body, massProps); }
127
+ getMassProperties(body, _instanceIndex) { return bodyOps.getMassProperties(this, body); }
128
+ // --- Damping ---
129
+ setLinearDamping(body, damping, _instanceIndex) { bodyOps.setLinearDamping(this, body, damping); }
130
+ getLinearDamping(body, _instanceIndex) { return bodyOps.getLinearDamping(this, body); }
131
+ setAngularDamping(body, damping, _instanceIndex) { bodyOps.setAngularDamping(this, body, damping); }
132
+ getAngularDamping(body, _instanceIndex) { return bodyOps.getAngularDamping(this, body); }
133
+ // --- Velocity ---
134
+ setLinearVelocity(body, linVel, _instanceIndex) { bodyOps.setLinearVelocity(this, body, linVel); }
135
+ getLinearVelocityToRef(body, linVel, _instanceIndex) { bodyOps.getLinearVelocityToRef(this, body, linVel); }
136
+ setAngularVelocity(body, angVel, _instanceIndex) { bodyOps.setAngularVelocity(this, body, angVel); }
137
+ getAngularVelocityToRef(body, angVel, _instanceIndex) { bodyOps.getAngularVelocityToRef(this, body, angVel); }
138
+ // --- Forces & impulses ---
139
+ applyImpulse(body, impulse, location, _instanceIndex) { bodyOps.applyImpulse(this, body, impulse, location); }
140
+ applyAngularImpulse(body, angularImpulse, _instanceIndex) { bodyOps.applyAngularImpulse(this, body, angularImpulse); }
141
+ applyForce(body, force, location, _instanceIndex) { bodyOps.applyForce(this, body, force, location); }
142
+ // --- Gravity factor ---
143
+ setGravityFactor(body, factor, _instanceIndex) { bodyOps.setGravityFactor(this, body, factor); }
144
+ getGravityFactor(body, _instanceIndex) { return bodyOps.getGravityFactor(this, body); }
145
+ // --- Target transform (kinematic) ---
146
+ setTargetTransform(body, position, rotation, _instanceIndex) {
147
+ bodyOps.setTargetTransform(this, body, position, rotation);
148
+ }
149
+ // --- Body geometry ---
150
+ getBodyGeometry(_body) { return {}; }
151
+ // --- Constraints ---
152
+ initConstraint(constraint, body, childBody) {
153
+ constraintOps.initConstraint(this, constraint, body, childBody);
154
+ }
155
+ addConstraint(body, childBody, constraint, _instanceIndex, _childInstanceIndex) {
156
+ if (!this.constraintToJoint.has(constraint)) {
157
+ this.initConstraint(constraint, body, childBody);
158
+ }
159
+ }
160
+ disposeConstraint(constraint) { constraintOps.disposeConstraint(this, constraint); }
161
+ setEnabled(constraint, isEnabled) { constraintOps.setEnabled(this, constraint, isEnabled); }
162
+ getEnabled(constraint) { return constraintOps.getEnabled(this, constraint); }
163
+ setCollisionsEnabled(constraint, isEnabled) { constraintOps.setCollisionsEnabled(this, constraint, isEnabled); }
164
+ getCollisionsEnabled(constraint) { return constraintOps.getCollisionsEnabled(this, constraint); }
165
+ setAxisFriction(constraint, axis, friction) { constraintOps.setAxisFriction(this, constraint, axis, friction); }
166
+ getAxisFriction(constraint, axis) { return constraintOps.getAxisFriction(this, constraint, axis); }
167
+ setAxisMode(constraint, axis, limitMode) { constraintOps.setAxisMode(this, constraint, axis, limitMode); }
168
+ getAxisMode(constraint, axis) { return constraintOps.getAxisMode(this, constraint, axis); }
169
+ setAxisMinLimit(constraint, axis, minLimit) { constraintOps.setAxisMinLimit(this, constraint, axis, minLimit); }
170
+ getAxisMinLimit(constraint, axis) { return constraintOps.getAxisMinLimit(this, constraint, axis); }
171
+ setAxisMaxLimit(constraint, axis, limit) { constraintOps.setAxisMaxLimit(this, constraint, axis, limit); }
172
+ getAxisMaxLimit(constraint, axis) { return constraintOps.getAxisMaxLimit(this, constraint, axis); }
173
+ setAxisMotorType(constraint, axis, motorType) { constraintOps.setAxisMotorType(this, constraint, axis, motorType); }
174
+ getAxisMotorType(constraint, axis) { return constraintOps.getAxisMotorType(this, constraint, axis); }
175
+ setAxisMotorTarget(constraint, axis, target) { constraintOps.setAxisMotorTarget(this, constraint, axis, target); }
176
+ getAxisMotorTarget(constraint, axis) { return constraintOps.getAxisMotorTarget(this, constraint, axis); }
177
+ setAxisMotorMaxForce(constraint, axis, maxForce) { constraintOps.setAxisMotorMaxForce(this, constraint, axis, maxForce); }
178
+ getAxisMotorMaxForce(constraint, axis) { return constraintOps.getAxisMotorMaxForce(this, constraint, axis); }
179
+ getBodiesUsingConstraint(constraint) { return constraintOps.getBodiesUsingConstraint(this, constraint); }
180
+ // --- Collision observables ---
181
+ getCollisionObservable(body, _instanceIndex) {
182
+ let obs = this.bodyCollisionObservables.get(body);
183
+ if (!obs) {
184
+ obs = new Observable();
185
+ this.bodyCollisionObservables.set(body, obs);
186
+ }
187
+ return obs;
188
+ }
189
+ getCollisionEndedObservable(body, _instanceIndex) {
190
+ let obs = this.bodyCollisionEndedObservables.get(body);
191
+ if (!obs) {
192
+ obs = new Observable();
193
+ this.bodyCollisionEndedObservables.set(body, obs);
194
+ }
195
+ return obs;
196
+ }
197
+ // --- Raycast ---
198
+ raycast(from, to, result, _query) {
199
+ const dir = to.subtract(from);
200
+ const maxToi = dir.length();
201
+ const normalizedDir = dir.normalize();
202
+ const ray = new this.rapier.Ray(new this.rapier.Vector3(from.x, from.y, from.z), new this.rapier.Vector3(normalizedDir.x, normalizedDir.y, normalizedDir.z));
203
+ const hit = this.world.castRayAndGetNormal(ray, maxToi, true);
204
+ if (hit) {
205
+ const hitPoint = ray.pointAt(hit.timeOfImpact);
206
+ const hitNormal = hit.normal;
207
+ result.setHitData(new Vector3(hitNormal.x, hitNormal.y, hitNormal.z), new Vector3(hitPoint.x, hitPoint.y, hitPoint.z));
208
+ result.calculateHitDistance();
209
+ }
210
+ }
211
+ // --- Dispose ---
212
+ dispose() {
213
+ this.eventQueue.free();
214
+ this.world.free();
215
+ this.bodyToRigidBody.clear();
216
+ this.bodyToColliders.clear();
217
+ this.shapeToColliderDesc.clear();
218
+ this.shapeTypeMap.clear();
219
+ this.constraintToJoint.clear();
220
+ this.constraintBodies.clear();
221
+ this.constraintAxisState.clear();
222
+ this.constraintEnabled.clear();
223
+ this.constraintDescriptors.clear();
224
+ this.collisionCallbackEnabled.clear();
225
+ this.collisionEndedCallbackEnabled.clear();
226
+ this.triggerShapes.clear();
227
+ this.bodyIdToPhysicsBody.clear();
228
+ this.bodyToShape.clear();
229
+ this.shapeToBody.clear();
230
+ this.compoundChildren.clear();
231
+ this.bodyEventMask.clear();
232
+ this.colliderHandleToBody.clear();
233
+ this.shapeFilterMembership.clear();
234
+ this.shapeFilterCollide.clear();
235
+ }
236
+ // --- Rapier-specific helpers for sync module ---
237
+ getRigidBody(body) {
238
+ return this.bodyToRigidBody.get(body);
239
+ }
240
+ setBodyTranslation(body, position) {
241
+ const rb = this.bodyToRigidBody.get(body);
242
+ if (rb) {
243
+ rb.setTranslation(new this.rapier.Vector3(position.x, position.y, position.z), true);
244
+ }
245
+ }
246
+ setBodyRotation(body, rotation) {
247
+ const rb = this.bodyToRigidBody.get(body);
248
+ if (rb) {
249
+ rb.setRotation(new this.rapier.Quaternion(rotation.x, rotation.y, rotation.z, rotation.w), true);
250
+ }
251
+ }
252
+ // --- Server collision event injection ---
253
+ registerBodyId(bodyId, body) {
254
+ this.bodyIdToPhysicsBody.set(bodyId, body);
255
+ }
256
+ unregisterBodyId(bodyId) {
257
+ this.bodyIdToPhysicsBody.delete(bodyId);
258
+ }
259
+ injectCollisionEvents(events) {
260
+ injectCollisionEvents(this, events);
261
+ }
262
+ }
263
+ //# sourceMappingURL=rapier-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rapier-plugin.js","sourceRoot":"","sources":["../src/rapier-plugin.ts"],"names":[],"mappings":"AACA,OAAO,EACL,OAAO,EAEP,UAAU,GACX,MAAM,iBAAiB,CAAC;AA2BzB,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAC1F,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAChD,OAAO,KAAK,QAAQ,MAAM,uBAAuB,CAAC;AAClD,OAAO,KAAK,aAAa,MAAM,4BAA4B,CAAC;AAE5D,MAAM,OAAO,YAAY;IAqCvB,YAAY,MA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,MAAM,EAAE,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC1C,IAAI,EAAE,EAAE,CAAC;YACP,EAAE,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;QACnG,CAAC;IACH,CAAC;IAED,2CAA2C;IAE3C,cAAc,CAAC,MAAc,EAAE,IAAiB;QAC9C,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC7C,CAAC;IAED,gBAAgB,CAAC,MAAc;QAC7B,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC1C,CAAC;IAED,qBAAqB,CAAC,MAA4B;QAChD,qBAAqB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACtC,CAAC;CACF"}
@@ -0,0 +1,21 @@
1
+ import { Vector3, BoundingBox, PhysicsShapeType } from '@babylonjs/core';
2
+ import type { PhysicsBody, PhysicsShape, PhysicsShapeParameters, PhysicsMaterial, Nullable, Quaternion } from '@babylonjs/core';
3
+ import type { RapierPluginState } from './rapier-types.js';
4
+ export declare function initShape(state: RapierPluginState, shape: PhysicsShape, type: PhysicsShapeType, options: PhysicsShapeParameters): void;
5
+ export declare function setShape(state: RapierPluginState, body: PhysicsBody, shape: Nullable<PhysicsShape>): void;
6
+ export declare function disposeShape(state: RapierPluginState, shape: PhysicsShape): void;
7
+ export declare function setMaterial(state: RapierPluginState, shape: PhysicsShape, material: PhysicsMaterial): void;
8
+ export declare function getMaterial(state: RapierPluginState, shape: PhysicsShape): PhysicsMaterial;
9
+ export declare function setDensity(state: RapierPluginState, shape: PhysicsShape, density: number): void;
10
+ export declare function getDensity(state: RapierPluginState, shape: PhysicsShape): number;
11
+ export declare function setTrigger(state: RapierPluginState, shape: PhysicsShape, isTrigger: boolean): void;
12
+ export declare function setShapeFilterMembershipMask(state: RapierPluginState, shape: PhysicsShape, membershipMask: number): void;
13
+ export declare function getShapeFilterMembershipMask(state: RapierPluginState, shape: PhysicsShape): number;
14
+ export declare function setShapeFilterCollideMask(state: RapierPluginState, shape: PhysicsShape, collideMask: number): void;
15
+ export declare function getShapeFilterCollideMask(state: RapierPluginState, shape: PhysicsShape): number;
16
+ export declare function addChild(state: RapierPluginState, shape: PhysicsShape, newChild: PhysicsShape, translation?: Vector3, rotation?: Quaternion, scale?: Vector3): void;
17
+ export declare function removeChild(state: RapierPluginState, shape: PhysicsShape, childIndex: number): void;
18
+ export declare function getNumChildren(state: RapierPluginState, shape: PhysicsShape): number;
19
+ export declare function getBoundingBox(state: RapierPluginState, shape: PhysicsShape): BoundingBox;
20
+ export declare function getBodyBoundingBox(state: RapierPluginState, body: PhysicsBody): BoundingBox;
21
+ //# sourceMappingURL=rapier-shape-ops.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rapier-shape-ops.d.ts","sourceRoot":"","sources":["../src/rapier-shape-ops.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,sBAAsB,EACtB,eAAe,EACf,QAAQ,EACR,UAAU,EACX,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE3D,wBAAgB,SAAS,CAAC,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,sBAAsB,GAAG,IAAI,CA2FtI;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,QAAQ,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,EAAE,OAAO,GAAG,IAAI,CAYnK;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CASnG;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,YAAY,GAAG,MAAM,CAEpF;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,YAAY,GAAG,WAAW,CAMzF;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,WAAW,GAAG,WAAW,CAoB3F"}
@@ -0,0 +1,314 @@
1
+ import { Vector3, BoundingBox, PhysicsShapeType } from '@babylonjs/core';
2
+ export function initShape(state, shape, type, options) {
3
+ let colliderDesc;
4
+ switch (type) {
5
+ case PhysicsShapeType.BOX: {
6
+ const ext = options.extents ?? new Vector3(1, 1, 1);
7
+ colliderDesc = state.rapier.ColliderDesc.cuboid(ext.x / 2, ext.y / 2, ext.z / 2);
8
+ break;
9
+ }
10
+ case PhysicsShapeType.SPHERE: {
11
+ const r = options.radius ?? 0.5;
12
+ colliderDesc = state.rapier.ColliderDesc.ball(r);
13
+ break;
14
+ }
15
+ case PhysicsShapeType.CAPSULE: {
16
+ const pointA = options.pointA ?? new Vector3(0, 0, 0);
17
+ const pointB = options.pointB ?? new Vector3(0, 1, 0);
18
+ const halfHeight = Vector3.Distance(pointA, pointB) / 2;
19
+ const radius = options.radius ?? 0.5;
20
+ colliderDesc = state.rapier.ColliderDesc.capsule(halfHeight, radius);
21
+ break;
22
+ }
23
+ case PhysicsShapeType.CYLINDER: {
24
+ const pointA = options.pointA ?? new Vector3(0, 0, 0);
25
+ const pointB = options.pointB ?? new Vector3(0, 1, 0);
26
+ const halfHeight = Vector3.Distance(pointA, pointB) / 2;
27
+ const radius = options.radius ?? 0.5;
28
+ colliderDesc = state.rapier.ColliderDesc.cylinder(halfHeight, radius);
29
+ break;
30
+ }
31
+ case PhysicsShapeType.MESH: {
32
+ const mesh = options.mesh;
33
+ if (mesh) {
34
+ const positions = mesh.getVerticesData('position');
35
+ const indices = mesh.getIndices();
36
+ if (positions && indices) {
37
+ colliderDesc = state.rapier.ColliderDesc.trimesh(new Float32Array(positions), new Uint32Array(indices));
38
+ }
39
+ else {
40
+ colliderDesc = state.rapier.ColliderDesc.ball(0.5);
41
+ }
42
+ }
43
+ else {
44
+ colliderDesc = state.rapier.ColliderDesc.ball(0.5);
45
+ }
46
+ break;
47
+ }
48
+ case PhysicsShapeType.CONVEX_HULL: {
49
+ const mesh = options.mesh;
50
+ if (mesh) {
51
+ const positions = mesh.getVerticesData('position');
52
+ if (positions) {
53
+ const desc = state.rapier.ColliderDesc.convexHull(new Float32Array(positions));
54
+ colliderDesc = desc ?? state.rapier.ColliderDesc.ball(0.5);
55
+ }
56
+ else {
57
+ colliderDesc = state.rapier.ColliderDesc.ball(0.5);
58
+ }
59
+ }
60
+ else {
61
+ colliderDesc = state.rapier.ColliderDesc.ball(0.5);
62
+ }
63
+ break;
64
+ }
65
+ case PhysicsShapeType.CONTAINER: {
66
+ colliderDesc = state.rapier.ColliderDesc.ball(0.001);
67
+ break;
68
+ }
69
+ case PhysicsShapeType.HEIGHTFIELD: {
70
+ const heights = options.heightFieldData;
71
+ const nrows = (options.numHeightFieldSamplesX ?? 2) - 1;
72
+ const ncols = (options.numHeightFieldSamplesZ ?? 2) - 1;
73
+ const sizeX = options.heightFieldSizeX ?? 1;
74
+ const sizeZ = options.heightFieldSizeZ ?? 1;
75
+ if (heights) {
76
+ colliderDesc = state.rapier.ColliderDesc.heightfield(nrows, ncols, heights, new state.rapier.Vector3(sizeX, 1, sizeZ));
77
+ }
78
+ else {
79
+ colliderDesc = state.rapier.ColliderDesc.ball(0.5);
80
+ }
81
+ break;
82
+ }
83
+ default:
84
+ colliderDesc = state.rapier.ColliderDesc.ball(0.5);
85
+ }
86
+ state.shapeToColliderDesc.set(shape, colliderDesc);
87
+ state.shapeTypeMap.set(shape, type);
88
+ }
89
+ export function setShape(state, body, shape) {
90
+ const rb = state.bodyToRigidBody.get(body);
91
+ if (!rb)
92
+ return;
93
+ const oldShape = state.bodyToShape.get(body);
94
+ if (oldShape) {
95
+ state.shapeToBody.delete(oldShape);
96
+ state.bodyToShape.delete(body);
97
+ }
98
+ const existing = state.bodyToColliders.get(body) ?? [];
99
+ for (const col of existing) {
100
+ state.colliderHandleToBody.delete(col.handle);
101
+ state.world.removeCollider(col, false);
102
+ }
103
+ if (!shape) {
104
+ state.bodyToColliders.set(body, []);
105
+ return;
106
+ }
107
+ state.bodyToShape.set(body, shape);
108
+ state.shapeToBody.set(shape, body);
109
+ const shapeType = state.shapeTypeMap.get(shape);
110
+ if (shapeType === PhysicsShapeType.CONTAINER) {
111
+ rebuildCompoundColliders(state, body, shape);
112
+ return;
113
+ }
114
+ const desc = state.shapeToColliderDesc.get(shape);
115
+ if (!desc)
116
+ return;
117
+ const collider = state.world.createCollider(desc, rb);
118
+ applyShapePropertiesToCollider(state, collider, shape);
119
+ state.colliderHandleToBody.set(collider.handle, body);
120
+ state.bodyToColliders.set(body, [collider]);
121
+ }
122
+ export function disposeShape(state, shape) {
123
+ state.shapeToColliderDesc.delete(shape);
124
+ state.shapeTypeMap.delete(shape);
125
+ state.shapeMaterialMap.delete(shape);
126
+ state.shapeDensityMap.delete(shape);
127
+ state.shapeFilterMembership.delete(shape);
128
+ state.shapeFilterCollide.delete(shape);
129
+ state.triggerShapes.delete(shape);
130
+ state.compoundChildren.delete(shape);
131
+ state.shapeToBody.delete(shape);
132
+ }
133
+ export function setMaterial(state, shape, material) {
134
+ state.shapeMaterialMap.set(shape, material);
135
+ for (const collider of getCollidersForShape(state, shape)) {
136
+ if (material.friction !== undefined)
137
+ collider.setFriction(material.friction);
138
+ if (material.restitution !== undefined)
139
+ collider.setRestitution(material.restitution);
140
+ }
141
+ }
142
+ export function getMaterial(state, shape) {
143
+ return state.shapeMaterialMap.get(shape) ?? { friction: 0.5, restitution: 0 };
144
+ }
145
+ export function setDensity(state, shape, density) {
146
+ state.shapeDensityMap.set(shape, density);
147
+ for (const collider of getCollidersForShape(state, shape)) {
148
+ collider.setDensity(density);
149
+ }
150
+ }
151
+ export function getDensity(state, shape) {
152
+ return state.shapeDensityMap.get(shape) ?? 1.0;
153
+ }
154
+ export function setTrigger(state, shape, isTrigger) {
155
+ if (isTrigger) {
156
+ state.triggerShapes.add(shape);
157
+ }
158
+ else {
159
+ state.triggerShapes.delete(shape);
160
+ }
161
+ for (const collider of getCollidersForShape(state, shape)) {
162
+ collider.setSensor(isTrigger);
163
+ }
164
+ }
165
+ export function setShapeFilterMembershipMask(state, shape, membershipMask) {
166
+ state.shapeFilterMembership.set(shape, membershipMask);
167
+ applyCollisionGroups(state, shape);
168
+ }
169
+ export function getShapeFilterMembershipMask(state, shape) {
170
+ return state.shapeFilterMembership.get(shape) ?? 0xFFFFFFFF;
171
+ }
172
+ export function setShapeFilterCollideMask(state, shape, collideMask) {
173
+ state.shapeFilterCollide.set(shape, collideMask);
174
+ applyCollisionGroups(state, shape);
175
+ }
176
+ export function getShapeFilterCollideMask(state, shape) {
177
+ return state.shapeFilterCollide.get(shape) ?? 0xFFFFFFFF;
178
+ }
179
+ export function addChild(state, shape, newChild, translation, rotation, scale) {
180
+ let children = state.compoundChildren.get(shape);
181
+ if (!children) {
182
+ children = [];
183
+ state.compoundChildren.set(shape, children);
184
+ }
185
+ children.push({ child: newChild, translation, rotation, scale });
186
+ const body = state.shapeToBody.get(shape);
187
+ if (body) {
188
+ rebuildCompoundColliders(state, body, shape);
189
+ }
190
+ }
191
+ export function removeChild(state, shape, childIndex) {
192
+ const children = state.compoundChildren.get(shape);
193
+ if (!children || childIndex < 0 || childIndex >= children.length)
194
+ return;
195
+ children.splice(childIndex, 1);
196
+ const body = state.shapeToBody.get(shape);
197
+ if (body) {
198
+ rebuildCompoundColliders(state, body, shape);
199
+ }
200
+ }
201
+ export function getNumChildren(state, shape) {
202
+ return state.compoundChildren.get(shape)?.length ?? 0;
203
+ }
204
+ export function getBoundingBox(state, shape) {
205
+ const colliders = getCollidersForShape(state, shape);
206
+ if (colliders.length === 0) {
207
+ return new BoundingBox(new Vector3(-0.5, -0.5, -0.5), new Vector3(0.5, 0.5, 0.5));
208
+ }
209
+ return computeColliderBoundingBox(state, colliders[0]);
210
+ }
211
+ export function getBodyBoundingBox(state, body) {
212
+ const colliders = state.bodyToColliders.get(body) ?? [];
213
+ if (colliders.length === 0) {
214
+ return new BoundingBox(new Vector3(-0.5, -0.5, -0.5), new Vector3(0.5, 0.5, 0.5));
215
+ }
216
+ let minX = Infinity, minY = Infinity, minZ = Infinity;
217
+ let maxX = -Infinity, maxY = -Infinity, maxZ = -Infinity;
218
+ for (const collider of colliders) {
219
+ const bb = computeColliderBoundingBox(state, collider);
220
+ minX = Math.min(minX, bb.minimum.x);
221
+ minY = Math.min(minY, bb.minimum.y);
222
+ minZ = Math.min(minZ, bb.minimum.z);
223
+ maxX = Math.max(maxX, bb.maximum.x);
224
+ maxY = Math.max(maxY, bb.maximum.y);
225
+ maxZ = Math.max(maxZ, bb.maximum.z);
226
+ }
227
+ return new BoundingBox(new Vector3(minX, minY, minZ), new Vector3(maxX, maxY, maxZ));
228
+ }
229
+ function getCollidersForShape(state, shape) {
230
+ const body = state.shapeToBody.get(shape);
231
+ if (!body)
232
+ return [];
233
+ return state.bodyToColliders.get(body) ?? [];
234
+ }
235
+ function applyCollisionGroups(state, shape) {
236
+ const membership = state.shapeFilterMembership.get(shape) ?? 0xFFFF;
237
+ const collide = state.shapeFilterCollide.get(shape) ?? 0xFFFF;
238
+ const groups = ((membership & 0xFFFF) << 16) | (collide & 0xFFFF);
239
+ for (const collider of getCollidersForShape(state, shape)) {
240
+ collider.setCollisionGroups(groups);
241
+ }
242
+ }
243
+ function applyShapePropertiesToCollider(state, collider, shape) {
244
+ const material = state.shapeMaterialMap.get(shape);
245
+ if (material) {
246
+ if (material.friction !== undefined)
247
+ collider.setFriction(material.friction);
248
+ if (material.restitution !== undefined)
249
+ collider.setRestitution(material.restitution);
250
+ }
251
+ const density = state.shapeDensityMap.get(shape);
252
+ if (density !== undefined)
253
+ collider.setDensity(density);
254
+ if (state.triggerShapes.has(shape))
255
+ collider.setSensor(true);
256
+ const membership = state.shapeFilterMembership.get(shape) ?? 0xFFFF;
257
+ const collide = state.shapeFilterCollide.get(shape) ?? 0xFFFF;
258
+ const groups = ((membership & 0xFFFF) << 16) | (collide & 0xFFFF);
259
+ collider.setCollisionGroups(groups);
260
+ collider.setActiveEvents(state.rapier.ActiveEvents.COLLISION_EVENTS);
261
+ }
262
+ function computeColliderBoundingBox(state, collider) {
263
+ const shapeType = collider.shapeType();
264
+ const RAPIER = state.rapier;
265
+ const t = collider.translation();
266
+ if (shapeType === RAPIER.ShapeType.Cuboid) {
267
+ const he = collider.halfExtents();
268
+ return new BoundingBox(new Vector3(t.x - he.x, t.y - he.y, t.z - he.z), new Vector3(t.x + he.x, t.y + he.y, t.z + he.z));
269
+ }
270
+ else if (shapeType === RAPIER.ShapeType.Ball) {
271
+ const r = collider.radius();
272
+ return new BoundingBox(new Vector3(t.x - r, t.y - r, t.z - r), new Vector3(t.x + r, t.y + r, t.z + r));
273
+ }
274
+ else if (shapeType === RAPIER.ShapeType.Capsule) {
275
+ const r = collider.radius();
276
+ const hh = collider.halfHeight();
277
+ return new BoundingBox(new Vector3(t.x - r, t.y - hh - r, t.z - r), new Vector3(t.x + r, t.y + hh + r, t.z + r));
278
+ }
279
+ else if (shapeType === RAPIER.ShapeType.Cylinder) {
280
+ const r = collider.radius();
281
+ const hh = collider.halfHeight();
282
+ return new BoundingBox(new Vector3(t.x - r, t.y - hh, t.z - r), new Vector3(t.x + r, t.y + hh, t.z + r));
283
+ }
284
+ return new BoundingBox(new Vector3(t.x - 0.5, t.y - 0.5, t.z - 0.5), new Vector3(t.x + 0.5, t.y + 0.5, t.z + 0.5));
285
+ }
286
+ function rebuildCompoundColliders(state, body, shape) {
287
+ const rb = state.bodyToRigidBody.get(body);
288
+ if (!rb)
289
+ return;
290
+ const existing = state.bodyToColliders.get(body) ?? [];
291
+ for (const col of existing) {
292
+ state.colliderHandleToBody.delete(col.handle);
293
+ state.world.removeCollider(col, false);
294
+ }
295
+ const children = state.compoundChildren.get(shape) ?? [];
296
+ const newColliders = [];
297
+ for (const entry of children) {
298
+ const childDesc = state.shapeToColliderDesc.get(entry.child);
299
+ if (!childDesc)
300
+ continue;
301
+ if (entry.translation) {
302
+ childDesc.setTranslation(entry.translation.x, entry.translation.y, entry.translation.z);
303
+ }
304
+ if (entry.rotation) {
305
+ childDesc.setRotation(new state.rapier.Quaternion(entry.rotation.x, entry.rotation.y, entry.rotation.z, entry.rotation.w));
306
+ }
307
+ const collider = state.world.createCollider(childDesc, rb);
308
+ applyShapePropertiesToCollider(state, collider, shape);
309
+ state.colliderHandleToBody.set(collider.handle, body);
310
+ newColliders.push(collider);
311
+ }
312
+ state.bodyToColliders.set(body, newColliders);
313
+ }
314
+ //# sourceMappingURL=rapier-shape-ops.js.map