@react-three/rapier 0.7.4 → 0.7.6
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/declarations/src/AnyCollider.d.ts +38 -10
- package/dist/declarations/src/RigidBody.d.ts +1 -1
- package/dist/declarations/src/api.d.ts +19 -19
- package/dist/declarations/src/types.d.ts +23 -12
- package/dist/declarations/src/utils.d.ts +4 -3
- package/dist/react-three-rapier.cjs.dev.js +154 -72
- package/dist/react-three-rapier.cjs.prod.js +154 -72
- package/dist/react-three-rapier.esm.js +155 -73
- package/package.json +9 -4
- package/readme.md +3 -1
@@ -1,9 +1,10 @@
|
|
1
|
+
import { Collider } from "@dimforge/rapier3d-compat";
|
1
2
|
import React, { ReactNode } from "react";
|
2
3
|
import { UseColliderOptions, CuboidArgs, RoundCuboidArgs, BallArgs, CapsuleArgs, HeightfieldArgs, TrimeshArgs, ConeArgs, CylinderArgs, ConvexHullArgs } from "./types";
|
3
4
|
export interface ColliderProps extends UseColliderOptions<any> {
|
4
5
|
children?: ReactNode;
|
5
6
|
}
|
6
|
-
export declare const AnyCollider: React.MemoExoticComponent<
|
7
|
+
export declare const AnyCollider: React.MemoExoticComponent<React.ForwardRefExoticComponent<ColliderProps & React.RefAttributes<Collider[]>>>;
|
7
8
|
declare type UseColliderOptionsRequiredArgs<T extends unknown[]> = Omit<UseColliderOptions<T>, "args"> & {
|
8
9
|
args: T;
|
9
10
|
children?: ReactNode;
|
@@ -17,13 +18,40 @@ export declare type TrimeshColliderProps = UseColliderOptionsRequiredArgs<Trimes
|
|
17
18
|
export declare type ConeColliderProps = UseColliderOptionsRequiredArgs<ConeArgs>;
|
18
19
|
export declare type CylinderColliderProps = UseColliderOptionsRequiredArgs<CylinderArgs>;
|
19
20
|
export declare type ConvexHullColliderProps = UseColliderOptionsRequiredArgs<ConvexHullArgs>;
|
20
|
-
export declare const CuboidCollider:
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
export declare const
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
export declare const
|
21
|
+
export declare const CuboidCollider: React.ForwardRefExoticComponent<Omit<UseColliderOptions<CuboidArgs>, "args"> & {
|
22
|
+
args: CuboidArgs;
|
23
|
+
children?: ReactNode;
|
24
|
+
} & React.RefAttributes<Collider[]>>;
|
25
|
+
export declare const RoundCuboidCollider: React.ForwardRefExoticComponent<Omit<UseColliderOptions<RoundCuboidArgs>, "args"> & {
|
26
|
+
args: RoundCuboidArgs;
|
27
|
+
children?: ReactNode;
|
28
|
+
} & React.RefAttributes<Collider[]>>;
|
29
|
+
export declare const BallCollider: React.ForwardRefExoticComponent<Omit<UseColliderOptions<BallArgs>, "args"> & {
|
30
|
+
args: BallArgs;
|
31
|
+
children?: ReactNode;
|
32
|
+
} & React.RefAttributes<Collider[]>>;
|
33
|
+
export declare const CapsuleCollider: React.ForwardRefExoticComponent<Omit<UseColliderOptions<CapsuleArgs>, "args"> & {
|
34
|
+
args: CapsuleArgs;
|
35
|
+
children?: ReactNode;
|
36
|
+
} & React.RefAttributes<Collider[]>>;
|
37
|
+
export declare const HeightfieldCollider: React.ForwardRefExoticComponent<Omit<UseColliderOptions<HeightfieldArgs>, "args"> & {
|
38
|
+
args: HeightfieldArgs;
|
39
|
+
children?: ReactNode;
|
40
|
+
} & React.RefAttributes<Collider[]>>;
|
41
|
+
export declare const TrimeshCollider: React.ForwardRefExoticComponent<Omit<UseColliderOptions<TrimeshArgs>, "args"> & {
|
42
|
+
args: TrimeshArgs;
|
43
|
+
children?: ReactNode;
|
44
|
+
} & React.RefAttributes<Collider[]>>;
|
45
|
+
export declare const ConeCollider: React.ForwardRefExoticComponent<Omit<UseColliderOptions<ConeArgs>, "args"> & {
|
46
|
+
args: ConeArgs;
|
47
|
+
children?: ReactNode;
|
48
|
+
} & React.RefAttributes<Collider[]>>;
|
49
|
+
export declare const CylinderCollider: React.ForwardRefExoticComponent<Omit<UseColliderOptions<CylinderArgs>, "args"> & {
|
50
|
+
args: CylinderArgs;
|
51
|
+
children?: ReactNode;
|
52
|
+
} & React.RefAttributes<Collider[]>>;
|
53
|
+
export declare const ConvexHullCollider: React.ForwardRefExoticComponent<Omit<UseColliderOptions<ConvexHullArgs>, "args"> & {
|
54
|
+
args: ConvexHullArgs;
|
55
|
+
children?: ReactNode;
|
56
|
+
} & React.RefAttributes<Collider[]>>;
|
29
57
|
export {};
|
@@ -17,4 +17,4 @@ export declare const useRigidBodyContext: () => {
|
|
17
17
|
export interface RigidBodyProps extends UseRigidBodyOptions {
|
18
18
|
children?: ReactNode;
|
19
19
|
}
|
20
|
-
export declare const RigidBody: React.ForwardRefExoticComponent<RigidBodyProps & React.RefAttributes<import("./api").RigidBodyApi
|
20
|
+
export declare const RigidBody: React.MemoExoticComponent<React.ForwardRefExoticComponent<RigidBodyProps & React.RefAttributes<import("./api").RigidBodyApi>>>;
|
@@ -22,27 +22,27 @@ export interface RigidBodyApi {
|
|
22
22
|
/**
|
23
23
|
* Applies an impulse at the center-of-mass of this rigid-body.
|
24
24
|
*/
|
25
|
-
applyImpulse(impulseVector: Vector3Object): void;
|
25
|
+
applyImpulse(impulseVector: Vector3Object, wakeUp?: boolean): void;
|
26
26
|
/**
|
27
27
|
* Applies an impulsive torque at the center-of-mass of this rigid-body.
|
28
28
|
*/
|
29
|
-
applyTorqueImpulse(torqueVector: Vector3Object): void;
|
29
|
+
applyTorqueImpulse(torqueVector: Vector3Object, wakeUp?: boolean): void;
|
30
30
|
/**
|
31
31
|
* Applies an impulse at the given world-space point of this rigid-body.
|
32
32
|
*/
|
33
|
-
applyImpulseAtPoint(impulseVector: Vector3Object, impulsePoint: Vector3Object): void;
|
33
|
+
applyImpulseAtPoint(impulseVector: Vector3Object, impulsePoint: Vector3Object, wakeUp?: boolean): void;
|
34
34
|
/**
|
35
35
|
* Adds a force at the center-of-mass of this rigid-body.
|
36
36
|
*/
|
37
|
-
addForce(force: Vector3Object): void;
|
37
|
+
addForce(force: Vector3Object, wakeUp?: boolean): void;
|
38
38
|
/**
|
39
39
|
* Adds a force at the given world-space point of this rigid-body.
|
40
40
|
*/
|
41
|
-
addForceAtPoint(force: Vector3Object, point: Vector3Object): void;
|
41
|
+
addForceAtPoint(force: Vector3Object, point: Vector3Object, wakeUp?: boolean): void;
|
42
42
|
/**
|
43
43
|
* Adds a torque at the center-of-mass of this rigid-body.
|
44
44
|
*/
|
45
|
-
addTorque(torque: Vector3Object): void;
|
45
|
+
addTorque(torque: Vector3Object, wakeUp?: boolean): void;
|
46
46
|
/**
|
47
47
|
* The world-space translation of this rigid-body.
|
48
48
|
*/
|
@@ -50,7 +50,7 @@ export interface RigidBodyApi {
|
|
50
50
|
/**
|
51
51
|
* Sets the translation of this rigid-body.
|
52
52
|
*/
|
53
|
-
setTranslation(translation: Vector3Object): void;
|
53
|
+
setTranslation(translation: Vector3Object, wakeUp?: boolean): void;
|
54
54
|
/**
|
55
55
|
* The world-space orientation of this rigid-body.
|
56
56
|
*/
|
@@ -58,7 +58,7 @@ export interface RigidBodyApi {
|
|
58
58
|
/**
|
59
59
|
* Sets the rotation quaternion of this rigid-body.
|
60
60
|
*/
|
61
|
-
setRotation(rotation: Quaternion): void;
|
61
|
+
setRotation(rotation: Quaternion, wakeUp?: boolean): void;
|
62
62
|
/**
|
63
63
|
* The linear velocity of this rigid-body.
|
64
64
|
*/
|
@@ -66,7 +66,7 @@ export interface RigidBodyApi {
|
|
66
66
|
/**
|
67
67
|
* Sets the linear velocity of this rigid-body.
|
68
68
|
*/
|
69
|
-
setLinvel(velocity: Vector3Object): void;
|
69
|
+
setLinvel(velocity: Vector3Object, wakeUp?: boolean): void;
|
70
70
|
/**
|
71
71
|
* The angular velocity of this rigid-body.
|
72
72
|
*/
|
@@ -74,7 +74,7 @@ export interface RigidBodyApi {
|
|
74
74
|
/**
|
75
75
|
* Sets the angular velocity of this rigid-body.
|
76
76
|
*/
|
77
|
-
setAngvel(velocity: Vector3Object): void;
|
77
|
+
setAngvel(velocity: Vector3Object, wakeUp?: boolean): void;
|
78
78
|
/**
|
79
79
|
* The linear damping of this rigid-body.
|
80
80
|
*/
|
@@ -112,27 +112,27 @@ export interface RigidBodyApi {
|
|
112
112
|
/**
|
113
113
|
* Resets to zero the user forces (but not torques) applied to this rigid-body.
|
114
114
|
*/
|
115
|
-
resetForces(): void;
|
115
|
+
resetForces(wakeUp?: boolean): void;
|
116
116
|
/**
|
117
117
|
* Resets to zero the user torques applied to this rigid-body.
|
118
118
|
*/
|
119
|
-
resetTorques(): void;
|
119
|
+
resetTorques(wakeUp?: boolean): void;
|
120
120
|
/**
|
121
121
|
* Locks or unlocks the ability of this rigid-body to rotate.
|
122
122
|
*/
|
123
|
-
lockRotations(locked: boolean): void;
|
123
|
+
lockRotations(locked: boolean, wakeUp?: boolean): void;
|
124
124
|
/**
|
125
125
|
* Locks or unlocks the ability of this rigid-body to translate.
|
126
126
|
*/
|
127
|
-
lockTranslations(locked: boolean): void;
|
127
|
+
lockTranslations(locked: boolean, wakeUp?: boolean): void;
|
128
128
|
/**
|
129
129
|
* Locks or unlocks the ability of this rigid-body to rotate along individual coordinate axes.
|
130
130
|
*/
|
131
|
-
setEnabledRotations(x: boolean, y: boolean, z: boolean): void;
|
131
|
+
setEnabledRotations(x: boolean, y: boolean, z: boolean, wakeUp?: boolean): void;
|
132
132
|
/**
|
133
133
|
* Locks or unlocks the ability of this rigid-body to translate along individual coordinate axes.
|
134
134
|
*/
|
135
|
-
setEnabledTranslations(x: boolean, y: boolean, z: boolean): void;
|
135
|
+
setEnabledTranslations(x: boolean, y: boolean, z: boolean, wakeUp?: boolean): void;
|
136
136
|
}
|
137
137
|
export declare const createRigidBodyApi: (ref: RefGetter<RigidBody>) => RigidBodyApi;
|
138
138
|
export interface InstancedRigidBodyApi {
|
@@ -155,9 +155,9 @@ export interface WorldApi {
|
|
155
155
|
createRigidBody(desc: RigidBodyDesc): RigidBody;
|
156
156
|
createCollider(desc: ColliderDesc, parent?: RigidBody): Collider;
|
157
157
|
removeRigidBody(rigidBody: RigidBody): void;
|
158
|
-
removeCollider(collider: Collider): void;
|
159
|
-
createImpulseJoint(params: JointData, rigidBodyA: RigidBody, rigidBodyB: RigidBody): ImpulseJoint;
|
160
|
-
removeImpulseJoint(joint: ImpulseJoint): void;
|
158
|
+
removeCollider(collider: Collider, wakeUp?: boolean): void;
|
159
|
+
createImpulseJoint(params: JointData, rigidBodyA: RigidBody, rigidBodyB: RigidBody, wakeUp?: boolean): ImpulseJoint;
|
160
|
+
removeImpulseJoint(joint: ImpulseJoint, wakeUp?: boolean): void;
|
161
161
|
forEachCollider(callback: (collider: Collider) => void): void;
|
162
162
|
setGravity(gravity: Vector3): void;
|
163
163
|
}
|
@@ -6,6 +6,7 @@ import { Object3DProps } from "@react-three/fiber";
|
|
6
6
|
import { Object3D } from "three";
|
7
7
|
export { CoefficientCombineRule as CoefficientCombineRule } from "@dimforge/rapier3d-compat";
|
8
8
|
export { RapierRigidBody, RapierCollider };
|
9
|
+
import { Rotation, Vector } from "@dimforge/rapier3d-compat/math";
|
9
10
|
export declare type RefGetter<T> = MutableRefObject<() => T | undefined>;
|
10
11
|
export declare type RigidBodyAutoCollider = "ball" | "cuboid" | "hull" | "trimesh" | false;
|
11
12
|
export interface UseRigidBodyAPI {
|
@@ -81,18 +82,6 @@ export interface UseColliderOptions<ColliderArgs extends Array<unknown>> {
|
|
81
82
|
* Arguments to pass to the collider
|
82
83
|
*/
|
83
84
|
args?: ColliderArgs;
|
84
|
-
/**
|
85
|
-
* The mass of this collider.
|
86
|
-
* The mass and density is automatically calculated based on the shape of the collider.
|
87
|
-
* Generally, it's not recommended to adjust the mass properties as it could lead to
|
88
|
-
* unexpected behaviors.
|
89
|
-
* More info https://rapier.rs/docs/user_guides/javascript/colliders#mass-properties
|
90
|
-
*/
|
91
|
-
mass?: number;
|
92
|
-
/**
|
93
|
-
* The center of mass of this rigid body
|
94
|
-
*/
|
95
|
-
centerOfMass?: Vector3Array;
|
96
85
|
/**
|
97
86
|
* Principal angular inertia of this rigid body
|
98
87
|
*/
|
@@ -157,8 +146,30 @@ export interface UseColliderOptions<ColliderArgs extends Array<unknown>> {
|
|
157
146
|
solverGroups?: InteractionGroups;
|
158
147
|
/**
|
159
148
|
* Sets the uniform density of this collider.
|
149
|
+
* If this is set, other mass-properties like the angular inertia tensor are computed
|
150
|
+
* automatically from the collider's shape.
|
151
|
+
* Cannot be used at the same time as the mass or massProperties values.
|
152
|
+
* More info https://rapier.rs/docs/user_guides/javascript/colliders#mass-properties
|
160
153
|
*/
|
161
154
|
density?: number;
|
155
|
+
/**
|
156
|
+
* The mass of this collider.
|
157
|
+
* Generally, it's not recommended to adjust the mass properties as it could lead to
|
158
|
+
* unexpected behaviors.
|
159
|
+
* Cannot be used at the same time as the density or massProperties values.
|
160
|
+
* More info https://rapier.rs/docs/user_guides/javascript/colliders#mass-properties
|
161
|
+
*/
|
162
|
+
mass?: number;
|
163
|
+
/**
|
164
|
+
* The mass properties of this rigid body.
|
165
|
+
* Cannot be used at the same time as the density or mass values.
|
166
|
+
*/
|
167
|
+
massProperties?: {
|
168
|
+
mass: number;
|
169
|
+
centerOfMass: Vector;
|
170
|
+
principalAngularInertia: Vector;
|
171
|
+
angularInertiaLocalFrame: Rotation;
|
172
|
+
};
|
162
173
|
/**
|
163
174
|
* Sets whether or not this collider is a sensor.
|
164
175
|
*/
|
@@ -1,9 +1,10 @@
|
|
1
1
|
import { Quaternion as RapierQuaternion, Vector3 as RapierVector3 } from "@dimforge/rapier3d-compat";
|
2
|
-
import { Vector3 } from "three";
|
2
|
+
import { Euler, Quaternion, Vector3 } from "three";
|
3
3
|
import { RigidBodyTypeString, Vector3Array } from "./types";
|
4
4
|
export declare const vectorArrayToVector3: (arr: Vector3Array) => Vector3;
|
5
|
-
export declare const vector3ToQuaternion: (v: Vector3) =>
|
5
|
+
export declare const vector3ToQuaternion: (v: Vector3) => Quaternion;
|
6
6
|
export declare const rapierVector3ToVector3: ({ x, y, z }: RapierVector3) => Vector3;
|
7
|
-
export declare const rapierQuaternionToQuaternion: ({ x, y, z, w }: RapierQuaternion) =>
|
7
|
+
export declare const rapierQuaternionToQuaternion: ({ x, y, z, w }: RapierQuaternion) => Quaternion;
|
8
8
|
export declare const rigidBodyTypeFromString: (type: RigidBodyTypeString) => number;
|
9
9
|
export declare const scaleVertices: (vertices: ArrayLike<number>, scale: Vector3) => number[];
|
10
|
+
export declare const vectorToTuple: (v: Vector3 | Quaternion | any[] | undefined | number | Euler) => any[];
|