@galacean/engine-physics-physx 1.3.23 → 1.4.0-alpha.0

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/module.js CHANGED
@@ -6,6 +6,12 @@ function _instanceof(left, right) {
6
6
  } else return left instanceof right;
7
7
  }
8
8
 
9
+ function _type_of(obj) {
10
+ "@swc/helpers - typeof";
11
+
12
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
13
+ }
14
+
9
15
  function _set_prototype_of(o, p) {
10
16
  _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
11
17
  o.__proto__ = p;
@@ -26,12 +32,6 @@ function _inherits(subClass, superClass) {
26
32
  if (superClass) _set_prototype_of(subClass, superClass);
27
33
  }
28
34
 
29
- var ShapeFlag;
30
- (function(ShapeFlag) {
31
- ShapeFlag[ShapeFlag[/** The shape will partake in collision in the physical simulation. */ "SIMULATION_SHAPE"] = 1] = "SIMULATION_SHAPE";
32
- ShapeFlag[ShapeFlag[/** The shape will partake in scene queries (ray casts, overlap tests, sweeps, ...). */ "SCENE_QUERY_SHAPE"] = 2] = "SCENE_QUERY_SHAPE";
33
- ShapeFlag[ShapeFlag[/** The shape is a trigger which can send reports whenever other shapes enter/leave its volume. */ "TRIGGER_SHAPE"] = 4] = "TRIGGER_SHAPE";
34
- })(ShapeFlag || (ShapeFlag = {}));
35
35
  /**
36
36
  * Abstract class for collider shapes.
37
37
  */ var PhysXColliderShape = /*#__PURE__*/ function() {
@@ -129,25 +129,19 @@ var ShapeFlag;
129
129
  };
130
130
  return PhysXColliderShape;
131
131
  }();
132
- (function() {
133
- PhysXColliderShape.halfSqrt = 0.70710678118655;
134
- })();
135
- (function() {
136
- PhysXColliderShape.transform = {
137
- translation: new Vector3(),
138
- rotation: null
139
- };
140
- })();
132
+ PhysXColliderShape.halfSqrt = 0.70710678118655;
133
+ PhysXColliderShape.transform = {
134
+ translation: new Vector3(),
135
+ rotation: null
136
+ };
141
137
 
142
138
  /**
143
139
  * Box collider shape in PhysX.
144
- */ var PhysXBoxColliderShape = /*#__PURE__*/ function(PhysXColliderShape1) {
145
- _inherits(PhysXBoxColliderShape, PhysXColliderShape1);
140
+ */ var PhysXBoxColliderShape = /*#__PURE__*/ function(PhysXColliderShape) {
141
+ _inherits(PhysXBoxColliderShape, PhysXColliderShape);
146
142
  function PhysXBoxColliderShape(physXPhysics, uniqueID, size, material) {
147
143
  var _this;
148
- _this = PhysXColliderShape1.call(this, physXPhysics) || this;
149
- /** @internal */ _this._halfSize = new Vector3();
150
- _this._sizeScale = new Vector3(1, 1, 1);
144
+ _this = PhysXColliderShape.call(this, physXPhysics) || this, /** @internal */ _this._halfSize = new Vector3(), _this._sizeScale = new Vector3(1, 1, 1);
151
145
  var halfSize = _this._halfSize;
152
146
  halfSize.set(size.x * 0.5, size.y * 0.5, size.z * 0.5);
153
147
  _this._pxGeometry = new physXPhysics._physX.PxBoxGeometry(halfSize.x, halfSize.y, halfSize.z);
@@ -170,7 +164,7 @@ var ShapeFlag;
170
164
  /**
171
165
  * {@inheritDoc IColliderShape.setWorldScale }
172
166
  */ _proto.setWorldScale = function setWorldScale(scale) {
173
- PhysXColliderShape1.prototype.setWorldScale.call(this, scale);
167
+ PhysXColliderShape.prototype.setWorldScale.call(this, scale);
174
168
  this._sizeScale.set(Math.abs(scale.x), Math.abs(scale.y), Math.abs(scale.z));
175
169
  var tempExtents = PhysXBoxColliderShape._tempHalfExtents;
176
170
  Vector3.multiply(this._halfSize, this._sizeScale, tempExtents);
@@ -191,9 +185,7 @@ var ShapeFlag;
191
185
  };
192
186
  return PhysXBoxColliderShape;
193
187
  }(PhysXColliderShape);
194
- (function() {
195
- PhysXBoxColliderShape._tempHalfExtents = new Vector3();
196
- })();
188
+ PhysXBoxColliderShape._tempHalfExtents = new Vector3();
197
189
 
198
190
  /**
199
191
  * Capsule collider shape in PhysX.
@@ -201,9 +193,7 @@ var ShapeFlag;
201
193
  _inherits(PhysXCapsuleColliderShape, PhysXColliderShape1);
202
194
  function PhysXCapsuleColliderShape(physXPhysics, uniqueID, radius, height, material) {
203
195
  var _this;
204
- _this = PhysXColliderShape1.call(this, physXPhysics) || this;
205
- _this._upAxis = /** Up axis is Y. */ 1;
206
- _this._sizeScale = new Vector3(1, 1, 1);
196
+ _this = PhysXColliderShape1.call(this, physXPhysics) || this, _this._upAxis = 1, _this._sizeScale = new Vector3(1, 1, 1);
207
197
  _this._radius = radius;
208
198
  _this._halfHeight = height * 0.5;
209
199
  _this._axis = new Quaternion(0, 0, PhysXColliderShape.halfSqrt, PhysXColliderShape.halfSqrt);
@@ -220,13 +210,13 @@ var ShapeFlag;
220
210
  this._radius = value;
221
211
  var sizeScale = this._sizeScale;
222
212
  switch(this._upAxis){
223
- case /** Up axis is X. */ 0:
213
+ case 0:
224
214
  this._pxGeometry.radius = this._radius * Math.max(sizeScale.y, sizeScale.z);
225
215
  break;
226
216
  case 1:
227
217
  this._pxGeometry.radius = this._radius * Math.max(sizeScale.x, sizeScale.z);
228
218
  break;
229
- case /** Up axis is Z. */ 2:
219
+ case 2:
230
220
  this._pxGeometry.radius = this._radius * Math.max(sizeScale.x, sizeScale.y);
231
221
  break;
232
222
  }
@@ -320,14 +310,6 @@ var ShapeFlag;
320
310
  };
321
311
  return PhysXCapsuleColliderShape;
322
312
  }(PhysXColliderShape);
323
- var /**
324
- * The up axis of the collider shape.
325
- */ ColliderShapeUpAxis;
326
- (function(ColliderShapeUpAxis) {
327
- ColliderShapeUpAxis[ColliderShapeUpAxis["X"] = 0] = "X";
328
- ColliderShapeUpAxis[ColliderShapeUpAxis["Y"] = 1] = "Y";
329
- ColliderShapeUpAxis[ColliderShapeUpAxis["Z"] = 2] = "Z";
330
- })(ColliderShapeUpAxis || (ColliderShapeUpAxis = {}));
331
313
 
332
314
  /**
333
315
  * Base class for character controllers.
@@ -447,9 +429,7 @@ var /**
447
429
  };
448
430
  return PhysXCharacterController;
449
431
  }();
450
- (function() {
451
- PhysXCharacterController._tempVec = new Vector3();
452
- })();
432
+ PhysXCharacterController._tempVec = new Vector3();
453
433
 
454
434
  /**
455
435
  * Abstract class of physical collider.
@@ -495,27 +475,18 @@ var /**
495
475
  };
496
476
  return PhysXCollider;
497
477
  }();
498
- (function() {
499
- PhysXCollider._tempTransform = {
500
- translation: null,
501
- rotation: null
502
- };
503
- })();
478
+ PhysXCollider._tempTransform = {
479
+ translation: null,
480
+ rotation: null
481
+ };
504
482
 
505
- var CollisionDetectionMode;
506
- (function(CollisionDetectionMode) {
507
- CollisionDetectionMode[CollisionDetectionMode[/** Continuous collision detection is off for this dynamic collider. */ "Discrete"] = 0] = "Discrete";
508
- CollisionDetectionMode[CollisionDetectionMode[/** Continuous collision detection is on for colliding with static mesh geometry. */ "Continuous"] = 1] = "Continuous";
509
- CollisionDetectionMode[CollisionDetectionMode[/** Continuous collision detection is on for colliding with static and dynamic geometry. */ "ContinuousDynamic"] = 2] = "ContinuousDynamic";
510
- CollisionDetectionMode[CollisionDetectionMode[/** Speculative continuous collision detection is on for static and dynamic geometries */ "ContinuousSpeculative"] = 3] = "ContinuousSpeculative";
511
- })(CollisionDetectionMode || (CollisionDetectionMode = {}));
512
483
  /**
513
484
  * A dynamic collider can act with self-defined movement or physical force
514
- */ var PhysXDynamicCollider = /*#__PURE__*/ function(PhysXCollider1) {
515
- _inherits(PhysXDynamicCollider, PhysXCollider1);
485
+ */ var PhysXDynamicCollider = /*#__PURE__*/ function(PhysXCollider) {
486
+ _inherits(PhysXDynamicCollider, PhysXCollider);
516
487
  function PhysXDynamicCollider(physXPhysics, position, rotation) {
517
488
  var _this;
518
- _this = PhysXCollider1.call(this, physXPhysics) || this;
489
+ _this = PhysXCollider.call(this, physXPhysics) || this;
519
490
  var transform = _this._transform(position, rotation);
520
491
  _this._pxActor = physXPhysics._pxPhysics.createRigidDynamic(transform);
521
492
  return _this;
@@ -658,12 +629,8 @@ var CollisionDetectionMode;
658
629
  };
659
630
  return PhysXDynamicCollider;
660
631
  }(PhysXCollider);
661
- (function() {
662
- PhysXDynamicCollider._tempTranslation = new Vector3();
663
- })();
664
- (function() {
665
- PhysXDynamicCollider._tempRotation = new Quaternion();
666
- })();
632
+ PhysXDynamicCollider._tempTranslation = new Vector3();
633
+ PhysXDynamicCollider._tempRotation = new Quaternion();
667
634
 
668
635
  var PhysXPhysicsManager = function PhysXPhysicsManager() {
669
636
  /** @internal */ this._eventMap = {};
@@ -712,15 +679,6 @@ var PhysXPhysicsManager = function PhysXPhysicsManager() {
712
679
  };
713
680
  return PhysXPhysicsMaterial;
714
681
  }();
715
- var /**
716
- * Describes how physics materials of the colliding objects are combined.
717
- */ CombineMode;
718
- (function(CombineMode) {
719
- CombineMode[CombineMode[/** Averages the friction/bounce of the two colliding materials. */ "Average"] = 0] = "Average";
720
- CombineMode[CombineMode[/** Uses the smaller friction/bounce of the two colliding materials. */ "Minimum"] = 1] = "Minimum";
721
- CombineMode[CombineMode[/** Multiplies the friction/bounce of the two colliding materials. */ "Multiply"] = 2] = "Multiply";
722
- CombineMode[CombineMode[/** Uses the larger friction/bounce of the two colliding materials. */ "Maximum"] = 3] = "Maximum";
723
- })(CombineMode || (CombineMode = {}));
724
682
 
725
683
  /**
726
684
  * A manager is a collection of colliders and constraints which can interact.
@@ -915,31 +873,8 @@ var /**
915
873
  };
916
874
  return PhysXPhysicsScene;
917
875
  }();
918
- (function() {
919
- PhysXPhysicsScene._tempPosition = new Vector3();
920
- })();
921
- (function() {
922
- PhysXPhysicsScene._tempNormal = new Vector3();
923
- })();
924
- var /**
925
- * Filtering flags for scene queries.
926
- */ QueryFlag;
927
- (function(QueryFlag) {
928
- QueryFlag[QueryFlag["STATIC"] = 1] = "STATIC";
929
- QueryFlag[QueryFlag["DYNAMIC"] = 2] = "DYNAMIC";
930
- QueryFlag[QueryFlag["PRE_FILTER"] = 4] = "PRE_FILTER";
931
- QueryFlag[QueryFlag["POST_FILTER"] = 8] = "POST_FILTER";
932
- QueryFlag[QueryFlag["ANY_HIT"] = 16] = "ANY_HIT";
933
- QueryFlag[QueryFlag["NO_BLOCK"] = 32] = "NO_BLOCK";
934
- })(QueryFlag || (QueryFlag = {}));
935
- var /**
936
- * Physics state
937
- */ TriggerEventState;
938
- (function(TriggerEventState) {
939
- TriggerEventState[TriggerEventState["Enter"] = 0] = "Enter";
940
- TriggerEventState[TriggerEventState["Stay"] = 1] = "Stay";
941
- TriggerEventState[TriggerEventState["Exit"] = 2] = "Exit";
942
- })(TriggerEventState || (TriggerEventState = {}));
876
+ PhysXPhysicsScene._tempPosition = new Vector3();
877
+ PhysXPhysicsScene._tempNormal = new Vector3();
943
878
  /**
944
879
  * Trigger event to store interactive object ids and state.
945
880
  */ var TriggerEvent = function TriggerEvent(index1, index2) {
@@ -950,11 +885,11 @@ var /**
950
885
  /**
951
886
  * A static collider component that will not move.
952
887
  * @remarks Mostly used for object which always stays at the same place and never moves around.
953
- */ var PhysXStaticCollider = /*#__PURE__*/ function(PhysXCollider1) {
954
- _inherits(PhysXStaticCollider, PhysXCollider1);
888
+ */ var PhysXStaticCollider = /*#__PURE__*/ function(PhysXCollider) {
889
+ _inherits(PhysXStaticCollider, PhysXCollider);
955
890
  function PhysXStaticCollider(physXPhysics, position, rotation) {
956
891
  var _this;
957
- _this = PhysXCollider1.call(this, physXPhysics) || this;
892
+ _this = PhysXCollider.call(this, physXPhysics) || this;
958
893
  _this._pxActor = physXPhysics._pxPhysics.createRigidStatic(_this._transform(position, rotation));
959
894
  return _this;
960
895
  }
@@ -963,12 +898,12 @@ var /**
963
898
 
964
899
  /**
965
900
  * PhysX runtime mode.
966
- */ var PhysXRuntimeMode;
967
- (function(PhysXRuntimeMode) {
968
- PhysXRuntimeMode[PhysXRuntimeMode[/** Use webAssembly mode first, if WebAssembly mode is not supported, roll back to JavaScript mode. */ "Auto"] = 0] = "Auto";
969
- PhysXRuntimeMode[PhysXRuntimeMode[/** WebAssembly mode. */ "WebAssembly"] = 1] = "WebAssembly";
970
- PhysXRuntimeMode[PhysXRuntimeMode[/** JavaScript mode. */ "JavaScript"] = 2] = "JavaScript";
971
- })(PhysXRuntimeMode || (PhysXRuntimeMode = {}));
901
+ */ var PhysXRuntimeMode = /*#__PURE__*/ function(PhysXRuntimeMode) {
902
+ /** Use webAssembly mode first, if WebAssembly mode is not supported, roll back to JavaScript mode. */ PhysXRuntimeMode[PhysXRuntimeMode["Auto"] = 0] = "Auto";
903
+ /** WebAssembly mode. */ PhysXRuntimeMode[PhysXRuntimeMode["WebAssembly"] = 1] = "WebAssembly";
904
+ /** JavaScript mode. */ PhysXRuntimeMode[PhysXRuntimeMode["JavaScript"] = 2] = "JavaScript";
905
+ return PhysXRuntimeMode;
906
+ }({});
972
907
 
973
908
  /**
974
909
  * a base interface providing common functionality for PhysX joints
@@ -983,8 +918,8 @@ var /**
983
918
  /**
984
919
  * {@inheritDoc IJoint.setConnectedCollider }
985
920
  */ _proto.setConnectedCollider = function setConnectedCollider(value) {
986
- var _value, _this__collider;
987
- this._pxJoint.setActors(((_value = value) == null ? void 0 : _value._pxActor) || null, ((_this__collider = this._collider) == null ? void 0 : _this__collider._pxActor) || null);
921
+ var _this__collider;
922
+ this._pxJoint.setActors((value == null ? void 0 : value._pxActor) || null, ((_this__collider = this._collider) == null ? void 0 : _this__collider._pxActor) || null);
988
923
  };
989
924
  /**
990
925
  * {@inheritDoc IJoint.setConnectedAnchor }
@@ -1034,15 +969,9 @@ var /**
1034
969
  };
1035
970
  return PhysXJoint;
1036
971
  }();
1037
- (function() {
1038
- PhysXJoint._xAxis = new Vector3(1, 0, 0);
1039
- })();
1040
- (function() {
1041
- PhysXJoint._defaultVec = new Vector3();
1042
- })();
1043
- (function() {
1044
- PhysXJoint._defaultQuat = new Quaternion();
1045
- })();
972
+ PhysXJoint._xAxis = new Vector3(1, 0, 0);
973
+ PhysXJoint._defaultVec = new Vector3();
974
+ PhysXJoint._defaultQuat = new Quaternion();
1046
975
 
1047
976
  /**
1048
977
  * A fixed joint permits no relative movement between two colliders. ie the bodies are glued together.
@@ -1064,9 +993,7 @@ var /**
1064
993
  _inherits(PhysXHingeJoint, PhysXJoint1);
1065
994
  function PhysXHingeJoint(physXPhysics, collider) {
1066
995
  var _this;
1067
- _this = PhysXJoint1.call(this, physXPhysics) || this;
1068
- _this._axisRotationQuaternion = new Quaternion();
1069
- _this._swingOffset = new Vector3();
996
+ _this = PhysXJoint1.call(this, physXPhysics) || this, _this._axisRotationQuaternion = new Quaternion(), _this._swingOffset = new Vector3();
1070
997
  _this._collider = collider;
1071
998
  _this._pxJoint = physXPhysics._pxPhysics.createRevoluteJoint(null, PhysXJoint._defaultVec, PhysXJoint._defaultQuat, collider._pxActor, PhysXJoint._defaultVec, PhysXJoint._defaultQuat);
1072
999
  return _this;
@@ -1140,8 +1067,7 @@ var /**
1140
1067
  _inherits(PhysXSpringJoint, PhysXJoint1);
1141
1068
  function PhysXSpringJoint(physXPhysics, collider) {
1142
1069
  var _this;
1143
- _this = PhysXJoint1.call(this, physXPhysics) || this;
1144
- _this._swingOffset = new Vector3();
1070
+ _this = PhysXJoint1.call(this, physXPhysics) || this, _this._swingOffset = new Vector3();
1145
1071
  _this._collider = collider;
1146
1072
  _this._pxJoint = physXPhysics._pxPhysics.createDistanceJoint(null, PhysXJoint._defaultVec, PhysXJoint._defaultQuat, collider._pxActor, PhysXJoint._defaultVec, PhysXJoint._defaultQuat);
1147
1073
  _this._pxJoint.setDistanceJointFlag(2, true); // enable max distance;
@@ -1203,12 +1129,11 @@ var /**
1203
1129
 
1204
1130
  /**
1205
1131
  * Sphere collider shape in PhysX.
1206
- */ var PhysXSphereColliderShape = /*#__PURE__*/ function(PhysXColliderShape1) {
1207
- _inherits(PhysXSphereColliderShape, PhysXColliderShape1);
1132
+ */ var PhysXSphereColliderShape = /*#__PURE__*/ function(PhysXColliderShape) {
1133
+ _inherits(PhysXSphereColliderShape, PhysXColliderShape);
1208
1134
  function PhysXSphereColliderShape(physXPhysics, uniqueID, radius, material) {
1209
1135
  var _this;
1210
- _this = PhysXColliderShape1.call(this, physXPhysics) || this;
1211
- _this._maxScale = 1;
1136
+ _this = PhysXColliderShape.call(this, physXPhysics) || this, _this._maxScale = 1;
1212
1137
  _this._radius = radius;
1213
1138
  _this._pxGeometry = new physXPhysics._physX.PxSphereGeometry(_this._radius * _this._maxScale);
1214
1139
  _this._initialize(material, uniqueID);
@@ -1226,7 +1151,7 @@ var /**
1226
1151
  /**
1227
1152
  * {@inheritDoc IColliderShape.setWorldScale }
1228
1153
  */ _proto.setWorldScale = function setWorldScale(scale) {
1229
- PhysXColliderShape1.prototype.setWorldScale.call(this, scale);
1154
+ PhysXColliderShape.prototype.setWorldScale.call(this, scale);
1230
1155
  this._maxScale = Math.max(Math.abs(scale.x), Math.abs(scale.y), Math.abs(scale.z));
1231
1156
  this._pxGeometry.radius = this._radius * this._maxScale;
1232
1157
  this._pxShape.setGeometry(this._pxGeometry);
@@ -1264,7 +1189,7 @@ var /**
1264
1189
  if (runtimeMode == PhysXRuntimeMode.Auto) {
1265
1190
  var supported = function() {
1266
1191
  try {
1267
- if (typeof WebAssembly === "object" && typeof WebAssembly.instantiate === "function") {
1192
+ if ((typeof WebAssembly === "undefined" ? "undefined" : _type_of(WebAssembly)) === "object" && typeof WebAssembly.instantiate === "function") {
1268
1193
  var module = new WebAssembly.Module(Uint8Array.of(0x0, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00));
1269
1194
  if (_instanceof(module, WebAssembly.Module)) return _instanceof(new WebAssembly.Instance(module), WebAssembly.Instance);
1270
1195
  }
@@ -1386,15 +1311,9 @@ var /**
1386
1311
  };
1387
1312
  return PhysXPhysics;
1388
1313
  }();
1389
- var InitializeState;
1390
- (function(InitializeState) {
1391
- InitializeState[InitializeState["Uninitialized"] = 0] = "Uninitialized";
1392
- InitializeState[InitializeState["Initializing"] = 1] = "Initializing";
1393
- InitializeState[InitializeState["Initialized"] = 2] = "Initialized";
1394
- })(InitializeState || (InitializeState = {}));
1395
1314
 
1396
1315
  //@ts-ignore
1397
- var version = "1.3.23";
1316
+ var version = "1.4.0-alpha.0";
1398
1317
  console.log("Galacean PhysX version: " + version);
1399
1318
 
1400
1319
  export { PhysXPhysics, PhysXRuntimeMode, version };