@galacean/effects-threejs 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/index.js +32 -23
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +2 -2
- package/dist/index.min.js.map +1 -1
- package/dist/index.mjs +32 -23
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Description: Galacean Effects runtime threejs plugin for the web
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
|
|
6
|
-
* Version: v2.3.0-beta.
|
|
6
|
+
* Version: v2.3.0-beta.3
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
@@ -16854,7 +16854,10 @@ exports.CameraController = /*#__PURE__*/ function(Behaviour) {
|
|
|
16854
16854
|
camera.far = this.options.far;
|
|
16855
16855
|
camera.fov = this.options.fov;
|
|
16856
16856
|
camera.clipMode = this.options.clipMode;
|
|
16857
|
-
camera.
|
|
16857
|
+
camera.transform.parentTransform = this.transform.parentTransform;
|
|
16858
|
+
camera.position = this.transform.position;
|
|
16859
|
+
// TODO 修正 GE 四元数旋转共轭问题
|
|
16860
|
+
camera.setQuat(this.transform.getQuaternion().clone().conjugate());
|
|
16858
16861
|
}
|
|
16859
16862
|
};
|
|
16860
16863
|
_proto.fromData = function fromData(data) {
|
|
@@ -25540,9 +25543,12 @@ var TextComponentBase = /*#__PURE__*/ function() {
|
|
|
25540
25543
|
this.textStyle = new TextStyle(options);
|
|
25541
25544
|
this.textLayout = new TextLayout(options);
|
|
25542
25545
|
this.text = options.text.toString();
|
|
25546
|
+
this.lineCount = this.getLineCount(options.text, true);
|
|
25543
25547
|
};
|
|
25544
|
-
_proto.getLineCount = function getLineCount(text,
|
|
25548
|
+
_proto.getLineCount = function getLineCount(text, init) {
|
|
25549
|
+
var context = this.context;
|
|
25545
25550
|
var _this_textLayout = this.textLayout, letterSpace = _this_textLayout.letterSpace, overflow = _this_textLayout.overflow;
|
|
25551
|
+
var fontScale = init ? this.textStyle.fontSize / 10 : 1 / this.textStyle.fontScale;
|
|
25546
25552
|
var width = this.textLayout.width + this.textStyle.fontOffset;
|
|
25547
25553
|
var lineCount = 1;
|
|
25548
25554
|
var x = 0;
|
|
@@ -25550,7 +25556,7 @@ var TextComponentBase = /*#__PURE__*/ function() {
|
|
|
25550
25556
|
var _context_measureText;
|
|
25551
25557
|
var str = text[i];
|
|
25552
25558
|
var _context_measureText_width;
|
|
25553
|
-
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;
|
|
25559
|
+
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;
|
|
25554
25560
|
// 和浏览器行为保持一致
|
|
25555
25561
|
x += letterSpace;
|
|
25556
25562
|
// 处理文本结束行为
|
|
@@ -25620,6 +25626,7 @@ var TextComponentBase = /*#__PURE__*/ function() {
|
|
|
25620
25626
|
return;
|
|
25621
25627
|
}
|
|
25622
25628
|
this.text = value.toString();
|
|
25629
|
+
this.lineCount = this.getLineCount(value, false);
|
|
25623
25630
|
this.isDirty = true;
|
|
25624
25631
|
};
|
|
25625
25632
|
/**
|
|
@@ -25780,35 +25787,32 @@ var TextComponentBase = /*#__PURE__*/ function() {
|
|
|
25780
25787
|
var layout = this.textLayout;
|
|
25781
25788
|
var fontScale = style.fontScale;
|
|
25782
25789
|
var width = (layout.width + style.fontOffset) * fontScale;
|
|
25790
|
+
var finalHeight = layout.lineHeight * this.lineCount;
|
|
25783
25791
|
var fontSize = style.fontSize * fontScale;
|
|
25784
25792
|
var lineHeight = layout.lineHeight * fontScale;
|
|
25785
25793
|
style.fontDesc = this.getFontDesc(fontSize);
|
|
25786
25794
|
this.char = (this.text || "").split("");
|
|
25787
25795
|
this.canvas.width = width;
|
|
25788
|
-
var height = this.canvas.height;
|
|
25789
|
-
context.font = style.fontDesc;
|
|
25790
|
-
this.lineCount = this.getLineCount(this.text, context);
|
|
25791
|
-
var finalHeight = layout.lineHeight * this.lineCount;
|
|
25792
25796
|
if (layout.autoWidth) {
|
|
25793
25797
|
this.canvas.height = finalHeight * fontScale;
|
|
25794
25798
|
this.item.transform.size.set(1, finalHeight / layout.height);
|
|
25795
25799
|
} else {
|
|
25796
25800
|
this.canvas.height = layout.height * fontScale;
|
|
25797
25801
|
}
|
|
25802
|
+
var height = this.canvas.height;
|
|
25803
|
+
// fix bug 1/255
|
|
25804
|
+
context.fillStyle = "rgba(255, 255, 255, 0.0039)";
|
|
25805
|
+
if (!flipY) {
|
|
25806
|
+
context.translate(0, height);
|
|
25807
|
+
context.scale(1, -1);
|
|
25808
|
+
}
|
|
25798
25809
|
// canvas size 变化后重新刷新 context
|
|
25799
25810
|
if (this.maxLineWidth > width && layout.overflow === TextOverflow.display) {
|
|
25800
25811
|
context.font = this.getFontDesc(fontSize * width / this.maxLineWidth);
|
|
25801
25812
|
} else {
|
|
25802
25813
|
context.font = style.fontDesc;
|
|
25803
25814
|
}
|
|
25804
|
-
// fix bug 1/255
|
|
25805
|
-
context.fillStyle = "rgba(255, 255, 255, 0.0039)";
|
|
25806
25815
|
context.clearRect(0, 0, width, height);
|
|
25807
|
-
if (!flipY) {
|
|
25808
|
-
context.translate(0, height);
|
|
25809
|
-
context.scale(1, -1);
|
|
25810
|
-
}
|
|
25811
|
-
context.fillRect(0, 0, width, height);
|
|
25812
25816
|
if (style.hasShadow) {
|
|
25813
25817
|
this.setupShadow();
|
|
25814
25818
|
}
|
|
@@ -25880,9 +25884,9 @@ var TextComponentBase = /*#__PURE__*/ function() {
|
|
|
25880
25884
|
this.material.setTexture("_MainTex", texture);
|
|
25881
25885
|
this.isDirty = false;
|
|
25882
25886
|
};
|
|
25883
|
-
_proto.getFontDesc = function getFontDesc(
|
|
25884
|
-
var _this_textStyle = this.textStyle, fontFamily = _this_textStyle.fontFamily, textWeight = _this_textStyle.textWeight, fontStyle = _this_textStyle.fontStyle;
|
|
25885
|
-
var fontDesc = "" + fontSize.toString() + "px ";
|
|
25887
|
+
_proto.getFontDesc = function getFontDesc(size) {
|
|
25888
|
+
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;
|
|
25889
|
+
var fontDesc = "" + (size || fontSize * fontScale).toString() + "px ";
|
|
25886
25890
|
if (!DEFAULT_FONTS.includes(fontFamily)) {
|
|
25887
25891
|
fontDesc += '"' + fontFamily + '"';
|
|
25888
25892
|
} else {
|
|
@@ -28817,12 +28821,14 @@ var tmpScale = new Vector3(1, 1, 1);
|
|
|
28817
28821
|
function Camera(name, options) {
|
|
28818
28822
|
if (options === void 0) options = {};
|
|
28819
28823
|
this.name = name;
|
|
28824
|
+
this./**
|
|
28825
|
+
* @internal
|
|
28826
|
+
*/ transform = new Transform();
|
|
28820
28827
|
this.viewportMatrix = Matrix4.fromIdentity();
|
|
28821
28828
|
this.viewMatrix = Matrix4.fromIdentity();
|
|
28822
28829
|
this.projectionMatrix = Matrix4.fromIdentity();
|
|
28823
28830
|
this.viewProjectionMatrix = Matrix4.fromIdentity();
|
|
28824
28831
|
this.inverseViewMatrix = Matrix4.fromIdentity();
|
|
28825
|
-
this.transform = new Transform();
|
|
28826
28832
|
this.dirty = true;
|
|
28827
28833
|
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 ? [
|
|
28828
28834
|
0,
|
|
@@ -28936,7 +28942,10 @@ var tmpScale = new Vector3(1, 1, 1);
|
|
|
28936
28942
|
* 设置相机的旋转四元数
|
|
28937
28943
|
* @param value - 旋转四元数
|
|
28938
28944
|
*/ _proto.setQuat = function setQuat(value) {
|
|
28939
|
-
this.transform.
|
|
28945
|
+
if (!this.transform.getQuaternion().equals(value)) {
|
|
28946
|
+
this.transform.setQuaternion(value.x, value.y, value.z, value.w);
|
|
28947
|
+
this.dirty = true;
|
|
28948
|
+
}
|
|
28940
28949
|
};
|
|
28941
28950
|
/**
|
|
28942
28951
|
* 获取相机旋转对应的四元数
|
|
@@ -28974,7 +28983,7 @@ var tmpScale = new Vector3(1, 1, 1);
|
|
|
28974
28983
|
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;
|
|
28975
28984
|
this.projectionMatrix.perspective(fov * DEG2RAD, aspect, near, far, clipMode === CameraClipMode.portrait);
|
|
28976
28985
|
this.projectionMatrix.premultiply(this.viewportMatrix);
|
|
28977
|
-
this.inverseViewMatrix.compose(this.position, this.getQuat()
|
|
28986
|
+
this.inverseViewMatrix.compose(this.position, this.getQuat(), tmpScale);
|
|
28978
28987
|
var _this_transform_getParentMatrix;
|
|
28979
28988
|
this.inverseViewMatrix.premultiply((_this_transform_getParentMatrix = this.transform.getParentMatrix()) != null ? _this_transform_getParentMatrix : Matrix4.IDENTITY);
|
|
28980
28989
|
this.viewMatrix.copyFrom(this.inverseViewMatrix).invert();
|
|
@@ -32092,7 +32101,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem);
|
|
|
32092
32101
|
registerPlugin("particle", ParticleLoader, exports.VFXItem);
|
|
32093
32102
|
registerPlugin("cal", CalculateLoader, exports.VFXItem);
|
|
32094
32103
|
registerPlugin("interact", InteractLoader, exports.VFXItem);
|
|
32095
|
-
var version$1 = "2.3.0-beta.
|
|
32104
|
+
var version$1 = "2.3.0-beta.3";
|
|
32096
32105
|
logger.info("Core version: " + version$1 + ".");
|
|
32097
32106
|
|
|
32098
32107
|
var _obj;
|
|
@@ -33738,7 +33747,7 @@ setMaxSpriteMeshItemCount(8);
|
|
|
33738
33747
|
*/ Mesh.create = function(engine, props) {
|
|
33739
33748
|
return new ThreeMesh(engine, props);
|
|
33740
33749
|
};
|
|
33741
|
-
var version = "2.3.0-beta.
|
|
33750
|
+
var version = "2.3.0-beta.3";
|
|
33742
33751
|
logger.info("THREEJS plugin version: " + version + ".");
|
|
33743
33752
|
|
|
33744
33753
|
exports.AbstractPlugin = AbstractPlugin;
|