@galacean/effects-core 2.4.7 → 2.5.0-alpha.0
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 +17 -8
- package/dist/fallback/utils.d.ts +1 -1
- package/dist/index.js +222 -245
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +222 -245
- package/dist/index.mjs.map +1 -1
- package/dist/plugins/sprite/sprite-item.d.ts +2 -22
- package/dist/plugins/text/text-item.d.ts +2 -2
- package/package.json +1 -1
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.
|
|
6
|
+
* Version: v2.5.0-alpha.0
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
@@ -345,11 +345,6 @@ function colorToArr$1(hex, normalized) {
|
|
|
345
345
|
parseInt(m[2], 16),
|
|
346
346
|
parseInt(m[3], 16),
|
|
347
347
|
255
|
|
348
|
-
] || [
|
|
349
|
-
0,
|
|
350
|
-
0,
|
|
351
|
-
0,
|
|
352
|
-
255
|
|
353
348
|
];
|
|
354
349
|
}
|
|
355
350
|
} else if (_instanceof1(hex, Array)) {
|
|
@@ -10212,7 +10207,7 @@ var itemFrame_frag = "#version 100\nprecision highp float;vec4 blendColor(vec4 c
|
|
|
10212
10207
|
|
|
10213
10208
|
var integrate = "float calculateMovement(float t,vec2 p1,vec2 p2,vec2 p3,vec2 p4){float movement=0.0;float h=(t-p1.x)*0.05;for(int i=0;i<=20;i++){float t=float(i)*h;float nt=binarySearchT(t,p1.x,p2.x,p3.x,p4.x);float y=cubicBezier(nt,p1.y,p2.y,p3.y,p4.y);float weight=(i==0||i==20)? 1.0 :(mod(float(i),2.)!=0.)? 4.0 : 2.0;movement+=weight*y;}movement*=h/3.;return movement;}float integrateFromBezierCurveFrames(float time,float frameStart,float frameCount){int start=int(frameStart);int count=int(frameCount-1.);float ret=0.;for(int i=0;i<ITR_END;i+=2){vec4 k0=lookup_curve(i+start);vec4 k1=lookup_curve(i+1+start);if(i==0&&time<k0.x){return ret;}vec2 p1=vec2(k0.x,k0.y);vec2 p2=vec2(k0.z,k0.w);vec2 p3=vec2(k1.z,k1.w);vec2 p4=vec2(k1.x,k1.y);if(time>=k1.x){ret+=calculateMovement(k1.x,p1,p2,p3,p4);}if(time>=k0.x&&time<k1.x){return ret+calculateMovement(time,p1,p2,p3,p4);}}return ret;}float integrateByTimeLineSeg(float t,vec2 p0,vec2 p1){float t0=p0.x;float t1=p1.x;float y0=p0.y;float y1=p1.y;vec4 tSqr=vec4(t,t,t0,t0);tSqr=tSqr*tSqr;vec4 a=vec4(2.*t,3.,-t0,3.)*tSqr;float t1y0=t1*y0;vec4 b=vec4(y0-y1,t0*y1-t1y0,2.*y0+y1,t1y0);float r=dot(a,b);return r/(t0-t1)*0.16666667;}float integrateLineSeg(float time,vec2 p0,vec2 p1){float h=time-p0.x;float y0=p0.y;return(y0+y0+(p1.y-y0)*h/(p1.x-p0.x))*h/2.;}float integrateFromLineSeg(float time,float frameStart,float frameCount){if(time==0.){return 0.;}int start=int(frameStart);int count=int(frameCount-1.);float ret=0.;for(int i=0;i<ITR_END;i++){if(i>count){return ret;}vec4 ks=lookup_curve(i+start);vec2 k0=ks.xy;vec2 k1=ks.zw;if(time>k0.x&&time<=k1.x){return ret+integrateLineSeg(time,k0,k1);}ret+=integrateLineSeg(k1.x,k0,k1);vec2 k2=lookup_curve(i+start+1).xy;if(time>k1.x&&time<=k2.x){return ret+integrateLineSeg(time,k1,k2);}ret+=integrateLineSeg(k2.x,k1,k2);}return ret;}float integrateByTimeFromLineSeg(float time,float frameStart,float frameCount){if(time==0.){return 0.;}int start=int(frameStart);int count=int(frameCount-1.);float ret=0.;for(int i=0;i<ITR_END;i++){if(i>count){return ret;}vec4 ks=lookup_curve(i+start);vec2 k0=ks.xy;vec2 k1=ks.zw;if(time>k0.x&&time<=k1.x){return ret+integrateByTimeLineSeg(time,k0,k1);}ret+=integrateByTimeLineSeg(k1.x,k0,k1);vec2 k2=lookup_curve(i+start+1).xy;if(time>k1.x&&time<=k2.x){return ret+integrateByTimeLineSeg(time,k1,k2);}ret+=integrateByTimeLineSeg(k2.x,k1,k2);}return ret;}float getIntegrateFromTime0(float t1,vec4 value){float type=value.x;if(type==0.){return value.y*t1;}if(type==1.){vec2 p0=vec2(0.,value.y);vec2 p1=vec2(value.w,value.z);return integrateLineSeg(t1,p0,p1);}if(type==3.){return integrateFromLineSeg(t1,value.y,value.z);}if(type==4.){return mix(value.y,value.z,aSeed)*t1;}if(type==5.){return integrateFromBezierCurveFrames(t1,value.z,value.w);}return 0.;}float getIntegrateByTimeFromTime(float t0,float t1,vec4 value){float type=value.x;if(type==0.){return value.y*(t1*t1-t0*t0)/2.;}else if(type==1.){vec2 p0=vec2(0.,value.y);vec2 p1=vec2(value.w,value.z);return integrateByTimeLineSeg(t1,p0,p1)-integrateByTimeLineSeg(t0,p0,p1);}if(type==3.){return integrateByTimeFromLineSeg(t1,value.y,value.z)-integrateByTimeFromLineSeg(t0,value.y,value.z);}if(type==4.){return mix(value.y,value.z,aSeed)*(t1*t1-t0*t0)/2.;}if(type==5.){return integrateFromBezierCurveFrames(t1,value.z,value.w)-integrateFromBezierCurveFrames(t0,value.z,value.w);}return 0.;}";
|
|
10214
10209
|
|
|
10215
|
-
var itemVert = "precision highp float;attribute vec2
|
|
10210
|
+
var itemVert = "precision highp float;attribute vec2 aUV;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(aUV.xy*_TexOffset.zw+_TexOffset.xy);vColor=_Color;vParams=vec3(texParams.w,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}";
|
|
10216
10211
|
|
|
10217
10212
|
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\nfloat halfX=vTexCoord.x*0.5;vec2 uv_rgb=vec2(halfX,vTexCoord.y);vec2 uv_alpha=vec2(halfX+0.5,vTexCoord.y);vec3 rgb=texture2D(_MainTex,uv_rgb).rgb;float alpha=max(texture2D(_MainTex,uv_alpha).r,1e-5);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(color.a<0.04){discard;}\n#endif\ncolor.a=clamp(color.a,0.0,1.0);gl_FragColor=color;}";
|
|
10218
10213
|
|
|
@@ -12448,6 +12443,15 @@ function getBezier2DValue(out, t, p0, p1, cpx0, cpy0, cpx1, cpy1) {
|
|
|
12448
12443
|
return out;
|
|
12449
12444
|
}
|
|
12450
12445
|
|
|
12446
|
+
var singleSplits = [
|
|
12447
|
+
[
|
|
12448
|
+
0,
|
|
12449
|
+
0,
|
|
12450
|
+
1,
|
|
12451
|
+
1,
|
|
12452
|
+
undefined
|
|
12453
|
+
]
|
|
12454
|
+
];
|
|
12451
12455
|
/**
|
|
12452
12456
|
* @since 2.1.0
|
|
12453
12457
|
*/ var BaseRenderComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
@@ -12455,11 +12459,12 @@ function getBezier2DValue(out, t, p0, p1, cpx0, cpy0, cpx1, cpy1) {
|
|
|
12455
12459
|
function BaseRenderComponent(engine) {
|
|
12456
12460
|
var _this;
|
|
12457
12461
|
_this = RendererComponent.call(this, engine) || this;
|
|
12458
|
-
_this.color = new Color(1, 1, 1, 1);
|
|
12459
12462
|
_this.visible = true;
|
|
12463
|
+
_this.splits = singleSplits;
|
|
12460
12464
|
/**
|
|
12461
12465
|
* 用于点击测试的碰撞器
|
|
12462
12466
|
*/ _this.meshCollider = new MeshCollider();
|
|
12467
|
+
_this._color = new Color(1, 1, 1, 1);
|
|
12463
12468
|
// TODO 点击测试后续抽象一个 Collider 组件
|
|
12464
12469
|
_this.getHitTestParams = function(force) {
|
|
12465
12470
|
var sizeMatrix = Matrix4.fromScale(_this.transform.size.x, _this.transform.size.y, 1);
|
|
@@ -12490,6 +12495,58 @@ function getBezier2DValue(out, t, p0, p1, cpx0, cpy0, cpx1, cpy1) {
|
|
|
12490
12495
|
mask: 0,
|
|
12491
12496
|
alphaMask: false
|
|
12492
12497
|
};
|
|
12498
|
+
_this.defaultGeometry = Geometry.create(_this.engine, {
|
|
12499
|
+
attributes: {
|
|
12500
|
+
aPos: {
|
|
12501
|
+
type: glContext.FLOAT,
|
|
12502
|
+
size: 3,
|
|
12503
|
+
data: new Float32Array([
|
|
12504
|
+
-0.5,
|
|
12505
|
+
0.5,
|
|
12506
|
+
0,
|
|
12507
|
+
-0.5,
|
|
12508
|
+
-0.5,
|
|
12509
|
+
0,
|
|
12510
|
+
0.5,
|
|
12511
|
+
0.5,
|
|
12512
|
+
0,
|
|
12513
|
+
0.5,
|
|
12514
|
+
-0.5,
|
|
12515
|
+
0
|
|
12516
|
+
])
|
|
12517
|
+
},
|
|
12518
|
+
aUV: {
|
|
12519
|
+
size: 2,
|
|
12520
|
+
offset: 0,
|
|
12521
|
+
releasable: true,
|
|
12522
|
+
type: glContext.FLOAT,
|
|
12523
|
+
data: new Float32Array([
|
|
12524
|
+
0,
|
|
12525
|
+
1,
|
|
12526
|
+
0,
|
|
12527
|
+
0,
|
|
12528
|
+
1,
|
|
12529
|
+
1,
|
|
12530
|
+
1,
|
|
12531
|
+
0
|
|
12532
|
+
])
|
|
12533
|
+
}
|
|
12534
|
+
},
|
|
12535
|
+
indices: {
|
|
12536
|
+
data: new Uint16Array([
|
|
12537
|
+
0,
|
|
12538
|
+
1,
|
|
12539
|
+
2,
|
|
12540
|
+
2,
|
|
12541
|
+
1,
|
|
12542
|
+
3
|
|
12543
|
+
]),
|
|
12544
|
+
releasable: true
|
|
12545
|
+
},
|
|
12546
|
+
mode: glContext.TRIANGLES,
|
|
12547
|
+
drawCount: 6
|
|
12548
|
+
});
|
|
12549
|
+
_this.geometry = _this.defaultGeometry;
|
|
12493
12550
|
var material = Material.create(_this.engine, {
|
|
12494
12551
|
shader: {
|
|
12495
12552
|
fragment: itemFrag,
|
|
@@ -12498,12 +12555,7 @@ function getBezier2DValue(out, t, p0, p1, cpx0, cpy0, cpx1, cpy1) {
|
|
|
12498
12555
|
}
|
|
12499
12556
|
});
|
|
12500
12557
|
_this.material = material;
|
|
12501
|
-
_this.material.setColor("_Color", new Color()
|
|
12502
|
-
1,
|
|
12503
|
-
1,
|
|
12504
|
-
1,
|
|
12505
|
-
1
|
|
12506
|
-
]));
|
|
12558
|
+
_this.material.setColor("_Color", new Color(1, 1, 1, 1));
|
|
12507
12559
|
_this.maskManager = new MaskProcessor(engine);
|
|
12508
12560
|
return _this;
|
|
12509
12561
|
}
|
|
@@ -12523,11 +12575,11 @@ function getBezier2DValue(out, t, p0, p1, cpx0, cpy0, cpx1, cpy1) {
|
|
|
12523
12575
|
};
|
|
12524
12576
|
_proto.setColor = function setColor(color) {
|
|
12525
12577
|
if (_instanceof1(color, Color)) {
|
|
12526
|
-
this.
|
|
12578
|
+
this._color.copyFrom(color);
|
|
12527
12579
|
} else {
|
|
12528
|
-
this.
|
|
12580
|
+
this._color.setFromArray(color);
|
|
12529
12581
|
}
|
|
12530
|
-
this.material.setColor("_Color", this.
|
|
12582
|
+
this.material.setColor("_Color", this._color);
|
|
12531
12583
|
};
|
|
12532
12584
|
_proto.setTexture = function setTexture(input) {
|
|
12533
12585
|
var _this = this;
|
|
@@ -12590,98 +12642,143 @@ function getBezier2DValue(out, t, p0, p1, cpx0, cpy0, cpx1, cpy1) {
|
|
|
12590
12642
|
var boundingBox = this.meshCollider.getBoundingBox();
|
|
12591
12643
|
return boundingBox;
|
|
12592
12644
|
};
|
|
12593
|
-
_proto.getItemGeometryData = function getItemGeometryData(
|
|
12594
|
-
var
|
|
12645
|
+
_proto.getItemGeometryData = function getItemGeometryData(renderer) {
|
|
12646
|
+
var _this = this, splits = _this.splits, textureSheetAnimation = _this.textureSheetAnimation;
|
|
12647
|
+
var sx = 1, sy = 1;
|
|
12648
|
+
var geometry = this.defaultGeometry;
|
|
12595
12649
|
if (renderer.shape) {
|
|
12596
12650
|
var _renderer_shape = renderer.shape, _renderer_shape_index = _renderer_shape.index, index = _renderer_shape_index === void 0 ? [] : _renderer_shape_index, _renderer_shape_aPoint = _renderer_shape.aPoint, aPoint = _renderer_shape_aPoint === void 0 ? [] : _renderer_shape_aPoint;
|
|
12597
12651
|
var point = new Float32Array(aPoint);
|
|
12598
12652
|
var position = [];
|
|
12599
|
-
var
|
|
12653
|
+
var aUV = [];
|
|
12600
12654
|
for(var i = 0; i < point.length; i += 6){
|
|
12601
|
-
|
|
12655
|
+
point[i] *= sx;
|
|
12656
|
+
point[i + 1] *= sy;
|
|
12657
|
+
aUV.push(aPoint[i + 2], aPoint[i + 3]);
|
|
12602
12658
|
position.push(point[i], point[i + 1], 0.0);
|
|
12603
12659
|
}
|
|
12604
12660
|
geometry.setAttributeData("aPos", new Float32Array(position));
|
|
12605
12661
|
return {
|
|
12606
12662
|
index: index,
|
|
12607
|
-
|
|
12663
|
+
aUV: aUV
|
|
12608
12664
|
};
|
|
12609
|
-
}
|
|
12610
|
-
|
|
12611
|
-
|
|
12612
|
-
|
|
12665
|
+
}
|
|
12666
|
+
var originData = [
|
|
12667
|
+
-.5,
|
|
12668
|
+
.5,
|
|
12669
|
+
-.5,
|
|
12670
|
+
-.5,
|
|
12671
|
+
.5,
|
|
12672
|
+
.5,
|
|
12673
|
+
.5,
|
|
12674
|
+
-.5
|
|
12675
|
+
];
|
|
12676
|
+
var aUV1 = [];
|
|
12677
|
+
var index1 = [];
|
|
12678
|
+
var position1 = [];
|
|
12679
|
+
if (splits.length === 1) {
|
|
12680
|
+
var split = textureSheetAnimation ? [
|
|
12613
12681
|
0,
|
|
12614
|
-
-0.5,
|
|
12615
|
-
-0.5,
|
|
12616
12682
|
0,
|
|
12617
|
-
|
|
12618
|
-
|
|
12683
|
+
1,
|
|
12684
|
+
1,
|
|
12685
|
+
splits[0][4]
|
|
12686
|
+
] : splits[0];
|
|
12687
|
+
var texOffset = split[4] ? [
|
|
12619
12688
|
0,
|
|
12620
|
-
0
|
|
12621
|
-
|
|
12689
|
+
0,
|
|
12690
|
+
1,
|
|
12691
|
+
0,
|
|
12692
|
+
0,
|
|
12693
|
+
1,
|
|
12694
|
+
1,
|
|
12695
|
+
1
|
|
12696
|
+
] : [
|
|
12697
|
+
0,
|
|
12698
|
+
1,
|
|
12699
|
+
0,
|
|
12700
|
+
0,
|
|
12701
|
+
1,
|
|
12702
|
+
1,
|
|
12703
|
+
1,
|
|
12622
12704
|
0
|
|
12623
|
-
]
|
|
12624
|
-
|
|
12625
|
-
|
|
12626
|
-
|
|
12627
|
-
|
|
12628
|
-
|
|
12629
|
-
|
|
12630
|
-
|
|
12631
|
-
|
|
12632
|
-
|
|
12633
|
-
|
|
12634
|
-
|
|
12635
|
-
|
|
12636
|
-
|
|
12637
|
-
|
|
12638
|
-
|
|
12639
|
-
|
|
12640
|
-
|
|
12641
|
-
0
|
|
12642
|
-
]
|
|
12643
|
-
};
|
|
12644
|
-
}
|
|
12645
|
-
};
|
|
12646
|
-
_proto.createGeometry = function createGeometry() {
|
|
12647
|
-
var geometry = Geometry.create(this.engine, {
|
|
12648
|
-
attributes: {
|
|
12649
|
-
aPos: {
|
|
12650
|
-
type: glContext.FLOAT,
|
|
12651
|
-
size: 3,
|
|
12652
|
-
data: new Float32Array([
|
|
12653
|
-
-0.5,
|
|
12654
|
-
0.5,
|
|
12705
|
+
];
|
|
12706
|
+
var tox = split[0];
|
|
12707
|
+
var toy = split[1];
|
|
12708
|
+
var tsx = split[4] ? split[3] : split[2];
|
|
12709
|
+
var tsy = split[4] ? split[2] : split[3];
|
|
12710
|
+
aUV1.push(texOffset[0] * tsx + tox, texOffset[1] * tsy + toy, texOffset[2] * tsx + tox, texOffset[3] * tsy + toy, texOffset[4] * tsx + tox, texOffset[5] * tsy + toy, texOffset[6] * tsx + tox, texOffset[7] * tsy + toy);
|
|
12711
|
+
position1.push(originData[0], originData[1], 0.0, originData[2], originData[3], 0.0, originData[4], originData[5], 0.0, originData[6], originData[7], 0.0);
|
|
12712
|
+
index1.push(0, 1, 2, 2, 1, 3);
|
|
12713
|
+
} else {
|
|
12714
|
+
// TODO: 原有打包纹理拆分逻辑,待移除
|
|
12715
|
+
//-------------------------------------------------------------------------
|
|
12716
|
+
var col = 2;
|
|
12717
|
+
var row = 2;
|
|
12718
|
+
for(var x = 0; x < col; x++){
|
|
12719
|
+
for(var y = 0; y < row; y++){
|
|
12720
|
+
var base = (y * 2 + x) * 4;
|
|
12721
|
+
// @ts-expect-error
|
|
12722
|
+
var split1 = textureSheetAnimation ? [
|
|
12655
12723
|
0,
|
|
12656
|
-
-0.5,
|
|
12657
|
-
-0.5,
|
|
12658
12724
|
0,
|
|
12659
|
-
|
|
12660
|
-
|
|
12725
|
+
1,
|
|
12726
|
+
1,
|
|
12727
|
+
splits[0][4]
|
|
12728
|
+
] : splits[y * 2 + x];
|
|
12729
|
+
var texOffset1 = split1[4] ? [
|
|
12661
12730
|
0,
|
|
12662
|
-
0
|
|
12663
|
-
|
|
12731
|
+
0,
|
|
12732
|
+
1,
|
|
12733
|
+
0,
|
|
12734
|
+
0,
|
|
12735
|
+
1,
|
|
12736
|
+
1,
|
|
12737
|
+
1
|
|
12738
|
+
] : [
|
|
12739
|
+
0,
|
|
12740
|
+
1,
|
|
12741
|
+
0,
|
|
12742
|
+
0,
|
|
12743
|
+
1,
|
|
12744
|
+
1,
|
|
12745
|
+
1,
|
|
12664
12746
|
0
|
|
12665
|
-
]
|
|
12666
|
-
|
|
12667
|
-
|
|
12668
|
-
|
|
12669
|
-
|
|
12670
|
-
|
|
12671
|
-
|
|
12672
|
-
|
|
12747
|
+
];
|
|
12748
|
+
var dw = ((x + x + 1) / col - 1) / 2;
|
|
12749
|
+
var dh = ((y + y + 1) / row - 1) / 2;
|
|
12750
|
+
var tox1 = split1[0];
|
|
12751
|
+
var toy1 = split1[1];
|
|
12752
|
+
var tsx1 = split1[4] ? split1[3] : split1[2];
|
|
12753
|
+
var tsy1 = split1[4] ? split1[2] : split1[3];
|
|
12754
|
+
var origin = [
|
|
12755
|
+
originData[0] / col + dw,
|
|
12756
|
+
originData[1] / row + dh,
|
|
12757
|
+
originData[2] / col + dw,
|
|
12758
|
+
originData[3] / row + dh,
|
|
12759
|
+
originData[4] / col + dw,
|
|
12760
|
+
originData[5] / row + dh,
|
|
12761
|
+
originData[6] / col + dw,
|
|
12762
|
+
originData[7] / row + dh
|
|
12763
|
+
];
|
|
12764
|
+
aUV1.push(texOffset1[0] * tsx1 + tox1, texOffset1[1] * tsy1 + toy1, texOffset1[2] * tsx1 + tox1, texOffset1[3] * tsy1 + toy1, texOffset1[4] * tsx1 + tox1, texOffset1[5] * tsy1 + toy1, texOffset1[6] * tsx1 + tox1, texOffset1[7] * tsy1 + toy1);
|
|
12765
|
+
position1.push(origin[0] * sx, origin[1] * sy, 0.0, origin[2] * sx, origin[3] * sy, 0.0, origin[4] * sx, origin[5] * sy, 0.0, origin[6] * sx, origin[7] * sy, 0.0);
|
|
12766
|
+
index1.push(base, 1 + base, 2 + base, 2 + base, 1 + base, 3 + base);
|
|
12673
12767
|
}
|
|
12674
|
-
}
|
|
12675
|
-
|
|
12676
|
-
|
|
12677
|
-
|
|
12678
|
-
|
|
12679
|
-
|
|
12680
|
-
}
|
|
12681
|
-
|
|
12682
|
-
|
|
12768
|
+
}
|
|
12769
|
+
}
|
|
12770
|
+
geometry.setAttributeData("aPos", new Float32Array(position1));
|
|
12771
|
+
return {
|
|
12772
|
+
index: index1,
|
|
12773
|
+
aUV: aUV1
|
|
12774
|
+
};
|
|
12775
|
+
};
|
|
12776
|
+
_proto.configureDefaultGeometry = function configureDefaultGeometry(renderer) {
|
|
12777
|
+
var geoData = this.getItemGeometryData(renderer);
|
|
12778
|
+
var index = geoData.index, aUV = geoData.aUV;
|
|
12779
|
+
var geometry = this.defaultGeometry;
|
|
12683
12780
|
geometry.setIndexData(new Uint16Array(index));
|
|
12684
|
-
geometry.setAttributeData("
|
|
12781
|
+
geometry.setAttributeData("aUV", new Float32Array(aUV));
|
|
12685
12782
|
geometry.setDrawCount(index.length);
|
|
12686
12783
|
return geometry;
|
|
12687
12784
|
};
|
|
@@ -12700,13 +12797,12 @@ function getBezier2DValue(out, t, p0, p1, cpx0, cpy0, cpx1, cpy1) {
|
|
|
12700
12797
|
setMaskMode(material, maskMode);
|
|
12701
12798
|
setSideMode(material, side);
|
|
12702
12799
|
material.shader.shaderData.properties = '_MainTex("_MainTex",2D) = "white" {}';
|
|
12703
|
-
material.setColor("_Color", new Color(0, 0, 0, 1));
|
|
12704
12800
|
material.setVector4("_TexOffset", new Vector4(0, 0, 1, 1));
|
|
12705
12801
|
material.setTexture("_MainTex", texture);
|
|
12706
|
-
|
|
12802
|
+
var preMultiAlpha = getPreMultiAlpha(blendMode);
|
|
12707
12803
|
var texParams = new Vector4();
|
|
12708
12804
|
texParams.x = renderer.occlusion ? +renderer.transparentOcclusion : 1;
|
|
12709
|
-
texParams.y =
|
|
12805
|
+
texParams.y = preMultiAlpha;
|
|
12710
12806
|
texParams.z = renderer.renderMode;
|
|
12711
12807
|
texParams.w = renderer.maskMode;
|
|
12712
12808
|
material.setVector4("_TexParams", texParams);
|
|
@@ -12732,8 +12828,11 @@ function getBezier2DValue(out, t, p0, p1, cpx0, cpy0, cpx1, cpy1) {
|
|
|
12732
12828
|
};
|
|
12733
12829
|
_proto.fromData = function fromData(data) {
|
|
12734
12830
|
RendererComponent.prototype.fromData.call(this, data);
|
|
12735
|
-
var
|
|
12736
|
-
var
|
|
12831
|
+
var baseRenderComponentData = data;
|
|
12832
|
+
var _baseRenderComponentData_renderer;
|
|
12833
|
+
var renderer = (_baseRenderComponentData_renderer = baseRenderComponentData.renderer) != null ? _baseRenderComponentData_renderer : {};
|
|
12834
|
+
var splits = baseRenderComponentData.splits;
|
|
12835
|
+
var textureSheetAnimation = baseRenderComponentData.textureSheetAnimation;
|
|
12737
12836
|
var maskProps = data.mask;
|
|
12738
12837
|
if (maskProps && maskProps.ref) {
|
|
12739
12838
|
maskProps.ref = this.engine.findObject(maskProps.ref);
|
|
@@ -12742,14 +12841,15 @@ function getBezier2DValue(out, t, p0, p1, cpx0, cpy0, cpx1, cpy1) {
|
|
|
12742
12841
|
// TODO 新蒙板上线后移除
|
|
12743
12842
|
//-------------------------------------------------------------------------
|
|
12744
12843
|
var shapeData = renderer.shape;
|
|
12745
|
-
|
|
12746
|
-
var split = data.splits && !data.textureSheetAnimation ? data.splits[0] : undefined;
|
|
12844
|
+
var split = splits && !textureSheetAnimation ? splits[0] : undefined;
|
|
12747
12845
|
var shapeGeometry = undefined;
|
|
12748
12846
|
if (shapeData !== undefined && shapeData !== null && !("aPoint" in shapeData && "index" in shapeData)) {
|
|
12749
12847
|
shapeGeometry = getGeometryByShape(shapeData, split);
|
|
12750
12848
|
}
|
|
12751
|
-
var _renderer_renderMode, _renderer_blending, _renderer_side, _renderer_alphaMask;
|
|
12752
12849
|
//-------------------------------------------------------------------------
|
|
12850
|
+
this.splits = splits || singleSplits;
|
|
12851
|
+
this.textureSheetAnimation = textureSheetAnimation;
|
|
12852
|
+
var _renderer_renderMode, _renderer_blending, _renderer_side, _renderer_alphaMask;
|
|
12753
12853
|
this.renderer = {
|
|
12754
12854
|
renderMode: (_renderer_renderMode = renderer.renderMode) != null ? _renderer_renderMode : RenderMode.MESH,
|
|
12755
12855
|
blending: (_renderer_blending = renderer.blending) != null ? _renderer_blending : BlendingMode.ALPHA,
|
|
@@ -12764,7 +12864,31 @@ function getBezier2DValue(out, t, p0, p1, cpx0, cpy0, cpx1, cpy1) {
|
|
|
12764
12864
|
alphaMask: (_renderer_alphaMask = renderer.alphaMask) != null ? _renderer_alphaMask : false
|
|
12765
12865
|
};
|
|
12766
12866
|
this.configureMaterial(this.renderer);
|
|
12867
|
+
if (baseRenderComponentData.geometry) {
|
|
12868
|
+
this.geometry = this.engine.findObject(baseRenderComponentData.geometry);
|
|
12869
|
+
} else {
|
|
12870
|
+
this.geometry = this.defaultGeometry;
|
|
12871
|
+
this.configureDefaultGeometry(this.renderer);
|
|
12872
|
+
}
|
|
12767
12873
|
};
|
|
12874
|
+
_create_class(BaseRenderComponent, [
|
|
12875
|
+
{
|
|
12876
|
+
key: "color",
|
|
12877
|
+
get: /**
|
|
12878
|
+
* 获取当前图层的颜色
|
|
12879
|
+
* @since 2.5.0
|
|
12880
|
+
*/ function get() {
|
|
12881
|
+
return this._color;
|
|
12882
|
+
},
|
|
12883
|
+
set: /**
|
|
12884
|
+
* 设置当前图层的颜色
|
|
12885
|
+
* @since 2.5.0
|
|
12886
|
+
*/ function set(value) {
|
|
12887
|
+
this._color = value;
|
|
12888
|
+
this.material.setColor("_Color", this._color);
|
|
12889
|
+
}
|
|
12890
|
+
}
|
|
12891
|
+
]);
|
|
12768
12892
|
return BaseRenderComponent;
|
|
12769
12893
|
}(RendererComponent);
|
|
12770
12894
|
|
|
@@ -12779,37 +12903,8 @@ exports.ShapeComponent = /*#__PURE__*/ function(BaseRenderComponent) {
|
|
|
12779
12903
|
_this.graphicsPath = new GraphicsPath();
|
|
12780
12904
|
_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";
|
|
12781
12905
|
_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";
|
|
12782
|
-
//
|
|
12906
|
+
// Add Geometry SubMesh
|
|
12783
12907
|
//-------------------------------------------------------------------------
|
|
12784
|
-
_this.geometry = Geometry.create(engine, {
|
|
12785
|
-
attributes: {
|
|
12786
|
-
aPos: {
|
|
12787
|
-
type: glContext.FLOAT,
|
|
12788
|
-
size: 3,
|
|
12789
|
-
data: new Float32Array([
|
|
12790
|
-
-0.5,
|
|
12791
|
-
0.5,
|
|
12792
|
-
0,
|
|
12793
|
-
-0.5,
|
|
12794
|
-
-0.5,
|
|
12795
|
-
0,
|
|
12796
|
-
0.5,
|
|
12797
|
-
0.5,
|
|
12798
|
-
0,
|
|
12799
|
-
0.5,
|
|
12800
|
-
-0.5,
|
|
12801
|
-
0
|
|
12802
|
-
])
|
|
12803
|
-
},
|
|
12804
|
-
aUV: {
|
|
12805
|
-
type: glContext.FLOAT,
|
|
12806
|
-
size: 2,
|
|
12807
|
-
data: new Float32Array()
|
|
12808
|
-
}
|
|
12809
|
-
},
|
|
12810
|
-
mode: glContext.TRIANGLES,
|
|
12811
|
-
drawCount: 4
|
|
12812
|
-
});
|
|
12813
12908
|
_this.geometry.subMeshes.push({
|
|
12814
12909
|
offset: 0,
|
|
12815
12910
|
indexCount: 0,
|
|
@@ -22634,15 +22729,6 @@ var ColorPlayable = /*#__PURE__*/ function(Playable) {
|
|
|
22634
22729
|
return ColorPlayable;
|
|
22635
22730
|
}(Playable);
|
|
22636
22731
|
|
|
22637
|
-
var singleSplits = [
|
|
22638
|
-
[
|
|
22639
|
-
0,
|
|
22640
|
-
0,
|
|
22641
|
-
1,
|
|
22642
|
-
1,
|
|
22643
|
-
undefined
|
|
22644
|
-
]
|
|
22645
|
-
];
|
|
22646
22732
|
var seed$2 = 0;
|
|
22647
22733
|
exports.SpriteColorPlayableAsset = /*#__PURE__*/ function(PlayableAsset) {
|
|
22648
22734
|
_inherits(SpriteColorPlayableAsset, PlayableAsset);
|
|
@@ -22668,10 +22754,8 @@ exports.SpriteComponent = /*#__PURE__*/ function(BaseRenderComponent) {
|
|
|
22668
22754
|
function SpriteComponent(engine, props) {
|
|
22669
22755
|
var _this;
|
|
22670
22756
|
_this = BaseRenderComponent.call(this, engine) || this;
|
|
22671
|
-
_this.splits = singleSplits;
|
|
22672
22757
|
_this.frameAnimationLoop = false;
|
|
22673
22758
|
_this.name = "MSprite" + seed$2++;
|
|
22674
|
-
_this.geometry = _this.createGeometry();
|
|
22675
22759
|
if (props) {
|
|
22676
22760
|
_this.fromData(props);
|
|
22677
22761
|
}
|
|
@@ -22761,111 +22845,10 @@ exports.SpriteComponent = /*#__PURE__*/ function(BaseRenderComponent) {
|
|
|
22761
22845
|
source.video.load();
|
|
22762
22846
|
}
|
|
22763
22847
|
};
|
|
22764
|
-
_proto.getItemGeometryData = function getItemGeometryData(geometry) {
|
|
22765
|
-
var _this = this, splits = _this.splits, textureSheetAnimation = _this.textureSheetAnimation;
|
|
22766
|
-
var sx = 1, sy = 1;
|
|
22767
|
-
var renderer = this.renderer;
|
|
22768
|
-
if (renderer.shape) {
|
|
22769
|
-
var _renderer_shape = renderer.shape, _renderer_shape_index = _renderer_shape.index, index = _renderer_shape_index === void 0 ? [] : _renderer_shape_index, _renderer_shape_aPoint = _renderer_shape.aPoint, aPoint = _renderer_shape_aPoint === void 0 ? [] : _renderer_shape_aPoint;
|
|
22770
|
-
var point = new Float32Array(aPoint);
|
|
22771
|
-
var position = [];
|
|
22772
|
-
var atlasOffset = [];
|
|
22773
|
-
for(var i = 0; i < point.length; i += 6){
|
|
22774
|
-
point[i] *= sx;
|
|
22775
|
-
point[i + 1] *= sy;
|
|
22776
|
-
atlasOffset.push(aPoint[i + 2], aPoint[i + 3]);
|
|
22777
|
-
position.push(point[i], point[i + 1], 0.0);
|
|
22778
|
-
}
|
|
22779
|
-
geometry.setAttributeData("aPos", new Float32Array(position));
|
|
22780
|
-
return {
|
|
22781
|
-
index: index,
|
|
22782
|
-
atlasOffset: atlasOffset
|
|
22783
|
-
};
|
|
22784
|
-
}
|
|
22785
|
-
var originData = [
|
|
22786
|
-
-.5,
|
|
22787
|
-
.5,
|
|
22788
|
-
-.5,
|
|
22789
|
-
-.5,
|
|
22790
|
-
.5,
|
|
22791
|
-
.5,
|
|
22792
|
-
.5,
|
|
22793
|
-
-.5
|
|
22794
|
-
];
|
|
22795
|
-
var atlasOffset1 = [];
|
|
22796
|
-
var index1 = [];
|
|
22797
|
-
var col = 2;
|
|
22798
|
-
var row = 2;
|
|
22799
|
-
if (splits.length === 1) {
|
|
22800
|
-
col = 1;
|
|
22801
|
-
row = 1;
|
|
22802
|
-
}
|
|
22803
|
-
var position1 = [];
|
|
22804
|
-
for(var x = 0; x < col; x++){
|
|
22805
|
-
for(var y = 0; y < row; y++){
|
|
22806
|
-
var base = (y * 2 + x) * 4;
|
|
22807
|
-
// @ts-expect-error
|
|
22808
|
-
var split = textureSheetAnimation ? [
|
|
22809
|
-
0,
|
|
22810
|
-
0,
|
|
22811
|
-
1,
|
|
22812
|
-
1,
|
|
22813
|
-
splits[0][4]
|
|
22814
|
-
] : splits[y * 2 + x];
|
|
22815
|
-
var texOffset = split[4] ? [
|
|
22816
|
-
0,
|
|
22817
|
-
0,
|
|
22818
|
-
1,
|
|
22819
|
-
0,
|
|
22820
|
-
0,
|
|
22821
|
-
1,
|
|
22822
|
-
1,
|
|
22823
|
-
1
|
|
22824
|
-
] : [
|
|
22825
|
-
0,
|
|
22826
|
-
1,
|
|
22827
|
-
0,
|
|
22828
|
-
0,
|
|
22829
|
-
1,
|
|
22830
|
-
1,
|
|
22831
|
-
1,
|
|
22832
|
-
0
|
|
22833
|
-
];
|
|
22834
|
-
var dw = ((x + x + 1) / col - 1) / 2;
|
|
22835
|
-
var dh = ((y + y + 1) / row - 1) / 2;
|
|
22836
|
-
var tox = split[0];
|
|
22837
|
-
var toy = split[1];
|
|
22838
|
-
var tsx = split[4] ? split[3] : split[2];
|
|
22839
|
-
var tsy = split[4] ? split[2] : split[3];
|
|
22840
|
-
var origin = [
|
|
22841
|
-
originData[0] / col + dw,
|
|
22842
|
-
originData[1] / row + dh,
|
|
22843
|
-
originData[2] / col + dw,
|
|
22844
|
-
originData[3] / row + dh,
|
|
22845
|
-
originData[4] / col + dw,
|
|
22846
|
-
originData[5] / row + dh,
|
|
22847
|
-
originData[6] / col + dw,
|
|
22848
|
-
originData[7] / row + dh
|
|
22849
|
-
];
|
|
22850
|
-
atlasOffset1.push(texOffset[0] * tsx + tox, texOffset[1] * tsy + toy, texOffset[2] * tsx + tox, texOffset[3] * tsy + toy, texOffset[4] * tsx + tox, texOffset[5] * tsy + toy, texOffset[6] * tsx + tox, texOffset[7] * tsy + toy);
|
|
22851
|
-
position1.push(origin[0] * sx, origin[1] * sy, 0.0, origin[2] * sx, origin[3] * sy, 0.0, origin[4] * sx, origin[5] * sy, 0.0, origin[6] * sx, origin[7] * sy, 0.0);
|
|
22852
|
-
index1.push(base, 1 + base, 2 + base, 2 + base, 1 + base, 3 + base);
|
|
22853
|
-
}
|
|
22854
|
-
}
|
|
22855
|
-
geometry.setAttributeData("aPos", new Float32Array(position1));
|
|
22856
|
-
return {
|
|
22857
|
-
index: index1,
|
|
22858
|
-
atlasOffset: atlasOffset1
|
|
22859
|
-
};
|
|
22860
|
-
};
|
|
22861
22848
|
_proto.fromData = function fromData(data) {
|
|
22862
22849
|
BaseRenderComponent.prototype.fromData.call(this, data);
|
|
22863
22850
|
var interaction = data.interaction, options = data.options;
|
|
22864
22851
|
this.interaction = interaction;
|
|
22865
|
-
this.splits = data.splits || singleSplits;
|
|
22866
|
-
this.textureSheetAnimation = data.textureSheetAnimation;
|
|
22867
|
-
var geometry = this.createGeometry();
|
|
22868
|
-
this.geometry = geometry;
|
|
22869
22852
|
var startColor = options.startColor || [
|
|
22870
22853
|
1,
|
|
22871
22854
|
1,
|
|
@@ -26144,7 +26127,6 @@ exports.TextComponent = /*#__PURE__*/ function(BaseRenderComponent) {
|
|
|
26144
26127
|
_this.SCALE_FACTOR = 0.1;
|
|
26145
26128
|
_this.ALPHA_FIX_VALUE = 1 / 255;
|
|
26146
26129
|
_this.name = "MText" + seed$1++;
|
|
26147
|
-
_this.geometry = _this.createGeometry();
|
|
26148
26130
|
if (props) {
|
|
26149
26131
|
_this.fromData(props);
|
|
26150
26132
|
}
|
|
@@ -27025,11 +27007,6 @@ function colorToArr(hex, normalized) {
|
|
|
27025
27007
|
parseInt(m[2], 16),
|
|
27026
27008
|
parseInt(m[3], 16),
|
|
27027
27009
|
255
|
|
27028
|
-
] || [
|
|
27029
|
-
0,
|
|
27030
|
-
0,
|
|
27031
|
-
0,
|
|
27032
|
-
255
|
|
27033
27010
|
];
|
|
27034
27011
|
}
|
|
27035
27012
|
} else if (_instanceof1(hex, Array)) {
|
|
@@ -31628,7 +31605,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem);
|
|
|
31628
31605
|
registerPlugin("particle", ParticleLoader, exports.VFXItem);
|
|
31629
31606
|
registerPlugin("cal", CalculateLoader, exports.VFXItem);
|
|
31630
31607
|
registerPlugin("interact", InteractLoader, exports.VFXItem);
|
|
31631
|
-
var version = "2.
|
|
31608
|
+
var version = "2.5.0-alpha.0";
|
|
31632
31609
|
logger.info("Core version: " + version + ".");
|
|
31633
31610
|
|
|
31634
31611
|
exports.AbstractPlugin = AbstractPlugin;
|