@galacean/effects-core 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.mjs 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-alpha.0
6
+ * Version: v2.3.0-alpha.2
7
7
  */
8
8
 
9
9
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
@@ -1035,7 +1035,8 @@ function _inherits(subClass, superClass) {
1035
1035
  JSONSceneVersion["2_4"] = "2.4";
1036
1036
  JSONSceneVersion["3_0"] = "3.0";
1037
1037
  JSONSceneVersion["3_1"] = "3.1";
1038
- JSONSceneVersion["LATEST"] = "3.1";
1038
+ JSONSceneVersion["3_2"] = "3.2";
1039
+ JSONSceneVersion["LATEST"] = "3.2";
1039
1040
  })(JSONSceneVersion || (JSONSceneVersion = {}));
1040
1041
 
1041
1042
  /*********************************************/ /* 元素属性参数类型 */ /*********************************************/ /**
@@ -1573,7 +1574,7 @@ var MaterialBlending;
1573
1574
  var TextOverflow;
1574
1575
  (function(TextOverflow) {
1575
1576
  /**
1576
- * display 模式下,会显示所有文本,存在文本超过边界框的情况。
1577
+ * display 模式下,会显示所有文本,文本大小会根据边界框调整。
1577
1578
  */ TextOverflow[TextOverflow["display"] = 0] = "display";
1578
1579
  /**
1579
1580
  * clip 模式下,当文本内容超出边界框时,多余的会被截断。
@@ -1666,12 +1667,18 @@ var BuiltinObjectGUID = {
1666
1667
  */ ShapePrimitiveType[ShapePrimitiveType["Star"] = 4] = "Star";
1667
1668
  })(ShapePrimitiveType || (ShapePrimitiveType = {}));
1668
1669
 
1669
- // 本期无该功能 待补充
1670
- var ShapeConnectType;
1671
- (function(ShapeConnectType) {})(ShapeConnectType || (ShapeConnectType = {}));
1672
- // @待补充
1673
- var ShapePointType;
1674
- (function(ShapePointType) {})(ShapePointType || (ShapePointType = {}));
1670
+ var LineCap;
1671
+ (function(LineCap) {
1672
+ /** 默认值。向线条的每个末端添加平直的边缘 */ LineCap[LineCap["Butt"] = 0] = "Butt";
1673
+ /** 向线条的每个末端添加圆形线帽 */ LineCap[LineCap["Round"] = 1] = "Round";
1674
+ /** 向线条的每个末端添加正方形线帽 */ LineCap[LineCap["Square"] = 2] = "Square";
1675
+ })(LineCap || (LineCap = {}));
1676
+ var LineJoin;
1677
+ (function(LineJoin) {
1678
+ /** 创建圆角 */ LineJoin[LineJoin["Round"] = 0] = "Round";
1679
+ /** 创建斜角 */ LineJoin[LineJoin["Bevel"] = 1] = "Bevel";
1680
+ /** 创建尖角 */ LineJoin[LineJoin["Miter"] = 2] = "Miter";
1681
+ })(LineJoin || (LineJoin = {}));
1675
1682
 
1676
1683
  /**
1677
1684
  * 动态换图类型
@@ -1880,8 +1887,8 @@ var index$1 = /*#__PURE__*/Object.freeze({
1880
1887
  get FontStyle () { return FontStyle; },
1881
1888
  BuiltinObjectGUID: BuiltinObjectGUID,
1882
1889
  get ShapePrimitiveType () { return ShapePrimitiveType; },
1883
- get ShapeConnectType () { return ShapeConnectType; },
1884
- get ShapePointType () { return ShapePointType; },
1890
+ get LineCap () { return LineCap; },
1891
+ get LineJoin () { return LineJoin; },
1885
1892
  get BackgroundType () { return BackgroundType; },
1886
1893
  get MultimediaType () { return MultimediaType; },
1887
1894
  get DataType () { return DataType; },
@@ -3800,7 +3807,9 @@ Vector4.ZERO = new Vector4(0.0, 0.0, 0.0, 0.0);
3800
3807
  if (renderer.renderingData.currentFrame.globalUniforms) {
3801
3808
  renderer.setGlobalMatrix("effects_ObjectToWorld", this.transform.getWorldMatrix());
3802
3809
  }
3803
- renderer.drawGeometry(this.geometry, this.material);
3810
+ for(var i = 0; i < this.materials.length; i++){
3811
+ renderer.drawGeometry(this.geometry, this.materials[i], i);
3812
+ }
3804
3813
  };
3805
3814
  _proto.getBoundingBox = function getBoundingBox() {
3806
3815
  var worldMatrix = this.transform.getWorldMatrix();
@@ -7335,7 +7344,15 @@ var BYTES_TYPE_MAP = (_obj$5 = {}, _obj$5[glContext.FLOAT] = Float32Array.BYTES_
7335
7344
  */ var Geometry = /*#__PURE__*/ function(EffectsObject) {
7336
7345
  _inherits(Geometry, EffectsObject);
7337
7346
  function Geometry() {
7338
- return EffectsObject.apply(this, arguments);
7347
+ var _this;
7348
+ _this = EffectsObject.apply(this, arguments) || this;
7349
+ /**
7350
+ * Geometry 的名称
7351
+ */ _this.name = "";
7352
+ /**
7353
+ * 子网格数据
7354
+ */ _this.subMeshes = [];
7355
+ return _this;
7339
7356
  }
7340
7357
  var _proto = Geometry.prototype;
7341
7358
  /**
@@ -10182,7 +10199,7 @@ var integrate = "float calculateMovement(float t,vec2 p1,vec2 p2,vec2 p3,vec2 p4
10182
10199
 
10183
10200
  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}";
10184
10201
 
10185
- 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;}";
10202
+ 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;}";
10186
10203
 
10187
10204
  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";
10188
10205
 
@@ -12701,18 +12718,12 @@ var BezierCurve = /*#__PURE__*/ function(ValueGetter) {
12701
12718
  var keyTimeStart = this.curveMap[keyTimeData[0]].timeStart;
12702
12719
  var keyTimeEnd = this.curveMap[keyTimeData[keyTimeData.length - 1]].timeEnd;
12703
12720
  if (time <= keyTimeStart) {
12704
- if (this.startKeyframe[0] === BezierKeyframeType.LINE || this.startKeyframe[0] === BezierKeyframeType.HOLD) {
12705
- keyframeInfo.getPointIndexInCurve(this.startKeyframe, keyframeInfo.pointIndexCache);
12706
- return this.endKeyframe[1][keyframeInfo.pointIndexCache.yIndex];
12707
- }
12708
- return this.getCurveValue(keyTimeData[0], keyTimeStart);
12721
+ keyframeInfo.getPointIndexInCurve(this.startKeyframe, keyframeInfo.pointIndexCache);
12722
+ return this.startKeyframe[1][keyframeInfo.pointIndexCache.yIndex];
12709
12723
  }
12710
12724
  if (time >= keyTimeEnd) {
12711
- if (this.endKeyframe[0] === BezierKeyframeType.LINE || this.endKeyframe[0] === BezierKeyframeType.HOLD) {
12712
- keyframeInfo.getPointIndexInCurve(this.endKeyframe, keyframeInfo.pointIndexCache);
12713
- return this.endKeyframe[1][keyframeInfo.pointIndexCache.yIndex];
12714
- }
12715
- return this.getCurveValue(keyTimeData[keyTimeData.length - 1], keyTimeEnd);
12725
+ keyframeInfo.getPointIndexInCurve(this.endKeyframe, keyframeInfo.pointIndexCache);
12726
+ return this.endKeyframe[1][keyframeInfo.pointIndexCache.yIndex];
12716
12727
  }
12717
12728
  for(var i = 0; i < keyTimeData.length; i++){
12718
12729
  var xMin = this.curveMap[keyTimeData[i]].timeStart;
@@ -13564,11 +13575,14 @@ var ColorCurve = /*#__PURE__*/ function(ValueGetter) {
13564
13575
  maxVertex: 4
13565
13576
  });
13566
13577
  };
13567
- _proto.createMaterial = function createMaterial(renderInfo, count) {
13568
- var side = renderInfo.side, occlusion = renderInfo.occlusion, blending = renderInfo.blending, maskMode = renderInfo.maskMode, mask = renderInfo.mask;
13569
- var materialProps = {
13578
+ _proto.getMaterialProps = function getMaterialProps(renderInfo, count) {
13579
+ return {
13570
13580
  shader: spriteMeshShaderFromRenderInfo(renderInfo, count, 1)
13571
13581
  };
13582
+ };
13583
+ _proto.createMaterial = function createMaterial(renderInfo, count) {
13584
+ var side = renderInfo.side, occlusion = renderInfo.occlusion, blending = renderInfo.blending, maskMode = renderInfo.maskMode, mask = renderInfo.mask;
13585
+ var materialProps = this.getMaterialProps(renderInfo, count);
13572
13586
  this.preMultiAlpha = getPreMultiAlpha(blending);
13573
13587
  var material = Material.create(this.engine, materialProps);
13574
13588
  var states = {
@@ -14855,6 +14869,10 @@ function triangulate(contours) {
14855
14869
  points
14856
14870
  ]);
14857
14871
  var indexStart = vertices.length / 2;
14872
+ // 当所有 points 在一条直线时, gluTess 三角化 triangles 会返回空数组,这边做一下额外处理返回线段左右端点组成的三角形,确保拿到的包围盒是正确的。
14873
+ if (triangles.length === 0) {
14874
+ this.getLineEndPointsTriangle(points, triangles);
14875
+ }
14858
14876
  for(var i = 0; i < triangles.length; i++){
14859
14877
  vertices[verticesOffset * 2 + i] = triangles[i];
14860
14878
  }
@@ -14863,6 +14881,57 @@ function triangulate(contours) {
14863
14881
  indices[indicesOffset + i1] = indexStart + i1;
14864
14882
  }
14865
14883
  };
14884
+ /**
14885
+ * 获取直线上最远的两个端点坐标组成的三角形
14886
+ */ _proto.getLineEndPointsTriangle = function getLineEndPointsTriangle(points, triangles) {
14887
+ // 参数检查
14888
+ if (!points || points.length < 2 || points.length % 2 !== 0) {
14889
+ throw new Error("Invalid points array");
14890
+ }
14891
+ if (points.length === 2) {
14892
+ triangles.push(points[0], points[1], points[0], points[1], points[0], points[1]);
14893
+ return;
14894
+ }
14895
+ // 取第一个线段计算斜率
14896
+ var dx = points[2] - points[0];
14897
+ var dy = points[3] - points[1];
14898
+ // 存放结果坐标
14899
+ var startX = points[0];
14900
+ var startY = points[1];
14901
+ var endX = points[0];
14902
+ var endY = points[1];
14903
+ // 根据斜率决定比较x还是y
14904
+ if (Math.abs(dx) >= Math.abs(dy)) {
14905
+ // 水平方向为主,比较x坐标
14906
+ for(var i = 0; i < points.length; i += 2){
14907
+ var x = points[i];
14908
+ var y = points[i + 1];
14909
+ if (x < startX) {
14910
+ startX = x;
14911
+ startY = y;
14912
+ }
14913
+ if (x > endX) {
14914
+ endX = x;
14915
+ endY = y;
14916
+ }
14917
+ }
14918
+ } else {
14919
+ // 垂直方向为主,比较y坐标
14920
+ for(var i1 = 0; i1 < points.length; i1 += 2){
14921
+ var x1 = points[i1];
14922
+ var y1 = points[i1 + 1];
14923
+ if (y1 < startY) {
14924
+ startX = x1;
14925
+ startY = y1;
14926
+ }
14927
+ if (y1 > endY) {
14928
+ endX = x1;
14929
+ endY = y1;
14930
+ }
14931
+ }
14932
+ }
14933
+ triangles.push(startX, startY, endX, endY, endX, endY);
14934
+ };
14866
14935
  _create_class(Polygon, [
14867
14936
  {
14868
14937
  key: "lastX",
@@ -15336,47 +15405,48 @@ var PolyStar = /*#__PURE__*/ function(ShapePrimitive) {
15336
15405
  }(ShapePrimitive);
15337
15406
 
15338
15407
  // Based on:
15339
- // const tempPoints = [new Point(), new Point(), new Point(), new Point()];
15340
15408
  /**
15341
- * The `Rectangle` object is an area defined by its position, as indicated by its upper-left corner
15342
- * point (`x`, `y`) and by its `width` and its `height`.
15409
+ * The `Rectangle` object is an area defined by its position, as indicated by its top-left corner
15410
+ * point (`x`, `y`) and by its `width` and its `height`, including a `roundness` property that
15411
+ * defines the roundness of the rounded corners.
15412
+ * @memberof maths
15343
15413
  */ var Rectangle$1 = /*#__PURE__*/ function(ShapePrimitive) {
15344
15414
  _inherits(Rectangle, ShapePrimitive);
15345
- function Rectangle(x, y, width, height) {
15415
+ function Rectangle(x, y, width, height, roundness) {
15346
15416
  if (x === void 0) x = 0;
15347
15417
  if (y === void 0) y = 0;
15348
15418
  if (width === void 0) width = 0;
15349
15419
  if (height === void 0) height = 0;
15420
+ if (roundness === void 0) roundness = 20;
15350
15421
  var _this;
15351
15422
  _this = ShapePrimitive.call(this) || this;
15352
- _this.x = Number(x);
15353
- _this.y = Number(y);
15354
- _this.width = Number(width);
15355
- _this.height = Number(height);
15423
+ _this.x = x;
15424
+ _this.y = y;
15425
+ _this.width = width;
15426
+ _this.height = height;
15427
+ _this.roundness = roundness;
15356
15428
  return _this;
15357
15429
  }
15358
15430
  var _proto = Rectangle.prototype;
15359
- /** Determines whether the Rectangle is empty. */ _proto.isEmpty = function isEmpty() {
15360
- return this.left === this.right || this.top === this.bottom;
15431
+ /**
15432
+ * Returns the framing rectangle of the rectangle as a Rectangle object
15433
+ * @param out - optional rectangle to store the result
15434
+ * @returns The framing rectangle
15435
+ */ _proto.getBounds = function getBounds(out) {
15436
+ out = out || new Rectangle();
15437
+ out.x = this.x;
15438
+ out.y = this.y;
15439
+ out.width = this.width;
15440
+ out.height = this.height;
15441
+ return out;
15361
15442
  };
15362
15443
  /**
15363
- * Creates a clone of this Rectangle
15364
- * @returns a copy of the rectangle
15444
+ * Creates a clone of this rectangle.
15445
+ * @returns - A copy of the rectangle.
15365
15446
  */ _proto.clone = function clone() {
15366
- return new Rectangle(this.x, this.y, this.width, this.height);
15447
+ return new Rectangle(this.x, this.y, this.width, this.height, this.roundness);
15367
15448
  };
15368
15449
  /**
15369
- * Converts a Bounds object to a Rectangle object.
15370
- * @param bounds - The bounds to copy and convert to a rectangle.
15371
- * @returns Returns itself.
15372
- */ // copyFromBounds (bounds: Bounds): this {
15373
- // this.x = bounds.minX;
15374
- // this.y = bounds.minY;
15375
- // this.width = bounds.maxX - bounds.minX;
15376
- // this.height = bounds.maxY - bounds.minY;
15377
- // return this;
15378
- // }
15379
- /**
15380
15450
  * Copies another rectangle to this one.
15381
15451
  * @param rectangle - The rectangle to copy from.
15382
15452
  * @returns Returns itself.
@@ -15385,6 +15455,7 @@ var PolyStar = /*#__PURE__*/ function(ShapePrimitive) {
15385
15455
  this.y = rectangle.y;
15386
15456
  this.width = rectangle.width;
15387
15457
  this.height = rectangle.height;
15458
+ this.roundness = rectangle.roundness;
15388
15459
  return this;
15389
15460
  };
15390
15461
  /**
@@ -15395,267 +15466,121 @@ var PolyStar = /*#__PURE__*/ function(ShapePrimitive) {
15395
15466
  rectangle.copyFrom(this);
15396
15467
  return rectangle;
15397
15468
  };
15398
- /**
15399
- * Checks whether the x and y coordinates given are contained within this Rectangle
15400
- * @param x - The X coordinate of the point to test
15401
- * @param y - The Y coordinate of the point to test
15402
- * @returns Whether the x/y coordinates are within this Rectangle
15403
- */ _proto.contains = function contains(x, y) {
15404
- if (this.width <= 0 || this.height <= 0) {
15405
- return false;
15469
+ _proto.build = function build(points) {
15470
+ var ry;
15471
+ var halfWidth = this.width / 2;
15472
+ var halfHeight = this.height / 2;
15473
+ var x = this.x + halfWidth;
15474
+ var y = this.y + halfHeight;
15475
+ var rx = ry = Math.max(0, Math.min(this.roundness / 100, 1) * Math.min(halfWidth, halfHeight));
15476
+ var dx = halfWidth - rx;
15477
+ var dy = halfHeight - ry;
15478
+ if (!(rx >= 0 && ry >= 0 && dx >= 0 && dy >= 0)) {
15479
+ return;
15406
15480
  }
15407
- if (x >= this.x && x < this.x + this.width) {
15408
- if (y >= this.y && y < this.y + this.height) {
15409
- return true;
15410
- }
15481
+ // 控制边缘的平滑程度
15482
+ var densityScale = 5;
15483
+ // Choose a number of segments such that the maximum absolute deviation from the circle is approximately 0.029
15484
+ var n = densityScale * Math.ceil(2.3 * Math.sqrt(rx + ry));
15485
+ var m = n * 8 + (dx ? 4 : 0) + (dy ? 4 : 0);
15486
+ if (m === 0) {
15487
+ return;
15411
15488
  }
15412
- return false;
15413
- };
15414
- /**
15415
- * Checks whether the x and y coordinates given are contained within this rectangle including the stroke.
15416
- * @param x - The X coordinate of the point to test
15417
- * @param y - The Y coordinate of the point to test
15418
- * @param strokeWidth - The width of the line to check
15419
- * @returns Whether the x/y coordinates are within this rectangle
15420
- */ _proto.strokeContains = function strokeContains(x, y, strokeWidth) {
15421
- var _this = this, width = _this.width, height = _this.height;
15422
- if (width <= 0 || height <= 0) {
15423
- return false;
15489
+ if (n === 0) {
15490
+ points[0] = points[6] = x + dx;
15491
+ points[1] = points[3] = y + dy;
15492
+ points[2] = points[4] = x - dx;
15493
+ points[5] = points[7] = y - dy;
15494
+ return;
15424
15495
  }
15425
- var _x = this.x;
15426
- var _y = this.y;
15427
- var outerLeft = _x - strokeWidth / 2;
15428
- var outerRight = _x + width + strokeWidth / 2;
15429
- var outerTop = _y - strokeWidth / 2;
15430
- var outerBottom = _y + height + strokeWidth / 2;
15431
- var innerLeft = _x + strokeWidth / 2;
15432
- var innerRight = _x + width - strokeWidth / 2;
15433
- var innerTop = _y + strokeWidth / 2;
15434
- var innerBottom = _y + height - strokeWidth / 2;
15435
- return x >= outerLeft && x <= outerRight && y >= outerTop && y <= outerBottom && !(x > innerLeft && x < innerRight && y > innerTop && y < innerBottom);
15436
- };
15437
- /**
15438
- * Determines whether the `other` Rectangle transformed by `transform` intersects with `this` Rectangle object.
15439
- * Returns true only if the area of the intersection is >0, this means that Rectangles
15440
- * sharing a side are not overlapping. Another side effect is that an arealess rectangle
15441
- * (width or height equal to zero) can't intersect any other rectangle.
15442
- * @param {Rectangle} other - The Rectangle to intersect with `this`.
15443
- * @param {Matrix} transform - The transformation matrix of `other`.
15444
- * @returns {boolean} A value of `true` if the transformed `other` Rectangle intersects with `this`; otherwise `false`.
15445
- */ // intersects (other: Rectangle, transform?: Matrix4): boolean {
15446
- // if (!transform) {
15447
- // const x0 = this.x < other.x ? other.x : this.x;
15448
- // const x1 = this.right > other.right ? other.right : this.right;
15449
- // if (x1 <= x0) {
15450
- // return false;
15451
- // }
15452
- // const y0 = this.y < other.y ? other.y : this.y;
15453
- // const y1 = this.bottom > other.bottom ? other.bottom : this.bottom;
15454
- // return y1 > y0;
15455
- // }
15456
- // const x0 = this.left;
15457
- // const x1 = this.right;
15458
- // const y0 = this.top;
15459
- // const y1 = this.bottom;
15460
- // if (x1 <= x0 || y1 <= y0) {
15461
- // return false;
15462
- // }
15463
- // const lt = tempPoints[0].set(other.left, other.top);
15464
- // const lb = tempPoints[1].set(other.left, other.bottom);
15465
- // const rt = tempPoints[2].set(other.right, other.top);
15466
- // const rb = tempPoints[3].set(other.right, other.bottom);
15467
- // if (rt.x <= lt.x || lb.y <= lt.y) {
15468
- // return false;
15469
- // }
15470
- // const s = Math.sign((transform.a * transform.d) - (transform.b * transform.c));
15471
- // if (s === 0) {
15472
- // return false;
15473
- // }
15474
- // transform.apply(lt, lt);
15475
- // transform.apply(lb, lb);
15476
- // transform.apply(rt, rt);
15477
- // transform.apply(rb, rb);
15478
- // if (Math.max(lt.x, lb.x, rt.x, rb.x) <= x0
15479
- // || Math.min(lt.x, lb.x, rt.x, rb.x) >= x1
15480
- // || Math.max(lt.y, lb.y, rt.y, rb.y) <= y0
15481
- // || Math.min(lt.y, lb.y, rt.y, rb.y) >= y1) {
15482
- // return false;
15483
- // }
15484
- // const nx = s * (lb.y - lt.y);
15485
- // const ny = s * (lt.x - lb.x);
15486
- // const n00 = (nx * x0) + (ny * y0);
15487
- // const n10 = (nx * x1) + (ny * y0);
15488
- // const n01 = (nx * x0) + (ny * y1);
15489
- // const n11 = (nx * x1) + (ny * y1);
15490
- // if (Math.max(n00, n10, n01, n11) <= (nx * lt.x) + (ny * lt.y)
15491
- // || Math.min(n00, n10, n01, n11) >= (nx * rb.x) + (ny * rb.y)) {
15492
- // return false;
15493
- // }
15494
- // const mx = s * (lt.y - rt.y);
15495
- // const my = s * (rt.x - lt.x);
15496
- // const m00 = (mx * x0) + (my * y0);
15497
- // const m10 = (mx * x1) + (my * y0);
15498
- // const m01 = (mx * x0) + (my * y1);
15499
- // const m11 = (mx * x1) + (my * y1);
15500
- // if (Math.max(m00, m10, m01, m11) <= (mx * lt.x) + (my * lt.y)
15501
- // || Math.min(m00, m10, m01, m11) >= (mx * rb.x) + (my * rb.y)) {
15502
- // return false;
15503
- // }
15504
- // return true;
15505
- // }
15506
- /**
15507
- * Pads the rectangle making it grow in all directions.
15508
- * If paddingY is omitted, both paddingX and paddingY will be set to paddingX.
15509
- * @param paddingX - The horizontal padding amount.
15510
- * @param paddingY - The vertical padding amount.
15511
- * @returns Returns itself.
15512
- */ _proto.pad = function pad(paddingX, paddingY) {
15513
- if (paddingX === void 0) paddingX = 0;
15514
- if (paddingY === void 0) paddingY = paddingX;
15515
- this.x -= paddingX;
15516
- this.y -= paddingY;
15517
- this.width += paddingX * 2;
15518
- this.height += paddingY * 2;
15519
- return this;
15520
- };
15521
- /**
15522
- * Fits this rectangle around the passed one.
15523
- * @param rectangle - The rectangle to fit.
15524
- * @returns Returns itself.
15525
- */ _proto.fit = function fit(rectangle) {
15526
- var x1 = Math.max(this.x, rectangle.x);
15527
- var x2 = Math.min(this.x + this.width, rectangle.x + rectangle.width);
15528
- var y1 = Math.max(this.y, rectangle.y);
15529
- var y2 = Math.min(this.y + this.height, rectangle.y + rectangle.height);
15530
- this.x = x1;
15531
- this.width = Math.max(x2 - x1, 0);
15532
- this.y = y1;
15533
- this.height = Math.max(y2 - y1, 0);
15534
- return this;
15535
- };
15536
- /**
15537
- * Enlarges rectangle that way its corners lie on grid
15538
- * @param resolution - resolution
15539
- * @param eps - precision
15540
- * @returns Returns itself.
15541
- */ _proto.ceil = function ceil(resolution, eps) {
15542
- if (resolution === void 0) resolution = 1;
15543
- if (eps === void 0) eps = 0.001;
15544
- var x2 = Math.ceil((this.x + this.width - eps) * resolution) / resolution;
15545
- var y2 = Math.ceil((this.y + this.height - eps) * resolution) / resolution;
15546
- this.x = Math.floor((this.x + eps) * resolution) / resolution;
15547
- this.y = Math.floor((this.y + eps) * resolution) / resolution;
15548
- this.width = x2 - this.x;
15549
- this.height = y2 - this.y;
15550
- return this;
15551
- };
15552
- /**
15553
- * Enlarges this rectangle to include the passed rectangle.
15554
- * @param rectangle - The rectangle to include.
15555
- * @returns Returns itself.
15556
- */ _proto.enlarge = function enlarge(rectangle) {
15557
- var x1 = Math.min(this.x, rectangle.x);
15558
- var x2 = Math.max(this.x + this.width, rectangle.x + rectangle.width);
15559
- var y1 = Math.min(this.y, rectangle.y);
15560
- var y2 = Math.max(this.y + this.height, rectangle.y + rectangle.height);
15561
- this.x = x1;
15562
- this.width = x2 - x1;
15563
- this.y = y1;
15564
- this.height = y2 - y1;
15565
- return this;
15566
- };
15567
- /**
15568
- * Returns the framing rectangle of the rectangle as a Rectangle object
15569
- * @param out - optional rectangle to store the result
15570
- * @returns The framing rectangle
15571
- */ _proto.getBounds = function getBounds(out) {
15572
- out = out || new Rectangle();
15573
- out.copyFrom(this);
15574
- return out;
15575
- };
15576
- _proto.getX = function getX() {
15577
- return this.x;
15578
- };
15579
- _proto.getY = function getY() {
15580
- return this.y;
15581
- };
15582
- _proto.build = function build(points) {
15583
- var x = this.x;
15584
- var y = this.y;
15585
- var width = this.width;
15586
- var height = this.height;
15587
- if (!(width >= 0 && height >= 0)) {
15588
- return points;
15496
+ var j1 = 0;
15497
+ var j2 = n * 4 + (dx ? 2 : 0) + 2;
15498
+ var j3 = j2;
15499
+ var j4 = m;
15500
+ var x0 = dx + rx;
15501
+ var y0 = dy;
15502
+ var x1 = x + x0;
15503
+ var x2 = x - x0;
15504
+ var y1 = y + y0;
15505
+ points[j1++] = x1;
15506
+ points[j1++] = y1;
15507
+ points[--j2] = y1;
15508
+ points[--j2] = x2;
15509
+ if (dy) {
15510
+ var y2 = y - y0;
15511
+ points[j3++] = x2;
15512
+ points[j3++] = y2;
15513
+ points[--j4] = y2;
15514
+ points[--j4] = x1;
15515
+ }
15516
+ for(var i = 1; i < n; i++){
15517
+ var a = Math.PI / 2 * (i / n);
15518
+ var x01 = dx + Math.cos(a) * rx;
15519
+ var y01 = dy + Math.sin(a) * ry;
15520
+ var x11 = x + x01;
15521
+ var x21 = x - x01;
15522
+ var y11 = y + y01;
15523
+ var y21 = y - y01;
15524
+ points[j1++] = x11;
15525
+ points[j1++] = y11;
15526
+ points[--j2] = y11;
15527
+ points[--j2] = x21;
15528
+ points[j3++] = x21;
15529
+ points[j3++] = y21;
15530
+ points[--j4] = y21;
15531
+ points[--j4] = x11;
15532
+ }
15533
+ x0 = dx;
15534
+ y0 = dy + ry;
15535
+ x1 = x + x0;
15536
+ x2 = x - x0;
15537
+ y1 = y + y0;
15538
+ var y22 = y - y0;
15539
+ points[j1++] = x1;
15540
+ points[j1++] = y1;
15541
+ points[--j4] = y22;
15542
+ points[--j4] = x1;
15543
+ if (dx) {
15544
+ points[j1++] = x2;
15545
+ points[j1++] = y1;
15546
+ points[--j4] = y22;
15547
+ points[--j4] = x2;
15589
15548
  }
15590
- points[0] = x;
15591
- points[1] = y;
15592
- points[2] = x + width;
15593
- points[3] = y;
15594
- points[4] = x + width;
15595
- points[5] = y + height;
15596
- points[6] = x;
15597
- points[7] = y + height;
15598
- return points;
15599
15549
  };
15600
15550
  _proto.triangulate = function triangulate(points, vertices, verticesOffset, indices, indicesOffset) {
15601
- var count = 0;
15602
- var verticesStride = 2;
15603
- verticesOffset *= verticesStride;
15604
- vertices[verticesOffset + count] = points[0];
15605
- vertices[verticesOffset + count + 1] = points[1];
15606
- count += verticesStride;
15607
- vertices[verticesOffset + count] = points[2];
15608
- vertices[verticesOffset + count + 1] = points[3];
15609
- count += verticesStride;
15610
- vertices[verticesOffset + count] = points[6];
15611
- vertices[verticesOffset + count + 1] = points[7];
15612
- count += verticesStride;
15613
- vertices[verticesOffset + count] = points[4];
15614
- vertices[verticesOffset + count + 1] = points[5];
15615
- count += verticesStride;
15616
- var verticesIndex = verticesOffset / verticesStride;
15617
- // triangle 1
15618
- indices[indicesOffset++] = verticesIndex;
15619
- indices[indicesOffset++] = verticesIndex + 1;
15620
- indices[indicesOffset++] = verticesIndex + 2;
15621
- // triangle 2
15622
- indices[indicesOffset++] = verticesIndex + 1;
15623
- indices[indicesOffset++] = verticesIndex + 3;
15624
- indices[indicesOffset++] = verticesIndex + 2;
15625
- };
15626
- _create_class(Rectangle, [
15627
- {
15628
- key: "left",
15629
- get: /** Returns the left edge of the rectangle. */ function get() {
15630
- return this.x;
15631
- }
15632
- },
15633
- {
15634
- key: "right",
15635
- get: /** Returns the right edge of the rectangle. */ function get() {
15636
- return this.x + this.width;
15637
- }
15638
- },
15639
- {
15640
- key: "top",
15641
- get: /** Returns the top edge of the rectangle. */ function get() {
15642
- return this.y;
15643
- }
15644
- },
15645
- {
15646
- key: "bottom",
15647
- get: /** Returns the bottom edge of the rectangle. */ function get() {
15648
- return this.y + this.height;
15649
- }
15551
+ if (points.length === 0) {
15552
+ return;
15650
15553
  }
15651
- ], [
15652
- {
15653
- key: "EMPTY",
15654
- get: /** A constant empty rectangle. This is a new object every time the property is accessed */ function get() {
15655
- return new Rectangle(0, 0, 0, 0);
15554
+ // Compute center (average of all points)
15555
+ var centerX = 0;
15556
+ var centerY = 0;
15557
+ for(var i = 0; i < points.length; i += 2){
15558
+ centerX += points[i];
15559
+ centerY += points[i + 1];
15560
+ }
15561
+ centerX /= points.length / 2;
15562
+ centerY /= points.length / 2;
15563
+ // Set center vertex
15564
+ var count = verticesOffset;
15565
+ vertices[count * 2] = centerX;
15566
+ vertices[count * 2 + 1] = centerY;
15567
+ var centerIndex = count++;
15568
+ // Set edge vertices and indices
15569
+ for(var i1 = 0; i1 < points.length; i1 += 2){
15570
+ vertices[count * 2] = points[i1];
15571
+ vertices[count * 2 + 1] = points[i1 + 1];
15572
+ if (i1 > 0) {
15573
+ indices[indicesOffset++] = count;
15574
+ indices[indicesOffset++] = centerIndex;
15575
+ indices[indicesOffset++] = count - 1;
15656
15576
  }
15577
+ count++;
15657
15578
  }
15658
- ]);
15579
+ // Connect last point to the first edge point
15580
+ indices[indicesOffset++] = centerIndex + 1;
15581
+ indices[indicesOffset++] = centerIndex;
15582
+ indices[indicesOffset++] = count - 1;
15583
+ };
15659
15584
  return Rectangle;
15660
15585
  }(ShapePrimitive);
15661
15586
 
@@ -15753,8 +15678,8 @@ var ShapePath = /*#__PURE__*/ function() {
15753
15678
  * @param h - The height of the rectangle.
15754
15679
  * @param transform - An optional `Matrix` object to apply a transformation to the rectangle.
15755
15680
  * @returns The instance of the current object for chaining.
15756
- */ _proto.rect = function rect(x, y, w, h, transform) {
15757
- this.drawShape(new Rectangle$1(x, y, w, h), transform);
15681
+ */ _proto.rect = function rect(x, y, w, h, roundness, transform) {
15682
+ this.drawShape(new Rectangle$1(x, y, w, h, roundness), transform);
15758
15683
  return this;
15759
15684
  };
15760
15685
  /**
@@ -15900,7 +15825,7 @@ var GraphicsPath = /*#__PURE__*/ function() {
15900
15825
  * @param h - The height of the rectangle.
15901
15826
  * @param transform - An optional `Matrix` object to apply a transformation to the rectangle.
15902
15827
  * @returns The instance of the current object for chaining.
15903
- */ _proto.rect = function rect(x, y, w, h, transform) {
15828
+ */ _proto.rect = function rect(x, y, w, h, roundness, transform) {
15904
15829
  this.instructions.push({
15905
15830
  action: "rect",
15906
15831
  data: [
@@ -15908,6 +15833,7 @@ var GraphicsPath = /*#__PURE__*/ function() {
15908
15833
  y,
15909
15834
  w,
15910
15835
  h,
15836
+ roundness,
15911
15837
  transform
15912
15838
  ]
15913
15839
  });
@@ -16217,9 +16143,9 @@ vertices, _verticesStride, _verticesOffset, indices, _indicesOffset) {
16217
16143
  var innerWeight = (1 - ratio) * 2;
16218
16144
  var outerWeight = ratio * 2;
16219
16145
  if (!closedShape) {
16220
- if (style.cap === "round") {
16146
+ if (style.cap === LineCap.Round) {
16221
16147
  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;
16222
- } else if (style.cap === "square") {
16148
+ } else if (style.cap === LineCap.Square) {
16223
16149
  indexCount += square(x0, y0, perpX, perpY, innerWeight, outerWeight, true, verts);
16224
16150
  }
16225
16151
  }
@@ -16258,7 +16184,7 @@ vertices, _verticesStride, _verticesOffset, indices, _indicesOffset) {
16258
16184
  verts.push(x1 - perpX * innerWeight, y1 - perpY * innerWeight);
16259
16185
  verts.push(x1 + perpX * outerWeight, y1 + perpY * outerWeight);
16260
16186
  /* 180 degree corner? */ if (dot >= 0) {
16261
- if (style.join === "round") {
16187
+ if (style.join === LineJoin.Round) {
16262
16188
  indexCount += round(x1, y1, x1 - perpX * innerWeight, y1 - perpY * innerWeight, x1 - perp1x * innerWeight, y1 - perp1y * innerWeight, verts, false) + 4;
16263
16189
  } else {
16264
16190
  indexCount += 2;
@@ -16282,7 +16208,7 @@ vertices, _verticesStride, _verticesOffset, indices, _indicesOffset) {
16282
16208
  var smallerInsideDiagonalSq = smallerInsideSegmentSq + insideWeight * insideWeight * widthSquared;
16283
16209
  var insideMiterOk = pDist <= smallerInsideDiagonalSq;
16284
16210
  if (insideMiterOk) {
16285
- if (style.join === "bevel" || pDist / widthSquared > miterLimitSquared) {
16211
+ if (style.join === LineJoin.Bevel || pDist / widthSquared > miterLimitSquared) {
16286
16212
  if (clockwise) /* rotating at inner angle */ {
16287
16213
  verts.push(imx, imy); // inner miter point
16288
16214
  verts.push(x1 + perpX * outerWeight, y1 + perpY * outerWeight); // first segment's outer vertex
@@ -16295,7 +16221,7 @@ vertices, _verticesStride, _verticesOffset, indices, _indicesOffset) {
16295
16221
  verts.push(omx, omy); // outer miter point
16296
16222
  }
16297
16223
  indexCount += 2;
16298
- } else if (style.join === "round") {
16224
+ } else if (style.join === LineJoin.Round) {
16299
16225
  if (clockwise) /* arc is outside */ {
16300
16226
  verts.push(imx, imy);
16301
16227
  verts.push(x1 + perpX * outerWeight, y1 + perpY * outerWeight);
@@ -16316,13 +16242,13 @@ vertices, _verticesStride, _verticesOffset, indices, _indicesOffset) {
16316
16242
  } else {
16317
16243
  verts.push(x1 - perpX * innerWeight, y1 - perpY * innerWeight); // first segment's inner vertex
16318
16244
  verts.push(x1 + perpX * outerWeight, y1 + perpY * outerWeight); // first segment's outer vertex
16319
- if (style.join === "round") {
16245
+ if (style.join === LineJoin.Round) {
16320
16246
  if (clockwise) /* arc is outside */ {
16321
16247
  indexCount += round(x1, y1, x1 + perpX * outerWeight, y1 + perpY * outerWeight, x1 + perp1x * outerWeight, y1 + perp1y * outerWeight, verts, true) + 2;
16322
16248
  } else /* arc is inside */ {
16323
16249
  indexCount += round(x1, y1, x1 - perpX * innerWeight, y1 - perpY * innerWeight, x1 - perp1x * innerWeight, y1 - perp1y * innerWeight, verts, false) + 2;
16324
16250
  }
16325
- } else if (style.join === "miter" && pDist / widthSquared <= miterLimitSquared) {
16251
+ } else if (style.join === LineJoin.Miter && pDist / widthSquared <= miterLimitSquared) {
16326
16252
  if (clockwise) {
16327
16253
  verts.push(omx, omy); // inner miter point
16328
16254
  verts.push(omx, omy); // inner miter point
@@ -16351,9 +16277,9 @@ vertices, _verticesStride, _verticesOffset, indices, _indicesOffset) {
16351
16277
  verts.push(x1 - perpX * innerWeight, y1 - perpY * innerWeight);
16352
16278
  verts.push(x1 + perpX * outerWeight, y1 + perpY * outerWeight);
16353
16279
  if (!closedShape) {
16354
- if (style.cap === "round") {
16280
+ if (style.cap === LineCap.Round) {
16355
16281
  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;
16356
- } else if (style.cap === "square") {
16282
+ } else if (style.cap === LineCap.Square) {
16357
16283
  indexCount += square(x1, y1, perpX, perpY, innerWeight, outerWeight, false, verts);
16358
16284
  }
16359
16285
  }
@@ -16380,9 +16306,10 @@ var ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
16380
16306
  var _this;
16381
16307
  _this = MeshComponent.call(this, engine) || this;
16382
16308
  _this.isStroke = false;
16309
+ _this.isFill = false;
16310
+ _this.shapeDirty = true;
16383
16311
  _this.graphicsPath = new GraphicsPath();
16384
16312
  _this.curveValues = [];
16385
- _this.shapeDirty = true;
16386
16313
  _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";
16387
16314
  _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";
16388
16315
  if (!_this.geometry) {
@@ -16415,6 +16342,15 @@ var ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
16415
16342
  mode: glContext.TRIANGLES,
16416
16343
  drawCount: 4
16417
16344
  });
16345
+ _this.geometry.subMeshes.push({
16346
+ offset: 0,
16347
+ indexCount: 0,
16348
+ vertexCount: 0
16349
+ }, {
16350
+ offset: 0,
16351
+ indexCount: 0,
16352
+ vertexCount: 0
16353
+ });
16418
16354
  }
16419
16355
  if (!_this.material) {
16420
16356
  var materialProps = {
@@ -16424,18 +16360,36 @@ var ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
16424
16360
  glslVersion: GLSLVersion.GLSL1
16425
16361
  }
16426
16362
  };
16427
- _this.material = Material.create(engine, materialProps);
16428
- _this.material.setColor("_Color", new Color(1, 1, 1, 1));
16429
- _this.material.depthMask = false;
16430
- _this.material.depthTest = true;
16431
- _this.material.blending = true;
16363
+ var fillMaterial = Material.create(engine, materialProps);
16364
+ fillMaterial.setColor("_Color", new Color(1, 1, 1, 1));
16365
+ fillMaterial.depthMask = false;
16366
+ fillMaterial.depthTest = true;
16367
+ fillMaterial.blending = true;
16368
+ _this.material = fillMaterial;
16369
+ var strokeMaterial = Material.create(engine, materialProps);
16370
+ strokeMaterial.setColor("_Color", new Color(0.25, 0.25, 0.25, 1));
16371
+ strokeMaterial.depthMask = false;
16372
+ strokeMaterial.depthTest = true;
16373
+ strokeMaterial.blending = true;
16374
+ _this.materials[1] = strokeMaterial;
16432
16375
  }
16433
16376
  _this.strokeAttributes = {
16434
16377
  width: 1,
16435
16378
  alignment: 0.5,
16436
- cap: "butt",
16437
- join: "miter",
16438
- miterLimit: 10
16379
+ cap: LineCap.Butt,
16380
+ join: LineJoin.Miter,
16381
+ miterLimit: 10,
16382
+ color: new Color(1, 1, 1, 1)
16383
+ };
16384
+ _this.fillAttribute = {
16385
+ color: new Color(1, 1, 1, 1)
16386
+ };
16387
+ _this.shapeAttribute = {
16388
+ type: ShapePrimitiveType.Custom,
16389
+ points: [],
16390
+ easingIns: [],
16391
+ easingOuts: [],
16392
+ shapes: []
16439
16393
  };
16440
16394
  return _this;
16441
16395
  }
@@ -16444,8 +16398,10 @@ var ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
16444
16398
  this.item.getHitTestParams = this.getHitTestParams;
16445
16399
  };
16446
16400
  _proto.onUpdate = function onUpdate(dt) {
16401
+ this.material.color = this.fillAttribute.color;
16402
+ this.materials[1].color = this.strokeAttributes.color;
16447
16403
  if (this.shapeDirty) {
16448
- this.buildPath(this.data);
16404
+ this.buildPath(this.shapeAttribute);
16449
16405
  this.buildGeometryFromPath(this.graphicsPath.shapePath);
16450
16406
  this.shapeDirty = false;
16451
16407
  }
@@ -16454,22 +16410,34 @@ var ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
16454
16410
  var shapePrimitives = shapePath.shapePrimitives;
16455
16411
  var vertices = [];
16456
16412
  var indices = [];
16457
- // triangulate shapePrimitive
16458
- for(var _iterator = _create_for_of_iterator_helper_loose(shapePrimitives), _step; !(_step = _iterator()).done;){
16459
- var shapePrimitive = _step.value;
16460
- var shape = shapePrimitive.shape;
16461
- var points = [];
16462
- var indexOffset = indices.length;
16463
- var vertOffset = vertices.length / 2;
16464
- shape.build(points);
16465
- if (!this.isStroke) {
16413
+ // Triangulate shapePrimitive
16414
+ //---------------------------------------------------
16415
+ if (this.isFill) {
16416
+ for(var _iterator = _create_for_of_iterator_helper_loose(shapePrimitives), _step; !(_step = _iterator()).done;){
16417
+ var shapePrimitive = _step.value;
16418
+ var shape = shapePrimitive.shape;
16419
+ var points = [];
16420
+ var indexOffset = indices.length;
16421
+ var vertOffset = vertices.length / 2;
16422
+ shape.build(points);
16466
16423
  shape.triangulate(points, vertices, vertOffset, indices, indexOffset);
16467
- } else {
16424
+ }
16425
+ }
16426
+ var fillIndexCount = indices.length;
16427
+ if (this.isStroke) {
16428
+ for(var _iterator1 = _create_for_of_iterator_helper_loose(shapePrimitives), _step1; !(_step1 = _iterator1()).done;){
16429
+ var shapePrimitive1 = _step1.value;
16430
+ var shape1 = shapePrimitive1.shape;
16431
+ var points1 = [];
16432
+ indices.length;
16433
+ var vertOffset1 = vertices.length / 2;
16468
16434
  var close = true;
16469
16435
  var lineStyle = this.strokeAttributes;
16470
- buildLine(points, lineStyle, false, close, vertices, 2, vertOffset, indices);
16436
+ shape1.build(points1);
16437
+ buildLine(points1, lineStyle, false, close, vertices, 2, vertOffset1, indices);
16471
16438
  }
16472
16439
  }
16440
+ var strokeIndexCount = indices.length - fillIndexCount;
16473
16441
  var vertexCount = vertices.length / 2;
16474
16442
  // get the current attribute and index arrays from the geometry, avoiding re-creation
16475
16443
  var positionArray = this.geometry.getAttributeData("aPos");
@@ -16502,21 +16470,25 @@ var ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
16502
16470
  this.geometry.setAttributeData("aUV", uvArray);
16503
16471
  this.geometry.setIndexData(indexArray);
16504
16472
  this.geometry.setDrawCount(indices.length);
16505
- };
16506
- _proto.buildPath = function buildPath(data) {
16473
+ var u16Size = 2;
16474
+ var fillSubMesh = this.geometry.subMeshes[0];
16475
+ var strokeSubMesh = this.geometry.subMeshes[1];
16476
+ fillSubMesh.indexCount = fillIndexCount;
16477
+ strokeSubMesh.offset = fillIndexCount * u16Size;
16478
+ strokeSubMesh.indexCount = strokeIndexCount;
16479
+ };
16480
+ _proto.buildPath = function buildPath(shapeAttribute) {
16507
16481
  this.graphicsPath.clear();
16508
- var shapeData = data;
16509
- switch(shapeData.type){
16482
+ switch(shapeAttribute.type){
16510
16483
  case ShapePrimitiveType.Custom:
16511
16484
  {
16512
- var customData = shapeData;
16513
- var points = customData.points;
16514
- var easingIns = customData.easingIns;
16515
- var easingOuts = customData.easingOuts;
16516
- for(var _iterator = _create_for_of_iterator_helper_loose(customData.shapes), _step; !(_step = _iterator()).done;){
16485
+ var customShapeAtribute = this.shapeAttribute;
16486
+ var points = customShapeAtribute.points;
16487
+ var easingIns = customShapeAtribute.easingIns;
16488
+ var easingOuts = customShapeAtribute.easingOuts;
16489
+ for(var _iterator = _create_for_of_iterator_helper_loose(customShapeAtribute.shapes), _step; !(_step = _iterator()).done;){
16517
16490
  var shape = _step.value;
16518
16491
  this.curveValues = [];
16519
- this.setFillColor(shape.fill);
16520
16492
  var indices = shape.indexes;
16521
16493
  for(var i = 1; i < indices.length; i++){
16522
16494
  var pointIndex = indices[i];
@@ -16546,48 +16518,127 @@ var ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
16546
16518
  }
16547
16519
  case ShapePrimitiveType.Ellipse:
16548
16520
  {
16549
- var ellipseData = shapeData;
16521
+ var ellipseData = shapeAttribute;
16550
16522
  this.graphicsPath.ellipse(0, 0, ellipseData.xRadius, ellipseData.yRadius);
16551
- this.setFillColor(ellipseData.fill);
16552
16523
  break;
16553
16524
  }
16554
16525
  case ShapePrimitiveType.Rectangle:
16555
16526
  {
16556
- var rectangleData = shapeData;
16557
- this.graphicsPath.rect(-rectangleData.width / 2, -rectangleData.height / 2, rectangleData.width, rectangleData.height);
16558
- this.setFillColor(rectangleData.fill);
16527
+ var rectangleData = shapeAttribute;
16528
+ this.graphicsPath.rect(-rectangleData.width / 2, -rectangleData.height / 2, rectangleData.width, rectangleData.height, rectangleData.roundness);
16559
16529
  break;
16560
16530
  }
16561
16531
  case ShapePrimitiveType.Star:
16562
16532
  {
16563
- var starData = shapeData;
16533
+ var starData = shapeAttribute;
16564
16534
  this.graphicsPath.polyStar(starData.pointCount, starData.outerRadius, starData.innerRadius, starData.outerRoundness, starData.innerRoundness, StarType.Star);
16565
- this.setFillColor(starData.fill);
16566
16535
  break;
16567
16536
  }
16568
16537
  case ShapePrimitiveType.Polygon:
16569
16538
  {
16570
- var polygonData = shapeData;
16539
+ var polygonData = shapeAttribute;
16571
16540
  this.graphicsPath.polyStar(polygonData.pointCount, polygonData.radius, polygonData.radius, polygonData.roundness, polygonData.roundness, StarType.Polygon);
16572
- this.setFillColor(polygonData.fill);
16573
16541
  break;
16574
16542
  }
16575
16543
  }
16576
16544
  };
16577
- _proto.setFillColor = function setFillColor(fill) {
16578
- if (fill) {
16579
- var color = fill.color;
16580
- this.material.setColor("_Color", new Color(color.r, color.g, color.b, color.a));
16581
- }
16582
- };
16583
16545
  _proto.fromData = function fromData(data) {
16584
16546
  MeshComponent.prototype.fromData.call(this, data);
16585
- this.data = data;
16586
16547
  this.shapeDirty = true;
16587
16548
  var strokeParam = data.stroke;
16588
16549
  if (strokeParam) {
16589
16550
  this.isStroke = true;
16590
16551
  this.strokeAttributes.width = strokeParam.width;
16552
+ this.strokeAttributes.color.copyFrom(strokeParam.color);
16553
+ this.strokeAttributes.cap = strokeParam.cap;
16554
+ this.strokeAttributes.join = strokeParam.join;
16555
+ }
16556
+ var fillParam = data.fill;
16557
+ if (fillParam) {
16558
+ this.isFill = true;
16559
+ this.fillAttribute.color.copyFrom(fillParam.color);
16560
+ }
16561
+ switch(data.type){
16562
+ case ShapePrimitiveType.Custom:
16563
+ {
16564
+ var customShapeData = data;
16565
+ var customShapeAttribute = {
16566
+ type: ShapePrimitiveType.Custom,
16567
+ points: [],
16568
+ easingIns: [],
16569
+ easingOuts: [],
16570
+ shapes: [],
16571
+ fill: customShapeData.fill
16572
+ };
16573
+ for(var _iterator = _create_for_of_iterator_helper_loose(customShapeData.points), _step; !(_step = _iterator()).done;){
16574
+ var point = _step.value;
16575
+ customShapeAttribute.points.push(new Vector2(point.x, point.y));
16576
+ }
16577
+ for(var _iterator1 = _create_for_of_iterator_helper_loose(customShapeData.easingIns), _step1; !(_step1 = _iterator1()).done;){
16578
+ var easingIn = _step1.value;
16579
+ customShapeAttribute.easingIns.push(new Vector2(easingIn.x, easingIn.y));
16580
+ }
16581
+ for(var _iterator2 = _create_for_of_iterator_helper_loose(customShapeData.easingOuts), _step2; !(_step2 = _iterator2()).done;){
16582
+ var easingOut = _step2.value;
16583
+ customShapeAttribute.easingOuts.push(new Vector2(easingOut.x, easingOut.y));
16584
+ }
16585
+ customShapeAttribute.shapes = customShapeData.shapes;
16586
+ this.shapeAttribute = customShapeAttribute;
16587
+ break;
16588
+ }
16589
+ case ShapePrimitiveType.Ellipse:
16590
+ {
16591
+ var ellipseData = data;
16592
+ var ellipseAttribute = {
16593
+ type: ShapePrimitiveType.Ellipse,
16594
+ xRadius: ellipseData.xRadius,
16595
+ yRadius: ellipseData.yRadius,
16596
+ fill: ellipseData.fill
16597
+ };
16598
+ this.shapeAttribute = ellipseAttribute;
16599
+ break;
16600
+ }
16601
+ case ShapePrimitiveType.Rectangle:
16602
+ {
16603
+ var rectangleData = data;
16604
+ var rectangleAttribute = {
16605
+ type: ShapePrimitiveType.Rectangle,
16606
+ width: rectangleData.width,
16607
+ height: rectangleData.height,
16608
+ roundness: rectangleData.roundness,
16609
+ fill: rectangleData.fill
16610
+ };
16611
+ this.shapeAttribute = rectangleAttribute;
16612
+ break;
16613
+ }
16614
+ case ShapePrimitiveType.Star:
16615
+ {
16616
+ var starData = data;
16617
+ var starAttribute = {
16618
+ type: ShapePrimitiveType.Star,
16619
+ pointCount: starData.pointCount,
16620
+ innerRadius: starData.innerRadius,
16621
+ outerRadius: starData.outerRadius,
16622
+ innerRoundness: starData.innerRoundness,
16623
+ outerRoundness: starData.outerRoundness,
16624
+ fill: starData.fill
16625
+ };
16626
+ this.shapeAttribute = starAttribute;
16627
+ break;
16628
+ }
16629
+ case ShapePrimitiveType.Polygon:
16630
+ {
16631
+ var polygonData = data;
16632
+ var polygonAttribute = {
16633
+ type: ShapePrimitiveType.Polygon,
16634
+ pointCount: polygonData.pointCount,
16635
+ radius: polygonData.radius,
16636
+ roundness: polygonData.roundness,
16637
+ fill: polygonData.fill
16638
+ };
16639
+ this.shapeAttribute = polygonAttribute;
16640
+ break;
16641
+ }
16591
16642
  }
16592
16643
  var material = this.material;
16593
16644
  //@ts-expect-error // TODO 新版蒙版上线后重构
@@ -16600,10 +16651,10 @@ var ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
16600
16651
  };
16601
16652
  _create_class(ShapeComponent, [
16602
16653
  {
16603
- key: "path",
16654
+ key: "shape",
16604
16655
  get: function get() {
16605
16656
  this.shapeDirty = true;
16606
- return this.data;
16657
+ return this.shapeAttribute;
16607
16658
  }
16608
16659
  }
16609
16660
  ]);
@@ -17423,10 +17474,8 @@ function shouldIgnoreBouncing(arg, mul) {
17423
17474
  };
17424
17475
  };
17425
17476
  _proto.setGeometry = function setGeometry(geometry, worldMatrix) {
17426
- if (this.geometry !== geometry) {
17427
- this.triangles = this.geometryToTriangles(geometry);
17428
- this.geometry = geometry;
17429
- }
17477
+ this.triangles = this.geometryToTriangles(geometry);
17478
+ this.geometry = geometry;
17430
17479
  var area = [];
17431
17480
  for(var _iterator = _create_for_of_iterator_helper_loose(this.triangles), _step; !(_step = _iterator()).done;){
17432
17481
  var triangle = _step.value;
@@ -17447,10 +17496,11 @@ function shouldIgnoreBouncing(arg, mul) {
17447
17496
  _proto.geometryToTriangles = function geometryToTriangles(geometry) {
17448
17497
  var _geometry_getIndexData;
17449
17498
  var indices = (_geometry_getIndexData = geometry.getIndexData()) != null ? _geometry_getIndexData : [];
17499
+ var drawCount = geometry.getDrawCount();
17450
17500
  var _geometry_getAttributeData;
17451
17501
  var vertices = (_geometry_getAttributeData = geometry.getAttributeData("aPos")) != null ? _geometry_getAttributeData : [];
17452
17502
  var res = [];
17453
- for(var i = 0; i < indices.length; i += 3){
17503
+ for(var i = 0; i < drawCount; i += 3){
17454
17504
  var index0 = indices[i] * 3;
17455
17505
  var index1 = indices[i + 1] * 3;
17456
17506
  var index2 = indices[i + 2] * 3;
@@ -21008,19 +21058,17 @@ var ParticleSystem = /*#__PURE__*/ function(Component) {
21008
21058
  rotation: rotation,
21009
21059
  path: path
21010
21060
  };
21011
- var parentTransform = this.transform.parentTransform;
21012
21061
  var selfPos = position.clone();
21013
21062
  if (path) {
21014
21063
  selfPos.add(path.getValue(0));
21015
21064
  }
21016
21065
  this.transform.setPosition(selfPos.x, selfPos.y, selfPos.z);
21017
- if (this.options.particleFollowParent && parentTransform) {
21018
- var worldMatrix = parentTransform.getWorldMatrix();
21066
+ if (this.options.particleFollowParent) {
21067
+ var worldMatrix = this.transform.getWorldMatrix();
21019
21068
  this.renderer.updateWorldMatrix(worldMatrix);
21020
21069
  }
21021
21070
  };
21022
21071
  _proto.updateEmitterTransform = function updateEmitterTransform(time) {
21023
- var parentTransform = this.transform.parentTransform;
21024
21072
  var _this_basicTransform = this.basicTransform, path = _this_basicTransform.path, position = _this_basicTransform.position;
21025
21073
  var selfPos = position.clone();
21026
21074
  if (path) {
@@ -21028,8 +21076,8 @@ var ParticleSystem = /*#__PURE__*/ function(Component) {
21028
21076
  selfPos.add(path.getValue(time / duration));
21029
21077
  }
21030
21078
  this.transform.setPosition(selfPos.x, selfPos.y, selfPos.z);
21031
- if (this.options.particleFollowParent && parentTransform) {
21032
- var worldMatrix = parentTransform.getWorldMatrix();
21079
+ if (this.options.particleFollowParent) {
21080
+ var worldMatrix = this.transform.getWorldMatrix();
21033
21081
  this.renderer.updateWorldMatrix(worldMatrix);
21034
21082
  }
21035
21083
  };
@@ -21417,7 +21465,7 @@ var ParticleSystem = /*#__PURE__*/ function(Component) {
21417
21465
  var lifetime = this.lifetime;
21418
21466
  var shape = this.shape;
21419
21467
  var speed = options.startSpeed.getValue(lifetime);
21420
- var matrix4 = options.particleFollowParent ? this.transform.getMatrix() : this.transform.getWorldMatrix();
21468
+ var matrix4 = options.particleFollowParent ? Matrix4.IDENTITY : this.transform.getWorldMatrix();
21421
21469
  var pointPosition = data.position;
21422
21470
  // 粒子的位置受发射器的位置影响,自身的旋转和缩放不受影响
21423
21471
  var position = matrix4.transformPoint(pointPosition, new Vector3());
@@ -24239,7 +24287,7 @@ var SerializationHelper = /*#__PURE__*/ function() {
24239
24287
  this.timelinePlayable.setTime(time);
24240
24288
  // The properties of the object may change dynamically,
24241
24289
  // so reset the track binding to avoid invalidation of the previously obtained binding object.
24242
- // this.resolveBindings();
24290
+ this.resolveBindings();
24243
24291
  this.timelinePlayable.evaluate();
24244
24292
  this.graph.evaluate(dt);
24245
24293
  };
@@ -24478,7 +24526,10 @@ var Vector4PropertyMixerPlayable = /*#__PURE__*/ function(PropertyMixerPlayable)
24478
24526
  }
24479
24527
  var _proto = Vector4PropertyMixerPlayable.prototype;
24480
24528
  _proto.resetPropertyValue = function resetPropertyValue() {
24481
- this.propertyValue.setZero();
24529
+ this.propertyValue.x = 0;
24530
+ this.propertyValue.y = 0;
24531
+ this.propertyValue.z = 0;
24532
+ this.propertyValue.w = 0;
24482
24533
  };
24483
24534
  _proto.addWeightedValue = function addWeightedValue(curveValue, weight) {
24484
24535
  var result = this.propertyValue;
@@ -24496,7 +24547,8 @@ var Vector2PropertyMixerPlayable = /*#__PURE__*/ function(PropertyMixerPlayable)
24496
24547
  }
24497
24548
  var _proto = Vector2PropertyMixerPlayable.prototype;
24498
24549
  _proto.resetPropertyValue = function resetPropertyValue() {
24499
- this.propertyValue.setZero();
24550
+ this.propertyValue.x = 0;
24551
+ this.propertyValue.y = 0;
24500
24552
  };
24501
24553
  _proto.addWeightedValue = function addWeightedValue(curveValue, weight) {
24502
24554
  var result = this.propertyValue;
@@ -25431,6 +25483,9 @@ var TextComponent = /*#__PURE__*/ function(BaseRenderComponent) {
25431
25483
  /**
25432
25484
  * 文本行数
25433
25485
  */ _this.lineCount = 0;
25486
+ /**
25487
+ * 每一行文本的最大宽度
25488
+ */ _this.maxLineWidth = 0;
25434
25489
  _this.SCALE_FACTOR = 0.1;
25435
25490
  _this.ALPHA_FIX_VALUE = 1 / 255;
25436
25491
  _this.name = "MText" + seed$1++;
@@ -25514,12 +25569,9 @@ var TextComponentBase = /*#__PURE__*/ function() {
25514
25569
  this.textStyle = new TextStyle(options);
25515
25570
  this.textLayout = new TextLayout(options);
25516
25571
  this.text = options.text.toString();
25517
- this.lineCount = this.getLineCount(options.text, true);
25518
25572
  };
25519
- _proto.getLineCount = function getLineCount(text, init) {
25520
- var context = this.context;
25521
- var letterSpace = this.textLayout.letterSpace;
25522
- var fontScale = init ? this.textStyle.fontSize / 10 : 1 / this.textStyle.fontScale;
25573
+ _proto.getLineCount = function getLineCount(text, context) {
25574
+ var _this_textLayout = this.textLayout, letterSpace = _this_textLayout.letterSpace, overflow = _this_textLayout.overflow;
25523
25575
  var width = this.textLayout.width + this.textStyle.fontOffset;
25524
25576
  var lineCount = 1;
25525
25577
  var x = 0;
@@ -25527,15 +25579,27 @@ var TextComponentBase = /*#__PURE__*/ function() {
25527
25579
  var _context_measureText;
25528
25580
  var str = text[i];
25529
25581
  var _context_measureText_width;
25530
- 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;
25582
+ 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;
25531
25583
  // 和浏览器行为保持一致
25532
25584
  x += letterSpace;
25533
- if (x + textMetrics > width && i > 0 || str === "\n") {
25534
- lineCount++;
25535
- x = 0;
25536
- }
25537
- if (str !== "\n") {
25538
- x += textMetrics;
25585
+ // 处理文本结束行为
25586
+ if (overflow === TextOverflow.display) {
25587
+ if (str === "\n") {
25588
+ lineCount++;
25589
+ x = 0;
25590
+ } else {
25591
+ x += textMetrics;
25592
+ this.maxLineWidth = Math.max(this.maxLineWidth, x);
25593
+ }
25594
+ } else {
25595
+ if (x + textMetrics > width && i > 0 || str === "\n") {
25596
+ lineCount++;
25597
+ this.maxLineWidth = Math.max(this.maxLineWidth, x);
25598
+ x = 0;
25599
+ }
25600
+ if (str !== "\n") {
25601
+ x += textMetrics;
25602
+ }
25539
25603
  }
25540
25604
  }
25541
25605
  return lineCount;
@@ -25585,7 +25649,6 @@ var TextComponentBase = /*#__PURE__*/ function() {
25585
25649
  return;
25586
25650
  }
25587
25651
  this.text = value.toString();
25588
- this.lineCount = this.getLineCount(value, false);
25589
25652
  this.isDirty = true;
25590
25653
  };
25591
25654
  /**
@@ -25667,6 +25730,18 @@ var TextComponentBase = /*#__PURE__*/ function() {
25667
25730
  this.isDirty = true;
25668
25731
  };
25669
25732
  /**
25733
+ * 设置文本溢出模式
25734
+ *
25735
+ * - clip: 当文本内容超出边界框时,多余的会被截断。
25736
+ * - display: 该模式下会显示所有文本,会自动调整文本字号以保证显示完整。
25737
+ * > 当存在多行时,部分行内文本可能存在文本字号变小的情况,其他行为正常情况
25738
+ *
25739
+ * @param overflow - 文本溢出模式
25740
+ */ _proto.setOverflow = function setOverflow(overflow) {
25741
+ this.textLayout.overflow = overflow;
25742
+ this.isDirty = true;
25743
+ };
25744
+ /**
25670
25745
  * 设置阴影颜色
25671
25746
  * @param value - 阴影颜色
25672
25747
  * @returns
@@ -25734,28 +25809,35 @@ var TextComponentBase = /*#__PURE__*/ function() {
25734
25809
  var layout = this.textLayout;
25735
25810
  var fontScale = style.fontScale;
25736
25811
  var width = (layout.width + style.fontOffset) * fontScale;
25737
- var finalHeight = layout.lineHeight * this.lineCount;
25738
25812
  var fontSize = style.fontSize * fontScale;
25739
25813
  var lineHeight = layout.lineHeight * fontScale;
25814
+ style.fontDesc = this.getFontDesc(fontSize);
25740
25815
  this.char = (this.text || "").split("");
25741
25816
  this.canvas.width = width;
25817
+ var height = this.canvas.height;
25818
+ context.font = style.fontDesc;
25819
+ this.lineCount = this.getLineCount(this.text, context);
25820
+ var finalHeight = layout.lineHeight * this.lineCount;
25742
25821
  if (layout.autoWidth) {
25743
25822
  this.canvas.height = finalHeight * fontScale;
25744
25823
  this.item.transform.size.set(1, finalHeight / layout.height);
25745
25824
  } else {
25746
25825
  this.canvas.height = layout.height * fontScale;
25747
25826
  }
25748
- var height = this.canvas.height;
25749
- context.clearRect(0, 0, width, height);
25827
+ // canvas size 变化后重新刷新 context
25828
+ if (this.maxLineWidth > width && layout.overflow === TextOverflow.display) {
25829
+ context.font = this.getFontDesc(fontSize * width / this.maxLineWidth);
25830
+ } else {
25831
+ context.font = style.fontDesc;
25832
+ }
25750
25833
  // fix bug 1/255
25751
25834
  context.fillStyle = "rgba(255, 255, 255, 0.0039)";
25835
+ context.clearRect(0, 0, width, height);
25752
25836
  if (!flipY) {
25753
25837
  context.translate(0, height);
25754
25838
  context.scale(1, -1);
25755
25839
  }
25756
25840
  context.fillRect(0, 0, width, height);
25757
- style.fontDesc = this.getFontDesc();
25758
- context.font = style.fontDesc;
25759
25841
  if (style.hasShadow) {
25760
25842
  this.setupShadow();
25761
25843
  }
@@ -25827,9 +25909,9 @@ var TextComponentBase = /*#__PURE__*/ function() {
25827
25909
  this.material.setTexture("_MainTex", texture);
25828
25910
  this.isDirty = false;
25829
25911
  };
25830
- _proto.getFontDesc = function getFontDesc() {
25831
- 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;
25832
- var fontDesc = "" + (fontSize * fontScale).toString() + "px ";
25912
+ _proto.getFontDesc = function getFontDesc(fontSize) {
25913
+ var _this_textStyle = this.textStyle, fontFamily = _this_textStyle.fontFamily, textWeight = _this_textStyle.textWeight, fontStyle = _this_textStyle.fontStyle;
25914
+ var fontDesc = "" + fontSize.toString() + "px ";
25833
25915
  if (!DEFAULT_FONTS.includes(fontFamily)) {
25834
25916
  fontDesc += '"' + fontFamily + '"';
25835
25917
  } else {
@@ -26599,12 +26681,29 @@ function getStandardInteractContent(ui) {
26599
26681
  * 3.1 版本数据适配
26600
26682
  * - 富文本插件名称的适配
26601
26683
  */ function version31Migration(json) {
26602
- var _json_plugins;
26684
+ var // 修正老版本数据中,富文本插件名称的问题
26685
+ _json_plugins;
26603
26686
  (_json_plugins = json.plugins) == null ? void 0 : _json_plugins.forEach(function(plugin, index) {
26604
26687
  if (plugin === "richtext") {
26605
26688
  json.plugins[index] = "rich-text";
26606
26689
  }
26607
26690
  });
26691
+ // Custom shape fill 属性位置迁移
26692
+ for(var _iterator = _create_for_of_iterator_helper_loose(json.components), _step; !(_step = _iterator()).done;){
26693
+ var component = _step.value;
26694
+ if (component.dataType === DataType.ShapeComponent) {
26695
+ var shapeComponent = component;
26696
+ if (shapeComponent.type === ShapePrimitiveType.Custom) {
26697
+ var _customShapeComponent_shapes;
26698
+ var customShapeComponent = shapeComponent;
26699
+ //@ts-expect-error
26700
+ if (((_customShapeComponent_shapes = customShapeComponent.shapes) == null ? void 0 : _customShapeComponent_shapes.length) > 0 && customShapeComponent.shapes[0].fill) {
26701
+ // @ts-expect-error
26702
+ customShapeComponent.fill = customShapeComponent.shapes[0].fill;
26703
+ }
26704
+ }
26705
+ }
26706
+ }
26608
26707
  return json;
26609
26708
  }
26610
26709
  /**
@@ -27434,8 +27533,6 @@ function getStandardJSON(json) {
27434
27533
  }
27435
27534
  // 修正老版本数据中,meshItem 以及 lightItem 结束行为错误问题
27436
27535
  version22Migration(json);
27437
- // 修正老版本数据中,富文本插件名称的问题
27438
- version31Migration(json);
27439
27536
  if (v0.test(json.version)) {
27440
27537
  var _exec;
27441
27538
  reverseParticle = ((_exec = /^(\d+)/.exec(json.version)) == null ? void 0 : _exec[0]) === "0";
@@ -27450,7 +27547,13 @@ function getStandardJSON(json) {
27450
27547
  json = version24Migration(json);
27451
27548
  }
27452
27549
  if (mainVersion < 3) {
27453
- return version30Migration(version21Migration(json));
27550
+ json = version30Migration(version21Migration(json));
27551
+ }
27552
+ // 3.x 版本格式转换
27553
+ if (mainVersion < 4) {
27554
+ if (minorVersion < 2) {
27555
+ json = version31Migration(json);
27556
+ }
27454
27557
  }
27455
27558
  return json;
27456
27559
  }
@@ -27506,13 +27609,11 @@ function getStandardJSONFromV0(json) {
27506
27609
  }
27507
27610
  function getStandardImage(image, index, imageTags) {
27508
27611
  var renderLevel = imageTags[index];
27509
- var oriY = image.oriY;
27510
27612
  if (typeof image === "string") {
27511
27613
  return {
27512
27614
  id: generateGUID(),
27513
27615
  renderLevel: renderLevel,
27514
- url: image,
27515
- oriY: oriY
27616
+ url: image
27516
27617
  };
27517
27618
  } else if (image.template) {
27518
27619
  return {
@@ -27520,14 +27621,12 @@ function getStandardImage(image, index, imageTags) {
27520
27621
  url: image.url,
27521
27622
  template: image.template,
27522
27623
  webp: image.webp,
27523
- renderLevel: renderLevel,
27524
- oriY: oriY
27624
+ renderLevel: renderLevel
27525
27625
  };
27526
27626
  } else if (image.compressed) {
27527
27627
  return {
27528
27628
  id: generateGUID(),
27529
27629
  url: image.url,
27530
- oriY: oriY,
27531
27630
  compressed: {
27532
27631
  astc: image.compressed.android,
27533
27632
  pvrtc: image.compressed.iOS
@@ -27540,8 +27639,7 @@ function getStandardImage(image, index, imageTags) {
27540
27639
  id: generateGUID(),
27541
27640
  url: image.url,
27542
27641
  webp: image.webp,
27543
- renderLevel: renderLevel,
27544
- oriY: oriY
27642
+ renderLevel: renderLevel
27545
27643
  };
27546
27644
  } else if (image && image.sourceType) {
27547
27645
  return image;
@@ -31983,7 +32081,7 @@ registerPlugin("sprite", SpriteLoader, VFXItem, true);
31983
32081
  registerPlugin("particle", ParticleLoader, VFXItem, true);
31984
32082
  registerPlugin("cal", CalculateLoader, VFXItem, true);
31985
32083
  registerPlugin("interact", InteractLoader, VFXItem, true);
31986
- var version = "2.3.0-alpha.0";
32084
+ var version = "2.3.0-alpha.2";
31987
32085
  logger.info("Core version: " + version + ".");
31988
32086
 
31989
32087
  export { AbstractPlugin, ActivationPlayable, ActivationPlayableAsset, ActivationTrack, AnimationClip, AnimationClipPlayable, Asset, AssetLoader, AssetManager, BYTES_TYPE_MAP, BaseRenderComponent, Behaviour, BezierCurve, BezierCurvePath, BezierCurveQuat, BinaryAsset, COMPRESSED_TEXTURE, COPY_FRAGMENT_SHADER, COPY_MESH_SHADER_ID, COPY_VERTEX_SHADER, CalculateLoader, Camera, CameraController, CameraVFXItemLoader, ColorCurve, ColorPropertyPlayableAsset, ColorPropertyTrack, Component, Composition, CompositionComponent, CompositionSourceManager, DEFAULT_FONTS, DEFAULT_FPS, Database, DestroyOptions, Downloader, EFFECTS_COPY_MESH_NAME, EVENT_TYPE_CLICK, EVENT_TYPE_TOUCH_END, EVENT_TYPE_TOUCH_MOVE, EVENT_TYPE_TOUCH_START, EffectComponent, EffectsObject, EffectsPackage, Engine, EventEmitter, EventSystem, Fake3DAnimationMode, Fake3DComponent, FilterMode, Float16ArrayWrapper, FloatPropertyPlayableAsset, FloatPropertyTrack, Framebuffer, GLSLVersion, GPUCapability, Geometry, GlobalUniforms, GradientValue, HELP_LINK, HitTestType, InteractComponent, InteractLoader, InteractMesh, Item, KTXTexture, LineSegments, LinearValue, Material, MaterialDataBlock, MaterialRenderType, MaterialTrack, Mesh, MeshCollider, ObjectBindingTrack, OrderType, PLAYER_OPTIONS_ENV_EDITOR, POST_PROCESS_SETTINGS, ParticleBehaviourPlayable, ParticleBehaviourPlayableAsset, ParticleLoader, ParticleMesh, ParticleSystem, ParticleSystemRenderer, ParticleTrack, PassTextureCache, PathSegments, PluginSystem, PostProcessVolume, PropertyTrack, RENDER_PASS_NAME_PREFIX, RENDER_PREFER_LOOKUP_TEXTURE, RUNTIME_ENV, RandomSetValue, RandomValue, RandomVectorValue, RenderFrame, RenderPass, RenderPassAttachmentStorageType, RenderPassDestroyAttachmentType, RenderPassPriorityNormal, RenderPassPriorityPostprocess, RenderPassPriorityPrepare, RenderTargetHandle, RenderTextureFormat, Renderbuffer, Renderer, RendererComponent, RuntimeClip, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0, SEMANTIC_PRE_COLOR_ATTACHMENT_0, SEMANTIC_PRE_COLOR_ATTACHMENT_SIZE_0, SPRITE_VERTEX_STRIDE, Scene, SemanticMap, SerializationHelper, Shader, ShaderCompileResultStatus, ShaderFactory, ShaderType, ShaderVariant, ShapeComponent, SpriteColorPlayableAsset, SpriteColorTrack, SpriteComponent, SpriteLoader, StaticValue, SubCompositionPlayableAsset, SubCompositionTrack, TEMPLATE_USE_OFFSCREEN_CANVAS, TextComponent, TextComponentBase, TextLayout, TextLoader, TextStyle, Texture, TextureFactory, TextureLoadAction, TextureSourceType, TextureStoreAction, Ticker, TimelineAsset, TimelineClip, TimelinePlayable, TrackAsset, TrackSortWrapper, TrackType, Transform, TransformAnimationPlayable, TransformPlayableAsset, TransformTrack, VFXItem, ValueGetter, Vector2Curve, Vector2PropertyPlayableAsset, Vector2PropertyTrack, Vector4Curve, Vector4PropertyPlayableAsset, Vector4PropertyTrack, addByOrder, addItem, addItemWithOrder, applyMixins, assertExist, asserts, base64ToFile, blend, calculateTranslation, canvasPool, colorGradingFrag, colorStopsFromGradient, colorToArr$1 as colorToArr, combineImageTemplate, createCopyShader, createGLContext, createKeyFrameMeta, createShape, createValueGetter, decimalEqual, defaultPlugins, deserializeMipmapTexture, earcut, effectsClass, effectsClassStore, enlargeBuffer, ensureFixedNumber, ensureVec3, findPreviousRenderPass, gaussianDown_frag as gaussianDownFrag, gaussianDownHFrag, gaussianDownVFrag, gaussianUpFrag, generateEmptyTypedArray, generateGUID, generateHalfFloatTexture, generateTransparentTexture, generateWhiteTexture, getBackgroundImage, getColorFromGradientStops, getConfig, getDefaultTextureFactory, getGeometryByShape, getGeometryTriangles, getImageItemRenderInfo, getKTXTextureOptions, getKeyFrameMetaByRawValue, getMergedStore, getParticleMeshShader, getPixelRatio, getPreMultiAlpha, getStandardComposition, getStandardImage, getStandardItem, getStandardJSON, getTextureSize, glContext, glType2VertexFormatType, gpuTimer, imageDataFromColor, imageDataFromGradient, initErrors, initGLContext, integrate, interpolateColor, isAlipayMiniApp, isAndroid, isArray, isCanvas, isFunction, isIOS, isIOSByUA, isMiniProgram, isObject, isSimulatorCellPhone, isString, isUniformStruct, isUniformStructArray, isValidFontFamily, isWebGL2, isWechatMiniApp, itemFrag, itemFrameFrag, itemVert, loadAVIFOptional, loadBinary, loadBlob, loadImage, loadMedia, loadVideo, loadWebPOptional, logger, index as math, maxSpriteMeshItemCount, modifyMaxKeyframeShader, nearestPowerOfTwo, noop, normalizeColor, numberToFix, parsePercent$1 as parsePercent, particleFrag, particleOriginTranslateMap$1 as particleOriginTranslateMap, particleUniformTypeMap, particleVert, passRenderLevel, pluginLoaderMap, randomInRange, registerPlugin, removeItem, rotateVec2, screenMeshVert, serialize, setBlendMode, setConfig, setDefaultTextureFactory, setMaskMode, setMaxSpriteMeshItemCount, setRayFromCamera, setSideMode, setSpriteMeshMaxItemCountByGPU, sortByOrder, index$1 as spec, spriteMeshShaderFromFilter, spriteMeshShaderFromRenderInfo, spriteMeshShaderIdFromRenderInfo, thresholdFrag, throwDestroyedError, trailVert, translatePoint, trianglesFromRect, unregisterPlugin, valIfUndefined, value, valueDefine, vecFill, vecMulCombine, version, vertexFormatType2GLType };