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