@galacean/engine-physics-lite 0.0.0-experimental-1.3-xr.9 → 0.0.0-experimental-1.3-xr.10
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 +26 -77
- package/dist/browser.js.map +1 -1
- package/dist/browser.min.js +1 -1
- package/dist/browser.min.js.map +1 -1
- package/dist/main.js +26 -77
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +26 -77
- package/dist/module.js +26 -77
- package/dist/module.js.map +1 -1
- package/package.json +7 -4
- package/types/DisorderedArray.d.ts +0 -18
package/dist/miniprogram.js
CHANGED
|
@@ -706,52 +706,6 @@ var /**
|
|
|
706
706
|
return LitePhysicsMaterial;
|
|
707
707
|
}();
|
|
708
708
|
|
|
709
|
-
/**
|
|
710
|
-
* High-performance unordered array, delete uses exchange method to improve performance, internal capacity only increases.
|
|
711
|
-
*/ var DisorderedArray = /*#__PURE__*/ function() {
|
|
712
|
-
function DisorderedArray(count) {
|
|
713
|
-
if (count === void 0) count = 0;
|
|
714
|
-
this.length = 0;
|
|
715
|
-
this._elements = new Array(count);
|
|
716
|
-
}
|
|
717
|
-
var _proto = DisorderedArray.prototype;
|
|
718
|
-
_proto.add = function add(element) {
|
|
719
|
-
if (this.length === this._elements.length) this._elements.push(element);
|
|
720
|
-
else this._elements[this.length] = element;
|
|
721
|
-
this.length++;
|
|
722
|
-
};
|
|
723
|
-
_proto.delete = function _delete(element) {
|
|
724
|
-
//TODO: It can be optimized for custom binary search and other algorithms, currently this._elements>=this.length wastes performance.
|
|
725
|
-
var index = this._elements.indexOf(element);
|
|
726
|
-
this.deleteByIndex(index);
|
|
727
|
-
};
|
|
728
|
-
_proto.get = function get(index) {
|
|
729
|
-
if (index >= this.length) {
|
|
730
|
-
throw "Index is out of range.";
|
|
731
|
-
}
|
|
732
|
-
return this._elements[index];
|
|
733
|
-
};
|
|
734
|
-
/**
|
|
735
|
-
*
|
|
736
|
-
* @param index
|
|
737
|
-
* @returns The replaced item is used to reset its index.
|
|
738
|
-
*/ _proto.deleteByIndex = function deleteByIndex(index) {
|
|
739
|
-
var elements = this._elements;
|
|
740
|
-
var end = null;
|
|
741
|
-
var lastIndex = this.length - 1;
|
|
742
|
-
if (index !== lastIndex) {
|
|
743
|
-
end = elements[lastIndex];
|
|
744
|
-
elements[index] = end;
|
|
745
|
-
}
|
|
746
|
-
this.length--;
|
|
747
|
-
return end;
|
|
748
|
-
};
|
|
749
|
-
_proto.garbageCollection = function garbageCollection() {
|
|
750
|
-
this._elements.length = this.length;
|
|
751
|
-
};
|
|
752
|
-
return DisorderedArray;
|
|
753
|
-
}();
|
|
754
|
-
|
|
755
709
|
/**
|
|
756
710
|
* Structure used to get information back from a raycast or a sweep.
|
|
757
711
|
* @internal
|
|
@@ -889,7 +843,7 @@ var /**
|
|
|
889
843
|
this._dynamicColliders = [];
|
|
890
844
|
this._sphere = new miniprogram.BoundingSphere();
|
|
891
845
|
this._box = new miniprogram.BoundingBox();
|
|
892
|
-
this._currentEvents = new DisorderedArray();
|
|
846
|
+
this._currentEvents = new miniprogram.DisorderedArray();
|
|
893
847
|
this._eventMap = {};
|
|
894
848
|
this._eventPool = [];
|
|
895
849
|
this._onContactEnter = onContactEnter;
|
|
@@ -915,8 +869,7 @@ var /**
|
|
|
915
869
|
*/ _proto.removeColliderShape = function removeColliderShape(colliderShape) {
|
|
916
870
|
var _this = this, eventPool = _this._eventPool, currentEvents = _this._currentEvents, eventMap = _this._eventMap;
|
|
917
871
|
var id = colliderShape._id;
|
|
918
|
-
|
|
919
|
-
var event = currentEvents.get(i);
|
|
872
|
+
currentEvents.forEach(function(event, i) {
|
|
920
873
|
if (event.index1 == id) {
|
|
921
874
|
currentEvents.deleteByIndex(i);
|
|
922
875
|
eventPool.push(event);
|
|
@@ -926,7 +879,7 @@ var /**
|
|
|
926
879
|
// If the shape is big index, should clear from the small index shape subMap
|
|
927
880
|
eventMap[event.index1][id] = undefined;
|
|
928
881
|
}
|
|
929
|
-
}
|
|
882
|
+
});
|
|
930
883
|
delete eventMap[id];
|
|
931
884
|
};
|
|
932
885
|
/**
|
|
@@ -962,7 +915,10 @@ var /**
|
|
|
962
915
|
return this._raycast(ray, distance, onRaycast, this._staticColliders, hit) || this._raycast(ray, distance, onRaycast, this._dynamicColliders, hit);
|
|
963
916
|
} else {
|
|
964
917
|
var raycastStaticRes = this._raycast(ray, distance, onRaycast, this._staticColliders, hit);
|
|
965
|
-
|
|
918
|
+
if (raycastStaticRes) {
|
|
919
|
+
distance = LitePhysicsScene._currentHit.distance;
|
|
920
|
+
}
|
|
921
|
+
var raycastDynamicRes = this._raycast(ray, distance, onRaycast, this._dynamicColliders, hit);
|
|
966
922
|
var isHit = raycastStaticRes || raycastDynamicRes;
|
|
967
923
|
var hitResult = LitePhysicsScene._hitResult;
|
|
968
924
|
if (!isHit) {
|
|
@@ -1060,25 +1016,25 @@ var /**
|
|
|
1060
1016
|
}
|
|
1061
1017
|
};
|
|
1062
1018
|
_proto._fireEvent = function _fireEvent() {
|
|
1063
|
-
var _this = this
|
|
1064
|
-
|
|
1065
|
-
|
|
1019
|
+
var _this = this;
|
|
1020
|
+
var _this1 = this, eventPool = _this1._eventPool, currentEvents = _this1._currentEvents;
|
|
1021
|
+
currentEvents.forEach(function(event, i) {
|
|
1066
1022
|
if (!event.alreadyInvoked) {
|
|
1067
1023
|
if (event.state == 0) {
|
|
1068
|
-
|
|
1024
|
+
_this._onTriggerEnter(event.index1, event.index2);
|
|
1069
1025
|
event.alreadyInvoked = true;
|
|
1070
1026
|
} else if (event.state == 1) {
|
|
1071
|
-
|
|
1027
|
+
_this._onTriggerStay(event.index1, event.index2);
|
|
1072
1028
|
event.alreadyInvoked = true;
|
|
1073
1029
|
}
|
|
1074
1030
|
} else {
|
|
1075
1031
|
event.state = 2;
|
|
1076
|
-
|
|
1077
|
-
this._onTriggerExit(event.index1, event.index2);
|
|
1032
|
+
_this._eventMap[event.index1][event.index2] = undefined;
|
|
1078
1033
|
currentEvents.deleteByIndex(i);
|
|
1034
|
+
_this._onTriggerExit(event.index1, event.index2);
|
|
1079
1035
|
eventPool.push(event);
|
|
1080
1036
|
}
|
|
1081
|
-
}
|
|
1037
|
+
});
|
|
1082
1038
|
};
|
|
1083
1039
|
_proto._boxCollision = function _boxCollision(other) {
|
|
1084
1040
|
if (_instanceof(other, LiteBoxColliderShape)) {
|
|
@@ -1105,26 +1061,19 @@ var /**
|
|
|
1105
1061
|
return false;
|
|
1106
1062
|
};
|
|
1107
1063
|
_proto._raycast = function _raycast(ray, distance, onRaycast, colliders, hit) {
|
|
1108
|
-
var hitResult;
|
|
1109
|
-
if (hit) {
|
|
1110
|
-
hitResult = LitePhysicsScene._hitResult;
|
|
1111
|
-
}
|
|
1112
1064
|
var isHit = false;
|
|
1113
1065
|
var curHit = LitePhysicsScene._currentHit;
|
|
1114
1066
|
for(var i = 0, len = colliders.length; i < len; i++){
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
return true;
|
|
1126
|
-
}
|
|
1127
|
-
distance = curHit.distance;
|
|
1067
|
+
if (colliders[i]._raycast(ray, onRaycast, curHit) && curHit.distance < distance) {
|
|
1068
|
+
if (hit) {
|
|
1069
|
+
isHit = true;
|
|
1070
|
+
var hitResult = LitePhysicsScene._hitResult;
|
|
1071
|
+
hitResult.normal.copyFrom(curHit.normal);
|
|
1072
|
+
hitResult.point.copyFrom(curHit.point);
|
|
1073
|
+
hitResult.distance = distance = curHit.distance;
|
|
1074
|
+
hitResult.shapeID = curHit.shapeID;
|
|
1075
|
+
} else {
|
|
1076
|
+
return true;
|
|
1128
1077
|
}
|
|
1129
1078
|
}
|
|
1130
1079
|
}
|
|
@@ -1271,7 +1220,7 @@ var LitePhysics = /*#__PURE__*/ function() {
|
|
|
1271
1220
|
}();
|
|
1272
1221
|
|
|
1273
1222
|
//@ts-ignore
|
|
1274
|
-
var version = "0.0.0-experimental-1.3-xr.
|
|
1223
|
+
var version = "0.0.0-experimental-1.3-xr.10";
|
|
1275
1224
|
console.log("Galacean PhysicsLite version: " + version);
|
|
1276
1225
|
|
|
1277
1226
|
exports.LitePhysics = LitePhysics;
|
package/dist/module.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Utils, Ray, Vector3, Matrix, Quaternion, MathUtil, BoundingBox, BoundingSphere, CollisionUtil } from '@galacean/engine';
|
|
1
|
+
import { Utils, Ray, Vector3, Matrix, Quaternion, MathUtil, BoundingBox, BoundingSphere, DisorderedArray, CollisionUtil } from '@galacean/engine';
|
|
2
2
|
|
|
3
3
|
function _set_prototype_of(o, p) {
|
|
4
4
|
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
@@ -702,52 +702,6 @@ var /**
|
|
|
702
702
|
return LitePhysicsMaterial;
|
|
703
703
|
}();
|
|
704
704
|
|
|
705
|
-
/**
|
|
706
|
-
* High-performance unordered array, delete uses exchange method to improve performance, internal capacity only increases.
|
|
707
|
-
*/ var DisorderedArray = /*#__PURE__*/ function() {
|
|
708
|
-
function DisorderedArray(count) {
|
|
709
|
-
if (count === void 0) count = 0;
|
|
710
|
-
this.length = 0;
|
|
711
|
-
this._elements = new Array(count);
|
|
712
|
-
}
|
|
713
|
-
var _proto = DisorderedArray.prototype;
|
|
714
|
-
_proto.add = function add(element) {
|
|
715
|
-
if (this.length === this._elements.length) this._elements.push(element);
|
|
716
|
-
else this._elements[this.length] = element;
|
|
717
|
-
this.length++;
|
|
718
|
-
};
|
|
719
|
-
_proto.delete = function _delete(element) {
|
|
720
|
-
//TODO: It can be optimized for custom binary search and other algorithms, currently this._elements>=this.length wastes performance.
|
|
721
|
-
var index = this._elements.indexOf(element);
|
|
722
|
-
this.deleteByIndex(index);
|
|
723
|
-
};
|
|
724
|
-
_proto.get = function get(index) {
|
|
725
|
-
if (index >= this.length) {
|
|
726
|
-
throw "Index is out of range.";
|
|
727
|
-
}
|
|
728
|
-
return this._elements[index];
|
|
729
|
-
};
|
|
730
|
-
/**
|
|
731
|
-
*
|
|
732
|
-
* @param index
|
|
733
|
-
* @returns The replaced item is used to reset its index.
|
|
734
|
-
*/ _proto.deleteByIndex = function deleteByIndex(index) {
|
|
735
|
-
var elements = this._elements;
|
|
736
|
-
var end = null;
|
|
737
|
-
var lastIndex = this.length - 1;
|
|
738
|
-
if (index !== lastIndex) {
|
|
739
|
-
end = elements[lastIndex];
|
|
740
|
-
elements[index] = end;
|
|
741
|
-
}
|
|
742
|
-
this.length--;
|
|
743
|
-
return end;
|
|
744
|
-
};
|
|
745
|
-
_proto.garbageCollection = function garbageCollection() {
|
|
746
|
-
this._elements.length = this.length;
|
|
747
|
-
};
|
|
748
|
-
return DisorderedArray;
|
|
749
|
-
}();
|
|
750
|
-
|
|
751
705
|
/**
|
|
752
706
|
* Structure used to get information back from a raycast or a sweep.
|
|
753
707
|
* @internal
|
|
@@ -911,8 +865,7 @@ var /**
|
|
|
911
865
|
*/ _proto.removeColliderShape = function removeColliderShape(colliderShape) {
|
|
912
866
|
var _this = this, eventPool = _this._eventPool, currentEvents = _this._currentEvents, eventMap = _this._eventMap;
|
|
913
867
|
var id = colliderShape._id;
|
|
914
|
-
|
|
915
|
-
var event = currentEvents.get(i);
|
|
868
|
+
currentEvents.forEach(function(event, i) {
|
|
916
869
|
if (event.index1 == id) {
|
|
917
870
|
currentEvents.deleteByIndex(i);
|
|
918
871
|
eventPool.push(event);
|
|
@@ -922,7 +875,7 @@ var /**
|
|
|
922
875
|
// If the shape is big index, should clear from the small index shape subMap
|
|
923
876
|
eventMap[event.index1][id] = undefined;
|
|
924
877
|
}
|
|
925
|
-
}
|
|
878
|
+
});
|
|
926
879
|
delete eventMap[id];
|
|
927
880
|
};
|
|
928
881
|
/**
|
|
@@ -958,7 +911,10 @@ var /**
|
|
|
958
911
|
return this._raycast(ray, distance, onRaycast, this._staticColliders, hit) || this._raycast(ray, distance, onRaycast, this._dynamicColliders, hit);
|
|
959
912
|
} else {
|
|
960
913
|
var raycastStaticRes = this._raycast(ray, distance, onRaycast, this._staticColliders, hit);
|
|
961
|
-
|
|
914
|
+
if (raycastStaticRes) {
|
|
915
|
+
distance = LitePhysicsScene._currentHit.distance;
|
|
916
|
+
}
|
|
917
|
+
var raycastDynamicRes = this._raycast(ray, distance, onRaycast, this._dynamicColliders, hit);
|
|
962
918
|
var isHit = raycastStaticRes || raycastDynamicRes;
|
|
963
919
|
var hitResult = LitePhysicsScene._hitResult;
|
|
964
920
|
if (!isHit) {
|
|
@@ -1056,25 +1012,25 @@ var /**
|
|
|
1056
1012
|
}
|
|
1057
1013
|
};
|
|
1058
1014
|
_proto._fireEvent = function _fireEvent() {
|
|
1059
|
-
var _this = this
|
|
1060
|
-
|
|
1061
|
-
|
|
1015
|
+
var _this = this;
|
|
1016
|
+
var _this1 = this, eventPool = _this1._eventPool, currentEvents = _this1._currentEvents;
|
|
1017
|
+
currentEvents.forEach(function(event, i) {
|
|
1062
1018
|
if (!event.alreadyInvoked) {
|
|
1063
1019
|
if (event.state == 0) {
|
|
1064
|
-
|
|
1020
|
+
_this._onTriggerEnter(event.index1, event.index2);
|
|
1065
1021
|
event.alreadyInvoked = true;
|
|
1066
1022
|
} else if (event.state == 1) {
|
|
1067
|
-
|
|
1023
|
+
_this._onTriggerStay(event.index1, event.index2);
|
|
1068
1024
|
event.alreadyInvoked = true;
|
|
1069
1025
|
}
|
|
1070
1026
|
} else {
|
|
1071
1027
|
event.state = 2;
|
|
1072
|
-
|
|
1073
|
-
this._onTriggerExit(event.index1, event.index2);
|
|
1028
|
+
_this._eventMap[event.index1][event.index2] = undefined;
|
|
1074
1029
|
currentEvents.deleteByIndex(i);
|
|
1030
|
+
_this._onTriggerExit(event.index1, event.index2);
|
|
1075
1031
|
eventPool.push(event);
|
|
1076
1032
|
}
|
|
1077
|
-
}
|
|
1033
|
+
});
|
|
1078
1034
|
};
|
|
1079
1035
|
_proto._boxCollision = function _boxCollision(other) {
|
|
1080
1036
|
if (_instanceof(other, LiteBoxColliderShape)) {
|
|
@@ -1101,26 +1057,19 @@ var /**
|
|
|
1101
1057
|
return false;
|
|
1102
1058
|
};
|
|
1103
1059
|
_proto._raycast = function _raycast(ray, distance, onRaycast, colliders, hit) {
|
|
1104
|
-
var hitResult;
|
|
1105
|
-
if (hit) {
|
|
1106
|
-
hitResult = LitePhysicsScene._hitResult;
|
|
1107
|
-
}
|
|
1108
1060
|
var isHit = false;
|
|
1109
1061
|
var curHit = LitePhysicsScene._currentHit;
|
|
1110
1062
|
for(var i = 0, len = colliders.length; i < len; i++){
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
return true;
|
|
1122
|
-
}
|
|
1123
|
-
distance = curHit.distance;
|
|
1063
|
+
if (colliders[i]._raycast(ray, onRaycast, curHit) && curHit.distance < distance) {
|
|
1064
|
+
if (hit) {
|
|
1065
|
+
isHit = true;
|
|
1066
|
+
var hitResult = LitePhysicsScene._hitResult;
|
|
1067
|
+
hitResult.normal.copyFrom(curHit.normal);
|
|
1068
|
+
hitResult.point.copyFrom(curHit.point);
|
|
1069
|
+
hitResult.distance = distance = curHit.distance;
|
|
1070
|
+
hitResult.shapeID = curHit.shapeID;
|
|
1071
|
+
} else {
|
|
1072
|
+
return true;
|
|
1124
1073
|
}
|
|
1125
1074
|
}
|
|
1126
1075
|
}
|
|
@@ -1267,7 +1216,7 @@ var LitePhysics = /*#__PURE__*/ function() {
|
|
|
1267
1216
|
}();
|
|
1268
1217
|
|
|
1269
1218
|
//@ts-ignore
|
|
1270
|
-
var version = "0.0.0-experimental-1.3-xr.
|
|
1219
|
+
var version = "0.0.0-experimental-1.3-xr.10";
|
|
1271
1220
|
console.log("Galacean PhysicsLite version: " + version);
|
|
1272
1221
|
|
|
1273
1222
|
export { LitePhysics, version };
|