@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/browser.js +35 -19
- package/dist/browser.js.map +1 -1
- package/dist/browser.min.js +1 -1
- package/dist/browser.min.js.map +1 -1
- package/dist/main.js +35 -19
- package/dist/main.js.map +1 -1
- package/dist/module.js +36 -20
- package/dist/module.js.map +1 -1
- package/package.json +4 -4
- package/types/PhysXDynamicCollider.d.ts +4 -0
- package/types/PhysXPhysics.d.ts +2 -2
- package/types/PhysXPhysicsScene.d.ts +2 -2
- package/types/shape/PhysXColliderShape.d.ts +6 -1
package/dist/module.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Vector3, Quaternion, DisorderedArray } from '@galacean/engine';
|
|
1
|
+
import { Vector4, Vector3, MathUtil, Quaternion, DisorderedArray } from '@galacean/engine';
|
|
2
2
|
|
|
3
3
|
function _instanceof(left, right) {
|
|
4
4
|
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
@@ -40,7 +40,7 @@ function _inherits(subClass, superClass) {
|
|
|
40
40
|
/** @internal */ this._contractOffset = 0.02;
|
|
41
41
|
this._worldScale = new Vector3(1, 1, 1);
|
|
42
42
|
this._position = new Vector3();
|
|
43
|
-
this._rotation =
|
|
43
|
+
this._rotation = new Vector3();
|
|
44
44
|
this._axis = null;
|
|
45
45
|
this._physXRotation = new Quaternion();
|
|
46
46
|
this._shapeFlags = 2 | 1;
|
|
@@ -50,8 +50,8 @@ function _inherits(subClass, superClass) {
|
|
|
50
50
|
/**
|
|
51
51
|
* {@inheritDoc IColliderShape.setRotation }
|
|
52
52
|
*/ _proto.setRotation = function setRotation(value) {
|
|
53
|
-
this._rotation
|
|
54
|
-
Quaternion.rotationYawPitchRoll(
|
|
53
|
+
var rotation = this._rotation.set(MathUtil.degreeToRadian(value.x), MathUtil.degreeToRadian(value.y), MathUtil.degreeToRadian(value.z));
|
|
54
|
+
Quaternion.rotationYawPitchRoll(rotation.y, rotation.x, rotation.z, this._physXRotation);
|
|
55
55
|
this._axis && Quaternion.multiply(this._physXRotation, this._axis, this._physXRotation);
|
|
56
56
|
this._physXRotation.normalize();
|
|
57
57
|
this._setLocalPose();
|
|
@@ -107,6 +107,15 @@ function _inherits(subClass, superClass) {
|
|
|
107
107
|
this._setShapeFlags(this._shapeFlags);
|
|
108
108
|
};
|
|
109
109
|
/**
|
|
110
|
+
* {@inheritDoc IColliderShape.pointDistance }
|
|
111
|
+
*/ _proto.pointDistance = function pointDistance(point) {
|
|
112
|
+
var info = this._pxGeometry.pointDistance(this._pxShape.getGlobalPose(), point);
|
|
113
|
+
var closestPoint = info.closestPoint;
|
|
114
|
+
var res = PhysXColliderShape._tempVector4;
|
|
115
|
+
res.set(closestPoint.x, closestPoint.y, closestPoint.z, info.distance);
|
|
116
|
+
return res;
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
110
119
|
* {@inheritDoc IColliderShape.destroy }
|
|
111
120
|
*/ _proto.destroy = function destroy() {
|
|
112
121
|
this._pxShape.release();
|
|
@@ -134,6 +143,7 @@ function _inherits(subClass, superClass) {
|
|
|
134
143
|
};
|
|
135
144
|
return PhysXColliderShape;
|
|
136
145
|
}();
|
|
146
|
+
PhysXColliderShape._tempVector4 = new Vector4();
|
|
137
147
|
PhysXColliderShape.halfSqrt = 0.70710678118655;
|
|
138
148
|
PhysXColliderShape.transform = {
|
|
139
149
|
translation: new Vector3(),
|
|
@@ -273,7 +283,7 @@ PhysXBoxColliderShape._tempHalfExtents = new Vector3();
|
|
|
273
283
|
break;
|
|
274
284
|
}
|
|
275
285
|
if (rotation) {
|
|
276
|
-
Quaternion.rotationYawPitchRoll(rotation.
|
|
286
|
+
Quaternion.rotationYawPitchRoll(rotation.y, rotation.x, rotation.z, physXRotation);
|
|
277
287
|
Quaternion.multiply(physXRotation, axis, physXRotation);
|
|
278
288
|
} else {
|
|
279
289
|
physXRotation.copyFrom(axis);
|
|
@@ -368,7 +378,7 @@ PhysXBoxColliderShape._tempHalfExtents = new Vector3();
|
|
|
368
378
|
* {@inheritDoc ICharacterController.setSlopeLimit }
|
|
369
379
|
*/ _proto.setSlopeLimit = function setSlopeLimit(slopeLimit) {
|
|
370
380
|
var _this__pxController;
|
|
371
|
-
(_this__pxController = this._pxController) == null ? void 0 : _this__pxController.setSlopeLimit(slopeLimit);
|
|
381
|
+
(_this__pxController = this._pxController) == null ? void 0 : _this__pxController.setSlopeLimit(Math.cos(slopeLimit * Math.PI / 180));
|
|
372
382
|
};
|
|
373
383
|
/**
|
|
374
384
|
* {@inheritDoc ICharacterController.addShape }
|
|
@@ -546,12 +556,13 @@ PhysXCollider._tempTransform = {
|
|
|
546
556
|
* {@inheritDoc IDynamicCollider.getAngularVelocity }
|
|
547
557
|
*/ _proto.getAngularVelocity = function getAngularVelocity(out) {
|
|
548
558
|
var velocity = this._pxActor.getAngularVelocity();
|
|
549
|
-
return out.set(velocity.x, velocity.y, velocity.z);
|
|
559
|
+
return out.set(MathUtil.radianToDegree(velocity.x), MathUtil.radianToDegree(velocity.y), MathUtil.radianToDegree(velocity.z));
|
|
550
560
|
};
|
|
551
561
|
/**
|
|
552
562
|
* {@inheritDoc IDynamicCollider.setAngularVelocity }
|
|
553
563
|
*/ _proto.setAngularVelocity = function setAngularVelocity(value) {
|
|
554
|
-
|
|
564
|
+
PhysXDynamicCollider._tempTranslation.set(MathUtil.degreeToRadian(value.x), MathUtil.degreeToRadian(value.y), MathUtil.degreeToRadian(value.z));
|
|
565
|
+
this._pxActor.setAngularVelocity(PhysXDynamicCollider._tempTranslation, true);
|
|
555
566
|
};
|
|
556
567
|
/**
|
|
557
568
|
* {@inheritDoc IDynamicCollider.setMass }
|
|
@@ -588,7 +599,7 @@ PhysXCollider._tempTransform = {
|
|
|
588
599
|
/**
|
|
589
600
|
* {@inheritDoc IDynamicCollider.setMaxAngularVelocity }
|
|
590
601
|
*/ _proto.setMaxAngularVelocity = function setMaxAngularVelocity(value) {
|
|
591
|
-
this._pxActor.setMaxAngularVelocity(value);
|
|
602
|
+
this._pxActor.setMaxAngularVelocity(MathUtil.degreeToRadian(value));
|
|
592
603
|
};
|
|
593
604
|
/**
|
|
594
605
|
* {@inheritDoc IDynamicCollider.getMaxDepenetrationVelocity }
|
|
@@ -635,6 +646,11 @@ PhysXCollider._tempTransform = {
|
|
|
635
646
|
}
|
|
636
647
|
};
|
|
637
648
|
/**
|
|
649
|
+
* {@inheritDoc IDynamicCollider.setUseGravity }
|
|
650
|
+
*/ _proto.setUseGravity = function setUseGravity(value) {
|
|
651
|
+
this._pxActor.setActorFlag(this._physXPhysics._physX.PxActorFlag.eDISABLE_GRAVITY, !value);
|
|
652
|
+
};
|
|
653
|
+
/**
|
|
638
654
|
* {@inheritDoc IDynamicCollider.setIsKinematic }
|
|
639
655
|
*/ _proto.setIsKinematic = function setIsKinematic(value) {
|
|
640
656
|
if (value) {
|
|
@@ -771,14 +787,14 @@ var PhysXPhysicsManager = function PhysXPhysicsManager() {
|
|
|
771
787
|
this._onTriggerExit = onTriggerExit;
|
|
772
788
|
this._onTriggerStay = onTriggerStay;
|
|
773
789
|
var triggerCallback = {
|
|
774
|
-
onContactBegin: function(
|
|
775
|
-
_this._onContactEnter(
|
|
790
|
+
onContactBegin: function(collision) {
|
|
791
|
+
_this._onContactEnter(collision);
|
|
776
792
|
},
|
|
777
|
-
onContactEnd: function(
|
|
778
|
-
_this._onContactExit(
|
|
793
|
+
onContactEnd: function(collision) {
|
|
794
|
+
_this._onContactExit(collision);
|
|
779
795
|
},
|
|
780
|
-
onContactPersist: function(
|
|
781
|
-
_this._onContactStay(
|
|
796
|
+
onContactPersist: function(collision) {
|
|
797
|
+
_this._onContactStay(collision);
|
|
782
798
|
},
|
|
783
799
|
onTriggerBegin: function(index1, index2) {
|
|
784
800
|
var event = index1 < index2 ? _this._getTrigger(index1, index2) : _this._getTrigger(index2, index1);
|
|
@@ -1118,7 +1134,7 @@ PhysXJoint._defaultQuat = new Quaternion();
|
|
|
1118
1134
|
/**
|
|
1119
1135
|
* {@inheritDoc IHingeJoint.getAngle }
|
|
1120
1136
|
*/ _proto.getAngle = function getAngle() {
|
|
1121
|
-
return this._pxJoint.getAngle();
|
|
1137
|
+
return MathUtil.radianToDegree(this._pxJoint.getAngle());
|
|
1122
1138
|
};
|
|
1123
1139
|
/**
|
|
1124
1140
|
* {@inheritDoc IHingeJoint.getVelocity }
|
|
@@ -1128,12 +1144,12 @@ PhysXJoint._defaultQuat = new Quaternion();
|
|
|
1128
1144
|
/**
|
|
1129
1145
|
* {@inheritDoc IHingeJoint.setHardLimitCone }
|
|
1130
1146
|
*/ _proto.setHardLimit = function setHardLimit(lowerLimit, upperLimit, contactDist) {
|
|
1131
|
-
this._pxJoint.setHardLimit(lowerLimit, upperLimit, contactDist);
|
|
1147
|
+
this._pxJoint.setHardLimit(MathUtil.degreeToRadian(lowerLimit), MathUtil.degreeToRadian(upperLimit), contactDist);
|
|
1132
1148
|
};
|
|
1133
1149
|
/**
|
|
1134
1150
|
* {@inheritDoc IHingeJoint.setHardLimitCone }
|
|
1135
1151
|
*/ _proto.setSoftLimit = function setSoftLimit(lowerLimit, upperLimit, stiffness, damping) {
|
|
1136
|
-
this._pxJoint.setSoftLimit(lowerLimit, upperLimit, stiffness, damping);
|
|
1152
|
+
this._pxJoint.setSoftLimit(MathUtil.degreeToRadian(lowerLimit), MathUtil.degreeToRadian(upperLimit), stiffness, damping);
|
|
1137
1153
|
};
|
|
1138
1154
|
/**
|
|
1139
1155
|
* {@inheritDoc IHingeJoint.setDriveVelocity }
|
|
@@ -1298,7 +1314,7 @@ PhysXHingeJoint._xAxis = new Vector3(1, 0, 0);
|
|
|
1298
1314
|
if (runtimeMode == PhysXRuntimeMode.JavaScript) {
|
|
1299
1315
|
script.src = "https://mdn.alipayobjects.com/rms/afts/file/A*rnDeR58NNGoAAAAAAAAAAAAAARQnAQ/physx.release.js.js";
|
|
1300
1316
|
} else if (runtimeMode == PhysXRuntimeMode.WebAssembly) {
|
|
1301
|
-
script.src = "https://mdn.alipayobjects.com/rms/afts/file/A*
|
|
1317
|
+
script.src = "https://mdn.alipayobjects.com/rms/afts/file/A*04GyRKeSJw4AAAAAAAAAAAAAARQnAQ/physx.release.js";
|
|
1302
1318
|
}
|
|
1303
1319
|
});
|
|
1304
1320
|
var initializePromise = new Promise(function(resolve, reject) {
|
|
@@ -1406,7 +1422,7 @@ PhysXHingeJoint._xAxis = new Vector3(1, 0, 0);
|
|
|
1406
1422
|
}();
|
|
1407
1423
|
|
|
1408
1424
|
//@ts-ignore
|
|
1409
|
-
var version = "1.4.0-alpha.
|
|
1425
|
+
var version = "1.4.0-alpha.2";
|
|
1410
1426
|
console.log("Galacean PhysX version: " + version);
|
|
1411
1427
|
|
|
1412
1428
|
export { PhysXPhysics, PhysXRuntimeMode, version };
|