@galacean/engine-physics-lite 0.0.0-experimental-0.9-plus.8 → 0.0.0-experimental-ktx2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.js CHANGED
@@ -1,26 +1,4 @@
1
- import { Ray, Vector3, Matrix, Quaternion, MathUtil, BoundingBox, BoundingSphere, CollisionUtil } from '@galacean/engine';
2
-
3
- /******************************************************************************
4
- Copyright (c) Microsoft Corporation.
5
-
6
- Permission to use, copy, modify, and/or distribute this software for any
7
- purpose with or without fee is hereby granted.
8
-
9
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
- PERFORMANCE OF THIS SOFTWARE.
16
- ***************************************************************************** */
17
-
18
- function __decorate(decorators, target, key, desc) {
19
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
- return c > 3 && r && Object.defineProperty(target, key, r), r;
23
- }
1
+ import { Utils, Ray, Vector3, Matrix, Quaternion, MathUtil, BoundingBox, BoundingSphere, CollisionUtil } from '@galacean/engine';
24
2
 
25
3
  function _set_prototype_of(o, p) {
26
4
  _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
@@ -66,22 +44,6 @@ function _instanceof(left, right) {
66
44
  } else return left instanceof right;
67
45
  }
68
46
 
69
- /**
70
- * Fastly remove an element from array.
71
- * @param array - Array
72
- * @param item - Element
73
- */ function removeFromArray(array, item) {
74
- var index = array.indexOf(item);
75
- if (index < 0) {
76
- return false;
77
- }
78
- var last = array.length - 1;
79
- if (index !== last) {
80
- array[index] = array[last];
81
- }
82
- array.length--;
83
- return true;
84
- }
85
47
  /**
86
48
  * Used to update tags.
87
49
  */ var LiteUpdateFlag = /*#__PURE__*/ function() {
@@ -95,7 +57,7 @@ function _instanceof(left, right) {
95
57
  /**
96
58
  * Destroy.
97
59
  */ _proto.destroy = function destroy() {
98
- removeFromArray(this._flags, this);
60
+ Utils.removeFromArray(this._flags, this);
99
61
  this._flags = null;
100
62
  };
101
63
  return LiteUpdateFlag;
@@ -687,6 +649,42 @@ var /**
687
649
  return LiteDynamicCollider;
688
650
  }(LiteCollider);
689
651
 
652
+ /**
653
+ * Physics material describes how to handle colliding objects (friction, bounciness).
654
+ */ var LitePhysicsMaterial = /*#__PURE__*/ function() {
655
+ function LitePhysicsMaterial(staticFriction, dynamicFriction, bounciness, frictionCombine, bounceCombine) {}
656
+ var _proto = LitePhysicsMaterial.prototype;
657
+ /**
658
+ * {@inheritDoc IPhysicsMaterial.setBounciness }
659
+ */ _proto.setBounciness = function setBounciness(value) {
660
+ throw "Physics-lite don't support physics material. Use Physics-PhysX instead!";
661
+ };
662
+ /**
663
+ * {@inheritDoc IPhysicsMaterial.setDynamicFriction }
664
+ */ _proto.setDynamicFriction = function setDynamicFriction(value) {
665
+ throw "Physics-lite don't support physics material. Use Physics-PhysX instead!";
666
+ };
667
+ /**
668
+ * {@inheritDoc IPhysicsMaterial.setStaticFriction }
669
+ */ _proto.setStaticFriction = function setStaticFriction(value) {
670
+ throw "Physics-lite don't support physics material. Use Physics-PhysX instead!";
671
+ };
672
+ /**
673
+ * {@inheritDoc IPhysicsMaterial.setBounceCombine }
674
+ */ _proto.setBounceCombine = function setBounceCombine(value) {
675
+ throw "Physics-lite don't support physics material. Use Physics-PhysX instead!";
676
+ };
677
+ /**
678
+ * {@inheritDoc IPhysicsMaterial.setFrictionCombine }
679
+ */ _proto.setFrictionCombine = function setFrictionCombine(value) {
680
+ throw "Physics-lite don't support physics material. Use Physics-PhysX instead!";
681
+ };
682
+ /**
683
+ * {@inheritDoc IPhysicsMaterial.destroy }
684
+ */ _proto.destroy = function destroy() {};
685
+ return LitePhysicsMaterial;
686
+ }();
687
+
690
688
  /**
691
689
  * High-performance unordered array, delete uses exchange method to improve performance, internal capacity only increases.
692
690
  */ var DisorderedArray = /*#__PURE__*/ function() {
@@ -859,8 +857,8 @@ var /**
859
857
 
860
858
  /**
861
859
  * A manager is a collection of colliders and constraints which can interact.
862
- */ var LitePhysicsManager = /*#__PURE__*/ function() {
863
- function LitePhysicsManager(onContactEnter, onContactExit, onContactStay, onTriggerEnter, onTriggerExit, onTriggerStay) {
860
+ */ var LitePhysicsScene = /*#__PURE__*/ function() {
861
+ function LitePhysicsScene(onContactEnter, onContactExit, onContactStay, onTriggerEnter, onTriggerExit, onTriggerStay) {
864
862
  this._colliders = [];
865
863
  this._sphere = new BoundingSphere();
866
864
  this._box = new BoundingBox();
@@ -874,7 +872,7 @@ var /**
874
872
  this._onTriggerExit = onTriggerExit;
875
873
  this._onTriggerStay = onTriggerStay;
876
874
  }
877
- var _proto = LitePhysicsManager.prototype;
875
+ var _proto = LitePhysicsScene.prototype;
878
876
  /**
879
877
  * {@inheritDoc IPhysicsManager.setGravity }
880
878
  */ _proto.setGravity = function setGravity(value) {
@@ -927,10 +925,10 @@ var /**
927
925
  var colliders = this._colliders;
928
926
  var hitResult;
929
927
  if (hit) {
930
- hitResult = LitePhysicsManager._hitResult;
928
+ hitResult = LitePhysicsScene._hitResult;
931
929
  }
932
930
  var isHit = false;
933
- var curHit = LitePhysicsManager._currentHit;
931
+ var curHit = LitePhysicsScene._currentHit;
934
932
  for(var i = 0, len = colliders.length; i < len; i++){
935
933
  var collider = colliders[i];
936
934
  if (collider._raycast(ray, onRaycast, curHit)) {
@@ -986,7 +984,7 @@ var /**
986
984
  for(var i = 0, len = myColliderShapes.length; i < len; i++){
987
985
  var myShape = myColliderShapes[i];
988
986
  if (_instanceof(myShape, LiteBoxColliderShape)) {
989
- LitePhysicsManager._updateWorldBox(myShape, this._box);
987
+ LitePhysicsScene._updateWorldBox(myShape, this._box);
990
988
  for(var j = 0, len1 = colliders.length; j < len1; j++){
991
989
  var colliderShape = colliders[j]._shapes;
992
990
  for(var k = 0, len2 = colliderShape.length; k < len2; k++){
@@ -1013,7 +1011,7 @@ var /**
1013
1011
  }
1014
1012
  }
1015
1013
  } else if (_instanceof(myShape, LiteSphereColliderShape)) {
1016
- LitePhysicsManager._upWorldSphere(myShape, this._sphere);
1014
+ LitePhysicsScene._upWorldSphere(myShape, this._sphere);
1017
1015
  for(var j1 = 0, len3 = colliders.length; j1 < len3; j1++){
1018
1016
  var colliderShape1 = colliders[j1]._shapes;
1019
1017
  for(var k1 = 0, len4 = colliderShape1.length; k1 < len4; k1++){
@@ -1065,24 +1063,24 @@ var /**
1065
1063
  };
1066
1064
  _proto._boxCollision = function _boxCollision(other) {
1067
1065
  if (_instanceof(other, LiteBoxColliderShape)) {
1068
- var box = LitePhysicsManager._tempBox;
1069
- LitePhysicsManager._updateWorldBox(other, box);
1066
+ var box = LitePhysicsScene._tempBox;
1067
+ LitePhysicsScene._updateWorldBox(other, box);
1070
1068
  return CollisionUtil.intersectsBoxAndBox(box, this._box);
1071
1069
  } else if (_instanceof(other, LiteSphereColliderShape)) {
1072
- var sphere = LitePhysicsManager._tempSphere;
1073
- LitePhysicsManager._upWorldSphere(other, sphere);
1070
+ var sphere = LitePhysicsScene._tempSphere;
1071
+ LitePhysicsScene._upWorldSphere(other, sphere);
1074
1072
  return CollisionUtil.intersectsSphereAndBox(sphere, this._box);
1075
1073
  }
1076
1074
  return false;
1077
1075
  };
1078
1076
  _proto._sphereCollision = function _sphereCollision(other) {
1079
1077
  if (_instanceof(other, LiteBoxColliderShape)) {
1080
- var box = LitePhysicsManager._tempBox;
1081
- LitePhysicsManager._updateWorldBox(other, box);
1078
+ var box = LitePhysicsScene._tempBox;
1079
+ LitePhysicsScene._updateWorldBox(other, box);
1082
1080
  return CollisionUtil.intersectsSphereAndBox(this._sphere, box);
1083
1081
  } else if (_instanceof(other, LiteSphereColliderShape)) {
1084
- var sphere = LitePhysicsManager._tempSphere;
1085
- LitePhysicsManager._upWorldSphere(other, sphere);
1082
+ var sphere = LitePhysicsScene._tempSphere;
1083
+ LitePhysicsScene._upWorldSphere(other, sphere);
1086
1084
  return CollisionUtil.intersectsSphereAndSphere(sphere, this._sphere);
1087
1085
  }
1088
1086
  return false;
@@ -1091,7 +1089,7 @@ var /**
1091
1089
  * Calculate the bounding box in world space from boxCollider.
1092
1090
  * @param boxCollider - The boxCollider to calculate
1093
1091
  * @param out - The calculated boundingBox
1094
- */ LitePhysicsManager._updateWorldBox = function _updateWorldBox(boxCollider, out) {
1092
+ */ LitePhysicsScene._updateWorldBox = function _updateWorldBox(boxCollider, out) {
1095
1093
  var mat = boxCollider._transform.worldMatrix;
1096
1094
  out.min.copyFrom(boxCollider._boxMin);
1097
1095
  out.max.copyFrom(boxCollider._boxMax);
@@ -1101,23 +1099,23 @@ var /**
1101
1099
  * Get the sphere info of the given sphere collider in world space.
1102
1100
  * @param sphereCollider - The given sphere collider
1103
1101
  * @param out - The calculated boundingSphere
1104
- */ LitePhysicsManager._upWorldSphere = function _upWorldSphere(sphereCollider, out) {
1102
+ */ LitePhysicsScene._upWorldSphere = function _upWorldSphere(sphereCollider, out) {
1105
1103
  Vector3.transformCoordinate(sphereCollider._transform.position, sphereCollider._transform.worldMatrix, out.center);
1106
1104
  out.radius = sphereCollider.worldRadius;
1107
1105
  };
1108
- return LitePhysicsManager;
1106
+ return LitePhysicsScene;
1109
1107
  }();
1110
1108
  (function() {
1111
- LitePhysicsManager._tempSphere = new BoundingSphere();
1109
+ LitePhysicsScene._tempSphere = new BoundingSphere();
1112
1110
  })();
1113
1111
  (function() {
1114
- LitePhysicsManager._tempBox = new BoundingBox();
1112
+ LitePhysicsScene._tempBox = new BoundingBox();
1115
1113
  })();
1116
1114
  (function() {
1117
- LitePhysicsManager._currentHit = new LiteHitResult();
1115
+ LitePhysicsScene._currentHit = new LiteHitResult();
1118
1116
  })();
1119
1117
  (function() {
1120
- LitePhysicsManager._hitResult = new LiteHitResult();
1118
+ LitePhysicsScene._hitResult = new LiteHitResult();
1121
1119
  })();
1122
1120
  var /**
1123
1121
  * Physics state
@@ -1135,42 +1133,6 @@ var /**
1135
1133
  this.index2 = index2;
1136
1134
  };
1137
1135
 
1138
- /**
1139
- * Physics material describes how to handle colliding objects (friction, bounciness).
1140
- */ var LitePhysicsMaterial = /*#__PURE__*/ function() {
1141
- function LitePhysicsMaterial(staticFriction, dynamicFriction, bounciness, frictionCombine, bounceCombine) {}
1142
- var _proto = LitePhysicsMaterial.prototype;
1143
- /**
1144
- * {@inheritDoc IPhysicsMaterial.setBounciness }
1145
- */ _proto.setBounciness = function setBounciness(value) {
1146
- throw "Physics-lite don't support physics material. Use Physics-PhysX instead!";
1147
- };
1148
- /**
1149
- * {@inheritDoc IPhysicsMaterial.setDynamicFriction }
1150
- */ _proto.setDynamicFriction = function setDynamicFriction(value) {
1151
- throw "Physics-lite don't support physics material. Use Physics-PhysX instead!";
1152
- };
1153
- /**
1154
- * {@inheritDoc IPhysicsMaterial.setStaticFriction }
1155
- */ _proto.setStaticFriction = function setStaticFriction(value) {
1156
- throw "Physics-lite don't support physics material. Use Physics-PhysX instead!";
1157
- };
1158
- /**
1159
- * {@inheritDoc IPhysicsMaterial.setBounceCombine }
1160
- */ _proto.setBounceCombine = function setBounceCombine(value) {
1161
- throw "Physics-lite don't support physics material. Use Physics-PhysX instead!";
1162
- };
1163
- /**
1164
- * {@inheritDoc IPhysicsMaterial.setFrictionCombine }
1165
- */ _proto.setFrictionCombine = function setFrictionCombine(value) {
1166
- throw "Physics-lite don't support physics material. Use Physics-PhysX instead!";
1167
- };
1168
- /**
1169
- * {@inheritDoc IPhysicsMaterial.destroy }
1170
- */ _proto.destroy = function destroy() {};
1171
- return LitePhysicsMaterial;
1172
- }();
1173
-
1174
1136
  /**
1175
1137
  * A static collider component that will not move.
1176
1138
  * @remarks Mostly used for object which always stays at the same place and never moves around.
@@ -1186,81 +1148,81 @@ var /**
1186
1148
  return LiteStaticCollider;
1187
1149
  }(LiteCollider);
1188
1150
 
1189
- /**
1190
- * Static interface implement decorator.
1191
- * https://stackoverflow.com/questions/13955157/how-to-define-static-property-in-typescript-interface
1192
- */ function StaticInterfaceImplement() {
1193
- return function(constructor) {
1194
- };
1195
- }
1196
-
1197
1151
  var LitePhysics = /*#__PURE__*/ function() {
1198
1152
  function LitePhysics() {}
1153
+ var _proto = LitePhysics.prototype;
1154
+ /**
1155
+ * {@inheritDoc IPhysics.initialize }
1156
+ */ _proto.initialize = function initialize() {
1157
+ return Promise.resolve();
1158
+ };
1199
1159
  /**
1200
1160
  * {@inheritDoc IPhysics.createPhysicsManager }
1201
- */ LitePhysics.createPhysicsManager = function createPhysicsManager(onContactBegin, onContactEnd, onContactPersist, onTriggerBegin, onTriggerEnd, onTriggerPersist) {
1202
- return new LitePhysicsManager(onContactBegin, onContactEnd, onContactPersist, onTriggerBegin, onTriggerEnd, onTriggerPersist);
1161
+ */ _proto.createPhysicsManager = function createPhysicsManager() {
1162
+ return null;
1163
+ };
1164
+ /**
1165
+ * {@inheritDoc IPhysics.createPhysicsScene }
1166
+ */ _proto.createPhysicsScene = function createPhysicsScene(physicsManager, onContactBegin, onContactEnd, onContactPersist, onTriggerBegin, onTriggerEnd, onTriggerPersist) {
1167
+ return new LitePhysicsScene(onContactBegin, onContactEnd, onContactPersist, onTriggerBegin, onTriggerEnd, onTriggerPersist);
1203
1168
  };
1204
1169
  /**
1205
1170
  * {@inheritDoc IPhysics.createStaticCollider }
1206
- */ LitePhysics.createStaticCollider = function createStaticCollider(position, rotation) {
1171
+ */ _proto.createStaticCollider = function createStaticCollider(position, rotation) {
1207
1172
  return new LiteStaticCollider(position, rotation);
1208
1173
  };
1209
1174
  /**
1210
1175
  * {@inheritDoc IPhysics.createDynamicCollider }
1211
- */ LitePhysics.createDynamicCollider = function createDynamicCollider(position, rotation) {
1176
+ */ _proto.createDynamicCollider = function createDynamicCollider(position, rotation) {
1212
1177
  return new LiteDynamicCollider(position, rotation);
1213
1178
  };
1214
1179
  /**
1215
1180
  * {@inheritDoc IPhysics.createCharacterController }
1216
- */ LitePhysics.createCharacterController = function createCharacterController() {
1181
+ */ _proto.createCharacterController = function createCharacterController() {
1217
1182
  throw "Physics-lite don't support createCharacterController. Use Physics-PhysX instead!";
1218
1183
  };
1219
1184
  /**
1220
1185
  * {@inheritDoc IPhysics.createPhysicsMaterial }
1221
- */ LitePhysics.createPhysicsMaterial = function createPhysicsMaterial(staticFriction, dynamicFriction, bounciness, frictionCombine, bounceCombine) {
1186
+ */ _proto.createPhysicsMaterial = function createPhysicsMaterial(staticFriction, dynamicFriction, bounciness, frictionCombine, bounceCombine) {
1222
1187
  return new LitePhysicsMaterial(staticFriction, dynamicFriction, bounciness, frictionCombine, bounceCombine);
1223
1188
  };
1224
1189
  /**
1225
1190
  * {@inheritDoc IPhysics.createBoxColliderShape }
1226
- */ LitePhysics.createBoxColliderShape = function createBoxColliderShape(uniqueID, size, material) {
1191
+ */ _proto.createBoxColliderShape = function createBoxColliderShape(uniqueID, size, material) {
1227
1192
  return new LiteBoxColliderShape(uniqueID, size, material);
1228
1193
  };
1229
1194
  /**
1230
1195
  * {@inheritDoc IPhysics.createSphereColliderShape }
1231
- */ LitePhysics.createSphereColliderShape = function createSphereColliderShape(uniqueID, radius, material) {
1196
+ */ _proto.createSphereColliderShape = function createSphereColliderShape(uniqueID, radius, material) {
1232
1197
  return new LiteSphereColliderShape(uniqueID, radius, material);
1233
1198
  };
1234
1199
  /**
1235
1200
  * {@inheritDoc IPhysics.createPlaneColliderShape }
1236
- */ LitePhysics.createPlaneColliderShape = function createPlaneColliderShape(uniqueID, material) {
1201
+ */ _proto.createPlaneColliderShape = function createPlaneColliderShape(uniqueID, material) {
1237
1202
  throw "Physics-lite don't support PlaneColliderShape. Use Physics-PhysX instead!";
1238
1203
  };
1239
1204
  /**
1240
1205
  * {@inheritDoc IPhysics.createCapsuleColliderShape }
1241
- */ LitePhysics.createCapsuleColliderShape = function createCapsuleColliderShape(uniqueID, radius, height, material) {
1206
+ */ _proto.createCapsuleColliderShape = function createCapsuleColliderShape(uniqueID, radius, height, material) {
1242
1207
  throw "Physics-lite don't support CapsuleColliderShape. Use Physics-PhysX instead!";
1243
1208
  };
1244
1209
  /**
1245
1210
  * {@inheritDoc IPhysics.createFixedJoint }
1246
- */ LitePhysics.createFixedJoint = function createFixedJoint(collider) {
1211
+ */ _proto.createFixedJoint = function createFixedJoint(collider) {
1247
1212
  throw "Physics-lite don't support CapsuleColliderShape. Use Physics-PhysX instead!";
1248
1213
  };
1249
1214
  /**
1250
1215
  * {@inheritDoc IPhysics.createHingeJoint }
1251
- */ LitePhysics.createHingeJoint = function createHingeJoint(collider) {
1216
+ */ _proto.createHingeJoint = function createHingeJoint(collider) {
1252
1217
  throw "Physics-lite don't support CapsuleColliderShape. Use Physics-PhysX instead!";
1253
1218
  };
1254
1219
  /**
1255
1220
  * {@inheritDoc IPhysics.createSpringJoint }
1256
- */ LitePhysics.createSpringJoint = function createSpringJoint(collider) {
1221
+ */ _proto.createSpringJoint = function createSpringJoint(collider) {
1257
1222
  throw "Physics-lite don't support CapsuleColliderShape. Use Physics-PhysX instead!";
1258
1223
  };
1259
1224
  return LitePhysics;
1260
1225
  }();
1261
- LitePhysics = __decorate([
1262
- StaticInterfaceImplement()
1263
- ], LitePhysics);
1264
1226
 
1265
1227
  export { LitePhysics };
1266
1228
  //# sourceMappingURL=module.js.map