@galacean/effects-core 2.0.0-alpha.16 → 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/comp-vfx-item.d.ts +1 -1
- package/dist/components/component.d.ts +2 -2
- package/dist/components/effect-component.d.ts +1 -1
- package/dist/components/renderer-component.d.ts +1 -1
- package/dist/composition.d.ts +5 -4
- package/dist/constants.d.ts +1 -1
- package/dist/decorators.d.ts +4 -3
- package/dist/effects-object.d.ts +1 -0
- package/dist/fallback/migration.d.ts +3 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +334 -361
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +331 -358
- package/dist/index.mjs.map +1 -1
- package/dist/material/utils.d.ts +3 -3
- package/dist/plugins/cal/calculate-item.d.ts +0 -3
- package/dist/plugins/index.d.ts +1 -2
- package/dist/plugins/interact/interact-item.d.ts +1 -1
- package/dist/plugins/particle/particle-mesh.d.ts +1 -1
- package/dist/plugins/particle/particle-system.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/plugins/text/index.d.ts +4 -0
- package/dist/plugins/timeline/track.d.ts +14 -14
- package/dist/render/shader.d.ts +4 -4
- package/dist/serialization-helper.d.ts +6 -5
- package/dist/shape/shape.d.ts +1 -1
- package/dist/texture/utils.d.ts +1 -1
- package/dist/transform.d.ts +3 -3
- package/dist/utils/index.d.ts +18 -13
- package/dist/vfx-item.d.ts +1 -2
- package/package.json +2 -2
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.18
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
@@ -328,7 +328,6 @@ function isSimulatorCellPhone() {
|
|
|
328
328
|
}
|
|
329
329
|
function isAlipayMiniApp() {
|
|
330
330
|
var _my;
|
|
331
|
-
// @ts-expect-error
|
|
332
331
|
return typeof my !== 'undefined' && ((_my = my) == null ? void 0 : _my.renderTarget) === 'web';
|
|
333
332
|
}
|
|
334
333
|
|
|
@@ -562,8 +561,8 @@ function noop() {}
|
|
|
562
561
|
*
|
|
563
562
|
* @static
|
|
564
563
|
* @function isString
|
|
565
|
-
* @param
|
|
566
|
-
* @return
|
|
564
|
+
* @param obj - 要判断的对象
|
|
565
|
+
* @return
|
|
567
566
|
*/ function isString(obj) {
|
|
568
567
|
return typeof obj === 'string';
|
|
569
568
|
}
|
|
@@ -572,8 +571,8 @@ function noop() {}
|
|
|
572
571
|
*
|
|
573
572
|
* @static
|
|
574
573
|
* @function isArray
|
|
575
|
-
* @param
|
|
576
|
-
* @return
|
|
574
|
+
* @param obj - 要判断的对象
|
|
575
|
+
* @return
|
|
577
576
|
*/ const isArray = Array.isArray || function(obj) {
|
|
578
577
|
return Object.prototype.toString.call(obj) === '[object Array]';
|
|
579
578
|
};
|
|
@@ -582,8 +581,8 @@ function noop() {}
|
|
|
582
581
|
*
|
|
583
582
|
* @static
|
|
584
583
|
* @function isFunction
|
|
585
|
-
* @param
|
|
586
|
-
* @return
|
|
584
|
+
* @param obj - 要判断的对象
|
|
585
|
+
* @return
|
|
587
586
|
*/ function isFunction(obj) {
|
|
588
587
|
return Object.prototype.toString.call(obj) === '[object Function]';
|
|
589
588
|
}
|
|
@@ -592,8 +591,8 @@ function noop() {}
|
|
|
592
591
|
*
|
|
593
592
|
* @static
|
|
594
593
|
* @function isObject
|
|
595
|
-
* @param
|
|
596
|
-
* @return
|
|
594
|
+
* @param obj - 要判断的对象
|
|
595
|
+
* @return
|
|
597
596
|
*/ function isObject(obj) {
|
|
598
597
|
return Object.prototype.toString.call(obj) === '[object Object]';
|
|
599
598
|
}
|
|
@@ -602,29 +601,16 @@ function isCanvas(canvas) {
|
|
|
602
601
|
// 小程序 Canvas 无法使用 instanceof HTMLCanvasElement 判断
|
|
603
602
|
return typeof canvas === 'object' && canvas !== null && ((_canvas_tagName = canvas.tagName) == null ? void 0 : _canvas_tagName.toUpperCase()) === 'CANVAS';
|
|
604
603
|
}
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
}
|
|
612
|
-
const ret = {};
|
|
613
|
-
const kas = Object.keys(obj);
|
|
614
|
-
for(let i = 0; i < kas.length; i++){
|
|
615
|
-
const key = kas[i];
|
|
616
|
-
ret[key] = deepClone(obj[key]);
|
|
617
|
-
}
|
|
618
|
-
return ret;
|
|
619
|
-
}
|
|
620
|
-
return obj;
|
|
621
|
-
}
|
|
622
|
-
// TODO: 改名
|
|
623
|
-
function random(min, max) {
|
|
604
|
+
/**
|
|
605
|
+
* 生成一个位于 min 和 max 之间的随机数
|
|
606
|
+
* @param min
|
|
607
|
+
* @param max
|
|
608
|
+
* @returns
|
|
609
|
+
*/ function randomInRange(min, max) {
|
|
624
610
|
return min + Math.random() * (max - min);
|
|
625
611
|
}
|
|
626
612
|
function throwDestroyedError() {
|
|
627
|
-
throw Error('
|
|
613
|
+
throw new Error('Destroyed item cannot be used again.');
|
|
628
614
|
}
|
|
629
615
|
function generateGUID() {
|
|
630
616
|
return v4().replace(/-/g, '');
|
|
@@ -3860,7 +3846,7 @@ var CameraClipMode;
|
|
|
3860
3846
|
* 蒙版形状切分
|
|
3861
3847
|
*/ ValueType[ValueType["SHAPE_SPLITS"] = 11] = "SHAPE_SPLITS";
|
|
3862
3848
|
/**
|
|
3863
|
-
|
|
3849
|
+
* 直线路径
|
|
3864
3850
|
*/ ValueType[ValueType["LINEAR_PATH"] = 12] = "LINEAR_PATH";
|
|
3865
3851
|
/**
|
|
3866
3852
|
* 多色
|
|
@@ -4036,7 +4022,7 @@ var TextAlignment;
|
|
|
4036
4022
|
(function(TextAlignment) {
|
|
4037
4023
|
/**
|
|
4038
4024
|
* text alignment starts from(x,y) to right direction
|
|
4039
|
-
* 从(x,y)开始第一个字符,向右边延伸
|
|
4025
|
+
* 从 (x,y) 开始第一个字符,向右边延伸
|
|
4040
4026
|
*/ TextAlignment[TextAlignment["left"] = 0] = "left";
|
|
4041
4027
|
/**
|
|
4042
4028
|
* (x,y) is middle position of text, where (left + right)/2 =(x,y)
|
|
@@ -4044,7 +4030,7 @@ var TextAlignment;
|
|
|
4044
4030
|
*/ TextAlignment[TextAlignment["middle"] = 1] = "middle";
|
|
4045
4031
|
/**
|
|
4046
4032
|
* text alignment ends with(x,y) from left direction
|
|
4047
|
-
* 从(x,y)结束最后一个字符,向左边延伸
|
|
4033
|
+
* 从 (x,y) 结束最后一个字符,向左边延伸
|
|
4048
4034
|
*/ TextAlignment[TextAlignment["right"] = 2] = "right";
|
|
4049
4035
|
})(TextAlignment || (TextAlignment = {}));
|
|
4050
4036
|
/**
|
|
@@ -4094,6 +4080,7 @@ var DataType;
|
|
|
4094
4080
|
DataType["TimelineAsset"] = "TimelineAsset";
|
|
4095
4081
|
DataType["TransformPlayableAsset"] = "TransformPlayableAsset";
|
|
4096
4082
|
DataType["SpriteColorPlayableAsset"] = "SpriteColorPlayableAsset";
|
|
4083
|
+
DataType["BinaryAsset"] = "BinaryAsset";
|
|
4097
4084
|
// FIXME: 先完成ECS的场景转换,后面移到spec中
|
|
4098
4085
|
DataType["MeshComponent"] = "MeshComponent";
|
|
4099
4086
|
DataType["SkyboxComponent"] = "SkyboxComponent";
|
|
@@ -4102,6 +4089,7 @@ var DataType;
|
|
|
4102
4089
|
DataType["ModelPluginComponent"] = "ModelPluginComponent";
|
|
4103
4090
|
DataType["TreeComponent"] = "TreeComponent";
|
|
4104
4091
|
DataType["AnimationComponent"] = "AnimationComponent";
|
|
4092
|
+
DataType["SpineComponent"] = "SpineComponent";
|
|
4105
4093
|
// Non-EffectObject
|
|
4106
4094
|
DataType["TimelineClip"] = "TimelineClip";
|
|
4107
4095
|
})(DataType || (DataType = {}));
|
|
@@ -4189,11 +4177,11 @@ var VertexBufferSemantic;
|
|
|
4189
4177
|
VertexBufferSemantic["TangentBS3"] = "TANGENT_BS3";
|
|
4190
4178
|
})(VertexBufferSemantic || (VertexBufferSemantic = {}));
|
|
4191
4179
|
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
|
|
4180
|
+
const BuiltinObjectGUID = {
|
|
4181
|
+
WhiteTexture: 'whitetexture00000000000000000000',
|
|
4182
|
+
PBRShader: 'pbr00000000000000000000000000000',
|
|
4183
|
+
UnlitShader: 'unlit000000000000000000000000000'
|
|
4184
|
+
};
|
|
4197
4185
|
|
|
4198
4186
|
var index$1 = /*#__PURE__*/Object.freeze({
|
|
4199
4187
|
__proto__: null,
|
|
@@ -4249,15 +4237,20 @@ var index$1 = /*#__PURE__*/Object.freeze({
|
|
|
4249
4237
|
BuiltinObjectGUID: BuiltinObjectGUID
|
|
4250
4238
|
});
|
|
4251
4239
|
|
|
4252
|
-
const effectsClassStore = {};
|
|
4253
4240
|
const decoratorInitialStore = {};
|
|
4254
4241
|
const mergedStore = {};
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4242
|
+
const effectsClassStore = {};
|
|
4243
|
+
function effectsClass(className) {
|
|
4244
|
+
return (target, context)=>{
|
|
4245
|
+
if (effectsClassStore[className]) {
|
|
4246
|
+
console.warn(`Class ${className} is already registered.`);
|
|
4247
|
+
}
|
|
4248
|
+
// TODO: three修改json dataType, 这边重复注册直接 return
|
|
4249
|
+
effectsClassStore[className] = target;
|
|
4250
|
+
};
|
|
4251
|
+
}
|
|
4252
|
+
function serialize(type, sourceName) {
|
|
4253
|
+
return generateSerializableMember(type, sourceName); // value member
|
|
4261
4254
|
}
|
|
4262
4255
|
function getMergedStore(target) {
|
|
4263
4256
|
const classKey = target.constructor.name;
|
|
@@ -4282,34 +4275,32 @@ function getMergedStore(target) {
|
|
|
4282
4275
|
}
|
|
4283
4276
|
return store;
|
|
4284
4277
|
}
|
|
4285
|
-
function serialize(type, sourceName) {
|
|
4286
|
-
return generateSerializableMember(type, sourceName); // value member
|
|
4287
|
-
}
|
|
4288
|
-
function effectsClass(className) {
|
|
4289
|
-
return (target, context)=>{
|
|
4290
|
-
if (effectsClassStore[className]) {
|
|
4291
|
-
console.warn('Class ' + className + ' 重复注册');
|
|
4292
|
-
}
|
|
4293
|
-
//TODO: three修改json dataType, 这边重复注册直接 return
|
|
4294
|
-
effectsClassStore[className] = target;
|
|
4295
|
-
};
|
|
4296
|
-
}
|
|
4297
4278
|
function generateSerializableMember(type, sourceName) {
|
|
4298
4279
|
return (target, propertyKey)=>{
|
|
4299
4280
|
const classStore = getDirectStore(target);
|
|
4300
4281
|
if (!classStore[propertyKey]) {
|
|
4301
4282
|
classStore[propertyKey] = {
|
|
4302
|
-
type
|
|
4303
|
-
sourceName
|
|
4283
|
+
type,
|
|
4284
|
+
sourceName
|
|
4304
4285
|
};
|
|
4305
4286
|
}
|
|
4306
4287
|
};
|
|
4307
4288
|
}
|
|
4289
|
+
function getDirectStore(target) {
|
|
4290
|
+
const classKey = target.constructor.name;
|
|
4291
|
+
if (!decoratorInitialStore[classKey]) {
|
|
4292
|
+
decoratorInitialStore[classKey] = {};
|
|
4293
|
+
}
|
|
4294
|
+
return decoratorInitialStore[classKey];
|
|
4295
|
+
}
|
|
4308
4296
|
|
|
4309
4297
|
/**
|
|
4310
4298
|
* @since 2.0.0
|
|
4311
4299
|
* @internal
|
|
4312
4300
|
*/ class EffectsObject {
|
|
4301
|
+
static is(obj) {
|
|
4302
|
+
return obj instanceof EffectsObject && 'guid' in obj;
|
|
4303
|
+
}
|
|
4313
4304
|
getInstanceId() {
|
|
4314
4305
|
return this.guid;
|
|
4315
4306
|
}
|
|
@@ -4505,6 +4496,7 @@ __decorate([
|
|
|
4505
4496
|
super(...args);
|
|
4506
4497
|
this.started = false;
|
|
4507
4498
|
this.materials = [];
|
|
4499
|
+
this._priority = 0;
|
|
4508
4500
|
this._enabled = true;
|
|
4509
4501
|
}
|
|
4510
4502
|
}
|
|
@@ -7032,8 +7024,8 @@ const SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0 = 'PRE_MAIN_COLOR_0';
|
|
|
7032
7024
|
const SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0 = 'PRE_MAIN_COLOR_SIZE_0';
|
|
7033
7025
|
const PLAYER_OPTIONS_ENV_EDITOR = 'editor';
|
|
7034
7026
|
const HELP_LINK = {
|
|
7035
|
-
'
|
|
7036
|
-
'
|
|
7027
|
+
'Item duration can\'t be less than 0': 'https://galacean.antgroup.com/effects/user/gasrv4ka5sacrwpg#AOnQS',
|
|
7028
|
+
'ValueType: 21/22 is not supported': 'https://galacean.antgroup.com/effects/user/gasrv4ka5sacrwpg#smO1b'
|
|
7037
7029
|
};
|
|
7038
7030
|
|
|
7039
7031
|
/**
|
|
@@ -7214,17 +7206,17 @@ const downgradeKeywords = {
|
|
|
7214
7206
|
};
|
|
7215
7207
|
/**
|
|
7216
7208
|
* 生成 shader,检测到 WebGL1 上下文会降级
|
|
7217
|
-
* @param
|
|
7209
|
+
* @param macros - 宏定义数组
|
|
7218
7210
|
* @param shader - 原始 shader 文本
|
|
7219
7211
|
* @param shaderType - shader 类型
|
|
7220
7212
|
* @return 去除版本号的 shader 文本
|
|
7221
|
-
*/ function
|
|
7213
|
+
*/ function createShaderWithMacros(macros, shader, shaderType, level) {
|
|
7222
7214
|
const ret = [];
|
|
7223
7215
|
let header = '';
|
|
7224
7216
|
// shader 标志宏,没有其他含义,方便不支持完全的自定义 shader 的三方引擎接入使用
|
|
7225
7217
|
ret.push('#define GE_RUNTIME');
|
|
7226
|
-
if (
|
|
7227
|
-
|
|
7218
|
+
if (macros) {
|
|
7219
|
+
macros.forEach(([key, value])=>{
|
|
7228
7220
|
if (value === true) {
|
|
7229
7221
|
ret.push(`#define ${key}`);
|
|
7230
7222
|
} else if (Number.isFinite(value)) {
|
|
@@ -7335,7 +7327,7 @@ function setBlendMode(material, blendMode) {
|
|
|
7335
7327
|
];
|
|
7336
7328
|
break;
|
|
7337
7329
|
default:
|
|
7338
|
-
console.warn(`
|
|
7330
|
+
console.warn(`BlendMode ${blendMode} not in specification, please set blend params separately.`);
|
|
7339
7331
|
}
|
|
7340
7332
|
}
|
|
7341
7333
|
function setSideMode(material, side) {
|
|
@@ -7381,7 +7373,7 @@ function setMaskMode(material, maskMode) {
|
|
|
7381
7373
|
material.stencilTest = false;
|
|
7382
7374
|
break;
|
|
7383
7375
|
default:
|
|
7384
|
-
console.warn(`
|
|
7376
|
+
console.warn(`MaskMode ${maskMode} not in specification, please set stencil params seperately.`);
|
|
7385
7377
|
}
|
|
7386
7378
|
}
|
|
7387
7379
|
|
|
@@ -7553,7 +7545,7 @@ function _loadImage() {
|
|
|
7553
7545
|
}
|
|
7554
7546
|
// 2. 非法类型
|
|
7555
7547
|
if (!url) {
|
|
7556
|
-
throw new Error(`Invalid url type: ${JSON.stringify(source)}
|
|
7548
|
+
throw new Error(`Invalid url type: ${JSON.stringify(source)}.`);
|
|
7557
7549
|
}
|
|
7558
7550
|
return new Promise((resolve, reject)=>{
|
|
7559
7551
|
const img = new Image();
|
|
@@ -7666,13 +7658,13 @@ function _loadMedia() {
|
|
|
7666
7658
|
return _loadMedia.apply(this, arguments);
|
|
7667
7659
|
}
|
|
7668
7660
|
|
|
7669
|
-
function deserializeMipmapTexture(
|
|
7661
|
+
function deserializeMipmapTexture(textureOptions, bins, engine) {
|
|
7670
7662
|
return _deserializeMipmapTexture.apply(this, arguments);
|
|
7671
7663
|
}
|
|
7672
7664
|
function _deserializeMipmapTexture() {
|
|
7673
|
-
_deserializeMipmapTexture = _async_to_generator(function*(
|
|
7674
|
-
if (
|
|
7675
|
-
const { mipmaps, target } =
|
|
7665
|
+
_deserializeMipmapTexture = _async_to_generator(function*(textureOptions, bins, engine, files = []) {
|
|
7666
|
+
if (textureOptions.target === 34067) {
|
|
7667
|
+
const { mipmaps, target } = textureOptions;
|
|
7676
7668
|
// const jobs = mipmaps.map(mipmap => Promise.all(mipmap.map(pointer => loadMipmapImage(pointer, bins))));
|
|
7677
7669
|
const loadedMipmaps = [];
|
|
7678
7670
|
for (const level of mipmaps){
|
|
@@ -7688,7 +7680,7 @@ function _deserializeMipmapTexture() {
|
|
|
7688
7680
|
// const bin = files[mipmaps[0][0][1][0]].url;
|
|
7689
7681
|
return _extends({
|
|
7690
7682
|
keepImageSource: false
|
|
7691
|
-
},
|
|
7683
|
+
}, textureOptions, {
|
|
7692
7684
|
mipmaps: loadedMipmaps,
|
|
7693
7685
|
sourceFrom: {
|
|
7694
7686
|
target,
|
|
@@ -7698,13 +7690,13 @@ function _deserializeMipmapTexture() {
|
|
|
7698
7690
|
});
|
|
7699
7691
|
} else {
|
|
7700
7692
|
// TODO: 补充测试用例
|
|
7701
|
-
const { mipmaps, target } =
|
|
7693
|
+
const { mipmaps, target } = textureOptions;
|
|
7702
7694
|
const jobs = mipmaps.map((pointer)=>loadMipmapImage(pointer, bins));
|
|
7703
7695
|
const loadedMipmaps = yield Promise.all(jobs);
|
|
7704
7696
|
const bin = files[mipmaps[0][1][0]].url;
|
|
7705
7697
|
return _extends({
|
|
7706
7698
|
keepImageSource: false
|
|
7707
|
-
},
|
|
7699
|
+
}, textureOptions, {
|
|
7708
7700
|
mipmaps: loadedMipmaps,
|
|
7709
7701
|
sourceType: exports.TextureSourceType.mipmaps,
|
|
7710
7702
|
sourceFrom: {
|
|
@@ -7729,7 +7721,7 @@ function _loadMipmapImage() {
|
|
|
7729
7721
|
const [index, start, length] = pointer[1];
|
|
7730
7722
|
const bin = bins[index];
|
|
7731
7723
|
if (!bin) {
|
|
7732
|
-
throw new Error(`
|
|
7724
|
+
throw new Error(`Invalid bin pointer: ${JSON.stringify(pointer)}.`);
|
|
7733
7725
|
}
|
|
7734
7726
|
return loadImage(new Blob([
|
|
7735
7727
|
new Uint8Array(bin, start, length)
|
|
@@ -7928,7 +7920,7 @@ class KTXTexture {
|
|
|
7928
7920
|
// 0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A
|
|
7929
7921
|
const identifier = new Uint8Array(this.arrayBuffer, this.baseOffset, 12);
|
|
7930
7922
|
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) {
|
|
7931
|
-
throw Error('
|
|
7923
|
+
throw new Error('Texture missing KTX identifier.');
|
|
7932
7924
|
}
|
|
7933
7925
|
// load the reset of the header in native 32 bit uint
|
|
7934
7926
|
const dataSize = Uint32Array.BYTES_PER_ELEMENT;
|
|
@@ -7950,15 +7942,15 @@ class KTXTexture {
|
|
|
7950
7942
|
// value of zero is an indication to generate mipmaps @ runtime. Not usually allowed for compressed, so disregard.
|
|
7951
7943
|
this.numberOfMipmapLevels = Math.max(1, this.numberOfMipmapLevels);
|
|
7952
7944
|
if (this.pixelHeight === 0 || this.pixelDepth !== 0) {
|
|
7953
|
-
logger.warn('Only 2D textures currently supported');
|
|
7945
|
+
logger.warn('Only 2D textures currently supported.');
|
|
7954
7946
|
return;
|
|
7955
7947
|
}
|
|
7956
7948
|
if (this.numberOfArrayElements !== 0) {
|
|
7957
|
-
logger.warn('Texture arrays not currently supported');
|
|
7949
|
+
logger.warn('Texture arrays not currently supported.');
|
|
7958
7950
|
return;
|
|
7959
7951
|
}
|
|
7960
7952
|
if (this.numberOfFaces !== facesExpected) {
|
|
7961
|
-
logger.warn(
|
|
7953
|
+
logger.warn(`Number of faces expected ${facesExpected}, but found ${this.numberOfFaces}.`);
|
|
7962
7954
|
return;
|
|
7963
7955
|
}
|
|
7964
7956
|
// we now have a completely validated file, so could use existence of loadType as success
|
|
@@ -7998,7 +7990,7 @@ class TextureFactory {
|
|
|
7998
7990
|
texture.updateSource(sourceOpts);
|
|
7999
7991
|
_this.reloadPending[id] = false;
|
|
8000
7992
|
} else {
|
|
8001
|
-
throw new Error('No source from');
|
|
7993
|
+
throw new Error('No source from.');
|
|
8002
7994
|
}
|
|
8003
7995
|
})();
|
|
8004
7996
|
}
|
|
@@ -8125,7 +8117,7 @@ class TextureFactory {
|
|
|
8125
8117
|
});
|
|
8126
8118
|
}
|
|
8127
8119
|
}
|
|
8128
|
-
throw new Error(`Invalid resource type: ${type}
|
|
8120
|
+
throw new Error(`Invalid resource type: ${type}.`);
|
|
8129
8121
|
})();
|
|
8130
8122
|
}
|
|
8131
8123
|
loadMipmapImages(pointers, bin) {
|
|
@@ -8941,19 +8933,19 @@ function buildEasingCurve(leftKeyframe, rightKeyframe) {
|
|
|
8941
8933
|
y2 = numberToFix((p2.y - p0.y) / valueInterval, 5);
|
|
8942
8934
|
}
|
|
8943
8935
|
if (x1 < 0) {
|
|
8944
|
-
console.error('
|
|
8936
|
+
console.error('Invalid bezier points, x1 < 0', p0, p1, p2, p3);
|
|
8945
8937
|
x1 = 0;
|
|
8946
8938
|
}
|
|
8947
8939
|
if (x2 < 0) {
|
|
8948
|
-
console.error('
|
|
8940
|
+
console.error('Invalid bezier points, x2 < 0', p0, p1, p2, p3);
|
|
8949
8941
|
x2 = 0;
|
|
8950
8942
|
}
|
|
8951
8943
|
if (x1 > 1) {
|
|
8952
|
-
console.error('
|
|
8944
|
+
console.error('Invalid bezier points, x1 >= 1', p0, p1, p2, p3);
|
|
8953
8945
|
x1 = 1;
|
|
8954
8946
|
}
|
|
8955
8947
|
if (x2 > 1) {
|
|
8956
|
-
console.error('
|
|
8948
|
+
console.error('Invalid bezier points, x2 >= 1', p0, p1, p2, p3);
|
|
8957
8949
|
x2 = 1;
|
|
8958
8950
|
}
|
|
8959
8951
|
const str = ('bez_' + x1 + '_' + y1 + '_' + x2 + '_' + y2).replace(/\./g, 'p');
|
|
@@ -9137,31 +9129,31 @@ class ValueGetter {
|
|
|
9137
9129
|
return halfFloat ? ret.data : ret;
|
|
9138
9130
|
}
|
|
9139
9131
|
onCreate(props) {
|
|
9140
|
-
throw Error(NOT_IMPLEMENT);
|
|
9132
|
+
throw new Error(NOT_IMPLEMENT);
|
|
9141
9133
|
}
|
|
9142
9134
|
getIntegrateValue(t0, t1, timeScale = 1) {
|
|
9143
|
-
throw Error(NOT_IMPLEMENT);
|
|
9135
|
+
throw new Error(NOT_IMPLEMENT);
|
|
9144
9136
|
}
|
|
9145
9137
|
getIntegrateByTime(t0, time) {
|
|
9146
|
-
throw Error(NOT_IMPLEMENT);
|
|
9138
|
+
throw new Error(NOT_IMPLEMENT);
|
|
9147
9139
|
}
|
|
9148
9140
|
getValue(time) {
|
|
9149
|
-
throw Error(NOT_IMPLEMENT);
|
|
9141
|
+
throw new Error(NOT_IMPLEMENT);
|
|
9150
9142
|
}
|
|
9151
9143
|
getMaxTime() {
|
|
9152
|
-
throw Error(NOT_IMPLEMENT);
|
|
9144
|
+
throw new Error(NOT_IMPLEMENT);
|
|
9153
9145
|
}
|
|
9154
9146
|
toUniform(meta) {
|
|
9155
|
-
throw Error(NOT_IMPLEMENT);
|
|
9147
|
+
throw new Error(NOT_IMPLEMENT);
|
|
9156
9148
|
}
|
|
9157
9149
|
map(func) {
|
|
9158
|
-
throw Error(NOT_IMPLEMENT);
|
|
9150
|
+
throw new Error(NOT_IMPLEMENT);
|
|
9159
9151
|
}
|
|
9160
9152
|
scaleXCoord(scale) {
|
|
9161
9153
|
return this;
|
|
9162
9154
|
}
|
|
9163
9155
|
toData() {
|
|
9164
|
-
throw Error(NOT_IMPLEMENT);
|
|
9156
|
+
throw new Error(NOT_IMPLEMENT);
|
|
9165
9157
|
}
|
|
9166
9158
|
constructor(arg){
|
|
9167
9159
|
this.onCreate(arg);
|
|
@@ -9213,7 +9205,7 @@ class RandomValue extends ValueGetter {
|
|
|
9213
9205
|
this.max = props[1];
|
|
9214
9206
|
}
|
|
9215
9207
|
getValue(time) {
|
|
9216
|
-
return
|
|
9208
|
+
return randomInRange(this.min, this.max);
|
|
9217
9209
|
}
|
|
9218
9210
|
toUniform() {
|
|
9219
9211
|
return new Float32Array([
|
|
@@ -9793,7 +9785,7 @@ function createValueGetter(args) {
|
|
|
9793
9785
|
if (isFunction(map$1[args[0]])) {
|
|
9794
9786
|
return map$1[args[0]](args[1]);
|
|
9795
9787
|
} else {
|
|
9796
|
-
throw new Error(`ValueType: ${args[0]} is not
|
|
9788
|
+
throw new Error(`ValueType: ${args[0]} is not supported, see ${HELP_LINK['ValueType: 21/22 is not supported']}.`);
|
|
9797
9789
|
}
|
|
9798
9790
|
}
|
|
9799
9791
|
function lineSegIntegrate(t, t0, t1, y0, y1) {
|
|
@@ -9967,7 +9959,7 @@ function createCopyShader(level, writeDepth) {
|
|
|
9967
9959
|
vertex: version + '\n' + COPY_VERTEX_SHADER,
|
|
9968
9960
|
fragment: version + '\n' + COPY_FRAGMENT_SHADER,
|
|
9969
9961
|
glslVersion: webgl2 ? exports.GLSLVersion.GLSL3 : exports.GLSLVersion.GLSL1,
|
|
9970
|
-
|
|
9962
|
+
macros: [
|
|
9971
9963
|
[
|
|
9972
9964
|
'WEBGL2',
|
|
9973
9965
|
!!webgl2
|
|
@@ -10031,7 +10023,7 @@ class PassTextureCache {
|
|
|
10031
10023
|
const refCount = this.textureRef[id];
|
|
10032
10024
|
if (refCount <= 1) {
|
|
10033
10025
|
if (refCount < 0) {
|
|
10034
|
-
console.error('
|
|
10026
|
+
console.error('Ref count < 0.');
|
|
10035
10027
|
}
|
|
10036
10028
|
const tex = this.textureCache[id];
|
|
10037
10029
|
if (tex) {
|
|
@@ -10645,21 +10637,21 @@ let seed$6 = 1;
|
|
|
10645
10637
|
}
|
|
10646
10638
|
}
|
|
10647
10639
|
|
|
10648
|
-
var blend = "vec4 blendColor(vec4 color,vec4 vc,float mode){vec4 ret=color*vc
|
|
10640
|
+
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;}";
|
|
10649
10641
|
|
|
10650
10642
|
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";
|
|
10651
10643
|
|
|
10652
10644
|
var compatible_vert = "#version 300 es\n#ifdef WEBGL2\n#define texture2D texture\n#else\n#endif\n";
|
|
10653
10645
|
|
|
10654
|
-
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
|
|
10646
|
+
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);}";
|
|
10655
10647
|
|
|
10656
10648
|
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.;}";
|
|
10657
10649
|
|
|
10658
10650
|
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}";
|
|
10659
10651
|
|
|
10660
|
-
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
|
|
10652
|
+
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;}";
|
|
10661
10653
|
|
|
10662
|
-
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
|
|
10654
|
+
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";
|
|
10663
10655
|
|
|
10664
10656
|
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}}";
|
|
10665
10657
|
|
|
@@ -11806,20 +11798,20 @@ class GPUCapability {
|
|
|
11806
11798
|
framebufferTexture2D(gl, target, index, textarget, texture) {
|
|
11807
11799
|
const ext = this.drawBufferExtension;
|
|
11808
11800
|
if (this.level === 1 && !ext && index > 0) {
|
|
11809
|
-
throw new Error('
|
|
11801
|
+
throw new Error('Draw multiple color buffers not available.');
|
|
11810
11802
|
}
|
|
11811
11803
|
const attachment = ext ? ext[`COLOR_ATTACHMENT${index}_WEBGL`] : gl[`COLOR_ATTACHMENT${index}`];
|
|
11812
11804
|
if (attachment) {
|
|
11813
11805
|
gl.framebufferTexture2D(target, attachment, textarget, texture, 0);
|
|
11814
11806
|
} else {
|
|
11815
|
-
console.error(
|
|
11807
|
+
console.error(`Invalid color attachment index: ${index}.`);
|
|
11816
11808
|
}
|
|
11817
11809
|
}
|
|
11818
11810
|
drawBuffers(gl, bufferStates) {
|
|
11819
11811
|
const ext = this.drawBufferExtension;
|
|
11820
11812
|
if (this.level === 1 && !ext) {
|
|
11821
11813
|
if (bufferStates.length > 1) {
|
|
11822
|
-
throw Error('
|
|
11814
|
+
throw new Error('Draw buffers not available.');
|
|
11823
11815
|
} else {
|
|
11824
11816
|
return;
|
|
11825
11817
|
}
|
|
@@ -12079,7 +12071,7 @@ class InteractMesh {
|
|
|
12079
12071
|
}
|
|
12080
12072
|
createMaterial(rendererOptions) {
|
|
12081
12073
|
var _this_engine_renderer;
|
|
12082
|
-
const
|
|
12074
|
+
const macros = [
|
|
12083
12075
|
[
|
|
12084
12076
|
'ENV_EDITOR',
|
|
12085
12077
|
((_this_engine_renderer = this.engine.renderer) == null ? void 0 : _this_engine_renderer.env) === PLAYER_OPTIONS_ENV_EDITOR
|
|
@@ -12092,7 +12084,7 @@ class InteractMesh {
|
|
|
12092
12084
|
fragment,
|
|
12093
12085
|
glslVersion: exports.GLSLVersion.GLSL1,
|
|
12094
12086
|
cacheId: `${rendererOptions.cachePrefix}_effects_interact`,
|
|
12095
|
-
|
|
12087
|
+
macros
|
|
12096
12088
|
},
|
|
12097
12089
|
uniformSemantics: {
|
|
12098
12090
|
effects_MatrixVP: 'VIEWPROJECTION',
|
|
@@ -12357,16 +12349,12 @@ function shouldIgnoreBouncing(arg, mul) {
|
|
|
12357
12349
|
}
|
|
12358
12350
|
|
|
12359
12351
|
exports.maxSpriteMeshItemCount = 8;
|
|
12360
|
-
exports.maxSpriteTextureCount = 8;
|
|
12361
12352
|
function setSpriteMeshMaxItemCountByGPU(gpuCapability) {
|
|
12362
|
-
// 8 or 16
|
|
12363
|
-
exports.maxSpriteTextureCount = Math.min(gpuCapability.maxFragmentTextures, 16);
|
|
12364
12353
|
if (gpuCapability.maxVertexUniforms >= 256) {
|
|
12365
12354
|
return exports.maxSpriteMeshItemCount = 32;
|
|
12366
12355
|
} else if (gpuCapability.maxVertexUniforms >= 128) {
|
|
12367
12356
|
return exports.maxSpriteMeshItemCount = 16;
|
|
12368
12357
|
}
|
|
12369
|
-
exports.maxSpriteTextureCount = 8;
|
|
12370
12358
|
}
|
|
12371
12359
|
function getImageItemRenderInfo(item) {
|
|
12372
12360
|
const { renderer } = item;
|
|
@@ -12384,27 +12372,11 @@ function getImageItemRenderInfo(item) {
|
|
|
12384
12372
|
};
|
|
12385
12373
|
}
|
|
12386
12374
|
function spriteMeshShaderFromFilter(level, options) {
|
|
12387
|
-
const {
|
|
12388
|
-
const
|
|
12389
|
-
[
|
|
12390
|
-
'MAX_ITEM_COUNT',
|
|
12391
|
-
count
|
|
12392
|
-
],
|
|
12393
|
-
[
|
|
12394
|
-
'PRE_MULTIPLY_ALPHA',
|
|
12395
|
-
false
|
|
12396
|
-
],
|
|
12375
|
+
const { env = '', wireframe } = options != null ? options : {};
|
|
12376
|
+
const macros = [
|
|
12397
12377
|
[
|
|
12398
12378
|
'ENV_EDITOR',
|
|
12399
12379
|
env === PLAYER_OPTIONS_ENV_EDITOR
|
|
12400
|
-
],
|
|
12401
|
-
[
|
|
12402
|
-
'USE_BLEND',
|
|
12403
|
-
!ignoreBlend
|
|
12404
|
-
],
|
|
12405
|
-
[
|
|
12406
|
-
'MAX_FRAG_TEX',
|
|
12407
|
-
exports.maxSpriteTextureCount >= 16 ? 16 : 8
|
|
12408
12380
|
]
|
|
12409
12381
|
];
|
|
12410
12382
|
const fragment = wireframe ? itemFrameFrag : itemFrag;
|
|
@@ -12413,7 +12385,7 @@ function spriteMeshShaderFromFilter(level, options) {
|
|
|
12413
12385
|
fragment,
|
|
12414
12386
|
vertex,
|
|
12415
12387
|
glslVersion: level === 1 ? exports.GLSLVersion.GLSL1 : exports.GLSLVersion.GLSL3,
|
|
12416
|
-
|
|
12388
|
+
macros,
|
|
12417
12389
|
shared: true
|
|
12418
12390
|
};
|
|
12419
12391
|
}
|
|
@@ -12423,7 +12395,6 @@ function spriteMeshShaderIdFromRenderInfo(renderInfo, count) {
|
|
|
12423
12395
|
function spriteMeshShaderFromRenderInfo(renderInfo, count, level, env) {
|
|
12424
12396
|
const { wireframe } = renderInfo;
|
|
12425
12397
|
const shader = spriteMeshShaderFromFilter(level, {
|
|
12426
|
-
count,
|
|
12427
12398
|
wireframe,
|
|
12428
12399
|
env
|
|
12429
12400
|
});
|
|
@@ -12437,9 +12408,6 @@ function spriteMeshShaderFromRenderInfo(renderInfo, count, level, env) {
|
|
|
12437
12408
|
function setMaxSpriteMeshItemCount(count) {
|
|
12438
12409
|
exports.maxSpriteMeshItemCount = count;
|
|
12439
12410
|
}
|
|
12440
|
-
function setSpriteMeshMaxFragmentTextures(count) {
|
|
12441
|
-
exports.maxSpriteTextureCount = count;
|
|
12442
|
-
}
|
|
12443
12411
|
|
|
12444
12412
|
const defRenderInfo = {
|
|
12445
12413
|
blending: 0,
|
|
@@ -13783,7 +13751,7 @@ class Cone {
|
|
|
13783
13751
|
// dir + [0,0,1]
|
|
13784
13752
|
dir.z += 1;
|
|
13785
13753
|
return {
|
|
13786
|
-
position: position.multiply(
|
|
13754
|
+
position: position.multiply(randomInRange(0, 1)),
|
|
13787
13755
|
direction: dir.normalize()
|
|
13788
13756
|
};
|
|
13789
13757
|
}
|
|
@@ -13795,7 +13763,7 @@ class Cone {
|
|
|
13795
13763
|
}
|
|
13796
13764
|
function getArcAngle(arc, arcMode, opt) {
|
|
13797
13765
|
if (arcMode === ShapeArcMode.RANDOM) {
|
|
13798
|
-
arc =
|
|
13766
|
+
arc = randomInRange(0, arc);
|
|
13799
13767
|
} else if (arcMode === ShapeArcMode.UNIDIRECTIONAL_CYCLE) {
|
|
13800
13768
|
const d = opt.index % (opt.total + 1);
|
|
13801
13769
|
arc = arc / opt.total * d;
|
|
@@ -13827,8 +13795,8 @@ class Circle {
|
|
|
13827
13795
|
}
|
|
13828
13796
|
class Rectangle {
|
|
13829
13797
|
generate(opt) {
|
|
13830
|
-
const x =
|
|
13831
|
-
const y =
|
|
13798
|
+
const x = randomInRange(-this._d, this._d);
|
|
13799
|
+
const y = randomInRange(-this._h, this._h);
|
|
13832
13800
|
return {
|
|
13833
13801
|
direction: new Vector3(0, 0, 1),
|
|
13834
13802
|
position: new Vector3(x, y, 0)
|
|
@@ -13873,7 +13841,7 @@ class RectangleEdge {
|
|
|
13873
13841
|
}
|
|
13874
13842
|
class Edge {
|
|
13875
13843
|
generate(options) {
|
|
13876
|
-
const x = this.arcMode === ShapeArcMode.UNIFORM_BURST ? options.burstIndex % options.burstCount / (options.burstCount - 1) :
|
|
13844
|
+
const x = this.arcMode === ShapeArcMode.UNIFORM_BURST ? options.burstIndex % options.burstCount / (options.burstCount - 1) : randomInRange(0, 1);
|
|
13877
13845
|
return {
|
|
13878
13846
|
direction: new Vector3(0, 1, 0),
|
|
13879
13847
|
position: new Vector3(this._d * (x - 0.5), 0, 0)
|
|
@@ -13891,7 +13859,7 @@ class Donut {
|
|
|
13891
13859
|
generate(opt) {
|
|
13892
13860
|
const dradius = this.donutRadius;
|
|
13893
13861
|
const center = this.radius - dradius;
|
|
13894
|
-
const angle =
|
|
13862
|
+
const angle = randomInRange(0, Math.PI * 2);
|
|
13895
13863
|
const arc = getArcAngle(this.arc, this.arcMode, opt) * DEG2RAD;
|
|
13896
13864
|
const rot = tempMat4$2.setFromRotationZ(arc);
|
|
13897
13865
|
const direction = new Vector3(Math.cos(angle), Math.sin(angle), 0);
|
|
@@ -13911,7 +13879,7 @@ class Donut {
|
|
|
13911
13879
|
const tempMat4$1 = new Matrix4();
|
|
13912
13880
|
class Sphere {
|
|
13913
13881
|
getHorizontalAngle() {
|
|
13914
|
-
return
|
|
13882
|
+
return randomInRange(-90, 90);
|
|
13915
13883
|
}
|
|
13916
13884
|
generate(opt) {
|
|
13917
13885
|
const rz = getArcAngle(this.arc, this.arcMode, opt) * DEG2RAD;
|
|
@@ -13933,7 +13901,7 @@ class Sphere {
|
|
|
13933
13901
|
}
|
|
13934
13902
|
class Hemisphere extends Sphere {
|
|
13935
13903
|
getHorizontalAngle() {
|
|
13936
|
-
return
|
|
13904
|
+
return randomInRange(0, 90);
|
|
13937
13905
|
}
|
|
13938
13906
|
}
|
|
13939
13907
|
|
|
@@ -14003,7 +13971,7 @@ function createShape(shapeOptions) {
|
|
|
14003
13971
|
const { type } = shapeOptions;
|
|
14004
13972
|
const Ctrl = map[type];
|
|
14005
13973
|
if (!Ctrl) {
|
|
14006
|
-
throw Error(
|
|
13974
|
+
throw new Error(`Invalid shape: ${type}.`);
|
|
14007
13975
|
}
|
|
14008
13976
|
const ctrl = new Ctrl(options);
|
|
14009
13977
|
if (type !== ShapeType.NONE) {
|
|
@@ -14972,7 +14940,7 @@ class TrailMesh {
|
|
|
14972
14940
|
const uniformValues = {};
|
|
14973
14941
|
// const lookUpTexture = getConfig(RENDER_PREFER_LOOKUP_TEXTURE) ? 1 : 0;
|
|
14974
14942
|
const lookUpTexture = 0;
|
|
14975
|
-
const
|
|
14943
|
+
const macros = [
|
|
14976
14944
|
[
|
|
14977
14945
|
'ENABLE_VERTEX_TEXTURE',
|
|
14978
14946
|
enableVertexTexture
|
|
@@ -14989,7 +14957,7 @@ class TrailMesh {
|
|
|
14989
14957
|
const useAttributeTrailStart = maxTrailCount > 64;
|
|
14990
14958
|
let shaderCacheId = 0;
|
|
14991
14959
|
if (colorOverLifetime) {
|
|
14992
|
-
|
|
14960
|
+
macros.push([
|
|
14993
14961
|
'COLOR_OVER_LIFETIME',
|
|
14994
14962
|
true
|
|
14995
14963
|
]);
|
|
@@ -14997,7 +14965,7 @@ class TrailMesh {
|
|
|
14997
14965
|
uniformValues.uColorOverLifetime = Texture.createWithData(engine, imageDataFromGradient(colorOverLifetime));
|
|
14998
14966
|
}
|
|
14999
14967
|
if (colorOverTrail) {
|
|
15000
|
-
|
|
14968
|
+
macros.push([
|
|
15001
14969
|
'COLOR_OVER_TRAIL',
|
|
15002
14970
|
true
|
|
15003
14971
|
]);
|
|
@@ -15005,7 +14973,7 @@ class TrailMesh {
|
|
|
15005
14973
|
uniformValues.uColorOverTrail = Texture.createWithData(engine, imageDataFromGradient(colorOverTrail));
|
|
15006
14974
|
}
|
|
15007
14975
|
if (useAttributeTrailStart) {
|
|
15008
|
-
|
|
14976
|
+
macros.push([
|
|
15009
14977
|
'ATTR_TRAIL_START',
|
|
15010
14978
|
1
|
|
15011
14979
|
]);
|
|
@@ -15015,7 +14983,7 @@ class TrailMesh {
|
|
|
15015
14983
|
}
|
|
15016
14984
|
uniformValues.uOpacityOverLifetimeValue = opacityOverLifetime.toUniform(keyFrameMeta);
|
|
15017
14985
|
const uWidthOverTrail = widthOverTrail.toUniform(keyFrameMeta);
|
|
15018
|
-
|
|
14986
|
+
macros.push([
|
|
15019
14987
|
'VERT_CURVE_VALUE_COUNT',
|
|
15020
14988
|
keyFrameMeta.index
|
|
15021
14989
|
], [
|
|
@@ -15034,7 +15002,7 @@ class TrailMesh {
|
|
|
15034
15002
|
shader: {
|
|
15035
15003
|
vertex,
|
|
15036
15004
|
fragment,
|
|
15037
|
-
|
|
15005
|
+
macros,
|
|
15038
15006
|
glslVersion: level === 1 ? exports.GLSLVersion.GLSL1 : exports.GLSLVersion.GLSL3,
|
|
15039
15007
|
shared: true,
|
|
15040
15008
|
name: `trail#${name}`,
|
|
@@ -15189,11 +15157,11 @@ function calculateDirection(prePoint, point, nextPoint) {
|
|
|
15189
15157
|
}
|
|
15190
15158
|
return dir.normalize().toArray();
|
|
15191
15159
|
}
|
|
15192
|
-
function getTrailMeshShader(trails, particleMaxCount, name, env = ''
|
|
15160
|
+
function getTrailMeshShader(trails, particleMaxCount, name, gpuCapability, env = '') {
|
|
15193
15161
|
let shaderCacheId = 0;
|
|
15194
15162
|
const lookUpTexture = getConfig(RENDER_PREFER_LOOKUP_TEXTURE) ? 1 : 0;
|
|
15195
15163
|
const enableVertexTexture = gpuCapability.detail.maxVertexTextures > 0;
|
|
15196
|
-
const
|
|
15164
|
+
const macros = [
|
|
15197
15165
|
[
|
|
15198
15166
|
'ENABLE_VERTEX_TEXTURE',
|
|
15199
15167
|
enableVertexTexture
|
|
@@ -15209,14 +15177,14 @@ function getTrailMeshShader(trails, particleMaxCount, name, env = '', gpuCapabil
|
|
|
15209
15177
|
];
|
|
15210
15178
|
const keyFrameMeta = createKeyFrameMeta();
|
|
15211
15179
|
if (trails.colorOverLifetime) {
|
|
15212
|
-
|
|
15180
|
+
macros.push([
|
|
15213
15181
|
'COLOR_OVER_LIFETIME',
|
|
15214
15182
|
true
|
|
15215
15183
|
]);
|
|
15216
15184
|
shaderCacheId |= 1;
|
|
15217
15185
|
}
|
|
15218
15186
|
if (trails.colorOverTrail) {
|
|
15219
|
-
|
|
15187
|
+
macros.push([
|
|
15220
15188
|
'COLOR_OVER_TRAIL',
|
|
15221
15189
|
true
|
|
15222
15190
|
]);
|
|
@@ -15224,7 +15192,7 @@ function getTrailMeshShader(trails, particleMaxCount, name, env = '', gpuCapabil
|
|
|
15224
15192
|
}
|
|
15225
15193
|
const useAttributeTrailStart = particleMaxCount > 64;
|
|
15226
15194
|
if (useAttributeTrailStart) {
|
|
15227
|
-
|
|
15195
|
+
macros.push([
|
|
15228
15196
|
'ATTR_TRAIL_START',
|
|
15229
15197
|
1
|
|
15230
15198
|
]);
|
|
@@ -15232,7 +15200,7 @@ function getTrailMeshShader(trails, particleMaxCount, name, env = '', gpuCapabil
|
|
|
15232
15200
|
}
|
|
15233
15201
|
getKeyFrameMetaByRawValue(keyFrameMeta, trails.opacityOverLifetime);
|
|
15234
15202
|
getKeyFrameMetaByRawValue(keyFrameMeta, trails.widthOverTrail);
|
|
15235
|
-
|
|
15203
|
+
macros.push([
|
|
15236
15204
|
'VERT_CURVE_VALUE_COUNT',
|
|
15237
15205
|
keyFrameMeta.index
|
|
15238
15206
|
], [
|
|
@@ -15242,7 +15210,7 @@ function getTrailMeshShader(trails, particleMaxCount, name, env = '', gpuCapabil
|
|
|
15242
15210
|
return {
|
|
15243
15211
|
vertex: trailVert,
|
|
15244
15212
|
fragment: particleFrag,
|
|
15245
|
-
|
|
15213
|
+
macros,
|
|
15246
15214
|
shared: true,
|
|
15247
15215
|
name: 'trail#' + name,
|
|
15248
15216
|
cacheId: `-t:+${shaderCacheId}+${keyFrameMeta.index}+${keyFrameMeta.max}`
|
|
@@ -15929,11 +15897,9 @@ class ParticleSystem extends Component {
|
|
|
15929
15897
|
this.props = props;
|
|
15930
15898
|
this.destroyed = false;
|
|
15931
15899
|
const cachePrefix = '';
|
|
15932
|
-
const options = props
|
|
15933
|
-
const
|
|
15934
|
-
const
|
|
15935
|
-
const gravityModifier = positionOverLifetime.gravityOverLifetime;
|
|
15936
|
-
const gravity = ensureVec3(positionOverLifetime.gravity);
|
|
15900
|
+
const { options, positionOverLifetime = {}, shape } = props;
|
|
15901
|
+
const gravityModifier = positionOverLifetime == null ? void 0 : positionOverLifetime.gravityOverLifetime;
|
|
15902
|
+
const gravity = ensureVec3(positionOverLifetime == null ? void 0 : positionOverLifetime.gravity);
|
|
15937
15903
|
const _textureSheetAnimation = props.textureSheetAnimation;
|
|
15938
15904
|
const textureSheetAnimation = _textureSheetAnimation ? {
|
|
15939
15905
|
animationDelay: createValueGetter(_textureSheetAnimation.animationDelay || 0),
|
|
@@ -15944,7 +15910,7 @@ class ParticleSystem extends Component {
|
|
|
15944
15910
|
row: _textureSheetAnimation.row,
|
|
15945
15911
|
total: _textureSheetAnimation.total || _textureSheetAnimation.col * _textureSheetAnimation.row
|
|
15946
15912
|
} : undefined;
|
|
15947
|
-
const startTurbulence = !!(shape && shape.turbulenceX || shape.turbulenceY || shape.turbulenceZ);
|
|
15913
|
+
const startTurbulence = !!(shape && shape.turbulenceX || (shape == null ? void 0 : shape.turbulenceY) || (shape == null ? void 0 : shape.turbulenceZ));
|
|
15948
15914
|
let turbulence;
|
|
15949
15915
|
if (startTurbulence) {
|
|
15950
15916
|
var _shape_turbulenceX, _shape_turbulenceY, _shape_turbulenceZ;
|
|
@@ -15975,7 +15941,7 @@ class ParticleSystem extends Component {
|
|
|
15975
15941
|
}
|
|
15976
15942
|
}
|
|
15977
15943
|
let forceTarget;
|
|
15978
|
-
if (positionOverLifetime.forceTarget) {
|
|
15944
|
+
if (positionOverLifetime == null ? void 0 : positionOverLifetime.forceTarget) {
|
|
15979
15945
|
forceTarget = {
|
|
15980
15946
|
target: positionOverLifetime.target || [
|
|
15981
15947
|
0,
|
|
@@ -16555,15 +16521,12 @@ class ParticleMesh {
|
|
|
16555
16521
|
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;
|
|
16556
16522
|
const { detail } = engine.gpuCapability;
|
|
16557
16523
|
const { halfFloatTexture, maxVertexUniforms } = detail;
|
|
16558
|
-
const
|
|
16524
|
+
const macros = [
|
|
16525
|
+
// spec.RenderMode
|
|
16559
16526
|
[
|
|
16560
16527
|
'RENDER_MODE',
|
|
16561
16528
|
+renderMode
|
|
16562
16529
|
],
|
|
16563
|
-
[
|
|
16564
|
-
'PRE_MULTIPLY_ALPHA',
|
|
16565
|
-
false
|
|
16566
|
-
],
|
|
16567
16530
|
[
|
|
16568
16531
|
'ENV_EDITOR',
|
|
16569
16532
|
env === PLAYER_OPTIONS_ENV_EDITOR
|
|
@@ -16579,13 +16542,13 @@ class ParticleMesh {
|
|
|
16579
16542
|
let useOrbitalVel;
|
|
16580
16543
|
this.useSprite = useSprite;
|
|
16581
16544
|
if (enableVertexTexture) {
|
|
16582
|
-
|
|
16545
|
+
macros.push([
|
|
16583
16546
|
'ENABLE_VERTEX_TEXTURE',
|
|
16584
16547
|
true
|
|
16585
16548
|
]);
|
|
16586
16549
|
}
|
|
16587
16550
|
if (speedOverLifetime) {
|
|
16588
|
-
|
|
16551
|
+
macros.push([
|
|
16589
16552
|
'SPEED_OVER_LIFETIME',
|
|
16590
16553
|
true
|
|
16591
16554
|
]);
|
|
@@ -16593,7 +16556,7 @@ class ParticleMesh {
|
|
|
16593
16556
|
uniformValues.uSpeedLifetimeValue = speedOverLifetime.toUniform(vertexKeyFrameMeta);
|
|
16594
16557
|
}
|
|
16595
16558
|
if (sprite == null ? void 0 : sprite.animate) {
|
|
16596
|
-
|
|
16559
|
+
macros.push([
|
|
16597
16560
|
'USE_SPRITE',
|
|
16598
16561
|
true
|
|
16599
16562
|
]);
|
|
@@ -16607,7 +16570,7 @@ class ParticleMesh {
|
|
|
16607
16570
|
this.useSprite = true;
|
|
16608
16571
|
}
|
|
16609
16572
|
if (colorOverLifetime == null ? void 0 : colorOverLifetime.color) {
|
|
16610
|
-
|
|
16573
|
+
macros.push([
|
|
16611
16574
|
'COLOR_OVER_LIFETIME',
|
|
16612
16575
|
true
|
|
16613
16576
|
]);
|
|
@@ -16632,7 +16595,7 @@ class ParticleMesh {
|
|
|
16632
16595
|
shaderCacheId |= 1 << 7 + i;
|
|
16633
16596
|
linearVelOverLifetime.enabled = true;
|
|
16634
16597
|
}
|
|
16635
|
-
|
|
16598
|
+
macros.push([
|
|
16636
16599
|
`LINEAR_VEL_${pro.toUpperCase()}`,
|
|
16637
16600
|
defL
|
|
16638
16601
|
]);
|
|
@@ -16643,13 +16606,13 @@ class ParticleMesh {
|
|
|
16643
16606
|
useOrbitalVel = true;
|
|
16644
16607
|
orbitalVelOverLifetime.enabled = true;
|
|
16645
16608
|
}
|
|
16646
|
-
|
|
16609
|
+
macros.push([
|
|
16647
16610
|
`ORB_VEL_${pro.toUpperCase()}`,
|
|
16648
16611
|
defO
|
|
16649
16612
|
]);
|
|
16650
16613
|
});
|
|
16651
16614
|
if (linearVelOverLifetime == null ? void 0 : linearVelOverLifetime.asMovement) {
|
|
16652
|
-
|
|
16615
|
+
macros.push([
|
|
16653
16616
|
'AS_LINEAR_MOVEMENT',
|
|
16654
16617
|
true
|
|
16655
16618
|
]);
|
|
@@ -16657,7 +16620,7 @@ class ParticleMesh {
|
|
|
16657
16620
|
}
|
|
16658
16621
|
if (useOrbitalVel) {
|
|
16659
16622
|
if (orbitalVelOverLifetime == null ? void 0 : orbitalVelOverLifetime.asRotation) {
|
|
16660
|
-
|
|
16623
|
+
macros.push([
|
|
16661
16624
|
'AS_ORBITAL_MOVEMENT',
|
|
16662
16625
|
true
|
|
16663
16626
|
]);
|
|
@@ -16672,7 +16635,7 @@ class ParticleMesh {
|
|
|
16672
16635
|
uniformValues.uSizeByLifetimeValue = sizeOverLifetime == null ? void 0 : sizeOverLifetime.x.toUniform(vertexKeyFrameMeta);
|
|
16673
16636
|
if (sizeOverLifetime == null ? void 0 : sizeOverLifetime.separateAxes) {
|
|
16674
16637
|
var _sizeOverLifetime_y;
|
|
16675
|
-
|
|
16638
|
+
macros.push([
|
|
16676
16639
|
'SIZE_Y_BY_LIFE',
|
|
16677
16640
|
1
|
|
16678
16641
|
]);
|
|
@@ -16682,7 +16645,7 @@ class ParticleMesh {
|
|
|
16682
16645
|
if (rotationOverLifetime == null ? void 0 : rotationOverLifetime.z) {
|
|
16683
16646
|
uniformValues.uRZByLifeTimeValue = rotationOverLifetime.z.toUniform(vertexKeyFrameMeta);
|
|
16684
16647
|
shaderCacheId |= 1 << 15;
|
|
16685
|
-
|
|
16648
|
+
macros.push([
|
|
16686
16649
|
'ROT_Z_LIFETIME',
|
|
16687
16650
|
1
|
|
16688
16651
|
]);
|
|
@@ -16690,7 +16653,7 @@ class ParticleMesh {
|
|
|
16690
16653
|
if (rotationOverLifetime == null ? void 0 : rotationOverLifetime.x) {
|
|
16691
16654
|
uniformValues.uRXByLifeTimeValue = rotationOverLifetime.x.toUniform(vertexKeyFrameMeta);
|
|
16692
16655
|
shaderCacheId |= 1 << 16;
|
|
16693
|
-
|
|
16656
|
+
macros.push([
|
|
16694
16657
|
'ROT_X_LIFETIME',
|
|
16695
16658
|
1
|
|
16696
16659
|
]);
|
|
@@ -16698,13 +16661,13 @@ class ParticleMesh {
|
|
|
16698
16661
|
if (rotationOverLifetime == null ? void 0 : rotationOverLifetime.y) {
|
|
16699
16662
|
uniformValues.uRYByLifeTimeValue = rotationOverLifetime.y.toUniform(vertexKeyFrameMeta);
|
|
16700
16663
|
shaderCacheId |= 1 << 17;
|
|
16701
|
-
|
|
16664
|
+
macros.push([
|
|
16702
16665
|
'ROT_Y_LIFETIME',
|
|
16703
16666
|
1
|
|
16704
16667
|
]);
|
|
16705
16668
|
}
|
|
16706
16669
|
if (rotationOverLifetime == null ? void 0 : rotationOverLifetime.asRotation) {
|
|
16707
|
-
|
|
16670
|
+
macros.push([
|
|
16708
16671
|
'ROT_LIFETIME_AS_MOVEMENT',
|
|
16709
16672
|
1
|
|
16710
16673
|
]);
|
|
@@ -16712,7 +16675,7 @@ class ParticleMesh {
|
|
|
16712
16675
|
}
|
|
16713
16676
|
uniformValues.uGravityModifierValue = gravityModifier.toUniform(vertexKeyFrameMeta);
|
|
16714
16677
|
if (forceTarget) {
|
|
16715
|
-
|
|
16678
|
+
macros.push([
|
|
16716
16679
|
'FINAL_TARGET',
|
|
16717
16680
|
true
|
|
16718
16681
|
]);
|
|
@@ -16758,7 +16721,7 @@ class ParticleMesh {
|
|
|
16758
16721
|
fragmentKeyFrameMeta.index,
|
|
16759
16722
|
fragmentKeyFrameMeta.max
|
|
16760
16723
|
].join('+');
|
|
16761
|
-
|
|
16724
|
+
macros.push([
|
|
16762
16725
|
'VERT_CURVE_VALUE_COUNT',
|
|
16763
16726
|
vertexKeyFrameMeta.index
|
|
16764
16727
|
], [
|
|
@@ -16780,7 +16743,7 @@ class ParticleMesh {
|
|
|
16780
16743
|
glslVersion: level === 1 ? exports.GLSLVersion.GLSL1 : exports.GLSLVersion.GLSL3,
|
|
16781
16744
|
shared: true,
|
|
16782
16745
|
cacheId: shaderCache,
|
|
16783
|
-
|
|
16746
|
+
macros,
|
|
16784
16747
|
name: `particle#${name}`
|
|
16785
16748
|
};
|
|
16786
16749
|
const mtlOptions = {
|
|
@@ -16857,7 +16820,7 @@ class ParticleMesh {
|
|
|
16857
16820
|
res.length = 0;
|
|
16858
16821
|
break;
|
|
16859
16822
|
default:
|
|
16860
|
-
console.warn(`
|
|
16823
|
+
console.warn(`Uniform ${name}'s type not in typeMap.`);
|
|
16861
16824
|
}
|
|
16862
16825
|
});
|
|
16863
16826
|
material.setVector3('emissionColor', new Vector3(0, 0, 0));
|
|
@@ -16988,19 +16951,15 @@ function generateGeometryProps(maxVertex, useSprite, name) {
|
|
|
16988
16951
|
maxVertex
|
|
16989
16952
|
};
|
|
16990
16953
|
}
|
|
16991
|
-
function getParticleMeshShader(item, env = ''
|
|
16954
|
+
function getParticleMeshShader(item, gpuCapability, env = '') {
|
|
16992
16955
|
var _props_renderer;
|
|
16993
16956
|
const props = item.content;
|
|
16994
16957
|
const renderMode = +(((_props_renderer = props.renderer) == null ? void 0 : _props_renderer.renderMode) || 0);
|
|
16995
|
-
const
|
|
16958
|
+
const macros = [
|
|
16996
16959
|
[
|
|
16997
16960
|
'RENDER_MODE',
|
|
16998
16961
|
renderMode
|
|
16999
16962
|
],
|
|
17000
|
-
[
|
|
17001
|
-
'PRE_MULTIPLY_ALPHA',
|
|
17002
|
-
false
|
|
17003
|
-
],
|
|
17004
16963
|
[
|
|
17005
16964
|
'ENV_EDITOR',
|
|
17006
16965
|
env === PLAYER_OPTIONS_ENV_EDITOR
|
|
@@ -17015,13 +16974,13 @@ function getParticleMeshShader(item, env = '', gpuCapability) {
|
|
|
17015
16974
|
let vertex_lookup_texture = 0;
|
|
17016
16975
|
let shaderCacheId = 0;
|
|
17017
16976
|
if (enableVertexTexture) {
|
|
17018
|
-
|
|
16977
|
+
macros.push([
|
|
17019
16978
|
'ENABLE_VERTEX_TEXTURE',
|
|
17020
16979
|
true
|
|
17021
16980
|
]);
|
|
17022
16981
|
}
|
|
17023
16982
|
if (speedOverLifetime) {
|
|
17024
|
-
|
|
16983
|
+
macros.push([
|
|
17025
16984
|
'SPEED_OVER_LIFETIME',
|
|
17026
16985
|
true
|
|
17027
16986
|
]);
|
|
@@ -17030,7 +16989,7 @@ function getParticleMeshShader(item, env = '', gpuCapability) {
|
|
|
17030
16989
|
}
|
|
17031
16990
|
const sprite = props.textureSheetAnimation;
|
|
17032
16991
|
if (sprite && sprite.animate) {
|
|
17033
|
-
|
|
16992
|
+
macros.push([
|
|
17034
16993
|
'USE_SPRITE',
|
|
17035
16994
|
true
|
|
17036
16995
|
]);
|
|
@@ -17038,7 +16997,7 @@ function getParticleMeshShader(item, env = '', gpuCapability) {
|
|
|
17038
16997
|
}
|
|
17039
16998
|
const colorOverLifetime = props.colorOverLifetime;
|
|
17040
16999
|
if (colorOverLifetime && colorOverLifetime.color) {
|
|
17041
|
-
|
|
17000
|
+
macros.push([
|
|
17042
17001
|
'COLOR_OVER_LIFETIME',
|
|
17043
17002
|
true
|
|
17044
17003
|
]);
|
|
@@ -17063,7 +17022,7 @@ function getParticleMeshShader(item, env = '', gpuCapability) {
|
|
|
17063
17022
|
defL = 1;
|
|
17064
17023
|
shaderCacheId |= 1 << 7 + i;
|
|
17065
17024
|
}
|
|
17066
|
-
|
|
17025
|
+
macros.push([
|
|
17067
17026
|
`LINEAR_VEL_${pro.toUpperCase()}`,
|
|
17068
17027
|
defL
|
|
17069
17028
|
]);
|
|
@@ -17074,13 +17033,13 @@ function getParticleMeshShader(item, env = '', gpuCapability) {
|
|
|
17074
17033
|
shaderCacheId |= 1 << 10 + i;
|
|
17075
17034
|
useOrbitalVel = true;
|
|
17076
17035
|
}
|
|
17077
|
-
|
|
17036
|
+
macros.push([
|
|
17078
17037
|
`ORB_VEL_${pro.toUpperCase()}`,
|
|
17079
17038
|
defO
|
|
17080
17039
|
]);
|
|
17081
17040
|
});
|
|
17082
17041
|
if (positionOverLifetime == null ? void 0 : positionOverLifetime.asMovement) {
|
|
17083
|
-
|
|
17042
|
+
macros.push([
|
|
17084
17043
|
'AS_LINEAR_MOVEMENT',
|
|
17085
17044
|
true
|
|
17086
17045
|
]);
|
|
@@ -17088,7 +17047,7 @@ function getParticleMeshShader(item, env = '', gpuCapability) {
|
|
|
17088
17047
|
}
|
|
17089
17048
|
if (useOrbitalVel) {
|
|
17090
17049
|
if (positionOverLifetime == null ? void 0 : positionOverLifetime.asRotation) {
|
|
17091
|
-
|
|
17050
|
+
macros.push([
|
|
17092
17051
|
'AS_ORBITAL_MOVEMENT',
|
|
17093
17052
|
true
|
|
17094
17053
|
]);
|
|
@@ -17100,7 +17059,7 @@ function getParticleMeshShader(item, env = '', gpuCapability) {
|
|
|
17100
17059
|
const separateAxes = sizeOverLifetime.separateAxes;
|
|
17101
17060
|
if (separateAxes) {
|
|
17102
17061
|
getKeyFrameMetaByRawValue(vertexKeyFrameMeta, sizeOverLifetime.x);
|
|
17103
|
-
|
|
17062
|
+
macros.push([
|
|
17104
17063
|
'SIZE_Y_BY_LIFE',
|
|
17105
17064
|
1
|
|
17106
17065
|
]);
|
|
@@ -17115,7 +17074,7 @@ function getParticleMeshShader(item, env = '', gpuCapability) {
|
|
|
17115
17074
|
if (rot.z) {
|
|
17116
17075
|
getKeyFrameMetaByRawValue(vertexKeyFrameMeta, rot == null ? void 0 : rot.z);
|
|
17117
17076
|
shaderCacheId |= 1 << 15;
|
|
17118
|
-
|
|
17077
|
+
macros.push([
|
|
17119
17078
|
'ROT_Z_LIFETIME',
|
|
17120
17079
|
1
|
|
17121
17080
|
]);
|
|
@@ -17124,7 +17083,7 @@ function getParticleMeshShader(item, env = '', gpuCapability) {
|
|
|
17124
17083
|
if (rot.x) {
|
|
17125
17084
|
getKeyFrameMetaByRawValue(vertexKeyFrameMeta, rot.x);
|
|
17126
17085
|
shaderCacheId |= 1 << 16;
|
|
17127
|
-
|
|
17086
|
+
macros.push([
|
|
17128
17087
|
'ROT_X_LIFETIME',
|
|
17129
17088
|
1
|
|
17130
17089
|
]);
|
|
@@ -17132,14 +17091,14 @@ function getParticleMeshShader(item, env = '', gpuCapability) {
|
|
|
17132
17091
|
if (rot.y) {
|
|
17133
17092
|
getKeyFrameMetaByRawValue(vertexKeyFrameMeta, rot.y);
|
|
17134
17093
|
shaderCacheId |= 1 << 17;
|
|
17135
|
-
|
|
17094
|
+
macros.push([
|
|
17136
17095
|
'ROT_Y_LIFETIME',
|
|
17137
17096
|
1
|
|
17138
17097
|
]);
|
|
17139
17098
|
}
|
|
17140
17099
|
}
|
|
17141
17100
|
if (rot == null ? void 0 : rot.asRotation) {
|
|
17142
|
-
|
|
17101
|
+
macros.push([
|
|
17143
17102
|
'ROT_LIFETIME_AS_MOVEMENT',
|
|
17144
17103
|
1
|
|
17145
17104
|
]);
|
|
@@ -17149,7 +17108,7 @@ function getParticleMeshShader(item, env = '', gpuCapability) {
|
|
|
17149
17108
|
getKeyFrameMetaByRawValue(vertexKeyFrameMeta, positionOverLifetime == null ? void 0 : positionOverLifetime.gravityOverLifetime);
|
|
17150
17109
|
const forceOpt = positionOverLifetime == null ? void 0 : positionOverLifetime.forceTarget;
|
|
17151
17110
|
if (forceOpt) {
|
|
17152
|
-
|
|
17111
|
+
macros.push([
|
|
17153
17112
|
'FINAL_TARGET',
|
|
17154
17113
|
true
|
|
17155
17114
|
]);
|
|
@@ -17190,10 +17149,10 @@ function getParticleMeshShader(item, env = '', gpuCapability) {
|
|
|
17190
17149
|
vertex: `#define LOOKUP_TEXTURE_CURVE ${vertex_lookup_texture}\n${particleVert}`,
|
|
17191
17150
|
shared: true,
|
|
17192
17151
|
cacheId: shaderCache,
|
|
17193
|
-
|
|
17152
|
+
macros,
|
|
17194
17153
|
name: `particle#${item.name}`
|
|
17195
17154
|
};
|
|
17196
|
-
|
|
17155
|
+
macros.push([
|
|
17197
17156
|
'VERT_CURVE_VALUE_COUNT',
|
|
17198
17157
|
vertexKeyFrameMeta.index
|
|
17199
17158
|
], [
|
|
@@ -17218,11 +17177,11 @@ function modifyMaxKeyframeShader(shader, maxVertex, maxFrag) {
|
|
|
17218
17177
|
shaderIds[3] = maxVertex;
|
|
17219
17178
|
shaderIds[5] = maxFrag;
|
|
17220
17179
|
shader.cacheId = shaderIds.join('+');
|
|
17221
|
-
if (!shader.
|
|
17180
|
+
if (!shader.macros) {
|
|
17222
17181
|
return;
|
|
17223
17182
|
}
|
|
17224
|
-
for(let i = 0; i < shader.
|
|
17225
|
-
const marco = shader.
|
|
17183
|
+
for(let i = 0; i < shader.macros.length; i++){
|
|
17184
|
+
const marco = shader.macros[i];
|
|
17226
17185
|
if (marco[0] === 'VERT_CURVE_VALUE_COUNT') {
|
|
17227
17186
|
marco[1] = maxVertex;
|
|
17228
17187
|
} else if (marco[0] === 'FRAG_CURVE_VALUE_COUNT') {
|
|
@@ -17251,17 +17210,17 @@ class ParticleLoader extends AbstractPlugin {
|
|
|
17251
17210
|
});
|
|
17252
17211
|
});
|
|
17253
17212
|
items.forEach((item)=>{
|
|
17254
|
-
const { shader, fragment, vertex } = getParticleMeshShader(item,
|
|
17213
|
+
const { shader, fragment, vertex } = getParticleMeshShader(item, gpuCapability, env);
|
|
17255
17214
|
shaders.push(shader);
|
|
17256
17215
|
maxFragmentCount = Math.max(maxFragmentCount, fragment);
|
|
17257
17216
|
maxVertexCount = Math.max(maxVertexCount, vertex);
|
|
17258
17217
|
// TODO 此处add是否有意义?shader变量似乎没有加到this.shaders数组。
|
|
17259
17218
|
if (item.content.trails) {
|
|
17260
|
-
const shader = getTrailMeshShader(item.content.trails, item.content.options.maxCount, item.name,
|
|
17261
|
-
var
|
|
17262
|
-
shader.vertex =
|
|
17263
|
-
var
|
|
17264
|
-
shader.fragment =
|
|
17219
|
+
const shader = getTrailMeshShader(item.content.trails, item.content.options.maxCount, item.name, gpuCapability, env);
|
|
17220
|
+
var _shader_macros;
|
|
17221
|
+
shader.vertex = createShaderWithMacros((_shader_macros = shader.macros) != null ? _shader_macros : [], shader.vertex, exports.ShaderType.vertex, level);
|
|
17222
|
+
var _shader_macros1;
|
|
17223
|
+
shader.fragment = createShaderWithMacros((_shader_macros1 = shader.macros) != null ? _shader_macros1 : [], shader.fragment, exports.ShaderType.fragment, level);
|
|
17265
17224
|
shader.glslVersion = level === 2 ? exports.GLSLVersion.GLSL3 : exports.GLSLVersion.GLSL1;
|
|
17266
17225
|
shaderLibrary.addShader(shader);
|
|
17267
17226
|
}
|
|
@@ -17273,10 +17232,10 @@ class ParticleLoader extends AbstractPlugin {
|
|
|
17273
17232
|
} else {
|
|
17274
17233
|
shader.glslVersion = exports.GLSLVersion.GLSL1;
|
|
17275
17234
|
}
|
|
17276
|
-
var
|
|
17277
|
-
shader.vertex =
|
|
17278
|
-
var
|
|
17279
|
-
shader.fragment =
|
|
17235
|
+
var _shader_macros;
|
|
17236
|
+
shader.vertex = createShaderWithMacros((_shader_macros = shader.macros) != null ? _shader_macros : [], shader.vertex, exports.ShaderType.vertex, level);
|
|
17237
|
+
var _shader_macros1;
|
|
17238
|
+
shader.fragment = createShaderWithMacros((_shader_macros1 = shader.macros) != null ? _shader_macros1 : [], shader.fragment, exports.ShaderType.fragment, level);
|
|
17280
17239
|
shaderLibrary.addShader(shader);
|
|
17281
17240
|
});
|
|
17282
17241
|
if (level === 2) {
|
|
@@ -17594,6 +17553,27 @@ class AnimationClipPlayable extends Playable {
|
|
|
17594
17553
|
}
|
|
17595
17554
|
}
|
|
17596
17555
|
|
|
17556
|
+
/**
|
|
17557
|
+
* @since 2.0.0
|
|
17558
|
+
* @internal
|
|
17559
|
+
*/ class TimelineClip {
|
|
17560
|
+
toLocalTime(time) {
|
|
17561
|
+
let localTime = time - this.start;
|
|
17562
|
+
const duration = this.duration;
|
|
17563
|
+
if (localTime - duration > 0.001) {
|
|
17564
|
+
if (this.endBehaviour === ItemEndBehavior.loop) {
|
|
17565
|
+
localTime = localTime % duration;
|
|
17566
|
+
} else if (this.endBehaviour === ItemEndBehavior.freeze) {
|
|
17567
|
+
localTime = Math.min(duration, localTime);
|
|
17568
|
+
}
|
|
17569
|
+
}
|
|
17570
|
+
return localTime;
|
|
17571
|
+
}
|
|
17572
|
+
constructor(){
|
|
17573
|
+
this.start = 0;
|
|
17574
|
+
this.duration = 0;
|
|
17575
|
+
}
|
|
17576
|
+
}
|
|
17597
17577
|
class TrackAsset extends PlayableAsset {
|
|
17598
17578
|
/**
|
|
17599
17579
|
* 重写该方法以获取自定义对象绑定
|
|
@@ -17674,7 +17654,7 @@ class TrackAsset extends PlayableAsset {
|
|
|
17674
17654
|
}
|
|
17675
17655
|
}
|
|
17676
17656
|
__decorate([
|
|
17677
|
-
serialize(
|
|
17657
|
+
serialize(TimelineClip)
|
|
17678
17658
|
], TrackAsset.prototype, "clips", void 0);
|
|
17679
17659
|
__decorate([
|
|
17680
17660
|
serialize()
|
|
@@ -17687,27 +17667,6 @@ exports.TrackType = void 0;
|
|
|
17687
17667
|
TrackType[TrackType["MasterTrack"] = 0] = "MasterTrack";
|
|
17688
17668
|
TrackType[TrackType["ObjectTrack"] = 1] = "ObjectTrack";
|
|
17689
17669
|
})(exports.TrackType || (exports.TrackType = {}));
|
|
17690
|
-
class TimelineClip {
|
|
17691
|
-
toLocalTime(time) {
|
|
17692
|
-
let localTime = time - this.start;
|
|
17693
|
-
const duration = this.duration;
|
|
17694
|
-
if (localTime - duration > 0.001) {
|
|
17695
|
-
if (this.endBehaviour === ItemEndBehavior.loop) {
|
|
17696
|
-
localTime = localTime % duration;
|
|
17697
|
-
} else if (this.endBehaviour === ItemEndBehavior.freeze) {
|
|
17698
|
-
localTime = Math.min(duration, localTime);
|
|
17699
|
-
}
|
|
17700
|
-
}
|
|
17701
|
-
return localTime;
|
|
17702
|
-
}
|
|
17703
|
-
constructor(){
|
|
17704
|
-
this.start = 0;
|
|
17705
|
-
this.duration = 0;
|
|
17706
|
-
}
|
|
17707
|
-
}
|
|
17708
|
-
TimelineClip = __decorate([
|
|
17709
|
-
effectsClass('TimelineClip')
|
|
17710
|
-
], TimelineClip);
|
|
17711
17670
|
class RuntimeClip {
|
|
17712
17671
|
set enable(value) {
|
|
17713
17672
|
if (value) {
|
|
@@ -17782,10 +17741,6 @@ class ObjectBindingTrack extends TrackAsset {
|
|
|
17782
17741
|
particleClip.endBehaviour = boundItem.endBehavior;
|
|
17783
17742
|
}
|
|
17784
17743
|
}
|
|
17785
|
-
fromData(data) {
|
|
17786
|
-
super.fromData(data);
|
|
17787
|
-
this.data = data;
|
|
17788
|
-
}
|
|
17789
17744
|
}
|
|
17790
17745
|
ObjectBindingTrack = __decorate([
|
|
17791
17746
|
effectsClass('ObjectBindingTrack')
|
|
@@ -17971,7 +17926,6 @@ function compareTracks(a, b) {
|
|
|
17971
17926
|
this.startTime = startTime;
|
|
17972
17927
|
this.resolveBindings();
|
|
17973
17928
|
this.timelinePlayable = this.timelineAsset.createPlayable(this.graph);
|
|
17974
|
-
this.timelinePlayable.play();
|
|
17975
17929
|
// 重播不销毁元素
|
|
17976
17930
|
if (this.item.endBehavior !== ItemEndBehavior.destroy) {
|
|
17977
17931
|
this.setReusable(true);
|
|
@@ -18027,7 +17981,7 @@ function compareTracks(a, b) {
|
|
|
18027
17981
|
const refId = itemData.content.options.refId;
|
|
18028
17982
|
const props = this.item.composition.refCompositionProps.get(refId);
|
|
18029
17983
|
if (!props) {
|
|
18030
|
-
throw new Error(
|
|
17984
|
+
throw new Error(`Referenced precomposition with Id: ${refId} does not exist.`);
|
|
18031
17985
|
}
|
|
18032
17986
|
// endBehaviour 类型需优化
|
|
18033
17987
|
props.content = itemData.content;
|
|
@@ -18171,7 +18125,7 @@ function compareTracks(a, b) {
|
|
|
18171
18125
|
class SubCompositionTrack extends TrackAsset {
|
|
18172
18126
|
resolveBinding(parentBinding) {
|
|
18173
18127
|
if (!(parentBinding instanceof VFXItem)) {
|
|
18174
|
-
throw new Error('SubCompositionTrack needs to be set under the VFXItem track');
|
|
18128
|
+
throw new Error('SubCompositionTrack needs to be set under the VFXItem track.');
|
|
18175
18129
|
}
|
|
18176
18130
|
return parentBinding.getComponent(CompositionComponent);
|
|
18177
18131
|
}
|
|
@@ -18355,7 +18309,6 @@ class CanvasPool {
|
|
|
18355
18309
|
return this.elements.shift();
|
|
18356
18310
|
}
|
|
18357
18311
|
if (getConfig(TEMPLATE_USE_OFFSCREEN_CANVAS)) {
|
|
18358
|
-
// @ts-expect-error
|
|
18359
18312
|
return window._createOffscreenCanvas(10, 10);
|
|
18360
18313
|
} else {
|
|
18361
18314
|
// in hongmeng system, create too many canvas will case render error
|
|
@@ -19179,7 +19132,6 @@ class VFXItem extends EffectsObject {
|
|
|
19179
19132
|
this.parentId = parentId;
|
|
19180
19133
|
this.duration = duration;
|
|
19181
19134
|
this.endBehavior = endBehavior;
|
|
19182
|
-
this.renderOrder = listIndex;
|
|
19183
19135
|
//@ts-expect-error
|
|
19184
19136
|
this.oldId = data.oldId;
|
|
19185
19137
|
if (!data.content) {
|
|
@@ -19188,19 +19140,13 @@ class VFXItem extends EffectsObject {
|
|
|
19188
19140
|
};
|
|
19189
19141
|
}
|
|
19190
19142
|
if (duration <= 0) {
|
|
19191
|
-
throw Error(`Item duration can't be less than 0, see ${HELP_LINK['Item duration can\'t be less than 0']}
|
|
19192
|
-
}
|
|
19193
|
-
|
|
19194
|
-
|
|
19195
|
-
const newComponent = component;
|
|
19196
|
-
this.components.push(newComponent);
|
|
19197
|
-
if (newComponent instanceof RendererComponent) {
|
|
19198
|
-
this.rendererComponents.push(newComponent);
|
|
19199
|
-
} else if (newComponent instanceof ItemBehaviour) {
|
|
19200
|
-
this.itemBehaviours.push(newComponent);
|
|
19201
|
-
}
|
|
19202
|
-
}
|
|
19143
|
+
throw new Error(`Item duration can't be less than 0, see ${HELP_LINK['Item duration can\'t be less than 0']}.`);
|
|
19144
|
+
}
|
|
19145
|
+
for (const component of this.components){
|
|
19146
|
+
component.onAttached();
|
|
19203
19147
|
}
|
|
19148
|
+
// renderOrder 在 component 初始化后设置。确保能拿到 rendererComponent。
|
|
19149
|
+
this.renderOrder = listIndex;
|
|
19204
19150
|
}
|
|
19205
19151
|
toData() {
|
|
19206
19152
|
var _this_parent;
|
|
@@ -19295,6 +19241,7 @@ class VFXItem extends EffectsObject {
|
|
|
19295
19241
|
/**
|
|
19296
19242
|
* 元素动画的速度
|
|
19297
19243
|
*/ this.speed = 1;
|
|
19244
|
+
this.listIndex = 0;
|
|
19298
19245
|
this.name = 'VFXItem';
|
|
19299
19246
|
this.transform.name = this.name;
|
|
19300
19247
|
this.transform.engine = engine;
|
|
@@ -19303,6 +19250,9 @@ class VFXItem extends EffectsObject {
|
|
|
19303
19250
|
}
|
|
19304
19251
|
}
|
|
19305
19252
|
}
|
|
19253
|
+
__decorate([
|
|
19254
|
+
serialize()
|
|
19255
|
+
], VFXItem.prototype, "components", void 0);
|
|
19306
19256
|
VFXItem = __decorate([
|
|
19307
19257
|
effectsClass(DataType.VFXItemData)
|
|
19308
19258
|
], VFXItem);
|
|
@@ -19356,7 +19306,7 @@ exports.Item = void 0;
|
|
|
19356
19306
|
pluginName = 'tree';
|
|
19357
19307
|
break;
|
|
19358
19308
|
default:
|
|
19359
|
-
throw new Error('
|
|
19309
|
+
throw new Error('Invalid vfx item type.');
|
|
19360
19310
|
}
|
|
19361
19311
|
}
|
|
19362
19312
|
return composition.pluginSystem.createPluginItem(pluginName, props, composition);
|
|
@@ -19397,13 +19347,13 @@ class PluginSystem {
|
|
|
19397
19347
|
createPluginItem(name, props, composition) {
|
|
19398
19348
|
const CTRL = pluginCtrlMap[name];
|
|
19399
19349
|
if (!CTRL) {
|
|
19400
|
-
throw new Error(`plugin ${name}
|
|
19350
|
+
throw new Error(`The plugin '${name}' does not have a registered constructor.`);
|
|
19401
19351
|
}
|
|
19402
19352
|
const engine = composition.getEngine();
|
|
19403
19353
|
const item = new CTRL(engine, props, composition);
|
|
19404
19354
|
item.composition = composition;
|
|
19405
19355
|
if (!(item instanceof VFXItem)) {
|
|
19406
|
-
throw new Error(`plugin ${name} invalid constructor type
|
|
19356
|
+
throw new Error(`The plugin '${name}' invalid constructor type.`);
|
|
19407
19357
|
}
|
|
19408
19358
|
return item;
|
|
19409
19359
|
}
|
|
@@ -19456,7 +19406,7 @@ class PluginSystem {
|
|
|
19456
19406
|
this.plugins = Object.keys(loaders).map((name)=>{
|
|
19457
19407
|
const CTRL = pluginLoaderMap[name];
|
|
19458
19408
|
if (!CTRL) {
|
|
19459
|
-
throw new Error(`plugin '${name}' not found.` + getPluginUsageInfo(name));
|
|
19409
|
+
throw new Error(`The plugin '${name}' not found.` + getPluginUsageInfo(name));
|
|
19460
19410
|
}
|
|
19461
19411
|
const loader = new CTRL();
|
|
19462
19412
|
loader.name = name;
|
|
@@ -19498,20 +19448,20 @@ class SerializationHelper {
|
|
|
19498
19448
|
if (value === undefined) {
|
|
19499
19449
|
value = effectsObject[key];
|
|
19500
19450
|
}
|
|
19501
|
-
if (value
|
|
19502
|
-
|
|
19503
|
-
} else if (value
|
|
19451
|
+
if (EffectsObject.is(value)) {
|
|
19452
|
+
SerializationHelper.collectSerializableObject(value, res);
|
|
19453
|
+
} else if (isArray(value)) {
|
|
19504
19454
|
for (const arrayValue of value){
|
|
19505
|
-
if (arrayValue
|
|
19506
|
-
|
|
19455
|
+
if (EffectsObject.is(arrayValue)) {
|
|
19456
|
+
SerializationHelper.collectSerializableObject(arrayValue, res);
|
|
19507
19457
|
}
|
|
19508
19458
|
}
|
|
19509
|
-
} else if (value
|
|
19459
|
+
} else if (isObject(value)) {
|
|
19510
19460
|
// 非 EffectsObject 对象只递归一层
|
|
19511
19461
|
for (const objectKey of Object.keys(value)){
|
|
19512
19462
|
const objectValue = value[objectKey];
|
|
19513
|
-
if (objectValue
|
|
19514
|
-
|
|
19463
|
+
if (EffectsObject.is(objectValue)) {
|
|
19464
|
+
SerializationHelper.collectSerializableObject(objectValue, res);
|
|
19515
19465
|
}
|
|
19516
19466
|
}
|
|
19517
19467
|
}
|
|
@@ -19546,17 +19496,17 @@ class SerializationHelper {
|
|
|
19546
19496
|
if (typeof value === 'number' || typeof value === 'string' || typeof value === 'boolean' || SerializationHelper.checkTypedArray(value)) {
|
|
19547
19497
|
// TODO json 数据避免传 typedArray
|
|
19548
19498
|
serializedData[key] = value;
|
|
19549
|
-
} else if (value
|
|
19499
|
+
} else if (isArray(value)) {
|
|
19550
19500
|
if (!serializedData[key]) {
|
|
19551
19501
|
serializedData[key] = [];
|
|
19552
19502
|
}
|
|
19553
19503
|
SerializationHelper.serializeArrayProperty(value, serializedData[key], 0);
|
|
19554
|
-
} else if (value
|
|
19504
|
+
} else if (EffectsObject.is(value)) {
|
|
19555
19505
|
// TODO 处理 EffectsObject 递归序列化
|
|
19556
19506
|
serializedData[key] = {
|
|
19557
19507
|
id: value.getInstanceId()
|
|
19558
19508
|
};
|
|
19559
|
-
} else if (value
|
|
19509
|
+
} else if (isObject(value)) {
|
|
19560
19510
|
if (!serializedData[key]) {
|
|
19561
19511
|
serializedData[key] = {};
|
|
19562
19512
|
}
|
|
@@ -19569,17 +19519,17 @@ class SerializationHelper {
|
|
|
19569
19519
|
if (typeof value === 'number' || typeof value === 'string' || typeof value === 'boolean' || SerializationHelper.checkTypedArray(value)) {
|
|
19570
19520
|
// TODO json 数据避免传 typedArray
|
|
19571
19521
|
serializedData[key] = value;
|
|
19572
|
-
} else if (value
|
|
19522
|
+
} else if (isArray(value)) {
|
|
19573
19523
|
if (!serializedData[key]) {
|
|
19574
19524
|
serializedData[key] = [];
|
|
19575
19525
|
}
|
|
19576
19526
|
SerializationHelper.serializeArrayProperty(value, serializedData[key], 0);
|
|
19577
|
-
} else if (value
|
|
19527
|
+
} else if (EffectsObject.is(value)) {
|
|
19578
19528
|
// TODO 处理 EffectsObject 递归序列化
|
|
19579
19529
|
serializedData[key] = {
|
|
19580
19530
|
id: value.getInstanceId()
|
|
19581
19531
|
};
|
|
19582
|
-
} else if (value
|
|
19532
|
+
} else if (isObject(value)) {
|
|
19583
19533
|
if (!serializedData[key]) {
|
|
19584
19534
|
serializedData[key] = {};
|
|
19585
19535
|
}
|
|
@@ -19639,24 +19589,24 @@ class SerializationHelper {
|
|
|
19639
19589
|
static checkTypedArray(obj) {
|
|
19640
19590
|
return obj instanceof Int8Array || obj instanceof Uint8Array || obj instanceof Uint8ClampedArray || obj instanceof Int16Array || obj instanceof Uint16Array || obj instanceof Int32Array || obj instanceof Uint32Array || obj instanceof Float32Array || obj instanceof Float64Array || obj instanceof ArrayBuffer;
|
|
19641
19591
|
}
|
|
19592
|
+
// check value is { id: 7e69662e964e4892ae8933f24562395b }
|
|
19642
19593
|
static checkDataPath(value) {
|
|
19643
|
-
|
|
19644
|
-
return value instanceof Object && Object.keys(value).length === 1 && value.id && value.id.length === 32;
|
|
19594
|
+
return !!(isObject(value) && Object.keys(value).length === 1 && 'id' in value && isString(value.id) && value.id.length === 32);
|
|
19645
19595
|
}
|
|
19646
19596
|
// TODO 测试函数,2.0 上线后移除
|
|
19647
19597
|
static checkGLTFNode(value) {
|
|
19648
|
-
return value
|
|
19598
|
+
return isObject(value) && value.nodeIndex !== undefined && value.isJoint !== undefined;
|
|
19649
19599
|
}
|
|
19650
19600
|
static checkImageSource(value) {
|
|
19651
19601
|
return isCanvas(value) || value instanceof HTMLImageElement;
|
|
19652
19602
|
}
|
|
19653
19603
|
static deserializeProperty(property, engine, level, type) {
|
|
19654
19604
|
if (level > 14) {
|
|
19655
|
-
console.error('
|
|
19605
|
+
console.error('The nested object layers of the serialized data exceed the maximum limit.');
|
|
19656
19606
|
return;
|
|
19657
19607
|
}
|
|
19658
19608
|
// 加载并链接 DataPath 字段表示的 EffectsObject 引用。Class 对象 copy [key, value] 会丢失对象信息,因此只递归数组对象和普通 js Object 结构对象。
|
|
19659
|
-
if (property
|
|
19609
|
+
if (isArray(property)) {
|
|
19660
19610
|
const res = [];
|
|
19661
19611
|
for (const value of property){
|
|
19662
19612
|
res.push(SerializationHelper.deserializeProperty(value, engine, level + 1, type));
|
|
@@ -19665,16 +19615,14 @@ class SerializationHelper {
|
|
|
19665
19615
|
// TODO json 数据避免传 typedArray
|
|
19666
19616
|
} else if (SerializationHelper.checkDataPath(property)) {
|
|
19667
19617
|
return engine.assetLoader.loadGUID(property.id);
|
|
19668
|
-
} else if (property
|
|
19618
|
+
} else if (isObject(property) && property.constructor === Object) {
|
|
19669
19619
|
let res;
|
|
19670
19620
|
if (type) {
|
|
19671
|
-
|
|
19672
|
-
res = new classConstructor();
|
|
19621
|
+
res = new type();
|
|
19673
19622
|
} else {
|
|
19674
19623
|
res = {};
|
|
19675
19624
|
}
|
|
19676
19625
|
for (const key of Object.keys(property)){
|
|
19677
|
-
// @ts-expect-error
|
|
19678
19626
|
res[key] = SerializationHelper.deserializeProperty(property[key], engine, level + 1);
|
|
19679
19627
|
}
|
|
19680
19628
|
return res;
|
|
@@ -19685,10 +19633,10 @@ class SerializationHelper {
|
|
|
19685
19633
|
static deserializePropertyAsync(property, engine, level, type) {
|
|
19686
19634
|
return _async_to_generator(function*() {
|
|
19687
19635
|
if (level > 14) {
|
|
19688
|
-
console.error('
|
|
19636
|
+
console.error('The nested object layers of the serialized data exceed the maximum limit.');
|
|
19689
19637
|
return;
|
|
19690
19638
|
}
|
|
19691
|
-
if (property
|
|
19639
|
+
if (isArray(property)) {
|
|
19692
19640
|
const res = [];
|
|
19693
19641
|
for (const value of property){
|
|
19694
19642
|
res.push((yield SerializationHelper.deserializePropertyAsync(value, engine, level + 1, type)));
|
|
@@ -19698,16 +19646,14 @@ class SerializationHelper {
|
|
|
19698
19646
|
} else if (SerializationHelper.checkDataPath(property)) {
|
|
19699
19647
|
const res = yield engine.assetLoader.loadGUIDAsync(property.id);
|
|
19700
19648
|
return res;
|
|
19701
|
-
} else if (property
|
|
19649
|
+
} else if (isObject(property) && property.constructor === Object) {
|
|
19702
19650
|
let res;
|
|
19703
19651
|
if (type) {
|
|
19704
|
-
|
|
19705
|
-
res = new classConstructor();
|
|
19652
|
+
res = new type();
|
|
19706
19653
|
} else {
|
|
19707
19654
|
res = {};
|
|
19708
19655
|
}
|
|
19709
19656
|
for (const key of Object.keys(property)){
|
|
19710
|
-
// @ts-expect-error
|
|
19711
19657
|
res[key] = SerializationHelper.deserializeProperty(property[key], engine, level + 1);
|
|
19712
19658
|
}
|
|
19713
19659
|
return res;
|
|
@@ -19718,7 +19664,7 @@ class SerializationHelper {
|
|
|
19718
19664
|
}
|
|
19719
19665
|
static serializeObjectProperty(objectProperty, serializedData, level) {
|
|
19720
19666
|
if (level > 14) {
|
|
19721
|
-
console.error('
|
|
19667
|
+
console.error('The nested object layers of the serialized data exceed the maximum limit.');
|
|
19722
19668
|
return;
|
|
19723
19669
|
}
|
|
19724
19670
|
if (!serializedData) {
|
|
@@ -19729,17 +19675,17 @@ class SerializationHelper {
|
|
|
19729
19675
|
if (typeof value === 'number' || typeof value === 'string' || typeof value === 'boolean' || SerializationHelper.checkTypedArray(objectProperty)) {
|
|
19730
19676
|
// TODO json 数据避免传 typedArray
|
|
19731
19677
|
serializedData[key] = value;
|
|
19732
|
-
} else if (value
|
|
19678
|
+
} else if (isArray(value)) {
|
|
19733
19679
|
if (!serializedData[key]) {
|
|
19734
19680
|
serializedData[key] = [];
|
|
19735
19681
|
}
|
|
19736
19682
|
SerializationHelper.serializeArrayProperty(value, serializedData[key], level + 1);
|
|
19737
|
-
} else if (value
|
|
19683
|
+
} else if (EffectsObject.is(value)) {
|
|
19738
19684
|
// TODO 处理 EffectsObject 递归序列化
|
|
19739
19685
|
serializedData[key] = {
|
|
19740
19686
|
id: value.getInstanceId()
|
|
19741
19687
|
};
|
|
19742
|
-
} else if (value
|
|
19688
|
+
} else if (isObject(value)) {
|
|
19743
19689
|
if (!serializedData[key]) {
|
|
19744
19690
|
serializedData[key] = {};
|
|
19745
19691
|
}
|
|
@@ -19749,7 +19695,7 @@ class SerializationHelper {
|
|
|
19749
19695
|
}
|
|
19750
19696
|
static serializeArrayProperty(arrayProperty, serializedData, level) {
|
|
19751
19697
|
if (level > 14) {
|
|
19752
|
-
console.error('
|
|
19698
|
+
console.error('The nested object layers of the serialized data exceed the maximum limit.');
|
|
19753
19699
|
return;
|
|
19754
19700
|
}
|
|
19755
19701
|
if (!serializedData) {
|
|
@@ -19760,17 +19706,17 @@ class SerializationHelper {
|
|
|
19760
19706
|
if (typeof value === 'number' || typeof value === 'string' || typeof value === 'boolean' || SerializationHelper.checkTypedArray(arrayProperty)) {
|
|
19761
19707
|
// TODO json 数据避免传 typedArray
|
|
19762
19708
|
serializedData[i] = value;
|
|
19763
|
-
} else if (value
|
|
19709
|
+
} else if (isArray(value)) {
|
|
19764
19710
|
if (!serializedData[i]) {
|
|
19765
19711
|
serializedData[i] = [];
|
|
19766
19712
|
}
|
|
19767
|
-
|
|
19768
|
-
} else if (value
|
|
19713
|
+
SerializationHelper.serializeArrayProperty(value, serializedData[i], level + 1);
|
|
19714
|
+
} else if (EffectsObject.is(value)) {
|
|
19769
19715
|
// TODO 处理 EffectsObject 递归序列化
|
|
19770
19716
|
serializedData[i] = {
|
|
19771
19717
|
id: value.getInstanceId()
|
|
19772
19718
|
};
|
|
19773
|
-
} else if (value
|
|
19719
|
+
} else if (isObject(value)) {
|
|
19774
19720
|
if (!serializedData[i]) {
|
|
19775
19721
|
serializedData[i] = {};
|
|
19776
19722
|
}
|
|
@@ -19791,7 +19737,7 @@ class SerializationHelper {
|
|
|
19791
19737
|
let effectsObject;
|
|
19792
19738
|
const effectsObjectData = this.findData(guid);
|
|
19793
19739
|
if (!effectsObjectData) {
|
|
19794
|
-
console.error(
|
|
19740
|
+
console.error(`Object data with uuid: ${guid} not found.`);
|
|
19795
19741
|
return undefined;
|
|
19796
19742
|
}
|
|
19797
19743
|
switch(effectsObjectData.dataType){
|
|
@@ -19813,7 +19759,7 @@ class SerializationHelper {
|
|
|
19813
19759
|
}
|
|
19814
19760
|
}
|
|
19815
19761
|
if (!effectsObject) {
|
|
19816
|
-
console.error(
|
|
19762
|
+
console.error(`Constructor for DataType: ${effectsObjectData.dataType} not found.`);
|
|
19817
19763
|
return undefined;
|
|
19818
19764
|
}
|
|
19819
19765
|
effectsObject.setInstanceId(effectsObjectData.id);
|
|
@@ -19832,12 +19778,12 @@ class SerializationHelper {
|
|
|
19832
19778
|
const effectsObjectData = _this.findData(guid);
|
|
19833
19779
|
if (!effectsObjectData) {
|
|
19834
19780
|
if (!_this.engine.database) {
|
|
19835
|
-
console.error(
|
|
19781
|
+
console.error(`Object data with uuid: ${guid} not found.`);
|
|
19836
19782
|
return undefined;
|
|
19837
19783
|
}
|
|
19838
19784
|
effectsObject = yield _this.engine.database.loadGUID(guid);
|
|
19839
19785
|
if (!effectsObject) {
|
|
19840
|
-
console.error(
|
|
19786
|
+
console.error(`Disk data with uuid: ${guid} not found.`);
|
|
19841
19787
|
return undefined;
|
|
19842
19788
|
}
|
|
19843
19789
|
_this.engine.addInstance(effectsObject);
|
|
@@ -19862,7 +19808,7 @@ class SerializationHelper {
|
|
|
19862
19808
|
}
|
|
19863
19809
|
}
|
|
19864
19810
|
if (!effectsObject) {
|
|
19865
|
-
console.error(
|
|
19811
|
+
console.error(`Constructor for DataType: ${effectsObjectData.dataType} not found.`);
|
|
19866
19812
|
return undefined;
|
|
19867
19813
|
}
|
|
19868
19814
|
effectsObject.setInstanceId(effectsObjectData.id);
|
|
@@ -20701,8 +20647,6 @@ function getStandardCameraContent(model) {
|
|
|
20701
20647
|
/**
|
|
20702
20648
|
* 3.0 以下版本数据适配(runtime 2.0及以上版本支持)
|
|
20703
20649
|
*/ function version30Migration(json) {
|
|
20704
|
-
var // 更正 spine 数据中的 images 属性
|
|
20705
|
-
_json_spines;
|
|
20706
20650
|
var // 兼容老版本数据中不存在textures的情况
|
|
20707
20651
|
_result;
|
|
20708
20652
|
const result = _extends({}, json, {
|
|
@@ -20712,7 +20656,8 @@ function getStandardCameraContent(model) {
|
|
|
20712
20656
|
materials: [],
|
|
20713
20657
|
shaders: [],
|
|
20714
20658
|
geometries: [],
|
|
20715
|
-
animations: []
|
|
20659
|
+
animations: [],
|
|
20660
|
+
miscs: []
|
|
20716
20661
|
});
|
|
20717
20662
|
// image数据添加 guid
|
|
20718
20663
|
for (const image of result.images){
|
|
@@ -20741,17 +20686,10 @@ function getStandardCameraContent(model) {
|
|
|
20741
20686
|
});
|
|
20742
20687
|
}
|
|
20743
20688
|
}
|
|
20744
|
-
|
|
20745
|
-
|
|
20746
|
-
|
|
20747
|
-
|
|
20748
|
-
const textureId = (_json_textures_spine_images_i = json.textures[spine.images[i]]) == null ? void 0 : _json_textures_spine_images_i.id;
|
|
20749
|
-
//@ts-expect-error
|
|
20750
|
-
spine.images[i] = {
|
|
20751
|
-
id: textureId
|
|
20752
|
-
};
|
|
20753
|
-
}
|
|
20754
|
-
});
|
|
20689
|
+
// 处理老版本数据中 bins 没有 id 的情况
|
|
20690
|
+
if (json.bins) {
|
|
20691
|
+
convertBinaryAsset(json.bins, result);
|
|
20692
|
+
}
|
|
20755
20693
|
const itemOldIdToGuidMap = {};
|
|
20756
20694
|
const guidToItemMap = {};
|
|
20757
20695
|
// 更正Composition.endBehavior
|
|
@@ -20972,6 +20910,10 @@ function getStandardCameraContent(model) {
|
|
|
20972
20910
|
//@ts-expect-error
|
|
20973
20911
|
item.type = 'orientation-transformer';
|
|
20974
20912
|
}
|
|
20913
|
+
// Spine 元素转为 guid 索引
|
|
20914
|
+
if (item.type === ItemType.spine && json.spines && json.spines.length !== 0) {
|
|
20915
|
+
convertSpineData(json.spines[item.content.options.spine], item.content, result);
|
|
20916
|
+
}
|
|
20975
20917
|
// item 的 content 转为 component data 加入 JSONScene.components
|
|
20976
20918
|
if (item.type === ItemType.sprite || item.type === ItemType.particle || item.type === ItemType.mesh || item.type === ItemType.skybox || item.type === ItemType.light || item.type === 'camera' || item.type === ItemType.tree || item.type === ItemType.interact || item.type === ItemType.camera || item.type === ItemType.text || item.type === ItemType.spine || item.type === 'editor-gizmo' || item.type === 'orientation-transformer') {
|
|
20977
20919
|
item.components = [];
|
|
@@ -21215,27 +21157,55 @@ function convertTimelineAsset(composition, guidToItemMap, jsonScene) {
|
|
|
21215
21157
|
id: timelineAssetData.id
|
|
21216
21158
|
};
|
|
21217
21159
|
composition.sceneBindings = sceneBindings;
|
|
21218
|
-
|
|
21219
|
-
jsonScene.animations = [];
|
|
21220
|
-
}
|
|
21221
|
-
// @ts-expect-error
|
|
21222
|
-
jsonScene.animations.push(timelineAssetData);
|
|
21160
|
+
jsonScene.miscs.push(timelineAssetData);
|
|
21223
21161
|
for (const trackData of trackDatas){
|
|
21224
21162
|
//@ts-expect-error
|
|
21225
|
-
jsonScene.
|
|
21163
|
+
jsonScene.miscs.push(trackData);
|
|
21226
21164
|
}
|
|
21227
21165
|
for (const playableAsset of playableAssetDatas){
|
|
21228
21166
|
//@ts-expect-error
|
|
21229
|
-
jsonScene.
|
|
21167
|
+
jsonScene.miscs.push(playableAsset);
|
|
21230
21168
|
}
|
|
21231
21169
|
}
|
|
21170
|
+
function convertBinaryAsset(bins, jsonScene) {
|
|
21171
|
+
//@ts-expect-error
|
|
21172
|
+
jsonScene.bins = bins.map((bin)=>({
|
|
21173
|
+
url: bin.url,
|
|
21174
|
+
'dataType': 'BinaryAsset',
|
|
21175
|
+
id: generateGUID()
|
|
21176
|
+
}));
|
|
21177
|
+
}
|
|
21178
|
+
function convertSpineData(resource, content, jsonScene) {
|
|
21179
|
+
//@ts-expect-error
|
|
21180
|
+
content.resource = {
|
|
21181
|
+
'atlas': {
|
|
21182
|
+
'bins': {
|
|
21183
|
+
//@ts-expect-error
|
|
21184
|
+
'id': jsonScene.bins[resource.atlas[1][0]].id
|
|
21185
|
+
},
|
|
21186
|
+
'source': resource.atlas[1].slice(1)
|
|
21187
|
+
},
|
|
21188
|
+
'skeleton': {
|
|
21189
|
+
'bins': {
|
|
21190
|
+
//@ts-expect-error
|
|
21191
|
+
'id': jsonScene.bins[resource.skeleton[1][0]].id
|
|
21192
|
+
},
|
|
21193
|
+
'source': resource.skeleton[1].slice(1)
|
|
21194
|
+
},
|
|
21195
|
+
'skeletonType': resource.skeletonType,
|
|
21196
|
+
'images': resource.images.map((i)=>({
|
|
21197
|
+
//@ts-expect-error
|
|
21198
|
+
id: jsonScene.textures[i].id
|
|
21199
|
+
}))
|
|
21200
|
+
};
|
|
21201
|
+
}
|
|
21232
21202
|
|
|
21233
21203
|
const v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
|
|
21234
21204
|
const standardVersion = /^(\d+)\.(\d+)$/;
|
|
21235
21205
|
let reverseParticle = false;
|
|
21236
21206
|
function getStandardJSON(json) {
|
|
21237
21207
|
if (!json || typeof json !== 'object') {
|
|
21238
|
-
throw Error('
|
|
21208
|
+
throw new Error('Invalid input: Expected a JSON object.');
|
|
21239
21209
|
}
|
|
21240
21210
|
// 修正老版本数据中,meshItem 以及 lightItem 结束行为错误问题
|
|
21241
21211
|
version22Migration(json);
|
|
@@ -21256,7 +21226,7 @@ function getStandardJSON(json) {
|
|
|
21256
21226
|
}
|
|
21257
21227
|
return json;
|
|
21258
21228
|
}
|
|
21259
|
-
throw Error(
|
|
21229
|
+
throw new Error(`Invalid JSON version: ${json.version}.`);
|
|
21260
21230
|
}
|
|
21261
21231
|
let currentVersion = '1.0';
|
|
21262
21232
|
function getStandardJSONFromV0(json) {
|
|
@@ -21342,7 +21312,7 @@ function getStandardImage(image, index, imageTags) {
|
|
|
21342
21312
|
} else if (image && image.sourceType) {
|
|
21343
21313
|
return image;
|
|
21344
21314
|
}
|
|
21345
|
-
throw Error('
|
|
21315
|
+
throw new Error('Invalid image type.');
|
|
21346
21316
|
}
|
|
21347
21317
|
function getStandardComposition(composition, opt = {}) {
|
|
21348
21318
|
var _composition_meta;
|
|
@@ -21609,7 +21579,7 @@ function _combineImageTemplate() {
|
|
|
21609
21579
|
image = url;
|
|
21610
21580
|
}
|
|
21611
21581
|
if (!image) {
|
|
21612
|
-
throw new Error('
|
|
21582
|
+
throw new Error('Image not provided.');
|
|
21613
21583
|
}
|
|
21614
21584
|
if (!template) {
|
|
21615
21585
|
return image;
|
|
@@ -21683,7 +21653,7 @@ let seed = 1;
|
|
|
21683
21653
|
cancelLoading = true;
|
|
21684
21654
|
_this.removeTimer(loadTimer);
|
|
21685
21655
|
const totalTime = performance.now() - startTime;
|
|
21686
|
-
reject(new Error(`Load time out: totalTime: ${totalTime.toFixed(4)}ms ${timeInfos.join(' ')}, url: ${assetUrl}
|
|
21656
|
+
reject(new Error(`Load time out: totalTime: ${totalTime.toFixed(4)}ms ${timeInfos.join(' ')}, url: ${assetUrl}.`));
|
|
21687
21657
|
}, _this.timeout * 1000);
|
|
21688
21658
|
_this.timers.push(loadTimer);
|
|
21689
21659
|
});
|
|
@@ -21695,7 +21665,7 @@ let seed = 1;
|
|
|
21695
21665
|
timeInfos.push(`[${label}: ${(performance.now() - st).toFixed(2)}]`);
|
|
21696
21666
|
return result;
|
|
21697
21667
|
} catch (e) {
|
|
21698
|
-
throw new Error(`Load error in ${label}, ${e}
|
|
21668
|
+
throw new Error(`Load error in ${label}, ${e}.`);
|
|
21699
21669
|
}
|
|
21700
21670
|
}
|
|
21701
21671
|
throw new Error('Load canceled.');
|
|
@@ -21766,7 +21736,7 @@ let seed = 1;
|
|
|
21766
21736
|
yield hookTimeInfo('processPlugins', ()=>pluginSystem.loadResources(scene, _this.options));
|
|
21767
21737
|
}
|
|
21768
21738
|
const totalTime = performance.now() - startTime;
|
|
21769
|
-
logger.info(`Load asset: totalTime: ${totalTime.toFixed(4)}ms ${timeInfos.join(' ')}, url: ${assetUrl}
|
|
21739
|
+
logger.info(`Load asset: totalTime: ${totalTime.toFixed(4)}ms ${timeInfos.join(' ')}, url: ${assetUrl}.`);
|
|
21770
21740
|
window.clearTimeout(loadTimer);
|
|
21771
21741
|
_this.removeTimer(loadTimer);
|
|
21772
21742
|
scene.totalTime = totalTime;
|
|
@@ -21787,7 +21757,7 @@ let seed = 1;
|
|
|
21787
21757
|
const shaderLibrary = renderer == null ? void 0 : renderer.getShaderLibrary();
|
|
21788
21758
|
yield pluginSystem == null ? void 0 : pluginSystem.precompile(compositions, renderer, options);
|
|
21789
21759
|
yield new Promise((resolve)=>{
|
|
21790
|
-
shaderLibrary.compileAllShaders(()=>{
|
|
21760
|
+
shaderLibrary == null ? void 0 : shaderLibrary.compileAllShaders(()=>{
|
|
21791
21761
|
resolve(null);
|
|
21792
21762
|
});
|
|
21793
21763
|
});
|
|
@@ -21838,7 +21808,7 @@ let seed = 1;
|
|
|
21838
21808
|
if (passRenderLevel(bin.renderLevel, renderLevel)) {
|
|
21839
21809
|
return _this.loadBins(new URL(bin.url, baseUrl).href);
|
|
21840
21810
|
}
|
|
21841
|
-
throw new Error(`Invalid bins source: ${JSON.stringify(bins)}
|
|
21811
|
+
throw new Error(`Invalid bins source: ${JSON.stringify(bins)}.`);
|
|
21842
21812
|
});
|
|
21843
21813
|
return Promise.all(jobs);
|
|
21844
21814
|
})();
|
|
@@ -21855,7 +21825,7 @@ let seed = 1;
|
|
|
21855
21825
|
if (font.fontURL && !AssetManager.fonts.has(font.fontFamily)) {
|
|
21856
21826
|
if (!isValidFontFamily(font.fontFamily)) {
|
|
21857
21827
|
// 在所有设备上提醒开发者
|
|
21858
|
-
console.warn(`Risky font family: ${font.fontFamily}
|
|
21828
|
+
console.warn(`Risky font family: ${font.fontFamily}.`);
|
|
21859
21829
|
}
|
|
21860
21830
|
try {
|
|
21861
21831
|
const url = new URL(font.fontURL, _this.baseUrl).href;
|
|
@@ -21867,7 +21837,7 @@ let seed = 1;
|
|
|
21867
21837
|
AssetManager.fonts.add(font.fontFamily);
|
|
21868
21838
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
21869
21839
|
} catch (e) {
|
|
21870
|
-
logger.warn(`Invalid font family or font source: ${JSON.stringify(font.fontURL)}
|
|
21840
|
+
logger.warn(`Invalid font family or font source: ${JSON.stringify(font.fontURL)}.`);
|
|
21871
21841
|
}
|
|
21872
21842
|
}
|
|
21873
21843
|
}));
|
|
@@ -21909,7 +21879,7 @@ let seed = 1;
|
|
|
21909
21879
|
}
|
|
21910
21880
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
21911
21881
|
} catch (e) {
|
|
21912
|
-
throw new Error(`Failed to load. Check the template or if the URL is ${isVideo ? 'video' : 'image'} type, URL: ${url}, Error: ${e.message}
|
|
21882
|
+
throw new Error(`Failed to load. Check the template or if the URL is ${isVideo ? 'video' : 'image'} type, URL: ${url}, Error: ${e.message}.`);
|
|
21913
21883
|
}
|
|
21914
21884
|
}
|
|
21915
21885
|
} else if ('compressed' in img && useCompressedTexture && compressedTexture) {
|
|
@@ -21958,9 +21928,9 @@ let seed = 1;
|
|
|
21958
21928
|
}
|
|
21959
21929
|
if ('mipmaps' in texOpts) {
|
|
21960
21930
|
try {
|
|
21961
|
-
return yield deserializeMipmapTexture(texOpts, bins, jsonScene.bins
|
|
21931
|
+
return yield deserializeMipmapTexture(texOpts, bins, engine, jsonScene.bins);
|
|
21962
21932
|
} catch (e) {
|
|
21963
|
-
throw new Error(`
|
|
21933
|
+
throw new Error(`Load texture ${idx} fails, error message: ${e}.`);
|
|
21964
21934
|
}
|
|
21965
21935
|
}
|
|
21966
21936
|
const { source } = texOpts;
|
|
@@ -21977,7 +21947,7 @@ let seed = 1;
|
|
|
21977
21947
|
tex.dataType = DataType.Texture;
|
|
21978
21948
|
return tex.sourceType === exports.TextureSourceType.compressed ? tex : _extends({}, tex, texOpts);
|
|
21979
21949
|
}
|
|
21980
|
-
throw new Error(`Invalid texture source: ${source}
|
|
21950
|
+
throw new Error(`Invalid texture source: ${source}.`);
|
|
21981
21951
|
}));
|
|
21982
21952
|
return Promise.all(jobs);
|
|
21983
21953
|
})();
|
|
@@ -22088,7 +22058,7 @@ function createTextureOptionsBySource(image, sourceFrom) {
|
|
|
22088
22058
|
magFilter: glContext.NEAREST
|
|
22089
22059
|
};
|
|
22090
22060
|
}
|
|
22091
|
-
throw new Error('Invalid texture options');
|
|
22061
|
+
throw new Error('Invalid texture options.');
|
|
22092
22062
|
}
|
|
22093
22063
|
|
|
22094
22064
|
const tmpScale = new Vector3(1, 1, 1);
|
|
@@ -22395,7 +22365,7 @@ let listOrder = 0;
|
|
|
22395
22365
|
if (itemProps.type === ItemType.composition) {
|
|
22396
22366
|
const refId = sourceItemData.content.options.refId;
|
|
22397
22367
|
if (!this.refCompositions.get(refId)) {
|
|
22398
|
-
throw new Error(
|
|
22368
|
+
throw new Error(`Invalid ref composition id: ${refId}.`);
|
|
22399
22369
|
}
|
|
22400
22370
|
const ref = this.getContent(this.refCompositions.get(refId));
|
|
22401
22371
|
if (!this.refCompositionProps.has(refId)) {
|
|
@@ -22489,7 +22459,7 @@ let listOrder = 0;
|
|
|
22489
22459
|
const { jsonScene, renderLevel, textureOptions, pluginSystem, totalTime } = scene;
|
|
22490
22460
|
const { compositions, imgUsage, compositionId } = jsonScene;
|
|
22491
22461
|
if (!textureOptions) {
|
|
22492
|
-
throw new Error('scene.textures expected');
|
|
22462
|
+
throw new Error('scene.textures expected.');
|
|
22493
22463
|
}
|
|
22494
22464
|
const cachedTextures = textureOptions;
|
|
22495
22465
|
for (const comp of compositions){
|
|
@@ -22500,7 +22470,7 @@ let listOrder = 0;
|
|
|
22500
22470
|
}
|
|
22501
22471
|
}
|
|
22502
22472
|
if (!this.composition) {
|
|
22503
|
-
throw new Error(
|
|
22473
|
+
throw new Error(`Invalid composition id: ${compositionId}.`);
|
|
22504
22474
|
}
|
|
22505
22475
|
this.jsonScene = jsonScene;
|
|
22506
22476
|
this.renderLevel = renderLevel;
|
|
@@ -22870,7 +22840,7 @@ let listOrder = 0;
|
|
|
22870
22840
|
}
|
|
22871
22841
|
parent.children.push(item);
|
|
22872
22842
|
} else {
|
|
22873
|
-
throw Error('
|
|
22843
|
+
throw new Error('The element references a non-existent element, please check the data.');
|
|
22874
22844
|
}
|
|
22875
22845
|
}
|
|
22876
22846
|
}
|
|
@@ -23101,7 +23071,7 @@ let listOrder = 0;
|
|
|
23101
23071
|
* 合成整体在水平方向移动 x 像素,垂直方向移动 y 像素
|
|
23102
23072
|
*/ translateByPixel(x, y) {
|
|
23103
23073
|
if (!this.renderer) {
|
|
23104
|
-
console.warn('
|
|
23074
|
+
console.warn('Renderer not assigned. Operation aborted.');
|
|
23105
23075
|
return;
|
|
23106
23076
|
}
|
|
23107
23077
|
this.rootItem.translateByPixel(x, y);
|
|
@@ -23115,7 +23085,7 @@ let listOrder = 0;
|
|
|
23115
23085
|
* @param y - y 坐标
|
|
23116
23086
|
*/ setPositionByPixel(x, y) {
|
|
23117
23087
|
if (!this.renderer) {
|
|
23118
|
-
console.warn('
|
|
23088
|
+
console.warn('Renderer not assigned. Operation aborted.');
|
|
23119
23089
|
return;
|
|
23120
23090
|
}
|
|
23121
23091
|
this.rootItem.setPositionByPixel(x, y);
|
|
@@ -23202,11 +23172,11 @@ let listOrder = 0;
|
|
|
23202
23172
|
/**
|
|
23203
23173
|
* 销毁状态位
|
|
23204
23174
|
*/ this.destroyed = false;
|
|
23175
|
+
this.postLoaders = [];
|
|
23205
23176
|
/**
|
|
23206
23177
|
* 合成暂停/播放 标识
|
|
23207
23178
|
*/ this.paused = false;
|
|
23208
23179
|
this.lastVideoUpdateTime = 0;
|
|
23209
|
-
this.postLoaders = [];
|
|
23210
23180
|
const { reusable = false, speed = 1, baseRenderOrder = 0, renderer, onPlayerPause, onMessageItem, onEnd, event, width, height } = props;
|
|
23211
23181
|
this.compositionSourceManager = new CompositionSourceManager(scene, renderer.engine);
|
|
23212
23182
|
scene.jsonScene.imgUsage = undefined;
|
|
@@ -23291,7 +23261,7 @@ let listOrder = 0;
|
|
|
23291
23261
|
}
|
|
23292
23262
|
addPackageDatas(scene) {
|
|
23293
23263
|
const { jsonScene, textureOptions = [] } = scene;
|
|
23294
|
-
const { items = [], materials = [], shaders = [], geometries = [], components = [], animations = [], bins = [] } = jsonScene;
|
|
23264
|
+
const { items = [], materials = [], shaders = [], geometries = [], components = [], animations = [], bins = [], miscs = [] } = jsonScene;
|
|
23295
23265
|
for (const vfxItemData of items){
|
|
23296
23266
|
this.addEffectsObjectData(vfxItemData);
|
|
23297
23267
|
}
|
|
@@ -23310,6 +23280,9 @@ let listOrder = 0;
|
|
|
23310
23280
|
for (const animationData of animations){
|
|
23311
23281
|
this.addEffectsObjectData(animationData);
|
|
23312
23282
|
}
|
|
23283
|
+
for (const miscData of miscs){
|
|
23284
|
+
this.addEffectsObjectData(miscData);
|
|
23285
|
+
}
|
|
23313
23286
|
for(let i = 0; i < bins.length; i++){
|
|
23314
23287
|
const binaryData = bins[i];
|
|
23315
23288
|
const binaryBuffer = scene.bins[i];
|
|
@@ -23427,7 +23400,7 @@ let listOrder = 0;
|
|
|
23427
23400
|
info.push(`Tex ${this.textures.length}`);
|
|
23428
23401
|
}
|
|
23429
23402
|
if (info.length > 0) {
|
|
23430
|
-
logger.warn(`Release GPU memory: ${info.join(', ')}
|
|
23403
|
+
logger.warn(`Release GPU memory: ${info.join(', ')}.`);
|
|
23431
23404
|
}
|
|
23432
23405
|
this.renderPasses.forEach((pass)=>pass.dispose());
|
|
23433
23406
|
this.meshes.forEach((mesh)=>mesh.dispose());
|
|
@@ -23552,7 +23525,7 @@ let listOrder = 0;
|
|
|
23552
23525
|
* @param ticker - 定时器类
|
|
23553
23526
|
*/ add(ticker) {
|
|
23554
23527
|
if (typeof ticker !== 'function') {
|
|
23555
|
-
throw new Error('
|
|
23528
|
+
throw new Error('The tick object must implement the tick method.');
|
|
23556
23529
|
}
|
|
23557
23530
|
this.tickers.push(ticker);
|
|
23558
23531
|
}
|
|
@@ -23684,7 +23657,9 @@ exports.SubCompositionPlayableAsset = SubCompositionPlayableAsset;
|
|
|
23684
23657
|
exports.SubCompositionTrack = SubCompositionTrack;
|
|
23685
23658
|
exports.TEMPLATE_USE_OFFSCREEN_CANVAS = TEMPLATE_USE_OFFSCREEN_CANVAS;
|
|
23686
23659
|
exports.TextComponent = TextComponent;
|
|
23660
|
+
exports.TextLayout = TextLayout;
|
|
23687
23661
|
exports.TextLoader = TextLoader;
|
|
23662
|
+
exports.TextStyle = TextStyle;
|
|
23688
23663
|
exports.Texture = Texture;
|
|
23689
23664
|
exports.TextureFactory = TextureFactory;
|
|
23690
23665
|
exports.Ticker = Ticker;
|
|
@@ -23717,12 +23692,11 @@ exports.compatibleVert = compatible_vert;
|
|
|
23717
23692
|
exports.createCopyShader = createCopyShader;
|
|
23718
23693
|
exports.createGLContext = createGLContext;
|
|
23719
23694
|
exports.createKeyFrameMeta = createKeyFrameMeta;
|
|
23720
|
-
exports.
|
|
23695
|
+
exports.createShaderWithMacros = createShaderWithMacros;
|
|
23721
23696
|
exports.createShape = createShape;
|
|
23722
23697
|
exports.createVFXItem = createVFXItem;
|
|
23723
23698
|
exports.createValueGetter = createValueGetter;
|
|
23724
23699
|
exports.decimalEqual = decimalEqual;
|
|
23725
|
-
exports.deepClone = deepClone;
|
|
23726
23700
|
exports.defaultGlobalVolume = defaultGlobalVolume;
|
|
23727
23701
|
exports.defaultPlugins = defaultPlugins;
|
|
23728
23702
|
exports.deserializeMipmapTexture = deserializeMipmapTexture;
|
|
@@ -23809,7 +23783,7 @@ exports.particleUniformTypeMap = particleUniformTypeMap;
|
|
|
23809
23783
|
exports.particleVert = particleVert;
|
|
23810
23784
|
exports.pluginLoaderMap = pluginLoaderMap;
|
|
23811
23785
|
exports.pointOnLine = pointOnLine;
|
|
23812
|
-
exports.
|
|
23786
|
+
exports.randomInRange = randomInRange;
|
|
23813
23787
|
exports.registerPlugin = registerPlugin;
|
|
23814
23788
|
exports.removeItem = removeItem;
|
|
23815
23789
|
exports.rotateVec2 = rotateVec2;
|
|
@@ -23822,7 +23796,6 @@ exports.setMaskMode = setMaskMode;
|
|
|
23822
23796
|
exports.setMaxSpriteMeshItemCount = setMaxSpriteMeshItemCount;
|
|
23823
23797
|
exports.setRayFromCamera = setRayFromCamera;
|
|
23824
23798
|
exports.setSideMode = setSideMode;
|
|
23825
|
-
exports.setSpriteMeshMaxFragmentTextures = setSpriteMeshMaxFragmentTextures;
|
|
23826
23799
|
exports.setSpriteMeshMaxItemCountByGPU = setSpriteMeshMaxItemCountByGPU;
|
|
23827
23800
|
exports.sortByOrder = sortByOrder;
|
|
23828
23801
|
exports.spec = index$1;
|