@galacean/effects-core 2.0.0-alpha.17 → 2.0.0-alpha.18
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/composition.d.ts +5 -4
- package/dist/constants.d.ts +1 -1
- package/dist/index.js +158 -190
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +158 -189
- package/dist/index.mjs.map +1 -1
- package/dist/material/utils.d.ts +3 -3
- package/dist/plugins/particle/particle-mesh.d.ts +1 -1
- package/dist/plugins/particle/trail-mesh.d.ts +1 -1
- package/dist/plugins/sprite/sprite-mesh.d.ts +0 -4
- package/dist/render/shader.d.ts +4 -4
- package/dist/texture/utils.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.mjs
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.18
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
@@ -606,7 +606,7 @@ function isCanvas(canvas) {
|
|
|
606
606
|
return min + Math.random() * (max - min);
|
|
607
607
|
}
|
|
608
608
|
function throwDestroyedError() {
|
|
609
|
-
throw Error('
|
|
609
|
+
throw new Error('Destroyed item cannot be used again.');
|
|
610
610
|
}
|
|
611
611
|
function generateGUID() {
|
|
612
612
|
return v4().replace(/-/g, '');
|
|
@@ -4239,7 +4239,7 @@ const effectsClassStore = {};
|
|
|
4239
4239
|
function effectsClass(className) {
|
|
4240
4240
|
return (target, context)=>{
|
|
4241
4241
|
if (effectsClassStore[className]) {
|
|
4242
|
-
console.warn(`Class ${className}
|
|
4242
|
+
console.warn(`Class ${className} is already registered.`);
|
|
4243
4243
|
}
|
|
4244
4244
|
// TODO: three修改json dataType, 这边重复注册直接 return
|
|
4245
4245
|
effectsClassStore[className] = target;
|
|
@@ -7020,8 +7020,8 @@ const SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0 = 'PRE_MAIN_COLOR_0';
|
|
|
7020
7020
|
const SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0 = 'PRE_MAIN_COLOR_SIZE_0';
|
|
7021
7021
|
const PLAYER_OPTIONS_ENV_EDITOR = 'editor';
|
|
7022
7022
|
const HELP_LINK = {
|
|
7023
|
-
'
|
|
7024
|
-
'
|
|
7023
|
+
'Item duration can\'t be less than 0': 'https://galacean.antgroup.com/effects/user/gasrv4ka5sacrwpg#AOnQS',
|
|
7024
|
+
'ValueType: 21/22 is not supported': 'https://galacean.antgroup.com/effects/user/gasrv4ka5sacrwpg#smO1b'
|
|
7025
7025
|
};
|
|
7026
7026
|
|
|
7027
7027
|
/**
|
|
@@ -7202,17 +7202,17 @@ const downgradeKeywords = {
|
|
|
7202
7202
|
};
|
|
7203
7203
|
/**
|
|
7204
7204
|
* 生成 shader,检测到 WebGL1 上下文会降级
|
|
7205
|
-
* @param
|
|
7205
|
+
* @param macros - 宏定义数组
|
|
7206
7206
|
* @param shader - 原始 shader 文本
|
|
7207
7207
|
* @param shaderType - shader 类型
|
|
7208
7208
|
* @return 去除版本号的 shader 文本
|
|
7209
|
-
*/ function
|
|
7209
|
+
*/ function createShaderWithMacros(macros, shader, shaderType, level) {
|
|
7210
7210
|
const ret = [];
|
|
7211
7211
|
let header = '';
|
|
7212
7212
|
// shader 标志宏,没有其他含义,方便不支持完全的自定义 shader 的三方引擎接入使用
|
|
7213
7213
|
ret.push('#define GE_RUNTIME');
|
|
7214
|
-
if (
|
|
7215
|
-
|
|
7214
|
+
if (macros) {
|
|
7215
|
+
macros.forEach(([key, value])=>{
|
|
7216
7216
|
if (value === true) {
|
|
7217
7217
|
ret.push(`#define ${key}`);
|
|
7218
7218
|
} else if (Number.isFinite(value)) {
|
|
@@ -7323,7 +7323,7 @@ function setBlendMode(material, blendMode) {
|
|
|
7323
7323
|
];
|
|
7324
7324
|
break;
|
|
7325
7325
|
default:
|
|
7326
|
-
console.warn(`
|
|
7326
|
+
console.warn(`BlendMode ${blendMode} not in specification, please set blend params separately.`);
|
|
7327
7327
|
}
|
|
7328
7328
|
}
|
|
7329
7329
|
function setSideMode(material, side) {
|
|
@@ -7369,7 +7369,7 @@ function setMaskMode(material, maskMode) {
|
|
|
7369
7369
|
material.stencilTest = false;
|
|
7370
7370
|
break;
|
|
7371
7371
|
default:
|
|
7372
|
-
console.warn(`
|
|
7372
|
+
console.warn(`MaskMode ${maskMode} not in specification, please set stencil params seperately.`);
|
|
7373
7373
|
}
|
|
7374
7374
|
}
|
|
7375
7375
|
|
|
@@ -7541,7 +7541,7 @@ function _loadImage() {
|
|
|
7541
7541
|
}
|
|
7542
7542
|
// 2. 非法类型
|
|
7543
7543
|
if (!url) {
|
|
7544
|
-
throw new Error(`Invalid url type: ${JSON.stringify(source)}
|
|
7544
|
+
throw new Error(`Invalid url type: ${JSON.stringify(source)}.`);
|
|
7545
7545
|
}
|
|
7546
7546
|
return new Promise((resolve, reject)=>{
|
|
7547
7547
|
const img = new Image();
|
|
@@ -7654,13 +7654,13 @@ function _loadMedia() {
|
|
|
7654
7654
|
return _loadMedia.apply(this, arguments);
|
|
7655
7655
|
}
|
|
7656
7656
|
|
|
7657
|
-
function deserializeMipmapTexture(
|
|
7657
|
+
function deserializeMipmapTexture(textureOptions, bins, engine) {
|
|
7658
7658
|
return _deserializeMipmapTexture.apply(this, arguments);
|
|
7659
7659
|
}
|
|
7660
7660
|
function _deserializeMipmapTexture() {
|
|
7661
|
-
_deserializeMipmapTexture = _async_to_generator(function*(
|
|
7662
|
-
if (
|
|
7663
|
-
const { mipmaps, target } =
|
|
7661
|
+
_deserializeMipmapTexture = _async_to_generator(function*(textureOptions, bins, engine, files = []) {
|
|
7662
|
+
if (textureOptions.target === 34067) {
|
|
7663
|
+
const { mipmaps, target } = textureOptions;
|
|
7664
7664
|
// const jobs = mipmaps.map(mipmap => Promise.all(mipmap.map(pointer => loadMipmapImage(pointer, bins))));
|
|
7665
7665
|
const loadedMipmaps = [];
|
|
7666
7666
|
for (const level of mipmaps){
|
|
@@ -7676,7 +7676,7 @@ function _deserializeMipmapTexture() {
|
|
|
7676
7676
|
// const bin = files[mipmaps[0][0][1][0]].url;
|
|
7677
7677
|
return _extends({
|
|
7678
7678
|
keepImageSource: false
|
|
7679
|
-
},
|
|
7679
|
+
}, textureOptions, {
|
|
7680
7680
|
mipmaps: loadedMipmaps,
|
|
7681
7681
|
sourceFrom: {
|
|
7682
7682
|
target,
|
|
@@ -7686,13 +7686,13 @@ function _deserializeMipmapTexture() {
|
|
|
7686
7686
|
});
|
|
7687
7687
|
} else {
|
|
7688
7688
|
// TODO: 补充测试用例
|
|
7689
|
-
const { mipmaps, target } =
|
|
7689
|
+
const { mipmaps, target } = textureOptions;
|
|
7690
7690
|
const jobs = mipmaps.map((pointer)=>loadMipmapImage(pointer, bins));
|
|
7691
7691
|
const loadedMipmaps = yield Promise.all(jobs);
|
|
7692
7692
|
const bin = files[mipmaps[0][1][0]].url;
|
|
7693
7693
|
return _extends({
|
|
7694
7694
|
keepImageSource: false
|
|
7695
|
-
},
|
|
7695
|
+
}, textureOptions, {
|
|
7696
7696
|
mipmaps: loadedMipmaps,
|
|
7697
7697
|
sourceType: TextureSourceType.mipmaps,
|
|
7698
7698
|
sourceFrom: {
|
|
@@ -7717,7 +7717,7 @@ function _loadMipmapImage() {
|
|
|
7717
7717
|
const [index, start, length] = pointer[1];
|
|
7718
7718
|
const bin = bins[index];
|
|
7719
7719
|
if (!bin) {
|
|
7720
|
-
throw new Error(`
|
|
7720
|
+
throw new Error(`Invalid bin pointer: ${JSON.stringify(pointer)}.`);
|
|
7721
7721
|
}
|
|
7722
7722
|
return loadImage(new Blob([
|
|
7723
7723
|
new Uint8Array(bin, start, length)
|
|
@@ -7916,7 +7916,7 @@ class KTXTexture {
|
|
|
7916
7916
|
// 0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A
|
|
7917
7917
|
const identifier = new Uint8Array(this.arrayBuffer, this.baseOffset, 12);
|
|
7918
7918
|
if (identifier[0] !== 0xab || identifier[1] !== 0x4b || identifier[2] !== 0x54 || identifier[3] !== 0x58 || identifier[4] !== 0x20 || identifier[5] !== 0x31 || identifier[6] !== 0x31 || identifier[7] !== 0xbb || identifier[8] !== 0x0d || identifier[9] !== 0x0a || identifier[10] !== 0x1a || identifier[11] !== 0x0a) {
|
|
7919
|
-
throw Error('
|
|
7919
|
+
throw new Error('Texture missing KTX identifier.');
|
|
7920
7920
|
}
|
|
7921
7921
|
// load the reset of the header in native 32 bit uint
|
|
7922
7922
|
const dataSize = Uint32Array.BYTES_PER_ELEMENT;
|
|
@@ -7938,15 +7938,15 @@ class KTXTexture {
|
|
|
7938
7938
|
// value of zero is an indication to generate mipmaps @ runtime. Not usually allowed for compressed, so disregard.
|
|
7939
7939
|
this.numberOfMipmapLevels = Math.max(1, this.numberOfMipmapLevels);
|
|
7940
7940
|
if (this.pixelHeight === 0 || this.pixelDepth !== 0) {
|
|
7941
|
-
logger.warn('Only 2D textures currently supported');
|
|
7941
|
+
logger.warn('Only 2D textures currently supported.');
|
|
7942
7942
|
return;
|
|
7943
7943
|
}
|
|
7944
7944
|
if (this.numberOfArrayElements !== 0) {
|
|
7945
|
-
logger.warn('Texture arrays not currently supported');
|
|
7945
|
+
logger.warn('Texture arrays not currently supported.');
|
|
7946
7946
|
return;
|
|
7947
7947
|
}
|
|
7948
7948
|
if (this.numberOfFaces !== facesExpected) {
|
|
7949
|
-
logger.warn(
|
|
7949
|
+
logger.warn(`Number of faces expected ${facesExpected}, but found ${this.numberOfFaces}.`);
|
|
7950
7950
|
return;
|
|
7951
7951
|
}
|
|
7952
7952
|
// we now have a completely validated file, so could use existence of loadType as success
|
|
@@ -7986,7 +7986,7 @@ class TextureFactory {
|
|
|
7986
7986
|
texture.updateSource(sourceOpts);
|
|
7987
7987
|
_this.reloadPending[id] = false;
|
|
7988
7988
|
} else {
|
|
7989
|
-
throw new Error('No source from');
|
|
7989
|
+
throw new Error('No source from.');
|
|
7990
7990
|
}
|
|
7991
7991
|
})();
|
|
7992
7992
|
}
|
|
@@ -8113,7 +8113,7 @@ class TextureFactory {
|
|
|
8113
8113
|
});
|
|
8114
8114
|
}
|
|
8115
8115
|
}
|
|
8116
|
-
throw new Error(`Invalid resource type: ${type}
|
|
8116
|
+
throw new Error(`Invalid resource type: ${type}.`);
|
|
8117
8117
|
})();
|
|
8118
8118
|
}
|
|
8119
8119
|
loadMipmapImages(pointers, bin) {
|
|
@@ -8929,19 +8929,19 @@ function buildEasingCurve(leftKeyframe, rightKeyframe) {
|
|
|
8929
8929
|
y2 = numberToFix((p2.y - p0.y) / valueInterval, 5);
|
|
8930
8930
|
}
|
|
8931
8931
|
if (x1 < 0) {
|
|
8932
|
-
console.error('
|
|
8932
|
+
console.error('Invalid bezier points, x1 < 0', p0, p1, p2, p3);
|
|
8933
8933
|
x1 = 0;
|
|
8934
8934
|
}
|
|
8935
8935
|
if (x2 < 0) {
|
|
8936
|
-
console.error('
|
|
8936
|
+
console.error('Invalid bezier points, x2 < 0', p0, p1, p2, p3);
|
|
8937
8937
|
x2 = 0;
|
|
8938
8938
|
}
|
|
8939
8939
|
if (x1 > 1) {
|
|
8940
|
-
console.error('
|
|
8940
|
+
console.error('Invalid bezier points, x1 >= 1', p0, p1, p2, p3);
|
|
8941
8941
|
x1 = 1;
|
|
8942
8942
|
}
|
|
8943
8943
|
if (x2 > 1) {
|
|
8944
|
-
console.error('
|
|
8944
|
+
console.error('Invalid bezier points, x2 >= 1', p0, p1, p2, p3);
|
|
8945
8945
|
x2 = 1;
|
|
8946
8946
|
}
|
|
8947
8947
|
const str = ('bez_' + x1 + '_' + y1 + '_' + x2 + '_' + y2).replace(/\./g, 'p');
|
|
@@ -9125,31 +9125,31 @@ class ValueGetter {
|
|
|
9125
9125
|
return halfFloat ? ret.data : ret;
|
|
9126
9126
|
}
|
|
9127
9127
|
onCreate(props) {
|
|
9128
|
-
throw Error(NOT_IMPLEMENT);
|
|
9128
|
+
throw new Error(NOT_IMPLEMENT);
|
|
9129
9129
|
}
|
|
9130
9130
|
getIntegrateValue(t0, t1, timeScale = 1) {
|
|
9131
|
-
throw Error(NOT_IMPLEMENT);
|
|
9131
|
+
throw new Error(NOT_IMPLEMENT);
|
|
9132
9132
|
}
|
|
9133
9133
|
getIntegrateByTime(t0, time) {
|
|
9134
|
-
throw Error(NOT_IMPLEMENT);
|
|
9134
|
+
throw new Error(NOT_IMPLEMENT);
|
|
9135
9135
|
}
|
|
9136
9136
|
getValue(time) {
|
|
9137
|
-
throw Error(NOT_IMPLEMENT);
|
|
9137
|
+
throw new Error(NOT_IMPLEMENT);
|
|
9138
9138
|
}
|
|
9139
9139
|
getMaxTime() {
|
|
9140
|
-
throw Error(NOT_IMPLEMENT);
|
|
9140
|
+
throw new Error(NOT_IMPLEMENT);
|
|
9141
9141
|
}
|
|
9142
9142
|
toUniform(meta) {
|
|
9143
|
-
throw Error(NOT_IMPLEMENT);
|
|
9143
|
+
throw new Error(NOT_IMPLEMENT);
|
|
9144
9144
|
}
|
|
9145
9145
|
map(func) {
|
|
9146
|
-
throw Error(NOT_IMPLEMENT);
|
|
9146
|
+
throw new Error(NOT_IMPLEMENT);
|
|
9147
9147
|
}
|
|
9148
9148
|
scaleXCoord(scale) {
|
|
9149
9149
|
return this;
|
|
9150
9150
|
}
|
|
9151
9151
|
toData() {
|
|
9152
|
-
throw Error(NOT_IMPLEMENT);
|
|
9152
|
+
throw new Error(NOT_IMPLEMENT);
|
|
9153
9153
|
}
|
|
9154
9154
|
constructor(arg){
|
|
9155
9155
|
this.onCreate(arg);
|
|
@@ -9781,7 +9781,7 @@ function createValueGetter(args) {
|
|
|
9781
9781
|
if (isFunction(map$1[args[0]])) {
|
|
9782
9782
|
return map$1[args[0]](args[1]);
|
|
9783
9783
|
} else {
|
|
9784
|
-
throw new Error(`ValueType: ${args[0]} is not
|
|
9784
|
+
throw new Error(`ValueType: ${args[0]} is not supported, see ${HELP_LINK['ValueType: 21/22 is not supported']}.`);
|
|
9785
9785
|
}
|
|
9786
9786
|
}
|
|
9787
9787
|
function lineSegIntegrate(t, t0, t1, y0, y1) {
|
|
@@ -9955,7 +9955,7 @@ function createCopyShader(level, writeDepth) {
|
|
|
9955
9955
|
vertex: version + '\n' + COPY_VERTEX_SHADER,
|
|
9956
9956
|
fragment: version + '\n' + COPY_FRAGMENT_SHADER,
|
|
9957
9957
|
glslVersion: webgl2 ? GLSLVersion.GLSL3 : GLSLVersion.GLSL1,
|
|
9958
|
-
|
|
9958
|
+
macros: [
|
|
9959
9959
|
[
|
|
9960
9960
|
'WEBGL2',
|
|
9961
9961
|
!!webgl2
|
|
@@ -10019,7 +10019,7 @@ class PassTextureCache {
|
|
|
10019
10019
|
const refCount = this.textureRef[id];
|
|
10020
10020
|
if (refCount <= 1) {
|
|
10021
10021
|
if (refCount < 0) {
|
|
10022
|
-
console.error('
|
|
10022
|
+
console.error('Ref count < 0.');
|
|
10023
10023
|
}
|
|
10024
10024
|
const tex = this.textureCache[id];
|
|
10025
10025
|
if (tex) {
|
|
@@ -10633,21 +10633,21 @@ let seed$6 = 1;
|
|
|
10633
10633
|
}
|
|
10634
10634
|
}
|
|
10635
10635
|
|
|
10636
|
-
var blend = "vec4 blendColor(vec4 color,vec4 vc,float mode){vec4 ret=color*vc
|
|
10636
|
+
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;}";
|
|
10637
10637
|
|
|
10638
10638
|
var compatible_frag = "#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\n";
|
|
10639
10639
|
|
|
10640
10640
|
var compatible_vert = "#version 300 es\n#ifdef WEBGL2\n#define texture2D texture\n#else\n#endif\n";
|
|
10641
10641
|
|
|
10642
|
-
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
|
|
10642
|
+
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);}";
|
|
10643
10643
|
|
|
10644
10644
|
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.;}";
|
|
10645
10645
|
|
|
10646
10646
|
var itemVert = "precision highp float;attribute vec2 atlasOffset;attribute vec3 aPos;varying vec2 vTexCoord;varying vec3 vParams;varying vec4 vColor;uniform vec2 _Size;uniform vec4 _Color;uniform vec4 _TexParams;uniform vec4 _TexOffset;uniform mat4 effects_MatrixVP;uniform mat4 effects_MatrixInvV;uniform mat4 effects_ObjectToWorld;\n#ifdef ENV_EDITOR\nuniform vec4 uEditorTransform;\n#endif\nvoid main(){vec4 texParams=_TexParams;vTexCoord=vec2(atlasOffset.xy*_TexOffset.zw+_TexOffset.xy);vColor=_Color;vParams=vec3(0.0,texParams.y,texParams.x);vec4 pos=vec4(aPos.xy*_Size,aPos.z,1.0);gl_Position=effects_MatrixVP*effects_ObjectToWorld*pos;\n#ifdef ENV_EDITOR\ngl_Position=vec4(gl_Position.xy*uEditorTransform.xy+uEditorTransform.zw*gl_Position.w,gl_Position.zw);\n#endif\n}";
|
|
10647
10647
|
|
|
10648
|
-
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
|
|
10648
|
+
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;}";
|
|
10649
10649
|
|
|
10650
|
-
var particleFrag = "#version 300 es\nprecision mediump 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
|
|
10650
|
+
var particleFrag = "#version 300 es\nprecision mediump 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;}\n#define PATICLE_SHADER 1\nin float vLife;in vec2 vTexCoord;in 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\nin vec4 vTexCoordBlend;\n#endif\nin 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(){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);fragColor=color;}\n#endif\n";
|
|
10651
10651
|
|
|
10652
10652
|
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}}";
|
|
10653
10653
|
|
|
@@ -11794,20 +11794,20 @@ class GPUCapability {
|
|
|
11794
11794
|
framebufferTexture2D(gl, target, index, textarget, texture) {
|
|
11795
11795
|
const ext = this.drawBufferExtension;
|
|
11796
11796
|
if (this.level === 1 && !ext && index > 0) {
|
|
11797
|
-
throw new Error('
|
|
11797
|
+
throw new Error('Draw multiple color buffers not available.');
|
|
11798
11798
|
}
|
|
11799
11799
|
const attachment = ext ? ext[`COLOR_ATTACHMENT${index}_WEBGL`] : gl[`COLOR_ATTACHMENT${index}`];
|
|
11800
11800
|
if (attachment) {
|
|
11801
11801
|
gl.framebufferTexture2D(target, attachment, textarget, texture, 0);
|
|
11802
11802
|
} else {
|
|
11803
|
-
console.error(
|
|
11803
|
+
console.error(`Invalid color attachment index: ${index}.`);
|
|
11804
11804
|
}
|
|
11805
11805
|
}
|
|
11806
11806
|
drawBuffers(gl, bufferStates) {
|
|
11807
11807
|
const ext = this.drawBufferExtension;
|
|
11808
11808
|
if (this.level === 1 && !ext) {
|
|
11809
11809
|
if (bufferStates.length > 1) {
|
|
11810
|
-
throw Error('
|
|
11810
|
+
throw new Error('Draw buffers not available.');
|
|
11811
11811
|
} else {
|
|
11812
11812
|
return;
|
|
11813
11813
|
}
|
|
@@ -12067,7 +12067,7 @@ class InteractMesh {
|
|
|
12067
12067
|
}
|
|
12068
12068
|
createMaterial(rendererOptions) {
|
|
12069
12069
|
var _this_engine_renderer;
|
|
12070
|
-
const
|
|
12070
|
+
const macros = [
|
|
12071
12071
|
[
|
|
12072
12072
|
'ENV_EDITOR',
|
|
12073
12073
|
((_this_engine_renderer = this.engine.renderer) == null ? void 0 : _this_engine_renderer.env) === PLAYER_OPTIONS_ENV_EDITOR
|
|
@@ -12080,7 +12080,7 @@ class InteractMesh {
|
|
|
12080
12080
|
fragment,
|
|
12081
12081
|
glslVersion: GLSLVersion.GLSL1,
|
|
12082
12082
|
cacheId: `${rendererOptions.cachePrefix}_effects_interact`,
|
|
12083
|
-
|
|
12083
|
+
macros
|
|
12084
12084
|
},
|
|
12085
12085
|
uniformSemantics: {
|
|
12086
12086
|
effects_MatrixVP: 'VIEWPROJECTION',
|
|
@@ -12345,16 +12345,12 @@ function shouldIgnoreBouncing(arg, mul) {
|
|
|
12345
12345
|
}
|
|
12346
12346
|
|
|
12347
12347
|
let maxSpriteMeshItemCount = 8;
|
|
12348
|
-
let maxSpriteTextureCount = 8;
|
|
12349
12348
|
function setSpriteMeshMaxItemCountByGPU(gpuCapability) {
|
|
12350
|
-
// 8 or 16
|
|
12351
|
-
maxSpriteTextureCount = Math.min(gpuCapability.maxFragmentTextures, 16);
|
|
12352
12349
|
if (gpuCapability.maxVertexUniforms >= 256) {
|
|
12353
12350
|
return maxSpriteMeshItemCount = 32;
|
|
12354
12351
|
} else if (gpuCapability.maxVertexUniforms >= 128) {
|
|
12355
12352
|
return maxSpriteMeshItemCount = 16;
|
|
12356
12353
|
}
|
|
12357
|
-
maxSpriteTextureCount = 8;
|
|
12358
12354
|
}
|
|
12359
12355
|
function getImageItemRenderInfo(item) {
|
|
12360
12356
|
const { renderer } = item;
|
|
@@ -12372,27 +12368,11 @@ function getImageItemRenderInfo(item) {
|
|
|
12372
12368
|
};
|
|
12373
12369
|
}
|
|
12374
12370
|
function spriteMeshShaderFromFilter(level, options) {
|
|
12375
|
-
const {
|
|
12376
|
-
const
|
|
12377
|
-
[
|
|
12378
|
-
'MAX_ITEM_COUNT',
|
|
12379
|
-
count
|
|
12380
|
-
],
|
|
12381
|
-
[
|
|
12382
|
-
'PRE_MULTIPLY_ALPHA',
|
|
12383
|
-
false
|
|
12384
|
-
],
|
|
12371
|
+
const { env = '', wireframe } = options != null ? options : {};
|
|
12372
|
+
const macros = [
|
|
12385
12373
|
[
|
|
12386
12374
|
'ENV_EDITOR',
|
|
12387
12375
|
env === PLAYER_OPTIONS_ENV_EDITOR
|
|
12388
|
-
],
|
|
12389
|
-
[
|
|
12390
|
-
'USE_BLEND',
|
|
12391
|
-
!ignoreBlend
|
|
12392
|
-
],
|
|
12393
|
-
[
|
|
12394
|
-
'MAX_FRAG_TEX',
|
|
12395
|
-
maxSpriteTextureCount >= 16 ? 16 : 8
|
|
12396
12376
|
]
|
|
12397
12377
|
];
|
|
12398
12378
|
const fragment = wireframe ? itemFrameFrag : itemFrag;
|
|
@@ -12401,7 +12381,7 @@ function spriteMeshShaderFromFilter(level, options) {
|
|
|
12401
12381
|
fragment,
|
|
12402
12382
|
vertex,
|
|
12403
12383
|
glslVersion: level === 1 ? GLSLVersion.GLSL1 : GLSLVersion.GLSL3,
|
|
12404
|
-
|
|
12384
|
+
macros,
|
|
12405
12385
|
shared: true
|
|
12406
12386
|
};
|
|
12407
12387
|
}
|
|
@@ -12411,7 +12391,6 @@ function spriteMeshShaderIdFromRenderInfo(renderInfo, count) {
|
|
|
12411
12391
|
function spriteMeshShaderFromRenderInfo(renderInfo, count, level, env) {
|
|
12412
12392
|
const { wireframe } = renderInfo;
|
|
12413
12393
|
const shader = spriteMeshShaderFromFilter(level, {
|
|
12414
|
-
count,
|
|
12415
12394
|
wireframe,
|
|
12416
12395
|
env
|
|
12417
12396
|
});
|
|
@@ -12425,9 +12404,6 @@ function spriteMeshShaderFromRenderInfo(renderInfo, count, level, env) {
|
|
|
12425
12404
|
function setMaxSpriteMeshItemCount(count) {
|
|
12426
12405
|
maxSpriteMeshItemCount = count;
|
|
12427
12406
|
}
|
|
12428
|
-
function setSpriteMeshMaxFragmentTextures(count) {
|
|
12429
|
-
maxSpriteTextureCount = count;
|
|
12430
|
-
}
|
|
12431
12407
|
|
|
12432
12408
|
const defRenderInfo = {
|
|
12433
12409
|
blending: 0,
|
|
@@ -13991,7 +13967,7 @@ function createShape(shapeOptions) {
|
|
|
13991
13967
|
const { type } = shapeOptions;
|
|
13992
13968
|
const Ctrl = map[type];
|
|
13993
13969
|
if (!Ctrl) {
|
|
13994
|
-
throw Error(
|
|
13970
|
+
throw new Error(`Invalid shape: ${type}.`);
|
|
13995
13971
|
}
|
|
13996
13972
|
const ctrl = new Ctrl(options);
|
|
13997
13973
|
if (type !== ShapeType.NONE) {
|
|
@@ -14960,7 +14936,7 @@ class TrailMesh {
|
|
|
14960
14936
|
const uniformValues = {};
|
|
14961
14937
|
// const lookUpTexture = getConfig(RENDER_PREFER_LOOKUP_TEXTURE) ? 1 : 0;
|
|
14962
14938
|
const lookUpTexture = 0;
|
|
14963
|
-
const
|
|
14939
|
+
const macros = [
|
|
14964
14940
|
[
|
|
14965
14941
|
'ENABLE_VERTEX_TEXTURE',
|
|
14966
14942
|
enableVertexTexture
|
|
@@ -14977,7 +14953,7 @@ class TrailMesh {
|
|
|
14977
14953
|
const useAttributeTrailStart = maxTrailCount > 64;
|
|
14978
14954
|
let shaderCacheId = 0;
|
|
14979
14955
|
if (colorOverLifetime) {
|
|
14980
|
-
|
|
14956
|
+
macros.push([
|
|
14981
14957
|
'COLOR_OVER_LIFETIME',
|
|
14982
14958
|
true
|
|
14983
14959
|
]);
|
|
@@ -14985,7 +14961,7 @@ class TrailMesh {
|
|
|
14985
14961
|
uniformValues.uColorOverLifetime = Texture.createWithData(engine, imageDataFromGradient(colorOverLifetime));
|
|
14986
14962
|
}
|
|
14987
14963
|
if (colorOverTrail) {
|
|
14988
|
-
|
|
14964
|
+
macros.push([
|
|
14989
14965
|
'COLOR_OVER_TRAIL',
|
|
14990
14966
|
true
|
|
14991
14967
|
]);
|
|
@@ -14993,7 +14969,7 @@ class TrailMesh {
|
|
|
14993
14969
|
uniformValues.uColorOverTrail = Texture.createWithData(engine, imageDataFromGradient(colorOverTrail));
|
|
14994
14970
|
}
|
|
14995
14971
|
if (useAttributeTrailStart) {
|
|
14996
|
-
|
|
14972
|
+
macros.push([
|
|
14997
14973
|
'ATTR_TRAIL_START',
|
|
14998
14974
|
1
|
|
14999
14975
|
]);
|
|
@@ -15003,7 +14979,7 @@ class TrailMesh {
|
|
|
15003
14979
|
}
|
|
15004
14980
|
uniformValues.uOpacityOverLifetimeValue = opacityOverLifetime.toUniform(keyFrameMeta);
|
|
15005
14981
|
const uWidthOverTrail = widthOverTrail.toUniform(keyFrameMeta);
|
|
15006
|
-
|
|
14982
|
+
macros.push([
|
|
15007
14983
|
'VERT_CURVE_VALUE_COUNT',
|
|
15008
14984
|
keyFrameMeta.index
|
|
15009
14985
|
], [
|
|
@@ -15022,7 +14998,7 @@ class TrailMesh {
|
|
|
15022
14998
|
shader: {
|
|
15023
14999
|
vertex,
|
|
15024
15000
|
fragment,
|
|
15025
|
-
|
|
15001
|
+
macros,
|
|
15026
15002
|
glslVersion: level === 1 ? GLSLVersion.GLSL1 : GLSLVersion.GLSL3,
|
|
15027
15003
|
shared: true,
|
|
15028
15004
|
name: `trail#${name}`,
|
|
@@ -15177,11 +15153,11 @@ function calculateDirection(prePoint, point, nextPoint) {
|
|
|
15177
15153
|
}
|
|
15178
15154
|
return dir.normalize().toArray();
|
|
15179
15155
|
}
|
|
15180
|
-
function getTrailMeshShader(trails, particleMaxCount, name, env = ''
|
|
15156
|
+
function getTrailMeshShader(trails, particleMaxCount, name, gpuCapability, env = '') {
|
|
15181
15157
|
let shaderCacheId = 0;
|
|
15182
15158
|
const lookUpTexture = getConfig(RENDER_PREFER_LOOKUP_TEXTURE) ? 1 : 0;
|
|
15183
15159
|
const enableVertexTexture = gpuCapability.detail.maxVertexTextures > 0;
|
|
15184
|
-
const
|
|
15160
|
+
const macros = [
|
|
15185
15161
|
[
|
|
15186
15162
|
'ENABLE_VERTEX_TEXTURE',
|
|
15187
15163
|
enableVertexTexture
|
|
@@ -15197,14 +15173,14 @@ function getTrailMeshShader(trails, particleMaxCount, name, env = '', gpuCapabil
|
|
|
15197
15173
|
];
|
|
15198
15174
|
const keyFrameMeta = createKeyFrameMeta();
|
|
15199
15175
|
if (trails.colorOverLifetime) {
|
|
15200
|
-
|
|
15176
|
+
macros.push([
|
|
15201
15177
|
'COLOR_OVER_LIFETIME',
|
|
15202
15178
|
true
|
|
15203
15179
|
]);
|
|
15204
15180
|
shaderCacheId |= 1;
|
|
15205
15181
|
}
|
|
15206
15182
|
if (trails.colorOverTrail) {
|
|
15207
|
-
|
|
15183
|
+
macros.push([
|
|
15208
15184
|
'COLOR_OVER_TRAIL',
|
|
15209
15185
|
true
|
|
15210
15186
|
]);
|
|
@@ -15212,7 +15188,7 @@ function getTrailMeshShader(trails, particleMaxCount, name, env = '', gpuCapabil
|
|
|
15212
15188
|
}
|
|
15213
15189
|
const useAttributeTrailStart = particleMaxCount > 64;
|
|
15214
15190
|
if (useAttributeTrailStart) {
|
|
15215
|
-
|
|
15191
|
+
macros.push([
|
|
15216
15192
|
'ATTR_TRAIL_START',
|
|
15217
15193
|
1
|
|
15218
15194
|
]);
|
|
@@ -15220,7 +15196,7 @@ function getTrailMeshShader(trails, particleMaxCount, name, env = '', gpuCapabil
|
|
|
15220
15196
|
}
|
|
15221
15197
|
getKeyFrameMetaByRawValue(keyFrameMeta, trails.opacityOverLifetime);
|
|
15222
15198
|
getKeyFrameMetaByRawValue(keyFrameMeta, trails.widthOverTrail);
|
|
15223
|
-
|
|
15199
|
+
macros.push([
|
|
15224
15200
|
'VERT_CURVE_VALUE_COUNT',
|
|
15225
15201
|
keyFrameMeta.index
|
|
15226
15202
|
], [
|
|
@@ -15230,7 +15206,7 @@ function getTrailMeshShader(trails, particleMaxCount, name, env = '', gpuCapabil
|
|
|
15230
15206
|
return {
|
|
15231
15207
|
vertex: trailVert,
|
|
15232
15208
|
fragment: particleFrag,
|
|
15233
|
-
|
|
15209
|
+
macros,
|
|
15234
15210
|
shared: true,
|
|
15235
15211
|
name: 'trail#' + name,
|
|
15236
15212
|
cacheId: `-t:+${shaderCacheId}+${keyFrameMeta.index}+${keyFrameMeta.max}`
|
|
@@ -16541,15 +16517,12 @@ class ParticleMesh {
|
|
|
16541
16517
|
const { speedOverLifetime, colorOverLifetime, linearVelOverLifetime, orbitalVelOverLifetime, sizeOverLifetime, rotationOverLifetime, sprite, gravityModifier, maxCount, textureFlip, useSprite, name, gravity, forceTarget, side, occlusion, anchor, blending, maskMode, mask, transparentOcclusion, meshSlots, renderMode = 0, diffuse = Texture.createWithData(engine) } = props;
|
|
16542
16518
|
const { detail } = engine.gpuCapability;
|
|
16543
16519
|
const { halfFloatTexture, maxVertexUniforms } = detail;
|
|
16544
|
-
const
|
|
16520
|
+
const macros = [
|
|
16521
|
+
// spec.RenderMode
|
|
16545
16522
|
[
|
|
16546
16523
|
'RENDER_MODE',
|
|
16547
16524
|
+renderMode
|
|
16548
16525
|
],
|
|
16549
|
-
[
|
|
16550
|
-
'PRE_MULTIPLY_ALPHA',
|
|
16551
|
-
false
|
|
16552
|
-
],
|
|
16553
16526
|
[
|
|
16554
16527
|
'ENV_EDITOR',
|
|
16555
16528
|
env === PLAYER_OPTIONS_ENV_EDITOR
|
|
@@ -16565,13 +16538,13 @@ class ParticleMesh {
|
|
|
16565
16538
|
let useOrbitalVel;
|
|
16566
16539
|
this.useSprite = useSprite;
|
|
16567
16540
|
if (enableVertexTexture) {
|
|
16568
|
-
|
|
16541
|
+
macros.push([
|
|
16569
16542
|
'ENABLE_VERTEX_TEXTURE',
|
|
16570
16543
|
true
|
|
16571
16544
|
]);
|
|
16572
16545
|
}
|
|
16573
16546
|
if (speedOverLifetime) {
|
|
16574
|
-
|
|
16547
|
+
macros.push([
|
|
16575
16548
|
'SPEED_OVER_LIFETIME',
|
|
16576
16549
|
true
|
|
16577
16550
|
]);
|
|
@@ -16579,7 +16552,7 @@ class ParticleMesh {
|
|
|
16579
16552
|
uniformValues.uSpeedLifetimeValue = speedOverLifetime.toUniform(vertexKeyFrameMeta);
|
|
16580
16553
|
}
|
|
16581
16554
|
if (sprite == null ? void 0 : sprite.animate) {
|
|
16582
|
-
|
|
16555
|
+
macros.push([
|
|
16583
16556
|
'USE_SPRITE',
|
|
16584
16557
|
true
|
|
16585
16558
|
]);
|
|
@@ -16593,7 +16566,7 @@ class ParticleMesh {
|
|
|
16593
16566
|
this.useSprite = true;
|
|
16594
16567
|
}
|
|
16595
16568
|
if (colorOverLifetime == null ? void 0 : colorOverLifetime.color) {
|
|
16596
|
-
|
|
16569
|
+
macros.push([
|
|
16597
16570
|
'COLOR_OVER_LIFETIME',
|
|
16598
16571
|
true
|
|
16599
16572
|
]);
|
|
@@ -16618,7 +16591,7 @@ class ParticleMesh {
|
|
|
16618
16591
|
shaderCacheId |= 1 << 7 + i;
|
|
16619
16592
|
linearVelOverLifetime.enabled = true;
|
|
16620
16593
|
}
|
|
16621
|
-
|
|
16594
|
+
macros.push([
|
|
16622
16595
|
`LINEAR_VEL_${pro.toUpperCase()}`,
|
|
16623
16596
|
defL
|
|
16624
16597
|
]);
|
|
@@ -16629,13 +16602,13 @@ class ParticleMesh {
|
|
|
16629
16602
|
useOrbitalVel = true;
|
|
16630
16603
|
orbitalVelOverLifetime.enabled = true;
|
|
16631
16604
|
}
|
|
16632
|
-
|
|
16605
|
+
macros.push([
|
|
16633
16606
|
`ORB_VEL_${pro.toUpperCase()}`,
|
|
16634
16607
|
defO
|
|
16635
16608
|
]);
|
|
16636
16609
|
});
|
|
16637
16610
|
if (linearVelOverLifetime == null ? void 0 : linearVelOverLifetime.asMovement) {
|
|
16638
|
-
|
|
16611
|
+
macros.push([
|
|
16639
16612
|
'AS_LINEAR_MOVEMENT',
|
|
16640
16613
|
true
|
|
16641
16614
|
]);
|
|
@@ -16643,7 +16616,7 @@ class ParticleMesh {
|
|
|
16643
16616
|
}
|
|
16644
16617
|
if (useOrbitalVel) {
|
|
16645
16618
|
if (orbitalVelOverLifetime == null ? void 0 : orbitalVelOverLifetime.asRotation) {
|
|
16646
|
-
|
|
16619
|
+
macros.push([
|
|
16647
16620
|
'AS_ORBITAL_MOVEMENT',
|
|
16648
16621
|
true
|
|
16649
16622
|
]);
|
|
@@ -16658,7 +16631,7 @@ class ParticleMesh {
|
|
|
16658
16631
|
uniformValues.uSizeByLifetimeValue = sizeOverLifetime == null ? void 0 : sizeOverLifetime.x.toUniform(vertexKeyFrameMeta);
|
|
16659
16632
|
if (sizeOverLifetime == null ? void 0 : sizeOverLifetime.separateAxes) {
|
|
16660
16633
|
var _sizeOverLifetime_y;
|
|
16661
|
-
|
|
16634
|
+
macros.push([
|
|
16662
16635
|
'SIZE_Y_BY_LIFE',
|
|
16663
16636
|
1
|
|
16664
16637
|
]);
|
|
@@ -16668,7 +16641,7 @@ class ParticleMesh {
|
|
|
16668
16641
|
if (rotationOverLifetime == null ? void 0 : rotationOverLifetime.z) {
|
|
16669
16642
|
uniformValues.uRZByLifeTimeValue = rotationOverLifetime.z.toUniform(vertexKeyFrameMeta);
|
|
16670
16643
|
shaderCacheId |= 1 << 15;
|
|
16671
|
-
|
|
16644
|
+
macros.push([
|
|
16672
16645
|
'ROT_Z_LIFETIME',
|
|
16673
16646
|
1
|
|
16674
16647
|
]);
|
|
@@ -16676,7 +16649,7 @@ class ParticleMesh {
|
|
|
16676
16649
|
if (rotationOverLifetime == null ? void 0 : rotationOverLifetime.x) {
|
|
16677
16650
|
uniformValues.uRXByLifeTimeValue = rotationOverLifetime.x.toUniform(vertexKeyFrameMeta);
|
|
16678
16651
|
shaderCacheId |= 1 << 16;
|
|
16679
|
-
|
|
16652
|
+
macros.push([
|
|
16680
16653
|
'ROT_X_LIFETIME',
|
|
16681
16654
|
1
|
|
16682
16655
|
]);
|
|
@@ -16684,13 +16657,13 @@ class ParticleMesh {
|
|
|
16684
16657
|
if (rotationOverLifetime == null ? void 0 : rotationOverLifetime.y) {
|
|
16685
16658
|
uniformValues.uRYByLifeTimeValue = rotationOverLifetime.y.toUniform(vertexKeyFrameMeta);
|
|
16686
16659
|
shaderCacheId |= 1 << 17;
|
|
16687
|
-
|
|
16660
|
+
macros.push([
|
|
16688
16661
|
'ROT_Y_LIFETIME',
|
|
16689
16662
|
1
|
|
16690
16663
|
]);
|
|
16691
16664
|
}
|
|
16692
16665
|
if (rotationOverLifetime == null ? void 0 : rotationOverLifetime.asRotation) {
|
|
16693
|
-
|
|
16666
|
+
macros.push([
|
|
16694
16667
|
'ROT_LIFETIME_AS_MOVEMENT',
|
|
16695
16668
|
1
|
|
16696
16669
|
]);
|
|
@@ -16698,7 +16671,7 @@ class ParticleMesh {
|
|
|
16698
16671
|
}
|
|
16699
16672
|
uniformValues.uGravityModifierValue = gravityModifier.toUniform(vertexKeyFrameMeta);
|
|
16700
16673
|
if (forceTarget) {
|
|
16701
|
-
|
|
16674
|
+
macros.push([
|
|
16702
16675
|
'FINAL_TARGET',
|
|
16703
16676
|
true
|
|
16704
16677
|
]);
|
|
@@ -16744,7 +16717,7 @@ class ParticleMesh {
|
|
|
16744
16717
|
fragmentKeyFrameMeta.index,
|
|
16745
16718
|
fragmentKeyFrameMeta.max
|
|
16746
16719
|
].join('+');
|
|
16747
|
-
|
|
16720
|
+
macros.push([
|
|
16748
16721
|
'VERT_CURVE_VALUE_COUNT',
|
|
16749
16722
|
vertexKeyFrameMeta.index
|
|
16750
16723
|
], [
|
|
@@ -16766,7 +16739,7 @@ class ParticleMesh {
|
|
|
16766
16739
|
glslVersion: level === 1 ? GLSLVersion.GLSL1 : GLSLVersion.GLSL3,
|
|
16767
16740
|
shared: true,
|
|
16768
16741
|
cacheId: shaderCache,
|
|
16769
|
-
|
|
16742
|
+
macros,
|
|
16770
16743
|
name: `particle#${name}`
|
|
16771
16744
|
};
|
|
16772
16745
|
const mtlOptions = {
|
|
@@ -16843,7 +16816,7 @@ class ParticleMesh {
|
|
|
16843
16816
|
res.length = 0;
|
|
16844
16817
|
break;
|
|
16845
16818
|
default:
|
|
16846
|
-
console.warn(`
|
|
16819
|
+
console.warn(`Uniform ${name}'s type not in typeMap.`);
|
|
16847
16820
|
}
|
|
16848
16821
|
});
|
|
16849
16822
|
material.setVector3('emissionColor', new Vector3(0, 0, 0));
|
|
@@ -16974,19 +16947,15 @@ function generateGeometryProps(maxVertex, useSprite, name) {
|
|
|
16974
16947
|
maxVertex
|
|
16975
16948
|
};
|
|
16976
16949
|
}
|
|
16977
|
-
function getParticleMeshShader(item, env = ''
|
|
16950
|
+
function getParticleMeshShader(item, gpuCapability, env = '') {
|
|
16978
16951
|
var _props_renderer;
|
|
16979
16952
|
const props = item.content;
|
|
16980
16953
|
const renderMode = +(((_props_renderer = props.renderer) == null ? void 0 : _props_renderer.renderMode) || 0);
|
|
16981
|
-
const
|
|
16954
|
+
const macros = [
|
|
16982
16955
|
[
|
|
16983
16956
|
'RENDER_MODE',
|
|
16984
16957
|
renderMode
|
|
16985
16958
|
],
|
|
16986
|
-
[
|
|
16987
|
-
'PRE_MULTIPLY_ALPHA',
|
|
16988
|
-
false
|
|
16989
|
-
],
|
|
16990
16959
|
[
|
|
16991
16960
|
'ENV_EDITOR',
|
|
16992
16961
|
env === PLAYER_OPTIONS_ENV_EDITOR
|
|
@@ -17001,13 +16970,13 @@ function getParticleMeshShader(item, env = '', gpuCapability) {
|
|
|
17001
16970
|
let vertex_lookup_texture = 0;
|
|
17002
16971
|
let shaderCacheId = 0;
|
|
17003
16972
|
if (enableVertexTexture) {
|
|
17004
|
-
|
|
16973
|
+
macros.push([
|
|
17005
16974
|
'ENABLE_VERTEX_TEXTURE',
|
|
17006
16975
|
true
|
|
17007
16976
|
]);
|
|
17008
16977
|
}
|
|
17009
16978
|
if (speedOverLifetime) {
|
|
17010
|
-
|
|
16979
|
+
macros.push([
|
|
17011
16980
|
'SPEED_OVER_LIFETIME',
|
|
17012
16981
|
true
|
|
17013
16982
|
]);
|
|
@@ -17016,7 +16985,7 @@ function getParticleMeshShader(item, env = '', gpuCapability) {
|
|
|
17016
16985
|
}
|
|
17017
16986
|
const sprite = props.textureSheetAnimation;
|
|
17018
16987
|
if (sprite && sprite.animate) {
|
|
17019
|
-
|
|
16988
|
+
macros.push([
|
|
17020
16989
|
'USE_SPRITE',
|
|
17021
16990
|
true
|
|
17022
16991
|
]);
|
|
@@ -17024,7 +16993,7 @@ function getParticleMeshShader(item, env = '', gpuCapability) {
|
|
|
17024
16993
|
}
|
|
17025
16994
|
const colorOverLifetime = props.colorOverLifetime;
|
|
17026
16995
|
if (colorOverLifetime && colorOverLifetime.color) {
|
|
17027
|
-
|
|
16996
|
+
macros.push([
|
|
17028
16997
|
'COLOR_OVER_LIFETIME',
|
|
17029
16998
|
true
|
|
17030
16999
|
]);
|
|
@@ -17049,7 +17018,7 @@ function getParticleMeshShader(item, env = '', gpuCapability) {
|
|
|
17049
17018
|
defL = 1;
|
|
17050
17019
|
shaderCacheId |= 1 << 7 + i;
|
|
17051
17020
|
}
|
|
17052
|
-
|
|
17021
|
+
macros.push([
|
|
17053
17022
|
`LINEAR_VEL_${pro.toUpperCase()}`,
|
|
17054
17023
|
defL
|
|
17055
17024
|
]);
|
|
@@ -17060,13 +17029,13 @@ function getParticleMeshShader(item, env = '', gpuCapability) {
|
|
|
17060
17029
|
shaderCacheId |= 1 << 10 + i;
|
|
17061
17030
|
useOrbitalVel = true;
|
|
17062
17031
|
}
|
|
17063
|
-
|
|
17032
|
+
macros.push([
|
|
17064
17033
|
`ORB_VEL_${pro.toUpperCase()}`,
|
|
17065
17034
|
defO
|
|
17066
17035
|
]);
|
|
17067
17036
|
});
|
|
17068
17037
|
if (positionOverLifetime == null ? void 0 : positionOverLifetime.asMovement) {
|
|
17069
|
-
|
|
17038
|
+
macros.push([
|
|
17070
17039
|
'AS_LINEAR_MOVEMENT',
|
|
17071
17040
|
true
|
|
17072
17041
|
]);
|
|
@@ -17074,7 +17043,7 @@ function getParticleMeshShader(item, env = '', gpuCapability) {
|
|
|
17074
17043
|
}
|
|
17075
17044
|
if (useOrbitalVel) {
|
|
17076
17045
|
if (positionOverLifetime == null ? void 0 : positionOverLifetime.asRotation) {
|
|
17077
|
-
|
|
17046
|
+
macros.push([
|
|
17078
17047
|
'AS_ORBITAL_MOVEMENT',
|
|
17079
17048
|
true
|
|
17080
17049
|
]);
|
|
@@ -17086,7 +17055,7 @@ function getParticleMeshShader(item, env = '', gpuCapability) {
|
|
|
17086
17055
|
const separateAxes = sizeOverLifetime.separateAxes;
|
|
17087
17056
|
if (separateAxes) {
|
|
17088
17057
|
getKeyFrameMetaByRawValue(vertexKeyFrameMeta, sizeOverLifetime.x);
|
|
17089
|
-
|
|
17058
|
+
macros.push([
|
|
17090
17059
|
'SIZE_Y_BY_LIFE',
|
|
17091
17060
|
1
|
|
17092
17061
|
]);
|
|
@@ -17101,7 +17070,7 @@ function getParticleMeshShader(item, env = '', gpuCapability) {
|
|
|
17101
17070
|
if (rot.z) {
|
|
17102
17071
|
getKeyFrameMetaByRawValue(vertexKeyFrameMeta, rot == null ? void 0 : rot.z);
|
|
17103
17072
|
shaderCacheId |= 1 << 15;
|
|
17104
|
-
|
|
17073
|
+
macros.push([
|
|
17105
17074
|
'ROT_Z_LIFETIME',
|
|
17106
17075
|
1
|
|
17107
17076
|
]);
|
|
@@ -17110,7 +17079,7 @@ function getParticleMeshShader(item, env = '', gpuCapability) {
|
|
|
17110
17079
|
if (rot.x) {
|
|
17111
17080
|
getKeyFrameMetaByRawValue(vertexKeyFrameMeta, rot.x);
|
|
17112
17081
|
shaderCacheId |= 1 << 16;
|
|
17113
|
-
|
|
17082
|
+
macros.push([
|
|
17114
17083
|
'ROT_X_LIFETIME',
|
|
17115
17084
|
1
|
|
17116
17085
|
]);
|
|
@@ -17118,14 +17087,14 @@ function getParticleMeshShader(item, env = '', gpuCapability) {
|
|
|
17118
17087
|
if (rot.y) {
|
|
17119
17088
|
getKeyFrameMetaByRawValue(vertexKeyFrameMeta, rot.y);
|
|
17120
17089
|
shaderCacheId |= 1 << 17;
|
|
17121
|
-
|
|
17090
|
+
macros.push([
|
|
17122
17091
|
'ROT_Y_LIFETIME',
|
|
17123
17092
|
1
|
|
17124
17093
|
]);
|
|
17125
17094
|
}
|
|
17126
17095
|
}
|
|
17127
17096
|
if (rot == null ? void 0 : rot.asRotation) {
|
|
17128
|
-
|
|
17097
|
+
macros.push([
|
|
17129
17098
|
'ROT_LIFETIME_AS_MOVEMENT',
|
|
17130
17099
|
1
|
|
17131
17100
|
]);
|
|
@@ -17135,7 +17104,7 @@ function getParticleMeshShader(item, env = '', gpuCapability) {
|
|
|
17135
17104
|
getKeyFrameMetaByRawValue(vertexKeyFrameMeta, positionOverLifetime == null ? void 0 : positionOverLifetime.gravityOverLifetime);
|
|
17136
17105
|
const forceOpt = positionOverLifetime == null ? void 0 : positionOverLifetime.forceTarget;
|
|
17137
17106
|
if (forceOpt) {
|
|
17138
|
-
|
|
17107
|
+
macros.push([
|
|
17139
17108
|
'FINAL_TARGET',
|
|
17140
17109
|
true
|
|
17141
17110
|
]);
|
|
@@ -17176,10 +17145,10 @@ function getParticleMeshShader(item, env = '', gpuCapability) {
|
|
|
17176
17145
|
vertex: `#define LOOKUP_TEXTURE_CURVE ${vertex_lookup_texture}\n${particleVert}`,
|
|
17177
17146
|
shared: true,
|
|
17178
17147
|
cacheId: shaderCache,
|
|
17179
|
-
|
|
17148
|
+
macros,
|
|
17180
17149
|
name: `particle#${item.name}`
|
|
17181
17150
|
};
|
|
17182
|
-
|
|
17151
|
+
macros.push([
|
|
17183
17152
|
'VERT_CURVE_VALUE_COUNT',
|
|
17184
17153
|
vertexKeyFrameMeta.index
|
|
17185
17154
|
], [
|
|
@@ -17204,11 +17173,11 @@ function modifyMaxKeyframeShader(shader, maxVertex, maxFrag) {
|
|
|
17204
17173
|
shaderIds[3] = maxVertex;
|
|
17205
17174
|
shaderIds[5] = maxFrag;
|
|
17206
17175
|
shader.cacheId = shaderIds.join('+');
|
|
17207
|
-
if (!shader.
|
|
17176
|
+
if (!shader.macros) {
|
|
17208
17177
|
return;
|
|
17209
17178
|
}
|
|
17210
|
-
for(let i = 0; i < shader.
|
|
17211
|
-
const marco = shader.
|
|
17179
|
+
for(let i = 0; i < shader.macros.length; i++){
|
|
17180
|
+
const marco = shader.macros[i];
|
|
17212
17181
|
if (marco[0] === 'VERT_CURVE_VALUE_COUNT') {
|
|
17213
17182
|
marco[1] = maxVertex;
|
|
17214
17183
|
} else if (marco[0] === 'FRAG_CURVE_VALUE_COUNT') {
|
|
@@ -17237,17 +17206,17 @@ class ParticleLoader extends AbstractPlugin {
|
|
|
17237
17206
|
});
|
|
17238
17207
|
});
|
|
17239
17208
|
items.forEach((item)=>{
|
|
17240
|
-
const { shader, fragment, vertex } = getParticleMeshShader(item,
|
|
17209
|
+
const { shader, fragment, vertex } = getParticleMeshShader(item, gpuCapability, env);
|
|
17241
17210
|
shaders.push(shader);
|
|
17242
17211
|
maxFragmentCount = Math.max(maxFragmentCount, fragment);
|
|
17243
17212
|
maxVertexCount = Math.max(maxVertexCount, vertex);
|
|
17244
17213
|
// TODO 此处add是否有意义?shader变量似乎没有加到this.shaders数组。
|
|
17245
17214
|
if (item.content.trails) {
|
|
17246
|
-
const shader = getTrailMeshShader(item.content.trails, item.content.options.maxCount, item.name,
|
|
17247
|
-
var
|
|
17248
|
-
shader.vertex =
|
|
17249
|
-
var
|
|
17250
|
-
shader.fragment =
|
|
17215
|
+
const shader = getTrailMeshShader(item.content.trails, item.content.options.maxCount, item.name, gpuCapability, env);
|
|
17216
|
+
var _shader_macros;
|
|
17217
|
+
shader.vertex = createShaderWithMacros((_shader_macros = shader.macros) != null ? _shader_macros : [], shader.vertex, ShaderType.vertex, level);
|
|
17218
|
+
var _shader_macros1;
|
|
17219
|
+
shader.fragment = createShaderWithMacros((_shader_macros1 = shader.macros) != null ? _shader_macros1 : [], shader.fragment, ShaderType.fragment, level);
|
|
17251
17220
|
shader.glslVersion = level === 2 ? GLSLVersion.GLSL3 : GLSLVersion.GLSL1;
|
|
17252
17221
|
shaderLibrary.addShader(shader);
|
|
17253
17222
|
}
|
|
@@ -17259,10 +17228,10 @@ class ParticleLoader extends AbstractPlugin {
|
|
|
17259
17228
|
} else {
|
|
17260
17229
|
shader.glslVersion = GLSLVersion.GLSL1;
|
|
17261
17230
|
}
|
|
17262
|
-
var
|
|
17263
|
-
shader.vertex =
|
|
17264
|
-
var
|
|
17265
|
-
shader.fragment =
|
|
17231
|
+
var _shader_macros;
|
|
17232
|
+
shader.vertex = createShaderWithMacros((_shader_macros = shader.macros) != null ? _shader_macros : [], shader.vertex, ShaderType.vertex, level);
|
|
17233
|
+
var _shader_macros1;
|
|
17234
|
+
shader.fragment = createShaderWithMacros((_shader_macros1 = shader.macros) != null ? _shader_macros1 : [], shader.fragment, ShaderType.fragment, level);
|
|
17266
17235
|
shaderLibrary.addShader(shader);
|
|
17267
17236
|
});
|
|
17268
17237
|
if (level === 2) {
|
|
@@ -18008,7 +17977,7 @@ function compareTracks(a, b) {
|
|
|
18008
17977
|
const refId = itemData.content.options.refId;
|
|
18009
17978
|
const props = this.item.composition.refCompositionProps.get(refId);
|
|
18010
17979
|
if (!props) {
|
|
18011
|
-
throw new Error(
|
|
17980
|
+
throw new Error(`Referenced precomposition with Id: ${refId} does not exist.`);
|
|
18012
17981
|
}
|
|
18013
17982
|
// endBehaviour 类型需优化
|
|
18014
17983
|
props.content = itemData.content;
|
|
@@ -18152,7 +18121,7 @@ function compareTracks(a, b) {
|
|
|
18152
18121
|
class SubCompositionTrack extends TrackAsset {
|
|
18153
18122
|
resolveBinding(parentBinding) {
|
|
18154
18123
|
if (!(parentBinding instanceof VFXItem)) {
|
|
18155
|
-
throw new Error('SubCompositionTrack needs to be set under the VFXItem track');
|
|
18124
|
+
throw new Error('SubCompositionTrack needs to be set under the VFXItem track.');
|
|
18156
18125
|
}
|
|
18157
18126
|
return parentBinding.getComponent(CompositionComponent);
|
|
18158
18127
|
}
|
|
@@ -19167,7 +19136,7 @@ class VFXItem extends EffectsObject {
|
|
|
19167
19136
|
};
|
|
19168
19137
|
}
|
|
19169
19138
|
if (duration <= 0) {
|
|
19170
|
-
throw Error(`Item duration can't be less than 0, see ${HELP_LINK['Item duration can\'t be less than 0']}
|
|
19139
|
+
throw new Error(`Item duration can't be less than 0, see ${HELP_LINK['Item duration can\'t be less than 0']}.`);
|
|
19171
19140
|
}
|
|
19172
19141
|
for (const component of this.components){
|
|
19173
19142
|
component.onAttached();
|
|
@@ -19333,7 +19302,7 @@ var Item;
|
|
|
19333
19302
|
pluginName = 'tree';
|
|
19334
19303
|
break;
|
|
19335
19304
|
default:
|
|
19336
|
-
throw new Error('
|
|
19305
|
+
throw new Error('Invalid vfx item type.');
|
|
19337
19306
|
}
|
|
19338
19307
|
}
|
|
19339
19308
|
return composition.pluginSystem.createPluginItem(pluginName, props, composition);
|
|
@@ -19374,13 +19343,13 @@ class PluginSystem {
|
|
|
19374
19343
|
createPluginItem(name, props, composition) {
|
|
19375
19344
|
const CTRL = pluginCtrlMap[name];
|
|
19376
19345
|
if (!CTRL) {
|
|
19377
|
-
throw new Error(`plugin ${name}
|
|
19346
|
+
throw new Error(`The plugin '${name}' does not have a registered constructor.`);
|
|
19378
19347
|
}
|
|
19379
19348
|
const engine = composition.getEngine();
|
|
19380
19349
|
const item = new CTRL(engine, props, composition);
|
|
19381
19350
|
item.composition = composition;
|
|
19382
19351
|
if (!(item instanceof VFXItem)) {
|
|
19383
|
-
throw new Error(`plugin ${name} invalid constructor type
|
|
19352
|
+
throw new Error(`The plugin '${name}' invalid constructor type.`);
|
|
19384
19353
|
}
|
|
19385
19354
|
return item;
|
|
19386
19355
|
}
|
|
@@ -19433,7 +19402,7 @@ class PluginSystem {
|
|
|
19433
19402
|
this.plugins = Object.keys(loaders).map((name)=>{
|
|
19434
19403
|
const CTRL = pluginLoaderMap[name];
|
|
19435
19404
|
if (!CTRL) {
|
|
19436
|
-
throw new Error(`plugin '${name}' not found.` + getPluginUsageInfo(name));
|
|
19405
|
+
throw new Error(`The plugin '${name}' not found.` + getPluginUsageInfo(name));
|
|
19437
19406
|
}
|
|
19438
19407
|
const loader = new CTRL();
|
|
19439
19408
|
loader.name = name;
|
|
@@ -19629,7 +19598,7 @@ class SerializationHelper {
|
|
|
19629
19598
|
}
|
|
19630
19599
|
static deserializeProperty(property, engine, level, type) {
|
|
19631
19600
|
if (level > 14) {
|
|
19632
|
-
console.error('
|
|
19601
|
+
console.error('The nested object layers of the serialized data exceed the maximum limit.');
|
|
19633
19602
|
return;
|
|
19634
19603
|
}
|
|
19635
19604
|
// 加载并链接 DataPath 字段表示的 EffectsObject 引用。Class 对象 copy [key, value] 会丢失对象信息,因此只递归数组对象和普通 js Object 结构对象。
|
|
@@ -19660,7 +19629,7 @@ class SerializationHelper {
|
|
|
19660
19629
|
static deserializePropertyAsync(property, engine, level, type) {
|
|
19661
19630
|
return _async_to_generator(function*() {
|
|
19662
19631
|
if (level > 14) {
|
|
19663
|
-
console.error('
|
|
19632
|
+
console.error('The nested object layers of the serialized data exceed the maximum limit.');
|
|
19664
19633
|
return;
|
|
19665
19634
|
}
|
|
19666
19635
|
if (isArray(property)) {
|
|
@@ -19691,7 +19660,7 @@ class SerializationHelper {
|
|
|
19691
19660
|
}
|
|
19692
19661
|
static serializeObjectProperty(objectProperty, serializedData, level) {
|
|
19693
19662
|
if (level > 14) {
|
|
19694
|
-
console.error('
|
|
19663
|
+
console.error('The nested object layers of the serialized data exceed the maximum limit.');
|
|
19695
19664
|
return;
|
|
19696
19665
|
}
|
|
19697
19666
|
if (!serializedData) {
|
|
@@ -19722,7 +19691,7 @@ class SerializationHelper {
|
|
|
19722
19691
|
}
|
|
19723
19692
|
static serializeArrayProperty(arrayProperty, serializedData, level) {
|
|
19724
19693
|
if (level > 14) {
|
|
19725
|
-
console.error('
|
|
19694
|
+
console.error('The nested object layers of the serialized data exceed the maximum limit.');
|
|
19726
19695
|
return;
|
|
19727
19696
|
}
|
|
19728
19697
|
if (!serializedData) {
|
|
@@ -19764,7 +19733,7 @@ class SerializationHelper {
|
|
|
19764
19733
|
let effectsObject;
|
|
19765
19734
|
const effectsObjectData = this.findData(guid);
|
|
19766
19735
|
if (!effectsObjectData) {
|
|
19767
|
-
console.error(
|
|
19736
|
+
console.error(`Object data with uuid: ${guid} not found.`);
|
|
19768
19737
|
return undefined;
|
|
19769
19738
|
}
|
|
19770
19739
|
switch(effectsObjectData.dataType){
|
|
@@ -19786,7 +19755,7 @@ class SerializationHelper {
|
|
|
19786
19755
|
}
|
|
19787
19756
|
}
|
|
19788
19757
|
if (!effectsObject) {
|
|
19789
|
-
console.error(
|
|
19758
|
+
console.error(`Constructor for DataType: ${effectsObjectData.dataType} not found.`);
|
|
19790
19759
|
return undefined;
|
|
19791
19760
|
}
|
|
19792
19761
|
effectsObject.setInstanceId(effectsObjectData.id);
|
|
@@ -19805,12 +19774,12 @@ class SerializationHelper {
|
|
|
19805
19774
|
const effectsObjectData = _this.findData(guid);
|
|
19806
19775
|
if (!effectsObjectData) {
|
|
19807
19776
|
if (!_this.engine.database) {
|
|
19808
|
-
console.error(
|
|
19777
|
+
console.error(`Object data with uuid: ${guid} not found.`);
|
|
19809
19778
|
return undefined;
|
|
19810
19779
|
}
|
|
19811
19780
|
effectsObject = yield _this.engine.database.loadGUID(guid);
|
|
19812
19781
|
if (!effectsObject) {
|
|
19813
|
-
console.error(
|
|
19782
|
+
console.error(`Disk data with uuid: ${guid} not found.`);
|
|
19814
19783
|
return undefined;
|
|
19815
19784
|
}
|
|
19816
19785
|
_this.engine.addInstance(effectsObject);
|
|
@@ -19835,7 +19804,7 @@ class SerializationHelper {
|
|
|
19835
19804
|
}
|
|
19836
19805
|
}
|
|
19837
19806
|
if (!effectsObject) {
|
|
19838
|
-
console.error(
|
|
19807
|
+
console.error(`Constructor for DataType: ${effectsObjectData.dataType} not found.`);
|
|
19839
19808
|
return undefined;
|
|
19840
19809
|
}
|
|
19841
19810
|
effectsObject.setInstanceId(effectsObjectData.id);
|
|
@@ -21232,7 +21201,7 @@ const standardVersion = /^(\d+)\.(\d+)$/;
|
|
|
21232
21201
|
let reverseParticle = false;
|
|
21233
21202
|
function getStandardJSON(json) {
|
|
21234
21203
|
if (!json || typeof json !== 'object') {
|
|
21235
|
-
throw Error('
|
|
21204
|
+
throw new Error('Invalid input: Expected a JSON object.');
|
|
21236
21205
|
}
|
|
21237
21206
|
// 修正老版本数据中,meshItem 以及 lightItem 结束行为错误问题
|
|
21238
21207
|
version22Migration(json);
|
|
@@ -21253,7 +21222,7 @@ function getStandardJSON(json) {
|
|
|
21253
21222
|
}
|
|
21254
21223
|
return json;
|
|
21255
21224
|
}
|
|
21256
|
-
throw Error(
|
|
21225
|
+
throw new Error(`Invalid JSON version: ${json.version}.`);
|
|
21257
21226
|
}
|
|
21258
21227
|
let currentVersion = '1.0';
|
|
21259
21228
|
function getStandardJSONFromV0(json) {
|
|
@@ -21339,7 +21308,7 @@ function getStandardImage(image, index, imageTags) {
|
|
|
21339
21308
|
} else if (image && image.sourceType) {
|
|
21340
21309
|
return image;
|
|
21341
21310
|
}
|
|
21342
|
-
throw Error('
|
|
21311
|
+
throw new Error('Invalid image type.');
|
|
21343
21312
|
}
|
|
21344
21313
|
function getStandardComposition(composition, opt = {}) {
|
|
21345
21314
|
var _composition_meta;
|
|
@@ -21606,7 +21575,7 @@ function _combineImageTemplate() {
|
|
|
21606
21575
|
image = url;
|
|
21607
21576
|
}
|
|
21608
21577
|
if (!image) {
|
|
21609
|
-
throw new Error('
|
|
21578
|
+
throw new Error('Image not provided.');
|
|
21610
21579
|
}
|
|
21611
21580
|
if (!template) {
|
|
21612
21581
|
return image;
|
|
@@ -21680,7 +21649,7 @@ let seed = 1;
|
|
|
21680
21649
|
cancelLoading = true;
|
|
21681
21650
|
_this.removeTimer(loadTimer);
|
|
21682
21651
|
const totalTime = performance.now() - startTime;
|
|
21683
|
-
reject(new Error(`Load time out: totalTime: ${totalTime.toFixed(4)}ms ${timeInfos.join(' ')}, url: ${assetUrl}
|
|
21652
|
+
reject(new Error(`Load time out: totalTime: ${totalTime.toFixed(4)}ms ${timeInfos.join(' ')}, url: ${assetUrl}.`));
|
|
21684
21653
|
}, _this.timeout * 1000);
|
|
21685
21654
|
_this.timers.push(loadTimer);
|
|
21686
21655
|
});
|
|
@@ -21692,7 +21661,7 @@ let seed = 1;
|
|
|
21692
21661
|
timeInfos.push(`[${label}: ${(performance.now() - st).toFixed(2)}]`);
|
|
21693
21662
|
return result;
|
|
21694
21663
|
} catch (e) {
|
|
21695
|
-
throw new Error(`Load error in ${label}, ${e}
|
|
21664
|
+
throw new Error(`Load error in ${label}, ${e}.`);
|
|
21696
21665
|
}
|
|
21697
21666
|
}
|
|
21698
21667
|
throw new Error('Load canceled.');
|
|
@@ -21763,7 +21732,7 @@ let seed = 1;
|
|
|
21763
21732
|
yield hookTimeInfo('processPlugins', ()=>pluginSystem.loadResources(scene, _this.options));
|
|
21764
21733
|
}
|
|
21765
21734
|
const totalTime = performance.now() - startTime;
|
|
21766
|
-
logger.info(`Load asset: totalTime: ${totalTime.toFixed(4)}ms ${timeInfos.join(' ')}, url: ${assetUrl}
|
|
21735
|
+
logger.info(`Load asset: totalTime: ${totalTime.toFixed(4)}ms ${timeInfos.join(' ')}, url: ${assetUrl}.`);
|
|
21767
21736
|
window.clearTimeout(loadTimer);
|
|
21768
21737
|
_this.removeTimer(loadTimer);
|
|
21769
21738
|
scene.totalTime = totalTime;
|
|
@@ -21835,7 +21804,7 @@ let seed = 1;
|
|
|
21835
21804
|
if (passRenderLevel(bin.renderLevel, renderLevel)) {
|
|
21836
21805
|
return _this.loadBins(new URL(bin.url, baseUrl).href);
|
|
21837
21806
|
}
|
|
21838
|
-
throw new Error(`Invalid bins source: ${JSON.stringify(bins)}
|
|
21807
|
+
throw new Error(`Invalid bins source: ${JSON.stringify(bins)}.`);
|
|
21839
21808
|
});
|
|
21840
21809
|
return Promise.all(jobs);
|
|
21841
21810
|
})();
|
|
@@ -21852,7 +21821,7 @@ let seed = 1;
|
|
|
21852
21821
|
if (font.fontURL && !AssetManager.fonts.has(font.fontFamily)) {
|
|
21853
21822
|
if (!isValidFontFamily(font.fontFamily)) {
|
|
21854
21823
|
// 在所有设备上提醒开发者
|
|
21855
|
-
console.warn(`Risky font family: ${font.fontFamily}
|
|
21824
|
+
console.warn(`Risky font family: ${font.fontFamily}.`);
|
|
21856
21825
|
}
|
|
21857
21826
|
try {
|
|
21858
21827
|
const url = new URL(font.fontURL, _this.baseUrl).href;
|
|
@@ -21864,7 +21833,7 @@ let seed = 1;
|
|
|
21864
21833
|
AssetManager.fonts.add(font.fontFamily);
|
|
21865
21834
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
21866
21835
|
} catch (e) {
|
|
21867
|
-
logger.warn(`Invalid font family or font source: ${JSON.stringify(font.fontURL)}
|
|
21836
|
+
logger.warn(`Invalid font family or font source: ${JSON.stringify(font.fontURL)}.`);
|
|
21868
21837
|
}
|
|
21869
21838
|
}
|
|
21870
21839
|
}));
|
|
@@ -21906,7 +21875,7 @@ let seed = 1;
|
|
|
21906
21875
|
}
|
|
21907
21876
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
21908
21877
|
} catch (e) {
|
|
21909
|
-
throw new Error(`Failed to load. Check the template or if the URL is ${isVideo ? 'video' : 'image'} type, URL: ${url}, Error: ${e.message}
|
|
21878
|
+
throw new Error(`Failed to load. Check the template or if the URL is ${isVideo ? 'video' : 'image'} type, URL: ${url}, Error: ${e.message}.`);
|
|
21910
21879
|
}
|
|
21911
21880
|
}
|
|
21912
21881
|
} else if ('compressed' in img && useCompressedTexture && compressedTexture) {
|
|
@@ -21955,9 +21924,9 @@ let seed = 1;
|
|
|
21955
21924
|
}
|
|
21956
21925
|
if ('mipmaps' in texOpts) {
|
|
21957
21926
|
try {
|
|
21958
|
-
return yield deserializeMipmapTexture(texOpts, bins, jsonScene.bins
|
|
21927
|
+
return yield deserializeMipmapTexture(texOpts, bins, engine, jsonScene.bins);
|
|
21959
21928
|
} catch (e) {
|
|
21960
|
-
throw new Error(`
|
|
21929
|
+
throw new Error(`Load texture ${idx} fails, error message: ${e}.`);
|
|
21961
21930
|
}
|
|
21962
21931
|
}
|
|
21963
21932
|
const { source } = texOpts;
|
|
@@ -21974,7 +21943,7 @@ let seed = 1;
|
|
|
21974
21943
|
tex.dataType = DataType.Texture;
|
|
21975
21944
|
return tex.sourceType === TextureSourceType.compressed ? tex : _extends({}, tex, texOpts);
|
|
21976
21945
|
}
|
|
21977
|
-
throw new Error(`Invalid texture source: ${source}
|
|
21946
|
+
throw new Error(`Invalid texture source: ${source}.`);
|
|
21978
21947
|
}));
|
|
21979
21948
|
return Promise.all(jobs);
|
|
21980
21949
|
})();
|
|
@@ -22085,7 +22054,7 @@ function createTextureOptionsBySource(image, sourceFrom) {
|
|
|
22085
22054
|
magFilter: glContext.NEAREST
|
|
22086
22055
|
};
|
|
22087
22056
|
}
|
|
22088
|
-
throw new Error('Invalid texture options');
|
|
22057
|
+
throw new Error('Invalid texture options.');
|
|
22089
22058
|
}
|
|
22090
22059
|
|
|
22091
22060
|
const tmpScale = new Vector3(1, 1, 1);
|
|
@@ -22392,7 +22361,7 @@ let listOrder = 0;
|
|
|
22392
22361
|
if (itemProps.type === ItemType.composition) {
|
|
22393
22362
|
const refId = sourceItemData.content.options.refId;
|
|
22394
22363
|
if (!this.refCompositions.get(refId)) {
|
|
22395
|
-
throw new Error(
|
|
22364
|
+
throw new Error(`Invalid ref composition id: ${refId}.`);
|
|
22396
22365
|
}
|
|
22397
22366
|
const ref = this.getContent(this.refCompositions.get(refId));
|
|
22398
22367
|
if (!this.refCompositionProps.has(refId)) {
|
|
@@ -22486,7 +22455,7 @@ let listOrder = 0;
|
|
|
22486
22455
|
const { jsonScene, renderLevel, textureOptions, pluginSystem, totalTime } = scene;
|
|
22487
22456
|
const { compositions, imgUsage, compositionId } = jsonScene;
|
|
22488
22457
|
if (!textureOptions) {
|
|
22489
|
-
throw new Error('scene.textures expected');
|
|
22458
|
+
throw new Error('scene.textures expected.');
|
|
22490
22459
|
}
|
|
22491
22460
|
const cachedTextures = textureOptions;
|
|
22492
22461
|
for (const comp of compositions){
|
|
@@ -22497,7 +22466,7 @@ let listOrder = 0;
|
|
|
22497
22466
|
}
|
|
22498
22467
|
}
|
|
22499
22468
|
if (!this.composition) {
|
|
22500
|
-
throw new Error(
|
|
22469
|
+
throw new Error(`Invalid composition id: ${compositionId}.`);
|
|
22501
22470
|
}
|
|
22502
22471
|
this.jsonScene = jsonScene;
|
|
22503
22472
|
this.renderLevel = renderLevel;
|
|
@@ -22867,7 +22836,7 @@ let listOrder = 0;
|
|
|
22867
22836
|
}
|
|
22868
22837
|
parent.children.push(item);
|
|
22869
22838
|
} else {
|
|
22870
|
-
throw Error('
|
|
22839
|
+
throw new Error('The element references a non-existent element, please check the data.');
|
|
22871
22840
|
}
|
|
22872
22841
|
}
|
|
22873
22842
|
}
|
|
@@ -23098,7 +23067,7 @@ let listOrder = 0;
|
|
|
23098
23067
|
* 合成整体在水平方向移动 x 像素,垂直方向移动 y 像素
|
|
23099
23068
|
*/ translateByPixel(x, y) {
|
|
23100
23069
|
if (!this.renderer) {
|
|
23101
|
-
console.warn('
|
|
23070
|
+
console.warn('Renderer not assigned. Operation aborted.');
|
|
23102
23071
|
return;
|
|
23103
23072
|
}
|
|
23104
23073
|
this.rootItem.translateByPixel(x, y);
|
|
@@ -23112,7 +23081,7 @@ let listOrder = 0;
|
|
|
23112
23081
|
* @param y - y 坐标
|
|
23113
23082
|
*/ setPositionByPixel(x, y) {
|
|
23114
23083
|
if (!this.renderer) {
|
|
23115
|
-
console.warn('
|
|
23084
|
+
console.warn('Renderer not assigned. Operation aborted.');
|
|
23116
23085
|
return;
|
|
23117
23086
|
}
|
|
23118
23087
|
this.rootItem.setPositionByPixel(x, y);
|
|
@@ -23199,11 +23168,11 @@ let listOrder = 0;
|
|
|
23199
23168
|
/**
|
|
23200
23169
|
* 销毁状态位
|
|
23201
23170
|
*/ this.destroyed = false;
|
|
23171
|
+
this.postLoaders = [];
|
|
23202
23172
|
/**
|
|
23203
23173
|
* 合成暂停/播放 标识
|
|
23204
23174
|
*/ this.paused = false;
|
|
23205
23175
|
this.lastVideoUpdateTime = 0;
|
|
23206
|
-
this.postLoaders = [];
|
|
23207
23176
|
const { reusable = false, speed = 1, baseRenderOrder = 0, renderer, onPlayerPause, onMessageItem, onEnd, event, width, height } = props;
|
|
23208
23177
|
this.compositionSourceManager = new CompositionSourceManager(scene, renderer.engine);
|
|
23209
23178
|
scene.jsonScene.imgUsage = undefined;
|
|
@@ -23427,7 +23396,7 @@ let listOrder = 0;
|
|
|
23427
23396
|
info.push(`Tex ${this.textures.length}`);
|
|
23428
23397
|
}
|
|
23429
23398
|
if (info.length > 0) {
|
|
23430
|
-
logger.warn(`Release GPU memory: ${info.join(', ')}
|
|
23399
|
+
logger.warn(`Release GPU memory: ${info.join(', ')}.`);
|
|
23431
23400
|
}
|
|
23432
23401
|
this.renderPasses.forEach((pass)=>pass.dispose());
|
|
23433
23402
|
this.meshes.forEach((mesh)=>mesh.dispose());
|
|
@@ -23552,7 +23521,7 @@ let listOrder = 0;
|
|
|
23552
23521
|
* @param ticker - 定时器类
|
|
23553
23522
|
*/ add(ticker) {
|
|
23554
23523
|
if (typeof ticker !== 'function') {
|
|
23555
|
-
throw new Error('
|
|
23524
|
+
throw new Error('The tick object must implement the tick method.');
|
|
23556
23525
|
}
|
|
23557
23526
|
this.tickers.push(ticker);
|
|
23558
23527
|
}
|
|
@@ -23583,5 +23552,5 @@ registerPlugin('particle', ParticleLoader, VFXItem, true);
|
|
|
23583
23552
|
registerPlugin('cal', CalculateLoader, VFXItem, true);
|
|
23584
23553
|
registerPlugin('interact', InteractLoader, VFXItem, true);
|
|
23585
23554
|
|
|
23586
|
-
export { AbstractPlugin, ActivationPlayable, ActivationPlayableAsset, ActivationTrack, AnimationClip, AnimationClipPlayable, AssetLoader, AssetManager, BYTES_TYPE_MAP, Behaviour, BezierCurve, BezierCurvePath, BezierCurveQuat, BinaryAsset, COMPRESSED_TEXTURE, COPY_FRAGMENT_SHADER, COPY_MESH_SHADER_ID, COPY_VERTEX_SHADER, CalculateLoader, Camera, CameraController, CameraVFXItemLoader, Component, Composition, CompositionComponent, CompositionSourceManager, DEFAULT_FONTS, Database, DestroyOptions, Downloader, EFFECTS_COPY_MESH_NAME, EVENT_TYPE_CLICK, EVENT_TYPE_TOUCH_END, EVENT_TYPE_TOUCH_MOVE, EVENT_TYPE_TOUCH_START, EffectComponent, EffectsObject, Engine, EventSystem, FilterMode, Float16ArrayWrapper, Framebuffer, GLSLVersion, GPUCapability, Geometry, GlobalUniforms, GradientValue, HELP_LINK, HitTestType, InteractComponent, InteractLoader, InteractMesh, Item, ItemBehaviour, KTXTexture, LineSegments, LinearValue, Material, MaterialDataBlock, MaterialRenderType, Mesh, ObjectBindingTrack, OrderType, PLAYER_OPTIONS_ENV_EDITOR, POST_PROCESS_SETTINGS, ParticleBehaviourPlayable, ParticleBehaviourPlayableAsset, ParticleLoader, ParticleMesh, ParticleSystem, ParticleSystemRenderer, PassTextureCache, PathSegments, PluginSystem, RENDER_PASS_NAME_PREFIX, RENDER_PREFER_LOOKUP_TEXTURE, RUNTIME_ENV, RandomSetValue, RandomValue, RandomVectorValue, RenderFrame, RenderPass, RenderPassAttachmentStorageType, RenderPassDestroyAttachmentType, RenderPassPriorityNormal, RenderPassPriorityPostprocess, RenderPassPriorityPrepare, RenderTargetHandle, RenderTextureFormat, Renderbuffer, Renderer, RendererComponent, RuntimeClip, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0, SEMANTIC_PRE_COLOR_ATTACHMENT_0, SEMANTIC_PRE_COLOR_ATTACHMENT_SIZE_0, SPRITE_VERTEX_STRIDE, SemanticMap, SerializationHelper, Shader, ShaderCompileResultStatus, ShaderType, ShaderVariant, SpriteColorPlayable, SpriteColorPlayableAsset, SpriteColorTrack, SpriteComponent, SpriteLoader, StaticValue, SubCompositionPlayableAsset, SubCompositionTrack, TEMPLATE_USE_OFFSCREEN_CANVAS, TextComponent, TextLayout, TextLoader, TextStyle, Texture, TextureFactory, TextureLoadAction, TextureSourceType, TextureStoreAction, Ticker, TimelineAsset, TimelineClip, TimelinePlayable, TrackAsset, TrackSortWrapper, TrackType, Transform, TransformAnimationPlayable, TransformPlayableAsset, TransformTrack, VFXItem, ValueGetter, addByOrder, addItem, addItemWithOrder, assertExist, asserts, base64ToFile, blend, calculateTranslation, canvasPool, colorGradingFrag, colorStopsFromGradient, colorToArr$1 as colorToArr, combineImageTemplate, compatible_frag as compatibleFrag, compatible_vert as compatibleVert, createCopyShader, createGLContext, createKeyFrameMeta,
|
|
23555
|
+
export { AbstractPlugin, ActivationPlayable, ActivationPlayableAsset, ActivationTrack, AnimationClip, AnimationClipPlayable, AssetLoader, AssetManager, BYTES_TYPE_MAP, Behaviour, BezierCurve, BezierCurvePath, BezierCurveQuat, BinaryAsset, COMPRESSED_TEXTURE, COPY_FRAGMENT_SHADER, COPY_MESH_SHADER_ID, COPY_VERTEX_SHADER, CalculateLoader, Camera, CameraController, CameraVFXItemLoader, Component, Composition, CompositionComponent, CompositionSourceManager, DEFAULT_FONTS, Database, DestroyOptions, Downloader, EFFECTS_COPY_MESH_NAME, EVENT_TYPE_CLICK, EVENT_TYPE_TOUCH_END, EVENT_TYPE_TOUCH_MOVE, EVENT_TYPE_TOUCH_START, EffectComponent, EffectsObject, Engine, EventSystem, FilterMode, Float16ArrayWrapper, Framebuffer, GLSLVersion, GPUCapability, Geometry, GlobalUniforms, GradientValue, HELP_LINK, HitTestType, InteractComponent, InteractLoader, InteractMesh, Item, ItemBehaviour, KTXTexture, LineSegments, LinearValue, Material, MaterialDataBlock, MaterialRenderType, Mesh, ObjectBindingTrack, OrderType, PLAYER_OPTIONS_ENV_EDITOR, POST_PROCESS_SETTINGS, ParticleBehaviourPlayable, ParticleBehaviourPlayableAsset, ParticleLoader, ParticleMesh, ParticleSystem, ParticleSystemRenderer, PassTextureCache, PathSegments, PluginSystem, RENDER_PASS_NAME_PREFIX, RENDER_PREFER_LOOKUP_TEXTURE, RUNTIME_ENV, RandomSetValue, RandomValue, RandomVectorValue, RenderFrame, RenderPass, RenderPassAttachmentStorageType, RenderPassDestroyAttachmentType, RenderPassPriorityNormal, RenderPassPriorityPostprocess, RenderPassPriorityPrepare, RenderTargetHandle, RenderTextureFormat, Renderbuffer, Renderer, RendererComponent, RuntimeClip, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0, SEMANTIC_PRE_COLOR_ATTACHMENT_0, SEMANTIC_PRE_COLOR_ATTACHMENT_SIZE_0, SPRITE_VERTEX_STRIDE, SemanticMap, SerializationHelper, Shader, ShaderCompileResultStatus, ShaderType, ShaderVariant, SpriteColorPlayable, SpriteColorPlayableAsset, SpriteColorTrack, SpriteComponent, SpriteLoader, StaticValue, SubCompositionPlayableAsset, SubCompositionTrack, TEMPLATE_USE_OFFSCREEN_CANVAS, TextComponent, TextLayout, TextLoader, TextStyle, Texture, TextureFactory, TextureLoadAction, TextureSourceType, TextureStoreAction, Ticker, TimelineAsset, TimelineClip, TimelinePlayable, TrackAsset, TrackSortWrapper, TrackType, Transform, TransformAnimationPlayable, TransformPlayableAsset, TransformTrack, VFXItem, ValueGetter, addByOrder, addItem, addItemWithOrder, assertExist, asserts, base64ToFile, blend, calculateTranslation, canvasPool, colorGradingFrag, colorStopsFromGradient, colorToArr$1 as colorToArr, combineImageTemplate, compatible_frag as compatibleFrag, compatible_vert as compatibleVert, createCopyShader, createGLContext, createKeyFrameMeta, createShaderWithMacros, createShape, createVFXItem, createValueGetter, decimalEqual, defaultGlobalVolume, defaultPlugins, deserializeMipmapTexture, earcut, effectsClass, effectsClassStore, enlargeBuffer, ensureFixedNumber, ensureVec3, findPreviousRenderPass, gaussianDown_frag as gaussianDownFrag, gaussianDownHFrag, gaussianDownVFrag, gaussianUpFrag, generateEmptyTypedArray, generateGUID, generateHalfFloatTexture, generateTransparentTexture, generateWhiteTexture, getBackgroundImage, getColorFromGradientStops, getConfig, getDefaultTemplateCanvasPool, getDefaultTextureFactory, getGeometryByShape, getGeometryTriangles, getImageItemRenderInfo, getKTXTextureOptions, getKeyFrameMetaByRawValue, getMergedStore, getParticleMeshShader, getPixelRatio, getPreMultiAlpha, getStandardComposition, getStandardImage, getStandardItem, getStandardJSON, getTextureSize, glContext, glType2VertexFormatType, gpuTimer, imageDataFromColor, imageDataFromGradient, initErrors, initGLContext, integrate, interpolateColor, isAlipayMiniApp, isAndroid, isArray, isCanvas, isFunction, isIOS, isObject, isSceneJSON, isSceneURL, isSceneWithOptions, isSimulatorCellPhone, isString, isUniformStruct, isUniformStructArray, isValidFontFamily, isWebGL2, itemFrag, itemFrameFrag, itemVert, loadBinary, loadBlob, loadImage, loadMedia, loadVideo, loadWebPOptional, logger, index as math, maxSpriteMeshItemCount, modifyMaxKeyframeShader, nearestPowerOfTwo, noop, normalizeColor, numberToFix, parsePercent$1 as parsePercent, particleFrag, particleOriginTranslateMap$1 as particleOriginTranslateMap, particleUniformTypeMap, particleVert, pluginLoaderMap, pointOnLine, randomInRange, registerPlugin, removeItem, rotateVec2, screenMeshVert, serialize, setBlendMode, setConfig, setDefaultTextureFactory, setMaskMode, setMaxSpriteMeshItemCount, setRayFromCamera, setSideMode, setSpriteMeshMaxItemCountByGPU, sortByOrder, index$1 as spec, spriteMeshShaderFromFilter, spriteMeshShaderFromRenderInfo, spriteMeshShaderIdFromRenderInfo, thresholdFrag, throwDestroyedError, trailVert, translatePoint, trianglesFromRect, unregisterPlugin, valIfUndefined, value, valueDefine, vecAssign, vecFill, vecMulCombine, vecNormalize, vertexFormatType2GLType };
|
|
23587
23556
|
//# sourceMappingURL=index.mjs.map
|