@react-three/rapier 1.3.1 → 1.5.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 (26) hide show
  1. package/dist/declarations/src/components/AnyCollider.d.ts +2 -2
  2. package/dist/declarations/src/components/InstancedRigidBodies.d.ts +2 -2
  3. package/dist/declarations/src/components/MeshCollider.d.ts +2 -2
  4. package/dist/declarations/src/components/Physics.d.ts +17 -4
  5. package/dist/declarations/src/components/RigidBody.d.ts +1 -1
  6. package/dist/declarations/src/hooks/hooks.d.ts +3 -3
  7. package/dist/declarations/src/hooks/joints.d.ts +1 -1
  8. package/dist/declarations/src/index.d.ts +15 -15
  9. package/dist/declarations/src/types.d.ts +52 -10
  10. package/dist/declarations/src/utils/interaction-groups.d.ts +1 -1
  11. package/dist/react-three-rapier.cjs.d.ts +1 -0
  12. package/dist/react-three-rapier.cjs.dev.js +162 -275
  13. package/dist/react-three-rapier.cjs.prod.js +162 -275
  14. package/dist/react-three-rapier.esm.js +162 -275
  15. package/package.json +8 -13
  16. package/readme.md +0 -2
  17. package/dist/declarations/src/components/Debug.d.ts +0 -2
  18. package/dist/declarations/src/components/FrameStepper.d.ts +0 -9
  19. package/dist/declarations/src/hooks/use-forwarded-ref.d.ts +0 -2
  20. package/dist/declarations/src/hooks/use-imperative-instance.d.ts +0 -5
  21. package/dist/declarations/src/utils/shared-objects.d.ts +0 -9
  22. package/dist/declarations/src/utils/singleton-proxy.d.ts +0 -11
  23. package/dist/declarations/src/utils/utils-collider.d.ts +0 -81
  24. package/dist/declarations/src/utils/utils-physics.d.ts +0 -1
  25. package/dist/declarations/src/utils/utils-rigidbody.d.ts +0 -24
  26. package/dist/declarations/src/utils/utils.d.ts +0 -14
@@ -1,7 +1,7 @@
1
1
  import { Collider } from "@dimforge/rapier3d-compat";
2
2
  import React, { ReactNode } from "react";
3
- import { ColliderOptions, CuboidArgs, RoundCuboidArgs, BallArgs, CapsuleArgs, HeightfieldArgs, TrimeshArgs, ConeArgs, CylinderArgs, ConvexHullArgs, RoundCylinderArgs } from "../types";
4
- import { RoundConeArgs } from "../types";
3
+ import { ColliderOptions, CuboidArgs, RoundCuboidArgs, BallArgs, CapsuleArgs, HeightfieldArgs, TrimeshArgs, ConeArgs, CylinderArgs, ConvexHullArgs, RoundCylinderArgs } from "../types.js";
4
+ import { RoundConeArgs } from "../types.js";
5
5
  export interface ColliderProps extends ColliderOptions<any> {
6
6
  children?: ReactNode;
7
7
  }
@@ -1,6 +1,6 @@
1
1
  import React, { ReactNode } from "react";
2
- import { RigidBodyProps } from "./RigidBody";
3
- import { RapierRigidBody } from "../types";
2
+ import { RigidBodyProps } from "./RigidBody.js";
3
+ import { RapierRigidBody } from "../types.js";
4
4
  export declare type InstancedRigidBodyProps = RigidBodyProps & {
5
5
  key: string | number;
6
6
  };
@@ -1,5 +1,5 @@
1
1
  import React, { ReactNode } from "react";
2
- import { RigidBodyAutoCollider } from "../types";
2
+ import { RigidBodyAutoCollider } from "../types.js";
3
3
  export interface MeshColliderProps {
4
4
  children: ReactNode;
5
5
  type: RigidBodyAutoCollider;
@@ -8,4 +8,4 @@ export interface MeshColliderProps {
8
8
  * A mesh collider is a collider that is automatically generated from the geometry of the children.
9
9
  * @category Colliders
10
10
  */
11
- export declare const MeshCollider: React.MemoExoticComponent<(props: MeshColliderProps) => JSX.Element>;
11
+ export declare const MeshCollider: React.MemoExoticComponent<(props: MeshColliderProps) => import("react/jsx-runtime").JSX.Element>;
@@ -2,7 +2,7 @@ import type Rapier from "@dimforge/rapier3d-compat";
2
2
  import { Collider, ColliderHandle, RigidBody, RigidBodyHandle, World } from "@dimforge/rapier3d-compat";
3
3
  import React, { FC, ReactNode } from "react";
4
4
  import { Matrix4, Object3D, Vector3 } from "three";
5
- import { CollisionEnterHandler, CollisionExitHandler, ContactForceHandler, IntersectionEnterHandler, IntersectionExitHandler, RigidBodyAutoCollider, Vector3Tuple } from "../types";
5
+ import { CollisionEnterHandler, CollisionExitHandler, ContactForceHandler, IntersectionEnterHandler, IntersectionExitHandler, RigidBodyAutoCollider, Vector3Tuple } from "../types.js";
6
6
  export interface RigidBodyState {
7
7
  meshType: "instancedMesh" | "mesh";
8
8
  rigidBody: RigidBody;
@@ -197,11 +197,24 @@ export interface PhysicsProps {
197
197
  */
198
198
  maxCcdSubsteps?: number;
199
199
  /**
200
- * The Error Reduction Parameter in between 0 and 1, is the proportion of the positional error to be corrected at each time step.
200
+ * Directly affects the `erp` (Error Reduction Parameter) which is the proportion (0 to 1) of the positional error to be corrected at each time step.
201
+ * The higher this value is, the more the physics engine will try to correct errors.
201
202
  *
202
- * @defaultValue 0.8
203
+ * This prop is currently undocumented in the Rapier documentation.
204
+ *
205
+ * @see https://github.com/dimforge/rapier/pull/651 where this change was made to Rapier
206
+ * @defaultValue 30
207
+ */
208
+ contactNaturalFrequency?: number;
209
+ /**
210
+ * The approximate size of most dynamic objects in the scene.
211
+ *
212
+ * This value is used internally to estimate some length-based tolerance.
213
+ * This value can be understood as the number of units-per-meter in your physical world compared to a human-sized world in meter.
214
+ *
215
+ * @defaultValue 1
203
216
  */
204
- erp?: number;
217
+ lengthUnit?: number;
205
218
  /**
206
219
  * Set the base automatic colliders for this physics world
207
220
  * All Meshes inside RigidBodies will generate a collider
@@ -1,7 +1,7 @@
1
1
  import React, { MutableRefObject, RefObject } from "react";
2
2
  import { ReactNode } from "react";
3
3
  import { Object3D } from "three";
4
- import { RapierRigidBody, RigidBodyOptions } from "../types";
4
+ import { RapierRigidBody, RigidBodyOptions } from "../types.js";
5
5
  export declare const RigidBodyContext: React.Context<{
6
6
  ref: RefObject<Object3D> | MutableRefObject<Object3D>;
7
7
  getRigidBody: () => RapierRigidBody;
@@ -1,7 +1,7 @@
1
1
  import React, { MutableRefObject } from "react";
2
- import { RapierContext, WorldStepCallback } from "../components/Physics";
2
+ import { RapierContext, WorldStepCallback } from "../components/Physics.js";
3
3
  import { Object3D } from "three";
4
- import { ColliderProps, RigidBodyProps } from "..";
4
+ import { ColliderProps, RigidBodyProps } from "../index.js";
5
5
  /**
6
6
  * Exposes the Rapier context, and world
7
7
  * @category Hooks
@@ -20,4 +20,4 @@ export declare const useAfterPhysicsStep: (callback: WorldStepCallback) => void;
20
20
  /**
21
21
  * @internal
22
22
  */
23
- export declare const useChildColliderProps: <O extends Object3D<import("three").Event>>(ref: React.MutableRefObject<O | null | undefined>, options: RigidBodyProps, ignoreMeshColliders?: boolean) => ColliderProps[];
23
+ export declare const useChildColliderProps: <O extends Object3D<import("three").Object3DEventMap>>(ref: React.MutableRefObject<O | null | undefined>, options: RigidBodyProps, ignoreMeshColliders?: boolean) => ColliderProps[];
@@ -1,6 +1,6 @@
1
1
  import { FixedImpulseJoint, ImpulseJoint, PrismaticImpulseJoint, RevoluteImpulseJoint, RopeImpulseJoint, SphericalImpulseJoint, SpringImpulseJoint } from "@dimforge/rapier3d-compat";
2
2
  import { RefObject } from "react";
3
- import { FixedJointParams, PrismaticJointParams, RapierRigidBody, RevoluteJointParams, RopeJointParams, SphericalJointParams, SpringJointParams, UseImpulseJoint } from "..";
3
+ import { FixedJointParams, PrismaticJointParams, RapierRigidBody, RevoluteJointParams, RopeJointParams, SphericalJointParams, SpringJointParams, UseImpulseJoint } from "../index.js";
4
4
  import type Rapier from "@dimforge/rapier3d-compat";
5
5
  /**
6
6
  * @internal
@@ -1,15 +1,15 @@
1
- export * from "./types";
2
- export type { RigidBodyProps } from "./components/RigidBody";
3
- export type { InstancedRigidBodiesProps, InstancedRigidBodyProps } from "./components/InstancedRigidBodies";
4
- export type { CylinderColliderProps, BallColliderProps, CapsuleColliderProps, ConeColliderProps, ConvexHullColliderProps, CuboidColliderProps, HeightfieldColliderProps, RoundCuboidColliderProps, TrimeshColliderProps, ColliderOptionsRequiredArgs } from "./components/AnyCollider";
5
- export type { PhysicsProps, RapierContext, WorldStepCallback } from "./components/Physics";
6
- export type { MeshColliderProps } from "./components/MeshCollider";
7
- export { Physics } from "./components/Physics";
8
- export { RigidBody } from "./components/RigidBody";
9
- export { MeshCollider } from "./components/MeshCollider";
10
- export { InstancedRigidBodies } from "./components/InstancedRigidBodies";
11
- export * from "./components/AnyCollider";
12
- export * from "./hooks/joints";
13
- export { useRapier, useBeforePhysicsStep, useAfterPhysicsStep } from "./hooks/hooks";
14
- export * from "./utils/interaction-groups";
15
- export * from "./utils/three-object-helpers";
1
+ export * from "./types.js";
2
+ export type { RigidBodyProps } from "./components/RigidBody.js";
3
+ export type { InstancedRigidBodiesProps, InstancedRigidBodyProps } from "./components/InstancedRigidBodies.js";
4
+ export type { CylinderColliderProps, BallColliderProps, CapsuleColliderProps, ConeColliderProps, ConvexHullColliderProps, CuboidColliderProps, HeightfieldColliderProps, RoundCuboidColliderProps, TrimeshColliderProps, ColliderOptionsRequiredArgs } from "./components/AnyCollider.js";
5
+ export type { PhysicsProps, RapierContext, WorldStepCallback } from "./components/Physics.js";
6
+ export type { MeshColliderProps } from "./components/MeshCollider.js";
7
+ export { Physics } from "./components/Physics.js";
8
+ export { RigidBody } from "./components/RigidBody.js";
9
+ export { MeshCollider } from "./components/MeshCollider.js";
10
+ export { InstancedRigidBodies } from "./components/InstancedRigidBodies.js";
11
+ export * from "./components/AnyCollider.js";
12
+ export * from "./hooks/joints.js";
13
+ export { useRapier, useBeforePhysicsStep, useAfterPhysicsStep } from "./hooks/hooks.js";
14
+ export * from "./utils/interaction-groups.js";
15
+ export * from "./utils/three-object-helpers.js";
@@ -1,12 +1,12 @@
1
1
  import { MutableRefObject, RefObject } from "react";
2
- import { CoefficientCombineRule, Collider as RapierCollider, ImpulseJoint, InteractionGroups, RigidBody as RapierRigidBody, TempContactManifold } from "@dimforge/rapier3d-compat";
2
+ import { ActiveCollisionTypes, CoefficientCombineRule, ImpulseJoint, InteractionGroups, Collider as RapierCollider, RigidBody as RapierRigidBody, TempContactManifold } from "@dimforge/rapier3d-compat";
3
3
  import { Rotation, Vector } from "@dimforge/rapier3d-compat/math";
4
- import { Object3DProps, Vector3, Quaternion } from "@react-three/fiber";
4
+ import { Object3DProps, Quaternion, Vector3 } from "@react-three/fiber";
5
5
  import { Object3D } from "three";
6
- import { ColliderProps } from ".";
7
- import { RigidBodyState } from "./components/Physics";
6
+ import { ColliderProps } from "./index.js";
7
+ import { RigidBodyState } from "./components/Physics.js";
8
8
  export { CoefficientCombineRule as CoefficientCombineRule } from "@dimforge/rapier3d-compat";
9
- export { RapierRigidBody, RapierCollider };
9
+ export { RapierCollider, RapierRigidBody };
10
10
  export declare type RefGetter<T> = MutableRefObject<() => T | undefined>;
11
11
  export declare type RigidBodyAutoCollider = "ball" | "cuboid" | "hull" | "trimesh" | false;
12
12
  export declare type CuboidArgs = [
@@ -139,7 +139,7 @@ export interface ColliderOptions<ColliderArgs extends Array<unknown>> {
139
139
  */
140
140
  scale?: Object3DProps["scale"];
141
141
  /**
142
- * Callback when this collider collides with another collider.
142
+ * Callback when this collider collideas with another collider.
143
143
  */
144
144
  onCollisionEnter?: CollisionEnterHandler;
145
145
  /**
@@ -166,6 +166,15 @@ export interface ColliderOptions<ColliderArgs extends Array<unknown>> {
166
166
  * The bit mask configuring the groups and mask for solver handling.
167
167
  */
168
168
  solverGroups?: InteractionGroups;
169
+ /**
170
+ * The collision types active for this collider.
171
+ *
172
+ * Use `ActiveCollisionTypes` to specify which collision types should be active for this collider.
173
+ *
174
+ * @see https://rapier.rs/javascript3d/classes/Collider.html#setActiveCollisionTypes
175
+ * @see https://rapier.rs/javascript3d/enums/ActiveCollisionTypes.html
176
+ */
177
+ activeCollisionTypes?: ActiveCollisionTypes;
169
178
  /**
170
179
  * Sets the uniform density of this collider.
171
180
  * If this is set, other mass-properties like the angular inertia tensor are computed
@@ -192,6 +201,18 @@ export interface ColliderOptions<ColliderArgs extends Array<unknown>> {
192
201
  principalAngularInertia: Vector;
193
202
  angularInertiaLocalFrame: Rotation;
194
203
  };
204
+ /**
205
+ * The contact skin of the collider.
206
+ *
207
+ * The contact skin acts as if the collider was enlarged with a skin of width contactSkin around it, keeping objects further apart when colliding.
208
+ *
209
+ * A non-zero contact skin can increase performance, and in some cases, stability.
210
+ * However it creates a small gap between colliding object (equal to the sum of their skin).
211
+ * If the skin is sufficiently small, this might not be visually significant or can be hidden by the rendering assets.
212
+ *
213
+ * @defaultValue 0
214
+ */
215
+ contactSkin?: number;
195
216
  /**
196
217
  * Sets whether or not this collider is a sensor.
197
218
  */
@@ -277,6 +298,20 @@ export interface RigidBodyOptions extends ColliderProps {
277
298
  * @defaultValue false
278
299
  */
279
300
  ccd?: boolean;
301
+ /**
302
+ * The maximum prediction distance Soft Continuous Collision-Detection.
303
+ *
304
+ * When set to 0, soft-CCD is disabled.
305
+ *
306
+ * Soft-CCD helps prevent tunneling especially of slow-but-thin to moderately fast objects.
307
+ * The soft CCD prediction distance indicates how far in the object’s path the CCD algorithm is allowed to inspect.
308
+ * Large values can impact performance badly by increasing the work needed from the broad-phase.
309
+ *
310
+ * It is a generally cheaper variant of regular CCD since it relies on predictive constraints instead of shape-cast and substeps.
311
+ *
312
+ * @defaultValue 0
313
+ */
314
+ softCcdPrediction?: number;
280
315
  /**
281
316
  * Initial position of the RigidBody
282
317
  */
@@ -325,6 +360,16 @@ export interface RigidBodyOptions extends ColliderProps {
325
360
  * Can be customized per-collider.
326
361
  */
327
362
  solverGroups?: InteractionGroups;
363
+ /**
364
+ * The default active collision types for all colliders in this rigid body.
365
+ * Can be customized per-collider.
366
+ *
367
+ * Use `ActiveCollisionTypes` to specify which collision types should be active for this collider.
368
+ *
369
+ * @see https://rapier.rs/javascript3d/classes/Collider.html#setActiveCollisionTypes
370
+ * @see https://rapier.rs/javascript3d/enums/ActiveCollisionTypes.html
371
+ */
372
+ activeCollisionTypes?: ActiveCollisionTypes;
328
373
  onSleep?(): void;
329
374
  onWake?(): void;
330
375
  /**
@@ -357,10 +402,7 @@ export interface RigidBodyOptions extends ColliderProps {
357
402
  */
358
403
  transformState?: (state: RigidBodyState) => RigidBodyState;
359
404
  }
360
- export declare type SphericalJointParams = [
361
- body1Anchor: Vector3,
362
- body2Anchor: Vector3
363
- ];
405
+ export declare type SphericalJointParams = [body1Anchor: Vector3, body2Anchor: Vector3];
364
406
  export declare type FixedJointParams = [
365
407
  body1Anchor: Vector3,
366
408
  body1LocalFrame: Quaternion,
@@ -31,4 +31,4 @@ import { InteractionGroups } from "@dimforge/rapier3d-compat";
31
31
  * @param filters Groups the interaction group should filter against. (Values can range from 0 to 15.)
32
32
  * @returns An InteractionGroup bitmask.
33
33
  */
34
- export declare const interactionGroups: (memberships: number | number[], filters?: number | number[]) => InteractionGroups;
34
+ export declare const interactionGroups: (memberships: number | number[], filters?: number | number[] | undefined) => InteractionGroups;
@@ -1 +1,2 @@
1
1
  export * from "./declarations/src/index";
2
+ //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVhY3QtdGhyZWUtcmFwaWVyLmNqcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi9kZWNsYXJhdGlvbnMvc3JjL2luZGV4LmQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEifQ==