@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.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.17
|
|
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,25 +601,12 @@ 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() {
|
|
@@ -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} 重复注册`);
|
|
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
|
}
|
|
@@ -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([
|
|
@@ -12778,13 +12770,16 @@ const tempColor = [
|
|
|
12778
12770
|
let seed$3 = 0;
|
|
12779
12771
|
class SpriteColorPlayable extends Playable {
|
|
12780
12772
|
processFrame(context) {
|
|
12781
|
-
const
|
|
12773
|
+
const boundObject = context.output.getUserData();
|
|
12774
|
+
if (!(boundObject instanceof VFXItem)) {
|
|
12775
|
+
return;
|
|
12776
|
+
}
|
|
12782
12777
|
if (!this.spriteMaterial) {
|
|
12783
|
-
this.spriteMaterial =
|
|
12778
|
+
this.spriteMaterial = boundObject.getComponent(SpriteComponent).material;
|
|
12784
12779
|
}
|
|
12785
12780
|
let colorInc = vecFill(tempColor, 1);
|
|
12786
12781
|
let colorChanged;
|
|
12787
|
-
const life = this.time /
|
|
12782
|
+
const life = this.time / boundObject.duration;
|
|
12788
12783
|
const opacityOverLifetime = this.opacityOverLifetime;
|
|
12789
12784
|
const colorOverLifetime = this.colorOverLifetime;
|
|
12790
12785
|
if (colorOverLifetime) {
|
|
@@ -12883,7 +12878,6 @@ class SpriteComponent extends RendererComponent {
|
|
|
12883
12878
|
renderer.drawGeometry(geo, material);
|
|
12884
12879
|
}
|
|
12885
12880
|
start() {
|
|
12886
|
-
this.priority = this.item.listIndex;
|
|
12887
12881
|
this.item.getHitTestParams = this.getHitTestParams;
|
|
12888
12882
|
}
|
|
12889
12883
|
update(dt) {
|
|
@@ -13781,7 +13775,7 @@ class Cone {
|
|
|
13781
13775
|
// dir + [0,0,1]
|
|
13782
13776
|
dir.z += 1;
|
|
13783
13777
|
return {
|
|
13784
|
-
position: position.multiply(
|
|
13778
|
+
position: position.multiply(randomInRange(0, 1)),
|
|
13785
13779
|
direction: dir.normalize()
|
|
13786
13780
|
};
|
|
13787
13781
|
}
|
|
@@ -13793,7 +13787,7 @@ class Cone {
|
|
|
13793
13787
|
}
|
|
13794
13788
|
function getArcAngle(arc, arcMode, opt) {
|
|
13795
13789
|
if (arcMode === ShapeArcMode.RANDOM) {
|
|
13796
|
-
arc =
|
|
13790
|
+
arc = randomInRange(0, arc);
|
|
13797
13791
|
} else if (arcMode === ShapeArcMode.UNIDIRECTIONAL_CYCLE) {
|
|
13798
13792
|
const d = opt.index % (opt.total + 1);
|
|
13799
13793
|
arc = arc / opt.total * d;
|
|
@@ -13825,8 +13819,8 @@ class Circle {
|
|
|
13825
13819
|
}
|
|
13826
13820
|
class Rectangle {
|
|
13827
13821
|
generate(opt) {
|
|
13828
|
-
const x =
|
|
13829
|
-
const y =
|
|
13822
|
+
const x = randomInRange(-this._d, this._d);
|
|
13823
|
+
const y = randomInRange(-this._h, this._h);
|
|
13830
13824
|
return {
|
|
13831
13825
|
direction: new Vector3(0, 0, 1),
|
|
13832
13826
|
position: new Vector3(x, y, 0)
|
|
@@ -13871,7 +13865,7 @@ class RectangleEdge {
|
|
|
13871
13865
|
}
|
|
13872
13866
|
class Edge {
|
|
13873
13867
|
generate(options) {
|
|
13874
|
-
const x = this.arcMode === ShapeArcMode.UNIFORM_BURST ? options.burstIndex % options.burstCount / (options.burstCount - 1) :
|
|
13868
|
+
const x = this.arcMode === ShapeArcMode.UNIFORM_BURST ? options.burstIndex % options.burstCount / (options.burstCount - 1) : randomInRange(0, 1);
|
|
13875
13869
|
return {
|
|
13876
13870
|
direction: new Vector3(0, 1, 0),
|
|
13877
13871
|
position: new Vector3(this._d * (x - 0.5), 0, 0)
|
|
@@ -13889,7 +13883,7 @@ class Donut {
|
|
|
13889
13883
|
generate(opt) {
|
|
13890
13884
|
const dradius = this.donutRadius;
|
|
13891
13885
|
const center = this.radius - dradius;
|
|
13892
|
-
const angle =
|
|
13886
|
+
const angle = randomInRange(0, Math.PI * 2);
|
|
13893
13887
|
const arc = getArcAngle(this.arc, this.arcMode, opt) * DEG2RAD;
|
|
13894
13888
|
const rot = tempMat4$2.setFromRotationZ(arc);
|
|
13895
13889
|
const direction = new Vector3(Math.cos(angle), Math.sin(angle), 0);
|
|
@@ -13909,7 +13903,7 @@ class Donut {
|
|
|
13909
13903
|
const tempMat4$1 = new Matrix4();
|
|
13910
13904
|
class Sphere {
|
|
13911
13905
|
getHorizontalAngle() {
|
|
13912
|
-
return
|
|
13906
|
+
return randomInRange(-90, 90);
|
|
13913
13907
|
}
|
|
13914
13908
|
generate(opt) {
|
|
13915
13909
|
const rz = getArcAngle(this.arc, this.arcMode, opt) * DEG2RAD;
|
|
@@ -13931,7 +13925,7 @@ class Sphere {
|
|
|
13931
13925
|
}
|
|
13932
13926
|
class Hemisphere extends Sphere {
|
|
13933
13927
|
getHorizontalAngle() {
|
|
13934
|
-
return
|
|
13928
|
+
return randomInRange(0, 90);
|
|
13935
13929
|
}
|
|
13936
13930
|
}
|
|
13937
13931
|
|
|
@@ -15252,7 +15246,7 @@ function getTrailMeshShader(trails, particleMaxCount, name, env = '', gpuCapabil
|
|
|
15252
15246
|
* @internal
|
|
15253
15247
|
*/ class ParticleSystemRenderer extends RendererComponent {
|
|
15254
15248
|
start() {
|
|
15255
|
-
this._priority = this.item.
|
|
15249
|
+
this._priority = this.item.renderOrder;
|
|
15256
15250
|
this.particleMesh.gravityModifier.scaleXCoord(this.item.duration);
|
|
15257
15251
|
for (const mesh of this.meshes){
|
|
15258
15252
|
mesh.start();
|
|
@@ -15927,11 +15921,9 @@ class ParticleSystem extends Component {
|
|
|
15927
15921
|
this.props = props;
|
|
15928
15922
|
this.destroyed = false;
|
|
15929
15923
|
const cachePrefix = '';
|
|
15930
|
-
const options = props
|
|
15931
|
-
const
|
|
15932
|
-
const
|
|
15933
|
-
const gravityModifier = positionOverLifetime.gravityOverLifetime;
|
|
15934
|
-
const gravity = ensureVec3(positionOverLifetime.gravity);
|
|
15924
|
+
const { options, positionOverLifetime = {}, shape } = props;
|
|
15925
|
+
const gravityModifier = positionOverLifetime == null ? void 0 : positionOverLifetime.gravityOverLifetime;
|
|
15926
|
+
const gravity = ensureVec3(positionOverLifetime == null ? void 0 : positionOverLifetime.gravity);
|
|
15935
15927
|
const _textureSheetAnimation = props.textureSheetAnimation;
|
|
15936
15928
|
const textureSheetAnimation = _textureSheetAnimation ? {
|
|
15937
15929
|
animationDelay: createValueGetter(_textureSheetAnimation.animationDelay || 0),
|
|
@@ -15942,7 +15934,7 @@ class ParticleSystem extends Component {
|
|
|
15942
15934
|
row: _textureSheetAnimation.row,
|
|
15943
15935
|
total: _textureSheetAnimation.total || _textureSheetAnimation.col * _textureSheetAnimation.row
|
|
15944
15936
|
} : undefined;
|
|
15945
|
-
const startTurbulence = !!(shape && shape.turbulenceX || shape.turbulenceY || shape.turbulenceZ);
|
|
15937
|
+
const startTurbulence = !!(shape && shape.turbulenceX || (shape == null ? void 0 : shape.turbulenceY) || (shape == null ? void 0 : shape.turbulenceZ));
|
|
15946
15938
|
let turbulence;
|
|
15947
15939
|
if (startTurbulence) {
|
|
15948
15940
|
var _shape_turbulenceX, _shape_turbulenceY, _shape_turbulenceZ;
|
|
@@ -15973,7 +15965,7 @@ class ParticleSystem extends Component {
|
|
|
15973
15965
|
}
|
|
15974
15966
|
}
|
|
15975
15967
|
let forceTarget;
|
|
15976
|
-
if (positionOverLifetime.forceTarget) {
|
|
15968
|
+
if (positionOverLifetime == null ? void 0 : positionOverLifetime.forceTarget) {
|
|
15977
15969
|
forceTarget = {
|
|
15978
15970
|
target: positionOverLifetime.target || [
|
|
15979
15971
|
0,
|
|
@@ -16282,13 +16274,13 @@ function randomArrItem(arr, keepArr) {
|
|
|
16282
16274
|
* @internal
|
|
16283
16275
|
*/ class ParticleBehaviourPlayable extends Playable {
|
|
16284
16276
|
start(context) {
|
|
16285
|
-
const
|
|
16286
|
-
if (this.particleSystem) {
|
|
16277
|
+
const boundObject = context.output.getUserData();
|
|
16278
|
+
if (this.particleSystem || !(boundObject instanceof VFXItem)) {
|
|
16287
16279
|
return;
|
|
16288
16280
|
}
|
|
16289
|
-
this.particleSystem =
|
|
16281
|
+
this.particleSystem = boundObject.getComponent(ParticleSystem);
|
|
16290
16282
|
if (this.particleSystem) {
|
|
16291
|
-
this.particleSystem.name =
|
|
16283
|
+
this.particleSystem.name = boundObject.name;
|
|
16292
16284
|
this.particleSystem.start();
|
|
16293
16285
|
this.particleSystem.initEmitterTransform();
|
|
16294
16286
|
}
|
|
@@ -17408,10 +17400,13 @@ const tempPos = new Vector3();
|
|
|
17408
17400
|
}
|
|
17409
17401
|
processFrame(context) {
|
|
17410
17402
|
if (!this.binding) {
|
|
17411
|
-
|
|
17412
|
-
|
|
17403
|
+
const boundObject = context.output.getUserData();
|
|
17404
|
+
if (boundObject instanceof VFXItem) {
|
|
17405
|
+
this.binding = boundObject;
|
|
17406
|
+
this.start();
|
|
17407
|
+
}
|
|
17413
17408
|
}
|
|
17414
|
-
if (this.binding.composition) {
|
|
17409
|
+
if (this.binding && this.binding.composition) {
|
|
17415
17410
|
this.sampleAnimation();
|
|
17416
17411
|
}
|
|
17417
17412
|
}
|
|
@@ -17579,13 +17574,37 @@ AnimationClip = __decorate([
|
|
|
17579
17574
|
], AnimationClip);
|
|
17580
17575
|
class AnimationClipPlayable extends Playable {
|
|
17581
17576
|
processFrame(context) {
|
|
17582
|
-
const
|
|
17583
|
-
if (
|
|
17584
|
-
|
|
17577
|
+
const boundObject = context.output.getUserData();
|
|
17578
|
+
if (!(boundObject instanceof VFXItem)) {
|
|
17579
|
+
return;
|
|
17580
|
+
}
|
|
17581
|
+
if (boundObject.composition) {
|
|
17582
|
+
this.clip.sampleAnimation(boundObject, this.time);
|
|
17585
17583
|
}
|
|
17586
17584
|
}
|
|
17587
17585
|
}
|
|
17588
17586
|
|
|
17587
|
+
/**
|
|
17588
|
+
* @since 2.0.0
|
|
17589
|
+
* @internal
|
|
17590
|
+
*/ class TimelineClip {
|
|
17591
|
+
toLocalTime(time) {
|
|
17592
|
+
let localTime = time - this.start;
|
|
17593
|
+
const duration = this.duration;
|
|
17594
|
+
if (localTime - duration > 0.001) {
|
|
17595
|
+
if (this.endBehaviour === ItemEndBehavior.loop) {
|
|
17596
|
+
localTime = localTime % duration;
|
|
17597
|
+
} else if (this.endBehaviour === ItemEndBehavior.freeze) {
|
|
17598
|
+
localTime = Math.min(duration, localTime);
|
|
17599
|
+
}
|
|
17600
|
+
}
|
|
17601
|
+
return localTime;
|
|
17602
|
+
}
|
|
17603
|
+
constructor(){
|
|
17604
|
+
this.start = 0;
|
|
17605
|
+
this.duration = 0;
|
|
17606
|
+
}
|
|
17607
|
+
}
|
|
17589
17608
|
class TrackAsset extends PlayableAsset {
|
|
17590
17609
|
/**
|
|
17591
17610
|
* 重写该方法以获取自定义对象绑定
|
|
@@ -17666,7 +17685,7 @@ class TrackAsset extends PlayableAsset {
|
|
|
17666
17685
|
}
|
|
17667
17686
|
}
|
|
17668
17687
|
__decorate([
|
|
17669
|
-
serialize(
|
|
17688
|
+
serialize(TimelineClip)
|
|
17670
17689
|
], TrackAsset.prototype, "clips", void 0);
|
|
17671
17690
|
__decorate([
|
|
17672
17691
|
serialize()
|
|
@@ -17679,27 +17698,6 @@ exports.TrackType = void 0;
|
|
|
17679
17698
|
TrackType[TrackType["MasterTrack"] = 0] = "MasterTrack";
|
|
17680
17699
|
TrackType[TrackType["ObjectTrack"] = 1] = "ObjectTrack";
|
|
17681
17700
|
})(exports.TrackType || (exports.TrackType = {}));
|
|
17682
|
-
class TimelineClip {
|
|
17683
|
-
toLocalTime(time) {
|
|
17684
|
-
let localTime = time - this.start;
|
|
17685
|
-
const duration = this.duration;
|
|
17686
|
-
if (localTime - duration > 0.001) {
|
|
17687
|
-
if (this.endBehaviour === ItemEndBehavior.loop) {
|
|
17688
|
-
localTime = localTime % duration;
|
|
17689
|
-
} else if (this.endBehaviour === ItemEndBehavior.freeze) {
|
|
17690
|
-
localTime = Math.min(duration, localTime);
|
|
17691
|
-
}
|
|
17692
|
-
}
|
|
17693
|
-
return localTime;
|
|
17694
|
-
}
|
|
17695
|
-
constructor(){
|
|
17696
|
-
this.start = 0;
|
|
17697
|
-
this.duration = 0;
|
|
17698
|
-
}
|
|
17699
|
-
}
|
|
17700
|
-
TimelineClip = __decorate([
|
|
17701
|
-
effectsClass('TimelineClip')
|
|
17702
|
-
], TimelineClip);
|
|
17703
17701
|
class RuntimeClip {
|
|
17704
17702
|
set enable(value) {
|
|
17705
17703
|
if (value) {
|
|
@@ -17774,10 +17772,6 @@ class ObjectBindingTrack extends TrackAsset {
|
|
|
17774
17772
|
particleClip.endBehaviour = boundItem.endBehavior;
|
|
17775
17773
|
}
|
|
17776
17774
|
}
|
|
17777
|
-
fromData(data) {
|
|
17778
|
-
super.fromData(data);
|
|
17779
|
-
this.data = data;
|
|
17780
|
-
}
|
|
17781
17775
|
}
|
|
17782
17776
|
ObjectBindingTrack = __decorate([
|
|
17783
17777
|
effectsClass('ObjectBindingTrack')
|
|
@@ -17791,13 +17785,11 @@ TransformTrack = __decorate([
|
|
|
17791
17785
|
|
|
17792
17786
|
class ActivationMixerPlayable extends Playable {
|
|
17793
17787
|
processFrame(context) {
|
|
17794
|
-
|
|
17795
|
-
|
|
17796
|
-
}
|
|
17797
|
-
if (!this.bindingItem) {
|
|
17788
|
+
const boundObject = context.output.getUserData();
|
|
17789
|
+
if (!(boundObject instanceof VFXItem)) {
|
|
17798
17790
|
return;
|
|
17799
17791
|
}
|
|
17800
|
-
const
|
|
17792
|
+
const boundItem = boundObject;
|
|
17801
17793
|
let hasInput = false;
|
|
17802
17794
|
for(let i = 0; i < this.getInputCount(); i++){
|
|
17803
17795
|
if (this.getInputWeight(i) > 0) {
|
|
@@ -17806,11 +17798,11 @@ class ActivationMixerPlayable extends Playable {
|
|
|
17806
17798
|
}
|
|
17807
17799
|
}
|
|
17808
17800
|
if (hasInput) {
|
|
17809
|
-
|
|
17810
|
-
this.showRendererComponents(
|
|
17801
|
+
boundItem.transform.setValid(true);
|
|
17802
|
+
this.showRendererComponents(boundItem);
|
|
17811
17803
|
} else {
|
|
17812
|
-
|
|
17813
|
-
this.hideRendererComponents(
|
|
17804
|
+
boundItem.transform.setValid(false);
|
|
17805
|
+
this.hideRendererComponents(boundItem);
|
|
17814
17806
|
}
|
|
17815
17807
|
}
|
|
17816
17808
|
hideRendererComponents(item) {
|
|
@@ -17965,7 +17957,6 @@ function compareTracks(a, b) {
|
|
|
17965
17957
|
this.startTime = startTime;
|
|
17966
17958
|
this.resolveBindings();
|
|
17967
17959
|
this.timelinePlayable = this.timelineAsset.createPlayable(this.graph);
|
|
17968
|
-
this.timelinePlayable.play();
|
|
17969
17960
|
// 重播不销毁元素
|
|
17970
17961
|
if (this.item.endBehavior !== ItemEndBehavior.destroy) {
|
|
17971
17962
|
this.setReusable(true);
|
|
@@ -18177,7 +18168,9 @@ SubCompositionTrack = __decorate([
|
|
|
18177
18168
|
class SubCompositionClipPlayable extends Playable {
|
|
18178
18169
|
processFrame(context) {
|
|
18179
18170
|
const boundObject = context.output.getUserData();
|
|
18180
|
-
boundObject
|
|
18171
|
+
if (boundObject instanceof CompositionComponent) {
|
|
18172
|
+
boundObject.time = this.getTime();
|
|
18173
|
+
}
|
|
18181
18174
|
}
|
|
18182
18175
|
}
|
|
18183
18176
|
|
|
@@ -18347,7 +18340,6 @@ class CanvasPool {
|
|
|
18347
18340
|
return this.elements.shift();
|
|
18348
18341
|
}
|
|
18349
18342
|
if (getConfig(TEMPLATE_USE_OFFSCREEN_CANVAS)) {
|
|
18350
|
-
// @ts-expect-error
|
|
18351
18343
|
return window._createOffscreenCanvas(10, 10);
|
|
18352
18344
|
} else {
|
|
18353
18345
|
// in hongmeng system, create too many canvas will case render error
|
|
@@ -18902,6 +18894,19 @@ class VFXItem extends EffectsObject {
|
|
|
18902
18894
|
return (_this_composition_reusable = (_this_composition = this.composition) == null ? void 0 : _this_composition.reusable) != null ? _this_composition_reusable : false;
|
|
18903
18895
|
}
|
|
18904
18896
|
/**
|
|
18897
|
+
* 元素在合成中的索引
|
|
18898
|
+
*/ get renderOrder() {
|
|
18899
|
+
return this.listIndex;
|
|
18900
|
+
}
|
|
18901
|
+
set renderOrder(value) {
|
|
18902
|
+
if (this.listIndex !== value) {
|
|
18903
|
+
this.listIndex = value;
|
|
18904
|
+
for (const rendererComponent of this.rendererComponents){
|
|
18905
|
+
rendererComponent.priority = value;
|
|
18906
|
+
}
|
|
18907
|
+
}
|
|
18908
|
+
}
|
|
18909
|
+
/**
|
|
18905
18910
|
* 设置元素的动画速度
|
|
18906
18911
|
* @param speed - 速度
|
|
18907
18912
|
*/ setSpeed(speed) {
|
|
@@ -19158,7 +19163,6 @@ class VFXItem extends EffectsObject {
|
|
|
19158
19163
|
this.parentId = parentId;
|
|
19159
19164
|
this.duration = duration;
|
|
19160
19165
|
this.endBehavior = endBehavior;
|
|
19161
|
-
this.listIndex = listIndex;
|
|
19162
19166
|
//@ts-expect-error
|
|
19163
19167
|
this.oldId = data.oldId;
|
|
19164
19168
|
if (!data.content) {
|
|
@@ -19169,17 +19173,11 @@ class VFXItem extends EffectsObject {
|
|
|
19169
19173
|
if (duration <= 0) {
|
|
19170
19174
|
throw Error(`Item duration can't be less than 0, see ${HELP_LINK['Item duration can\'t be less than 0']}`);
|
|
19171
19175
|
}
|
|
19172
|
-
|
|
19173
|
-
|
|
19174
|
-
const newComponent = component;
|
|
19175
|
-
this.components.push(newComponent);
|
|
19176
|
-
if (newComponent instanceof RendererComponent) {
|
|
19177
|
-
this.rendererComponents.push(newComponent);
|
|
19178
|
-
} else if (newComponent instanceof ItemBehaviour) {
|
|
19179
|
-
this.itemBehaviours.push(newComponent);
|
|
19180
|
-
}
|
|
19181
|
-
}
|
|
19176
|
+
for (const component of this.components){
|
|
19177
|
+
component.onAttached();
|
|
19182
19178
|
}
|
|
19179
|
+
// renderOrder 在 component 初始化后设置。确保能拿到 rendererComponent。
|
|
19180
|
+
this.renderOrder = listIndex;
|
|
19183
19181
|
}
|
|
19184
19182
|
toData() {
|
|
19185
19183
|
var _this_parent;
|
|
@@ -19274,6 +19272,7 @@ class VFXItem extends EffectsObject {
|
|
|
19274
19272
|
/**
|
|
19275
19273
|
* 元素动画的速度
|
|
19276
19274
|
*/ this.speed = 1;
|
|
19275
|
+
this.listIndex = 0;
|
|
19277
19276
|
this.name = 'VFXItem';
|
|
19278
19277
|
this.transform.name = this.name;
|
|
19279
19278
|
this.transform.engine = engine;
|
|
@@ -19282,6 +19281,9 @@ class VFXItem extends EffectsObject {
|
|
|
19282
19281
|
}
|
|
19283
19282
|
}
|
|
19284
19283
|
}
|
|
19284
|
+
__decorate([
|
|
19285
|
+
serialize()
|
|
19286
|
+
], VFXItem.prototype, "components", void 0);
|
|
19285
19287
|
VFXItem = __decorate([
|
|
19286
19288
|
effectsClass(DataType.VFXItemData)
|
|
19287
19289
|
], VFXItem);
|
|
@@ -19477,20 +19479,20 @@ class SerializationHelper {
|
|
|
19477
19479
|
if (value === undefined) {
|
|
19478
19480
|
value = effectsObject[key];
|
|
19479
19481
|
}
|
|
19480
|
-
if (value
|
|
19481
|
-
|
|
19482
|
-
} else if (value
|
|
19482
|
+
if (EffectsObject.is(value)) {
|
|
19483
|
+
SerializationHelper.collectSerializableObject(value, res);
|
|
19484
|
+
} else if (isArray(value)) {
|
|
19483
19485
|
for (const arrayValue of value){
|
|
19484
|
-
if (arrayValue
|
|
19485
|
-
|
|
19486
|
+
if (EffectsObject.is(arrayValue)) {
|
|
19487
|
+
SerializationHelper.collectSerializableObject(arrayValue, res);
|
|
19486
19488
|
}
|
|
19487
19489
|
}
|
|
19488
|
-
} else if (value
|
|
19490
|
+
} else if (isObject(value)) {
|
|
19489
19491
|
// 非 EffectsObject 对象只递归一层
|
|
19490
19492
|
for (const objectKey of Object.keys(value)){
|
|
19491
19493
|
const objectValue = value[objectKey];
|
|
19492
|
-
if (objectValue
|
|
19493
|
-
|
|
19494
|
+
if (EffectsObject.is(objectValue)) {
|
|
19495
|
+
SerializationHelper.collectSerializableObject(objectValue, res);
|
|
19494
19496
|
}
|
|
19495
19497
|
}
|
|
19496
19498
|
}
|
|
@@ -19525,17 +19527,17 @@ class SerializationHelper {
|
|
|
19525
19527
|
if (typeof value === 'number' || typeof value === 'string' || typeof value === 'boolean' || SerializationHelper.checkTypedArray(value)) {
|
|
19526
19528
|
// TODO json 数据避免传 typedArray
|
|
19527
19529
|
serializedData[key] = value;
|
|
19528
|
-
} else if (value
|
|
19530
|
+
} else if (isArray(value)) {
|
|
19529
19531
|
if (!serializedData[key]) {
|
|
19530
19532
|
serializedData[key] = [];
|
|
19531
19533
|
}
|
|
19532
19534
|
SerializationHelper.serializeArrayProperty(value, serializedData[key], 0);
|
|
19533
|
-
} else if (value
|
|
19535
|
+
} else if (EffectsObject.is(value)) {
|
|
19534
19536
|
// TODO 处理 EffectsObject 递归序列化
|
|
19535
19537
|
serializedData[key] = {
|
|
19536
19538
|
id: value.getInstanceId()
|
|
19537
19539
|
};
|
|
19538
|
-
} else if (value
|
|
19540
|
+
} else if (isObject(value)) {
|
|
19539
19541
|
if (!serializedData[key]) {
|
|
19540
19542
|
serializedData[key] = {};
|
|
19541
19543
|
}
|
|
@@ -19548,17 +19550,17 @@ class SerializationHelper {
|
|
|
19548
19550
|
if (typeof value === 'number' || typeof value === 'string' || typeof value === 'boolean' || SerializationHelper.checkTypedArray(value)) {
|
|
19549
19551
|
// TODO json 数据避免传 typedArray
|
|
19550
19552
|
serializedData[key] = value;
|
|
19551
|
-
} else if (value
|
|
19553
|
+
} else if (isArray(value)) {
|
|
19552
19554
|
if (!serializedData[key]) {
|
|
19553
19555
|
serializedData[key] = [];
|
|
19554
19556
|
}
|
|
19555
19557
|
SerializationHelper.serializeArrayProperty(value, serializedData[key], 0);
|
|
19556
|
-
} else if (value
|
|
19558
|
+
} else if (EffectsObject.is(value)) {
|
|
19557
19559
|
// TODO 处理 EffectsObject 递归序列化
|
|
19558
19560
|
serializedData[key] = {
|
|
19559
19561
|
id: value.getInstanceId()
|
|
19560
19562
|
};
|
|
19561
|
-
} else if (value
|
|
19563
|
+
} else if (isObject(value)) {
|
|
19562
19564
|
if (!serializedData[key]) {
|
|
19563
19565
|
serializedData[key] = {};
|
|
19564
19566
|
}
|
|
@@ -19618,13 +19620,13 @@ class SerializationHelper {
|
|
|
19618
19620
|
static checkTypedArray(obj) {
|
|
19619
19621
|
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;
|
|
19620
19622
|
}
|
|
19623
|
+
// check value is { id: 7e69662e964e4892ae8933f24562395b }
|
|
19621
19624
|
static checkDataPath(value) {
|
|
19622
|
-
|
|
19623
|
-
return value instanceof Object && Object.keys(value).length === 1 && value.id && value.id.length === 32;
|
|
19625
|
+
return !!(isObject(value) && Object.keys(value).length === 1 && 'id' in value && isString(value.id) && value.id.length === 32);
|
|
19624
19626
|
}
|
|
19625
19627
|
// TODO 测试函数,2.0 上线后移除
|
|
19626
19628
|
static checkGLTFNode(value) {
|
|
19627
|
-
return value
|
|
19629
|
+
return isObject(value) && value.nodeIndex !== undefined && value.isJoint !== undefined;
|
|
19628
19630
|
}
|
|
19629
19631
|
static checkImageSource(value) {
|
|
19630
19632
|
return isCanvas(value) || value instanceof HTMLImageElement;
|
|
@@ -19634,9 +19636,8 @@ class SerializationHelper {
|
|
|
19634
19636
|
console.error('序列化数据的内嵌对象层数大于上限');
|
|
19635
19637
|
return;
|
|
19636
19638
|
}
|
|
19637
|
-
|
|
19638
|
-
|
|
19639
|
-
} else if (property instanceof Array) {
|
|
19639
|
+
// 加载并链接 DataPath 字段表示的 EffectsObject 引用。Class 对象 copy [key, value] 会丢失对象信息,因此只递归数组对象和普通 js Object 结构对象。
|
|
19640
|
+
if (isArray(property)) {
|
|
19640
19641
|
const res = [];
|
|
19641
19642
|
for (const value of property){
|
|
19642
19643
|
res.push(SerializationHelper.deserializeProperty(value, engine, level + 1, type));
|
|
@@ -19645,21 +19646,19 @@ class SerializationHelper {
|
|
|
19645
19646
|
// TODO json 数据避免传 typedArray
|
|
19646
19647
|
} else if (SerializationHelper.checkDataPath(property)) {
|
|
19647
19648
|
return engine.assetLoader.loadGUID(property.id);
|
|
19648
|
-
} else if (
|
|
19649
|
-
return property;
|
|
19650
|
-
} else if (property instanceof Object) {
|
|
19649
|
+
} else if (isObject(property) && property.constructor === Object) {
|
|
19651
19650
|
let res;
|
|
19652
19651
|
if (type) {
|
|
19653
|
-
|
|
19654
|
-
res = new classConstructor();
|
|
19652
|
+
res = new type();
|
|
19655
19653
|
} else {
|
|
19656
19654
|
res = {};
|
|
19657
19655
|
}
|
|
19658
19656
|
for (const key of Object.keys(property)){
|
|
19659
|
-
// @ts-expect-error
|
|
19660
19657
|
res[key] = SerializationHelper.deserializeProperty(property[key], engine, level + 1);
|
|
19661
19658
|
}
|
|
19662
19659
|
return res;
|
|
19660
|
+
} else {
|
|
19661
|
+
return property;
|
|
19663
19662
|
}
|
|
19664
19663
|
}
|
|
19665
19664
|
static deserializePropertyAsync(property, engine, level, type) {
|
|
@@ -19668,9 +19667,7 @@ class SerializationHelper {
|
|
|
19668
19667
|
console.error('序列化数据的内嵌对象层数大于上限');
|
|
19669
19668
|
return;
|
|
19670
19669
|
}
|
|
19671
|
-
if (
|
|
19672
|
-
return property;
|
|
19673
|
-
} else if (property instanceof Array) {
|
|
19670
|
+
if (isArray(property)) {
|
|
19674
19671
|
const res = [];
|
|
19675
19672
|
for (const value of property){
|
|
19676
19673
|
res.push((yield SerializationHelper.deserializePropertyAsync(value, engine, level + 1, type)));
|
|
@@ -19680,21 +19677,19 @@ class SerializationHelper {
|
|
|
19680
19677
|
} else if (SerializationHelper.checkDataPath(property)) {
|
|
19681
19678
|
const res = yield engine.assetLoader.loadGUIDAsync(property.id);
|
|
19682
19679
|
return res;
|
|
19683
|
-
} else if (
|
|
19684
|
-
return property;
|
|
19685
|
-
} else if (property instanceof Object) {
|
|
19680
|
+
} else if (isObject(property) && property.constructor === Object) {
|
|
19686
19681
|
let res;
|
|
19687
19682
|
if (type) {
|
|
19688
|
-
|
|
19689
|
-
res = new classConstructor();
|
|
19683
|
+
res = new type();
|
|
19690
19684
|
} else {
|
|
19691
19685
|
res = {};
|
|
19692
19686
|
}
|
|
19693
19687
|
for (const key of Object.keys(property)){
|
|
19694
|
-
// @ts-expect-error
|
|
19695
19688
|
res[key] = SerializationHelper.deserializeProperty(property[key], engine, level + 1);
|
|
19696
19689
|
}
|
|
19697
19690
|
return res;
|
|
19691
|
+
} else {
|
|
19692
|
+
return property;
|
|
19698
19693
|
}
|
|
19699
19694
|
})();
|
|
19700
19695
|
}
|
|
@@ -19711,17 +19706,17 @@ class SerializationHelper {
|
|
|
19711
19706
|
if (typeof value === 'number' || typeof value === 'string' || typeof value === 'boolean' || SerializationHelper.checkTypedArray(objectProperty)) {
|
|
19712
19707
|
// TODO json 数据避免传 typedArray
|
|
19713
19708
|
serializedData[key] = value;
|
|
19714
|
-
} else if (value
|
|
19709
|
+
} else if (isArray(value)) {
|
|
19715
19710
|
if (!serializedData[key]) {
|
|
19716
19711
|
serializedData[key] = [];
|
|
19717
19712
|
}
|
|
19718
19713
|
SerializationHelper.serializeArrayProperty(value, serializedData[key], level + 1);
|
|
19719
|
-
} else if (value
|
|
19714
|
+
} else if (EffectsObject.is(value)) {
|
|
19720
19715
|
// TODO 处理 EffectsObject 递归序列化
|
|
19721
19716
|
serializedData[key] = {
|
|
19722
19717
|
id: value.getInstanceId()
|
|
19723
19718
|
};
|
|
19724
|
-
} else if (value
|
|
19719
|
+
} else if (isObject(value)) {
|
|
19725
19720
|
if (!serializedData[key]) {
|
|
19726
19721
|
serializedData[key] = {};
|
|
19727
19722
|
}
|
|
@@ -19742,17 +19737,17 @@ class SerializationHelper {
|
|
|
19742
19737
|
if (typeof value === 'number' || typeof value === 'string' || typeof value === 'boolean' || SerializationHelper.checkTypedArray(arrayProperty)) {
|
|
19743
19738
|
// TODO json 数据避免传 typedArray
|
|
19744
19739
|
serializedData[i] = value;
|
|
19745
|
-
} else if (value
|
|
19740
|
+
} else if (isArray(value)) {
|
|
19746
19741
|
if (!serializedData[i]) {
|
|
19747
19742
|
serializedData[i] = [];
|
|
19748
19743
|
}
|
|
19749
|
-
|
|
19750
|
-
} else if (value
|
|
19744
|
+
SerializationHelper.serializeArrayProperty(value, serializedData[i], level + 1);
|
|
19745
|
+
} else if (EffectsObject.is(value)) {
|
|
19751
19746
|
// TODO 处理 EffectsObject 递归序列化
|
|
19752
19747
|
serializedData[i] = {
|
|
19753
19748
|
id: value.getInstanceId()
|
|
19754
19749
|
};
|
|
19755
|
-
} else if (value
|
|
19750
|
+
} else if (isObject(value)) {
|
|
19756
19751
|
if (!serializedData[i]) {
|
|
19757
19752
|
serializedData[i] = {};
|
|
19758
19753
|
}
|
|
@@ -20683,8 +20678,6 @@ function getStandardCameraContent(model) {
|
|
|
20683
20678
|
/**
|
|
20684
20679
|
* 3.0 以下版本数据适配(runtime 2.0及以上版本支持)
|
|
20685
20680
|
*/ function version30Migration(json) {
|
|
20686
|
-
var // 更正 spine 数据中的 images 属性
|
|
20687
|
-
_json_spines;
|
|
20688
20681
|
var // 兼容老版本数据中不存在textures的情况
|
|
20689
20682
|
_result;
|
|
20690
20683
|
const result = _extends({}, json, {
|
|
@@ -20694,7 +20687,8 @@ function getStandardCameraContent(model) {
|
|
|
20694
20687
|
materials: [],
|
|
20695
20688
|
shaders: [],
|
|
20696
20689
|
geometries: [],
|
|
20697
|
-
animations: []
|
|
20690
|
+
animations: [],
|
|
20691
|
+
miscs: []
|
|
20698
20692
|
});
|
|
20699
20693
|
// image数据添加 guid
|
|
20700
20694
|
for (const image of result.images){
|
|
@@ -20723,17 +20717,10 @@ function getStandardCameraContent(model) {
|
|
|
20723
20717
|
});
|
|
20724
20718
|
}
|
|
20725
20719
|
}
|
|
20726
|
-
|
|
20727
|
-
|
|
20728
|
-
|
|
20729
|
-
|
|
20730
|
-
const textureId = (_json_textures_spine_images_i = json.textures[spine.images[i]]) == null ? void 0 : _json_textures_spine_images_i.id;
|
|
20731
|
-
//@ts-expect-error
|
|
20732
|
-
spine.images[i] = {
|
|
20733
|
-
id: textureId
|
|
20734
|
-
};
|
|
20735
|
-
}
|
|
20736
|
-
});
|
|
20720
|
+
// 处理老版本数据中 bins 没有 id 的情况
|
|
20721
|
+
if (json.bins) {
|
|
20722
|
+
convertBinaryAsset(json.bins, result);
|
|
20723
|
+
}
|
|
20737
20724
|
const itemOldIdToGuidMap = {};
|
|
20738
20725
|
const guidToItemMap = {};
|
|
20739
20726
|
// 更正Composition.endBehavior
|
|
@@ -20954,6 +20941,10 @@ function getStandardCameraContent(model) {
|
|
|
20954
20941
|
//@ts-expect-error
|
|
20955
20942
|
item.type = 'orientation-transformer';
|
|
20956
20943
|
}
|
|
20944
|
+
// Spine 元素转为 guid 索引
|
|
20945
|
+
if (item.type === ItemType.spine && json.spines && json.spines.length !== 0) {
|
|
20946
|
+
convertSpineData(json.spines[item.content.options.spine], item.content, result);
|
|
20947
|
+
}
|
|
20957
20948
|
// item 的 content 转为 component data 加入 JSONScene.components
|
|
20958
20949
|
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') {
|
|
20959
20950
|
item.components = [];
|
|
@@ -21197,20 +21188,48 @@ function convertTimelineAsset(composition, guidToItemMap, jsonScene) {
|
|
|
21197
21188
|
id: timelineAssetData.id
|
|
21198
21189
|
};
|
|
21199
21190
|
composition.sceneBindings = sceneBindings;
|
|
21200
|
-
|
|
21201
|
-
jsonScene.animations = [];
|
|
21202
|
-
}
|
|
21203
|
-
// @ts-expect-error
|
|
21204
|
-
jsonScene.animations.push(timelineAssetData);
|
|
21191
|
+
jsonScene.miscs.push(timelineAssetData);
|
|
21205
21192
|
for (const trackData of trackDatas){
|
|
21206
21193
|
//@ts-expect-error
|
|
21207
|
-
jsonScene.
|
|
21194
|
+
jsonScene.miscs.push(trackData);
|
|
21208
21195
|
}
|
|
21209
21196
|
for (const playableAsset of playableAssetDatas){
|
|
21210
21197
|
//@ts-expect-error
|
|
21211
|
-
jsonScene.
|
|
21198
|
+
jsonScene.miscs.push(playableAsset);
|
|
21212
21199
|
}
|
|
21213
21200
|
}
|
|
21201
|
+
function convertBinaryAsset(bins, jsonScene) {
|
|
21202
|
+
//@ts-expect-error
|
|
21203
|
+
jsonScene.bins = bins.map((bin)=>({
|
|
21204
|
+
url: bin.url,
|
|
21205
|
+
'dataType': 'BinaryAsset',
|
|
21206
|
+
id: generateGUID()
|
|
21207
|
+
}));
|
|
21208
|
+
}
|
|
21209
|
+
function convertSpineData(resource, content, jsonScene) {
|
|
21210
|
+
//@ts-expect-error
|
|
21211
|
+
content.resource = {
|
|
21212
|
+
'atlas': {
|
|
21213
|
+
'bins': {
|
|
21214
|
+
//@ts-expect-error
|
|
21215
|
+
'id': jsonScene.bins[resource.atlas[1][0]].id
|
|
21216
|
+
},
|
|
21217
|
+
'source': resource.atlas[1].slice(1)
|
|
21218
|
+
},
|
|
21219
|
+
'skeleton': {
|
|
21220
|
+
'bins': {
|
|
21221
|
+
//@ts-expect-error
|
|
21222
|
+
'id': jsonScene.bins[resource.skeleton[1][0]].id
|
|
21223
|
+
},
|
|
21224
|
+
'source': resource.skeleton[1].slice(1)
|
|
21225
|
+
},
|
|
21226
|
+
'skeletonType': resource.skeletonType,
|
|
21227
|
+
'images': resource.images.map((i)=>({
|
|
21228
|
+
//@ts-expect-error
|
|
21229
|
+
id: jsonScene.textures[i].id
|
|
21230
|
+
}))
|
|
21231
|
+
};
|
|
21232
|
+
}
|
|
21214
21233
|
|
|
21215
21234
|
const v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
|
|
21216
21235
|
const standardVersion = /^(\d+)\.(\d+)$/;
|
|
@@ -21513,7 +21532,17 @@ function getStandardItem(item, opt = {}) {
|
|
|
21513
21532
|
}
|
|
21514
21533
|
}
|
|
21515
21534
|
|
|
21516
|
-
|
|
21535
|
+
/**
|
|
21536
|
+
* 机型和渲染等级对应表
|
|
21537
|
+
*
|
|
21538
|
+
* 机型:B-低端机、A-中端机、S-高端机
|
|
21539
|
+
* 渲染等级:B-低、A-中、S-高、A+-中高、B+-全部
|
|
21540
|
+
*
|
|
21541
|
+
* - S(高端机):高、全部、中高
|
|
21542
|
+
* - A(中端机):中、全部、中高
|
|
21543
|
+
* - B(低端机):低、全部
|
|
21544
|
+
* - undefined(全部机型)
|
|
21545
|
+
*/ const renderLevelPassSet = {
|
|
21517
21546
|
[RenderLevel.S]: [
|
|
21518
21547
|
RenderLevel.S,
|
|
21519
21548
|
RenderLevel.BPlus,
|
|
@@ -21759,7 +21788,7 @@ let seed = 1;
|
|
|
21759
21788
|
const shaderLibrary = renderer == null ? void 0 : renderer.getShaderLibrary();
|
|
21760
21789
|
yield pluginSystem == null ? void 0 : pluginSystem.precompile(compositions, renderer, options);
|
|
21761
21790
|
yield new Promise((resolve)=>{
|
|
21762
|
-
shaderLibrary.compileAllShaders(()=>{
|
|
21791
|
+
shaderLibrary == null ? void 0 : shaderLibrary.compileAllShaders(()=>{
|
|
21763
21792
|
resolve(null);
|
|
21764
21793
|
});
|
|
21765
21794
|
});
|
|
@@ -23187,7 +23216,7 @@ let listOrder = 0;
|
|
|
23187
23216
|
scene.textures = undefined;
|
|
23188
23217
|
scene.consumed = true;
|
|
23189
23218
|
}
|
|
23190
|
-
const { sourceContent, pluginSystem, imgUsage, totalTime,
|
|
23219
|
+
const { sourceContent, pluginSystem, imgUsage, totalTime, refCompositionProps } = this.compositionSourceManager;
|
|
23191
23220
|
assertExist(sourceContent);
|
|
23192
23221
|
this.renderer = renderer;
|
|
23193
23222
|
this.refCompositionProps = refCompositionProps;
|
|
@@ -23213,7 +23242,6 @@ let listOrder = 0;
|
|
|
23213
23242
|
};
|
|
23214
23243
|
this.reusable = reusable;
|
|
23215
23244
|
this.speed = speed;
|
|
23216
|
-
this.renderLevel = renderLevel;
|
|
23217
23245
|
this.autoRefTex = !this.keepResource && imageUsage && this.rootItem.endBehavior !== ItemEndBehavior.loop;
|
|
23218
23246
|
this.name = sourceContent.name;
|
|
23219
23247
|
this.pluginSystem = pluginSystem;
|
|
@@ -23264,7 +23292,7 @@ let listOrder = 0;
|
|
|
23264
23292
|
}
|
|
23265
23293
|
addPackageDatas(scene) {
|
|
23266
23294
|
const { jsonScene, textureOptions = [] } = scene;
|
|
23267
|
-
const { items = [], materials = [], shaders = [], geometries = [], components = [], animations = [], bins = [] } = jsonScene;
|
|
23295
|
+
const { items = [], materials = [], shaders = [], geometries = [], components = [], animations = [], bins = [], miscs = [] } = jsonScene;
|
|
23268
23296
|
for (const vfxItemData of items){
|
|
23269
23297
|
this.addEffectsObjectData(vfxItemData);
|
|
23270
23298
|
}
|
|
@@ -23283,6 +23311,9 @@ let listOrder = 0;
|
|
|
23283
23311
|
for (const animationData of animations){
|
|
23284
23312
|
this.addEffectsObjectData(animationData);
|
|
23285
23313
|
}
|
|
23314
|
+
for (const miscData of miscs){
|
|
23315
|
+
this.addEffectsObjectData(miscData);
|
|
23316
|
+
}
|
|
23286
23317
|
for(let i = 0; i < bins.length; i++){
|
|
23287
23318
|
const binaryData = bins[i];
|
|
23288
23319
|
const binaryBuffer = scene.bins[i];
|
|
@@ -23657,7 +23688,9 @@ exports.SubCompositionPlayableAsset = SubCompositionPlayableAsset;
|
|
|
23657
23688
|
exports.SubCompositionTrack = SubCompositionTrack;
|
|
23658
23689
|
exports.TEMPLATE_USE_OFFSCREEN_CANVAS = TEMPLATE_USE_OFFSCREEN_CANVAS;
|
|
23659
23690
|
exports.TextComponent = TextComponent;
|
|
23691
|
+
exports.TextLayout = TextLayout;
|
|
23660
23692
|
exports.TextLoader = TextLoader;
|
|
23693
|
+
exports.TextStyle = TextStyle;
|
|
23661
23694
|
exports.Texture = Texture;
|
|
23662
23695
|
exports.TextureFactory = TextureFactory;
|
|
23663
23696
|
exports.Ticker = Ticker;
|
|
@@ -23695,7 +23728,6 @@ exports.createShape = createShape;
|
|
|
23695
23728
|
exports.createVFXItem = createVFXItem;
|
|
23696
23729
|
exports.createValueGetter = createValueGetter;
|
|
23697
23730
|
exports.decimalEqual = decimalEqual;
|
|
23698
|
-
exports.deepClone = deepClone;
|
|
23699
23731
|
exports.defaultGlobalVolume = defaultGlobalVolume;
|
|
23700
23732
|
exports.defaultPlugins = defaultPlugins;
|
|
23701
23733
|
exports.deserializeMipmapTexture = deserializeMipmapTexture;
|
|
@@ -23782,7 +23814,7 @@ exports.particleUniformTypeMap = particleUniformTypeMap;
|
|
|
23782
23814
|
exports.particleVert = particleVert;
|
|
23783
23815
|
exports.pluginLoaderMap = pluginLoaderMap;
|
|
23784
23816
|
exports.pointOnLine = pointOnLine;
|
|
23785
|
-
exports.
|
|
23817
|
+
exports.randomInRange = randomInRange;
|
|
23786
23818
|
exports.registerPlugin = registerPlugin;
|
|
23787
23819
|
exports.removeItem = removeItem;
|
|
23788
23820
|
exports.rotateVec2 = rotateVec2;
|