@galacean/engine-physics-lite 0.0.0-experimental-ktx2.0 → 0.0.0-experimental-double11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/browser.js CHANGED
@@ -653,42 +653,6 @@
653
653
  return LiteDynamicCollider;
654
654
  }(LiteCollider);
655
655
 
656
- /**
657
- * Physics material describes how to handle colliding objects (friction, bounciness).
658
- */ var LitePhysicsMaterial = /*#__PURE__*/ function() {
659
- function LitePhysicsMaterial(staticFriction, dynamicFriction, bounciness, frictionCombine, bounceCombine) {}
660
- var _proto = LitePhysicsMaterial.prototype;
661
- /**
662
- * {@inheritDoc IPhysicsMaterial.setBounciness }
663
- */ _proto.setBounciness = function setBounciness(value) {
664
- throw "Physics-lite don't support physics material. Use Physics-PhysX instead!";
665
- };
666
- /**
667
- * {@inheritDoc IPhysicsMaterial.setDynamicFriction }
668
- */ _proto.setDynamicFriction = function setDynamicFriction(value) {
669
- throw "Physics-lite don't support physics material. Use Physics-PhysX instead!";
670
- };
671
- /**
672
- * {@inheritDoc IPhysicsMaterial.setStaticFriction }
673
- */ _proto.setStaticFriction = function setStaticFriction(value) {
674
- throw "Physics-lite don't support physics material. Use Physics-PhysX instead!";
675
- };
676
- /**
677
- * {@inheritDoc IPhysicsMaterial.setBounceCombine }
678
- */ _proto.setBounceCombine = function setBounceCombine(value) {
679
- throw "Physics-lite don't support physics material. Use Physics-PhysX instead!";
680
- };
681
- /**
682
- * {@inheritDoc IPhysicsMaterial.setFrictionCombine }
683
- */ _proto.setFrictionCombine = function setFrictionCombine(value) {
684
- throw "Physics-lite don't support physics material. Use Physics-PhysX instead!";
685
- };
686
- /**
687
- * {@inheritDoc IPhysicsMaterial.destroy }
688
- */ _proto.destroy = function destroy() {};
689
- return LitePhysicsMaterial;
690
- }();
691
-
692
656
  /**
693
657
  * High-performance unordered array, delete uses exchange method to improve performance, internal capacity only increases.
694
658
  */ var DisorderedArray = /*#__PURE__*/ function() {
@@ -829,7 +793,7 @@
829
793
  /**
830
794
  * {@inheritDoc IColliderShape.setWorldScale }
831
795
  */ _proto.setWorldScale = function setWorldScale(scale) {
832
- this._maxScale = Math.max(scale.x, Math.max(scale.x, scale.y));
796
+ this._maxScale = Math.max(scale.x, scale.y, scale.z);
833
797
  };
834
798
  /**
835
799
  * @internal
@@ -861,8 +825,8 @@
861
825
 
862
826
  /**
863
827
  * A manager is a collection of colliders and constraints which can interact.
864
- */ var LitePhysicsScene = /*#__PURE__*/ function() {
865
- function LitePhysicsScene(onContactEnter, onContactExit, onContactStay, onTriggerEnter, onTriggerExit, onTriggerStay) {
828
+ */ var LitePhysicsManager = /*#__PURE__*/ function() {
829
+ function LitePhysicsManager(onContactEnter, onContactExit, onContactStay, onTriggerEnter, onTriggerExit, onTriggerStay) {
866
830
  this._colliders = [];
867
831
  this._sphere = new engine.BoundingSphere();
868
832
  this._box = new engine.BoundingBox();
@@ -876,7 +840,7 @@
876
840
  this._onTriggerExit = onTriggerExit;
877
841
  this._onTriggerStay = onTriggerStay;
878
842
  }
879
- var _proto = LitePhysicsScene.prototype;
843
+ var _proto = LitePhysicsManager.prototype;
880
844
  /**
881
845
  * {@inheritDoc IPhysicsManager.setGravity }
882
846
  */ _proto.setGravity = function setGravity(value) {
@@ -929,25 +893,23 @@
929
893
  var colliders = this._colliders;
930
894
  var hitResult;
931
895
  if (hit) {
932
- hitResult = LitePhysicsScene._hitResult;
896
+ hitResult = LitePhysicsManager._hitResult;
933
897
  }
934
898
  var isHit = false;
935
- var curHit = LitePhysicsScene._currentHit;
899
+ var curHit = LitePhysicsManager._currentHit;
936
900
  for(var i = 0, len = colliders.length; i < len; i++){
937
901
  var collider = colliders[i];
938
- if (collider._raycast(ray, onRaycast, curHit)) {
902
+ if (collider._raycast(ray, onRaycast, curHit) && curHit.distance < distance) {
939
903
  isHit = true;
940
- if (curHit.distance < distance) {
941
- if (hitResult) {
942
- hitResult.normal.copyFrom(curHit.normal);
943
- hitResult.point.copyFrom(curHit.point);
944
- hitResult.distance = curHit.distance;
945
- hitResult.shapeID = curHit.shapeID;
946
- } else {
947
- return true;
948
- }
949
- distance = curHit.distance;
904
+ if (hitResult) {
905
+ hitResult.normal.copyFrom(curHit.normal);
906
+ hitResult.point.copyFrom(curHit.point);
907
+ hitResult.distance = curHit.distance;
908
+ hitResult.shapeID = curHit.shapeID;
909
+ } else {
910
+ return true;
950
911
  }
912
+ distance = curHit.distance;
951
913
  }
952
914
  }
953
915
  if (!isHit && hitResult) {
@@ -988,7 +950,7 @@
988
950
  for(var i = 0, len = myColliderShapes.length; i < len; i++){
989
951
  var myShape = myColliderShapes[i];
990
952
  if (_instanceof(myShape, LiteBoxColliderShape)) {
991
- LitePhysicsScene._updateWorldBox(myShape, this._box);
953
+ LitePhysicsManager._updateWorldBox(myShape, this._box);
992
954
  for(var j = 0, len1 = colliders.length; j < len1; j++){
993
955
  var colliderShape = colliders[j]._shapes;
994
956
  for(var k = 0, len2 = colliderShape.length; k < len2; k++){
@@ -1015,7 +977,7 @@
1015
977
  }
1016
978
  }
1017
979
  } else if (_instanceof(myShape, LiteSphereColliderShape)) {
1018
- LitePhysicsScene._upWorldSphere(myShape, this._sphere);
980
+ LitePhysicsManager._upWorldSphere(myShape, this._sphere);
1019
981
  for(var j1 = 0, len3 = colliders.length; j1 < len3; j1++){
1020
982
  var colliderShape1 = colliders[j1]._shapes;
1021
983
  for(var k1 = 0, len4 = colliderShape1.length; k1 < len4; k1++){
@@ -1067,24 +1029,24 @@
1067
1029
  };
1068
1030
  _proto._boxCollision = function _boxCollision(other) {
1069
1031
  if (_instanceof(other, LiteBoxColliderShape)) {
1070
- var box = LitePhysicsScene._tempBox;
1071
- LitePhysicsScene._updateWorldBox(other, box);
1032
+ var box = LitePhysicsManager._tempBox;
1033
+ LitePhysicsManager._updateWorldBox(other, box);
1072
1034
  return engine.CollisionUtil.intersectsBoxAndBox(box, this._box);
1073
1035
  } else if (_instanceof(other, LiteSphereColliderShape)) {
1074
- var sphere = LitePhysicsScene._tempSphere;
1075
- LitePhysicsScene._upWorldSphere(other, sphere);
1036
+ var sphere = LitePhysicsManager._tempSphere;
1037
+ LitePhysicsManager._upWorldSphere(other, sphere);
1076
1038
  return engine.CollisionUtil.intersectsSphereAndBox(sphere, this._box);
1077
1039
  }
1078
1040
  return false;
1079
1041
  };
1080
1042
  _proto._sphereCollision = function _sphereCollision(other) {
1081
1043
  if (_instanceof(other, LiteBoxColliderShape)) {
1082
- var box = LitePhysicsScene._tempBox;
1083
- LitePhysicsScene._updateWorldBox(other, box);
1044
+ var box = LitePhysicsManager._tempBox;
1045
+ LitePhysicsManager._updateWorldBox(other, box);
1084
1046
  return engine.CollisionUtil.intersectsSphereAndBox(this._sphere, box);
1085
1047
  } else if (_instanceof(other, LiteSphereColliderShape)) {
1086
- var sphere = LitePhysicsScene._tempSphere;
1087
- LitePhysicsScene._upWorldSphere(other, sphere);
1048
+ var sphere = LitePhysicsManager._tempSphere;
1049
+ LitePhysicsManager._upWorldSphere(other, sphere);
1088
1050
  return engine.CollisionUtil.intersectsSphereAndSphere(sphere, this._sphere);
1089
1051
  }
1090
1052
  return false;
@@ -1093,7 +1055,7 @@
1093
1055
  * Calculate the bounding box in world space from boxCollider.
1094
1056
  * @param boxCollider - The boxCollider to calculate
1095
1057
  * @param out - The calculated boundingBox
1096
- */ LitePhysicsScene._updateWorldBox = function _updateWorldBox(boxCollider, out) {
1058
+ */ LitePhysicsManager._updateWorldBox = function _updateWorldBox(boxCollider, out) {
1097
1059
  var mat = boxCollider._transform.worldMatrix;
1098
1060
  out.min.copyFrom(boxCollider._boxMin);
1099
1061
  out.max.copyFrom(boxCollider._boxMax);
@@ -1103,23 +1065,23 @@
1103
1065
  * Get the sphere info of the given sphere collider in world space.
1104
1066
  * @param sphereCollider - The given sphere collider
1105
1067
  * @param out - The calculated boundingSphere
1106
- */ LitePhysicsScene._upWorldSphere = function _upWorldSphere(sphereCollider, out) {
1068
+ */ LitePhysicsManager._upWorldSphere = function _upWorldSphere(sphereCollider, out) {
1107
1069
  engine.Vector3.transformCoordinate(sphereCollider._transform.position, sphereCollider._transform.worldMatrix, out.center);
1108
1070
  out.radius = sphereCollider.worldRadius;
1109
1071
  };
1110
- return LitePhysicsScene;
1072
+ return LitePhysicsManager;
1111
1073
  }();
1112
1074
  (function() {
1113
- LitePhysicsScene._tempSphere = new engine.BoundingSphere();
1075
+ LitePhysicsManager._tempSphere = new engine.BoundingSphere();
1114
1076
  })();
1115
1077
  (function() {
1116
- LitePhysicsScene._tempBox = new engine.BoundingBox();
1078
+ LitePhysicsManager._tempBox = new engine.BoundingBox();
1117
1079
  })();
1118
1080
  (function() {
1119
- LitePhysicsScene._currentHit = new LiteHitResult();
1081
+ LitePhysicsManager._currentHit = new LiteHitResult();
1120
1082
  })();
1121
1083
  (function() {
1122
- LitePhysicsScene._hitResult = new LiteHitResult();
1084
+ LitePhysicsManager._hitResult = new LiteHitResult();
1123
1085
  })();
1124
1086
  var /**
1125
1087
  * Physics state
@@ -1137,6 +1099,42 @@
1137
1099
  this.index2 = index2;
1138
1100
  };
1139
1101
 
1102
+ /**
1103
+ * Physics material describes how to handle colliding objects (friction, bounciness).
1104
+ */ var LitePhysicsMaterial = /*#__PURE__*/ function() {
1105
+ function LitePhysicsMaterial(staticFriction, dynamicFriction, bounciness, frictionCombine, bounceCombine) {}
1106
+ var _proto = LitePhysicsMaterial.prototype;
1107
+ /**
1108
+ * {@inheritDoc IPhysicsMaterial.setBounciness }
1109
+ */ _proto.setBounciness = function setBounciness(value) {
1110
+ throw "Physics-lite don't support physics material. Use Physics-PhysX instead!";
1111
+ };
1112
+ /**
1113
+ * {@inheritDoc IPhysicsMaterial.setDynamicFriction }
1114
+ */ _proto.setDynamicFriction = function setDynamicFriction(value) {
1115
+ throw "Physics-lite don't support physics material. Use Physics-PhysX instead!";
1116
+ };
1117
+ /**
1118
+ * {@inheritDoc IPhysicsMaterial.setStaticFriction }
1119
+ */ _proto.setStaticFriction = function setStaticFriction(value) {
1120
+ throw "Physics-lite don't support physics material. Use Physics-PhysX instead!";
1121
+ };
1122
+ /**
1123
+ * {@inheritDoc IPhysicsMaterial.setBounceCombine }
1124
+ */ _proto.setBounceCombine = function setBounceCombine(value) {
1125
+ throw "Physics-lite don't support physics material. Use Physics-PhysX instead!";
1126
+ };
1127
+ /**
1128
+ * {@inheritDoc IPhysicsMaterial.setFrictionCombine }
1129
+ */ _proto.setFrictionCombine = function setFrictionCombine(value) {
1130
+ throw "Physics-lite don't support physics material. Use Physics-PhysX instead!";
1131
+ };
1132
+ /**
1133
+ * {@inheritDoc IPhysicsMaterial.destroy }
1134
+ */ _proto.destroy = function destroy() {};
1135
+ return LitePhysicsMaterial;
1136
+ }();
1137
+
1140
1138
  /**
1141
1139
  * A static collider component that will not move.
1142
1140
  * @remarks Mostly used for object which always stays at the same place and never moves around.
@@ -1162,13 +1160,8 @@
1162
1160
  };
1163
1161
  /**
1164
1162
  * {@inheritDoc IPhysics.createPhysicsManager }
1165
- */ _proto.createPhysicsManager = function createPhysicsManager() {
1166
- return null;
1167
- };
1168
- /**
1169
- * {@inheritDoc IPhysics.createPhysicsScene }
1170
- */ _proto.createPhysicsScene = function createPhysicsScene(physicsManager, onContactBegin, onContactEnd, onContactPersist, onTriggerBegin, onTriggerEnd, onTriggerPersist) {
1171
- return new LitePhysicsScene(onContactBegin, onContactEnd, onContactPersist, onTriggerBegin, onTriggerEnd, onTriggerPersist);
1163
+ */ _proto.createPhysicsManager = function createPhysicsManager(onContactBegin, onContactEnd, onContactPersist, onTriggerBegin, onTriggerEnd, onTriggerPersist) {
1164
+ return new LitePhysicsManager(onContactBegin, onContactEnd, onContactPersist, onTriggerBegin, onTriggerEnd, onTriggerPersist);
1172
1165
  };
1173
1166
  /**
1174
1167
  * {@inheritDoc IPhysics.createStaticCollider }
@@ -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.PhysicsLite={}),t.Galacean)}(this,function(t,e){"use strict";function i(t,e){return(i=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&&i(t,e)}function s(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function o(t,e,i){return e&&s(t.prototype,e),i&&s(t,i),t}function r(t,e){return null!=e&&"undefined"!=typeof Symbol&&e[Symbol.hasInstance]?!!e[Symbol.hasInstance](t):t instanceof e}var a,h,l,c,u=function(){function t(t){void 0===t&&(t=[]),this._flags=t,this.flag=!0,this._flags.push(this)}return t.prototype.destroy=function(){e.Utils.removeFromArray(this._flags,this),this._flags=null},t}(),d=function(){function t(){this._updateFlags=[]}var e=t.prototype;return e.register=function(){return new u(this._updateFlags)},e.distribute=function(){for(var t=this._updateFlags,e=t.length-1;e>=0;e--)t[e].flag=!0},t}(),_=function(){function t(){this._transform=new p,this._invModelMatrix=new e.Matrix,this._transform.owner=this,this._inverseWorldMatFlag=this._transform.registerWorldChangeFlag()}var i=t.prototype;return i.setRotation=function(t){console.log("Physics-lite don't support setRotation. Use Physics-PhysX instead!")},i.setPosition=function(t){this._transform.setPosition(t.x,t.y,t.z)},i.setContactOffset=function(t){console.log("Physics-lite don't support setContactOffset. Use Physics-PhysX instead!")},i.setMaterial=function(t){console.log("Physics-lite don't support setMaterial. Use Physics-PhysX instead!")},i.setUniqueID=function(t){this._id=t},i.setIsTrigger=function(t){console.log("Physics-lite don't support setIsTrigger. Use Physics-PhysX instead!")},i.destroy=function(){},i._updateHitResult=function(i,n,s,o,r){void 0===r&&(r=!1);var a=t._tempPoint;i.getPoint(n,a),r||e.Vector3.transformCoordinate(a,this._transform.worldMatrix,a);var h=e.Vector3.distance(o,a);h<s.distance&&(s.point.copyFrom(a),s.distance=h,s.shapeID=this._id)},i._getLocalRay=function(i){var n=this._getInvModelMatrix(),s=t._ray;return e.Vector3.transformCoordinate(i.origin,n,s.origin),e.Vector3.transformNormal(i.direction,n,s.direction),s.direction.normalize(),s},i._getInvModelMatrix=function(){return this._inverseWorldMatFlag.flag&&(e.Matrix.invert(this._transform.worldMatrix,this._invModelMatrix),this._inverseWorldMatFlag.flag=!1),this._invModelMatrix},t}();_._ray=new e.Ray,_._tempPoint=new e.Vector3;var p=function(){function t(){this._position=new e.Vector3,this._rotation=new e.Vector3,this._rotationQuaternion=new e.Quaternion,this._scale=new e.Vector3(1,1,1),this._worldRotationQuaternion=new e.Quaternion,this._localMatrix=new e.Matrix,this._worldMatrix=new e.Matrix,this._updateFlagManager=new d,this._isParentDirty=!0,this._parentTransformCache=null,this._dirtyFlag=188}var i=t.prototype;return i.setPosition=function(t,e,i){this._position.set(t,e,i),this.position=this._position},i.setRotationQuaternion=function(t,e,i,n){this._rotationQuaternion.set(t,e,i,n),this.rotationQuaternion=this._rotationQuaternion},i.setScale=function(t,e,i){this._scale.set(t,e,i),this.scale=this._scale},i.registerWorldChangeFlag=function(){return this._updateFlagManager.register()},i._updateWorldPositionFlag=function(){if(!this._isContainDirtyFlags(132)&&(this._worldAssociatedChange(132),r(this._owner,f)))for(var t=this._owner._shapes,e=0,i=t.length;e<i;e++)t[e]._transform._updateWorldPositionFlag()},i._updateWorldRotationFlag=function(){if(!this._isContainDirtyFlags(152)&&(this._worldAssociatedChange(152),r(this._owner,f)))for(var t=this._owner._shapes,e=0,i=t.length;e<i;e++)t[e]._transform._updateWorldRotationFlag()},i._updateWorldScaleFlag=function(){if(!this._isContainDirtyFlags(160)&&(this._worldAssociatedChange(160),r(this._owner,f)))for(var t=this._owner._shapes,e=0,i=t.length;e<i;e++)t[e]._transform._updateWorldScaleFlag()},i._updateAllWorldFlag=function(){if(!this._isContainDirtyFlags(188)&&(this._worldAssociatedChange(188),r(this._owner,f)))for(var t=this._owner._shapes,e=0,i=t.length;e<i;e++)t[e]._transform._updateAllWorldFlag()},i._getParentTransform=function(){if(!this._isParentDirty)return this._parentTransformCache;var t=null;return r(this._owner,_)&&(t=this._owner._collider._transform),this._parentTransformCache=t,this._isParentDirty=!1,t},i._isContainDirtyFlags=function(t){return(this._dirtyFlag&t)===t},i._isContainDirtyFlag=function(t){return(this._dirtyFlag&t)!=0},i._setDirtyFlagTrue=function(t){this._dirtyFlag|=t},i._setDirtyFlagFalse=function(t){this._dirtyFlag&=~t},i._worldAssociatedChange=function(t){this._dirtyFlag|=t,this._updateFlagManager.distribute()},o(t,[{key:"owner",set:function(t){this._owner=t}},{key:"position",get:function(){return this._position},set:function(t){this._position!==t&&this._position.copyFrom(t),this._setDirtyFlagTrue(64),this._updateWorldPositionFlag()}},{key:"rotationQuaternion",get:function(){return this._isContainDirtyFlag(2)&&(e.Quaternion.rotationEuler(e.MathUtil.degreeToRadian(this._rotation.x),e.MathUtil.degreeToRadian(this._rotation.y),e.MathUtil.degreeToRadian(this._rotation.z),this._rotationQuaternion),this._setDirtyFlagFalse(2)),this._rotationQuaternion},set:function(t){this._rotationQuaternion!==t&&this._rotationQuaternion.copyFrom(t),this._setDirtyFlagTrue(65),this._setDirtyFlagFalse(2),this._updateWorldRotationFlag()}},{key:"worldRotationQuaternion",get:function(){if(this._isContainDirtyFlag(16)){var t=this._getParentTransform();null!=t?e.Quaternion.multiply(t.worldRotationQuaternion,this.rotationQuaternion,this._worldRotationQuaternion):this._worldRotationQuaternion.copyFrom(this.rotationQuaternion),this._setDirtyFlagFalse(16)}return this._worldRotationQuaternion},set:function(i){this._worldRotationQuaternion!==i&&this._worldRotationQuaternion.copyFrom(i);var n=this._getParentTransform();n?(e.Quaternion.invert(n.worldRotationQuaternion,t._tempQuat0),e.Quaternion.multiply(i,t._tempQuat0,this._rotationQuaternion)):this._rotationQuaternion.copyFrom(i),this.rotationQuaternion=this._rotationQuaternion,this._setDirtyFlagFalse(16)}},{key:"scale",get:function(){return this._scale},set:function(t){this._scale!==t&&this._scale.copyFrom(t),this._setDirtyFlagTrue(64),this._updateWorldScaleFlag()}},{key:"localMatrix",get:function(){return this._isContainDirtyFlag(64)&&(e.Matrix.affineTransformation(this._scale,this.rotationQuaternion,this._position,this._localMatrix),this._setDirtyFlagFalse(64)),this._localMatrix},set:function(t){this._localMatrix!==t&&this._localMatrix.copyFrom(t),this._localMatrix.decompose(this._position,this._rotationQuaternion,this._scale),this._setDirtyFlagTrue(1),this._setDirtyFlagFalse(64),this._updateAllWorldFlag()}},{key:"worldMatrix",get:function(){if(this._isContainDirtyFlag(128)){var t=this._getParentTransform();t?e.Matrix.multiply(t.worldMatrix,this.localMatrix,this._worldMatrix):this._worldMatrix.copyFrom(this.localMatrix),this._setDirtyFlagFalse(128)}return this._worldMatrix},set:function(i){this._worldMatrix!==i&&this._worldMatrix.copyFrom(i);var n=this._getParentTransform();n?(e.Matrix.invert(n.worldMatrix,t._tempMat42),e.Matrix.multiply(t._tempMat42,i,this._localMatrix)):this._localMatrix.copyFrom(i),this.localMatrix=this._localMatrix,this._setDirtyFlagFalse(128)}}]),t}();p._tempQuat0=new e.Quaternion,p._tempMat42=new e.Matrix,(a=l||(l={}))[a.LocalEuler=1]="LocalEuler",a[a.LocalQuat=2]="LocalQuat",a[a.WorldPosition=4]="WorldPosition",a[a.WorldEuler=8]="WorldEuler",a[a.WorldQuat=16]="WorldQuat",a[a.WorldScale=32]="WorldScale",a[a.LocalMatrix=64]="LocalMatrix",a[a.WorldMatrix=128]="WorldMatrix",a[a.WmWp=132]="WmWp",a[a.WmWeWq=152]="WmWeWq",a[a.WmWpWeWq=156]="WmWpWeWq",a[a.WmWs=160]="WmWs",a[a.WmWpWs=164]="WmWpWs",a[a.WmWpWeWqWs=188]="WmWpWeWqWs";var f=function(){function t(){this._shapes=[],this._transform=new p,this._transform.owner=this}var e=t.prototype;return e.addShape=function(t){var e=t._collider;e!==this&&(e&&e.removeShape(t),this._shapes.push(t),t._collider=this)},e.removeShape=function(t){var e=this._shapes.indexOf(t);-1!==e&&(this._shapes.splice(e,1),t._collider=null)},e.setWorldTransform=function(t,e){this._transform.setPosition(t.x,t.y,t.z),this._transform.setRotationQuaternion(e.x,e.y,e.z,e.w)},e.getWorldTransform=function(t,e){var i=this._transform,n=i.position,s=i.rotationQuaternion;t.set(n.x,n.y,n.z),e.set(s.x,s.y,s.z,s.w)},e.destroy=function(){},e._raycast=function(t,e,i){i.distance=Number.MAX_VALUE;for(var n=this._shapes,s=0,o=n.length;s<o;s++){var r=n[s];e(r._id)&&r._raycast(t,i)}return i.distance!=Number.MAX_VALUE},t}(),y=function(t){function e(e,i){var n;return(n=t.call(this)||this)._transform.setPosition(e.x,e.y,e.z),n._transform.setRotationQuaternion(i.x,i.y,i.z,i.w),n}n(e,t);var i=e.prototype;return i.addForce=function(t){throw"Physics-lite don't support addForce. Use Physics-PhysX instead!"},i.addTorque=function(t){throw"Physics-lite don't support addTorque. Use Physics-PhysX instead!"},i.move=function(t,e){throw"Physics-lite don't support move. Use Physics-PhysX instead!"},i.sleep=function(){throw"Physics-lite don't support putToSleep. Use Physics-PhysX instead!"},i.setAngularDamping=function(t){throw"Physics-lite don't support setAngularDamping. Use Physics-PhysX instead!"},i.setAngularVelocity=function(t){throw"Physics-lite don't support setAngularVelocity. Use Physics-PhysX instead!"},i.setCenterOfMass=function(t){throw"Physics-lite don't support setCenterOfMass. Use Physics-PhysX instead!"},i.setCollisionDetectionMode=function(t){throw"Physics-lite don't support setCollisionDetectionMode. Use Physics-PhysX instead!"},i.setConstraints=function(t){throw"Physics-lite don't support setConstraints. Use Physics-PhysX instead!"},i.setInertiaTensor=function(t){throw"Physics-lite don't support setInertiaTensor. Use Physics-PhysX instead!"},i.setIsKinematic=function(t){throw"Physics-lite don't support setIsKinematic. Use Physics-PhysX instead!"},i.setLinearDamping=function(t){throw"Physics-lite don't support setLinearDamping. Use Physics-PhysX instead!"},i.setLinearVelocity=function(t){throw"Physics-lite don't support setLinearVelocity. Use Physics-PhysX instead!"},i.setMass=function(t){throw"Physics-lite don't support setMass. Use Physics-PhysX instead!"},i.setMaxAngularVelocity=function(t){throw"Physics-lite don't support setMaxAngularVelocity. Use Physics-PhysX instead!"},i.setMaxDepenetrationVelocity=function(t){throw"Physics-lite don't support setMaxDepenetrationVelocity. Use Physics-PhysX instead!"},i.setSleepThreshold=function(t){throw"Physics-lite don't support setSleepThreshold. Use Physics-PhysX instead!"},i.setSolverIterations=function(t){throw"Physics-lite don't support setSolverIterations. Use Physics-PhysX instead!"},i.wakeUp=function(){throw"Physics-lite don't support wakeUp. Use Physics-PhysX instead!"},e}(f),g=function(){function t(t,e,i,n,s){}var e=t.prototype;return e.setBounciness=function(t){throw"Physics-lite don't support physics material. Use Physics-PhysX instead!"},e.setDynamicFriction=function(t){throw"Physics-lite don't support physics material. Use Physics-PhysX instead!"},e.setStaticFriction=function(t){throw"Physics-lite don't support physics material. Use Physics-PhysX instead!"},e.setBounceCombine=function(t){throw"Physics-lite don't support physics material. Use Physics-PhysX instead!"},e.setFrictionCombine=function(t){throw"Physics-lite don't support physics material. Use Physics-PhysX instead!"},e.destroy=function(){},t}(),m=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}(),P=function(){this.shapeID=-1,this.distance=0,this.point=new e.Vector3,this.normal=new e.Vector3},x=function(t){function i(i,n,s){var o;return(o=t.call(this)||this)._halfSize=new e.Vector3,o._scale=new e.Vector3(1,1,1),o._boxMin=new e.Vector3(-.5,-.5,-.5),o._boxMax=new e.Vector3(.5,.5,.5),o._id=i,o._halfSize.set(.5*n.x,.5*n.y,.5*n.z),o._setBondingBox(),o}n(i,t);var s=i.prototype;return s.setPosition=function(e){t.prototype.setPosition.call(this,e),this._setBondingBox()},s.setWorldScale=function(t){this._transform.position=this._transform.position.multiply(t),this._scale.copyFrom(t)},s.setSize=function(t){this._halfSize.set(.5*t.x,.5*t.y,.5*t.z),this._setBondingBox()},s._raycast=function(t,e){var n=this._getLocalRay(t),s=i._tempBox;s.min.set(-this._halfSize.x*this._scale.x,-this._halfSize.y*this._scale.y,-this._halfSize.z*this._scale.z),s.max.set(this._halfSize.x*this._scale.x,this._halfSize.y*this._scale.y,this._halfSize.z*this._scale.z);var o=n.intersectBox(s);return -1!==o&&(this._updateHitResult(n,o,e,t.origin),!0)},s._setBondingBox=function(){var t=this._transform.position,i=this._halfSize;e.Vector3.add(t,i,this._boxMax),e.Vector3.subtract(t,i,this._boxMin)},i}(_);x._tempBox=new e.BoundingBox;var v=function(t){function i(e,i,n){var s;return(s=t.call(this)||this)._radius=1,s._maxScale=1,s._radius=i,s._id=e,s}n(i,t);var s=i.prototype;return s.setRadius=function(t){this._radius=t},s.setWorldScale=function(t){this._maxScale=Math.max(t.x,Math.max(t.x,t.y))},s._raycast=function(t,n){var s=i._tempSphere;e.Vector3.transformCoordinate(this._transform.position,this._collider._transform.worldMatrix,s.center),s.radius=this.worldRadius;var o=t.intersectSphere(s);return -1!==o&&(this._updateHitResult(t,o,n,t.origin,!0),!0)},o(i,[{key:"worldRadius",get:function(){return this._radius*this._maxScale}}]),i}(_);v._tempSphere=new e.BoundingSphere;var w=function(){function t(t,i,n,s,o,r){this._colliders=[],this._sphere=new e.BoundingSphere,this._box=new e.BoundingBox,this._currentEvents=new m,this._eventMap={},this._eventPool=[],this._onContactEnter=t,this._onContactExit=i,this._onContactStay=n,this._onTriggerEnter=s,this._onTriggerExit=o,this._onTriggerStay=r}var i=t.prototype;return i.setGravity=function(t){console.log("Physics-lite don't support gravity. Use Physics-PhysX instead!")},i.addColliderShape=function(t){this._eventMap[t._id]={}},i.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._eventMap[n]},i.addCollider=function(t){this._colliders.push(t)},i.removeCollider=function(t){var e=this._colliders.indexOf(t);-1!==e&&this._colliders.splice(e,1)},i.update=function(t){for(var e=this._colliders,i=0,n=e.length;i<n;i++)this._collisionDetection(t,e[i]);this._fireEvent()},i.raycast=function(e,i,n,s){var o,r=this._colliders;s&&(o=t._hitResult);for(var a=!1,h=t._currentHit,l=0,c=r.length;l<c;l++)if(r[l]._raycast(e,n,h)&&(a=!0,h.distance<i)){if(!o)return!0;o.normal.copyFrom(h.normal),o.point.copyFrom(h.point),o.distance=h.distance,o.shapeID=h.shapeID,i=h.distance}return!a&&o?(o.shapeID=-1,o.distance=0,o.point.set(0,0,0),o.normal.set(0,0,0)):a&&o&&s(o.shapeID,o.distance,o.point,o.normal),a},i.addCharacterController=function(t){throw"Physics-lite don't support addCharacterController. Use Physics-PhysX instead!"},i.removeCharacterController=function(t){throw"Physics-lite don't support removeCharacterController. Use Physics-PhysX instead!"},i._getTrigger=function(t,e){var i;return this._eventPool.length?((i=this._eventPool.pop()).index1=t,i.index2=e):i=new M(t,e),this._eventMap[t][e]=i,i},i._collisionDetection=function(e,i){for(var n=this._colliders,s=i._shapes,o=0,a=s.length;o<a;o++){var h=s[o];if(r(h,x)){t._updateWorldBox(h,this._box);for(var l=0,c=n.length;l<c;l++)for(var u=n[l]._shapes,d=0,_=u.length;d<_;d++){var p=u[d],f=p._id,y=h._id,g=f<y?this._eventMap[f][y]:this._eventMap[y][f];if((void 0===g||g.alreadyInvoked)&&p!=h&&this._boxCollision(p)){if(void 0===g){var m=f<y?this._getTrigger(f,y):this._getTrigger(y,f);m.state=0,m.alreadyInvoked=!1,this._currentEvents.add(m)}else 0===g.state?(g.state=1,g.alreadyInvoked=!1):1===g.state&&(g.alreadyInvoked=!1)}}}else if(r(h,v)){t._upWorldSphere(h,this._sphere);for(var P=0,w=n.length;P<w;P++)for(var M=n[P]._shapes,F=0,C=M.length;F<C;F++){var W=M[F],S=W._id,U=h._id,D=S<U?this._eventMap[S][U]:this._eventMap[U][S];if((void 0===D||D.alreadyInvoked)&&W!=h&&this._sphereCollision(W)){if(void 0===D){var Q=S<U?this._getTrigger(S,U):this._getTrigger(U,S);Q.state=0,Q.alreadyInvoked=!1,this._currentEvents.add(Q)}else 0===D.state?(D.state=1,D.alreadyInvoked=!1):1===D.state&&(D.alreadyInvoked=!1)}}}}},i._fireEvent=function(){for(var t=this._eventPool,e=this._currentEvents,i=e.length-1;i>=0;i--){var n=e.get(i);n.alreadyInvoked?(n.state=2,this._eventMap[n.index1][n.index2]=void 0,this._onTriggerExit(n.index1,n.index2),e.deleteByIndex(i),t.push(n)):0==n.state?(this._onTriggerEnter(n.index1,n.index2),n.alreadyInvoked=!0):1==n.state&&(this._onTriggerStay(n.index1,n.index2),n.alreadyInvoked=!0)}},i._boxCollision=function(i){if(r(i,x)){var n=t._tempBox;return t._updateWorldBox(i,n),e.CollisionUtil.intersectsBoxAndBox(n,this._box)}if(r(i,v)){var s=t._tempSphere;return t._upWorldSphere(i,s),e.CollisionUtil.intersectsSphereAndBox(s,this._box)}return!1},i._sphereCollision=function(i){if(r(i,x)){var n=t._tempBox;return t._updateWorldBox(i,n),e.CollisionUtil.intersectsSphereAndBox(this._sphere,n)}if(r(i,v)){var s=t._tempSphere;return t._upWorldSphere(i,s),e.CollisionUtil.intersectsSphereAndSphere(s,this._sphere)}return!1},t._updateWorldBox=function(t,i){var n=t._transform.worldMatrix;i.min.copyFrom(t._boxMin),i.max.copyFrom(t._boxMax),e.BoundingBox.transform(i,n,i)},t._upWorldSphere=function(t,i){e.Vector3.transformCoordinate(t._transform.position,t._transform.worldMatrix,i.center),i.radius=t.worldRadius},t}();w._tempSphere=new e.BoundingSphere,w._tempBox=new e.BoundingBox,w._currentHit=new P,w._hitResult=new P,(h=c||(c={}))[h.Enter=0]="Enter",h[h.Stay=1]="Stay",h[h.Exit=2]="Exit";var M=function(t,e){this.alreadyInvoked=!1,this.index1=t,this.index2=e},F=function(t){function e(e,i){var n;return(n=t.call(this)||this)._transform.setPosition(e.x,e.y,e.z),n._transform.setRotationQuaternion(i.x,i.y,i.z,i.w),n}return n(e,t),e}(f),C=function(){function t(){}var e=t.prototype;return e.initialize=function(){return Promise.resolve()},e.createPhysicsManager=function(){return null},e.createPhysicsScene=function(t,e,i,n,s,o,r){return new w(e,i,n,s,o,r)},e.createStaticCollider=function(t,e){return new F(t,e)},e.createDynamicCollider=function(t,e){return new y(t,e)},e.createCharacterController=function(){throw"Physics-lite don't support createCharacterController. Use Physics-PhysX instead!"},e.createPhysicsMaterial=function(t,e,i,n,s){return new g(t,e,i,n,s)},e.createBoxColliderShape=function(t,e,i){return new x(t,e,i)},e.createSphereColliderShape=function(t,e,i){return new v(t,e,i)},e.createPlaneColliderShape=function(t,e){throw"Physics-lite don't support PlaneColliderShape. Use Physics-PhysX instead!"},e.createCapsuleColliderShape=function(t,e,i,n){throw"Physics-lite don't support CapsuleColliderShape. Use Physics-PhysX instead!"},e.createFixedJoint=function(t){throw"Physics-lite don't support CapsuleColliderShape. Use Physics-PhysX instead!"},e.createHingeJoint=function(t){throw"Physics-lite don't support CapsuleColliderShape. Use Physics-PhysX instead!"},e.createSpringJoint=function(t){throw"Physics-lite don't support CapsuleColliderShape. Use Physics-PhysX instead!"},t}();t.LitePhysics=C,Object.defineProperty(t,"__esModule",{value:!0})});
1
+ !function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports,require("@galacean/engine")):"function"==typeof define&&define.amd?define(["exports","@galacean/engine"],i):i(((t="undefined"!=typeof globalThis?globalThis:t||self).Galacean=t.Galacean||{},t.Galacean.PhysicsLite={}),t.Galacean)}(this,function(t,i){"use strict";function e(t,i){return(e=Object.setPrototypeOf||function(t,i){return t.__proto__=i,t})(t,i)}function n(t,i){if("function"!=typeof i&&null!==i)throw TypeError("Super expression must either be null or a function");t.prototype=Object.create(i&&i.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),i&&e(t,i)}function s(t,i){for(var e=0;e<i.length;e++){var n=i[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function o(t,i,e){return i&&s(t.prototype,i),e&&s(t,e),t}function r(t,i){return null!=i&&"undefined"!=typeof Symbol&&i[Symbol.hasInstance]?!!i[Symbol.hasInstance](t):t instanceof i}var a,h,l,c,u=function(){function t(t){void 0===t&&(t=[]),this._flags=t,this.flag=!0,this._flags.push(this)}return t.prototype.destroy=function(){i.Utils.removeFromArray(this._flags,this),this._flags=null},t}(),d=function(){function t(){this._updateFlags=[]}var i=t.prototype;return i.register=function(){return new u(this._updateFlags)},i.distribute=function(){for(var t=this._updateFlags,i=t.length-1;i>=0;i--)t[i].flag=!0},t}(),_=function(){function t(){this._transform=new p,this._invModelMatrix=new i.Matrix,this._transform.owner=this,this._inverseWorldMatFlag=this._transform.registerWorldChangeFlag()}var e=t.prototype;return e.setRotation=function(t){console.log("Physics-lite don't support setRotation. Use Physics-PhysX instead!")},e.setPosition=function(t){this._transform.setPosition(t.x,t.y,t.z)},e.setContactOffset=function(t){console.log("Physics-lite don't support setContactOffset. Use Physics-PhysX instead!")},e.setMaterial=function(t){console.log("Physics-lite don't support setMaterial. Use Physics-PhysX instead!")},e.setUniqueID=function(t){this._id=t},e.setIsTrigger=function(t){console.log("Physics-lite don't support setIsTrigger. Use Physics-PhysX instead!")},e.destroy=function(){},e._updateHitResult=function(e,n,s,o,r){void 0===r&&(r=!1);var a=t._tempPoint;e.getPoint(n,a),r||i.Vector3.transformCoordinate(a,this._transform.worldMatrix,a);var h=i.Vector3.distance(o,a);h<s.distance&&(s.point.copyFrom(a),s.distance=h,s.shapeID=this._id)},e._getLocalRay=function(e){var n=this._getInvModelMatrix(),s=t._ray;return i.Vector3.transformCoordinate(e.origin,n,s.origin),i.Vector3.transformNormal(e.direction,n,s.direction),s.direction.normalize(),s},e._getInvModelMatrix=function(){return this._inverseWorldMatFlag.flag&&(i.Matrix.invert(this._transform.worldMatrix,this._invModelMatrix),this._inverseWorldMatFlag.flag=!1),this._invModelMatrix},t}();_._ray=new i.Ray,_._tempPoint=new i.Vector3;var p=function(){function t(){this._position=new i.Vector3,this._rotation=new i.Vector3,this._rotationQuaternion=new i.Quaternion,this._scale=new i.Vector3(1,1,1),this._worldRotationQuaternion=new i.Quaternion,this._localMatrix=new i.Matrix,this._worldMatrix=new i.Matrix,this._updateFlagManager=new d,this._isParentDirty=!0,this._parentTransformCache=null,this._dirtyFlag=188}var e=t.prototype;return e.setPosition=function(t,i,e){this._position.set(t,i,e),this.position=this._position},e.setRotationQuaternion=function(t,i,e,n){this._rotationQuaternion.set(t,i,e,n),this.rotationQuaternion=this._rotationQuaternion},e.setScale=function(t,i,e){this._scale.set(t,i,e),this.scale=this._scale},e.registerWorldChangeFlag=function(){return this._updateFlagManager.register()},e._updateWorldPositionFlag=function(){if(!this._isContainDirtyFlags(132)&&(this._worldAssociatedChange(132),r(this._owner,f)))for(var t=this._owner._shapes,i=0,e=t.length;i<e;i++)t[i]._transform._updateWorldPositionFlag()},e._updateWorldRotationFlag=function(){if(!this._isContainDirtyFlags(152)&&(this._worldAssociatedChange(152),r(this._owner,f)))for(var t=this._owner._shapes,i=0,e=t.length;i<e;i++)t[i]._transform._updateWorldRotationFlag()},e._updateWorldScaleFlag=function(){if(!this._isContainDirtyFlags(160)&&(this._worldAssociatedChange(160),r(this._owner,f)))for(var t=this._owner._shapes,i=0,e=t.length;i<e;i++)t[i]._transform._updateWorldScaleFlag()},e._updateAllWorldFlag=function(){if(!this._isContainDirtyFlags(188)&&(this._worldAssociatedChange(188),r(this._owner,f)))for(var t=this._owner._shapes,i=0,e=t.length;i<e;i++)t[i]._transform._updateAllWorldFlag()},e._getParentTransform=function(){if(!this._isParentDirty)return this._parentTransformCache;var t=null;return r(this._owner,_)&&(t=this._owner._collider._transform),this._parentTransformCache=t,this._isParentDirty=!1,t},e._isContainDirtyFlags=function(t){return(this._dirtyFlag&t)===t},e._isContainDirtyFlag=function(t){return(this._dirtyFlag&t)!=0},e._setDirtyFlagTrue=function(t){this._dirtyFlag|=t},e._setDirtyFlagFalse=function(t){this._dirtyFlag&=~t},e._worldAssociatedChange=function(t){this._dirtyFlag|=t,this._updateFlagManager.distribute()},o(t,[{key:"owner",set:function(t){this._owner=t}},{key:"position",get:function(){return this._position},set:function(t){this._position!==t&&this._position.copyFrom(t),this._setDirtyFlagTrue(64),this._updateWorldPositionFlag()}},{key:"rotationQuaternion",get:function(){return this._isContainDirtyFlag(2)&&(i.Quaternion.rotationEuler(i.MathUtil.degreeToRadian(this._rotation.x),i.MathUtil.degreeToRadian(this._rotation.y),i.MathUtil.degreeToRadian(this._rotation.z),this._rotationQuaternion),this._setDirtyFlagFalse(2)),this._rotationQuaternion},set:function(t){this._rotationQuaternion!==t&&this._rotationQuaternion.copyFrom(t),this._setDirtyFlagTrue(65),this._setDirtyFlagFalse(2),this._updateWorldRotationFlag()}},{key:"worldRotationQuaternion",get:function(){if(this._isContainDirtyFlag(16)){var t=this._getParentTransform();null!=t?i.Quaternion.multiply(t.worldRotationQuaternion,this.rotationQuaternion,this._worldRotationQuaternion):this._worldRotationQuaternion.copyFrom(this.rotationQuaternion),this._setDirtyFlagFalse(16)}return this._worldRotationQuaternion},set:function(e){this._worldRotationQuaternion!==e&&this._worldRotationQuaternion.copyFrom(e);var n=this._getParentTransform();n?(i.Quaternion.invert(n.worldRotationQuaternion,t._tempQuat0),i.Quaternion.multiply(e,t._tempQuat0,this._rotationQuaternion)):this._rotationQuaternion.copyFrom(e),this.rotationQuaternion=this._rotationQuaternion,this._setDirtyFlagFalse(16)}},{key:"scale",get:function(){return this._scale},set:function(t){this._scale!==t&&this._scale.copyFrom(t),this._setDirtyFlagTrue(64),this._updateWorldScaleFlag()}},{key:"localMatrix",get:function(){return this._isContainDirtyFlag(64)&&(i.Matrix.affineTransformation(this._scale,this.rotationQuaternion,this._position,this._localMatrix),this._setDirtyFlagFalse(64)),this._localMatrix},set:function(t){this._localMatrix!==t&&this._localMatrix.copyFrom(t),this._localMatrix.decompose(this._position,this._rotationQuaternion,this._scale),this._setDirtyFlagTrue(1),this._setDirtyFlagFalse(64),this._updateAllWorldFlag()}},{key:"worldMatrix",get:function(){if(this._isContainDirtyFlag(128)){var t=this._getParentTransform();t?i.Matrix.multiply(t.worldMatrix,this.localMatrix,this._worldMatrix):this._worldMatrix.copyFrom(this.localMatrix),this._setDirtyFlagFalse(128)}return this._worldMatrix},set:function(e){this._worldMatrix!==e&&this._worldMatrix.copyFrom(e);var n=this._getParentTransform();n?(i.Matrix.invert(n.worldMatrix,t._tempMat42),i.Matrix.multiply(t._tempMat42,e,this._localMatrix)):this._localMatrix.copyFrom(e),this.localMatrix=this._localMatrix,this._setDirtyFlagFalse(128)}}]),t}();p._tempQuat0=new i.Quaternion,p._tempMat42=new i.Matrix,(a=l||(l={}))[a.LocalEuler=1]="LocalEuler",a[a.LocalQuat=2]="LocalQuat",a[a.WorldPosition=4]="WorldPosition",a[a.WorldEuler=8]="WorldEuler",a[a.WorldQuat=16]="WorldQuat",a[a.WorldScale=32]="WorldScale",a[a.LocalMatrix=64]="LocalMatrix",a[a.WorldMatrix=128]="WorldMatrix",a[a.WmWp=132]="WmWp",a[a.WmWeWq=152]="WmWeWq",a[a.WmWpWeWq=156]="WmWpWeWq",a[a.WmWs=160]="WmWs",a[a.WmWpWs=164]="WmWpWs",a[a.WmWpWeWqWs=188]="WmWpWeWqWs";var f=function(){function t(){this._shapes=[],this._transform=new p,this._transform.owner=this}var i=t.prototype;return i.addShape=function(t){var i=t._collider;i!==this&&(i&&i.removeShape(t),this._shapes.push(t),t._collider=this)},i.removeShape=function(t){var i=this._shapes.indexOf(t);-1!==i&&(this._shapes.splice(i,1),t._collider=null)},i.setWorldTransform=function(t,i){this._transform.setPosition(t.x,t.y,t.z),this._transform.setRotationQuaternion(i.x,i.y,i.z,i.w)},i.getWorldTransform=function(t,i){var e=this._transform,n=e.position,s=e.rotationQuaternion;t.set(n.x,n.y,n.z),i.set(s.x,s.y,s.z,s.w)},i.destroy=function(){},i._raycast=function(t,i,e){e.distance=Number.MAX_VALUE;for(var n=this._shapes,s=0,o=n.length;s<o;s++){var r=n[s];i(r._id)&&r._raycast(t,e)}return e.distance!=Number.MAX_VALUE},t}(),y=function(t){function i(i,e){var n;return(n=t.call(this)||this)._transform.setPosition(i.x,i.y,i.z),n._transform.setRotationQuaternion(e.x,e.y,e.z,e.w),n}n(i,t);var e=i.prototype;return e.addForce=function(t){throw"Physics-lite don't support addForce. Use Physics-PhysX instead!"},e.addTorque=function(t){throw"Physics-lite don't support addTorque. Use Physics-PhysX instead!"},e.move=function(t,i){throw"Physics-lite don't support move. Use Physics-PhysX instead!"},e.sleep=function(){throw"Physics-lite don't support putToSleep. Use Physics-PhysX instead!"},e.setAngularDamping=function(t){throw"Physics-lite don't support setAngularDamping. Use Physics-PhysX instead!"},e.setAngularVelocity=function(t){throw"Physics-lite don't support setAngularVelocity. Use Physics-PhysX instead!"},e.setCenterOfMass=function(t){throw"Physics-lite don't support setCenterOfMass. Use Physics-PhysX instead!"},e.setCollisionDetectionMode=function(t){throw"Physics-lite don't support setCollisionDetectionMode. Use Physics-PhysX instead!"},e.setConstraints=function(t){throw"Physics-lite don't support setConstraints. Use Physics-PhysX instead!"},e.setInertiaTensor=function(t){throw"Physics-lite don't support setInertiaTensor. Use Physics-PhysX instead!"},e.setIsKinematic=function(t){throw"Physics-lite don't support setIsKinematic. Use Physics-PhysX instead!"},e.setLinearDamping=function(t){throw"Physics-lite don't support setLinearDamping. Use Physics-PhysX instead!"},e.setLinearVelocity=function(t){throw"Physics-lite don't support setLinearVelocity. Use Physics-PhysX instead!"},e.setMass=function(t){throw"Physics-lite don't support setMass. Use Physics-PhysX instead!"},e.setMaxAngularVelocity=function(t){throw"Physics-lite don't support setMaxAngularVelocity. Use Physics-PhysX instead!"},e.setMaxDepenetrationVelocity=function(t){throw"Physics-lite don't support setMaxDepenetrationVelocity. Use Physics-PhysX instead!"},e.setSleepThreshold=function(t){throw"Physics-lite don't support setSleepThreshold. Use Physics-PhysX instead!"},e.setSolverIterations=function(t){throw"Physics-lite don't support setSolverIterations. Use Physics-PhysX instead!"},e.wakeUp=function(){throw"Physics-lite don't support wakeUp. Use Physics-PhysX instead!"},i}(f),g=function(){function t(t){void 0===t&&(t=0),this.length=0,this._elements=Array(t)}var i=t.prototype;return i.add=function(t){this.length===this._elements.length?this._elements.push(t):this._elements[this.length]=t,this.length++},i.delete=function(t){var i=this._elements.indexOf(t);this.deleteByIndex(i)},i.get=function(t){if(t>=this.length)throw"Index is out of range.";return this._elements[t]},i.deleteByIndex=function(t){var i=this._elements,e=null,n=this.length-1;return t!==n&&(e=i[n],i[t]=e),this.length--,e},i.garbageCollection=function(){this._elements.length=this.length},t}(),m=function(){this.shapeID=-1,this.distance=0,this.point=new i.Vector3,this.normal=new i.Vector3},P=function(t){function e(e,n,s){var o;return(o=t.call(this)||this)._halfSize=new i.Vector3,o._scale=new i.Vector3(1,1,1),o._boxMin=new i.Vector3(-.5,-.5,-.5),o._boxMax=new i.Vector3(.5,.5,.5),o._id=e,o._halfSize.set(.5*n.x,.5*n.y,.5*n.z),o._setBondingBox(),o}n(e,t);var s=e.prototype;return s.setPosition=function(i){t.prototype.setPosition.call(this,i),this._setBondingBox()},s.setWorldScale=function(t){this._transform.position=this._transform.position.multiply(t),this._scale.copyFrom(t)},s.setSize=function(t){this._halfSize.set(.5*t.x,.5*t.y,.5*t.z),this._setBondingBox()},s._raycast=function(t,i){var n=this._getLocalRay(t),s=e._tempBox;s.min.set(-this._halfSize.x*this._scale.x,-this._halfSize.y*this._scale.y,-this._halfSize.z*this._scale.z),s.max.set(this._halfSize.x*this._scale.x,this._halfSize.y*this._scale.y,this._halfSize.z*this._scale.z);var o=n.intersectBox(s);return -1!==o&&(this._updateHitResult(n,o,i,t.origin),!0)},s._setBondingBox=function(){var t=this._transform.position,e=this._halfSize;i.Vector3.add(t,e,this._boxMax),i.Vector3.subtract(t,e,this._boxMin)},e}(_);P._tempBox=new i.BoundingBox;var x=function(t){function e(i,e,n){var s;return(s=t.call(this)||this)._radius=1,s._maxScale=1,s._radius=e,s._id=i,s}n(e,t);var s=e.prototype;return s.setRadius=function(t){this._radius=t},s.setWorldScale=function(t){this._maxScale=Math.max(t.x,t.y,t.z)},s._raycast=function(t,n){var s=e._tempSphere;i.Vector3.transformCoordinate(this._transform.position,this._collider._transform.worldMatrix,s.center),s.radius=this.worldRadius;var o=t.intersectSphere(s);return -1!==o&&(this._updateHitResult(t,o,n,t.origin,!0),!0)},o(e,[{key:"worldRadius",get:function(){return this._radius*this._maxScale}}]),e}(_);x._tempSphere=new i.BoundingSphere;var v=function(){function t(t,e,n,s,o,r){this._colliders=[],this._sphere=new i.BoundingSphere,this._box=new i.BoundingBox,this._currentEvents=new g,this._eventMap={},this._eventPool=[],this._onContactEnter=t,this._onContactExit=e,this._onContactStay=n,this._onTriggerEnter=s,this._onTriggerExit=o,this._onTriggerStay=r}var e=t.prototype;return e.setGravity=function(t){console.log("Physics-lite don't support gravity. Use Physics-PhysX instead!")},e.addColliderShape=function(t){this._eventMap[t._id]={}},e.removeColliderShape=function(t){for(var i=this._eventPool,e=this._currentEvents,n=t._id,s=e.length-1;s>=0;s--){var o=e.get(s);(o.index1==n||o.index2==n)&&(e.deleteByIndex(s),i.push(o))}delete this._eventMap[n]},e.addCollider=function(t){this._colliders.push(t)},e.removeCollider=function(t){var i=this._colliders.indexOf(t);-1!==i&&this._colliders.splice(i,1)},e.update=function(t){for(var i=this._colliders,e=0,n=i.length;e<n;e++)this._collisionDetection(t,i[e]);this._fireEvent()},e.raycast=function(i,e,n,s){var o,r=this._colliders;s&&(o=t._hitResult);for(var a=!1,h=t._currentHit,l=0,c=r.length;l<c;l++)if(r[l]._raycast(i,n,h)&&h.distance<e){if(a=!0,!o)return!0;o.normal.copyFrom(h.normal),o.point.copyFrom(h.point),o.distance=h.distance,o.shapeID=h.shapeID,e=h.distance}return!a&&o?(o.shapeID=-1,o.distance=0,o.point.set(0,0,0),o.normal.set(0,0,0)):a&&o&&s(o.shapeID,o.distance,o.point,o.normal),a},e.addCharacterController=function(t){throw"Physics-lite don't support addCharacterController. Use Physics-PhysX instead!"},e.removeCharacterController=function(t){throw"Physics-lite don't support removeCharacterController. Use Physics-PhysX instead!"},e._getTrigger=function(t,i){var e;return this._eventPool.length?((e=this._eventPool.pop()).index1=t,e.index2=i):e=new w(t,i),this._eventMap[t][i]=e,e},e._collisionDetection=function(i,e){for(var n=this._colliders,s=e._shapes,o=0,a=s.length;o<a;o++){var h=s[o];if(r(h,P)){t._updateWorldBox(h,this._box);for(var l=0,c=n.length;l<c;l++)for(var u=n[l]._shapes,d=0,_=u.length;d<_;d++){var p=u[d],f=p._id,y=h._id,g=f<y?this._eventMap[f][y]:this._eventMap[y][f];if((void 0===g||g.alreadyInvoked)&&p!=h&&this._boxCollision(p)){if(void 0===g){var m=f<y?this._getTrigger(f,y):this._getTrigger(y,f);m.state=0,m.alreadyInvoked=!1,this._currentEvents.add(m)}else 0===g.state?(g.state=1,g.alreadyInvoked=!1):1===g.state&&(g.alreadyInvoked=!1)}}}else if(r(h,x)){t._upWorldSphere(h,this._sphere);for(var v=0,w=n.length;v<w;v++)for(var M=n[v]._shapes,F=0,C=M.length;F<C;F++){var W=M[F],S=W._id,U=h._id,D=S<U?this._eventMap[S][U]:this._eventMap[U][S];if((void 0===D||D.alreadyInvoked)&&W!=h&&this._sphereCollision(W)){if(void 0===D){var Q=S<U?this._getTrigger(S,U):this._getTrigger(U,S);Q.state=0,Q.alreadyInvoked=!1,this._currentEvents.add(Q)}else 0===D.state?(D.state=1,D.alreadyInvoked=!1):1===D.state&&(D.alreadyInvoked=!1)}}}}},e._fireEvent=function(){for(var t=this._eventPool,i=this._currentEvents,e=i.length-1;e>=0;e--){var n=i.get(e);n.alreadyInvoked?(n.state=2,this._eventMap[n.index1][n.index2]=void 0,this._onTriggerExit(n.index1,n.index2),i.deleteByIndex(e),t.push(n)):0==n.state?(this._onTriggerEnter(n.index1,n.index2),n.alreadyInvoked=!0):1==n.state&&(this._onTriggerStay(n.index1,n.index2),n.alreadyInvoked=!0)}},e._boxCollision=function(e){if(r(e,P)){var n=t._tempBox;return t._updateWorldBox(e,n),i.CollisionUtil.intersectsBoxAndBox(n,this._box)}if(r(e,x)){var s=t._tempSphere;return t._upWorldSphere(e,s),i.CollisionUtil.intersectsSphereAndBox(s,this._box)}return!1},e._sphereCollision=function(e){if(r(e,P)){var n=t._tempBox;return t._updateWorldBox(e,n),i.CollisionUtil.intersectsSphereAndBox(this._sphere,n)}if(r(e,x)){var s=t._tempSphere;return t._upWorldSphere(e,s),i.CollisionUtil.intersectsSphereAndSphere(s,this._sphere)}return!1},t._updateWorldBox=function(t,e){var n=t._transform.worldMatrix;e.min.copyFrom(t._boxMin),e.max.copyFrom(t._boxMax),i.BoundingBox.transform(e,n,e)},t._upWorldSphere=function(t,e){i.Vector3.transformCoordinate(t._transform.position,t._transform.worldMatrix,e.center),e.radius=t.worldRadius},t}();v._tempSphere=new i.BoundingSphere,v._tempBox=new i.BoundingBox,v._currentHit=new m,v._hitResult=new m,(h=c||(c={}))[h.Enter=0]="Enter",h[h.Stay=1]="Stay",h[h.Exit=2]="Exit";var w=function(t,i){this.alreadyInvoked=!1,this.index1=t,this.index2=i},M=function(){function t(t,i,e,n,s){}var i=t.prototype;return i.setBounciness=function(t){throw"Physics-lite don't support physics material. Use Physics-PhysX instead!"},i.setDynamicFriction=function(t){throw"Physics-lite don't support physics material. Use Physics-PhysX instead!"},i.setStaticFriction=function(t){throw"Physics-lite don't support physics material. Use Physics-PhysX instead!"},i.setBounceCombine=function(t){throw"Physics-lite don't support physics material. Use Physics-PhysX instead!"},i.setFrictionCombine=function(t){throw"Physics-lite don't support physics material. Use Physics-PhysX instead!"},i.destroy=function(){},t}(),F=function(t){function i(i,e){var n;return(n=t.call(this)||this)._transform.setPosition(i.x,i.y,i.z),n._transform.setRotationQuaternion(e.x,e.y,e.z,e.w),n}return n(i,t),i}(f),C=function(){function t(){}var i=t.prototype;return i.initialize=function(){return Promise.resolve()},i.createPhysicsManager=function(t,i,e,n,s,o){return new v(t,i,e,n,s,o)},i.createStaticCollider=function(t,i){return new F(t,i)},i.createDynamicCollider=function(t,i){return new y(t,i)},i.createCharacterController=function(){throw"Physics-lite don't support createCharacterController. Use Physics-PhysX instead!"},i.createPhysicsMaterial=function(t,i,e,n,s){return new M(t,i,e,n,s)},i.createBoxColliderShape=function(t,i,e){return new P(t,i,e)},i.createSphereColliderShape=function(t,i,e){return new x(t,i,e)},i.createPlaneColliderShape=function(t,i){throw"Physics-lite don't support PlaneColliderShape. Use Physics-PhysX instead!"},i.createCapsuleColliderShape=function(t,i,e,n){throw"Physics-lite don't support CapsuleColliderShape. Use Physics-PhysX instead!"},i.createFixedJoint=function(t){throw"Physics-lite don't support CapsuleColliderShape. Use Physics-PhysX instead!"},i.createHingeJoint=function(t){throw"Physics-lite don't support CapsuleColliderShape. Use Physics-PhysX instead!"},i.createSpringJoint=function(t){throw"Physics-lite don't support CapsuleColliderShape. Use Physics-PhysX instead!"},t}();t.LitePhysics=C,Object.defineProperty(t,"__esModule",{value:!0})});
package/dist/main.js CHANGED
@@ -653,42 +653,6 @@ var /**
653
653
  return LiteDynamicCollider;
654
654
  }(LiteCollider);
655
655
 
656
- /**
657
- * Physics material describes how to handle colliding objects (friction, bounciness).
658
- */ var LitePhysicsMaterial = /*#__PURE__*/ function() {
659
- function LitePhysicsMaterial(staticFriction, dynamicFriction, bounciness, frictionCombine, bounceCombine) {}
660
- var _proto = LitePhysicsMaterial.prototype;
661
- /**
662
- * {@inheritDoc IPhysicsMaterial.setBounciness }
663
- */ _proto.setBounciness = function setBounciness(value) {
664
- throw "Physics-lite don't support physics material. Use Physics-PhysX instead!";
665
- };
666
- /**
667
- * {@inheritDoc IPhysicsMaterial.setDynamicFriction }
668
- */ _proto.setDynamicFriction = function setDynamicFriction(value) {
669
- throw "Physics-lite don't support physics material. Use Physics-PhysX instead!";
670
- };
671
- /**
672
- * {@inheritDoc IPhysicsMaterial.setStaticFriction }
673
- */ _proto.setStaticFriction = function setStaticFriction(value) {
674
- throw "Physics-lite don't support physics material. Use Physics-PhysX instead!";
675
- };
676
- /**
677
- * {@inheritDoc IPhysicsMaterial.setBounceCombine }
678
- */ _proto.setBounceCombine = function setBounceCombine(value) {
679
- throw "Physics-lite don't support physics material. Use Physics-PhysX instead!";
680
- };
681
- /**
682
- * {@inheritDoc IPhysicsMaterial.setFrictionCombine }
683
- */ _proto.setFrictionCombine = function setFrictionCombine(value) {
684
- throw "Physics-lite don't support physics material. Use Physics-PhysX instead!";
685
- };
686
- /**
687
- * {@inheritDoc IPhysicsMaterial.destroy }
688
- */ _proto.destroy = function destroy() {};
689
- return LitePhysicsMaterial;
690
- }();
691
-
692
656
  /**
693
657
  * High-performance unordered array, delete uses exchange method to improve performance, internal capacity only increases.
694
658
  */ var DisorderedArray = /*#__PURE__*/ function() {
@@ -829,7 +793,7 @@ var /**
829
793
  /**
830
794
  * {@inheritDoc IColliderShape.setWorldScale }
831
795
  */ _proto.setWorldScale = function setWorldScale(scale) {
832
- this._maxScale = Math.max(scale.x, Math.max(scale.x, scale.y));
796
+ this._maxScale = Math.max(scale.x, scale.y, scale.z);
833
797
  };
834
798
  /**
835
799
  * @internal
@@ -861,8 +825,8 @@ var /**
861
825
 
862
826
  /**
863
827
  * A manager is a collection of colliders and constraints which can interact.
864
- */ var LitePhysicsScene = /*#__PURE__*/ function() {
865
- function LitePhysicsScene(onContactEnter, onContactExit, onContactStay, onTriggerEnter, onTriggerExit, onTriggerStay) {
828
+ */ var LitePhysicsManager = /*#__PURE__*/ function() {
829
+ function LitePhysicsManager(onContactEnter, onContactExit, onContactStay, onTriggerEnter, onTriggerExit, onTriggerStay) {
866
830
  this._colliders = [];
867
831
  this._sphere = new engine.BoundingSphere();
868
832
  this._box = new engine.BoundingBox();
@@ -876,7 +840,7 @@ var /**
876
840
  this._onTriggerExit = onTriggerExit;
877
841
  this._onTriggerStay = onTriggerStay;
878
842
  }
879
- var _proto = LitePhysicsScene.prototype;
843
+ var _proto = LitePhysicsManager.prototype;
880
844
  /**
881
845
  * {@inheritDoc IPhysicsManager.setGravity }
882
846
  */ _proto.setGravity = function setGravity(value) {
@@ -929,25 +893,23 @@ var /**
929
893
  var colliders = this._colliders;
930
894
  var hitResult;
931
895
  if (hit) {
932
- hitResult = LitePhysicsScene._hitResult;
896
+ hitResult = LitePhysicsManager._hitResult;
933
897
  }
934
898
  var isHit = false;
935
- var curHit = LitePhysicsScene._currentHit;
899
+ var curHit = LitePhysicsManager._currentHit;
936
900
  for(var i = 0, len = colliders.length; i < len; i++){
937
901
  var collider = colliders[i];
938
- if (collider._raycast(ray, onRaycast, curHit)) {
902
+ if (collider._raycast(ray, onRaycast, curHit) && curHit.distance < distance) {
939
903
  isHit = true;
940
- if (curHit.distance < distance) {
941
- if (hitResult) {
942
- hitResult.normal.copyFrom(curHit.normal);
943
- hitResult.point.copyFrom(curHit.point);
944
- hitResult.distance = curHit.distance;
945
- hitResult.shapeID = curHit.shapeID;
946
- } else {
947
- return true;
948
- }
949
- distance = curHit.distance;
904
+ if (hitResult) {
905
+ hitResult.normal.copyFrom(curHit.normal);
906
+ hitResult.point.copyFrom(curHit.point);
907
+ hitResult.distance = curHit.distance;
908
+ hitResult.shapeID = curHit.shapeID;
909
+ } else {
910
+ return true;
950
911
  }
912
+ distance = curHit.distance;
951
913
  }
952
914
  }
953
915
  if (!isHit && hitResult) {
@@ -988,7 +950,7 @@ var /**
988
950
  for(var i = 0, len = myColliderShapes.length; i < len; i++){
989
951
  var myShape = myColliderShapes[i];
990
952
  if (_instanceof(myShape, LiteBoxColliderShape)) {
991
- LitePhysicsScene._updateWorldBox(myShape, this._box);
953
+ LitePhysicsManager._updateWorldBox(myShape, this._box);
992
954
  for(var j = 0, len1 = colliders.length; j < len1; j++){
993
955
  var colliderShape = colliders[j]._shapes;
994
956
  for(var k = 0, len2 = colliderShape.length; k < len2; k++){
@@ -1015,7 +977,7 @@ var /**
1015
977
  }
1016
978
  }
1017
979
  } else if (_instanceof(myShape, LiteSphereColliderShape)) {
1018
- LitePhysicsScene._upWorldSphere(myShape, this._sphere);
980
+ LitePhysicsManager._upWorldSphere(myShape, this._sphere);
1019
981
  for(var j1 = 0, len3 = colliders.length; j1 < len3; j1++){
1020
982
  var colliderShape1 = colliders[j1]._shapes;
1021
983
  for(var k1 = 0, len4 = colliderShape1.length; k1 < len4; k1++){
@@ -1067,24 +1029,24 @@ var /**
1067
1029
  };
1068
1030
  _proto._boxCollision = function _boxCollision(other) {
1069
1031
  if (_instanceof(other, LiteBoxColliderShape)) {
1070
- var box = LitePhysicsScene._tempBox;
1071
- LitePhysicsScene._updateWorldBox(other, box);
1032
+ var box = LitePhysicsManager._tempBox;
1033
+ LitePhysicsManager._updateWorldBox(other, box);
1072
1034
  return engine.CollisionUtil.intersectsBoxAndBox(box, this._box);
1073
1035
  } else if (_instanceof(other, LiteSphereColliderShape)) {
1074
- var sphere = LitePhysicsScene._tempSphere;
1075
- LitePhysicsScene._upWorldSphere(other, sphere);
1036
+ var sphere = LitePhysicsManager._tempSphere;
1037
+ LitePhysicsManager._upWorldSphere(other, sphere);
1076
1038
  return engine.CollisionUtil.intersectsSphereAndBox(sphere, this._box);
1077
1039
  }
1078
1040
  return false;
1079
1041
  };
1080
1042
  _proto._sphereCollision = function _sphereCollision(other) {
1081
1043
  if (_instanceof(other, LiteBoxColliderShape)) {
1082
- var box = LitePhysicsScene._tempBox;
1083
- LitePhysicsScene._updateWorldBox(other, box);
1044
+ var box = LitePhysicsManager._tempBox;
1045
+ LitePhysicsManager._updateWorldBox(other, box);
1084
1046
  return engine.CollisionUtil.intersectsSphereAndBox(this._sphere, box);
1085
1047
  } else if (_instanceof(other, LiteSphereColliderShape)) {
1086
- var sphere = LitePhysicsScene._tempSphere;
1087
- LitePhysicsScene._upWorldSphere(other, sphere);
1048
+ var sphere = LitePhysicsManager._tempSphere;
1049
+ LitePhysicsManager._upWorldSphere(other, sphere);
1088
1050
  return engine.CollisionUtil.intersectsSphereAndSphere(sphere, this._sphere);
1089
1051
  }
1090
1052
  return false;
@@ -1093,7 +1055,7 @@ var /**
1093
1055
  * Calculate the bounding box in world space from boxCollider.
1094
1056
  * @param boxCollider - The boxCollider to calculate
1095
1057
  * @param out - The calculated boundingBox
1096
- */ LitePhysicsScene._updateWorldBox = function _updateWorldBox(boxCollider, out) {
1058
+ */ LitePhysicsManager._updateWorldBox = function _updateWorldBox(boxCollider, out) {
1097
1059
  var mat = boxCollider._transform.worldMatrix;
1098
1060
  out.min.copyFrom(boxCollider._boxMin);
1099
1061
  out.max.copyFrom(boxCollider._boxMax);
@@ -1103,23 +1065,23 @@ var /**
1103
1065
  * Get the sphere info of the given sphere collider in world space.
1104
1066
  * @param sphereCollider - The given sphere collider
1105
1067
  * @param out - The calculated boundingSphere
1106
- */ LitePhysicsScene._upWorldSphere = function _upWorldSphere(sphereCollider, out) {
1068
+ */ LitePhysicsManager._upWorldSphere = function _upWorldSphere(sphereCollider, out) {
1107
1069
  engine.Vector3.transformCoordinate(sphereCollider._transform.position, sphereCollider._transform.worldMatrix, out.center);
1108
1070
  out.radius = sphereCollider.worldRadius;
1109
1071
  };
1110
- return LitePhysicsScene;
1072
+ return LitePhysicsManager;
1111
1073
  }();
1112
1074
  (function() {
1113
- LitePhysicsScene._tempSphere = new engine.BoundingSphere();
1075
+ LitePhysicsManager._tempSphere = new engine.BoundingSphere();
1114
1076
  })();
1115
1077
  (function() {
1116
- LitePhysicsScene._tempBox = new engine.BoundingBox();
1078
+ LitePhysicsManager._tempBox = new engine.BoundingBox();
1117
1079
  })();
1118
1080
  (function() {
1119
- LitePhysicsScene._currentHit = new LiteHitResult();
1081
+ LitePhysicsManager._currentHit = new LiteHitResult();
1120
1082
  })();
1121
1083
  (function() {
1122
- LitePhysicsScene._hitResult = new LiteHitResult();
1084
+ LitePhysicsManager._hitResult = new LiteHitResult();
1123
1085
  })();
1124
1086
  var /**
1125
1087
  * Physics state
@@ -1137,6 +1099,42 @@ var /**
1137
1099
  this.index2 = index2;
1138
1100
  };
1139
1101
 
1102
+ /**
1103
+ * Physics material describes how to handle colliding objects (friction, bounciness).
1104
+ */ var LitePhysicsMaterial = /*#__PURE__*/ function() {
1105
+ function LitePhysicsMaterial(staticFriction, dynamicFriction, bounciness, frictionCombine, bounceCombine) {}
1106
+ var _proto = LitePhysicsMaterial.prototype;
1107
+ /**
1108
+ * {@inheritDoc IPhysicsMaterial.setBounciness }
1109
+ */ _proto.setBounciness = function setBounciness(value) {
1110
+ throw "Physics-lite don't support physics material. Use Physics-PhysX instead!";
1111
+ };
1112
+ /**
1113
+ * {@inheritDoc IPhysicsMaterial.setDynamicFriction }
1114
+ */ _proto.setDynamicFriction = function setDynamicFriction(value) {
1115
+ throw "Physics-lite don't support physics material. Use Physics-PhysX instead!";
1116
+ };
1117
+ /**
1118
+ * {@inheritDoc IPhysicsMaterial.setStaticFriction }
1119
+ */ _proto.setStaticFriction = function setStaticFriction(value) {
1120
+ throw "Physics-lite don't support physics material. Use Physics-PhysX instead!";
1121
+ };
1122
+ /**
1123
+ * {@inheritDoc IPhysicsMaterial.setBounceCombine }
1124
+ */ _proto.setBounceCombine = function setBounceCombine(value) {
1125
+ throw "Physics-lite don't support physics material. Use Physics-PhysX instead!";
1126
+ };
1127
+ /**
1128
+ * {@inheritDoc IPhysicsMaterial.setFrictionCombine }
1129
+ */ _proto.setFrictionCombine = function setFrictionCombine(value) {
1130
+ throw "Physics-lite don't support physics material. Use Physics-PhysX instead!";
1131
+ };
1132
+ /**
1133
+ * {@inheritDoc IPhysicsMaterial.destroy }
1134
+ */ _proto.destroy = function destroy() {};
1135
+ return LitePhysicsMaterial;
1136
+ }();
1137
+
1140
1138
  /**
1141
1139
  * A static collider component that will not move.
1142
1140
  * @remarks Mostly used for object which always stays at the same place and never moves around.
@@ -1162,13 +1160,8 @@ var LitePhysics = /*#__PURE__*/ function() {
1162
1160
  };
1163
1161
  /**
1164
1162
  * {@inheritDoc IPhysics.createPhysicsManager }
1165
- */ _proto.createPhysicsManager = function createPhysicsManager() {
1166
- return null;
1167
- };
1168
- /**
1169
- * {@inheritDoc IPhysics.createPhysicsScene }
1170
- */ _proto.createPhysicsScene = function createPhysicsScene(physicsManager, onContactBegin, onContactEnd, onContactPersist, onTriggerBegin, onTriggerEnd, onTriggerPersist) {
1171
- return new LitePhysicsScene(onContactBegin, onContactEnd, onContactPersist, onTriggerBegin, onTriggerEnd, onTriggerPersist);
1163
+ */ _proto.createPhysicsManager = function createPhysicsManager(onContactBegin, onContactEnd, onContactPersist, onTriggerBegin, onTriggerEnd, onTriggerPersist) {
1164
+ return new LitePhysicsManager(onContactBegin, onContactEnd, onContactPersist, onTriggerBegin, onTriggerEnd, onTriggerPersist);
1172
1165
  };
1173
1166
  /**
1174
1167
  * {@inheritDoc IPhysics.createStaticCollider }