@galacean/engine-physics-physx 1.1.0-alpha.3 → 1.1.0-beta.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/browser.js CHANGED
@@ -87,7 +87,7 @@
87
87
  */ var PhysXColliderShape = /*#__PURE__*/ function() {
88
88
  function PhysXColliderShape(physXPhysics) {
89
89
  /** @internal */ this._controllers = new DisorderedArray();
90
- this._scale = new engine.Vector3(1, 1, 1);
90
+ this._worldScale = new engine.Vector3(1, 1, 1);
91
91
  this._position = new engine.Vector3();
92
92
  this._rotation = null;
93
93
  this._axis = null;
@@ -114,18 +114,18 @@
114
114
  }
115
115
  var controllers = this._controllers;
116
116
  for(var i = 0, n = controllers.length; i < n; i++){
117
- controllers.get(i)._setLocalPosition(this._position, this._scale);
117
+ controllers.get(i)._setLocalPosition(this._position, this._worldScale);
118
118
  }
119
119
  this._setLocalPose();
120
120
  };
121
121
  /**
122
122
  * {@inheritDoc IColliderShape.setWorldScale }
123
123
  */ _proto.setWorldScale = function setWorldScale(scale) {
124
- this._scale.copyFrom(scale);
124
+ this._worldScale.copyFrom(scale);
125
125
  this._setLocalPose();
126
126
  var controllers = this._controllers;
127
127
  for(var i = 0, n = controllers.length; i < n; i++){
128
- controllers.get(i)._setLocalPosition(this._position, this._scale);
128
+ controllers.get(i)._setLocalPosition(this._position, this._worldScale);
129
129
  }
130
130
  };
131
131
  /**
@@ -164,7 +164,7 @@
164
164
  };
165
165
  _proto._setLocalPose = function _setLocalPose() {
166
166
  var transform = PhysXColliderShape.transform;
167
- engine.Vector3.multiply(this._position, this._scale, transform.translation);
167
+ engine.Vector3.multiply(this._position, this._worldScale, transform.translation);
168
168
  transform.rotation = this._physXRotation;
169
169
  this._pxShape.setLocalPose(transform);
170
170
  };
@@ -191,14 +191,14 @@
191
191
 
192
192
  /**
193
193
  * Box collider shape in PhysX.
194
- */ var PhysXBoxColliderShape = /*#__PURE__*/ function(PhysXColliderShape) {
195
- _inherits(PhysXBoxColliderShape, PhysXColliderShape);
194
+ */ var PhysXBoxColliderShape = /*#__PURE__*/ function(PhysXColliderShape1) {
195
+ _inherits(PhysXBoxColliderShape, PhysXColliderShape1);
196
196
  function PhysXBoxColliderShape(physXPhysics, uniqueID, size, material) {
197
197
  var _this;
198
- _this = PhysXColliderShape.call(this, physXPhysics) || this;
198
+ _this = PhysXColliderShape1.call(this, physXPhysics) || this;
199
199
  /** @internal */ _this._halfSize = new engine.Vector3();
200
200
  _this._halfSize.set(size.x * 0.5, size.y * 0.5, size.z * 0.5);
201
- _this._pxGeometry = new physXPhysics._physX.PxBoxGeometry(_this._halfSize.x * _this._scale.x, _this._halfSize.y * _this._scale.y, _this._halfSize.z * _this._scale.z);
201
+ _this._pxGeometry = new physXPhysics._physX.PxBoxGeometry(_this._halfSize.x * _this._worldScale.x, _this._halfSize.y * _this._worldScale.y, _this._halfSize.z * _this._worldScale.z);
202
202
  _this._initialize(material, uniqueID);
203
203
  _this._setLocalPose();
204
204
  return _this;
@@ -209,7 +209,7 @@
209
209
  */ _proto.setSize = function setSize(value) {
210
210
  var tempExtents = PhysXBoxColliderShape._tempHalfExtents;
211
211
  this._halfSize.set(value.x * 0.5, value.y * 0.5, value.z * 0.5);
212
- engine.Vector3.multiply(this._halfSize, this._scale, tempExtents);
212
+ engine.Vector3.multiply(this._halfSize, this._worldScale, tempExtents);
213
213
  this._pxGeometry.halfExtents = tempExtents;
214
214
  this._pxShape.setGeometry(this._pxGeometry);
215
215
  this._updateController(tempExtents);
@@ -217,9 +217,9 @@
217
217
  /**
218
218
  * {@inheritDoc IColliderShape.setWorldScale }
219
219
  */ _proto.setWorldScale = function setWorldScale(scale) {
220
- PhysXColliderShape.prototype.setWorldScale.call(this, scale);
220
+ PhysXColliderShape1.prototype.setWorldScale.call(this, scale);
221
221
  var tempExtents = PhysXBoxColliderShape._tempHalfExtents;
222
- engine.Vector3.multiply(this._halfSize, this._scale, tempExtents);
222
+ engine.Vector3.multiply(this._halfSize, this._worldScale, tempExtents);
223
223
  this._pxGeometry.halfExtents = tempExtents;
224
224
  this._pxShape.setGeometry(this._pxGeometry);
225
225
  this._updateController(tempExtents);
@@ -263,13 +263,13 @@
263
263
  this._radius = value;
264
264
  switch(this._upAxis){
265
265
  case /** Up axis is X. */ 0:
266
- this._pxGeometry.radius = this._radius * Math.max(this._scale.y, this._scale.z);
266
+ this._pxGeometry.radius = this._radius * Math.max(this._worldScale.y, this._worldScale.z);
267
267
  break;
268
268
  case 1:
269
- this._pxGeometry.radius = this._radius * Math.max(this._scale.x, this._scale.z);
269
+ this._pxGeometry.radius = this._radius * Math.max(this._worldScale.x, this._worldScale.z);
270
270
  break;
271
271
  case /** Up axis is Z. */ 2:
272
- this._pxGeometry.radius = this._radius * Math.max(this._scale.x, this._scale.y);
272
+ this._pxGeometry.radius = this._radius * Math.max(this._worldScale.x, this._worldScale.y);
273
273
  break;
274
274
  }
275
275
  this._pxShape.setGeometry(this._pxGeometry);
@@ -285,13 +285,13 @@
285
285
  this._halfHeight = value * 0.5;
286
286
  switch(this._upAxis){
287
287
  case 0:
288
- this._pxGeometry.halfHeight = this._halfHeight * this._scale.x;
288
+ this._pxGeometry.halfHeight = this._halfHeight * this._worldScale.x;
289
289
  break;
290
290
  case 1:
291
- this._pxGeometry.halfHeight = this._halfHeight * this._scale.y;
291
+ this._pxGeometry.halfHeight = this._halfHeight * this._worldScale.y;
292
292
  break;
293
293
  case 2:
294
- this._pxGeometry.halfHeight = this._halfHeight * this._scale.z;
294
+ this._pxGeometry.halfHeight = this._halfHeight * this._worldScale.z;
295
295
  break;
296
296
  }
297
297
  this._pxShape.setGeometry(this._pxGeometry);
@@ -534,11 +534,11 @@
534
534
  })(CollisionDetectionMode || (CollisionDetectionMode = {}));
535
535
  /**
536
536
  * A dynamic collider can act with self-defined movement or physical force
537
- */ var PhysXDynamicCollider = /*#__PURE__*/ function(PhysXCollider) {
538
- _inherits(PhysXDynamicCollider, PhysXCollider);
537
+ */ var PhysXDynamicCollider = /*#__PURE__*/ function(PhysXCollider1) {
538
+ _inherits(PhysXDynamicCollider, PhysXCollider1);
539
539
  function PhysXDynamicCollider(physXPhysics, position, rotation) {
540
540
  var _this;
541
- _this = PhysXCollider.call(this, physXPhysics) || this;
541
+ _this = PhysXCollider1.call(this, physXPhysics) || this;
542
542
  var transform = _this._transform(position, rotation);
543
543
  _this._pxActor = physXPhysics._pxPhysics.createRigidDynamic(transform);
544
544
  return _this;
@@ -968,11 +968,11 @@
968
968
  /**
969
969
  * A static collider component that will not move.
970
970
  * @remarks Mostly used for object which always stays at the same place and never moves around.
971
- */ var PhysXStaticCollider = /*#__PURE__*/ function(PhysXCollider) {
972
- _inherits(PhysXStaticCollider, PhysXCollider);
971
+ */ var PhysXStaticCollider = /*#__PURE__*/ function(PhysXCollider1) {
972
+ _inherits(PhysXStaticCollider, PhysXCollider1);
973
973
  function PhysXStaticCollider(physXPhysics, position, rotation) {
974
974
  var _this;
975
- _this = PhysXCollider.call(this, physXPhysics) || this;
975
+ _this = PhysXCollider1.call(this, physXPhysics) || this;
976
976
  _this._pxActor = physXPhysics._pxPhysics.createRigidStatic(_this._transform(position, rotation));
977
977
  return _this;
978
978
  }
@@ -1001,8 +1001,8 @@
1001
1001
  /**
1002
1002
  * {@inheritDoc IJoint.setConnectedCollider }
1003
1003
  */ _proto.setConnectedCollider = function setConnectedCollider(value) {
1004
- var _this__collider;
1005
- this._pxJoint.setActors((value == null ? void 0 : value._pxActor) || null, ((_this__collider = this._collider) == null ? void 0 : _this__collider._pxActor) || null);
1004
+ var _value, _this__collider;
1005
+ this._pxJoint.setActors(((_value = value) == null ? void 0 : _value._pxActor) || null, ((_this__collider = this._collider) == null ? void 0 : _this__collider._pxActor) || null);
1006
1006
  };
1007
1007
  /**
1008
1008
  * {@inheritDoc IJoint.setConnectedAnchor }
@@ -1223,11 +1223,11 @@
1223
1223
 
1224
1224
  /**
1225
1225
  * Sphere collider shape in PhysX.
1226
- */ var PhysXSphereColliderShape = /*#__PURE__*/ function(PhysXColliderShape) {
1227
- _inherits(PhysXSphereColliderShape, PhysXColliderShape);
1226
+ */ var PhysXSphereColliderShape = /*#__PURE__*/ function(PhysXColliderShape1) {
1227
+ _inherits(PhysXSphereColliderShape, PhysXColliderShape1);
1228
1228
  function PhysXSphereColliderShape(physXPhysics, uniqueID, radius, material) {
1229
1229
  var _this;
1230
- _this = PhysXColliderShape.call(this, physXPhysics) || this;
1230
+ _this = PhysXColliderShape1.call(this, physXPhysics) || this;
1231
1231
  _this._maxScale = 1;
1232
1232
  _this._radius = radius;
1233
1233
  _this._pxGeometry = new physXPhysics._physX.PxSphereGeometry(_this._radius * _this._maxScale);
@@ -1246,7 +1246,7 @@
1246
1246
  /**
1247
1247
  * {@inheritDoc IColliderShape.setWorldScale }
1248
1248
  */ _proto.setWorldScale = function setWorldScale(scale) {
1249
- PhysXColliderShape.prototype.setWorldScale.call(this, scale);
1249
+ PhysXColliderShape1.prototype.setWorldScale.call(this, scale);
1250
1250
  this._maxScale = Math.max(scale.x, scale.y, scale.z);
1251
1251
  this._pxGeometry.radius = this._radius * this._maxScale;
1252
1252
  this._pxShape.setGeometry(this._pxGeometry);
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@galacean/engine")):"function"==typeof define&&define.amd?define(["exports","@galacean/engine"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).Galacean=t.Galacean||{},t.Galacean.PhysicsPhysX={}),t.Galacean)}(this,function(t,e){"use strict";function i(t,e){return null!=e&&"undefined"!=typeof Symbol&&e[Symbol.hasInstance]?!!e[Symbol.hasInstance](t):t instanceof e}function s(t,e){return(s=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function n(t,e){if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&s(t,e)}var o,r,a,h,l,c,_,u,p,f,x,y,d,g,m,S=function(){function t(t){void 0===t&&(t=0),this.length=0,this._elements=Array(t)}var e=t.prototype;return e.add=function(t){this.length===this._elements.length?this._elements.push(t):this._elements[this.length]=t,this.length++},e.delete=function(t){var e=this._elements.indexOf(t);this.deleteByIndex(e)},e.get=function(t){if(t>=this.length)throw"Index is out of range.";return this._elements[t]},e.deleteByIndex=function(t){var e=this._elements,i=null,s=this.length-1;return t!==s&&(i=e[s],e[t]=i),this.length--,i},e.garbageCollection=function(){this._elements.length=this.length},t}();(o=p||(p={}))[o.SIMULATION_SHAPE=1]="SIMULATION_SHAPE",o[o.SCENE_QUERY_SHAPE=2]="SCENE_QUERY_SHAPE",o[o.TRIGGER_SHAPE=4]="TRIGGER_SHAPE";var v=function(){function t(t){this._controllers=new S,this._scale=new e.Vector3(1,1,1),this._position=new e.Vector3,this._rotation=null,this._axis=null,this._physXRotation=new e.Quaternion,this._shapeFlags=3,this._pxMaterials=[,],this._physXPhysics=t}var i=t.prototype;return i.setRotation=function(t){this._rotation=t,e.Quaternion.rotationYawPitchRoll(t.x,t.y,t.z,this._physXRotation),this._axis&&e.Quaternion.multiply(this._physXRotation,this._axis,this._physXRotation),this._physXRotation.normalize(),this._setLocalPose()},i.setPosition=function(t){t!==this._position&&this._position.copyFrom(t);for(var e=this._controllers,i=0,s=e.length;i<s;i++)e.get(i)._setLocalPosition(this._position,this._scale);this._setLocalPose()},i.setWorldScale=function(t){this._scale.copyFrom(t),this._setLocalPose();for(var e=this._controllers,i=0,s=e.length;i<s;i++)e.get(i)._setLocalPosition(this._position,this._scale)},i.setContactOffset=function(t){this._pxShape.setContactOffset(t);for(var e=this._controllers,i=0,s=e.length;i<s;i++)e.get(i)._pxController.setContactOffset(t)},i.setMaterial=function(t){this._pxMaterials[0]=t._pxMaterial,this._pxShape.setMaterials(this._pxMaterials)},i.setIsTrigger=function(t){this._modifyFlag(1,!t),this._modifyFlag(4,t),this._setShapeFlags(this._shapeFlags)},i.destroy=function(){this._pxShape.release()},i._setShapeFlags=function(t){this._shapeFlags=t,this._pxShape.setFlags(new this._physXPhysics._physX.PxShapeFlags(this._shapeFlags))},i._setLocalPose=function(){var i=t.transform;e.Vector3.multiply(this._position,this._scale,i.translation),i.rotation=this._physXRotation,this._pxShape.setLocalPose(i)},i._initialize=function(t,e){this._id=e,this._pxMaterials[0]=t._pxMaterial,this._pxShape=this._physXPhysics._pxPhysics.createShape(this._pxGeometry,t._pxMaterial,!0,new this._physXPhysics._physX.PxShapeFlags(this._shapeFlags)),this._pxShape.setUUID(e)},i._modifyFlag=function(t,e){this._shapeFlags=e?this._shapeFlags|t:this._shapeFlags&~t},t}();v.halfSqrt=.70710678118655,v.transform={translation:new e.Vector3,rotation:null};var P=function(t){function i(i,s,n,o){var r;return(r=t.call(this,i)||this)._halfSize=new e.Vector3,r._halfSize.set(.5*n.x,.5*n.y,.5*n.z),r._pxGeometry=new i._physX.PxBoxGeometry(r._halfSize.x*r._scale.x,r._halfSize.y*r._scale.y,r._halfSize.z*r._scale.z),r._initialize(o,s),r._setLocalPose(),r}n(i,t);var s=i.prototype;return s.setSize=function(t){var s=i._tempHalfExtents;this._halfSize.set(.5*t.x,.5*t.y,.5*t.z),e.Vector3.multiply(this._halfSize,this._scale,s),this._pxGeometry.halfExtents=s,this._pxShape.setGeometry(this._pxGeometry),this._updateController(s)},s.setWorldScale=function(s){t.prototype.setWorldScale.call(this,s);var n=i._tempHalfExtents;e.Vector3.multiply(this._halfSize,this._scale,n),this._pxGeometry.halfExtents=n,this._pxShape.setGeometry(this._pxGeometry),this._updateController(n)},s._updateController=function(t){for(var e=this._controllers,i=0,s=e.length;i<s;i++){var n=e.get(i)._pxController;n.setHalfHeight(t.x),n.setHalfSideExtent(t.y),n.setHalfForwardExtent(t.z)}},i}(v);P._tempHalfExtents=new e.Vector3;var C=function(t){function i(i,s,n,o,r){var a;return(a=t.call(this,i)||this)._upAxis=1,a._radius=n,a._halfHeight=.5*o,a._axis=new e.Quaternion(0,0,v.halfSqrt,v.halfSqrt),a._physXRotation.copyFrom(a._axis),a._pxGeometry=new i._physX.PxCapsuleGeometry(a._radius,a._halfHeight),a._initialize(r,s),a._setLocalPose(),a}n(i,t);var s=i.prototype;return s.setRadius=function(t){switch(this._radius=t,this._upAxis){case 0:this._pxGeometry.radius=this._radius*Math.max(this._scale.y,this._scale.z);break;case 1:this._pxGeometry.radius=this._radius*Math.max(this._scale.x,this._scale.z);break;case 2:this._pxGeometry.radius=this._radius*Math.max(this._scale.x,this._scale.y)}this._pxShape.setGeometry(this._pxGeometry);for(var e=this._pxGeometry.radius,i=this._controllers,s=0,n=i.length;s<n;s++)i.get(s)._pxController.setRadius(e)},s.setHeight=function(t){switch(this._halfHeight=.5*t,this._upAxis){case 0:this._pxGeometry.halfHeight=this._halfHeight*this._scale.x;break;case 1:this._pxGeometry.halfHeight=this._halfHeight*this._scale.y;break;case 2:this._pxGeometry.halfHeight=this._halfHeight*this._scale.z}this._pxShape.setGeometry(this._pxGeometry);for(var e=2*this._pxGeometry.halfHeight,i=this._controllers,s=0,n=i.length;s<n;s++)i.get(s)._pxController.setHeight(e)},s.setUpAxis=function(t){var i=this._rotation,s=this._axis,n=this._physXRotation;switch(this._upAxis=t,this._upAxis){case 0:s.set(0,0,0,1);break;case 1:s.set(0,0,v.halfSqrt,v.halfSqrt);break;case 2:s.set(0,v.halfSqrt,0,v.halfSqrt)}i?(e.Quaternion.rotationYawPitchRoll(i.x,i.y,i.z,n),e.Quaternion.multiply(n,s,n)):n.copyFrom(s),this._setLocalPose()},s.setWorldScale=function(e){t.prototype.setWorldScale.call(this,e);var i=this._pxGeometry;switch(this._upAxis){case 0:i.radius=this._radius*Math.max(e.y,e.z),i.halfHeight=this._halfHeight*e.x;break;case 1:i.radius=this._radius*Math.max(e.x,e.z),i.halfHeight=this._halfHeight*e.y;break;case 2:i.radius=this._radius*Math.max(e.x,e.y),i.halfHeight=this._halfHeight*e.z}this._pxShape.setGeometry(i);for(var s=i.radius,n=2*i.halfHeight,o=this._controllers,r=0,a=o.length;r<a;r++){var h=o.get(r)._pxController;h.setRadius(s),h.setHeight(n)}},i}(v);(r=f||(f={}))[r.X=0]="X",r[r.Y=1]="Y",r[r.Z=2]="Z";var A=function(){function t(t){this._scaledOffset=new e.Vector3,this._position=null,this._physXPhysics=t}var s=t.prototype;return s.move=function(t,e,i){return this._pxController.move(t,e,i)},s.setWorldPosition=function(i){this._position=i,this._pxController&&(e.Vector3.add(i,this._scaledOffset,t._tempVec),this._pxController.setPosition(t._tempVec))},s.getWorldPosition=function(t){t.copyFrom(this._pxController.getPosition()),t.subtract(this._scaledOffset)},s.setStepOffset=function(t){this._pxController.setStepOffset(t)},s.setNonWalkableMode=function(t){this._pxController.setNonWalkableMode(t)},s.setUpDirection=function(t){this._pxController.setUpDirection(t)},s.setSlopeLimit=function(t){this._pxController.setSlopeLimit(t)},s.addShape=function(t){this._pxManager&&this._createPXController(this._pxManager,t),this._shape=t,t._controllers.add(this)},s.removeShape=function(t){this._destroyPXController(),this._shape=null,t._controllers.delete(this)},s.destroy=function(){this._destroyPXController()},s._createPXController=function(t,e){var s;if(i(e,P))(s=new this._physXPhysics._physX.PxBoxControllerDesc).halfHeight=e._halfSize.x,s.halfSideExtent=e._halfSize.y,s.halfForwardExtent=e._halfSize.z;else if(i(e,C))(s=new this._physXPhysics._physX.PxCapsuleControllerDesc).radius=e._radius,s.height=2*e._halfHeight,s.climbingMode=1;else throw"unsupported shape type";s.setMaterial(e._pxMaterials[0]),this._pxController=t._getControllerManager().createController(s),this._pxController.setUUID(e._id)},s._destroyPXController=function(){this._pxController&&(this._pxController.release(),this._pxController=null)},s._setLocalPosition=function(t,i){e.Vector3.multiply(t,i,this._scaledOffset),this.setWorldPosition(t)},t}();A._tempVec=new e.Vector3;var M=function(){function t(t){this._physXPhysics=t}var e=t.prototype;return e.addShape=function(t){this._pxActor.attachShape(t._pxShape)},e.removeShape=function(t){this._pxActor.detachShape(t._pxShape,!0)},e.setWorldTransform=function(t,e){this._pxActor.setGlobalPose(this._transform(t,e),!0)},e.getWorldTransform=function(t,e){var i=this._pxActor.getGlobalPose();t.set(i.translation.x,i.translation.y,i.translation.z),e.set(i.rotation.x,i.rotation.y,i.rotation.z,i.rotation.w)},e.destroy=function(){this._pxActor.release()},e._transform=function(e,i){var s=t._tempTransform;return s.translation=e,s.rotation=i.normalize(),s},t}();M._tempTransform={translation:null,rotation:null},(a=x||(x={}))[a.Discrete=0]="Discrete",a[a.Continuous=1]="Continuous",a[a.ContinuousDynamic=2]="ContinuousDynamic",a[a.ContinuousSpeculative=3]="ContinuousSpeculative";var F=function(t){function s(e,i,s){var n,o=(n=t.call(this,e)||this)._transform(i,s);return n._pxActor=e._pxPhysics.createRigidDynamic(o),n}n(s,t);var o=s.prototype;return o.setLinearDamping=function(t){this._pxActor.setLinearDamping(t)},o.setAngularDamping=function(t){this._pxActor.setAngularDamping(t)},o.setLinearVelocity=function(t){this._pxActor.setLinearVelocity(t,!0)},o.setAngularVelocity=function(t){this._pxActor.setAngularVelocity(t,!0)},o.setMass=function(t){this._pxActor.setMass(t)},o.setCenterOfMass=function(t){this._pxActor.setCMassLocalPose(t)},o.setInertiaTensor=function(t){this._pxActor.setMassSpaceInertiaTensor(t)},o.setMaxAngularVelocity=function(t){this._pxActor.setMaxAngularVelocity(t)},o.setMaxDepenetrationVelocity=function(t){this._pxActor.setMaxDepenetrationVelocity(t)},o.setSleepThreshold=function(t){this._pxActor.setSleepThreshold(t)},o.setSolverIterations=function(t){this._pxActor.setSolverIterationCounts(t,1)},o.setCollisionDetectionMode=function(t){switch(t){case 1:this._pxActor.setRigidBodyFlag(this._physXPhysics._physX.PxRigidBodyFlag.eENABLE_CCD,!0);break;case 2:this._pxActor.setRigidBodyFlag(this._physXPhysics._physX.PxRigidBodyFlag.eENABLE_CCD_FRICTION,!0);break;case 3:this._pxActor.setRigidBodyFlag(this._physXPhysics._physX.PxRigidBodyFlag.eENABLE_SPECULATIVE_CCD,!0);break;case 0:var e=this._physXPhysics._physX;this._pxActor.setRigidBodyFlag(e.PxRigidBodyFlag.eENABLE_CCD,!1),this._pxActor.setRigidBodyFlag(e.PxRigidBodyFlag.eENABLE_CCD_FRICTION,!1),this._pxActor.setRigidBodyFlag(e.PxRigidBodyFlag.eENABLE_SPECULATIVE_CCD,!1)}},o.setIsKinematic=function(t){t?this._pxActor.setRigidBodyFlag(this._physXPhysics._physX.PxRigidBodyFlag.eKINEMATIC,!0):this._pxActor.setRigidBodyFlag(this._physXPhysics._physX.PxRigidBodyFlag.eKINEMATIC,!1)},o.setConstraints=function(t){this._pxActor.setRigidDynamicLockFlags(t)},o.addForce=function(t){this._pxActor.addForce({x:t.x,y:t.y,z:t.z})},o.addTorque=function(t){this._pxActor.addTorque({x:t.x,y:t.y,z:t.z})},o.move=function(t,n){if(n){this._pxActor.setKinematicTarget(t,n);return}var o=s._tempTranslation,r=s._tempRotation;this.getWorldTransform(o,r),i(t,e.Vector3)?this._pxActor.setKinematicTarget(t,r):this._pxActor.setKinematicTarget(o,t)},o.sleep=function(){return this._pxActor.putToSleep()},o.wakeUp=function(){return this._pxActor.wakeUp()},s}(M);F._tempTranslation=new e.Vector3,F._tempRotation=new e.Quaternion;var w=function(){this._eventMap={}},b=function(){function t(t,e,i,s,n,o){this._physXPhysics=t;var r=t._pxPhysics.createMaterial(e,i,s);r.setFrictionCombineMode(n),r.setRestitutionCombineMode(o),this._pxMaterial=r}var e=t.prototype;return e.setBounciness=function(t){this._pxMaterial.setRestitution(t)},e.setDynamicFriction=function(t){this._pxMaterial.setDynamicFriction(t)},e.setStaticFriction=function(t){this._pxMaterial.setStaticFriction(t)},e.setBounceCombine=function(t){this._pxMaterial.setRestitutionCombineMode(t)},e.setFrictionCombine=function(t){this._pxMaterial.setFrictionCombineMode(t)},e.destroy=function(){this._pxMaterial.release()},t}();(h=y||(y={}))[h.Average=0]="Average",h[h.Minimum=1]="Minimum",h[h.Multiply=2]="Multiply",h[h.Maximum=3]="Maximum";var R=function(){function t(t,e,i,s,n,o,r,a){var h=this;this._pxControllerManager=null,this._currentEvents=new S,this._eventPool=[],this._physXPhysics=t,this._physXManager=e;var l=t._physX;this._pxRaycastHit=new l.PxRaycastHit,this._pxFilterData=new l.PxQueryFilterData,this._pxFilterData.flags=new l.PxQueryFlags(7),this._onContactEnter=i,this._onContactExit=s,this._onContactStay=n,this._onTriggerEnter=o,this._onTriggerExit=r,this._onTriggerStay=a;var c=t._pxPhysics,_=l.PxSimulationEventCallback.implement({onContactBegin:function(t,e){h._onContactEnter(t,e)},onContactEnd:function(t,e){h._onContactExit(t,e)},onContactPersist:function(t,e){h._onContactStay(t,e)},onTriggerBegin:function(t,e){var i=t<e?h._getTrigger(t,e):h._getTrigger(e,t);i.state=0,h._currentEvents.add(i)},onTriggerEnd:function(t,e){var i;if(t<e){var s=h._physXManager._eventMap[t];i=s[e],s[e]=void 0}else{var n=h._physXManager._eventMap[e];i=n[t],n[t]=void 0}i.state=2}}),u=l.getDefaultSceneDesc(c.getTolerancesScale(),0,_);this._pxScene=c.createScene(u)}var e=t.prototype;return e.setGravity=function(t){this._pxScene.setGravity(t)},e.addColliderShape=function(t){this._physXManager._eventMap[t._id]={}},e.removeColliderShape=function(t){for(var e=this._eventPool,i=this._currentEvents,s=t._id,n=i.length-1;n>=0;n--){var o=i.get(n);(o.index1==s||o.index2==s)&&(i.deleteByIndex(n),e.push(o))}delete this._physXManager._eventMap[s]},e.addCollider=function(t){this._pxScene.addActor(t._pxActor,null)},e.removeCollider=function(t){this._pxScene.removeActor(t._pxActor,!0)},e.addCharacterController=function(t){if(!t._pxController){var e=t._shape;if(e){var i=t._pxManager;i!==this&&(i&&t._destroyPXController(),t._createPXController(this,e))}}t._pxManager=this},e.removeCharacterController=function(t){t._pxManager=null},e.update=function(t){this._simulate(t),this._fetchResults(),this._fireEvent()},e.raycast=function(e,i,s,n){var o=this._pxRaycastHit;i=Math.min(i,34e37);var r=this._pxScene.raycastSingle(e.origin,e.direction,i,o,this._pxFilterData,this._physXPhysics._physX.PxQueryFilterCallback.implement({preFilter:function(t,e,i){return s(e)?2:0},postFilter:function(t,e){}}));if(r&&void 0!=n){var a=t._tempPosition,h=t._tempNormal,l=o.position,c=o.normal;a.set(l.x,l.y,l.z),h.set(c.x,c.y,c.z),n(o.getShape().getUUID(),o.distance,a,h)}return r},e._getControllerManager=function(){var t=this._pxControllerManager;return null===t&&(this._pxControllerManager=t=this._pxScene.createControllerManager()),t},e._simulate=function(t){this._pxScene.simulate(t,!0)},e._fetchResults=function(t){void 0===t&&(t=!0),this._pxScene.fetchResults(t)},e._getTrigger=function(t,e){var i;return this._eventPool.length?((i=this._eventPool.pop()).index1=t,i.index2=e):i=new X(t,e),this._physXManager._eventMap[t][e]=i,i},e._fireEvent=function(){for(var t=this._eventPool,e=this._currentEvents,i=e.length-1;i>=0;i--){var s=e.get(i);0==s.state?(this._onTriggerEnter(s.index1,s.index2),s.state=1):1==s.state?this._onTriggerStay(s.index1,s.index2):2==s.state&&(this._onTriggerExit(s.index1,s.index2),e.deleteByIndex(i),t.push(s))}},t}();R._tempPosition=new e.Vector3,R._tempNormal=new e.Vector3,(l=d||(d={}))[l.STATIC=1]="STATIC",l[l.DYNAMIC=2]="DYNAMIC",l[l.PRE_FILTER=4]="PRE_FILTER",l[l.POST_FILTER=8]="POST_FILTER",l[l.ANY_HIT=16]="ANY_HIT",l[l.NO_BLOCK=32]="NO_BLOCK",(c=g||(g={}))[c.Enter=0]="Enter",c[c.Stay=1]="Stay",c[c.Exit=2]="Exit";var X=function(t,e){this.index1=t,this.index2=e},E=function(t){function e(e,i,s){var n;return(n=t.call(this,e)||this)._pxActor=e._pxPhysics.createRigidStatic(n._transform(i,s)),n}return n(e,t),e}(M);t.PhysXRuntimeMode=void 0,(_=t.PhysXRuntimeMode||(t.PhysXRuntimeMode={}))[_.Auto=0]="Auto",_[_.WebAssembly=1]="WebAssembly",_[_.JavaScript=2]="JavaScript";var T=function(){function t(t){this._connectedAnchor=new e.Vector3,this._breakForce=Number.MAX_VALUE,this._breakTorque=Number.MAX_VALUE,this._physXPhysics=t}var i=t.prototype;return i.setConnectedCollider=function(t){var e;this._pxJoint.setActors((null==t?void 0:t._pxActor)||null,(null==(e=this._collider)?void 0:e._pxActor)||null)},i.setConnectedAnchor=function(e){this._connectedAnchor.copyFrom(e),this._setLocalPose(0,e,t._defaultQuat)},i.setConnectedMassScale=function(t){this._pxJoint.setInvMassScale0(1/t)},i.setConnectedInertiaScale=function(t){this._pxJoint.setInvInertiaScale0(1/t)},i.setMassScale=function(t){this._pxJoint.setInvMassScale1(1/t)},i.setInertiaScale=function(t){this._pxJoint.setInvInertiaScale1(1/t)},i.setBreakForce=function(t){this._breakForce=t,this._pxJoint.setBreakForce(this._breakForce,this._breakTorque)},i.setBreakTorque=function(t){this._breakTorque=t,this._pxJoint.setBreakForce(this._breakForce,this._breakTorque)},i._setLocalPose=function(t,e,i){this._pxJoint.setLocalPose(t,e,i)},t}();T._xAxis=new e.Vector3(1,0,0),T._defaultVec=new e.Vector3,T._defaultQuat=new e.Quaternion;var I=function(t){function e(e,i){var s;return(s=t.call(this,e)||this)._collider=i,s._pxJoint=e._pxPhysics.createFixedJoint(null,T._defaultVec,T._defaultQuat,i._pxActor,T._defaultVec,T._defaultQuat),s}return n(e,t),e}(T),z=function(t){function i(i,s){var n;return(n=t.call(this,i)||this)._axisRotationQuaternion=new e.Quaternion,n._swingOffset=new e.Vector3,n._velocity=new e.Vector3,n._collider=s,n._pxJoint=i._pxPhysics.createRevoluteJoint(null,T._defaultVec,T._defaultQuat,s._pxActor,T._defaultVec,T._defaultQuat),n}n(i,t);var s=i.prototype;return s.setAxis=function(t){var i=T._xAxis,s=this._axisRotationQuaternion;i.set(1,0,0),t.normalize();var n=Math.acos(e.Vector3.dot(i,t));e.Vector3.cross(i,t,i),e.Quaternion.rotationAxisAngle(i,n,s),this._setLocalPose(0,this._swingOffset,s)},s.setSwingOffset=function(t){this._swingOffset.copyFrom(t),this._setLocalPose(1,this._swingOffset,this._axisRotationQuaternion)},s.getAngle=function(){return this._pxJoint.getAngle()},s.getVelocity=function(){var t=this._velocity;return t.copyFrom(this._pxJoint.getVelocity()),t},s.setHardLimit=function(t,e,i){this._pxJoint.setHardLimit(t,e,i)},s.setSoftLimit=function(t,e,i,s){this._pxJoint.setSoftLimit(t,e,i,s)},s.setDriveVelocity=function(t){this._pxJoint.setDriveVelocity(t)},s.setDriveForceLimit=function(t){this._pxJoint.setDriveForceLimit(t)},s.setDriveGearRatio=function(t){this._pxJoint.setDriveGearRatio(t)},s.setHingeJointFlag=function(t,e){this._pxJoint.setRevoluteJointFlag(t,e)},i}(T),D=function(t){function i(i,s){var n;return(n=t.call(this,i)||this)._swingOffset=new e.Vector3,n._collider=s,n._pxJoint=i._pxPhysics.createDistanceJoint(null,T._defaultVec,T._defaultQuat,s._pxActor,T._defaultVec,T._defaultQuat),n._pxJoint.setDistanceJointFlag(2,!0),n._pxJoint.setDistanceJointFlag(4,!0),n._pxJoint.setDistanceJointFlag(8,!0),n}n(i,t);var s=i.prototype;return s.setSwingOffset=function(t){this._swingOffset.copyFrom(t),this._setLocalPose(1,t,T._defaultQuat)},s.setMinDistance=function(t){this._pxJoint.setMinDistance(t)},s.setMaxDistance=function(t){this._pxJoint.setMaxDistance(t)},s.setTolerance=function(t){this._pxJoint.setTolerance(t)},s.setStiffness=function(t){this._pxJoint.setStiffness(t)},s.setDamping=function(t){this._pxJoint.setDamping(t)},i}(T),L=function(t){function i(i,s,n){var o;return(o=t.call(this,i)||this)._axis=new e.Quaternion(0,0,v.halfSqrt,v.halfSqrt),o._physXRotation.copyFrom(o._axis),o._pxGeometry=new i._physX.PxPlaneGeometry,o._initialize(n,s),o._setLocalPose(),o}return n(i,t),i}(v),V=function(t){function e(e,i,s,n){var o;return(o=t.call(this,e)||this)._maxScale=1,o._radius=s,o._pxGeometry=new e._physX.PxSphereGeometry(o._radius*o._maxScale),o._initialize(n,i),o._setLocalPose(),o}n(e,t);var i=e.prototype;return i.setRadius=function(t){this._radius=t,this._pxGeometry.radius=t*this._maxScale,this._pxShape.setGeometry(this._pxGeometry)},i.setWorldScale=function(e){t.prototype.setWorldScale.call(this,e),this._maxScale=Math.max(e.x,e.y,e.z),this._pxGeometry.radius=this._radius*this._maxScale,this._pxShape.setGeometry(this._pxGeometry)},e}(v),G=function(){function s(e){void 0===e&&(e=t.PhysXRuntimeMode.Auto),this._initializeState=0,this._runTimeMode=e}var n=s.prototype;return n.initialize=function(){var s=this;if(2===this._initializeState)return Promise.resolve();if(1===this._initializeState)return this._initializePromise;var n=this._runTimeMode,o=new Promise(function(s,o){var r=document.createElement("script");document.body.appendChild(r),r.async=!0,r.onload=s,r.onerror=o,n==t.PhysXRuntimeMode.Auto&&(n=!function(){try{if("object"==typeof WebAssembly&&"function"==typeof WebAssembly.instantiate){var t=new WebAssembly.Module(Uint8Array.of(0,97,115,109,1,0,0,0));if(i(t,WebAssembly.Module))return i(new WebAssembly.Instance(t),WebAssembly.Instance)}}catch(t){}return!1}()?t.PhysXRuntimeMode.JavaScript:t.PhysXRuntimeMode.WebAssembly),n==t.PhysXRuntimeMode.JavaScript?r.src="https://gw.alipayobjects.com/os/lib/galacean/engine-physics-physx/"+e.version+"/libs/physx.release.js.js":n==t.PhysXRuntimeMode.WebAssembly&&(r.src="https://gw.alipayobjects.com/os/lib/galacean/engine-physics-physx/"+e.version+"/libs/physx.release.js")}),r=new Promise(function(t,e){o.then(function(){return window.PHYSX().then(function(e){s._init(e),s._initializeState=2,s._initializePromise=null,console.log("PhysX loaded."),t()},e)},e).catch(e)});return this._initializePromise=r,r},n.destroy=function(){this._physX.PxCloseExtensions(),this._pxPhysics.release(),this._pxFoundation.release(),this._physX=null,this._pxFoundation=null,this._pxPhysics=null},n.createPhysicsManager=function(){return new w},n.createPhysicsScene=function(t,e,i,s,n,o,r){return new R(this,t,e,i,s,n,o,r)},n.createStaticCollider=function(t,e){return new E(this,t,e)},n.createDynamicCollider=function(t,e){return new F(this,t,e)},n.createCharacterController=function(){return new A(this)},n.createPhysicsMaterial=function(t,e,i,s,n){return new b(this,t,e,i,s,n)},n.createBoxColliderShape=function(t,e,i){return new P(this,t,e,i)},n.createSphereColliderShape=function(t,e,i){return new V(this,t,e,i)},n.createPlaneColliderShape=function(t,e){return new L(this,t,e)},n.createCapsuleColliderShape=function(t,e,i,s){return new C(this,t,e,i,s)},n.createFixedJoint=function(t){return new I(this,t)},n.createHingeJoint=function(t){return new z(this,t)},n.createSpringJoint=function(t){return new D(this,t)},n._init=function(t){var e=t.PX_PHYSICS_VERSION,i=new t.PxDefaultErrorCallback,s=new t.PxDefaultAllocator,n=t.PxCreateFoundation(e,s,i),o=t.PxCreatePhysics(e,n,new t.PxTolerancesScale,!1,null);t.PxInitExtensions(o,null),this._physX=t,this._pxFoundation=n,this._pxPhysics=o},s}();(u=m||(m={}))[u.Uninitialized=0]="Uninitialized",u[u.Initializing=1]="Initializing",u[u.Initialized=2]="Initialized",t.PhysXPhysics=G,Object.defineProperty(t,"__esModule",{value:!0})});
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@galacean/engine")):"function"==typeof define&&define.amd?define(["exports","@galacean/engine"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).Galacean=t.Galacean||{},t.Galacean.PhysicsPhysX={}),t.Galacean)}(this,function(t,e){"use strict";function i(t,e){return null!=e&&"undefined"!=typeof Symbol&&e[Symbol.hasInstance]?!!e[Symbol.hasInstance](t):t instanceof e}function n(t,e){return(n=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function s(t,e){if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&n(t,e)}var o,r,a,l,h,c,_,u,p,f,x,y,d,g,m,S=function(){function t(t){void 0===t&&(t=0),this.length=0,this._elements=Array(t)}var e=t.prototype;return e.add=function(t){this.length===this._elements.length?this._elements.push(t):this._elements[this.length]=t,this.length++},e.delete=function(t){var e=this._elements.indexOf(t);this.deleteByIndex(e)},e.get=function(t){if(t>=this.length)throw"Index is out of range.";return this._elements[t]},e.deleteByIndex=function(t){var e=this._elements,i=null,n=this.length-1;return t!==n&&(i=e[n],e[t]=i),this.length--,i},e.garbageCollection=function(){this._elements.length=this.length},t}();(o=p||(p={}))[o.SIMULATION_SHAPE=1]="SIMULATION_SHAPE",o[o.SCENE_QUERY_SHAPE=2]="SCENE_QUERY_SHAPE",o[o.TRIGGER_SHAPE=4]="TRIGGER_SHAPE";var v=function(){function t(t){this._controllers=new S,this._worldScale=new e.Vector3(1,1,1),this._position=new e.Vector3,this._rotation=null,this._axis=null,this._physXRotation=new e.Quaternion,this._shapeFlags=3,this._pxMaterials=[,],this._physXPhysics=t}var i=t.prototype;return i.setRotation=function(t){this._rotation=t,e.Quaternion.rotationYawPitchRoll(t.x,t.y,t.z,this._physXRotation),this._axis&&e.Quaternion.multiply(this._physXRotation,this._axis,this._physXRotation),this._physXRotation.normalize(),this._setLocalPose()},i.setPosition=function(t){t!==this._position&&this._position.copyFrom(t);for(var e=this._controllers,i=0,n=e.length;i<n;i++)e.get(i)._setLocalPosition(this._position,this._worldScale);this._setLocalPose()},i.setWorldScale=function(t){this._worldScale.copyFrom(t),this._setLocalPose();for(var e=this._controllers,i=0,n=e.length;i<n;i++)e.get(i)._setLocalPosition(this._position,this._worldScale)},i.setContactOffset=function(t){this._pxShape.setContactOffset(t);for(var e=this._controllers,i=0,n=e.length;i<n;i++)e.get(i)._pxController.setContactOffset(t)},i.setMaterial=function(t){this._pxMaterials[0]=t._pxMaterial,this._pxShape.setMaterials(this._pxMaterials)},i.setIsTrigger=function(t){this._modifyFlag(1,!t),this._modifyFlag(4,t),this._setShapeFlags(this._shapeFlags)},i.destroy=function(){this._pxShape.release()},i._setShapeFlags=function(t){this._shapeFlags=t,this._pxShape.setFlags(new this._physXPhysics._physX.PxShapeFlags(this._shapeFlags))},i._setLocalPose=function(){var i=t.transform;e.Vector3.multiply(this._position,this._worldScale,i.translation),i.rotation=this._physXRotation,this._pxShape.setLocalPose(i)},i._initialize=function(t,e){this._id=e,this._pxMaterials[0]=t._pxMaterial,this._pxShape=this._physXPhysics._pxPhysics.createShape(this._pxGeometry,t._pxMaterial,!0,new this._physXPhysics._physX.PxShapeFlags(this._shapeFlags)),this._pxShape.setUUID(e)},i._modifyFlag=function(t,e){this._shapeFlags=e?this._shapeFlags|t:this._shapeFlags&~t},t}();v.halfSqrt=.70710678118655,v.transform={translation:new e.Vector3,rotation:null};var P=function(t){function i(i,n,s,o){var r;return(r=t.call(this,i)||this)._halfSize=new e.Vector3,r._halfSize.set(.5*s.x,.5*s.y,.5*s.z),r._pxGeometry=new i._physX.PxBoxGeometry(r._halfSize.x*r._worldScale.x,r._halfSize.y*r._worldScale.y,r._halfSize.z*r._worldScale.z),r._initialize(o,n),r._setLocalPose(),r}s(i,t);var n=i.prototype;return n.setSize=function(t){var n=i._tempHalfExtents;this._halfSize.set(.5*t.x,.5*t.y,.5*t.z),e.Vector3.multiply(this._halfSize,this._worldScale,n),this._pxGeometry.halfExtents=n,this._pxShape.setGeometry(this._pxGeometry),this._updateController(n)},n.setWorldScale=function(n){t.prototype.setWorldScale.call(this,n);var s=i._tempHalfExtents;e.Vector3.multiply(this._halfSize,this._worldScale,s),this._pxGeometry.halfExtents=s,this._pxShape.setGeometry(this._pxGeometry),this._updateController(s)},n._updateController=function(t){for(var e=this._controllers,i=0,n=e.length;i<n;i++){var s=e.get(i)._pxController;s.setHalfHeight(t.x),s.setHalfSideExtent(t.y),s.setHalfForwardExtent(t.z)}},i}(v);P._tempHalfExtents=new e.Vector3;var C=function(t){function i(i,n,s,o,r){var a;return(a=t.call(this,i)||this)._upAxis=1,a._radius=s,a._halfHeight=.5*o,a._axis=new e.Quaternion(0,0,v.halfSqrt,v.halfSqrt),a._physXRotation.copyFrom(a._axis),a._pxGeometry=new i._physX.PxCapsuleGeometry(a._radius,a._halfHeight),a._initialize(r,n),a._setLocalPose(),a}s(i,t);var n=i.prototype;return n.setRadius=function(t){switch(this._radius=t,this._upAxis){case 0:this._pxGeometry.radius=this._radius*Math.max(this._worldScale.y,this._worldScale.z);break;case 1:this._pxGeometry.radius=this._radius*Math.max(this._worldScale.x,this._worldScale.z);break;case 2:this._pxGeometry.radius=this._radius*Math.max(this._worldScale.x,this._worldScale.y)}this._pxShape.setGeometry(this._pxGeometry);for(var e=this._pxGeometry.radius,i=this._controllers,n=0,s=i.length;n<s;n++)i.get(n)._pxController.setRadius(e)},n.setHeight=function(t){switch(this._halfHeight=.5*t,this._upAxis){case 0:this._pxGeometry.halfHeight=this._halfHeight*this._worldScale.x;break;case 1:this._pxGeometry.halfHeight=this._halfHeight*this._worldScale.y;break;case 2:this._pxGeometry.halfHeight=this._halfHeight*this._worldScale.z}this._pxShape.setGeometry(this._pxGeometry);for(var e=2*this._pxGeometry.halfHeight,i=this._controllers,n=0,s=i.length;n<s;n++)i.get(n)._pxController.setHeight(e)},n.setUpAxis=function(t){var i=this._rotation,n=this._axis,s=this._physXRotation;switch(this._upAxis=t,this._upAxis){case 0:n.set(0,0,0,1);break;case 1:n.set(0,0,v.halfSqrt,v.halfSqrt);break;case 2:n.set(0,v.halfSqrt,0,v.halfSqrt)}i?(e.Quaternion.rotationYawPitchRoll(i.x,i.y,i.z,s),e.Quaternion.multiply(s,n,s)):s.copyFrom(n),this._setLocalPose()},n.setWorldScale=function(e){t.prototype.setWorldScale.call(this,e);var i=this._pxGeometry;switch(this._upAxis){case 0:i.radius=this._radius*Math.max(e.y,e.z),i.halfHeight=this._halfHeight*e.x;break;case 1:i.radius=this._radius*Math.max(e.x,e.z),i.halfHeight=this._halfHeight*e.y;break;case 2:i.radius=this._radius*Math.max(e.x,e.y),i.halfHeight=this._halfHeight*e.z}this._pxShape.setGeometry(i);for(var n=i.radius,s=2*i.halfHeight,o=this._controllers,r=0,a=o.length;r<a;r++){var l=o.get(r)._pxController;l.setRadius(n),l.setHeight(s)}},i}(v);(r=f||(f={}))[r.X=0]="X",r[r.Y=1]="Y",r[r.Z=2]="Z";var A=function(){function t(t){this._scaledOffset=new e.Vector3,this._position=null,this._physXPhysics=t}var n=t.prototype;return n.move=function(t,e,i){return this._pxController.move(t,e,i)},n.setWorldPosition=function(i){this._position=i,this._pxController&&(e.Vector3.add(i,this._scaledOffset,t._tempVec),this._pxController.setPosition(t._tempVec))},n.getWorldPosition=function(t){t.copyFrom(this._pxController.getPosition()),t.subtract(this._scaledOffset)},n.setStepOffset=function(t){this._pxController.setStepOffset(t)},n.setNonWalkableMode=function(t){this._pxController.setNonWalkableMode(t)},n.setUpDirection=function(t){this._pxController.setUpDirection(t)},n.setSlopeLimit=function(t){this._pxController.setSlopeLimit(t)},n.addShape=function(t){this._pxManager&&this._createPXController(this._pxManager,t),this._shape=t,t._controllers.add(this)},n.removeShape=function(t){this._destroyPXController(),this._shape=null,t._controllers.delete(this)},n.destroy=function(){this._destroyPXController()},n._createPXController=function(t,e){var n;if(i(e,P))(n=new this._physXPhysics._physX.PxBoxControllerDesc).halfHeight=e._halfSize.x,n.halfSideExtent=e._halfSize.y,n.halfForwardExtent=e._halfSize.z;else if(i(e,C))(n=new this._physXPhysics._physX.PxCapsuleControllerDesc).radius=e._radius,n.height=2*e._halfHeight,n.climbingMode=1;else throw"unsupported shape type";n.setMaterial(e._pxMaterials[0]),this._pxController=t._getControllerManager().createController(n),this._pxController.setUUID(e._id)},n._destroyPXController=function(){this._pxController&&(this._pxController.release(),this._pxController=null)},n._setLocalPosition=function(t,i){e.Vector3.multiply(t,i,this._scaledOffset),this.setWorldPosition(t)},t}();A._tempVec=new e.Vector3;var M=function(){function t(t){this._physXPhysics=t}var e=t.prototype;return e.addShape=function(t){this._pxActor.attachShape(t._pxShape)},e.removeShape=function(t){this._pxActor.detachShape(t._pxShape,!0)},e.setWorldTransform=function(t,e){this._pxActor.setGlobalPose(this._transform(t,e),!0)},e.getWorldTransform=function(t,e){var i=this._pxActor.getGlobalPose();t.set(i.translation.x,i.translation.y,i.translation.z),e.set(i.rotation.x,i.rotation.y,i.rotation.z,i.rotation.w)},e.destroy=function(){this._pxActor.release()},e._transform=function(e,i){var n=t._tempTransform;return n.translation=e,n.rotation=i.normalize(),n},t}();M._tempTransform={translation:null,rotation:null},(a=x||(x={}))[a.Discrete=0]="Discrete",a[a.Continuous=1]="Continuous",a[a.ContinuousDynamic=2]="ContinuousDynamic",a[a.ContinuousSpeculative=3]="ContinuousSpeculative";var w=function(t){function n(e,i,n){var s,o=(s=t.call(this,e)||this)._transform(i,n);return s._pxActor=e._pxPhysics.createRigidDynamic(o),s}s(n,t);var o=n.prototype;return o.setLinearDamping=function(t){this._pxActor.setLinearDamping(t)},o.setAngularDamping=function(t){this._pxActor.setAngularDamping(t)},o.setLinearVelocity=function(t){this._pxActor.setLinearVelocity(t,!0)},o.setAngularVelocity=function(t){this._pxActor.setAngularVelocity(t,!0)},o.setMass=function(t){this._pxActor.setMass(t)},o.setCenterOfMass=function(t){this._pxActor.setCMassLocalPose(t)},o.setInertiaTensor=function(t){this._pxActor.setMassSpaceInertiaTensor(t)},o.setMaxAngularVelocity=function(t){this._pxActor.setMaxAngularVelocity(t)},o.setMaxDepenetrationVelocity=function(t){this._pxActor.setMaxDepenetrationVelocity(t)},o.setSleepThreshold=function(t){this._pxActor.setSleepThreshold(t)},o.setSolverIterations=function(t){this._pxActor.setSolverIterationCounts(t,1)},o.setCollisionDetectionMode=function(t){switch(t){case 1:this._pxActor.setRigidBodyFlag(this._physXPhysics._physX.PxRigidBodyFlag.eENABLE_CCD,!0);break;case 2:this._pxActor.setRigidBodyFlag(this._physXPhysics._physX.PxRigidBodyFlag.eENABLE_CCD_FRICTION,!0);break;case 3:this._pxActor.setRigidBodyFlag(this._physXPhysics._physX.PxRigidBodyFlag.eENABLE_SPECULATIVE_CCD,!0);break;case 0:var e=this._physXPhysics._physX;this._pxActor.setRigidBodyFlag(e.PxRigidBodyFlag.eENABLE_CCD,!1),this._pxActor.setRigidBodyFlag(e.PxRigidBodyFlag.eENABLE_CCD_FRICTION,!1),this._pxActor.setRigidBodyFlag(e.PxRigidBodyFlag.eENABLE_SPECULATIVE_CCD,!1)}},o.setIsKinematic=function(t){t?this._pxActor.setRigidBodyFlag(this._physXPhysics._physX.PxRigidBodyFlag.eKINEMATIC,!0):this._pxActor.setRigidBodyFlag(this._physXPhysics._physX.PxRigidBodyFlag.eKINEMATIC,!1)},o.setConstraints=function(t){this._pxActor.setRigidDynamicLockFlags(t)},o.addForce=function(t){this._pxActor.addForce({x:t.x,y:t.y,z:t.z})},o.addTorque=function(t){this._pxActor.addTorque({x:t.x,y:t.y,z:t.z})},o.move=function(t,s){if(s){this._pxActor.setKinematicTarget(t,s);return}var o=n._tempTranslation,r=n._tempRotation;this.getWorldTransform(o,r),i(t,e.Vector3)?this._pxActor.setKinematicTarget(t,r):this._pxActor.setKinematicTarget(o,t)},o.sleep=function(){return this._pxActor.putToSleep()},o.wakeUp=function(){return this._pxActor.wakeUp()},n}(M);w._tempTranslation=new e.Vector3,w._tempRotation=new e.Quaternion;var F=function(){this._eventMap={}},b=function(){function t(t,e,i,n,s,o){this._physXPhysics=t;var r=t._pxPhysics.createMaterial(e,i,n);r.setFrictionCombineMode(s),r.setRestitutionCombineMode(o),this._pxMaterial=r}var e=t.prototype;return e.setBounciness=function(t){this._pxMaterial.setRestitution(t)},e.setDynamicFriction=function(t){this._pxMaterial.setDynamicFriction(t)},e.setStaticFriction=function(t){this._pxMaterial.setStaticFriction(t)},e.setBounceCombine=function(t){this._pxMaterial.setRestitutionCombineMode(t)},e.setFrictionCombine=function(t){this._pxMaterial.setFrictionCombineMode(t)},e.destroy=function(){this._pxMaterial.release()},t}();(l=y||(y={}))[l.Average=0]="Average",l[l.Minimum=1]="Minimum",l[l.Multiply=2]="Multiply",l[l.Maximum=3]="Maximum";var R=function(){function t(t,e,i,n,s,o,r,a){var l=this;this._pxControllerManager=null,this._currentEvents=new S,this._eventPool=[],this._physXPhysics=t,this._physXManager=e;var h=t._physX;this._pxRaycastHit=new h.PxRaycastHit,this._pxFilterData=new h.PxQueryFilterData,this._pxFilterData.flags=new h.PxQueryFlags(7),this._onContactEnter=i,this._onContactExit=n,this._onContactStay=s,this._onTriggerEnter=o,this._onTriggerExit=r,this._onTriggerStay=a;var c=t._pxPhysics,_=h.PxSimulationEventCallback.implement({onContactBegin:function(t,e){l._onContactEnter(t,e)},onContactEnd:function(t,e){l._onContactExit(t,e)},onContactPersist:function(t,e){l._onContactStay(t,e)},onTriggerBegin:function(t,e){var i=t<e?l._getTrigger(t,e):l._getTrigger(e,t);i.state=0,l._currentEvents.add(i)},onTriggerEnd:function(t,e){var i;if(t<e){var n=l._physXManager._eventMap[t];i=n[e],n[e]=void 0}else{var s=l._physXManager._eventMap[e];i=s[t],s[t]=void 0}i.state=2}}),u=h.getDefaultSceneDesc(c.getTolerancesScale(),0,_);this._pxScene=c.createScene(u)}var e=t.prototype;return e.setGravity=function(t){this._pxScene.setGravity(t)},e.addColliderShape=function(t){this._physXManager._eventMap[t._id]={}},e.removeColliderShape=function(t){for(var e=this._eventPool,i=this._currentEvents,n=t._id,s=i.length-1;s>=0;s--){var o=i.get(s);(o.index1==n||o.index2==n)&&(i.deleteByIndex(s),e.push(o))}delete this._physXManager._eventMap[n]},e.addCollider=function(t){this._pxScene.addActor(t._pxActor,null)},e.removeCollider=function(t){this._pxScene.removeActor(t._pxActor,!0)},e.addCharacterController=function(t){if(!t._pxController){var e=t._shape;if(e){var i=t._pxManager;i!==this&&(i&&t._destroyPXController(),t._createPXController(this,e))}}t._pxManager=this},e.removeCharacterController=function(t){t._pxManager=null},e.update=function(t){this._simulate(t),this._fetchResults(),this._fireEvent()},e.raycast=function(e,i,n,s){var o=this._pxRaycastHit;i=Math.min(i,34e37);var r=this._pxScene.raycastSingle(e.origin,e.direction,i,o,this._pxFilterData,this._physXPhysics._physX.PxQueryFilterCallback.implement({preFilter:function(t,e,i){return n(e)?2:0},postFilter:function(t,e){}}));if(r&&void 0!=s){var a=t._tempPosition,l=t._tempNormal,h=o.position,c=o.normal;a.set(h.x,h.y,h.z),l.set(c.x,c.y,c.z),s(o.getShape().getUUID(),o.distance,a,l)}return r},e._getControllerManager=function(){var t=this._pxControllerManager;return null===t&&(this._pxControllerManager=t=this._pxScene.createControllerManager()),t},e._simulate=function(t){this._pxScene.simulate(t,!0)},e._fetchResults=function(t){void 0===t&&(t=!0),this._pxScene.fetchResults(t)},e._getTrigger=function(t,e){var i;return this._eventPool.length?((i=this._eventPool.pop()).index1=t,i.index2=e):i=new X(t,e),this._physXManager._eventMap[t][e]=i,i},e._fireEvent=function(){for(var t=this._eventPool,e=this._currentEvents,i=e.length-1;i>=0;i--){var n=e.get(i);0==n.state?(this._onTriggerEnter(n.index1,n.index2),n.state=1):1==n.state?this._onTriggerStay(n.index1,n.index2):2==n.state&&(this._onTriggerExit(n.index1,n.index2),e.deleteByIndex(i),t.push(n))}},t}();R._tempPosition=new e.Vector3,R._tempNormal=new e.Vector3,(h=d||(d={}))[h.STATIC=1]="STATIC",h[h.DYNAMIC=2]="DYNAMIC",h[h.PRE_FILTER=4]="PRE_FILTER",h[h.POST_FILTER=8]="POST_FILTER",h[h.ANY_HIT=16]="ANY_HIT",h[h.NO_BLOCK=32]="NO_BLOCK",(c=g||(g={}))[c.Enter=0]="Enter",c[c.Stay=1]="Stay",c[c.Exit=2]="Exit";var X=function(t,e){this.index1=t,this.index2=e},E=function(t){function e(e,i,n){var s;return(s=t.call(this,e)||this)._pxActor=e._pxPhysics.createRigidStatic(s._transform(i,n)),s}return s(e,t),e}(M);t.PhysXRuntimeMode=void 0,(_=t.PhysXRuntimeMode||(t.PhysXRuntimeMode={}))[_.Auto=0]="Auto",_[_.WebAssembly=1]="WebAssembly",_[_.JavaScript=2]="JavaScript";var T=function(){function t(t){this._connectedAnchor=new e.Vector3,this._breakForce=Number.MAX_VALUE,this._breakTorque=Number.MAX_VALUE,this._physXPhysics=t}var i=t.prototype;return i.setConnectedCollider=function(t){var e;this._pxJoint.setActors((null==t?void 0:t._pxActor)||null,(null==(e=this._collider)?void 0:e._pxActor)||null)},i.setConnectedAnchor=function(e){this._connectedAnchor.copyFrom(e),this._setLocalPose(0,e,t._defaultQuat)},i.setConnectedMassScale=function(t){this._pxJoint.setInvMassScale0(1/t)},i.setConnectedInertiaScale=function(t){this._pxJoint.setInvInertiaScale0(1/t)},i.setMassScale=function(t){this._pxJoint.setInvMassScale1(1/t)},i.setInertiaScale=function(t){this._pxJoint.setInvInertiaScale1(1/t)},i.setBreakForce=function(t){this._breakForce=t,this._pxJoint.setBreakForce(this._breakForce,this._breakTorque)},i.setBreakTorque=function(t){this._breakTorque=t,this._pxJoint.setBreakForce(this._breakForce,this._breakTorque)},i._setLocalPose=function(t,e,i){this._pxJoint.setLocalPose(t,e,i)},t}();T._xAxis=new e.Vector3(1,0,0),T._defaultVec=new e.Vector3,T._defaultQuat=new e.Quaternion;var I=function(t){function e(e,i){var n;return(n=t.call(this,e)||this)._collider=i,n._pxJoint=e._pxPhysics.createFixedJoint(null,T._defaultVec,T._defaultQuat,i._pxActor,T._defaultVec,T._defaultQuat),n}return s(e,t),e}(T),z=function(t){function i(i,n){var s;return(s=t.call(this,i)||this)._axisRotationQuaternion=new e.Quaternion,s._swingOffset=new e.Vector3,s._velocity=new e.Vector3,s._collider=n,s._pxJoint=i._pxPhysics.createRevoluteJoint(null,T._defaultVec,T._defaultQuat,n._pxActor,T._defaultVec,T._defaultQuat),s}s(i,t);var n=i.prototype;return n.setAxis=function(t){var i=T._xAxis,n=this._axisRotationQuaternion;i.set(1,0,0),t.normalize();var s=Math.acos(e.Vector3.dot(i,t));e.Vector3.cross(i,t,i),e.Quaternion.rotationAxisAngle(i,s,n),this._setLocalPose(0,this._swingOffset,n)},n.setSwingOffset=function(t){this._swingOffset.copyFrom(t),this._setLocalPose(1,this._swingOffset,this._axisRotationQuaternion)},n.getAngle=function(){return this._pxJoint.getAngle()},n.getVelocity=function(){var t=this._velocity;return t.copyFrom(this._pxJoint.getVelocity()),t},n.setHardLimit=function(t,e,i){this._pxJoint.setHardLimit(t,e,i)},n.setSoftLimit=function(t,e,i,n){this._pxJoint.setSoftLimit(t,e,i,n)},n.setDriveVelocity=function(t){this._pxJoint.setDriveVelocity(t)},n.setDriveForceLimit=function(t){this._pxJoint.setDriveForceLimit(t)},n.setDriveGearRatio=function(t){this._pxJoint.setDriveGearRatio(t)},n.setHingeJointFlag=function(t,e){this._pxJoint.setRevoluteJointFlag(t,e)},i}(T),D=function(t){function i(i,n){var s;return(s=t.call(this,i)||this)._swingOffset=new e.Vector3,s._collider=n,s._pxJoint=i._pxPhysics.createDistanceJoint(null,T._defaultVec,T._defaultQuat,n._pxActor,T._defaultVec,T._defaultQuat),s._pxJoint.setDistanceJointFlag(2,!0),s._pxJoint.setDistanceJointFlag(4,!0),s._pxJoint.setDistanceJointFlag(8,!0),s}s(i,t);var n=i.prototype;return n.setSwingOffset=function(t){this._swingOffset.copyFrom(t),this._setLocalPose(1,t,T._defaultQuat)},n.setMinDistance=function(t){this._pxJoint.setMinDistance(t)},n.setMaxDistance=function(t){this._pxJoint.setMaxDistance(t)},n.setTolerance=function(t){this._pxJoint.setTolerance(t)},n.setStiffness=function(t){this._pxJoint.setStiffness(t)},n.setDamping=function(t){this._pxJoint.setDamping(t)},i}(T),L=function(t){function i(i,n,s){var o;return(o=t.call(this,i)||this)._axis=new e.Quaternion(0,0,v.halfSqrt,v.halfSqrt),o._physXRotation.copyFrom(o._axis),o._pxGeometry=new i._physX.PxPlaneGeometry,o._initialize(s,n),o._setLocalPose(),o}return s(i,t),i}(v),V=function(t){function e(e,i,n,s){var o;return(o=t.call(this,e)||this)._maxScale=1,o._radius=n,o._pxGeometry=new e._physX.PxSphereGeometry(o._radius*o._maxScale),o._initialize(s,i),o._setLocalPose(),o}s(e,t);var i=e.prototype;return i.setRadius=function(t){this._radius=t,this._pxGeometry.radius=t*this._maxScale,this._pxShape.setGeometry(this._pxGeometry)},i.setWorldScale=function(e){t.prototype.setWorldScale.call(this,e),this._maxScale=Math.max(e.x,e.y,e.z),this._pxGeometry.radius=this._radius*this._maxScale,this._pxShape.setGeometry(this._pxGeometry)},e}(v),G=function(){function n(e){void 0===e&&(e=t.PhysXRuntimeMode.Auto),this._initializeState=0,this._runTimeMode=e}var s=n.prototype;return s.initialize=function(){var n=this;if(2===this._initializeState)return Promise.resolve();if(1===this._initializeState)return this._initializePromise;var s=this._runTimeMode,o=new Promise(function(n,o){var r=document.createElement("script");document.body.appendChild(r),r.async=!0,r.onload=n,r.onerror=o,s==t.PhysXRuntimeMode.Auto&&(s=!function(){try{if("object"==typeof WebAssembly&&"function"==typeof WebAssembly.instantiate){var t=new WebAssembly.Module(Uint8Array.of(0,97,115,109,1,0,0,0));if(i(t,WebAssembly.Module))return i(new WebAssembly.Instance(t),WebAssembly.Instance)}}catch(t){}return!1}()?t.PhysXRuntimeMode.JavaScript:t.PhysXRuntimeMode.WebAssembly),s==t.PhysXRuntimeMode.JavaScript?r.src="https://gw.alipayobjects.com/os/lib/galacean/engine-physics-physx/"+e.version+"/libs/physx.release.js.js":s==t.PhysXRuntimeMode.WebAssembly&&(r.src="https://gw.alipayobjects.com/os/lib/galacean/engine-physics-physx/"+e.version+"/libs/physx.release.js")}),r=new Promise(function(t,e){o.then(function(){return window.PHYSX().then(function(e){n._init(e),n._initializeState=2,n._initializePromise=null,console.log("PhysX loaded."),t()},e)},e).catch(e)});return this._initializePromise=r,r},s.destroy=function(){this._physX.PxCloseExtensions(),this._pxPhysics.release(),this._pxFoundation.release(),this._physX=null,this._pxFoundation=null,this._pxPhysics=null},s.createPhysicsManager=function(){return new F},s.createPhysicsScene=function(t,e,i,n,s,o,r){return new R(this,t,e,i,n,s,o,r)},s.createStaticCollider=function(t,e){return new E(this,t,e)},s.createDynamicCollider=function(t,e){return new w(this,t,e)},s.createCharacterController=function(){return new A(this)},s.createPhysicsMaterial=function(t,e,i,n,s){return new b(this,t,e,i,n,s)},s.createBoxColliderShape=function(t,e,i){return new P(this,t,e,i)},s.createSphereColliderShape=function(t,e,i){return new V(this,t,e,i)},s.createPlaneColliderShape=function(t,e){return new L(this,t,e)},s.createCapsuleColliderShape=function(t,e,i,n){return new C(this,t,e,i,n)},s.createFixedJoint=function(t){return new I(this,t)},s.createHingeJoint=function(t){return new z(this,t)},s.createSpringJoint=function(t){return new D(this,t)},s._init=function(t){var e=t.PX_PHYSICS_VERSION,i=new t.PxDefaultErrorCallback,n=new t.PxDefaultAllocator,s=t.PxCreateFoundation(e,n,i),o=t.PxCreatePhysics(e,s,new t.PxTolerancesScale,!1,null);t.PxInitExtensions(o,null),this._physX=t,this._pxFoundation=s,this._pxPhysics=o},n}();(u=m||(m={}))[u.Uninitialized=0]="Uninitialized",u[u.Initializing=1]="Initializing",u[u.Initialized=2]="Initialized",t.PhysXPhysics=G,Object.defineProperty(t,"__esModule",{value:!0})});
package/dist/main.js CHANGED
@@ -87,7 +87,7 @@ var ShapeFlag;
87
87
  */ var PhysXColliderShape = /*#__PURE__*/ function() {
88
88
  function PhysXColliderShape(physXPhysics) {
89
89
  /** @internal */ this._controllers = new DisorderedArray();
90
- this._scale = new engine.Vector3(1, 1, 1);
90
+ this._worldScale = new engine.Vector3(1, 1, 1);
91
91
  this._position = new engine.Vector3();
92
92
  this._rotation = null;
93
93
  this._axis = null;
@@ -114,18 +114,18 @@ var ShapeFlag;
114
114
  }
115
115
  var controllers = this._controllers;
116
116
  for(var i = 0, n = controllers.length; i < n; i++){
117
- controllers.get(i)._setLocalPosition(this._position, this._scale);
117
+ controllers.get(i)._setLocalPosition(this._position, this._worldScale);
118
118
  }
119
119
  this._setLocalPose();
120
120
  };
121
121
  /**
122
122
  * {@inheritDoc IColliderShape.setWorldScale }
123
123
  */ _proto.setWorldScale = function setWorldScale(scale) {
124
- this._scale.copyFrom(scale);
124
+ this._worldScale.copyFrom(scale);
125
125
  this._setLocalPose();
126
126
  var controllers = this._controllers;
127
127
  for(var i = 0, n = controllers.length; i < n; i++){
128
- controllers.get(i)._setLocalPosition(this._position, this._scale);
128
+ controllers.get(i)._setLocalPosition(this._position, this._worldScale);
129
129
  }
130
130
  };
131
131
  /**
@@ -164,7 +164,7 @@ var ShapeFlag;
164
164
  };
165
165
  _proto._setLocalPose = function _setLocalPose() {
166
166
  var transform = PhysXColliderShape.transform;
167
- engine.Vector3.multiply(this._position, this._scale, transform.translation);
167
+ engine.Vector3.multiply(this._position, this._worldScale, transform.translation);
168
168
  transform.rotation = this._physXRotation;
169
169
  this._pxShape.setLocalPose(transform);
170
170
  };
@@ -191,14 +191,14 @@ var ShapeFlag;
191
191
 
192
192
  /**
193
193
  * Box collider shape in PhysX.
194
- */ var PhysXBoxColliderShape = /*#__PURE__*/ function(PhysXColliderShape) {
195
- _inherits(PhysXBoxColliderShape, PhysXColliderShape);
194
+ */ var PhysXBoxColliderShape = /*#__PURE__*/ function(PhysXColliderShape1) {
195
+ _inherits(PhysXBoxColliderShape, PhysXColliderShape1);
196
196
  function PhysXBoxColliderShape(physXPhysics, uniqueID, size, material) {
197
197
  var _this;
198
- _this = PhysXColliderShape.call(this, physXPhysics) || this;
198
+ _this = PhysXColliderShape1.call(this, physXPhysics) || this;
199
199
  /** @internal */ _this._halfSize = new engine.Vector3();
200
200
  _this._halfSize.set(size.x * 0.5, size.y * 0.5, size.z * 0.5);
201
- _this._pxGeometry = new physXPhysics._physX.PxBoxGeometry(_this._halfSize.x * _this._scale.x, _this._halfSize.y * _this._scale.y, _this._halfSize.z * _this._scale.z);
201
+ _this._pxGeometry = new physXPhysics._physX.PxBoxGeometry(_this._halfSize.x * _this._worldScale.x, _this._halfSize.y * _this._worldScale.y, _this._halfSize.z * _this._worldScale.z);
202
202
  _this._initialize(material, uniqueID);
203
203
  _this._setLocalPose();
204
204
  return _this;
@@ -209,7 +209,7 @@ var ShapeFlag;
209
209
  */ _proto.setSize = function setSize(value) {
210
210
  var tempExtents = PhysXBoxColliderShape._tempHalfExtents;
211
211
  this._halfSize.set(value.x * 0.5, value.y * 0.5, value.z * 0.5);
212
- engine.Vector3.multiply(this._halfSize, this._scale, tempExtents);
212
+ engine.Vector3.multiply(this._halfSize, this._worldScale, tempExtents);
213
213
  this._pxGeometry.halfExtents = tempExtents;
214
214
  this._pxShape.setGeometry(this._pxGeometry);
215
215
  this._updateController(tempExtents);
@@ -217,9 +217,9 @@ var ShapeFlag;
217
217
  /**
218
218
  * {@inheritDoc IColliderShape.setWorldScale }
219
219
  */ _proto.setWorldScale = function setWorldScale(scale) {
220
- PhysXColliderShape.prototype.setWorldScale.call(this, scale);
220
+ PhysXColliderShape1.prototype.setWorldScale.call(this, scale);
221
221
  var tempExtents = PhysXBoxColliderShape._tempHalfExtents;
222
- engine.Vector3.multiply(this._halfSize, this._scale, tempExtents);
222
+ engine.Vector3.multiply(this._halfSize, this._worldScale, tempExtents);
223
223
  this._pxGeometry.halfExtents = tempExtents;
224
224
  this._pxShape.setGeometry(this._pxGeometry);
225
225
  this._updateController(tempExtents);
@@ -263,13 +263,13 @@ var ShapeFlag;
263
263
  this._radius = value;
264
264
  switch(this._upAxis){
265
265
  case /** Up axis is X. */ 0:
266
- this._pxGeometry.radius = this._radius * Math.max(this._scale.y, this._scale.z);
266
+ this._pxGeometry.radius = this._radius * Math.max(this._worldScale.y, this._worldScale.z);
267
267
  break;
268
268
  case 1:
269
- this._pxGeometry.radius = this._radius * Math.max(this._scale.x, this._scale.z);
269
+ this._pxGeometry.radius = this._radius * Math.max(this._worldScale.x, this._worldScale.z);
270
270
  break;
271
271
  case /** Up axis is Z. */ 2:
272
- this._pxGeometry.radius = this._radius * Math.max(this._scale.x, this._scale.y);
272
+ this._pxGeometry.radius = this._radius * Math.max(this._worldScale.x, this._worldScale.y);
273
273
  break;
274
274
  }
275
275
  this._pxShape.setGeometry(this._pxGeometry);
@@ -285,13 +285,13 @@ var ShapeFlag;
285
285
  this._halfHeight = value * 0.5;
286
286
  switch(this._upAxis){
287
287
  case 0:
288
- this._pxGeometry.halfHeight = this._halfHeight * this._scale.x;
288
+ this._pxGeometry.halfHeight = this._halfHeight * this._worldScale.x;
289
289
  break;
290
290
  case 1:
291
- this._pxGeometry.halfHeight = this._halfHeight * this._scale.y;
291
+ this._pxGeometry.halfHeight = this._halfHeight * this._worldScale.y;
292
292
  break;
293
293
  case 2:
294
- this._pxGeometry.halfHeight = this._halfHeight * this._scale.z;
294
+ this._pxGeometry.halfHeight = this._halfHeight * this._worldScale.z;
295
295
  break;
296
296
  }
297
297
  this._pxShape.setGeometry(this._pxGeometry);
@@ -534,11 +534,11 @@ var CollisionDetectionMode;
534
534
  })(CollisionDetectionMode || (CollisionDetectionMode = {}));
535
535
  /**
536
536
  * A dynamic collider can act with self-defined movement or physical force
537
- */ var PhysXDynamicCollider = /*#__PURE__*/ function(PhysXCollider) {
538
- _inherits(PhysXDynamicCollider, PhysXCollider);
537
+ */ var PhysXDynamicCollider = /*#__PURE__*/ function(PhysXCollider1) {
538
+ _inherits(PhysXDynamicCollider, PhysXCollider1);
539
539
  function PhysXDynamicCollider(physXPhysics, position, rotation) {
540
540
  var _this;
541
- _this = PhysXCollider.call(this, physXPhysics) || this;
541
+ _this = PhysXCollider1.call(this, physXPhysics) || this;
542
542
  var transform = _this._transform(position, rotation);
543
543
  _this._pxActor = physXPhysics._pxPhysics.createRigidDynamic(transform);
544
544
  return _this;
@@ -968,11 +968,11 @@ var /**
968
968
  /**
969
969
  * A static collider component that will not move.
970
970
  * @remarks Mostly used for object which always stays at the same place and never moves around.
971
- */ var PhysXStaticCollider = /*#__PURE__*/ function(PhysXCollider) {
972
- _inherits(PhysXStaticCollider, PhysXCollider);
971
+ */ var PhysXStaticCollider = /*#__PURE__*/ function(PhysXCollider1) {
972
+ _inherits(PhysXStaticCollider, PhysXCollider1);
973
973
  function PhysXStaticCollider(physXPhysics, position, rotation) {
974
974
  var _this;
975
- _this = PhysXCollider.call(this, physXPhysics) || this;
975
+ _this = PhysXCollider1.call(this, physXPhysics) || this;
976
976
  _this._pxActor = physXPhysics._pxPhysics.createRigidStatic(_this._transform(position, rotation));
977
977
  return _this;
978
978
  }
@@ -1001,8 +1001,8 @@ var /**
1001
1001
  /**
1002
1002
  * {@inheritDoc IJoint.setConnectedCollider }
1003
1003
  */ _proto.setConnectedCollider = function setConnectedCollider(value) {
1004
- var _this__collider;
1005
- this._pxJoint.setActors((value == null ? void 0 : value._pxActor) || null, ((_this__collider = this._collider) == null ? void 0 : _this__collider._pxActor) || null);
1004
+ var _value, _this__collider;
1005
+ this._pxJoint.setActors(((_value = value) == null ? void 0 : _value._pxActor) || null, ((_this__collider = this._collider) == null ? void 0 : _this__collider._pxActor) || null);
1006
1006
  };
1007
1007
  /**
1008
1008
  * {@inheritDoc IJoint.setConnectedAnchor }
@@ -1223,11 +1223,11 @@ var /**
1223
1223
 
1224
1224
  /**
1225
1225
  * Sphere collider shape in PhysX.
1226
- */ var PhysXSphereColliderShape = /*#__PURE__*/ function(PhysXColliderShape) {
1227
- _inherits(PhysXSphereColliderShape, PhysXColliderShape);
1226
+ */ var PhysXSphereColliderShape = /*#__PURE__*/ function(PhysXColliderShape1) {
1227
+ _inherits(PhysXSphereColliderShape, PhysXColliderShape1);
1228
1228
  function PhysXSphereColliderShape(physXPhysics, uniqueID, radius, material) {
1229
1229
  var _this;
1230
- _this = PhysXColliderShape.call(this, physXPhysics) || this;
1230
+ _this = PhysXColliderShape1.call(this, physXPhysics) || this;
1231
1231
  _this._maxScale = 1;
1232
1232
  _this._radius = radius;
1233
1233
  _this._pxGeometry = new physXPhysics._physX.PxSphereGeometry(_this._radius * _this._maxScale);
@@ -1246,7 +1246,7 @@ var /**
1246
1246
  /**
1247
1247
  * {@inheritDoc IColliderShape.setWorldScale }
1248
1248
  */ _proto.setWorldScale = function setWorldScale(scale) {
1249
- PhysXColliderShape.prototype.setWorldScale.call(this, scale);
1249
+ PhysXColliderShape1.prototype.setWorldScale.call(this, scale);
1250
1250
  this._maxScale = Math.max(scale.x, scale.y, scale.z);
1251
1251
  this._pxGeometry.radius = this._radius * this._maxScale;
1252
1252
  this._pxShape.setGeometry(this._pxGeometry);