@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.mjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Description: Galacean Effects runtime threejs plugin for the web
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
|
|
6
|
-
* Version: v2.1.0-alpha.
|
|
6
|
+
* Version: v2.1.0-alpha.2
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import * as THREE from 'three';
|
|
@@ -4687,7 +4687,13 @@ function getDirectStore(target) {
|
|
|
4687
4687
|
}
|
|
4688
4688
|
};
|
|
4689
4689
|
_proto.dispose = function dispose() {
|
|
4690
|
-
this.
|
|
4690
|
+
if (this.isEnableCalled) {
|
|
4691
|
+
this.disable();
|
|
4692
|
+
}
|
|
4693
|
+
if (this.isAwakeCalled) {
|
|
4694
|
+
this.isAwakeCalled = false;
|
|
4695
|
+
this.onDestroy();
|
|
4696
|
+
}
|
|
4691
4697
|
if (this.item) {
|
|
4692
4698
|
removeItem(this.item.components, this);
|
|
4693
4699
|
}
|
|
@@ -8344,7 +8350,7 @@ var seed$9 = 1;
|
|
|
8344
8350
|
* 通过 URL 创建 Texture 对象。
|
|
8345
8351
|
* @param url - 要创建的 Texture URL
|
|
8346
8352
|
* @since 2.0.0
|
|
8347
|
-
*/ Texture.fromImage = function fromImage(url, engine) {
|
|
8353
|
+
*/ Texture.fromImage = function fromImage(url, engine, options) {
|
|
8348
8354
|
return _async_to_generator(function() {
|
|
8349
8355
|
var image, texture;
|
|
8350
8356
|
return __generator(this, function(_state) {
|
|
@@ -8356,12 +8362,13 @@ var seed$9 = 1;
|
|
|
8356
8362
|
];
|
|
8357
8363
|
case 1:
|
|
8358
8364
|
image = _state.sent();
|
|
8359
|
-
texture = Texture.create(engine, {
|
|
8365
|
+
texture = Texture.create(engine, _extends({
|
|
8360
8366
|
sourceType: TextureSourceType.image,
|
|
8361
8367
|
image: image,
|
|
8368
|
+
target: glContext.TEXTURE_2D,
|
|
8362
8369
|
id: generateGUID(),
|
|
8363
8370
|
flipY: true
|
|
8364
|
-
});
|
|
8371
|
+
}, options));
|
|
8365
8372
|
texture.initialize();
|
|
8366
8373
|
return [
|
|
8367
8374
|
2,
|
|
@@ -10028,8 +10035,13 @@ var RandomValue = /*#__PURE__*/ function(ValueGetter) {
|
|
|
10028
10035
|
this.min = props[0];
|
|
10029
10036
|
this.max = props[1];
|
|
10030
10037
|
};
|
|
10031
|
-
_proto.getValue = function getValue(time) {
|
|
10032
|
-
|
|
10038
|
+
_proto.getValue = function getValue(time, seed) {
|
|
10039
|
+
var randomSeed = seed != null ? seed : Math.random();
|
|
10040
|
+
return this.min + randomSeed * (this.max - this.min);
|
|
10041
|
+
};
|
|
10042
|
+
_proto.getIntegrateValue = function getIntegrateValue(t0, t1, timeScale) {
|
|
10043
|
+
var seed = timeScale != null ? timeScale : 1.0;
|
|
10044
|
+
return (this.min + seed * (this.max - this.min)) * (t1 - t0);
|
|
10033
10045
|
};
|
|
10034
10046
|
_proto.toUniform = function toUniform() {
|
|
10035
10047
|
return new Float32Array([
|
|
@@ -10288,15 +10300,19 @@ var BezierCurve = /*#__PURE__*/ function(ValueGetter) {
|
|
|
10288
10300
|
points: points,
|
|
10289
10301
|
timeInterval: timeInterval,
|
|
10290
10302
|
valueInterval: valueInterval,
|
|
10291
|
-
curve: curve
|
|
10303
|
+
curve: curve,
|
|
10304
|
+
timeStart: Number(s.x),
|
|
10305
|
+
timeEnd: Number(e.x)
|
|
10292
10306
|
};
|
|
10293
10307
|
}
|
|
10294
10308
|
};
|
|
10295
10309
|
_proto.getValue = function getValue(time) {
|
|
10296
10310
|
var result = 0;
|
|
10297
10311
|
var keyTimeData = Object.keys(this.curveMap);
|
|
10298
|
-
var keyTimeStart =
|
|
10299
|
-
var keyTimeEnd =
|
|
10312
|
+
var keyTimeStart = this.curveMap[keyTimeData[0]].timeStart;
|
|
10313
|
+
var keyTimeEnd = this.curveMap[keyTimeData[keyTimeData.length - 1]].timeEnd;
|
|
10314
|
+
// const keyTimeStart = Number(keyTimeData[0].split('&')[0]);
|
|
10315
|
+
// const keyTimeEnd = Number(keyTimeData[keyTimeData.length - 1].split('&')[1]);
|
|
10300
10316
|
if (time <= keyTimeStart) {
|
|
10301
10317
|
return this.getCurveValue(keyTimeData[0], keyTimeStart);
|
|
10302
10318
|
}
|
|
@@ -10304,7 +10320,9 @@ var BezierCurve = /*#__PURE__*/ function(ValueGetter) {
|
|
|
10304
10320
|
return this.getCurveValue(keyTimeData[keyTimeData.length - 1], keyTimeEnd);
|
|
10305
10321
|
}
|
|
10306
10322
|
for(var i = 0; i < keyTimeData.length; i++){
|
|
10307
|
-
var
|
|
10323
|
+
var xMin = this.curveMap[keyTimeData[i]].timeStart;
|
|
10324
|
+
var xMax = this.curveMap[keyTimeData[i]].timeEnd;
|
|
10325
|
+
// const [xMin, xMax] = keyTimeData[i].split('&');
|
|
10308
10326
|
if (time >= Number(xMin) && time < Number(xMax)) {
|
|
10309
10327
|
result = this.getCurveValue(keyTimeData[i], time);
|
|
10310
10328
|
break;
|
|
@@ -10317,12 +10335,13 @@ var BezierCurve = /*#__PURE__*/ function(ValueGetter) {
|
|
|
10317
10335
|
var time = (t1 - t0) / ts;
|
|
10318
10336
|
var result = 0;
|
|
10319
10337
|
var keyTimeData = Object.keys(this.curveMap);
|
|
10320
|
-
var keyTimeStart =
|
|
10338
|
+
var keyTimeStart = this.curveMap[keyTimeData[0]].timeStart;
|
|
10321
10339
|
if (time <= keyTimeStart) {
|
|
10322
10340
|
return 0;
|
|
10323
10341
|
}
|
|
10324
10342
|
for(var i = 0; i < keyTimeData.length; i++){
|
|
10325
|
-
var
|
|
10343
|
+
var xMin = this.curveMap[keyTimeData[i]].timeStart;
|
|
10344
|
+
var xMax = this.curveMap[keyTimeData[i]].timeEnd;
|
|
10326
10345
|
if (time >= Number(xMax)) {
|
|
10327
10346
|
result += ts * this.getCurveIntegrateValue(keyTimeData[i], Number(xMax));
|
|
10328
10347
|
}
|
|
@@ -11556,7 +11575,7 @@ var itemFrag = "precision highp float;varying vec4 vColor;varying vec2 vTexCoord
|
|
|
11556
11575
|
|
|
11557
11576
|
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";
|
|
11558
11577
|
|
|
11559
|
-
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}}";
|
|
11578
|
+
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}}";
|
|
11560
11579
|
|
|
11561
11580
|
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}";
|
|
11562
11581
|
|
|
@@ -16534,6 +16553,7 @@ function getTrailMeshShader(trails, particleMaxCount, name, gpuCapability, env)
|
|
|
16534
16553
|
_proto.onUpdate = function onUpdate(dt) {
|
|
16535
16554
|
var time = this.particleMesh.time;
|
|
16536
16555
|
this.particleMesh.mesh.material.setVector4("uParams", new Vector4(time, this.item.duration, 0, 0));
|
|
16556
|
+
this.particleMesh.onUpdate(dt);
|
|
16537
16557
|
};
|
|
16538
16558
|
_proto.render = function render(renderer) {
|
|
16539
16559
|
for(var _iterator = _create_for_of_iterator_helper_loose(this.meshes), _step; !(_step = _iterator()).done;){
|
|
@@ -16548,6 +16568,7 @@ function getTrailMeshShader(trails, particleMaxCount, name, gpuCapability, env)
|
|
|
16548
16568
|
};
|
|
16549
16569
|
_proto.updateTime = function updateTime(now, delta) {
|
|
16550
16570
|
this.particleMesh.time = now;
|
|
16571
|
+
// this.particleMesh.onUpdate(delta);
|
|
16551
16572
|
if (this.trailMesh) {
|
|
16552
16573
|
this.trailMesh.time = now;
|
|
16553
16574
|
this.trailMesh.onUpdate(delta);
|
|
@@ -16646,6 +16667,9 @@ var ParticleSystem = /*#__PURE__*/ function(Component) {
|
|
|
16646
16667
|
_proto.isFrozen = function isFrozen() {
|
|
16647
16668
|
return this.frozen;
|
|
16648
16669
|
};
|
|
16670
|
+
_proto.isEnded = function isEnded() {
|
|
16671
|
+
return this.ended;
|
|
16672
|
+
};
|
|
16649
16673
|
_proto.initEmitterTransform = function initEmitterTransform() {
|
|
16650
16674
|
var position = this.item.transform.position.clone();
|
|
16651
16675
|
var rotation = this.item.transform.rotation.clone();
|
|
@@ -17591,11 +17615,8 @@ function randomArrItem(arr, keepArr) {
|
|
|
17591
17615
|
}
|
|
17592
17616
|
var particleSystem = this.particleSystem;
|
|
17593
17617
|
if (particleSystem) {
|
|
17594
|
-
// TODO: [1.31] @十弦 验证 https://github.com/galacean/effects-runtime/commit/3e7d73d37b7d98c2a25e4544e80e928b17801ccd#diff-fae062f28caf3771cfedd3a20dc22f9749bd054c7541bf2fd50a9a5e413153d4
|
|
17595
|
-
// particleSystem.setParentTransform(parentItem.transform);
|
|
17596
|
-
particleSystem.setVisible(true);
|
|
17597
17618
|
var deltaTime = context.deltaTime;
|
|
17598
|
-
if (this.time < particleSystem.item.duration && particleSystem.
|
|
17619
|
+
if (this.time >= 0 && this.time < particleSystem.item.duration && particleSystem.isEnded()) {
|
|
17599
17620
|
particleSystem.reset();
|
|
17600
17621
|
}
|
|
17601
17622
|
if (Math.abs(this.time - this.lastTime) < 0.001) {
|
|
@@ -17654,6 +17675,13 @@ var particleUniformTypeMap = {
|
|
|
17654
17675
|
var ParticleMesh = /*#__PURE__*/ function() {
|
|
17655
17676
|
function ParticleMesh(engine, props) {
|
|
17656
17677
|
this.particleCount = 0;
|
|
17678
|
+
this.cachedVelocity = new Vector3();
|
|
17679
|
+
this.cachedRotationVector3 = new Vector3();
|
|
17680
|
+
this.cachedRotationMatrix = new Matrix3();
|
|
17681
|
+
this.cachedLinearMove = new Vector3();
|
|
17682
|
+
this.tempMatrix3 = new Matrix3();
|
|
17683
|
+
this.tempVector3 = new Vector3();
|
|
17684
|
+
this.VERT_MAX_KEY_FRAME_COUNT = 0;
|
|
17657
17685
|
var _engine_renderer;
|
|
17658
17686
|
var env = ((_engine_renderer = engine.renderer) != null ? _engine_renderer : {}).env;
|
|
17659
17687
|
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;
|
|
@@ -17872,6 +17900,7 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
17872
17900
|
"FRAG_MAX_KEY_FRAME_COUNT",
|
|
17873
17901
|
fragmentKeyFrameMeta.max
|
|
17874
17902
|
]);
|
|
17903
|
+
this.VERT_MAX_KEY_FRAME_COUNT = vertexKeyFrameMeta.max;
|
|
17875
17904
|
var fragment = particleFrag;
|
|
17876
17905
|
var originalVertex = "#define LOOKUP_TEXTURE_CURVE " + vertex_lookup_texture + "\n" + particleVert;
|
|
17877
17906
|
var vertex = originalVertex;
|
|
@@ -17980,6 +18009,7 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
17980
18009
|
this.orbitalVelOverLifetime = orbitalVelOverLifetime;
|
|
17981
18010
|
this.orbitalVelOverLifetime = orbitalVelOverLifetime;
|
|
17982
18011
|
this.gravityModifier = gravityModifier;
|
|
18012
|
+
this.rotationOverLifetime = rotationOverLifetime;
|
|
17983
18013
|
this.maxCount = maxCount;
|
|
17984
18014
|
// this.duration = duration;
|
|
17985
18015
|
this.textureOffsets = textureFlip ? [
|
|
@@ -18044,15 +18074,230 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
18044
18074
|
// @ts-expect-error
|
|
18045
18075
|
geometry.setIndexData(new index.constructor(0));
|
|
18046
18076
|
};
|
|
18077
|
+
_proto.onUpdate = function onUpdate(dt) {
|
|
18078
|
+
var aPosArray = this.geometry.getAttributeData("aPos"); // vector3
|
|
18079
|
+
var aVelArray = this.geometry.getAttributeData("aVel"); // vector3
|
|
18080
|
+
var aOffsetArray = this.geometry.getAttributeData("aOffset");
|
|
18081
|
+
var aRotArray = this.geometry.getAttributeData("aRot"); // vector3
|
|
18082
|
+
var aSeedArray = this.geometry.getAttributeData("aSeed"); // float
|
|
18083
|
+
// const uParams = this.mesh.material.getVector4('uParams');
|
|
18084
|
+
// if (!uParams) {
|
|
18085
|
+
// return;
|
|
18086
|
+
// }
|
|
18087
|
+
var localTime = this.time;
|
|
18088
|
+
var particleCount = Math.ceil(aPosArray.length / 12);
|
|
18089
|
+
// calculate particle translation
|
|
18090
|
+
var aTranslationArray = this.geometry.getAttributeData("aTranslation");
|
|
18091
|
+
if (aTranslationArray.length < particleCount * 3) {
|
|
18092
|
+
aTranslationArray = this.expandArray(aTranslationArray, particleCount * 3);
|
|
18093
|
+
}
|
|
18094
|
+
var velocity = this.cachedVelocity;
|
|
18095
|
+
for(var i = 0; i < particleCount; i++){
|
|
18096
|
+
var velOffset = i * 12 + 3;
|
|
18097
|
+
velocity.set(aVelArray[velOffset], aVelArray[velOffset + 1], aVelArray[velOffset + 2]);
|
|
18098
|
+
this.calculateTranslation(velocity, aOffsetArray[i * 4 + 2], localTime, aOffsetArray[i * 4 + 3]);
|
|
18099
|
+
var aTranslationOffset = i * 3;
|
|
18100
|
+
if (aOffsetArray[i * 4 + 2] < localTime) {
|
|
18101
|
+
var translation = velocity.multiply(dt / 1000);
|
|
18102
|
+
aTranslationArray[aTranslationOffset] += translation.x;
|
|
18103
|
+
aTranslationArray[aTranslationOffset + 1] += translation.y;
|
|
18104
|
+
aTranslationArray[aTranslationOffset + 2] += translation.z;
|
|
18105
|
+
}
|
|
18106
|
+
}
|
|
18107
|
+
this.geometry.setAttributeData("aTranslation", aTranslationArray);
|
|
18108
|
+
// calculate particle rotation
|
|
18109
|
+
var aRotationArray = this.geometry.getAttributeData("aRotation0");
|
|
18110
|
+
if (aRotationArray.length < particleCount * 9) {
|
|
18111
|
+
aRotationArray = this.expandArray(aRotationArray, particleCount * 9);
|
|
18112
|
+
}
|
|
18113
|
+
for(var i1 = 0; i1 < particleCount; i1++){
|
|
18114
|
+
var time = localTime - aOffsetArray[i1 * 4 + 2];
|
|
18115
|
+
var duration = aOffsetArray[i1 * 4 + 3];
|
|
18116
|
+
var life = clamp$1(time / duration, 0.0, 1.0);
|
|
18117
|
+
var aRotOffset = i1 * 8;
|
|
18118
|
+
var aRot = this.cachedRotationVector3.set(aRotArray[aRotOffset], aRotArray[aRotOffset + 1], aRotArray[aRotOffset + 2]);
|
|
18119
|
+
var aSeed = aSeedArray[i1 * 8 + 3];
|
|
18120
|
+
var aRotation = this.transformFromRotation(aRot, life, duration, aSeed, this.cachedRotationMatrix);
|
|
18121
|
+
var aRotationOffset = i1 * 9;
|
|
18122
|
+
var matrixArray = aRotation.toArray();
|
|
18123
|
+
aRotationArray.set(matrixArray, aRotationOffset);
|
|
18124
|
+
}
|
|
18125
|
+
this.geometry.setAttributeData("aRotation0", aRotationArray);
|
|
18126
|
+
// calculate linear movement
|
|
18127
|
+
var aLinearMoveArray = this.geometry.getAttributeData("aLinearMove");
|
|
18128
|
+
if (aLinearMoveArray.length < particleCount * 3) {
|
|
18129
|
+
aLinearMoveArray = this.expandArray(aLinearMoveArray, particleCount * 3);
|
|
18130
|
+
}
|
|
18131
|
+
var linearMove = this.cachedLinearMove;
|
|
18132
|
+
for(var i2 = 0; i2 < particleCount; i2++){
|
|
18133
|
+
var time1 = localTime - aOffsetArray[i2 * 4 + 2];
|
|
18134
|
+
var duration1 = aOffsetArray[i2 * 4 + 3];
|
|
18135
|
+
// const life = math.clamp(time / duration, 0.0, 1.0);
|
|
18136
|
+
var aSeed1 = aSeedArray[i2 * 8 + 3];
|
|
18137
|
+
linearMove.setZero();
|
|
18138
|
+
this.calLinearMov(time1, duration1, aSeed1, linearMove);
|
|
18139
|
+
var aLinearMoveOffset = i2 * 3;
|
|
18140
|
+
aLinearMoveArray[aLinearMoveOffset] = linearMove.x;
|
|
18141
|
+
aLinearMoveArray[aLinearMoveOffset + 1] = linearMove.y;
|
|
18142
|
+
aLinearMoveArray[aLinearMoveOffset + 2] = linearMove.z;
|
|
18143
|
+
}
|
|
18144
|
+
this.geometry.setAttributeData("aLinearMove", aLinearMoveArray);
|
|
18145
|
+
};
|
|
18047
18146
|
_proto.minusTime = function minusTime(time) {
|
|
18048
|
-
var
|
|
18049
|
-
|
|
18050
|
-
|
|
18051
|
-
data[i + 2] -= time;
|
|
18147
|
+
var aOffset = this.geometry.getAttributeData("aOffset");
|
|
18148
|
+
for(var i = 0; i < aOffset.length; i += 4){
|
|
18149
|
+
aOffset[i + 2] -= time;
|
|
18052
18150
|
}
|
|
18053
|
-
this.geometry.setAttributeData("aOffset",
|
|
18151
|
+
this.geometry.setAttributeData("aOffset", aOffset);
|
|
18054
18152
|
this.time -= time;
|
|
18055
18153
|
};
|
|
18154
|
+
_proto.calculateTranslation = function calculateTranslation(velocity, t0, t1, duration) {
|
|
18155
|
+
var uAcceleration = this.mesh.material.getVector4("uAcceleration");
|
|
18156
|
+
var uGravityModifierValue = this.mesh.material.getVector4("uGravityModifierValue");
|
|
18157
|
+
if (!uAcceleration || !uGravityModifierValue) {
|
|
18158
|
+
return velocity;
|
|
18159
|
+
}
|
|
18160
|
+
var dt = t1 - t0; // 相对delay的时间
|
|
18161
|
+
var d = this.gravityModifier.getIntegrateValue(0, dt, duration);
|
|
18162
|
+
var acc = this.tempVector3.set(uAcceleration.x * d, uAcceleration.y * d, uAcceleration.z * d);
|
|
18163
|
+
// speedIntegrate = speedOverLifetime.getIntegrateValue(0, time, duration);
|
|
18164
|
+
if (this.speedOverLifetime) {
|
|
18165
|
+
// dt / dur 归一化
|
|
18166
|
+
var speed = this.speedOverLifetime.getValue(dt / duration);
|
|
18167
|
+
return velocity.multiply(speed).add(acc);
|
|
18168
|
+
}
|
|
18169
|
+
return velocity.add(acc);
|
|
18170
|
+
};
|
|
18171
|
+
_proto.transformFromRotation = function transformFromRotation(rot, life, dur, aSeed, result) {
|
|
18172
|
+
var rotation = rot;
|
|
18173
|
+
if (!this.rotationOverLifetime) {
|
|
18174
|
+
return result.setZero();
|
|
18175
|
+
}
|
|
18176
|
+
if (this.rotationOverLifetime.asRotation) {
|
|
18177
|
+
// Adjust rotation based on the specified lifetime components
|
|
18178
|
+
if (this.rotationOverLifetime.x) {
|
|
18179
|
+
if (_instanceof1(this.rotationOverLifetime.x, RandomValue)) {
|
|
18180
|
+
rotation.x += this.rotationOverLifetime.x.getValue(life, aSeed);
|
|
18181
|
+
} else {
|
|
18182
|
+
rotation.x += this.rotationOverLifetime.x.getValue(life);
|
|
18183
|
+
}
|
|
18184
|
+
}
|
|
18185
|
+
if (this.rotationOverLifetime.y) {
|
|
18186
|
+
if (_instanceof1(this.rotationOverLifetime.y, RandomValue)) {
|
|
18187
|
+
rotation.y += this.rotationOverLifetime.y.getValue(life, aSeed);
|
|
18188
|
+
} else {
|
|
18189
|
+
rotation.y += this.rotationOverLifetime.y.getValue(life);
|
|
18190
|
+
}
|
|
18191
|
+
}
|
|
18192
|
+
if (this.rotationOverLifetime.z) {
|
|
18193
|
+
if (_instanceof1(this.rotationOverLifetime.z, RandomValue)) {
|
|
18194
|
+
rotation.z += this.rotationOverLifetime.z.getValue(life, aSeed);
|
|
18195
|
+
} else {
|
|
18196
|
+
rotation.z += this.rotationOverLifetime.z.getValue(life);
|
|
18197
|
+
}
|
|
18198
|
+
}
|
|
18199
|
+
} else {
|
|
18200
|
+
// Adjust rotation based on the specified lifetime components
|
|
18201
|
+
if (this.rotationOverLifetime.x) {
|
|
18202
|
+
if (_instanceof1(this.rotationOverLifetime.x, RandomValue)) {
|
|
18203
|
+
rotation.x += this.rotationOverLifetime.x.getIntegrateValue(0.0, life, aSeed) * dur;
|
|
18204
|
+
} else {
|
|
18205
|
+
rotation.x += this.rotationOverLifetime.x.getIntegrateValue(0.0, life, dur) * dur;
|
|
18206
|
+
}
|
|
18207
|
+
}
|
|
18208
|
+
if (this.rotationOverLifetime.y) {
|
|
18209
|
+
if (_instanceof1(this.rotationOverLifetime.y, RandomValue)) {
|
|
18210
|
+
rotation.y += this.rotationOverLifetime.y.getIntegrateValue(0.0, life, aSeed) * dur;
|
|
18211
|
+
} else {
|
|
18212
|
+
rotation.y += this.rotationOverLifetime.y.getIntegrateValue(0.0, life, dur) * dur;
|
|
18213
|
+
}
|
|
18214
|
+
}
|
|
18215
|
+
if (this.rotationOverLifetime.z) {
|
|
18216
|
+
if (_instanceof1(this.rotationOverLifetime.z, RandomValue)) {
|
|
18217
|
+
rotation.z += this.rotationOverLifetime.z.getIntegrateValue(0.0, life, aSeed) * dur;
|
|
18218
|
+
} else {
|
|
18219
|
+
rotation.z += this.rotationOverLifetime.z.getIntegrateValue(0.0, life, dur) * dur;
|
|
18220
|
+
}
|
|
18221
|
+
}
|
|
18222
|
+
}
|
|
18223
|
+
// If the rotation vector is zero, return the identity matrix
|
|
18224
|
+
if (rotation.dot(rotation) === 0.0) {
|
|
18225
|
+
return result.identity();
|
|
18226
|
+
}
|
|
18227
|
+
// Return the rotation matrix derived from the rotation vector
|
|
18228
|
+
return this.mat3FromRotation(rotation, result);
|
|
18229
|
+
};
|
|
18230
|
+
_proto.mat3FromRotation = function mat3FromRotation(rotation, result) {
|
|
18231
|
+
var d2r = Math.PI / 180;
|
|
18232
|
+
var rotationXD2r = rotation.x * d2r;
|
|
18233
|
+
var rotationYD2r = rotation.y * d2r;
|
|
18234
|
+
var rotationZD2r = rotation.z * d2r;
|
|
18235
|
+
var sinRX = Math.sin(rotationXD2r);
|
|
18236
|
+
var sinRY = Math.sin(rotationYD2r);
|
|
18237
|
+
var sinRZ = Math.sin(rotationZD2r);
|
|
18238
|
+
var cosRX = Math.cos(rotationXD2r);
|
|
18239
|
+
var cosRY = Math.cos(rotationYD2r);
|
|
18240
|
+
var cosRZ = Math.cos(rotationZD2r);
|
|
18241
|
+
// rotZ * rotY * rotX
|
|
18242
|
+
result.set(cosRZ, -sinRZ, 0., sinRZ, cosRZ, 0., 0., 0., 1.); //rotZ
|
|
18243
|
+
result.multiply(this.tempMatrix3.set(cosRY, 0., sinRY, 0., 1., 0., -sinRY, 0, cosRY)); //rotY
|
|
18244
|
+
result.multiply(this.tempMatrix3.set(1., 0., 0., 0, cosRX, -sinRX, 0., sinRX, cosRX)); //rotX
|
|
18245
|
+
return result;
|
|
18246
|
+
};
|
|
18247
|
+
_proto.calLinearMov = function calLinearMov(time, duration, aSeed, result) {
|
|
18248
|
+
var mov = result;
|
|
18249
|
+
var lifetime = time / duration;
|
|
18250
|
+
if (!this.linearVelOverLifetime || !this.linearVelOverLifetime.enabled) {
|
|
18251
|
+
return mov;
|
|
18252
|
+
}
|
|
18253
|
+
if (this.linearVelOverLifetime.asMovement) {
|
|
18254
|
+
if (this.linearVelOverLifetime.x) {
|
|
18255
|
+
if (_instanceof1(this.linearVelOverLifetime.x, RandomValue)) {
|
|
18256
|
+
mov.x = this.linearVelOverLifetime.x.getValue(lifetime, aSeed);
|
|
18257
|
+
} else {
|
|
18258
|
+
mov.x = this.linearVelOverLifetime.x.getValue(lifetime);
|
|
18259
|
+
}
|
|
18260
|
+
}
|
|
18261
|
+
if (this.linearVelOverLifetime.y) {
|
|
18262
|
+
if (_instanceof1(this.linearVelOverLifetime.y, RandomValue)) {
|
|
18263
|
+
mov.y = this.linearVelOverLifetime.y.getValue(lifetime, aSeed);
|
|
18264
|
+
} else {
|
|
18265
|
+
mov.y = this.linearVelOverLifetime.y.getValue(lifetime);
|
|
18266
|
+
}
|
|
18267
|
+
}
|
|
18268
|
+
if (this.linearVelOverLifetime.z) {
|
|
18269
|
+
if (_instanceof1(this.linearVelOverLifetime.z, RandomValue)) {
|
|
18270
|
+
mov.z = this.linearVelOverLifetime.z.getValue(lifetime, aSeed);
|
|
18271
|
+
} else {
|
|
18272
|
+
mov.z = this.linearVelOverLifetime.z.getValue(lifetime);
|
|
18273
|
+
}
|
|
18274
|
+
}
|
|
18275
|
+
} else {
|
|
18276
|
+
// Adjust rotation based on the specified lifetime components
|
|
18277
|
+
if (this.linearVelOverLifetime.x) {
|
|
18278
|
+
if (_instanceof1(this.linearVelOverLifetime.x, RandomValue)) {
|
|
18279
|
+
mov.x = this.linearVelOverLifetime.x.getIntegrateValue(0.0, time, aSeed);
|
|
18280
|
+
} else {
|
|
18281
|
+
mov.x = this.linearVelOverLifetime.x.getIntegrateValue(0.0, time, duration);
|
|
18282
|
+
}
|
|
18283
|
+
}
|
|
18284
|
+
if (this.linearVelOverLifetime.y) {
|
|
18285
|
+
if (_instanceof1(this.linearVelOverLifetime.y, RandomValue)) {
|
|
18286
|
+
mov.y = this.linearVelOverLifetime.y.getIntegrateValue(0.0, time, aSeed);
|
|
18287
|
+
} else {
|
|
18288
|
+
mov.y = this.linearVelOverLifetime.y.getIntegrateValue(0.0, time, duration);
|
|
18289
|
+
}
|
|
18290
|
+
}
|
|
18291
|
+
if (this.linearVelOverLifetime.z) {
|
|
18292
|
+
if (_instanceof1(this.linearVelOverLifetime.z, RandomValue)) {
|
|
18293
|
+
mov.z = this.linearVelOverLifetime.z.getIntegrateValue(0.0, time, aSeed);
|
|
18294
|
+
} else {
|
|
18295
|
+
mov.z = this.linearVelOverLifetime.z.getIntegrateValue(0.0, time, duration);
|
|
18296
|
+
}
|
|
18297
|
+
}
|
|
18298
|
+
}
|
|
18299
|
+
return mov;
|
|
18300
|
+
};
|
|
18056
18301
|
_proto.removePoint = function removePoint(index) {
|
|
18057
18302
|
if (index < this.particleCount) {
|
|
18058
18303
|
this.geometry.setAttributeSubData("aOffset", index * 16, new Float32Array(16));
|
|
@@ -18076,7 +18321,8 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
18076
18321
|
var pointData = {
|
|
18077
18322
|
aPos: new Float32Array(48),
|
|
18078
18323
|
aRot: new Float32Array(32),
|
|
18079
|
-
aOffset: new Float32Array(16)
|
|
18324
|
+
aOffset: new Float32Array(16),
|
|
18325
|
+
aTranslation: new Float32Array(12)
|
|
18080
18326
|
};
|
|
18081
18327
|
var useSprite = this.useSprite;
|
|
18082
18328
|
if (useSprite) {
|
|
@@ -18185,6 +18431,11 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
18185
18431
|
geometry.setDrawCount(this.particleCount * 6);
|
|
18186
18432
|
}
|
|
18187
18433
|
};
|
|
18434
|
+
_proto.expandArray = function expandArray(array, newSize) {
|
|
18435
|
+
var newArr = new Float32Array(newSize);
|
|
18436
|
+
newArr.set(array);
|
|
18437
|
+
return newArr;
|
|
18438
|
+
};
|
|
18188
18439
|
return ParticleMesh;
|
|
18189
18440
|
}();
|
|
18190
18441
|
var gl2UniformSlots = [
|
|
@@ -18254,6 +18505,32 @@ function generateGeometryProps(maxVertex, useSprite, name) {
|
|
|
18254
18505
|
size: 4,
|
|
18255
18506
|
stride: 4 * bpe,
|
|
18256
18507
|
data: new Float32Array(0)
|
|
18508
|
+
},
|
|
18509
|
+
aTranslation: {
|
|
18510
|
+
size: 3,
|
|
18511
|
+
data: new Float32Array(0)
|
|
18512
|
+
},
|
|
18513
|
+
aLinearMove: {
|
|
18514
|
+
size: 3,
|
|
18515
|
+
data: new Float32Array(0)
|
|
18516
|
+
},
|
|
18517
|
+
aRotation0: {
|
|
18518
|
+
size: 3,
|
|
18519
|
+
offset: 0,
|
|
18520
|
+
stride: 9 * bpe,
|
|
18521
|
+
data: new Float32Array(0)
|
|
18522
|
+
},
|
|
18523
|
+
aRotation1: {
|
|
18524
|
+
size: 3,
|
|
18525
|
+
offset: 3 * bpe,
|
|
18526
|
+
stride: 9 * bpe,
|
|
18527
|
+
dataSource: "aRotation0"
|
|
18528
|
+
},
|
|
18529
|
+
aRotation2: {
|
|
18530
|
+
size: 3,
|
|
18531
|
+
offset: 6 * bpe,
|
|
18532
|
+
stride: 9 * bpe,
|
|
18533
|
+
dataSource: "aRotation0"
|
|
18257
18534
|
}
|
|
18258
18535
|
};
|
|
18259
18536
|
if (useSprite) {
|
|
@@ -19460,6 +19737,18 @@ function compareTracks(a, b) {
|
|
|
19460
19737
|
}
|
|
19461
19738
|
}
|
|
19462
19739
|
};
|
|
19740
|
+
_proto.showItems = function showItems() {
|
|
19741
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(this.items), _step; !(_step = _iterator()).done;){
|
|
19742
|
+
var item = _step.value;
|
|
19743
|
+
item.setVisible(true);
|
|
19744
|
+
}
|
|
19745
|
+
};
|
|
19746
|
+
_proto.hideItems = function hideItems() {
|
|
19747
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(this.items), _step; !(_step = _iterator()).done;){
|
|
19748
|
+
var item = _step.value;
|
|
19749
|
+
item.setVisible(false);
|
|
19750
|
+
}
|
|
19751
|
+
};
|
|
19463
19752
|
_proto.onDestroy = function onDestroy() {
|
|
19464
19753
|
if (this.item.composition) {
|
|
19465
19754
|
if (this.items) {
|
|
@@ -19570,6 +19859,34 @@ function compareTracks(a, b) {
|
|
|
19570
19859
|
return CompositionComponent;
|
|
19571
19860
|
}(Behaviour);
|
|
19572
19861
|
|
|
19862
|
+
var SubCompositionMixerPlayable = /*#__PURE__*/ function(Playable) {
|
|
19863
|
+
_inherits(SubCompositionMixerPlayable, Playable);
|
|
19864
|
+
function SubCompositionMixerPlayable() {
|
|
19865
|
+
return Playable.apply(this, arguments);
|
|
19866
|
+
}
|
|
19867
|
+
var _proto = SubCompositionMixerPlayable.prototype;
|
|
19868
|
+
_proto.processFrame = function processFrame(context) {
|
|
19869
|
+
var boundObject = context.output.getUserData();
|
|
19870
|
+
if (!_instanceof1(boundObject, CompositionComponent)) {
|
|
19871
|
+
return;
|
|
19872
|
+
}
|
|
19873
|
+
var compositionComponent = boundObject;
|
|
19874
|
+
var hasInput = false;
|
|
19875
|
+
for(var i = 0; i < this.getInputCount(); i++){
|
|
19876
|
+
if (this.getInputWeight(i) > 0) {
|
|
19877
|
+
hasInput = true;
|
|
19878
|
+
break;
|
|
19879
|
+
}
|
|
19880
|
+
}
|
|
19881
|
+
if (hasInput) {
|
|
19882
|
+
compositionComponent.showItems();
|
|
19883
|
+
} else {
|
|
19884
|
+
compositionComponent.hideItems();
|
|
19885
|
+
}
|
|
19886
|
+
};
|
|
19887
|
+
return SubCompositionMixerPlayable;
|
|
19888
|
+
}(Playable);
|
|
19889
|
+
|
|
19573
19890
|
var SubCompositionTrack = /*#__PURE__*/ function(TrackAsset) {
|
|
19574
19891
|
_inherits(SubCompositionTrack, TrackAsset);
|
|
19575
19892
|
function SubCompositionTrack() {
|
|
@@ -19582,6 +19899,9 @@ var SubCompositionTrack = /*#__PURE__*/ function(TrackAsset) {
|
|
|
19582
19899
|
}
|
|
19583
19900
|
return parentBinding.getComponent(CompositionComponent);
|
|
19584
19901
|
};
|
|
19902
|
+
_proto.createTrackMixer = function createTrackMixer(graph) {
|
|
19903
|
+
return new SubCompositionMixerPlayable(graph);
|
|
19904
|
+
};
|
|
19585
19905
|
return SubCompositionTrack;
|
|
19586
19906
|
}(TrackAsset);
|
|
19587
19907
|
SubCompositionTrack = __decorate([
|
|
@@ -23677,22 +23997,6 @@ var seed$1 = 1;
|
|
|
23677
23997
|
this.timeout = timeout;
|
|
23678
23998
|
};
|
|
23679
23999
|
/**
|
|
23680
|
-
* 根据用户传入的参数修改场景数据
|
|
23681
|
-
*/ _proto.updateSceneData = function updateSceneData(items) {
|
|
23682
|
-
var variables = this.options.variables;
|
|
23683
|
-
if (!variables || Object.keys(variables).length === 0) {
|
|
23684
|
-
return;
|
|
23685
|
-
}
|
|
23686
|
-
items.forEach(function(item) {
|
|
23687
|
-
if (item.type === ItemType.text) {
|
|
23688
|
-
var textVariable = variables[item.name];
|
|
23689
|
-
if (textVariable) {
|
|
23690
|
-
item.content.options.text = textVariable;
|
|
23691
|
-
}
|
|
23692
|
-
}
|
|
23693
|
-
});
|
|
23694
|
-
};
|
|
23695
|
-
/**
|
|
23696
24000
|
* 场景创建,通过 json 创建出场景对象,并进行提前编译等工作
|
|
23697
24001
|
* @param url - json 的 URL 链接或者 json 对象
|
|
23698
24002
|
* @param renderer - renderer 对象,用于获取管理、编译 shader 及 GPU 上下文的参数
|
|
@@ -23819,7 +24123,6 @@ var seed$1 = 1;
|
|
|
23819
24123
|
for(i1 = 0; i1 < scene.images.length; i1++){
|
|
23820
24124
|
scene.textureOptions[i1].image = scene.images[i1];
|
|
23821
24125
|
}
|
|
23822
|
-
_this.updateSceneData(scene.jsonScene.items);
|
|
23823
24126
|
_state.label = 5;
|
|
23824
24127
|
case 5:
|
|
23825
24128
|
return [
|
|
@@ -23876,7 +24179,6 @@ var seed$1 = 1;
|
|
|
23876
24179
|
];
|
|
23877
24180
|
case 10:
|
|
23878
24181
|
loadedTextures = _state.sent();
|
|
23879
|
-
_this.updateSceneData(jsonScene.items);
|
|
23880
24182
|
scene = {
|
|
23881
24183
|
timeInfos: timeInfos,
|
|
23882
24184
|
url: url,
|
|
@@ -25210,6 +25512,7 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
25210
25512
|
* 跳到指定时间点(不做任何播放行为)
|
|
25211
25513
|
* @param time - 相对 startTime 的时间
|
|
25212
25514
|
*/ _proto.setTime = function setTime(time) {
|
|
25515
|
+
var speed = this.speed;
|
|
25213
25516
|
var pause = this.paused;
|
|
25214
25517
|
if (pause) {
|
|
25215
25518
|
this.resume();
|
|
@@ -25218,7 +25521,9 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
25218
25521
|
this.rootComposition.onStart();
|
|
25219
25522
|
this.rootComposition.isStartCalled = true;
|
|
25220
25523
|
}
|
|
25524
|
+
this.setSpeed(1);
|
|
25221
25525
|
this.forwardTime(time + this.startTime);
|
|
25526
|
+
this.setSpeed(speed);
|
|
25222
25527
|
if (pause) {
|
|
25223
25528
|
this.pause();
|
|
25224
25529
|
}
|
|
@@ -25230,7 +25535,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
25230
25535
|
/**
|
|
25231
25536
|
* 前进合成到指定时间
|
|
25232
25537
|
* @param time - 相对0时刻的时间
|
|
25233
|
-
* @param skipRender - 是否跳过渲染
|
|
25234
25538
|
*/ _proto.forwardTime = function forwardTime(time) {
|
|
25235
25539
|
var deltaTime = time * 1000 - this.rootComposition.time * 1000;
|
|
25236
25540
|
var reverse = deltaTime < 0;
|
|
@@ -25280,7 +25584,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
25280
25584
|
/**
|
|
25281
25585
|
* 合成更新,针对所有 item 的更新
|
|
25282
25586
|
* @param deltaTime - 更新的时间步长
|
|
25283
|
-
* @param skipRender - 是否需要渲染
|
|
25284
25587
|
*/ _proto.update = function update(deltaTime) {
|
|
25285
25588
|
if (!this.assigned || this.paused) {
|
|
25286
25589
|
return;
|
|
@@ -27783,7 +28086,7 @@ registerPlugin("sprite", SpriteLoader, VFXItem, true);
|
|
|
27783
28086
|
registerPlugin("particle", ParticleLoader, VFXItem, true);
|
|
27784
28087
|
registerPlugin("cal", CalculateLoader, VFXItem, true);
|
|
27785
28088
|
registerPlugin("interact", InteractLoader, VFXItem, true);
|
|
27786
|
-
var version$1 = "2.1.0-alpha.
|
|
28089
|
+
var version$1 = "2.1.0-alpha.2";
|
|
27787
28090
|
logger.info("Core version: " + version$1 + ".");
|
|
27788
28091
|
|
|
27789
28092
|
var _obj;
|
|
@@ -29464,7 +29767,7 @@ setMaxSpriteMeshItemCount(8);
|
|
|
29464
29767
|
*/ Mesh.create = function(engine, props) {
|
|
29465
29768
|
return new ThreeMesh(engine, props);
|
|
29466
29769
|
};
|
|
29467
|
-
var version = "2.1.0-alpha.
|
|
29770
|
+
var version = "2.1.0-alpha.2";
|
|
29468
29771
|
logger.info("THREEJS plugin version: " + version + ".");
|
|
29469
29772
|
|
|
29470
29773
|
export { AbstractPlugin, ActivationPlayable, ActivationPlayableAsset, ActivationTrack, AnimationClip, AnimationClipPlayable, AssetLoader, AssetManager, BYTES_TYPE_MAP, Behaviour, BezierCurve, BezierCurvePath, BezierCurveQuat, BinaryAsset, COMPRESSED_TEXTURE, CONSTANT_MAP_BLEND, CONSTANT_MAP_DEPTH, CONSTANT_MAP_STENCIL_FUNC, CONSTANT_MAP_STENCIL_OP, COPY_FRAGMENT_SHADER, COPY_MESH_SHADER_ID, COPY_VERTEX_SHADER, CalculateLoader, Camera, CameraController, CameraVFXItemLoader, Component, Composition, CompositionComponent, CompositionSourceManager, DEFAULT_FONTS, DEFAULT_FPS, Database, DestroyOptions, Downloader, EFFECTS_COPY_MESH_NAME, EVENT_TYPE_CLICK, EVENT_TYPE_TOUCH_END, EVENT_TYPE_TOUCH_MOVE, EVENT_TYPE_TOUCH_START, EffectComponent, EffectsObject, EffectsPackage, Engine, EventEmitter, EventSystem, FilterMode, Float16ArrayWrapper, Framebuffer, GLSLVersion, GPUCapability, Geometry, GlobalUniforms, GradientValue, HELP_LINK, HitTestType, InteractComponent, InteractLoader, InteractMesh, Item, KTXTexture, LineSegments, LinearValue, Material, MaterialDataBlock, MaterialRenderType, Mesh, ObjectBindingTrack, OrderType, PLAYER_OPTIONS_ENV_EDITOR, POST_PROCESS_SETTINGS, ParticleBehaviourPlayable, ParticleBehaviourPlayableAsset, ParticleLoader, ParticleMesh, ParticleSystem, ParticleSystemRenderer, PassTextureCache, PathSegments, PluginSystem, PostProcessVolume, RENDER_PASS_NAME_PREFIX, RENDER_PREFER_LOOKUP_TEXTURE, RUNTIME_ENV, RandomSetValue, RandomValue, RandomVectorValue, RenderFrame, RenderPass, RenderPassAttachmentStorageType, RenderPassDestroyAttachmentType, RenderPassPriorityNormal, RenderPassPriorityPostprocess, RenderPassPriorityPrepare, RenderTargetHandle, RenderTextureFormat, Renderbuffer, Renderer, RendererComponent, RuntimeClip, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0, SEMANTIC_PRE_COLOR_ATTACHMENT_0, SEMANTIC_PRE_COLOR_ATTACHMENT_SIZE_0, SPRITE_VERTEX_STRIDE, SemanticMap, SerializationHelper, Shader, ShaderCompileResultStatus, ShaderFactory, ShaderType, ShaderVariant, SpriteColorPlayable, SpriteColorPlayableAsset, SpriteColorTrack, SpriteComponent, SpriteLoader, StaticValue, SubCompositionPlayableAsset, SubCompositionTrack, TEMPLATE_USE_OFFSCREEN_CANVAS, TEXTURE_UNIFORM_MAP, TextComponent, TextComponentBase, TextLayout, TextLoader, TextStyle, Texture, TextureFactory, TextureLoadAction, TextureSourceType, TextureStoreAction, ThreeComposition, ThreeDisplayObject, ThreeEngine, ThreeMaterial, ThreeSpriteComponent, ThreeTextComponent, ThreeTexture, Ticker, TimelineAsset, TimelineClip, TimelinePlayable, TrackAsset, TrackSortWrapper, TrackType, Transform, TransformAnimationPlayable, TransformPlayableAsset, TransformTrack, VFXItem, ValueGetter, addByOrder, addItem, addItemWithOrder, applyMixins, assertExist, asserts, base64ToFile, blend, calculateTranslation, canvasPool, colorGradingFrag, colorStopsFromGradient, colorToArr$1 as colorToArr, combineImageTemplate, createCopyShader, createGLContext, createKeyFrameMeta, createShape, createValueGetter, decimalEqual, defaultGlobalVolume, defaultPlugins, deserializeMipmapTexture, earcut, effectsClass, effectsClassStore, enlargeBuffer, ensureFixedNumber, ensureVec3, findPreviousRenderPass, gaussianDown_frag as gaussianDownFrag, gaussianDownHFrag, gaussianDownVFrag, gaussianUpFrag, generateEmptyTypedArray, generateGUID, generateHalfFloatTexture, generateTransparentTexture, generateWhiteTexture, getBackgroundImage, getColorFromGradientStops, getConfig, getDefaultTextureFactory, getGeometryByShape, getGeometryTriangles, getImageItemRenderInfo, getKTXTextureOptions, getKeyFrameMetaByRawValue, getMergedStore, getParticleMeshShader, getPixelRatio, getPreMultiAlpha, getStandardComposition, getStandardImage, getStandardItem, getStandardJSON, getTextureSize, glContext, glType2VertexFormatType, gpuTimer, imageDataFromColor, imageDataFromGradient, initErrors, initGLContext, integrate, interpolateColor, isAlipayMiniApp, isAndroid, isArray, isCanvas, isFunction, isIOS, isIOSByUA, isMiniProgram, isObject, isSceneJSON, isSceneURL, isSceneWithOptions, isSimulatorCellPhone, isString, isUniformStruct, isUniformStructArray, isValidFontFamily, isWebGL2, isWechatMiniApp, itemFrag, itemFrameFrag, itemVert, loadAVIFOptional, loadBinary, loadBlob, loadImage, loadMedia, loadVideo, loadWebPOptional, logger, index as math, maxSpriteMeshItemCount, modifyMaxKeyframeShader, nearestPowerOfTwo, noop, normalizeColor, numberToFix, parsePercent$1 as parsePercent, particleFrag, particleOriginTranslateMap$1 as particleOriginTranslateMap, particleUniformTypeMap, particleVert, pluginLoaderMap, randomInRange, registerPlugin, removeItem, rotateVec2, screenMeshVert, serialize, setBlendMode, setConfig, setDefaultTextureFactory, setMaskMode, setMaxSpriteMeshItemCount, setRayFromCamera, setSideMode, setSpriteMeshMaxItemCountByGPU, setUniformValue, sortByOrder, index$1 as spec, spriteMeshShaderFromFilter, spriteMeshShaderFromRenderInfo, spriteMeshShaderIdFromRenderInfo, thresholdFrag, throwDestroyedError, trailVert, translatePoint, trianglesFromRect, unregisterPlugin, valIfUndefined, value, valueDefine, vecFill, vecMulCombine, version, vertexFormatType2GLType };
|