@galacean/engine-physics-lite 1.0.0-beta.9 → 1.1.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.js +65 -60
- package/dist/browser.min.js +1 -1
- package/dist/main.js +65 -60
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +11531 -11144
- package/dist/module.js +65 -60
- package/dist/module.js.map +1 -1
- package/package.json +4 -4
- package/types/LitePhysics.d.ts +8 -2
- package/types/LitePhysicsManager.d.ts +1 -77
- package/types/LitePhysicsScene.d.ts +79 -0
package/dist/module.js
CHANGED
|
@@ -649,6 +649,42 @@ 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
|
+
|
|
652
688
|
/**
|
|
653
689
|
* High-performance unordered array, delete uses exchange method to improve performance, internal capacity only increases.
|
|
654
690
|
*/ var DisorderedArray = /*#__PURE__*/ function() {
|
|
@@ -821,8 +857,8 @@ var /**
|
|
|
821
857
|
|
|
822
858
|
/**
|
|
823
859
|
* A manager is a collection of colliders and constraints which can interact.
|
|
824
|
-
*/ var
|
|
825
|
-
function
|
|
860
|
+
*/ var LitePhysicsScene = /*#__PURE__*/ function() {
|
|
861
|
+
function LitePhysicsScene(onContactEnter, onContactExit, onContactStay, onTriggerEnter, onTriggerExit, onTriggerStay) {
|
|
826
862
|
this._colliders = [];
|
|
827
863
|
this._sphere = new BoundingSphere();
|
|
828
864
|
this._box = new BoundingBox();
|
|
@@ -836,7 +872,7 @@ var /**
|
|
|
836
872
|
this._onTriggerExit = onTriggerExit;
|
|
837
873
|
this._onTriggerStay = onTriggerStay;
|
|
838
874
|
}
|
|
839
|
-
var _proto =
|
|
875
|
+
var _proto = LitePhysicsScene.prototype;
|
|
840
876
|
/**
|
|
841
877
|
* {@inheritDoc IPhysicsManager.setGravity }
|
|
842
878
|
*/ _proto.setGravity = function setGravity(value) {
|
|
@@ -889,10 +925,10 @@ var /**
|
|
|
889
925
|
var colliders = this._colliders;
|
|
890
926
|
var hitResult;
|
|
891
927
|
if (hit) {
|
|
892
|
-
hitResult =
|
|
928
|
+
hitResult = LitePhysicsScene._hitResult;
|
|
893
929
|
}
|
|
894
930
|
var isHit = false;
|
|
895
|
-
var curHit =
|
|
931
|
+
var curHit = LitePhysicsScene._currentHit;
|
|
896
932
|
for(var i = 0, len = colliders.length; i < len; i++){
|
|
897
933
|
var collider = colliders[i];
|
|
898
934
|
if (collider._raycast(ray, onRaycast, curHit)) {
|
|
@@ -948,7 +984,7 @@ var /**
|
|
|
948
984
|
for(var i = 0, len = myColliderShapes.length; i < len; i++){
|
|
949
985
|
var myShape = myColliderShapes[i];
|
|
950
986
|
if (_instanceof(myShape, LiteBoxColliderShape)) {
|
|
951
|
-
|
|
987
|
+
LitePhysicsScene._updateWorldBox(myShape, this._box);
|
|
952
988
|
for(var j = 0, len1 = colliders.length; j < len1; j++){
|
|
953
989
|
var colliderShape = colliders[j]._shapes;
|
|
954
990
|
for(var k = 0, len2 = colliderShape.length; k < len2; k++){
|
|
@@ -975,7 +1011,7 @@ var /**
|
|
|
975
1011
|
}
|
|
976
1012
|
}
|
|
977
1013
|
} else if (_instanceof(myShape, LiteSphereColliderShape)) {
|
|
978
|
-
|
|
1014
|
+
LitePhysicsScene._upWorldSphere(myShape, this._sphere);
|
|
979
1015
|
for(var j1 = 0, len3 = colliders.length; j1 < len3; j1++){
|
|
980
1016
|
var colliderShape1 = colliders[j1]._shapes;
|
|
981
1017
|
for(var k1 = 0, len4 = colliderShape1.length; k1 < len4; k1++){
|
|
@@ -1027,24 +1063,24 @@ var /**
|
|
|
1027
1063
|
};
|
|
1028
1064
|
_proto._boxCollision = function _boxCollision(other) {
|
|
1029
1065
|
if (_instanceof(other, LiteBoxColliderShape)) {
|
|
1030
|
-
var box =
|
|
1031
|
-
|
|
1066
|
+
var box = LitePhysicsScene._tempBox;
|
|
1067
|
+
LitePhysicsScene._updateWorldBox(other, box);
|
|
1032
1068
|
return CollisionUtil.intersectsBoxAndBox(box, this._box);
|
|
1033
1069
|
} else if (_instanceof(other, LiteSphereColliderShape)) {
|
|
1034
|
-
var sphere =
|
|
1035
|
-
|
|
1070
|
+
var sphere = LitePhysicsScene._tempSphere;
|
|
1071
|
+
LitePhysicsScene._upWorldSphere(other, sphere);
|
|
1036
1072
|
return CollisionUtil.intersectsSphereAndBox(sphere, this._box);
|
|
1037
1073
|
}
|
|
1038
1074
|
return false;
|
|
1039
1075
|
};
|
|
1040
1076
|
_proto._sphereCollision = function _sphereCollision(other) {
|
|
1041
1077
|
if (_instanceof(other, LiteBoxColliderShape)) {
|
|
1042
|
-
var box =
|
|
1043
|
-
|
|
1078
|
+
var box = LitePhysicsScene._tempBox;
|
|
1079
|
+
LitePhysicsScene._updateWorldBox(other, box);
|
|
1044
1080
|
return CollisionUtil.intersectsSphereAndBox(this._sphere, box);
|
|
1045
1081
|
} else if (_instanceof(other, LiteSphereColliderShape)) {
|
|
1046
|
-
var sphere =
|
|
1047
|
-
|
|
1082
|
+
var sphere = LitePhysicsScene._tempSphere;
|
|
1083
|
+
LitePhysicsScene._upWorldSphere(other, sphere);
|
|
1048
1084
|
return CollisionUtil.intersectsSphereAndSphere(sphere, this._sphere);
|
|
1049
1085
|
}
|
|
1050
1086
|
return false;
|
|
@@ -1053,7 +1089,7 @@ var /**
|
|
|
1053
1089
|
* Calculate the bounding box in world space from boxCollider.
|
|
1054
1090
|
* @param boxCollider - The boxCollider to calculate
|
|
1055
1091
|
* @param out - The calculated boundingBox
|
|
1056
|
-
*/
|
|
1092
|
+
*/ LitePhysicsScene._updateWorldBox = function _updateWorldBox(boxCollider, out) {
|
|
1057
1093
|
var mat = boxCollider._transform.worldMatrix;
|
|
1058
1094
|
out.min.copyFrom(boxCollider._boxMin);
|
|
1059
1095
|
out.max.copyFrom(boxCollider._boxMax);
|
|
@@ -1063,23 +1099,23 @@ var /**
|
|
|
1063
1099
|
* Get the sphere info of the given sphere collider in world space.
|
|
1064
1100
|
* @param sphereCollider - The given sphere collider
|
|
1065
1101
|
* @param out - The calculated boundingSphere
|
|
1066
|
-
*/
|
|
1102
|
+
*/ LitePhysicsScene._upWorldSphere = function _upWorldSphere(sphereCollider, out) {
|
|
1067
1103
|
Vector3.transformCoordinate(sphereCollider._transform.position, sphereCollider._transform.worldMatrix, out.center);
|
|
1068
1104
|
out.radius = sphereCollider.worldRadius;
|
|
1069
1105
|
};
|
|
1070
|
-
return
|
|
1106
|
+
return LitePhysicsScene;
|
|
1071
1107
|
}();
|
|
1072
1108
|
(function() {
|
|
1073
|
-
|
|
1109
|
+
LitePhysicsScene._tempSphere = new BoundingSphere();
|
|
1074
1110
|
})();
|
|
1075
1111
|
(function() {
|
|
1076
|
-
|
|
1112
|
+
LitePhysicsScene._tempBox = new BoundingBox();
|
|
1077
1113
|
})();
|
|
1078
1114
|
(function() {
|
|
1079
|
-
|
|
1115
|
+
LitePhysicsScene._currentHit = new LiteHitResult();
|
|
1080
1116
|
})();
|
|
1081
1117
|
(function() {
|
|
1082
|
-
|
|
1118
|
+
LitePhysicsScene._hitResult = new LiteHitResult();
|
|
1083
1119
|
})();
|
|
1084
1120
|
var /**
|
|
1085
1121
|
* Physics state
|
|
@@ -1097,42 +1133,6 @@ var /**
|
|
|
1097
1133
|
this.index2 = index2;
|
|
1098
1134
|
};
|
|
1099
1135
|
|
|
1100
|
-
/**
|
|
1101
|
-
* Physics material describes how to handle colliding objects (friction, bounciness).
|
|
1102
|
-
*/ var LitePhysicsMaterial = /*#__PURE__*/ function() {
|
|
1103
|
-
function LitePhysicsMaterial(staticFriction, dynamicFriction, bounciness, frictionCombine, bounceCombine) {}
|
|
1104
|
-
var _proto = LitePhysicsMaterial.prototype;
|
|
1105
|
-
/**
|
|
1106
|
-
* {@inheritDoc IPhysicsMaterial.setBounciness }
|
|
1107
|
-
*/ _proto.setBounciness = function setBounciness(value) {
|
|
1108
|
-
throw "Physics-lite don't support physics material. Use Physics-PhysX instead!";
|
|
1109
|
-
};
|
|
1110
|
-
/**
|
|
1111
|
-
* {@inheritDoc IPhysicsMaterial.setDynamicFriction }
|
|
1112
|
-
*/ _proto.setDynamicFriction = function setDynamicFriction(value) {
|
|
1113
|
-
throw "Physics-lite don't support physics material. Use Physics-PhysX instead!";
|
|
1114
|
-
};
|
|
1115
|
-
/**
|
|
1116
|
-
* {@inheritDoc IPhysicsMaterial.setStaticFriction }
|
|
1117
|
-
*/ _proto.setStaticFriction = function setStaticFriction(value) {
|
|
1118
|
-
throw "Physics-lite don't support physics material. Use Physics-PhysX instead!";
|
|
1119
|
-
};
|
|
1120
|
-
/**
|
|
1121
|
-
* {@inheritDoc IPhysicsMaterial.setBounceCombine }
|
|
1122
|
-
*/ _proto.setBounceCombine = function setBounceCombine(value) {
|
|
1123
|
-
throw "Physics-lite don't support physics material. Use Physics-PhysX instead!";
|
|
1124
|
-
};
|
|
1125
|
-
/**
|
|
1126
|
-
* {@inheritDoc IPhysicsMaterial.setFrictionCombine }
|
|
1127
|
-
*/ _proto.setFrictionCombine = function setFrictionCombine(value) {
|
|
1128
|
-
throw "Physics-lite don't support physics material. Use Physics-PhysX instead!";
|
|
1129
|
-
};
|
|
1130
|
-
/**
|
|
1131
|
-
* {@inheritDoc IPhysicsMaterial.destroy }
|
|
1132
|
-
*/ _proto.destroy = function destroy() {};
|
|
1133
|
-
return LitePhysicsMaterial;
|
|
1134
|
-
}();
|
|
1135
|
-
|
|
1136
1136
|
/**
|
|
1137
1137
|
* A static collider component that will not move.
|
|
1138
1138
|
* @remarks Mostly used for object which always stays at the same place and never moves around.
|
|
@@ -1158,8 +1158,13 @@ var LitePhysics = /*#__PURE__*/ function() {
|
|
|
1158
1158
|
};
|
|
1159
1159
|
/**
|
|
1160
1160
|
* {@inheritDoc IPhysics.createPhysicsManager }
|
|
1161
|
-
*/ _proto.createPhysicsManager = function createPhysicsManager(
|
|
1162
|
-
return
|
|
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);
|
|
1163
1168
|
};
|
|
1164
1169
|
/**
|
|
1165
1170
|
* {@inheritDoc IPhysics.createStaticCollider }
|