@galacean/effects-core 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/dist/canvas-pool.d.ts +0 -1
- package/dist/components/effect-component.d.ts +2 -22
- package/dist/index.js +272 -220
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +272 -214
- package/dist/index.mjs.map +1 -1
- package/dist/material/material.d.ts +1 -5
- package/dist/material/utils.d.ts +0 -10
- package/dist/math/utils.d.ts +0 -3
- package/dist/plugins/particle/burst.d.ts +10 -3
- package/dist/plugins/particle/particle-loader.d.ts +1 -1
- package/dist/plugins/particle/particle-system.d.ts +1 -1
- package/dist/plugins/particle/particle-vfx-item.d.ts +1 -0
- package/dist/render/create-copy-shader.d.ts +2 -2
- package/dist/render/mesh.d.ts +1 -1
- package/dist/shader/index.d.ts +1 -2
- package/dist/shader/shader-factory.d.ts +35 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Description: Galacean Effects runtime core for the web
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
|
|
6
|
-
* Version: v2.0.0-alpha.
|
|
6
|
+
* Version: v2.0.0-alpha.35
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
@@ -4786,7 +4786,9 @@ __decorate([
|
|
|
4786
4786
|
// }
|
|
4787
4787
|
/**
|
|
4788
4788
|
* 在每次设置 enabled 为 true 时触发
|
|
4789
|
-
*/ _proto.onEnable = function onEnable() {
|
|
4789
|
+
*/ _proto.onEnable = function onEnable() {
|
|
4790
|
+
// OVERRIDE
|
|
4791
|
+
};
|
|
4790
4792
|
/**
|
|
4791
4793
|
* 生命周期函数,在第一次 update 前调用,生命周期内只调用一次
|
|
4792
4794
|
*/ _proto.start = function start() {
|
|
@@ -7655,55 +7657,6 @@ function getPreMultiAlpha(blending) {
|
|
|
7655
7657
|
return 1;
|
|
7656
7658
|
}
|
|
7657
7659
|
}
|
|
7658
|
-
var _obj$6;
|
|
7659
|
-
var downgradeKeywords = (_obj$6 = {}, _obj$6[exports.ShaderType.vertex] = {
|
|
7660
|
-
in: "attribute",
|
|
7661
|
-
out: "varying"
|
|
7662
|
-
}, _obj$6[exports.ShaderType.fragment] = {
|
|
7663
|
-
in: "varying"
|
|
7664
|
-
}, _obj$6);
|
|
7665
|
-
/**
|
|
7666
|
-
* 生成 shader,检测到 WebGL1 上下文会降级
|
|
7667
|
-
* @param macros - 宏定义数组
|
|
7668
|
-
* @param shader - 原始 shader 文本
|
|
7669
|
-
* @param shaderType - shader 类型
|
|
7670
|
-
* @return 去除版本号的 shader 文本
|
|
7671
|
-
*/ function createShaderWithMacros(macros, shader, shaderType, level) {
|
|
7672
|
-
var ret = [];
|
|
7673
|
-
var header = "";
|
|
7674
|
-
// shader 标志宏,没有其他含义,方便不支持完全的自定义 shader 的三方引擎接入使用
|
|
7675
|
-
ret.push("#define GE_RUNTIME");
|
|
7676
|
-
if (macros) {
|
|
7677
|
-
macros.forEach(function(param) {
|
|
7678
|
-
var key = param[0], value = param[1];
|
|
7679
|
-
if (value === true) {
|
|
7680
|
-
ret.push("#define " + key);
|
|
7681
|
-
} else if (Number.isFinite(value)) {
|
|
7682
|
-
ret.push("#define " + key + " " + value);
|
|
7683
|
-
}
|
|
7684
|
-
});
|
|
7685
|
-
header = ret.length ? ret.join("\n") + "\n" : "";
|
|
7686
|
-
}
|
|
7687
|
-
var versionTag = /#version\s+\b\d{3}\b\s*(es)?/;
|
|
7688
|
-
var GL_TYPE = "WEBGL" + level;
|
|
7689
|
-
header = header + ("\n#ifndef " + GL_TYPE + "\n#define " + GL_TYPE + "\n#endif");
|
|
7690
|
-
var fullShader = header + "\n" + shader;
|
|
7691
|
-
// 判断shader是否带有版本头
|
|
7692
|
-
var match = fullShader.match(versionTag);
|
|
7693
|
-
var version = match ? match[0] : "";
|
|
7694
|
-
if (version && version.includes("300")) {
|
|
7695
|
-
var reg = new RegExp("" + version, "g");
|
|
7696
|
-
// 带版本头且level为1,降级
|
|
7697
|
-
if (level === 1) {
|
|
7698
|
-
fullShader = fullShader.replace(/\b(in|out)\b/g, function(str) {
|
|
7699
|
-
var _downgradeKeywords_shaderType_str;
|
|
7700
|
-
return (_downgradeKeywords_shaderType_str = downgradeKeywords[shaderType][str]) != null ? _downgradeKeywords_shaderType_str : str;
|
|
7701
|
-
});
|
|
7702
|
-
}
|
|
7703
|
-
fullShader = fullShader.replace(reg, "\n");
|
|
7704
|
-
}
|
|
7705
|
-
return fullShader;
|
|
7706
|
-
}
|
|
7707
7660
|
function setBlendMode(material, blendMode) {
|
|
7708
7661
|
switch(blendMode){
|
|
7709
7662
|
case undefined:
|
|
@@ -8406,7 +8359,7 @@ function _loadMipmapImage() {
|
|
|
8406
8359
|
return _loadMipmapImage.apply(this, arguments);
|
|
8407
8360
|
}
|
|
8408
8361
|
|
|
8409
|
-
var seed$
|
|
8362
|
+
var seed$8 = 1;
|
|
8410
8363
|
/**
|
|
8411
8364
|
* Texture 抽象类
|
|
8412
8365
|
*/ var Texture = /*#__PURE__*/ function(EffectsObject) {
|
|
@@ -8415,7 +8368,7 @@ var seed$9 = 1;
|
|
|
8415
8368
|
var _this;
|
|
8416
8369
|
_this = EffectsObject.call(this, engine) || this;
|
|
8417
8370
|
_this.destroyed = false;
|
|
8418
|
-
_this.id = "Tex" + seed$
|
|
8371
|
+
_this.id = "Tex" + seed$8++;
|
|
8419
8372
|
return _this;
|
|
8420
8373
|
}
|
|
8421
8374
|
var _proto = Texture.prototype;
|
|
@@ -9043,7 +8996,7 @@ exports.MaterialRenderType = void 0;
|
|
|
9043
8996
|
/**
|
|
9044
8997
|
* 用于设置材质默认名称的自增序号
|
|
9045
8998
|
* @internal
|
|
9046
|
-
*/ var seed$
|
|
8999
|
+
*/ var seed$7 = 1;
|
|
9047
9000
|
/**
|
|
9048
9001
|
* Material 抽象类
|
|
9049
9002
|
*/ var Material = /*#__PURE__*/ function(EffectsObject) {
|
|
@@ -9056,14 +9009,14 @@ exports.MaterialRenderType = void 0;
|
|
|
9056
9009
|
_this.destroyed = false;
|
|
9057
9010
|
_this.initialized = false;
|
|
9058
9011
|
if (props) {
|
|
9059
|
-
var _props_name = props.name, name = _props_name === void 0 ? "Material" + seed$
|
|
9012
|
+
var _props_name = props.name, name = _props_name === void 0 ? "Material" + seed$7++ : _props_name, _props_renderType = props.renderType, renderType = _props_renderType === void 0 ? 0 : _props_renderType, shader = props.shader, uniformSemantics = props.uniformSemantics;
|
|
9060
9013
|
_this.name = name;
|
|
9061
9014
|
_this.renderType = renderType; // TODO 没有地方用到
|
|
9062
9015
|
_this.shaderSource = shader;
|
|
9063
9016
|
_this.props = props;
|
|
9064
9017
|
_this.uniformSemantics = _extends({}, uniformSemantics); // TODO 废弃,待移除
|
|
9065
9018
|
} else {
|
|
9066
|
-
_this.name = "Material" + seed$
|
|
9019
|
+
_this.name = "Material" + seed$7++;
|
|
9067
9020
|
_this.renderType = 0;
|
|
9068
9021
|
}
|
|
9069
9022
|
return _this;
|
|
@@ -9388,29 +9341,6 @@ function vecFill(out, number) {
|
|
|
9388
9341
|
}
|
|
9389
9342
|
return out;
|
|
9390
9343
|
}
|
|
9391
|
-
function vecAssign(out, a, count, start) {
|
|
9392
|
-
if (start === void 0) start = 0;
|
|
9393
|
-
for(var i = 0; i < count; i++){
|
|
9394
|
-
out[i] = a[i + start];
|
|
9395
|
-
}
|
|
9396
|
-
return out;
|
|
9397
|
-
}
|
|
9398
|
-
function vecNormalize(out, a) {
|
|
9399
|
-
var _Math;
|
|
9400
|
-
if (arguments.length === 1) {
|
|
9401
|
-
a = out;
|
|
9402
|
-
out = [];
|
|
9403
|
-
}
|
|
9404
|
-
var ap = a;
|
|
9405
|
-
var sum = (_Math = Math).hypot.apply(_Math, [].concat(ap));
|
|
9406
|
-
if (sum === 0) {
|
|
9407
|
-
return vecAssign(out, ap, ap.length);
|
|
9408
|
-
}
|
|
9409
|
-
for(var i = 0; i < ap.length; i++){
|
|
9410
|
-
out[i] = ap[i] / sum;
|
|
9411
|
-
}
|
|
9412
|
-
return out;
|
|
9413
|
-
}
|
|
9414
9344
|
function vecMulCombine(out, a, b) {
|
|
9415
9345
|
if (a && b) {
|
|
9416
9346
|
for(var i = 0, len = a.length; i < len; i++){
|
|
@@ -9500,10 +9430,6 @@ function numberToFix(a, fixed) {
|
|
|
9500
9430
|
var base = Math.pow(10, fixed);
|
|
9501
9431
|
return Math.floor(a * base) / base;
|
|
9502
9432
|
}
|
|
9503
|
-
function pointOnLine(x1, y1, x2, y2, x3, y3) {
|
|
9504
|
-
var det1 = x1 * y2 + y1 * x3 + x2 * y3 - x3 * y2 - y3 * x1 - x2 * y1;
|
|
9505
|
-
return det1 > -0.001 && det1 < 0.001;
|
|
9506
|
-
}
|
|
9507
9433
|
|
|
9508
9434
|
function _is_native_reflect_construct() {
|
|
9509
9435
|
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
@@ -10946,21 +10872,16 @@ exports.Shader = __decorate([
|
|
|
10946
10872
|
|
|
10947
10873
|
var EFFECTS_COPY_MESH_NAME = "effects-internal-copy";
|
|
10948
10874
|
var COPY_MESH_SHADER_ID = "effects-internal-copy-mesh";
|
|
10949
|
-
var COPY_VERTEX_SHADER = "\
|
|
10950
|
-
var COPY_FRAGMENT_SHADER = "precision mediump float;\
|
|
10875
|
+
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}";
|
|
10876
|
+
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";
|
|
10951
10877
|
function createCopyShader(level, writeDepth) {
|
|
10952
10878
|
var webgl2 = level === 2;
|
|
10953
|
-
var version = webgl2 ? "#version 300 es" : "";
|
|
10954
10879
|
return {
|
|
10955
10880
|
name: EFFECTS_COPY_MESH_NAME,
|
|
10956
|
-
vertex:
|
|
10957
|
-
fragment:
|
|
10881
|
+
vertex: COPY_VERTEX_SHADER,
|
|
10882
|
+
fragment: COPY_FRAGMENT_SHADER,
|
|
10958
10883
|
glslVersion: webgl2 ? exports.GLSLVersion.GLSL3 : exports.GLSLVersion.GLSL1,
|
|
10959
10884
|
macros: [
|
|
10960
|
-
[
|
|
10961
|
-
"WEBGL2",
|
|
10962
|
-
!!webgl2
|
|
10963
|
-
],
|
|
10964
10885
|
[
|
|
10965
10886
|
"DEPTH_TEXTURE",
|
|
10966
10887
|
!!writeDepth
|
|
@@ -11128,7 +11049,7 @@ function generateEmptyTypedArray(type) {
|
|
|
11128
11049
|
return new Float32Array(0);
|
|
11129
11050
|
}
|
|
11130
11051
|
|
|
11131
|
-
var seed$
|
|
11052
|
+
var seed$6 = 1;
|
|
11132
11053
|
/**
|
|
11133
11054
|
* Mesh 抽象类
|
|
11134
11055
|
*/ var Mesh = /*#__PURE__*/ function(RendererComponent) {
|
|
@@ -11140,14 +11061,14 @@ var seed$7 = 1;
|
|
|
11140
11061
|
_this.visible = true;
|
|
11141
11062
|
if (props) {
|
|
11142
11063
|
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;
|
|
11143
|
-
_this.id = "Mesh" + seed$
|
|
11064
|
+
_this.id = "Mesh" + seed$6++;
|
|
11144
11065
|
_this.name = name;
|
|
11145
11066
|
_this.geometry = geometry;
|
|
11146
11067
|
_this.material = material;
|
|
11147
11068
|
_this.priority = priority;
|
|
11148
11069
|
_this.worldMatrix = worldMatrix;
|
|
11149
11070
|
} else {
|
|
11150
|
-
_this.id = "Mesh" + seed$
|
|
11071
|
+
_this.id = "Mesh" + seed$6++;
|
|
11151
11072
|
_this.name = "<unnamed>";
|
|
11152
11073
|
_this.worldMatrix = Matrix4.fromIdentity();
|
|
11153
11074
|
_this._priority = 0;
|
|
@@ -11352,7 +11273,7 @@ exports.RenderPassDestroyAttachmentType = void 0;
|
|
|
11352
11273
|
* 强制销毁
|
|
11353
11274
|
*/ RenderPassDestroyAttachmentType[RenderPassDestroyAttachmentType["destroy"] = 0] = "destroy";
|
|
11354
11275
|
})(exports.RenderPassDestroyAttachmentType || (exports.RenderPassDestroyAttachmentType = {}));
|
|
11355
|
-
var seed$
|
|
11276
|
+
var seed$5 = 1;
|
|
11356
11277
|
/**
|
|
11357
11278
|
* RenderPass 抽象类
|
|
11358
11279
|
*/ var RenderPass = /*#__PURE__*/ function() {
|
|
@@ -11362,7 +11283,7 @@ var seed$6 = 1;
|
|
|
11362
11283
|
*/ this.attachments = [];
|
|
11363
11284
|
this.destroyed = false;
|
|
11364
11285
|
this.initialized = false;
|
|
11365
|
-
var _options_name = options.name, name = _options_name === void 0 ? "RenderPass_" + seed$
|
|
11286
|
+
var _options_name = options.name, name = _options_name === void 0 ? "RenderPass_" + seed$5++ : _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;
|
|
11366
11287
|
this.name = name;
|
|
11367
11288
|
this.renderer = renderer;
|
|
11368
11289
|
this.priority = priority;
|
|
@@ -11582,10 +11503,12 @@ var seed$6 = 1;
|
|
|
11582
11503
|
*/ _proto.getDepthAttachment = function getDepthAttachment() {
|
|
11583
11504
|
var framebuffer = this.framebuffer;
|
|
11584
11505
|
if (framebuffer) {
|
|
11506
|
+
var depthTexture = framebuffer.getDepthTexture();
|
|
11507
|
+
var texture = depthTexture ? this.getDepthTexture(depthTexture, framebuffer.externalStorage) : undefined;
|
|
11585
11508
|
return {
|
|
11586
11509
|
storageType: framebuffer.depthStencilStorageType,
|
|
11587
11510
|
storage: framebuffer.depthStorage,
|
|
11588
|
-
texture:
|
|
11511
|
+
texture: texture
|
|
11589
11512
|
};
|
|
11590
11513
|
}
|
|
11591
11514
|
};
|
|
@@ -11594,10 +11517,12 @@ var seed$6 = 1;
|
|
|
11594
11517
|
*/ _proto.getStencilAttachment = function getStencilAttachment() {
|
|
11595
11518
|
var framebuffer = this.framebuffer;
|
|
11596
11519
|
if (framebuffer) {
|
|
11520
|
+
var stencilTexture = framebuffer.getStencilTexture();
|
|
11521
|
+
var texture = stencilTexture ? this.getDepthTexture(stencilTexture, framebuffer.externalStorage) : undefined;
|
|
11597
11522
|
return {
|
|
11598
11523
|
storageType: framebuffer.depthStencilStorageType,
|
|
11599
11524
|
storage: framebuffer.stencilStorage,
|
|
11600
|
-
texture:
|
|
11525
|
+
texture: texture
|
|
11601
11526
|
};
|
|
11602
11527
|
}
|
|
11603
11528
|
};
|
|
@@ -11709,11 +11634,7 @@ var seed$6 = 1;
|
|
|
11709
11634
|
|
|
11710
11635
|
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;}";
|
|
11711
11636
|
|
|
11712
|
-
var
|
|
11713
|
-
|
|
11714
|
-
var compatible_vert = "#version 300 es\n#ifdef WEBGL2\n#define texture2D texture\n#else\n#endif\n";
|
|
11715
|
-
|
|
11716
|
-
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);}";
|
|
11637
|
+
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);}";
|
|
11717
11638
|
|
|
11718
11639
|
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.;}";
|
|
11719
11640
|
|
|
@@ -11721,13 +11642,13 @@ var itemVert = "precision highp float;attribute vec2 atlasOffset;attribute vec3
|
|
|
11721
11642
|
|
|
11722
11643
|
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;}";
|
|
11723
11644
|
|
|
11724
|
-
var particleFrag = "#version
|
|
11645
|
+
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";
|
|
11725
11646
|
|
|
11726
|
-
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}}";
|
|
11647
|
+
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}}";
|
|
11727
11648
|
|
|
11728
|
-
var trailVert = "#version
|
|
11649
|
+
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}";
|
|
11729
11650
|
|
|
11730
|
-
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\
|
|
11651
|
+
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.;}";
|
|
11731
11652
|
|
|
11732
11653
|
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";
|
|
11733
11654
|
|
|
@@ -11745,6 +11666,159 @@ var gaussianUpFrag = "precision highp float;varying vec2 uv;uniform sampler2D _M
|
|
|
11745
11666
|
|
|
11746
11667
|
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);}";
|
|
11747
11668
|
|
|
11669
|
+
var shaderLib = {};
|
|
11670
|
+
var ShaderFactory = /*#__PURE__*/ function() {
|
|
11671
|
+
function ShaderFactory() {}
|
|
11672
|
+
ShaderFactory.registerInclude = function registerInclude(includeName, includeSource) {
|
|
11673
|
+
if (shaderLib[includeName]) {
|
|
11674
|
+
logger.warn('The "' + includeName + '" shader include already exist.');
|
|
11675
|
+
}
|
|
11676
|
+
shaderLib[includeName] = includeSource;
|
|
11677
|
+
};
|
|
11678
|
+
ShaderFactory.unRegisterInclude = function unRegisterInclude(includeName) {
|
|
11679
|
+
delete shaderLib[includeName];
|
|
11680
|
+
};
|
|
11681
|
+
ShaderFactory.unRegisterAllIncludes = function unRegisterAllIncludes() {
|
|
11682
|
+
Object.keys(shaderLib).forEach(function(key) {
|
|
11683
|
+
ShaderFactory.unRegisterInclude(key);
|
|
11684
|
+
});
|
|
11685
|
+
};
|
|
11686
|
+
/**
|
|
11687
|
+
* 生成 shader,检测到 WebGL1 上下文会降级
|
|
11688
|
+
* @param macros - 宏定义数组
|
|
11689
|
+
* @param shader - 原始 shader 文本
|
|
11690
|
+
* @param shaderType - shader 类型
|
|
11691
|
+
* @return 去除版本号的 shader 文本
|
|
11692
|
+
*/ ShaderFactory.genFinalShaderCode = function genFinalShaderCode(options) {
|
|
11693
|
+
var level = options.level, shaderType = options.shaderType, shader = options.shader, macros = options.macros, removeVersion = options.removeVersion;
|
|
11694
|
+
var macroString = ShaderFactory.genMacroString(level, macros);
|
|
11695
|
+
var versionString = ShaderFactory.genShaderVersion(level);
|
|
11696
|
+
var source = ShaderFactory.parseIncludes(shader);
|
|
11697
|
+
var isVersion300 = ShaderFactory.isVersion300(source);
|
|
11698
|
+
source = ShaderFactory.removeWebGLVersion(source);
|
|
11699
|
+
if (level === 2 && !isVersion300) {
|
|
11700
|
+
source = ShaderFactory.convertTo300(source, shaderType === exports.ShaderType.fragment);
|
|
11701
|
+
}
|
|
11702
|
+
if (removeVersion) {
|
|
11703
|
+
return macroString + source;
|
|
11704
|
+
}
|
|
11705
|
+
return versionString + macroString + source;
|
|
11706
|
+
};
|
|
11707
|
+
/**
|
|
11708
|
+
* Convert lower GLSL version to GLSL 300 es.
|
|
11709
|
+
* @param source - code
|
|
11710
|
+
* @param isFragment - Whether it is a fragment shader.
|
|
11711
|
+
* */ ShaderFactory.convertTo300 = function convertTo300(source, isFragment) {
|
|
11712
|
+
source = source.replace(/\bvarying\b/g, isFragment ? "in" : "out");
|
|
11713
|
+
source = source.replace(/\btexture(2D|Cube)\b/g, "texture");
|
|
11714
|
+
// Remove extensions
|
|
11715
|
+
var regex = /#extension.+(GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g;
|
|
11716
|
+
source = source.replace(regex, "");
|
|
11717
|
+
if (isFragment) {
|
|
11718
|
+
source = source.replace(/\btexture(2D|Cube)LodEXT\b/g, "textureLod");
|
|
11719
|
+
source = source.replace(/\btexture(2D|Cube)GradEXT\b/g, "textureGrad");
|
|
11720
|
+
source = source.replace(/\bgl_FragDepthEXT\b/g, "gl_FragDepth");
|
|
11721
|
+
if (!ShaderFactory.has300Output(source)) {
|
|
11722
|
+
var isMRT = /\bgl_FragData\[.+?\]/g.test(source);
|
|
11723
|
+
if (isMRT) {
|
|
11724
|
+
source = source.replace(/\bgl_FragColor\b/g, "gl_FragData[0]");
|
|
11725
|
+
var result = source.match(/\bgl_FragData\[.+?\]/g);
|
|
11726
|
+
if (result) {
|
|
11727
|
+
source = ShaderFactory.replaceMRTShader(source, result);
|
|
11728
|
+
}
|
|
11729
|
+
} else {
|
|
11730
|
+
source = source.replace(/void\s+?main\s*\(/g, "out vec4 glFragColor;\nvoid main(");
|
|
11731
|
+
source = source.replace(/\bgl_FragColor\b/g, "glFragColor");
|
|
11732
|
+
}
|
|
11733
|
+
}
|
|
11734
|
+
} else {
|
|
11735
|
+
source = source.replace(/\battribute\b/g, "in");
|
|
11736
|
+
}
|
|
11737
|
+
return source;
|
|
11738
|
+
};
|
|
11739
|
+
ShaderFactory.parseIncludes = function parseIncludes(source, regex) {
|
|
11740
|
+
if (regex === void 0) regex = /#include <(.+)>/gm;
|
|
11741
|
+
var match;
|
|
11742
|
+
while((match = regex.exec(source)) !== null){
|
|
11743
|
+
var shaderName = match[1];
|
|
11744
|
+
var replace = shaderLib[shaderName];
|
|
11745
|
+
if (replace === undefined) {
|
|
11746
|
+
throw new Error("Can't find include shader name " + shaderName);
|
|
11747
|
+
}
|
|
11748
|
+
source = source.replace(match[0], replace);
|
|
11749
|
+
}
|
|
11750
|
+
return source;
|
|
11751
|
+
};
|
|
11752
|
+
ShaderFactory.genMacroString = function genMacroString(level, macros, addRuntimeMacro) {
|
|
11753
|
+
if (addRuntimeMacro === void 0) addRuntimeMacro = true;
|
|
11754
|
+
var macroList = [];
|
|
11755
|
+
var webGLVersion = "WEBGL" + level;
|
|
11756
|
+
macroList.push("#ifndef " + webGLVersion);
|
|
11757
|
+
macroList.push("#define " + webGLVersion);
|
|
11758
|
+
macroList.push("#endif");
|
|
11759
|
+
if (addRuntimeMacro) {
|
|
11760
|
+
macroList.push("#define GE_RUNTIME");
|
|
11761
|
+
}
|
|
11762
|
+
if (macros && macros.length) {
|
|
11763
|
+
macros.forEach(function(param) {
|
|
11764
|
+
var key = param[0], value = param[1];
|
|
11765
|
+
if (value === true) {
|
|
11766
|
+
macroList.push("#define " + key);
|
|
11767
|
+
} else if (Number.isFinite(value)) {
|
|
11768
|
+
macroList.push("#define " + key + " " + value);
|
|
11769
|
+
}
|
|
11770
|
+
});
|
|
11771
|
+
}
|
|
11772
|
+
if (macroList.length) {
|
|
11773
|
+
return macroList.join("\n") + "\n";
|
|
11774
|
+
}
|
|
11775
|
+
return "";
|
|
11776
|
+
};
|
|
11777
|
+
ShaderFactory.genShaderVersion = function genShaderVersion(level) {
|
|
11778
|
+
if (level === 1) {
|
|
11779
|
+
return "#version 100\n";
|
|
11780
|
+
}
|
|
11781
|
+
return "#version 300 es\n";
|
|
11782
|
+
};
|
|
11783
|
+
ShaderFactory.isVersion300 = function isVersion300(source) {
|
|
11784
|
+
var versionTag = /#version\s+\b\d{3}\b\s*(es)?/;
|
|
11785
|
+
var match = source.match(versionTag);
|
|
11786
|
+
var version = match ? match[0] : "";
|
|
11787
|
+
return version.includes("300");
|
|
11788
|
+
};
|
|
11789
|
+
ShaderFactory.removeWebGLVersion = function removeWebGLVersion(source) {
|
|
11790
|
+
var versionTag = /#version\s+\b\d{3}\b\s*(es)?/;
|
|
11791
|
+
var match = source.match(versionTag);
|
|
11792
|
+
if (match) {
|
|
11793
|
+
return source.replace(match[0], "");
|
|
11794
|
+
}
|
|
11795
|
+
return source;
|
|
11796
|
+
};
|
|
11797
|
+
ShaderFactory.has300Output = function has300Output(fragmentShader) {
|
|
11798
|
+
// [layout(location = 0)] out [highp] vec4 [color];
|
|
11799
|
+
var fragReg = /\bout\s+(?:\w+\s+)?(?:vec4)\s+(?:\w+)\s*;/;
|
|
11800
|
+
return fragReg.test(fragmentShader);
|
|
11801
|
+
};
|
|
11802
|
+
ShaderFactory.replaceMRTShader = function replaceMRTShader(source, result) {
|
|
11803
|
+
var mrtIndexSet = new Set();
|
|
11804
|
+
var declaration = "";
|
|
11805
|
+
for(var i = 0; i < result.length; i++){
|
|
11806
|
+
var res = result[i].match(/\bgl_FragData\[(.+?)\]/);
|
|
11807
|
+
if (res) {
|
|
11808
|
+
mrtIndexSet.add(res[1]);
|
|
11809
|
+
}
|
|
11810
|
+
}
|
|
11811
|
+
mrtIndexSet.forEach(function(index) {
|
|
11812
|
+
declaration += "layout(location=" + index + ") out vec4 fragOutColor" + index + ";\n";
|
|
11813
|
+
});
|
|
11814
|
+
declaration += "void main(";
|
|
11815
|
+
source = source.replace(/\bgl_FragData\[(.+?)\]/g, "fragOutColor$1");
|
|
11816
|
+
source = source.replace(/void\s+?main\s*\(/g, declaration);
|
|
11817
|
+
return source;
|
|
11818
|
+
};
|
|
11819
|
+
return ShaderFactory;
|
|
11820
|
+
}();
|
|
11821
|
+
|
|
11748
11822
|
// Bloom 阈值 Pass
|
|
11749
11823
|
var BloomThresholdPass = /*#__PURE__*/ function(RenderPass) {
|
|
11750
11824
|
_inherits(BloomThresholdPass, RenderPass);
|
|
@@ -12042,7 +12116,7 @@ var ToneMappingPass = /*#__PURE__*/ function(RenderPass) {
|
|
|
12042
12116
|
}(RenderPass);
|
|
12043
12117
|
|
|
12044
12118
|
var RENDER_PASS_NAME_PREFIX = "_effects_default_";
|
|
12045
|
-
var seed$
|
|
12119
|
+
var seed$4 = 1;
|
|
12046
12120
|
/**
|
|
12047
12121
|
* RenderFrame 抽象类
|
|
12048
12122
|
*/ var RenderFrame = /*#__PURE__*/ function() {
|
|
@@ -12196,7 +12270,7 @@ var seed$5 = 1;
|
|
|
12196
12270
|
}
|
|
12197
12271
|
this.semantics = new SemanticMap(options.semantics);
|
|
12198
12272
|
this.clearAction = clearAction;
|
|
12199
|
-
this.name = "RenderFrame" + seed$
|
|
12273
|
+
this.name = "RenderFrame" + seed$4++;
|
|
12200
12274
|
var firstRP = renderPasses[0];
|
|
12201
12275
|
this.emptyTexture = generateWhiteTexture(engine);
|
|
12202
12276
|
this.transparentTexture = generateTransparentTexture(engine);
|
|
@@ -12505,6 +12579,9 @@ var seed$5 = 1;
|
|
|
12505
12579
|
_proto.addToRenderPass = function addToRenderPass(renderPass, mesh) {
|
|
12506
12580
|
var info = this.renderPassInfoMap.get(renderPass);
|
|
12507
12581
|
var priority = mesh.priority;
|
|
12582
|
+
if (!info) {
|
|
12583
|
+
return;
|
|
12584
|
+
}
|
|
12508
12585
|
if (renderPass.meshes.length === 0) {
|
|
12509
12586
|
info.listStart = info.listEnd = priority;
|
|
12510
12587
|
} else {
|
|
@@ -12679,6 +12756,8 @@ var seed$5 = 1;
|
|
|
12679
12756
|
* 创建拷贝 RenderPass 用到的 Mesh 对象
|
|
12680
12757
|
* @param semantics - RenderPass 渲染时 Framebuffer 的颜色和深度纹理、大小和是否混合
|
|
12681
12758
|
*/ _proto.createCopyMesh = function createCopyMesh(semantics) {
|
|
12759
|
+
var // FIXME: 如果不把shader添加进shaderLibrary,这里可以移到core中,有性能上的考虑
|
|
12760
|
+
_this_renderer_getShaderLibrary;
|
|
12682
12761
|
var name = EFFECTS_COPY_MESH_NAME;
|
|
12683
12762
|
var engine = this.renderer.engine;
|
|
12684
12763
|
var geometry = Geometry.create(engine, {
|
|
@@ -12703,8 +12782,7 @@ var seed$5 = 1;
|
|
|
12703
12782
|
drawCount: 4
|
|
12704
12783
|
});
|
|
12705
12784
|
var shader = createCopyShader(engine.gpuCapability.level, !!(semantics == null ? void 0 : semantics.depthTexture));
|
|
12706
|
-
|
|
12707
|
-
this.renderer.getShaderLibrary().addShader(shader);
|
|
12785
|
+
(_this_renderer_getShaderLibrary = this.renderer.getShaderLibrary()) == null ? void 0 : _this_renderer_getShaderLibrary.addShader(shader);
|
|
12708
12786
|
var material = Material.create(engine, {
|
|
12709
12787
|
uniformValues: {
|
|
12710
12788
|
// @ts-expect-error
|
|
@@ -12768,7 +12846,10 @@ var FinalCopyRP = /*#__PURE__*/ function(RenderPass) {
|
|
|
12768
12846
|
}
|
|
12769
12847
|
var _proto = FinalCopyRP.prototype;
|
|
12770
12848
|
_proto.configure = function configure(renderer) {
|
|
12771
|
-
|
|
12849
|
+
var framebuffer = renderer.getFramebuffer();
|
|
12850
|
+
if (framebuffer) {
|
|
12851
|
+
this.prePassTexture = framebuffer.getColorTextures()[0];
|
|
12852
|
+
}
|
|
12772
12853
|
renderer.setFramebuffer(null);
|
|
12773
12854
|
};
|
|
12774
12855
|
_proto.execute = function execute(renderer) {
|
|
@@ -13129,7 +13210,7 @@ var Renderer = /*#__PURE__*/ function() {
|
|
|
13129
13210
|
|
|
13130
13211
|
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";
|
|
13131
13212
|
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";
|
|
13132
|
-
var seed$
|
|
13213
|
+
var seed$3 = 1;
|
|
13133
13214
|
var InteractMesh = /*#__PURE__*/ function() {
|
|
13134
13215
|
function InteractMesh(props, rendererOptions, transform, engine) {
|
|
13135
13216
|
this.transform = transform;
|
|
@@ -13230,7 +13311,7 @@ var InteractMesh = /*#__PURE__*/ function() {
|
|
|
13230
13311
|
};
|
|
13231
13312
|
_proto.createMesh = function createMesh(geometry, material) {
|
|
13232
13313
|
return Mesh.create(this.engine, {
|
|
13233
|
-
name: "Interact_preview" + seed$
|
|
13314
|
+
name: "Interact_preview" + seed$3++,
|
|
13234
13315
|
priority: 0,
|
|
13235
13316
|
worldMatrix: Matrix4.fromIdentity(),
|
|
13236
13317
|
geometry: geometry,
|
|
@@ -13282,13 +13363,15 @@ exports.InteractComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
|
13282
13363
|
if (type === InteractType.CLICK) {
|
|
13283
13364
|
this.clickable = true;
|
|
13284
13365
|
if (showPreview && env === PLAYER_OPTIONS_ENV_EDITOR) {
|
|
13285
|
-
var rendererOptions =
|
|
13286
|
-
|
|
13366
|
+
var rendererOptions = composition == null ? void 0 : composition.getRendererOptions();
|
|
13367
|
+
if (rendererOptions !== undefined) {
|
|
13368
|
+
this.previewContent = new InteractMesh(this.item.props.content, rendererOptions, this.transform, this.engine);
|
|
13369
|
+
}
|
|
13287
13370
|
}
|
|
13288
13371
|
}
|
|
13289
13372
|
if (options.type === InteractType.DRAG) {
|
|
13290
13373
|
if (env !== PLAYER_OPTIONS_ENV_EDITOR || options.enableInEditor) {
|
|
13291
|
-
composition.event && this.beginDragTarget(options, composition.event);
|
|
13374
|
+
(composition == null ? void 0 : composition.event) && this.beginDragTarget(options, composition.event);
|
|
13292
13375
|
}
|
|
13293
13376
|
}
|
|
13294
13377
|
if (this.previewContent) {
|
|
@@ -13559,11 +13642,11 @@ var SpriteLoader = /*#__PURE__*/ function(AbstractPlugin) {
|
|
|
13559
13642
|
var shaderLibrary = render.getShaderLibrary();
|
|
13560
13643
|
var _render_engine_gpuCapability = render.engine.gpuCapability, level = _render_engine_gpuCapability.level, detail = _render_engine_gpuCapability.detail;
|
|
13561
13644
|
var env = (options != null ? options : {}).env;
|
|
13562
|
-
if (!shaderLibrary.shaderResults[spriteMeshShaderIdFromRenderInfo(defRenderInfo, 2)]) {
|
|
13563
|
-
shaderLibrary.addShader(spriteMeshShaderFromRenderInfo(defRenderInfo, 2, 1, env));
|
|
13564
|
-
shaderLibrary.addShader(spriteMeshShaderFromRenderInfo(defRenderInfo, exports.maxSpriteMeshItemCount, 1, env));
|
|
13645
|
+
if (!(shaderLibrary == null ? void 0 : shaderLibrary.shaderResults[spriteMeshShaderIdFromRenderInfo(defRenderInfo, 2)])) {
|
|
13646
|
+
shaderLibrary == null ? void 0 : shaderLibrary.addShader(spriteMeshShaderFromRenderInfo(defRenderInfo, 2, 1, env));
|
|
13647
|
+
shaderLibrary == null ? void 0 : shaderLibrary.addShader(spriteMeshShaderFromRenderInfo(defRenderInfo, exports.maxSpriteMeshItemCount, 1, env));
|
|
13565
13648
|
if (detail.writableFragDepth) {
|
|
13566
|
-
shaderLibrary.addShader(createCopyShader(level, true));
|
|
13649
|
+
shaderLibrary == null ? void 0 : shaderLibrary.addShader(createCopyShader(level, true));
|
|
13567
13650
|
}
|
|
13568
13651
|
}
|
|
13569
13652
|
return Promise.resolve();
|
|
@@ -13895,7 +13978,7 @@ var tempColor = [
|
|
|
13895
13978
|
1,
|
|
13896
13979
|
1
|
|
13897
13980
|
];
|
|
13898
|
-
var seed$
|
|
13981
|
+
var seed$2 = 0;
|
|
13899
13982
|
var SpriteColorPlayable = /*#__PURE__*/ function(Playable) {
|
|
13900
13983
|
_inherits(SpriteColorPlayable, Playable);
|
|
13901
13984
|
function SpriteColorPlayable() {
|
|
@@ -13936,8 +14019,9 @@ var SpriteColorPlayable = /*#__PURE__*/ function(Playable) {
|
|
|
13936
14019
|
colorChanged = true;
|
|
13937
14020
|
}
|
|
13938
14021
|
if (colorChanged) {
|
|
14022
|
+
var _this_spriteMaterial_getVector4;
|
|
13939
14023
|
vecMulCombine(this.renderColor, colorInc, this.startColor);
|
|
13940
|
-
this.spriteMaterial.getVector4("_Color").setFromArray(this.renderColor);
|
|
14024
|
+
(_this_spriteMaterial_getVector4 = this.spriteMaterial.getVector4("_Color")) == null ? void 0 : _this_spriteMaterial_getVector4.setFromArray(this.renderColor);
|
|
13941
14025
|
}
|
|
13942
14026
|
};
|
|
13943
14027
|
_proto.create = function create(clipData) {
|
|
@@ -14003,7 +14087,7 @@ exports.SpriteComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
|
14003
14087
|
}
|
|
14004
14088
|
}
|
|
14005
14089
|
};
|
|
14006
|
-
_this.name = "MSprite" + seed$
|
|
14090
|
+
_this.name = "MSprite" + seed$2++;
|
|
14007
14091
|
_this.renderer = {
|
|
14008
14092
|
renderMode: RenderMode.BILLBOARD,
|
|
14009
14093
|
blending: BlendingMode.ALPHA,
|
|
@@ -14189,9 +14273,11 @@ exports.SpriteComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
|
14189
14273
|
var data = this.getItemInitData();
|
|
14190
14274
|
var renderer = this.renderer;
|
|
14191
14275
|
var texParams = this.material.getVector4("_TexParams");
|
|
14192
|
-
texParams
|
|
14193
|
-
|
|
14194
|
-
|
|
14276
|
+
if (texParams) {
|
|
14277
|
+
texParams.x = renderer.occlusion ? +renderer.transparentOcclusion : 1;
|
|
14278
|
+
texParams.y = +this.preMultiAlpha;
|
|
14279
|
+
texParams.z = renderer.renderMode;
|
|
14280
|
+
}
|
|
14195
14281
|
var attributes = {
|
|
14196
14282
|
atlasOffset: new Float32Array(data.atlasOffset.length),
|
|
14197
14283
|
index: new Uint16Array(data.index.length)
|
|
@@ -14484,7 +14570,7 @@ function setConfig(name, value) {
|
|
|
14484
14570
|
}
|
|
14485
14571
|
|
|
14486
14572
|
var tempQuat$1 = new Quaternion();
|
|
14487
|
-
var seed$
|
|
14573
|
+
var seed$1 = 1;
|
|
14488
14574
|
// TODO 继承 Component
|
|
14489
14575
|
var Transform = /*#__PURE__*/ function() {
|
|
14490
14576
|
function Transform(props, parent) {
|
|
@@ -14535,7 +14621,7 @@ var Transform = /*#__PURE__*/ function() {
|
|
|
14535
14621
|
quat: new Quaternion(0, 0, 0, 1),
|
|
14536
14622
|
scale: new Vector3(1, 1, 1)
|
|
14537
14623
|
};
|
|
14538
|
-
this.name = "transform_" + seed$
|
|
14624
|
+
this.name = "transform_" + seed$1++;
|
|
14539
14625
|
if (props) {
|
|
14540
14626
|
this.setTransform(props);
|
|
14541
14627
|
}
|
|
@@ -15840,8 +15926,8 @@ function getBezier2DValue(out, t, p0, p1, cpx0, cpy0, cpx1, cpy1) {
|
|
|
15840
15926
|
}
|
|
15841
15927
|
|
|
15842
15928
|
var Burst = /*#__PURE__*/ function() {
|
|
15843
|
-
function Burst(
|
|
15844
|
-
var time =
|
|
15929
|
+
function Burst(options) {
|
|
15930
|
+
var time = options.time, interval = options.interval, count = options.count, cycles = options.cycles, probability = options.probability;
|
|
15845
15931
|
this.time = +time || 0;
|
|
15846
15932
|
this.interval = +interval || 1;
|
|
15847
15933
|
this.count = _instanceof1(count, ValueGetter) ? count : createValueGetter(count);
|
|
@@ -15869,7 +15955,14 @@ var Burst = /*#__PURE__*/ function() {
|
|
|
15869
15955
|
this.now = 0;
|
|
15870
15956
|
};
|
|
15871
15957
|
_proto.clone = function clone() {
|
|
15872
|
-
|
|
15958
|
+
var options = {
|
|
15959
|
+
time: this.time,
|
|
15960
|
+
interval: this.interval,
|
|
15961
|
+
count: this.count,
|
|
15962
|
+
cycles: this.cycles,
|
|
15963
|
+
probability: this.probability
|
|
15964
|
+
};
|
|
15965
|
+
return new Burst(options);
|
|
15873
15966
|
};
|
|
15874
15967
|
return Burst;
|
|
15875
15968
|
}();
|
|
@@ -16331,6 +16424,7 @@ var TrailMesh = /*#__PURE__*/ function() {
|
|
|
16331
16424
|
if (index >= 0 && index < pointCountPerTrail) {
|
|
16332
16425
|
var startIndex = (trail * pointCountPerTrail + index) * 24 + 8;
|
|
16333
16426
|
var data = this.geometry.getAttributeData("aColor");
|
|
16427
|
+
assertExist(data);
|
|
16334
16428
|
out.x = data[startIndex];
|
|
16335
16429
|
out.y = data[1 + startIndex];
|
|
16336
16430
|
out.z = data[2 + startIndex];
|
|
@@ -16338,14 +16432,14 @@ var TrailMesh = /*#__PURE__*/ function() {
|
|
|
16338
16432
|
}
|
|
16339
16433
|
};
|
|
16340
16434
|
_proto.clearAllTrails = function clearAllTrails() {
|
|
16341
|
-
var
|
|
16435
|
+
var indexData = this.geometry.getIndexData();
|
|
16436
|
+
assertExist(indexData);
|
|
16342
16437
|
this.trailCursors = new Uint16Array(this.trailCursors.length);
|
|
16343
|
-
|
|
16344
|
-
geo.setIndexData(new Uint16Array(geo.getIndexData().length));
|
|
16438
|
+
this.geometry.setIndexData(new Uint16Array(indexData.length));
|
|
16345
16439
|
};
|
|
16346
16440
|
_proto.minusTime = function minusTime(time) {
|
|
16347
|
-
// FIXME: 可选性
|
|
16348
16441
|
var data = this.geometry.getAttributeData("aTime");
|
|
16442
|
+
assertExist(data);
|
|
16349
16443
|
for(var i = 0; i < data.length; i++){
|
|
16350
16444
|
data[i] -= time;
|
|
16351
16445
|
}
|
|
@@ -16357,6 +16451,7 @@ var TrailMesh = /*#__PURE__*/ function() {
|
|
|
16357
16451
|
var pointCountPerTrail = this.pointCountPerTrail;
|
|
16358
16452
|
var indicesPerTrail = (pointCountPerTrail - 1) * 6;
|
|
16359
16453
|
var indices = this.geometry.getIndexData();
|
|
16454
|
+
assertExist(indices);
|
|
16360
16455
|
indices.set(new Uint16Array(indicesPerTrail), index * indicesPerTrail);
|
|
16361
16456
|
this.geometry.setIndexData(indices);
|
|
16362
16457
|
this.trailCursors[index] = 0;
|
|
@@ -16810,7 +16905,7 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
|
|
|
16810
16905
|
break;
|
|
16811
16906
|
}
|
|
16812
16907
|
var burst = bursts[j];
|
|
16813
|
-
var opts =
|
|
16908
|
+
var opts = burst.getGeneratorOptions(timePassed, lifetime);
|
|
16814
16909
|
if (opts) {
|
|
16815
16910
|
var originVec = [
|
|
16816
16911
|
0,
|
|
@@ -16819,9 +16914,6 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
|
|
|
16819
16914
|
];
|
|
16820
16915
|
var offsets = emission.burstOffsets[j];
|
|
16821
16916
|
var burstOffset = offsets && offsets[opts.cycleIndex] || originVec;
|
|
16822
|
-
if (burst.once) {
|
|
16823
|
-
this.removeBurst(j);
|
|
16824
|
-
}
|
|
16825
16917
|
for(var i1 = 0; i1 < opts.count && cursor < maxCount; i1++){
|
|
16826
16918
|
var _p_transform;
|
|
16827
16919
|
if (shouldSkipGenerate()) {
|
|
@@ -17458,13 +17550,14 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
|
|
|
17458
17550
|
}
|
|
17459
17551
|
}
|
|
17460
17552
|
this.renderer = new ParticleSystemRenderer(this.engine, particleMeshProps, trailMeshProps);
|
|
17553
|
+
this.renderer.item = this.item;
|
|
17461
17554
|
this.meshes = this.renderer.meshes;
|
|
17462
|
-
// this.item = vfxItem;
|
|
17463
17555
|
var interaction = props.interaction;
|
|
17464
17556
|
if (interaction) {
|
|
17557
|
+
var _interaction_radius;
|
|
17465
17558
|
this.interaction = {
|
|
17466
17559
|
multiple: interaction.multiple,
|
|
17467
|
-
radius: interaction.radius,
|
|
17560
|
+
radius: (_interaction_radius = interaction.radius) != null ? _interaction_radius : 0.4,
|
|
17468
17561
|
behavior: interaction.behavior
|
|
17469
17562
|
};
|
|
17470
17563
|
}
|
|
@@ -17548,7 +17641,10 @@ function randomArrItem(arr, keepArr) {
|
|
|
17548
17641
|
*/ var ParticleBehaviourPlayable = /*#__PURE__*/ function(Playable) {
|
|
17549
17642
|
_inherits(ParticleBehaviourPlayable, Playable);
|
|
17550
17643
|
function ParticleBehaviourPlayable() {
|
|
17551
|
-
|
|
17644
|
+
var _this;
|
|
17645
|
+
_this = Playable.apply(this, arguments) || this;
|
|
17646
|
+
_this.lastTime = 0;
|
|
17647
|
+
return _this;
|
|
17552
17648
|
}
|
|
17553
17649
|
var _proto = ParticleBehaviourPlayable.prototype;
|
|
17554
17650
|
_proto.start = function start(context) {
|
|
@@ -17576,8 +17672,12 @@ function randomArrItem(arr, keepArr) {
|
|
|
17576
17672
|
if (this.time < particleSystem.item.duration && particleSystem.isFrozen()) {
|
|
17577
17673
|
particleSystem.reset();
|
|
17578
17674
|
}
|
|
17675
|
+
if (Math.abs(this.time - this.lastTime) < 0.001) {
|
|
17676
|
+
deltaTime = 0;
|
|
17677
|
+
}
|
|
17579
17678
|
particleSystem.onUpdate(deltaTime);
|
|
17580
17679
|
}
|
|
17680
|
+
this.lastTime = this.time;
|
|
17581
17681
|
};
|
|
17582
17682
|
return ParticleBehaviourPlayable;
|
|
17583
17683
|
}(Playable);
|
|
@@ -17990,6 +18090,7 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
17990
18090
|
_proto.getPointColor = function getPointColor(index) {
|
|
17991
18091
|
var data = this.geometry.getAttributeData("aRot");
|
|
17992
18092
|
var i = index * 32 + 4;
|
|
18093
|
+
assertExist(data);
|
|
17993
18094
|
return [
|
|
17994
18095
|
data[i],
|
|
17995
18096
|
data[i + 1],
|
|
@@ -18019,6 +18120,7 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
18019
18120
|
};
|
|
18020
18121
|
_proto.minusTime = function minusTime(time) {
|
|
18021
18122
|
var data = this.geometry.getAttributeData("aOffset");
|
|
18123
|
+
assertExist(data);
|
|
18022
18124
|
for(var i = 0; i < data.length; i += 4){
|
|
18023
18125
|
data[i + 2] -= time;
|
|
18024
18126
|
}
|
|
@@ -18145,6 +18247,7 @@ var ParticleMesh = /*#__PURE__*/ function() {
|
|
|
18145
18247
|
var attrSize = geometry.getAttributeStride(name) / Float32Array.BYTES_PER_ELEMENT;
|
|
18146
18248
|
if (increaseBuffer) {
|
|
18147
18249
|
var baseData = geometry.getAttributeData(name);
|
|
18250
|
+
assertExist(baseData);
|
|
18148
18251
|
var geoData = enlargeBuffer(baseData, vertexCount * attrSize, maxCount * 4 * attrSize, inc);
|
|
18149
18252
|
geoData.set(data, data.length * index);
|
|
18150
18253
|
geometry.setAttributeData(name, geoData);
|
|
@@ -18514,12 +18617,8 @@ var ParticleLoader = /*#__PURE__*/ function(AbstractPlugin) {
|
|
|
18514
18617
|
// TODO 此处add是否有意义?shader变量似乎没有加到this.shaders数组。
|
|
18515
18618
|
if (item.content.trails) {
|
|
18516
18619
|
var shader1 = getTrailMeshShader(item.content.trails, item.content.options.maxCount, item.name, gpuCapability, env);
|
|
18517
|
-
var _shader_macros;
|
|
18518
|
-
shader1.vertex = createShaderWithMacros((_shader_macros = shader1.macros) != null ? _shader_macros : [], shader1.vertex, exports.ShaderType.vertex, level);
|
|
18519
|
-
var _shader_macros1;
|
|
18520
|
-
shader1.fragment = createShaderWithMacros((_shader_macros1 = shader1.macros) != null ? _shader_macros1 : [], shader1.fragment, exports.ShaderType.fragment, level);
|
|
18521
18620
|
shader1.glslVersion = level === 2 ? exports.GLSLVersion.GLSL3 : exports.GLSLVersion.GLSL1;
|
|
18522
|
-
shaderLibrary.addShader(shader1);
|
|
18621
|
+
shaderLibrary == null ? void 0 : shaderLibrary.addShader(shader1);
|
|
18523
18622
|
}
|
|
18524
18623
|
});
|
|
18525
18624
|
shaders.forEach(function(shader) {
|
|
@@ -18529,15 +18628,10 @@ var ParticleLoader = /*#__PURE__*/ function(AbstractPlugin) {
|
|
|
18529
18628
|
} else {
|
|
18530
18629
|
shader.glslVersion = exports.GLSLVersion.GLSL1;
|
|
18531
18630
|
}
|
|
18532
|
-
|
|
18533
|
-
shader.vertex = createShaderWithMacros((_shader_macros = shader.macros) != null ? _shader_macros : [], shader.vertex, exports.ShaderType.vertex, level);
|
|
18534
|
-
var _shader_macros1;
|
|
18535
|
-
shader.fragment = createShaderWithMacros((_shader_macros1 = shader.macros) != null ? _shader_macros1 : [], shader.fragment, exports.ShaderType.fragment, level);
|
|
18536
|
-
shaderLibrary.addShader(shader);
|
|
18631
|
+
shaderLibrary == null ? void 0 : shaderLibrary.addShader(shader);
|
|
18537
18632
|
});
|
|
18538
18633
|
if (level === 2) {
|
|
18539
18634
|
items.forEach(function(item) {
|
|
18540
|
-
// @ts-expect-error
|
|
18541
18635
|
item.content.options.meshSlots = [
|
|
18542
18636
|
maxVertexCount,
|
|
18543
18637
|
maxFragmentCount
|
|
@@ -19406,7 +19500,7 @@ function compareTracks(a, b) {
|
|
|
19406
19500
|
this.items.length = 0;
|
|
19407
19501
|
if (this.item.composition) {
|
|
19408
19502
|
var assetLoader = this.item.engine.assetLoader;
|
|
19409
|
-
var itemProps = this.
|
|
19503
|
+
var itemProps = this.data.items ? this.data.items : [];
|
|
19410
19504
|
for(var i = 0; i < itemProps.length; i++){
|
|
19411
19505
|
var item = void 0;
|
|
19412
19506
|
var itemData = itemProps[i];
|
|
@@ -19775,7 +19869,9 @@ var CanvasPool = /*#__PURE__*/ function() {
|
|
|
19775
19869
|
};
|
|
19776
19870
|
_proto.getCanvas = function getCanvas() {
|
|
19777
19871
|
if (this.elements.length !== 0) {
|
|
19778
|
-
|
|
19872
|
+
var canvas = this.elements.shift();
|
|
19873
|
+
assertExist(canvas);
|
|
19874
|
+
return canvas;
|
|
19779
19875
|
}
|
|
19780
19876
|
if (getConfig(TEMPLATE_USE_OFFSCREEN_CANVAS)) {
|
|
19781
19877
|
return window._createOffscreenCanvas(10, 10);
|
|
@@ -19800,9 +19896,6 @@ var CanvasPool = /*#__PURE__*/ function() {
|
|
|
19800
19896
|
return CanvasPool;
|
|
19801
19897
|
}();
|
|
19802
19898
|
var canvasPool = new CanvasPool();
|
|
19803
|
-
function getDefaultTemplateCanvasPool() {
|
|
19804
|
-
return canvasPool;
|
|
19805
|
-
}
|
|
19806
19899
|
|
|
19807
19900
|
var DEFAULT_FONTS = [
|
|
19808
19901
|
"serif",
|
|
@@ -20224,7 +20317,6 @@ var TextLoader = /*#__PURE__*/ function(AbstractPlugin) {
|
|
|
20224
20317
|
return TextLoader;
|
|
20225
20318
|
}(AbstractPlugin);
|
|
20226
20319
|
|
|
20227
|
-
var seed$1 = 1;
|
|
20228
20320
|
exports.EffectComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
20229
20321
|
_inherits(EffectComponent, RendererComponent);
|
|
20230
20322
|
function EffectComponent(engine) {
|
|
@@ -20235,7 +20327,6 @@ exports.EffectComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
|
20235
20327
|
*/ _this.worldMatrix = Matrix4.fromIdentity();
|
|
20236
20328
|
_this.triangles = [];
|
|
20237
20329
|
_this.destroyed = false;
|
|
20238
|
-
_this.visible = false;
|
|
20239
20330
|
// TODO 点击测试后续抽象一个 Collider 组件
|
|
20240
20331
|
_this.getHitTestParams = function(force) {
|
|
20241
20332
|
var area = _this.getBoundingBox();
|
|
@@ -20246,18 +20337,11 @@ exports.EffectComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
|
20246
20337
|
};
|
|
20247
20338
|
}
|
|
20248
20339
|
};
|
|
20249
|
-
_this.
|
|
20250
|
-
_this.name = "<unnamed>";
|
|
20340
|
+
_this.name = "EffectComponent";
|
|
20251
20341
|
_this._priority = 0;
|
|
20252
20342
|
return _this;
|
|
20253
20343
|
}
|
|
20254
20344
|
var _proto = EffectComponent.prototype;
|
|
20255
|
-
/**
|
|
20256
|
-
* 设置当前 Mesh 的可见性。
|
|
20257
|
-
* @param visible - true:可见,false:不可见
|
|
20258
|
-
*/ _proto.setVisible = function setVisible(visible) {
|
|
20259
|
-
this.visible = visible;
|
|
20260
|
-
};
|
|
20261
20345
|
_proto.start = function start() {
|
|
20262
20346
|
this.item.getHitTestParams = this.getHitTestParams;
|
|
20263
20347
|
};
|
|
@@ -20268,16 +20352,6 @@ exports.EffectComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
|
20268
20352
|
renderer.drawGeometry(this.geometry, this.material);
|
|
20269
20353
|
};
|
|
20270
20354
|
/**
|
|
20271
|
-
* 获取当前 Mesh 的可见性。
|
|
20272
|
-
*/ _proto.getVisible = function getVisible() {
|
|
20273
|
-
return this.visible;
|
|
20274
|
-
};
|
|
20275
|
-
/**
|
|
20276
|
-
* 获取当前 Mesh 的第一个 geometry。
|
|
20277
|
-
*/ _proto.firstGeometry = function firstGeometry() {
|
|
20278
|
-
return this.geometry;
|
|
20279
|
-
};
|
|
20280
|
-
/**
|
|
20281
20355
|
* 设置当前 Mesh 的材质
|
|
20282
20356
|
* @param material - 要设置的材质
|
|
20283
20357
|
* @param destroy - 可选的材质销毁选项
|
|
@@ -20324,27 +20398,11 @@ exports.EffectComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
|
20324
20398
|
* @param options - 可选的销毁选项
|
|
20325
20399
|
*/ _proto.dispose = function dispose(options) {
|
|
20326
20400
|
if (this.destroyed) {
|
|
20327
|
-
//console.error('call mesh.destroy multiple times', this);
|
|
20328
20401
|
return;
|
|
20329
20402
|
}
|
|
20330
|
-
// if (options?.geometries !== DestroyOptions.keep) {
|
|
20331
|
-
// this.geometry.dispose();
|
|
20332
|
-
// }
|
|
20333
|
-
// const materialDestroyOption = options?.material;
|
|
20334
|
-
// if (materialDestroyOption !== DestroyOptions.keep) {
|
|
20335
|
-
// this.material.dispose(materialDestroyOption);
|
|
20336
|
-
// }
|
|
20337
20403
|
this.destroyed = true;
|
|
20338
20404
|
RendererComponent.prototype.dispose.call(this);
|
|
20339
20405
|
};
|
|
20340
|
-
_create_class(EffectComponent, [
|
|
20341
|
-
{
|
|
20342
|
-
key: "isDestroyed",
|
|
20343
|
-
get: function get() {
|
|
20344
|
-
return this.destroyed;
|
|
20345
|
-
}
|
|
20346
|
-
}
|
|
20347
|
-
]);
|
|
20348
20406
|
return EffectComponent;
|
|
20349
20407
|
}(RendererComponent);
|
|
20350
20408
|
__decorate([
|
|
@@ -20354,8 +20412,10 @@ exports.EffectComponent = __decorate([
|
|
|
20354
20412
|
effectsClass(DataType.EffectComponent)
|
|
20355
20413
|
], exports.EffectComponent);
|
|
20356
20414
|
function geometryToTriangles(geometry) {
|
|
20357
|
-
var
|
|
20358
|
-
var
|
|
20415
|
+
var _geometry_getIndexData;
|
|
20416
|
+
var indices = (_geometry_getIndexData = geometry.getIndexData()) != null ? _geometry_getIndexData : [];
|
|
20417
|
+
var _geometry_getAttributeData;
|
|
20418
|
+
var vertices = (_geometry_getAttributeData = geometry.getAttributeData("aPos")) != null ? _geometry_getAttributeData : [];
|
|
20359
20419
|
var res = [];
|
|
20360
20420
|
for(var i = 0; i < indices.length; i += 3){
|
|
20361
20421
|
var index0 = indices[i] * 3;
|
|
@@ -23080,6 +23140,7 @@ function getStandardJSON(json) {
|
|
|
23080
23140
|
reverseParticle = ((_exec = /^(\d+)/.exec(json.version)) == null ? void 0 : _exec[0]) === "0";
|
|
23081
23141
|
return version30Migration(version21Migration(getStandardJSONFromV0(json)));
|
|
23082
23142
|
}
|
|
23143
|
+
reverseParticle = false;
|
|
23083
23144
|
var vs = standardVersion.exec(json.version) || [];
|
|
23084
23145
|
var mainVersion = Number(vs[1]);
|
|
23085
23146
|
var minorVersion = Number(vs[2]);
|
|
@@ -23826,7 +23887,6 @@ var seed = 1;
|
|
|
23826
23887
|
return __generator(this, function(_state) {
|
|
23827
23888
|
switch(_state.label){
|
|
23828
23889
|
case 0:
|
|
23829
|
-
// TODO: 后面切换到新的数据版本,就不用掉用 getStandardJSON 做转换了
|
|
23830
23890
|
jsonScene = getStandardJSON(json);
|
|
23831
23891
|
_jsonScene_plugins = jsonScene.plugins, plugins = _jsonScene_plugins === void 0 ? [] : _jsonScene_plugins, sceneCompositions = jsonScene.compositions, imgUsage = jsonScene.imgUsage, images = jsonScene.images;
|
|
23832
23892
|
pluginSystem = new PluginSystem(plugins);
|
|
@@ -24120,18 +24180,18 @@ var seed = 1;
|
|
|
24120
24180
|
source: source
|
|
24121
24181
|
};
|
|
24122
24182
|
});
|
|
24123
|
-
jobs = textures.map(/*#__PURE__*/ _async_to_generator(function(
|
|
24124
|
-
var e, source, image,
|
|
24183
|
+
jobs = textures.map(/*#__PURE__*/ _async_to_generator(function(textureOptions, idx) {
|
|
24184
|
+
var e, source, image, texture;
|
|
24125
24185
|
return __generator(this, function(_state) {
|
|
24126
24186
|
switch(_state.label){
|
|
24127
24187
|
case 0:
|
|
24128
|
-
if (_instanceof1(
|
|
24188
|
+
if (_instanceof1(textureOptions, Texture)) {
|
|
24129
24189
|
return [
|
|
24130
24190
|
2,
|
|
24131
|
-
|
|
24191
|
+
textureOptions
|
|
24132
24192
|
];
|
|
24133
24193
|
}
|
|
24134
|
-
if (!("mipmaps" in
|
|
24194
|
+
if (!("mipmaps" in textureOptions)) return [
|
|
24135
24195
|
3,
|
|
24136
24196
|
4
|
|
24137
24197
|
];
|
|
@@ -24145,7 +24205,7 @@ var seed = 1;
|
|
|
24145
24205
|
]);
|
|
24146
24206
|
return [
|
|
24147
24207
|
4,
|
|
24148
|
-
deserializeMipmapTexture(
|
|
24208
|
+
deserializeMipmapTexture(textureOptions, bins, engine, jsonScene.bins)
|
|
24149
24209
|
];
|
|
24150
24210
|
case 2:
|
|
24151
24211
|
return [
|
|
@@ -24156,12 +24216,11 @@ var seed = 1;
|
|
|
24156
24216
|
e = _state.sent();
|
|
24157
24217
|
throw new Error("Load texture " + idx + " fails, error message: " + e + ".");
|
|
24158
24218
|
case 4:
|
|
24159
|
-
source =
|
|
24219
|
+
source = textureOptions.source;
|
|
24160
24220
|
if (!isObject(source)) return [
|
|
24161
24221
|
3,
|
|
24162
24222
|
5
|
|
24163
24223
|
];
|
|
24164
|
-
//@ts-expect-error
|
|
24165
24224
|
image = engine.assetLoader.loadGUID(source.id).data;
|
|
24166
24225
|
return [
|
|
24167
24226
|
3,
|
|
@@ -24181,12 +24240,12 @@ var seed = 1;
|
|
|
24181
24240
|
_state.label = 7;
|
|
24182
24241
|
case 7:
|
|
24183
24242
|
if (image) {
|
|
24184
|
-
|
|
24185
|
-
|
|
24186
|
-
|
|
24243
|
+
texture = createTextureOptionsBySource(image, _this.assets[idx]);
|
|
24244
|
+
texture.id = textureOptions.id;
|
|
24245
|
+
texture.dataType = DataType.Texture;
|
|
24187
24246
|
return [
|
|
24188
24247
|
2,
|
|
24189
|
-
|
|
24248
|
+
texture.sourceType === exports.TextureSourceType.compressed ? texture : _extends({}, texture, textureOptions)
|
|
24190
24249
|
];
|
|
24191
24250
|
}
|
|
24192
24251
|
throw new Error("Invalid texture source: " + source + ".");
|
|
@@ -24681,7 +24740,6 @@ var listOrder = 0;
|
|
|
24681
24740
|
if (!this.refCompositionProps.has(refId)) {
|
|
24682
24741
|
this.refCompositionProps.set(refId, ref);
|
|
24683
24742
|
}
|
|
24684
|
-
itemProps.items = ref.items;
|
|
24685
24743
|
}
|
|
24686
24744
|
items.push(itemProps);
|
|
24687
24745
|
}
|
|
@@ -27573,7 +27631,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem, true);
|
|
|
27573
27631
|
registerPlugin("particle", ParticleLoader, exports.VFXItem, true);
|
|
27574
27632
|
registerPlugin("cal", CalculateLoader, exports.VFXItem, true);
|
|
27575
27633
|
registerPlugin("interact", InteractLoader, exports.VFXItem, true);
|
|
27576
|
-
var version = "2.0.0-alpha.
|
|
27634
|
+
var version = "2.0.0-alpha.35";
|
|
27577
27635
|
logger.info("Core version: " + version + ".");
|
|
27578
27636
|
|
|
27579
27637
|
exports.AbstractPlugin = AbstractPlugin;
|
|
@@ -27658,6 +27716,7 @@ exports.SEMANTIC_PRE_COLOR_ATTACHMENT_SIZE_0 = SEMANTIC_PRE_COLOR_ATTACHMENT_SIZ
|
|
|
27658
27716
|
exports.SPRITE_VERTEX_STRIDE = SPRITE_VERTEX_STRIDE;
|
|
27659
27717
|
exports.SemanticMap = SemanticMap;
|
|
27660
27718
|
exports.SerializationHelper = SerializationHelper;
|
|
27719
|
+
exports.ShaderFactory = ShaderFactory;
|
|
27661
27720
|
exports.ShaderVariant = ShaderVariant;
|
|
27662
27721
|
exports.SpriteColorPlayable = SpriteColorPlayable;
|
|
27663
27722
|
exports.SpriteLoader = SpriteLoader;
|
|
@@ -27690,12 +27749,9 @@ exports.colorGradingFrag = colorGradingFrag;
|
|
|
27690
27749
|
exports.colorStopsFromGradient = colorStopsFromGradient;
|
|
27691
27750
|
exports.colorToArr = colorToArr$1;
|
|
27692
27751
|
exports.combineImageTemplate = combineImageTemplate;
|
|
27693
|
-
exports.compatibleFrag = compatible_frag;
|
|
27694
|
-
exports.compatibleVert = compatible_vert;
|
|
27695
27752
|
exports.createCopyShader = createCopyShader;
|
|
27696
27753
|
exports.createGLContext = createGLContext;
|
|
27697
27754
|
exports.createKeyFrameMeta = createKeyFrameMeta;
|
|
27698
|
-
exports.createShaderWithMacros = createShaderWithMacros;
|
|
27699
27755
|
exports.createShape = createShape;
|
|
27700
27756
|
exports.createValueGetter = createValueGetter;
|
|
27701
27757
|
exports.decimalEqual = decimalEqual;
|
|
@@ -27721,7 +27777,6 @@ exports.generateWhiteTexture = generateWhiteTexture;
|
|
|
27721
27777
|
exports.getBackgroundImage = getBackgroundImage;
|
|
27722
27778
|
exports.getColorFromGradientStops = getColorFromGradientStops;
|
|
27723
27779
|
exports.getConfig = getConfig;
|
|
27724
|
-
exports.getDefaultTemplateCanvasPool = getDefaultTemplateCanvasPool;
|
|
27725
27780
|
exports.getDefaultTextureFactory = getDefaultTextureFactory;
|
|
27726
27781
|
exports.getGeometryByShape = getGeometryByShape;
|
|
27727
27782
|
exports.getGeometryTriangles = getGeometryTriangles;
|
|
@@ -27788,7 +27843,6 @@ exports.particleOriginTranslateMap = particleOriginTranslateMap$1;
|
|
|
27788
27843
|
exports.particleUniformTypeMap = particleUniformTypeMap;
|
|
27789
27844
|
exports.particleVert = particleVert;
|
|
27790
27845
|
exports.pluginLoaderMap = pluginLoaderMap;
|
|
27791
|
-
exports.pointOnLine = pointOnLine;
|
|
27792
27846
|
exports.randomInRange = randomInRange;
|
|
27793
27847
|
exports.registerPlugin = registerPlugin;
|
|
27794
27848
|
exports.removeItem = removeItem;
|
|
@@ -27817,10 +27871,8 @@ exports.unregisterPlugin = unregisterPlugin;
|
|
|
27817
27871
|
exports.valIfUndefined = valIfUndefined;
|
|
27818
27872
|
exports.value = value;
|
|
27819
27873
|
exports.valueDefine = valueDefine;
|
|
27820
|
-
exports.vecAssign = vecAssign;
|
|
27821
27874
|
exports.vecFill = vecFill;
|
|
27822
27875
|
exports.vecMulCombine = vecMulCombine;
|
|
27823
|
-
exports.vecNormalize = vecNormalize;
|
|
27824
27876
|
exports.version = version;
|
|
27825
27877
|
exports.vertexFormatType2GLType = vertexFormatType2GLType;
|
|
27826
27878
|
//# sourceMappingURL=index.js.map
|