@galacean/engine-physics-physx 1.4.0-alpha.1 → 1.4.0-alpha.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.
package/dist/main.js CHANGED
@@ -44,7 +44,7 @@ function _inherits(subClass, superClass) {
44
44
  /** @internal */ this._contractOffset = 0.02;
45
45
  this._worldScale = new engine.Vector3(1, 1, 1);
46
46
  this._position = new engine.Vector3();
47
- this._rotation = null;
47
+ this._rotation = new engine.Vector3();
48
48
  this._axis = null;
49
49
  this._physXRotation = new engine.Quaternion();
50
50
  this._shapeFlags = 2 | 1;
@@ -54,8 +54,8 @@ function _inherits(subClass, superClass) {
54
54
  /**
55
55
  * {@inheritDoc IColliderShape.setRotation }
56
56
  */ _proto.setRotation = function setRotation(value) {
57
- this._rotation = value;
58
- engine.Quaternion.rotationYawPitchRoll(value.x, value.y, value.z, this._physXRotation);
57
+ var rotation = this._rotation.set(engine.MathUtil.degreeToRadian(value.x), engine.MathUtil.degreeToRadian(value.y), engine.MathUtil.degreeToRadian(value.z));
58
+ engine.Quaternion.rotationYawPitchRoll(rotation.y, rotation.x, rotation.z, this._physXRotation);
59
59
  this._axis && engine.Quaternion.multiply(this._physXRotation, this._axis, this._physXRotation);
60
60
  this._physXRotation.normalize();
61
61
  this._setLocalPose();
@@ -111,6 +111,15 @@ function _inherits(subClass, superClass) {
111
111
  this._setShapeFlags(this._shapeFlags);
112
112
  };
113
113
  /**
114
+ * {@inheritDoc IColliderShape.pointDistance }
115
+ */ _proto.pointDistance = function pointDistance(point) {
116
+ var info = this._pxGeometry.pointDistance(this._pxShape.getGlobalPose(), point);
117
+ var closestPoint = info.closestPoint;
118
+ var res = PhysXColliderShape._tempVector4;
119
+ res.set(closestPoint.x, closestPoint.y, closestPoint.z, info.distance);
120
+ return res;
121
+ };
122
+ /**
114
123
  * {@inheritDoc IColliderShape.destroy }
115
124
  */ _proto.destroy = function destroy() {
116
125
  this._pxShape.release();
@@ -138,6 +147,7 @@ function _inherits(subClass, superClass) {
138
147
  };
139
148
  return PhysXColliderShape;
140
149
  }();
150
+ PhysXColliderShape._tempVector4 = new engine.Vector4();
141
151
  PhysXColliderShape.halfSqrt = 0.70710678118655;
142
152
  PhysXColliderShape.transform = {
143
153
  translation: new engine.Vector3(),
@@ -277,7 +287,7 @@ PhysXBoxColliderShape._tempHalfExtents = new engine.Vector3();
277
287
  break;
278
288
  }
279
289
  if (rotation) {
280
- engine.Quaternion.rotationYawPitchRoll(rotation.x, rotation.y, rotation.z, physXRotation);
290
+ engine.Quaternion.rotationYawPitchRoll(rotation.y, rotation.x, rotation.z, physXRotation);
281
291
  engine.Quaternion.multiply(physXRotation, axis, physXRotation);
282
292
  } else {
283
293
  physXRotation.copyFrom(axis);
@@ -372,7 +382,7 @@ PhysXBoxColliderShape._tempHalfExtents = new engine.Vector3();
372
382
  * {@inheritDoc ICharacterController.setSlopeLimit }
373
383
  */ _proto.setSlopeLimit = function setSlopeLimit(slopeLimit) {
374
384
  var _this__pxController;
375
- (_this__pxController = this._pxController) == null ? void 0 : _this__pxController.setSlopeLimit(slopeLimit);
385
+ (_this__pxController = this._pxController) == null ? void 0 : _this__pxController.setSlopeLimit(Math.cos(slopeLimit * Math.PI / 180));
376
386
  };
377
387
  /**
378
388
  * {@inheritDoc ICharacterController.addShape }
@@ -550,12 +560,13 @@ PhysXCollider._tempTransform = {
550
560
  * {@inheritDoc IDynamicCollider.getAngularVelocity }
551
561
  */ _proto.getAngularVelocity = function getAngularVelocity(out) {
552
562
  var velocity = this._pxActor.getAngularVelocity();
553
- return out.set(velocity.x, velocity.y, velocity.z);
563
+ return out.set(engine.MathUtil.radianToDegree(velocity.x), engine.MathUtil.radianToDegree(velocity.y), engine.MathUtil.radianToDegree(velocity.z));
554
564
  };
555
565
  /**
556
566
  * {@inheritDoc IDynamicCollider.setAngularVelocity }
557
567
  */ _proto.setAngularVelocity = function setAngularVelocity(value) {
558
- this._pxActor.setAngularVelocity(value, true);
568
+ PhysXDynamicCollider._tempTranslation.set(engine.MathUtil.degreeToRadian(value.x), engine.MathUtil.degreeToRadian(value.y), engine.MathUtil.degreeToRadian(value.z));
569
+ this._pxActor.setAngularVelocity(PhysXDynamicCollider._tempTranslation, true);
559
570
  };
560
571
  /**
561
572
  * {@inheritDoc IDynamicCollider.setMass }
@@ -592,7 +603,7 @@ PhysXCollider._tempTransform = {
592
603
  /**
593
604
  * {@inheritDoc IDynamicCollider.setMaxAngularVelocity }
594
605
  */ _proto.setMaxAngularVelocity = function setMaxAngularVelocity(value) {
595
- this._pxActor.setMaxAngularVelocity(value);
606
+ this._pxActor.setMaxAngularVelocity(engine.MathUtil.degreeToRadian(value));
596
607
  };
597
608
  /**
598
609
  * {@inheritDoc IDynamicCollider.getMaxDepenetrationVelocity }
@@ -639,6 +650,11 @@ PhysXCollider._tempTransform = {
639
650
  }
640
651
  };
641
652
  /**
653
+ * {@inheritDoc IDynamicCollider.setUseGravity }
654
+ */ _proto.setUseGravity = function setUseGravity(value) {
655
+ this._pxActor.setActorFlag(this._physXPhysics._physX.PxActorFlag.eDISABLE_GRAVITY, !value);
656
+ };
657
+ /**
642
658
  * {@inheritDoc IDynamicCollider.setIsKinematic }
643
659
  */ _proto.setIsKinematic = function setIsKinematic(value) {
644
660
  if (value) {
@@ -775,14 +791,14 @@ var PhysXPhysicsManager = function PhysXPhysicsManager() {
775
791
  this._onTriggerExit = onTriggerExit;
776
792
  this._onTriggerStay = onTriggerStay;
777
793
  var triggerCallback = {
778
- onContactBegin: function(index1, index2) {
779
- _this._onContactEnter(index1, index2);
794
+ onContactBegin: function(collision) {
795
+ _this._onContactEnter(collision);
780
796
  },
781
- onContactEnd: function(index1, index2) {
782
- _this._onContactExit(index1, index2);
797
+ onContactEnd: function(collision) {
798
+ _this._onContactExit(collision);
783
799
  },
784
- onContactPersist: function(index1, index2) {
785
- _this._onContactStay(index1, index2);
800
+ onContactPersist: function(collision) {
801
+ _this._onContactStay(collision);
786
802
  },
787
803
  onTriggerBegin: function(index1, index2) {
788
804
  var event = index1 < index2 ? _this._getTrigger(index1, index2) : _this._getTrigger(index2, index1);
@@ -1122,7 +1138,7 @@ PhysXJoint._defaultQuat = new engine.Quaternion();
1122
1138
  /**
1123
1139
  * {@inheritDoc IHingeJoint.getAngle }
1124
1140
  */ _proto.getAngle = function getAngle() {
1125
- return this._pxJoint.getAngle();
1141
+ return engine.MathUtil.radianToDegree(this._pxJoint.getAngle());
1126
1142
  };
1127
1143
  /**
1128
1144
  * {@inheritDoc IHingeJoint.getVelocity }
@@ -1132,12 +1148,12 @@ PhysXJoint._defaultQuat = new engine.Quaternion();
1132
1148
  /**
1133
1149
  * {@inheritDoc IHingeJoint.setHardLimitCone }
1134
1150
  */ _proto.setHardLimit = function setHardLimit(lowerLimit, upperLimit, contactDist) {
1135
- this._pxJoint.setHardLimit(lowerLimit, upperLimit, contactDist);
1151
+ this._pxJoint.setHardLimit(engine.MathUtil.degreeToRadian(lowerLimit), engine.MathUtil.degreeToRadian(upperLimit), contactDist);
1136
1152
  };
1137
1153
  /**
1138
1154
  * {@inheritDoc IHingeJoint.setHardLimitCone }
1139
1155
  */ _proto.setSoftLimit = function setSoftLimit(lowerLimit, upperLimit, stiffness, damping) {
1140
- this._pxJoint.setSoftLimit(lowerLimit, upperLimit, stiffness, damping);
1156
+ this._pxJoint.setSoftLimit(engine.MathUtil.degreeToRadian(lowerLimit), engine.MathUtil.degreeToRadian(upperLimit), stiffness, damping);
1141
1157
  };
1142
1158
  /**
1143
1159
  * {@inheritDoc IHingeJoint.setDriveVelocity }
@@ -1302,7 +1318,7 @@ PhysXHingeJoint._xAxis = new engine.Vector3(1, 0, 0);
1302
1318
  if (runtimeMode == PhysXRuntimeMode.JavaScript) {
1303
1319
  script.src = "https://mdn.alipayobjects.com/rms/afts/file/A*rnDeR58NNGoAAAAAAAAAAAAAARQnAQ/physx.release.js.js";
1304
1320
  } else if (runtimeMode == PhysXRuntimeMode.WebAssembly) {
1305
- script.src = "https://mdn.alipayobjects.com/rms/afts/file/A*rP-bRKBDf0YAAAAAAAAAAAAAARQnAQ/physx.release.js";
1321
+ script.src = "https://mdn.alipayobjects.com/rms/afts/file/A*04GyRKeSJw4AAAAAAAAAAAAAARQnAQ/physx.release.js";
1306
1322
  }
1307
1323
  });
1308
1324
  var initializePromise = new Promise(function(resolve, reject) {
@@ -1410,7 +1426,7 @@ PhysXHingeJoint._xAxis = new engine.Vector3(1, 0, 0);
1410
1426
  }();
1411
1427
 
1412
1428
  //@ts-ignore
1413
- var version = "1.4.0-alpha.1";
1429
+ var version = "1.4.0-alpha.2";
1414
1430
  console.log("Galacean PhysX version: " + version);
1415
1431
 
1416
1432
  exports.PhysXPhysics = PhysXPhysics;