@galacean/effects-threejs 2.1.0-alpha.0 → 2.1.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +349 -46
- 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 +349 -46
- package/dist/index.mjs.map +1 -1
- 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.1.0-alpha.
|
|
6
|
+
* Version: v2.1.0-alpha.2
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
@@ -4711,7 +4711,13 @@ function getDirectStore(target) {
|
|
|
4711
4711
|
}
|
|
4712
4712
|
};
|
|
4713
4713
|
_proto.dispose = function dispose() {
|
|
4714
|
-
this.
|
|
4714
|
+
if (this.isEnableCalled) {
|
|
4715
|
+
this.disable();
|
|
4716
|
+
}
|
|
4717
|
+
if (this.isAwakeCalled) {
|
|
4718
|
+
this.isAwakeCalled = false;
|
|
4719
|
+
this.onDestroy();
|
|
4720
|
+
}
|
|
4715
4721
|
if (this.item) {
|
|
4716
4722
|
removeItem(this.item.components, this);
|
|
4717
4723
|
}
|
|
@@ -8368,7 +8374,7 @@ var seed$9 = 1;
|
|
|
8368
8374
|
* 通过 URL 创建 Texture 对象。
|
|
8369
8375
|
* @param url - 要创建的 Texture URL
|
|
8370
8376
|
* @since 2.0.0
|
|
8371
|
-
*/ Texture.fromImage = function fromImage(url, engine) {
|
|
8377
|
+
*/ Texture.fromImage = function fromImage(url, engine, options) {
|
|
8372
8378
|
return _async_to_generator(function() {
|
|
8373
8379
|
var image, texture;
|
|
8374
8380
|
return __generator(this, function(_state) {
|
|
@@ -8380,12 +8386,13 @@ var seed$9 = 1;
|
|
|
8380
8386
|
];
|
|
8381
8387
|
case 1:
|
|
8382
8388
|
image = _state.sent();
|
|
8383
|
-
texture = Texture.create(engine, {
|
|
8389
|
+
texture = Texture.create(engine, _extends({
|
|
8384
8390
|
sourceType: exports.TextureSourceType.image,
|
|
8385
8391
|
image: image,
|
|
8392
|
+
target: glContext.TEXTURE_2D,
|
|
8386
8393
|
id: generateGUID(),
|
|
8387
8394
|
flipY: true
|
|
8388
|
-
});
|
|
8395
|
+
}, options));
|
|
8389
8396
|
texture.initialize();
|
|
8390
8397
|
return [
|
|
8391
8398
|
2,
|
|
@@ -10052,8 +10059,13 @@ var RandomValue = /*#__PURE__*/ function(ValueGetter) {
|
|
|
10052
10059
|
this.min = props[0];
|
|
10053
10060
|
this.max = props[1];
|
|
10054
10061
|
};
|
|
10055
|
-
_proto.getValue = function getValue(time) {
|
|
10056
|
-
|
|
10062
|
+
_proto.getValue = function getValue(time, seed) {
|
|
10063
|
+
var randomSeed = seed != null ? seed : Math.random();
|
|
10064
|
+
return this.min + randomSeed * (this.max - this.min);
|
|
10065
|
+
};
|
|
10066
|
+
_proto.getIntegrateValue = function getIntegrateValue(t0, t1, timeScale) {
|
|
10067
|
+
var seed = timeScale != null ? timeScale : 1.0;
|
|
10068
|
+
return (this.min + seed * (this.max - this.min)) * (t1 - t0);
|
|
10057
10069
|
};
|
|
10058
10070
|
_proto.toUniform = function toUniform() {
|
|
10059
10071
|
return new Float32Array([
|
|
@@ -10312,15 +10324,19 @@ var BezierCurve = /*#__PURE__*/ function(ValueGetter) {
|
|
|
10312
10324
|
points: points,
|
|
10313
10325
|
timeInterval: timeInterval,
|
|
10314
10326
|
valueInterval: valueInterval,
|
|
10315
|
-
curve: curve
|
|
10327
|
+
curve: curve,
|
|
10328
|
+
timeStart: Number(s.x),
|
|
10329
|
+
timeEnd: Number(e.x)
|
|
10316
10330
|
};
|
|
10317
10331
|
}
|
|
10318
10332
|
};
|
|
10319
10333
|
_proto.getValue = function getValue(time) {
|
|
10320
10334
|
var result = 0;
|
|
10321
10335
|
var keyTimeData = Object.keys(this.curveMap);
|
|
10322
|
-
var keyTimeStart =
|
|
10323
|
-
var keyTimeEnd =
|
|
10336
|
+
var keyTimeStart = this.curveMap[keyTimeData[0]].timeStart;
|
|
10337
|
+
var keyTimeEnd = this.curveMap[keyTimeData[keyTimeData.length - 1]].timeEnd;
|
|
10338
|
+
// const keyTimeStart = Number(keyTimeData[0].split('&')[0]);
|
|
10339
|
+
// const keyTimeEnd = Number(keyTimeData[keyTimeData.length - 1].split('&')[1]);
|
|
10324
10340
|
if (time <= keyTimeStart) {
|
|
10325
10341
|
return this.getCurveValue(keyTimeData[0], keyTimeStart);
|
|
10326
10342
|
}
|
|
@@ -10328,7 +10344,9 @@ var BezierCurve = /*#__PURE__*/ function(ValueGetter) {
|
|
|
10328
10344
|
return this.getCurveValue(keyTimeData[keyTimeData.length - 1], keyTimeEnd);
|
|
10329
10345
|
}
|
|
10330
10346
|
for(var i = 0; i < keyTimeData.length; i++){
|
|
10331
|
-
var
|
|
10347
|
+
var xMin = this.curveMap[keyTimeData[i]].timeStart;
|
|
10348
|
+
var xMax = this.curveMap[keyTimeData[i]].timeEnd;
|
|
10349
|
+
// const [xMin, xMax] = keyTimeData[i].split('&');
|
|
10332
10350
|
if (time >= Number(xMin) && time < Number(xMax)) {
|
|
10333
10351
|
result = this.getCurveValue(keyTimeData[i], time);
|
|
10334
10352
|
break;
|
|
@@ -10341,12 +10359,13 @@ var BezierCurve = /*#__PURE__*/ function(ValueGetter) {
|
|
|
10341
10359
|
var time = (t1 - t0) / ts;
|
|
10342
10360
|
var result = 0;
|
|
10343
10361
|
var keyTimeData = Object.keys(this.curveMap);
|
|
10344
|
-
var keyTimeStart =
|
|
10362
|
+
var keyTimeStart = this.curveMap[keyTimeData[0]].timeStart;
|
|
10345
10363
|
if (time <= keyTimeStart) {
|
|
10346
10364
|
return 0;
|
|
10347
10365
|
}
|
|
10348
10366
|
for(var i = 0; i < keyTimeData.length; i++){
|
|
10349
|
-
var
|
|
10367
|
+
var xMin = this.curveMap[keyTimeData[i]].timeStart;
|
|
10368
|
+
var xMax = this.curveMap[keyTimeData[i]].timeEnd;
|
|
10350
10369
|
if (time >= Number(xMax)) {
|
|
10351
10370
|
result += ts * this.getCurveIntegrateValue(keyTimeData[i], Number(xMax));
|
|
10352
10371
|
}
|
|
@@ -11580,7 +11599,7 @@ var itemFrag = "precision highp float;varying vec4 vColor;varying vec2 vTexCoord
|
|
|
11580
11599
|
|
|
11581
11600
|
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";
|
|
11582
11601
|
|
|
11583
|
-
var particleVert = "#version 100\nprecision mediump float;\n#define SHADER_VERTEX 1\n#define PATICLE_SHADER 1\n#ifdef SHADER_VERTEX\n#define CURVE_VALUE_TEXTURE uVCurveValueTexture\n#define CURVE_VALUE_ARRAY uVCurveValues\n#define CURVE_VALUE_COUNT VERT_CURVE_VALUE_COUNT\n#define FRAG_CURVE_VALUE_COUNT 0\n#else\n#define CURVE_VALUE_TEXTURE uFCurveValueTexture\n#define CURVE_VALUE_ARRAY uFCurveValues\n#define CURVE_VALUE_COUNT FRAG_CURVE_VALUE_COUNT\n#define VERT_CURVE_VALUE_COUNT 0\n#endif\n#if CURVE_VALUE_COUNT > 0\n#if LOOKUP_TEXTURE_CURVE\nuniform sampler2D CURVE_VALUE_TEXTURE;const float uCurveCount=1./float(CURVE_VALUE_COUNT);\n#define lookup_curve(i) texture2D(CURVE_VALUE_TEXTURE,vec2(float(i) * uCurveCount,0.))\n#else\nuniform vec4 CURVE_VALUE_ARRAY[CURVE_VALUE_COUNT];\n#define lookup_curve(i) CURVE_VALUE_ARRAY[i]\n#endif\n#else\n#define lookup_curve(i) vec4(0.)\n#endif\n#ifdef WEBGL2\n#define ITR_END (count + 1)\n#else\n#define ITR_END MAX_C\n#endif\n#define NONE_CONST_INDEX 1\n#ifdef SHADER_VERTEX\nattribute float aSeed;varying float vSeed;\n#endif\n#ifdef SHADER_VERTEX\n#define MAX_C VERT_MAX_KEY_FRAME_COUNT\n#else\n#define MAX_C FRAG_MAX_KEY_FRAME_COUNT\n#endif\nmat4 cubicBezierMatrix=mat4(1.0,-3.0,3.0,-1.0,0.0,3.0,-6.0,3.0,0.0,0.0,3.0,-3.0,0.0,0.0,0.0,1.0);float cubicBezier(float t,float y1,float y2,float y3,float y4){vec4 tVec=vec4(1.0,t,t*t,t*t*t);vec4 yVec=vec4(y1,y2,y3,y4);vec4 result=tVec*cubicBezierMatrix*yVec;return result.x+result.y+result.z+result.w;}float binarySearchT(float x,float x1,float x2,float x3,float x4){float left=0.0;float right=1.0;float mid=0.0;float computedX;for(int i=0;i<8;i++){mid=(left+right)*0.5;computedX=cubicBezier(mid,x1,x2,x3,x4);if(abs(computedX-x)<0.0001){break;}else if(computedX>x){right=mid;}else{left=mid;}}return mid;}float valueFromBezierCurveFrames(float time,float frameStart,float frameCount){int start=int(frameStart);int count=int(frameCount-1.);for(int i=0;i<ITR_END;i+=2){if(i>=count){break;}vec4 k0=lookup_curve(i+start);vec4 k1=lookup_curve(i+1+start);if(i==0&&time<k0.x){return k0.y;}if(i==int(frameCount-2.)&&time>=k1.x){return k1.y;}if(time>=k0.x&&time<=k1.x){float t=(time-k0.x)/(k1.x-k0.x);float nt=binarySearchT(time,k0.x,k0.z,k1.z,k1.x);return cubicBezier(nt,k0.y,k0.w,k1.w,k1.y);}}}float evaluteLineSeg(float t,vec2 p0,vec2 p1){return p0.y+(p1.y-p0.y)*(t-p0.x)/(p1.x-p0.x);}float valueFromLineSegs(float time,float frameStart,float frameCount){int start=int(frameStart);int count=int(frameCount-1.);int end=start+count;for(int i=0;i<ITR_END;i++){if(i>count){return lookup_curve(i).w;}vec4 seg=lookup_curve(i+start);vec2 p0=seg.xy;vec2 p1=seg.zw;if(time>=p0.x&&time<=p1.x){return evaluteLineSeg(time,p0,p1);}vec2 p2=lookup_curve(i+start+1).xy;if(time>p1.x&&time<=p2.x){return evaluteLineSeg(time,p1,p2);}}return lookup_curve(0).y;}float getValueFromTime(float time,vec4 value){float type=value.x;if(type==0.){return value.y;}if(type==1.){return mix(value.y,value.z,time/value.w);}if(type==3.){return valueFromLineSegs(time,value.y,value.z);}if(type==4.){return mix(value.y,value.z,aSeed);}if(type==5.){return valueFromBezierCurveFrames(time,value.z,value.w);}return 0.;}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.;}const float d2r=3.141592653589793/180.;attribute vec3 aPos;attribute vec4 aOffset;attribute vec3 aVel;attribute vec3 aRot;attribute vec4 aColor;attribute vec3 aDirX;attribute vec3 aDirY;\n#ifdef USE_SPRITE\nattribute vec3 aSprite;uniform vec4 uSprite;struct UVDetail{vec2 uv0;vec3 uv1;};UVDetail getSpriteUV(vec2 uv,float lifeTime);varying vec4 vTexCoordBlend;\n#endif\n#ifdef FINAL_TARGET\nuniform vec3 uFinalTarget;uniform vec4 uForceCurve;\n#endif\nuniform mat4 effects_ObjectToWorld;uniform mat4 effects_MatrixV;uniform mat4 effects_MatrixVP;uniform vec4 uParams;uniform vec4 uAcceleration;uniform vec4 uGravityModifierValue;uniform vec4 uOpacityOverLifetimeValue;\n#ifdef ROT_X_LIFETIME\nuniform vec4 uRXByLifeTimeValue;\n#endif\n#ifdef ROT_Y_LIFETIME\nuniform vec4 uRYByLifeTimeValue;\n#endif\n#ifdef ROT_Z_LIFETIME\nuniform vec4 uRZByLifeTimeValue;\n#endif\n#ifdef COLOR_OVER_LIFETIME\nuniform sampler2D uColorOverLifetime;\n#endif\n#if LINEAR_VEL_X + LINEAR_VEL_Y + LINEAR_VEL_Z\n#if LINEAR_VEL_X\nuniform vec4 uLinearXByLifetimeValue;\n#endif\n#if LINEAR_VEL_Y\nuniform vec4 uLinearYByLifetimeValue;\n#endif\n#if LINEAR_VEL_Z\nuniform vec4 uLinearZByLifetimeValue;\n#endif\n#endif\n#ifdef SPEED_OVER_LIFETIME\nuniform vec4 uSpeedLifetimeValue;\n#endif\n#if ORB_VEL_X + ORB_VEL_Y + ORB_VEL_Z\n#if ORB_VEL_X\nuniform vec4 uOrbXByLifetimeValue;\n#endif\n#if ORB_VEL_Y\nuniform vec4 uOrbYByLifetimeValue;\n#endif\n#if ORB_VEL_Z\nuniform vec4 uOrbZByLifetimeValue;\n#endif\nuniform vec3 uOrbCenter;\n#endif\nuniform vec4 uSizeByLifetimeValue;\n#ifdef SIZE_Y_BY_LIFE\nuniform vec4 uSizeYByLifetimeValue;\n#endif\nvarying float vLife;varying vec4 vColor;varying vec2 vTexCoord;\n#ifdef ENV_EDITOR\nuniform vec4 uEditorTransform;\n#endif\nvec3 calOrbitalMov(float _life,float _dur){vec3 orb=vec3(0.0);\n#ifdef AS_ORBITAL_MOVEMENT\n#define FUNC(a) getValueFromTime(_life,a)\n#else\n#define FUNC(a) getIntegrateFromTime0(_life,a) * _dur\n#endif\n#if ORB_VEL_X\norb.x=FUNC(uOrbXByLifetimeValue);\n#endif\n#if ORB_VEL_Y\norb.y=FUNC(uOrbYByLifetimeValue);\n#endif\n#if ORB_VEL_Z\norb.z=FUNC(uOrbZByLifetimeValue);\n#endif\n#undef FUNC\nreturn orb;}vec3 calLinearMov(float _life,float _dur){vec3 mov=vec3(0.0);\n#ifdef AS_LINEAR_MOVEMENT\n#define FUNC(a) getValueFromTime(_life,a)\n#else\n#define FUNC(a) getIntegrateFromTime0(_life,a) * _dur\n#endif\n#if LINEAR_VEL_X\nmov.x=FUNC(uLinearXByLifetimeValue);\n#endif\n#if LINEAR_VEL_Y\nmov.y=FUNC(uLinearYByLifetimeValue);\n#endif\n#if LINEAR_VEL_Z\nmov.z=FUNC(uLinearZByLifetimeValue);\n#endif\n#undef FUNC\nreturn mov;}mat3 mat3FromRotation(vec3 rotation){vec3 sinR=sin(rotation*d2r);vec3 cosR=cos(rotation*d2r);return mat3(cosR.z,-sinR.z,0.,sinR.z,cosR.z,0.,0.,0.,1.)*mat3(cosR.y,0.,sinR.y,0.,1.,0.,-sinR.y,0,cosR.y)*mat3(1.,0.,0.,0,cosR.x,-sinR.x,0.,sinR.x,cosR.x);}\n#ifdef USE_SPRITE\nUVDetail getSpriteUV(vec2 uv,float lifeTime){float t=fract(clamp((lifeTime-aSprite.x)/aSprite.y,0.0,1.)*aSprite.z);float frame=uSprite.z*t;float frameIndex=max(ceil(frame)-1.,0.);float row=floor((frameIndex+0.1)/uSprite.x);float col=frameIndex-row*uSprite.x;vec2 retUV=(vec2(col,row)+uv)/uSprite.xy;UVDetail ret;if(uSprite.w>0.){float blend=frame-frameIndex;float frameIndex1=min(ceil(frame),uSprite.z-1.);float row1=floor((frameIndex1+0.1)/uSprite.x);float col1=frameIndex1-row1*uSprite.x;vec2 coord=(vec2(col1,row1)+uv)/uSprite.xy-retUV;ret.uv1=vec3(coord.x,1.-coord.y,blend);}ret.uv0=vec2(retUV.x,1.-retUV.y);return ret;}\n#endif\nvec3 calculateTranslation(vec3 vel,float t0,float t1,float dur){float dt=t1-t0;float d=getIntegrateByTimeFromTime(0.,dt,uGravityModifierValue);vec3 acc=uAcceleration.xyz*d;\n#ifdef SPEED_OVER_LIFETIME\nreturn vel*getIntegrateFromTime0(dt/dur,uSpeedLifetimeValue)*dur+acc;\n#endif\nreturn vel*dt+acc;}mat3 transformFromRotation(vec3 rot,float _life,float _dur){vec3 rotation=rot;\n#ifdef ROT_LIFETIME_AS_MOVEMENT\n#define FUNC1(a) getValueFromTime(_life,a)\n#else\n#define FUNC1(a) getIntegrateFromTime0(_life,a) * _dur\n#endif\n#ifdef ROT_X_LIFETIME\nrotation.x+=FUNC1(uRXByLifeTimeValue);\n#endif\n#ifdef ROT_Y_LIFETIME\nrotation.y+=FUNC1(uRYByLifeTimeValue);\n#endif\n#ifdef ROT_Z_LIFETIME\nrotation.z+=FUNC1(uRZByLifeTimeValue);\n#endif\nif(dot(rotation,rotation)==0.0){return mat3(1.0);}\n#undef FUNC1\nreturn mat3FromRotation(rotation);}void main(){float time=uParams.x-aOffset.z;float dur=aOffset.w;if(time<0.||time>dur){gl_Position=vec4(-3.,-3.,-3.,1.);}else{float life=clamp(time/dur,0.0,1.0);vLife=life;\n#ifdef USE_SPRITE\nUVDetail uvD=getSpriteUV(aOffset.xy,time);vTexCoord=uvD.uv0;vTexCoordBlend=vec4(uvD.uv1,uSprite.w);\n#else\nvTexCoord=aOffset.xy;\n#endif\nvColor=aColor;\n#ifdef COLOR_OVER_LIFETIME\n#ifdef ENABLE_VERTEX_TEXTURE\nvColor*=texture2D(uColorOverLifetime,vec2(life,0.));\n#endif\n#endif\nvColor.a*=clamp(getValueFromTime(life,uOpacityOverLifetimeValue),0.,1.);vec3 size=vec3(vec2(getValueFromTime(life,uSizeByLifetimeValue)),1.0);\n#ifdef SIZE_Y_BY_LIFE\nsize.y=getValueFromTime(life,uSizeYByLifetimeValue);\n#endif\nvec3 point=transformFromRotation(aRot,life,dur)*(aDirX*size.x+aDirY*size.y);vec3 pt=calculateTranslation(aVel,aOffset.z,uParams.x,dur);vec3 _pos=aPos+pt;\n#if ORB_VEL_X + ORB_VEL_Y + ORB_VEL_Z\n_pos=mat3FromRotation(calOrbitalMov(life,dur))*(_pos-uOrbCenter);_pos+=uOrbCenter;\n#endif\n#if LINEAR_VEL_X + LINEAR_VEL_Y + LINEAR_VEL_Z\n_pos.xyz+=calLinearMov(life,dur);\n#endif\n#ifdef FINAL_TARGET\nfloat force=getValueFromTime(life,uForceCurve);vec4 pos=vec4(mix(_pos,uFinalTarget,force),1.);\n#else\nvec4 pos=vec4(_pos,1.0);\n#endif\n#if RENDER_MODE == 1\npos.xyz+=point;pos=effects_ObjectToWorld*pos;\n#elif RENDER_MODE == 3\npos=effects_ObjectToWorld*pos;pos.xyz+=effects_MatrixV[0].xyz*point.x+effects_MatrixV[2].xyz*point.y;\n#elif RENDER_MODE == 2\npos=effects_ObjectToWorld*pos;pos.xy+=point.xy;\n#elif RENDER_MODE == 0\npos=effects_ObjectToWorld*pos;pos.xyz+=effects_MatrixV[0].xyz*point.x+effects_MatrixV[1].xyz*point.y;\n#endif\ngl_Position=effects_MatrixVP*pos;vSeed=aSeed;gl_PointSize=6.0;\n#ifdef ENV_EDITOR\ngl_Position=vec4(gl_Position.xy*uEditorTransform.xy+uEditorTransform.zw*gl_Position.w,gl_Position.zw);\n#endif\n}}";
|
|
11602
|
+
var particleVert = "#version 100\nprecision mediump float;\n#define SHADER_VERTEX 1\n#define PATICLE_SHADER 1\n#ifdef SHADER_VERTEX\n#define CURVE_VALUE_TEXTURE uVCurveValueTexture\n#define CURVE_VALUE_ARRAY uVCurveValues\n#define CURVE_VALUE_COUNT VERT_CURVE_VALUE_COUNT\n#define FRAG_CURVE_VALUE_COUNT 0\n#else\n#define CURVE_VALUE_TEXTURE uFCurveValueTexture\n#define CURVE_VALUE_ARRAY uFCurveValues\n#define CURVE_VALUE_COUNT FRAG_CURVE_VALUE_COUNT\n#define VERT_CURVE_VALUE_COUNT 0\n#endif\n#if CURVE_VALUE_COUNT > 0\n#if LOOKUP_TEXTURE_CURVE\nuniform sampler2D CURVE_VALUE_TEXTURE;const float uCurveCount=1./float(CURVE_VALUE_COUNT);\n#define lookup_curve(i) texture2D(CURVE_VALUE_TEXTURE,vec2(float(i) * uCurveCount,0.))\n#else\nuniform vec4 CURVE_VALUE_ARRAY[CURVE_VALUE_COUNT];\n#define lookup_curve(i) CURVE_VALUE_ARRAY[i]\n#endif\n#else\n#define lookup_curve(i) vec4(0.)\n#endif\n#ifdef WEBGL2\n#define ITR_END (count + 1)\n#else\n#define ITR_END MAX_C\n#endif\n#define NONE_CONST_INDEX 1\n#ifdef SHADER_VERTEX\nattribute float aSeed;varying float vSeed;\n#endif\n#ifdef SHADER_VERTEX\n#define MAX_C VERT_MAX_KEY_FRAME_COUNT\n#else\n#define MAX_C FRAG_MAX_KEY_FRAME_COUNT\n#endif\nmat4 cubicBezierMatrix=mat4(1.0,-3.0,3.0,-1.0,0.0,3.0,-6.0,3.0,0.0,0.0,3.0,-3.0,0.0,0.0,0.0,1.0);float cubicBezier(float t,float y1,float y2,float y3,float y4){vec4 tVec=vec4(1.0,t,t*t,t*t*t);vec4 yVec=vec4(y1,y2,y3,y4);vec4 result=tVec*cubicBezierMatrix*yVec;return result.x+result.y+result.z+result.w;}float binarySearchT(float x,float x1,float x2,float x3,float x4){float left=0.0;float right=1.0;float mid=0.0;float computedX;for(int i=0;i<8;i++){mid=(left+right)*0.5;computedX=cubicBezier(mid,x1,x2,x3,x4);if(abs(computedX-x)<0.0001){break;}else if(computedX>x){right=mid;}else{left=mid;}}return mid;}float valueFromBezierCurveFrames(float time,float frameStart,float frameCount){int start=int(frameStart);int count=int(frameCount-1.);for(int i=0;i<ITR_END;i+=2){if(i>=count){break;}vec4 k0=lookup_curve(i+start);vec4 k1=lookup_curve(i+1+start);if(i==0&&time<k0.x){return k0.y;}if(i==int(frameCount-2.)&&time>=k1.x){return k1.y;}if(time>=k0.x&&time<=k1.x){float t=(time-k0.x)/(k1.x-k0.x);float nt=binarySearchT(time,k0.x,k0.z,k1.z,k1.x);return cubicBezier(nt,k0.y,k0.w,k1.w,k1.y);}}}float evaluteLineSeg(float t,vec2 p0,vec2 p1){return p0.y+(p1.y-p0.y)*(t-p0.x)/(p1.x-p0.x);}float valueFromLineSegs(float time,float frameStart,float frameCount){int start=int(frameStart);int count=int(frameCount-1.);int end=start+count;for(int i=0;i<ITR_END;i++){if(i>count){return lookup_curve(i).w;}vec4 seg=lookup_curve(i+start);vec2 p0=seg.xy;vec2 p1=seg.zw;if(time>=p0.x&&time<=p1.x){return evaluteLineSeg(time,p0,p1);}vec2 p2=lookup_curve(i+start+1).xy;if(time>p1.x&&time<=p2.x){return evaluteLineSeg(time,p1,p2);}}return lookup_curve(0).y;}float getValueFromTime(float time,vec4 value){float type=value.x;if(type==0.){return value.y;}if(type==1.){return mix(value.y,value.z,time/value.w);}if(type==3.){return valueFromLineSegs(time,value.y,value.z);}if(type==4.){return mix(value.y,value.z,aSeed);}if(type==5.){return valueFromBezierCurveFrames(time,value.z,value.w);}return 0.;}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.;}const float d2r=3.141592653589793/180.;attribute vec3 aPos;attribute vec4 aOffset;attribute vec4 aColor;attribute vec3 aDirX;attribute vec3 aDirY;attribute vec3 aTranslation;attribute vec3 aRotation0;attribute vec3 aRotation1;attribute vec3 aRotation2;attribute vec3 aLinearMove;\n#ifdef USE_SPRITE\nattribute vec3 aSprite;uniform vec4 uSprite;struct UVDetail{vec2 uv0;vec3 uv1;};UVDetail getSpriteUV(vec2 uv,float lifeTime);varying vec4 vTexCoordBlend;\n#endif\n#ifdef FINAL_TARGET\nuniform vec3 uFinalTarget;uniform vec4 uForceCurve;\n#endif\nuniform mat4 effects_ObjectToWorld;uniform mat4 effects_MatrixV;uniform mat4 effects_MatrixVP;uniform vec4 uParams;uniform vec4 uOpacityOverLifetimeValue;\n#ifdef COLOR_OVER_LIFETIME\nuniform sampler2D uColorOverLifetime;\n#endif\nuniform vec4 uOrbXByLifetimeValue;uniform vec4 uOrbYByLifetimeValue;uniform vec4 uOrbZByLifetimeValue;uniform vec3 uOrbCenter;uniform vec4 uSizeByLifetimeValue;\n#ifdef SIZE_Y_BY_LIFE\nuniform vec4 uSizeYByLifetimeValue;\n#endif\nvarying float vLife;varying vec4 vColor;varying vec2 vTexCoord;\n#ifdef ENV_EDITOR\nuniform vec4 uEditorTransform;\n#endif\nvec3 calOrbitalMov(float _life,float _dur){vec3 orb=vec3(0.0);\n#ifdef AS_ORBITAL_MOVEMENT\n#define FUNC(a) getValueFromTime(_life,a)\n#else\n#define FUNC(a) getIntegrateFromTime0(_life,a) * _dur\n#endif\n#if ORB_VEL_X\norb.x=FUNC(uOrbXByLifetimeValue);\n#endif\n#if ORB_VEL_Y\norb.y=FUNC(uOrbYByLifetimeValue);\n#endif\n#if ORB_VEL_Z\norb.z=FUNC(uOrbZByLifetimeValue);\n#endif\n#undef FUNC\nreturn orb;}mat3 mat3FromRotation(vec3 rotation){vec3 sinR=sin(rotation*d2r);vec3 cosR=cos(rotation*d2r);return mat3(cosR.z,-sinR.z,0.,sinR.z,cosR.z,0.,0.,0.,1.)*mat3(cosR.y,0.,sinR.y,0.,1.,0.,-sinR.y,0,cosR.y)*mat3(1.,0.,0.,0,cosR.x,-sinR.x,0.,sinR.x,cosR.x);}\n#ifdef USE_SPRITE\nUVDetail getSpriteUV(vec2 uv,float lifeTime){float t=fract(clamp((lifeTime-aSprite.x)/aSprite.y,0.0,1.)*aSprite.z);float frame=uSprite.z*t;float frameIndex=max(ceil(frame)-1.,0.);float row=floor((frameIndex+0.1)/uSprite.x);float col=frameIndex-row*uSprite.x;vec2 retUV=(vec2(col,row)+uv)/uSprite.xy;UVDetail ret;if(uSprite.w>0.){float blend=frame-frameIndex;float frameIndex1=min(ceil(frame),uSprite.z-1.);float row1=floor((frameIndex1+0.1)/uSprite.x);float col1=frameIndex1-row1*uSprite.x;vec2 coord=(vec2(col1,row1)+uv)/uSprite.xy-retUV;ret.uv1=vec3(coord.x,1.-coord.y,blend);}ret.uv0=vec2(retUV.x,1.-retUV.y);return ret;}\n#endif\nvoid main(){float time=uParams.x-aOffset.z;float dur=aOffset.w;if(time<0.||time>dur){gl_Position=vec4(-3.,-3.,-3.,1.);}else{float life=clamp(time/dur,0.0,1.0);vLife=life;\n#ifdef USE_SPRITE\nUVDetail uvD=getSpriteUV(aOffset.xy,time);vTexCoord=uvD.uv0;vTexCoordBlend=vec4(uvD.uv1,uSprite.w);\n#else\nvTexCoord=aOffset.xy;\n#endif\nvColor=aColor;\n#ifdef COLOR_OVER_LIFETIME\n#ifdef ENABLE_VERTEX_TEXTURE\nvColor*=texture2D(uColorOverLifetime,vec2(life,0.));\n#endif\n#endif\nvColor.a*=clamp(getValueFromTime(life,uOpacityOverLifetimeValue),0.,1.);vec3 size=vec3(vec2(getValueFromTime(life,uSizeByLifetimeValue)),1.0);\n#ifdef SIZE_Y_BY_LIFE\nsize.y=getValueFromTime(life,uSizeYByLifetimeValue);\n#endif\nmat3 aRotation=mat3(aRotation0,aRotation1,aRotation2);vec3 point=aRotation*(aDirX*size.x+aDirY*size.y);vec3 _pos=aPos+aTranslation;\n#if ORB_VEL_X + ORB_VEL_Y + ORB_VEL_Z\n_pos=mat3FromRotation(calOrbitalMov(life,dur))*(_pos-uOrbCenter);_pos+=uOrbCenter;\n#endif\n_pos.xyz+=aLinearMove;\n#ifdef FINAL_TARGET\nfloat force=getValueFromTime(life,uForceCurve);vec4 pos=vec4(mix(_pos,uFinalTarget,force),1.);\n#else\nvec4 pos=vec4(_pos,1.0);\n#endif\n#if RENDER_MODE == 1\npos.xyz+=point;pos=effects_ObjectToWorld*pos;\n#elif RENDER_MODE == 3\npos=effects_ObjectToWorld*pos;pos.xyz+=effects_MatrixV[0].xyz*point.x+effects_MatrixV[2].xyz*point.y;\n#elif RENDER_MODE == 2\npos=effects_ObjectToWorld*pos;pos.xy+=point.xy;\n#elif RENDER_MODE == 0\npos=effects_ObjectToWorld*pos;pos.xyz+=effects_MatrixV[0].xyz*point.x+effects_MatrixV[1].xyz*point.y;\n#endif\ngl_Position=effects_MatrixVP*pos;vSeed=aSeed;gl_PointSize=6.0;\n#ifdef ENV_EDITOR\ngl_Position=vec4(gl_Position.xy*uEditorTransform.xy+uEditorTransform.zw*gl_Position.w,gl_Position.zw);\n#endif\n}}";
|
|
11584
11603
|
|
|
11585
11604
|
var trailVert = "#version 100\nprecision mediump float;\n#define SHADER_VERTEX 1\n#ifdef SHADER_VERTEX\n#define CURVE_VALUE_TEXTURE uVCurveValueTexture\n#define CURVE_VALUE_ARRAY uVCurveValues\n#define CURVE_VALUE_COUNT VERT_CURVE_VALUE_COUNT\n#define FRAG_CURVE_VALUE_COUNT 0\n#else\n#define CURVE_VALUE_TEXTURE uFCurveValueTexture\n#define CURVE_VALUE_ARRAY uFCurveValues\n#define CURVE_VALUE_COUNT FRAG_CURVE_VALUE_COUNT\n#define VERT_CURVE_VALUE_COUNT 0\n#endif\n#if CURVE_VALUE_COUNT > 0\n#if LOOKUP_TEXTURE_CURVE\nuniform sampler2D CURVE_VALUE_TEXTURE;const float uCurveCount=1./float(CURVE_VALUE_COUNT);\n#define lookup_curve(i) texture2D(CURVE_VALUE_TEXTURE,vec2(float(i) * uCurveCount,0.))\n#else\nuniform vec4 CURVE_VALUE_ARRAY[CURVE_VALUE_COUNT];\n#define lookup_curve(i) CURVE_VALUE_ARRAY[i]\n#endif\n#else\n#define lookup_curve(i) vec4(0.)\n#endif\n#ifdef WEBGL2\n#define ITR_END (count + 1)\n#else\n#define ITR_END MAX_C\n#endif\n#define NONE_CONST_INDEX 1\n#ifdef SHADER_VERTEX\nattribute float aSeed;varying float vSeed;\n#endif\n#ifdef SHADER_VERTEX\n#define MAX_C VERT_MAX_KEY_FRAME_COUNT\n#else\n#define MAX_C FRAG_MAX_KEY_FRAME_COUNT\n#endif\nmat4 cubicBezierMatrix=mat4(1.0,-3.0,3.0,-1.0,0.0,3.0,-6.0,3.0,0.0,0.0,3.0,-3.0,0.0,0.0,0.0,1.0);float cubicBezier(float t,float y1,float y2,float y3,float y4){vec4 tVec=vec4(1.0,t,t*t,t*t*t);vec4 yVec=vec4(y1,y2,y3,y4);vec4 result=tVec*cubicBezierMatrix*yVec;return result.x+result.y+result.z+result.w;}float binarySearchT(float x,float x1,float x2,float x3,float x4){float left=0.0;float right=1.0;float mid=0.0;float computedX;for(int i=0;i<8;i++){mid=(left+right)*0.5;computedX=cubicBezier(mid,x1,x2,x3,x4);if(abs(computedX-x)<0.0001){break;}else if(computedX>x){right=mid;}else{left=mid;}}return mid;}float valueFromBezierCurveFrames(float time,float frameStart,float frameCount){int start=int(frameStart);int count=int(frameCount-1.);for(int i=0;i<ITR_END;i+=2){if(i>=count){break;}vec4 k0=lookup_curve(i+start);vec4 k1=lookup_curve(i+1+start);if(i==0&&time<k0.x){return k0.y;}if(i==int(frameCount-2.)&&time>=k1.x){return k1.y;}if(time>=k0.x&&time<=k1.x){float t=(time-k0.x)/(k1.x-k0.x);float nt=binarySearchT(time,k0.x,k0.z,k1.z,k1.x);return cubicBezier(nt,k0.y,k0.w,k1.w,k1.y);}}}float evaluteLineSeg(float t,vec2 p0,vec2 p1){return p0.y+(p1.y-p0.y)*(t-p0.x)/(p1.x-p0.x);}float valueFromLineSegs(float time,float frameStart,float frameCount){int start=int(frameStart);int count=int(frameCount-1.);int end=start+count;for(int i=0;i<ITR_END;i++){if(i>count){return lookup_curve(i).w;}vec4 seg=lookup_curve(i+start);vec2 p0=seg.xy;vec2 p1=seg.zw;if(time>=p0.x&&time<=p1.x){return evaluteLineSeg(time,p0,p1);}vec2 p2=lookup_curve(i+start+1).xy;if(time>p1.x&&time<=p2.x){return evaluteLineSeg(time,p1,p2);}}return lookup_curve(0).y;}float getValueFromTime(float time,vec4 value){float type=value.x;if(type==0.){return value.y;}if(type==1.){return mix(value.y,value.z,time/value.w);}if(type==3.){return valueFromLineSegs(time,value.y,value.z);}if(type==4.){return mix(value.y,value.z,aSeed);}if(type==5.){return valueFromBezierCurveFrames(time,value.z,value.w);}return 0.;}attribute vec4 aPos;attribute vec3 aDir;attribute vec3 aInfo;attribute vec4 aColor;attribute float aTime;\n#ifdef ATTR_TRAIL_START\nattribute float aTrailStart;\n#else\nuniform float uTrailStart[64];attribute float aTrailStartIndex;\n#endif\nuniform mat4 effects_MatrixInvV;uniform mat4 effects_ObjectToWorld;uniform mat4 effects_MatrixVP;uniform vec4 uTextureMap;uniform float uTime;uniform vec4 uParams;uniform vec4 uColorParams;uniform vec4 uOpacityOverLifetimeValue;uniform vec4 uWidthOverTrail;\n#ifdef COLOR_OVER_TRAIL\nuniform sampler2D uColorOverTrail;\n#endif\n#ifdef COLOR_OVER_LIFETIME\nuniform sampler2D uColorOverLifetime;\n#endif\nvarying float vLife;varying vec2 vTexCoord;varying vec4 vColor;\n#ifdef ENV_EDITOR\nuniform vec4 uEditorTransform;\n#endif\nvoid main(){vec4 _pa=effects_MatrixVP*vec4(aPos.xyz,1.);vec4 _pb=effects_MatrixVP*vec4(aPos.xyz+aDir,1.);vec2 dir=normalize(_pb.xy/_pb.w-_pa.xy/_pa.w);vec2 screen_xy=vec2(-dir.y,dir.x);vec4 pos=effects_ObjectToWorld*vec4(aPos.xyz,1.);\n#ifdef ATTR_TRAIL_START\nfloat ts=aTrailStart;\n#else\nfloat ts=uTrailStart[int(aTrailStartIndex)];\n#endif\nfloat trail=(ts-aInfo.y)/uParams.y;float width=aPos.w*getValueFromTime(trail,uWidthOverTrail)/max(abs(screen_xy.x),abs(screen_xy.y));pos.xyz+=(effects_MatrixInvV[0].xyz*screen_xy.x+effects_MatrixInvV[1].xyz*screen_xy.y)*width;float time=min((uTime-aTime)/aInfo.x,1.0);gl_Position=effects_MatrixVP*pos;vColor=aColor;\n#ifdef COLOR_OVER_LIFETIME\n#ifdef ENABLE_VERTEX_TEXTURE\nvColor*=texture2D(uColorOverLifetime,vec2(time,0.));\n#endif\n#endif\n#ifdef COLOR_OVER_TRAIL\nvColor*=texture2D(uColorOverTrail,vec2(trail,0.));\n#endif\nvColor.a*=clamp(getValueFromTime(time,uOpacityOverLifetimeValue),0.,1.);vLife=time;vTexCoord=uTextureMap.xy+vec2(trail,aInfo.z)*uTextureMap.zw;vSeed=aSeed;\n#ifdef ENV_EDITOR\ngl_Position=vec4(gl_Position.xy*uEditorTransform.xy+uEditorTransform.zw*gl_Position.w,gl_Position.zw);\n#endif\n}";
|
|
11586
11605
|
|
|
@@ -16558,6 +16577,7 @@ function getTrailMeshShader(trails, particleMaxCount, name, gpuCapability, env)
|
|
|
16558
16577
|
_proto.onUpdate = function onUpdate(dt) {
|
|
16559
16578
|
var time = this.particleMesh.time;
|
|
16560
16579
|
this.particleMesh.mesh.material.setVector4("uParams", new Vector4(time, this.item.duration, 0, 0));
|
|
16580
|
+
this.particleMesh.onUpdate(dt);
|
|
16561
16581
|
};
|
|
16562
16582
|
_proto.render = function render(renderer) {
|
|
16563
16583
|
for(var _iterator = _create_for_of_iterator_helper_loose(this.meshes), _step; !(_step = _iterator()).done;){
|
|
@@ -16572,6 +16592,7 @@ function getTrailMeshShader(trails, particleMaxCount, name, gpuCapability, env)
|
|
|
16572
16592
|
};
|
|
16573
16593
|
_proto.updateTime = function updateTime(now, delta) {
|
|
16574
16594
|
this.particleMesh.time = now;
|
|
16595
|
+
// this.particleMesh.onUpdate(delta);
|
|
16575
16596
|
if (this.trailMesh) {
|
|
16576
16597
|
this.trailMesh.time = now;
|
|
16577
16598
|
this.trailMesh.onUpdate(delta);
|
|
@@ -16670,6 +16691,9 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
|
|
|
16670
16691
|
_proto.isFrozen = function isFrozen() {
|
|
16671
16692
|
return this.frozen;
|
|
16672
16693
|
};
|
|
16694
|
+
_proto.isEnded = function isEnded() {
|
|
16695
|
+
return this.ended;
|
|
16696
|
+
};
|
|
16673
16697
|
_proto.initEmitterTransform = function initEmitterTransform() {
|
|
16674
16698
|
var position = this.item.transform.position.clone();
|
|
16675
16699
|
var rotation = this.item.transform.rotation.clone();
|
|
@@ -17615,11 +17639,8 @@ function randomArrItem(arr, keepArr) {
|
|
|
17615
17639
|
}
|
|
17616
17640
|
var particleSystem = this.particleSystem;
|
|
17617
17641
|
if (particleSystem) {
|
|
17618
|
-
// TODO: [1.31] @十弦 验证 https://github.com/galacean/effects-runtime/commit/3e7d73d37b7d98c2a25e4544e80e928b17801ccd#diff-fae062f28caf3771cfedd3a20dc22f9749bd054c7541bf2fd50a9a5e413153d4
|
|
17619
|
-
// particleSystem.setParentTransform(parentItem.transform);
|
|
17620
|
-
particleSystem.setVisible(true);
|
|
17621
17642
|
var deltaTime = context.deltaTime;
|
|
17622
|
-
if (this.time < particleSystem.item.duration && particleSystem.
|
|
17643
|
+
if (this.time >= 0 && this.time < particleSystem.item.duration && particleSystem.isEnded()) {
|
|
17623
17644
|
particleSystem.reset();
|
|
17624
17645
|
}
|
|
17625
17646
|
if (Math.abs(this.time - this.lastTime) < 0.001) {
|
|
@@ -17678,6 +17699,13 @@ var particleUniformTypeMap = {
|
|
|
17678
17699
|
var ParticleMesh = /*#__PURE__*/ function() {
|
|
17679
17700
|
function ParticleMesh(engine, props) {
|
|
17680
17701
|
this.particleCount = 0;
|
|
17702
|
+
this.cachedVelocity = new Vector3();
|
|
17703
|
+
this.cachedRotationVector3 = new Vector3();
|
|
17704
|
+
this.cachedRotationMatrix = new Matrix3();
|
|
17705
|
+
this.cachedLinearMove = new Vector3();
|
|
17706
|
+
this.tempMatrix3 = new Matrix3();
|
|
17707
|
+
this.tempVector3 = new Vector3();
|
|
17708
|
+
this.VERT_MAX_KEY_FRAME_COUNT = 0;
|
|
17681
17709
|
var _engine_renderer;
|
|
17682
17710
|
var env = ((_engine_renderer = engine.renderer) != null ? _engine_renderer : {}).env;
|
|
17683
17711
|
var speedOverLifetime = props.speedOverLifetime, colorOverLifetime = props.colorOverLifetime, linearVelOverLifetime = props.linearVelOverLifetime, orbitalVelOverLifetime = props.orbitalVelOverLifetime, sizeOverLifetime = props.sizeOverLifetime, rotationOverLifetime = props.rotationOverLifetime, sprite = props.sprite, gravityModifier = props.gravityModifier, maxCount = props.maxCount, textureFlip = props.textureFlip, useSprite = props.useSprite, name = props.name, gravity = props.gravity, forceTarget = props.forceTarget, side = props.side, occlusion = props.occlusion, anchor = props.anchor, blending = props.blending, maskMode = props.maskMode, mask = props.mask, transparentOcclusion = props.transparentOcclusion, meshSlots = props.meshSlots, _props_renderMode = props.renderMode, renderMode = _props_renderMode === void 0 ? 0 : _props_renderMode, _props_diffuse = props.diffuse, diffuse = _props_diffuse === void 0 ? Texture.createWithData(engine) : _props_diffuse;
|
|
@@ -17896,6 +17924,7 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
17896
17924
|
"FRAG_MAX_KEY_FRAME_COUNT",
|
|
17897
17925
|
fragmentKeyFrameMeta.max
|
|
17898
17926
|
]);
|
|
17927
|
+
this.VERT_MAX_KEY_FRAME_COUNT = vertexKeyFrameMeta.max;
|
|
17899
17928
|
var fragment = particleFrag;
|
|
17900
17929
|
var originalVertex = "#define LOOKUP_TEXTURE_CURVE " + vertex_lookup_texture + "\n" + particleVert;
|
|
17901
17930
|
var vertex = originalVertex;
|
|
@@ -18004,6 +18033,7 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
18004
18033
|
this.orbitalVelOverLifetime = orbitalVelOverLifetime;
|
|
18005
18034
|
this.orbitalVelOverLifetime = orbitalVelOverLifetime;
|
|
18006
18035
|
this.gravityModifier = gravityModifier;
|
|
18036
|
+
this.rotationOverLifetime = rotationOverLifetime;
|
|
18007
18037
|
this.maxCount = maxCount;
|
|
18008
18038
|
// this.duration = duration;
|
|
18009
18039
|
this.textureOffsets = textureFlip ? [
|
|
@@ -18068,15 +18098,230 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
18068
18098
|
// @ts-expect-error
|
|
18069
18099
|
geometry.setIndexData(new index.constructor(0));
|
|
18070
18100
|
};
|
|
18101
|
+
_proto.onUpdate = function onUpdate(dt) {
|
|
18102
|
+
var aPosArray = this.geometry.getAttributeData("aPos"); // vector3
|
|
18103
|
+
var aVelArray = this.geometry.getAttributeData("aVel"); // vector3
|
|
18104
|
+
var aOffsetArray = this.geometry.getAttributeData("aOffset");
|
|
18105
|
+
var aRotArray = this.geometry.getAttributeData("aRot"); // vector3
|
|
18106
|
+
var aSeedArray = this.geometry.getAttributeData("aSeed"); // float
|
|
18107
|
+
// const uParams = this.mesh.material.getVector4('uParams');
|
|
18108
|
+
// if (!uParams) {
|
|
18109
|
+
// return;
|
|
18110
|
+
// }
|
|
18111
|
+
var localTime = this.time;
|
|
18112
|
+
var particleCount = Math.ceil(aPosArray.length / 12);
|
|
18113
|
+
// calculate particle translation
|
|
18114
|
+
var aTranslationArray = this.geometry.getAttributeData("aTranslation");
|
|
18115
|
+
if (aTranslationArray.length < particleCount * 3) {
|
|
18116
|
+
aTranslationArray = this.expandArray(aTranslationArray, particleCount * 3);
|
|
18117
|
+
}
|
|
18118
|
+
var velocity = this.cachedVelocity;
|
|
18119
|
+
for(var i = 0; i < particleCount; i++){
|
|
18120
|
+
var velOffset = i * 12 + 3;
|
|
18121
|
+
velocity.set(aVelArray[velOffset], aVelArray[velOffset + 1], aVelArray[velOffset + 2]);
|
|
18122
|
+
this.calculateTranslation(velocity, aOffsetArray[i * 4 + 2], localTime, aOffsetArray[i * 4 + 3]);
|
|
18123
|
+
var aTranslationOffset = i * 3;
|
|
18124
|
+
if (aOffsetArray[i * 4 + 2] < localTime) {
|
|
18125
|
+
var translation = velocity.multiply(dt / 1000);
|
|
18126
|
+
aTranslationArray[aTranslationOffset] += translation.x;
|
|
18127
|
+
aTranslationArray[aTranslationOffset + 1] += translation.y;
|
|
18128
|
+
aTranslationArray[aTranslationOffset + 2] += translation.z;
|
|
18129
|
+
}
|
|
18130
|
+
}
|
|
18131
|
+
this.geometry.setAttributeData("aTranslation", aTranslationArray);
|
|
18132
|
+
// calculate particle rotation
|
|
18133
|
+
var aRotationArray = this.geometry.getAttributeData("aRotation0");
|
|
18134
|
+
if (aRotationArray.length < particleCount * 9) {
|
|
18135
|
+
aRotationArray = this.expandArray(aRotationArray, particleCount * 9);
|
|
18136
|
+
}
|
|
18137
|
+
for(var i1 = 0; i1 < particleCount; i1++){
|
|
18138
|
+
var time = localTime - aOffsetArray[i1 * 4 + 2];
|
|
18139
|
+
var duration = aOffsetArray[i1 * 4 + 3];
|
|
18140
|
+
var life = clamp$1(time / duration, 0.0, 1.0);
|
|
18141
|
+
var aRotOffset = i1 * 8;
|
|
18142
|
+
var aRot = this.cachedRotationVector3.set(aRotArray[aRotOffset], aRotArray[aRotOffset + 1], aRotArray[aRotOffset + 2]);
|
|
18143
|
+
var aSeed = aSeedArray[i1 * 8 + 3];
|
|
18144
|
+
var aRotation = this.transformFromRotation(aRot, life, duration, aSeed, this.cachedRotationMatrix);
|
|
18145
|
+
var aRotationOffset = i1 * 9;
|
|
18146
|
+
var matrixArray = aRotation.toArray();
|
|
18147
|
+
aRotationArray.set(matrixArray, aRotationOffset);
|
|
18148
|
+
}
|
|
18149
|
+
this.geometry.setAttributeData("aRotation0", aRotationArray);
|
|
18150
|
+
// calculate linear movement
|
|
18151
|
+
var aLinearMoveArray = this.geometry.getAttributeData("aLinearMove");
|
|
18152
|
+
if (aLinearMoveArray.length < particleCount * 3) {
|
|
18153
|
+
aLinearMoveArray = this.expandArray(aLinearMoveArray, particleCount * 3);
|
|
18154
|
+
}
|
|
18155
|
+
var linearMove = this.cachedLinearMove;
|
|
18156
|
+
for(var i2 = 0; i2 < particleCount; i2++){
|
|
18157
|
+
var time1 = localTime - aOffsetArray[i2 * 4 + 2];
|
|
18158
|
+
var duration1 = aOffsetArray[i2 * 4 + 3];
|
|
18159
|
+
// const life = math.clamp(time / duration, 0.0, 1.0);
|
|
18160
|
+
var aSeed1 = aSeedArray[i2 * 8 + 3];
|
|
18161
|
+
linearMove.setZero();
|
|
18162
|
+
this.calLinearMov(time1, duration1, aSeed1, linearMove);
|
|
18163
|
+
var aLinearMoveOffset = i2 * 3;
|
|
18164
|
+
aLinearMoveArray[aLinearMoveOffset] = linearMove.x;
|
|
18165
|
+
aLinearMoveArray[aLinearMoveOffset + 1] = linearMove.y;
|
|
18166
|
+
aLinearMoveArray[aLinearMoveOffset + 2] = linearMove.z;
|
|
18167
|
+
}
|
|
18168
|
+
this.geometry.setAttributeData("aLinearMove", aLinearMoveArray);
|
|
18169
|
+
};
|
|
18071
18170
|
_proto.minusTime = function minusTime(time) {
|
|
18072
|
-
var
|
|
18073
|
-
|
|
18074
|
-
|
|
18075
|
-
data[i + 2] -= time;
|
|
18171
|
+
var aOffset = this.geometry.getAttributeData("aOffset");
|
|
18172
|
+
for(var i = 0; i < aOffset.length; i += 4){
|
|
18173
|
+
aOffset[i + 2] -= time;
|
|
18076
18174
|
}
|
|
18077
|
-
this.geometry.setAttributeData("aOffset",
|
|
18175
|
+
this.geometry.setAttributeData("aOffset", aOffset);
|
|
18078
18176
|
this.time -= time;
|
|
18079
18177
|
};
|
|
18178
|
+
_proto.calculateTranslation = function calculateTranslation(velocity, t0, t1, duration) {
|
|
18179
|
+
var uAcceleration = this.mesh.material.getVector4("uAcceleration");
|
|
18180
|
+
var uGravityModifierValue = this.mesh.material.getVector4("uGravityModifierValue");
|
|
18181
|
+
if (!uAcceleration || !uGravityModifierValue) {
|
|
18182
|
+
return velocity;
|
|
18183
|
+
}
|
|
18184
|
+
var dt = t1 - t0; // 相对delay的时间
|
|
18185
|
+
var d = this.gravityModifier.getIntegrateValue(0, dt, duration);
|
|
18186
|
+
var acc = this.tempVector3.set(uAcceleration.x * d, uAcceleration.y * d, uAcceleration.z * d);
|
|
18187
|
+
// speedIntegrate = speedOverLifetime.getIntegrateValue(0, time, duration);
|
|
18188
|
+
if (this.speedOverLifetime) {
|
|
18189
|
+
// dt / dur 归一化
|
|
18190
|
+
var speed = this.speedOverLifetime.getValue(dt / duration);
|
|
18191
|
+
return velocity.multiply(speed).add(acc);
|
|
18192
|
+
}
|
|
18193
|
+
return velocity.add(acc);
|
|
18194
|
+
};
|
|
18195
|
+
_proto.transformFromRotation = function transformFromRotation(rot, life, dur, aSeed, result) {
|
|
18196
|
+
var rotation = rot;
|
|
18197
|
+
if (!this.rotationOverLifetime) {
|
|
18198
|
+
return result.setZero();
|
|
18199
|
+
}
|
|
18200
|
+
if (this.rotationOverLifetime.asRotation) {
|
|
18201
|
+
// Adjust rotation based on the specified lifetime components
|
|
18202
|
+
if (this.rotationOverLifetime.x) {
|
|
18203
|
+
if (_instanceof1(this.rotationOverLifetime.x, RandomValue)) {
|
|
18204
|
+
rotation.x += this.rotationOverLifetime.x.getValue(life, aSeed);
|
|
18205
|
+
} else {
|
|
18206
|
+
rotation.x += this.rotationOverLifetime.x.getValue(life);
|
|
18207
|
+
}
|
|
18208
|
+
}
|
|
18209
|
+
if (this.rotationOverLifetime.y) {
|
|
18210
|
+
if (_instanceof1(this.rotationOverLifetime.y, RandomValue)) {
|
|
18211
|
+
rotation.y += this.rotationOverLifetime.y.getValue(life, aSeed);
|
|
18212
|
+
} else {
|
|
18213
|
+
rotation.y += this.rotationOverLifetime.y.getValue(life);
|
|
18214
|
+
}
|
|
18215
|
+
}
|
|
18216
|
+
if (this.rotationOverLifetime.z) {
|
|
18217
|
+
if (_instanceof1(this.rotationOverLifetime.z, RandomValue)) {
|
|
18218
|
+
rotation.z += this.rotationOverLifetime.z.getValue(life, aSeed);
|
|
18219
|
+
} else {
|
|
18220
|
+
rotation.z += this.rotationOverLifetime.z.getValue(life);
|
|
18221
|
+
}
|
|
18222
|
+
}
|
|
18223
|
+
} else {
|
|
18224
|
+
// Adjust rotation based on the specified lifetime components
|
|
18225
|
+
if (this.rotationOverLifetime.x) {
|
|
18226
|
+
if (_instanceof1(this.rotationOverLifetime.x, RandomValue)) {
|
|
18227
|
+
rotation.x += this.rotationOverLifetime.x.getIntegrateValue(0.0, life, aSeed) * dur;
|
|
18228
|
+
} else {
|
|
18229
|
+
rotation.x += this.rotationOverLifetime.x.getIntegrateValue(0.0, life, dur) * dur;
|
|
18230
|
+
}
|
|
18231
|
+
}
|
|
18232
|
+
if (this.rotationOverLifetime.y) {
|
|
18233
|
+
if (_instanceof1(this.rotationOverLifetime.y, RandomValue)) {
|
|
18234
|
+
rotation.y += this.rotationOverLifetime.y.getIntegrateValue(0.0, life, aSeed) * dur;
|
|
18235
|
+
} else {
|
|
18236
|
+
rotation.y += this.rotationOverLifetime.y.getIntegrateValue(0.0, life, dur) * dur;
|
|
18237
|
+
}
|
|
18238
|
+
}
|
|
18239
|
+
if (this.rotationOverLifetime.z) {
|
|
18240
|
+
if (_instanceof1(this.rotationOverLifetime.z, RandomValue)) {
|
|
18241
|
+
rotation.z += this.rotationOverLifetime.z.getIntegrateValue(0.0, life, aSeed) * dur;
|
|
18242
|
+
} else {
|
|
18243
|
+
rotation.z += this.rotationOverLifetime.z.getIntegrateValue(0.0, life, dur) * dur;
|
|
18244
|
+
}
|
|
18245
|
+
}
|
|
18246
|
+
}
|
|
18247
|
+
// If the rotation vector is zero, return the identity matrix
|
|
18248
|
+
if (rotation.dot(rotation) === 0.0) {
|
|
18249
|
+
return result.identity();
|
|
18250
|
+
}
|
|
18251
|
+
// Return the rotation matrix derived from the rotation vector
|
|
18252
|
+
return this.mat3FromRotation(rotation, result);
|
|
18253
|
+
};
|
|
18254
|
+
_proto.mat3FromRotation = function mat3FromRotation(rotation, result) {
|
|
18255
|
+
var d2r = Math.PI / 180;
|
|
18256
|
+
var rotationXD2r = rotation.x * d2r;
|
|
18257
|
+
var rotationYD2r = rotation.y * d2r;
|
|
18258
|
+
var rotationZD2r = rotation.z * d2r;
|
|
18259
|
+
var sinRX = Math.sin(rotationXD2r);
|
|
18260
|
+
var sinRY = Math.sin(rotationYD2r);
|
|
18261
|
+
var sinRZ = Math.sin(rotationZD2r);
|
|
18262
|
+
var cosRX = Math.cos(rotationXD2r);
|
|
18263
|
+
var cosRY = Math.cos(rotationYD2r);
|
|
18264
|
+
var cosRZ = Math.cos(rotationZD2r);
|
|
18265
|
+
// rotZ * rotY * rotX
|
|
18266
|
+
result.set(cosRZ, -sinRZ, 0., sinRZ, cosRZ, 0., 0., 0., 1.); //rotZ
|
|
18267
|
+
result.multiply(this.tempMatrix3.set(cosRY, 0., sinRY, 0., 1., 0., -sinRY, 0, cosRY)); //rotY
|
|
18268
|
+
result.multiply(this.tempMatrix3.set(1., 0., 0., 0, cosRX, -sinRX, 0., sinRX, cosRX)); //rotX
|
|
18269
|
+
return result;
|
|
18270
|
+
};
|
|
18271
|
+
_proto.calLinearMov = function calLinearMov(time, duration, aSeed, result) {
|
|
18272
|
+
var mov = result;
|
|
18273
|
+
var lifetime = time / duration;
|
|
18274
|
+
if (!this.linearVelOverLifetime || !this.linearVelOverLifetime.enabled) {
|
|
18275
|
+
return mov;
|
|
18276
|
+
}
|
|
18277
|
+
if (this.linearVelOverLifetime.asMovement) {
|
|
18278
|
+
if (this.linearVelOverLifetime.x) {
|
|
18279
|
+
if (_instanceof1(this.linearVelOverLifetime.x, RandomValue)) {
|
|
18280
|
+
mov.x = this.linearVelOverLifetime.x.getValue(lifetime, aSeed);
|
|
18281
|
+
} else {
|
|
18282
|
+
mov.x = this.linearVelOverLifetime.x.getValue(lifetime);
|
|
18283
|
+
}
|
|
18284
|
+
}
|
|
18285
|
+
if (this.linearVelOverLifetime.y) {
|
|
18286
|
+
if (_instanceof1(this.linearVelOverLifetime.y, RandomValue)) {
|
|
18287
|
+
mov.y = this.linearVelOverLifetime.y.getValue(lifetime, aSeed);
|
|
18288
|
+
} else {
|
|
18289
|
+
mov.y = this.linearVelOverLifetime.y.getValue(lifetime);
|
|
18290
|
+
}
|
|
18291
|
+
}
|
|
18292
|
+
if (this.linearVelOverLifetime.z) {
|
|
18293
|
+
if (_instanceof1(this.linearVelOverLifetime.z, RandomValue)) {
|
|
18294
|
+
mov.z = this.linearVelOverLifetime.z.getValue(lifetime, aSeed);
|
|
18295
|
+
} else {
|
|
18296
|
+
mov.z = this.linearVelOverLifetime.z.getValue(lifetime);
|
|
18297
|
+
}
|
|
18298
|
+
}
|
|
18299
|
+
} else {
|
|
18300
|
+
// Adjust rotation based on the specified lifetime components
|
|
18301
|
+
if (this.linearVelOverLifetime.x) {
|
|
18302
|
+
if (_instanceof1(this.linearVelOverLifetime.x, RandomValue)) {
|
|
18303
|
+
mov.x = this.linearVelOverLifetime.x.getIntegrateValue(0.0, time, aSeed);
|
|
18304
|
+
} else {
|
|
18305
|
+
mov.x = this.linearVelOverLifetime.x.getIntegrateValue(0.0, time, duration);
|
|
18306
|
+
}
|
|
18307
|
+
}
|
|
18308
|
+
if (this.linearVelOverLifetime.y) {
|
|
18309
|
+
if (_instanceof1(this.linearVelOverLifetime.y, RandomValue)) {
|
|
18310
|
+
mov.y = this.linearVelOverLifetime.y.getIntegrateValue(0.0, time, aSeed);
|
|
18311
|
+
} else {
|
|
18312
|
+
mov.y = this.linearVelOverLifetime.y.getIntegrateValue(0.0, time, duration);
|
|
18313
|
+
}
|
|
18314
|
+
}
|
|
18315
|
+
if (this.linearVelOverLifetime.z) {
|
|
18316
|
+
if (_instanceof1(this.linearVelOverLifetime.z, RandomValue)) {
|
|
18317
|
+
mov.z = this.linearVelOverLifetime.z.getIntegrateValue(0.0, time, aSeed);
|
|
18318
|
+
} else {
|
|
18319
|
+
mov.z = this.linearVelOverLifetime.z.getIntegrateValue(0.0, time, duration);
|
|
18320
|
+
}
|
|
18321
|
+
}
|
|
18322
|
+
}
|
|
18323
|
+
return mov;
|
|
18324
|
+
};
|
|
18080
18325
|
_proto.removePoint = function removePoint(index) {
|
|
18081
18326
|
if (index < this.particleCount) {
|
|
18082
18327
|
this.geometry.setAttributeSubData("aOffset", index * 16, new Float32Array(16));
|
|
@@ -18100,7 +18345,8 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
18100
18345
|
var pointData = {
|
|
18101
18346
|
aPos: new Float32Array(48),
|
|
18102
18347
|
aRot: new Float32Array(32),
|
|
18103
|
-
aOffset: new Float32Array(16)
|
|
18348
|
+
aOffset: new Float32Array(16),
|
|
18349
|
+
aTranslation: new Float32Array(12)
|
|
18104
18350
|
};
|
|
18105
18351
|
var useSprite = this.useSprite;
|
|
18106
18352
|
if (useSprite) {
|
|
@@ -18209,6 +18455,11 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
18209
18455
|
geometry.setDrawCount(this.particleCount * 6);
|
|
18210
18456
|
}
|
|
18211
18457
|
};
|
|
18458
|
+
_proto.expandArray = function expandArray(array, newSize) {
|
|
18459
|
+
var newArr = new Float32Array(newSize);
|
|
18460
|
+
newArr.set(array);
|
|
18461
|
+
return newArr;
|
|
18462
|
+
};
|
|
18212
18463
|
return ParticleMesh;
|
|
18213
18464
|
}();
|
|
18214
18465
|
var gl2UniformSlots = [
|
|
@@ -18278,6 +18529,32 @@ function generateGeometryProps(maxVertex, useSprite, name) {
|
|
|
18278
18529
|
size: 4,
|
|
18279
18530
|
stride: 4 * bpe,
|
|
18280
18531
|
data: new Float32Array(0)
|
|
18532
|
+
},
|
|
18533
|
+
aTranslation: {
|
|
18534
|
+
size: 3,
|
|
18535
|
+
data: new Float32Array(0)
|
|
18536
|
+
},
|
|
18537
|
+
aLinearMove: {
|
|
18538
|
+
size: 3,
|
|
18539
|
+
data: new Float32Array(0)
|
|
18540
|
+
},
|
|
18541
|
+
aRotation0: {
|
|
18542
|
+
size: 3,
|
|
18543
|
+
offset: 0,
|
|
18544
|
+
stride: 9 * bpe,
|
|
18545
|
+
data: new Float32Array(0)
|
|
18546
|
+
},
|
|
18547
|
+
aRotation1: {
|
|
18548
|
+
size: 3,
|
|
18549
|
+
offset: 3 * bpe,
|
|
18550
|
+
stride: 9 * bpe,
|
|
18551
|
+
dataSource: "aRotation0"
|
|
18552
|
+
},
|
|
18553
|
+
aRotation2: {
|
|
18554
|
+
size: 3,
|
|
18555
|
+
offset: 6 * bpe,
|
|
18556
|
+
stride: 9 * bpe,
|
|
18557
|
+
dataSource: "aRotation0"
|
|
18281
18558
|
}
|
|
18282
18559
|
};
|
|
18283
18560
|
if (useSprite) {
|
|
@@ -19484,6 +19761,18 @@ function compareTracks(a, b) {
|
|
|
19484
19761
|
}
|
|
19485
19762
|
}
|
|
19486
19763
|
};
|
|
19764
|
+
_proto.showItems = function showItems() {
|
|
19765
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(this.items), _step; !(_step = _iterator()).done;){
|
|
19766
|
+
var item = _step.value;
|
|
19767
|
+
item.setVisible(true);
|
|
19768
|
+
}
|
|
19769
|
+
};
|
|
19770
|
+
_proto.hideItems = function hideItems() {
|
|
19771
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(this.items), _step; !(_step = _iterator()).done;){
|
|
19772
|
+
var item = _step.value;
|
|
19773
|
+
item.setVisible(false);
|
|
19774
|
+
}
|
|
19775
|
+
};
|
|
19487
19776
|
_proto.onDestroy = function onDestroy() {
|
|
19488
19777
|
if (this.item.composition) {
|
|
19489
19778
|
if (this.items) {
|
|
@@ -19594,6 +19883,34 @@ function compareTracks(a, b) {
|
|
|
19594
19883
|
return CompositionComponent;
|
|
19595
19884
|
}(Behaviour);
|
|
19596
19885
|
|
|
19886
|
+
var SubCompositionMixerPlayable = /*#__PURE__*/ function(Playable) {
|
|
19887
|
+
_inherits(SubCompositionMixerPlayable, Playable);
|
|
19888
|
+
function SubCompositionMixerPlayable() {
|
|
19889
|
+
return Playable.apply(this, arguments);
|
|
19890
|
+
}
|
|
19891
|
+
var _proto = SubCompositionMixerPlayable.prototype;
|
|
19892
|
+
_proto.processFrame = function processFrame(context) {
|
|
19893
|
+
var boundObject = context.output.getUserData();
|
|
19894
|
+
if (!_instanceof1(boundObject, CompositionComponent)) {
|
|
19895
|
+
return;
|
|
19896
|
+
}
|
|
19897
|
+
var compositionComponent = boundObject;
|
|
19898
|
+
var hasInput = false;
|
|
19899
|
+
for(var i = 0; i < this.getInputCount(); i++){
|
|
19900
|
+
if (this.getInputWeight(i) > 0) {
|
|
19901
|
+
hasInput = true;
|
|
19902
|
+
break;
|
|
19903
|
+
}
|
|
19904
|
+
}
|
|
19905
|
+
if (hasInput) {
|
|
19906
|
+
compositionComponent.showItems();
|
|
19907
|
+
} else {
|
|
19908
|
+
compositionComponent.hideItems();
|
|
19909
|
+
}
|
|
19910
|
+
};
|
|
19911
|
+
return SubCompositionMixerPlayable;
|
|
19912
|
+
}(Playable);
|
|
19913
|
+
|
|
19597
19914
|
exports.SubCompositionTrack = /*#__PURE__*/ function(TrackAsset) {
|
|
19598
19915
|
_inherits(SubCompositionTrack, TrackAsset);
|
|
19599
19916
|
function SubCompositionTrack() {
|
|
@@ -19606,6 +19923,9 @@ exports.SubCompositionTrack = /*#__PURE__*/ function(TrackAsset) {
|
|
|
19606
19923
|
}
|
|
19607
19924
|
return parentBinding.getComponent(CompositionComponent);
|
|
19608
19925
|
};
|
|
19926
|
+
_proto.createTrackMixer = function createTrackMixer(graph) {
|
|
19927
|
+
return new SubCompositionMixerPlayable(graph);
|
|
19928
|
+
};
|
|
19609
19929
|
return SubCompositionTrack;
|
|
19610
19930
|
}(exports.TrackAsset);
|
|
19611
19931
|
exports.SubCompositionTrack = __decorate([
|
|
@@ -23701,22 +24021,6 @@ var seed$1 = 1;
|
|
|
23701
24021
|
this.timeout = timeout;
|
|
23702
24022
|
};
|
|
23703
24023
|
/**
|
|
23704
|
-
* 根据用户传入的参数修改场景数据
|
|
23705
|
-
*/ _proto.updateSceneData = function updateSceneData(items) {
|
|
23706
|
-
var variables = this.options.variables;
|
|
23707
|
-
if (!variables || Object.keys(variables).length === 0) {
|
|
23708
|
-
return;
|
|
23709
|
-
}
|
|
23710
|
-
items.forEach(function(item) {
|
|
23711
|
-
if (item.type === ItemType.text) {
|
|
23712
|
-
var textVariable = variables[item.name];
|
|
23713
|
-
if (textVariable) {
|
|
23714
|
-
item.content.options.text = textVariable;
|
|
23715
|
-
}
|
|
23716
|
-
}
|
|
23717
|
-
});
|
|
23718
|
-
};
|
|
23719
|
-
/**
|
|
23720
24024
|
* 场景创建,通过 json 创建出场景对象,并进行提前编译等工作
|
|
23721
24025
|
* @param url - json 的 URL 链接或者 json 对象
|
|
23722
24026
|
* @param renderer - renderer 对象,用于获取管理、编译 shader 及 GPU 上下文的参数
|
|
@@ -23843,7 +24147,6 @@ var seed$1 = 1;
|
|
|
23843
24147
|
for(i1 = 0; i1 < scene.images.length; i1++){
|
|
23844
24148
|
scene.textureOptions[i1].image = scene.images[i1];
|
|
23845
24149
|
}
|
|
23846
|
-
_this.updateSceneData(scene.jsonScene.items);
|
|
23847
24150
|
_state.label = 5;
|
|
23848
24151
|
case 5:
|
|
23849
24152
|
return [
|
|
@@ -23900,7 +24203,6 @@ var seed$1 = 1;
|
|
|
23900
24203
|
];
|
|
23901
24204
|
case 10:
|
|
23902
24205
|
loadedTextures = _state.sent();
|
|
23903
|
-
_this.updateSceneData(jsonScene.items);
|
|
23904
24206
|
scene = {
|
|
23905
24207
|
timeInfos: timeInfos,
|
|
23906
24208
|
url: url,
|
|
@@ -25234,6 +25536,7 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
25234
25536
|
* 跳到指定时间点(不做任何播放行为)
|
|
25235
25537
|
* @param time - 相对 startTime 的时间
|
|
25236
25538
|
*/ _proto.setTime = function setTime(time) {
|
|
25539
|
+
var speed = this.speed;
|
|
25237
25540
|
var pause = this.paused;
|
|
25238
25541
|
if (pause) {
|
|
25239
25542
|
this.resume();
|
|
@@ -25242,7 +25545,9 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
25242
25545
|
this.rootComposition.onStart();
|
|
25243
25546
|
this.rootComposition.isStartCalled = true;
|
|
25244
25547
|
}
|
|
25548
|
+
this.setSpeed(1);
|
|
25245
25549
|
this.forwardTime(time + this.startTime);
|
|
25550
|
+
this.setSpeed(speed);
|
|
25246
25551
|
if (pause) {
|
|
25247
25552
|
this.pause();
|
|
25248
25553
|
}
|
|
@@ -25254,7 +25559,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
25254
25559
|
/**
|
|
25255
25560
|
* 前进合成到指定时间
|
|
25256
25561
|
* @param time - 相对0时刻的时间
|
|
25257
|
-
* @param skipRender - 是否跳过渲染
|
|
25258
25562
|
*/ _proto.forwardTime = function forwardTime(time) {
|
|
25259
25563
|
var deltaTime = time * 1000 - this.rootComposition.time * 1000;
|
|
25260
25564
|
var reverse = deltaTime < 0;
|
|
@@ -25304,7 +25608,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
25304
25608
|
/**
|
|
25305
25609
|
* 合成更新,针对所有 item 的更新
|
|
25306
25610
|
* @param deltaTime - 更新的时间步长
|
|
25307
|
-
* @param skipRender - 是否需要渲染
|
|
25308
25611
|
*/ _proto.update = function update(deltaTime) {
|
|
25309
25612
|
if (!this.assigned || this.paused) {
|
|
25310
25613
|
return;
|
|
@@ -27807,7 +28110,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem, true);
|
|
|
27807
28110
|
registerPlugin("particle", ParticleLoader, exports.VFXItem, true);
|
|
27808
28111
|
registerPlugin("cal", CalculateLoader, exports.VFXItem, true);
|
|
27809
28112
|
registerPlugin("interact", InteractLoader, exports.VFXItem, true);
|
|
27810
|
-
var version$1 = "2.1.0-alpha.
|
|
28113
|
+
var version$1 = "2.1.0-alpha.2";
|
|
27811
28114
|
logger.info("Core version: " + version$1 + ".");
|
|
27812
28115
|
|
|
27813
28116
|
var _obj;
|
|
@@ -29488,7 +29791,7 @@ setMaxSpriteMeshItemCount(8);
|
|
|
29488
29791
|
*/ Mesh.create = function(engine, props) {
|
|
29489
29792
|
return new ThreeMesh(engine, props);
|
|
29490
29793
|
};
|
|
29491
|
-
var version = "2.1.0-alpha.
|
|
29794
|
+
var version = "2.1.0-alpha.2";
|
|
29492
29795
|
logger.info("THREEJS plugin version: " + version + ".");
|
|
29493
29796
|
|
|
29494
29797
|
exports.AbstractPlugin = AbstractPlugin;
|