@galacean/engine 0.0.0-experimental-uploadSameBuffer.0 → 0.0.0-experimental-renderSort.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 CHANGED
@@ -6907,13 +6907,15 @@
6907
6907
  ];
6908
6908
  })();
6909
6909
  (function() {
6910
- /** These characters are all tall to help calculate the height required for text. */ TextUtils._measureString = "|\xc9q\xc5";
6910
+ // _heightMultiplier used to measure the height of text, but in miniprogram performance is different from h5.
6911
+ // so can set _heightMultiplier to adapt miniprogram, the larger the value, the worse the performance.
6912
+ /** @internal */ TextUtils._heightMultiplier = 2;
6911
6913
  })();
6912
6914
  (function() {
6913
- TextUtils._measureBaseline = "M";
6915
+ /** These characters are all tall to help calculate the height required for text. */ TextUtils._measureString = "|\xc9q\xc5";
6914
6916
  })();
6915
6917
  (function() {
6916
- TextUtils._heightMultiplier = 2;
6918
+ TextUtils._measureBaseline = "M";
6917
6919
  })();
6918
6920
  (function() {
6919
6921
  TextUtils._baselineMultiplier = 1.4;
@@ -6996,7 +6998,7 @@
6996
6998
  var _this = this, engine = _this._engine;
6997
6999
  var fontAtlas = new FontAtlas(engine);
6998
7000
  var texture = new Texture2D(engine, 256, 256, exports.TextureFormat.R8G8B8A8, false);
6999
- texture.filterMode = exports.TextureFilterMode.Point;
7001
+ texture.filterMode = exports.TextureFilterMode.Bilinear;
7000
7002
  fontAtlas.texture = texture;
7001
7003
  fontAtlas.isGCIgnored = texture.isGCIgnored = true;
7002
7004
  this._fontAtlases.push(fontAtlas);
@@ -17402,6 +17404,8 @@
17402
17404
  }
17403
17405
  mesh.addSubMesh(this._getSubMeshFromPool(vertexStartIndex, vertexCount));
17404
17406
  batchedQueue[curMeshIndex] = preElement;
17407
+ // Set data option use Discard, or will resulted in performance slowdown when open antialias and cross-rendering of 3D and 2D elements.
17408
+ // Device: iphone X(16.7.2)、iphone 15 pro max(17.1.1)、iphone XR(17.1.2) etc.
17405
17409
  this._vertexBuffers[_flushId].setData(vertices, 0, 0, vertexIndex, exports.SetDataOptions.Discard);
17406
17410
  this._indiceBuffers[_flushId].setData(indices, 0, 0, indiceIndex, exports.SetDataOptions.Discard);
17407
17411
  };
@@ -23245,7 +23249,7 @@
23245
23249
  /**
23246
23250
  * @internal
23247
23251
  */ _proto._render = function _render(context) {
23248
- if (this._text === "" || this.enableWrapping && this.width <= 0 || this.overflowMode === exports.OverflowMode.Truncate && this.height <= 0) {
23252
+ if (this._isTextNoVisible()) {
23249
23253
  return;
23250
23254
  }
23251
23255
  if (this._isContainDirtyFlag(0x10)) {
@@ -23337,8 +23341,8 @@
23337
23341
  }
23338
23342
  };
23339
23343
  _proto._updateLocalData = function _updateLocalData() {
23340
- var _this = this, color = _this.color, charRenderDatas = _this._charRenderDatas, charFont = _this._subFont;
23341
23344
  var _this__localBounds = this._localBounds, min = _this__localBounds.min, max = _this__localBounds.max;
23345
+ var _this = this, color = _this.color, charRenderDatas = _this._charRenderDatas, charFont = _this._subFont;
23342
23346
  var textMetrics = this.enableWrapping ? TextUtils.measureTextWithWrap(this) : TextUtils.measureTextWithoutWrap(this);
23343
23347
  var height = textMetrics.height, lines = textMetrics.lines, lineWidths = textMetrics.lineWidths, lineHeight = textMetrics.lineHeight, lineMaxSizes = textMetrics.lineMaxSizes;
23344
23348
  var charRenderDataPool = TextRenderer._charRenderDataPool;
@@ -23406,7 +23410,7 @@
23406
23410
  var left = startX * pixelsPerUnitReciprocal;
23407
23411
  var right = (startX + w) * pixelsPerUnitReciprocal;
23408
23412
  var top = (startY + ascent) * pixelsPerUnitReciprocal;
23409
- var bottom = (startY - descent + 1) * pixelsPerUnitReciprocal;
23413
+ var bottom = (startY - descent) * pixelsPerUnitReciprocal;
23410
23414
  localPositions.set(left, top, right, bottom);
23411
23415
  i === firstLine && (maxY = Math.max(maxY, top));
23412
23416
  minY = Math.min(minY, bottom);
@@ -23447,6 +23451,9 @@
23447
23451
  Renderer1.prototype._onTransformChanged.call(this, bit);
23448
23452
  this._setDirtyFlagTrue(0x4 | 0x8);
23449
23453
  };
23454
+ _proto._isTextNoVisible = function _isTextNoVisible() {
23455
+ return this._text === "" || this._fontSize === 0 || this.enableWrapping && this.width <= 0 || this.overflowMode === exports.OverflowMode.Truncate && this.height <= 0;
23456
+ };
23450
23457
  _create_class$3(TextRenderer, [
23451
23458
  {
23452
23459
  key: "color",
@@ -23649,6 +23656,16 @@
23649
23656
  get: /**
23650
23657
  * The bounding volume of the TextRenderer.
23651
23658
  */ function get() {
23659
+ if (this._isTextNoVisible()) {
23660
+ if (this._isContainDirtyFlag(0x8)) {
23661
+ var localBounds = this._localBounds;
23662
+ localBounds.min.set(0, 0, 0);
23663
+ localBounds.max.set(0, 0, 0);
23664
+ this._updateBounds(this._bounds);
23665
+ this._setDirtyFlagFalse(0x8);
23666
+ }
23667
+ return this._bounds;
23668
+ }
23652
23669
  this._isContainDirtyFlag(0x1) && this._resetSubFont();
23653
23670
  this._isContainDirtyFlag(0x2) && this._updateLocalData();
23654
23671
  this._isContainDirtyFlag(0x4) && this._updatePosition();
@@ -26541,38 +26558,45 @@
26541
26558
  var v0 = a[from];
26542
26559
  var v1 = a[to - 1];
26543
26560
  var v2 = a[third_index];
26561
+ var swapFlag = false;
26544
26562
  var c01 = compareFunc(v0, v1);
26545
26563
  if (c01 > 0) {
26546
26564
  // v1 < v0, so swap them.
26547
26565
  var tmp = v0;
26548
26566
  v0 = v1;
26549
26567
  v1 = tmp;
26568
+ swapFlag = true;
26550
26569
  } // v0 <= v1.
26551
26570
  var c02 = compareFunc(v0, v2);
26552
- if (c02 >= 0) {
26553
- // v2 <= v0 <= v1.
26571
+ if (c02 > 0) {
26572
+ // v2 < v0.
26554
26573
  var tmp1 = v0;
26555
26574
  v0 = v2;
26556
26575
  v2 = v1;
26557
26576
  v1 = tmp1;
26577
+ swapFlag = true;
26558
26578
  } else {
26559
- // v0 <= v1 && v0 < v2
26579
+ // v2 >= v0
26560
26580
  var c12 = compareFunc(v1, v2);
26561
26581
  if (c12 > 0) {
26562
26582
  // v0 <= v2 < v1
26563
26583
  var tmp2 = v1;
26564
26584
  v1 = v2;
26565
26585
  v2 = tmp2;
26586
+ swapFlag = true;
26566
26587
  }
26567
26588
  }
26568
26589
  // v0 <= v1 <= v2
26569
- a[from] = v0;
26570
- a[to - 1] = v2;
26571
- var pivot = v1;
26572
26590
  var low_end = from + 1; // Upper bound of elements lower than pivot.
26573
26591
  var high_start = to - 1; // Lower bound of elements greater than pivot.
26574
- a[third_index] = a[low_end];
26575
- a[low_end] = pivot;
26592
+ var pivot = v2;
26593
+ if (swapFlag) {
26594
+ a[from] = v0;
26595
+ a[to - 1] = v2;
26596
+ pivot = v1;
26597
+ a[third_index] = a[low_end];
26598
+ a[low_end] = pivot;
26599
+ }
26576
26600
  // From low_end to i are elements equal to pivot.
26577
26601
  // From i to high_start are elements that haven't been compared yet.
26578
26602
  partition: for(var i = low_end + 1; i < high_start; i++){
@@ -26627,12 +26651,38 @@
26627
26651
  /**
26628
26652
  * @internal
26629
26653
  */ RenderQueue._compareFromNearToFar = function _compareFromNearToFar(a, b) {
26630
- return a.data.component.priority - b.data.component.priority || a.data.material._priority - b.data.material._priority || a.data.component._distanceForSort - b.data.component._distanceForSort;
26654
+ var dataA = a.data;
26655
+ var dataB = b.data;
26656
+ var componentA = dataA.component;
26657
+ var componentB = dataB.component;
26658
+ var priorityOrder = componentA.priority - componentB.priority;
26659
+ if (priorityOrder !== 0) {
26660
+ return priorityOrder;
26661
+ }
26662
+ // make suer from the same renderer.
26663
+ if (componentA.instanceId === componentB.instanceId) {
26664
+ return dataA.material._priority - dataB.material._priority || componentA._distanceForSort - componentB._distanceForSort;
26665
+ } else {
26666
+ return componentA._distanceForSort - componentB._distanceForSort;
26667
+ }
26631
26668
  };
26632
26669
  /**
26633
26670
  * @internal
26634
26671
  */ RenderQueue._compareFromFarToNear = function _compareFromFarToNear(a, b) {
26635
- return a.data.component.priority - b.data.component.priority || a.data.material._priority - b.data.material._priority || b.data.component._distanceForSort - a.data.component._distanceForSort;
26672
+ var dataA = a.data;
26673
+ var dataB = b.data;
26674
+ var componentA = dataA.component;
26675
+ var componentB = dataB.component;
26676
+ var priorityOrder = componentA.priority - componentB.priority;
26677
+ if (priorityOrder !== 0) {
26678
+ return priorityOrder;
26679
+ }
26680
+ // make suer from the same renderer.
26681
+ if (componentA.instanceId === componentB.instanceId) {
26682
+ return dataA.material._priority - dataB.material._priority || componentB._distanceForSort - componentA._distanceForSort;
26683
+ } else {
26684
+ return componentB._distanceForSort - componentA._distanceForSort;
26685
+ }
26636
26686
  };
26637
26687
  return RenderQueue;
26638
26688
  }();
@@ -43146,7 +43196,7 @@
43146
43196
  };
43147
43197
  _proto._makeSprite = function _makeSprite(engine, config, texture) {
43148
43198
  // Generate a SpriteAtlas object.
43149
- var region = config.region, atlasRegionOffset = config.atlasRegionOffset, atlasRegion = config.atlasRegion, pivot = config.pivot, border = config.border;
43199
+ var region = config.region, atlasRegionOffset = config.atlasRegionOffset, atlasRegion = config.atlasRegion, pivot = config.pivot, border = config.border, width = config.width, height = config.height;
43150
43200
  var sprite = new Sprite(engine, texture, region ? this._tempRect.set(region.x, region.y, region.w, region.h) : undefined, pivot ? this._tempVec2.set(pivot.x, pivot.y) : undefined, border ? this._tempVec4.set(border.x, border.y, border.z, border.w) : undefined, config.name);
43151
43201
  if (texture) {
43152
43202
  var invW = 1 / texture.width;
@@ -43158,6 +43208,8 @@
43158
43208
  }
43159
43209
  config.atlasRotated && (sprite.atlasRotated = true);
43160
43210
  }
43211
+ isNaN(width) || (sprite.width = width);
43212
+ isNaN(height) || (sprite.height = height);
43161
43213
  return sprite;
43162
43214
  };
43163
43215
  return SpriteAtlasLoader;
@@ -43192,11 +43244,19 @@
43192
43244
  if (data.texture) {
43193
43245
  return resourceManager // @ts-ignore
43194
43246
  .getResourceByRef(data.texture).then(function(texture) {
43195
- return new Sprite(resourceManager.engine, texture, data.region, data.pivot, data.border);
43247
+ var sprite = new Sprite(resourceManager.engine, texture, data.region, data.pivot, data.border);
43248
+ var width = data.width, height = data.height;
43249
+ isNaN(width) || (sprite.width = width);
43250
+ isNaN(height) || (sprite.height = height);
43251
+ return sprite;
43196
43252
  });
43197
43253
  } else {
43198
43254
  return new AssetPromise(function(resolve) {
43199
- resolve(new Sprite(resourceManager.engine, null, data.region, data.pivot, data.border));
43255
+ var sprite = new Sprite(resourceManager.engine, null, data.region, data.pivot, data.border);
43256
+ var width = data.width, height = data.height;
43257
+ isNaN(width) || (sprite.width = width);
43258
+ isNaN(height) || (sprite.height = height);
43259
+ resolve(sprite);
43200
43260
  });
43201
43261
  }
43202
43262
  };
@@ -43975,7 +44035,7 @@
43975
44035
  ], GALACEAN_animation_event);
43976
44036
 
43977
44037
  //@ts-ignore
43978
- var version = "0.0.0-experimental-uploadSameBuffer.0";
44038
+ var version = "0.0.0-experimental-renderSort.0";
43979
44039
  console.log("Galacean engine version: " + version);
43980
44040
  for(var key in CoreObjects){
43981
44041
  Loader.registerClass(key, CoreObjects[key]);