@galacean/effects-threejs 2.3.0-alpha.0 → 2.3.0-alpha.2

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 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-alpha.0
6
+ * Version: v2.3.0-alpha.2
7
7
  */
8
8
 
9
9
  'use strict';
@@ -1061,7 +1061,8 @@ function _inherits(subClass, superClass) {
1061
1061
  JSONSceneVersion["2_4"] = "2.4";
1062
1062
  JSONSceneVersion["3_0"] = "3.0";
1063
1063
  JSONSceneVersion["3_1"] = "3.1";
1064
- JSONSceneVersion["LATEST"] = "3.1";
1064
+ JSONSceneVersion["3_2"] = "3.2";
1065
+ JSONSceneVersion["LATEST"] = "3.2";
1065
1066
  })(JSONSceneVersion || (JSONSceneVersion = {}));
1066
1067
 
1067
1068
  /*********************************************/ /* 元素属性参数类型 */ /*********************************************/ /**
@@ -1599,7 +1600,7 @@ var MaterialBlending;
1599
1600
  var TextOverflow;
1600
1601
  (function(TextOverflow) {
1601
1602
  /**
1602
- * display 模式下,会显示所有文本,存在文本超过边界框的情况。
1603
+ * display 模式下,会显示所有文本,文本大小会根据边界框调整。
1603
1604
  */ TextOverflow[TextOverflow["display"] = 0] = "display";
1604
1605
  /**
1605
1606
  * clip 模式下,当文本内容超出边界框时,多余的会被截断。
@@ -1692,12 +1693,18 @@ var BuiltinObjectGUID = {
1692
1693
  */ ShapePrimitiveType[ShapePrimitiveType["Star"] = 4] = "Star";
1693
1694
  })(ShapePrimitiveType || (ShapePrimitiveType = {}));
1694
1695
 
1695
- // 本期无该功能 待补充
1696
- var ShapeConnectType;
1697
- (function(ShapeConnectType) {})(ShapeConnectType || (ShapeConnectType = {}));
1698
- // @待补充
1699
- var ShapePointType;
1700
- (function(ShapePointType) {})(ShapePointType || (ShapePointType = {}));
1696
+ var LineCap;
1697
+ (function(LineCap) {
1698
+ /** 默认值。向线条的每个末端添加平直的边缘 */ LineCap[LineCap["Butt"] = 0] = "Butt";
1699
+ /** 向线条的每个末端添加圆形线帽 */ LineCap[LineCap["Round"] = 1] = "Round";
1700
+ /** 向线条的每个末端添加正方形线帽 */ LineCap[LineCap["Square"] = 2] = "Square";
1701
+ })(LineCap || (LineCap = {}));
1702
+ var LineJoin;
1703
+ (function(LineJoin) {
1704
+ /** 创建圆角 */ LineJoin[LineJoin["Round"] = 0] = "Round";
1705
+ /** 创建斜角 */ LineJoin[LineJoin["Bevel"] = 1] = "Bevel";
1706
+ /** 创建尖角 */ LineJoin[LineJoin["Miter"] = 2] = "Miter";
1707
+ })(LineJoin || (LineJoin = {}));
1701
1708
 
1702
1709
  /**
1703
1710
  * 动态换图类型
@@ -1906,8 +1913,8 @@ var index$1 = /*#__PURE__*/Object.freeze({
1906
1913
  get FontStyle () { return FontStyle; },
1907
1914
  BuiltinObjectGUID: BuiltinObjectGUID,
1908
1915
  get ShapePrimitiveType () { return ShapePrimitiveType; },
1909
- get ShapeConnectType () { return ShapeConnectType; },
1910
- get ShapePointType () { return ShapePointType; },
1916
+ get LineCap () { return LineCap; },
1917
+ get LineJoin () { return LineJoin; },
1911
1918
  get BackgroundType () { return BackgroundType; },
1912
1919
  get MultimediaType () { return MultimediaType; },
1913
1920
  get DataType () { return DataType; },
@@ -3826,7 +3833,9 @@ Vector4.ZERO = new Vector4(0.0, 0.0, 0.0, 0.0);
3826
3833
  if (renderer.renderingData.currentFrame.globalUniforms) {
3827
3834
  renderer.setGlobalMatrix("effects_ObjectToWorld", this.transform.getWorldMatrix());
3828
3835
  }
3829
- renderer.drawGeometry(this.geometry, this.material);
3836
+ for(var i = 0; i < this.materials.length; i++){
3837
+ renderer.drawGeometry(this.geometry, this.materials[i], i);
3838
+ }
3830
3839
  };
3831
3840
  _proto.getBoundingBox = function getBoundingBox() {
3832
3841
  var worldMatrix = this.transform.getWorldMatrix();
@@ -7361,7 +7370,15 @@ var BYTES_TYPE_MAP = (_obj$6 = {}, _obj$6[glContext.FLOAT] = Float32Array.BYTES_
7361
7370
  */ var Geometry = /*#__PURE__*/ function(EffectsObject) {
7362
7371
  _inherits(Geometry, EffectsObject);
7363
7372
  function Geometry() {
7364
- return EffectsObject.apply(this, arguments);
7373
+ var _this;
7374
+ _this = EffectsObject.apply(this, arguments) || this;
7375
+ /**
7376
+ * Geometry 的名称
7377
+ */ _this.name = "";
7378
+ /**
7379
+ * 子网格数据
7380
+ */ _this.subMeshes = [];
7381
+ return _this;
7365
7382
  }
7366
7383
  var _proto = Geometry.prototype;
7367
7384
  /**
@@ -10208,7 +10225,7 @@ var integrate = "float calculateMovement(float t,vec2 p1,vec2 p2,vec2 p3,vec2 p4
10208
10225
 
10209
10226
  var itemVert = "precision highp float;attribute vec2 atlasOffset;attribute vec3 aPos;varying vec2 vTexCoord;varying vec3 vParams;varying vec4 vColor;uniform vec2 _Size;uniform vec3 _Scale;uniform vec4 _Color;uniform vec4 _TexParams;uniform vec4 _TexOffset;uniform mat4 effects_MatrixVP;uniform mat4 effects_ObjectToWorld;uniform mat4 effects_MatrixV;\n#ifdef ENV_EDITOR\nuniform vec4 uEditorTransform;\n#endif\nvoid main(){vec4 texParams=_TexParams;vTexCoord=vec2(atlasOffset.xy*_TexOffset.zw+_TexOffset.xy);vColor=_Color;vParams=vec3(0.0,texParams.y,texParams.x);if(texParams.z==1.0){vec4 pos=vec4(aPos.xy*_Size,aPos.z,1.0);gl_Position=effects_MatrixVP*effects_ObjectToWorld*pos;}else{mat4 view=effects_MatrixV;vec3 camRight=vec3(view[0][0],view[1][0],view[2][0]);vec3 camUp=vec3(view[0][1],view[1][1],view[2][1]);vec3 worldPosition=vec3(effects_ObjectToWorld*vec4(0.0,0.0,0.0,1.0));vec3 vertexPosition=worldPosition+camRight*aPos.x*_Size.x*_Scale.x+camUp*aPos.y*_Size.y*_Scale.y;gl_Position=effects_MatrixVP*vec4(vertexPosition,1.0);}\n#ifdef ENV_EDITOR\ngl_Position=vec4(gl_Position.xy*uEditorTransform.xy+uEditorTransform.zw*gl_Position.w,gl_Position.zw);\n#endif\n}";
10210
10227
 
10211
- var itemFrag = "precision highp float;varying vec4 vColor;varying vec2 vTexCoord;varying vec3 vParams;uniform sampler2D _MainTex;vec4 blendColor(vec4 color,vec4 vc,float mode){vec4 ret=color*vc;float alpha=ret.a;if(mode==1.){ret.rgb*=alpha;}else if(mode==2.){ret.rgb*=alpha;ret.a=dot(ret.rgb,vec3(0.33333333));}else if(mode==3.){alpha=color.r*alpha;ret=vec4(vc.rgb*alpha,alpha);}return ret;}void main(){vec4 color=vec4(0.);vec4 texColor=texture2D(_MainTex,vTexCoord.xy);color=blendColor(texColor,vColor,floor(0.5+vParams.y));\n#ifdef ALPHA_CLIP\nif(vParams.z==0.&&color.a<0.04){discard;}\n#endif\ncolor.a=clamp(color.a,0.0,1.0);gl_FragColor=color;}";
10228
+ var itemFrag = "precision highp float;varying vec4 vColor;varying vec2 vTexCoord;varying vec3 vParams;uniform sampler2D _MainTex;vec4 blendColor(vec4 color,vec4 vc,float mode){vec4 ret=color*vc;float alpha=ret.a;if(mode==1.){ret.rgb*=alpha;}else if(mode==2.){ret.rgb*=alpha;ret.a=dot(ret.rgb,vec3(0.33333333));}else if(mode==3.){alpha=color.r*alpha;ret=vec4(vc.rgb*alpha,alpha);}return ret;}void main(){vec4 color=vec4(0.);\n#ifdef TRANSPARENT_VIDEO\nvec2 uv_rgb=vec2(vTexCoord.x*0.5000,vTexCoord.y);vec2 uv_alpha=vec2(vTexCoord.x*0.5000+0.5000,vTexCoord.y);vec3 rgb=texture2D(_MainTex,uv_rgb).rgb;float alpha=texture2D(_MainTex,uv_alpha).r;vec4 texColor=vec4(rgb/alpha,alpha);\n#else\nvec4 texColor=texture2D(_MainTex,vTexCoord.xy);\n#endif\ncolor=blendColor(texColor,vColor,floor(0.5+vParams.y));\n#ifdef ALPHA_CLIP\nif(vParams.z==0.&&color.a<0.04){discard;}\n#endif\ncolor.a=clamp(color.a,0.0,1.0);gl_FragColor=color;}";
10212
10229
 
10213
10230
  var particleFrag = "#version 100\nprecision mediump float;vec4 blendColor(vec4 color,vec4 vc,float mode){vec4 ret=color*vc;float alpha=ret.a;if(mode==1.){ret.rgb*=alpha;}else if(mode==2.){ret.rgb*=alpha;ret.a=dot(ret.rgb,vec3(0.33333333));}else if(mode==3.){alpha=color.r*alpha;ret=vec4(vc.rgb*alpha,alpha);}return ret;}\n#define PATICLE_SHADER 1\nvarying float vLife;varying vec2 vTexCoord;varying vec4 vColor;uniform vec3 emissionColor;uniform float emissionIntensity;uniform sampler2D uMaskTex;uniform vec4 uColorParams;uniform vec2 uTexOffset;\n#ifdef COLOR_OVER_LIFETIME\nuniform sampler2D uColorOverLifetime;\n#endif\n#ifdef USE_SPRITE\nvarying vec4 vTexCoordBlend;\n#endif\nvarying float vSeed;\n#ifdef PREVIEW_BORDER\nuniform vec4 uPreviewColor;\n#endif\n#ifdef USE_SPRITE\nvec4 getTextureColor(sampler2D tex,vec2 texCoord){if(vTexCoordBlend.w>0.){return mix(texture2D(tex,texCoord),texture2D(tex,vTexCoordBlend.xy+texCoord),vTexCoordBlend.z);}return texture2D(tex,texCoord);}\n#else\n#define getTextureColor texture2D\n#endif\n#ifndef WEBGL2\n#define round(a) floor(0.5+a)\n#endif\n#ifdef PREVIEW_BORDER\nvoid main(){gl_FragColor=uPreviewColor;}\n#else\nvoid main(){vec4 color=vec4(1.0);vec4 tempColor=vColor;vec2 texOffset=uTexOffset;if(vLife<0.){discard;}if(uColorParams.x>0.0){color=getTextureColor(uMaskTex,vTexCoord);}\n#ifdef COLOR_OVER_LIFETIME\n#ifndef ENABLE_VERTEX_TEXTURE\ntempColor*=texture2D(uColorOverLifetime,vec2(vLife,0.));\n#endif\n#endif\ncolor=blendColor(color,tempColor,round(uColorParams.y));if(color.a<=0.01&&uColorParams.w>0.){float _at=texture2D(uMaskTex,vTexCoord+texOffset).a+texture2D(uMaskTex,vTexCoord+texOffset*-1.).a;if(_at<=0.02){discard;}}vec3 emission=emissionColor*pow(2.0,emissionIntensity);color=vec4(pow(pow(color.rgb,vec3(2.2))+emission,vec3(1.0/2.2)),color.a);gl_FragColor=color;}\n#endif\n";
10214
10231
 
@@ -12727,18 +12744,12 @@ var BezierCurve = /*#__PURE__*/ function(ValueGetter) {
12727
12744
  var keyTimeStart = this.curveMap[keyTimeData[0]].timeStart;
12728
12745
  var keyTimeEnd = this.curveMap[keyTimeData[keyTimeData.length - 1]].timeEnd;
12729
12746
  if (time <= keyTimeStart) {
12730
- if (this.startKeyframe[0] === BezierKeyframeType.LINE || this.startKeyframe[0] === BezierKeyframeType.HOLD) {
12731
- keyframeInfo.getPointIndexInCurve(this.startKeyframe, keyframeInfo.pointIndexCache);
12732
- return this.endKeyframe[1][keyframeInfo.pointIndexCache.yIndex];
12733
- }
12734
- return this.getCurveValue(keyTimeData[0], keyTimeStart);
12747
+ keyframeInfo.getPointIndexInCurve(this.startKeyframe, keyframeInfo.pointIndexCache);
12748
+ return this.startKeyframe[1][keyframeInfo.pointIndexCache.yIndex];
12735
12749
  }
12736
12750
  if (time >= keyTimeEnd) {
12737
- if (this.endKeyframe[0] === BezierKeyframeType.LINE || this.endKeyframe[0] === BezierKeyframeType.HOLD) {
12738
- keyframeInfo.getPointIndexInCurve(this.endKeyframe, keyframeInfo.pointIndexCache);
12739
- return this.endKeyframe[1][keyframeInfo.pointIndexCache.yIndex];
12740
- }
12741
- return this.getCurveValue(keyTimeData[keyTimeData.length - 1], keyTimeEnd);
12751
+ keyframeInfo.getPointIndexInCurve(this.endKeyframe, keyframeInfo.pointIndexCache);
12752
+ return this.endKeyframe[1][keyframeInfo.pointIndexCache.yIndex];
12742
12753
  }
12743
12754
  for(var i = 0; i < keyTimeData.length; i++){
12744
12755
  var xMin = this.curveMap[keyTimeData[i]].timeStart;
@@ -13590,11 +13601,14 @@ var ColorCurve = /*#__PURE__*/ function(ValueGetter) {
13590
13601
  maxVertex: 4
13591
13602
  });
13592
13603
  };
13593
- _proto.createMaterial = function createMaterial(renderInfo, count) {
13594
- var side = renderInfo.side, occlusion = renderInfo.occlusion, blending = renderInfo.blending, maskMode = renderInfo.maskMode, mask = renderInfo.mask;
13595
- var materialProps = {
13604
+ _proto.getMaterialProps = function getMaterialProps(renderInfo, count) {
13605
+ return {
13596
13606
  shader: spriteMeshShaderFromRenderInfo(renderInfo, count, 1)
13597
13607
  };
13608
+ };
13609
+ _proto.createMaterial = function createMaterial(renderInfo, count) {
13610
+ var side = renderInfo.side, occlusion = renderInfo.occlusion, blending = renderInfo.blending, maskMode = renderInfo.maskMode, mask = renderInfo.mask;
13611
+ var materialProps = this.getMaterialProps(renderInfo, count);
13598
13612
  this.preMultiAlpha = getPreMultiAlpha(blending);
13599
13613
  var material = Material.create(this.engine, materialProps);
13600
13614
  var states = {
@@ -14881,6 +14895,10 @@ function triangulate(contours) {
14881
14895
  points
14882
14896
  ]);
14883
14897
  var indexStart = vertices.length / 2;
14898
+ // 当所有 points 在一条直线时, gluTess 三角化 triangles 会返回空数组,这边做一下额外处理返回线段左右端点组成的三角形,确保拿到的包围盒是正确的。
14899
+ if (triangles.length === 0) {
14900
+ this.getLineEndPointsTriangle(points, triangles);
14901
+ }
14884
14902
  for(var i = 0; i < triangles.length; i++){
14885
14903
  vertices[verticesOffset * 2 + i] = triangles[i];
14886
14904
  }
@@ -14889,6 +14907,57 @@ function triangulate(contours) {
14889
14907
  indices[indicesOffset + i1] = indexStart + i1;
14890
14908
  }
14891
14909
  };
14910
+ /**
14911
+ * 获取直线上最远的两个端点坐标组成的三角形
14912
+ */ _proto.getLineEndPointsTriangle = function getLineEndPointsTriangle(points, triangles) {
14913
+ // 参数检查
14914
+ if (!points || points.length < 2 || points.length % 2 !== 0) {
14915
+ throw new Error("Invalid points array");
14916
+ }
14917
+ if (points.length === 2) {
14918
+ triangles.push(points[0], points[1], points[0], points[1], points[0], points[1]);
14919
+ return;
14920
+ }
14921
+ // 取第一个线段计算斜率
14922
+ var dx = points[2] - points[0];
14923
+ var dy = points[3] - points[1];
14924
+ // 存放结果坐标
14925
+ var startX = points[0];
14926
+ var startY = points[1];
14927
+ var endX = points[0];
14928
+ var endY = points[1];
14929
+ // 根据斜率决定比较x还是y
14930
+ if (Math.abs(dx) >= Math.abs(dy)) {
14931
+ // 水平方向为主,比较x坐标
14932
+ for(var i = 0; i < points.length; i += 2){
14933
+ var x = points[i];
14934
+ var y = points[i + 1];
14935
+ if (x < startX) {
14936
+ startX = x;
14937
+ startY = y;
14938
+ }
14939
+ if (x > endX) {
14940
+ endX = x;
14941
+ endY = y;
14942
+ }
14943
+ }
14944
+ } else {
14945
+ // 垂直方向为主,比较y坐标
14946
+ for(var i1 = 0; i1 < points.length; i1 += 2){
14947
+ var x1 = points[i1];
14948
+ var y1 = points[i1 + 1];
14949
+ if (y1 < startY) {
14950
+ startX = x1;
14951
+ startY = y1;
14952
+ }
14953
+ if (y1 > endY) {
14954
+ endX = x1;
14955
+ endY = y1;
14956
+ }
14957
+ }
14958
+ }
14959
+ triangles.push(startX, startY, endX, endY, endX, endY);
14960
+ };
14892
14961
  _create_class(Polygon, [
14893
14962
  {
14894
14963
  key: "lastX",
@@ -15362,47 +15431,48 @@ var PolyStar = /*#__PURE__*/ function(ShapePrimitive) {
15362
15431
  }(ShapePrimitive);
15363
15432
 
15364
15433
  // Based on:
15365
- // const tempPoints = [new Point(), new Point(), new Point(), new Point()];
15366
15434
  /**
15367
- * The `Rectangle` object is an area defined by its position, as indicated by its upper-left corner
15368
- * point (`x`, `y`) and by its `width` and its `height`.
15435
+ * The `Rectangle` object is an area defined by its position, as indicated by its top-left corner
15436
+ * point (`x`, `y`) and by its `width` and its `height`, including a `roundness` property that
15437
+ * defines the roundness of the rounded corners.
15438
+ * @memberof maths
15369
15439
  */ var Rectangle$1 = /*#__PURE__*/ function(ShapePrimitive) {
15370
15440
  _inherits(Rectangle, ShapePrimitive);
15371
- function Rectangle(x, y, width, height) {
15441
+ function Rectangle(x, y, width, height, roundness) {
15372
15442
  if (x === void 0) x = 0;
15373
15443
  if (y === void 0) y = 0;
15374
15444
  if (width === void 0) width = 0;
15375
15445
  if (height === void 0) height = 0;
15446
+ if (roundness === void 0) roundness = 20;
15376
15447
  var _this;
15377
15448
  _this = ShapePrimitive.call(this) || this;
15378
- _this.x = Number(x);
15379
- _this.y = Number(y);
15380
- _this.width = Number(width);
15381
- _this.height = Number(height);
15449
+ _this.x = x;
15450
+ _this.y = y;
15451
+ _this.width = width;
15452
+ _this.height = height;
15453
+ _this.roundness = roundness;
15382
15454
  return _this;
15383
15455
  }
15384
15456
  var _proto = Rectangle.prototype;
15385
- /** Determines whether the Rectangle is empty. */ _proto.isEmpty = function isEmpty() {
15386
- return this.left === this.right || this.top === this.bottom;
15457
+ /**
15458
+ * Returns the framing rectangle of the rectangle as a Rectangle object
15459
+ * @param out - optional rectangle to store the result
15460
+ * @returns The framing rectangle
15461
+ */ _proto.getBounds = function getBounds(out) {
15462
+ out = out || new Rectangle();
15463
+ out.x = this.x;
15464
+ out.y = this.y;
15465
+ out.width = this.width;
15466
+ out.height = this.height;
15467
+ return out;
15387
15468
  };
15388
15469
  /**
15389
- * Creates a clone of this Rectangle
15390
- * @returns a copy of the rectangle
15470
+ * Creates a clone of this rectangle.
15471
+ * @returns - A copy of the rectangle.
15391
15472
  */ _proto.clone = function clone() {
15392
- return new Rectangle(this.x, this.y, this.width, this.height);
15473
+ return new Rectangle(this.x, this.y, this.width, this.height, this.roundness);
15393
15474
  };
15394
15475
  /**
15395
- * Converts a Bounds object to a Rectangle object.
15396
- * @param bounds - The bounds to copy and convert to a rectangle.
15397
- * @returns Returns itself.
15398
- */ // copyFromBounds (bounds: Bounds): this {
15399
- // this.x = bounds.minX;
15400
- // this.y = bounds.minY;
15401
- // this.width = bounds.maxX - bounds.minX;
15402
- // this.height = bounds.maxY - bounds.minY;
15403
- // return this;
15404
- // }
15405
- /**
15406
15476
  * Copies another rectangle to this one.
15407
15477
  * @param rectangle - The rectangle to copy from.
15408
15478
  * @returns Returns itself.
@@ -15411,6 +15481,7 @@ var PolyStar = /*#__PURE__*/ function(ShapePrimitive) {
15411
15481
  this.y = rectangle.y;
15412
15482
  this.width = rectangle.width;
15413
15483
  this.height = rectangle.height;
15484
+ this.roundness = rectangle.roundness;
15414
15485
  return this;
15415
15486
  };
15416
15487
  /**
@@ -15421,267 +15492,121 @@ var PolyStar = /*#__PURE__*/ function(ShapePrimitive) {
15421
15492
  rectangle.copyFrom(this);
15422
15493
  return rectangle;
15423
15494
  };
15424
- /**
15425
- * Checks whether the x and y coordinates given are contained within this Rectangle
15426
- * @param x - The X coordinate of the point to test
15427
- * @param y - The Y coordinate of the point to test
15428
- * @returns Whether the x/y coordinates are within this Rectangle
15429
- */ _proto.contains = function contains(x, y) {
15430
- if (this.width <= 0 || this.height <= 0) {
15431
- return false;
15495
+ _proto.build = function build(points) {
15496
+ var ry;
15497
+ var halfWidth = this.width / 2;
15498
+ var halfHeight = this.height / 2;
15499
+ var x = this.x + halfWidth;
15500
+ var y = this.y + halfHeight;
15501
+ var rx = ry = Math.max(0, Math.min(this.roundness / 100, 1) * Math.min(halfWidth, halfHeight));
15502
+ var dx = halfWidth - rx;
15503
+ var dy = halfHeight - ry;
15504
+ if (!(rx >= 0 && ry >= 0 && dx >= 0 && dy >= 0)) {
15505
+ return;
15432
15506
  }
15433
- if (x >= this.x && x < this.x + this.width) {
15434
- if (y >= this.y && y < this.y + this.height) {
15435
- return true;
15436
- }
15507
+ // 控制边缘的平滑程度
15508
+ var densityScale = 5;
15509
+ // Choose a number of segments such that the maximum absolute deviation from the circle is approximately 0.029
15510
+ var n = densityScale * Math.ceil(2.3 * Math.sqrt(rx + ry));
15511
+ var m = n * 8 + (dx ? 4 : 0) + (dy ? 4 : 0);
15512
+ if (m === 0) {
15513
+ return;
15437
15514
  }
15438
- return false;
15439
- };
15440
- /**
15441
- * Checks whether the x and y coordinates given are contained within this rectangle including the stroke.
15442
- * @param x - The X coordinate of the point to test
15443
- * @param y - The Y coordinate of the point to test
15444
- * @param strokeWidth - The width of the line to check
15445
- * @returns Whether the x/y coordinates are within this rectangle
15446
- */ _proto.strokeContains = function strokeContains(x, y, strokeWidth) {
15447
- var _this = this, width = _this.width, height = _this.height;
15448
- if (width <= 0 || height <= 0) {
15449
- return false;
15515
+ if (n === 0) {
15516
+ points[0] = points[6] = x + dx;
15517
+ points[1] = points[3] = y + dy;
15518
+ points[2] = points[4] = x - dx;
15519
+ points[5] = points[7] = y - dy;
15520
+ return;
15450
15521
  }
15451
- var _x = this.x;
15452
- var _y = this.y;
15453
- var outerLeft = _x - strokeWidth / 2;
15454
- var outerRight = _x + width + strokeWidth / 2;
15455
- var outerTop = _y - strokeWidth / 2;
15456
- var outerBottom = _y + height + strokeWidth / 2;
15457
- var innerLeft = _x + strokeWidth / 2;
15458
- var innerRight = _x + width - strokeWidth / 2;
15459
- var innerTop = _y + strokeWidth / 2;
15460
- var innerBottom = _y + height - strokeWidth / 2;
15461
- return x >= outerLeft && x <= outerRight && y >= outerTop && y <= outerBottom && !(x > innerLeft && x < innerRight && y > innerTop && y < innerBottom);
15462
- };
15463
- /**
15464
- * Determines whether the `other` Rectangle transformed by `transform` intersects with `this` Rectangle object.
15465
- * Returns true only if the area of the intersection is >0, this means that Rectangles
15466
- * sharing a side are not overlapping. Another side effect is that an arealess rectangle
15467
- * (width or height equal to zero) can't intersect any other rectangle.
15468
- * @param {Rectangle} other - The Rectangle to intersect with `this`.
15469
- * @param {Matrix} transform - The transformation matrix of `other`.
15470
- * @returns {boolean} A value of `true` if the transformed `other` Rectangle intersects with `this`; otherwise `false`.
15471
- */ // intersects (other: Rectangle, transform?: Matrix4): boolean {
15472
- // if (!transform) {
15473
- // const x0 = this.x < other.x ? other.x : this.x;
15474
- // const x1 = this.right > other.right ? other.right : this.right;
15475
- // if (x1 <= x0) {
15476
- // return false;
15477
- // }
15478
- // const y0 = this.y < other.y ? other.y : this.y;
15479
- // const y1 = this.bottom > other.bottom ? other.bottom : this.bottom;
15480
- // return y1 > y0;
15481
- // }
15482
- // const x0 = this.left;
15483
- // const x1 = this.right;
15484
- // const y0 = this.top;
15485
- // const y1 = this.bottom;
15486
- // if (x1 <= x0 || y1 <= y0) {
15487
- // return false;
15488
- // }
15489
- // const lt = tempPoints[0].set(other.left, other.top);
15490
- // const lb = tempPoints[1].set(other.left, other.bottom);
15491
- // const rt = tempPoints[2].set(other.right, other.top);
15492
- // const rb = tempPoints[3].set(other.right, other.bottom);
15493
- // if (rt.x <= lt.x || lb.y <= lt.y) {
15494
- // return false;
15495
- // }
15496
- // const s = Math.sign((transform.a * transform.d) - (transform.b * transform.c));
15497
- // if (s === 0) {
15498
- // return false;
15499
- // }
15500
- // transform.apply(lt, lt);
15501
- // transform.apply(lb, lb);
15502
- // transform.apply(rt, rt);
15503
- // transform.apply(rb, rb);
15504
- // if (Math.max(lt.x, lb.x, rt.x, rb.x) <= x0
15505
- // || Math.min(lt.x, lb.x, rt.x, rb.x) >= x1
15506
- // || Math.max(lt.y, lb.y, rt.y, rb.y) <= y0
15507
- // || Math.min(lt.y, lb.y, rt.y, rb.y) >= y1) {
15508
- // return false;
15509
- // }
15510
- // const nx = s * (lb.y - lt.y);
15511
- // const ny = s * (lt.x - lb.x);
15512
- // const n00 = (nx * x0) + (ny * y0);
15513
- // const n10 = (nx * x1) + (ny * y0);
15514
- // const n01 = (nx * x0) + (ny * y1);
15515
- // const n11 = (nx * x1) + (ny * y1);
15516
- // if (Math.max(n00, n10, n01, n11) <= (nx * lt.x) + (ny * lt.y)
15517
- // || Math.min(n00, n10, n01, n11) >= (nx * rb.x) + (ny * rb.y)) {
15518
- // return false;
15519
- // }
15520
- // const mx = s * (lt.y - rt.y);
15521
- // const my = s * (rt.x - lt.x);
15522
- // const m00 = (mx * x0) + (my * y0);
15523
- // const m10 = (mx * x1) + (my * y0);
15524
- // const m01 = (mx * x0) + (my * y1);
15525
- // const m11 = (mx * x1) + (my * y1);
15526
- // if (Math.max(m00, m10, m01, m11) <= (mx * lt.x) + (my * lt.y)
15527
- // || Math.min(m00, m10, m01, m11) >= (mx * rb.x) + (my * rb.y)) {
15528
- // return false;
15529
- // }
15530
- // return true;
15531
- // }
15532
- /**
15533
- * Pads the rectangle making it grow in all directions.
15534
- * If paddingY is omitted, both paddingX and paddingY will be set to paddingX.
15535
- * @param paddingX - The horizontal padding amount.
15536
- * @param paddingY - The vertical padding amount.
15537
- * @returns Returns itself.
15538
- */ _proto.pad = function pad(paddingX, paddingY) {
15539
- if (paddingX === void 0) paddingX = 0;
15540
- if (paddingY === void 0) paddingY = paddingX;
15541
- this.x -= paddingX;
15542
- this.y -= paddingY;
15543
- this.width += paddingX * 2;
15544
- this.height += paddingY * 2;
15545
- return this;
15546
- };
15547
- /**
15548
- * Fits this rectangle around the passed one.
15549
- * @param rectangle - The rectangle to fit.
15550
- * @returns Returns itself.
15551
- */ _proto.fit = function fit(rectangle) {
15552
- var x1 = Math.max(this.x, rectangle.x);
15553
- var x2 = Math.min(this.x + this.width, rectangle.x + rectangle.width);
15554
- var y1 = Math.max(this.y, rectangle.y);
15555
- var y2 = Math.min(this.y + this.height, rectangle.y + rectangle.height);
15556
- this.x = x1;
15557
- this.width = Math.max(x2 - x1, 0);
15558
- this.y = y1;
15559
- this.height = Math.max(y2 - y1, 0);
15560
- return this;
15561
- };
15562
- /**
15563
- * Enlarges rectangle that way its corners lie on grid
15564
- * @param resolution - resolution
15565
- * @param eps - precision
15566
- * @returns Returns itself.
15567
- */ _proto.ceil = function ceil(resolution, eps) {
15568
- if (resolution === void 0) resolution = 1;
15569
- if (eps === void 0) eps = 0.001;
15570
- var x2 = Math.ceil((this.x + this.width - eps) * resolution) / resolution;
15571
- var y2 = Math.ceil((this.y + this.height - eps) * resolution) / resolution;
15572
- this.x = Math.floor((this.x + eps) * resolution) / resolution;
15573
- this.y = Math.floor((this.y + eps) * resolution) / resolution;
15574
- this.width = x2 - this.x;
15575
- this.height = y2 - this.y;
15576
- return this;
15577
- };
15578
- /**
15579
- * Enlarges this rectangle to include the passed rectangle.
15580
- * @param rectangle - The rectangle to include.
15581
- * @returns Returns itself.
15582
- */ _proto.enlarge = function enlarge(rectangle) {
15583
- var x1 = Math.min(this.x, rectangle.x);
15584
- var x2 = Math.max(this.x + this.width, rectangle.x + rectangle.width);
15585
- var y1 = Math.min(this.y, rectangle.y);
15586
- var y2 = Math.max(this.y + this.height, rectangle.y + rectangle.height);
15587
- this.x = x1;
15588
- this.width = x2 - x1;
15589
- this.y = y1;
15590
- this.height = y2 - y1;
15591
- return this;
15592
- };
15593
- /**
15594
- * Returns the framing rectangle of the rectangle as a Rectangle object
15595
- * @param out - optional rectangle to store the result
15596
- * @returns The framing rectangle
15597
- */ _proto.getBounds = function getBounds(out) {
15598
- out = out || new Rectangle();
15599
- out.copyFrom(this);
15600
- return out;
15601
- };
15602
- _proto.getX = function getX() {
15603
- return this.x;
15604
- };
15605
- _proto.getY = function getY() {
15606
- return this.y;
15607
- };
15608
- _proto.build = function build(points) {
15609
- var x = this.x;
15610
- var y = this.y;
15611
- var width = this.width;
15612
- var height = this.height;
15613
- if (!(width >= 0 && height >= 0)) {
15614
- return points;
15522
+ var j1 = 0;
15523
+ var j2 = n * 4 + (dx ? 2 : 0) + 2;
15524
+ var j3 = j2;
15525
+ var j4 = m;
15526
+ var x0 = dx + rx;
15527
+ var y0 = dy;
15528
+ var x1 = x + x0;
15529
+ var x2 = x - x0;
15530
+ var y1 = y + y0;
15531
+ points[j1++] = x1;
15532
+ points[j1++] = y1;
15533
+ points[--j2] = y1;
15534
+ points[--j2] = x2;
15535
+ if (dy) {
15536
+ var y2 = y - y0;
15537
+ points[j3++] = x2;
15538
+ points[j3++] = y2;
15539
+ points[--j4] = y2;
15540
+ points[--j4] = x1;
15541
+ }
15542
+ for(var i = 1; i < n; i++){
15543
+ var a = Math.PI / 2 * (i / n);
15544
+ var x01 = dx + Math.cos(a) * rx;
15545
+ var y01 = dy + Math.sin(a) * ry;
15546
+ var x11 = x + x01;
15547
+ var x21 = x - x01;
15548
+ var y11 = y + y01;
15549
+ var y21 = y - y01;
15550
+ points[j1++] = x11;
15551
+ points[j1++] = y11;
15552
+ points[--j2] = y11;
15553
+ points[--j2] = x21;
15554
+ points[j3++] = x21;
15555
+ points[j3++] = y21;
15556
+ points[--j4] = y21;
15557
+ points[--j4] = x11;
15558
+ }
15559
+ x0 = dx;
15560
+ y0 = dy + ry;
15561
+ x1 = x + x0;
15562
+ x2 = x - x0;
15563
+ y1 = y + y0;
15564
+ var y22 = y - y0;
15565
+ points[j1++] = x1;
15566
+ points[j1++] = y1;
15567
+ points[--j4] = y22;
15568
+ points[--j4] = x1;
15569
+ if (dx) {
15570
+ points[j1++] = x2;
15571
+ points[j1++] = y1;
15572
+ points[--j4] = y22;
15573
+ points[--j4] = x2;
15615
15574
  }
15616
- points[0] = x;
15617
- points[1] = y;
15618
- points[2] = x + width;
15619
- points[3] = y;
15620
- points[4] = x + width;
15621
- points[5] = y + height;
15622
- points[6] = x;
15623
- points[7] = y + height;
15624
- return points;
15625
15575
  };
15626
15576
  _proto.triangulate = function triangulate(points, vertices, verticesOffset, indices, indicesOffset) {
15627
- var count = 0;
15628
- var verticesStride = 2;
15629
- verticesOffset *= verticesStride;
15630
- vertices[verticesOffset + count] = points[0];
15631
- vertices[verticesOffset + count + 1] = points[1];
15632
- count += verticesStride;
15633
- vertices[verticesOffset + count] = points[2];
15634
- vertices[verticesOffset + count + 1] = points[3];
15635
- count += verticesStride;
15636
- vertices[verticesOffset + count] = points[6];
15637
- vertices[verticesOffset + count + 1] = points[7];
15638
- count += verticesStride;
15639
- vertices[verticesOffset + count] = points[4];
15640
- vertices[verticesOffset + count + 1] = points[5];
15641
- count += verticesStride;
15642
- var verticesIndex = verticesOffset / verticesStride;
15643
- // triangle 1
15644
- indices[indicesOffset++] = verticesIndex;
15645
- indices[indicesOffset++] = verticesIndex + 1;
15646
- indices[indicesOffset++] = verticesIndex + 2;
15647
- // triangle 2
15648
- indices[indicesOffset++] = verticesIndex + 1;
15649
- indices[indicesOffset++] = verticesIndex + 3;
15650
- indices[indicesOffset++] = verticesIndex + 2;
15651
- };
15652
- _create_class(Rectangle, [
15653
- {
15654
- key: "left",
15655
- get: /** Returns the left edge of the rectangle. */ function get() {
15656
- return this.x;
15657
- }
15658
- },
15659
- {
15660
- key: "right",
15661
- get: /** Returns the right edge of the rectangle. */ function get() {
15662
- return this.x + this.width;
15663
- }
15664
- },
15665
- {
15666
- key: "top",
15667
- get: /** Returns the top edge of the rectangle. */ function get() {
15668
- return this.y;
15669
- }
15670
- },
15671
- {
15672
- key: "bottom",
15673
- get: /** Returns the bottom edge of the rectangle. */ function get() {
15674
- return this.y + this.height;
15675
- }
15577
+ if (points.length === 0) {
15578
+ return;
15676
15579
  }
15677
- ], [
15678
- {
15679
- key: "EMPTY",
15680
- get: /** A constant empty rectangle. This is a new object every time the property is accessed */ function get() {
15681
- return new Rectangle(0, 0, 0, 0);
15580
+ // Compute center (average of all points)
15581
+ var centerX = 0;
15582
+ var centerY = 0;
15583
+ for(var i = 0; i < points.length; i += 2){
15584
+ centerX += points[i];
15585
+ centerY += points[i + 1];
15586
+ }
15587
+ centerX /= points.length / 2;
15588
+ centerY /= points.length / 2;
15589
+ // Set center vertex
15590
+ var count = verticesOffset;
15591
+ vertices[count * 2] = centerX;
15592
+ vertices[count * 2 + 1] = centerY;
15593
+ var centerIndex = count++;
15594
+ // Set edge vertices and indices
15595
+ for(var i1 = 0; i1 < points.length; i1 += 2){
15596
+ vertices[count * 2] = points[i1];
15597
+ vertices[count * 2 + 1] = points[i1 + 1];
15598
+ if (i1 > 0) {
15599
+ indices[indicesOffset++] = count;
15600
+ indices[indicesOffset++] = centerIndex;
15601
+ indices[indicesOffset++] = count - 1;
15682
15602
  }
15603
+ count++;
15683
15604
  }
15684
- ]);
15605
+ // Connect last point to the first edge point
15606
+ indices[indicesOffset++] = centerIndex + 1;
15607
+ indices[indicesOffset++] = centerIndex;
15608
+ indices[indicesOffset++] = count - 1;
15609
+ };
15685
15610
  return Rectangle;
15686
15611
  }(ShapePrimitive);
15687
15612
 
@@ -15779,8 +15704,8 @@ var ShapePath = /*#__PURE__*/ function() {
15779
15704
  * @param h - The height of the rectangle.
15780
15705
  * @param transform - An optional `Matrix` object to apply a transformation to the rectangle.
15781
15706
  * @returns The instance of the current object for chaining.
15782
- */ _proto.rect = function rect(x, y, w, h, transform) {
15783
- this.drawShape(new Rectangle$1(x, y, w, h), transform);
15707
+ */ _proto.rect = function rect(x, y, w, h, roundness, transform) {
15708
+ this.drawShape(new Rectangle$1(x, y, w, h, roundness), transform);
15784
15709
  return this;
15785
15710
  };
15786
15711
  /**
@@ -15926,7 +15851,7 @@ var GraphicsPath = /*#__PURE__*/ function() {
15926
15851
  * @param h - The height of the rectangle.
15927
15852
  * @param transform - An optional `Matrix` object to apply a transformation to the rectangle.
15928
15853
  * @returns The instance of the current object for chaining.
15929
- */ _proto.rect = function rect(x, y, w, h, transform) {
15854
+ */ _proto.rect = function rect(x, y, w, h, roundness, transform) {
15930
15855
  this.instructions.push({
15931
15856
  action: "rect",
15932
15857
  data: [
@@ -15934,6 +15859,7 @@ var GraphicsPath = /*#__PURE__*/ function() {
15934
15859
  y,
15935
15860
  w,
15936
15861
  h,
15862
+ roundness,
15937
15863
  transform
15938
15864
  ]
15939
15865
  });
@@ -16243,9 +16169,9 @@ vertices, _verticesStride, _verticesOffset, indices, _indicesOffset) {
16243
16169
  var innerWeight = (1 - ratio) * 2;
16244
16170
  var outerWeight = ratio * 2;
16245
16171
  if (!closedShape) {
16246
- if (style.cap === "round") {
16172
+ if (style.cap === LineCap.Round) {
16247
16173
  indexCount += round(x0 - perpX * (innerWeight - outerWeight) * 0.5, y0 - perpY * (innerWeight - outerWeight) * 0.5, x0 - perpX * innerWeight, y0 - perpY * innerWeight, x0 + perpX * outerWeight, y0 + perpY * outerWeight, verts, true) + 2;
16248
- } else if (style.cap === "square") {
16174
+ } else if (style.cap === LineCap.Square) {
16249
16175
  indexCount += square(x0, y0, perpX, perpY, innerWeight, outerWeight, true, verts);
16250
16176
  }
16251
16177
  }
@@ -16284,7 +16210,7 @@ vertices, _verticesStride, _verticesOffset, indices, _indicesOffset) {
16284
16210
  verts.push(x1 - perpX * innerWeight, y1 - perpY * innerWeight);
16285
16211
  verts.push(x1 + perpX * outerWeight, y1 + perpY * outerWeight);
16286
16212
  /* 180 degree corner? */ if (dot >= 0) {
16287
- if (style.join === "round") {
16213
+ if (style.join === LineJoin.Round) {
16288
16214
  indexCount += round(x1, y1, x1 - perpX * innerWeight, y1 - perpY * innerWeight, x1 - perp1x * innerWeight, y1 - perp1y * innerWeight, verts, false) + 4;
16289
16215
  } else {
16290
16216
  indexCount += 2;
@@ -16308,7 +16234,7 @@ vertices, _verticesStride, _verticesOffset, indices, _indicesOffset) {
16308
16234
  var smallerInsideDiagonalSq = smallerInsideSegmentSq + insideWeight * insideWeight * widthSquared;
16309
16235
  var insideMiterOk = pDist <= smallerInsideDiagonalSq;
16310
16236
  if (insideMiterOk) {
16311
- if (style.join === "bevel" || pDist / widthSquared > miterLimitSquared) {
16237
+ if (style.join === LineJoin.Bevel || pDist / widthSquared > miterLimitSquared) {
16312
16238
  if (clockwise) /* rotating at inner angle */ {
16313
16239
  verts.push(imx, imy); // inner miter point
16314
16240
  verts.push(x1 + perpX * outerWeight, y1 + perpY * outerWeight); // first segment's outer vertex
@@ -16321,7 +16247,7 @@ vertices, _verticesStride, _verticesOffset, indices, _indicesOffset) {
16321
16247
  verts.push(omx, omy); // outer miter point
16322
16248
  }
16323
16249
  indexCount += 2;
16324
- } else if (style.join === "round") {
16250
+ } else if (style.join === LineJoin.Round) {
16325
16251
  if (clockwise) /* arc is outside */ {
16326
16252
  verts.push(imx, imy);
16327
16253
  verts.push(x1 + perpX * outerWeight, y1 + perpY * outerWeight);
@@ -16342,13 +16268,13 @@ vertices, _verticesStride, _verticesOffset, indices, _indicesOffset) {
16342
16268
  } else {
16343
16269
  verts.push(x1 - perpX * innerWeight, y1 - perpY * innerWeight); // first segment's inner vertex
16344
16270
  verts.push(x1 + perpX * outerWeight, y1 + perpY * outerWeight); // first segment's outer vertex
16345
- if (style.join === "round") {
16271
+ if (style.join === LineJoin.Round) {
16346
16272
  if (clockwise) /* arc is outside */ {
16347
16273
  indexCount += round(x1, y1, x1 + perpX * outerWeight, y1 + perpY * outerWeight, x1 + perp1x * outerWeight, y1 + perp1y * outerWeight, verts, true) + 2;
16348
16274
  } else /* arc is inside */ {
16349
16275
  indexCount += round(x1, y1, x1 - perpX * innerWeight, y1 - perpY * innerWeight, x1 - perp1x * innerWeight, y1 - perp1y * innerWeight, verts, false) + 2;
16350
16276
  }
16351
- } else if (style.join === "miter" && pDist / widthSquared <= miterLimitSquared) {
16277
+ } else if (style.join === LineJoin.Miter && pDist / widthSquared <= miterLimitSquared) {
16352
16278
  if (clockwise) {
16353
16279
  verts.push(omx, omy); // inner miter point
16354
16280
  verts.push(omx, omy); // inner miter point
@@ -16377,9 +16303,9 @@ vertices, _verticesStride, _verticesOffset, indices, _indicesOffset) {
16377
16303
  verts.push(x1 - perpX * innerWeight, y1 - perpY * innerWeight);
16378
16304
  verts.push(x1 + perpX * outerWeight, y1 + perpY * outerWeight);
16379
16305
  if (!closedShape) {
16380
- if (style.cap === "round") {
16306
+ if (style.cap === LineCap.Round) {
16381
16307
  indexCount += round(x1 - perpX * (innerWeight - outerWeight) * 0.5, y1 - perpY * (innerWeight - outerWeight) * 0.5, x1 - perpX * innerWeight, y1 - perpY * innerWeight, x1 + perpX * outerWeight, y1 + perpY * outerWeight, verts, false) + 2;
16382
- } else if (style.cap === "square") {
16308
+ } else if (style.cap === LineCap.Square) {
16383
16309
  indexCount += square(x1, y1, perpX, perpY, innerWeight, outerWeight, false, verts);
16384
16310
  }
16385
16311
  }
@@ -16406,9 +16332,10 @@ exports.ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
16406
16332
  var _this;
16407
16333
  _this = MeshComponent.call(this, engine) || this;
16408
16334
  _this.isStroke = false;
16335
+ _this.isFill = false;
16336
+ _this.shapeDirty = true;
16409
16337
  _this.graphicsPath = new GraphicsPath();
16410
16338
  _this.curveValues = [];
16411
- _this.shapeDirty = true;
16412
16339
  _this.vert = "\nprecision highp float;\n\nattribute vec3 aPos;//x y\n\nuniform mat4 effects_MatrixVP;\nuniform mat4 effects_MatrixInvV;\nuniform mat4 effects_ObjectToWorld;\n\nvoid main() {\n vec4 pos = vec4(aPos.xyz, 1.0);\n gl_Position = effects_MatrixVP * effects_ObjectToWorld * pos;\n}\n";
16413
16340
  _this.frag = "\nprecision highp float;\n\nuniform vec4 _Color;\n\nvoid main() {\n vec4 color = _Color;\n color.rgb *= color.a;\n gl_FragColor = color;\n}\n";
16414
16341
  if (!_this.geometry) {
@@ -16441,6 +16368,15 @@ exports.ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
16441
16368
  mode: glContext.TRIANGLES,
16442
16369
  drawCount: 4
16443
16370
  });
16371
+ _this.geometry.subMeshes.push({
16372
+ offset: 0,
16373
+ indexCount: 0,
16374
+ vertexCount: 0
16375
+ }, {
16376
+ offset: 0,
16377
+ indexCount: 0,
16378
+ vertexCount: 0
16379
+ });
16444
16380
  }
16445
16381
  if (!_this.material) {
16446
16382
  var materialProps = {
@@ -16450,18 +16386,36 @@ exports.ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
16450
16386
  glslVersion: exports.GLSLVersion.GLSL1
16451
16387
  }
16452
16388
  };
16453
- _this.material = Material.create(engine, materialProps);
16454
- _this.material.setColor("_Color", new Color(1, 1, 1, 1));
16455
- _this.material.depthMask = false;
16456
- _this.material.depthTest = true;
16457
- _this.material.blending = true;
16389
+ var fillMaterial = Material.create(engine, materialProps);
16390
+ fillMaterial.setColor("_Color", new Color(1, 1, 1, 1));
16391
+ fillMaterial.depthMask = false;
16392
+ fillMaterial.depthTest = true;
16393
+ fillMaterial.blending = true;
16394
+ _this.material = fillMaterial;
16395
+ var strokeMaterial = Material.create(engine, materialProps);
16396
+ strokeMaterial.setColor("_Color", new Color(0.25, 0.25, 0.25, 1));
16397
+ strokeMaterial.depthMask = false;
16398
+ strokeMaterial.depthTest = true;
16399
+ strokeMaterial.blending = true;
16400
+ _this.materials[1] = strokeMaterial;
16458
16401
  }
16459
16402
  _this.strokeAttributes = {
16460
16403
  width: 1,
16461
16404
  alignment: 0.5,
16462
- cap: "butt",
16463
- join: "miter",
16464
- miterLimit: 10
16405
+ cap: LineCap.Butt,
16406
+ join: LineJoin.Miter,
16407
+ miterLimit: 10,
16408
+ color: new Color(1, 1, 1, 1)
16409
+ };
16410
+ _this.fillAttribute = {
16411
+ color: new Color(1, 1, 1, 1)
16412
+ };
16413
+ _this.shapeAttribute = {
16414
+ type: ShapePrimitiveType.Custom,
16415
+ points: [],
16416
+ easingIns: [],
16417
+ easingOuts: [],
16418
+ shapes: []
16465
16419
  };
16466
16420
  return _this;
16467
16421
  }
@@ -16470,8 +16424,10 @@ exports.ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
16470
16424
  this.item.getHitTestParams = this.getHitTestParams;
16471
16425
  };
16472
16426
  _proto.onUpdate = function onUpdate(dt) {
16427
+ this.material.color = this.fillAttribute.color;
16428
+ this.materials[1].color = this.strokeAttributes.color;
16473
16429
  if (this.shapeDirty) {
16474
- this.buildPath(this.data);
16430
+ this.buildPath(this.shapeAttribute);
16475
16431
  this.buildGeometryFromPath(this.graphicsPath.shapePath);
16476
16432
  this.shapeDirty = false;
16477
16433
  }
@@ -16480,22 +16436,34 @@ exports.ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
16480
16436
  var shapePrimitives = shapePath.shapePrimitives;
16481
16437
  var vertices = [];
16482
16438
  var indices = [];
16483
- // triangulate shapePrimitive
16484
- for(var _iterator = _create_for_of_iterator_helper_loose(shapePrimitives), _step; !(_step = _iterator()).done;){
16485
- var shapePrimitive = _step.value;
16486
- var shape = shapePrimitive.shape;
16487
- var points = [];
16488
- var indexOffset = indices.length;
16489
- var vertOffset = vertices.length / 2;
16490
- shape.build(points);
16491
- if (!this.isStroke) {
16439
+ // Triangulate shapePrimitive
16440
+ //---------------------------------------------------
16441
+ if (this.isFill) {
16442
+ for(var _iterator = _create_for_of_iterator_helper_loose(shapePrimitives), _step; !(_step = _iterator()).done;){
16443
+ var shapePrimitive = _step.value;
16444
+ var shape = shapePrimitive.shape;
16445
+ var points = [];
16446
+ var indexOffset = indices.length;
16447
+ var vertOffset = vertices.length / 2;
16448
+ shape.build(points);
16492
16449
  shape.triangulate(points, vertices, vertOffset, indices, indexOffset);
16493
- } else {
16450
+ }
16451
+ }
16452
+ var fillIndexCount = indices.length;
16453
+ if (this.isStroke) {
16454
+ for(var _iterator1 = _create_for_of_iterator_helper_loose(shapePrimitives), _step1; !(_step1 = _iterator1()).done;){
16455
+ var shapePrimitive1 = _step1.value;
16456
+ var shape1 = shapePrimitive1.shape;
16457
+ var points1 = [];
16458
+ indices.length;
16459
+ var vertOffset1 = vertices.length / 2;
16494
16460
  var close = true;
16495
16461
  var lineStyle = this.strokeAttributes;
16496
- buildLine(points, lineStyle, false, close, vertices, 2, vertOffset, indices);
16462
+ shape1.build(points1);
16463
+ buildLine(points1, lineStyle, false, close, vertices, 2, vertOffset1, indices);
16497
16464
  }
16498
16465
  }
16466
+ var strokeIndexCount = indices.length - fillIndexCount;
16499
16467
  var vertexCount = vertices.length / 2;
16500
16468
  // get the current attribute and index arrays from the geometry, avoiding re-creation
16501
16469
  var positionArray = this.geometry.getAttributeData("aPos");
@@ -16528,21 +16496,25 @@ exports.ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
16528
16496
  this.geometry.setAttributeData("aUV", uvArray);
16529
16497
  this.geometry.setIndexData(indexArray);
16530
16498
  this.geometry.setDrawCount(indices.length);
16531
- };
16532
- _proto.buildPath = function buildPath(data) {
16499
+ var u16Size = 2;
16500
+ var fillSubMesh = this.geometry.subMeshes[0];
16501
+ var strokeSubMesh = this.geometry.subMeshes[1];
16502
+ fillSubMesh.indexCount = fillIndexCount;
16503
+ strokeSubMesh.offset = fillIndexCount * u16Size;
16504
+ strokeSubMesh.indexCount = strokeIndexCount;
16505
+ };
16506
+ _proto.buildPath = function buildPath(shapeAttribute) {
16533
16507
  this.graphicsPath.clear();
16534
- var shapeData = data;
16535
- switch(shapeData.type){
16508
+ switch(shapeAttribute.type){
16536
16509
  case ShapePrimitiveType.Custom:
16537
16510
  {
16538
- var customData = shapeData;
16539
- var points = customData.points;
16540
- var easingIns = customData.easingIns;
16541
- var easingOuts = customData.easingOuts;
16542
- for(var _iterator = _create_for_of_iterator_helper_loose(customData.shapes), _step; !(_step = _iterator()).done;){
16511
+ var customShapeAtribute = this.shapeAttribute;
16512
+ var points = customShapeAtribute.points;
16513
+ var easingIns = customShapeAtribute.easingIns;
16514
+ var easingOuts = customShapeAtribute.easingOuts;
16515
+ for(var _iterator = _create_for_of_iterator_helper_loose(customShapeAtribute.shapes), _step; !(_step = _iterator()).done;){
16543
16516
  var shape = _step.value;
16544
16517
  this.curveValues = [];
16545
- this.setFillColor(shape.fill);
16546
16518
  var indices = shape.indexes;
16547
16519
  for(var i = 1; i < indices.length; i++){
16548
16520
  var pointIndex = indices[i];
@@ -16572,48 +16544,127 @@ exports.ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
16572
16544
  }
16573
16545
  case ShapePrimitiveType.Ellipse:
16574
16546
  {
16575
- var ellipseData = shapeData;
16547
+ var ellipseData = shapeAttribute;
16576
16548
  this.graphicsPath.ellipse(0, 0, ellipseData.xRadius, ellipseData.yRadius);
16577
- this.setFillColor(ellipseData.fill);
16578
16549
  break;
16579
16550
  }
16580
16551
  case ShapePrimitiveType.Rectangle:
16581
16552
  {
16582
- var rectangleData = shapeData;
16583
- this.graphicsPath.rect(-rectangleData.width / 2, -rectangleData.height / 2, rectangleData.width, rectangleData.height);
16584
- this.setFillColor(rectangleData.fill);
16553
+ var rectangleData = shapeAttribute;
16554
+ this.graphicsPath.rect(-rectangleData.width / 2, -rectangleData.height / 2, rectangleData.width, rectangleData.height, rectangleData.roundness);
16585
16555
  break;
16586
16556
  }
16587
16557
  case ShapePrimitiveType.Star:
16588
16558
  {
16589
- var starData = shapeData;
16559
+ var starData = shapeAttribute;
16590
16560
  this.graphicsPath.polyStar(starData.pointCount, starData.outerRadius, starData.innerRadius, starData.outerRoundness, starData.innerRoundness, StarType.Star);
16591
- this.setFillColor(starData.fill);
16592
16561
  break;
16593
16562
  }
16594
16563
  case ShapePrimitiveType.Polygon:
16595
16564
  {
16596
- var polygonData = shapeData;
16565
+ var polygonData = shapeAttribute;
16597
16566
  this.graphicsPath.polyStar(polygonData.pointCount, polygonData.radius, polygonData.radius, polygonData.roundness, polygonData.roundness, StarType.Polygon);
16598
- this.setFillColor(polygonData.fill);
16599
16567
  break;
16600
16568
  }
16601
16569
  }
16602
16570
  };
16603
- _proto.setFillColor = function setFillColor(fill) {
16604
- if (fill) {
16605
- var color = fill.color;
16606
- this.material.setColor("_Color", new Color(color.r, color.g, color.b, color.a));
16607
- }
16608
- };
16609
16571
  _proto.fromData = function fromData(data) {
16610
16572
  MeshComponent.prototype.fromData.call(this, data);
16611
- this.data = data;
16612
16573
  this.shapeDirty = true;
16613
16574
  var strokeParam = data.stroke;
16614
16575
  if (strokeParam) {
16615
16576
  this.isStroke = true;
16616
16577
  this.strokeAttributes.width = strokeParam.width;
16578
+ this.strokeAttributes.color.copyFrom(strokeParam.color);
16579
+ this.strokeAttributes.cap = strokeParam.cap;
16580
+ this.strokeAttributes.join = strokeParam.join;
16581
+ }
16582
+ var fillParam = data.fill;
16583
+ if (fillParam) {
16584
+ this.isFill = true;
16585
+ this.fillAttribute.color.copyFrom(fillParam.color);
16586
+ }
16587
+ switch(data.type){
16588
+ case ShapePrimitiveType.Custom:
16589
+ {
16590
+ var customShapeData = data;
16591
+ var customShapeAttribute = {
16592
+ type: ShapePrimitiveType.Custom,
16593
+ points: [],
16594
+ easingIns: [],
16595
+ easingOuts: [],
16596
+ shapes: [],
16597
+ fill: customShapeData.fill
16598
+ };
16599
+ for(var _iterator = _create_for_of_iterator_helper_loose(customShapeData.points), _step; !(_step = _iterator()).done;){
16600
+ var point = _step.value;
16601
+ customShapeAttribute.points.push(new Vector2(point.x, point.y));
16602
+ }
16603
+ for(var _iterator1 = _create_for_of_iterator_helper_loose(customShapeData.easingIns), _step1; !(_step1 = _iterator1()).done;){
16604
+ var easingIn = _step1.value;
16605
+ customShapeAttribute.easingIns.push(new Vector2(easingIn.x, easingIn.y));
16606
+ }
16607
+ for(var _iterator2 = _create_for_of_iterator_helper_loose(customShapeData.easingOuts), _step2; !(_step2 = _iterator2()).done;){
16608
+ var easingOut = _step2.value;
16609
+ customShapeAttribute.easingOuts.push(new Vector2(easingOut.x, easingOut.y));
16610
+ }
16611
+ customShapeAttribute.shapes = customShapeData.shapes;
16612
+ this.shapeAttribute = customShapeAttribute;
16613
+ break;
16614
+ }
16615
+ case ShapePrimitiveType.Ellipse:
16616
+ {
16617
+ var ellipseData = data;
16618
+ var ellipseAttribute = {
16619
+ type: ShapePrimitiveType.Ellipse,
16620
+ xRadius: ellipseData.xRadius,
16621
+ yRadius: ellipseData.yRadius,
16622
+ fill: ellipseData.fill
16623
+ };
16624
+ this.shapeAttribute = ellipseAttribute;
16625
+ break;
16626
+ }
16627
+ case ShapePrimitiveType.Rectangle:
16628
+ {
16629
+ var rectangleData = data;
16630
+ var rectangleAttribute = {
16631
+ type: ShapePrimitiveType.Rectangle,
16632
+ width: rectangleData.width,
16633
+ height: rectangleData.height,
16634
+ roundness: rectangleData.roundness,
16635
+ fill: rectangleData.fill
16636
+ };
16637
+ this.shapeAttribute = rectangleAttribute;
16638
+ break;
16639
+ }
16640
+ case ShapePrimitiveType.Star:
16641
+ {
16642
+ var starData = data;
16643
+ var starAttribute = {
16644
+ type: ShapePrimitiveType.Star,
16645
+ pointCount: starData.pointCount,
16646
+ innerRadius: starData.innerRadius,
16647
+ outerRadius: starData.outerRadius,
16648
+ innerRoundness: starData.innerRoundness,
16649
+ outerRoundness: starData.outerRoundness,
16650
+ fill: starData.fill
16651
+ };
16652
+ this.shapeAttribute = starAttribute;
16653
+ break;
16654
+ }
16655
+ case ShapePrimitiveType.Polygon:
16656
+ {
16657
+ var polygonData = data;
16658
+ var polygonAttribute = {
16659
+ type: ShapePrimitiveType.Polygon,
16660
+ pointCount: polygonData.pointCount,
16661
+ radius: polygonData.radius,
16662
+ roundness: polygonData.roundness,
16663
+ fill: polygonData.fill
16664
+ };
16665
+ this.shapeAttribute = polygonAttribute;
16666
+ break;
16667
+ }
16617
16668
  }
16618
16669
  var material = this.material;
16619
16670
  //@ts-expect-error // TODO 新版蒙版上线后重构
@@ -16626,10 +16677,10 @@ exports.ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
16626
16677
  };
16627
16678
  _create_class(ShapeComponent, [
16628
16679
  {
16629
- key: "path",
16680
+ key: "shape",
16630
16681
  get: function get() {
16631
16682
  this.shapeDirty = true;
16632
- return this.data;
16683
+ return this.shapeAttribute;
16633
16684
  }
16634
16685
  }
16635
16686
  ]);
@@ -17449,10 +17500,8 @@ function shouldIgnoreBouncing(arg, mul) {
17449
17500
  };
17450
17501
  };
17451
17502
  _proto.setGeometry = function setGeometry(geometry, worldMatrix) {
17452
- if (this.geometry !== geometry) {
17453
- this.triangles = this.geometryToTriangles(geometry);
17454
- this.geometry = geometry;
17455
- }
17503
+ this.triangles = this.geometryToTriangles(geometry);
17504
+ this.geometry = geometry;
17456
17505
  var area = [];
17457
17506
  for(var _iterator = _create_for_of_iterator_helper_loose(this.triangles), _step; !(_step = _iterator()).done;){
17458
17507
  var triangle = _step.value;
@@ -17473,10 +17522,11 @@ function shouldIgnoreBouncing(arg, mul) {
17473
17522
  _proto.geometryToTriangles = function geometryToTriangles(geometry) {
17474
17523
  var _geometry_getIndexData;
17475
17524
  var indices = (_geometry_getIndexData = geometry.getIndexData()) != null ? _geometry_getIndexData : [];
17525
+ var drawCount = geometry.getDrawCount();
17476
17526
  var _geometry_getAttributeData;
17477
17527
  var vertices = (_geometry_getAttributeData = geometry.getAttributeData("aPos")) != null ? _geometry_getAttributeData : [];
17478
17528
  var res = [];
17479
- for(var i = 0; i < indices.length; i += 3){
17529
+ for(var i = 0; i < drawCount; i += 3){
17480
17530
  var index0 = indices[i] * 3;
17481
17531
  var index1 = indices[i + 1] * 3;
17482
17532
  var index2 = indices[i + 2] * 3;
@@ -21034,19 +21084,17 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
21034
21084
  rotation: rotation,
21035
21085
  path: path
21036
21086
  };
21037
- var parentTransform = this.transform.parentTransform;
21038
21087
  var selfPos = position.clone();
21039
21088
  if (path) {
21040
21089
  selfPos.add(path.getValue(0));
21041
21090
  }
21042
21091
  this.transform.setPosition(selfPos.x, selfPos.y, selfPos.z);
21043
- if (this.options.particleFollowParent && parentTransform) {
21044
- var worldMatrix = parentTransform.getWorldMatrix();
21092
+ if (this.options.particleFollowParent) {
21093
+ var worldMatrix = this.transform.getWorldMatrix();
21045
21094
  this.renderer.updateWorldMatrix(worldMatrix);
21046
21095
  }
21047
21096
  };
21048
21097
  _proto.updateEmitterTransform = function updateEmitterTransform(time) {
21049
- var parentTransform = this.transform.parentTransform;
21050
21098
  var _this_basicTransform = this.basicTransform, path = _this_basicTransform.path, position = _this_basicTransform.position;
21051
21099
  var selfPos = position.clone();
21052
21100
  if (path) {
@@ -21054,8 +21102,8 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
21054
21102
  selfPos.add(path.getValue(time / duration));
21055
21103
  }
21056
21104
  this.transform.setPosition(selfPos.x, selfPos.y, selfPos.z);
21057
- if (this.options.particleFollowParent && parentTransform) {
21058
- var worldMatrix = parentTransform.getWorldMatrix();
21105
+ if (this.options.particleFollowParent) {
21106
+ var worldMatrix = this.transform.getWorldMatrix();
21059
21107
  this.renderer.updateWorldMatrix(worldMatrix);
21060
21108
  }
21061
21109
  };
@@ -21443,7 +21491,7 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
21443
21491
  var lifetime = this.lifetime;
21444
21492
  var shape = this.shape;
21445
21493
  var speed = options.startSpeed.getValue(lifetime);
21446
- var matrix4 = options.particleFollowParent ? this.transform.getMatrix() : this.transform.getWorldMatrix();
21494
+ var matrix4 = options.particleFollowParent ? Matrix4.IDENTITY : this.transform.getWorldMatrix();
21447
21495
  var pointPosition = data.position;
21448
21496
  // 粒子的位置受发射器的位置影响,自身的旋转和缩放不受影响
21449
21497
  var position = matrix4.transformPoint(pointPosition, new Vector3());
@@ -24265,7 +24313,7 @@ var SerializationHelper = /*#__PURE__*/ function() {
24265
24313
  this.timelinePlayable.setTime(time);
24266
24314
  // The properties of the object may change dynamically,
24267
24315
  // so reset the track binding to avoid invalidation of the previously obtained binding object.
24268
- // this.resolveBindings();
24316
+ this.resolveBindings();
24269
24317
  this.timelinePlayable.evaluate();
24270
24318
  this.graph.evaluate(dt);
24271
24319
  };
@@ -24504,7 +24552,10 @@ var Vector4PropertyMixerPlayable = /*#__PURE__*/ function(PropertyMixerPlayable)
24504
24552
  }
24505
24553
  var _proto = Vector4PropertyMixerPlayable.prototype;
24506
24554
  _proto.resetPropertyValue = function resetPropertyValue() {
24507
- this.propertyValue.setZero();
24555
+ this.propertyValue.x = 0;
24556
+ this.propertyValue.y = 0;
24557
+ this.propertyValue.z = 0;
24558
+ this.propertyValue.w = 0;
24508
24559
  };
24509
24560
  _proto.addWeightedValue = function addWeightedValue(curveValue, weight) {
24510
24561
  var result = this.propertyValue;
@@ -24522,7 +24573,8 @@ var Vector2PropertyMixerPlayable = /*#__PURE__*/ function(PropertyMixerPlayable)
24522
24573
  }
24523
24574
  var _proto = Vector2PropertyMixerPlayable.prototype;
24524
24575
  _proto.resetPropertyValue = function resetPropertyValue() {
24525
- this.propertyValue.setZero();
24576
+ this.propertyValue.x = 0;
24577
+ this.propertyValue.y = 0;
24526
24578
  };
24527
24579
  _proto.addWeightedValue = function addWeightedValue(curveValue, weight) {
24528
24580
  var result = this.propertyValue;
@@ -25457,6 +25509,9 @@ exports.TextComponent = /*#__PURE__*/ function(BaseRenderComponent) {
25457
25509
  /**
25458
25510
  * 文本行数
25459
25511
  */ _this.lineCount = 0;
25512
+ /**
25513
+ * 每一行文本的最大宽度
25514
+ */ _this.maxLineWidth = 0;
25460
25515
  _this.SCALE_FACTOR = 0.1;
25461
25516
  _this.ALPHA_FIX_VALUE = 1 / 255;
25462
25517
  _this.name = "MText" + seed$2++;
@@ -25540,12 +25595,9 @@ var TextComponentBase = /*#__PURE__*/ function() {
25540
25595
  this.textStyle = new TextStyle(options);
25541
25596
  this.textLayout = new TextLayout(options);
25542
25597
  this.text = options.text.toString();
25543
- this.lineCount = this.getLineCount(options.text, true);
25544
25598
  };
25545
- _proto.getLineCount = function getLineCount(text, init) {
25546
- var context = this.context;
25547
- var letterSpace = this.textLayout.letterSpace;
25548
- var fontScale = init ? this.textStyle.fontSize / 10 : 1 / this.textStyle.fontScale;
25599
+ _proto.getLineCount = function getLineCount(text, context) {
25600
+ var _this_textLayout = this.textLayout, letterSpace = _this_textLayout.letterSpace, overflow = _this_textLayout.overflow;
25549
25601
  var width = this.textLayout.width + this.textStyle.fontOffset;
25550
25602
  var lineCount = 1;
25551
25603
  var x = 0;
@@ -25553,15 +25605,27 @@ var TextComponentBase = /*#__PURE__*/ function() {
25553
25605
  var _context_measureText;
25554
25606
  var str = text[i];
25555
25607
  var _context_measureText_width;
25556
- 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;
25608
+ 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;
25557
25609
  // 和浏览器行为保持一致
25558
25610
  x += letterSpace;
25559
- if (x + textMetrics > width && i > 0 || str === "\n") {
25560
- lineCount++;
25561
- x = 0;
25562
- }
25563
- if (str !== "\n") {
25564
- x += textMetrics;
25611
+ // 处理文本结束行为
25612
+ if (overflow === TextOverflow.display) {
25613
+ if (str === "\n") {
25614
+ lineCount++;
25615
+ x = 0;
25616
+ } else {
25617
+ x += textMetrics;
25618
+ this.maxLineWidth = Math.max(this.maxLineWidth, x);
25619
+ }
25620
+ } else {
25621
+ if (x + textMetrics > width && i > 0 || str === "\n") {
25622
+ lineCount++;
25623
+ this.maxLineWidth = Math.max(this.maxLineWidth, x);
25624
+ x = 0;
25625
+ }
25626
+ if (str !== "\n") {
25627
+ x += textMetrics;
25628
+ }
25565
25629
  }
25566
25630
  }
25567
25631
  return lineCount;
@@ -25611,7 +25675,6 @@ var TextComponentBase = /*#__PURE__*/ function() {
25611
25675
  return;
25612
25676
  }
25613
25677
  this.text = value.toString();
25614
- this.lineCount = this.getLineCount(value, false);
25615
25678
  this.isDirty = true;
25616
25679
  };
25617
25680
  /**
@@ -25693,6 +25756,18 @@ var TextComponentBase = /*#__PURE__*/ function() {
25693
25756
  this.isDirty = true;
25694
25757
  };
25695
25758
  /**
25759
+ * 设置文本溢出模式
25760
+ *
25761
+ * - clip: 当文本内容超出边界框时,多余的会被截断。
25762
+ * - display: 该模式下会显示所有文本,会自动调整文本字号以保证显示完整。
25763
+ * > 当存在多行时,部分行内文本可能存在文本字号变小的情况,其他行为正常情况
25764
+ *
25765
+ * @param overflow - 文本溢出模式
25766
+ */ _proto.setOverflow = function setOverflow(overflow) {
25767
+ this.textLayout.overflow = overflow;
25768
+ this.isDirty = true;
25769
+ };
25770
+ /**
25696
25771
  * 设置阴影颜色
25697
25772
  * @param value - 阴影颜色
25698
25773
  * @returns
@@ -25760,28 +25835,35 @@ var TextComponentBase = /*#__PURE__*/ function() {
25760
25835
  var layout = this.textLayout;
25761
25836
  var fontScale = style.fontScale;
25762
25837
  var width = (layout.width + style.fontOffset) * fontScale;
25763
- var finalHeight = layout.lineHeight * this.lineCount;
25764
25838
  var fontSize = style.fontSize * fontScale;
25765
25839
  var lineHeight = layout.lineHeight * fontScale;
25840
+ style.fontDesc = this.getFontDesc(fontSize);
25766
25841
  this.char = (this.text || "").split("");
25767
25842
  this.canvas.width = width;
25843
+ var height = this.canvas.height;
25844
+ context.font = style.fontDesc;
25845
+ this.lineCount = this.getLineCount(this.text, context);
25846
+ var finalHeight = layout.lineHeight * this.lineCount;
25768
25847
  if (layout.autoWidth) {
25769
25848
  this.canvas.height = finalHeight * fontScale;
25770
25849
  this.item.transform.size.set(1, finalHeight / layout.height);
25771
25850
  } else {
25772
25851
  this.canvas.height = layout.height * fontScale;
25773
25852
  }
25774
- var height = this.canvas.height;
25775
- context.clearRect(0, 0, width, height);
25853
+ // canvas size 变化后重新刷新 context
25854
+ if (this.maxLineWidth > width && layout.overflow === TextOverflow.display) {
25855
+ context.font = this.getFontDesc(fontSize * width / this.maxLineWidth);
25856
+ } else {
25857
+ context.font = style.fontDesc;
25858
+ }
25776
25859
  // fix bug 1/255
25777
25860
  context.fillStyle = "rgba(255, 255, 255, 0.0039)";
25861
+ context.clearRect(0, 0, width, height);
25778
25862
  if (!flipY) {
25779
25863
  context.translate(0, height);
25780
25864
  context.scale(1, -1);
25781
25865
  }
25782
25866
  context.fillRect(0, 0, width, height);
25783
- style.fontDesc = this.getFontDesc();
25784
- context.font = style.fontDesc;
25785
25867
  if (style.hasShadow) {
25786
25868
  this.setupShadow();
25787
25869
  }
@@ -25853,9 +25935,9 @@ var TextComponentBase = /*#__PURE__*/ function() {
25853
25935
  this.material.setTexture("_MainTex", texture);
25854
25936
  this.isDirty = false;
25855
25937
  };
25856
- _proto.getFontDesc = function getFontDesc() {
25857
- 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;
25858
- var fontDesc = "" + (fontSize * fontScale).toString() + "px ";
25938
+ _proto.getFontDesc = function getFontDesc(fontSize) {
25939
+ var _this_textStyle = this.textStyle, fontFamily = _this_textStyle.fontFamily, textWeight = _this_textStyle.textWeight, fontStyle = _this_textStyle.fontStyle;
25940
+ var fontDesc = "" + fontSize.toString() + "px ";
25859
25941
  if (!DEFAULT_FONTS.includes(fontFamily)) {
25860
25942
  fontDesc += '"' + fontFamily + '"';
25861
25943
  } else {
@@ -26625,12 +26707,29 @@ function getStandardInteractContent(ui) {
26625
26707
  * 3.1 版本数据适配
26626
26708
  * - 富文本插件名称的适配
26627
26709
  */ function version31Migration(json) {
26628
- var _json_plugins;
26710
+ var // 修正老版本数据中,富文本插件名称的问题
26711
+ _json_plugins;
26629
26712
  (_json_plugins = json.plugins) == null ? void 0 : _json_plugins.forEach(function(plugin, index) {
26630
26713
  if (plugin === "richtext") {
26631
26714
  json.plugins[index] = "rich-text";
26632
26715
  }
26633
26716
  });
26717
+ // Custom shape fill 属性位置迁移
26718
+ for(var _iterator = _create_for_of_iterator_helper_loose(json.components), _step; !(_step = _iterator()).done;){
26719
+ var component = _step.value;
26720
+ if (component.dataType === DataType.ShapeComponent) {
26721
+ var shapeComponent = component;
26722
+ if (shapeComponent.type === ShapePrimitiveType.Custom) {
26723
+ var _customShapeComponent_shapes;
26724
+ var customShapeComponent = shapeComponent;
26725
+ //@ts-expect-error
26726
+ if (((_customShapeComponent_shapes = customShapeComponent.shapes) == null ? void 0 : _customShapeComponent_shapes.length) > 0 && customShapeComponent.shapes[0].fill) {
26727
+ // @ts-expect-error
26728
+ customShapeComponent.fill = customShapeComponent.shapes[0].fill;
26729
+ }
26730
+ }
26731
+ }
26732
+ }
26634
26733
  return json;
26635
26734
  }
26636
26735
  /**
@@ -27460,8 +27559,6 @@ function getStandardJSON(json) {
27460
27559
  }
27461
27560
  // 修正老版本数据中,meshItem 以及 lightItem 结束行为错误问题
27462
27561
  version22Migration(json);
27463
- // 修正老版本数据中,富文本插件名称的问题
27464
- version31Migration(json);
27465
27562
  if (v0.test(json.version)) {
27466
27563
  var _exec;
27467
27564
  reverseParticle = ((_exec = /^(\d+)/.exec(json.version)) == null ? void 0 : _exec[0]) === "0";
@@ -27476,7 +27573,13 @@ function getStandardJSON(json) {
27476
27573
  json = version24Migration(json);
27477
27574
  }
27478
27575
  if (mainVersion < 3) {
27479
- return version30Migration(version21Migration(json));
27576
+ json = version30Migration(version21Migration(json));
27577
+ }
27578
+ // 3.x 版本格式转换
27579
+ if (mainVersion < 4) {
27580
+ if (minorVersion < 2) {
27581
+ json = version31Migration(json);
27582
+ }
27480
27583
  }
27481
27584
  return json;
27482
27585
  }
@@ -27532,13 +27635,11 @@ function getStandardJSONFromV0(json) {
27532
27635
  }
27533
27636
  function getStandardImage(image, index, imageTags) {
27534
27637
  var renderLevel = imageTags[index];
27535
- var oriY = image.oriY;
27536
27638
  if (typeof image === "string") {
27537
27639
  return {
27538
27640
  id: generateGUID(),
27539
27641
  renderLevel: renderLevel,
27540
- url: image,
27541
- oriY: oriY
27642
+ url: image
27542
27643
  };
27543
27644
  } else if (image.template) {
27544
27645
  return {
@@ -27546,14 +27647,12 @@ function getStandardImage(image, index, imageTags) {
27546
27647
  url: image.url,
27547
27648
  template: image.template,
27548
27649
  webp: image.webp,
27549
- renderLevel: renderLevel,
27550
- oriY: oriY
27650
+ renderLevel: renderLevel
27551
27651
  };
27552
27652
  } else if (image.compressed) {
27553
27653
  return {
27554
27654
  id: generateGUID(),
27555
27655
  url: image.url,
27556
- oriY: oriY,
27557
27656
  compressed: {
27558
27657
  astc: image.compressed.android,
27559
27658
  pvrtc: image.compressed.iOS
@@ -27566,8 +27665,7 @@ function getStandardImage(image, index, imageTags) {
27566
27665
  id: generateGUID(),
27567
27666
  url: image.url,
27568
27667
  webp: image.webp,
27569
- renderLevel: renderLevel,
27570
- oriY: oriY
27668
+ renderLevel: renderLevel
27571
27669
  };
27572
27670
  } else if (image && image.sourceType) {
27573
27671
  return image;
@@ -32009,7 +32107,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem, true);
32009
32107
  registerPlugin("particle", ParticleLoader, exports.VFXItem, true);
32010
32108
  registerPlugin("cal", CalculateLoader, exports.VFXItem, true);
32011
32109
  registerPlugin("interact", InteractLoader, exports.VFXItem, true);
32012
- var version$1 = "2.3.0-alpha.0";
32110
+ var version$1 = "2.3.0-alpha.2";
32013
32111
  logger.info("Core version: " + version$1 + ".");
32014
32112
 
32015
32113
  var _obj;
@@ -33642,7 +33740,7 @@ setMaxSpriteMeshItemCount(8);
33642
33740
  */ Mesh.create = function(engine, props) {
33643
33741
  return new ThreeMesh(engine, props);
33644
33742
  };
33645
- var version = "2.3.0-alpha.0";
33743
+ var version = "2.3.0-alpha.2";
33646
33744
  logger.info("THREEJS plugin version: " + version + ".");
33647
33745
 
33648
33746
  exports.AbstractPlugin = AbstractPlugin;