@galacean/engine-core 1.3.3 → 1.3.6

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
@@ -10759,6 +10759,9 @@ var SubRenderElement = /*#__PURE__*/ function() {
10759
10759
  __decorate([
10760
10760
  assignmentClone
10761
10761
  ], SpriteMask.prototype, "influenceLayers", void 0);
10762
+ __decorate([
10763
+ ignoreClone
10764
+ ], SpriteMask.prototype, "_renderElement", void 0);
10762
10765
  __decorate([
10763
10766
  ignoreClone
10764
10767
  ], SpriteMask.prototype, "_subChunk", void 0);
@@ -11169,9 +11172,12 @@ var /**
11169
11172
  // Safari gets data confusion through getImageData when the canvas width is not an integer.
11170
11173
  // The measure text width of some special invisible characters may be 0, so make sure the width is at least 1.
11171
11174
  // @todo: Text layout may vary from standard and not support emoji.
11172
- var textMetrics = context.measureText(measureString);
11175
+ var _context_measureText = context.measureText(measureString), actualBoundingBoxLeft = _context_measureText.actualBoundingBoxLeft, actualBoundingBoxRight = _context_measureText.actualBoundingBoxRight, actualWidth = _context_measureText.width;
11173
11176
  // In some case (ex: " "), actualBoundingBoxRight and actualBoundingBoxLeft will be 0, so use width.
11174
- var width = Math.max(1, Math.round(textMetrics.actualBoundingBoxRight - textMetrics.actualBoundingBoxLeft || textMetrics.width));
11177
+ // TODO: With testing, actualBoundingBoxLeft + actualBoundingBoxRight is the actual rendering width
11178
+ // but the space rules between characters are unclear. Using actualBoundingBoxRight + Math.abs(actualBoundingBoxLeft) is the closest to the native effect.
11179
+ var width = Math.max(1, Math.round(Math.max(actualBoundingBoxRight + Math.abs(actualBoundingBoxLeft), actualWidth)));
11180
+ // Make sure enough width.
11175
11181
  var baseline = Math.ceil(context.measureText(TextUtils._measureBaseline).width);
11176
11182
  var height = baseline * TextUtils._heightMultiplier;
11177
11183
  baseline = TextUtils._baselineMultiplier * baseline | 0;
@@ -11185,7 +11191,11 @@ var /**
11185
11191
  context.clearRect(0, 0, width, height);
11186
11192
  context.textBaseline = "middle";
11187
11193
  context.fillStyle = "#fff";
11188
- context.fillText(measureString, 0, baseline);
11194
+ if (actualBoundingBoxLeft > 0) {
11195
+ context.fillText(measureString, actualBoundingBoxLeft, baseline);
11196
+ } else {
11197
+ context.fillText(measureString, 0, baseline);
11198
+ }
11189
11199
  var colorData = context.getImageData(0, 0, width, height).data;
11190
11200
  var len = colorData.length;
11191
11201
  var top = -1;
@@ -11229,9 +11239,9 @@ var /**
11229
11239
  y: 0,
11230
11240
  w: width,
11231
11241
  h: size,
11232
- offsetX: 0,
11242
+ offsetX: actualBoundingBoxLeft > 0 ? actualBoundingBoxLeft : 0,
11233
11243
  offsetY: (ascent - descent) * 0.5,
11234
- xAdvance: width,
11244
+ xAdvance: Math.round(actualWidth),
11235
11245
  uvs: [
11236
11246
  new engineMath.Vector2(),
11237
11247
  new engineMath.Vector2(),
@@ -11800,7 +11810,7 @@ var /**
11800
11810
  j === firstRow && (minX = Math.min(minX, left));
11801
11811
  maxX = Math.max(maxX, right);
11802
11812
  }
11803
- startX += charInfo.xAdvance;
11813
+ startX += charInfo.xAdvance + charInfo.offsetX;
11804
11814
  }
11805
11815
  }
11806
11816
  startY -= lineHeight;
@@ -12630,8 +12640,6 @@ var BufferUtil = /*#__PURE__*/ function() {
12630
12640
  _this = ReferResource1.call(this, engine) || this;
12631
12641
  /** @internal */ _this._renderStates = [] // todo: later will as a part of shaderData when shader effect frame is OK, that is more powerful and flexible.
12632
12642
  ;
12633
- /** @internal */ _this._priority = 0 // todo: temporary resolution of submesh rendering order issue.
12634
- ;
12635
12643
  _this._shaderData = new ShaderData(ShaderDataGroup.Material);
12636
12644
  _this.shader = shader;
12637
12645
  return _this;
@@ -18881,7 +18889,7 @@ var ObjectPool = /*#__PURE__*/ function() {
18881
18889
  * @internal
18882
18890
  */ var PrimitiveChunkManager = /*#__PURE__*/ function() {
18883
18891
  function PrimitiveChunkManager(engine, maxVertexCount) {
18884
- if (maxVertexCount === void 0) maxVertexCount = PrimitiveChunkManager.MAX_VERTEX_COUNT;
18892
+ if (maxVertexCount === void 0) maxVertexCount = 4096;
18885
18893
  this.engine = engine;
18886
18894
  this.maxVertexCount = maxVertexCount;
18887
18895
  this.primitiveChunks = new Array();
@@ -18922,9 +18930,6 @@ var ObjectPool = /*#__PURE__*/ function() {
18922
18930
  };
18923
18931
  return PrimitiveChunkManager;
18924
18932
  }();
18925
- (function() {
18926
- /** The maximum number of vertex. */ PrimitiveChunkManager.MAX_VERTEX_COUNT = 4096;
18927
- })();
18928
18933
 
18929
18934
  /**
18930
18935
  * @internal
@@ -20927,6 +20932,8 @@ var Collision = function Collision() {
20927
20932
  _this._setUpDirection = _this._setUpDirection.bind(_assert_this_initialized(_this));
20928
20933
  //@ts-ignore
20929
20934
  _this._upDirection._onValueChanged = _this._setUpDirection;
20935
+ // sync world position to physical space
20936
+ _this._onUpdate();
20930
20937
  return _this;
20931
20938
  }
20932
20939
  var _proto = CharacterController.prototype;
@@ -20937,7 +20944,9 @@ var Collision = function Collision() {
20937
20944
  * @param elapsedTime - Time elapsed since last call
20938
20945
  * @return flags - The ControllerCollisionFlag
20939
20946
  */ _proto.move = function move(disp, minDist, elapsedTime) {
20940
- return this._nativeCollider.move(disp, minDist, elapsedTime);
20947
+ var flags = this._nativeCollider.move(disp, minDist, elapsedTime);
20948
+ this._syncWorldPositionFromPhysicalSpace();
20949
+ return flags;
20941
20950
  };
20942
20951
  /**
20943
20952
  * Add collider shape on this controller.
@@ -20973,8 +20982,7 @@ var Collision = function Collision() {
20973
20982
  /**
20974
20983
  * @internal
20975
20984
  */ _proto._onLateUpdate = function _onLateUpdate() {
20976
- var position = this.entity.transform.worldPosition;
20977
- this._nativeCollider.getWorldPosition(position);
20985
+ this._syncWorldPositionFromPhysicalSpace();
20978
20986
  this._updateFlag.flag = false;
20979
20987
  };
20980
20988
  /**
@@ -20997,6 +21005,9 @@ var Collision = function Collision() {
20997
21005
  physics._removeColliderShape(shapes[i]);
20998
21006
  }
20999
21007
  };
21008
+ _proto._syncWorldPositionFromPhysicalSpace = function _syncWorldPositionFromPhysicalSpace() {
21009
+ this._nativeCollider.getWorldPosition(this.entity.transform.worldPosition);
21010
+ };
21000
21011
  _proto._setUpDirection = function _setUpDirection() {
21001
21012
  this._nativeCollider.setUpDirection(this._upDirection);
21002
21013
  };
@@ -28681,7 +28692,9 @@ exports.AnimatorLayerBlendingMode = void 0;
28681
28692
  // Precalculate to get the transition
28682
28693
  srcPlayData.update(playDeltaTime);
28683
28694
  var clipTime = srcPlayData.clipTime, isForwards = srcPlayData.isForwards;
28684
- var transition = this._applyTransitionsByCondition(layerIndex, layerData, layer, state, layer.stateMachine.anyStateTransitions, aniUpdate) || this._applyStateTransitions(layerIndex, layerData, layer, isForwards, srcPlayData, state.transitions, lastClipTime, clipTime, playDeltaTime, aniUpdate);
28695
+ var transitions = state.transitions;
28696
+ var anyStateTransitions = layer.stateMachine.anyStateTransitions;
28697
+ var transition = anyStateTransitions.length && this._applyTransitionsByCondition(layerIndex, layerData, layer, state, anyStateTransitions, aniUpdate) || transitions.length && this._applyStateTransitions(layerIndex, layerData, layer, isForwards, srcPlayData, transitions, lastClipTime, clipTime, playDeltaTime, aniUpdate);
28685
28698
  var playCostTime;
28686
28699
  if (transition) {
28687
28700
  var clipDuration = state.clip.length;
@@ -28765,7 +28778,7 @@ exports.AnimatorLayerBlendingMode = void 0;
28765
28778
  playedTime - dstPlayDeltaTime > transitionDuration ? // -(transitionDuration - playedTime)
28766
28779
  playedTime - transitionDuration : dstPlayDeltaTime;
28767
28780
  }
28768
- var actualCostTime = dstPlaySpeed === 0 ? 0 : dstPlayCostTime / dstPlaySpeed;
28781
+ var actualCostTime = dstPlaySpeed === 0 ? deltaTime : dstPlayCostTime / dstPlaySpeed;
28769
28782
  var srcPlayCostTime = actualCostTime * srcPlaySpeed;
28770
28783
  srcPlayData.update(srcPlayCostTime);
28771
28784
  destPlayData.update(dstPlayCostTime);
@@ -28773,6 +28786,7 @@ exports.AnimatorLayerBlendingMode = void 0;
28773
28786
  (crossWeight >= 1.0 - engineMath.MathUtil.zeroTolerance || transitionDuration === 0) && (crossWeight = 1.0);
28774
28787
  var crossFadeFinished = crossWeight === 1.0;
28775
28788
  if (crossFadeFinished) {
28789
+ srcPlayData.playState = AnimatorStatePlayState.Finished;
28776
28790
  this._preparePlayOwner(layerData, destState);
28777
28791
  this._evaluatePlayingState(destPlayData, weight, additive, aniUpdate);
28778
28792
  } else {
@@ -28827,7 +28841,7 @@ exports.AnimatorLayerBlendingMode = void 0;
28827
28841
  playedTime - playDeltaTime > transitionDuration ? // -(transitionDuration - playedTime)
28828
28842
  playedTime - transitionDuration : playDeltaTime;
28829
28843
  }
28830
- var actualCostTime = playSpeed === 0 ? 0 : dstPlayCostTime / playSpeed;
28844
+ var actualCostTime = playSpeed === 0 ? deltaTime : dstPlayCostTime / playSpeed;
28831
28845
  destPlayData.update(dstPlayCostTime);
28832
28846
  var crossWeight = Math.abs(destPlayData.frameTime) / transitionDuration;
28833
28847
  (crossWeight >= 1.0 - engineMath.MathUtil.zeroTolerance || transitionDuration === 0) && (crossWeight = 1.0);
@@ -28867,14 +28881,16 @@ exports.AnimatorLayerBlendingMode = void 0;
28867
28881
  }
28868
28882
  };
28869
28883
  _proto._updateFinishedState = function _updateFinishedState(layerIndex, layerData, layer, weight, additive, deltaTime, aniUpdate) {
28870
- var stateMachine = layer.stateMachine;
28884
+ layer.stateMachine;
28871
28885
  var playData = layerData.srcPlayData;
28872
28886
  var state = playData.state;
28873
28887
  var actualSpeed = state.speed * this.speed;
28874
28888
  var actualDeltaTime = actualSpeed * deltaTime;
28875
28889
  playData.updateOrientation(actualDeltaTime);
28876
28890
  var clipTime = playData.clipTime, isForwards = playData.isForwards;
28877
- var transition = this._applyTransitionsByCondition(layerIndex, layerData, layer, state, stateMachine.anyStateTransitions, aniUpdate) || this._applyStateTransitions(layerIndex, layerData, layer, isForwards, playData, state.transitions, clipTime, clipTime, actualDeltaTime, aniUpdate);
28891
+ var transitions = state.transitions;
28892
+ var anyStateTransitions = layer.stateMachine.anyStateTransitions;
28893
+ var transition = anyStateTransitions.length && this._applyTransitionsByCondition(layerIndex, layerData, layer, state, anyStateTransitions, aniUpdate) || transitions.length && this._applyStateTransitions(layerIndex, layerData, layer, isForwards, playData, transitions, clipTime, clipTime, actualDeltaTime, aniUpdate);
28878
28894
  if (transition) {
28879
28895
  this._updateState(layerIndex, layerData, layer, deltaTime, aniUpdate);
28880
28896
  } else {