@galacean/engine-physics-physx 0.0.0-experimental-2.0-game.13 → 0.0.0-experimental-2.0-game.14

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);
@@ -51,6 +57,7 @@
51
57
  this._physXRotation = new engine.Quaternion();
52
58
  this._shapeFlags = 2 | 1;
53
59
  this._physXPhysics = physXPhysics;
60
+ this._contractOffset = physXPhysics.getDefaultContactOffset();
54
61
  }
55
62
  var _proto = PhysXColliderShape.prototype;
56
63
  /**
@@ -1608,12 +1615,6 @@
1608
1615
  return self;
1609
1616
  }
1610
1617
 
1611
- function _type_of(obj) {
1612
- "@swc/helpers - typeof";
1613
-
1614
- return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
1615
- }
1616
-
1617
1618
  function _possible_constructor_return(self, call) {
1618
1619
  if (call && (_type_of(call) === "object" || typeof call === "function")) return call;
1619
1620
 
@@ -1822,14 +1823,23 @@
1822
1823
  /**
1823
1824
  * PhysX object creation.
1824
1825
  */ var PhysXPhysics = /*#__PURE__*/ function() {
1825
- function PhysXPhysics(runtimeMode, runtimeUrls) {
1826
- if (runtimeMode === void 0) runtimeMode = PhysXRuntimeMode.Auto;
1826
+ function PhysXPhysics(runtimeModeOrOptions, runtimeUrls, options) {
1827
+ if (runtimeModeOrOptions === void 0) runtimeModeOrOptions = PhysXRuntimeMode.Auto;
1828
+ var _this__tolerancesScaleOptions, _this__tolerancesScaleOptions1;
1827
1829
  this._initializeState = 0;
1830
+ this._defaultContactOffset = 0.02;
1831
+ this._defaultSleepThreshold = 5e-3;
1832
+ var isOptionsObject = (typeof runtimeModeOrOptions === "undefined" ? "undefined" : _type_of(runtimeModeOrOptions)) === "object";
1833
+ var runtimeMode = isOptionsObject ? PhysXRuntimeMode.Auto : runtimeModeOrOptions != null ? runtimeModeOrOptions : PhysXRuntimeMode.Auto;
1834
+ var resolvedOptions = isOptionsObject ? runtimeModeOrOptions : options;
1828
1835
  this._runTimeMode = runtimeMode;
1829
1836
  var _runtimeUrls_wasmSIMDModeUrl;
1830
1837
  this._wasmSIMDModeUrl = (_runtimeUrls_wasmSIMDModeUrl = runtimeUrls == null ? void 0 : runtimeUrls.wasmSIMDModeUrl) != null ? _runtimeUrls_wasmSIMDModeUrl : "https://mdn.alipayobjects.com/rms/afts/file/A*iHrYQKBrgTAAAAAAQ4AAAAgAehQnAQ/physx.release.simd.js";
1831
1838
  var _runtimeUrls_wasmModeUrl;
1832
1839
  this._wasmModeUrl = (_runtimeUrls_wasmModeUrl = runtimeUrls == null ? void 0 : runtimeUrls.wasmModeUrl) != null ? _runtimeUrls_wasmModeUrl : "https://mdn.alipayobjects.com/rms/afts/file/A*DFuvR6Mv5C0AAAAAQ4AAAAgAehQnAQ/physx.release.js";
1840
+ this._tolerancesScaleOptions = resolvedOptions == null ? void 0 : resolvedOptions.tolerancesScale;
1841
+ var _this__tolerancesScaleOptions_length, _this__tolerancesScaleOptions_speed;
1842
+ this._updateScaledDefaults((_this__tolerancesScaleOptions_length = (_this__tolerancesScaleOptions = this._tolerancesScaleOptions) == null ? void 0 : _this__tolerancesScaleOptions.length) != null ? _this__tolerancesScaleOptions_length : 1, (_this__tolerancesScaleOptions_speed = (_this__tolerancesScaleOptions1 = this._tolerancesScaleOptions) == null ? void 0 : _this__tolerancesScaleOptions1.speed) != null ? _this__tolerancesScaleOptions_speed : 10);
1833
1843
  }
1834
1844
  var _proto = PhysXPhysics.prototype;
1835
1845
  /**
@@ -1899,6 +1909,16 @@
1899
1909
  return scene;
1900
1910
  };
1901
1911
  /**
1912
+ * {@inheritDoc IPhysics.getDefaultContactOffset }
1913
+ */ _proto.getDefaultContactOffset = function getDefaultContactOffset() {
1914
+ return this._defaultContactOffset;
1915
+ };
1916
+ /**
1917
+ * {@inheritDoc IPhysics.getDefaultSleepThreshold }
1918
+ */ _proto.getDefaultSleepThreshold = function getDefaultSleepThreshold() {
1919
+ return this._defaultSleepThreshold;
1920
+ };
1921
+ /**
1902
1922
  * {@inheritDoc IPhysics.createStaticCollider }
1903
1923
  */ _proto.createStaticCollider = function createStaticCollider(position, rotation) {
1904
1924
  return new PhysXStaticCollider(this, position, rotation);
@@ -1975,6 +1995,7 @@
1975
1995
  var allocator = new physX.PxDefaultAllocator();
1976
1996
  var pxFoundation = physX.PxCreateFoundation(version, allocator, defaultErrorCallback);
1977
1997
  var tolerancesScale = new physX.PxTolerancesScale();
1998
+ this._applyTolerancesScale(tolerancesScale);
1978
1999
  var pxPhysics = physX.PxCreatePhysics(version, pxFoundation, tolerancesScale, false, null);
1979
2000
  physX.PxInitExtensions(pxPhysics, null);
1980
2001
  // Initialize cooking for mesh colliders
@@ -1995,11 +2016,32 @@
1995
2016
  this._allocator = allocator;
1996
2017
  this._tolerancesScale = tolerancesScale;
1997
2018
  };
2019
+ _proto._applyTolerancesScale = function _applyTolerancesScale(tolerancesScale) {
2020
+ var _this__tolerancesScaleOptions, _this__tolerancesScaleOptions1;
2021
+ var _this__tolerancesScaleOptions_length;
2022
+ var length = (_this__tolerancesScaleOptions_length = (_this__tolerancesScaleOptions = this._tolerancesScaleOptions) == null ? void 0 : _this__tolerancesScaleOptions.length) != null ? _this__tolerancesScaleOptions_length : tolerancesScale.length;
2023
+ var _this__tolerancesScaleOptions_speed;
2024
+ var speed = (_this__tolerancesScaleOptions_speed = (_this__tolerancesScaleOptions1 = this._tolerancesScaleOptions) == null ? void 0 : _this__tolerancesScaleOptions1.speed) != null ? _this__tolerancesScaleOptions_speed : tolerancesScale.speed;
2025
+ this._assertPositiveFinite(length, "tolerancesScale.length");
2026
+ this._assertPositiveFinite(speed, "tolerancesScale.speed");
2027
+ tolerancesScale.length = length;
2028
+ tolerancesScale.speed = speed;
2029
+ this._updateScaledDefaults(length, speed);
2030
+ };
2031
+ _proto._assertPositiveFinite = function _assertPositiveFinite(value, name) {
2032
+ if (!Number.isFinite(value) || value <= 0) {
2033
+ throw new Error("PhysXPhysics " + name + " must be a positive finite number.");
2034
+ }
2035
+ };
2036
+ _proto._updateScaledDefaults = function _updateScaledDefaults(length, speed) {
2037
+ this._defaultContactOffset = 0.02 * length;
2038
+ this._defaultSleepThreshold = 5e-5 * speed * speed;
2039
+ };
1998
2040
  return PhysXPhysics;
1999
2041
  }();
2000
2042
 
2001
2043
  //@ts-ignore
2002
- var version = "0.0.0-experimental-2.0-game.13";
2044
+ var version = "0.0.0-experimental-2.0-game.14";
2003
2045
  console.log("Galacean Engine Physics PhysX Version: " + version);
2004
2046
 
2005
2047
  exports.PhysXPhysics = PhysXPhysics;