@galacean/effects-threejs 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/index.js +223 -246
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +2 -2
- package/dist/index.min.js.map +1 -1
- package/dist/index.mjs +223 -246
- package/dist/index.mjs.map +1 -1
- package/dist/three-sprite-component.d.ts +3 -3
- package/dist/three-text-component.d.ts +2 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Description: Galacean Effects runtime threejs plugin for the web
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
|
|
6
|
-
* Version: v2.
|
|
6
|
+
* Version: v2.5.0-alpha.0
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
@@ -367,11 +367,6 @@ function colorToArr$1(hex, normalized) {
|
|
|
367
367
|
parseInt(m[2], 16),
|
|
368
368
|
parseInt(m[3], 16),
|
|
369
369
|
255
|
|
370
|
-
] || [
|
|
371
|
-
0,
|
|
372
|
-
0,
|
|
373
|
-
0,
|
|
374
|
-
255
|
|
375
370
|
];
|
|
376
371
|
}
|
|
377
372
|
} else if (_instanceof1(hex, Array)) {
|
|
@@ -10234,7 +10229,7 @@ var itemFrame_frag = "#version 100\nprecision highp float;vec4 blendColor(vec4 c
|
|
|
10234
10229
|
|
|
10235
10230
|
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.;}";
|
|
10236
10231
|
|
|
10237
|
-
var itemVert = "precision highp float;attribute vec2
|
|
10232
|
+
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}";
|
|
10238
10233
|
|
|
10239
10234
|
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;}";
|
|
10240
10235
|
|
|
@@ -12470,6 +12465,15 @@ function getBezier2DValue(out, t, p0, p1, cpx0, cpy0, cpx1, cpy1) {
|
|
|
12470
12465
|
return out;
|
|
12471
12466
|
}
|
|
12472
12467
|
|
|
12468
|
+
var singleSplits = [
|
|
12469
|
+
[
|
|
12470
|
+
0,
|
|
12471
|
+
0,
|
|
12472
|
+
1,
|
|
12473
|
+
1,
|
|
12474
|
+
undefined
|
|
12475
|
+
]
|
|
12476
|
+
];
|
|
12473
12477
|
/**
|
|
12474
12478
|
* @since 2.1.0
|
|
12475
12479
|
*/ var BaseRenderComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
@@ -12477,11 +12481,12 @@ function getBezier2DValue(out, t, p0, p1, cpx0, cpy0, cpx1, cpy1) {
|
|
|
12477
12481
|
function BaseRenderComponent(engine) {
|
|
12478
12482
|
var _this;
|
|
12479
12483
|
_this = RendererComponent.call(this, engine) || this;
|
|
12480
|
-
_this.color = new Color(1, 1, 1, 1);
|
|
12481
12484
|
_this.visible = true;
|
|
12485
|
+
_this.splits = singleSplits;
|
|
12482
12486
|
/**
|
|
12483
12487
|
* 用于点击测试的碰撞器
|
|
12484
12488
|
*/ _this.meshCollider = new MeshCollider();
|
|
12489
|
+
_this._color = new Color(1, 1, 1, 1);
|
|
12485
12490
|
// TODO 点击测试后续抽象一个 Collider 组件
|
|
12486
12491
|
_this.getHitTestParams = function(force) {
|
|
12487
12492
|
var sizeMatrix = Matrix4.fromScale(_this.transform.size.x, _this.transform.size.y, 1);
|
|
@@ -12512,6 +12517,58 @@ function getBezier2DValue(out, t, p0, p1, cpx0, cpy0, cpx1, cpy1) {
|
|
|
12512
12517
|
mask: 0,
|
|
12513
12518
|
alphaMask: false
|
|
12514
12519
|
};
|
|
12520
|
+
_this.defaultGeometry = Geometry.create(_this.engine, {
|
|
12521
|
+
attributes: {
|
|
12522
|
+
aPos: {
|
|
12523
|
+
type: glContext.FLOAT,
|
|
12524
|
+
size: 3,
|
|
12525
|
+
data: new Float32Array([
|
|
12526
|
+
-0.5,
|
|
12527
|
+
0.5,
|
|
12528
|
+
0,
|
|
12529
|
+
-0.5,
|
|
12530
|
+
-0.5,
|
|
12531
|
+
0,
|
|
12532
|
+
0.5,
|
|
12533
|
+
0.5,
|
|
12534
|
+
0,
|
|
12535
|
+
0.5,
|
|
12536
|
+
-0.5,
|
|
12537
|
+
0
|
|
12538
|
+
])
|
|
12539
|
+
},
|
|
12540
|
+
aUV: {
|
|
12541
|
+
size: 2,
|
|
12542
|
+
offset: 0,
|
|
12543
|
+
releasable: true,
|
|
12544
|
+
type: glContext.FLOAT,
|
|
12545
|
+
data: new Float32Array([
|
|
12546
|
+
0,
|
|
12547
|
+
1,
|
|
12548
|
+
0,
|
|
12549
|
+
0,
|
|
12550
|
+
1,
|
|
12551
|
+
1,
|
|
12552
|
+
1,
|
|
12553
|
+
0
|
|
12554
|
+
])
|
|
12555
|
+
}
|
|
12556
|
+
},
|
|
12557
|
+
indices: {
|
|
12558
|
+
data: new Uint16Array([
|
|
12559
|
+
0,
|
|
12560
|
+
1,
|
|
12561
|
+
2,
|
|
12562
|
+
2,
|
|
12563
|
+
1,
|
|
12564
|
+
3
|
|
12565
|
+
]),
|
|
12566
|
+
releasable: true
|
|
12567
|
+
},
|
|
12568
|
+
mode: glContext.TRIANGLES,
|
|
12569
|
+
drawCount: 6
|
|
12570
|
+
});
|
|
12571
|
+
_this.geometry = _this.defaultGeometry;
|
|
12515
12572
|
var material = Material.create(_this.engine, {
|
|
12516
12573
|
shader: {
|
|
12517
12574
|
fragment: itemFrag,
|
|
@@ -12520,12 +12577,7 @@ function getBezier2DValue(out, t, p0, p1, cpx0, cpy0, cpx1, cpy1) {
|
|
|
12520
12577
|
}
|
|
12521
12578
|
});
|
|
12522
12579
|
_this.material = material;
|
|
12523
|
-
_this.material.setColor("_Color", new Color()
|
|
12524
|
-
1,
|
|
12525
|
-
1,
|
|
12526
|
-
1,
|
|
12527
|
-
1
|
|
12528
|
-
]));
|
|
12580
|
+
_this.material.setColor("_Color", new Color(1, 1, 1, 1));
|
|
12529
12581
|
_this.maskManager = new MaskProcessor(engine);
|
|
12530
12582
|
return _this;
|
|
12531
12583
|
}
|
|
@@ -12545,11 +12597,11 @@ function getBezier2DValue(out, t, p0, p1, cpx0, cpy0, cpx1, cpy1) {
|
|
|
12545
12597
|
};
|
|
12546
12598
|
_proto.setColor = function setColor(color) {
|
|
12547
12599
|
if (_instanceof1(color, Color)) {
|
|
12548
|
-
this.
|
|
12600
|
+
this._color.copyFrom(color);
|
|
12549
12601
|
} else {
|
|
12550
|
-
this.
|
|
12602
|
+
this._color.setFromArray(color);
|
|
12551
12603
|
}
|
|
12552
|
-
this.material.setColor("_Color", this.
|
|
12604
|
+
this.material.setColor("_Color", this._color);
|
|
12553
12605
|
};
|
|
12554
12606
|
_proto.setTexture = function setTexture(input) {
|
|
12555
12607
|
var _this = this;
|
|
@@ -12612,98 +12664,143 @@ function getBezier2DValue(out, t, p0, p1, cpx0, cpy0, cpx1, cpy1) {
|
|
|
12612
12664
|
var boundingBox = this.meshCollider.getBoundingBox();
|
|
12613
12665
|
return boundingBox;
|
|
12614
12666
|
};
|
|
12615
|
-
_proto.getItemGeometryData = function getItemGeometryData(
|
|
12616
|
-
var
|
|
12667
|
+
_proto.getItemGeometryData = function getItemGeometryData(renderer) {
|
|
12668
|
+
var _this = this, splits = _this.splits, textureSheetAnimation = _this.textureSheetAnimation;
|
|
12669
|
+
var sx = 1, sy = 1;
|
|
12670
|
+
var geometry = this.defaultGeometry;
|
|
12617
12671
|
if (renderer.shape) {
|
|
12618
12672
|
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;
|
|
12619
12673
|
var point = new Float32Array(aPoint);
|
|
12620
12674
|
var position = [];
|
|
12621
|
-
var
|
|
12675
|
+
var aUV = [];
|
|
12622
12676
|
for(var i = 0; i < point.length; i += 6){
|
|
12623
|
-
|
|
12677
|
+
point[i] *= sx;
|
|
12678
|
+
point[i + 1] *= sy;
|
|
12679
|
+
aUV.push(aPoint[i + 2], aPoint[i + 3]);
|
|
12624
12680
|
position.push(point[i], point[i + 1], 0.0);
|
|
12625
12681
|
}
|
|
12626
12682
|
geometry.setAttributeData("aPos", new Float32Array(position));
|
|
12627
12683
|
return {
|
|
12628
12684
|
index: index,
|
|
12629
|
-
|
|
12685
|
+
aUV: aUV
|
|
12630
12686
|
};
|
|
12631
|
-
}
|
|
12632
|
-
|
|
12633
|
-
|
|
12634
|
-
|
|
12687
|
+
}
|
|
12688
|
+
var originData = [
|
|
12689
|
+
-.5,
|
|
12690
|
+
.5,
|
|
12691
|
+
-.5,
|
|
12692
|
+
-.5,
|
|
12693
|
+
.5,
|
|
12694
|
+
.5,
|
|
12695
|
+
.5,
|
|
12696
|
+
-.5
|
|
12697
|
+
];
|
|
12698
|
+
var aUV1 = [];
|
|
12699
|
+
var index1 = [];
|
|
12700
|
+
var position1 = [];
|
|
12701
|
+
if (splits.length === 1) {
|
|
12702
|
+
var split = textureSheetAnimation ? [
|
|
12635
12703
|
0,
|
|
12636
|
-
-0.5,
|
|
12637
|
-
-0.5,
|
|
12638
12704
|
0,
|
|
12639
|
-
|
|
12640
|
-
|
|
12705
|
+
1,
|
|
12706
|
+
1,
|
|
12707
|
+
splits[0][4]
|
|
12708
|
+
] : splits[0];
|
|
12709
|
+
var texOffset = split[4] ? [
|
|
12641
12710
|
0,
|
|
12642
|
-
0
|
|
12643
|
-
|
|
12711
|
+
0,
|
|
12712
|
+
1,
|
|
12713
|
+
0,
|
|
12714
|
+
0,
|
|
12715
|
+
1,
|
|
12716
|
+
1,
|
|
12717
|
+
1
|
|
12718
|
+
] : [
|
|
12719
|
+
0,
|
|
12720
|
+
1,
|
|
12721
|
+
0,
|
|
12722
|
+
0,
|
|
12723
|
+
1,
|
|
12724
|
+
1,
|
|
12725
|
+
1,
|
|
12644
12726
|
0
|
|
12645
|
-
]
|
|
12646
|
-
|
|
12647
|
-
|
|
12648
|
-
|
|
12649
|
-
|
|
12650
|
-
|
|
12651
|
-
|
|
12652
|
-
|
|
12653
|
-
|
|
12654
|
-
|
|
12655
|
-
|
|
12656
|
-
|
|
12657
|
-
|
|
12658
|
-
|
|
12659
|
-
|
|
12660
|
-
|
|
12661
|
-
|
|
12662
|
-
|
|
12663
|
-
0
|
|
12664
|
-
]
|
|
12665
|
-
};
|
|
12666
|
-
}
|
|
12667
|
-
};
|
|
12668
|
-
_proto.createGeometry = function createGeometry() {
|
|
12669
|
-
var geometry = Geometry.create(this.engine, {
|
|
12670
|
-
attributes: {
|
|
12671
|
-
aPos: {
|
|
12672
|
-
type: glContext.FLOAT,
|
|
12673
|
-
size: 3,
|
|
12674
|
-
data: new Float32Array([
|
|
12675
|
-
-0.5,
|
|
12676
|
-
0.5,
|
|
12727
|
+
];
|
|
12728
|
+
var tox = split[0];
|
|
12729
|
+
var toy = split[1];
|
|
12730
|
+
var tsx = split[4] ? split[3] : split[2];
|
|
12731
|
+
var tsy = split[4] ? split[2] : split[3];
|
|
12732
|
+
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);
|
|
12733
|
+
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);
|
|
12734
|
+
index1.push(0, 1, 2, 2, 1, 3);
|
|
12735
|
+
} else {
|
|
12736
|
+
// TODO: 原有打包纹理拆分逻辑,待移除
|
|
12737
|
+
//-------------------------------------------------------------------------
|
|
12738
|
+
var col = 2;
|
|
12739
|
+
var row = 2;
|
|
12740
|
+
for(var x = 0; x < col; x++){
|
|
12741
|
+
for(var y = 0; y < row; y++){
|
|
12742
|
+
var base = (y * 2 + x) * 4;
|
|
12743
|
+
// @ts-expect-error
|
|
12744
|
+
var split1 = textureSheetAnimation ? [
|
|
12677
12745
|
0,
|
|
12678
|
-
-0.5,
|
|
12679
|
-
-0.5,
|
|
12680
12746
|
0,
|
|
12681
|
-
|
|
12682
|
-
|
|
12747
|
+
1,
|
|
12748
|
+
1,
|
|
12749
|
+
splits[0][4]
|
|
12750
|
+
] : splits[y * 2 + x];
|
|
12751
|
+
var texOffset1 = split1[4] ? [
|
|
12683
12752
|
0,
|
|
12684
|
-
0
|
|
12685
|
-
|
|
12753
|
+
0,
|
|
12754
|
+
1,
|
|
12755
|
+
0,
|
|
12756
|
+
0,
|
|
12757
|
+
1,
|
|
12758
|
+
1,
|
|
12759
|
+
1
|
|
12760
|
+
] : [
|
|
12761
|
+
0,
|
|
12762
|
+
1,
|
|
12763
|
+
0,
|
|
12764
|
+
0,
|
|
12765
|
+
1,
|
|
12766
|
+
1,
|
|
12767
|
+
1,
|
|
12686
12768
|
0
|
|
12687
|
-
]
|
|
12688
|
-
|
|
12689
|
-
|
|
12690
|
-
|
|
12691
|
-
|
|
12692
|
-
|
|
12693
|
-
|
|
12694
|
-
|
|
12769
|
+
];
|
|
12770
|
+
var dw = ((x + x + 1) / col - 1) / 2;
|
|
12771
|
+
var dh = ((y + y + 1) / row - 1) / 2;
|
|
12772
|
+
var tox1 = split1[0];
|
|
12773
|
+
var toy1 = split1[1];
|
|
12774
|
+
var tsx1 = split1[4] ? split1[3] : split1[2];
|
|
12775
|
+
var tsy1 = split1[4] ? split1[2] : split1[3];
|
|
12776
|
+
var origin = [
|
|
12777
|
+
originData[0] / col + dw,
|
|
12778
|
+
originData[1] / row + dh,
|
|
12779
|
+
originData[2] / col + dw,
|
|
12780
|
+
originData[3] / row + dh,
|
|
12781
|
+
originData[4] / col + dw,
|
|
12782
|
+
originData[5] / row + dh,
|
|
12783
|
+
originData[6] / col + dw,
|
|
12784
|
+
originData[7] / row + dh
|
|
12785
|
+
];
|
|
12786
|
+
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);
|
|
12787
|
+
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);
|
|
12788
|
+
index1.push(base, 1 + base, 2 + base, 2 + base, 1 + base, 3 + base);
|
|
12695
12789
|
}
|
|
12696
|
-
}
|
|
12697
|
-
|
|
12698
|
-
|
|
12699
|
-
|
|
12700
|
-
|
|
12701
|
-
|
|
12702
|
-
}
|
|
12703
|
-
|
|
12704
|
-
|
|
12790
|
+
}
|
|
12791
|
+
}
|
|
12792
|
+
geometry.setAttributeData("aPos", new Float32Array(position1));
|
|
12793
|
+
return {
|
|
12794
|
+
index: index1,
|
|
12795
|
+
aUV: aUV1
|
|
12796
|
+
};
|
|
12797
|
+
};
|
|
12798
|
+
_proto.configureDefaultGeometry = function configureDefaultGeometry(renderer) {
|
|
12799
|
+
var geoData = this.getItemGeometryData(renderer);
|
|
12800
|
+
var index = geoData.index, aUV = geoData.aUV;
|
|
12801
|
+
var geometry = this.defaultGeometry;
|
|
12705
12802
|
geometry.setIndexData(new Uint16Array(index));
|
|
12706
|
-
geometry.setAttributeData("
|
|
12803
|
+
geometry.setAttributeData("aUV", new Float32Array(aUV));
|
|
12707
12804
|
geometry.setDrawCount(index.length);
|
|
12708
12805
|
return geometry;
|
|
12709
12806
|
};
|
|
@@ -12722,13 +12819,12 @@ function getBezier2DValue(out, t, p0, p1, cpx0, cpy0, cpx1, cpy1) {
|
|
|
12722
12819
|
setMaskMode(material, maskMode);
|
|
12723
12820
|
setSideMode(material, side);
|
|
12724
12821
|
material.shader.shaderData.properties = '_MainTex("_MainTex",2D) = "white" {}';
|
|
12725
|
-
material.setColor("_Color", new Color(0, 0, 0, 1));
|
|
12726
12822
|
material.setVector4("_TexOffset", new Vector4(0, 0, 1, 1));
|
|
12727
12823
|
material.setTexture("_MainTex", texture);
|
|
12728
|
-
|
|
12824
|
+
var preMultiAlpha = getPreMultiAlpha(blendMode);
|
|
12729
12825
|
var texParams = new Vector4();
|
|
12730
12826
|
texParams.x = renderer.occlusion ? +renderer.transparentOcclusion : 1;
|
|
12731
|
-
texParams.y =
|
|
12827
|
+
texParams.y = preMultiAlpha;
|
|
12732
12828
|
texParams.z = renderer.renderMode;
|
|
12733
12829
|
texParams.w = renderer.maskMode;
|
|
12734
12830
|
material.setVector4("_TexParams", texParams);
|
|
@@ -12754,8 +12850,11 @@ function getBezier2DValue(out, t, p0, p1, cpx0, cpy0, cpx1, cpy1) {
|
|
|
12754
12850
|
};
|
|
12755
12851
|
_proto.fromData = function fromData(data) {
|
|
12756
12852
|
RendererComponent.prototype.fromData.call(this, data);
|
|
12757
|
-
var
|
|
12758
|
-
var
|
|
12853
|
+
var baseRenderComponentData = data;
|
|
12854
|
+
var _baseRenderComponentData_renderer;
|
|
12855
|
+
var renderer = (_baseRenderComponentData_renderer = baseRenderComponentData.renderer) != null ? _baseRenderComponentData_renderer : {};
|
|
12856
|
+
var splits = baseRenderComponentData.splits;
|
|
12857
|
+
var textureSheetAnimation = baseRenderComponentData.textureSheetAnimation;
|
|
12759
12858
|
var maskProps = data.mask;
|
|
12760
12859
|
if (maskProps && maskProps.ref) {
|
|
12761
12860
|
maskProps.ref = this.engine.findObject(maskProps.ref);
|
|
@@ -12764,14 +12863,15 @@ function getBezier2DValue(out, t, p0, p1, cpx0, cpy0, cpx1, cpy1) {
|
|
|
12764
12863
|
// TODO 新蒙板上线后移除
|
|
12765
12864
|
//-------------------------------------------------------------------------
|
|
12766
12865
|
var shapeData = renderer.shape;
|
|
12767
|
-
|
|
12768
|
-
var split = data.splits && !data.textureSheetAnimation ? data.splits[0] : undefined;
|
|
12866
|
+
var split = splits && !textureSheetAnimation ? splits[0] : undefined;
|
|
12769
12867
|
var shapeGeometry = undefined;
|
|
12770
12868
|
if (shapeData !== undefined && shapeData !== null && !("aPoint" in shapeData && "index" in shapeData)) {
|
|
12771
12869
|
shapeGeometry = getGeometryByShape(shapeData, split);
|
|
12772
12870
|
}
|
|
12773
|
-
var _renderer_renderMode, _renderer_blending, _renderer_side, _renderer_alphaMask;
|
|
12774
12871
|
//-------------------------------------------------------------------------
|
|
12872
|
+
this.splits = splits || singleSplits;
|
|
12873
|
+
this.textureSheetAnimation = textureSheetAnimation;
|
|
12874
|
+
var _renderer_renderMode, _renderer_blending, _renderer_side, _renderer_alphaMask;
|
|
12775
12875
|
this.renderer = {
|
|
12776
12876
|
renderMode: (_renderer_renderMode = renderer.renderMode) != null ? _renderer_renderMode : RenderMode.MESH,
|
|
12777
12877
|
blending: (_renderer_blending = renderer.blending) != null ? _renderer_blending : BlendingMode.ALPHA,
|
|
@@ -12786,7 +12886,31 @@ function getBezier2DValue(out, t, p0, p1, cpx0, cpy0, cpx1, cpy1) {
|
|
|
12786
12886
|
alphaMask: (_renderer_alphaMask = renderer.alphaMask) != null ? _renderer_alphaMask : false
|
|
12787
12887
|
};
|
|
12788
12888
|
this.configureMaterial(this.renderer);
|
|
12889
|
+
if (baseRenderComponentData.geometry) {
|
|
12890
|
+
this.geometry = this.engine.findObject(baseRenderComponentData.geometry);
|
|
12891
|
+
} else {
|
|
12892
|
+
this.geometry = this.defaultGeometry;
|
|
12893
|
+
this.configureDefaultGeometry(this.renderer);
|
|
12894
|
+
}
|
|
12789
12895
|
};
|
|
12896
|
+
_create_class(BaseRenderComponent, [
|
|
12897
|
+
{
|
|
12898
|
+
key: "color",
|
|
12899
|
+
get: /**
|
|
12900
|
+
* 获取当前图层的颜色
|
|
12901
|
+
* @since 2.5.0
|
|
12902
|
+
*/ function get() {
|
|
12903
|
+
return this._color;
|
|
12904
|
+
},
|
|
12905
|
+
set: /**
|
|
12906
|
+
* 设置当前图层的颜色
|
|
12907
|
+
* @since 2.5.0
|
|
12908
|
+
*/ function set(value) {
|
|
12909
|
+
this._color = value;
|
|
12910
|
+
this.material.setColor("_Color", this._color);
|
|
12911
|
+
}
|
|
12912
|
+
}
|
|
12913
|
+
]);
|
|
12790
12914
|
return BaseRenderComponent;
|
|
12791
12915
|
}(RendererComponent);
|
|
12792
12916
|
|
|
@@ -12801,37 +12925,8 @@ exports.ShapeComponent = /*#__PURE__*/ function(BaseRenderComponent) {
|
|
|
12801
12925
|
_this.graphicsPath = new GraphicsPath();
|
|
12802
12926
|
_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";
|
|
12803
12927
|
_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";
|
|
12804
|
-
//
|
|
12928
|
+
// Add Geometry SubMesh
|
|
12805
12929
|
//-------------------------------------------------------------------------
|
|
12806
|
-
_this.geometry = Geometry.create(engine, {
|
|
12807
|
-
attributes: {
|
|
12808
|
-
aPos: {
|
|
12809
|
-
type: glContext.FLOAT,
|
|
12810
|
-
size: 3,
|
|
12811
|
-
data: new Float32Array([
|
|
12812
|
-
-0.5,
|
|
12813
|
-
0.5,
|
|
12814
|
-
0,
|
|
12815
|
-
-0.5,
|
|
12816
|
-
-0.5,
|
|
12817
|
-
0,
|
|
12818
|
-
0.5,
|
|
12819
|
-
0.5,
|
|
12820
|
-
0,
|
|
12821
|
-
0.5,
|
|
12822
|
-
-0.5,
|
|
12823
|
-
0
|
|
12824
|
-
])
|
|
12825
|
-
},
|
|
12826
|
-
aUV: {
|
|
12827
|
-
type: glContext.FLOAT,
|
|
12828
|
-
size: 2,
|
|
12829
|
-
data: new Float32Array()
|
|
12830
|
-
}
|
|
12831
|
-
},
|
|
12832
|
-
mode: glContext.TRIANGLES,
|
|
12833
|
-
drawCount: 4
|
|
12834
|
-
});
|
|
12835
12930
|
_this.geometry.subMeshes.push({
|
|
12836
12931
|
offset: 0,
|
|
12837
12932
|
indexCount: 0,
|
|
@@ -22656,15 +22751,6 @@ var ColorPlayable = /*#__PURE__*/ function(Playable) {
|
|
|
22656
22751
|
return ColorPlayable;
|
|
22657
22752
|
}(Playable);
|
|
22658
22753
|
|
|
22659
|
-
var singleSplits = [
|
|
22660
|
-
[
|
|
22661
|
-
0,
|
|
22662
|
-
0,
|
|
22663
|
-
1,
|
|
22664
|
-
1,
|
|
22665
|
-
undefined
|
|
22666
|
-
]
|
|
22667
|
-
];
|
|
22668
22754
|
var seed$3 = 0;
|
|
22669
22755
|
exports.SpriteColorPlayableAsset = /*#__PURE__*/ function(PlayableAsset) {
|
|
22670
22756
|
_inherits(SpriteColorPlayableAsset, PlayableAsset);
|
|
@@ -22690,10 +22776,8 @@ exports.SpriteComponent = /*#__PURE__*/ function(BaseRenderComponent) {
|
|
|
22690
22776
|
function SpriteComponent(engine, props) {
|
|
22691
22777
|
var _this;
|
|
22692
22778
|
_this = BaseRenderComponent.call(this, engine) || this;
|
|
22693
|
-
_this.splits = singleSplits;
|
|
22694
22779
|
_this.frameAnimationLoop = false;
|
|
22695
22780
|
_this.name = "MSprite" + seed$3++;
|
|
22696
|
-
_this.geometry = _this.createGeometry();
|
|
22697
22781
|
if (props) {
|
|
22698
22782
|
_this.fromData(props);
|
|
22699
22783
|
}
|
|
@@ -22783,111 +22867,10 @@ exports.SpriteComponent = /*#__PURE__*/ function(BaseRenderComponent) {
|
|
|
22783
22867
|
source.video.load();
|
|
22784
22868
|
}
|
|
22785
22869
|
};
|
|
22786
|
-
_proto.getItemGeometryData = function getItemGeometryData(geometry) {
|
|
22787
|
-
var _this = this, splits = _this.splits, textureSheetAnimation = _this.textureSheetAnimation;
|
|
22788
|
-
var sx = 1, sy = 1;
|
|
22789
|
-
var renderer = this.renderer;
|
|
22790
|
-
if (renderer.shape) {
|
|
22791
|
-
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;
|
|
22792
|
-
var point = new Float32Array(aPoint);
|
|
22793
|
-
var position = [];
|
|
22794
|
-
var atlasOffset = [];
|
|
22795
|
-
for(var i = 0; i < point.length; i += 6){
|
|
22796
|
-
point[i] *= sx;
|
|
22797
|
-
point[i + 1] *= sy;
|
|
22798
|
-
atlasOffset.push(aPoint[i + 2], aPoint[i + 3]);
|
|
22799
|
-
position.push(point[i], point[i + 1], 0.0);
|
|
22800
|
-
}
|
|
22801
|
-
geometry.setAttributeData("aPos", new Float32Array(position));
|
|
22802
|
-
return {
|
|
22803
|
-
index: index,
|
|
22804
|
-
atlasOffset: atlasOffset
|
|
22805
|
-
};
|
|
22806
|
-
}
|
|
22807
|
-
var originData = [
|
|
22808
|
-
-.5,
|
|
22809
|
-
.5,
|
|
22810
|
-
-.5,
|
|
22811
|
-
-.5,
|
|
22812
|
-
.5,
|
|
22813
|
-
.5,
|
|
22814
|
-
.5,
|
|
22815
|
-
-.5
|
|
22816
|
-
];
|
|
22817
|
-
var atlasOffset1 = [];
|
|
22818
|
-
var index1 = [];
|
|
22819
|
-
var col = 2;
|
|
22820
|
-
var row = 2;
|
|
22821
|
-
if (splits.length === 1) {
|
|
22822
|
-
col = 1;
|
|
22823
|
-
row = 1;
|
|
22824
|
-
}
|
|
22825
|
-
var position1 = [];
|
|
22826
|
-
for(var x = 0; x < col; x++){
|
|
22827
|
-
for(var y = 0; y < row; y++){
|
|
22828
|
-
var base = (y * 2 + x) * 4;
|
|
22829
|
-
// @ts-expect-error
|
|
22830
|
-
var split = textureSheetAnimation ? [
|
|
22831
|
-
0,
|
|
22832
|
-
0,
|
|
22833
|
-
1,
|
|
22834
|
-
1,
|
|
22835
|
-
splits[0][4]
|
|
22836
|
-
] : splits[y * 2 + x];
|
|
22837
|
-
var texOffset = split[4] ? [
|
|
22838
|
-
0,
|
|
22839
|
-
0,
|
|
22840
|
-
1,
|
|
22841
|
-
0,
|
|
22842
|
-
0,
|
|
22843
|
-
1,
|
|
22844
|
-
1,
|
|
22845
|
-
1
|
|
22846
|
-
] : [
|
|
22847
|
-
0,
|
|
22848
|
-
1,
|
|
22849
|
-
0,
|
|
22850
|
-
0,
|
|
22851
|
-
1,
|
|
22852
|
-
1,
|
|
22853
|
-
1,
|
|
22854
|
-
0
|
|
22855
|
-
];
|
|
22856
|
-
var dw = ((x + x + 1) / col - 1) / 2;
|
|
22857
|
-
var dh = ((y + y + 1) / row - 1) / 2;
|
|
22858
|
-
var tox = split[0];
|
|
22859
|
-
var toy = split[1];
|
|
22860
|
-
var tsx = split[4] ? split[3] : split[2];
|
|
22861
|
-
var tsy = split[4] ? split[2] : split[3];
|
|
22862
|
-
var origin = [
|
|
22863
|
-
originData[0] / col + dw,
|
|
22864
|
-
originData[1] / row + dh,
|
|
22865
|
-
originData[2] / col + dw,
|
|
22866
|
-
originData[3] / row + dh,
|
|
22867
|
-
originData[4] / col + dw,
|
|
22868
|
-
originData[5] / row + dh,
|
|
22869
|
-
originData[6] / col + dw,
|
|
22870
|
-
originData[7] / row + dh
|
|
22871
|
-
];
|
|
22872
|
-
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);
|
|
22873
|
-
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);
|
|
22874
|
-
index1.push(base, 1 + base, 2 + base, 2 + base, 1 + base, 3 + base);
|
|
22875
|
-
}
|
|
22876
|
-
}
|
|
22877
|
-
geometry.setAttributeData("aPos", new Float32Array(position1));
|
|
22878
|
-
return {
|
|
22879
|
-
index: index1,
|
|
22880
|
-
atlasOffset: atlasOffset1
|
|
22881
|
-
};
|
|
22882
|
-
};
|
|
22883
22870
|
_proto.fromData = function fromData(data) {
|
|
22884
22871
|
BaseRenderComponent.prototype.fromData.call(this, data);
|
|
22885
22872
|
var interaction = data.interaction, options = data.options;
|
|
22886
22873
|
this.interaction = interaction;
|
|
22887
|
-
this.splits = data.splits || singleSplits;
|
|
22888
|
-
this.textureSheetAnimation = data.textureSheetAnimation;
|
|
22889
|
-
var geometry = this.createGeometry();
|
|
22890
|
-
this.geometry = geometry;
|
|
22891
22874
|
var startColor = options.startColor || [
|
|
22892
22875
|
1,
|
|
22893
22876
|
1,
|
|
@@ -26166,7 +26149,6 @@ exports.TextComponent = /*#__PURE__*/ function(BaseRenderComponent) {
|
|
|
26166
26149
|
_this.SCALE_FACTOR = 0.1;
|
|
26167
26150
|
_this.ALPHA_FIX_VALUE = 1 / 255;
|
|
26168
26151
|
_this.name = "MText" + seed$2++;
|
|
26169
|
-
_this.geometry = _this.createGeometry();
|
|
26170
26152
|
if (props) {
|
|
26171
26153
|
_this.fromData(props);
|
|
26172
26154
|
}
|
|
@@ -27047,11 +27029,6 @@ function colorToArr(hex, normalized) {
|
|
|
27047
27029
|
parseInt(m[2], 16),
|
|
27048
27030
|
parseInt(m[3], 16),
|
|
27049
27031
|
255
|
|
27050
|
-
] || [
|
|
27051
|
-
0,
|
|
27052
|
-
0,
|
|
27053
|
-
0,
|
|
27054
|
-
255
|
|
27055
27032
|
];
|
|
27056
27033
|
}
|
|
27057
27034
|
} else if (_instanceof1(hex, Array)) {
|
|
@@ -31650,7 +31627,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem);
|
|
|
31650
31627
|
registerPlugin("particle", ParticleLoader, exports.VFXItem);
|
|
31651
31628
|
registerPlugin("cal", CalculateLoader, exports.VFXItem);
|
|
31652
31629
|
registerPlugin("interact", InteractLoader, exports.VFXItem);
|
|
31653
|
-
var version$1 = "2.
|
|
31630
|
+
var version$1 = "2.5.0-alpha.0";
|
|
31654
31631
|
logger.info("Core version: " + version$1 + ".");
|
|
31655
31632
|
|
|
31656
31633
|
var _obj;
|
|
@@ -33252,7 +33229,7 @@ setMaxSpriteMeshItemCount(8);
|
|
|
33252
33229
|
*/ Mesh.create = function(engine, props) {
|
|
33253
33230
|
return new ThreeMesh(engine, props);
|
|
33254
33231
|
};
|
|
33255
|
-
var version = "2.
|
|
33232
|
+
var version = "2.5.0-alpha.0";
|
|
33256
33233
|
logger.info("THREEJS plugin version: " + version + ".");
|
|
33257
33234
|
|
|
33258
33235
|
exports.AbstractPlugin = AbstractPlugin;
|