@galacean/engine 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/browser.js CHANGED
@@ -11453,13 +11453,17 @@
11453
11453
  */ var DisorderedArray = /*#__PURE__*/ function() {
11454
11454
  var DisorderedArray = function DisorderedArray(count) {
11455
11455
  if (count === void 0) count = 0;
11456
- this.length = 0;
11457
- this._isLooping = false;
11456
+ /** The length of the array. */ this.length = 0;
11457
+ this._loopCounter = 0 // Ignore nested loops, use counter to solve the problem
11458
+ ;
11458
11459
  this._blankCount = 0;
11459
11460
  this._elements = new Array(count);
11460
11461
  };
11461
11462
  var _proto = DisorderedArray.prototype;
11462
- _proto.add = function add(element) {
11463
+ /**
11464
+ * Add an element to disordered array.
11465
+ * @param element - The element to be added
11466
+ */ _proto.add = function add(element) {
11463
11467
  if (this.length === this._elements.length) {
11464
11468
  this._elements.push(element);
11465
11469
  } else {
@@ -11467,18 +11471,29 @@
11467
11471
  }
11468
11472
  this.length++;
11469
11473
  };
11470
- _proto.delete = function _delete(element) {
11474
+ /**
11475
+ * Delete the specified element.
11476
+ * @param element - The element to be deleted
11477
+ */ _proto.delete = function _delete(element) {
11471
11478
  // @todo: It can be optimized for custom binary search and other algorithms, currently this._elements>=this.length wastes performance.
11472
11479
  var index = this._elements.indexOf(element);
11473
11480
  this.deleteByIndex(index);
11474
11481
  };
11475
- _proto.set = function set(index, element) {
11482
+ /**
11483
+ * Set the element at the specified index.
11484
+ * @param index - The index of the element to be set
11485
+ * @param element - The element to be set
11486
+ */ _proto.set = function set(index, element) {
11476
11487
  if (index >= this.length) {
11477
11488
  throw "Index is out of range.";
11478
11489
  }
11479
11490
  this._elements[index] = element;
11480
11491
  };
11481
- _proto.get = function get(index) {
11492
+ /**
11493
+ * Get the element at the specified index.
11494
+ * @param index - The index of the element to be get
11495
+ * @returns The element at the specified index
11496
+ */ _proto.get = function get(index) {
11482
11497
  if (index >= this.length) {
11483
11498
  throw "Index is out of range.";
11484
11499
  }
@@ -11491,7 +11506,7 @@
11491
11506
  */ _proto.deleteByIndex = function deleteByIndex(index) {
11492
11507
  var elements = this._elements;
11493
11508
  var end;
11494
- if (this._isLooping) {
11509
+ if (this._loopCounter > 0) {
11495
11510
  this._elements[index] = null;
11496
11511
  this._blankCount++;
11497
11512
  } else {
@@ -11505,41 +11520,57 @@
11505
11520
  }
11506
11521
  return end;
11507
11522
  };
11508
- _proto.forEach = function forEach(callbackFn, swapFn) {
11523
+ /**
11524
+ * Loop through all elements.
11525
+ * @param callbackFn - The callback function
11526
+ * @param swapFn - The swap function can process the element after the callback function, it will be called after end looping(`isLopping` = true)
11527
+ */ _proto.forEach = function forEach(callbackFn, swapFn) {
11509
11528
  this._startLoop();
11510
11529
  var elements = this._elements;
11511
11530
  for(var i = 0, n = this.length; i < n; i++){
11512
11531
  var element = elements[i];
11513
- element && callbackFn(element);
11532
+ element && callbackFn(element, i);
11514
11533
  }
11515
11534
  this._endLoop(swapFn);
11516
11535
  };
11517
- _proto.forEachAndClean = function forEachAndClean(callbackFn, swapFn) {
11536
+ /**
11537
+ * Loop through all elements and clean up the blank elements.
11538
+ * @param callbackFn - The callback function
11539
+ * @param swapFn - The swap function can process the element after the callback function, it will be called after end looping(`isLopping` = true)
11540
+ */ _proto.forEachAndClean = function forEachAndClean(callbackFn, swapFn) {
11518
11541
  this._startLoop();
11519
11542
  var preEnd = this.length;
11520
11543
  var elements = this._elements;
11521
11544
  for(var i = 0, n = preEnd; i < n; i++){
11522
11545
  var element = elements[i];
11523
- element && callbackFn(element);
11546
+ element && callbackFn(element, i);
11524
11547
  }
11525
11548
  this._endLoopAndClean(preEnd, elements, swapFn);
11526
11549
  };
11527
- _proto.sort = function sort(compareFn) {
11550
+ /**
11551
+ * Sort the array.
11552
+ * @param compareFn - The comparison function
11553
+ */ _proto.sort = function sort(compareFn) {
11528
11554
  Utils._quickSort(this._elements, 0, this.length, compareFn);
11529
11555
  };
11530
- _proto.garbageCollection = function garbageCollection() {
11556
+ /**
11557
+ * Garbage collection, clean up all cached elements.
11558
+ */ _proto.garbageCollection = function garbageCollection() {
11531
11559
  this._elements.length = this.length;
11532
11560
  };
11533
11561
  _proto._startLoop = function _startLoop() {
11534
- this._isLooping = true;
11562
+ ++this._loopCounter;
11535
11563
  };
11536
11564
  _proto._endLoop = function _endLoop(swapFn) {
11537
- this._isLooping = false;
11565
+ if (--this._loopCounter !== 0) {
11566
+ return;
11567
+ }
11538
11568
  if (this._blankCount) {
11539
11569
  var from = 0;
11540
11570
  var to = this.length - 1;
11541
11571
  var elements = this._elements;
11542
11572
  partition: do {
11573
+ var _swapFn;
11543
11574
  while(elements[from])if (++from >= to) {
11544
11575
  break partition;
11545
11576
  }
@@ -11547,7 +11578,7 @@
11547
11578
  break partition;
11548
11579
  }
11549
11580
  var swapElement = elements[to];
11550
- swapFn(swapElement, from);
11581
+ (_swapFn = swapFn) == null ? void 0 : _swapFn(swapElement, from);
11551
11582
  elements[from++] = swapElement;
11552
11583
  elements[to--] = null;
11553
11584
  }while (from < to);
@@ -11556,18 +11587,31 @@
11556
11587
  }
11557
11588
  };
11558
11589
  _proto._endLoopAndClean = function _endLoopAndClean(preEnd, elements, swapFn) {
11590
+ if (--this._loopCounter !== 0) {
11591
+ return;
11592
+ }
11559
11593
  var index = 0;
11560
11594
  for(var i = preEnd, n = this.length; i < n; i++){
11595
+ var _swapFn;
11561
11596
  var element = elements[i];
11562
11597
  if (!element) continue;
11563
11598
  elements[index] = element;
11564
- swapFn(element, index);
11599
+ (_swapFn = swapFn) == null ? void 0 : _swapFn(element, index);
11565
11600
  index++;
11566
11601
  }
11567
- this._isLooping = false;
11568
11602
  this.length = index;
11569
11603
  this._blankCount = 0;
11570
11604
  };
11605
+ _create_class$2(DisorderedArray, [
11606
+ {
11607
+ key: "isLopping",
11608
+ get: /**
11609
+ * Get whether the array is in the loop.
11610
+ */ function get() {
11611
+ return this._loopCounter > 0;
11612
+ }
11613
+ }
11614
+ ]);
11571
11615
  return DisorderedArray;
11572
11616
  }();
11573
11617
  var _TiledSpriteAssembler;
@@ -39035,6 +39079,7 @@
39035
39079
  get DepthTextureMode () { return exports.DepthTextureMode; },
39036
39080
  get DiffuseMode () { return exports.DiffuseMode; },
39037
39081
  DirectLight: DirectLight,
39082
+ DisorderedArray: DisorderedArray,
39038
39083
  get Downsampling () { return exports.Downsampling; },
39039
39084
  DynamicCollider: DynamicCollider,
39040
39085
  get DynamicColliderConstraints () { return exports.DynamicColliderConstraints; },
@@ -48101,7 +48146,7 @@
48101
48146
  ], EXT_texture_webp);
48102
48147
 
48103
48148
  //@ts-ignore
48104
- var version = "1.3.9";
48149
+ var version = "1.3.11";
48105
48150
  console.log("Galacean engine version: " + version);
48106
48151
  for(var key in CoreObjects){
48107
48152
  Loader.registerClass(key, CoreObjects[key]);
@@ -48159,6 +48204,7 @@
48159
48204
  exports.CurveKey = CurveKey;
48160
48205
  exports.DepthState = DepthState;
48161
48206
  exports.DirectLight = DirectLight;
48207
+ exports.DisorderedArray = DisorderedArray;
48162
48208
  exports.DynamicCollider = DynamicCollider;
48163
48209
  exports.EmissionModule = EmissionModule;
48164
48210
  exports.Engine = Engine;