@galacean/engine 1.0.0-beta.17 → 1.0.0-beta.18

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
@@ -6483,6 +6483,11 @@
6483
6483
  subFont.nativeFontString = fontString;
6484
6484
  for(var i = 0, n = subTexts.length; i < n; i++){
6485
6485
  var subText = subTexts[i];
6486
+ // If subText is empty, push an empty line directly
6487
+ if (subText.length === 0) {
6488
+ this._pushLine(lines, lineWidths, lineMaxSizes, "", 0, 0, 0);
6489
+ continue;
6490
+ }
6486
6491
  var word = "";
6487
6492
  var wordWidth = 0;
6488
6493
  var wordMaxAscent = 0;
@@ -6510,7 +6515,10 @@
6510
6515
  // If it is a word before, need to handle the previous word and line
6511
6516
  if (word.length > 0) {
6512
6517
  if (lineWidth + wordWidth > wrapWidth) {
6513
- this._pushLine(lines, lineWidths, lineMaxSizes, line, lineWidth, lineMaxAscent, lineMaxDescent);
6518
+ // Push if before line is not empty
6519
+ if (lineWidth > 0) {
6520
+ this._pushLine(lines, lineWidths, lineMaxSizes, line, lineWidth, lineMaxAscent, lineMaxDescent);
6521
+ }
6514
6522
  textWidth = Math.max(textWidth, lineWidth);
6515
6523
  notFirstLine = true;
6516
6524
  line = word;
@@ -6555,7 +6563,10 @@
6555
6563
  line = "";
6556
6564
  lineWidth = lineMaxAscent = lineMaxDescent = 0;
6557
6565
  }
6558
- this._pushLine(lines, lineWidths, lineMaxSizes, word, wordWidth, wordMaxAscent, wordMaxDescent);
6566
+ // Push if before word is not empty
6567
+ if (wordWidth > 0) {
6568
+ this._pushLine(lines, lineWidths, lineMaxSizes, word, wordWidth, wordMaxAscent, wordMaxDescent);
6569
+ }
6559
6570
  textWidth = Math.max(textWidth, wordWidth);
6560
6571
  notFirstLine = true;
6561
6572
  word = char;
@@ -6574,11 +6585,15 @@
6574
6585
  // If the total width from line and word exceed wrap width
6575
6586
  if (lineWidth + wordWidth > wrapWidth) {
6576
6587
  // Push chars to a single line
6577
- this._pushLine(lines, lineWidths, lineMaxSizes, line, lineWidth, lineMaxAscent, lineMaxDescent);
6588
+ if (lineWidth > 0) {
6589
+ this._pushLine(lines, lineWidths, lineMaxSizes, line, lineWidth, lineMaxAscent, lineMaxDescent);
6590
+ }
6578
6591
  textWidth = Math.max(textWidth, lineWidth);
6579
6592
  lineWidth = 0;
6580
6593
  // Push word to a single line
6581
- this._pushLine(lines, lineWidths, lineMaxSizes, word, wordWidth, wordMaxAscent, wordMaxDescent);
6594
+ if (wordWidth > 0) {
6595
+ this._pushLine(lines, lineWidths, lineMaxSizes, word, wordWidth, wordMaxAscent, wordMaxDescent);
6596
+ }
6582
6597
  textWidth = Math.max(textWidth, wordWidth);
6583
6598
  } else {
6584
6599
  // Merge to chars
@@ -6610,23 +6625,20 @@
6610
6625
  var subFont = renderer._subFont;
6611
6626
  var fontString = subFont.nativeFontString;
6612
6627
  var fontSizeInfo = TextUtils.measureFont(fontString);
6613
- var lines = renderer.text.split(/(?:\r\n|\r|\n)/);
6614
- var lineCount = lines.length;
6628
+ var subTexts = renderer.text.split(/(?:\r\n|\r|\n)/);
6629
+ var textCount = subTexts.length;
6630
+ var lines = new Array();
6615
6631
  var lineWidths = new Array();
6616
6632
  var lineMaxSizes = new Array();
6617
6633
  var _pixelsPerUnit = Engine._pixelsPerUnit;
6618
6634
  var lineHeight = fontSizeInfo.size + renderer.lineSpacing * _pixelsPerUnit;
6619
6635
  var width = 0;
6620
- var height = renderer.height * _pixelsPerUnit;
6621
- if (renderer.overflowMode === exports.OverflowMode.Overflow) {
6622
- height = lineHeight * lineCount;
6623
- }
6624
6636
  subFont.nativeFontString = fontString;
6625
- for(var i = 0; i < lineCount; ++i){
6626
- var line = lines[i];
6637
+ for(var i = 0; i < textCount; ++i){
6638
+ var line = subTexts[i];
6627
6639
  var curWidth = 0;
6628
- var maxAscent = -1;
6629
- var maxDescent = -1;
6640
+ var maxAscent = 0;
6641
+ var maxDescent = 0;
6630
6642
  for(var j = 0, m = line.length; j < m; ++j){
6631
6643
  var charInfo = TextUtils._getCharInfo(line[j], fontString, subFont);
6632
6644
  curWidth += charInfo.xAdvance;
@@ -6637,16 +6649,15 @@
6637
6649
  maxAscent < ascent && (maxAscent = ascent);
6638
6650
  maxDescent < descent && (maxDescent = descent);
6639
6651
  }
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;
6652
+ if (curWidth > 0) {
6653
+ this._pushLine(lines, lineWidths, lineMaxSizes, line, curWidth, maxAscent, maxDescent);
6654
+ width = Math.max(width, curWidth);
6648
6655
  }
6649
6656
  }
6657
+ var height = renderer.height * _pixelsPerUnit;
6658
+ if (renderer.overflowMode === exports.OverflowMode.Overflow) {
6659
+ height = lineHeight * lines.length;
6660
+ }
6650
6661
  return {
6651
6662
  width: width,
6652
6663
  height: height,
@@ -7492,7 +7503,6 @@
7492
7503
  var EventDispatcher = function EventDispatcher() {
7493
7504
  this._events = Object.create(null);
7494
7505
  this._eventCount = 0;
7495
- this._dispatchingListeners = [];
7496
7506
  };
7497
7507
  var _proto = EventDispatcher.prototype;
7498
7508
  /**
@@ -7532,7 +7542,8 @@
7532
7542
  if (Array.isArray(listeners)) {
7533
7543
  var count = listeners.length;
7534
7544
  // cloning list to avoid structure breaking
7535
- var dispatchingListeners = this._dispatchingListeners;
7545
+ var pool = EventDispatcher._dispatchingListenersPool;
7546
+ var dispatchingListeners = pool.length > 0 ? pool.pop() : [];
7536
7547
  dispatchingListeners.length = count;
7537
7548
  for(var i = 0; i < count; i++){
7538
7549
  dispatchingListeners[i] = listeners[i];
@@ -7546,6 +7557,7 @@
7546
7557
  }
7547
7558
  // remove hooked function to avoid gc problem
7548
7559
  dispatchingListeners.length = 0;
7560
+ pool.push(dispatchingListeners);
7549
7561
  } else {
7550
7562
  if (listeners.once) this.off(event, listeners.fn);
7551
7563
  listeners.fn(data);
@@ -7646,6 +7658,9 @@
7646
7658
  };
7647
7659
  return EventDispatcher;
7648
7660
  }();
7661
+ (function() {
7662
+ EventDispatcher._dispatchingListenersPool = [];
7663
+ })();
7649
7664
  /**
7650
7665
  * Shader property.
7651
7666
  */ var ShaderProperty = /*#__PURE__*/ function() {
@@ -18429,6 +18444,15 @@
18429
18444
  };
18430
18445
  /**
18431
18446
  * @internal
18447
+ */ _proto._prepareRender = function _prepareRender(context) {
18448
+ if (!this._mesh) {
18449
+ Logger.error("mesh is null.");
18450
+ return;
18451
+ }
18452
+ Renderer.prototype._prepareRender.call(this, context);
18453
+ };
18454
+ /**
18455
+ * @internal
18432
18456
  */ _proto._cloneTo = function _cloneTo(target) {
18433
18457
  Renderer.prototype._cloneTo.call(this, target);
18434
18458
  target.mesh = this._mesh;
@@ -18450,49 +18474,45 @@
18450
18474
  * @internal
18451
18475
  */ _proto._render = function _render(context) {
18452
18476
  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
- }
18477
+ if (this._dirtyUpdateFlag & 0x2) {
18478
+ var shaderData = this.shaderData;
18479
+ var vertexElements = mesh._vertexElements;
18480
+ shaderData.disableMacro(MeshRenderer._uvMacro);
18481
+ shaderData.disableMacro(MeshRenderer._uv1Macro);
18482
+ shaderData.disableMacro(MeshRenderer._normalMacro);
18483
+ shaderData.disableMacro(MeshRenderer._tangentMacro);
18484
+ shaderData.disableMacro(MeshRenderer._enableVertexColorMacro);
18485
+ for(var i = 0, n = vertexElements.length; i < n; i++){
18486
+ switch(vertexElements[i].semantic){
18487
+ case "TEXCOORD_0":
18488
+ shaderData.enableMacro(MeshRenderer._uvMacro);
18489
+ break;
18490
+ case "TEXCOORD_1":
18491
+ shaderData.enableMacro(MeshRenderer._uv1Macro);
18492
+ break;
18493
+ case "NORMAL":
18494
+ shaderData.enableMacro(MeshRenderer._normalMacro);
18495
+ break;
18496
+ case "TANGENT":
18497
+ shaderData.enableMacro(MeshRenderer._tangentMacro);
18498
+ break;
18499
+ case "COLOR_0":
18500
+ this._enableVertexColor && shaderData.enableMacro(MeshRenderer._enableVertexColorMacro);
18501
+ break;
18480
18502
  }
18481
- this._dirtyUpdateFlag &= ~0x2;
18482
- }
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
18503
  }
18494
- } else {
18495
- Logger.error("mesh is null.");
18504
+ this._dirtyUpdateFlag &= ~0x2;
18505
+ }
18506
+ var materials = this._materials;
18507
+ var subMeshes = mesh.subMeshes;
18508
+ var renderPipeline = context.camera._renderPipeline;
18509
+ var meshRenderDataPool = this._engine._meshRenderDataPool;
18510
+ for(var i1 = 0, n1 = subMeshes.length; i1 < n1; i1++){
18511
+ var material = materials[i1];
18512
+ if (!material) continue;
18513
+ var renderData = meshRenderDataPool.getFromPool();
18514
+ renderData.set(this, material, mesh, subMeshes[i1]);
18515
+ renderPipeline.pushRenderData(context, renderData);
18496
18516
  }
18497
18517
  };
18498
18518
  _proto._setMesh = function _setMesh(mesh) {
@@ -24189,18 +24209,10 @@
24189
24209
  var _config_type;
24190
24210
  config.type = (_config_type = config.type) != null ? _config_type : getMimeTypeFromUrl(url);
24191
24211
  var realRequest = config.type === "image" ? requestImage : requestRes;
24192
- var lastError;
24193
24212
  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
- });
24213
+ return realRequest(url, config).onProgress(setProgress);
24200
24214
  }, retryCount, retryInterval);
24201
- executor.start(function() {
24202
- reject(lastError);
24203
- });
24215
+ executor.start().onError(reject).onComplete(resolve);
24204
24216
  });
24205
24217
  }
24206
24218
  function requestImage(url, config) {
@@ -24287,23 +24299,33 @@
24287
24299
  this.exec = this.exec.bind(this);
24288
24300
  };
24289
24301
  var _proto = MultiExecutor.prototype;
24290
- _proto.start = function start(done) {
24291
- this.done = done;
24302
+ _proto.start = function start() {
24292
24303
  this.exec();
24304
+ return this;
24293
24305
  };
24294
- _proto.stop = function stop() {
24295
- clearTimeout(this._timeoutId);
24306
+ _proto.onComplete = function onComplete(func) {
24307
+ this._onComplete = func;
24308
+ return this;
24309
+ };
24310
+ _proto.onError = function onError(func) {
24311
+ this._onError = func;
24312
+ return this;
24313
+ };
24314
+ _proto.cancel = function cancel() {
24315
+ window.clearTimeout(this._timeoutId);
24296
24316
  };
24297
24317
  _proto.exec = function exec() {
24298
24318
  var _this = this;
24299
24319
  if (this._currentCount >= this.totalCount) {
24300
- this.done && this.done();
24320
+ this._onError && this._onError(this._error);
24301
24321
  return;
24302
24322
  }
24303
24323
  this._currentCount++;
24304
- this.execFunc(this._currentCount).then(function() {
24305
- //@ts-ignore
24306
- _this._timeoutId = setTimeout(_this.exec, _this.interval);
24324
+ this.execFunc(this._currentCount).then(function(result) {
24325
+ return _this._onComplete && _this._onComplete(result);
24326
+ }).catch(function(e) {
24327
+ _this._error = e;
24328
+ _this._timeoutId = window.setTimeout(_this.exec, _this.interval);
24307
24329
  });
24308
24330
  };
24309
24331
  return MultiExecutor;
@@ -26914,92 +26936,97 @@
26914
26936
  }
26915
26937
  };
26916
26938
  _proto._updateLocalData = function _updateLocalData() {
26917
- var _this = this, color = _this.color, horizontalAlignment = _this.horizontalAlignment, verticalAlignment = _this.verticalAlignment, charRenderDatas = _this._charRenderDatas;
26939
+ var _this = this, color = _this.color, charRenderDatas = _this._charRenderDatas, charFont = _this._subFont;
26918
26940
  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
26941
  var textMetrics = this.enableWrapping ? TextUtils.measureTextWithWrap(this) : TextUtils.measureTextWithoutWrap(this);
26926
26942
  var height = textMetrics.height, lines = textMetrics.lines, lineWidths = textMetrics.lineWidths, lineHeight = textMetrics.lineHeight, lineMaxSizes = textMetrics.lineMaxSizes;
26927
26943
  var charRenderDataPool = TextRenderer._charRenderDataPool;
26928
- var halfLineHeight = lineHeight * 0.5;
26929
26944
  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
26945
  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);
26946
+ if (linesLen > 0) {
26947
+ var _pixelsPerUnit = Engine._pixelsPerUnit;
26948
+ var horizontalAlignment = this.horizontalAlignment;
26949
+ var pixelsPerUnitReciprocal = 1.0 / _pixelsPerUnit;
26950
+ var rendererWidth = this.width * _pixelsPerUnit;
26951
+ var halfRendererWidth = rendererWidth * 0.5;
26952
+ var rendererHeight = this.height * _pixelsPerUnit;
26953
+ var halfLineHeight = lineHeight * 0.5;
26954
+ var startY = 0;
26955
+ var topDiff = lineHeight * 0.5 - lineMaxSizes[0].ascent;
26956
+ var bottomDiff = lineHeight * 0.5 - lineMaxSizes[linesLen - 1].descent - 1;
26957
+ switch(this.verticalAlignment){
26958
+ case exports.TextVerticalAlignment.Top:
26959
+ startY = rendererHeight * 0.5 - halfLineHeight + topDiff;
26960
+ break;
26961
+ case exports.TextVerticalAlignment.Center:
26962
+ startY = height * 0.5 - halfLineHeight - (bottomDiff - topDiff) * 0.5;
26963
+ break;
26964
+ case exports.TextVerticalAlignment.Bottom:
26965
+ startY = height - rendererHeight * 0.5 - halfLineHeight - bottomDiff;
26966
+ break;
26967
+ }
26968
+ var firstLine = -1;
26969
+ var minX = Number.MAX_SAFE_INTEGER;
26970
+ var minY = Number.MAX_SAFE_INTEGER;
26971
+ var maxX = Number.MIN_SAFE_INTEGER;
26972
+ var maxY = Number.MIN_SAFE_INTEGER;
26973
+ for(var i = 0; i < linesLen; ++i){
26974
+ var lineWidth = lineWidths[i];
26975
+ if (lineWidth > 0) {
26976
+ var line = lines[i];
26977
+ var startX = 0;
26978
+ var firstRow = -1;
26979
+ if (firstLine < 0) {
26980
+ firstLine = i;
26981
+ }
26982
+ switch(horizontalAlignment){
26983
+ case exports.TextHorizontalAlignment.Left:
26984
+ startX = -halfRendererWidth;
26985
+ break;
26986
+ case exports.TextHorizontalAlignment.Center:
26987
+ startX = -lineWidth * 0.5;
26988
+ break;
26989
+ case exports.TextHorizontalAlignment.Right:
26990
+ startX = halfRendererWidth - lineWidth;
26991
+ break;
26992
+ }
26993
+ for(var j = 0, n = line.length; j < n; ++j){
26994
+ var char = line[j];
26995
+ var charInfo = charFont._getCharInfo(char);
26996
+ if (charInfo.h > 0) {
26997
+ var _charRenderDatas, _ref;
26998
+ firstRow < 0 && (firstRow = j);
26999
+ var charRenderData = (_charRenderDatas = charRenderDatas)[_ref = renderDataCount++] || (_charRenderDatas[_ref] = charRenderDataPool.get());
27000
+ var renderData = charRenderData.renderData, localPositions = charRenderData.localPositions;
27001
+ charRenderData.texture = charFont._getTextureByIndex(charInfo.index);
27002
+ renderData.color = color;
27003
+ renderData.uvs = charInfo.uvs;
27004
+ var w = charInfo.w, ascent = charInfo.ascent, descent = charInfo.descent;
27005
+ var left = startX * pixelsPerUnitReciprocal;
27006
+ var right = (startX + w) * pixelsPerUnitReciprocal;
27007
+ var top = (startY + ascent) * pixelsPerUnitReciprocal;
27008
+ var bottom = (startY - descent + 1) * pixelsPerUnitReciprocal;
27009
+ localPositions.set(left, top, right, bottom);
27010
+ i === firstLine && (maxY = Math.max(maxY, top));
27011
+ minY = Math.min(minY, bottom);
27012
+ j === firstRow && (minX = Math.min(minX, left));
27013
+ maxX = Math.max(maxX, right);
27014
+ }
27015
+ startX += charInfo.xAdvance;
26991
27016
  }
26992
- startX += charInfo.xAdvance;
26993
27017
  }
27018
+ startY -= lineHeight;
26994
27019
  }
26995
- startY -= lineHeight;
26996
- }
26997
- if (firstLine < 0) {
27020
+ if (firstLine < 0) {
27021
+ min.set(0, 0, 0);
27022
+ max.set(0, 0, 0);
27023
+ } else {
27024
+ min.set(minX, minY, 0);
27025
+ max.set(maxX, maxY, 0);
27026
+ }
27027
+ } else {
26998
27028
  min.set(0, 0, 0);
26999
27029
  max.set(0, 0, 0);
27000
- } else {
27001
- min.set(minX, minY, 0);
27002
- max.set(maxX, maxY, 0);
27003
27030
  }
27004
27031
  // Revert excess render data to pool.
27005
27032
  var lastRenderDataCount = charRenderDatas.length;
@@ -28982,7 +29009,8 @@
28982
29009
  };
28983
29010
  _proto._saveAnimatorEventHandlers = function _saveAnimatorEventHandlers(state, animatorStateData) {
28984
29011
  var eventHandlerPool = this._animationEventHandlerPool;
28985
- var scripts = this._entity._scripts;
29012
+ var scripts = [];
29013
+ this._entity.getComponents(Script, scripts);
28986
29014
  var scriptCount = scripts.length;
28987
29015
  var eventHandlers = animatorStateData.eventHandlers;
28988
29016
  var events = state.clip.events;
@@ -28995,7 +29023,7 @@
28995
29023
  eventHandler.event = event;
28996
29024
  handlers.length = 0;
28997
29025
  for(var j = scriptCount - 1; j >= 0; j--){
28998
- var handler = scripts.get(j)[funcName];
29026
+ var handler = scripts[j][funcName];
28999
29027
  handler && handlers.push(handler);
29000
29028
  }
29001
29029
  eventHandlers.push(eventHandler);
@@ -34038,15 +34066,18 @@
34038
34066
  for(var _iterator2 = _create_for_of_iterator_helper_loose(meshInfo.blendShapes), _step2; !(_step2 = _iterator2()).done;){
34039
34067
  var restoreInfo = _step2.value;
34040
34068
  var frame = restoreInfo.blendShape.frames[0];
34041
- var positionData = _this._getBufferData(buffers, restoreInfo.position);
34042
- frame.deltaPositions = GLTFUtils.floatBufferToVector3Array(positionData);
34069
+ var position = restoreInfo.position;
34070
+ var positionData = _this._getBufferData(buffers, position.buffer);
34071
+ frame.deltaPositions = GLTFUtils.bufferToVector3Array(positionData, position.stride, position.byteOffset, position.count);
34043
34072
  if (restoreInfo.normal) {
34044
- var normalData = _this._getBufferData(buffers, restoreInfo.normal);
34045
- frame.deltaNormals = GLTFUtils.floatBufferToVector3Array(normalData);
34073
+ var normal = restoreInfo.normal;
34074
+ var normalData = _this._getBufferData(buffers, normal.buffer);
34075
+ frame.deltaNormals = GLTFUtils.bufferToVector3Array(normalData, normal.stride, normal.byteOffset, normal.count);
34046
34076
  }
34047
34077
  if (restoreInfo.tangent) {
34048
- var tangentData = _this._getBufferData(buffers, restoreInfo.tangent);
34049
- frame.deltaTangents = GLTFUtils.floatBufferToVector3Array(tangentData);
34078
+ var tangent = restoreInfo.tangent;
34079
+ var tangentData = _this._getBufferData(buffers, tangent.buffer);
34080
+ frame.deltaTangents = GLTFUtils.bufferToVector3Array(tangentData, tangent.stride, tangent.byteOffset, tangent.count);
34050
34081
  }
34051
34082
  }
34052
34083
  mesh.uploadData(true);
@@ -34130,6 +34161,14 @@
34130
34161
  this.normal = normal;
34131
34162
  this.tangent = tangent;
34132
34163
  };
34164
+ /**
34165
+ * @internal
34166
+ */ var BlendShapeDataRestoreInfo = function BlendShapeDataRestoreInfo(buffer, stride, byteOffset, count) {
34167
+ this.buffer = buffer;
34168
+ this.stride = stride;
34169
+ this.byteOffset = byteOffset;
34170
+ this.count = count;
34171
+ };
34133
34172
  /**
34134
34173
  * Module for glTF 2.0 Interface
34135
34174
  */ var AccessorComponentType;
@@ -34428,8 +34467,10 @@
34428
34467
  return context.getBuffers().then(function(buffers) {
34429
34468
  var bufferIndex = bufferView.buffer;
34430
34469
  var buffer = buffers[bufferIndex];
34431
- var bufferByteOffset = bufferView.byteOffset || 0;
34432
- var byteOffset = accessor.byteOffset || 0;
34470
+ var _bufferView_byteOffset;
34471
+ var bufferByteOffset = (_bufferView_byteOffset = bufferView.byteOffset) != null ? _bufferView_byteOffset : 0;
34472
+ var _accessor_byteOffset;
34473
+ var byteOffset = (_accessor_byteOffset = accessor.byteOffset) != null ? _accessor_byteOffset : 0;
34433
34474
  var TypedArray = GLTFUtils.getComponentType(componentType);
34434
34475
  var dataElementSize = GLTFUtils.getAccessorTypeSize(accessor.type);
34435
34476
  var dataElementBytes = TypedArray.BYTES_PER_ELEMENT;
@@ -34463,6 +34504,17 @@
34463
34504
  return bufferInfo;
34464
34505
  });
34465
34506
  };
34507
+ GLTFUtils.bufferToVector3Array = function bufferToVector3Array(data, byteStride, accessorByteOffset, count) {
34508
+ var bytesPerElement = data.BYTES_PER_ELEMENT;
34509
+ var offset = accessorByteOffset % byteStride / bytesPerElement;
34510
+ var stride = byteStride / bytesPerElement;
34511
+ var vector3s = new Array(count);
34512
+ for(var i = 0; i < count; i++){
34513
+ var index = offset + i * stride;
34514
+ vector3s[i] = new Vector3(data[index], data[index + 1], data[index + 2]);
34515
+ }
34516
+ return vector3s;
34517
+ };
34466
34518
  /**
34467
34519
  * @deprecated
34468
34520
  * Get accessor data.
@@ -35556,7 +35608,7 @@
35556
35608
  }
35557
35609
  // BlendShapes
35558
35610
  if (targets) {
35559
- promises.push(GLTFMeshParser._createBlendShape(mesh, meshRestoreInfo, gltfMesh, targets, getBlendShapeData));
35611
+ promises.push(GLTFMeshParser._createBlendShape(mesh, meshRestoreInfo, gltfMesh, accessors, targets, getBlendShapeData));
35560
35612
  }
35561
35613
  return Promise.all(promises).then(function() {
35562
35614
  mesh.uploadData(!keepMeshData);
@@ -35572,7 +35624,7 @@
35572
35624
  };
35573
35625
  /**
35574
35626
  * @internal
35575
- */ GLTFMeshParser._createBlendShape = function _createBlendShape(mesh, meshRestoreInfo, glTFMesh, glTFTargets, getBlendShapeData) {
35627
+ */ GLTFMeshParser._createBlendShape = function _createBlendShape(mesh, meshRestoreInfo, glTFMesh, accessors, glTFTargets, getBlendShapeData) {
35576
35628
  var _loop = function _loop(i, n) {
35577
35629
  var name = blendShapeNames ? blendShapeNames[i] : "blendShape" + i;
35578
35630
  var promise = Promise.all([
@@ -35580,16 +35632,36 @@
35580
35632
  getBlendShapeData("NORMAL", i),
35581
35633
  getBlendShapeData("TANGENT", i)
35582
35634
  ]).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;
35635
+ var posBufferInfo = infos[0];
35636
+ var norBufferInfo = infos[1];
35637
+ var tanBufferInfo = infos[2];
35638
+ var target = glTFTargets[i];
35639
+ var posAccessor;
35640
+ var norAccessor;
35641
+ var tanAccessor;
35642
+ var positions = null;
35643
+ if (posBufferInfo) {
35644
+ posAccessor = accessors[target["POSITION"]];
35645
+ var _posAccessor_byteOffset;
35646
+ positions = GLTFUtils.bufferToVector3Array(posBufferInfo.data, posBufferInfo.stride, (_posAccessor_byteOffset = posAccessor.byteOffset) != null ? _posAccessor_byteOffset : 0, posAccessor.count);
35647
+ }
35648
+ var normals = null;
35649
+ if (norBufferInfo) {
35650
+ norAccessor = accessors[target["NORMAL"]];
35651
+ var _norAccessor_byteOffset;
35652
+ normals = GLTFUtils.bufferToVector3Array(norBufferInfo.data, norBufferInfo.stride, (_norAccessor_byteOffset = norAccessor.byteOffset) != null ? _norAccessor_byteOffset : 0, norAccessor.count);
35653
+ }
35654
+ var tangents = null;
35655
+ if (tanBufferInfo) {
35656
+ tanAccessor = accessors[target["NORMAL"]];
35657
+ var _tanAccessor_byteOffset;
35658
+ tangents = GLTFUtils.bufferToVector3Array(tanBufferInfo.data, tanBufferInfo.stride, (_tanAccessor_byteOffset = tanAccessor.byteOffset) != null ? _tanAccessor_byteOffset : 0, tanAccessor.count);
35659
+ }
35589
35660
  var blendShape = new BlendShape(name);
35590
- blendShape.addFrame(1.0, deltaPositions, deltaNormals, deltaTangents);
35661
+ blendShape.addFrame(1.0, positions, normals, tangents);
35591
35662
  mesh.addBlendShape(blendShape);
35592
- meshRestoreInfo.blendShapes.push(new BlendShapeRestoreInfo(blendShape, deltaPosBufferInfo.restoreInfo, deltaNorBufferInfo == null ? void 0 : deltaNorBufferInfo.restoreInfo, deltaTanBufferInfo == null ? void 0 : deltaTanBufferInfo.restoreInfo));
35663
+ var _posAccessor_byteOffset1, _norAccessor_byteOffset1, _tanAccessor_byteOffset1;
35664
+ 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
35665
  });
35594
35666
  promises.push(promise);
35595
35667
  };
@@ -35916,13 +35988,13 @@
35916
35988
  };
35917
35989
  _proto._parseSampler = function _parseSampler(texture, samplerInfo) {
35918
35990
  var filterMode = samplerInfo.filterMode, wrapModeU = samplerInfo.wrapModeU, wrapModeV = samplerInfo.wrapModeV;
35919
- if (filterMode) {
35991
+ if (filterMode !== undefined) {
35920
35992
  texture.filterMode = filterMode;
35921
35993
  }
35922
- if (wrapModeU) {
35994
+ if (wrapModeU !== undefined) {
35923
35995
  texture.wrapModeU = wrapModeU;
35924
35996
  }
35925
- if (wrapModeV) {
35997
+ if (wrapModeV !== undefined) {
35926
35998
  texture.wrapModeV = wrapModeV;
35927
35999
  }
35928
36000
  };
@@ -36056,7 +36128,7 @@
36056
36128
  resourceManager.addContentRestorer(restorer);
36057
36129
  masterPromiseInfo.resolve(glTFResource);
36058
36130
  }).catch(function(e) {
36059
- var msg = "Error loading glTF model from " + url + " .";
36131
+ var msg = "Error loading glTF model from " + url + " : " + e;
36060
36132
  Logger.error(msg);
36061
36133
  masterPromiseInfo.reject(msg);
36062
36134
  context.defaultSceneRootPromiseInfo.reject(e);
@@ -38251,7 +38323,7 @@
38251
38323
  mesh.addSubMesh(0, vertexCount, mode);
38252
38324
  }
38253
38325
  // BlendShapes
38254
- targets && GLTFMeshParser._createBlendShape(mesh, null, gltfMesh, targets, getBlendShapeData);
38326
+ targets && GLTFMeshParser._createBlendShape(mesh, null, gltfMesh, accessors, targets, getBlendShapeData);
38255
38327
  mesh.uploadData(!keepMeshData);
38256
38328
  return Promise.resolve(mesh);
38257
38329
  };
@@ -38477,7 +38549,7 @@
38477
38549
  ], GALACEAN_animation_event);
38478
38550
 
38479
38551
  //@ts-ignore
38480
- var version = "1.0.0-beta.17";
38552
+ var version = "1.0.0-beta.18";
38481
38553
  console.log("Galacean engine version: " + version);
38482
38554
  for(var key in CoreObjects){
38483
38555
  Loader.registerClass(key, CoreObjects[key]);