@galacean/engine-physics-physx 0.0.0-experimental-2.0-skill.0 → 0.0.0-experimental-2.0-migrate.7

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 CHANGED
@@ -4,6 +4,12 @@
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.Galacean = global.Galacean || {}, global.Galacean.PhysicsPhysX = {}), global.Galacean));
5
5
  })(this, (function (exports, engine) { 'use strict';
6
6
 
7
+ function _type_of(obj) {
8
+ "@swc/helpers - typeof";
9
+
10
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
11
+ }
12
+
7
13
  function _instanceof(left, right) {
8
14
  if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
9
15
  return !!right[Symbol.hasInstance](left);
@@ -43,7 +49,7 @@
43
49
  */ var PhysXColliderShape = /*#__PURE__*/ function() {
44
50
  function PhysXColliderShape(physXPhysics) {
45
51
  /** @internal */ this._controllers = new engine.DisorderedArray();
46
- /** @internal */ this._contractOffset = 0.02;
52
+ /** @internal */ this._contactOffset = 0.02;
47
53
  /** @internal */ this._worldScale = new engine.Vector3(1, 1, 1);
48
54
  /** @internal */ this._position = new engine.Vector3();
49
55
  /** @internal */ this._rotation = new engine.Vector3();
@@ -51,6 +57,7 @@
51
57
  this._physXRotation = new engine.Quaternion();
52
58
  this._shapeFlags = 2 | 1;
53
59
  this._physXPhysics = physXPhysics;
60
+ this._contactOffset = physXPhysics.getDefaultContactOffset();
54
61
  }
55
62
  var _proto = PhysXColliderShape.prototype;
56
63
  /**
@@ -88,7 +95,7 @@
88
95
  * {@inheritDoc IColliderShape.setContactOffset }
89
96
  * @default 0.02f * PxTolerancesScale::length
90
97
  */ _proto.setContactOffset = function setContactOffset(offset) {
91
- this._contractOffset = offset;
98
+ this._contactOffset = offset;
92
99
  var controllers = this._controllers;
93
100
  if (controllers.length) {
94
101
  for(var i = 0, n = controllers.length; i < n; i++){
@@ -429,7 +436,7 @@
429
436
  this._pxManager && this._createPXController(this._pxManager, shape);
430
437
  this._shape = shape;
431
438
  shape._controllers.add(this);
432
- (_this__pxController = this._pxController) == null ? void 0 : _this__pxController.setContactOffset(shape._contractOffset);
439
+ (_this__pxController = this._pxController) == null ? void 0 : _this__pxController.setContactOffset(shape._contactOffset);
433
440
  (_this__scene = this._scene) == null ? void 0 : _this__scene._addColliderShape(shape._id);
434
441
  };
435
442
  /**
@@ -583,7 +590,15 @@
583
590
  _inherits(PhysXDynamicCollider, PhysXCollider);
584
591
  function PhysXDynamicCollider(physXPhysics, position, rotation) {
585
592
  var _this;
586
- _this = PhysXCollider.call(this, physXPhysics) || this;
593
+ _this = PhysXCollider.call(this, physXPhysics) || this, /**
594
+ * Whether actor is currently kinematic.
595
+ * PhysX 拒绝在 kinematic actor 上启用 CCD(会打印警告并忽略),
596
+ * 所以 setCollisionDetectionMode 在 kinematic 状态下只缓存目标值,
597
+ * 等切回 dynamic 时再真正写到 PhysX。
598
+ */ _this._isKinematic = false, /**
599
+ * Cached collision detection mode. Always reflects user's intent.
600
+ * 实际 PhysX CCD flag 可能跟这个不一致(kinematic 时强制 Discrete)。
601
+ */ _this._collisionDetectionMode = 0;
587
602
  var transform = _this._transform(position, rotation);
588
603
  _this._pxActor = physXPhysics._pxPhysics.createRigidDynamic(transform);
589
604
  return _this;
@@ -666,7 +681,7 @@
666
681
  };
667
682
  /**
668
683
  * {@inheritDoc IDynamicCollider.setSleepThreshold }
669
- * @default 1e-5f * PxTolerancesScale::speed * PxTolerancesScale::speed
684
+ * @default 5e-5f * PxTolerancesScale::speed * PxTolerancesScale::speed
670
685
  */ _proto.setSleepThreshold = function setSleepThreshold(value) {
671
686
  this._pxActor.setSleepThreshold(value);
672
687
  };
@@ -677,7 +692,45 @@
677
692
  };
678
693
  /**
679
694
  * {@inheritDoc IDynamicCollider.setCollisionDetectionMode }
695
+ *
696
+ * PhysX 在 kinematic actor 上调用 setRigidBodyFlag(eENABLE_CCD, true) 会触发警告:
697
+ * "kinematic bodies with CCD enabled are not supported! CCD will be ignored"
698
+ * 虽然 PhysX 会忽略这次调用而非真的拒绝(切回 dynamic 时 flag 不会自动恢复),
699
+ * 但每次 setIsKinematic 切换都会让这个 warning 重复打印,污染日志,
700
+ * 同时让 actor 在 dynamic 状态下 CCD flag 状态不确定。
701
+ *
702
+ * 解决: 只在 dynamic 状态时立即 apply CCD flags。kinematic 时仅缓存到
703
+ * `_collisionDetectionMode`,等切回 dynamic 时由 setIsKinematic 重新 apply。
680
704
  */ _proto.setCollisionDetectionMode = function setCollisionDetectionMode(value) {
705
+ this._collisionDetectionMode = value;
706
+ if (!this._isKinematic) {
707
+ this._applyCollisionDetectionFlags(value);
708
+ }
709
+ };
710
+ /**
711
+ * {@inheritDoc IDynamicCollider.setUseGravity }
712
+ */ _proto.setUseGravity = function setUseGravity(value) {
713
+ this._pxActor.setActorFlag(this._physXPhysics._physX.PxActorFlag.eDISABLE_GRAVITY, !value);
714
+ };
715
+ /**
716
+ * {@inheritDoc IDynamicCollider.setIsKinematic }
717
+ *
718
+ * 切换 kinematic 状态时同步处理 CCD flag:
719
+ * - 切到 kinematic 前先关 CCD(避免 PhysX 警告 + 让状态显式)
720
+ * - 切回 dynamic 后恢复用户期望的 CCD mode(来自 `_collisionDetectionMode` 缓存)
721
+ */ _proto.setIsKinematic = function setIsKinematic(value) {
722
+ if (this._isKinematic === value) return;
723
+ var physX = this._physXPhysics._physX;
724
+ if (value) {
725
+ this._applyCollisionDetectionFlags(0);
726
+ this._pxActor.setRigidBodyFlag(physX.PxRigidBodyFlag.eKINEMATIC, true);
727
+ } else {
728
+ this._pxActor.setRigidBodyFlag(physX.PxRigidBodyFlag.eKINEMATIC, false);
729
+ this._applyCollisionDetectionFlags(this._collisionDetectionMode);
730
+ }
731
+ this._isKinematic = value;
732
+ };
733
+ _proto._applyCollisionDetectionFlags = function _applyCollisionDetectionFlags(value) {
681
734
  var physX = this._physXPhysics._physX;
682
735
  switch(value){
683
736
  case 1:
@@ -703,27 +756,20 @@
703
756
  }
704
757
  };
705
758
  /**
706
- * {@inheritDoc IDynamicCollider.setUseGravity }
707
- */ _proto.setUseGravity = function setUseGravity(value) {
708
- this._pxActor.setActorFlag(this._physXPhysics._physX.PxActorFlag.eDISABLE_GRAVITY, !value);
709
- };
710
- /**
711
- * {@inheritDoc IDynamicCollider.setIsKinematic }
712
- */ _proto.setIsKinematic = function setIsKinematic(value) {
713
- if (value) {
714
- this._pxActor.setRigidBodyFlag(this._physXPhysics._physX.PxRigidBodyFlag.eKINEMATIC, true);
715
- } else {
716
- this._pxActor.setRigidBodyFlag(this._physXPhysics._physX.PxRigidBodyFlag.eKINEMATIC, false);
717
- }
718
- };
719
- /**
720
759
  * {@inheritDoc IDynamicCollider.setConstraints }
721
760
  */ _proto.setConstraints = function setConstraints(flags) {
722
761
  this._pxActor.setRigidDynamicLockFlags(flags);
723
762
  };
724
763
  /**
725
764
  * {@inheritDoc IDynamicCollider.addForce }
765
+ *
766
+ * PhysX 在 kinematic actor 上调 addForce 是 no-op(doc: "kinematic bodies don't
767
+ * respond to forces")。提前 return 避免无意义的 wasm boundary cross。
768
+ *
769
+ * Sleeping actor 不需要显式 wakeUp — wasm binding 调用 `addForce(force, eFORCE,
770
+ * autowake=true)`,PhysX 自动唤醒(已通过 `applyForce on sleeping actor` 测试验证)。
726
771
  */ _proto.addForce = function addForce(force) {
772
+ if (this._isKinematic) return;
727
773
  this._pxActor.addForce(force);
728
774
  };
729
775
  /**
@@ -733,23 +779,33 @@
733
779
  };
734
780
  /**
735
781
  * {@inheritDoc IDynamicCollider.addTorque }
782
+ *
783
+ * 同 addForce — kinematic 提前 return,sleeping 由 PhysX autowake 自动处理。
736
784
  */ _proto.addTorque = function addTorque(torque) {
785
+ if (this._isKinematic) return;
737
786
  this._pxActor.addTorque(torque);
738
787
  };
739
788
  /**
740
789
  * {@inheritDoc IDynamicCollider.move }
790
+ *
791
+ * PhysX 要求 setKinematicTarget 的 rotation 是 normalized quaternion,否则会触发
792
+ * 内部 assertion / 警告,并把 actor 转到错误的姿态。所以在写入 wasm 边界前统一 normalize。
741
793
  */ _proto.move = function move(positionOrRotation, rotation) {
794
+ var tempTranslation = PhysXDynamicCollider._tempTranslation;
795
+ var tempRotation = PhysXDynamicCollider._tempRotation;
742
796
  if (rotation) {
743
- this._pxActor.setKinematicTarget(positionOrRotation, rotation);
797
+ tempRotation.copyFrom(rotation).normalize();
798
+ this._pxActor.setKinematicTarget(positionOrRotation, tempRotation);
744
799
  return;
745
800
  }
746
- var tempTranslation = PhysXDynamicCollider._tempTranslation;
747
- var tempRotation = PhysXDynamicCollider._tempRotation;
748
- this.getWorldTransform(tempTranslation, tempRotation);
749
801
  if (_instanceof(positionOrRotation, engine.Vector3)) {
802
+ this.getWorldTransform(tempTranslation, tempRotation);
803
+ // current rotation read from PhysX is already normalized; no extra work needed
750
804
  this._pxActor.setKinematicTarget(positionOrRotation, tempRotation);
751
805
  } else {
752
- this._pxActor.setKinematicTarget(tempTranslation, positionOrRotation);
806
+ this.getWorldTransform(tempTranslation, tempRotation);
807
+ tempRotation.copyFrom(positionOrRotation).normalize();
808
+ this._pxActor.setKinematicTarget(tempTranslation, tempRotation);
753
809
  }
754
810
  };
755
811
  /**
@@ -852,6 +908,7 @@
852
908
  this._activeTriggers = new engine.DisorderedArray();
853
909
  this._contactEvents = [];
854
910
  this._contactEventCount = 0;
911
+ this._contactEventEnabled = true;
855
912
  this._triggerEvents = [];
856
913
  this._physicsEvents = {
857
914
  contactEvents: [],
@@ -974,6 +1031,17 @@
974
1031
  this._fetchResults();
975
1032
  };
976
1033
  /**
1034
+ * {@inheritDoc IPhysicsScene.setContactEventEnabled }
1035
+ */ _proto.setContactEventEnabled = function setContactEventEnabled(enabled) {
1036
+ if (this._contactEventEnabled === enabled) {
1037
+ return;
1038
+ }
1039
+ this._contactEventEnabled = enabled;
1040
+ if (!enabled) {
1041
+ this._contactEventCount = 0;
1042
+ }
1043
+ };
1044
+ /**
977
1045
  * {@inheritDoc IPhysicsScene.updateEvents }
978
1046
  */ _proto.updateEvents = function updateEvents() {
979
1047
  var physicsEvents = this._physicsEvents;
@@ -1221,6 +1289,7 @@
1221
1289
  };
1222
1290
  _proto._bufferContactEvent = function _bufferContactEvent(collision, state) {
1223
1291
  var _this__contactEvents, _index;
1292
+ if (!this._contactEventEnabled) return;
1224
1293
  var index = this._contactEventCount++;
1225
1294
  var event = (_this__contactEvents = this._contactEvents)[_index = index] || (_this__contactEvents[_index] = new ContactEvent());
1226
1295
  event.shape0Id = collision.shape0Id;
@@ -1558,12 +1627,6 @@
1558
1627
  return self;
1559
1628
  }
1560
1629
 
1561
- function _type_of(obj) {
1562
- "@swc/helpers - typeof";
1563
-
1564
- return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
1565
- }
1566
-
1567
1630
  function _possible_constructor_return(self, call) {
1568
1631
  if (call && (_type_of(call) === "object" || typeof call === "function")) return call;
1569
1632
 
@@ -1578,7 +1641,8 @@
1578
1641
  var _this;
1579
1642
  _this = PhysXColliderShape.call(this, physXPhysics) || this, _this._pxMesh = null;
1580
1643
  _this._isConvex = isConvex;
1581
- if (!_this._cookMesh(positions, indices, cookingFlags)) {
1644
+ var cooked = _this._cookMesh(positions, indices, isConvex, cookingFlags);
1645
+ if (!cooked) {
1582
1646
  return _possible_constructor_return(_this);
1583
1647
  }
1584
1648
  var physX = physXPhysics._physX, physics = physXPhysics._pxPhysics;
@@ -1586,9 +1650,11 @@
1586
1650
  var shapeFlags = ShapeFlag.SCENE_QUERY_SHAPE | ShapeFlag.SIMULATION_SHAPE;
1587
1651
  var meshFlag = isConvex ? PhysXMeshColliderShape._tightBoundsFlag : 0;
1588
1652
  var createShapeFn = isConvex ? physX.createConvexMeshShape : physX.createTriMeshShape;
1589
- _this._pxShape = createShapeFn(_this._pxMesh, scaleX, scaleY, scaleZ, meshFlag, shapeFlags, material._pxMaterial, physics);
1653
+ _this._pxShape = createShapeFn(cooked.mesh, scaleX, scaleY, scaleZ, meshFlag, shapeFlags, material._pxMaterial, physics);
1590
1654
  _this._id = uniqueID;
1591
1655
  _this._pxMaterial = material._pxMaterial;
1656
+ _this._pxMesh = cooked.mesh;
1657
+ _this._pxGeometry = cooked.geometry;
1592
1658
  _this._pxShape.setUUID(uniqueID);
1593
1659
  _this._setLocalPose();
1594
1660
  return _this;
@@ -1597,16 +1663,25 @@
1597
1663
  /**
1598
1664
  * {@inheritDoc IMeshColliderShape.setMeshData }
1599
1665
  */ _proto.setMeshData = function setMeshData(positions, indices, isConvex, cookingFlags) {
1600
- var _this__pxMesh, _this__pxGeometry;
1601
- (_this__pxMesh = this._pxMesh) == null ? void 0 : _this__pxMesh.release();
1602
- (_this__pxGeometry = this._pxGeometry) == null ? void 0 : _this__pxGeometry.delete();
1603
- this._pxMesh = null;
1604
- this._pxGeometry = null;
1605
- this._isConvex = isConvex;
1606
- if (!this._cookMesh(positions, indices, cookingFlags)) {
1666
+ var cooked = this._cookMesh(positions, indices, isConvex, cookingFlags);
1667
+ if (!cooked) {
1607
1668
  return false;
1608
1669
  }
1609
- this._pxShape.setGeometry(this._pxGeometry);
1670
+ var oldMesh = this._pxMesh;
1671
+ var oldGeometry = this._pxGeometry;
1672
+ try {
1673
+ this._pxShape.setGeometry(cooked.geometry);
1674
+ } catch (error) {
1675
+ var _cooked_mesh, _cooked_geometry;
1676
+ (_cooked_mesh = cooked.mesh) == null ? void 0 : _cooked_mesh.release();
1677
+ (_cooked_geometry = cooked.geometry) == null ? void 0 : _cooked_geometry.delete();
1678
+ throw error;
1679
+ }
1680
+ this._pxMesh = cooked.mesh;
1681
+ this._pxGeometry = cooked.geometry;
1682
+ this._isConvex = isConvex;
1683
+ oldMesh == null ? void 0 : oldMesh.release();
1684
+ oldGeometry == null ? void 0 : oldGeometry.delete();
1610
1685
  return true;
1611
1686
  };
1612
1687
  /**
@@ -1622,7 +1697,7 @@
1622
1697
  (_this__pxMesh = this._pxMesh) == null ? void 0 : _this__pxMesh.release();
1623
1698
  PhysXColliderShape.prototype.destroy.call(this);
1624
1699
  };
1625
- _proto._cookMesh = function _cookMesh(positions, indices, cookingFlags) {
1700
+ _proto._cookMesh = function _cookMesh(positions, indices, isConvex, cookingFlags) {
1626
1701
  var _this__physXPhysics = this._physXPhysics, physX = _this__physXPhysics._physX, physics = _this__physXPhysics._pxPhysics, cooking = _this__physXPhysics._pxCooking, cookingParams = _this__physXPhysics._pxCookingParams;
1627
1702
  // Apply per-shape cooking flags
1628
1703
  var preprocessFlags = 0;
@@ -1635,33 +1710,37 @@
1635
1710
  physX.setCookingMeshPreprocessParams(cookingParams, preprocessFlags);
1636
1711
  cooking.setParams(cookingParams);
1637
1712
  var verticesPtr = this._allocatePositions(positions);
1638
- if (this._isConvex) {
1639
- this._pxMesh = cooking.createConvexMesh(verticesPtr, positions.length, physics);
1713
+ var pxMesh = null;
1714
+ if (isConvex) {
1715
+ pxMesh = cooking.createConvexMesh(verticesPtr, positions.length, physics);
1640
1716
  physX._free(verticesPtr);
1641
- if (!this._pxMesh) {
1717
+ if (!pxMesh) {
1642
1718
  this._logConvexCookingError(physX);
1643
- return false;
1719
+ return null;
1644
1720
  }
1645
1721
  } else {
1646
1722
  if (!indices) {
1647
1723
  physX._free(verticesPtr);
1648
1724
  console.error("PhysXMeshColliderShape: Triangle mesh requires indices.");
1649
- return false;
1725
+ return null;
1650
1726
  }
1651
1727
  var isU32 = _instanceof(indices, Uint32Array);
1652
1728
  var indicesPtr = this._allocateIndices(indices, isU32);
1653
- this._pxMesh = cooking.createTriMesh(verticesPtr, positions.length, indicesPtr, indices.length / 3, !isU32, physics);
1729
+ pxMesh = cooking.createTriMesh(verticesPtr, positions.length, indicesPtr, indices.length / 3, !isU32, physics);
1654
1730
  physX._free(verticesPtr);
1655
1731
  physX._free(indicesPtr);
1656
- if (!this._pxMesh) {
1732
+ if (!pxMesh) {
1657
1733
  this._logTriMeshCookingError(physX);
1658
- return false;
1734
+ return null;
1659
1735
  }
1660
1736
  }
1661
1737
  var _this__worldScale = this._worldScale, scaleX = _this__worldScale.x, scaleY = _this__worldScale.y, scaleZ = _this__worldScale.z;
1662
- var meshFlag = this._isConvex ? PhysXMeshColliderShape._tightBoundsFlag : 0;
1663
- this._pxGeometry = this._isConvex ? physX.createConvexMeshGeometry(this._pxMesh, scaleX, scaleY, scaleZ, meshFlag) : physX.createTriMeshGeometry(this._pxMesh, scaleX, scaleY, scaleZ, meshFlag);
1664
- return true;
1738
+ var meshFlag = isConvex ? PhysXMeshColliderShape._tightBoundsFlag : 0;
1739
+ var geometry = isConvex ? physX.createConvexMeshGeometry(pxMesh, scaleX, scaleY, scaleZ, meshFlag) : physX.createTriMeshGeometry(pxMesh, scaleX, scaleY, scaleZ, meshFlag);
1740
+ return {
1741
+ mesh: pxMesh,
1742
+ geometry: geometry
1743
+ };
1665
1744
  };
1666
1745
  _proto._logConvexCookingError = function _logConvexCookingError(physX) {
1667
1746
  switch(physX.getLastConvexCookingResult()){
@@ -1711,9 +1790,15 @@
1711
1790
  var _this__worldScale = this._worldScale, scaleX = _this__worldScale.x, scaleY = _this__worldScale.y, scaleZ = _this__worldScale.z;
1712
1791
  var meshFlag = this._isConvex ? PhysXMeshColliderShape._tightBoundsFlag : 0;
1713
1792
  var newGeometry = this._isConvex ? physX.createConvexMeshGeometry(this._pxMesh, scaleX, scaleY, scaleZ, meshFlag) : physX.createTriMeshGeometry(this._pxMesh, scaleX, scaleY, scaleZ, meshFlag);
1714
- this._pxGeometry.delete();
1793
+ var oldGeometry = this._pxGeometry;
1794
+ try {
1795
+ this._pxShape.setGeometry(newGeometry);
1796
+ } catch (error) {
1797
+ newGeometry == null ? void 0 : newGeometry.delete();
1798
+ throw error;
1799
+ }
1715
1800
  this._pxGeometry = newGeometry;
1716
- this._pxShape.setGeometry(this._pxGeometry);
1801
+ oldGeometry == null ? void 0 : oldGeometry.delete();
1717
1802
  };
1718
1803
  return PhysXMeshColliderShape;
1719
1804
  }(PhysXColliderShape);
@@ -1772,14 +1857,27 @@
1772
1857
  /**
1773
1858
  * PhysX object creation.
1774
1859
  */ var PhysXPhysics = /*#__PURE__*/ function() {
1775
- function PhysXPhysics(runtimeMode, runtimeUrls) {
1776
- if (runtimeMode === void 0) runtimeMode = PhysXRuntimeMode.Auto;
1860
+ function PhysXPhysics(runtimeModeOrOptions, runtimeUrls, options) {
1861
+ if (runtimeModeOrOptions === void 0) runtimeModeOrOptions = PhysXRuntimeMode.Auto;
1862
+ var _this__tolerancesScaleOptions, _this__tolerancesScaleOptions1;
1777
1863
  this._initializeState = 0;
1864
+ this._defaultContactOffset = 0.02;
1865
+ this._defaultSleepThreshold = 5e-3;
1866
+ var isOptionsObject = (typeof runtimeModeOrOptions === "undefined" ? "undefined" : _type_of(runtimeModeOrOptions)) === "object";
1867
+ var runtimeMode = isOptionsObject ? PhysXRuntimeMode.Auto : runtimeModeOrOptions != null ? runtimeModeOrOptions : PhysXRuntimeMode.Auto;
1868
+ var resolvedOptions = isOptionsObject ? runtimeModeOrOptions : options;
1778
1869
  this._runTimeMode = runtimeMode;
1779
1870
  var _runtimeUrls_wasmSIMDModeUrl;
1780
- this._wasmSIMDModeUrl = (_runtimeUrls_wasmSIMDModeUrl = runtimeUrls == null ? void 0 : runtimeUrls.wasmSIMDModeUrl) != null ? _runtimeUrls_wasmSIMDModeUrl : "https://mdn.alipayobjects.com/rms/uri/file/as/apwallet/1781696156399/suyi/physx.release.simd.js";
1871
+ this._wasmSIMDModeUrl = (_runtimeUrls_wasmSIMDModeUrl = runtimeUrls == null ? void 0 : runtimeUrls.wasmSIMDModeUrl) != null ? _runtimeUrls_wasmSIMDModeUrl : "https://mdn.alipayobjects.com/rms/uri/file/as/apwallet/1786450043249/suyi/physx.release.simd.js";
1781
1872
  var _runtimeUrls_wasmModeUrl;
1782
- this._wasmModeUrl = (_runtimeUrls_wasmModeUrl = runtimeUrls == null ? void 0 : runtimeUrls.wasmModeUrl) != null ? _runtimeUrls_wasmModeUrl : "https://mdn.alipayobjects.com/rms/uri/file/as/apwallet/1781696156399/suyi/physx.release.js";
1873
+ this._wasmModeUrl = (_runtimeUrls_wasmModeUrl = runtimeUrls == null ? void 0 : runtimeUrls.wasmModeUrl) != null ? _runtimeUrls_wasmModeUrl : "https://mdn.alipayobjects.com/rms/uri/file/as/apwallet/1786450043249/suyi/physx.release.js";
1874
+ this._tolerancesScaleOptions = resolvedOptions == null ? void 0 : resolvedOptions.tolerancesScale;
1875
+ var _this__tolerancesScaleOptions_length;
1876
+ var length = (_this__tolerancesScaleOptions_length = (_this__tolerancesScaleOptions = this._tolerancesScaleOptions) == null ? void 0 : _this__tolerancesScaleOptions.length) != null ? _this__tolerancesScaleOptions_length : 1;
1877
+ var _this__tolerancesScaleOptions_speed;
1878
+ var speed = (_this__tolerancesScaleOptions_speed = (_this__tolerancesScaleOptions1 = this._tolerancesScaleOptions) == null ? void 0 : _this__tolerancesScaleOptions1.speed) != null ? _this__tolerancesScaleOptions_speed : 10;
1879
+ this._validateTolerancesScale(length, speed);
1880
+ this._updateScaledDefaults(length, speed);
1783
1881
  }
1784
1882
  var _proto = PhysXPhysics.prototype;
1785
1883
  /**
@@ -1849,6 +1947,16 @@
1849
1947
  return scene;
1850
1948
  };
1851
1949
  /**
1950
+ * {@inheritDoc IPhysics.getDefaultContactOffset }
1951
+ */ _proto.getDefaultContactOffset = function getDefaultContactOffset() {
1952
+ return this._defaultContactOffset;
1953
+ };
1954
+ /**
1955
+ * {@inheritDoc IPhysics.getDefaultSleepThreshold }
1956
+ */ _proto.getDefaultSleepThreshold = function getDefaultSleepThreshold() {
1957
+ return this._defaultSleepThreshold;
1958
+ };
1959
+ /**
1852
1960
  * {@inheritDoc IPhysics.createStaticCollider }
1853
1961
  */ _proto.createStaticCollider = function createStaticCollider(position, rotation) {
1854
1962
  return new PhysXStaticCollider(this, position, rotation);
@@ -1925,6 +2033,7 @@
1925
2033
  var allocator = new physX.PxDefaultAllocator();
1926
2034
  var pxFoundation = physX.PxCreateFoundation(version, allocator, defaultErrorCallback);
1927
2035
  var tolerancesScale = new physX.PxTolerancesScale();
2036
+ this._applyTolerancesScale(tolerancesScale);
1928
2037
  var pxPhysics = physX.PxCreatePhysics(version, pxFoundation, tolerancesScale, false, null);
1929
2038
  physX.PxInitExtensions(pxPhysics, null);
1930
2039
  // Initialize cooking for mesh colliders
@@ -1945,11 +2054,35 @@
1945
2054
  this._allocator = allocator;
1946
2055
  this._tolerancesScale = tolerancesScale;
1947
2056
  };
2057
+ _proto._applyTolerancesScale = function _applyTolerancesScale(tolerancesScale) {
2058
+ var _this__tolerancesScaleOptions, _this__tolerancesScaleOptions1;
2059
+ var _this__tolerancesScaleOptions_length;
2060
+ var length = (_this__tolerancesScaleOptions_length = (_this__tolerancesScaleOptions = this._tolerancesScaleOptions) == null ? void 0 : _this__tolerancesScaleOptions.length) != null ? _this__tolerancesScaleOptions_length : tolerancesScale.length;
2061
+ var _this__tolerancesScaleOptions_speed;
2062
+ var speed = (_this__tolerancesScaleOptions_speed = (_this__tolerancesScaleOptions1 = this._tolerancesScaleOptions) == null ? void 0 : _this__tolerancesScaleOptions1.speed) != null ? _this__tolerancesScaleOptions_speed : tolerancesScale.speed;
2063
+ this._validateTolerancesScale(length, speed);
2064
+ tolerancesScale.length = length;
2065
+ tolerancesScale.speed = speed;
2066
+ this._updateScaledDefaults(length, speed);
2067
+ };
2068
+ _proto._assertPositiveFinite = function _assertPositiveFinite(value, name) {
2069
+ if (!Number.isFinite(value) || value <= 0) {
2070
+ throw new Error("PhysXPhysics " + name + " must be a positive finite number.");
2071
+ }
2072
+ };
2073
+ _proto._validateTolerancesScale = function _validateTolerancesScale(length, speed) {
2074
+ this._assertPositiveFinite(length, "tolerancesScale.length");
2075
+ this._assertPositiveFinite(speed, "tolerancesScale.speed");
2076
+ };
2077
+ _proto._updateScaledDefaults = function _updateScaledDefaults(length, speed) {
2078
+ this._defaultContactOffset = 0.02 * length;
2079
+ this._defaultSleepThreshold = 5e-5 * speed * speed;
2080
+ };
1948
2081
  return PhysXPhysics;
1949
2082
  }();
1950
2083
 
1951
2084
  //@ts-ignore
1952
- var version = "0.0.0-experimental-2.0-skill.0";
2085
+ var version = "0.0.0-experimental-2.0-migrate.7";
1953
2086
  console.log("Galacean Engine Physics PhysX Version: " + version);
1954
2087
 
1955
2088
  exports.PhysXPhysics = PhysXPhysics;