@galacean/engine-physics-lite 0.0.0-experimental-ktx2.0 → 0.0.0-experimental-double11.1
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 +70 -77
- package/dist/browser.min.js +1 -1
- package/dist/main.js +70 -77
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +70 -77
- package/dist/module.js +70 -77
- package/dist/module.js.map +1 -1
- package/package.json +4 -4
- package/types/LitePhysics.d.ts +2 -8
- package/types/LitePhysicsManager.d.ts +77 -1
package/dist/miniprogram.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,
|
|
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
|
|
865
|
-
function
|
|
828
|
+
*/ var LitePhysicsManager = /*#__PURE__*/ function() {
|
|
829
|
+
function LitePhysicsManager(onContactEnter, onContactExit, onContactStay, onTriggerEnter, onTriggerExit, onTriggerStay) {
|
|
866
830
|
this._colliders = [];
|
|
867
831
|
this._sphere = new miniprogram.BoundingSphere();
|
|
868
832
|
this._box = new miniprogram.BoundingBox();
|
|
@@ -876,7 +840,7 @@ var /**
|
|
|
876
840
|
this._onTriggerExit = onTriggerExit;
|
|
877
841
|
this._onTriggerStay = onTriggerStay;
|
|
878
842
|
}
|
|
879
|
-
var _proto =
|
|
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 =
|
|
896
|
+
hitResult = LitePhysicsManager._hitResult;
|
|
933
897
|
}
|
|
934
898
|
var isHit = false;
|
|
935
|
-
var curHit =
|
|
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 (
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 =
|
|
1071
|
-
|
|
1032
|
+
var box = LitePhysicsManager._tempBox;
|
|
1033
|
+
LitePhysicsManager._updateWorldBox(other, box);
|
|
1072
1034
|
return miniprogram.CollisionUtil.intersectsBoxAndBox(box, this._box);
|
|
1073
1035
|
} else if (_instanceof(other, LiteSphereColliderShape)) {
|
|
1074
|
-
var sphere =
|
|
1075
|
-
|
|
1036
|
+
var sphere = LitePhysicsManager._tempSphere;
|
|
1037
|
+
LitePhysicsManager._upWorldSphere(other, sphere);
|
|
1076
1038
|
return miniprogram.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 =
|
|
1083
|
-
|
|
1044
|
+
var box = LitePhysicsManager._tempBox;
|
|
1045
|
+
LitePhysicsManager._updateWorldBox(other, box);
|
|
1084
1046
|
return miniprogram.CollisionUtil.intersectsSphereAndBox(this._sphere, box);
|
|
1085
1047
|
} else if (_instanceof(other, LiteSphereColliderShape)) {
|
|
1086
|
-
var sphere =
|
|
1087
|
-
|
|
1048
|
+
var sphere = LitePhysicsManager._tempSphere;
|
|
1049
|
+
LitePhysicsManager._upWorldSphere(other, sphere);
|
|
1088
1050
|
return miniprogram.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
|
-
*/
|
|
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
|
-
*/
|
|
1068
|
+
*/ LitePhysicsManager._upWorldSphere = function _upWorldSphere(sphereCollider, out) {
|
|
1107
1069
|
miniprogram.Vector3.transformCoordinate(sphereCollider._transform.position, sphereCollider._transform.worldMatrix, out.center);
|
|
1108
1070
|
out.radius = sphereCollider.worldRadius;
|
|
1109
1071
|
};
|
|
1110
|
-
return
|
|
1072
|
+
return LitePhysicsManager;
|
|
1111
1073
|
}();
|
|
1112
1074
|
(function() {
|
|
1113
|
-
|
|
1075
|
+
LitePhysicsManager._tempSphere = new miniprogram.BoundingSphere();
|
|
1114
1076
|
})();
|
|
1115
1077
|
(function() {
|
|
1116
|
-
|
|
1078
|
+
LitePhysicsManager._tempBox = new miniprogram.BoundingBox();
|
|
1117
1079
|
})();
|
|
1118
1080
|
(function() {
|
|
1119
|
-
|
|
1081
|
+
LitePhysicsManager._currentHit = new LiteHitResult();
|
|
1120
1082
|
})();
|
|
1121
1083
|
(function() {
|
|
1122
|
-
|
|
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
|
|
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 }
|
package/dist/module.js
CHANGED
|
@@ -649,42 +649,6 @@ var /**
|
|
|
649
649
|
return LiteDynamicCollider;
|
|
650
650
|
}(LiteCollider);
|
|
651
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
|
-
|
|
688
652
|
/**
|
|
689
653
|
* High-performance unordered array, delete uses exchange method to improve performance, internal capacity only increases.
|
|
690
654
|
*/ var DisorderedArray = /*#__PURE__*/ function() {
|
|
@@ -825,7 +789,7 @@ var /**
|
|
|
825
789
|
/**
|
|
826
790
|
* {@inheritDoc IColliderShape.setWorldScale }
|
|
827
791
|
*/ _proto.setWorldScale = function setWorldScale(scale) {
|
|
828
|
-
this._maxScale = Math.max(scale.x,
|
|
792
|
+
this._maxScale = Math.max(scale.x, scale.y, scale.z);
|
|
829
793
|
};
|
|
830
794
|
/**
|
|
831
795
|
* @internal
|
|
@@ -857,8 +821,8 @@ var /**
|
|
|
857
821
|
|
|
858
822
|
/**
|
|
859
823
|
* A manager is a collection of colliders and constraints which can interact.
|
|
860
|
-
*/ var
|
|
861
|
-
function
|
|
824
|
+
*/ var LitePhysicsManager = /*#__PURE__*/ function() {
|
|
825
|
+
function LitePhysicsManager(onContactEnter, onContactExit, onContactStay, onTriggerEnter, onTriggerExit, onTriggerStay) {
|
|
862
826
|
this._colliders = [];
|
|
863
827
|
this._sphere = new BoundingSphere();
|
|
864
828
|
this._box = new BoundingBox();
|
|
@@ -872,7 +836,7 @@ var /**
|
|
|
872
836
|
this._onTriggerExit = onTriggerExit;
|
|
873
837
|
this._onTriggerStay = onTriggerStay;
|
|
874
838
|
}
|
|
875
|
-
var _proto =
|
|
839
|
+
var _proto = LitePhysicsManager.prototype;
|
|
876
840
|
/**
|
|
877
841
|
* {@inheritDoc IPhysicsManager.setGravity }
|
|
878
842
|
*/ _proto.setGravity = function setGravity(value) {
|
|
@@ -925,25 +889,23 @@ var /**
|
|
|
925
889
|
var colliders = this._colliders;
|
|
926
890
|
var hitResult;
|
|
927
891
|
if (hit) {
|
|
928
|
-
hitResult =
|
|
892
|
+
hitResult = LitePhysicsManager._hitResult;
|
|
929
893
|
}
|
|
930
894
|
var isHit = false;
|
|
931
|
-
var curHit =
|
|
895
|
+
var curHit = LitePhysicsManager._currentHit;
|
|
932
896
|
for(var i = 0, len = colliders.length; i < len; i++){
|
|
933
897
|
var collider = colliders[i];
|
|
934
|
-
if (collider._raycast(ray, onRaycast, curHit)) {
|
|
898
|
+
if (collider._raycast(ray, onRaycast, curHit) && curHit.distance < distance) {
|
|
935
899
|
isHit = true;
|
|
936
|
-
if (
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
return true;
|
|
944
|
-
}
|
|
945
|
-
distance = curHit.distance;
|
|
900
|
+
if (hitResult) {
|
|
901
|
+
hitResult.normal.copyFrom(curHit.normal);
|
|
902
|
+
hitResult.point.copyFrom(curHit.point);
|
|
903
|
+
hitResult.distance = curHit.distance;
|
|
904
|
+
hitResult.shapeID = curHit.shapeID;
|
|
905
|
+
} else {
|
|
906
|
+
return true;
|
|
946
907
|
}
|
|
908
|
+
distance = curHit.distance;
|
|
947
909
|
}
|
|
948
910
|
}
|
|
949
911
|
if (!isHit && hitResult) {
|
|
@@ -984,7 +946,7 @@ var /**
|
|
|
984
946
|
for(var i = 0, len = myColliderShapes.length; i < len; i++){
|
|
985
947
|
var myShape = myColliderShapes[i];
|
|
986
948
|
if (_instanceof(myShape, LiteBoxColliderShape)) {
|
|
987
|
-
|
|
949
|
+
LitePhysicsManager._updateWorldBox(myShape, this._box);
|
|
988
950
|
for(var j = 0, len1 = colliders.length; j < len1; j++){
|
|
989
951
|
var colliderShape = colliders[j]._shapes;
|
|
990
952
|
for(var k = 0, len2 = colliderShape.length; k < len2; k++){
|
|
@@ -1011,7 +973,7 @@ var /**
|
|
|
1011
973
|
}
|
|
1012
974
|
}
|
|
1013
975
|
} else if (_instanceof(myShape, LiteSphereColliderShape)) {
|
|
1014
|
-
|
|
976
|
+
LitePhysicsManager._upWorldSphere(myShape, this._sphere);
|
|
1015
977
|
for(var j1 = 0, len3 = colliders.length; j1 < len3; j1++){
|
|
1016
978
|
var colliderShape1 = colliders[j1]._shapes;
|
|
1017
979
|
for(var k1 = 0, len4 = colliderShape1.length; k1 < len4; k1++){
|
|
@@ -1063,24 +1025,24 @@ var /**
|
|
|
1063
1025
|
};
|
|
1064
1026
|
_proto._boxCollision = function _boxCollision(other) {
|
|
1065
1027
|
if (_instanceof(other, LiteBoxColliderShape)) {
|
|
1066
|
-
var box =
|
|
1067
|
-
|
|
1028
|
+
var box = LitePhysicsManager._tempBox;
|
|
1029
|
+
LitePhysicsManager._updateWorldBox(other, box);
|
|
1068
1030
|
return CollisionUtil.intersectsBoxAndBox(box, this._box);
|
|
1069
1031
|
} else if (_instanceof(other, LiteSphereColliderShape)) {
|
|
1070
|
-
var sphere =
|
|
1071
|
-
|
|
1032
|
+
var sphere = LitePhysicsManager._tempSphere;
|
|
1033
|
+
LitePhysicsManager._upWorldSphere(other, sphere);
|
|
1072
1034
|
return CollisionUtil.intersectsSphereAndBox(sphere, this._box);
|
|
1073
1035
|
}
|
|
1074
1036
|
return false;
|
|
1075
1037
|
};
|
|
1076
1038
|
_proto._sphereCollision = function _sphereCollision(other) {
|
|
1077
1039
|
if (_instanceof(other, LiteBoxColliderShape)) {
|
|
1078
|
-
var box =
|
|
1079
|
-
|
|
1040
|
+
var box = LitePhysicsManager._tempBox;
|
|
1041
|
+
LitePhysicsManager._updateWorldBox(other, box);
|
|
1080
1042
|
return CollisionUtil.intersectsSphereAndBox(this._sphere, box);
|
|
1081
1043
|
} else if (_instanceof(other, LiteSphereColliderShape)) {
|
|
1082
|
-
var sphere =
|
|
1083
|
-
|
|
1044
|
+
var sphere = LitePhysicsManager._tempSphere;
|
|
1045
|
+
LitePhysicsManager._upWorldSphere(other, sphere);
|
|
1084
1046
|
return CollisionUtil.intersectsSphereAndSphere(sphere, this._sphere);
|
|
1085
1047
|
}
|
|
1086
1048
|
return false;
|
|
@@ -1089,7 +1051,7 @@ var /**
|
|
|
1089
1051
|
* Calculate the bounding box in world space from boxCollider.
|
|
1090
1052
|
* @param boxCollider - The boxCollider to calculate
|
|
1091
1053
|
* @param out - The calculated boundingBox
|
|
1092
|
-
*/
|
|
1054
|
+
*/ LitePhysicsManager._updateWorldBox = function _updateWorldBox(boxCollider, out) {
|
|
1093
1055
|
var mat = boxCollider._transform.worldMatrix;
|
|
1094
1056
|
out.min.copyFrom(boxCollider._boxMin);
|
|
1095
1057
|
out.max.copyFrom(boxCollider._boxMax);
|
|
@@ -1099,23 +1061,23 @@ var /**
|
|
|
1099
1061
|
* Get the sphere info of the given sphere collider in world space.
|
|
1100
1062
|
* @param sphereCollider - The given sphere collider
|
|
1101
1063
|
* @param out - The calculated boundingSphere
|
|
1102
|
-
*/
|
|
1064
|
+
*/ LitePhysicsManager._upWorldSphere = function _upWorldSphere(sphereCollider, out) {
|
|
1103
1065
|
Vector3.transformCoordinate(sphereCollider._transform.position, sphereCollider._transform.worldMatrix, out.center);
|
|
1104
1066
|
out.radius = sphereCollider.worldRadius;
|
|
1105
1067
|
};
|
|
1106
|
-
return
|
|
1068
|
+
return LitePhysicsManager;
|
|
1107
1069
|
}();
|
|
1108
1070
|
(function() {
|
|
1109
|
-
|
|
1071
|
+
LitePhysicsManager._tempSphere = new BoundingSphere();
|
|
1110
1072
|
})();
|
|
1111
1073
|
(function() {
|
|
1112
|
-
|
|
1074
|
+
LitePhysicsManager._tempBox = new BoundingBox();
|
|
1113
1075
|
})();
|
|
1114
1076
|
(function() {
|
|
1115
|
-
|
|
1077
|
+
LitePhysicsManager._currentHit = new LiteHitResult();
|
|
1116
1078
|
})();
|
|
1117
1079
|
(function() {
|
|
1118
|
-
|
|
1080
|
+
LitePhysicsManager._hitResult = new LiteHitResult();
|
|
1119
1081
|
})();
|
|
1120
1082
|
var /**
|
|
1121
1083
|
* Physics state
|
|
@@ -1133,6 +1095,42 @@ var /**
|
|
|
1133
1095
|
this.index2 = index2;
|
|
1134
1096
|
};
|
|
1135
1097
|
|
|
1098
|
+
/**
|
|
1099
|
+
* Physics material describes how to handle colliding objects (friction, bounciness).
|
|
1100
|
+
*/ var LitePhysicsMaterial = /*#__PURE__*/ function() {
|
|
1101
|
+
function LitePhysicsMaterial(staticFriction, dynamicFriction, bounciness, frictionCombine, bounceCombine) {}
|
|
1102
|
+
var _proto = LitePhysicsMaterial.prototype;
|
|
1103
|
+
/**
|
|
1104
|
+
* {@inheritDoc IPhysicsMaterial.setBounciness }
|
|
1105
|
+
*/ _proto.setBounciness = function setBounciness(value) {
|
|
1106
|
+
throw "Physics-lite don't support physics material. Use Physics-PhysX instead!";
|
|
1107
|
+
};
|
|
1108
|
+
/**
|
|
1109
|
+
* {@inheritDoc IPhysicsMaterial.setDynamicFriction }
|
|
1110
|
+
*/ _proto.setDynamicFriction = function setDynamicFriction(value) {
|
|
1111
|
+
throw "Physics-lite don't support physics material. Use Physics-PhysX instead!";
|
|
1112
|
+
};
|
|
1113
|
+
/**
|
|
1114
|
+
* {@inheritDoc IPhysicsMaterial.setStaticFriction }
|
|
1115
|
+
*/ _proto.setStaticFriction = function setStaticFriction(value) {
|
|
1116
|
+
throw "Physics-lite don't support physics material. Use Physics-PhysX instead!";
|
|
1117
|
+
};
|
|
1118
|
+
/**
|
|
1119
|
+
* {@inheritDoc IPhysicsMaterial.setBounceCombine }
|
|
1120
|
+
*/ _proto.setBounceCombine = function setBounceCombine(value) {
|
|
1121
|
+
throw "Physics-lite don't support physics material. Use Physics-PhysX instead!";
|
|
1122
|
+
};
|
|
1123
|
+
/**
|
|
1124
|
+
* {@inheritDoc IPhysicsMaterial.setFrictionCombine }
|
|
1125
|
+
*/ _proto.setFrictionCombine = function setFrictionCombine(value) {
|
|
1126
|
+
throw "Physics-lite don't support physics material. Use Physics-PhysX instead!";
|
|
1127
|
+
};
|
|
1128
|
+
/**
|
|
1129
|
+
* {@inheritDoc IPhysicsMaterial.destroy }
|
|
1130
|
+
*/ _proto.destroy = function destroy() {};
|
|
1131
|
+
return LitePhysicsMaterial;
|
|
1132
|
+
}();
|
|
1133
|
+
|
|
1136
1134
|
/**
|
|
1137
1135
|
* A static collider component that will not move.
|
|
1138
1136
|
* @remarks Mostly used for object which always stays at the same place and never moves around.
|
|
@@ -1158,13 +1156,8 @@ var LitePhysics = /*#__PURE__*/ function() {
|
|
|
1158
1156
|
};
|
|
1159
1157
|
/**
|
|
1160
1158
|
* {@inheritDoc IPhysics.createPhysicsManager }
|
|
1161
|
-
*/ _proto.createPhysicsManager = function createPhysicsManager() {
|
|
1162
|
-
return
|
|
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);
|
|
1159
|
+
*/ _proto.createPhysicsManager = function createPhysicsManager(onContactBegin, onContactEnd, onContactPersist, onTriggerBegin, onTriggerEnd, onTriggerPersist) {
|
|
1160
|
+
return new LitePhysicsManager(onContactBegin, onContactEnd, onContactPersist, onTriggerBegin, onTriggerEnd, onTriggerPersist);
|
|
1168
1161
|
};
|
|
1169
1162
|
/**
|
|
1170
1163
|
* {@inheritDoc IPhysics.createStaticCollider }
|