@galacean/effects-threejs 2.0.0-alpha.33 → 2.0.0-alpha.35
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/README.md +20 -0
- package/dist/index.js +291 -225
- 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 +291 -219
- 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.0.0-alpha.
|
|
6
|
+
* Version: v2.0.0-alpha.35
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
@@ -4808,7 +4808,9 @@ __decorate([
|
|
|
4808
4808
|
// }
|
|
4809
4809
|
/**
|
|
4810
4810
|
* 在每次设置 enabled 为 true 时触发
|
|
4811
|
-
*/ _proto.onEnable = function onEnable() {
|
|
4811
|
+
*/ _proto.onEnable = function onEnable() {
|
|
4812
|
+
// OVERRIDE
|
|
4813
|
+
};
|
|
4812
4814
|
/**
|
|
4813
4815
|
* 生命周期函数,在第一次 update 前调用,生命周期内只调用一次
|
|
4814
4816
|
*/ _proto.start = function start() {
|
|
@@ -7677,55 +7679,6 @@ function getPreMultiAlpha(blending) {
|
|
|
7677
7679
|
return 1;
|
|
7678
7680
|
}
|
|
7679
7681
|
}
|
|
7680
|
-
var _obj$7;
|
|
7681
|
-
var downgradeKeywords = (_obj$7 = {}, _obj$7[exports.ShaderType.vertex] = {
|
|
7682
|
-
in: "attribute",
|
|
7683
|
-
out: "varying"
|
|
7684
|
-
}, _obj$7[exports.ShaderType.fragment] = {
|
|
7685
|
-
in: "varying"
|
|
7686
|
-
}, _obj$7);
|
|
7687
|
-
/**
|
|
7688
|
-
* 生成 shader,检测到 WebGL1 上下文会降级
|
|
7689
|
-
* @param macros - 宏定义数组
|
|
7690
|
-
* @param shader - 原始 shader 文本
|
|
7691
|
-
* @param shaderType - shader 类型
|
|
7692
|
-
* @return 去除版本号的 shader 文本
|
|
7693
|
-
*/ function createShaderWithMacros(macros, shader, shaderType, level) {
|
|
7694
|
-
var ret = [];
|
|
7695
|
-
var header = "";
|
|
7696
|
-
// shader 标志宏,没有其他含义,方便不支持完全的自定义 shader 的三方引擎接入使用
|
|
7697
|
-
ret.push("#define GE_RUNTIME");
|
|
7698
|
-
if (macros) {
|
|
7699
|
-
macros.forEach(function(param) {
|
|
7700
|
-
var key = param[0], value = param[1];
|
|
7701
|
-
if (value === true) {
|
|
7702
|
-
ret.push("#define " + key);
|
|
7703
|
-
} else if (Number.isFinite(value)) {
|
|
7704
|
-
ret.push("#define " + key + " " + value);
|
|
7705
|
-
}
|
|
7706
|
-
});
|
|
7707
|
-
header = ret.length ? ret.join("\n") + "\n" : "";
|
|
7708
|
-
}
|
|
7709
|
-
var versionTag = /#version\s+\b\d{3}\b\s*(es)?/;
|
|
7710
|
-
var GL_TYPE = "WEBGL" + level;
|
|
7711
|
-
header = header + ("\n#ifndef " + GL_TYPE + "\n#define " + GL_TYPE + "\n#endif");
|
|
7712
|
-
var fullShader = header + "\n" + shader;
|
|
7713
|
-
// 判断shader是否带有版本头
|
|
7714
|
-
var match = fullShader.match(versionTag);
|
|
7715
|
-
var version = match ? match[0] : "";
|
|
7716
|
-
if (version && version.includes("300")) {
|
|
7717
|
-
var reg = new RegExp("" + version, "g");
|
|
7718
|
-
// 带版本头且level为1,降级
|
|
7719
|
-
if (level === 1) {
|
|
7720
|
-
fullShader = fullShader.replace(/\b(in|out)\b/g, function(str) {
|
|
7721
|
-
var _downgradeKeywords_shaderType_str;
|
|
7722
|
-
return (_downgradeKeywords_shaderType_str = downgradeKeywords[shaderType][str]) != null ? _downgradeKeywords_shaderType_str : str;
|
|
7723
|
-
});
|
|
7724
|
-
}
|
|
7725
|
-
fullShader = fullShader.replace(reg, "\n");
|
|
7726
|
-
}
|
|
7727
|
-
return fullShader;
|
|
7728
|
-
}
|
|
7729
7682
|
function setBlendMode(material, blendMode) {
|
|
7730
7683
|
switch(blendMode){
|
|
7731
7684
|
case undefined:
|
|
@@ -8428,7 +8381,7 @@ function _loadMipmapImage() {
|
|
|
8428
8381
|
return _loadMipmapImage.apply(this, arguments);
|
|
8429
8382
|
}
|
|
8430
8383
|
|
|
8431
|
-
var seed$
|
|
8384
|
+
var seed$9 = 1;
|
|
8432
8385
|
/**
|
|
8433
8386
|
* Texture 抽象类
|
|
8434
8387
|
*/ var Texture = /*#__PURE__*/ function(EffectsObject) {
|
|
@@ -8437,7 +8390,7 @@ var seed$a = 1;
|
|
|
8437
8390
|
var _this;
|
|
8438
8391
|
_this = EffectsObject.call(this, engine) || this;
|
|
8439
8392
|
_this.destroyed = false;
|
|
8440
|
-
_this.id = "Tex" + seed$
|
|
8393
|
+
_this.id = "Tex" + seed$9++;
|
|
8441
8394
|
return _this;
|
|
8442
8395
|
}
|
|
8443
8396
|
var _proto = Texture.prototype;
|
|
@@ -9065,7 +9018,7 @@ exports.MaterialRenderType = void 0;
|
|
|
9065
9018
|
/**
|
|
9066
9019
|
* 用于设置材质默认名称的自增序号
|
|
9067
9020
|
* @internal
|
|
9068
|
-
*/ var seed$
|
|
9021
|
+
*/ var seed$8 = 1;
|
|
9069
9022
|
/**
|
|
9070
9023
|
* Material 抽象类
|
|
9071
9024
|
*/ var Material = /*#__PURE__*/ function(EffectsObject) {
|
|
@@ -9078,14 +9031,14 @@ exports.MaterialRenderType = void 0;
|
|
|
9078
9031
|
_this.destroyed = false;
|
|
9079
9032
|
_this.initialized = false;
|
|
9080
9033
|
if (props) {
|
|
9081
|
-
var _props_name = props.name, name = _props_name === void 0 ? "Material" + seed$
|
|
9034
|
+
var _props_name = props.name, name = _props_name === void 0 ? "Material" + seed$8++ : _props_name, _props_renderType = props.renderType, renderType = _props_renderType === void 0 ? 0 : _props_renderType, shader = props.shader, uniformSemantics = props.uniformSemantics;
|
|
9082
9035
|
_this.name = name;
|
|
9083
9036
|
_this.renderType = renderType; // TODO 没有地方用到
|
|
9084
9037
|
_this.shaderSource = shader;
|
|
9085
9038
|
_this.props = props;
|
|
9086
9039
|
_this.uniformSemantics = _extends({}, uniformSemantics); // TODO 废弃,待移除
|
|
9087
9040
|
} else {
|
|
9088
|
-
_this.name = "Material" + seed$
|
|
9041
|
+
_this.name = "Material" + seed$8++;
|
|
9089
9042
|
_this.renderType = 0;
|
|
9090
9043
|
}
|
|
9091
9044
|
return _this;
|
|
@@ -9410,29 +9363,6 @@ function vecFill(out, number) {
|
|
|
9410
9363
|
}
|
|
9411
9364
|
return out;
|
|
9412
9365
|
}
|
|
9413
|
-
function vecAssign(out, a, count, start) {
|
|
9414
|
-
if (start === void 0) start = 0;
|
|
9415
|
-
for(var i = 0; i < count; i++){
|
|
9416
|
-
out[i] = a[i + start];
|
|
9417
|
-
}
|
|
9418
|
-
return out;
|
|
9419
|
-
}
|
|
9420
|
-
function vecNormalize(out, a) {
|
|
9421
|
-
var _Math;
|
|
9422
|
-
if (arguments.length === 1) {
|
|
9423
|
-
a = out;
|
|
9424
|
-
out = [];
|
|
9425
|
-
}
|
|
9426
|
-
var ap = a;
|
|
9427
|
-
var sum = (_Math = Math).hypot.apply(_Math, [].concat(ap));
|
|
9428
|
-
if (sum === 0) {
|
|
9429
|
-
return vecAssign(out, ap, ap.length);
|
|
9430
|
-
}
|
|
9431
|
-
for(var i = 0; i < ap.length; i++){
|
|
9432
|
-
out[i] = ap[i] / sum;
|
|
9433
|
-
}
|
|
9434
|
-
return out;
|
|
9435
|
-
}
|
|
9436
9366
|
function vecMulCombine(out, a, b) {
|
|
9437
9367
|
if (a && b) {
|
|
9438
9368
|
for(var i = 0, len = a.length; i < len; i++){
|
|
@@ -9522,10 +9452,6 @@ function numberToFix(a, fixed) {
|
|
|
9522
9452
|
var base = Math.pow(10, fixed);
|
|
9523
9453
|
return Math.floor(a * base) / base;
|
|
9524
9454
|
}
|
|
9525
|
-
function pointOnLine(x1, y1, x2, y2, x3, y3) {
|
|
9526
|
-
var det1 = x1 * y2 + y1 * x3 + x2 * y3 - x3 * y2 - y3 * x1 - x2 * y1;
|
|
9527
|
-
return det1 > -0.001 && det1 < 0.001;
|
|
9528
|
-
}
|
|
9529
9455
|
|
|
9530
9456
|
function _is_native_reflect_construct() {
|
|
9531
9457
|
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
@@ -10968,21 +10894,16 @@ exports.Shader = __decorate([
|
|
|
10968
10894
|
|
|
10969
10895
|
var EFFECTS_COPY_MESH_NAME = "effects-internal-copy";
|
|
10970
10896
|
var COPY_MESH_SHADER_ID = "effects-internal-copy-mesh";
|
|
10971
|
-
var COPY_VERTEX_SHADER = "\
|
|
10972
|
-
var COPY_FRAGMENT_SHADER = "precision mediump float;\
|
|
10897
|
+
var COPY_VERTEX_SHADER = "\nprecision highp float;\nattribute vec2 aPos;\nvarying vec2 vTex;\nvoid main(){\n gl_Position = vec4(aPos,0.,1.0);\n vTex = (aPos + vec2(1.0))/2.;\n}";
|
|
10898
|
+
var COPY_FRAGMENT_SHADER = "precision mediump float;\nvarying vec2 vTex;\n\n#ifdef DEPTH_TEXTURE\nuniform sampler2D uDepth;\n#extension GL_EXT_frag_depth : enable\n#endif\nvoid main(){\n #ifdef DEPTH_TEXTURE\n gl_FragDepthEXT = texture2D(uDepth,vTex).r;\n #endif\n}\n";
|
|
10973
10899
|
function createCopyShader(level, writeDepth) {
|
|
10974
10900
|
var webgl2 = level === 2;
|
|
10975
|
-
var version = webgl2 ? "#version 300 es" : "";
|
|
10976
10901
|
return {
|
|
10977
10902
|
name: EFFECTS_COPY_MESH_NAME,
|
|
10978
|
-
vertex:
|
|
10979
|
-
fragment:
|
|
10903
|
+
vertex: COPY_VERTEX_SHADER,
|
|
10904
|
+
fragment: COPY_FRAGMENT_SHADER,
|
|
10980
10905
|
glslVersion: webgl2 ? exports.GLSLVersion.GLSL3 : exports.GLSLVersion.GLSL1,
|
|
10981
10906
|
macros: [
|
|
10982
|
-
[
|
|
10983
|
-
"WEBGL2",
|
|
10984
|
-
!!webgl2
|
|
10985
|
-
],
|
|
10986
10907
|
[
|
|
10987
10908
|
"DEPTH_TEXTURE",
|
|
10988
10909
|
!!writeDepth
|
|
@@ -11150,7 +11071,7 @@ function generateEmptyTypedArray(type) {
|
|
|
11150
11071
|
return new Float32Array(0);
|
|
11151
11072
|
}
|
|
11152
11073
|
|
|
11153
|
-
var seed$
|
|
11074
|
+
var seed$7 = 1;
|
|
11154
11075
|
/**
|
|
11155
11076
|
* Mesh 抽象类
|
|
11156
11077
|
*/ var Mesh = /*#__PURE__*/ function(RendererComponent) {
|
|
@@ -11162,14 +11083,14 @@ var seed$8 = 1;
|
|
|
11162
11083
|
_this.visible = true;
|
|
11163
11084
|
if (props) {
|
|
11164
11085
|
var material = props.material, geometry = props.geometry, _props_name = props.name, name = _props_name === void 0 ? "<unnamed>" : _props_name, _props_priority = props.priority, priority = _props_priority === void 0 ? 0 : _props_priority, _props_worldMatrix = props.worldMatrix, worldMatrix = _props_worldMatrix === void 0 ? Matrix4.fromIdentity() : _props_worldMatrix;
|
|
11165
|
-
_this.id = "Mesh" + seed$
|
|
11086
|
+
_this.id = "Mesh" + seed$7++;
|
|
11166
11087
|
_this.name = name;
|
|
11167
11088
|
_this.geometry = geometry;
|
|
11168
11089
|
_this.material = material;
|
|
11169
11090
|
_this.priority = priority;
|
|
11170
11091
|
_this.worldMatrix = worldMatrix;
|
|
11171
11092
|
} else {
|
|
11172
|
-
_this.id = "Mesh" + seed$
|
|
11093
|
+
_this.id = "Mesh" + seed$7++;
|
|
11173
11094
|
_this.name = "<unnamed>";
|
|
11174
11095
|
_this.worldMatrix = Matrix4.fromIdentity();
|
|
11175
11096
|
_this._priority = 0;
|
|
@@ -11374,7 +11295,7 @@ exports.RenderPassDestroyAttachmentType = void 0;
|
|
|
11374
11295
|
* 强制销毁
|
|
11375
11296
|
*/ RenderPassDestroyAttachmentType[RenderPassDestroyAttachmentType["destroy"] = 0] = "destroy";
|
|
11376
11297
|
})(exports.RenderPassDestroyAttachmentType || (exports.RenderPassDestroyAttachmentType = {}));
|
|
11377
|
-
var seed$
|
|
11298
|
+
var seed$6 = 1;
|
|
11378
11299
|
/**
|
|
11379
11300
|
* RenderPass 抽象类
|
|
11380
11301
|
*/ var RenderPass = /*#__PURE__*/ function() {
|
|
@@ -11384,7 +11305,7 @@ var seed$7 = 1;
|
|
|
11384
11305
|
*/ this.attachments = [];
|
|
11385
11306
|
this.destroyed = false;
|
|
11386
11307
|
this.initialized = false;
|
|
11387
|
-
var _options_name = options.name, name = _options_name === void 0 ? "RenderPass_" + seed$
|
|
11308
|
+
var _options_name = options.name, name = _options_name === void 0 ? "RenderPass_" + seed$6++ : _options_name, clearAction = options.clearAction, semantics = options.semantics, depthStencilAttachment = options.depthStencilAttachment, storeAction = options.storeAction, _options_priority = options.priority, priority = _options_priority === void 0 ? 0 : _options_priority, _options_meshOrder = options.meshOrder, meshOrder = _options_meshOrder === void 0 ? exports.OrderType.ascending : _options_meshOrder, _options_meshes = options.meshes, meshes = _options_meshes === void 0 ? [] : _options_meshes, _options_delegate = options.delegate, delegate = _options_delegate === void 0 ? {} : _options_delegate;
|
|
11388
11309
|
this.name = name;
|
|
11389
11310
|
this.renderer = renderer;
|
|
11390
11311
|
this.priority = priority;
|
|
@@ -11604,10 +11525,12 @@ var seed$7 = 1;
|
|
|
11604
11525
|
*/ _proto.getDepthAttachment = function getDepthAttachment() {
|
|
11605
11526
|
var framebuffer = this.framebuffer;
|
|
11606
11527
|
if (framebuffer) {
|
|
11528
|
+
var depthTexture = framebuffer.getDepthTexture();
|
|
11529
|
+
var texture = depthTexture ? this.getDepthTexture(depthTexture, framebuffer.externalStorage) : undefined;
|
|
11607
11530
|
return {
|
|
11608
11531
|
storageType: framebuffer.depthStencilStorageType,
|
|
11609
11532
|
storage: framebuffer.depthStorage,
|
|
11610
|
-
texture:
|
|
11533
|
+
texture: texture
|
|
11611
11534
|
};
|
|
11612
11535
|
}
|
|
11613
11536
|
};
|
|
@@ -11616,10 +11539,12 @@ var seed$7 = 1;
|
|
|
11616
11539
|
*/ _proto.getStencilAttachment = function getStencilAttachment() {
|
|
11617
11540
|
var framebuffer = this.framebuffer;
|
|
11618
11541
|
if (framebuffer) {
|
|
11542
|
+
var stencilTexture = framebuffer.getStencilTexture();
|
|
11543
|
+
var texture = stencilTexture ? this.getDepthTexture(stencilTexture, framebuffer.externalStorage) : undefined;
|
|
11619
11544
|
return {
|
|
11620
11545
|
storageType: framebuffer.depthStencilStorageType,
|
|
11621
11546
|
storage: framebuffer.stencilStorage,
|
|
11622
|
-
texture:
|
|
11547
|
+
texture: texture
|
|
11623
11548
|
};
|
|
11624
11549
|
}
|
|
11625
11550
|
};
|
|
@@ -11731,11 +11656,7 @@ var seed$7 = 1;
|
|
|
11731
11656
|
|
|
11732
11657
|
var blend = "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;}";
|
|
11733
11658
|
|
|
11734
|
-
var
|
|
11735
|
-
|
|
11736
|
-
var compatible_vert = "#version 300 es\n#ifdef WEBGL2\n#define texture2D texture\n#else\n#endif\n";
|
|
11737
|
-
|
|
11738
|
-
var itemFrameFrag = "#version 300 es\nprecision highp float;\n#version 300 es\n#ifdef WEBGL2\n#define texture2D texture\n#define textureCube texture\n#define textureCubeLodEXT textureLod\nlayout(location=0)out vec4 fragColor;\n#else\n#define fragColor gl_FragColor\n#endif\nvec4 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;}in vec4 vColor;in vec4 vTexCoord;in highp vec2 vParams;uniform vec3 uFrameColor;void main(){fragColor=vec4(uFrameColor.xyz,1.0);}";
|
|
11659
|
+
var itemFrameFrag = "#version 100\nprecision highp 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;}varying vec4 vColor;varying vec4 vTexCoord;varying highp vec2 vParams;uniform vec3 uFrameColor;void main(){gl_FragColor=vec4(uFrameColor.xyz,1.0);}";
|
|
11739
11660
|
|
|
11740
11661
|
var integrate = "float calculateMovement(float t,vec2 p1,vec2 p2,vec2 p3,vec2 p4){float movement=0.0;float h=(t-p1.x)*0.05;for(int i=0;i<=20;i++){float t=float(i)*h;float nt=binarySearchT(t,p1.x,p2.x,p3.x,p4.x);float y=cubicBezier(nt,p1.y,p2.y,p3.y,p4.y);float weight=(i==0||i==20)? 1.0 :(mod(float(i),2.)!=0.)? 4.0 : 2.0;movement+=weight*y;}movement*=h/3.;return movement;}float integrateFromBezierCurveFrames(float time,float frameStart,float frameCount){int start=int(frameStart);int count=int(frameCount-1.);float ret=0.;for(int i=0;i<ITR_END;i+=2){vec4 k0=lookup_curve(i+start);vec4 k1=lookup_curve(i+1+start);if(i==0&&time<k0.x){return ret;}vec2 p1=vec2(k0.x,k0.y);vec2 p2=vec2(k0.z,k0.w);vec2 p3=vec2(k1.z,k1.w);vec2 p4=vec2(k1.x,k1.y);if(time>=k1.x){ret+=calculateMovement(k1.x,p1,p2,p3,p4);}if(time>=k0.x&&time<k1.x){return ret+calculateMovement(time,p1,p2,p3,p4);}}return ret;}float integrateByTimeLineSeg(float t,vec2 p0,vec2 p1){float t0=p0.x;float t1=p1.x;float y0=p0.y;float y1=p1.y;vec4 tSqr=vec4(t,t,t0,t0);tSqr=tSqr*tSqr;vec4 a=vec4(2.*t,3.,-t0,3.)*tSqr;float t1y0=t1*y0;vec4 b=vec4(y0-y1,t0*y1-t1y0,2.*y0+y1,t1y0);float r=dot(a,b);return r/(t0-t1)*0.16666667;}float integrateLineSeg(float time,vec2 p0,vec2 p1){float h=time-p0.x;float y0=p0.y;return(y0+y0+(p1.y-y0)*h/(p1.x-p0.x))*h/2.;}float integrateFromLineSeg(float time,float frameStart,float frameCount){if(time==0.){return 0.;}int start=int(frameStart);int count=int(frameCount-1.);float ret=0.;for(int i=0;i<ITR_END;i++){if(i>count){return ret;}vec4 ks=lookup_curve(i+start);vec2 k0=ks.xy;vec2 k1=ks.zw;if(time>k0.x&&time<=k1.x){return ret+integrateLineSeg(time,k0,k1);}ret+=integrateLineSeg(k1.x,k0,k1);vec2 k2=lookup_curve(i+start+1).xy;if(time>k1.x&&time<=k2.x){return ret+integrateLineSeg(time,k1,k2);}ret+=integrateLineSeg(k2.x,k1,k2);}return ret;}float integrateByTimeFromLineSeg(float time,float frameStart,float frameCount){if(time==0.){return 0.;}int start=int(frameStart);int count=int(frameCount-1.);float ret=0.;for(int i=0;i<ITR_END;i++){if(i>count){return ret;}vec4 ks=lookup_curve(i+start);vec2 k0=ks.xy;vec2 k1=ks.zw;if(time>k0.x&&time<=k1.x){return ret+integrateByTimeLineSeg(time,k0,k1);}ret+=integrateByTimeLineSeg(k1.x,k0,k1);vec2 k2=lookup_curve(i+start+1).xy;if(time>k1.x&&time<=k2.x){return ret+integrateByTimeLineSeg(time,k1,k2);}ret+=integrateByTimeLineSeg(k2.x,k1,k2);}return ret;}float getIntegrateFromTime0(float t1,vec4 value){float type=value.x;if(type==0.){return value.y*t1;}if(type==1.){vec2 p0=vec2(0.,value.y);vec2 p1=vec2(value.w,value.z);return integrateLineSeg(t1,p0,p1);}if(type==3.){return integrateFromLineSeg(t1,value.y,value.z);}if(type==4.){return mix(value.y,value.z,aSeed)*t1;}if(type==5.){return integrateFromBezierCurveFrames(t1,value.z,value.w);}return 0.;}float getIntegrateByTimeFromTime(float t0,float t1,vec4 value){float type=value.x;if(type==0.){return value.y*(t1*t1-t0*t0)/2.;}else if(type==1.){vec2 p0=vec2(0.,value.y);vec2 p1=vec2(value.w,value.z);return integrateByTimeLineSeg(t1,p0,p1)-integrateByTimeLineSeg(t0,p0,p1);}if(type==3.){return integrateByTimeFromLineSeg(t1,value.y,value.z)-integrateByTimeFromLineSeg(t0,value.y,value.z);}if(type==4.){return mix(value.y,value.z,aSeed)*(t1*t1-t0*t0)/2.;}if(type==5.){return integrateFromBezierCurveFrames(t1,value.z,value.w)-integrateFromBezierCurveFrames(t0,value.z,value.w);}return 0.;}";
|
|
11741
11662
|
|
|
@@ -11743,13 +11664,13 @@ var itemVert = "precision highp float;attribute vec2 atlasOffset;attribute vec3
|
|
|
11743
11664
|
|
|
11744
11665
|
var itemFrag = "precision highp float;varying vec4 vColor;varying vec2 vTexCoord;varying vec3 vParams;uniform sampler2D uSampler0;vec4 blendColor(vec4 color,vec4 vc,float mode){vec4 ret=color*vc;float alpha=ret.a;if(mode==1.){ret.rgb*=alpha;}else if(mode==2.){ret.rgb*=alpha;ret.a=dot(ret.rgb,vec3(0.33333333));}else if(mode==3.){alpha=color.r*alpha;ret=vec4(vc.rgb*alpha,alpha);}return ret;}void main(){vec4 color=vec4(0.);vec4 texColor=texture2D(uSampler0,vTexCoord.xy);color=blendColor(texColor,vColor,floor(0.5+vParams.y));if(vParams.z==0.&&color.a<0.04){discard;}color.a=clamp(color.a,0.0,1.0);gl_FragColor=color;}";
|
|
11745
11666
|
|
|
11746
|
-
var particleFrag = "#version
|
|
11667
|
+
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";
|
|
11747
11668
|
|
|
11748
|
-
var particleVert = "#version 300 es\nprecision mediump float;\n#define SHADER_VERTEX 1\n#define PATICLE_SHADER 1\n#version 300 es\n#ifdef WEBGL2\n#define texture2D texture\n#else\n#endif\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\nin float aSeed;out 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.;in vec3 aPos;in vec4 aOffset;in vec3 aVel;in vec3 aRot;in vec4 aColor;in vec3 aDirX;in vec3 aDirY;\n#ifdef USE_SPRITE\nin vec3 aSprite;uniform vec4 uSprite;struct UVDetail{vec2 uv0;vec3 uv1;};UVDetail getSpriteUV(vec2 uv,float lifeTime);out 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\nout float vLife;out vec4 vColor;out 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}}";
|
|
11669
|
+
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}}";
|
|
11749
11670
|
|
|
11750
|
-
var trailVert = "#version
|
|
11671
|
+
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}";
|
|
11751
11672
|
|
|
11752
|
-
var value = "#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\
|
|
11673
|
+
var value = "#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.;}";
|
|
11753
11674
|
|
|
11754
11675
|
var valueDefine = "#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";
|
|
11755
11676
|
|
|
@@ -11767,6 +11688,159 @@ var gaussianUpFrag = "precision highp float;varying vec2 uv;uniform sampler2D _M
|
|
|
11767
11688
|
|
|
11768
11689
|
var thresholdFrag = "precision highp float;varying vec2 uv;uniform sampler2D _MainTex;uniform float _Threshold;void main(){vec4 mainTex=texture2D(_MainTex,uv);mainTex.rgb=pow(mainTex.rgb,vec3(2.2));float brightness=max(mainTex.r,max(mainTex.g,mainTex.b));float w=max(0.0,brightness-_Threshold)/max(brightness,0.00001);mainTex.rgb*=w;mainTex.rgb*=mainTex.a;gl_FragColor=vec4(mainTex.rgb,1.0);}";
|
|
11769
11690
|
|
|
11691
|
+
var shaderLib = {};
|
|
11692
|
+
var ShaderFactory = /*#__PURE__*/ function() {
|
|
11693
|
+
function ShaderFactory() {}
|
|
11694
|
+
ShaderFactory.registerInclude = function registerInclude(includeName, includeSource) {
|
|
11695
|
+
if (shaderLib[includeName]) {
|
|
11696
|
+
logger.warn('The "' + includeName + '" shader include already exist.');
|
|
11697
|
+
}
|
|
11698
|
+
shaderLib[includeName] = includeSource;
|
|
11699
|
+
};
|
|
11700
|
+
ShaderFactory.unRegisterInclude = function unRegisterInclude(includeName) {
|
|
11701
|
+
delete shaderLib[includeName];
|
|
11702
|
+
};
|
|
11703
|
+
ShaderFactory.unRegisterAllIncludes = function unRegisterAllIncludes() {
|
|
11704
|
+
Object.keys(shaderLib).forEach(function(key) {
|
|
11705
|
+
ShaderFactory.unRegisterInclude(key);
|
|
11706
|
+
});
|
|
11707
|
+
};
|
|
11708
|
+
/**
|
|
11709
|
+
* 生成 shader,检测到 WebGL1 上下文会降级
|
|
11710
|
+
* @param macros - 宏定义数组
|
|
11711
|
+
* @param shader - 原始 shader 文本
|
|
11712
|
+
* @param shaderType - shader 类型
|
|
11713
|
+
* @return 去除版本号的 shader 文本
|
|
11714
|
+
*/ ShaderFactory.genFinalShaderCode = function genFinalShaderCode(options) {
|
|
11715
|
+
var level = options.level, shaderType = options.shaderType, shader = options.shader, macros = options.macros, removeVersion = options.removeVersion;
|
|
11716
|
+
var macroString = ShaderFactory.genMacroString(level, macros);
|
|
11717
|
+
var versionString = ShaderFactory.genShaderVersion(level);
|
|
11718
|
+
var source = ShaderFactory.parseIncludes(shader);
|
|
11719
|
+
var isVersion300 = ShaderFactory.isVersion300(source);
|
|
11720
|
+
source = ShaderFactory.removeWebGLVersion(source);
|
|
11721
|
+
if (level === 2 && !isVersion300) {
|
|
11722
|
+
source = ShaderFactory.convertTo300(source, shaderType === exports.ShaderType.fragment);
|
|
11723
|
+
}
|
|
11724
|
+
if (removeVersion) {
|
|
11725
|
+
return macroString + source;
|
|
11726
|
+
}
|
|
11727
|
+
return versionString + macroString + source;
|
|
11728
|
+
};
|
|
11729
|
+
/**
|
|
11730
|
+
* Convert lower GLSL version to GLSL 300 es.
|
|
11731
|
+
* @param source - code
|
|
11732
|
+
* @param isFragment - Whether it is a fragment shader.
|
|
11733
|
+
* */ ShaderFactory.convertTo300 = function convertTo300(source, isFragment) {
|
|
11734
|
+
source = source.replace(/\bvarying\b/g, isFragment ? "in" : "out");
|
|
11735
|
+
source = source.replace(/\btexture(2D|Cube)\b/g, "texture");
|
|
11736
|
+
// Remove extensions
|
|
11737
|
+
var regex = /#extension.+(GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g;
|
|
11738
|
+
source = source.replace(regex, "");
|
|
11739
|
+
if (isFragment) {
|
|
11740
|
+
source = source.replace(/\btexture(2D|Cube)LodEXT\b/g, "textureLod");
|
|
11741
|
+
source = source.replace(/\btexture(2D|Cube)GradEXT\b/g, "textureGrad");
|
|
11742
|
+
source = source.replace(/\bgl_FragDepthEXT\b/g, "gl_FragDepth");
|
|
11743
|
+
if (!ShaderFactory.has300Output(source)) {
|
|
11744
|
+
var isMRT = /\bgl_FragData\[.+?\]/g.test(source);
|
|
11745
|
+
if (isMRT) {
|
|
11746
|
+
source = source.replace(/\bgl_FragColor\b/g, "gl_FragData[0]");
|
|
11747
|
+
var result = source.match(/\bgl_FragData\[.+?\]/g);
|
|
11748
|
+
if (result) {
|
|
11749
|
+
source = ShaderFactory.replaceMRTShader(source, result);
|
|
11750
|
+
}
|
|
11751
|
+
} else {
|
|
11752
|
+
source = source.replace(/void\s+?main\s*\(/g, "out vec4 glFragColor;\nvoid main(");
|
|
11753
|
+
source = source.replace(/\bgl_FragColor\b/g, "glFragColor");
|
|
11754
|
+
}
|
|
11755
|
+
}
|
|
11756
|
+
} else {
|
|
11757
|
+
source = source.replace(/\battribute\b/g, "in");
|
|
11758
|
+
}
|
|
11759
|
+
return source;
|
|
11760
|
+
};
|
|
11761
|
+
ShaderFactory.parseIncludes = function parseIncludes(source, regex) {
|
|
11762
|
+
if (regex === void 0) regex = /#include <(.+)>/gm;
|
|
11763
|
+
var match;
|
|
11764
|
+
while((match = regex.exec(source)) !== null){
|
|
11765
|
+
var shaderName = match[1];
|
|
11766
|
+
var replace = shaderLib[shaderName];
|
|
11767
|
+
if (replace === undefined) {
|
|
11768
|
+
throw new Error("Can't find include shader name " + shaderName);
|
|
11769
|
+
}
|
|
11770
|
+
source = source.replace(match[0], replace);
|
|
11771
|
+
}
|
|
11772
|
+
return source;
|
|
11773
|
+
};
|
|
11774
|
+
ShaderFactory.genMacroString = function genMacroString(level, macros, addRuntimeMacro) {
|
|
11775
|
+
if (addRuntimeMacro === void 0) addRuntimeMacro = true;
|
|
11776
|
+
var macroList = [];
|
|
11777
|
+
var webGLVersion = "WEBGL" + level;
|
|
11778
|
+
macroList.push("#ifndef " + webGLVersion);
|
|
11779
|
+
macroList.push("#define " + webGLVersion);
|
|
11780
|
+
macroList.push("#endif");
|
|
11781
|
+
if (addRuntimeMacro) {
|
|
11782
|
+
macroList.push("#define GE_RUNTIME");
|
|
11783
|
+
}
|
|
11784
|
+
if (macros && macros.length) {
|
|
11785
|
+
macros.forEach(function(param) {
|
|
11786
|
+
var key = param[0], value = param[1];
|
|
11787
|
+
if (value === true) {
|
|
11788
|
+
macroList.push("#define " + key);
|
|
11789
|
+
} else if (Number.isFinite(value)) {
|
|
11790
|
+
macroList.push("#define " + key + " " + value);
|
|
11791
|
+
}
|
|
11792
|
+
});
|
|
11793
|
+
}
|
|
11794
|
+
if (macroList.length) {
|
|
11795
|
+
return macroList.join("\n") + "\n";
|
|
11796
|
+
}
|
|
11797
|
+
return "";
|
|
11798
|
+
};
|
|
11799
|
+
ShaderFactory.genShaderVersion = function genShaderVersion(level) {
|
|
11800
|
+
if (level === 1) {
|
|
11801
|
+
return "#version 100\n";
|
|
11802
|
+
}
|
|
11803
|
+
return "#version 300 es\n";
|
|
11804
|
+
};
|
|
11805
|
+
ShaderFactory.isVersion300 = function isVersion300(source) {
|
|
11806
|
+
var versionTag = /#version\s+\b\d{3}\b\s*(es)?/;
|
|
11807
|
+
var match = source.match(versionTag);
|
|
11808
|
+
var version = match ? match[0] : "";
|
|
11809
|
+
return version.includes("300");
|
|
11810
|
+
};
|
|
11811
|
+
ShaderFactory.removeWebGLVersion = function removeWebGLVersion(source) {
|
|
11812
|
+
var versionTag = /#version\s+\b\d{3}\b\s*(es)?/;
|
|
11813
|
+
var match = source.match(versionTag);
|
|
11814
|
+
if (match) {
|
|
11815
|
+
return source.replace(match[0], "");
|
|
11816
|
+
}
|
|
11817
|
+
return source;
|
|
11818
|
+
};
|
|
11819
|
+
ShaderFactory.has300Output = function has300Output(fragmentShader) {
|
|
11820
|
+
// [layout(location = 0)] out [highp] vec4 [color];
|
|
11821
|
+
var fragReg = /\bout\s+(?:\w+\s+)?(?:vec4)\s+(?:\w+)\s*;/;
|
|
11822
|
+
return fragReg.test(fragmentShader);
|
|
11823
|
+
};
|
|
11824
|
+
ShaderFactory.replaceMRTShader = function replaceMRTShader(source, result) {
|
|
11825
|
+
var mrtIndexSet = new Set();
|
|
11826
|
+
var declaration = "";
|
|
11827
|
+
for(var i = 0; i < result.length; i++){
|
|
11828
|
+
var res = result[i].match(/\bgl_FragData\[(.+?)\]/);
|
|
11829
|
+
if (res) {
|
|
11830
|
+
mrtIndexSet.add(res[1]);
|
|
11831
|
+
}
|
|
11832
|
+
}
|
|
11833
|
+
mrtIndexSet.forEach(function(index) {
|
|
11834
|
+
declaration += "layout(location=" + index + ") out vec4 fragOutColor" + index + ";\n";
|
|
11835
|
+
});
|
|
11836
|
+
declaration += "void main(";
|
|
11837
|
+
source = source.replace(/\bgl_FragData\[(.+?)\]/g, "fragOutColor$1");
|
|
11838
|
+
source = source.replace(/void\s+?main\s*\(/g, declaration);
|
|
11839
|
+
return source;
|
|
11840
|
+
};
|
|
11841
|
+
return ShaderFactory;
|
|
11842
|
+
}();
|
|
11843
|
+
|
|
11770
11844
|
// Bloom 阈值 Pass
|
|
11771
11845
|
var BloomThresholdPass = /*#__PURE__*/ function(RenderPass) {
|
|
11772
11846
|
_inherits(BloomThresholdPass, RenderPass);
|
|
@@ -12064,7 +12138,7 @@ var ToneMappingPass = /*#__PURE__*/ function(RenderPass) {
|
|
|
12064
12138
|
}(RenderPass);
|
|
12065
12139
|
|
|
12066
12140
|
var RENDER_PASS_NAME_PREFIX = "_effects_default_";
|
|
12067
|
-
var seed$
|
|
12141
|
+
var seed$5 = 1;
|
|
12068
12142
|
/**
|
|
12069
12143
|
* RenderFrame 抽象类
|
|
12070
12144
|
*/ var RenderFrame = /*#__PURE__*/ function() {
|
|
@@ -12218,7 +12292,7 @@ var seed$6 = 1;
|
|
|
12218
12292
|
}
|
|
12219
12293
|
this.semantics = new SemanticMap(options.semantics);
|
|
12220
12294
|
this.clearAction = clearAction;
|
|
12221
|
-
this.name = "RenderFrame" + seed$
|
|
12295
|
+
this.name = "RenderFrame" + seed$5++;
|
|
12222
12296
|
var firstRP = renderPasses[0];
|
|
12223
12297
|
this.emptyTexture = generateWhiteTexture(engine);
|
|
12224
12298
|
this.transparentTexture = generateTransparentTexture(engine);
|
|
@@ -12527,6 +12601,9 @@ var seed$6 = 1;
|
|
|
12527
12601
|
_proto.addToRenderPass = function addToRenderPass(renderPass, mesh) {
|
|
12528
12602
|
var info = this.renderPassInfoMap.get(renderPass);
|
|
12529
12603
|
var priority = mesh.priority;
|
|
12604
|
+
if (!info) {
|
|
12605
|
+
return;
|
|
12606
|
+
}
|
|
12530
12607
|
if (renderPass.meshes.length === 0) {
|
|
12531
12608
|
info.listStart = info.listEnd = priority;
|
|
12532
12609
|
} else {
|
|
@@ -12701,6 +12778,8 @@ var seed$6 = 1;
|
|
|
12701
12778
|
* 创建拷贝 RenderPass 用到的 Mesh 对象
|
|
12702
12779
|
* @param semantics - RenderPass 渲染时 Framebuffer 的颜色和深度纹理、大小和是否混合
|
|
12703
12780
|
*/ _proto.createCopyMesh = function createCopyMesh(semantics) {
|
|
12781
|
+
var // FIXME: 如果不把shader添加进shaderLibrary,这里可以移到core中,有性能上的考虑
|
|
12782
|
+
_this_renderer_getShaderLibrary;
|
|
12704
12783
|
var name = EFFECTS_COPY_MESH_NAME;
|
|
12705
12784
|
var engine = this.renderer.engine;
|
|
12706
12785
|
var geometry = Geometry.create(engine, {
|
|
@@ -12725,8 +12804,7 @@ var seed$6 = 1;
|
|
|
12725
12804
|
drawCount: 4
|
|
12726
12805
|
});
|
|
12727
12806
|
var shader = createCopyShader(engine.gpuCapability.level, !!(semantics == null ? void 0 : semantics.depthTexture));
|
|
12728
|
-
|
|
12729
|
-
this.renderer.getShaderLibrary().addShader(shader);
|
|
12807
|
+
(_this_renderer_getShaderLibrary = this.renderer.getShaderLibrary()) == null ? void 0 : _this_renderer_getShaderLibrary.addShader(shader);
|
|
12730
12808
|
var material = Material.create(engine, {
|
|
12731
12809
|
uniformValues: {
|
|
12732
12810
|
// @ts-expect-error
|
|
@@ -12790,7 +12868,10 @@ var FinalCopyRP = /*#__PURE__*/ function(RenderPass) {
|
|
|
12790
12868
|
}
|
|
12791
12869
|
var _proto = FinalCopyRP.prototype;
|
|
12792
12870
|
_proto.configure = function configure(renderer) {
|
|
12793
|
-
|
|
12871
|
+
var framebuffer = renderer.getFramebuffer();
|
|
12872
|
+
if (framebuffer) {
|
|
12873
|
+
this.prePassTexture = framebuffer.getColorTextures()[0];
|
|
12874
|
+
}
|
|
12794
12875
|
renderer.setFramebuffer(null);
|
|
12795
12876
|
};
|
|
12796
12877
|
_proto.execute = function execute(renderer) {
|
|
@@ -13151,7 +13232,7 @@ var Renderer = /*#__PURE__*/ function() {
|
|
|
13151
13232
|
|
|
13152
13233
|
var vertex = "\nprecision highp float;\n\nattribute vec2 aPoint;\nuniform vec4 uPos;\nuniform vec2 uSize;\nuniform vec4 uQuat;\nuniform vec4 uColor;\nuniform mat4 effects_ObjectToWorld;\nuniform mat4 effects_MatrixInvV;\nuniform mat4 effects_MatrixVP;\nvarying vec4 vColor;\n#ifdef ENV_EDITOR\n uniform vec4 uEditorTransform;\n#endif\n\nvec3 rotateByQuat(vec3 a, vec4 quat){\n vec3 qvec = quat.xyz;\n vec3 uv = cross(qvec, a);\n vec3 uuv = cross(qvec, uv) * 2.;\n return a +(uv * 2. * quat.w + uuv);\n}\n\nvoid main() {\n vec4 _pos = uPos;\n vec3 point = rotateByQuat(vec3(aPoint.xy * uSize, 0.),uQuat);\n vec4 pos = vec4(_pos.xyz, 1.0);\n pos = effects_ObjectToWorld * pos;\n pos.xyz += effects_MatrixInvV[0].xyz * point.x+ effects_MatrixInvV[1].xyz * point.y;\n gl_Position = effects_MatrixVP * pos;\n vColor = uColor;\n #ifdef ENV_EDITOR\n gl_Position = vec4(gl_Position.xy * uEditorTransform.xy + uEditorTransform.zw * gl_Position.w, gl_Position.zw);\n #endif\n}\n";
|
|
13153
13234
|
var fragment = "\nprecision highp float;\n\n#define fragColor gl_FragColor\n\nvarying vec4 vColor;\nvoid main() {\n gl_FragColor = vColor*vColor.a;\n}\n";
|
|
13154
|
-
var seed$
|
|
13235
|
+
var seed$4 = 1;
|
|
13155
13236
|
var InteractMesh = /*#__PURE__*/ function() {
|
|
13156
13237
|
function InteractMesh(props, rendererOptions, transform, engine) {
|
|
13157
13238
|
this.transform = transform;
|
|
@@ -13252,7 +13333,7 @@ var InteractMesh = /*#__PURE__*/ function() {
|
|
|
13252
13333
|
};
|
|
13253
13334
|
_proto.createMesh = function createMesh(geometry, material) {
|
|
13254
13335
|
return Mesh.create(this.engine, {
|
|
13255
|
-
name: "Interact_preview" + seed$
|
|
13336
|
+
name: "Interact_preview" + seed$4++,
|
|
13256
13337
|
priority: 0,
|
|
13257
13338
|
worldMatrix: Matrix4.fromIdentity(),
|
|
13258
13339
|
geometry: geometry,
|
|
@@ -13304,13 +13385,15 @@ exports.InteractComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
|
13304
13385
|
if (type === InteractType.CLICK) {
|
|
13305
13386
|
this.clickable = true;
|
|
13306
13387
|
if (showPreview && env === PLAYER_OPTIONS_ENV_EDITOR) {
|
|
13307
|
-
var rendererOptions =
|
|
13308
|
-
|
|
13388
|
+
var rendererOptions = composition == null ? void 0 : composition.getRendererOptions();
|
|
13389
|
+
if (rendererOptions !== undefined) {
|
|
13390
|
+
this.previewContent = new InteractMesh(this.item.props.content, rendererOptions, this.transform, this.engine);
|
|
13391
|
+
}
|
|
13309
13392
|
}
|
|
13310
13393
|
}
|
|
13311
13394
|
if (options.type === InteractType.DRAG) {
|
|
13312
13395
|
if (env !== PLAYER_OPTIONS_ENV_EDITOR || options.enableInEditor) {
|
|
13313
|
-
composition.event && this.beginDragTarget(options, composition.event);
|
|
13396
|
+
(composition == null ? void 0 : composition.event) && this.beginDragTarget(options, composition.event);
|
|
13314
13397
|
}
|
|
13315
13398
|
}
|
|
13316
13399
|
if (this.previewContent) {
|
|
@@ -13581,11 +13664,11 @@ var SpriteLoader = /*#__PURE__*/ function(AbstractPlugin) {
|
|
|
13581
13664
|
var shaderLibrary = render.getShaderLibrary();
|
|
13582
13665
|
var _render_engine_gpuCapability = render.engine.gpuCapability, level = _render_engine_gpuCapability.level, detail = _render_engine_gpuCapability.detail;
|
|
13583
13666
|
var env = (options != null ? options : {}).env;
|
|
13584
|
-
if (!shaderLibrary.shaderResults[spriteMeshShaderIdFromRenderInfo(defRenderInfo, 2)]) {
|
|
13585
|
-
shaderLibrary.addShader(spriteMeshShaderFromRenderInfo(defRenderInfo, 2, 1, env));
|
|
13586
|
-
shaderLibrary.addShader(spriteMeshShaderFromRenderInfo(defRenderInfo, exports.maxSpriteMeshItemCount, 1, env));
|
|
13667
|
+
if (!(shaderLibrary == null ? void 0 : shaderLibrary.shaderResults[spriteMeshShaderIdFromRenderInfo(defRenderInfo, 2)])) {
|
|
13668
|
+
shaderLibrary == null ? void 0 : shaderLibrary.addShader(spriteMeshShaderFromRenderInfo(defRenderInfo, 2, 1, env));
|
|
13669
|
+
shaderLibrary == null ? void 0 : shaderLibrary.addShader(spriteMeshShaderFromRenderInfo(defRenderInfo, exports.maxSpriteMeshItemCount, 1, env));
|
|
13587
13670
|
if (detail.writableFragDepth) {
|
|
13588
|
-
shaderLibrary.addShader(createCopyShader(level, true));
|
|
13671
|
+
shaderLibrary == null ? void 0 : shaderLibrary.addShader(createCopyShader(level, true));
|
|
13589
13672
|
}
|
|
13590
13673
|
}
|
|
13591
13674
|
return Promise.resolve();
|
|
@@ -13917,7 +14000,7 @@ var tempColor = [
|
|
|
13917
14000
|
1,
|
|
13918
14001
|
1
|
|
13919
14002
|
];
|
|
13920
|
-
var seed$
|
|
14003
|
+
var seed$3 = 0;
|
|
13921
14004
|
var SpriteColorPlayable = /*#__PURE__*/ function(Playable) {
|
|
13922
14005
|
_inherits(SpriteColorPlayable, Playable);
|
|
13923
14006
|
function SpriteColorPlayable() {
|
|
@@ -13958,8 +14041,9 @@ var SpriteColorPlayable = /*#__PURE__*/ function(Playable) {
|
|
|
13958
14041
|
colorChanged = true;
|
|
13959
14042
|
}
|
|
13960
14043
|
if (colorChanged) {
|
|
14044
|
+
var _this_spriteMaterial_getVector4;
|
|
13961
14045
|
vecMulCombine(this.renderColor, colorInc, this.startColor);
|
|
13962
|
-
this.spriteMaterial.getVector4("_Color").setFromArray(this.renderColor);
|
|
14046
|
+
(_this_spriteMaterial_getVector4 = this.spriteMaterial.getVector4("_Color")) == null ? void 0 : _this_spriteMaterial_getVector4.setFromArray(this.renderColor);
|
|
13963
14047
|
}
|
|
13964
14048
|
};
|
|
13965
14049
|
_proto.create = function create(clipData) {
|
|
@@ -14025,7 +14109,7 @@ exports.SpriteComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
|
14025
14109
|
}
|
|
14026
14110
|
}
|
|
14027
14111
|
};
|
|
14028
|
-
_this.name = "MSprite" + seed$
|
|
14112
|
+
_this.name = "MSprite" + seed$3++;
|
|
14029
14113
|
_this.renderer = {
|
|
14030
14114
|
renderMode: RenderMode.BILLBOARD,
|
|
14031
14115
|
blending: BlendingMode.ALPHA,
|
|
@@ -14211,9 +14295,11 @@ exports.SpriteComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
|
14211
14295
|
var data = this.getItemInitData();
|
|
14212
14296
|
var renderer = this.renderer;
|
|
14213
14297
|
var texParams = this.material.getVector4("_TexParams");
|
|
14214
|
-
texParams
|
|
14215
|
-
|
|
14216
|
-
|
|
14298
|
+
if (texParams) {
|
|
14299
|
+
texParams.x = renderer.occlusion ? +renderer.transparentOcclusion : 1;
|
|
14300
|
+
texParams.y = +this.preMultiAlpha;
|
|
14301
|
+
texParams.z = renderer.renderMode;
|
|
14302
|
+
}
|
|
14217
14303
|
var attributes = {
|
|
14218
14304
|
atlasOffset: new Float32Array(data.atlasOffset.length),
|
|
14219
14305
|
index: new Uint16Array(data.index.length)
|
|
@@ -14506,7 +14592,7 @@ function setConfig(name, value) {
|
|
|
14506
14592
|
}
|
|
14507
14593
|
|
|
14508
14594
|
var tempQuat$1 = new Quaternion();
|
|
14509
|
-
var seed$
|
|
14595
|
+
var seed$2 = 1;
|
|
14510
14596
|
// TODO 继承 Component
|
|
14511
14597
|
var Transform = /*#__PURE__*/ function() {
|
|
14512
14598
|
function Transform(props, parent) {
|
|
@@ -14557,7 +14643,7 @@ var Transform = /*#__PURE__*/ function() {
|
|
|
14557
14643
|
quat: new Quaternion(0, 0, 0, 1),
|
|
14558
14644
|
scale: new Vector3(1, 1, 1)
|
|
14559
14645
|
};
|
|
14560
|
-
this.name = "transform_" + seed$
|
|
14646
|
+
this.name = "transform_" + seed$2++;
|
|
14561
14647
|
if (props) {
|
|
14562
14648
|
this.setTransform(props);
|
|
14563
14649
|
}
|
|
@@ -15862,8 +15948,8 @@ function getBezier2DValue(out, t, p0, p1, cpx0, cpy0, cpx1, cpy1) {
|
|
|
15862
15948
|
}
|
|
15863
15949
|
|
|
15864
15950
|
var Burst = /*#__PURE__*/ function() {
|
|
15865
|
-
function Burst(
|
|
15866
|
-
var time =
|
|
15951
|
+
function Burst(options) {
|
|
15952
|
+
var time = options.time, interval = options.interval, count = options.count, cycles = options.cycles, probability = options.probability;
|
|
15867
15953
|
this.time = +time || 0;
|
|
15868
15954
|
this.interval = +interval || 1;
|
|
15869
15955
|
this.count = _instanceof1(count, ValueGetter) ? count : createValueGetter(count);
|
|
@@ -15891,7 +15977,14 @@ var Burst = /*#__PURE__*/ function() {
|
|
|
15891
15977
|
this.now = 0;
|
|
15892
15978
|
};
|
|
15893
15979
|
_proto.clone = function clone() {
|
|
15894
|
-
|
|
15980
|
+
var options = {
|
|
15981
|
+
time: this.time,
|
|
15982
|
+
interval: this.interval,
|
|
15983
|
+
count: this.count,
|
|
15984
|
+
cycles: this.cycles,
|
|
15985
|
+
probability: this.probability
|
|
15986
|
+
};
|
|
15987
|
+
return new Burst(options);
|
|
15895
15988
|
};
|
|
15896
15989
|
return Burst;
|
|
15897
15990
|
}();
|
|
@@ -16353,6 +16446,7 @@ var TrailMesh = /*#__PURE__*/ function() {
|
|
|
16353
16446
|
if (index >= 0 && index < pointCountPerTrail) {
|
|
16354
16447
|
var startIndex = (trail * pointCountPerTrail + index) * 24 + 8;
|
|
16355
16448
|
var data = this.geometry.getAttributeData("aColor");
|
|
16449
|
+
assertExist(data);
|
|
16356
16450
|
out.x = data[startIndex];
|
|
16357
16451
|
out.y = data[1 + startIndex];
|
|
16358
16452
|
out.z = data[2 + startIndex];
|
|
@@ -16360,14 +16454,14 @@ var TrailMesh = /*#__PURE__*/ function() {
|
|
|
16360
16454
|
}
|
|
16361
16455
|
};
|
|
16362
16456
|
_proto.clearAllTrails = function clearAllTrails() {
|
|
16363
|
-
var
|
|
16457
|
+
var indexData = this.geometry.getIndexData();
|
|
16458
|
+
assertExist(indexData);
|
|
16364
16459
|
this.trailCursors = new Uint16Array(this.trailCursors.length);
|
|
16365
|
-
|
|
16366
|
-
geo.setIndexData(new Uint16Array(geo.getIndexData().length));
|
|
16460
|
+
this.geometry.setIndexData(new Uint16Array(indexData.length));
|
|
16367
16461
|
};
|
|
16368
16462
|
_proto.minusTime = function minusTime(time) {
|
|
16369
|
-
// FIXME: 可选性
|
|
16370
16463
|
var data = this.geometry.getAttributeData("aTime");
|
|
16464
|
+
assertExist(data);
|
|
16371
16465
|
for(var i = 0; i < data.length; i++){
|
|
16372
16466
|
data[i] -= time;
|
|
16373
16467
|
}
|
|
@@ -16379,6 +16473,7 @@ var TrailMesh = /*#__PURE__*/ function() {
|
|
|
16379
16473
|
var pointCountPerTrail = this.pointCountPerTrail;
|
|
16380
16474
|
var indicesPerTrail = (pointCountPerTrail - 1) * 6;
|
|
16381
16475
|
var indices = this.geometry.getIndexData();
|
|
16476
|
+
assertExist(indices);
|
|
16382
16477
|
indices.set(new Uint16Array(indicesPerTrail), index * indicesPerTrail);
|
|
16383
16478
|
this.geometry.setIndexData(indices);
|
|
16384
16479
|
this.trailCursors[index] = 0;
|
|
@@ -16832,7 +16927,7 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
|
|
|
16832
16927
|
break;
|
|
16833
16928
|
}
|
|
16834
16929
|
var burst = bursts[j];
|
|
16835
|
-
var opts =
|
|
16930
|
+
var opts = burst.getGeneratorOptions(timePassed, lifetime);
|
|
16836
16931
|
if (opts) {
|
|
16837
16932
|
var originVec = [
|
|
16838
16933
|
0,
|
|
@@ -16841,9 +16936,6 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
|
|
|
16841
16936
|
];
|
|
16842
16937
|
var offsets = emission.burstOffsets[j];
|
|
16843
16938
|
var burstOffset = offsets && offsets[opts.cycleIndex] || originVec;
|
|
16844
|
-
if (burst.once) {
|
|
16845
|
-
this.removeBurst(j);
|
|
16846
|
-
}
|
|
16847
16939
|
for(var i1 = 0; i1 < opts.count && cursor < maxCount; i1++){
|
|
16848
16940
|
var _p_transform;
|
|
16849
16941
|
if (shouldSkipGenerate()) {
|
|
@@ -17480,13 +17572,14 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
|
|
|
17480
17572
|
}
|
|
17481
17573
|
}
|
|
17482
17574
|
this.renderer = new ParticleSystemRenderer(this.engine, particleMeshProps, trailMeshProps);
|
|
17575
|
+
this.renderer.item = this.item;
|
|
17483
17576
|
this.meshes = this.renderer.meshes;
|
|
17484
|
-
// this.item = vfxItem;
|
|
17485
17577
|
var interaction = props.interaction;
|
|
17486
17578
|
if (interaction) {
|
|
17579
|
+
var _interaction_radius;
|
|
17487
17580
|
this.interaction = {
|
|
17488
17581
|
multiple: interaction.multiple,
|
|
17489
|
-
radius: interaction.radius,
|
|
17582
|
+
radius: (_interaction_radius = interaction.radius) != null ? _interaction_radius : 0.4,
|
|
17490
17583
|
behavior: interaction.behavior
|
|
17491
17584
|
};
|
|
17492
17585
|
}
|
|
@@ -17570,7 +17663,10 @@ function randomArrItem(arr, keepArr) {
|
|
|
17570
17663
|
*/ var ParticleBehaviourPlayable = /*#__PURE__*/ function(Playable) {
|
|
17571
17664
|
_inherits(ParticleBehaviourPlayable, Playable);
|
|
17572
17665
|
function ParticleBehaviourPlayable() {
|
|
17573
|
-
|
|
17666
|
+
var _this;
|
|
17667
|
+
_this = Playable.apply(this, arguments) || this;
|
|
17668
|
+
_this.lastTime = 0;
|
|
17669
|
+
return _this;
|
|
17574
17670
|
}
|
|
17575
17671
|
var _proto = ParticleBehaviourPlayable.prototype;
|
|
17576
17672
|
_proto.start = function start(context) {
|
|
@@ -17598,8 +17694,12 @@ function randomArrItem(arr, keepArr) {
|
|
|
17598
17694
|
if (this.time < particleSystem.item.duration && particleSystem.isFrozen()) {
|
|
17599
17695
|
particleSystem.reset();
|
|
17600
17696
|
}
|
|
17697
|
+
if (Math.abs(this.time - this.lastTime) < 0.001) {
|
|
17698
|
+
deltaTime = 0;
|
|
17699
|
+
}
|
|
17601
17700
|
particleSystem.onUpdate(deltaTime);
|
|
17602
17701
|
}
|
|
17702
|
+
this.lastTime = this.time;
|
|
17603
17703
|
};
|
|
17604
17704
|
return ParticleBehaviourPlayable;
|
|
17605
17705
|
}(Playable);
|
|
@@ -18012,6 +18112,7 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
18012
18112
|
_proto.getPointColor = function getPointColor(index) {
|
|
18013
18113
|
var data = this.geometry.getAttributeData("aRot");
|
|
18014
18114
|
var i = index * 32 + 4;
|
|
18115
|
+
assertExist(data);
|
|
18015
18116
|
return [
|
|
18016
18117
|
data[i],
|
|
18017
18118
|
data[i + 1],
|
|
@@ -18041,6 +18142,7 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
18041
18142
|
};
|
|
18042
18143
|
_proto.minusTime = function minusTime(time) {
|
|
18043
18144
|
var data = this.geometry.getAttributeData("aOffset");
|
|
18145
|
+
assertExist(data);
|
|
18044
18146
|
for(var i = 0; i < data.length; i += 4){
|
|
18045
18147
|
data[i + 2] -= time;
|
|
18046
18148
|
}
|
|
@@ -18167,6 +18269,7 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
18167
18269
|
var attrSize = geometry.getAttributeStride(name) / Float32Array.BYTES_PER_ELEMENT;
|
|
18168
18270
|
if (increaseBuffer) {
|
|
18169
18271
|
var baseData = geometry.getAttributeData(name);
|
|
18272
|
+
assertExist(baseData);
|
|
18170
18273
|
var geoData = enlargeBuffer(baseData, vertexCount * attrSize, maxCount * 4 * attrSize, inc);
|
|
18171
18274
|
geoData.set(data, data.length * index);
|
|
18172
18275
|
geometry.setAttributeData(name, geoData);
|
|
@@ -18536,12 +18639,8 @@ var ParticleLoader = /*#__PURE__*/ function(AbstractPlugin) {
|
|
|
18536
18639
|
// TODO 此处add是否有意义?shader变量似乎没有加到this.shaders数组。
|
|
18537
18640
|
if (item.content.trails) {
|
|
18538
18641
|
var shader1 = getTrailMeshShader(item.content.trails, item.content.options.maxCount, item.name, gpuCapability, env);
|
|
18539
|
-
var _shader_macros;
|
|
18540
|
-
shader1.vertex = createShaderWithMacros((_shader_macros = shader1.macros) != null ? _shader_macros : [], shader1.vertex, exports.ShaderType.vertex, level);
|
|
18541
|
-
var _shader_macros1;
|
|
18542
|
-
shader1.fragment = createShaderWithMacros((_shader_macros1 = shader1.macros) != null ? _shader_macros1 : [], shader1.fragment, exports.ShaderType.fragment, level);
|
|
18543
18642
|
shader1.glslVersion = level === 2 ? exports.GLSLVersion.GLSL3 : exports.GLSLVersion.GLSL1;
|
|
18544
|
-
shaderLibrary.addShader(shader1);
|
|
18643
|
+
shaderLibrary == null ? void 0 : shaderLibrary.addShader(shader1);
|
|
18545
18644
|
}
|
|
18546
18645
|
});
|
|
18547
18646
|
shaders.forEach(function(shader) {
|
|
@@ -18551,15 +18650,10 @@ var ParticleLoader = /*#__PURE__*/ function(AbstractPlugin) {
|
|
|
18551
18650
|
} else {
|
|
18552
18651
|
shader.glslVersion = exports.GLSLVersion.GLSL1;
|
|
18553
18652
|
}
|
|
18554
|
-
|
|
18555
|
-
shader.vertex = createShaderWithMacros((_shader_macros = shader.macros) != null ? _shader_macros : [], shader.vertex, exports.ShaderType.vertex, level);
|
|
18556
|
-
var _shader_macros1;
|
|
18557
|
-
shader.fragment = createShaderWithMacros((_shader_macros1 = shader.macros) != null ? _shader_macros1 : [], shader.fragment, exports.ShaderType.fragment, level);
|
|
18558
|
-
shaderLibrary.addShader(shader);
|
|
18653
|
+
shaderLibrary == null ? void 0 : shaderLibrary.addShader(shader);
|
|
18559
18654
|
});
|
|
18560
18655
|
if (level === 2) {
|
|
18561
18656
|
items.forEach(function(item) {
|
|
18562
|
-
// @ts-expect-error
|
|
18563
18657
|
item.content.options.meshSlots = [
|
|
18564
18658
|
maxVertexCount,
|
|
18565
18659
|
maxFragmentCount
|
|
@@ -19428,7 +19522,7 @@ function compareTracks(a, b) {
|
|
|
19428
19522
|
this.items.length = 0;
|
|
19429
19523
|
if (this.item.composition) {
|
|
19430
19524
|
var assetLoader = this.item.engine.assetLoader;
|
|
19431
|
-
var itemProps = this.
|
|
19525
|
+
var itemProps = this.data.items ? this.data.items : [];
|
|
19432
19526
|
for(var i = 0; i < itemProps.length; i++){
|
|
19433
19527
|
var item = void 0;
|
|
19434
19528
|
var itemData = itemProps[i];
|
|
@@ -19797,7 +19891,9 @@ var CanvasPool = /*#__PURE__*/ function() {
|
|
|
19797
19891
|
};
|
|
19798
19892
|
_proto.getCanvas = function getCanvas() {
|
|
19799
19893
|
if (this.elements.length !== 0) {
|
|
19800
|
-
|
|
19894
|
+
var canvas = this.elements.shift();
|
|
19895
|
+
assertExist(canvas);
|
|
19896
|
+
return canvas;
|
|
19801
19897
|
}
|
|
19802
19898
|
if (getConfig(TEMPLATE_USE_OFFSCREEN_CANVAS)) {
|
|
19803
19899
|
return window._createOffscreenCanvas(10, 10);
|
|
@@ -19822,9 +19918,6 @@ var CanvasPool = /*#__PURE__*/ function() {
|
|
|
19822
19918
|
return CanvasPool;
|
|
19823
19919
|
}();
|
|
19824
19920
|
var canvasPool = new CanvasPool();
|
|
19825
|
-
function getDefaultTemplateCanvasPool() {
|
|
19826
|
-
return canvasPool;
|
|
19827
|
-
}
|
|
19828
19921
|
|
|
19829
19922
|
var DEFAULT_FONTS = [
|
|
19830
19923
|
"serif",
|
|
@@ -20246,7 +20339,6 @@ var TextLoader = /*#__PURE__*/ function(AbstractPlugin) {
|
|
|
20246
20339
|
return TextLoader;
|
|
20247
20340
|
}(AbstractPlugin);
|
|
20248
20341
|
|
|
20249
|
-
var seed$2 = 1;
|
|
20250
20342
|
exports.EffectComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
20251
20343
|
_inherits(EffectComponent, RendererComponent);
|
|
20252
20344
|
function EffectComponent(engine) {
|
|
@@ -20257,7 +20349,6 @@ exports.EffectComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
|
20257
20349
|
*/ _this.worldMatrix = Matrix4.fromIdentity();
|
|
20258
20350
|
_this.triangles = [];
|
|
20259
20351
|
_this.destroyed = false;
|
|
20260
|
-
_this.visible = false;
|
|
20261
20352
|
// TODO 点击测试后续抽象一个 Collider 组件
|
|
20262
20353
|
_this.getHitTestParams = function(force) {
|
|
20263
20354
|
var area = _this.getBoundingBox();
|
|
@@ -20268,18 +20359,11 @@ exports.EffectComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
|
20268
20359
|
};
|
|
20269
20360
|
}
|
|
20270
20361
|
};
|
|
20271
|
-
_this.
|
|
20272
|
-
_this.name = "<unnamed>";
|
|
20362
|
+
_this.name = "EffectComponent";
|
|
20273
20363
|
_this._priority = 0;
|
|
20274
20364
|
return _this;
|
|
20275
20365
|
}
|
|
20276
20366
|
var _proto = EffectComponent.prototype;
|
|
20277
|
-
/**
|
|
20278
|
-
* 设置当前 Mesh 的可见性。
|
|
20279
|
-
* @param visible - true:可见,false:不可见
|
|
20280
|
-
*/ _proto.setVisible = function setVisible(visible) {
|
|
20281
|
-
this.visible = visible;
|
|
20282
|
-
};
|
|
20283
20367
|
_proto.start = function start() {
|
|
20284
20368
|
this.item.getHitTestParams = this.getHitTestParams;
|
|
20285
20369
|
};
|
|
@@ -20290,16 +20374,6 @@ exports.EffectComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
|
20290
20374
|
renderer.drawGeometry(this.geometry, this.material);
|
|
20291
20375
|
};
|
|
20292
20376
|
/**
|
|
20293
|
-
* 获取当前 Mesh 的可见性。
|
|
20294
|
-
*/ _proto.getVisible = function getVisible() {
|
|
20295
|
-
return this.visible;
|
|
20296
|
-
};
|
|
20297
|
-
/**
|
|
20298
|
-
* 获取当前 Mesh 的第一个 geometry。
|
|
20299
|
-
*/ _proto.firstGeometry = function firstGeometry() {
|
|
20300
|
-
return this.geometry;
|
|
20301
|
-
};
|
|
20302
|
-
/**
|
|
20303
20377
|
* 设置当前 Mesh 的材质
|
|
20304
20378
|
* @param material - 要设置的材质
|
|
20305
20379
|
* @param destroy - 可选的材质销毁选项
|
|
@@ -20346,27 +20420,11 @@ exports.EffectComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
|
20346
20420
|
* @param options - 可选的销毁选项
|
|
20347
20421
|
*/ _proto.dispose = function dispose(options) {
|
|
20348
20422
|
if (this.destroyed) {
|
|
20349
|
-
//console.error('call mesh.destroy multiple times', this);
|
|
20350
20423
|
return;
|
|
20351
20424
|
}
|
|
20352
|
-
// if (options?.geometries !== DestroyOptions.keep) {
|
|
20353
|
-
// this.geometry.dispose();
|
|
20354
|
-
// }
|
|
20355
|
-
// const materialDestroyOption = options?.material;
|
|
20356
|
-
// if (materialDestroyOption !== DestroyOptions.keep) {
|
|
20357
|
-
// this.material.dispose(materialDestroyOption);
|
|
20358
|
-
// }
|
|
20359
20425
|
this.destroyed = true;
|
|
20360
20426
|
RendererComponent.prototype.dispose.call(this);
|
|
20361
20427
|
};
|
|
20362
|
-
_create_class(EffectComponent, [
|
|
20363
|
-
{
|
|
20364
|
-
key: "isDestroyed",
|
|
20365
|
-
get: function get() {
|
|
20366
|
-
return this.destroyed;
|
|
20367
|
-
}
|
|
20368
|
-
}
|
|
20369
|
-
]);
|
|
20370
20428
|
return EffectComponent;
|
|
20371
20429
|
}(RendererComponent);
|
|
20372
20430
|
__decorate([
|
|
@@ -20376,8 +20434,10 @@ exports.EffectComponent = __decorate([
|
|
|
20376
20434
|
effectsClass(DataType.EffectComponent)
|
|
20377
20435
|
], exports.EffectComponent);
|
|
20378
20436
|
function geometryToTriangles(geometry) {
|
|
20379
|
-
var
|
|
20380
|
-
var
|
|
20437
|
+
var _geometry_getIndexData;
|
|
20438
|
+
var indices = (_geometry_getIndexData = geometry.getIndexData()) != null ? _geometry_getIndexData : [];
|
|
20439
|
+
var _geometry_getAttributeData;
|
|
20440
|
+
var vertices = (_geometry_getAttributeData = geometry.getAttributeData("aPos")) != null ? _geometry_getAttributeData : [];
|
|
20381
20441
|
var res = [];
|
|
20382
20442
|
for(var i = 0; i < indices.length; i += 3){
|
|
20383
20443
|
var index0 = indices[i] * 3;
|
|
@@ -23102,6 +23162,7 @@ function getStandardJSON(json) {
|
|
|
23102
23162
|
reverseParticle = ((_exec = /^(\d+)/.exec(json.version)) == null ? void 0 : _exec[0]) === "0";
|
|
23103
23163
|
return version30Migration(version21Migration(getStandardJSONFromV0(json)));
|
|
23104
23164
|
}
|
|
23165
|
+
reverseParticle = false;
|
|
23105
23166
|
var vs = standardVersion.exec(json.version) || [];
|
|
23106
23167
|
var mainVersion = Number(vs[1]);
|
|
23107
23168
|
var minorVersion = Number(vs[2]);
|
|
@@ -23848,7 +23909,6 @@ var seed$1 = 1;
|
|
|
23848
23909
|
return __generator(this, function(_state) {
|
|
23849
23910
|
switch(_state.label){
|
|
23850
23911
|
case 0:
|
|
23851
|
-
// TODO: 后面切换到新的数据版本,就不用掉用 getStandardJSON 做转换了
|
|
23852
23912
|
jsonScene = getStandardJSON(json);
|
|
23853
23913
|
_jsonScene_plugins = jsonScene.plugins, plugins = _jsonScene_plugins === void 0 ? [] : _jsonScene_plugins, sceneCompositions = jsonScene.compositions, imgUsage = jsonScene.imgUsage, images = jsonScene.images;
|
|
23854
23914
|
pluginSystem = new PluginSystem(plugins);
|
|
@@ -24142,18 +24202,18 @@ var seed$1 = 1;
|
|
|
24142
24202
|
source: source
|
|
24143
24203
|
};
|
|
24144
24204
|
});
|
|
24145
|
-
jobs = textures.map(/*#__PURE__*/ _async_to_generator(function(
|
|
24146
|
-
var e, source, image,
|
|
24205
|
+
jobs = textures.map(/*#__PURE__*/ _async_to_generator(function(textureOptions, idx) {
|
|
24206
|
+
var e, source, image, texture;
|
|
24147
24207
|
return __generator(this, function(_state) {
|
|
24148
24208
|
switch(_state.label){
|
|
24149
24209
|
case 0:
|
|
24150
|
-
if (_instanceof1(
|
|
24210
|
+
if (_instanceof1(textureOptions, Texture)) {
|
|
24151
24211
|
return [
|
|
24152
24212
|
2,
|
|
24153
|
-
|
|
24213
|
+
textureOptions
|
|
24154
24214
|
];
|
|
24155
24215
|
}
|
|
24156
|
-
if (!("mipmaps" in
|
|
24216
|
+
if (!("mipmaps" in textureOptions)) return [
|
|
24157
24217
|
3,
|
|
24158
24218
|
4
|
|
24159
24219
|
];
|
|
@@ -24167,7 +24227,7 @@ var seed$1 = 1;
|
|
|
24167
24227
|
]);
|
|
24168
24228
|
return [
|
|
24169
24229
|
4,
|
|
24170
|
-
deserializeMipmapTexture(
|
|
24230
|
+
deserializeMipmapTexture(textureOptions, bins, engine, jsonScene.bins)
|
|
24171
24231
|
];
|
|
24172
24232
|
case 2:
|
|
24173
24233
|
return [
|
|
@@ -24178,12 +24238,11 @@ var seed$1 = 1;
|
|
|
24178
24238
|
e = _state.sent();
|
|
24179
24239
|
throw new Error("Load texture " + idx + " fails, error message: " + e + ".");
|
|
24180
24240
|
case 4:
|
|
24181
|
-
source =
|
|
24241
|
+
source = textureOptions.source;
|
|
24182
24242
|
if (!isObject(source)) return [
|
|
24183
24243
|
3,
|
|
24184
24244
|
5
|
|
24185
24245
|
];
|
|
24186
|
-
//@ts-expect-error
|
|
24187
24246
|
image = engine.assetLoader.loadGUID(source.id).data;
|
|
24188
24247
|
return [
|
|
24189
24248
|
3,
|
|
@@ -24203,12 +24262,12 @@ var seed$1 = 1;
|
|
|
24203
24262
|
_state.label = 7;
|
|
24204
24263
|
case 7:
|
|
24205
24264
|
if (image) {
|
|
24206
|
-
|
|
24207
|
-
|
|
24208
|
-
|
|
24265
|
+
texture = createTextureOptionsBySource(image, _this.assets[idx]);
|
|
24266
|
+
texture.id = textureOptions.id;
|
|
24267
|
+
texture.dataType = DataType.Texture;
|
|
24209
24268
|
return [
|
|
24210
24269
|
2,
|
|
24211
|
-
|
|
24270
|
+
texture.sourceType === exports.TextureSourceType.compressed ? texture : _extends({}, texture, textureOptions)
|
|
24212
24271
|
];
|
|
24213
24272
|
}
|
|
24214
24273
|
throw new Error("Invalid texture source: " + source + ".");
|
|
@@ -24703,7 +24762,6 @@ var listOrder = 0;
|
|
|
24703
24762
|
if (!this.refCompositionProps.has(refId)) {
|
|
24704
24763
|
this.refCompositionProps.set(refId, ref);
|
|
24705
24764
|
}
|
|
24706
|
-
itemProps.items = ref.items;
|
|
24707
24765
|
}
|
|
24708
24766
|
items.push(itemProps);
|
|
24709
24767
|
}
|
|
@@ -27595,7 +27653,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem, true);
|
|
|
27595
27653
|
registerPlugin("particle", ParticleLoader, exports.VFXItem, true);
|
|
27596
27654
|
registerPlugin("cal", CalculateLoader, exports.VFXItem, true);
|
|
27597
27655
|
registerPlugin("interact", InteractLoader, exports.VFXItem, true);
|
|
27598
|
-
var version$1 = "2.0.0-alpha.
|
|
27656
|
+
var version$1 = "2.0.0-alpha.35";
|
|
27599
27657
|
logger.info("Core version: " + version$1 + ".");
|
|
27600
27658
|
|
|
27601
27659
|
var _obj;
|
|
@@ -27670,11 +27728,12 @@ var _obj3;
|
|
|
27670
27728
|
var shader = props == null ? void 0 : props.shader;
|
|
27671
27729
|
var level = engine.gpuCapability.level;
|
|
27672
27730
|
_this.shader = new exports.Shader(engine);
|
|
27731
|
+
var _shader_vertex, _shader_fragment;
|
|
27673
27732
|
_this.shader.shaderData = _extends({}, shader, {
|
|
27674
27733
|
id: generateGUID(),
|
|
27675
27734
|
dataType: DataType.Shader,
|
|
27676
|
-
vertex: (shader == null ? void 0 : shader.vertex)
|
|
27677
|
-
fragment: (shader == null ? void 0 : shader.fragment)
|
|
27735
|
+
vertex: (_shader_vertex = shader == null ? void 0 : shader.vertex) != null ? _shader_vertex : "",
|
|
27736
|
+
fragment: (_shader_fragment = shader == null ? void 0 : shader.fragment) != null ? _shader_fragment : ""
|
|
27678
27737
|
});
|
|
27679
27738
|
for(var i = 0; i < exports.maxSpriteMeshItemCount; i++){
|
|
27680
27739
|
_this.uniforms["uSampler" + i] = new THREE__namespace.Uniform(null);
|
|
@@ -27740,9 +27799,22 @@ var _obj3;
|
|
|
27740
27799
|
8,
|
|
27741
27800
|
1
|
|
27742
27801
|
]);
|
|
27802
|
+
var _shader_vertex1, _shader_fragment1;
|
|
27743
27803
|
_this.material = new THREE__namespace.RawShaderMaterial({
|
|
27744
|
-
vertexShader:
|
|
27745
|
-
|
|
27804
|
+
vertexShader: ShaderFactory.genFinalShaderCode({
|
|
27805
|
+
level: _this.engine.gpuCapability.level,
|
|
27806
|
+
shaderType: exports.ShaderType.vertex,
|
|
27807
|
+
shader: (_shader_vertex1 = shader == null ? void 0 : shader.vertex) != null ? _shader_vertex1 : "",
|
|
27808
|
+
macros: shader == null ? void 0 : shader.macros,
|
|
27809
|
+
removeVersion: true
|
|
27810
|
+
}),
|
|
27811
|
+
fragmentShader: ShaderFactory.genFinalShaderCode({
|
|
27812
|
+
level: _this.engine.gpuCapability.level,
|
|
27813
|
+
shaderType: exports.ShaderType.fragment,
|
|
27814
|
+
shader: (_shader_fragment1 = shader == null ? void 0 : shader.fragment) != null ? _shader_fragment1 : "",
|
|
27815
|
+
macros: shader == null ? void 0 : shader.macros,
|
|
27816
|
+
removeVersion: true
|
|
27817
|
+
}),
|
|
27746
27818
|
alphaToCoverage: false,
|
|
27747
27819
|
depthFunc: THREE__namespace.LessDepth,
|
|
27748
27820
|
polygonOffsetFactor: THREE__namespace.ZeroFactor,
|
|
@@ -29262,7 +29334,7 @@ setMaxSpriteMeshItemCount(8);
|
|
|
29262
29334
|
*/ Mesh.create = function(engine, props) {
|
|
29263
29335
|
return new ThreeMesh(engine, props);
|
|
29264
29336
|
};
|
|
29265
|
-
var version = "2.0.0-alpha.
|
|
29337
|
+
var version = "2.0.0-alpha.35";
|
|
29266
29338
|
logger.info("THREEJS plugin version: " + version + ".");
|
|
29267
29339
|
|
|
29268
29340
|
exports.AbstractPlugin = AbstractPlugin;
|
|
@@ -29351,6 +29423,7 @@ exports.SEMANTIC_PRE_COLOR_ATTACHMENT_SIZE_0 = SEMANTIC_PRE_COLOR_ATTACHMENT_SIZ
|
|
|
29351
29423
|
exports.SPRITE_VERTEX_STRIDE = SPRITE_VERTEX_STRIDE;
|
|
29352
29424
|
exports.SemanticMap = SemanticMap;
|
|
29353
29425
|
exports.SerializationHelper = SerializationHelper;
|
|
29426
|
+
exports.ShaderFactory = ShaderFactory;
|
|
29354
29427
|
exports.ShaderVariant = ShaderVariant;
|
|
29355
29428
|
exports.SpriteColorPlayable = SpriteColorPlayable;
|
|
29356
29429
|
exports.SpriteLoader = SpriteLoader;
|
|
@@ -29389,12 +29462,9 @@ exports.colorGradingFrag = colorGradingFrag;
|
|
|
29389
29462
|
exports.colorStopsFromGradient = colorStopsFromGradient;
|
|
29390
29463
|
exports.colorToArr = colorToArr$1;
|
|
29391
29464
|
exports.combineImageTemplate = combineImageTemplate;
|
|
29392
|
-
exports.compatibleFrag = compatible_frag;
|
|
29393
|
-
exports.compatibleVert = compatible_vert;
|
|
29394
29465
|
exports.createCopyShader = createCopyShader;
|
|
29395
29466
|
exports.createGLContext = createGLContext;
|
|
29396
29467
|
exports.createKeyFrameMeta = createKeyFrameMeta;
|
|
29397
|
-
exports.createShaderWithMacros = createShaderWithMacros;
|
|
29398
29468
|
exports.createShape = createShape;
|
|
29399
29469
|
exports.createValueGetter = createValueGetter;
|
|
29400
29470
|
exports.decimalEqual = decimalEqual;
|
|
@@ -29420,7 +29490,6 @@ exports.generateWhiteTexture = generateWhiteTexture;
|
|
|
29420
29490
|
exports.getBackgroundImage = getBackgroundImage;
|
|
29421
29491
|
exports.getColorFromGradientStops = getColorFromGradientStops;
|
|
29422
29492
|
exports.getConfig = getConfig;
|
|
29423
|
-
exports.getDefaultTemplateCanvasPool = getDefaultTemplateCanvasPool;
|
|
29424
29493
|
exports.getDefaultTextureFactory = getDefaultTextureFactory;
|
|
29425
29494
|
exports.getGeometryByShape = getGeometryByShape;
|
|
29426
29495
|
exports.getGeometryTriangles = getGeometryTriangles;
|
|
@@ -29487,7 +29556,6 @@ exports.particleOriginTranslateMap = particleOriginTranslateMap$1;
|
|
|
29487
29556
|
exports.particleUniformTypeMap = particleUniformTypeMap;
|
|
29488
29557
|
exports.particleVert = particleVert;
|
|
29489
29558
|
exports.pluginLoaderMap = pluginLoaderMap;
|
|
29490
|
-
exports.pointOnLine = pointOnLine;
|
|
29491
29559
|
exports.randomInRange = randomInRange;
|
|
29492
29560
|
exports.registerPlugin = registerPlugin;
|
|
29493
29561
|
exports.removeItem = removeItem;
|
|
@@ -29517,10 +29585,8 @@ exports.unregisterPlugin = unregisterPlugin;
|
|
|
29517
29585
|
exports.valIfUndefined = valIfUndefined;
|
|
29518
29586
|
exports.value = value;
|
|
29519
29587
|
exports.valueDefine = valueDefine;
|
|
29520
|
-
exports.vecAssign = vecAssign;
|
|
29521
29588
|
exports.vecFill = vecFill;
|
|
29522
29589
|
exports.vecMulCombine = vecMulCombine;
|
|
29523
|
-
exports.vecNormalize = vecNormalize;
|
|
29524
29590
|
exports.version = version;
|
|
29525
29591
|
exports.vertexFormatType2GLType = vertexFormatType2GLType;
|
|
29526
29592
|
//# sourceMappingURL=index.js.map
|