@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/browser.js
CHANGED
|
@@ -706,52 +706,6 @@
|
|
|
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 @@
|
|
|
889
843
|
this._dynamicColliders = [];
|
|
890
844
|
this._sphere = new engine.BoundingSphere();
|
|
891
845
|
this._box = new engine.BoundingBox();
|
|
892
|
-
this._currentEvents = new DisorderedArray();
|
|
846
|
+
this._currentEvents = new engine.DisorderedArray();
|
|
893
847
|
this._eventMap = {};
|
|
894
848
|
this._eventPool = [];
|
|
895
849
|
this._onContactEnter = onContactEnter;
|
|
@@ -915,8 +869,7 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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;
|