@react-three/rapier 0.7.3 → 0.7.5

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.
@@ -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<(props: ColliderProps) => JSX.Element>;
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: (props: CuboidColliderProps) => JSX.Element;
21
- export declare const RoundCuboidCollider: (props: RoundCuboidColliderProps) => JSX.Element;
22
- export declare const BallCollider: (props: BallColliderProps) => JSX.Element;
23
- export declare const CapsuleCollider: (props: CapsuleColliderProps) => JSX.Element;
24
- export declare const HeightfieldCollider: (props: HeightfieldColliderProps) => JSX.Element;
25
- export declare const TrimeshCollider: (props: TrimeshColliderProps) => JSX.Element;
26
- export declare const ConeCollider: (props: ConeColliderProps) => JSX.Element;
27
- export declare const CylinderCollider: (props: CylinderColliderProps) => JSX.Element;
28
- export declare const ConvexHullCollider: (props: ConvexHullColliderProps) => JSX.Element;
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 {};
@@ -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
  */
@@ -84,24 +84,24 @@ const createRigidBodyApi = ref => {
84
84
 
85
85
  mass: () => ref.current().mass(),
86
86
 
87
- applyImpulse(impulseVector) {
88
- ref.current().applyImpulse(impulseVector, true);
87
+ applyImpulse(impulseVector, wakeUp = true) {
88
+ ref.current().applyImpulse(impulseVector, wakeUp);
89
89
  },
90
90
 
91
- applyTorqueImpulse(torqueVector) {
92
- ref.current().applyTorqueImpulse(torqueVector, true);
91
+ applyTorqueImpulse(torqueVector, wakeUp = true) {
92
+ ref.current().applyTorqueImpulse(torqueVector, wakeUp);
93
93
  },
94
94
 
95
- applyImpulseAtPoint: (impulseVector, impulsePoint) => ref.current().applyImpulseAtPoint(impulseVector, impulsePoint, true),
96
- addForce: force => ref.current().addForce(force, true),
97
- addForceAtPoint: (force, point) => ref.current().addForceAtPoint(force, point, true),
98
- addTorque: torque => ref.current().addTorque(torque, true),
95
+ applyImpulseAtPoint: (impulseVector, impulsePoint, wakeUp = true) => ref.current().applyImpulseAtPoint(impulseVector, impulsePoint, wakeUp),
96
+ addForce: (force, wakeUp = true) => ref.current().addForce(force, wakeUp),
97
+ addForceAtPoint: (force, point, wakeUp = true) => ref.current().addForceAtPoint(force, point, wakeUp),
98
+ addTorque: (torque, wakeUp = true) => ref.current().addTorque(torque, wakeUp),
99
99
 
100
100
  translation() {
101
101
  return rapierVector3ToVector3(ref.current().translation());
102
102
  },
103
103
 
104
- setTranslation: translation => ref.current().setTranslation(translation, true),
104
+ setTranslation: (translation, wakeUp = true) => ref.current().setTranslation(translation, wakeUp),
105
105
 
106
106
  rotation() {
107
107
  const {
@@ -113,8 +113,8 @@ const createRigidBodyApi = ref => {
113
113
  return new three.Quaternion(x, y, z, w);
114
114
  },
115
115
 
116
- setRotation: rotation => {
117
- ref.current().setRotation(rotation, true);
116
+ setRotation: (rotation, wakeUp = true) => {
117
+ ref.current().setRotation(rotation, wakeUp);
118
118
  },
119
119
 
120
120
  linvel() {
@@ -126,7 +126,7 @@ const createRigidBodyApi = ref => {
126
126
  return new three.Vector3(x, y, z);
127
127
  },
128
128
 
129
- setLinvel: velocity => ref.current().setLinvel(velocity, true),
129
+ setLinvel: (velocity, wakeUp = true) => ref.current().setLinvel(velocity, wakeUp),
130
130
 
131
131
  angvel() {
132
132
  const {
@@ -137,7 +137,7 @@ const createRigidBodyApi = ref => {
137
137
  return new three.Vector3(x, y, z);
138
138
  },
139
139
 
140
- setAngvel: velocity => ref.current().setAngvel(velocity, true),
140
+ setAngvel: (velocity, wakeUp = true) => ref.current().setAngvel(velocity, wakeUp),
141
141
 
142
142
  linearDamping() {
143
143
  return ref.current().linearDamping();
@@ -154,12 +154,12 @@ const createRigidBodyApi = ref => {
154
154
  ref.current().setNextKinematicRotation(rotation);
155
155
  },
156
156
  setNextKinematicTranslation: translation => ref.current().setNextKinematicTranslation(translation),
157
- resetForces: () => ref.current().resetForces(true),
158
- resetTorques: () => ref.current().resetTorques(true),
159
- lockRotations: locked => ref.current().lockRotations(locked, true),
160
- lockTranslations: locked => ref.current().lockTranslations(locked, true),
161
- setEnabledRotations: (x, y, z) => ref.current().setEnabledRotations(x, y, z, true),
162
- setEnabledTranslations: (x, y, z) => ref.current().setEnabledTranslations(x, y, z, true)
157
+ resetForces: (wakeUp = true) => ref.current().resetForces(wakeUp),
158
+ resetTorques: (wakeUp = true) => ref.current().resetTorques(wakeUp),
159
+ lockRotations: (locked, wakeUp = true) => ref.current().lockRotations(locked, wakeUp),
160
+ lockTranslations: (locked, wakeUp = true) => ref.current().lockTranslations(locked, wakeUp),
161
+ setEnabledRotations: (x, y, z, wakeUp = true) => ref.current().setEnabledRotations(x, y, z, wakeUp),
162
+ setEnabledTranslations: (x, y, z, wakeUp = true) => ref.current().setEnabledTranslations(x, y, z, wakeUp)
163
163
  };
164
164
  };
165
165
  const createInstancedRigidBodiesApi = bodiesGetter => ({
@@ -182,9 +182,9 @@ const createWorldApi = ref => {
182
182
  createRigidBody: desc => ref.current().createRigidBody(desc),
183
183
  createCollider: (desc, rigidBody) => ref.current().createCollider(desc, rigidBody),
184
184
  removeRigidBody: rigidBody => ref.current().removeRigidBody(rigidBody),
185
- removeCollider: collider => ref.current().removeCollider(collider, true),
186
- createImpulseJoint: (params, rigidBodyA, rigidBodyB) => ref.current().createImpulseJoint(params, rigidBodyA, rigidBodyB, true),
187
- removeImpulseJoint: joint => ref.current().removeImpulseJoint(joint, true),
185
+ removeCollider: (collider, wakeUp = true) => ref.current().removeCollider(collider, wakeUp),
186
+ createImpulseJoint: (params, rigidBodyA, rigidBodyB, wakeUp = true) => ref.current().createImpulseJoint(params, rigidBodyA, rigidBodyB, wakeUp),
187
+ removeImpulseJoint: (joint, wakeUp = true) => ref.current().removeImpulseJoint(joint, wakeUp),
188
188
  forEachCollider: callback => ref.current().forEachCollider(callback),
189
189
  setGravity: ({
190
190
  x,
@@ -746,6 +746,32 @@ const createColliderFromOptions = (options, world, scale, rigidBody) => {
746
746
  const desc = rapier3dCompat.ColliderDesc[options.shape](...scaledArgs);
747
747
  return world.createCollider(desc, rigidBody);
748
748
  };
749
+ const massPropertiesConflictError = "Please pick ONLY ONE of the `density`, `mass` and `massProperties` options.";
750
+
751
+ const setColliderMassOptions = (collider, options) => {
752
+ if (options.density !== undefined) {
753
+ if (options.mass !== undefined || options.massProperties !== undefined) {
754
+ throw new Error(massPropertiesConflictError);
755
+ }
756
+
757
+ collider.setDensity(options.density);
758
+ return;
759
+ }
760
+
761
+ if (options.mass !== undefined) {
762
+ if (options.massProperties !== undefined) {
763
+ throw new Error(massPropertiesConflictError);
764
+ }
765
+
766
+ collider.setMass(options.mass);
767
+ return;
768
+ }
769
+
770
+ if (options.massProperties !== undefined) {
771
+ collider.setMassProperties(options.massProperties.mass, options.massProperties.centerOfMass, options.massProperties.principalAngularInertia, options.massProperties.angularInertiaLocalFrame);
772
+ }
773
+ };
774
+
749
775
  const mutableColliderOptions = {
750
776
  sensor: (collider, value) => {
751
777
  collider.setSensor(value);
@@ -759,14 +785,14 @@ const mutableColliderOptions = {
759
785
  friction: (collider, value) => {
760
786
  collider.setFriction(value);
761
787
  },
788
+ frictionCombineRule: (collider, value) => {
789
+ collider.setFrictionCombineRule(value);
790
+ },
762
791
  restitution: (collider, value) => {
763
792
  collider.setRestitution(value);
764
793
  },
765
- density: (collider, value) => {
766
- collider.setDensity(value);
767
- },
768
- mass: (collider, value) => {
769
- collider.setMass(value);
794
+ restitutionCombineRule: (collider, value) => {
795
+ collider.setRestitutionCombineRule(value);
770
796
  }
771
797
  };
772
798
  const mutableColliderOptionKeys = Object.keys(mutableColliderOptions);
@@ -780,17 +806,32 @@ const setColliderOptions = (collider, options, states) => {
780
806
 
781
807
  _matrix4.copy(state.object.matrixWorld).premultiply(state.worldParent.matrixWorld.clone().invert()).decompose(_position, _rotation, _scale);
782
808
 
783
- collider.setTranslationWrtParent({
784
- x: _position.x * parentWorldScale.x,
785
- y: _position.y * parentWorldScale.y,
786
- z: _position.z * parentWorldScale.z
787
- });
788
- collider.setRotationWrtParent(_rotation);
809
+ if (collider.parent()) {
810
+ collider.setTranslationWrtParent({
811
+ x: _position.x * parentWorldScale.x,
812
+ y: _position.y * parentWorldScale.y,
813
+ z: _position.z * parentWorldScale.z
814
+ });
815
+ collider.setRotationWrtParent(_rotation);
816
+ } else {
817
+ collider.setTranslation({
818
+ x: _position.x * parentWorldScale.x,
819
+ y: _position.y * parentWorldScale.y,
820
+ z: _position.z * parentWorldScale.z
821
+ });
822
+ collider.setRotation(_rotation);
823
+ }
824
+
789
825
  mutableColliderOptionKeys.forEach(key => {
790
826
  if (key in options) {
791
- mutableColliderOptions[key](collider, options[key]);
827
+ const option = options[key];
828
+ mutableColliderOptions[key](collider, // @ts-ignore Option does not want to fit into the function, but it will
829
+ option, options);
792
830
  }
793
- });
831
+ }); // handle mass separately, because the assignments
832
+ // are exclusive.
833
+
834
+ setColliderMassOptions(collider, options);
794
835
  }
795
836
  };
796
837
  const useUpdateColliderOptions = (collidersRef, props, states) => {
@@ -1099,7 +1140,7 @@ const usePrismaticJoint = (body1, body2, [body1Anchor, body2Anchor, axis]) => {
1099
1140
  };
1100
1141
 
1101
1142
  // Colliders
1102
- const AnyCollider = /*#__PURE__*/React.memo(props => {
1143
+ const AnyCollider = /*#__PURE__*/React.memo( /*#__PURE__*/React__default["default"].forwardRef((props, forwardedRef) => {
1103
1144
  const {
1104
1145
  children,
1105
1146
  position,
@@ -1114,7 +1155,15 @@ const AnyCollider = /*#__PURE__*/React.memo(props => {
1114
1155
  } = useRapier();
1115
1156
  const rigidBodyContext = useRigidBodyContext();
1116
1157
  const ref = React.useRef(null);
1117
- const collidersRef = React.useRef([]);
1158
+ const collidersRef = React.useMemo(() => {
1159
+ if (forwardedRef !== null) {
1160
+ return forwardedRef;
1161
+ }
1162
+
1163
+ const result = /*#__PURE__*/React__default["default"].createRef();
1164
+ result.current = [];
1165
+ return result;
1166
+ }, []);
1118
1167
  React.useEffect(() => {
1119
1168
  const object = ref.current;
1120
1169
  const worldScale = object.getWorldScale(new three.Vector3());
@@ -1147,8 +1196,11 @@ const AnyCollider = /*#__PURE__*/React.memo(props => {
1147
1196
  });
1148
1197
  };
1149
1198
  }, []);
1150
- useUpdateColliderOptions(collidersRef, props, colliderStates);
1151
- useColliderEvents(collidersRef, props, colliderEvents);
1199
+ const mergedProps = React.useMemo(() => {
1200
+ return _objectSpread2(_objectSpread2({}, rigidBodyContext === null || rigidBodyContext === void 0 ? void 0 : rigidBodyContext.options), props);
1201
+ }, [props, rigidBodyContext === null || rigidBodyContext === void 0 ? void 0 : rigidBodyContext.options]);
1202
+ useUpdateColliderOptions(collidersRef, mergedProps, colliderStates);
1203
+ useColliderEvents(collidersRef, mergedProps, colliderEvents);
1152
1204
  return /*#__PURE__*/React__default["default"].createElement("object3D", {
1153
1205
  position: position,
1154
1206
  rotation: rotation,
@@ -1156,52 +1208,61 @@ const AnyCollider = /*#__PURE__*/React.memo(props => {
1156
1208
  scale: scale,
1157
1209
  ref: ref
1158
1210
  }, children);
1159
- });
1160
- const CuboidCollider = props => {
1211
+ }));
1212
+ const CuboidCollider = /*#__PURE__*/React__default["default"].forwardRef((props, ref) => {
1161
1213
  return /*#__PURE__*/React__default["default"].createElement(AnyCollider, _extends({}, props, {
1162
- shape: "cuboid"
1214
+ shape: "cuboid",
1215
+ ref: ref
1163
1216
  }));
1164
- };
1165
- const RoundCuboidCollider = props => {
1217
+ });
1218
+ const RoundCuboidCollider = /*#__PURE__*/React__default["default"].forwardRef((props, ref) => {
1166
1219
  return /*#__PURE__*/React__default["default"].createElement(AnyCollider, _extends({}, props, {
1167
- shape: "roundCuboid"
1220
+ shape: "roundCuboid",
1221
+ ref: ref
1168
1222
  }));
1169
- };
1170
- const BallCollider = props => {
1223
+ });
1224
+ const BallCollider = /*#__PURE__*/React__default["default"].forwardRef((props, ref) => {
1171
1225
  return /*#__PURE__*/React__default["default"].createElement(AnyCollider, _extends({}, props, {
1172
- shape: "ball"
1226
+ shape: "ball",
1227
+ ref: ref
1173
1228
  }));
1174
- };
1175
- const CapsuleCollider = props => {
1229
+ });
1230
+ const CapsuleCollider = /*#__PURE__*/React__default["default"].forwardRef((props, ref) => {
1176
1231
  return /*#__PURE__*/React__default["default"].createElement(AnyCollider, _extends({}, props, {
1177
- shape: "capsule"
1232
+ shape: "capsule",
1233
+ ref: ref
1178
1234
  }));
1179
- };
1180
- const HeightfieldCollider = props => {
1235
+ });
1236
+ const HeightfieldCollider = /*#__PURE__*/React__default["default"].forwardRef((props, ref) => {
1181
1237
  return /*#__PURE__*/React__default["default"].createElement(AnyCollider, _extends({}, props, {
1182
- shape: "heightfield"
1238
+ shape: "heightfield",
1239
+ ref: ref
1183
1240
  }));
1184
- };
1185
- const TrimeshCollider = props => {
1241
+ });
1242
+ const TrimeshCollider = /*#__PURE__*/React__default["default"].forwardRef((props, ref) => {
1186
1243
  return /*#__PURE__*/React__default["default"].createElement(AnyCollider, _extends({}, props, {
1187
- shape: "trimesh"
1244
+ shape: "trimesh",
1245
+ ref: ref
1188
1246
  }));
1189
- };
1190
- const ConeCollider = props => {
1247
+ });
1248
+ const ConeCollider = /*#__PURE__*/React__default["default"].forwardRef((props, ref) => {
1191
1249
  return /*#__PURE__*/React__default["default"].createElement(AnyCollider, _extends({}, props, {
1192
- shape: "cone"
1250
+ shape: "cone",
1251
+ ref: ref
1193
1252
  }));
1194
- };
1195
- const CylinderCollider = props => {
1253
+ });
1254
+ const CylinderCollider = /*#__PURE__*/React__default["default"].forwardRef((props, ref) => {
1196
1255
  return /*#__PURE__*/React__default["default"].createElement(AnyCollider, _extends({}, props, {
1197
- shape: "cylinder"
1256
+ shape: "cylinder",
1257
+ ref: ref
1198
1258
  }));
1199
- };
1200
- const ConvexHullCollider = props => {
1259
+ });
1260
+ const ConvexHullCollider = /*#__PURE__*/React__default["default"].forwardRef((props, ref) => {
1201
1261
  return /*#__PURE__*/React__default["default"].createElement(AnyCollider, _extends({}, props, {
1202
- shape: "convexHull"
1262
+ shape: "convexHull",
1263
+ ref: ref
1203
1264
  }));
1204
- };
1265
+ });
1205
1266
 
1206
1267
  const _excluded$1 = ["children", "type", "position", "rotation", "scale", "quaternion"];
1207
1268
  const RigidBodyContext = /*#__PURE__*/React.createContext(undefined);
@@ -1277,7 +1338,7 @@ const geometryFromCollider = collider => {
1277
1338
  y,
1278
1339
  z
1279
1340
  } = collider.shape.halfExtents;
1280
- return new three.BoxBufferGeometry(x * 2 + 0.01, y * 2 + 0.01, z * 2 + 0.01);
1341
+ return new three.BoxGeometry(x * 2 + 0.01, y * 2 + 0.01, z * 2 + 0.01);
1281
1342
  }
1282
1343
 
1283
1344
  case rapier3dCompat.ShapeType.RoundCuboid:
@@ -1294,7 +1355,7 @@ const geometryFromCollider = collider => {
1294
1355
  case rapier3dCompat.ShapeType.Ball:
1295
1356
  {
1296
1357
  const r = collider.shape.radius;
1297
- return new three.SphereBufferGeometry(r + +0.01, 8, 8);
1358
+ return new three.SphereGeometry(r + +0.01, 8, 8);
1298
1359
  }
1299
1360
 
1300
1361
  case rapier3dCompat.ShapeType.TriMesh:
@@ -1326,7 +1387,7 @@ const geometryFromCollider = collider => {
1326
1387
  {
1327
1388
  const r = collider.shape.radius;
1328
1389
  const h = collider.shape.halfHeight;
1329
- const g = new three.CylinderBufferGeometry(r, r, h * 2);
1390
+ const g = new three.CylinderGeometry(r, r, h * 2);
1330
1391
  return g;
1331
1392
  }
1332
1393
 
@@ -1334,7 +1395,7 @@ const geometryFromCollider = collider => {
1334
1395
  {
1335
1396
  const r = collider.shape.radius;
1336
1397
  const h = collider.shape.halfHeight;
1337
- const g = new three.CapsuleBufferGeometry(r, h * 2, 4, 8);
1398
+ const g = new three.CapsuleGeometry(r, h * 2, 4, 8);
1338
1399
  return g;
1339
1400
  }
1340
1401
 
@@ -1342,7 +1403,7 @@ const geometryFromCollider = collider => {
1342
1403
  {
1343
1404
  const r = collider.shape.radius;
1344
1405
  const h = collider.shape.halfHeight;
1345
- const g = new three.ConeBufferGeometry(r, h * 2, 16);
1406
+ const g = new three.ConeGeometry(r, h * 2, 16);
1346
1407
  return g;
1347
1408
  }
1348
1409
 
@@ -1362,7 +1423,7 @@ const geometryFromCollider = collider => {
1362
1423
  }
1363
1424
  }
1364
1425
 
1365
- return new three.BoxBufferGeometry(1, 1, 1);
1426
+ return new three.BoxGeometry(1, 1, 1);
1366
1427
  };
1367
1428
 
1368
1429
  const DebugShape = /*#__PURE__*/React.memo(({