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