@alexandernanberg/rapier3d 0.0.1 → 0.0.3
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/compat-simd.d.mts +44 -3
- package/dist/compat-simd.d.mts.map +1 -1
- package/dist/compat-simd.mjs +94 -36
- package/dist/compat-simd.mjs.map +1 -1
- package/dist/compat.d.mts +44 -3
- package/dist/compat.d.mts.map +1 -1
- package/dist/compat.mjs +94 -36
- package/dist/compat.mjs.map +1 -1
- package/dist/rapier.d.mts +44 -3
- package/dist/rapier.d.mts.map +1 -1
- package/dist/rapier.mjs +93 -35
- package/dist/rapier.mjs.map +1 -1
- package/dist/rapier_wasm_3d_bg.wasm +0 -0
- package/dist/rapier_wasm_3d_simd_bg.wasm +0 -0
- package/dist/simd.d.mts +44 -3
- package/dist/simd.d.mts.map +1 -1
- package/dist/simd.mjs +93 -35
- package/dist/simd.mjs.map +1 -1
- package/package.json +1 -1
package/dist/rapier.mjs
CHANGED
|
@@ -23,8 +23,12 @@ var RawBroadPhase = class RawBroadPhase {
|
|
|
23
23
|
* @param {RawNarrowPhase} narrow_phase
|
|
24
24
|
* @param {RawRigidBodySet} bodies
|
|
25
25
|
* @param {RawColliderSet} colliders
|
|
26
|
-
* @param {
|
|
27
|
-
* @param {
|
|
26
|
+
* @param {number} ray_ox
|
|
27
|
+
* @param {number} ray_oy
|
|
28
|
+
* @param {number} ray_oz
|
|
29
|
+
* @param {number} ray_dx
|
|
30
|
+
* @param {number} ray_dy
|
|
31
|
+
* @param {number} ray_dz
|
|
28
32
|
* @param {number} maxToi
|
|
29
33
|
* @param {boolean} solid
|
|
30
34
|
* @param {number} filter_flags
|
|
@@ -34,14 +38,12 @@ var RawBroadPhase = class RawBroadPhase {
|
|
|
34
38
|
* @param {Function} filter_predicate
|
|
35
39
|
* @returns {RawRayColliderHit | undefined}
|
|
36
40
|
*/
|
|
37
|
-
castRay(narrow_phase, bodies, colliders,
|
|
41
|
+
castRay(narrow_phase, bodies, colliders, ray_ox, ray_oy, ray_oz, ray_dx, ray_dy, ray_dz, maxToi, solid, filter_flags, filter_groups, filter_exclude_collider, filter_exclude_rigid_body, filter_predicate) {
|
|
38
42
|
try {
|
|
39
43
|
_assertClass(narrow_phase, RawNarrowPhase);
|
|
40
44
|
_assertClass(bodies, RawRigidBodySet);
|
|
41
45
|
_assertClass(colliders, RawColliderSet);
|
|
42
|
-
|
|
43
|
-
_assertClass(rayDir, RawVector);
|
|
44
|
-
const ret = wasm.rawbroadphase_castRay(this.__wbg_ptr, narrow_phase.__wbg_ptr, bodies.__wbg_ptr, colliders.__wbg_ptr, rayOrig.__wbg_ptr, rayDir.__wbg_ptr, maxToi, solid, filter_flags, isLikeNone(filter_groups) ? 4294967297 : filter_groups >>> 0, !isLikeNone(filter_exclude_collider), isLikeNone(filter_exclude_collider) ? 0 : filter_exclude_collider, !isLikeNone(filter_exclude_rigid_body), isLikeNone(filter_exclude_rigid_body) ? 0 : filter_exclude_rigid_body, addBorrowedObject(filter_predicate));
|
|
46
|
+
const ret = wasm.rawbroadphase_castRay(this.__wbg_ptr, narrow_phase.__wbg_ptr, bodies.__wbg_ptr, colliders.__wbg_ptr, ray_ox, ray_oy, ray_oz, ray_dx, ray_dy, ray_dz, maxToi, solid, filter_flags, isLikeNone(filter_groups) ? 4294967297 : filter_groups >>> 0, !isLikeNone(filter_exclude_collider), isLikeNone(filter_exclude_collider) ? 0 : filter_exclude_collider, !isLikeNone(filter_exclude_rigid_body), isLikeNone(filter_exclude_rigid_body) ? 0 : filter_exclude_rigid_body, addBorrowedObject(filter_predicate));
|
|
45
47
|
return ret === 0 ? void 0 : RawRayColliderHit.__wrap(ret);
|
|
46
48
|
} finally {
|
|
47
49
|
heap[stack_pointer++] = void 0;
|
|
@@ -51,8 +53,12 @@ var RawBroadPhase = class RawBroadPhase {
|
|
|
51
53
|
* @param {RawNarrowPhase} narrow_phase
|
|
52
54
|
* @param {RawRigidBodySet} bodies
|
|
53
55
|
* @param {RawColliderSet} colliders
|
|
54
|
-
* @param {
|
|
55
|
-
* @param {
|
|
56
|
+
* @param {number} ray_ox
|
|
57
|
+
* @param {number} ray_oy
|
|
58
|
+
* @param {number} ray_oz
|
|
59
|
+
* @param {number} ray_dx
|
|
60
|
+
* @param {number} ray_dy
|
|
61
|
+
* @param {number} ray_dz
|
|
56
62
|
* @param {number} maxToi
|
|
57
63
|
* @param {boolean} solid
|
|
58
64
|
* @param {number} filter_flags
|
|
@@ -62,14 +68,12 @@ var RawBroadPhase = class RawBroadPhase {
|
|
|
62
68
|
* @param {Function} filter_predicate
|
|
63
69
|
* @returns {RawRayColliderIntersection | undefined}
|
|
64
70
|
*/
|
|
65
|
-
castRayAndGetNormal(narrow_phase, bodies, colliders,
|
|
71
|
+
castRayAndGetNormal(narrow_phase, bodies, colliders, ray_ox, ray_oy, ray_oz, ray_dx, ray_dy, ray_dz, maxToi, solid, filter_flags, filter_groups, filter_exclude_collider, filter_exclude_rigid_body, filter_predicate) {
|
|
66
72
|
try {
|
|
67
73
|
_assertClass(narrow_phase, RawNarrowPhase);
|
|
68
74
|
_assertClass(bodies, RawRigidBodySet);
|
|
69
75
|
_assertClass(colliders, RawColliderSet);
|
|
70
|
-
|
|
71
|
-
_assertClass(rayDir, RawVector);
|
|
72
|
-
const ret = wasm.rawbroadphase_castRayAndGetNormal(this.__wbg_ptr, narrow_phase.__wbg_ptr, bodies.__wbg_ptr, colliders.__wbg_ptr, rayOrig.__wbg_ptr, rayDir.__wbg_ptr, maxToi, solid, filter_flags, isLikeNone(filter_groups) ? 4294967297 : filter_groups >>> 0, !isLikeNone(filter_exclude_collider), isLikeNone(filter_exclude_collider) ? 0 : filter_exclude_collider, !isLikeNone(filter_exclude_rigid_body), isLikeNone(filter_exclude_rigid_body) ? 0 : filter_exclude_rigid_body, addBorrowedObject(filter_predicate));
|
|
76
|
+
const ret = wasm.rawbroadphase_castRayAndGetNormal(this.__wbg_ptr, narrow_phase.__wbg_ptr, bodies.__wbg_ptr, colliders.__wbg_ptr, ray_ox, ray_oy, ray_oz, ray_dx, ray_dy, ray_dz, maxToi, solid, filter_flags, isLikeNone(filter_groups) ? 4294967297 : filter_groups >>> 0, !isLikeNone(filter_exclude_collider), isLikeNone(filter_exclude_collider) ? 0 : filter_exclude_collider, !isLikeNone(filter_exclude_rigid_body), isLikeNone(filter_exclude_rigid_body) ? 0 : filter_exclude_rigid_body, addBorrowedObject(filter_predicate));
|
|
73
77
|
return ret === 0 ? void 0 : RawRayColliderIntersection.__wrap(ret);
|
|
74
78
|
} finally {
|
|
75
79
|
heap[stack_pointer++] = void 0;
|
|
@@ -188,8 +192,12 @@ var RawBroadPhase = class RawBroadPhase {
|
|
|
188
192
|
* @param {RawNarrowPhase} narrow_phase
|
|
189
193
|
* @param {RawRigidBodySet} bodies
|
|
190
194
|
* @param {RawColliderSet} colliders
|
|
191
|
-
* @param {
|
|
192
|
-
* @param {
|
|
195
|
+
* @param {number} ray_ox
|
|
196
|
+
* @param {number} ray_oy
|
|
197
|
+
* @param {number} ray_oz
|
|
198
|
+
* @param {number} ray_dx
|
|
199
|
+
* @param {number} ray_dy
|
|
200
|
+
* @param {number} ray_dz
|
|
193
201
|
* @param {number} maxToi
|
|
194
202
|
* @param {boolean} solid
|
|
195
203
|
* @param {Function} callback
|
|
@@ -199,14 +207,12 @@ var RawBroadPhase = class RawBroadPhase {
|
|
|
199
207
|
* @param {number | null | undefined} filter_exclude_rigid_body
|
|
200
208
|
* @param {Function} filter_predicate
|
|
201
209
|
*/
|
|
202
|
-
intersectionsWithRay(narrow_phase, bodies, colliders,
|
|
210
|
+
intersectionsWithRay(narrow_phase, bodies, colliders, ray_ox, ray_oy, ray_oz, ray_dx, ray_dy, ray_dz, maxToi, solid, callback, filter_flags, filter_groups, filter_exclude_collider, filter_exclude_rigid_body, filter_predicate) {
|
|
203
211
|
try {
|
|
204
212
|
_assertClass(narrow_phase, RawNarrowPhase);
|
|
205
213
|
_assertClass(bodies, RawRigidBodySet);
|
|
206
214
|
_assertClass(colliders, RawColliderSet);
|
|
207
|
-
|
|
208
|
-
_assertClass(rayDir, RawVector);
|
|
209
|
-
wasm.rawbroadphase_intersectionsWithRay(this.__wbg_ptr, narrow_phase.__wbg_ptr, bodies.__wbg_ptr, colliders.__wbg_ptr, rayOrig.__wbg_ptr, rayDir.__wbg_ptr, maxToi, solid, addBorrowedObject(callback), filter_flags, isLikeNone(filter_groups) ? 4294967297 : filter_groups >>> 0, !isLikeNone(filter_exclude_collider), isLikeNone(filter_exclude_collider) ? 0 : filter_exclude_collider, !isLikeNone(filter_exclude_rigid_body), isLikeNone(filter_exclude_rigid_body) ? 0 : filter_exclude_rigid_body, addBorrowedObject(filter_predicate));
|
|
215
|
+
wasm.rawbroadphase_intersectionsWithRay(this.__wbg_ptr, narrow_phase.__wbg_ptr, bodies.__wbg_ptr, colliders.__wbg_ptr, ray_ox, ray_oy, ray_oz, ray_dx, ray_dy, ray_dz, maxToi, solid, addBorrowedObject(callback), filter_flags, isLikeNone(filter_groups) ? 4294967297 : filter_groups >>> 0, !isLikeNone(filter_exclude_collider), isLikeNone(filter_exclude_collider) ? 0 : filter_exclude_collider, !isLikeNone(filter_exclude_rigid_body), isLikeNone(filter_exclude_rigid_body) ? 0 : filter_exclude_rigid_body, addBorrowedObject(filter_predicate));
|
|
210
216
|
} finally {
|
|
211
217
|
heap[stack_pointer++] = void 0;
|
|
212
218
|
heap[stack_pointer++] = void 0;
|
|
@@ -4436,6 +4442,25 @@ var RawRigidBodySet = class RawRigidBodySet {
|
|
|
4436
4442
|
wasm.rawrigidbodyset_rbSetNextKinematicRotation(this.__wbg_ptr, handle, x, y, z, w);
|
|
4437
4443
|
}
|
|
4438
4444
|
/**
|
|
4445
|
+
* If this rigid body is kinematic, sets its future translation and rotation after the next
|
|
4446
|
+
* timestep integration in a single WASM call.
|
|
4447
|
+
*
|
|
4448
|
+
* # Parameters
|
|
4449
|
+
* - `tx`, `ty`, `tz`: the world-space position of the rigid-body.
|
|
4450
|
+
* - `rx`, `ry`, `rz`, `rw`: the rotation quaternion components.
|
|
4451
|
+
* @param {number} handle
|
|
4452
|
+
* @param {number} tx
|
|
4453
|
+
* @param {number} ty
|
|
4454
|
+
* @param {number} tz
|
|
4455
|
+
* @param {number} rx
|
|
4456
|
+
* @param {number} ry
|
|
4457
|
+
* @param {number} rz
|
|
4458
|
+
* @param {number} rw
|
|
4459
|
+
*/
|
|
4460
|
+
rbSetNextKinematicTransform(handle, tx, ty, tz, rx, ry, rz, rw) {
|
|
4461
|
+
wasm.rawrigidbodyset_rbSetNextKinematicTransform(this.__wbg_ptr, handle, tx, ty, tz, rx, ry, rz, rw);
|
|
4462
|
+
}
|
|
4463
|
+
/**
|
|
4439
4464
|
* If this rigid body is kinematic, sets its future translation after the next timestep integration.
|
|
4440
4465
|
*
|
|
4441
4466
|
* This should be used instead of `rigidBody.setTranslation` to make the dynamic object
|
|
@@ -4486,6 +4511,26 @@ var RawRigidBodySet = class RawRigidBodySet {
|
|
|
4486
4511
|
wasm.rawrigidbodyset_rbSetSoftCcdPrediction(this.__wbg_ptr, handle, prediction);
|
|
4487
4512
|
}
|
|
4488
4513
|
/**
|
|
4514
|
+
* Sets both the translation and rotation of this rigid-body in a single WASM call.
|
|
4515
|
+
*
|
|
4516
|
+
* # Parameters
|
|
4517
|
+
* - `tx`, `ty`, `tz`: the world-space position of the rigid-body.
|
|
4518
|
+
* - `rx`, `ry`, `rz`, `rw`: the rotation quaternion components.
|
|
4519
|
+
* - `wakeUp`: forces the rigid-body to wake-up so it is properly affected by forces.
|
|
4520
|
+
* @param {number} handle
|
|
4521
|
+
* @param {number} tx
|
|
4522
|
+
* @param {number} ty
|
|
4523
|
+
* @param {number} tz
|
|
4524
|
+
* @param {number} rx
|
|
4525
|
+
* @param {number} ry
|
|
4526
|
+
* @param {number} rz
|
|
4527
|
+
* @param {number} rw
|
|
4528
|
+
* @param {boolean} wakeUp
|
|
4529
|
+
*/
|
|
4530
|
+
rbSetTransform(handle, tx, ty, tz, rx, ry, rz, rw, wakeUp) {
|
|
4531
|
+
wasm.rawrigidbodyset_rbSetTransform(this.__wbg_ptr, handle, tx, ty, tz, rx, ry, rz, rw, wakeUp);
|
|
4532
|
+
}
|
|
4533
|
+
/**
|
|
4489
4534
|
* Sets the translation of this rigid-body.
|
|
4490
4535
|
*
|
|
4491
4536
|
* # Parameters
|
|
@@ -6334,6 +6379,33 @@ var RigidBody = class {
|
|
|
6334
6379
|
this.rawSet.rbSetNextKinematicRotation(this.handle, rot.x, rot.y, rot.z, rot.w);
|
|
6335
6380
|
}
|
|
6336
6381
|
/**
|
|
6382
|
+
* Sets both the translation and rotation of this rigid-body in a single WASM call.
|
|
6383
|
+
*
|
|
6384
|
+
* This is more efficient than calling `setTranslation` and `setRotation` separately
|
|
6385
|
+
* when both need to be updated.
|
|
6386
|
+
*
|
|
6387
|
+
* @param tra - The world-space position of the rigid-body.
|
|
6388
|
+
* @param rot - The rotation to set.
|
|
6389
|
+
* @param wakeUp - Forces the rigid-body to wake-up so it is properly affected by forces if it
|
|
6390
|
+
* wasn't moving before modifying its position.
|
|
6391
|
+
*/
|
|
6392
|
+
setTransform(tra, rot, wakeUp) {
|
|
6393
|
+
this.rawSet.rbSetTransform(this.handle, tra.x, tra.y, tra.z, rot.x, rot.y, rot.z, rot.w, wakeUp);
|
|
6394
|
+
}
|
|
6395
|
+
/**
|
|
6396
|
+
* If this rigid body is kinematic, sets its future translation and rotation after the next
|
|
6397
|
+
* timestep integration in a single WASM call.
|
|
6398
|
+
*
|
|
6399
|
+
* This is more efficient than calling `setNextKinematicTranslation` and `setNextKinematicRotation`
|
|
6400
|
+
* separately when both need to be updated.
|
|
6401
|
+
*
|
|
6402
|
+
* @param tra - The kinematic translation to set.
|
|
6403
|
+
* @param rot - The kinematic rotation to set.
|
|
6404
|
+
*/
|
|
6405
|
+
setNextKinematicTransform(tra, rot) {
|
|
6406
|
+
this.rawSet.rbSetNextKinematicTransform(this.handle, tra.x, tra.y, tra.z, rot.x, rot.y, rot.z, rot.w);
|
|
6407
|
+
}
|
|
6408
|
+
/**
|
|
6337
6409
|
* The linear velocity of this rigid-body.
|
|
6338
6410
|
*
|
|
6339
6411
|
* @param target - Optional target object to write the result to (avoids allocation).
|
|
@@ -8284,12 +8356,7 @@ var BroadPhase = class {
|
|
|
8284
8356
|
* @param filter - The callback to filter out which collider will be hit.
|
|
8285
8357
|
*/
|
|
8286
8358
|
castRay(narrowPhase, bodies, colliders, ray, maxToi, solid, filterFlags, filterGroups, filterExcludeCollider, filterExcludeRigidBody, filterPredicate) {
|
|
8287
|
-
|
|
8288
|
-
let rawDir = VectorOps.intoRaw(ray.dir);
|
|
8289
|
-
let result = RayColliderHit.fromRaw(colliders, this.raw.castRay(narrowPhase.raw, bodies.raw, colliders.raw, rawOrig, rawDir, maxToi, solid, filterFlags ?? 0, filterGroups, filterExcludeCollider, filterExcludeRigidBody, filterPredicate));
|
|
8290
|
-
rawOrig.free();
|
|
8291
|
-
rawDir.free();
|
|
8292
|
-
return result;
|
|
8359
|
+
return RayColliderHit.fromRaw(colliders, this.raw.castRay(narrowPhase.raw, bodies.raw, colliders.raw, ray.origin.x, ray.origin.y, ray.origin.z, ray.dir.x, ray.dir.y, ray.dir.z, maxToi, solid, filterFlags ?? 0, filterGroups, filterExcludeCollider, filterExcludeRigidBody, filterPredicate));
|
|
8293
8360
|
}
|
|
8294
8361
|
/**
|
|
8295
8362
|
* Find the closest intersection between a ray and a set of collider.
|
|
@@ -8305,12 +8372,7 @@ var BroadPhase = class {
|
|
|
8305
8372
|
* @param groups - Used to filter the colliders that can or cannot be hit by the ray.
|
|
8306
8373
|
*/
|
|
8307
8374
|
castRayAndGetNormal(narrowPhase, bodies, colliders, ray, maxToi, solid, filterFlags, filterGroups, filterExcludeCollider, filterExcludeRigidBody, filterPredicate) {
|
|
8308
|
-
|
|
8309
|
-
let rawDir = VectorOps.intoRaw(ray.dir);
|
|
8310
|
-
let result = RayColliderIntersection.fromRaw(colliders, this.raw.castRayAndGetNormal(narrowPhase.raw, bodies.raw, colliders.raw, rawOrig, rawDir, maxToi, solid, filterFlags ?? 0, filterGroups, filterExcludeCollider, filterExcludeRigidBody, filterPredicate));
|
|
8311
|
-
rawOrig.free();
|
|
8312
|
-
rawDir.free();
|
|
8313
|
-
return result;
|
|
8375
|
+
return RayColliderIntersection.fromRaw(colliders, this.raw.castRayAndGetNormal(narrowPhase.raw, bodies.raw, colliders.raw, ray.origin.x, ray.origin.y, ray.origin.z, ray.dir.x, ray.dir.y, ray.dir.z, maxToi, solid, filterFlags ?? 0, filterGroups, filterExcludeCollider, filterExcludeRigidBody, filterPredicate));
|
|
8314
8376
|
}
|
|
8315
8377
|
/**
|
|
8316
8378
|
* Cast a ray and collects all the intersections between a ray and the scene.
|
|
@@ -8327,14 +8389,10 @@ var BroadPhase = class {
|
|
|
8327
8389
|
* If this callback returns `false`, then the cast will stop and no further hits will be detected/reported.
|
|
8328
8390
|
*/
|
|
8329
8391
|
intersectionsWithRay(narrowPhase, bodies, colliders, ray, maxToi, solid, callback, filterFlags, filterGroups, filterExcludeCollider, filterExcludeRigidBody, filterPredicate) {
|
|
8330
|
-
let rawOrig = VectorOps.intoRaw(ray.origin);
|
|
8331
|
-
let rawDir = VectorOps.intoRaw(ray.dir);
|
|
8332
8392
|
let rawCallback = (rawInter) => {
|
|
8333
8393
|
return callback(RayColliderIntersection.fromRaw(colliders, rawInter));
|
|
8334
8394
|
};
|
|
8335
|
-
this.raw.intersectionsWithRay(narrowPhase.raw, bodies.raw, colliders.raw,
|
|
8336
|
-
rawOrig.free();
|
|
8337
|
-
rawDir.free();
|
|
8395
|
+
this.raw.intersectionsWithRay(narrowPhase.raw, bodies.raw, colliders.raw, ray.origin.x, ray.origin.y, ray.origin.z, ray.dir.x, ray.dir.y, ray.dir.z, maxToi, solid, rawCallback, filterFlags ?? 0, filterGroups, filterExcludeCollider, filterExcludeRigidBody, filterPredicate);
|
|
8338
8396
|
}
|
|
8339
8397
|
/**
|
|
8340
8398
|
* Gets the handle of up to one collider intersecting the given shape.
|