@react-three/rapier 0.11.1 → 0.11.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.
@@ -332,12 +332,14 @@ export declare type PrismaticJointParams = [
332
332
  body1Anchor: Vector3Array,
333
333
  body1LocalFrame: Vector3Array,
334
334
  body2Anchor: Vector3Array,
335
- body2LocalFrame: Vector3Array
335
+ body2LocalFrame: Vector3Array,
336
+ limits?: [min: number, max: number]
336
337
  ];
337
338
  export declare type RevoluteJointParams = [
338
339
  body1Anchor: Vector3Array,
339
340
  body2Anchor: Vector3Array,
340
- axis: Vector3Array
341
+ axis: Vector3Array,
342
+ limits?: [min: number, max: number]
341
343
  ];
342
344
  export declare type RigidBodyApiRef = MutableRefObject<undefined | null | RigidBodyApi>;
343
345
  export interface UseImpulseJoint<P> {
@@ -590,10 +590,12 @@ const useColliderEvents = (collidersRef, props, events) => {
590
590
  };
591
591
 
592
592
  const rigidBodyDescFromOptions = options => {
593
+ var _options$canSleep;
594
+
593
595
  const type = rigidBodyTypeFromString((options === null || options === void 0 ? void 0 : options.type) || "dynamic");
594
596
  const desc = new rapier3dCompat.RigidBodyDesc(type); // Apply immutable options
595
597
 
596
- desc.canSleep = (options === null || options === void 0 ? void 0 : options.canSleep) || true;
598
+ desc.canSleep = (_options$canSleep = options === null || options === void 0 ? void 0 : options.canSleep) !== null && _options$canSleep !== void 0 ? _options$canSleep : true;
597
599
  return desc;
598
600
  };
599
601
  const createRigidBodyState = ({
@@ -883,11 +885,18 @@ const useSphericalJoint = (body1, body2, [body1Anchor, body2Anchor]) => {
883
885
  * They are characterized by one local anchor as well as one local axis on each rigid-body.
884
886
  */
885
887
 
886
- const useRevoluteJoint = (body1, body2, [body1Anchor, body2Anchor, axis]) => {
888
+ const useRevoluteJoint = (body1, body2, [body1Anchor, body2Anchor, axis, limits]) => {
887
889
  const {
888
890
  rapier
889
891
  } = useRapier();
890
- return useImpulseJoint(body1, body2, rapier.JointData.revolute(vectorArrayToVector3(body1Anchor), vectorArrayToVector3(body2Anchor), vectorArrayToVector3(axis)));
892
+ const params = rapier.JointData.revolute(vectorArrayToVector3(body1Anchor), vectorArrayToVector3(body2Anchor), vectorArrayToVector3(axis));
893
+
894
+ if (limits) {
895
+ params.limitsEnabled = true;
896
+ params.limits = limits;
897
+ }
898
+
899
+ return useImpulseJoint(body1, body2, params);
891
900
  };
892
901
  /**
893
902
  * The prismatic joint prevents any relative movement between two rigid-bodies, except for relative translations along one axis.
@@ -895,11 +904,18 @@ const useRevoluteJoint = (body1, body2, [body1Anchor, body2Anchor, axis]) => {
895
904
  * local tangent axis can be specified for each rigid-body.
896
905
  */
897
906
 
898
- const usePrismaticJoint = (body1, body2, [body1Anchor, body2Anchor, axis]) => {
907
+ const usePrismaticJoint = (body1, body2, [body1Anchor, body2Anchor, axis, limits]) => {
899
908
  const {
900
909
  rapier
901
910
  } = useRapier();
902
- return useImpulseJoint(body1, body2, rapier.JointData.prismatic(vectorArrayToVector3(body1Anchor), vectorArrayToVector3(body2Anchor), vectorArrayToVector3(axis)));
911
+ const params = rapier.JointData.prismatic(vectorArrayToVector3(body1Anchor), vectorArrayToVector3(body2Anchor), vectorArrayToVector3(axis));
912
+
913
+ if (limits) {
914
+ params.limitsEnabled = true;
915
+ params.limits = limits;
916
+ }
917
+
918
+ return useImpulseJoint(body1, body2, params);
903
919
  };
904
920
 
905
921
  const calcForceByType = {
@@ -590,10 +590,12 @@ const useColliderEvents = (collidersRef, props, events) => {
590
590
  };
591
591
 
592
592
  const rigidBodyDescFromOptions = options => {
593
+ var _options$canSleep;
594
+
593
595
  const type = rigidBodyTypeFromString((options === null || options === void 0 ? void 0 : options.type) || "dynamic");
594
596
  const desc = new rapier3dCompat.RigidBodyDesc(type); // Apply immutable options
595
597
 
596
- desc.canSleep = (options === null || options === void 0 ? void 0 : options.canSleep) || true;
598
+ desc.canSleep = (_options$canSleep = options === null || options === void 0 ? void 0 : options.canSleep) !== null && _options$canSleep !== void 0 ? _options$canSleep : true;
597
599
  return desc;
598
600
  };
599
601
  const createRigidBodyState = ({
@@ -883,11 +885,18 @@ const useSphericalJoint = (body1, body2, [body1Anchor, body2Anchor]) => {
883
885
  * They are characterized by one local anchor as well as one local axis on each rigid-body.
884
886
  */
885
887
 
886
- const useRevoluteJoint = (body1, body2, [body1Anchor, body2Anchor, axis]) => {
888
+ const useRevoluteJoint = (body1, body2, [body1Anchor, body2Anchor, axis, limits]) => {
887
889
  const {
888
890
  rapier
889
891
  } = useRapier();
890
- return useImpulseJoint(body1, body2, rapier.JointData.revolute(vectorArrayToVector3(body1Anchor), vectorArrayToVector3(body2Anchor), vectorArrayToVector3(axis)));
892
+ const params = rapier.JointData.revolute(vectorArrayToVector3(body1Anchor), vectorArrayToVector3(body2Anchor), vectorArrayToVector3(axis));
893
+
894
+ if (limits) {
895
+ params.limitsEnabled = true;
896
+ params.limits = limits;
897
+ }
898
+
899
+ return useImpulseJoint(body1, body2, params);
891
900
  };
892
901
  /**
893
902
  * The prismatic joint prevents any relative movement between two rigid-bodies, except for relative translations along one axis.
@@ -895,11 +904,18 @@ const useRevoluteJoint = (body1, body2, [body1Anchor, body2Anchor, axis]) => {
895
904
  * local tangent axis can be specified for each rigid-body.
896
905
  */
897
906
 
898
- const usePrismaticJoint = (body1, body2, [body1Anchor, body2Anchor, axis]) => {
907
+ const usePrismaticJoint = (body1, body2, [body1Anchor, body2Anchor, axis, limits]) => {
899
908
  const {
900
909
  rapier
901
910
  } = useRapier();
902
- return useImpulseJoint(body1, body2, rapier.JointData.prismatic(vectorArrayToVector3(body1Anchor), vectorArrayToVector3(body2Anchor), vectorArrayToVector3(axis)));
911
+ const params = rapier.JointData.prismatic(vectorArrayToVector3(body1Anchor), vectorArrayToVector3(body2Anchor), vectorArrayToVector3(axis));
912
+
913
+ if (limits) {
914
+ params.limitsEnabled = true;
915
+ params.limits = limits;
916
+ }
917
+
918
+ return useImpulseJoint(body1, body2, params);
903
919
  };
904
920
 
905
921
  const calcForceByType = {
@@ -565,10 +565,12 @@ const useColliderEvents = (collidersRef, props, events) => {
565
565
  };
566
566
 
567
567
  const rigidBodyDescFromOptions = options => {
568
+ var _options$canSleep;
569
+
568
570
  const type = rigidBodyTypeFromString((options === null || options === void 0 ? void 0 : options.type) || "dynamic");
569
571
  const desc = new RigidBodyDesc(type); // Apply immutable options
570
572
 
571
- desc.canSleep = (options === null || options === void 0 ? void 0 : options.canSleep) || true;
573
+ desc.canSleep = (_options$canSleep = options === null || options === void 0 ? void 0 : options.canSleep) !== null && _options$canSleep !== void 0 ? _options$canSleep : true;
572
574
  return desc;
573
575
  };
574
576
  const createRigidBodyState = ({
@@ -858,11 +860,18 @@ const useSphericalJoint = (body1, body2, [body1Anchor, body2Anchor]) => {
858
860
  * They are characterized by one local anchor as well as one local axis on each rigid-body.
859
861
  */
860
862
 
861
- const useRevoluteJoint = (body1, body2, [body1Anchor, body2Anchor, axis]) => {
863
+ const useRevoluteJoint = (body1, body2, [body1Anchor, body2Anchor, axis, limits]) => {
862
864
  const {
863
865
  rapier
864
866
  } = useRapier();
865
- return useImpulseJoint(body1, body2, rapier.JointData.revolute(vectorArrayToVector3(body1Anchor), vectorArrayToVector3(body2Anchor), vectorArrayToVector3(axis)));
867
+ const params = rapier.JointData.revolute(vectorArrayToVector3(body1Anchor), vectorArrayToVector3(body2Anchor), vectorArrayToVector3(axis));
868
+
869
+ if (limits) {
870
+ params.limitsEnabled = true;
871
+ params.limits = limits;
872
+ }
873
+
874
+ return useImpulseJoint(body1, body2, params);
866
875
  };
867
876
  /**
868
877
  * The prismatic joint prevents any relative movement between two rigid-bodies, except for relative translations along one axis.
@@ -870,11 +879,18 @@ const useRevoluteJoint = (body1, body2, [body1Anchor, body2Anchor, axis]) => {
870
879
  * local tangent axis can be specified for each rigid-body.
871
880
  */
872
881
 
873
- const usePrismaticJoint = (body1, body2, [body1Anchor, body2Anchor, axis]) => {
882
+ const usePrismaticJoint = (body1, body2, [body1Anchor, body2Anchor, axis, limits]) => {
874
883
  const {
875
884
  rapier
876
885
  } = useRapier();
877
- return useImpulseJoint(body1, body2, rapier.JointData.prismatic(vectorArrayToVector3(body1Anchor), vectorArrayToVector3(body2Anchor), vectorArrayToVector3(axis)));
886
+ const params = rapier.JointData.prismatic(vectorArrayToVector3(body1Anchor), vectorArrayToVector3(body2Anchor), vectorArrayToVector3(axis));
887
+
888
+ if (limits) {
889
+ params.limitsEnabled = true;
890
+ params.limits = limits;
891
+ }
892
+
893
+ return useImpulseJoint(body1, body2, params);
878
894
  };
879
895
 
880
896
  const calcForceByType = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-three/rapier",
3
- "version": "0.11.1",
3
+ "version": "0.11.2",
4
4
  "source": "src/index.ts",
5
5
  "main": "dist/react-three-rapier.cjs.js",
6
6
  "module": "dist/react-three-rapier.esm.js",
package/readme.md CHANGED
@@ -500,4 +500,4 @@ step(1 / 60);
500
500
  - WIP
501
501
 
502
502
  ### Joints Example
503
- <a href="https://codesandbox.io/s/react-three-rapier-sensors-byjmsk"><img src="https://raw.githubusercontent.com/pmndrs/react-three-rapier/HEAD/packages/react-three-rapier/misc/example-joints.jpg" width="240" /></a>
503
+ <a href="https://codesandbox.io/s/react-three-rapier-joints-mhhbd4"><img src="https://raw.githubusercontent.com/pmndrs/react-three-rapier/HEAD/packages/react-three-rapier/misc/example-joints.jpg" width="240" /></a>