@galacean/engine-core 1.3.2 → 1.3.5

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.
@@ -11170,9 +11170,12 @@ var /**
11170
11170
  // Safari gets data confusion through getImageData when the canvas width is not an integer.
11171
11171
  // The measure text width of some special invisible characters may be 0, so make sure the width is at least 1.
11172
11172
  // @todo: Text layout may vary from standard and not support emoji.
11173
- var textMetrics = context.measureText(measureString);
11173
+ var _context_measureText = context.measureText(measureString), actualBoundingBoxLeft = _context_measureText.actualBoundingBoxLeft, actualBoundingBoxRight = _context_measureText.actualBoundingBoxRight, actualWidth = _context_measureText.width;
11174
11174
  // In some case (ex: " "), actualBoundingBoxRight and actualBoundingBoxLeft will be 0, so use width.
11175
- var width = Math.max(1, Math.round(textMetrics.actualBoundingBoxRight - textMetrics.actualBoundingBoxLeft || textMetrics.width));
11175
+ // TODO: With testing, actualBoundingBoxLeft + actualBoundingBoxRight is the actual rendering width
11176
+ // but the space rules between characters are unclear. Using actualBoundingBoxRight + Math.abs(actualBoundingBoxLeft) is the closest to the native effect.
11177
+ var width = Math.max(1, Math.round(Math.max(actualBoundingBoxRight + Math.abs(actualBoundingBoxLeft), actualWidth)));
11178
+ // Make sure enough width.
11176
11179
  var baseline = Math.ceil(context.measureText(TextUtils._measureBaseline).width);
11177
11180
  var height = baseline * TextUtils._heightMultiplier;
11178
11181
  baseline = TextUtils._baselineMultiplier * baseline | 0;
@@ -11186,7 +11189,11 @@ var /**
11186
11189
  context.clearRect(0, 0, width, height);
11187
11190
  context.textBaseline = "middle";
11188
11191
  context.fillStyle = "#fff";
11189
- context.fillText(measureString, 0, baseline);
11192
+ if (actualBoundingBoxLeft > 0) {
11193
+ context.fillText(measureString, actualBoundingBoxLeft, baseline);
11194
+ } else {
11195
+ context.fillText(measureString, 0, baseline);
11196
+ }
11190
11197
  var colorData = context.getImageData(0, 0, width, height).data;
11191
11198
  var len = colorData.length;
11192
11199
  var top = -1;
@@ -11230,9 +11237,9 @@ var /**
11230
11237
  y: 0,
11231
11238
  w: width,
11232
11239
  h: size,
11233
- offsetX: 0,
11240
+ offsetX: actualBoundingBoxLeft > 0 ? actualBoundingBoxLeft : 0,
11234
11241
  offsetY: (ascent - descent) * 0.5,
11235
- xAdvance: width,
11242
+ xAdvance: Math.round(actualWidth),
11236
11243
  uvs: [
11237
11244
  new miniprogram.Vector2(),
11238
11245
  new miniprogram.Vector2(),
@@ -11801,7 +11808,7 @@ var /**
11801
11808
  j === firstRow && (minX = Math.min(minX, left));
11802
11809
  maxX = Math.max(maxX, right);
11803
11810
  }
11804
- startX += charInfo.xAdvance;
11811
+ startX += charInfo.xAdvance + charInfo.offsetX;
11805
11812
  }
11806
11813
  }
11807
11814
  startY -= lineHeight;
@@ -12631,8 +12638,6 @@ var BufferUtil = /*#__PURE__*/ function() {
12631
12638
  _this = ReferResource1.call(this, engine) || this;
12632
12639
  /** @internal */ _this._renderStates = [] // todo: later will as a part of shaderData when shader effect frame is OK, that is more powerful and flexible.
12633
12640
  ;
12634
- /** @internal */ _this._priority = 0 // todo: temporary resolution of submesh rendering order issue.
12635
- ;
12636
12641
  _this._shaderData = new ShaderData(ShaderDataGroup.Material);
12637
12642
  _this.shader = shader;
12638
12643
  return _this;
@@ -17824,6 +17829,17 @@ var ComponentCloner = /*#__PURE__*/ function() {
17824
17829
  this._setInActiveInHierarchy(this._activeChangedComponents, activeChangeFlag);
17825
17830
  this._setActiveComponents(false, activeChangeFlag);
17826
17831
  };
17832
+ /**
17833
+ * @internal
17834
+ */ _proto._setTransformDirty = function _setTransformDirty() {
17835
+ if (this.transform) {
17836
+ this.transform._parentChange();
17837
+ } else {
17838
+ for(var i = 0, len = this._children.length; i < len; i++){
17839
+ this._children[i]._setTransformDirty();
17840
+ }
17841
+ }
17842
+ };
17827
17843
  _proto._addToChildrenList = function _addToChildrenList(index, child) {
17828
17844
  var children = this._children;
17829
17845
  var childCount = children.length;
@@ -17933,15 +17949,6 @@ var ComponentCloner = /*#__PURE__*/ function() {
17933
17949
  child.isActive && child._setInActiveInHierarchy(activeChangedComponents, activeChangeFlag);
17934
17950
  }
17935
17951
  };
17936
- _proto._setTransformDirty = function _setTransformDirty() {
17937
- if (this.transform) {
17938
- this.transform._parentChange();
17939
- } else {
17940
- for(var i = 0, len = this._children.length; i < len; i++){
17941
- this._children[i]._setTransformDirty();
17942
- }
17943
- }
17944
- };
17945
17952
  _proto._setSiblingIndex = function _setSiblingIndex(sibling, target) {
17946
17953
  target = Math.min(target, sibling.length - 1);
17947
17954
  if (target < 0) {
@@ -18880,7 +18887,7 @@ var ObjectPool = /*#__PURE__*/ function() {
18880
18887
  * @internal
18881
18888
  */ var PrimitiveChunkManager = /*#__PURE__*/ function() {
18882
18889
  function PrimitiveChunkManager(engine, maxVertexCount) {
18883
- if (maxVertexCount === void 0) maxVertexCount = PrimitiveChunkManager.MAX_VERTEX_COUNT;
18890
+ if (maxVertexCount === void 0) maxVertexCount = 4096;
18884
18891
  this.engine = engine;
18885
18892
  this.maxVertexCount = maxVertexCount;
18886
18893
  this.primitiveChunks = new Array();
@@ -18921,9 +18928,6 @@ var ObjectPool = /*#__PURE__*/ function() {
18921
18928
  };
18922
18929
  return PrimitiveChunkManager;
18923
18930
  }();
18924
- (function() {
18925
- /** The maximum number of vertex. */ PrimitiveChunkManager.MAX_VERTEX_COUNT = 4096;
18926
- })();
18927
18931
 
18928
18932
  /**
18929
18933
  * @internal
@@ -25667,6 +25671,7 @@ Shader.create(_PostProcessManager.UBER_SHADER_NAME, blitVs, UberPost);
25667
25671
  if (!isRoot) {
25668
25672
  entity._isRoot = true;
25669
25673
  entity._removeFromParent();
25674
+ entity._setTransformDirty();
25670
25675
  }
25671
25676
  // Add or remove from scene's rootEntities
25672
25677
  var oldScene = entity._scene;
package/dist/module.js CHANGED
@@ -11165,9 +11165,12 @@ var /**
11165
11165
  // Safari gets data confusion through getImageData when the canvas width is not an integer.
11166
11166
  // The measure text width of some special invisible characters may be 0, so make sure the width is at least 1.
11167
11167
  // @todo: Text layout may vary from standard and not support emoji.
11168
- var textMetrics = context.measureText(measureString);
11168
+ var _context_measureText = context.measureText(measureString), actualBoundingBoxLeft = _context_measureText.actualBoundingBoxLeft, actualBoundingBoxRight = _context_measureText.actualBoundingBoxRight, actualWidth = _context_measureText.width;
11169
11169
  // In some case (ex: " "), actualBoundingBoxRight and actualBoundingBoxLeft will be 0, so use width.
11170
- var width = Math.max(1, Math.round(textMetrics.actualBoundingBoxRight - textMetrics.actualBoundingBoxLeft || textMetrics.width));
11170
+ // TODO: With testing, actualBoundingBoxLeft + actualBoundingBoxRight is the actual rendering width
11171
+ // but the space rules between characters are unclear. Using actualBoundingBoxRight + Math.abs(actualBoundingBoxLeft) is the closest to the native effect.
11172
+ var width = Math.max(1, Math.round(Math.max(actualBoundingBoxRight + Math.abs(actualBoundingBoxLeft), actualWidth)));
11173
+ // Make sure enough width.
11171
11174
  var baseline = Math.ceil(context.measureText(TextUtils._measureBaseline).width);
11172
11175
  var height = baseline * TextUtils._heightMultiplier;
11173
11176
  baseline = TextUtils._baselineMultiplier * baseline | 0;
@@ -11181,7 +11184,11 @@ var /**
11181
11184
  context.clearRect(0, 0, width, height);
11182
11185
  context.textBaseline = "middle";
11183
11186
  context.fillStyle = "#fff";
11184
- context.fillText(measureString, 0, baseline);
11187
+ if (actualBoundingBoxLeft > 0) {
11188
+ context.fillText(measureString, actualBoundingBoxLeft, baseline);
11189
+ } else {
11190
+ context.fillText(measureString, 0, baseline);
11191
+ }
11185
11192
  var colorData = context.getImageData(0, 0, width, height).data;
11186
11193
  var len = colorData.length;
11187
11194
  var top = -1;
@@ -11225,9 +11232,9 @@ var /**
11225
11232
  y: 0,
11226
11233
  w: width,
11227
11234
  h: size,
11228
- offsetX: 0,
11235
+ offsetX: actualBoundingBoxLeft > 0 ? actualBoundingBoxLeft : 0,
11229
11236
  offsetY: (ascent - descent) * 0.5,
11230
- xAdvance: width,
11237
+ xAdvance: Math.round(actualWidth),
11231
11238
  uvs: [
11232
11239
  new Vector2(),
11233
11240
  new Vector2(),
@@ -11796,7 +11803,7 @@ var /**
11796
11803
  j === firstRow && (minX = Math.min(minX, left));
11797
11804
  maxX = Math.max(maxX, right);
11798
11805
  }
11799
- startX += charInfo.xAdvance;
11806
+ startX += charInfo.xAdvance + charInfo.offsetX;
11800
11807
  }
11801
11808
  }
11802
11809
  startY -= lineHeight;
@@ -12626,8 +12633,6 @@ var BufferUtil = /*#__PURE__*/ function() {
12626
12633
  _this = ReferResource1.call(this, engine) || this;
12627
12634
  /** @internal */ _this._renderStates = [] // todo: later will as a part of shaderData when shader effect frame is OK, that is more powerful and flexible.
12628
12635
  ;
12629
- /** @internal */ _this._priority = 0 // todo: temporary resolution of submesh rendering order issue.
12630
- ;
12631
12636
  _this._shaderData = new ShaderData(ShaderDataGroup.Material);
12632
12637
  _this.shader = shader;
12633
12638
  return _this;
@@ -17819,6 +17824,17 @@ var ComponentCloner = /*#__PURE__*/ function() {
17819
17824
  this._setInActiveInHierarchy(this._activeChangedComponents, activeChangeFlag);
17820
17825
  this._setActiveComponents(false, activeChangeFlag);
17821
17826
  };
17827
+ /**
17828
+ * @internal
17829
+ */ _proto._setTransformDirty = function _setTransformDirty() {
17830
+ if (this.transform) {
17831
+ this.transform._parentChange();
17832
+ } else {
17833
+ for(var i = 0, len = this._children.length; i < len; i++){
17834
+ this._children[i]._setTransformDirty();
17835
+ }
17836
+ }
17837
+ };
17822
17838
  _proto._addToChildrenList = function _addToChildrenList(index, child) {
17823
17839
  var children = this._children;
17824
17840
  var childCount = children.length;
@@ -17928,15 +17944,6 @@ var ComponentCloner = /*#__PURE__*/ function() {
17928
17944
  child.isActive && child._setInActiveInHierarchy(activeChangedComponents, activeChangeFlag);
17929
17945
  }
17930
17946
  };
17931
- _proto._setTransformDirty = function _setTransformDirty() {
17932
- if (this.transform) {
17933
- this.transform._parentChange();
17934
- } else {
17935
- for(var i = 0, len = this._children.length; i < len; i++){
17936
- this._children[i]._setTransformDirty();
17937
- }
17938
- }
17939
- };
17940
17947
  _proto._setSiblingIndex = function _setSiblingIndex(sibling, target) {
17941
17948
  target = Math.min(target, sibling.length - 1);
17942
17949
  if (target < 0) {
@@ -18875,7 +18882,7 @@ var ObjectPool = /*#__PURE__*/ function() {
18875
18882
  * @internal
18876
18883
  */ var PrimitiveChunkManager = /*#__PURE__*/ function() {
18877
18884
  function PrimitiveChunkManager(engine, maxVertexCount) {
18878
- if (maxVertexCount === void 0) maxVertexCount = PrimitiveChunkManager.MAX_VERTEX_COUNT;
18885
+ if (maxVertexCount === void 0) maxVertexCount = 4096;
18879
18886
  this.engine = engine;
18880
18887
  this.maxVertexCount = maxVertexCount;
18881
18888
  this.primitiveChunks = new Array();
@@ -18916,9 +18923,6 @@ var ObjectPool = /*#__PURE__*/ function() {
18916
18923
  };
18917
18924
  return PrimitiveChunkManager;
18918
18925
  }();
18919
- (function() {
18920
- /** The maximum number of vertex. */ PrimitiveChunkManager.MAX_VERTEX_COUNT = 4096;
18921
- })();
18922
18926
 
18923
18927
  /**
18924
18928
  * @internal
@@ -25662,6 +25666,7 @@ Shader.create(_PostProcessManager.UBER_SHADER_NAME, blitVs, UberPost);
25662
25666
  if (!isRoot) {
25663
25667
  entity._isRoot = true;
25664
25668
  entity._removeFromParent();
25669
+ entity._setTransformDirty();
25665
25670
  }
25666
25671
  // Add or remove from scene's rootEntities
25667
25672
  var oldScene = entity._scene;