@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/rapier.d.mts CHANGED
@@ -4,13 +4,13 @@
4
4
  declare class RawBroadPhase {
5
5
  free(): void;
6
6
  [Symbol.dispose](): void;
7
- castRay(narrow_phase: RawNarrowPhase, bodies: RawRigidBodySet, colliders: RawColliderSet, rayOrig: RawVector, rayDir: RawVector, maxToi: number, solid: boolean, filter_flags: number, filter_groups: number | null | undefined, filter_exclude_collider: number | null | undefined, filter_exclude_rigid_body: number | null | undefined, filter_predicate: Function): RawRayColliderHit | undefined;
8
- castRayAndGetNormal(narrow_phase: RawNarrowPhase, bodies: RawRigidBodySet, colliders: RawColliderSet, rayOrig: RawVector, rayDir: RawVector, maxToi: number, solid: boolean, filter_flags: number, filter_groups: number | null | undefined, filter_exclude_collider: number | null | undefined, filter_exclude_rigid_body: number | null | undefined, filter_predicate: Function): RawRayColliderIntersection | undefined;
7
+ castRay(narrow_phase: RawNarrowPhase, bodies: RawRigidBodySet, colliders: RawColliderSet, ray_ox: number, ray_oy: number, ray_oz: number, ray_dx: number, ray_dy: number, ray_dz: number, maxToi: number, solid: boolean, filter_flags: number, filter_groups: number | null | undefined, filter_exclude_collider: number | null | undefined, filter_exclude_rigid_body: number | null | undefined, filter_predicate: Function): RawRayColliderHit | undefined;
8
+ castRayAndGetNormal(narrow_phase: RawNarrowPhase, bodies: RawRigidBodySet, colliders: RawColliderSet, ray_ox: number, ray_oy: number, ray_oz: number, ray_dx: number, ray_dy: number, ray_dz: number, maxToi: number, solid: boolean, filter_flags: number, filter_groups: number | null | undefined, filter_exclude_collider: number | null | undefined, filter_exclude_rigid_body: number | null | undefined, filter_predicate: Function): RawRayColliderIntersection | undefined;
9
9
  castShape(narrow_phase: RawNarrowPhase, bodies: RawRigidBodySet, colliders: RawColliderSet, shapePos: RawVector, shapeRot: RawRotation, shapeVel: RawVector, shape: RawShape, target_distance: number, maxToi: number, stop_at_penetration: boolean, filter_flags: number, filter_groups: number | null | undefined, filter_exclude_collider: number | null | undefined, filter_exclude_rigid_body: number | null | undefined, filter_predicate: Function): RawColliderShapeCastHit | undefined;
10
10
  collidersWithAabbIntersectingAabb(narrow_phase: RawNarrowPhase, bodies: RawRigidBodySet, colliders: RawColliderSet, aabbCenter: RawVector, aabbHalfExtents: RawVector, callback: Function): void;
11
11
  intersectionWithShape(narrow_phase: RawNarrowPhase, bodies: RawRigidBodySet, colliders: RawColliderSet, shapePos: RawVector, shapeRot: RawRotation, shape: RawShape, filter_flags: number, filter_groups: number | null | undefined, filter_exclude_collider: number | null | undefined, filter_exclude_rigid_body: number | null | undefined, filter_predicate: Function): number | undefined;
12
12
  intersectionsWithPoint(narrow_phase: RawNarrowPhase, bodies: RawRigidBodySet, colliders: RawColliderSet, point: RawVector, callback: Function, filter_flags: number, filter_groups: number | null | undefined, filter_exclude_collider: number | null | undefined, filter_exclude_rigid_body: number | null | undefined, filter_predicate: Function): void;
13
- intersectionsWithRay(narrow_phase: RawNarrowPhase, bodies: RawRigidBodySet, colliders: RawColliderSet, rayOrig: RawVector, rayDir: RawVector, maxToi: number, solid: boolean, callback: Function, filter_flags: number, filter_groups: number | null | undefined, filter_exclude_collider: number | null | undefined, filter_exclude_rigid_body: number | null | undefined, filter_predicate: Function): void;
13
+ intersectionsWithRay(narrow_phase: RawNarrowPhase, bodies: RawRigidBodySet, colliders: RawColliderSet, ray_ox: number, ray_oy: number, ray_oz: number, ray_dx: number, ray_dy: number, ray_dz: number, maxToi: number, solid: boolean, callback: Function, filter_flags: number, filter_groups: number | null | undefined, filter_exclude_collider: number | null | undefined, filter_exclude_rigid_body: number | null | undefined, filter_predicate: Function): void;
14
14
  intersectionsWithShape(narrow_phase: RawNarrowPhase, bodies: RawRigidBodySet, colliders: RawColliderSet, shapePos: RawVector, shapeRot: RawRotation, shape: RawShape, callback: Function, filter_flags: number, filter_groups: number | null | undefined, filter_exclude_collider: number | null | undefined, filter_exclude_rigid_body: number | null | undefined, filter_predicate: Function): void;
15
15
  constructor();
16
16
  projectPoint(narrow_phase: RawNarrowPhase, bodies: RawRigidBodySet, colliders: RawColliderSet, point: RawVector, solid: boolean, filter_flags: number, filter_groups: number | null | undefined, filter_exclude_collider: number | null | undefined, filter_exclude_rigid_body: number | null | undefined, filter_predicate: Function): RawPointColliderProjection | undefined;
@@ -959,6 +959,23 @@ declare class RawRigidBodySet {
959
959
  * - `w`: the scalar component of the quaternion.
960
960
  */
961
961
  rbSetNextKinematicRotation(handle: number, x: number, y: number, z: number, w: number): void;
962
+ /**
963
+ * If this rigid body is kinematic, sets its future translation and rotation after the next
964
+ * timestep integration in a single WASM call.
965
+ *
966
+ * # Parameters
967
+ * - `tx`, `ty`, `tz`: the world-space position of the rigid-body.
968
+ * - `rx`, `ry`, `rz`, `rw`: the rotation quaternion components.
969
+ */
970
+ rbSetNextKinematicTransform(handle: number, tx: number, ty: number, tz: number, rx: number, ry: number, rz: number, rw: number): void;
971
+ /**
972
+ * Sets next kinematic transforms for multiple rigid-bodies in a single WASM call.
973
+ *
974
+ * # Parameters
975
+ * - `data`: Float32Array with layout [handle, tx, ty, tz, rx, ry, rz, rw] × N
976
+ * - `count`: Number of bodies in the batch
977
+ */
978
+ rbSetNextKinematicTransformsBatch(data: Float32Array, count: number): void;
962
979
  /**
963
980
  * If this rigid body is kinematic, sets its future translation after the next timestep integration.
964
981
  *
@@ -989,6 +1006,24 @@ declare class RawRigidBodySet {
989
1006
  */
990
1007
  rbSetRotation(handle: number, x: number, y: number, z: number, w: number, wakeUp: boolean): void;
991
1008
  rbSetSoftCcdPrediction(handle: number, prediction: number): void;
1009
+ /**
1010
+ * Sets both the translation and rotation of this rigid-body in a single WASM call.
1011
+ *
1012
+ * # Parameters
1013
+ * - `tx`, `ty`, `tz`: the world-space position of the rigid-body.
1014
+ * - `rx`, `ry`, `rz`, `rw`: the rotation quaternion components.
1015
+ * - `wakeUp`: forces the rigid-body to wake-up so it is properly affected by forces.
1016
+ */
1017
+ rbSetTransform(handle: number, tx: number, ty: number, tz: number, rx: number, ry: number, rz: number, rw: number, wakeUp: boolean): void;
1018
+ /**
1019
+ * Sets transforms for multiple rigid-bodies in a single WASM call.
1020
+ *
1021
+ * # Parameters
1022
+ * - `data`: Float32Array with layout [handle, tx, ty, tz, rx, ry, rz, rw] × N
1023
+ * - `count`: Number of bodies in the batch
1024
+ * - `wakeUp`: forces the rigid-bodies to wake-up
1025
+ */
1026
+ rbSetTransformsBatch(data: Float32Array, count: number, wakeUp: boolean): void;
992
1027
  /**
993
1028
  * Sets the translation of this rigid-body.
994
1029
  *
@@ -2242,6 +2277,46 @@ declare class World {
2242
2277
  * @param body - The description of the rigid-body to create.
2243
2278
  */
2244
2279
  createRigidBody(body: RigidBodyDesc): RigidBody;
2280
+ /**
2281
+ * Sets transforms for multiple rigid-bodies in a single WASM call.
2282
+ *
2283
+ * This is more efficient than calling `setTransform` on each body individually
2284
+ * when you need to update many bodies at once.
2285
+ *
2286
+ * @param batch - The batch of transforms to apply.
2287
+ * @param wakeUp - Forces the rigid-bodies to wake-up so they are properly affected by forces.
2288
+ *
2289
+ * @example
2290
+ * ```typescript
2291
+ * const batch = RAPIER.createTransformBatch(1000);
2292
+ * batch.clear();
2293
+ * for (const body of dynamicBodies) {
2294
+ * batch.add(body.handle, newPosition, newRotation);
2295
+ * }
2296
+ * world.setTransformsBatch(batch, true);
2297
+ * ```
2298
+ */
2299
+ setTransformsBatch(batch: TransformBatch, wakeUp: boolean): void;
2300
+ /**
2301
+ * Sets next kinematic transforms for multiple rigid-bodies in a single WASM call.
2302
+ *
2303
+ * This is more efficient than calling `setNextKinematicTransform` on each body individually
2304
+ * when you need to update many kinematic bodies at once.
2305
+ *
2306
+ * @param batch - The batch of transforms to apply.
2307
+ *
2308
+ * @example
2309
+ * ```typescript
2310
+ * const batch = RAPIER.createTransformBatch(1000);
2311
+ * batch.clear();
2312
+ * for (const body of kinematicBodies) {
2313
+ * batch.add(body.handle, mesh.position, mesh.quaternion);
2314
+ * }
2315
+ * world.setNextKinematicTransformsBatch(batch);
2316
+ * world.step();
2317
+ * ```
2318
+ */
2319
+ setNextKinematicTransformsBatch(batch: TransformBatch): void;
2245
2320
  /**
2246
2321
  * Creates a new character controller.
2247
2322
  *
@@ -4912,6 +4987,29 @@ declare class RigidBody {
4912
4987
  * @param rot - The kinematic rotation to set.
4913
4988
  */
4914
4989
  setNextKinematicRotation(rot: Rotation): void;
4990
+ /**
4991
+ * Sets both the translation and rotation of this rigid-body in a single WASM call.
4992
+ *
4993
+ * This is more efficient than calling `setTranslation` and `setRotation` separately
4994
+ * when both need to be updated.
4995
+ *
4996
+ * @param tra - The world-space position of the rigid-body.
4997
+ * @param rot - The rotation to set.
4998
+ * @param wakeUp - Forces the rigid-body to wake-up so it is properly affected by forces if it
4999
+ * wasn't moving before modifying its position.
5000
+ */
5001
+ setTransform(tra: Vector, rot: Rotation, wakeUp: boolean): void;
5002
+ /**
5003
+ * If this rigid body is kinematic, sets its future translation and rotation after the next
5004
+ * timestep integration in a single WASM call.
5005
+ *
5006
+ * This is more efficient than calling `setNextKinematicTranslation` and `setNextKinematicRotation`
5007
+ * separately when both need to be updated.
5008
+ *
5009
+ * @param tra - The kinematic translation to set.
5010
+ * @param rot - The kinematic rotation to set.
5011
+ */
5012
+ setNextKinematicTransform(tra: Vector, rot: Rotation): void;
4915
5013
  /**
4916
5014
  * The linear velocity of this rigid-body.
4917
5015
  *
@@ -6056,8 +6154,87 @@ declare class CCDSolver {
6056
6154
  free(): void;
6057
6155
  constructor(raw?: RawCCDSolver);
6058
6156
  }
6157
+ //#endregion
6158
+ //#region src/dynamics/transform_batch.d.ts
6159
+ /**
6160
+ * A batch of transforms for efficient bulk updates.
6161
+ *
6162
+ * This class allows you to collect multiple body transforms and apply them
6163
+ * all in a single WASM call, reducing boundary-crossing overhead.
6164
+ *
6165
+ * @example
6166
+ * ```typescript
6167
+ * const batch = RAPIER.createTransformBatch(1000);
6168
+ *
6169
+ * // In your game loop:
6170
+ * batch.clear();
6171
+ * for (const body of kinematicBodies) {
6172
+ * batch.add(body.handle, mesh.position, mesh.quaternion);
6173
+ * }
6174
+ * world.setNextKinematicTransformsBatch(batch);
6175
+ * world.step();
6176
+ * ```
6177
+ */
6178
+ declare class TransformBatch {
6179
+ /** @internal */
6180
+ buffer: Float32Array;
6181
+ /** @internal */
6182
+ count: number;
6183
+ private static FLOATS_PER_ENTRY;
6184
+ /**
6185
+ * Creates a new TransformBatch with the given initial capacity.
6186
+ *
6187
+ * @param capacity - The initial number of transforms this batch can hold.
6188
+ */
6189
+ constructor(capacity: number);
6190
+ /**
6191
+ * The current number of transforms in the batch.
6192
+ */
6193
+ get length(): number;
6194
+ /**
6195
+ * The maximum number of transforms this batch can hold without growing.
6196
+ */
6197
+ get capacity(): number;
6198
+ /**
6199
+ * Clears all transforms from the batch.
6200
+ * Call this at the start of each frame before adding new transforms.
6201
+ */
6202
+ clear(): void;
6203
+ /**
6204
+ * Adds a transform to the batch.
6205
+ *
6206
+ * @param handle - The rigid body handle.
6207
+ * @param translation - The position to set.
6208
+ * @param rotation - The rotation quaternion to set.
6209
+ */
6210
+ add(handle: RigidBodyHandle, translation: Vector, rotation: Rotation): void;
6211
+ private grow;
6212
+ }
6213
+ /**
6214
+ * Creates a new TransformBatch for efficient bulk body updates.
6215
+ *
6216
+ * @param capacity - The initial number of transforms the batch can hold.
6217
+ * The batch will automatically grow if more are added.
6218
+ * @returns A new TransformBatch instance.
6219
+ *
6220
+ * @example
6221
+ * ```typescript
6222
+ * // Create once, reuse every frame
6223
+ * const batch = RAPIER.createTransformBatch(1000);
6224
+ *
6225
+ * function update() {
6226
+ * batch.clear();
6227
+ * for (const body of kinematicBodies) {
6228
+ * batch.add(body.handle, mesh.position, mesh.quaternion);
6229
+ * }
6230
+ * world.setNextKinematicTransformsBatch(batch);
6231
+ * world.step();
6232
+ * }
6233
+ * ```
6234
+ */
6235
+ declare function createTransformBatch(capacity: number): TransformBatch;
6059
6236
  declare namespace exports_d_exports {
6060
- export { ActiveCollisionTypes, ActiveEvents, ActiveHooks, Ball, BroadPhase, CCDSolver, Capsule, CharacterCollision, CoefficientCombineRule, Collider, ColliderDesc, ColliderHandle, ColliderSet, ColliderShapeCastHit, Cone, ConvexPolyhedron, Cuboid, Cylinder, DebugRenderBuffers, DebugRenderPipeline, DynamicRayCastVehicleController, EventQueue, FeatureType, FixedImpulseJoint, FixedMultibodyJoint, GenericImpulseJoint, HalfSpace, HeightFieldFlags, Heightfield, ImpulseJoint, ImpulseJointHandle, ImpulseJointSet, IntegrationParameters, InteractionGroups, IslandManager, JointAxesMask, JointData, JointType, KinematicCharacterController, MassPropsMode, MotorModel, MultibodyJoint, MultibodyJointHandle, MultibodyJointSet, NarrowPhase, PhysicsHooks, PhysicsPipeline, PidAxesMask, PidController, PointColliderProjection, PointProjection, Polyline, PrismaticImpulseJoint, PrismaticMultibodyJoint, Quaternion, QueryFilterFlags, Ray, RayColliderHit, RayColliderIntersection, RayIntersection, RevoluteImpulseJoint, RevoluteMultibodyJoint, RigidBody, RigidBodyDesc, RigidBodyHandle, RigidBodySet, RigidBodyType, RopeImpulseJoint, Rotation, 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, Vector, Vector3, VectorOps, Voxels, World, reserveMemory, version };
6237
+ export { ActiveCollisionTypes, ActiveEvents, ActiveHooks, Ball, BroadPhase, CCDSolver, Capsule, CharacterCollision, CoefficientCombineRule, Collider, ColliderDesc, ColliderHandle, ColliderSet, ColliderShapeCastHit, Cone, ConvexPolyhedron, Cuboid, Cylinder, DebugRenderBuffers, DebugRenderPipeline, DynamicRayCastVehicleController, EventQueue, FeatureType, FixedImpulseJoint, FixedMultibodyJoint, GenericImpulseJoint, HalfSpace, HeightFieldFlags, Heightfield, ImpulseJoint, ImpulseJointHandle, ImpulseJointSet, IntegrationParameters, InteractionGroups, IslandManager, JointAxesMask, JointData, JointType, KinematicCharacterController, MassPropsMode, MotorModel, MultibodyJoint, MultibodyJointHandle, MultibodyJointSet, NarrowPhase, PhysicsHooks, PhysicsPipeline, PidAxesMask, PidController, PointColliderProjection, PointProjection, Polyline, PrismaticImpulseJoint, PrismaticMultibodyJoint, Quaternion, QueryFilterFlags, Ray, RayColliderHit, RayColliderIntersection, RayIntersection, RevoluteImpulseJoint, RevoluteMultibodyJoint, RigidBody, RigidBodyDesc, RigidBodyHandle, RigidBodySet, RigidBodyType, RopeImpulseJoint, Rotation, 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, Vector, Vector3, VectorOps, Voxels, World, createTransformBatch, reserveMemory, version };
6061
6238
  }
6062
6239
  declare function version(): string;
6063
6240
  declare function reserveMemory(extraBytesCount: number): void;
@@ -6069,5 +6246,5 @@ declare function reserveMemory(extraBytesCount: number): void;
6069
6246
  */
6070
6247
  declare function init(input?: InitInput): Promise<void>;
6071
6248
  //#endregion
6072
- export { ActiveCollisionTypes, ActiveEvents, ActiveHooks, Ball, BroadPhase, CCDSolver, Capsule, CharacterCollision, CoefficientCombineRule, Collider, ColliderDesc, ColliderHandle, ColliderSet, ColliderShapeCastHit, Cone, ConvexPolyhedron, Cuboid, Cylinder, DebugRenderBuffers, DebugRenderPipeline, DynamicRayCastVehicleController, EventQueue, FeatureType, FixedImpulseJoint, FixedMultibodyJoint, GenericImpulseJoint, HalfSpace, HeightFieldFlags, Heightfield, ImpulseJoint, ImpulseJointHandle, ImpulseJointSet, IntegrationParameters, InteractionGroups, IslandManager, JointAxesMask, JointData, JointType, KinematicCharacterController, MassPropsMode, MotorModel, MultibodyJoint, MultibodyJointHandle, MultibodyJointSet, NarrowPhase, PhysicsHooks, PhysicsPipeline, PidAxesMask, PidController, PointColliderProjection, PointProjection, Polyline, PrismaticImpulseJoint, PrismaticMultibodyJoint, Quaternion, QueryFilterFlags, Ray, RayColliderHit, RayColliderIntersection, RayIntersection, RevoluteImpulseJoint, RevoluteMultibodyJoint, RigidBody, RigidBodyDesc, RigidBodyHandle, RigidBodySet, RigidBodyType, RopeImpulseJoint, Rotation, 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, Vector, Vector3, VectorOps, Voxels, World, exports_d_exports as default, init, reserveMemory, version };
6249
+ export { ActiveCollisionTypes, ActiveEvents, ActiveHooks, Ball, BroadPhase, CCDSolver, Capsule, CharacterCollision, CoefficientCombineRule, Collider, ColliderDesc, ColliderHandle, ColliderSet, ColliderShapeCastHit, Cone, ConvexPolyhedron, Cuboid, Cylinder, DebugRenderBuffers, DebugRenderPipeline, DynamicRayCastVehicleController, EventQueue, FeatureType, FixedImpulseJoint, FixedMultibodyJoint, GenericImpulseJoint, HalfSpace, HeightFieldFlags, Heightfield, ImpulseJoint, ImpulseJointHandle, ImpulseJointSet, IntegrationParameters, InteractionGroups, IslandManager, JointAxesMask, JointData, JointType, KinematicCharacterController, MassPropsMode, MotorModel, MultibodyJoint, MultibodyJointHandle, MultibodyJointSet, NarrowPhase, PhysicsHooks, PhysicsPipeline, PidAxesMask, PidController, PointColliderProjection, PointProjection, Polyline, PrismaticImpulseJoint, PrismaticMultibodyJoint, Quaternion, QueryFilterFlags, Ray, RayColliderHit, RayColliderIntersection, RayIntersection, RevoluteImpulseJoint, RevoluteMultibodyJoint, RigidBody, RigidBodyDesc, RigidBodyHandle, RigidBodySet, RigidBodyType, RopeImpulseJoint, Rotation, 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, Vector, Vector3, VectorOps, Voxels, World, createTransformBatch, exports_d_exports as default, init, reserveMemory, version };
6073
6250
  //# sourceMappingURL=rapier.d.mts.map