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