@galacean/engine-core 1.3.9 → 1.3.11
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/main.js +63 -18
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +63 -18
- package/dist/module.js +63 -19
- package/dist/module.js.map +1 -1
- package/package.json +3 -3
- package/types/index.d.ts +1 -0
- package/types/utils/DisorderedArray.d.ts +70 -0
- package/types/DisorderedArray.d.ts +0 -27
package/dist/main.js
CHANGED
|
@@ -6611,13 +6611,17 @@ SlicedSpriteAssembler = __decorate([
|
|
|
6611
6611
|
*/ var DisorderedArray = /*#__PURE__*/ function() {
|
|
6612
6612
|
function DisorderedArray(count) {
|
|
6613
6613
|
if (count === void 0) count = 0;
|
|
6614
|
-
this.length = 0;
|
|
6615
|
-
this.
|
|
6614
|
+
/** The length of the array. */ this.length = 0;
|
|
6615
|
+
this._loopCounter = 0 // Ignore nested loops, use counter to solve the problem
|
|
6616
|
+
;
|
|
6616
6617
|
this._blankCount = 0;
|
|
6617
6618
|
this._elements = new Array(count);
|
|
6618
6619
|
}
|
|
6619
6620
|
var _proto = DisorderedArray.prototype;
|
|
6620
|
-
|
|
6621
|
+
/**
|
|
6622
|
+
* Add an element to disordered array.
|
|
6623
|
+
* @param element - The element to be added
|
|
6624
|
+
*/ _proto.add = function add(element) {
|
|
6621
6625
|
if (this.length === this._elements.length) {
|
|
6622
6626
|
this._elements.push(element);
|
|
6623
6627
|
} else {
|
|
@@ -6625,18 +6629,29 @@ SlicedSpriteAssembler = __decorate([
|
|
|
6625
6629
|
}
|
|
6626
6630
|
this.length++;
|
|
6627
6631
|
};
|
|
6628
|
-
|
|
6632
|
+
/**
|
|
6633
|
+
* Delete the specified element.
|
|
6634
|
+
* @param element - The element to be deleted
|
|
6635
|
+
*/ _proto.delete = function _delete(element) {
|
|
6629
6636
|
// @todo: It can be optimized for custom binary search and other algorithms, currently this._elements>=this.length wastes performance.
|
|
6630
6637
|
var index = this._elements.indexOf(element);
|
|
6631
6638
|
this.deleteByIndex(index);
|
|
6632
6639
|
};
|
|
6633
|
-
|
|
6640
|
+
/**
|
|
6641
|
+
* Set the element at the specified index.
|
|
6642
|
+
* @param index - The index of the element to be set
|
|
6643
|
+
* @param element - The element to be set
|
|
6644
|
+
*/ _proto.set = function set(index, element) {
|
|
6634
6645
|
if (index >= this.length) {
|
|
6635
6646
|
throw "Index is out of range.";
|
|
6636
6647
|
}
|
|
6637
6648
|
this._elements[index] = element;
|
|
6638
6649
|
};
|
|
6639
|
-
|
|
6650
|
+
/**
|
|
6651
|
+
* Get the element at the specified index.
|
|
6652
|
+
* @param index - The index of the element to be get
|
|
6653
|
+
* @returns The element at the specified index
|
|
6654
|
+
*/ _proto.get = function get(index) {
|
|
6640
6655
|
if (index >= this.length) {
|
|
6641
6656
|
throw "Index is out of range.";
|
|
6642
6657
|
}
|
|
@@ -6649,7 +6664,7 @@ SlicedSpriteAssembler = __decorate([
|
|
|
6649
6664
|
*/ _proto.deleteByIndex = function deleteByIndex(index) {
|
|
6650
6665
|
var elements = this._elements;
|
|
6651
6666
|
var end;
|
|
6652
|
-
if (this.
|
|
6667
|
+
if (this._loopCounter > 0) {
|
|
6653
6668
|
this._elements[index] = null;
|
|
6654
6669
|
this._blankCount++;
|
|
6655
6670
|
} else {
|
|
@@ -6663,41 +6678,57 @@ SlicedSpriteAssembler = __decorate([
|
|
|
6663
6678
|
}
|
|
6664
6679
|
return end;
|
|
6665
6680
|
};
|
|
6666
|
-
|
|
6681
|
+
/**
|
|
6682
|
+
* Loop through all elements.
|
|
6683
|
+
* @param callbackFn - The callback function
|
|
6684
|
+
* @param swapFn - The swap function can process the element after the callback function, it will be called after end looping(`isLopping` = true)
|
|
6685
|
+
*/ _proto.forEach = function forEach(callbackFn, swapFn) {
|
|
6667
6686
|
this._startLoop();
|
|
6668
6687
|
var elements = this._elements;
|
|
6669
6688
|
for(var i = 0, n = this.length; i < n; i++){
|
|
6670
6689
|
var element = elements[i];
|
|
6671
|
-
element && callbackFn(element);
|
|
6690
|
+
element && callbackFn(element, i);
|
|
6672
6691
|
}
|
|
6673
6692
|
this._endLoop(swapFn);
|
|
6674
6693
|
};
|
|
6675
|
-
|
|
6694
|
+
/**
|
|
6695
|
+
* Loop through all elements and clean up the blank elements.
|
|
6696
|
+
* @param callbackFn - The callback function
|
|
6697
|
+
* @param swapFn - The swap function can process the element after the callback function, it will be called after end looping(`isLopping` = true)
|
|
6698
|
+
*/ _proto.forEachAndClean = function forEachAndClean(callbackFn, swapFn) {
|
|
6676
6699
|
this._startLoop();
|
|
6677
6700
|
var preEnd = this.length;
|
|
6678
6701
|
var elements = this._elements;
|
|
6679
6702
|
for(var i = 0, n = preEnd; i < n; i++){
|
|
6680
6703
|
var element = elements[i];
|
|
6681
|
-
element && callbackFn(element);
|
|
6704
|
+
element && callbackFn(element, i);
|
|
6682
6705
|
}
|
|
6683
6706
|
this._endLoopAndClean(preEnd, elements, swapFn);
|
|
6684
6707
|
};
|
|
6685
|
-
|
|
6708
|
+
/**
|
|
6709
|
+
* Sort the array.
|
|
6710
|
+
* @param compareFn - The comparison function
|
|
6711
|
+
*/ _proto.sort = function sort(compareFn) {
|
|
6686
6712
|
Utils._quickSort(this._elements, 0, this.length, compareFn);
|
|
6687
6713
|
};
|
|
6688
|
-
|
|
6714
|
+
/**
|
|
6715
|
+
* Garbage collection, clean up all cached elements.
|
|
6716
|
+
*/ _proto.garbageCollection = function garbageCollection() {
|
|
6689
6717
|
this._elements.length = this.length;
|
|
6690
6718
|
};
|
|
6691
6719
|
_proto._startLoop = function _startLoop() {
|
|
6692
|
-
this.
|
|
6720
|
+
++this._loopCounter;
|
|
6693
6721
|
};
|
|
6694
6722
|
_proto._endLoop = function _endLoop(swapFn) {
|
|
6695
|
-
this.
|
|
6723
|
+
if (--this._loopCounter !== 0) {
|
|
6724
|
+
return;
|
|
6725
|
+
}
|
|
6696
6726
|
if (this._blankCount) {
|
|
6697
6727
|
var from = 0;
|
|
6698
6728
|
var to = this.length - 1;
|
|
6699
6729
|
var elements = this._elements;
|
|
6700
6730
|
partition: do {
|
|
6731
|
+
var _swapFn;
|
|
6701
6732
|
while(elements[from])if (++from >= to) {
|
|
6702
6733
|
break partition;
|
|
6703
6734
|
}
|
|
@@ -6705,7 +6736,7 @@ SlicedSpriteAssembler = __decorate([
|
|
|
6705
6736
|
break partition;
|
|
6706
6737
|
}
|
|
6707
6738
|
var swapElement = elements[to];
|
|
6708
|
-
swapFn(swapElement, from);
|
|
6739
|
+
(_swapFn = swapFn) == null ? void 0 : _swapFn(swapElement, from);
|
|
6709
6740
|
elements[from++] = swapElement;
|
|
6710
6741
|
elements[to--] = null;
|
|
6711
6742
|
}while (from < to);
|
|
@@ -6714,18 +6745,31 @@ SlicedSpriteAssembler = __decorate([
|
|
|
6714
6745
|
}
|
|
6715
6746
|
};
|
|
6716
6747
|
_proto._endLoopAndClean = function _endLoopAndClean(preEnd, elements, swapFn) {
|
|
6748
|
+
if (--this._loopCounter !== 0) {
|
|
6749
|
+
return;
|
|
6750
|
+
}
|
|
6717
6751
|
var index = 0;
|
|
6718
6752
|
for(var i = preEnd, n = this.length; i < n; i++){
|
|
6753
|
+
var _swapFn;
|
|
6719
6754
|
var element = elements[i];
|
|
6720
6755
|
if (!element) continue;
|
|
6721
6756
|
elements[index] = element;
|
|
6722
|
-
swapFn(element, index);
|
|
6757
|
+
(_swapFn = swapFn) == null ? void 0 : _swapFn(element, index);
|
|
6723
6758
|
index++;
|
|
6724
6759
|
}
|
|
6725
|
-
this._isLooping = false;
|
|
6726
6760
|
this.length = index;
|
|
6727
6761
|
this._blankCount = 0;
|
|
6728
6762
|
};
|
|
6763
|
+
_create_class(DisorderedArray, [
|
|
6764
|
+
{
|
|
6765
|
+
key: "isLopping",
|
|
6766
|
+
get: /**
|
|
6767
|
+
* Get whether the array is in the loop.
|
|
6768
|
+
*/ function get() {
|
|
6769
|
+
return this._loopCounter > 0;
|
|
6770
|
+
}
|
|
6771
|
+
}
|
|
6772
|
+
]);
|
|
6729
6773
|
return DisorderedArray;
|
|
6730
6774
|
}();
|
|
6731
6775
|
|
|
@@ -34464,6 +34508,7 @@ exports.CubeProbe = CubeProbe;
|
|
|
34464
34508
|
exports.CurveKey = CurveKey;
|
|
34465
34509
|
exports.DepthState = DepthState;
|
|
34466
34510
|
exports.DirectLight = DirectLight;
|
|
34511
|
+
exports.DisorderedArray = DisorderedArray;
|
|
34467
34512
|
exports.DynamicCollider = DynamicCollider;
|
|
34468
34513
|
exports.EmissionModule = EmissionModule;
|
|
34469
34514
|
exports.Engine = Engine;
|