@galacean/engine 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/browser.js CHANGED
@@ -5286,25 +5286,29 @@
5286
5286
  ]);
5287
5287
  return Color;
5288
5288
  }();
5289
- /******************************************************************************
5290
- Copyright (c) Microsoft Corporation.
5291
-
5292
- Permission to use, copy, modify, and/or distribute this software for any
5293
- purpose with or without fee is hereby granted.
5294
-
5295
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
5296
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
5297
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
5298
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
5299
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
5300
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
5301
- PERFORMANCE OF THIS SOFTWARE.
5289
+ /******************************************************************************
5290
+ Copyright (c) Microsoft Corporation.
5291
+
5292
+ Permission to use, copy, modify, and/or distribute this software for any
5293
+ purpose with or without fee is hereby granted.
5294
+
5295
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
5296
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
5297
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
5298
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
5299
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
5300
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
5301
+ PERFORMANCE OF THIS SOFTWARE.
5302
5302
  ***************************************************************************** */ function __decorate$1(decorators, target, key, desc) {
5303
5303
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5304
5304
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5305
5305
  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;
5306
5306
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5307
5307
  }
5308
+ typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
5309
+ var e = new Error(message);
5310
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
5311
+ };
5308
5312
  function _instanceof1$2(left, right) {
5309
5313
  if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
5310
5314
  return !!right[Symbol.hasInstance](left);
@@ -6483,6 +6487,11 @@
6483
6487
  subFont.nativeFontString = fontString;
6484
6488
  for(var i = 0, n = subTexts.length; i < n; i++){
6485
6489
  var subText = subTexts[i];
6490
+ // If subText is empty, push an empty line directly
6491
+ if (subText.length === 0) {
6492
+ this._pushLine(lines, lineWidths, lineMaxSizes, "", 0, 0, 0);
6493
+ continue;
6494
+ }
6486
6495
  var word = "";
6487
6496
  var wordWidth = 0;
6488
6497
  var wordMaxAscent = 0;
@@ -6510,7 +6519,10 @@
6510
6519
  // If it is a word before, need to handle the previous word and line
6511
6520
  if (word.length > 0) {
6512
6521
  if (lineWidth + wordWidth > wrapWidth) {
6513
- this._pushLine(lines, lineWidths, lineMaxSizes, line, lineWidth, lineMaxAscent, lineMaxDescent);
6522
+ // Push if before line is not empty
6523
+ if (lineWidth > 0) {
6524
+ this._pushLine(lines, lineWidths, lineMaxSizes, line, lineWidth, lineMaxAscent, lineMaxDescent);
6525
+ }
6514
6526
  textWidth = Math.max(textWidth, lineWidth);
6515
6527
  notFirstLine = true;
6516
6528
  line = word;
@@ -6555,7 +6567,10 @@
6555
6567
  line = "";
6556
6568
  lineWidth = lineMaxAscent = lineMaxDescent = 0;
6557
6569
  }
6558
- this._pushLine(lines, lineWidths, lineMaxSizes, word, wordWidth, wordMaxAscent, wordMaxDescent);
6570
+ // Push if before word is not empty
6571
+ if (wordWidth > 0) {
6572
+ this._pushLine(lines, lineWidths, lineMaxSizes, word, wordWidth, wordMaxAscent, wordMaxDescent);
6573
+ }
6559
6574
  textWidth = Math.max(textWidth, wordWidth);
6560
6575
  notFirstLine = true;
6561
6576
  word = char;
@@ -6574,11 +6589,15 @@
6574
6589
  // If the total width from line and word exceed wrap width
6575
6590
  if (lineWidth + wordWidth > wrapWidth) {
6576
6591
  // Push chars to a single line
6577
- this._pushLine(lines, lineWidths, lineMaxSizes, line, lineWidth, lineMaxAscent, lineMaxDescent);
6592
+ if (lineWidth > 0) {
6593
+ this._pushLine(lines, lineWidths, lineMaxSizes, line, lineWidth, lineMaxAscent, lineMaxDescent);
6594
+ }
6578
6595
  textWidth = Math.max(textWidth, lineWidth);
6579
6596
  lineWidth = 0;
6580
6597
  // Push word to a single line
6581
- this._pushLine(lines, lineWidths, lineMaxSizes, word, wordWidth, wordMaxAscent, wordMaxDescent);
6598
+ if (wordWidth > 0) {
6599
+ this._pushLine(lines, lineWidths, lineMaxSizes, word, wordWidth, wordMaxAscent, wordMaxDescent);
6600
+ }
6582
6601
  textWidth = Math.max(textWidth, wordWidth);
6583
6602
  } else {
6584
6603
  // Merge to chars
@@ -6610,23 +6629,20 @@
6610
6629
  var subFont = renderer._subFont;
6611
6630
  var fontString = subFont.nativeFontString;
6612
6631
  var fontSizeInfo = TextUtils.measureFont(fontString);
6613
- var lines = renderer.text.split(/(?:\r\n|\r|\n)/);
6614
- var lineCount = lines.length;
6632
+ var subTexts = renderer.text.split(/(?:\r\n|\r|\n)/);
6633
+ var textCount = subTexts.length;
6634
+ var lines = new Array();
6615
6635
  var lineWidths = new Array();
6616
6636
  var lineMaxSizes = new Array();
6617
6637
  var _pixelsPerUnit = Engine._pixelsPerUnit;
6618
6638
  var lineHeight = fontSizeInfo.size + renderer.lineSpacing * _pixelsPerUnit;
6619
6639
  var width = 0;
6620
- var height = renderer.height * _pixelsPerUnit;
6621
- if (renderer.overflowMode === exports.OverflowMode.Overflow) {
6622
- height = lineHeight * lineCount;
6623
- }
6624
6640
  subFont.nativeFontString = fontString;
6625
- for(var i = 0; i < lineCount; ++i){
6626
- var line = lines[i];
6641
+ for(var i = 0; i < textCount; ++i){
6642
+ var line = subTexts[i];
6627
6643
  var curWidth = 0;
6628
- var maxAscent = -1;
6629
- var maxDescent = -1;
6644
+ var maxAscent = 0;
6645
+ var maxDescent = 0;
6630
6646
  for(var j = 0, m = line.length; j < m; ++j){
6631
6647
  var charInfo = TextUtils._getCharInfo(line[j], fontString, subFont);
6632
6648
  curWidth += charInfo.xAdvance;
@@ -6637,16 +6653,15 @@
6637
6653
  maxAscent < ascent && (maxAscent = ascent);
6638
6654
  maxDescent < descent && (maxDescent = descent);
6639
6655
  }
6640
- lineWidths[i] = curWidth;
6641
- lineMaxSizes[i] = {
6642
- ascent: maxAscent,
6643
- descent: maxDescent,
6644
- size: maxAscent + maxDescent
6645
- };
6646
- if (curWidth > width) {
6647
- width = curWidth;
6656
+ if (curWidth > 0) {
6657
+ this._pushLine(lines, lineWidths, lineMaxSizes, line, curWidth, maxAscent, maxDescent);
6658
+ width = Math.max(width, curWidth);
6648
6659
  }
6649
6660
  }
6661
+ var height = renderer.height * _pixelsPerUnit;
6662
+ if (renderer.overflowMode === exports.OverflowMode.Overflow) {
6663
+ height = lineHeight * lines.length;
6664
+ }
6650
6665
  return {
6651
6666
  width: width,
6652
6667
  height: height,
@@ -7492,7 +7507,6 @@
7492
7507
  var EventDispatcher = function EventDispatcher() {
7493
7508
  this._events = Object.create(null);
7494
7509
  this._eventCount = 0;
7495
- this._dispatchingListeners = [];
7496
7510
  };
7497
7511
  var _proto = EventDispatcher.prototype;
7498
7512
  /**
@@ -7532,7 +7546,8 @@
7532
7546
  if (Array.isArray(listeners)) {
7533
7547
  var count = listeners.length;
7534
7548
  // cloning list to avoid structure breaking
7535
- var dispatchingListeners = this._dispatchingListeners;
7549
+ var pool = EventDispatcher._dispatchingListenersPool;
7550
+ var dispatchingListeners = pool.length > 0 ? pool.pop() : [];
7536
7551
  dispatchingListeners.length = count;
7537
7552
  for(var i = 0; i < count; i++){
7538
7553
  dispatchingListeners[i] = listeners[i];
@@ -7546,6 +7561,7 @@
7546
7561
  }
7547
7562
  // remove hooked function to avoid gc problem
7548
7563
  dispatchingListeners.length = 0;
7564
+ pool.push(dispatchingListeners);
7549
7565
  } else {
7550
7566
  if (listeners.once) this.off(event, listeners.fn);
7551
7567
  listeners.fn(data);
@@ -7646,6 +7662,9 @@
7646
7662
  };
7647
7663
  return EventDispatcher;
7648
7664
  }();
7665
+ (function() {
7666
+ EventDispatcher._dispatchingListenersPool = [];
7667
+ })();
7649
7668
  /**
7650
7669
  * Shader property.
7651
7670
  */ var ShaderProperty = /*#__PURE__*/ function() {
@@ -8802,6 +8821,23 @@
8802
8821
  scale.z < 0 && (isInvert = !isInvert);
8803
8822
  return isInvert;
8804
8823
  };
8824
+ _proto._onDestroy = function _onDestroy() {
8825
+ Component.prototype._onDestroy.call(this);
8826
+ //@ts-ignore
8827
+ this._worldPosition._onValueChanged = null;
8828
+ //@ts-ignore
8829
+ this._rotation._onValueChanged = null;
8830
+ //@ts-ignore
8831
+ this._worldRotation._onValueChanged = null;
8832
+ //@ts-ignore
8833
+ this._rotationQuaternion._onValueChanged = null;
8834
+ //@ts-ignore
8835
+ this._worldRotationQuaternion._onValueChanged = null;
8836
+ //@ts-ignore
8837
+ this._position._onValueChanged = null;
8838
+ //@ts-ignore
8839
+ this._scale._onValueChanged = null;
8840
+ };
8805
8841
  /**
8806
8842
  * Get worldMatrix: Will trigger the worldMatrix update of itself and all parent entities.
8807
8843
  * Get worldPosition: Will trigger the worldMatrix, local position update of itself and the worldMatrix update of all parent entities.
@@ -9493,6 +9529,7 @@
9493
9529
  return component;
9494
9530
  }
9495
9531
  }
9532
+ return null;
9496
9533
  };
9497
9534
  /**
9498
9535
  * Get components which match the type.
@@ -18429,6 +18466,15 @@
18429
18466
  };
18430
18467
  /**
18431
18468
  * @internal
18469
+ */ _proto._prepareRender = function _prepareRender(context) {
18470
+ if (!this._mesh) {
18471
+ Logger.error("mesh is null.");
18472
+ return;
18473
+ }
18474
+ Renderer.prototype._prepareRender.call(this, context);
18475
+ };
18476
+ /**
18477
+ * @internal
18432
18478
  */ _proto._cloneTo = function _cloneTo(target) {
18433
18479
  Renderer.prototype._cloneTo.call(this, target);
18434
18480
  target.mesh = this._mesh;
@@ -18450,49 +18496,45 @@
18450
18496
  * @internal
18451
18497
  */ _proto._render = function _render(context) {
18452
18498
  var mesh = this._mesh;
18453
- if (mesh) {
18454
- if (this._dirtyUpdateFlag & 0x2) {
18455
- var shaderData = this.shaderData;
18456
- var vertexElements = mesh._vertexElements;
18457
- shaderData.disableMacro(MeshRenderer._uvMacro);
18458
- shaderData.disableMacro(MeshRenderer._uv1Macro);
18459
- shaderData.disableMacro(MeshRenderer._normalMacro);
18460
- shaderData.disableMacro(MeshRenderer._tangentMacro);
18461
- shaderData.disableMacro(MeshRenderer._enableVertexColorMacro);
18462
- for(var i = 0, n = vertexElements.length; i < n; i++){
18463
- switch(vertexElements[i].semantic){
18464
- case "TEXCOORD_0":
18465
- shaderData.enableMacro(MeshRenderer._uvMacro);
18466
- break;
18467
- case "TEXCOORD_1":
18468
- shaderData.enableMacro(MeshRenderer._uv1Macro);
18469
- break;
18470
- case "NORMAL":
18471
- shaderData.enableMacro(MeshRenderer._normalMacro);
18472
- break;
18473
- case "TANGENT":
18474
- shaderData.enableMacro(MeshRenderer._tangentMacro);
18475
- break;
18476
- case "COLOR_0":
18477
- this._enableVertexColor && shaderData.enableMacro(MeshRenderer._enableVertexColorMacro);
18478
- break;
18479
- }
18499
+ if (this._dirtyUpdateFlag & 0x2) {
18500
+ var shaderData = this.shaderData;
18501
+ var vertexElements = mesh._vertexElements;
18502
+ shaderData.disableMacro(MeshRenderer._uvMacro);
18503
+ shaderData.disableMacro(MeshRenderer._uv1Macro);
18504
+ shaderData.disableMacro(MeshRenderer._normalMacro);
18505
+ shaderData.disableMacro(MeshRenderer._tangentMacro);
18506
+ shaderData.disableMacro(MeshRenderer._enableVertexColorMacro);
18507
+ for(var i = 0, n = vertexElements.length; i < n; i++){
18508
+ switch(vertexElements[i].semantic){
18509
+ case "TEXCOORD_0":
18510
+ shaderData.enableMacro(MeshRenderer._uvMacro);
18511
+ break;
18512
+ case "TEXCOORD_1":
18513
+ shaderData.enableMacro(MeshRenderer._uv1Macro);
18514
+ break;
18515
+ case "NORMAL":
18516
+ shaderData.enableMacro(MeshRenderer._normalMacro);
18517
+ break;
18518
+ case "TANGENT":
18519
+ shaderData.enableMacro(MeshRenderer._tangentMacro);
18520
+ break;
18521
+ case "COLOR_0":
18522
+ this._enableVertexColor && shaderData.enableMacro(MeshRenderer._enableVertexColorMacro);
18523
+ break;
18480
18524
  }
18481
- this._dirtyUpdateFlag &= ~0x2;
18482
18525
  }
18483
- var materials = this._materials;
18484
- var subMeshes = mesh.subMeshes;
18485
- var renderPipeline = context.camera._renderPipeline;
18486
- var meshRenderDataPool = this._engine._meshRenderDataPool;
18487
- for(var i1 = 0, n1 = subMeshes.length; i1 < n1; i1++){
18488
- var material = materials[i1];
18489
- if (!material) continue;
18490
- var renderData = meshRenderDataPool.getFromPool();
18491
- renderData.set(this, material, mesh, subMeshes[i1]);
18492
- renderPipeline.pushRenderData(context, renderData);
18493
- }
18494
- } else {
18495
- Logger.error("mesh is null.");
18526
+ this._dirtyUpdateFlag &= ~0x2;
18527
+ }
18528
+ var materials = this._materials;
18529
+ var subMeshes = mesh.subMeshes;
18530
+ var renderPipeline = context.camera._renderPipeline;
18531
+ var meshRenderDataPool = this._engine._meshRenderDataPool;
18532
+ for(var i1 = 0, n1 = subMeshes.length; i1 < n1; i1++){
18533
+ var material = materials[i1];
18534
+ if (!material) continue;
18535
+ var renderData = meshRenderDataPool.getFromPool();
18536
+ renderData.set(this, material, mesh, subMeshes[i1]);
18537
+ renderPipeline.pushRenderData(context, renderData);
18496
18538
  }
18497
18539
  };
18498
18540
  _proto._setMesh = function _setMesh(mesh) {
@@ -24189,18 +24231,10 @@
24189
24231
  var _config_type;
24190
24232
  config.type = (_config_type = config.type) != null ? _config_type : getMimeTypeFromUrl(url);
24191
24233
  var realRequest = config.type === "image" ? requestImage : requestRes;
24192
- var lastError;
24193
24234
  var executor = new MultiExecutor(function() {
24194
- return realRequest(url, config).onProgress(setProgress).then(function(res) {
24195
- resolve(res);
24196
- executor.stop();
24197
- }).catch(function(err) {
24198
- return lastError = err;
24199
- });
24235
+ return realRequest(url, config).onProgress(setProgress);
24200
24236
  }, retryCount, retryInterval);
24201
- executor.start(function() {
24202
- reject(lastError);
24203
- });
24237
+ executor.start().onError(reject).onComplete(resolve);
24204
24238
  });
24205
24239
  }
24206
24240
  function requestImage(url, config) {
@@ -24287,23 +24321,33 @@
24287
24321
  this.exec = this.exec.bind(this);
24288
24322
  };
24289
24323
  var _proto = MultiExecutor.prototype;
24290
- _proto.start = function start(done) {
24291
- this.done = done;
24324
+ _proto.start = function start() {
24292
24325
  this.exec();
24326
+ return this;
24293
24327
  };
24294
- _proto.stop = function stop() {
24295
- clearTimeout(this._timeoutId);
24328
+ _proto.onComplete = function onComplete(func) {
24329
+ this._onComplete = func;
24330
+ return this;
24331
+ };
24332
+ _proto.onError = function onError(func) {
24333
+ this._onError = func;
24334
+ return this;
24335
+ };
24336
+ _proto.cancel = function cancel() {
24337
+ window.clearTimeout(this._timeoutId);
24296
24338
  };
24297
24339
  _proto.exec = function exec() {
24298
24340
  var _this = this;
24299
24341
  if (this._currentCount >= this.totalCount) {
24300
- this.done && this.done();
24342
+ this._onError && this._onError(this._error);
24301
24343
  return;
24302
24344
  }
24303
24345
  this._currentCount++;
24304
- this.execFunc(this._currentCount).then(function() {
24305
- //@ts-ignore
24306
- _this._timeoutId = setTimeout(_this.exec, _this.interval);
24346
+ this.execFunc(this._currentCount).then(function(result) {
24347
+ return _this._onComplete && _this._onComplete(result);
24348
+ }).catch(function(e) {
24349
+ _this._error = e;
24350
+ _this._timeoutId = window.setTimeout(_this.exec, _this.interval);
24307
24351
  });
24308
24352
  };
24309
24353
  return MultiExecutor;
@@ -26914,92 +26958,97 @@
26914
26958
  }
26915
26959
  };
26916
26960
  _proto._updateLocalData = function _updateLocalData() {
26917
- var _this = this, color = _this.color, horizontalAlignment = _this.horizontalAlignment, verticalAlignment = _this.verticalAlignment, charRenderDatas = _this._charRenderDatas;
26961
+ var _this = this, color = _this.color, charRenderDatas = _this._charRenderDatas, charFont = _this._subFont;
26918
26962
  var _this__localBounds = this._localBounds, min = _this__localBounds.min, max = _this__localBounds.max;
26919
- var _pixelsPerUnit = Engine._pixelsPerUnit;
26920
- var pixelsPerUnitReciprocal = 1.0 / _pixelsPerUnit;
26921
- var charFont = this._subFont;
26922
- var rendererWidth = this.width * _pixelsPerUnit;
26923
- var halfRendererWidth = rendererWidth * 0.5;
26924
- var rendererHeight = this.height * _pixelsPerUnit;
26925
26963
  var textMetrics = this.enableWrapping ? TextUtils.measureTextWithWrap(this) : TextUtils.measureTextWithoutWrap(this);
26926
26964
  var height = textMetrics.height, lines = textMetrics.lines, lineWidths = textMetrics.lineWidths, lineHeight = textMetrics.lineHeight, lineMaxSizes = textMetrics.lineMaxSizes;
26927
26965
  var charRenderDataPool = TextRenderer._charRenderDataPool;
26928
- var halfLineHeight = lineHeight * 0.5;
26929
26966
  var linesLen = lines.length;
26930
- var startY = 0;
26931
- var topDiff = lineHeight * 0.5 - lineMaxSizes[0].ascent;
26932
- var bottomDiff = lineHeight * 0.5 - lineMaxSizes[linesLen - 1].descent - 1;
26933
- switch(verticalAlignment){
26934
- case exports.TextVerticalAlignment.Top:
26935
- startY = rendererHeight * 0.5 - halfLineHeight + topDiff;
26936
- break;
26937
- case exports.TextVerticalAlignment.Center:
26938
- startY = height * 0.5 - halfLineHeight - (bottomDiff - topDiff) * 0.5;
26939
- break;
26940
- case exports.TextVerticalAlignment.Bottom:
26941
- startY = height - rendererHeight * 0.5 - halfLineHeight - bottomDiff;
26942
- break;
26943
- }
26944
26967
  var renderDataCount = 0;
26945
- var firstLine = -1;
26946
- var minX = Number.MAX_SAFE_INTEGER;
26947
- var minY = Number.MAX_SAFE_INTEGER;
26948
- var maxX = Number.MIN_SAFE_INTEGER;
26949
- var maxY = Number.MIN_SAFE_INTEGER;
26950
- for(var i = 0; i < linesLen; ++i){
26951
- var lineWidth = lineWidths[i];
26952
- if (lineWidth > 0) {
26953
- var line = lines[i];
26954
- var startX = 0;
26955
- var firstRow = -1;
26956
- if (firstLine < 0) {
26957
- firstLine = i;
26958
- }
26959
- switch(horizontalAlignment){
26960
- case exports.TextHorizontalAlignment.Left:
26961
- startX = -halfRendererWidth;
26962
- break;
26963
- case exports.TextHorizontalAlignment.Center:
26964
- startX = -lineWidth * 0.5;
26965
- break;
26966
- case exports.TextHorizontalAlignment.Right:
26967
- startX = halfRendererWidth - lineWidth;
26968
- break;
26969
- }
26970
- for(var j = 0, n = line.length; j < n; ++j){
26971
- var char = line[j];
26972
- var charInfo = charFont._getCharInfo(char);
26973
- if (charInfo.h > 0) {
26974
- var _charRenderDatas, _ref;
26975
- firstRow < 0 && (firstRow = j);
26976
- var charRenderData = (_charRenderDatas = charRenderDatas)[_ref = renderDataCount++] || (_charRenderDatas[_ref] = charRenderDataPool.get());
26977
- var renderData = charRenderData.renderData, localPositions = charRenderData.localPositions;
26978
- charRenderData.texture = charFont._getTextureByIndex(charInfo.index);
26979
- renderData.color = color;
26980
- renderData.uvs = charInfo.uvs;
26981
- var w = charInfo.w, ascent = charInfo.ascent, descent = charInfo.descent;
26982
- var left = startX * pixelsPerUnitReciprocal;
26983
- var right = (startX + w) * pixelsPerUnitReciprocal;
26984
- var top = (startY + ascent) * pixelsPerUnitReciprocal;
26985
- var bottom = (startY - descent + 1) * pixelsPerUnitReciprocal;
26986
- localPositions.set(left, top, right, bottom);
26987
- i === firstLine && (maxY = Math.max(maxY, top));
26988
- minY = Math.min(minY, bottom);
26989
- j === firstRow && (minX = Math.min(minX, left));
26990
- maxX = Math.max(maxX, right);
26968
+ if (linesLen > 0) {
26969
+ var _pixelsPerUnit = Engine._pixelsPerUnit;
26970
+ var horizontalAlignment = this.horizontalAlignment;
26971
+ var pixelsPerUnitReciprocal = 1.0 / _pixelsPerUnit;
26972
+ var rendererWidth = this.width * _pixelsPerUnit;
26973
+ var halfRendererWidth = rendererWidth * 0.5;
26974
+ var rendererHeight = this.height * _pixelsPerUnit;
26975
+ var halfLineHeight = lineHeight * 0.5;
26976
+ var startY = 0;
26977
+ var topDiff = lineHeight * 0.5 - lineMaxSizes[0].ascent;
26978
+ var bottomDiff = lineHeight * 0.5 - lineMaxSizes[linesLen - 1].descent - 1;
26979
+ switch(this.verticalAlignment){
26980
+ case exports.TextVerticalAlignment.Top:
26981
+ startY = rendererHeight * 0.5 - halfLineHeight + topDiff;
26982
+ break;
26983
+ case exports.TextVerticalAlignment.Center:
26984
+ startY = height * 0.5 - halfLineHeight - (bottomDiff - topDiff) * 0.5;
26985
+ break;
26986
+ case exports.TextVerticalAlignment.Bottom:
26987
+ startY = height - rendererHeight * 0.5 - halfLineHeight - bottomDiff;
26988
+ break;
26989
+ }
26990
+ var firstLine = -1;
26991
+ var minX = Number.MAX_SAFE_INTEGER;
26992
+ var minY = Number.MAX_SAFE_INTEGER;
26993
+ var maxX = Number.MIN_SAFE_INTEGER;
26994
+ var maxY = Number.MIN_SAFE_INTEGER;
26995
+ for(var i = 0; i < linesLen; ++i){
26996
+ var lineWidth = lineWidths[i];
26997
+ if (lineWidth > 0) {
26998
+ var line = lines[i];
26999
+ var startX = 0;
27000
+ var firstRow = -1;
27001
+ if (firstLine < 0) {
27002
+ firstLine = i;
27003
+ }
27004
+ switch(horizontalAlignment){
27005
+ case exports.TextHorizontalAlignment.Left:
27006
+ startX = -halfRendererWidth;
27007
+ break;
27008
+ case exports.TextHorizontalAlignment.Center:
27009
+ startX = -lineWidth * 0.5;
27010
+ break;
27011
+ case exports.TextHorizontalAlignment.Right:
27012
+ startX = halfRendererWidth - lineWidth;
27013
+ break;
27014
+ }
27015
+ for(var j = 0, n = line.length; j < n; ++j){
27016
+ var char = line[j];
27017
+ var charInfo = charFont._getCharInfo(char);
27018
+ if (charInfo.h > 0) {
27019
+ var _charRenderDatas, _ref;
27020
+ firstRow < 0 && (firstRow = j);
27021
+ var charRenderData = (_charRenderDatas = charRenderDatas)[_ref = renderDataCount++] || (_charRenderDatas[_ref] = charRenderDataPool.get());
27022
+ var renderData = charRenderData.renderData, localPositions = charRenderData.localPositions;
27023
+ charRenderData.texture = charFont._getTextureByIndex(charInfo.index);
27024
+ renderData.color = color;
27025
+ renderData.uvs = charInfo.uvs;
27026
+ var w = charInfo.w, ascent = charInfo.ascent, descent = charInfo.descent;
27027
+ var left = startX * pixelsPerUnitReciprocal;
27028
+ var right = (startX + w) * pixelsPerUnitReciprocal;
27029
+ var top = (startY + ascent) * pixelsPerUnitReciprocal;
27030
+ var bottom = (startY - descent + 1) * pixelsPerUnitReciprocal;
27031
+ localPositions.set(left, top, right, bottom);
27032
+ i === firstLine && (maxY = Math.max(maxY, top));
27033
+ minY = Math.min(minY, bottom);
27034
+ j === firstRow && (minX = Math.min(minX, left));
27035
+ maxX = Math.max(maxX, right);
27036
+ }
27037
+ startX += charInfo.xAdvance;
26991
27038
  }
26992
- startX += charInfo.xAdvance;
26993
27039
  }
27040
+ startY -= lineHeight;
26994
27041
  }
26995
- startY -= lineHeight;
26996
- }
26997
- if (firstLine < 0) {
27042
+ if (firstLine < 0) {
27043
+ min.set(0, 0, 0);
27044
+ max.set(0, 0, 0);
27045
+ } else {
27046
+ min.set(minX, minY, 0);
27047
+ max.set(maxX, maxY, 0);
27048
+ }
27049
+ } else {
26998
27050
  min.set(0, 0, 0);
26999
27051
  max.set(0, 0, 0);
27000
- } else {
27001
- min.set(minX, minY, 0);
27002
- max.set(maxX, maxY, 0);
27003
27052
  }
27004
27053
  // Revert excess render data to pool.
27005
27054
  var lastRenderDataCount = charRenderDatas.length;
@@ -28982,7 +29031,8 @@
28982
29031
  };
28983
29032
  _proto._saveAnimatorEventHandlers = function _saveAnimatorEventHandlers(state, animatorStateData) {
28984
29033
  var eventHandlerPool = this._animationEventHandlerPool;
28985
- var scripts = this._entity._scripts;
29034
+ var scripts = [];
29035
+ this._entity.getComponents(Script, scripts);
28986
29036
  var scriptCount = scripts.length;
28987
29037
  var eventHandlers = animatorStateData.eventHandlers;
28988
29038
  var events = state.clip.events;
@@ -28995,7 +29045,7 @@
28995
29045
  eventHandler.event = event;
28996
29046
  handlers.length = 0;
28997
29047
  for(var j = scriptCount - 1; j >= 0; j--){
28998
- var handler = scripts.get(j)[funcName];
29048
+ var handler = scripts[j][funcName];
28999
29049
  handler && handlers.push(handler);
29000
29050
  }
29001
29051
  eventHandlers.push(eventHandler);
@@ -33587,19 +33637,19 @@
33587
33637
  });
33588
33638
  if (superClass) _set_prototype_of(subClass, superClass);
33589
33639
  }
33590
- /******************************************************************************
33591
- Copyright (c) Microsoft Corporation.
33592
-
33593
- Permission to use, copy, modify, and/or distribute this software for any
33594
- purpose with or without fee is hereby granted.
33595
-
33596
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
33597
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
33598
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
33599
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
33600
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
33601
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
33602
- PERFORMANCE OF THIS SOFTWARE.
33640
+ /******************************************************************************
33641
+ Copyright (c) Microsoft Corporation.
33642
+
33643
+ Permission to use, copy, modify, and/or distribute this software for any
33644
+ purpose with or without fee is hereby granted.
33645
+
33646
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
33647
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
33648
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
33649
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
33650
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
33651
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
33652
+ PERFORMANCE OF THIS SOFTWARE.
33603
33653
  ***************************************************************************** */ function __decorate(decorators, target, key, desc) {
33604
33654
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
33605
33655
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -33701,6 +33751,10 @@
33701
33751
  return this;
33702
33752
  }), g;
33703
33753
  }
33754
+ typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
33755
+ var e = new Error(message);
33756
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
33757
+ };
33704
33758
  var AnimatorControllerLoader = /*#__PURE__*/ function(Loader1) {
33705
33759
  var AnimatorControllerLoader = function AnimatorControllerLoader() {
33706
33760
  return Loader1.apply(this, arguments);
@@ -34038,15 +34092,18 @@
34038
34092
  for(var _iterator2 = _create_for_of_iterator_helper_loose(meshInfo.blendShapes), _step2; !(_step2 = _iterator2()).done;){
34039
34093
  var restoreInfo = _step2.value;
34040
34094
  var frame = restoreInfo.blendShape.frames[0];
34041
- var positionData = _this._getBufferData(buffers, restoreInfo.position);
34042
- frame.deltaPositions = GLTFUtils.floatBufferToVector3Array(positionData);
34095
+ var position = restoreInfo.position;
34096
+ var positionData = _this._getBufferData(buffers, position.buffer);
34097
+ frame.deltaPositions = GLTFUtils.bufferToVector3Array(positionData, position.stride, position.byteOffset, position.count);
34043
34098
  if (restoreInfo.normal) {
34044
- var normalData = _this._getBufferData(buffers, restoreInfo.normal);
34045
- frame.deltaNormals = GLTFUtils.floatBufferToVector3Array(normalData);
34099
+ var normal = restoreInfo.normal;
34100
+ var normalData = _this._getBufferData(buffers, normal.buffer);
34101
+ frame.deltaNormals = GLTFUtils.bufferToVector3Array(normalData, normal.stride, normal.byteOffset, normal.count);
34046
34102
  }
34047
34103
  if (restoreInfo.tangent) {
34048
- var tangentData = _this._getBufferData(buffers, restoreInfo.tangent);
34049
- frame.deltaTangents = GLTFUtils.floatBufferToVector3Array(tangentData);
34104
+ var tangent = restoreInfo.tangent;
34105
+ var tangentData = _this._getBufferData(buffers, tangent.buffer);
34106
+ frame.deltaTangents = GLTFUtils.bufferToVector3Array(tangentData, tangent.stride, tangent.byteOffset, tangent.count);
34050
34107
  }
34051
34108
  }
34052
34109
  mesh.uploadData(true);
@@ -34130,6 +34187,14 @@
34130
34187
  this.normal = normal;
34131
34188
  this.tangent = tangent;
34132
34189
  };
34190
+ /**
34191
+ * @internal
34192
+ */ var BlendShapeDataRestoreInfo = function BlendShapeDataRestoreInfo(buffer, stride, byteOffset, count) {
34193
+ this.buffer = buffer;
34194
+ this.stride = stride;
34195
+ this.byteOffset = byteOffset;
34196
+ this.count = count;
34197
+ };
34133
34198
  /**
34134
34199
  * Module for glTF 2.0 Interface
34135
34200
  */ var AccessorComponentType;
@@ -34428,8 +34493,10 @@
34428
34493
  return context.getBuffers().then(function(buffers) {
34429
34494
  var bufferIndex = bufferView.buffer;
34430
34495
  var buffer = buffers[bufferIndex];
34431
- var bufferByteOffset = bufferView.byteOffset || 0;
34432
- var byteOffset = accessor.byteOffset || 0;
34496
+ var _bufferView_byteOffset;
34497
+ var bufferByteOffset = (_bufferView_byteOffset = bufferView.byteOffset) != null ? _bufferView_byteOffset : 0;
34498
+ var _accessor_byteOffset;
34499
+ var byteOffset = (_accessor_byteOffset = accessor.byteOffset) != null ? _accessor_byteOffset : 0;
34433
34500
  var TypedArray = GLTFUtils.getComponentType(componentType);
34434
34501
  var dataElementSize = GLTFUtils.getAccessorTypeSize(accessor.type);
34435
34502
  var dataElementBytes = TypedArray.BYTES_PER_ELEMENT;
@@ -34463,6 +34530,17 @@
34463
34530
  return bufferInfo;
34464
34531
  });
34465
34532
  };
34533
+ GLTFUtils.bufferToVector3Array = function bufferToVector3Array(data, byteStride, accessorByteOffset, count) {
34534
+ var bytesPerElement = data.BYTES_PER_ELEMENT;
34535
+ var offset = accessorByteOffset % byteStride / bytesPerElement;
34536
+ var stride = byteStride / bytesPerElement;
34537
+ var vector3s = new Array(count);
34538
+ for(var i = 0; i < count; i++){
34539
+ var index = offset + i * stride;
34540
+ vector3s[i] = new Vector3(data[index], data[index + 1], data[index + 2]);
34541
+ }
34542
+ return vector3s;
34543
+ };
34466
34544
  /**
34467
34545
  * @deprecated
34468
34546
  * Get accessor data.
@@ -35556,7 +35634,7 @@
35556
35634
  }
35557
35635
  // BlendShapes
35558
35636
  if (targets) {
35559
- promises.push(GLTFMeshParser._createBlendShape(mesh, meshRestoreInfo, gltfMesh, targets, getBlendShapeData));
35637
+ promises.push(GLTFMeshParser._createBlendShape(mesh, meshRestoreInfo, gltfMesh, accessors, targets, getBlendShapeData));
35560
35638
  }
35561
35639
  return Promise.all(promises).then(function() {
35562
35640
  mesh.uploadData(!keepMeshData);
@@ -35572,7 +35650,7 @@
35572
35650
  };
35573
35651
  /**
35574
35652
  * @internal
35575
- */ GLTFMeshParser._createBlendShape = function _createBlendShape(mesh, meshRestoreInfo, glTFMesh, glTFTargets, getBlendShapeData) {
35653
+ */ GLTFMeshParser._createBlendShape = function _createBlendShape(mesh, meshRestoreInfo, glTFMesh, accessors, glTFTargets, getBlendShapeData) {
35576
35654
  var _loop = function _loop(i, n) {
35577
35655
  var name = blendShapeNames ? blendShapeNames[i] : "blendShape" + i;
35578
35656
  var promise = Promise.all([
@@ -35580,16 +35658,36 @@
35580
35658
  getBlendShapeData("NORMAL", i),
35581
35659
  getBlendShapeData("TANGENT", i)
35582
35660
  ]).then(function(infos) {
35583
- var deltaPosBufferInfo = infos[0];
35584
- var deltaNorBufferInfo = infos[1];
35585
- var deltaTanBufferInfo = infos[2];
35586
- var deltaPositions = deltaPosBufferInfo.data ? GLTFUtils.floatBufferToVector3Array(deltaPosBufferInfo.data) : null;
35587
- var deltaNormals = (deltaNorBufferInfo == null ? void 0 : deltaNorBufferInfo.data) ? GLTFUtils.floatBufferToVector3Array(deltaNorBufferInfo == null ? void 0 : deltaNorBufferInfo.data) : null;
35588
- var deltaTangents = (deltaTanBufferInfo == null ? void 0 : deltaTanBufferInfo.data) ? GLTFUtils.floatBufferToVector3Array(deltaTanBufferInfo == null ? void 0 : deltaTanBufferInfo.data) : null;
35661
+ var posBufferInfo = infos[0];
35662
+ var norBufferInfo = infos[1];
35663
+ var tanBufferInfo = infos[2];
35664
+ var target = glTFTargets[i];
35665
+ var posAccessor;
35666
+ var norAccessor;
35667
+ var tanAccessor;
35668
+ var positions = null;
35669
+ if (posBufferInfo) {
35670
+ posAccessor = accessors[target["POSITION"]];
35671
+ var _posAccessor_byteOffset;
35672
+ positions = GLTFUtils.bufferToVector3Array(posBufferInfo.data, posBufferInfo.stride, (_posAccessor_byteOffset = posAccessor.byteOffset) != null ? _posAccessor_byteOffset : 0, posAccessor.count);
35673
+ }
35674
+ var normals = null;
35675
+ if (norBufferInfo) {
35676
+ norAccessor = accessors[target["NORMAL"]];
35677
+ var _norAccessor_byteOffset;
35678
+ normals = GLTFUtils.bufferToVector3Array(norBufferInfo.data, norBufferInfo.stride, (_norAccessor_byteOffset = norAccessor.byteOffset) != null ? _norAccessor_byteOffset : 0, norAccessor.count);
35679
+ }
35680
+ var tangents = null;
35681
+ if (tanBufferInfo) {
35682
+ tanAccessor = accessors[target["NORMAL"]];
35683
+ var _tanAccessor_byteOffset;
35684
+ tangents = GLTFUtils.bufferToVector3Array(tanBufferInfo.data, tanBufferInfo.stride, (_tanAccessor_byteOffset = tanAccessor.byteOffset) != null ? _tanAccessor_byteOffset : 0, tanAccessor.count);
35685
+ }
35589
35686
  var blendShape = new BlendShape(name);
35590
- blendShape.addFrame(1.0, deltaPositions, deltaNormals, deltaTangents);
35687
+ blendShape.addFrame(1.0, positions, normals, tangents);
35591
35688
  mesh.addBlendShape(blendShape);
35592
- meshRestoreInfo.blendShapes.push(new BlendShapeRestoreInfo(blendShape, deltaPosBufferInfo.restoreInfo, deltaNorBufferInfo == null ? void 0 : deltaNorBufferInfo.restoreInfo, deltaTanBufferInfo == null ? void 0 : deltaTanBufferInfo.restoreInfo));
35689
+ var _posAccessor_byteOffset1, _norAccessor_byteOffset1, _tanAccessor_byteOffset1;
35690
+ meshRestoreInfo.blendShapes.push(new BlendShapeRestoreInfo(blendShape, new BlendShapeDataRestoreInfo(posBufferInfo.restoreInfo, posBufferInfo.stride, (_posAccessor_byteOffset1 = posAccessor.byteOffset) != null ? _posAccessor_byteOffset1 : 0, posAccessor.count), norBufferInfo ? new BlendShapeDataRestoreInfo(norBufferInfo.restoreInfo, norBufferInfo.stride, (_norAccessor_byteOffset1 = norAccessor.byteOffset) != null ? _norAccessor_byteOffset1 : 0, norAccessor.count) : null, tanBufferInfo ? new BlendShapeDataRestoreInfo(tanBufferInfo.restoreInfo, tanBufferInfo.stride, (_tanAccessor_byteOffset1 = tanAccessor.byteOffset) != null ? _tanAccessor_byteOffset1 : 0, tanAccessor.count) : null));
35593
35691
  });
35594
35692
  promises.push(promise);
35595
35693
  };
@@ -35916,13 +36014,13 @@
35916
36014
  };
35917
36015
  _proto._parseSampler = function _parseSampler(texture, samplerInfo) {
35918
36016
  var filterMode = samplerInfo.filterMode, wrapModeU = samplerInfo.wrapModeU, wrapModeV = samplerInfo.wrapModeV;
35919
- if (filterMode) {
36017
+ if (filterMode !== undefined) {
35920
36018
  texture.filterMode = filterMode;
35921
36019
  }
35922
- if (wrapModeU) {
36020
+ if (wrapModeU !== undefined) {
35923
36021
  texture.wrapModeU = wrapModeU;
35924
36022
  }
35925
- if (wrapModeV) {
36023
+ if (wrapModeV !== undefined) {
35926
36024
  texture.wrapModeV = wrapModeV;
35927
36025
  }
35928
36026
  };
@@ -36056,7 +36154,7 @@
36056
36154
  resourceManager.addContentRestorer(restorer);
36057
36155
  masterPromiseInfo.resolve(glTFResource);
36058
36156
  }).catch(function(e) {
36059
- var msg = "Error loading glTF model from " + url + " .";
36157
+ var msg = "Error loading glTF model from " + url + " : " + e;
36060
36158
  Logger.error(msg);
36061
36159
  masterPromiseInfo.reject(msg);
36062
36160
  context.defaultSceneRootPromiseInfo.reject(e);
@@ -38251,7 +38349,7 @@
38251
38349
  mesh.addSubMesh(0, vertexCount, mode);
38252
38350
  }
38253
38351
  // BlendShapes
38254
- targets && GLTFMeshParser._createBlendShape(mesh, null, gltfMesh, targets, getBlendShapeData);
38352
+ targets && GLTFMeshParser._createBlendShape(mesh, null, gltfMesh, accessors, targets, getBlendShapeData);
38255
38353
  mesh.uploadData(!keepMeshData);
38256
38354
  return Promise.resolve(mesh);
38257
38355
  };
@@ -38477,7 +38575,7 @@
38477
38575
  ], GALACEAN_animation_event);
38478
38576
 
38479
38577
  //@ts-ignore
38480
- var version = "1.0.0-beta.17";
38578
+ var version = "1.0.0-beta.19";
38481
38579
  console.log("Galacean engine version: " + version);
38482
38580
  for(var key in CoreObjects){
38483
38581
  Loader.registerClass(key, CoreObjects[key]);