@galacean/effects-core 2.3.0-beta.1 → 2.3.0-beta.3

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/camera.d.ts CHANGED
@@ -73,7 +73,6 @@ export declare class Camera {
73
73
  private inverseViewMatrix;
74
74
  private inverseProjectionMatrix;
75
75
  private inverseViewProjectionMatrix;
76
- private transform;
77
76
  private dirty;
78
77
  /**
79
78
  *
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * Description: Galacean Effects runtime core for the web
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
6
- * Version: v2.3.0-beta.1
6
+ * Version: v2.3.0-beta.3
7
7
  */
8
8
 
9
9
  'use strict';
@@ -16832,7 +16832,10 @@ exports.CameraController = /*#__PURE__*/ function(Behaviour) {
16832
16832
  camera.far = this.options.far;
16833
16833
  camera.fov = this.options.fov;
16834
16834
  camera.clipMode = this.options.clipMode;
16835
- camera.setTransform(this.transform);
16835
+ camera.transform.parentTransform = this.transform.parentTransform;
16836
+ camera.position = this.transform.position;
16837
+ // TODO 修正 GE 四元数旋转共轭问题
16838
+ camera.setQuat(this.transform.getQuaternion().clone().conjugate());
16836
16839
  }
16837
16840
  };
16838
16841
  _proto.fromData = function fromData(data) {
@@ -25518,9 +25521,12 @@ var TextComponentBase = /*#__PURE__*/ function() {
25518
25521
  this.textStyle = new TextStyle(options);
25519
25522
  this.textLayout = new TextLayout(options);
25520
25523
  this.text = options.text.toString();
25524
+ this.lineCount = this.getLineCount(options.text, true);
25521
25525
  };
25522
- _proto.getLineCount = function getLineCount(text, context) {
25526
+ _proto.getLineCount = function getLineCount(text, init) {
25527
+ var context = this.context;
25523
25528
  var _this_textLayout = this.textLayout, letterSpace = _this_textLayout.letterSpace, overflow = _this_textLayout.overflow;
25529
+ var fontScale = init ? this.textStyle.fontSize / 10 : 1 / this.textStyle.fontScale;
25524
25530
  var width = this.textLayout.width + this.textStyle.fontOffset;
25525
25531
  var lineCount = 1;
25526
25532
  var x = 0;
@@ -25528,7 +25534,7 @@ var TextComponentBase = /*#__PURE__*/ function() {
25528
25534
  var _context_measureText;
25529
25535
  var str = text[i];
25530
25536
  var _context_measureText_width;
25531
- var textMetrics = (_context_measureText_width = context == null ? void 0 : (_context_measureText = context.measureText(str)) == null ? void 0 : _context_measureText.width) != null ? _context_measureText_width : 0;
25537
+ var textMetrics = ((_context_measureText_width = context == null ? void 0 : (_context_measureText = context.measureText(str)) == null ? void 0 : _context_measureText.width) != null ? _context_measureText_width : 0) * fontScale;
25532
25538
  // 和浏览器行为保持一致
25533
25539
  x += letterSpace;
25534
25540
  // 处理文本结束行为
@@ -25598,6 +25604,7 @@ var TextComponentBase = /*#__PURE__*/ function() {
25598
25604
  return;
25599
25605
  }
25600
25606
  this.text = value.toString();
25607
+ this.lineCount = this.getLineCount(value, false);
25601
25608
  this.isDirty = true;
25602
25609
  };
25603
25610
  /**
@@ -25758,35 +25765,32 @@ var TextComponentBase = /*#__PURE__*/ function() {
25758
25765
  var layout = this.textLayout;
25759
25766
  var fontScale = style.fontScale;
25760
25767
  var width = (layout.width + style.fontOffset) * fontScale;
25768
+ var finalHeight = layout.lineHeight * this.lineCount;
25761
25769
  var fontSize = style.fontSize * fontScale;
25762
25770
  var lineHeight = layout.lineHeight * fontScale;
25763
25771
  style.fontDesc = this.getFontDesc(fontSize);
25764
25772
  this.char = (this.text || "").split("");
25765
25773
  this.canvas.width = width;
25766
- var height = this.canvas.height;
25767
- context.font = style.fontDesc;
25768
- this.lineCount = this.getLineCount(this.text, context);
25769
- var finalHeight = layout.lineHeight * this.lineCount;
25770
25774
  if (layout.autoWidth) {
25771
25775
  this.canvas.height = finalHeight * fontScale;
25772
25776
  this.item.transform.size.set(1, finalHeight / layout.height);
25773
25777
  } else {
25774
25778
  this.canvas.height = layout.height * fontScale;
25775
25779
  }
25780
+ var height = this.canvas.height;
25781
+ // fix bug 1/255
25782
+ context.fillStyle = "rgba(255, 255, 255, 0.0039)";
25783
+ if (!flipY) {
25784
+ context.translate(0, height);
25785
+ context.scale(1, -1);
25786
+ }
25776
25787
  // canvas size 变化后重新刷新 context
25777
25788
  if (this.maxLineWidth > width && layout.overflow === TextOverflow.display) {
25778
25789
  context.font = this.getFontDesc(fontSize * width / this.maxLineWidth);
25779
25790
  } else {
25780
25791
  context.font = style.fontDesc;
25781
25792
  }
25782
- // fix bug 1/255
25783
- context.fillStyle = "rgba(255, 255, 255, 0.0039)";
25784
25793
  context.clearRect(0, 0, width, height);
25785
- if (!flipY) {
25786
- context.translate(0, height);
25787
- context.scale(1, -1);
25788
- }
25789
- context.fillRect(0, 0, width, height);
25790
25794
  if (style.hasShadow) {
25791
25795
  this.setupShadow();
25792
25796
  }
@@ -25858,9 +25862,9 @@ var TextComponentBase = /*#__PURE__*/ function() {
25858
25862
  this.material.setTexture("_MainTex", texture);
25859
25863
  this.isDirty = false;
25860
25864
  };
25861
- _proto.getFontDesc = function getFontDesc(fontSize) {
25862
- var _this_textStyle = this.textStyle, fontFamily = _this_textStyle.fontFamily, textWeight = _this_textStyle.textWeight, fontStyle = _this_textStyle.fontStyle;
25863
- var fontDesc = "" + fontSize.toString() + "px ";
25865
+ _proto.getFontDesc = function getFontDesc(size) {
25866
+ var _this_textStyle = this.textStyle, fontSize = _this_textStyle.fontSize, fontScale = _this_textStyle.fontScale, fontFamily = _this_textStyle.fontFamily, textWeight = _this_textStyle.textWeight, fontStyle = _this_textStyle.fontStyle;
25867
+ var fontDesc = "" + (size || fontSize * fontScale).toString() + "px ";
25864
25868
  if (!DEFAULT_FONTS.includes(fontFamily)) {
25865
25869
  fontDesc += '"' + fontFamily + '"';
25866
25870
  } else {
@@ -28795,12 +28799,14 @@ var tmpScale = new Vector3(1, 1, 1);
28795
28799
  function Camera(name, options) {
28796
28800
  if (options === void 0) options = {};
28797
28801
  this.name = name;
28802
+ this./**
28803
+ * @internal
28804
+ */ transform = new Transform();
28798
28805
  this.viewportMatrix = Matrix4.fromIdentity();
28799
28806
  this.viewMatrix = Matrix4.fromIdentity();
28800
28807
  this.projectionMatrix = Matrix4.fromIdentity();
28801
28808
  this.viewProjectionMatrix = Matrix4.fromIdentity();
28802
28809
  this.inverseViewMatrix = Matrix4.fromIdentity();
28803
- this.transform = new Transform();
28804
28810
  this.dirty = true;
28805
28811
  var _options_near = options.near, near = _options_near === void 0 ? 0.1 : _options_near, _options_far = options.far, far = _options_far === void 0 ? 20 : _options_far, _options_fov = options.fov, fov = _options_fov === void 0 ? 60 : _options_fov, _options_aspect = options.aspect, aspect = _options_aspect === void 0 ? 1 : _options_aspect, _options_clipMode = options.clipMode, clipMode = _options_clipMode === void 0 ? CameraClipMode.portrait : _options_clipMode, _options_position = options.position, position = _options_position === void 0 ? [
28806
28812
  0,
@@ -28914,7 +28920,10 @@ var tmpScale = new Vector3(1, 1, 1);
28914
28920
  * 设置相机的旋转四元数
28915
28921
  * @param value - 旋转四元数
28916
28922
  */ _proto.setQuat = function setQuat(value) {
28917
- this.transform.setQuaternion(value.x, value.y, value.z, value.w);
28923
+ if (!this.transform.getQuaternion().equals(value)) {
28924
+ this.transform.setQuaternion(value.x, value.y, value.z, value.w);
28925
+ this.dirty = true;
28926
+ }
28918
28927
  };
28919
28928
  /**
28920
28929
  * 获取相机旋转对应的四元数
@@ -28952,7 +28961,7 @@ var tmpScale = new Vector3(1, 1, 1);
28952
28961
  var _this_options = this.options, fov = _this_options.fov, aspect = _this_options.aspect, near = _this_options.near, far = _this_options.far, clipMode = _this_options.clipMode;
28953
28962
  this.projectionMatrix.perspective(fov * DEG2RAD, aspect, near, far, clipMode === CameraClipMode.portrait);
28954
28963
  this.projectionMatrix.premultiply(this.viewportMatrix);
28955
- this.inverseViewMatrix.compose(this.position, this.getQuat().conjugate(), tmpScale);
28964
+ this.inverseViewMatrix.compose(this.position, this.getQuat(), tmpScale);
28956
28965
  var _this_transform_getParentMatrix;
28957
28966
  this.inverseViewMatrix.premultiply((_this_transform_getParentMatrix = this.transform.getParentMatrix()) != null ? _this_transform_getParentMatrix : Matrix4.IDENTITY);
28958
28967
  this.viewMatrix.copyFrom(this.inverseViewMatrix).invert();
@@ -32070,7 +32079,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem);
32070
32079
  registerPlugin("particle", ParticleLoader, exports.VFXItem);
32071
32080
  registerPlugin("cal", CalculateLoader, exports.VFXItem);
32072
32081
  registerPlugin("interact", InteractLoader, exports.VFXItem);
32073
- var version = "2.3.0-beta.1";
32082
+ var version = "2.3.0-beta.3";
32074
32083
  logger.info("Core version: " + version + ".");
32075
32084
 
32076
32085
  exports.AbstractPlugin = AbstractPlugin;