@galacean/effects-core 2.0.0-alpha.15 → 2.0.0-alpha.17
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-source-manager.d.ts +2 -2
- package/dist/composition.d.ts +0 -4
- 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 +240 -208
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +238 -207
- package/dist/index.mjs.map +1 -1
- package/dist/pass-render-level.d.ts +3 -1
- package/dist/plugins/cal/calculate-item.d.ts +0 -3
- package/dist/plugins/cal/calculate-vfx-item.d.ts +1 -1
- package/dist/plugins/index.d.ts +1 -2
- package/dist/plugins/interact/interact-item.d.ts +1 -1
- package/dist/plugins/particle/particle-system.d.ts +2 -2
- package/dist/plugins/sprite/sprite-item.d.ts +1 -1
- package/dist/plugins/text/index.d.ts +4 -0
- package/dist/plugins/timeline/playables/activation-mixer-playable.d.ts +0 -1
- package/dist/plugins/timeline/track.d.ts +14 -14
- package/dist/scene.d.ts +5 -3
- package/dist/serialization-helper.d.ts +6 -5
- package/dist/shape/shape.d.ts +1 -1
- package/dist/transform.d.ts +3 -3
- package/dist/utils/index.d.ts +21 -13
- package/dist/vfx-item.d.ts +7 -7
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Description: Galacean Effects runtime core for the web
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
|
|
6
|
-
* Version: v2.0.0-alpha.
|
|
6
|
+
* Version: v2.0.0-alpha.17
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
@@ -324,7 +324,6 @@ function isSimulatorCellPhone() {
|
|
|
324
324
|
}
|
|
325
325
|
function isAlipayMiniApp() {
|
|
326
326
|
var _my;
|
|
327
|
-
// @ts-expect-error
|
|
328
327
|
return typeof my !== 'undefined' && ((_my = my) == null ? void 0 : _my.renderTarget) === 'web';
|
|
329
328
|
}
|
|
330
329
|
|
|
@@ -558,8 +557,8 @@ function noop() {}
|
|
|
558
557
|
*
|
|
559
558
|
* @static
|
|
560
559
|
* @function isString
|
|
561
|
-
* @param
|
|
562
|
-
* @return
|
|
560
|
+
* @param obj - 要判断的对象
|
|
561
|
+
* @return
|
|
563
562
|
*/ function isString(obj) {
|
|
564
563
|
return typeof obj === 'string';
|
|
565
564
|
}
|
|
@@ -568,8 +567,8 @@ function noop() {}
|
|
|
568
567
|
*
|
|
569
568
|
* @static
|
|
570
569
|
* @function isArray
|
|
571
|
-
* @param
|
|
572
|
-
* @return
|
|
570
|
+
* @param obj - 要判断的对象
|
|
571
|
+
* @return
|
|
573
572
|
*/ const isArray = Array.isArray || function(obj) {
|
|
574
573
|
return Object.prototype.toString.call(obj) === '[object Array]';
|
|
575
574
|
};
|
|
@@ -578,8 +577,8 @@ function noop() {}
|
|
|
578
577
|
*
|
|
579
578
|
* @static
|
|
580
579
|
* @function isFunction
|
|
581
|
-
* @param
|
|
582
|
-
* @return
|
|
580
|
+
* @param obj - 要判断的对象
|
|
581
|
+
* @return
|
|
583
582
|
*/ function isFunction(obj) {
|
|
584
583
|
return Object.prototype.toString.call(obj) === '[object Function]';
|
|
585
584
|
}
|
|
@@ -588,8 +587,8 @@ function noop() {}
|
|
|
588
587
|
*
|
|
589
588
|
* @static
|
|
590
589
|
* @function isObject
|
|
591
|
-
* @param
|
|
592
|
-
* @return
|
|
590
|
+
* @param obj - 要判断的对象
|
|
591
|
+
* @return
|
|
593
592
|
*/ function isObject(obj) {
|
|
594
593
|
return Object.prototype.toString.call(obj) === '[object Object]';
|
|
595
594
|
}
|
|
@@ -598,25 +597,12 @@ function isCanvas(canvas) {
|
|
|
598
597
|
// 小程序 Canvas 无法使用 instanceof HTMLCanvasElement 判断
|
|
599
598
|
return typeof canvas === 'object' && canvas !== null && ((_canvas_tagName = canvas.tagName) == null ? void 0 : _canvas_tagName.toUpperCase()) === 'CANVAS';
|
|
600
599
|
}
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
}
|
|
608
|
-
const ret = {};
|
|
609
|
-
const kas = Object.keys(obj);
|
|
610
|
-
for(let i = 0; i < kas.length; i++){
|
|
611
|
-
const key = kas[i];
|
|
612
|
-
ret[key] = deepClone(obj[key]);
|
|
613
|
-
}
|
|
614
|
-
return ret;
|
|
615
|
-
}
|
|
616
|
-
return obj;
|
|
617
|
-
}
|
|
618
|
-
// TODO: 改名
|
|
619
|
-
function random(min, max) {
|
|
600
|
+
/**
|
|
601
|
+
* 生成一个位于 min 和 max 之间的随机数
|
|
602
|
+
* @param min
|
|
603
|
+
* @param max
|
|
604
|
+
* @returns
|
|
605
|
+
*/ function randomInRange(min, max) {
|
|
620
606
|
return min + Math.random() * (max - min);
|
|
621
607
|
}
|
|
622
608
|
function throwDestroyedError() {
|
|
@@ -3856,7 +3842,7 @@ var CameraClipMode;
|
|
|
3856
3842
|
* 蒙版形状切分
|
|
3857
3843
|
*/ ValueType[ValueType["SHAPE_SPLITS"] = 11] = "SHAPE_SPLITS";
|
|
3858
3844
|
/**
|
|
3859
|
-
|
|
3845
|
+
* 直线路径
|
|
3860
3846
|
*/ ValueType[ValueType["LINEAR_PATH"] = 12] = "LINEAR_PATH";
|
|
3861
3847
|
/**
|
|
3862
3848
|
* 多色
|
|
@@ -4032,7 +4018,7 @@ var TextAlignment;
|
|
|
4032
4018
|
(function(TextAlignment) {
|
|
4033
4019
|
/**
|
|
4034
4020
|
* text alignment starts from(x,y) to right direction
|
|
4035
|
-
* 从(x,y)开始第一个字符,向右边延伸
|
|
4021
|
+
* 从 (x,y) 开始第一个字符,向右边延伸
|
|
4036
4022
|
*/ TextAlignment[TextAlignment["left"] = 0] = "left";
|
|
4037
4023
|
/**
|
|
4038
4024
|
* (x,y) is middle position of text, where (left + right)/2 =(x,y)
|
|
@@ -4040,7 +4026,7 @@ var TextAlignment;
|
|
|
4040
4026
|
*/ TextAlignment[TextAlignment["middle"] = 1] = "middle";
|
|
4041
4027
|
/**
|
|
4042
4028
|
* text alignment ends with(x,y) from left direction
|
|
4043
|
-
* 从(x,y)结束最后一个字符,向左边延伸
|
|
4029
|
+
* 从 (x,y) 结束最后一个字符,向左边延伸
|
|
4044
4030
|
*/ TextAlignment[TextAlignment["right"] = 2] = "right";
|
|
4045
4031
|
})(TextAlignment || (TextAlignment = {}));
|
|
4046
4032
|
/**
|
|
@@ -4090,6 +4076,7 @@ var DataType;
|
|
|
4090
4076
|
DataType["TimelineAsset"] = "TimelineAsset";
|
|
4091
4077
|
DataType["TransformPlayableAsset"] = "TransformPlayableAsset";
|
|
4092
4078
|
DataType["SpriteColorPlayableAsset"] = "SpriteColorPlayableAsset";
|
|
4079
|
+
DataType["BinaryAsset"] = "BinaryAsset";
|
|
4093
4080
|
// FIXME: 先完成ECS的场景转换,后面移到spec中
|
|
4094
4081
|
DataType["MeshComponent"] = "MeshComponent";
|
|
4095
4082
|
DataType["SkyboxComponent"] = "SkyboxComponent";
|
|
@@ -4098,6 +4085,7 @@ var DataType;
|
|
|
4098
4085
|
DataType["ModelPluginComponent"] = "ModelPluginComponent";
|
|
4099
4086
|
DataType["TreeComponent"] = "TreeComponent";
|
|
4100
4087
|
DataType["AnimationComponent"] = "AnimationComponent";
|
|
4088
|
+
DataType["SpineComponent"] = "SpineComponent";
|
|
4101
4089
|
// Non-EffectObject
|
|
4102
4090
|
DataType["TimelineClip"] = "TimelineClip";
|
|
4103
4091
|
})(DataType || (DataType = {}));
|
|
@@ -4185,11 +4173,11 @@ var VertexBufferSemantic;
|
|
|
4185
4173
|
VertexBufferSemantic["TangentBS3"] = "TANGENT_BS3";
|
|
4186
4174
|
})(VertexBufferSemantic || (VertexBufferSemantic = {}));
|
|
4187
4175
|
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4176
|
+
const BuiltinObjectGUID = {
|
|
4177
|
+
WhiteTexture: 'whitetexture00000000000000000000',
|
|
4178
|
+
PBRShader: 'pbr00000000000000000000000000000',
|
|
4179
|
+
UnlitShader: 'unlit000000000000000000000000000'
|
|
4180
|
+
};
|
|
4193
4181
|
|
|
4194
4182
|
var index$1 = /*#__PURE__*/Object.freeze({
|
|
4195
4183
|
__proto__: null,
|
|
@@ -4245,15 +4233,20 @@ var index$1 = /*#__PURE__*/Object.freeze({
|
|
|
4245
4233
|
BuiltinObjectGUID: BuiltinObjectGUID
|
|
4246
4234
|
});
|
|
4247
4235
|
|
|
4248
|
-
const effectsClassStore = {};
|
|
4249
4236
|
const decoratorInitialStore = {};
|
|
4250
4237
|
const mergedStore = {};
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4238
|
+
const effectsClassStore = {};
|
|
4239
|
+
function effectsClass(className) {
|
|
4240
|
+
return (target, context)=>{
|
|
4241
|
+
if (effectsClassStore[className]) {
|
|
4242
|
+
console.warn(`Class ${className} 重复注册`);
|
|
4243
|
+
}
|
|
4244
|
+
// TODO: three修改json dataType, 这边重复注册直接 return
|
|
4245
|
+
effectsClassStore[className] = target;
|
|
4246
|
+
};
|
|
4247
|
+
}
|
|
4248
|
+
function serialize(type, sourceName) {
|
|
4249
|
+
return generateSerializableMember(type, sourceName); // value member
|
|
4257
4250
|
}
|
|
4258
4251
|
function getMergedStore(target) {
|
|
4259
4252
|
const classKey = target.constructor.name;
|
|
@@ -4278,34 +4271,32 @@ function getMergedStore(target) {
|
|
|
4278
4271
|
}
|
|
4279
4272
|
return store;
|
|
4280
4273
|
}
|
|
4281
|
-
function serialize(type, sourceName) {
|
|
4282
|
-
return generateSerializableMember(type, sourceName); // value member
|
|
4283
|
-
}
|
|
4284
|
-
function effectsClass(className) {
|
|
4285
|
-
return (target, context)=>{
|
|
4286
|
-
if (effectsClassStore[className]) {
|
|
4287
|
-
console.warn('Class ' + className + ' 重复注册');
|
|
4288
|
-
}
|
|
4289
|
-
//TODO: three修改json dataType, 这边重复注册直接 return
|
|
4290
|
-
effectsClassStore[className] = target;
|
|
4291
|
-
};
|
|
4292
|
-
}
|
|
4293
4274
|
function generateSerializableMember(type, sourceName) {
|
|
4294
4275
|
return (target, propertyKey)=>{
|
|
4295
4276
|
const classStore = getDirectStore(target);
|
|
4296
4277
|
if (!classStore[propertyKey]) {
|
|
4297
4278
|
classStore[propertyKey] = {
|
|
4298
|
-
type
|
|
4299
|
-
sourceName
|
|
4279
|
+
type,
|
|
4280
|
+
sourceName
|
|
4300
4281
|
};
|
|
4301
4282
|
}
|
|
4302
4283
|
};
|
|
4303
4284
|
}
|
|
4285
|
+
function getDirectStore(target) {
|
|
4286
|
+
const classKey = target.constructor.name;
|
|
4287
|
+
if (!decoratorInitialStore[classKey]) {
|
|
4288
|
+
decoratorInitialStore[classKey] = {};
|
|
4289
|
+
}
|
|
4290
|
+
return decoratorInitialStore[classKey];
|
|
4291
|
+
}
|
|
4304
4292
|
|
|
4305
4293
|
/**
|
|
4306
4294
|
* @since 2.0.0
|
|
4307
4295
|
* @internal
|
|
4308
4296
|
*/ class EffectsObject {
|
|
4297
|
+
static is(obj) {
|
|
4298
|
+
return obj instanceof EffectsObject && 'guid' in obj;
|
|
4299
|
+
}
|
|
4309
4300
|
getInstanceId() {
|
|
4310
4301
|
return this.guid;
|
|
4311
4302
|
}
|
|
@@ -4501,6 +4492,7 @@ __decorate([
|
|
|
4501
4492
|
super(...args);
|
|
4502
4493
|
this.started = false;
|
|
4503
4494
|
this.materials = [];
|
|
4495
|
+
this._priority = 0;
|
|
4504
4496
|
this._enabled = true;
|
|
4505
4497
|
}
|
|
4506
4498
|
}
|
|
@@ -9209,7 +9201,7 @@ class RandomValue extends ValueGetter {
|
|
|
9209
9201
|
this.max = props[1];
|
|
9210
9202
|
}
|
|
9211
9203
|
getValue(time) {
|
|
9212
|
-
return
|
|
9204
|
+
return randomInRange(this.min, this.max);
|
|
9213
9205
|
}
|
|
9214
9206
|
toUniform() {
|
|
9215
9207
|
return new Float32Array([
|
|
@@ -12774,13 +12766,16 @@ const tempColor = [
|
|
|
12774
12766
|
let seed$3 = 0;
|
|
12775
12767
|
class SpriteColorPlayable extends Playable {
|
|
12776
12768
|
processFrame(context) {
|
|
12777
|
-
const
|
|
12769
|
+
const boundObject = context.output.getUserData();
|
|
12770
|
+
if (!(boundObject instanceof VFXItem)) {
|
|
12771
|
+
return;
|
|
12772
|
+
}
|
|
12778
12773
|
if (!this.spriteMaterial) {
|
|
12779
|
-
this.spriteMaterial =
|
|
12774
|
+
this.spriteMaterial = boundObject.getComponent(SpriteComponent).material;
|
|
12780
12775
|
}
|
|
12781
12776
|
let colorInc = vecFill(tempColor, 1);
|
|
12782
12777
|
let colorChanged;
|
|
12783
|
-
const life = this.time /
|
|
12778
|
+
const life = this.time / boundObject.duration;
|
|
12784
12779
|
const opacityOverLifetime = this.opacityOverLifetime;
|
|
12785
12780
|
const colorOverLifetime = this.colorOverLifetime;
|
|
12786
12781
|
if (colorOverLifetime) {
|
|
@@ -12879,7 +12874,6 @@ class SpriteComponent extends RendererComponent {
|
|
|
12879
12874
|
renderer.drawGeometry(geo, material);
|
|
12880
12875
|
}
|
|
12881
12876
|
start() {
|
|
12882
|
-
this.priority = this.item.listIndex;
|
|
12883
12877
|
this.item.getHitTestParams = this.getHitTestParams;
|
|
12884
12878
|
}
|
|
12885
12879
|
update(dt) {
|
|
@@ -13777,7 +13771,7 @@ class Cone {
|
|
|
13777
13771
|
// dir + [0,0,1]
|
|
13778
13772
|
dir.z += 1;
|
|
13779
13773
|
return {
|
|
13780
|
-
position: position.multiply(
|
|
13774
|
+
position: position.multiply(randomInRange(0, 1)),
|
|
13781
13775
|
direction: dir.normalize()
|
|
13782
13776
|
};
|
|
13783
13777
|
}
|
|
@@ -13789,7 +13783,7 @@ class Cone {
|
|
|
13789
13783
|
}
|
|
13790
13784
|
function getArcAngle(arc, arcMode, opt) {
|
|
13791
13785
|
if (arcMode === ShapeArcMode.RANDOM) {
|
|
13792
|
-
arc =
|
|
13786
|
+
arc = randomInRange(0, arc);
|
|
13793
13787
|
} else if (arcMode === ShapeArcMode.UNIDIRECTIONAL_CYCLE) {
|
|
13794
13788
|
const d = opt.index % (opt.total + 1);
|
|
13795
13789
|
arc = arc / opt.total * d;
|
|
@@ -13821,8 +13815,8 @@ class Circle {
|
|
|
13821
13815
|
}
|
|
13822
13816
|
class Rectangle {
|
|
13823
13817
|
generate(opt) {
|
|
13824
|
-
const x =
|
|
13825
|
-
const y =
|
|
13818
|
+
const x = randomInRange(-this._d, this._d);
|
|
13819
|
+
const y = randomInRange(-this._h, this._h);
|
|
13826
13820
|
return {
|
|
13827
13821
|
direction: new Vector3(0, 0, 1),
|
|
13828
13822
|
position: new Vector3(x, y, 0)
|
|
@@ -13867,7 +13861,7 @@ class RectangleEdge {
|
|
|
13867
13861
|
}
|
|
13868
13862
|
class Edge {
|
|
13869
13863
|
generate(options) {
|
|
13870
|
-
const x = this.arcMode === ShapeArcMode.UNIFORM_BURST ? options.burstIndex % options.burstCount / (options.burstCount - 1) :
|
|
13864
|
+
const x = this.arcMode === ShapeArcMode.UNIFORM_BURST ? options.burstIndex % options.burstCount / (options.burstCount - 1) : randomInRange(0, 1);
|
|
13871
13865
|
return {
|
|
13872
13866
|
direction: new Vector3(0, 1, 0),
|
|
13873
13867
|
position: new Vector3(this._d * (x - 0.5), 0, 0)
|
|
@@ -13885,7 +13879,7 @@ class Donut {
|
|
|
13885
13879
|
generate(opt) {
|
|
13886
13880
|
const dradius = this.donutRadius;
|
|
13887
13881
|
const center = this.radius - dradius;
|
|
13888
|
-
const angle =
|
|
13882
|
+
const angle = randomInRange(0, Math.PI * 2);
|
|
13889
13883
|
const arc = getArcAngle(this.arc, this.arcMode, opt) * DEG2RAD;
|
|
13890
13884
|
const rot = tempMat4$2.setFromRotationZ(arc);
|
|
13891
13885
|
const direction = new Vector3(Math.cos(angle), Math.sin(angle), 0);
|
|
@@ -13905,7 +13899,7 @@ class Donut {
|
|
|
13905
13899
|
const tempMat4$1 = new Matrix4();
|
|
13906
13900
|
class Sphere {
|
|
13907
13901
|
getHorizontalAngle() {
|
|
13908
|
-
return
|
|
13902
|
+
return randomInRange(-90, 90);
|
|
13909
13903
|
}
|
|
13910
13904
|
generate(opt) {
|
|
13911
13905
|
const rz = getArcAngle(this.arc, this.arcMode, opt) * DEG2RAD;
|
|
@@ -13927,7 +13921,7 @@ class Sphere {
|
|
|
13927
13921
|
}
|
|
13928
13922
|
class Hemisphere extends Sphere {
|
|
13929
13923
|
getHorizontalAngle() {
|
|
13930
|
-
return
|
|
13924
|
+
return randomInRange(0, 90);
|
|
13931
13925
|
}
|
|
13932
13926
|
}
|
|
13933
13927
|
|
|
@@ -15248,7 +15242,7 @@ function getTrailMeshShader(trails, particleMaxCount, name, env = '', gpuCapabil
|
|
|
15248
15242
|
* @internal
|
|
15249
15243
|
*/ class ParticleSystemRenderer extends RendererComponent {
|
|
15250
15244
|
start() {
|
|
15251
|
-
this._priority = this.item.
|
|
15245
|
+
this._priority = this.item.renderOrder;
|
|
15252
15246
|
this.particleMesh.gravityModifier.scaleXCoord(this.item.duration);
|
|
15253
15247
|
for (const mesh of this.meshes){
|
|
15254
15248
|
mesh.start();
|
|
@@ -15923,11 +15917,9 @@ class ParticleSystem extends Component {
|
|
|
15923
15917
|
this.props = props;
|
|
15924
15918
|
this.destroyed = false;
|
|
15925
15919
|
const cachePrefix = '';
|
|
15926
|
-
const options = props
|
|
15927
|
-
const
|
|
15928
|
-
const
|
|
15929
|
-
const gravityModifier = positionOverLifetime.gravityOverLifetime;
|
|
15930
|
-
const gravity = ensureVec3(positionOverLifetime.gravity);
|
|
15920
|
+
const { options, positionOverLifetime = {}, shape } = props;
|
|
15921
|
+
const gravityModifier = positionOverLifetime == null ? void 0 : positionOverLifetime.gravityOverLifetime;
|
|
15922
|
+
const gravity = ensureVec3(positionOverLifetime == null ? void 0 : positionOverLifetime.gravity);
|
|
15931
15923
|
const _textureSheetAnimation = props.textureSheetAnimation;
|
|
15932
15924
|
const textureSheetAnimation = _textureSheetAnimation ? {
|
|
15933
15925
|
animationDelay: createValueGetter(_textureSheetAnimation.animationDelay || 0),
|
|
@@ -15938,7 +15930,7 @@ class ParticleSystem extends Component {
|
|
|
15938
15930
|
row: _textureSheetAnimation.row,
|
|
15939
15931
|
total: _textureSheetAnimation.total || _textureSheetAnimation.col * _textureSheetAnimation.row
|
|
15940
15932
|
} : undefined;
|
|
15941
|
-
const startTurbulence = !!(shape && shape.turbulenceX || shape.turbulenceY || shape.turbulenceZ);
|
|
15933
|
+
const startTurbulence = !!(shape && shape.turbulenceX || (shape == null ? void 0 : shape.turbulenceY) || (shape == null ? void 0 : shape.turbulenceZ));
|
|
15942
15934
|
let turbulence;
|
|
15943
15935
|
if (startTurbulence) {
|
|
15944
15936
|
var _shape_turbulenceX, _shape_turbulenceY, _shape_turbulenceZ;
|
|
@@ -15969,7 +15961,7 @@ class ParticleSystem extends Component {
|
|
|
15969
15961
|
}
|
|
15970
15962
|
}
|
|
15971
15963
|
let forceTarget;
|
|
15972
|
-
if (positionOverLifetime.forceTarget) {
|
|
15964
|
+
if (positionOverLifetime == null ? void 0 : positionOverLifetime.forceTarget) {
|
|
15973
15965
|
forceTarget = {
|
|
15974
15966
|
target: positionOverLifetime.target || [
|
|
15975
15967
|
0,
|
|
@@ -16278,13 +16270,13 @@ function randomArrItem(arr, keepArr) {
|
|
|
16278
16270
|
* @internal
|
|
16279
16271
|
*/ class ParticleBehaviourPlayable extends Playable {
|
|
16280
16272
|
start(context) {
|
|
16281
|
-
const
|
|
16282
|
-
if (this.particleSystem) {
|
|
16273
|
+
const boundObject = context.output.getUserData();
|
|
16274
|
+
if (this.particleSystem || !(boundObject instanceof VFXItem)) {
|
|
16283
16275
|
return;
|
|
16284
16276
|
}
|
|
16285
|
-
this.particleSystem =
|
|
16277
|
+
this.particleSystem = boundObject.getComponent(ParticleSystem);
|
|
16286
16278
|
if (this.particleSystem) {
|
|
16287
|
-
this.particleSystem.name =
|
|
16279
|
+
this.particleSystem.name = boundObject.name;
|
|
16288
16280
|
this.particleSystem.start();
|
|
16289
16281
|
this.particleSystem.initEmitterTransform();
|
|
16290
16282
|
}
|
|
@@ -17404,10 +17396,13 @@ const tempPos = new Vector3();
|
|
|
17404
17396
|
}
|
|
17405
17397
|
processFrame(context) {
|
|
17406
17398
|
if (!this.binding) {
|
|
17407
|
-
|
|
17408
|
-
|
|
17399
|
+
const boundObject = context.output.getUserData();
|
|
17400
|
+
if (boundObject instanceof VFXItem) {
|
|
17401
|
+
this.binding = boundObject;
|
|
17402
|
+
this.start();
|
|
17403
|
+
}
|
|
17409
17404
|
}
|
|
17410
|
-
if (this.binding.composition) {
|
|
17405
|
+
if (this.binding && this.binding.composition) {
|
|
17411
17406
|
this.sampleAnimation();
|
|
17412
17407
|
}
|
|
17413
17408
|
}
|
|
@@ -17575,13 +17570,37 @@ AnimationClip = __decorate([
|
|
|
17575
17570
|
], AnimationClip);
|
|
17576
17571
|
class AnimationClipPlayable extends Playable {
|
|
17577
17572
|
processFrame(context) {
|
|
17578
|
-
const
|
|
17579
|
-
if (
|
|
17580
|
-
|
|
17573
|
+
const boundObject = context.output.getUserData();
|
|
17574
|
+
if (!(boundObject instanceof VFXItem)) {
|
|
17575
|
+
return;
|
|
17576
|
+
}
|
|
17577
|
+
if (boundObject.composition) {
|
|
17578
|
+
this.clip.sampleAnimation(boundObject, this.time);
|
|
17581
17579
|
}
|
|
17582
17580
|
}
|
|
17583
17581
|
}
|
|
17584
17582
|
|
|
17583
|
+
/**
|
|
17584
|
+
* @since 2.0.0
|
|
17585
|
+
* @internal
|
|
17586
|
+
*/ class TimelineClip {
|
|
17587
|
+
toLocalTime(time) {
|
|
17588
|
+
let localTime = time - this.start;
|
|
17589
|
+
const duration = this.duration;
|
|
17590
|
+
if (localTime - duration > 0.001) {
|
|
17591
|
+
if (this.endBehaviour === ItemEndBehavior.loop) {
|
|
17592
|
+
localTime = localTime % duration;
|
|
17593
|
+
} else if (this.endBehaviour === ItemEndBehavior.freeze) {
|
|
17594
|
+
localTime = Math.min(duration, localTime);
|
|
17595
|
+
}
|
|
17596
|
+
}
|
|
17597
|
+
return localTime;
|
|
17598
|
+
}
|
|
17599
|
+
constructor(){
|
|
17600
|
+
this.start = 0;
|
|
17601
|
+
this.duration = 0;
|
|
17602
|
+
}
|
|
17603
|
+
}
|
|
17585
17604
|
class TrackAsset extends PlayableAsset {
|
|
17586
17605
|
/**
|
|
17587
17606
|
* 重写该方法以获取自定义对象绑定
|
|
@@ -17662,7 +17681,7 @@ class TrackAsset extends PlayableAsset {
|
|
|
17662
17681
|
}
|
|
17663
17682
|
}
|
|
17664
17683
|
__decorate([
|
|
17665
|
-
serialize(
|
|
17684
|
+
serialize(TimelineClip)
|
|
17666
17685
|
], TrackAsset.prototype, "clips", void 0);
|
|
17667
17686
|
__decorate([
|
|
17668
17687
|
serialize()
|
|
@@ -17675,27 +17694,6 @@ var TrackType;
|
|
|
17675
17694
|
TrackType[TrackType["MasterTrack"] = 0] = "MasterTrack";
|
|
17676
17695
|
TrackType[TrackType["ObjectTrack"] = 1] = "ObjectTrack";
|
|
17677
17696
|
})(TrackType || (TrackType = {}));
|
|
17678
|
-
class TimelineClip {
|
|
17679
|
-
toLocalTime(time) {
|
|
17680
|
-
let localTime = time - this.start;
|
|
17681
|
-
const duration = this.duration;
|
|
17682
|
-
if (localTime - duration > 0.001) {
|
|
17683
|
-
if (this.endBehaviour === ItemEndBehavior.loop) {
|
|
17684
|
-
localTime = localTime % duration;
|
|
17685
|
-
} else if (this.endBehaviour === ItemEndBehavior.freeze) {
|
|
17686
|
-
localTime = Math.min(duration, localTime);
|
|
17687
|
-
}
|
|
17688
|
-
}
|
|
17689
|
-
return localTime;
|
|
17690
|
-
}
|
|
17691
|
-
constructor(){
|
|
17692
|
-
this.start = 0;
|
|
17693
|
-
this.duration = 0;
|
|
17694
|
-
}
|
|
17695
|
-
}
|
|
17696
|
-
TimelineClip = __decorate([
|
|
17697
|
-
effectsClass('TimelineClip')
|
|
17698
|
-
], TimelineClip);
|
|
17699
17697
|
class RuntimeClip {
|
|
17700
17698
|
set enable(value) {
|
|
17701
17699
|
if (value) {
|
|
@@ -17770,10 +17768,6 @@ class ObjectBindingTrack extends TrackAsset {
|
|
|
17770
17768
|
particleClip.endBehaviour = boundItem.endBehavior;
|
|
17771
17769
|
}
|
|
17772
17770
|
}
|
|
17773
|
-
fromData(data) {
|
|
17774
|
-
super.fromData(data);
|
|
17775
|
-
this.data = data;
|
|
17776
|
-
}
|
|
17777
17771
|
}
|
|
17778
17772
|
ObjectBindingTrack = __decorate([
|
|
17779
17773
|
effectsClass('ObjectBindingTrack')
|
|
@@ -17787,13 +17781,11 @@ TransformTrack = __decorate([
|
|
|
17787
17781
|
|
|
17788
17782
|
class ActivationMixerPlayable extends Playable {
|
|
17789
17783
|
processFrame(context) {
|
|
17790
|
-
|
|
17791
|
-
|
|
17792
|
-
}
|
|
17793
|
-
if (!this.bindingItem) {
|
|
17784
|
+
const boundObject = context.output.getUserData();
|
|
17785
|
+
if (!(boundObject instanceof VFXItem)) {
|
|
17794
17786
|
return;
|
|
17795
17787
|
}
|
|
17796
|
-
const
|
|
17788
|
+
const boundItem = boundObject;
|
|
17797
17789
|
let hasInput = false;
|
|
17798
17790
|
for(let i = 0; i < this.getInputCount(); i++){
|
|
17799
17791
|
if (this.getInputWeight(i) > 0) {
|
|
@@ -17802,11 +17794,11 @@ class ActivationMixerPlayable extends Playable {
|
|
|
17802
17794
|
}
|
|
17803
17795
|
}
|
|
17804
17796
|
if (hasInput) {
|
|
17805
|
-
|
|
17806
|
-
this.showRendererComponents(
|
|
17797
|
+
boundItem.transform.setValid(true);
|
|
17798
|
+
this.showRendererComponents(boundItem);
|
|
17807
17799
|
} else {
|
|
17808
|
-
|
|
17809
|
-
this.hideRendererComponents(
|
|
17800
|
+
boundItem.transform.setValid(false);
|
|
17801
|
+
this.hideRendererComponents(boundItem);
|
|
17810
17802
|
}
|
|
17811
17803
|
}
|
|
17812
17804
|
hideRendererComponents(item) {
|
|
@@ -17961,7 +17953,6 @@ function compareTracks(a, b) {
|
|
|
17961
17953
|
this.startTime = startTime;
|
|
17962
17954
|
this.resolveBindings();
|
|
17963
17955
|
this.timelinePlayable = this.timelineAsset.createPlayable(this.graph);
|
|
17964
|
-
this.timelinePlayable.play();
|
|
17965
17956
|
// 重播不销毁元素
|
|
17966
17957
|
if (this.item.endBehavior !== ItemEndBehavior.destroy) {
|
|
17967
17958
|
this.setReusable(true);
|
|
@@ -18173,7 +18164,9 @@ SubCompositionTrack = __decorate([
|
|
|
18173
18164
|
class SubCompositionClipPlayable extends Playable {
|
|
18174
18165
|
processFrame(context) {
|
|
18175
18166
|
const boundObject = context.output.getUserData();
|
|
18176
|
-
boundObject
|
|
18167
|
+
if (boundObject instanceof CompositionComponent) {
|
|
18168
|
+
boundObject.time = this.getTime();
|
|
18169
|
+
}
|
|
18177
18170
|
}
|
|
18178
18171
|
}
|
|
18179
18172
|
|
|
@@ -18343,7 +18336,6 @@ class CanvasPool {
|
|
|
18343
18336
|
return this.elements.shift();
|
|
18344
18337
|
}
|
|
18345
18338
|
if (getConfig(TEMPLATE_USE_OFFSCREEN_CANVAS)) {
|
|
18346
|
-
// @ts-expect-error
|
|
18347
18339
|
return window._createOffscreenCanvas(10, 10);
|
|
18348
18340
|
} else {
|
|
18349
18341
|
// in hongmeng system, create too many canvas will case render error
|
|
@@ -18898,6 +18890,19 @@ class VFXItem extends EffectsObject {
|
|
|
18898
18890
|
return (_this_composition_reusable = (_this_composition = this.composition) == null ? void 0 : _this_composition.reusable) != null ? _this_composition_reusable : false;
|
|
18899
18891
|
}
|
|
18900
18892
|
/**
|
|
18893
|
+
* 元素在合成中的索引
|
|
18894
|
+
*/ get renderOrder() {
|
|
18895
|
+
return this.listIndex;
|
|
18896
|
+
}
|
|
18897
|
+
set renderOrder(value) {
|
|
18898
|
+
if (this.listIndex !== value) {
|
|
18899
|
+
this.listIndex = value;
|
|
18900
|
+
for (const rendererComponent of this.rendererComponents){
|
|
18901
|
+
rendererComponent.priority = value;
|
|
18902
|
+
}
|
|
18903
|
+
}
|
|
18904
|
+
}
|
|
18905
|
+
/**
|
|
18901
18906
|
* 设置元素的动画速度
|
|
18902
18907
|
* @param speed - 速度
|
|
18903
18908
|
*/ setSpeed(speed) {
|
|
@@ -19154,7 +19159,6 @@ class VFXItem extends EffectsObject {
|
|
|
19154
19159
|
this.parentId = parentId;
|
|
19155
19160
|
this.duration = duration;
|
|
19156
19161
|
this.endBehavior = endBehavior;
|
|
19157
|
-
this.listIndex = listIndex;
|
|
19158
19162
|
//@ts-expect-error
|
|
19159
19163
|
this.oldId = data.oldId;
|
|
19160
19164
|
if (!data.content) {
|
|
@@ -19165,17 +19169,11 @@ class VFXItem extends EffectsObject {
|
|
|
19165
19169
|
if (duration <= 0) {
|
|
19166
19170
|
throw Error(`Item duration can't be less than 0, see ${HELP_LINK['Item duration can\'t be less than 0']}`);
|
|
19167
19171
|
}
|
|
19168
|
-
|
|
19169
|
-
|
|
19170
|
-
const newComponent = component;
|
|
19171
|
-
this.components.push(newComponent);
|
|
19172
|
-
if (newComponent instanceof RendererComponent) {
|
|
19173
|
-
this.rendererComponents.push(newComponent);
|
|
19174
|
-
} else if (newComponent instanceof ItemBehaviour) {
|
|
19175
|
-
this.itemBehaviours.push(newComponent);
|
|
19176
|
-
}
|
|
19177
|
-
}
|
|
19172
|
+
for (const component of this.components){
|
|
19173
|
+
component.onAttached();
|
|
19178
19174
|
}
|
|
19175
|
+
// renderOrder 在 component 初始化后设置。确保能拿到 rendererComponent。
|
|
19176
|
+
this.renderOrder = listIndex;
|
|
19179
19177
|
}
|
|
19180
19178
|
toData() {
|
|
19181
19179
|
var _this_parent;
|
|
@@ -19270,6 +19268,7 @@ class VFXItem extends EffectsObject {
|
|
|
19270
19268
|
/**
|
|
19271
19269
|
* 元素动画的速度
|
|
19272
19270
|
*/ this.speed = 1;
|
|
19271
|
+
this.listIndex = 0;
|
|
19273
19272
|
this.name = 'VFXItem';
|
|
19274
19273
|
this.transform.name = this.name;
|
|
19275
19274
|
this.transform.engine = engine;
|
|
@@ -19278,6 +19277,9 @@ class VFXItem extends EffectsObject {
|
|
|
19278
19277
|
}
|
|
19279
19278
|
}
|
|
19280
19279
|
}
|
|
19280
|
+
__decorate([
|
|
19281
|
+
serialize()
|
|
19282
|
+
], VFXItem.prototype, "components", void 0);
|
|
19281
19283
|
VFXItem = __decorate([
|
|
19282
19284
|
effectsClass(DataType.VFXItemData)
|
|
19283
19285
|
], VFXItem);
|
|
@@ -19473,20 +19475,20 @@ class SerializationHelper {
|
|
|
19473
19475
|
if (value === undefined) {
|
|
19474
19476
|
value = effectsObject[key];
|
|
19475
19477
|
}
|
|
19476
|
-
if (value
|
|
19477
|
-
|
|
19478
|
-
} else if (value
|
|
19478
|
+
if (EffectsObject.is(value)) {
|
|
19479
|
+
SerializationHelper.collectSerializableObject(value, res);
|
|
19480
|
+
} else if (isArray(value)) {
|
|
19479
19481
|
for (const arrayValue of value){
|
|
19480
|
-
if (arrayValue
|
|
19481
|
-
|
|
19482
|
+
if (EffectsObject.is(arrayValue)) {
|
|
19483
|
+
SerializationHelper.collectSerializableObject(arrayValue, res);
|
|
19482
19484
|
}
|
|
19483
19485
|
}
|
|
19484
|
-
} else if (value
|
|
19486
|
+
} else if (isObject(value)) {
|
|
19485
19487
|
// 非 EffectsObject 对象只递归一层
|
|
19486
19488
|
for (const objectKey of Object.keys(value)){
|
|
19487
19489
|
const objectValue = value[objectKey];
|
|
19488
|
-
if (objectValue
|
|
19489
|
-
|
|
19490
|
+
if (EffectsObject.is(objectValue)) {
|
|
19491
|
+
SerializationHelper.collectSerializableObject(objectValue, res);
|
|
19490
19492
|
}
|
|
19491
19493
|
}
|
|
19492
19494
|
}
|
|
@@ -19521,17 +19523,17 @@ class SerializationHelper {
|
|
|
19521
19523
|
if (typeof value === 'number' || typeof value === 'string' || typeof value === 'boolean' || SerializationHelper.checkTypedArray(value)) {
|
|
19522
19524
|
// TODO json 数据避免传 typedArray
|
|
19523
19525
|
serializedData[key] = value;
|
|
19524
|
-
} else if (value
|
|
19526
|
+
} else if (isArray(value)) {
|
|
19525
19527
|
if (!serializedData[key]) {
|
|
19526
19528
|
serializedData[key] = [];
|
|
19527
19529
|
}
|
|
19528
19530
|
SerializationHelper.serializeArrayProperty(value, serializedData[key], 0);
|
|
19529
|
-
} else if (value
|
|
19531
|
+
} else if (EffectsObject.is(value)) {
|
|
19530
19532
|
// TODO 处理 EffectsObject 递归序列化
|
|
19531
19533
|
serializedData[key] = {
|
|
19532
19534
|
id: value.getInstanceId()
|
|
19533
19535
|
};
|
|
19534
|
-
} else if (value
|
|
19536
|
+
} else if (isObject(value)) {
|
|
19535
19537
|
if (!serializedData[key]) {
|
|
19536
19538
|
serializedData[key] = {};
|
|
19537
19539
|
}
|
|
@@ -19544,17 +19546,17 @@ class SerializationHelper {
|
|
|
19544
19546
|
if (typeof value === 'number' || typeof value === 'string' || typeof value === 'boolean' || SerializationHelper.checkTypedArray(value)) {
|
|
19545
19547
|
// TODO json 数据避免传 typedArray
|
|
19546
19548
|
serializedData[key] = value;
|
|
19547
|
-
} else if (value
|
|
19549
|
+
} else if (isArray(value)) {
|
|
19548
19550
|
if (!serializedData[key]) {
|
|
19549
19551
|
serializedData[key] = [];
|
|
19550
19552
|
}
|
|
19551
19553
|
SerializationHelper.serializeArrayProperty(value, serializedData[key], 0);
|
|
19552
|
-
} else if (value
|
|
19554
|
+
} else if (EffectsObject.is(value)) {
|
|
19553
19555
|
// TODO 处理 EffectsObject 递归序列化
|
|
19554
19556
|
serializedData[key] = {
|
|
19555
19557
|
id: value.getInstanceId()
|
|
19556
19558
|
};
|
|
19557
|
-
} else if (value
|
|
19559
|
+
} else if (isObject(value)) {
|
|
19558
19560
|
if (!serializedData[key]) {
|
|
19559
19561
|
serializedData[key] = {};
|
|
19560
19562
|
}
|
|
@@ -19614,13 +19616,13 @@ class SerializationHelper {
|
|
|
19614
19616
|
static checkTypedArray(obj) {
|
|
19615
19617
|
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;
|
|
19616
19618
|
}
|
|
19619
|
+
// check value is { id: 7e69662e964e4892ae8933f24562395b }
|
|
19617
19620
|
static checkDataPath(value) {
|
|
19618
|
-
|
|
19619
|
-
return value instanceof Object && Object.keys(value).length === 1 && value.id && value.id.length === 32;
|
|
19621
|
+
return !!(isObject(value) && Object.keys(value).length === 1 && 'id' in value && isString(value.id) && value.id.length === 32);
|
|
19620
19622
|
}
|
|
19621
19623
|
// TODO 测试函数,2.0 上线后移除
|
|
19622
19624
|
static checkGLTFNode(value) {
|
|
19623
|
-
return value
|
|
19625
|
+
return isObject(value) && value.nodeIndex !== undefined && value.isJoint !== undefined;
|
|
19624
19626
|
}
|
|
19625
19627
|
static checkImageSource(value) {
|
|
19626
19628
|
return isCanvas(value) || value instanceof HTMLImageElement;
|
|
@@ -19630,9 +19632,8 @@ class SerializationHelper {
|
|
|
19630
19632
|
console.error('序列化数据的内嵌对象层数大于上限');
|
|
19631
19633
|
return;
|
|
19632
19634
|
}
|
|
19633
|
-
|
|
19634
|
-
|
|
19635
|
-
} else if (property instanceof Array) {
|
|
19635
|
+
// 加载并链接 DataPath 字段表示的 EffectsObject 引用。Class 对象 copy [key, value] 会丢失对象信息,因此只递归数组对象和普通 js Object 结构对象。
|
|
19636
|
+
if (isArray(property)) {
|
|
19636
19637
|
const res = [];
|
|
19637
19638
|
for (const value of property){
|
|
19638
19639
|
res.push(SerializationHelper.deserializeProperty(value, engine, level + 1, type));
|
|
@@ -19641,21 +19642,19 @@ class SerializationHelper {
|
|
|
19641
19642
|
// TODO json 数据避免传 typedArray
|
|
19642
19643
|
} else if (SerializationHelper.checkDataPath(property)) {
|
|
19643
19644
|
return engine.assetLoader.loadGUID(property.id);
|
|
19644
|
-
} else if (
|
|
19645
|
-
return property;
|
|
19646
|
-
} else if (property instanceof Object) {
|
|
19645
|
+
} else if (isObject(property) && property.constructor === Object) {
|
|
19647
19646
|
let res;
|
|
19648
19647
|
if (type) {
|
|
19649
|
-
|
|
19650
|
-
res = new classConstructor();
|
|
19648
|
+
res = new type();
|
|
19651
19649
|
} else {
|
|
19652
19650
|
res = {};
|
|
19653
19651
|
}
|
|
19654
19652
|
for (const key of Object.keys(property)){
|
|
19655
|
-
// @ts-expect-error
|
|
19656
19653
|
res[key] = SerializationHelper.deserializeProperty(property[key], engine, level + 1);
|
|
19657
19654
|
}
|
|
19658
19655
|
return res;
|
|
19656
|
+
} else {
|
|
19657
|
+
return property;
|
|
19659
19658
|
}
|
|
19660
19659
|
}
|
|
19661
19660
|
static deserializePropertyAsync(property, engine, level, type) {
|
|
@@ -19664,9 +19663,7 @@ class SerializationHelper {
|
|
|
19664
19663
|
console.error('序列化数据的内嵌对象层数大于上限');
|
|
19665
19664
|
return;
|
|
19666
19665
|
}
|
|
19667
|
-
if (
|
|
19668
|
-
return property;
|
|
19669
|
-
} else if (property instanceof Array) {
|
|
19666
|
+
if (isArray(property)) {
|
|
19670
19667
|
const res = [];
|
|
19671
19668
|
for (const value of property){
|
|
19672
19669
|
res.push((yield SerializationHelper.deserializePropertyAsync(value, engine, level + 1, type)));
|
|
@@ -19676,21 +19673,19 @@ class SerializationHelper {
|
|
|
19676
19673
|
} else if (SerializationHelper.checkDataPath(property)) {
|
|
19677
19674
|
const res = yield engine.assetLoader.loadGUIDAsync(property.id);
|
|
19678
19675
|
return res;
|
|
19679
|
-
} else if (
|
|
19680
|
-
return property;
|
|
19681
|
-
} else if (property instanceof Object) {
|
|
19676
|
+
} else if (isObject(property) && property.constructor === Object) {
|
|
19682
19677
|
let res;
|
|
19683
19678
|
if (type) {
|
|
19684
|
-
|
|
19685
|
-
res = new classConstructor();
|
|
19679
|
+
res = new type();
|
|
19686
19680
|
} else {
|
|
19687
19681
|
res = {};
|
|
19688
19682
|
}
|
|
19689
19683
|
for (const key of Object.keys(property)){
|
|
19690
|
-
// @ts-expect-error
|
|
19691
19684
|
res[key] = SerializationHelper.deserializeProperty(property[key], engine, level + 1);
|
|
19692
19685
|
}
|
|
19693
19686
|
return res;
|
|
19687
|
+
} else {
|
|
19688
|
+
return property;
|
|
19694
19689
|
}
|
|
19695
19690
|
})();
|
|
19696
19691
|
}
|
|
@@ -19707,17 +19702,17 @@ class SerializationHelper {
|
|
|
19707
19702
|
if (typeof value === 'number' || typeof value === 'string' || typeof value === 'boolean' || SerializationHelper.checkTypedArray(objectProperty)) {
|
|
19708
19703
|
// TODO json 数据避免传 typedArray
|
|
19709
19704
|
serializedData[key] = value;
|
|
19710
|
-
} else if (value
|
|
19705
|
+
} else if (isArray(value)) {
|
|
19711
19706
|
if (!serializedData[key]) {
|
|
19712
19707
|
serializedData[key] = [];
|
|
19713
19708
|
}
|
|
19714
19709
|
SerializationHelper.serializeArrayProperty(value, serializedData[key], level + 1);
|
|
19715
|
-
} else if (value
|
|
19710
|
+
} else if (EffectsObject.is(value)) {
|
|
19716
19711
|
// TODO 处理 EffectsObject 递归序列化
|
|
19717
19712
|
serializedData[key] = {
|
|
19718
19713
|
id: value.getInstanceId()
|
|
19719
19714
|
};
|
|
19720
|
-
} else if (value
|
|
19715
|
+
} else if (isObject(value)) {
|
|
19721
19716
|
if (!serializedData[key]) {
|
|
19722
19717
|
serializedData[key] = {};
|
|
19723
19718
|
}
|
|
@@ -19738,17 +19733,17 @@ class SerializationHelper {
|
|
|
19738
19733
|
if (typeof value === 'number' || typeof value === 'string' || typeof value === 'boolean' || SerializationHelper.checkTypedArray(arrayProperty)) {
|
|
19739
19734
|
// TODO json 数据避免传 typedArray
|
|
19740
19735
|
serializedData[i] = value;
|
|
19741
|
-
} else if (value
|
|
19736
|
+
} else if (isArray(value)) {
|
|
19742
19737
|
if (!serializedData[i]) {
|
|
19743
19738
|
serializedData[i] = [];
|
|
19744
19739
|
}
|
|
19745
|
-
|
|
19746
|
-
} else if (value
|
|
19740
|
+
SerializationHelper.serializeArrayProperty(value, serializedData[i], level + 1);
|
|
19741
|
+
} else if (EffectsObject.is(value)) {
|
|
19747
19742
|
// TODO 处理 EffectsObject 递归序列化
|
|
19748
19743
|
serializedData[i] = {
|
|
19749
19744
|
id: value.getInstanceId()
|
|
19750
19745
|
};
|
|
19751
|
-
} else if (value
|
|
19746
|
+
} else if (isObject(value)) {
|
|
19752
19747
|
if (!serializedData[i]) {
|
|
19753
19748
|
serializedData[i] = {};
|
|
19754
19749
|
}
|
|
@@ -20679,8 +20674,6 @@ function getStandardCameraContent(model) {
|
|
|
20679
20674
|
/**
|
|
20680
20675
|
* 3.0 以下版本数据适配(runtime 2.0及以上版本支持)
|
|
20681
20676
|
*/ function version30Migration(json) {
|
|
20682
|
-
var // 更正 spine 数据中的 images 属性
|
|
20683
|
-
_json_spines;
|
|
20684
20677
|
var // 兼容老版本数据中不存在textures的情况
|
|
20685
20678
|
_result;
|
|
20686
20679
|
const result = _extends({}, json, {
|
|
@@ -20690,7 +20683,8 @@ function getStandardCameraContent(model) {
|
|
|
20690
20683
|
materials: [],
|
|
20691
20684
|
shaders: [],
|
|
20692
20685
|
geometries: [],
|
|
20693
|
-
animations: []
|
|
20686
|
+
animations: [],
|
|
20687
|
+
miscs: []
|
|
20694
20688
|
});
|
|
20695
20689
|
// image数据添加 guid
|
|
20696
20690
|
for (const image of result.images){
|
|
@@ -20719,17 +20713,10 @@ function getStandardCameraContent(model) {
|
|
|
20719
20713
|
});
|
|
20720
20714
|
}
|
|
20721
20715
|
}
|
|
20722
|
-
|
|
20723
|
-
|
|
20724
|
-
|
|
20725
|
-
|
|
20726
|
-
const textureId = (_json_textures_spine_images_i = json.textures[spine.images[i]]) == null ? void 0 : _json_textures_spine_images_i.id;
|
|
20727
|
-
//@ts-expect-error
|
|
20728
|
-
spine.images[i] = {
|
|
20729
|
-
id: textureId
|
|
20730
|
-
};
|
|
20731
|
-
}
|
|
20732
|
-
});
|
|
20716
|
+
// 处理老版本数据中 bins 没有 id 的情况
|
|
20717
|
+
if (json.bins) {
|
|
20718
|
+
convertBinaryAsset(json.bins, result);
|
|
20719
|
+
}
|
|
20733
20720
|
const itemOldIdToGuidMap = {};
|
|
20734
20721
|
const guidToItemMap = {};
|
|
20735
20722
|
// 更正Composition.endBehavior
|
|
@@ -20950,6 +20937,10 @@ function getStandardCameraContent(model) {
|
|
|
20950
20937
|
//@ts-expect-error
|
|
20951
20938
|
item.type = 'orientation-transformer';
|
|
20952
20939
|
}
|
|
20940
|
+
// Spine 元素转为 guid 索引
|
|
20941
|
+
if (item.type === ItemType.spine && json.spines && json.spines.length !== 0) {
|
|
20942
|
+
convertSpineData(json.spines[item.content.options.spine], item.content, result);
|
|
20943
|
+
}
|
|
20953
20944
|
// item 的 content 转为 component data 加入 JSONScene.components
|
|
20954
20945
|
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') {
|
|
20955
20946
|
item.components = [];
|
|
@@ -21193,20 +21184,48 @@ function convertTimelineAsset(composition, guidToItemMap, jsonScene) {
|
|
|
21193
21184
|
id: timelineAssetData.id
|
|
21194
21185
|
};
|
|
21195
21186
|
composition.sceneBindings = sceneBindings;
|
|
21196
|
-
|
|
21197
|
-
jsonScene.animations = [];
|
|
21198
|
-
}
|
|
21199
|
-
// @ts-expect-error
|
|
21200
|
-
jsonScene.animations.push(timelineAssetData);
|
|
21187
|
+
jsonScene.miscs.push(timelineAssetData);
|
|
21201
21188
|
for (const trackData of trackDatas){
|
|
21202
21189
|
//@ts-expect-error
|
|
21203
|
-
jsonScene.
|
|
21190
|
+
jsonScene.miscs.push(trackData);
|
|
21204
21191
|
}
|
|
21205
21192
|
for (const playableAsset of playableAssetDatas){
|
|
21206
21193
|
//@ts-expect-error
|
|
21207
|
-
jsonScene.
|
|
21194
|
+
jsonScene.miscs.push(playableAsset);
|
|
21208
21195
|
}
|
|
21209
21196
|
}
|
|
21197
|
+
function convertBinaryAsset(bins, jsonScene) {
|
|
21198
|
+
//@ts-expect-error
|
|
21199
|
+
jsonScene.bins = bins.map((bin)=>({
|
|
21200
|
+
url: bin.url,
|
|
21201
|
+
'dataType': 'BinaryAsset',
|
|
21202
|
+
id: generateGUID()
|
|
21203
|
+
}));
|
|
21204
|
+
}
|
|
21205
|
+
function convertSpineData(resource, content, jsonScene) {
|
|
21206
|
+
//@ts-expect-error
|
|
21207
|
+
content.resource = {
|
|
21208
|
+
'atlas': {
|
|
21209
|
+
'bins': {
|
|
21210
|
+
//@ts-expect-error
|
|
21211
|
+
'id': jsonScene.bins[resource.atlas[1][0]].id
|
|
21212
|
+
},
|
|
21213
|
+
'source': resource.atlas[1].slice(1)
|
|
21214
|
+
},
|
|
21215
|
+
'skeleton': {
|
|
21216
|
+
'bins': {
|
|
21217
|
+
//@ts-expect-error
|
|
21218
|
+
'id': jsonScene.bins[resource.skeleton[1][0]].id
|
|
21219
|
+
},
|
|
21220
|
+
'source': resource.skeleton[1].slice(1)
|
|
21221
|
+
},
|
|
21222
|
+
'skeletonType': resource.skeletonType,
|
|
21223
|
+
'images': resource.images.map((i)=>({
|
|
21224
|
+
//@ts-expect-error
|
|
21225
|
+
id: jsonScene.textures[i].id
|
|
21226
|
+
}))
|
|
21227
|
+
};
|
|
21228
|
+
}
|
|
21210
21229
|
|
|
21211
21230
|
const v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
|
|
21212
21231
|
const standardVersion = /^(\d+)\.(\d+)$/;
|
|
@@ -21509,7 +21528,17 @@ function getStandardItem(item, opt = {}) {
|
|
|
21509
21528
|
}
|
|
21510
21529
|
}
|
|
21511
21530
|
|
|
21512
|
-
|
|
21531
|
+
/**
|
|
21532
|
+
* 机型和渲染等级对应表
|
|
21533
|
+
*
|
|
21534
|
+
* 机型:B-低端机、A-中端机、S-高端机
|
|
21535
|
+
* 渲染等级:B-低、A-中、S-高、A+-中高、B+-全部
|
|
21536
|
+
*
|
|
21537
|
+
* - S(高端机):高、全部、中高
|
|
21538
|
+
* - A(中端机):中、全部、中高
|
|
21539
|
+
* - B(低端机):低、全部
|
|
21540
|
+
* - undefined(全部机型)
|
|
21541
|
+
*/ const renderLevelPassSet = {
|
|
21513
21542
|
[RenderLevel.S]: [
|
|
21514
21543
|
RenderLevel.S,
|
|
21515
21544
|
RenderLevel.BPlus,
|
|
@@ -21755,7 +21784,7 @@ let seed = 1;
|
|
|
21755
21784
|
const shaderLibrary = renderer == null ? void 0 : renderer.getShaderLibrary();
|
|
21756
21785
|
yield pluginSystem == null ? void 0 : pluginSystem.precompile(compositions, renderer, options);
|
|
21757
21786
|
yield new Promise((resolve)=>{
|
|
21758
|
-
shaderLibrary.compileAllShaders(()=>{
|
|
21787
|
+
shaderLibrary == null ? void 0 : shaderLibrary.compileAllShaders(()=>{
|
|
21759
21788
|
resolve(null);
|
|
21760
21789
|
});
|
|
21761
21790
|
});
|
|
@@ -23183,7 +23212,7 @@ let listOrder = 0;
|
|
|
23183
23212
|
scene.textures = undefined;
|
|
23184
23213
|
scene.consumed = true;
|
|
23185
23214
|
}
|
|
23186
|
-
const { sourceContent, pluginSystem, imgUsage, totalTime,
|
|
23215
|
+
const { sourceContent, pluginSystem, imgUsage, totalTime, refCompositionProps } = this.compositionSourceManager;
|
|
23187
23216
|
assertExist(sourceContent);
|
|
23188
23217
|
this.renderer = renderer;
|
|
23189
23218
|
this.refCompositionProps = refCompositionProps;
|
|
@@ -23209,7 +23238,6 @@ let listOrder = 0;
|
|
|
23209
23238
|
};
|
|
23210
23239
|
this.reusable = reusable;
|
|
23211
23240
|
this.speed = speed;
|
|
23212
|
-
this.renderLevel = renderLevel;
|
|
23213
23241
|
this.autoRefTex = !this.keepResource && imageUsage && this.rootItem.endBehavior !== ItemEndBehavior.loop;
|
|
23214
23242
|
this.name = sourceContent.name;
|
|
23215
23243
|
this.pluginSystem = pluginSystem;
|
|
@@ -23260,7 +23288,7 @@ let listOrder = 0;
|
|
|
23260
23288
|
}
|
|
23261
23289
|
addPackageDatas(scene) {
|
|
23262
23290
|
const { jsonScene, textureOptions = [] } = scene;
|
|
23263
|
-
const { items = [], materials = [], shaders = [], geometries = [], components = [], animations = [], bins = [] } = jsonScene;
|
|
23291
|
+
const { items = [], materials = [], shaders = [], geometries = [], components = [], animations = [], bins = [], miscs = [] } = jsonScene;
|
|
23264
23292
|
for (const vfxItemData of items){
|
|
23265
23293
|
this.addEffectsObjectData(vfxItemData);
|
|
23266
23294
|
}
|
|
@@ -23279,6 +23307,9 @@ let listOrder = 0;
|
|
|
23279
23307
|
for (const animationData of animations){
|
|
23280
23308
|
this.addEffectsObjectData(animationData);
|
|
23281
23309
|
}
|
|
23310
|
+
for (const miscData of miscs){
|
|
23311
|
+
this.addEffectsObjectData(miscData);
|
|
23312
|
+
}
|
|
23282
23313
|
for(let i = 0; i < bins.length; i++){
|
|
23283
23314
|
const binaryData = bins[i];
|
|
23284
23315
|
const binaryBuffer = scene.bins[i];
|
|
@@ -23552,5 +23583,5 @@ registerPlugin('particle', ParticleLoader, VFXItem, true);
|
|
|
23552
23583
|
registerPlugin('cal', CalculateLoader, VFXItem, true);
|
|
23553
23584
|
registerPlugin('interact', InteractLoader, VFXItem, true);
|
|
23554
23585
|
|
|
23555
|
-
export { AbstractPlugin, ActivationPlayable, ActivationPlayableAsset, ActivationTrack, AnimationClip, AnimationClipPlayable, AssetLoader, AssetManager, BYTES_TYPE_MAP, Behaviour, BezierCurve, BezierCurvePath, BezierCurveQuat, BinaryAsset, COMPRESSED_TEXTURE, COPY_FRAGMENT_SHADER, COPY_MESH_SHADER_ID, COPY_VERTEX_SHADER, CalculateLoader, Camera, CameraController, CameraVFXItemLoader, Component, Composition, CompositionComponent, CompositionSourceManager, DEFAULT_FONTS, Database, DestroyOptions, Downloader, EFFECTS_COPY_MESH_NAME, EVENT_TYPE_CLICK, EVENT_TYPE_TOUCH_END, EVENT_TYPE_TOUCH_MOVE, EVENT_TYPE_TOUCH_START, EffectComponent, EffectsObject, Engine, EventSystem, FilterMode, Float16ArrayWrapper, Framebuffer, GLSLVersion, GPUCapability, Geometry, GlobalUniforms, GradientValue, HELP_LINK, HitTestType, InteractComponent, InteractLoader, InteractMesh, Item, ItemBehaviour, KTXTexture, LineSegments, LinearValue, Material, MaterialDataBlock, MaterialRenderType, Mesh, ObjectBindingTrack, OrderType, PLAYER_OPTIONS_ENV_EDITOR, POST_PROCESS_SETTINGS, ParticleBehaviourPlayable, ParticleBehaviourPlayableAsset, ParticleLoader, ParticleMesh, ParticleSystem, ParticleSystemRenderer, PassTextureCache, PathSegments, PluginSystem, RENDER_PASS_NAME_PREFIX, RENDER_PREFER_LOOKUP_TEXTURE, RUNTIME_ENV, RandomSetValue, RandomValue, RandomVectorValue, RenderFrame, RenderPass, RenderPassAttachmentStorageType, RenderPassDestroyAttachmentType, RenderPassPriorityNormal, RenderPassPriorityPostprocess, RenderPassPriorityPrepare, RenderTargetHandle, RenderTextureFormat, Renderbuffer, Renderer, RendererComponent, RuntimeClip, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0, SEMANTIC_PRE_COLOR_ATTACHMENT_0, SEMANTIC_PRE_COLOR_ATTACHMENT_SIZE_0, SPRITE_VERTEX_STRIDE, SemanticMap, SerializationHelper, Shader, ShaderCompileResultStatus, ShaderType, ShaderVariant, SpriteColorPlayable, SpriteColorPlayableAsset, SpriteColorTrack, SpriteComponent, SpriteLoader, StaticValue, SubCompositionPlayableAsset, SubCompositionTrack, TEMPLATE_USE_OFFSCREEN_CANVAS, TextComponent, TextLoader, Texture, TextureFactory, TextureLoadAction, TextureSourceType, TextureStoreAction, Ticker, TimelineAsset, TimelineClip, TimelinePlayable, TrackAsset, TrackSortWrapper, TrackType, Transform, TransformAnimationPlayable, TransformPlayableAsset, TransformTrack, VFXItem, ValueGetter, addByOrder, addItem, addItemWithOrder, assertExist, asserts, base64ToFile, blend, calculateTranslation, canvasPool, colorGradingFrag, colorStopsFromGradient, colorToArr$1 as colorToArr, combineImageTemplate, compatible_frag as compatibleFrag, compatible_vert as compatibleVert, createCopyShader, createGLContext, createKeyFrameMeta, createShaderWithMarcos, createShape, createVFXItem, createValueGetter, decimalEqual,
|
|
23586
|
+
export { AbstractPlugin, ActivationPlayable, ActivationPlayableAsset, ActivationTrack, AnimationClip, AnimationClipPlayable, AssetLoader, AssetManager, BYTES_TYPE_MAP, Behaviour, BezierCurve, BezierCurvePath, BezierCurveQuat, BinaryAsset, COMPRESSED_TEXTURE, COPY_FRAGMENT_SHADER, COPY_MESH_SHADER_ID, COPY_VERTEX_SHADER, CalculateLoader, Camera, CameraController, CameraVFXItemLoader, Component, Composition, CompositionComponent, CompositionSourceManager, DEFAULT_FONTS, Database, DestroyOptions, Downloader, EFFECTS_COPY_MESH_NAME, EVENT_TYPE_CLICK, EVENT_TYPE_TOUCH_END, EVENT_TYPE_TOUCH_MOVE, EVENT_TYPE_TOUCH_START, EffectComponent, EffectsObject, Engine, EventSystem, FilterMode, Float16ArrayWrapper, Framebuffer, GLSLVersion, GPUCapability, Geometry, GlobalUniforms, GradientValue, HELP_LINK, HitTestType, InteractComponent, InteractLoader, InteractMesh, Item, ItemBehaviour, KTXTexture, LineSegments, LinearValue, Material, MaterialDataBlock, MaterialRenderType, Mesh, ObjectBindingTrack, OrderType, PLAYER_OPTIONS_ENV_EDITOR, POST_PROCESS_SETTINGS, ParticleBehaviourPlayable, ParticleBehaviourPlayableAsset, ParticleLoader, ParticleMesh, ParticleSystem, ParticleSystemRenderer, PassTextureCache, PathSegments, PluginSystem, RENDER_PASS_NAME_PREFIX, RENDER_PREFER_LOOKUP_TEXTURE, RUNTIME_ENV, RandomSetValue, RandomValue, RandomVectorValue, RenderFrame, RenderPass, RenderPassAttachmentStorageType, RenderPassDestroyAttachmentType, RenderPassPriorityNormal, RenderPassPriorityPostprocess, RenderPassPriorityPrepare, RenderTargetHandle, RenderTextureFormat, Renderbuffer, Renderer, RendererComponent, RuntimeClip, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0, SEMANTIC_PRE_COLOR_ATTACHMENT_0, SEMANTIC_PRE_COLOR_ATTACHMENT_SIZE_0, SPRITE_VERTEX_STRIDE, SemanticMap, SerializationHelper, Shader, ShaderCompileResultStatus, ShaderType, ShaderVariant, SpriteColorPlayable, SpriteColorPlayableAsset, SpriteColorTrack, SpriteComponent, SpriteLoader, StaticValue, SubCompositionPlayableAsset, SubCompositionTrack, TEMPLATE_USE_OFFSCREEN_CANVAS, TextComponent, TextLayout, TextLoader, TextStyle, Texture, TextureFactory, TextureLoadAction, TextureSourceType, TextureStoreAction, Ticker, TimelineAsset, TimelineClip, TimelinePlayable, TrackAsset, TrackSortWrapper, TrackType, Transform, TransformAnimationPlayable, TransformPlayableAsset, TransformTrack, VFXItem, ValueGetter, addByOrder, addItem, addItemWithOrder, assertExist, asserts, base64ToFile, blend, calculateTranslation, canvasPool, colorGradingFrag, colorStopsFromGradient, colorToArr$1 as colorToArr, combineImageTemplate, compatible_frag as compatibleFrag, compatible_vert as compatibleVert, createCopyShader, createGLContext, createKeyFrameMeta, createShaderWithMarcos, createShape, createVFXItem, createValueGetter, decimalEqual, defaultGlobalVolume, defaultPlugins, deserializeMipmapTexture, earcut, effectsClass, effectsClassStore, enlargeBuffer, ensureFixedNumber, ensureVec3, findPreviousRenderPass, gaussianDown_frag as gaussianDownFrag, gaussianDownHFrag, gaussianDownVFrag, gaussianUpFrag, generateEmptyTypedArray, generateGUID, generateHalfFloatTexture, generateTransparentTexture, generateWhiteTexture, getBackgroundImage, getColorFromGradientStops, getConfig, getDefaultTemplateCanvasPool, getDefaultTextureFactory, getGeometryByShape, getGeometryTriangles, getImageItemRenderInfo, getKTXTextureOptions, getKeyFrameMetaByRawValue, getMergedStore, getParticleMeshShader, getPixelRatio, getPreMultiAlpha, getStandardComposition, getStandardImage, getStandardItem, getStandardJSON, getTextureSize, glContext, glType2VertexFormatType, gpuTimer, imageDataFromColor, imageDataFromGradient, initErrors, initGLContext, integrate, interpolateColor, isAlipayMiniApp, isAndroid, isArray, isCanvas, isFunction, isIOS, isObject, isSceneJSON, isSceneURL, isSceneWithOptions, isSimulatorCellPhone, isString, isUniformStruct, isUniformStructArray, isValidFontFamily, isWebGL2, itemFrag, itemFrameFrag, itemVert, loadBinary, loadBlob, loadImage, loadMedia, loadVideo, loadWebPOptional, logger, index as math, maxSpriteMeshItemCount, maxSpriteTextureCount, modifyMaxKeyframeShader, nearestPowerOfTwo, noop, normalizeColor, numberToFix, parsePercent$1 as parsePercent, particleFrag, particleOriginTranslateMap$1 as particleOriginTranslateMap, particleUniformTypeMap, particleVert, pluginLoaderMap, pointOnLine, randomInRange, registerPlugin, removeItem, rotateVec2, screenMeshVert, serialize, setBlendMode, setConfig, setDefaultTextureFactory, setMaskMode, setMaxSpriteMeshItemCount, setRayFromCamera, setSideMode, setSpriteMeshMaxFragmentTextures, setSpriteMeshMaxItemCountByGPU, sortByOrder, index$1 as spec, spriteMeshShaderFromFilter, spriteMeshShaderFromRenderInfo, spriteMeshShaderIdFromRenderInfo, thresholdFrag, throwDestroyedError, trailVert, translatePoint, trianglesFromRect, unregisterPlugin, valIfUndefined, value, valueDefine, vecAssign, vecFill, vecMulCombine, vecNormalize, vertexFormatType2GLType };
|
|
23556
23587
|
//# sourceMappingURL=index.mjs.map
|