@alexandernanberg/rapier3d 0.0.1 → 0.0.2
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 +182 -5
- package/dist/compat-simd.d.mts.map +1 -1
- package/dist/compat-simd.mjs +283 -37
- package/dist/compat-simd.mjs.map +1 -1
- package/dist/compat.d.mts +182 -5
- package/dist/compat.d.mts.map +1 -1
- package/dist/compat.mjs +283 -37
- package/dist/compat.mjs.map +1 -1
- package/dist/rapier.d.mts +182 -5
- package/dist/rapier.d.mts.map +1 -1
- package/dist/rapier.mjs +282 -36
- 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 +182 -5
- package/dist/simd.d.mts.map +1 -1
- package/dist/simd.mjs +282 -36
- package/dist/simd.mjs.map +1 -1
- package/package.json +1 -1
package/dist/simd.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,41 @@ 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
|
+
/**
|
|
4464
|
+
* Sets next kinematic transforms for multiple rigid-bodies in a single WASM call.
|
|
4465
|
+
*
|
|
4466
|
+
* # Parameters
|
|
4467
|
+
* - `data`: Float32Array with layout [handle, tx, ty, tz, rx, ry, rz, rw] × N
|
|
4468
|
+
* - `count`: Number of bodies in the batch
|
|
4469
|
+
* @param {Float32Array} data
|
|
4470
|
+
* @param {number} count
|
|
4471
|
+
*/
|
|
4472
|
+
rbSetNextKinematicTransformsBatch(data, count) {
|
|
4473
|
+
try {
|
|
4474
|
+
wasm.rawrigidbodyset_rbSetNextKinematicTransformsBatch(this.__wbg_ptr, addBorrowedObject(data), count);
|
|
4475
|
+
} finally {
|
|
4476
|
+
heap[stack_pointer++] = void 0;
|
|
4477
|
+
}
|
|
4478
|
+
}
|
|
4479
|
+
/**
|
|
4439
4480
|
* If this rigid body is kinematic, sets its future translation after the next timestep integration.
|
|
4440
4481
|
*
|
|
4441
4482
|
* This should be used instead of `rigidBody.setTranslation` to make the dynamic object
|
|
@@ -4486,6 +4527,44 @@ var RawRigidBodySet = class RawRigidBodySet {
|
|
|
4486
4527
|
wasm.rawrigidbodyset_rbSetSoftCcdPrediction(this.__wbg_ptr, handle, prediction);
|
|
4487
4528
|
}
|
|
4488
4529
|
/**
|
|
4530
|
+
* Sets both the translation and rotation of this rigid-body in a single WASM call.
|
|
4531
|
+
*
|
|
4532
|
+
* # Parameters
|
|
4533
|
+
* - `tx`, `ty`, `tz`: the world-space position of the rigid-body.
|
|
4534
|
+
* - `rx`, `ry`, `rz`, `rw`: the rotation quaternion components.
|
|
4535
|
+
* - `wakeUp`: forces the rigid-body to wake-up so it is properly affected by forces.
|
|
4536
|
+
* @param {number} handle
|
|
4537
|
+
* @param {number} tx
|
|
4538
|
+
* @param {number} ty
|
|
4539
|
+
* @param {number} tz
|
|
4540
|
+
* @param {number} rx
|
|
4541
|
+
* @param {number} ry
|
|
4542
|
+
* @param {number} rz
|
|
4543
|
+
* @param {number} rw
|
|
4544
|
+
* @param {boolean} wakeUp
|
|
4545
|
+
*/
|
|
4546
|
+
rbSetTransform(handle, tx, ty, tz, rx, ry, rz, rw, wakeUp) {
|
|
4547
|
+
wasm.rawrigidbodyset_rbSetTransform(this.__wbg_ptr, handle, tx, ty, tz, rx, ry, rz, rw, wakeUp);
|
|
4548
|
+
}
|
|
4549
|
+
/**
|
|
4550
|
+
* Sets transforms for multiple rigid-bodies in a single WASM call.
|
|
4551
|
+
*
|
|
4552
|
+
* # Parameters
|
|
4553
|
+
* - `data`: Float32Array with layout [handle, tx, ty, tz, rx, ry, rz, rw] × N
|
|
4554
|
+
* - `count`: Number of bodies in the batch
|
|
4555
|
+
* - `wakeUp`: forces the rigid-bodies to wake-up
|
|
4556
|
+
* @param {Float32Array} data
|
|
4557
|
+
* @param {number} count
|
|
4558
|
+
* @param {boolean} wakeUp
|
|
4559
|
+
*/
|
|
4560
|
+
rbSetTransformsBatch(data, count, wakeUp) {
|
|
4561
|
+
try {
|
|
4562
|
+
wasm.rawrigidbodyset_rbSetTransformsBatch(this.__wbg_ptr, addBorrowedObject(data), count, wakeUp);
|
|
4563
|
+
} finally {
|
|
4564
|
+
heap[stack_pointer++] = void 0;
|
|
4565
|
+
}
|
|
4566
|
+
}
|
|
4567
|
+
/**
|
|
4489
4568
|
* Sets the translation of this rigid-body.
|
|
4490
4569
|
*
|
|
4491
4570
|
* # Parameters
|
|
@@ -5535,6 +5614,9 @@ function __wbg_get_imports() {
|
|
|
5535
5614
|
__wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {
|
|
5536
5615
|
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
|
|
5537
5616
|
},
|
|
5617
|
+
__wbg_prototypesetcall_c7e6a26aeade796d: function(arg0, arg1, arg2) {
|
|
5618
|
+
Float32Array.prototype.set.call(getArrayF32FromWasm0(arg0, arg1), getObject(arg2));
|
|
5619
|
+
},
|
|
5538
5620
|
__wbg_rawcontactforceevent_new: function(arg0) {
|
|
5539
5621
|
return addHeapObject(RawContactForceEvent.__wrap(arg0));
|
|
5540
5622
|
},
|
|
@@ -6334,6 +6416,33 @@ var RigidBody = class {
|
|
|
6334
6416
|
this.rawSet.rbSetNextKinematicRotation(this.handle, rot.x, rot.y, rot.z, rot.w);
|
|
6335
6417
|
}
|
|
6336
6418
|
/**
|
|
6419
|
+
* Sets both the translation and rotation of this rigid-body in a single WASM call.
|
|
6420
|
+
*
|
|
6421
|
+
* This is more efficient than calling `setTranslation` and `setRotation` separately
|
|
6422
|
+
* when both need to be updated.
|
|
6423
|
+
*
|
|
6424
|
+
* @param tra - The world-space position of the rigid-body.
|
|
6425
|
+
* @param rot - The rotation to set.
|
|
6426
|
+
* @param wakeUp - Forces the rigid-body to wake-up so it is properly affected by forces if it
|
|
6427
|
+
* wasn't moving before modifying its position.
|
|
6428
|
+
*/
|
|
6429
|
+
setTransform(tra, rot, wakeUp) {
|
|
6430
|
+
this.rawSet.rbSetTransform(this.handle, tra.x, tra.y, tra.z, rot.x, rot.y, rot.z, rot.w, wakeUp);
|
|
6431
|
+
}
|
|
6432
|
+
/**
|
|
6433
|
+
* If this rigid body is kinematic, sets its future translation and rotation after the next
|
|
6434
|
+
* timestep integration in a single WASM call.
|
|
6435
|
+
*
|
|
6436
|
+
* This is more efficient than calling `setNextKinematicTranslation` and `setNextKinematicRotation`
|
|
6437
|
+
* separately when both need to be updated.
|
|
6438
|
+
*
|
|
6439
|
+
* @param tra - The kinematic translation to set.
|
|
6440
|
+
* @param rot - The kinematic rotation to set.
|
|
6441
|
+
*/
|
|
6442
|
+
setNextKinematicTransform(tra, rot) {
|
|
6443
|
+
this.rawSet.rbSetNextKinematicTransform(this.handle, tra.x, tra.y, tra.z, rot.x, rot.y, rot.z, rot.w);
|
|
6444
|
+
}
|
|
6445
|
+
/**
|
|
6337
6446
|
* The linear velocity of this rigid-body.
|
|
6338
6447
|
*
|
|
6339
6448
|
* @param target - Optional target object to write the result to (avoids allocation).
|
|
@@ -8088,6 +8197,111 @@ var IslandManager = class {
|
|
|
8088
8197
|
}
|
|
8089
8198
|
};
|
|
8090
8199
|
|
|
8200
|
+
//#endregion
|
|
8201
|
+
//#region src/dynamics/transform_batch.ts
|
|
8202
|
+
/**
|
|
8203
|
+
* A batch of transforms for efficient bulk updates.
|
|
8204
|
+
*
|
|
8205
|
+
* This class allows you to collect multiple body transforms and apply them
|
|
8206
|
+
* all in a single WASM call, reducing boundary-crossing overhead.
|
|
8207
|
+
*
|
|
8208
|
+
* @example
|
|
8209
|
+
* ```typescript
|
|
8210
|
+
* const batch = RAPIER.createTransformBatch(1000);
|
|
8211
|
+
*
|
|
8212
|
+
* // In your game loop:
|
|
8213
|
+
* batch.clear();
|
|
8214
|
+
* for (const body of kinematicBodies) {
|
|
8215
|
+
* batch.add(body.handle, mesh.position, mesh.quaternion);
|
|
8216
|
+
* }
|
|
8217
|
+
* world.setNextKinematicTransformsBatch(batch);
|
|
8218
|
+
* world.step();
|
|
8219
|
+
* ```
|
|
8220
|
+
*/
|
|
8221
|
+
var TransformBatch = class TransformBatch {
|
|
8222
|
+
static {
|
|
8223
|
+
this.FLOATS_PER_ENTRY = 8;
|
|
8224
|
+
}
|
|
8225
|
+
/**
|
|
8226
|
+
* Creates a new TransformBatch with the given initial capacity.
|
|
8227
|
+
*
|
|
8228
|
+
* @param capacity - The initial number of transforms this batch can hold.
|
|
8229
|
+
*/
|
|
8230
|
+
constructor(capacity) {
|
|
8231
|
+
this.count = 0;
|
|
8232
|
+
this.buffer = new Float32Array(capacity * TransformBatch.FLOATS_PER_ENTRY);
|
|
8233
|
+
}
|
|
8234
|
+
/**
|
|
8235
|
+
* The current number of transforms in the batch.
|
|
8236
|
+
*/
|
|
8237
|
+
get length() {
|
|
8238
|
+
return this.count;
|
|
8239
|
+
}
|
|
8240
|
+
/**
|
|
8241
|
+
* The maximum number of transforms this batch can hold without growing.
|
|
8242
|
+
*/
|
|
8243
|
+
get capacity() {
|
|
8244
|
+
return this.buffer.length / TransformBatch.FLOATS_PER_ENTRY;
|
|
8245
|
+
}
|
|
8246
|
+
/**
|
|
8247
|
+
* Clears all transforms from the batch.
|
|
8248
|
+
* Call this at the start of each frame before adding new transforms.
|
|
8249
|
+
*/
|
|
8250
|
+
clear() {
|
|
8251
|
+
this.count = 0;
|
|
8252
|
+
}
|
|
8253
|
+
/**
|
|
8254
|
+
* Adds a transform to the batch.
|
|
8255
|
+
*
|
|
8256
|
+
* @param handle - The rigid body handle.
|
|
8257
|
+
* @param translation - The position to set.
|
|
8258
|
+
* @param rotation - The rotation quaternion to set.
|
|
8259
|
+
*/
|
|
8260
|
+
add(handle, translation, rotation) {
|
|
8261
|
+
if (this.count >= this.capacity) this.grow();
|
|
8262
|
+
const offset = this.count * TransformBatch.FLOATS_PER_ENTRY;
|
|
8263
|
+
this.buffer[offset] = handle;
|
|
8264
|
+
this.buffer[offset + 1] = translation.x;
|
|
8265
|
+
this.buffer[offset + 2] = translation.y;
|
|
8266
|
+
this.buffer[offset + 3] = translation.z;
|
|
8267
|
+
this.buffer[offset + 4] = rotation.x;
|
|
8268
|
+
this.buffer[offset + 5] = rotation.y;
|
|
8269
|
+
this.buffer[offset + 6] = rotation.z;
|
|
8270
|
+
this.buffer[offset + 7] = rotation.w;
|
|
8271
|
+
this.count++;
|
|
8272
|
+
}
|
|
8273
|
+
grow() {
|
|
8274
|
+
const newBuffer = new Float32Array(this.buffer.length * 2);
|
|
8275
|
+
newBuffer.set(this.buffer);
|
|
8276
|
+
this.buffer = newBuffer;
|
|
8277
|
+
}
|
|
8278
|
+
};
|
|
8279
|
+
/**
|
|
8280
|
+
* Creates a new TransformBatch for efficient bulk body updates.
|
|
8281
|
+
*
|
|
8282
|
+
* @param capacity - The initial number of transforms the batch can hold.
|
|
8283
|
+
* The batch will automatically grow if more are added.
|
|
8284
|
+
* @returns A new TransformBatch instance.
|
|
8285
|
+
*
|
|
8286
|
+
* @example
|
|
8287
|
+
* ```typescript
|
|
8288
|
+
* // Create once, reuse every frame
|
|
8289
|
+
* const batch = RAPIER.createTransformBatch(1000);
|
|
8290
|
+
*
|
|
8291
|
+
* function update() {
|
|
8292
|
+
* batch.clear();
|
|
8293
|
+
* for (const body of kinematicBodies) {
|
|
8294
|
+
* batch.add(body.handle, mesh.position, mesh.quaternion);
|
|
8295
|
+
* }
|
|
8296
|
+
* world.setNextKinematicTransformsBatch(batch);
|
|
8297
|
+
* world.step();
|
|
8298
|
+
* }
|
|
8299
|
+
* ```
|
|
8300
|
+
*/
|
|
8301
|
+
function createTransformBatch(capacity) {
|
|
8302
|
+
return new TransformBatch(capacity);
|
|
8303
|
+
}
|
|
8304
|
+
|
|
8091
8305
|
//#endregion
|
|
8092
8306
|
//#region src/geometry/feature.ts
|
|
8093
8307
|
let FeatureType = /* @__PURE__ */ function(FeatureType) {
|
|
@@ -8284,12 +8498,7 @@ var BroadPhase = class {
|
|
|
8284
8498
|
* @param filter - The callback to filter out which collider will be hit.
|
|
8285
8499
|
*/
|
|
8286
8500
|
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;
|
|
8501
|
+
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
8502
|
}
|
|
8294
8503
|
/**
|
|
8295
8504
|
* Find the closest intersection between a ray and a set of collider.
|
|
@@ -8305,12 +8514,7 @@ var BroadPhase = class {
|
|
|
8305
8514
|
* @param groups - Used to filter the colliders that can or cannot be hit by the ray.
|
|
8306
8515
|
*/
|
|
8307
8516
|
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;
|
|
8517
|
+
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
8518
|
}
|
|
8315
8519
|
/**
|
|
8316
8520
|
* Cast a ray and collects all the intersections between a ray and the scene.
|
|
@@ -8327,14 +8531,10 @@ var BroadPhase = class {
|
|
|
8327
8531
|
* If this callback returns `false`, then the cast will stop and no further hits will be detected/reported.
|
|
8328
8532
|
*/
|
|
8329
8533
|
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
8534
|
let rawCallback = (rawInter) => {
|
|
8333
8535
|
return callback(RayColliderIntersection.fromRaw(colliders, rawInter));
|
|
8334
8536
|
};
|
|
8335
|
-
this.raw.intersectionsWithRay(narrowPhase.raw, bodies.raw, colliders.raw,
|
|
8336
|
-
rawOrig.free();
|
|
8337
|
-
rawDir.free();
|
|
8537
|
+
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
8538
|
}
|
|
8339
8539
|
/**
|
|
8340
8540
|
* Gets the handle of up to one collider intersecting the given shape.
|
|
@@ -10445,6 +10645,50 @@ var World = class World {
|
|
|
10445
10645
|
return this.bodies.createRigidBody(this.colliders, body);
|
|
10446
10646
|
}
|
|
10447
10647
|
/**
|
|
10648
|
+
* Sets transforms for multiple rigid-bodies in a single WASM call.
|
|
10649
|
+
*
|
|
10650
|
+
* This is more efficient than calling `setTransform` on each body individually
|
|
10651
|
+
* when you need to update many bodies at once.
|
|
10652
|
+
*
|
|
10653
|
+
* @param batch - The batch of transforms to apply.
|
|
10654
|
+
* @param wakeUp - Forces the rigid-bodies to wake-up so they are properly affected by forces.
|
|
10655
|
+
*
|
|
10656
|
+
* @example
|
|
10657
|
+
* ```typescript
|
|
10658
|
+
* const batch = RAPIER.createTransformBatch(1000);
|
|
10659
|
+
* batch.clear();
|
|
10660
|
+
* for (const body of dynamicBodies) {
|
|
10661
|
+
* batch.add(body.handle, newPosition, newRotation);
|
|
10662
|
+
* }
|
|
10663
|
+
* world.setTransformsBatch(batch, true);
|
|
10664
|
+
* ```
|
|
10665
|
+
*/
|
|
10666
|
+
setTransformsBatch(batch, wakeUp) {
|
|
10667
|
+
this.bodies.raw.rbSetTransformsBatch(batch.buffer, batch.count, wakeUp);
|
|
10668
|
+
}
|
|
10669
|
+
/**
|
|
10670
|
+
* Sets next kinematic transforms for multiple rigid-bodies in a single WASM call.
|
|
10671
|
+
*
|
|
10672
|
+
* This is more efficient than calling `setNextKinematicTransform` on each body individually
|
|
10673
|
+
* when you need to update many kinematic bodies at once.
|
|
10674
|
+
*
|
|
10675
|
+
* @param batch - The batch of transforms to apply.
|
|
10676
|
+
*
|
|
10677
|
+
* @example
|
|
10678
|
+
* ```typescript
|
|
10679
|
+
* const batch = RAPIER.createTransformBatch(1000);
|
|
10680
|
+
* batch.clear();
|
|
10681
|
+
* for (const body of kinematicBodies) {
|
|
10682
|
+
* batch.add(body.handle, mesh.position, mesh.quaternion);
|
|
10683
|
+
* }
|
|
10684
|
+
* world.setNextKinematicTransformsBatch(batch);
|
|
10685
|
+
* world.step();
|
|
10686
|
+
* ```
|
|
10687
|
+
*/
|
|
10688
|
+
setNextKinematicTransformsBatch(batch) {
|
|
10689
|
+
this.bodies.raw.rbSetNextKinematicTransformsBatch(batch.buffer, batch.count);
|
|
10690
|
+
}
|
|
10691
|
+
/**
|
|
10448
10692
|
* Creates a new character controller.
|
|
10449
10693
|
*
|
|
10450
10694
|
* @param offset - The artificial gap added between the character’s chape and its environment.
|
|
@@ -12574,6 +12818,7 @@ var exports_exports = /* @__PURE__ */ __exportAll({
|
|
|
12574
12818
|
SpringImpulseJoint: () => SpringImpulseJoint,
|
|
12575
12819
|
TempContactForceEvent: () => TempContactForceEvent,
|
|
12576
12820
|
TempContactManifold: () => TempContactManifold,
|
|
12821
|
+
TransformBatch: () => TransformBatch,
|
|
12577
12822
|
TriMesh: () => TriMesh,
|
|
12578
12823
|
TriMeshFlags: () => TriMeshFlags,
|
|
12579
12824
|
Triangle: () => Triangle,
|
|
@@ -12583,6 +12828,7 @@ var exports_exports = /* @__PURE__ */ __exportAll({
|
|
|
12583
12828
|
VectorOps: () => VectorOps,
|
|
12584
12829
|
Voxels: () => Voxels,
|
|
12585
12830
|
World: () => World,
|
|
12831
|
+
createTransformBatch: () => createTransformBatch,
|
|
12586
12832
|
reserveMemory: () => reserveMemory,
|
|
12587
12833
|
version: () => version
|
|
12588
12834
|
});
|
|
@@ -12609,5 +12855,5 @@ async function init(input) {
|
|
|
12609
12855
|
var rapier_simd_default = exports_exports;
|
|
12610
12856
|
|
|
12611
12857
|
//#endregion
|
|
12612
|
-
export { ActiveCollisionTypes, ActiveEvents, ActiveHooks, Ball, BroadPhase, CCDSolver, Capsule, CharacterCollision, CoefficientCombineRule, Collider, ColliderDesc, ColliderSet, ColliderShapeCastHit, Cone, ConvexPolyhedron, Cuboid, Cylinder, DebugRenderBuffers, DebugRenderPipeline, DynamicRayCastVehicleController, EventQueue, FeatureType, FixedImpulseJoint, FixedMultibodyJoint, GenericImpulseJoint, HalfSpace, HeightFieldFlags, Heightfield, ImpulseJoint, ImpulseJointSet, IntegrationParameters, IslandManager, JointAxesMask, JointData, JointType, KinematicCharacterController, MassPropsMode, MotorModel, MultibodyJoint, MultibodyJointSet, NarrowPhase, PhysicsPipeline, PidAxesMask, PidController, PointColliderProjection, PointProjection, Polyline, PrismaticImpulseJoint, PrismaticMultibodyJoint, Quaternion, QueryFilterFlags, Ray, RayColliderHit, RayColliderIntersection, RayIntersection, RevoluteImpulseJoint, RevoluteMultibodyJoint, RigidBody, RigidBodyDesc, RigidBodySet, RigidBodyType, RopeImpulseJoint, RotationOps, RoundCone, RoundConvexPolyhedron, RoundCuboid, RoundCylinder, RoundTriangle, SdpMatrix3, SdpMatrix3Ops, Segment, SerializationPipeline, Shape, ShapeCastHit, ShapeContact, ShapeType, SolverFlags, SphericalImpulseJoint, SphericalMultibodyJoint, SpringImpulseJoint, TempContactForceEvent, TempContactManifold, TriMesh, TriMeshFlags, Triangle, UnitImpulseJoint, UnitMultibodyJoint, Vector3, VectorOps, Voxels, World, rapier_simd_default as default, init, reserveMemory, version };
|
|
12858
|
+
export { ActiveCollisionTypes, ActiveEvents, ActiveHooks, Ball, BroadPhase, CCDSolver, Capsule, CharacterCollision, CoefficientCombineRule, Collider, ColliderDesc, ColliderSet, ColliderShapeCastHit, Cone, ConvexPolyhedron, Cuboid, Cylinder, DebugRenderBuffers, DebugRenderPipeline, DynamicRayCastVehicleController, EventQueue, FeatureType, FixedImpulseJoint, FixedMultibodyJoint, GenericImpulseJoint, HalfSpace, HeightFieldFlags, Heightfield, ImpulseJoint, ImpulseJointSet, IntegrationParameters, IslandManager, JointAxesMask, JointData, JointType, KinematicCharacterController, MassPropsMode, MotorModel, MultibodyJoint, MultibodyJointSet, NarrowPhase, PhysicsPipeline, PidAxesMask, PidController, PointColliderProjection, PointProjection, Polyline, PrismaticImpulseJoint, PrismaticMultibodyJoint, Quaternion, QueryFilterFlags, Ray, RayColliderHit, RayColliderIntersection, RayIntersection, RevoluteImpulseJoint, RevoluteMultibodyJoint, RigidBody, RigidBodyDesc, RigidBodySet, RigidBodyType, RopeImpulseJoint, RotationOps, RoundCone, RoundConvexPolyhedron, RoundCuboid, RoundCylinder, RoundTriangle, SdpMatrix3, SdpMatrix3Ops, Segment, SerializationPipeline, Shape, ShapeCastHit, ShapeContact, ShapeType, SolverFlags, SphericalImpulseJoint, SphericalMultibodyJoint, SpringImpulseJoint, TempContactForceEvent, TempContactManifold, TransformBatch, TriMesh, TriMeshFlags, Triangle, UnitImpulseJoint, UnitMultibodyJoint, Vector3, VectorOps, Voxels, World, createTransformBatch, rapier_simd_default as default, init, reserveMemory, version };
|
|
12613
12859
|
//# sourceMappingURL=simd.mjs.map
|