@galacean/engine-core 1.0.0-beta.17 → 1.0.0-beta.19

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.
@@ -376,28 +376,33 @@ function _inherits(subClass, superClass) {
376
376
  return Color;
377
377
  }();
378
378
 
379
- /******************************************************************************
380
- Copyright (c) Microsoft Corporation.
381
-
382
- Permission to use, copy, modify, and/or distribute this software for any
383
- purpose with or without fee is hereby granted.
384
-
385
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
386
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
387
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
388
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
389
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
390
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
391
- PERFORMANCE OF THIS SOFTWARE.
392
- ***************************************************************************** */
393
-
394
- function __decorate(decorators, target, key, desc) {
395
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
396
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
397
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
398
- return c > 3 && r && Object.defineProperty(target, key, r), r;
379
+ /******************************************************************************
380
+ Copyright (c) Microsoft Corporation.
381
+
382
+ Permission to use, copy, modify, and/or distribute this software for any
383
+ purpose with or without fee is hereby granted.
384
+
385
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
386
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
387
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
388
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
389
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
390
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
391
+ PERFORMANCE OF THIS SOFTWARE.
392
+ ***************************************************************************** */
393
+
394
+ function __decorate(decorators, target, key, desc) {
395
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
396
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
397
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
398
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
399
399
  }
400
400
 
401
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
402
+ var e = new Error(message);
403
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
404
+ };
405
+
401
406
  function _instanceof(left, right) {
402
407
  if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
403
408
  return !!right[Symbol.hasInstance](left);
@@ -1599,6 +1604,11 @@ var Logger = {
1599
1604
  subFont.nativeFontString = fontString;
1600
1605
  for(var i = 0, n = subTexts.length; i < n; i++){
1601
1606
  var subText = subTexts[i];
1607
+ // If subText is empty, push an empty line directly
1608
+ if (subText.length === 0) {
1609
+ this._pushLine(lines, lineWidths, lineMaxSizes, "", 0, 0, 0);
1610
+ continue;
1611
+ }
1602
1612
  var word = "";
1603
1613
  var wordWidth = 0;
1604
1614
  var wordMaxAscent = 0;
@@ -1626,7 +1636,10 @@ var Logger = {
1626
1636
  // If it is a word before, need to handle the previous word and line
1627
1637
  if (word.length > 0) {
1628
1638
  if (lineWidth + wordWidth > wrapWidth) {
1629
- this._pushLine(lines, lineWidths, lineMaxSizes, line, lineWidth, lineMaxAscent, lineMaxDescent);
1639
+ // Push if before line is not empty
1640
+ if (lineWidth > 0) {
1641
+ this._pushLine(lines, lineWidths, lineMaxSizes, line, lineWidth, lineMaxAscent, lineMaxDescent);
1642
+ }
1630
1643
  textWidth = Math.max(textWidth, lineWidth);
1631
1644
  notFirstLine = true;
1632
1645
  line = word;
@@ -1671,7 +1684,10 @@ var Logger = {
1671
1684
  line = "";
1672
1685
  lineWidth = lineMaxAscent = lineMaxDescent = 0;
1673
1686
  }
1674
- this._pushLine(lines, lineWidths, lineMaxSizes, word, wordWidth, wordMaxAscent, wordMaxDescent);
1687
+ // Push if before word is not empty
1688
+ if (wordWidth > 0) {
1689
+ this._pushLine(lines, lineWidths, lineMaxSizes, word, wordWidth, wordMaxAscent, wordMaxDescent);
1690
+ }
1675
1691
  textWidth = Math.max(textWidth, wordWidth);
1676
1692
  notFirstLine = true;
1677
1693
  word = char;
@@ -1690,11 +1706,15 @@ var Logger = {
1690
1706
  // If the total width from line and word exceed wrap width
1691
1707
  if (lineWidth + wordWidth > wrapWidth) {
1692
1708
  // Push chars to a single line
1693
- this._pushLine(lines, lineWidths, lineMaxSizes, line, lineWidth, lineMaxAscent, lineMaxDescent);
1709
+ if (lineWidth > 0) {
1710
+ this._pushLine(lines, lineWidths, lineMaxSizes, line, lineWidth, lineMaxAscent, lineMaxDescent);
1711
+ }
1694
1712
  textWidth = Math.max(textWidth, lineWidth);
1695
1713
  lineWidth = 0;
1696
1714
  // Push word to a single line
1697
- this._pushLine(lines, lineWidths, lineMaxSizes, word, wordWidth, wordMaxAscent, wordMaxDescent);
1715
+ if (wordWidth > 0) {
1716
+ this._pushLine(lines, lineWidths, lineMaxSizes, word, wordWidth, wordMaxAscent, wordMaxDescent);
1717
+ }
1698
1718
  textWidth = Math.max(textWidth, wordWidth);
1699
1719
  } else {
1700
1720
  // Merge to chars
@@ -1726,23 +1746,20 @@ var Logger = {
1726
1746
  var subFont = renderer._subFont;
1727
1747
  var fontString = subFont.nativeFontString;
1728
1748
  var fontSizeInfo = TextUtils.measureFont(fontString);
1729
- var lines = renderer.text.split(/(?:\r\n|\r|\n)/);
1730
- var lineCount = lines.length;
1749
+ var subTexts = renderer.text.split(/(?:\r\n|\r|\n)/);
1750
+ var textCount = subTexts.length;
1751
+ var lines = new Array();
1731
1752
  var lineWidths = new Array();
1732
1753
  var lineMaxSizes = new Array();
1733
1754
  var _pixelsPerUnit = Engine._pixelsPerUnit;
1734
1755
  var lineHeight = fontSizeInfo.size + renderer.lineSpacing * _pixelsPerUnit;
1735
1756
  var width = 0;
1736
- var height = renderer.height * _pixelsPerUnit;
1737
- if (renderer.overflowMode === exports.OverflowMode.Overflow) {
1738
- height = lineHeight * lineCount;
1739
- }
1740
1757
  subFont.nativeFontString = fontString;
1741
- for(var i = 0; i < lineCount; ++i){
1742
- var line = lines[i];
1758
+ for(var i = 0; i < textCount; ++i){
1759
+ var line = subTexts[i];
1743
1760
  var curWidth = 0;
1744
- var maxAscent = -1;
1745
- var maxDescent = -1;
1761
+ var maxAscent = 0;
1762
+ var maxDescent = 0;
1746
1763
  for(var j = 0, m = line.length; j < m; ++j){
1747
1764
  var charInfo = TextUtils._getCharInfo(line[j], fontString, subFont);
1748
1765
  curWidth += charInfo.xAdvance;
@@ -1753,16 +1770,15 @@ var Logger = {
1753
1770
  maxAscent < ascent && (maxAscent = ascent);
1754
1771
  maxDescent < descent && (maxDescent = descent);
1755
1772
  }
1756
- lineWidths[i] = curWidth;
1757
- lineMaxSizes[i] = {
1758
- ascent: maxAscent,
1759
- descent: maxDescent,
1760
- size: maxAscent + maxDescent
1761
- };
1762
- if (curWidth > width) {
1763
- width = curWidth;
1773
+ if (curWidth > 0) {
1774
+ this._pushLine(lines, lineWidths, lineMaxSizes, line, curWidth, maxAscent, maxDescent);
1775
+ width = Math.max(width, curWidth);
1764
1776
  }
1765
1777
  }
1778
+ var height = renderer.height * _pixelsPerUnit;
1779
+ if (renderer.overflowMode === exports.OverflowMode.Overflow) {
1780
+ height = lineHeight * lines.length;
1781
+ }
1766
1782
  return {
1767
1783
  width: width,
1768
1784
  height: height,
@@ -2615,7 +2631,6 @@ var rePropName$1 = RegExp(// Match anything that isn't a dot or bracket.
2615
2631
  function EventDispatcher() {
2616
2632
  this._events = Object.create(null);
2617
2633
  this._eventCount = 0;
2618
- this._dispatchingListeners = [];
2619
2634
  }
2620
2635
  var _proto = EventDispatcher.prototype;
2621
2636
  /**
@@ -2655,7 +2670,8 @@ var rePropName$1 = RegExp(// Match anything that isn't a dot or bracket.
2655
2670
  if (Array.isArray(listeners)) {
2656
2671
  var count = listeners.length;
2657
2672
  // cloning list to avoid structure breaking
2658
- var dispatchingListeners = this._dispatchingListeners;
2673
+ var pool = EventDispatcher._dispatchingListenersPool;
2674
+ var dispatchingListeners = pool.length > 0 ? pool.pop() : [];
2659
2675
  dispatchingListeners.length = count;
2660
2676
  for(var i = 0; i < count; i++){
2661
2677
  dispatchingListeners[i] = listeners[i];
@@ -2669,6 +2685,7 @@ var rePropName$1 = RegExp(// Match anything that isn't a dot or bracket.
2669
2685
  }
2670
2686
  // remove hooked function to avoid gc problem
2671
2687
  dispatchingListeners.length = 0;
2688
+ pool.push(dispatchingListeners);
2672
2689
  } else {
2673
2690
  if (listeners.once) this.off(event, listeners.fn);
2674
2691
  listeners.fn(data);
@@ -2769,6 +2786,9 @@ var rePropName$1 = RegExp(// Match anything that isn't a dot or bracket.
2769
2786
  };
2770
2787
  return EventDispatcher;
2771
2788
  }();
2789
+ (function() {
2790
+ EventDispatcher._dispatchingListenersPool = [];
2791
+ })();
2772
2792
 
2773
2793
  /**
2774
2794
  * Shader property.
@@ -3940,6 +3960,23 @@ var rePropName = RegExp(// Match anything that isn't a dot or bracket.
3940
3960
  scale.z < 0 && (isInvert = !isInvert);
3941
3961
  return isInvert;
3942
3962
  };
3963
+ _proto._onDestroy = function _onDestroy() {
3964
+ Component.prototype._onDestroy.call(this);
3965
+ //@ts-ignore
3966
+ this._worldPosition._onValueChanged = null;
3967
+ //@ts-ignore
3968
+ this._rotation._onValueChanged = null;
3969
+ //@ts-ignore
3970
+ this._worldRotation._onValueChanged = null;
3971
+ //@ts-ignore
3972
+ this._rotationQuaternion._onValueChanged = null;
3973
+ //@ts-ignore
3974
+ this._worldRotationQuaternion._onValueChanged = null;
3975
+ //@ts-ignore
3976
+ this._position._onValueChanged = null;
3977
+ //@ts-ignore
3978
+ this._scale._onValueChanged = null;
3979
+ };
3943
3980
  /**
3944
3981
  * Get worldMatrix: Will trigger the worldMatrix update of itself and all parent entities.
3945
3982
  * Get worldPosition: Will trigger the worldMatrix, local position update of itself and the worldMatrix update of all parent entities.
@@ -4633,6 +4670,7 @@ var ComponentCloner = /*#__PURE__*/ function() {
4633
4670
  return component;
4634
4671
  }
4635
4672
  }
4673
+ return null;
4636
4674
  };
4637
4675
  /**
4638
4676
  * Get components which match the type.
@@ -13736,6 +13774,15 @@ var VertexChangedFlags;
13736
13774
  };
13737
13775
  /**
13738
13776
  * @internal
13777
+ */ _proto._prepareRender = function _prepareRender(context) {
13778
+ if (!this._mesh) {
13779
+ Logger.error("mesh is null.");
13780
+ return;
13781
+ }
13782
+ Renderer.prototype._prepareRender.call(this, context);
13783
+ };
13784
+ /**
13785
+ * @internal
13739
13786
  */ _proto._cloneTo = function _cloneTo(target) {
13740
13787
  Renderer.prototype._cloneTo.call(this, target);
13741
13788
  target.mesh = this._mesh;
@@ -13757,49 +13804,45 @@ var VertexChangedFlags;
13757
13804
  * @internal
13758
13805
  */ _proto._render = function _render(context) {
13759
13806
  var mesh = this._mesh;
13760
- if (mesh) {
13761
- if (this._dirtyUpdateFlag & 0x2) {
13762
- var shaderData = this.shaderData;
13763
- var vertexElements = mesh._vertexElements;
13764
- shaderData.disableMacro(MeshRenderer._uvMacro);
13765
- shaderData.disableMacro(MeshRenderer._uv1Macro);
13766
- shaderData.disableMacro(MeshRenderer._normalMacro);
13767
- shaderData.disableMacro(MeshRenderer._tangentMacro);
13768
- shaderData.disableMacro(MeshRenderer._enableVertexColorMacro);
13769
- for(var i = 0, n = vertexElements.length; i < n; i++){
13770
- switch(vertexElements[i].semantic){
13771
- case "TEXCOORD_0":
13772
- shaderData.enableMacro(MeshRenderer._uvMacro);
13773
- break;
13774
- case "TEXCOORD_1":
13775
- shaderData.enableMacro(MeshRenderer._uv1Macro);
13776
- break;
13777
- case "NORMAL":
13778
- shaderData.enableMacro(MeshRenderer._normalMacro);
13779
- break;
13780
- case "TANGENT":
13781
- shaderData.enableMacro(MeshRenderer._tangentMacro);
13782
- break;
13783
- case "COLOR_0":
13784
- this._enableVertexColor && shaderData.enableMacro(MeshRenderer._enableVertexColorMacro);
13785
- break;
13786
- }
13807
+ if (this._dirtyUpdateFlag & 0x2) {
13808
+ var shaderData = this.shaderData;
13809
+ var vertexElements = mesh._vertexElements;
13810
+ shaderData.disableMacro(MeshRenderer._uvMacro);
13811
+ shaderData.disableMacro(MeshRenderer._uv1Macro);
13812
+ shaderData.disableMacro(MeshRenderer._normalMacro);
13813
+ shaderData.disableMacro(MeshRenderer._tangentMacro);
13814
+ shaderData.disableMacro(MeshRenderer._enableVertexColorMacro);
13815
+ for(var i = 0, n = vertexElements.length; i < n; i++){
13816
+ switch(vertexElements[i].semantic){
13817
+ case "TEXCOORD_0":
13818
+ shaderData.enableMacro(MeshRenderer._uvMacro);
13819
+ break;
13820
+ case "TEXCOORD_1":
13821
+ shaderData.enableMacro(MeshRenderer._uv1Macro);
13822
+ break;
13823
+ case "NORMAL":
13824
+ shaderData.enableMacro(MeshRenderer._normalMacro);
13825
+ break;
13826
+ case "TANGENT":
13827
+ shaderData.enableMacro(MeshRenderer._tangentMacro);
13828
+ break;
13829
+ case "COLOR_0":
13830
+ this._enableVertexColor && shaderData.enableMacro(MeshRenderer._enableVertexColorMacro);
13831
+ break;
13787
13832
  }
13788
- this._dirtyUpdateFlag &= ~0x2;
13789
13833
  }
13790
- var materials = this._materials;
13791
- var subMeshes = mesh.subMeshes;
13792
- var renderPipeline = context.camera._renderPipeline;
13793
- var meshRenderDataPool = this._engine._meshRenderDataPool;
13794
- for(var i1 = 0, n1 = subMeshes.length; i1 < n1; i1++){
13795
- var material = materials[i1];
13796
- if (!material) continue;
13797
- var renderData = meshRenderDataPool.getFromPool();
13798
- renderData.set(this, material, mesh, subMeshes[i1]);
13799
- renderPipeline.pushRenderData(context, renderData);
13800
- }
13801
- } else {
13802
- Logger.error("mesh is null.");
13834
+ this._dirtyUpdateFlag &= ~0x2;
13835
+ }
13836
+ var materials = this._materials;
13837
+ var subMeshes = mesh.subMeshes;
13838
+ var renderPipeline = context.camera._renderPipeline;
13839
+ var meshRenderDataPool = this._engine._meshRenderDataPool;
13840
+ for(var i1 = 0, n1 = subMeshes.length; i1 < n1; i1++){
13841
+ var material = materials[i1];
13842
+ if (!material) continue;
13843
+ var renderData = meshRenderDataPool.getFromPool();
13844
+ renderData.set(this, material, mesh, subMeshes[i1]);
13845
+ renderPipeline.pushRenderData(context, renderData);
13803
13846
  }
13804
13847
  };
13805
13848
  _proto._setMesh = function _setMesh(mesh) {
@@ -19558,18 +19601,10 @@ var defaultInterval = 500;
19558
19601
  var _config_type;
19559
19602
  config.type = (_config_type = config.type) != null ? _config_type : getMimeTypeFromUrl(url);
19560
19603
  var realRequest = config.type === "image" ? requestImage : requestRes;
19561
- var lastError;
19562
19604
  var executor = new MultiExecutor(function() {
19563
- return realRequest(url, config).onProgress(setProgress).then(function(res) {
19564
- resolve(res);
19565
- executor.stop();
19566
- }).catch(function(err) {
19567
- return lastError = err;
19568
- });
19605
+ return realRequest(url, config).onProgress(setProgress);
19569
19606
  }, retryCount, retryInterval);
19570
- executor.start(function() {
19571
- reject(lastError);
19572
- });
19607
+ executor.start().onError(reject).onComplete(resolve);
19573
19608
  });
19574
19609
  }
19575
19610
  function requestImage(url, config) {
@@ -19656,23 +19691,33 @@ var MultiExecutor = /*#__PURE__*/ function() {
19656
19691
  this.exec = this.exec.bind(this);
19657
19692
  }
19658
19693
  var _proto = MultiExecutor.prototype;
19659
- _proto.start = function start(done) {
19660
- this.done = done;
19694
+ _proto.start = function start() {
19661
19695
  this.exec();
19696
+ return this;
19662
19697
  };
19663
- _proto.stop = function stop() {
19664
- clearTimeout(this._timeoutId);
19698
+ _proto.onComplete = function onComplete(func) {
19699
+ this._onComplete = func;
19700
+ return this;
19701
+ };
19702
+ _proto.onError = function onError(func) {
19703
+ this._onError = func;
19704
+ return this;
19705
+ };
19706
+ _proto.cancel = function cancel() {
19707
+ engineMiniprogramAdapter.window.clearTimeout(this._timeoutId);
19665
19708
  };
19666
19709
  _proto.exec = function exec() {
19667
19710
  var _this = this;
19668
19711
  if (this._currentCount >= this.totalCount) {
19669
- this.done && this.done();
19712
+ this._onError && this._onError(this._error);
19670
19713
  return;
19671
19714
  }
19672
19715
  this._currentCount++;
19673
- this.execFunc(this._currentCount).then(function() {
19674
- //@ts-ignore
19675
- _this._timeoutId = setTimeout(_this.exec, _this.interval);
19716
+ this.execFunc(this._currentCount).then(function(result) {
19717
+ return _this._onComplete && _this._onComplete(result);
19718
+ }).catch(function(e) {
19719
+ _this._error = e;
19720
+ _this._timeoutId = engineMiniprogramAdapter.window.setTimeout(_this.exec, _this.interval);
19676
19721
  });
19677
19722
  };
19678
19723
  return MultiExecutor;
@@ -22305,92 +22350,97 @@ var /**
22305
22350
  }
22306
22351
  };
22307
22352
  _proto._updateLocalData = function _updateLocalData() {
22308
- var _this = this, color = _this.color, horizontalAlignment = _this.horizontalAlignment, verticalAlignment = _this.verticalAlignment, charRenderDatas = _this._charRenderDatas;
22353
+ var _this = this, color = _this.color, charRenderDatas = _this._charRenderDatas, charFont = _this._subFont;
22309
22354
  var _this__localBounds = this._localBounds, min = _this__localBounds.min, max = _this__localBounds.max;
22310
- var _pixelsPerUnit = Engine._pixelsPerUnit;
22311
- var pixelsPerUnitReciprocal = 1.0 / _pixelsPerUnit;
22312
- var charFont = this._subFont;
22313
- var rendererWidth = this.width * _pixelsPerUnit;
22314
- var halfRendererWidth = rendererWidth * 0.5;
22315
- var rendererHeight = this.height * _pixelsPerUnit;
22316
22355
  var textMetrics = this.enableWrapping ? TextUtils.measureTextWithWrap(this) : TextUtils.measureTextWithoutWrap(this);
22317
22356
  var height = textMetrics.height, lines = textMetrics.lines, lineWidths = textMetrics.lineWidths, lineHeight = textMetrics.lineHeight, lineMaxSizes = textMetrics.lineMaxSizes;
22318
22357
  var charRenderDataPool = TextRenderer._charRenderDataPool;
22319
- var halfLineHeight = lineHeight * 0.5;
22320
22358
  var linesLen = lines.length;
22321
- var startY = 0;
22322
- var topDiff = lineHeight * 0.5 - lineMaxSizes[0].ascent;
22323
- var bottomDiff = lineHeight * 0.5 - lineMaxSizes[linesLen - 1].descent - 1;
22324
- switch(verticalAlignment){
22325
- case exports.TextVerticalAlignment.Top:
22326
- startY = rendererHeight * 0.5 - halfLineHeight + topDiff;
22327
- break;
22328
- case exports.TextVerticalAlignment.Center:
22329
- startY = height * 0.5 - halfLineHeight - (bottomDiff - topDiff) * 0.5;
22330
- break;
22331
- case exports.TextVerticalAlignment.Bottom:
22332
- startY = height - rendererHeight * 0.5 - halfLineHeight - bottomDiff;
22333
- break;
22334
- }
22335
22359
  var renderDataCount = 0;
22336
- var firstLine = -1;
22337
- var minX = Number.MAX_SAFE_INTEGER;
22338
- var minY = Number.MAX_SAFE_INTEGER;
22339
- var maxX = Number.MIN_SAFE_INTEGER;
22340
- var maxY = Number.MIN_SAFE_INTEGER;
22341
- for(var i = 0; i < linesLen; ++i){
22342
- var lineWidth = lineWidths[i];
22343
- if (lineWidth > 0) {
22344
- var line = lines[i];
22345
- var startX = 0;
22346
- var firstRow = -1;
22347
- if (firstLine < 0) {
22348
- firstLine = i;
22349
- }
22350
- switch(horizontalAlignment){
22351
- case exports.TextHorizontalAlignment.Left:
22352
- startX = -halfRendererWidth;
22353
- break;
22354
- case exports.TextHorizontalAlignment.Center:
22355
- startX = -lineWidth * 0.5;
22356
- break;
22357
- case exports.TextHorizontalAlignment.Right:
22358
- startX = halfRendererWidth - lineWidth;
22359
- break;
22360
- }
22361
- for(var j = 0, n = line.length; j < n; ++j){
22362
- var char = line[j];
22363
- var charInfo = charFont._getCharInfo(char);
22364
- if (charInfo.h > 0) {
22365
- var _charRenderDatas, _ref;
22366
- firstRow < 0 && (firstRow = j);
22367
- var charRenderData = (_charRenderDatas = charRenderDatas)[_ref = renderDataCount++] || (_charRenderDatas[_ref] = charRenderDataPool.get());
22368
- var renderData = charRenderData.renderData, localPositions = charRenderData.localPositions;
22369
- charRenderData.texture = charFont._getTextureByIndex(charInfo.index);
22370
- renderData.color = color;
22371
- renderData.uvs = charInfo.uvs;
22372
- var w = charInfo.w, ascent = charInfo.ascent, descent = charInfo.descent;
22373
- var left = startX * pixelsPerUnitReciprocal;
22374
- var right = (startX + w) * pixelsPerUnitReciprocal;
22375
- var top = (startY + ascent) * pixelsPerUnitReciprocal;
22376
- var bottom = (startY - descent + 1) * pixelsPerUnitReciprocal;
22377
- localPositions.set(left, top, right, bottom);
22378
- i === firstLine && (maxY = Math.max(maxY, top));
22379
- minY = Math.min(minY, bottom);
22380
- j === firstRow && (minX = Math.min(minX, left));
22381
- maxX = Math.max(maxX, right);
22360
+ if (linesLen > 0) {
22361
+ var _pixelsPerUnit = Engine._pixelsPerUnit;
22362
+ var horizontalAlignment = this.horizontalAlignment;
22363
+ var pixelsPerUnitReciprocal = 1.0 / _pixelsPerUnit;
22364
+ var rendererWidth = this.width * _pixelsPerUnit;
22365
+ var halfRendererWidth = rendererWidth * 0.5;
22366
+ var rendererHeight = this.height * _pixelsPerUnit;
22367
+ var halfLineHeight = lineHeight * 0.5;
22368
+ var startY = 0;
22369
+ var topDiff = lineHeight * 0.5 - lineMaxSizes[0].ascent;
22370
+ var bottomDiff = lineHeight * 0.5 - lineMaxSizes[linesLen - 1].descent - 1;
22371
+ switch(this.verticalAlignment){
22372
+ case exports.TextVerticalAlignment.Top:
22373
+ startY = rendererHeight * 0.5 - halfLineHeight + topDiff;
22374
+ break;
22375
+ case exports.TextVerticalAlignment.Center:
22376
+ startY = height * 0.5 - halfLineHeight - (bottomDiff - topDiff) * 0.5;
22377
+ break;
22378
+ case exports.TextVerticalAlignment.Bottom:
22379
+ startY = height - rendererHeight * 0.5 - halfLineHeight - bottomDiff;
22380
+ break;
22381
+ }
22382
+ var firstLine = -1;
22383
+ var minX = Number.MAX_SAFE_INTEGER;
22384
+ var minY = Number.MAX_SAFE_INTEGER;
22385
+ var maxX = Number.MIN_SAFE_INTEGER;
22386
+ var maxY = Number.MIN_SAFE_INTEGER;
22387
+ for(var i = 0; i < linesLen; ++i){
22388
+ var lineWidth = lineWidths[i];
22389
+ if (lineWidth > 0) {
22390
+ var line = lines[i];
22391
+ var startX = 0;
22392
+ var firstRow = -1;
22393
+ if (firstLine < 0) {
22394
+ firstLine = i;
22395
+ }
22396
+ switch(horizontalAlignment){
22397
+ case exports.TextHorizontalAlignment.Left:
22398
+ startX = -halfRendererWidth;
22399
+ break;
22400
+ case exports.TextHorizontalAlignment.Center:
22401
+ startX = -lineWidth * 0.5;
22402
+ break;
22403
+ case exports.TextHorizontalAlignment.Right:
22404
+ startX = halfRendererWidth - lineWidth;
22405
+ break;
22406
+ }
22407
+ for(var j = 0, n = line.length; j < n; ++j){
22408
+ var char = line[j];
22409
+ var charInfo = charFont._getCharInfo(char);
22410
+ if (charInfo.h > 0) {
22411
+ var _charRenderDatas, _ref;
22412
+ firstRow < 0 && (firstRow = j);
22413
+ var charRenderData = (_charRenderDatas = charRenderDatas)[_ref = renderDataCount++] || (_charRenderDatas[_ref] = charRenderDataPool.get());
22414
+ var renderData = charRenderData.renderData, localPositions = charRenderData.localPositions;
22415
+ charRenderData.texture = charFont._getTextureByIndex(charInfo.index);
22416
+ renderData.color = color;
22417
+ renderData.uvs = charInfo.uvs;
22418
+ var w = charInfo.w, ascent = charInfo.ascent, descent = charInfo.descent;
22419
+ var left = startX * pixelsPerUnitReciprocal;
22420
+ var right = (startX + w) * pixelsPerUnitReciprocal;
22421
+ var top = (startY + ascent) * pixelsPerUnitReciprocal;
22422
+ var bottom = (startY - descent + 1) * pixelsPerUnitReciprocal;
22423
+ localPositions.set(left, top, right, bottom);
22424
+ i === firstLine && (maxY = Math.max(maxY, top));
22425
+ minY = Math.min(minY, bottom);
22426
+ j === firstRow && (minX = Math.min(minX, left));
22427
+ maxX = Math.max(maxX, right);
22428
+ }
22429
+ startX += charInfo.xAdvance;
22382
22430
  }
22383
- startX += charInfo.xAdvance;
22384
22431
  }
22432
+ startY -= lineHeight;
22385
22433
  }
22386
- startY -= lineHeight;
22387
- }
22388
- if (firstLine < 0) {
22434
+ if (firstLine < 0) {
22435
+ min.set(0, 0, 0);
22436
+ max.set(0, 0, 0);
22437
+ } else {
22438
+ min.set(minX, minY, 0);
22439
+ max.set(maxX, maxY, 0);
22440
+ }
22441
+ } else {
22389
22442
  min.set(0, 0, 0);
22390
22443
  max.set(0, 0, 0);
22391
- } else {
22392
- min.set(minX, minY, 0);
22393
- max.set(maxX, maxY, 0);
22394
22444
  }
22395
22445
  // Revert excess render data to pool.
22396
22446
  var lastRenderDataCount = charRenderDatas.length;
@@ -24406,7 +24456,8 @@ exports.AnimatorLayerBlendingMode = void 0;
24406
24456
  };
24407
24457
  _proto._saveAnimatorEventHandlers = function _saveAnimatorEventHandlers(state, animatorStateData) {
24408
24458
  var eventHandlerPool = this._animationEventHandlerPool;
24409
- var scripts = this._entity._scripts;
24459
+ var scripts = [];
24460
+ this._entity.getComponents(Script, scripts);
24410
24461
  var scriptCount = scripts.length;
24411
24462
  var eventHandlers = animatorStateData.eventHandlers;
24412
24463
  var events = state.clip.events;
@@ -24419,7 +24470,7 @@ exports.AnimatorLayerBlendingMode = void 0;
24419
24470
  eventHandler.event = event;
24420
24471
  handlers.length = 0;
24421
24472
  for(var j = scriptCount - 1; j >= 0; j--){
24422
- var handler = scripts.get(j)[funcName];
24473
+ var handler = scripts[j][funcName];
24423
24474
  handler && handlers.push(handler);
24424
24475
  }
24425
24476
  eventHandlers.push(eventHandler);