@react-three/rapier 0.7.3 → 0.7.4

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.
@@ -780,12 +780,22 @@ const setColliderOptions = (collider, options, states) => {
780
780
 
781
781
  _matrix4.copy(state.object.matrixWorld).premultiply(state.worldParent.matrixWorld.clone().invert()).decompose(_position, _rotation, _scale);
782
782
 
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);
783
+ if (collider.parent()) {
784
+ collider.setTranslationWrtParent({
785
+ x: _position.x * parentWorldScale.x,
786
+ y: _position.y * parentWorldScale.y,
787
+ z: _position.z * parentWorldScale.z
788
+ });
789
+ collider.setRotationWrtParent(_rotation);
790
+ } else {
791
+ collider.setTranslation({
792
+ x: _position.x * parentWorldScale.x,
793
+ y: _position.y * parentWorldScale.y,
794
+ z: _position.z * parentWorldScale.z
795
+ });
796
+ collider.setRotation(_rotation);
797
+ }
798
+
789
799
  mutableColliderOptionKeys.forEach(key => {
790
800
  if (key in options) {
791
801
  mutableColliderOptions[key](collider, options[key]);
@@ -1147,8 +1157,11 @@ const AnyCollider = /*#__PURE__*/React.memo(props => {
1147
1157
  });
1148
1158
  };
1149
1159
  }, []);
1150
- useUpdateColliderOptions(collidersRef, props, colliderStates);
1151
- useColliderEvents(collidersRef, props, colliderEvents);
1160
+ const mergedProps = React.useMemo(() => {
1161
+ return _objectSpread2(_objectSpread2({}, rigidBodyContext === null || rigidBodyContext === void 0 ? void 0 : rigidBodyContext.options), props);
1162
+ }, [props, rigidBodyContext === null || rigidBodyContext === void 0 ? void 0 : rigidBodyContext.options]);
1163
+ useUpdateColliderOptions(collidersRef, mergedProps, colliderStates);
1164
+ useColliderEvents(collidersRef, mergedProps, colliderEvents);
1152
1165
  return /*#__PURE__*/React__default["default"].createElement("object3D", {
1153
1166
  position: position,
1154
1167
  rotation: rotation,
@@ -780,12 +780,22 @@ const setColliderOptions = (collider, options, states) => {
780
780
 
781
781
  _matrix4.copy(state.object.matrixWorld).premultiply(state.worldParent.matrixWorld.clone().invert()).decompose(_position, _rotation, _scale);
782
782
 
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);
783
+ if (collider.parent()) {
784
+ collider.setTranslationWrtParent({
785
+ x: _position.x * parentWorldScale.x,
786
+ y: _position.y * parentWorldScale.y,
787
+ z: _position.z * parentWorldScale.z
788
+ });
789
+ collider.setRotationWrtParent(_rotation);
790
+ } else {
791
+ collider.setTranslation({
792
+ x: _position.x * parentWorldScale.x,
793
+ y: _position.y * parentWorldScale.y,
794
+ z: _position.z * parentWorldScale.z
795
+ });
796
+ collider.setRotation(_rotation);
797
+ }
798
+
789
799
  mutableColliderOptionKeys.forEach(key => {
790
800
  if (key in options) {
791
801
  mutableColliderOptions[key](collider, options[key]);
@@ -1147,8 +1157,11 @@ const AnyCollider = /*#__PURE__*/React.memo(props => {
1147
1157
  });
1148
1158
  };
1149
1159
  }, []);
1150
- useUpdateColliderOptions(collidersRef, props, colliderStates);
1151
- useColliderEvents(collidersRef, props, colliderEvents);
1160
+ const mergedProps = React.useMemo(() => {
1161
+ return _objectSpread2(_objectSpread2({}, rigidBodyContext === null || rigidBodyContext === void 0 ? void 0 : rigidBodyContext.options), props);
1162
+ }, [props, rigidBodyContext === null || rigidBodyContext === void 0 ? void 0 : rigidBodyContext.options]);
1163
+ useUpdateColliderOptions(collidersRef, mergedProps, colliderStates);
1164
+ useColliderEvents(collidersRef, mergedProps, colliderEvents);
1152
1165
  return /*#__PURE__*/React__default["default"].createElement("object3D", {
1153
1166
  position: position,
1154
1167
  rotation: rotation,
@@ -755,12 +755,22 @@ const setColliderOptions = (collider, options, states) => {
755
755
 
756
756
  _matrix4.copy(state.object.matrixWorld).premultiply(state.worldParent.matrixWorld.clone().invert()).decompose(_position, _rotation, _scale);
757
757
 
758
- collider.setTranslationWrtParent({
759
- x: _position.x * parentWorldScale.x,
760
- y: _position.y * parentWorldScale.y,
761
- z: _position.z * parentWorldScale.z
762
- });
763
- collider.setRotationWrtParent(_rotation);
758
+ if (collider.parent()) {
759
+ collider.setTranslationWrtParent({
760
+ x: _position.x * parentWorldScale.x,
761
+ y: _position.y * parentWorldScale.y,
762
+ z: _position.z * parentWorldScale.z
763
+ });
764
+ collider.setRotationWrtParent(_rotation);
765
+ } else {
766
+ collider.setTranslation({
767
+ x: _position.x * parentWorldScale.x,
768
+ y: _position.y * parentWorldScale.y,
769
+ z: _position.z * parentWorldScale.z
770
+ });
771
+ collider.setRotation(_rotation);
772
+ }
773
+
764
774
  mutableColliderOptionKeys.forEach(key => {
765
775
  if (key in options) {
766
776
  mutableColliderOptions[key](collider, options[key]);
@@ -1122,8 +1132,11 @@ const AnyCollider = /*#__PURE__*/memo(props => {
1122
1132
  });
1123
1133
  };
1124
1134
  }, []);
1125
- useUpdateColliderOptions(collidersRef, props, colliderStates);
1126
- useColliderEvents(collidersRef, props, colliderEvents);
1135
+ const mergedProps = useMemo(() => {
1136
+ return _objectSpread2(_objectSpread2({}, rigidBodyContext === null || rigidBodyContext === void 0 ? void 0 : rigidBodyContext.options), props);
1137
+ }, [props, rigidBodyContext === null || rigidBodyContext === void 0 ? void 0 : rigidBodyContext.options]);
1138
+ useUpdateColliderOptions(collidersRef, mergedProps, colliderStates);
1139
+ useColliderEvents(collidersRef, mergedProps, colliderEvents);
1127
1140
  return /*#__PURE__*/React.createElement("object3D", {
1128
1141
  position: position,
1129
1142
  rotation: rotation,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-three/rapier",
3
- "version": "0.7.3",
3
+ "version": "0.7.4",
4
4
  "source": "src/index.ts",
5
5
  "main": "dist/react-three-rapier.cjs.js",
6
6
  "module": "dist/react-three-rapier.esm.js",