@galacean/effects-threejs 2.0.0-alpha.1 → 2.0.0-alpha.3

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/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * Description: Galacean Effects runtime threejs plugin for the web
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
6
- * Version: v2.0.0-alpha.1
6
+ * Version: v2.0.0-alpha.3
7
7
  */
8
8
 
9
9
  'use strict';
@@ -7364,275 +7364,6 @@ function generateSerializableMember(type, sourceName) {
7364
7364
  };
7365
7365
  }
7366
7366
 
7367
- /**
7368
- * @since 2.0.0
7369
- * @internal
7370
- */
7371
- var EffectsObject = /** @class */ (function () {
7372
- function EffectsObject(engine) {
7373
- this.engine = engine;
7374
- this.guid = generateGUID();
7375
- this.taggedProperties = {};
7376
- this.engine.addInstance(this);
7377
- }
7378
- EffectsObject.prototype.getInstanceId = function () {
7379
- return this.guid;
7380
- };
7381
- EffectsObject.prototype.setInstanceId = function (guid) {
7382
- this.engine.removeInstance(this.guid);
7383
- this.guid = guid;
7384
- this.engine.addInstance(this);
7385
- };
7386
- EffectsObject.prototype.toData = function () { };
7387
- /**
7388
- * 反序列化函数
7389
- *
7390
- * @param data - 对象的序列化的数据
7391
- */
7392
- EffectsObject.prototype.fromData = function (data) {
7393
- if (data.id) {
7394
- this.setInstanceId(data.id);
7395
- }
7396
- };
7397
- EffectsObject.prototype.dispose = function () { };
7398
- __decorate([
7399
- serialize()
7400
- ], EffectsObject.prototype, "guid", void 0);
7401
- return EffectsObject;
7402
- }());
7403
-
7404
- /**
7405
- * @since 2.0.0
7406
- * @internal
7407
- */
7408
- var Component = /** @class */ (function (_super) {
7409
- __extends(Component, _super);
7410
- function Component() {
7411
- return _super !== null && _super.apply(this, arguments) || this;
7412
- }
7413
- Object.defineProperty(Component.prototype, "transform", {
7414
- /**
7415
- * 附加到的 VFXItem 对象 Transform 组件
7416
- */
7417
- get: function () {
7418
- return this.item.transform;
7419
- },
7420
- enumerable: false,
7421
- configurable: true
7422
- });
7423
- Component.prototype.onAttached = function () { };
7424
- Component.prototype.onDestroy = function () { };
7425
- Component.prototype.fromData = function (data) {
7426
- _super.prototype.fromData.call(this, data);
7427
- if (data.item) {
7428
- this.item = data.item;
7429
- }
7430
- };
7431
- Component.prototype.dispose = function () {
7432
- this.onDestroy();
7433
- if (this.item) {
7434
- removeItem(this.item.components, this);
7435
- }
7436
- };
7437
- return Component;
7438
- }(EffectsObject));
7439
- /**
7440
- * @since 2.0.0
7441
- * @internal
7442
- */
7443
- var Behaviour = /** @class */ (function (_super) {
7444
- __extends(Behaviour, _super);
7445
- function Behaviour() {
7446
- var _this = _super !== null && _super.apply(this, arguments) || this;
7447
- _this._enabled = true;
7448
- return _this;
7449
- }
7450
- Object.defineProperty(Behaviour.prototype, "isActiveAndEnabled", {
7451
- /**
7452
- * 组件是否可以更新,true 更新,false 不更新
7453
- */
7454
- get: function () {
7455
- return this.item.getVisible() && this.enabled;
7456
- },
7457
- enumerable: false,
7458
- configurable: true
7459
- });
7460
- Object.defineProperty(Behaviour.prototype, "enabled", {
7461
- get: function () {
7462
- return this._enabled;
7463
- },
7464
- set: function (value) {
7465
- this._enabled = value;
7466
- if (value) {
7467
- this.onBehaviourEnable();
7468
- }
7469
- },
7470
- enumerable: false,
7471
- configurable: true
7472
- });
7473
- Behaviour.prototype.onBehaviourEnable = function () { };
7474
- Behaviour.prototype.fromData = function (data) {
7475
- _super.prototype.fromData.call(this, data);
7476
- };
7477
- Behaviour.prototype.toData = function () {
7478
- _super.prototype.toData.call(this);
7479
- };
7480
- __decorate([
7481
- serialize()
7482
- ], Behaviour.prototype, "_enabled", void 0);
7483
- return Behaviour;
7484
- }(Component));
7485
- /**
7486
- * @since 2.0.0
7487
- * @internal
7488
- */
7489
- var ItemBehaviour = /** @class */ (function (_super) {
7490
- __extends(ItemBehaviour, _super);
7491
- function ItemBehaviour() {
7492
- var _this = _super !== null && _super.apply(this, arguments) || this;
7493
- _this.started = false;
7494
- return _this;
7495
- }
7496
- // /**
7497
- // * 生命周期函数,初始化后调用,生命周期内只调用一次
7498
- // */
7499
- // awake () {
7500
- // // OVERRIDE
7501
- // }
7502
- /**
7503
- * 在每次设置 enabled 为 true 时触发
7504
- */
7505
- ItemBehaviour.prototype.onEnable = function () { };
7506
- /**
7507
- * 生命周期函数,在第一次 update 前调用,生命周期内只调用一次
7508
- */
7509
- ItemBehaviour.prototype.start = function () {
7510
- // OVERRIDE
7511
- };
7512
- /**
7513
- * 生命周期函数,每帧调用一次
7514
- */
7515
- ItemBehaviour.prototype.update = function (dt) {
7516
- // OVERRIDE
7517
- };
7518
- /**
7519
- * 生命周期函数,每帧调用一次,在 update 之后调用
7520
- */
7521
- ItemBehaviour.prototype.lateUpdate = function (dt) {
7522
- // OVERRIDE
7523
- };
7524
- ItemBehaviour.prototype.onAttached = function () {
7525
- this.item.itemBehaviours.push(this);
7526
- };
7527
- ItemBehaviour.prototype.dispose = function () {
7528
- if (this.item) {
7529
- removeItem(this.item.itemBehaviours, this);
7530
- }
7531
- _super.prototype.dispose.call(this);
7532
- };
7533
- ItemBehaviour.prototype.onBehaviourEnable = function () {
7534
- this.onEnable();
7535
- if (!this.started) {
7536
- this.start();
7537
- this.started = true;
7538
- }
7539
- };
7540
- return ItemBehaviour;
7541
- }(Behaviour));
7542
-
7543
- /**
7544
- * 所有渲染组件的基类
7545
- * @since 2.0.0
7546
- */
7547
- var RendererComponent = /** @class */ (function (_super) {
7548
- __extends(RendererComponent, _super);
7549
- function RendererComponent() {
7550
- var _this = _super !== null && _super.apply(this, arguments) || this;
7551
- _this.started = false;
7552
- _this.materials = [];
7553
- _this._enabled = true;
7554
- return _this;
7555
- }
7556
- Object.defineProperty(RendererComponent.prototype, "priority", {
7557
- get: function () {
7558
- return this._priority;
7559
- },
7560
- set: function (value) {
7561
- this._priority = value;
7562
- },
7563
- enumerable: false,
7564
- configurable: true
7565
- });
7566
- Object.defineProperty(RendererComponent.prototype, "enabled", {
7567
- get: function () {
7568
- return this._enabled;
7569
- },
7570
- set: function (value) {
7571
- this._enabled = value;
7572
- if (value) {
7573
- this.onEnable();
7574
- }
7575
- },
7576
- enumerable: false,
7577
- configurable: true
7578
- });
7579
- Object.defineProperty(RendererComponent.prototype, "isActiveAndEnabled", {
7580
- /**
7581
- * 组件是否可以更新,true 更新,false 不更新
7582
- */
7583
- get: function () {
7584
- return this.item.getVisible() && this.enabled;
7585
- },
7586
- enumerable: false,
7587
- configurable: true
7588
- });
7589
- Object.defineProperty(RendererComponent.prototype, "material", {
7590
- get: function () {
7591
- return this.materials[0];
7592
- },
7593
- set: function (material) {
7594
- if (this.materials.length === 0) {
7595
- this.materials.push(material);
7596
- }
7597
- else {
7598
- this.materials[0] = material;
7599
- }
7600
- },
7601
- enumerable: false,
7602
- configurable: true
7603
- });
7604
- RendererComponent.prototype.onEnable = function () { };
7605
- RendererComponent.prototype.start = function () { };
7606
- RendererComponent.prototype.update = function (dt) { };
7607
- RendererComponent.prototype.lateUpdate = function (dt) { };
7608
- RendererComponent.prototype.render = function (renderer) { };
7609
- RendererComponent.prototype.onAttached = function () {
7610
- this.item.rendererComponents.push(this);
7611
- };
7612
- RendererComponent.prototype.fromData = function (data) {
7613
- _super.prototype.fromData.call(this, data);
7614
- };
7615
- RendererComponent.prototype.toData = function () {
7616
- _super.prototype.toData.call(this);
7617
- };
7618
- RendererComponent.prototype.dispose = function () {
7619
- if (this.item) {
7620
- removeItem(this.item.rendererComponents, this);
7621
- }
7622
- _super.prototype.dispose.call(this);
7623
- };
7624
- __decorate([
7625
- serialize()
7626
- ], RendererComponent.prototype, "materials", void 0);
7627
- __decorate([
7628
- serialize()
7629
- ], RendererComponent.prototype, "_priority", void 0);
7630
- __decorate([
7631
- serialize()
7632
- ], RendererComponent.prototype, "_enabled", void 0);
7633
- return RendererComponent;
7634
- }(Component));
7635
-
7636
7367
  exports.ShaderType = void 0;
7637
7368
  (function (ShaderType) {
7638
7369
  ShaderType[ShaderType["vertex"] = 0] = "vertex";
@@ -8219,6 +7950,43 @@ function loadMipmapImage(pointer, bins) {
8219
7950
  });
8220
7951
  }
8221
7952
 
7953
+ /**
7954
+ * @since 2.0.0
7955
+ * @internal
7956
+ */
7957
+ var EffectsObject = /** @class */ (function () {
7958
+ function EffectsObject(engine) {
7959
+ this.engine = engine;
7960
+ this.guid = generateGUID();
7961
+ this.taggedProperties = {};
7962
+ this.engine.addInstance(this);
7963
+ }
7964
+ EffectsObject.prototype.getInstanceId = function () {
7965
+ return this.guid;
7966
+ };
7967
+ EffectsObject.prototype.setInstanceId = function (guid) {
7968
+ this.engine.removeInstance(this.guid);
7969
+ this.guid = guid;
7970
+ this.engine.addInstance(this);
7971
+ };
7972
+ EffectsObject.prototype.toData = function () { };
7973
+ /**
7974
+ * 反序列化函数
7975
+ *
7976
+ * @param data - 对象的序列化的数据
7977
+ */
7978
+ EffectsObject.prototype.fromData = function (data) {
7979
+ if (data.id) {
7980
+ this.setInstanceId(data.id);
7981
+ }
7982
+ };
7983
+ EffectsObject.prototype.dispose = function () { };
7984
+ __decorate([
7985
+ serialize()
7986
+ ], EffectsObject.prototype, "guid", void 0);
7987
+ return EffectsObject;
7988
+ }());
7989
+
8222
7990
  var seed$a = 1;
8223
7991
  /**
8224
7992
  * Texture 抽象类
@@ -9029,54 +8797,286 @@ var SemanticMap = /** @class */ (function () {
9029
8797
  SemanticMap.prototype.hasSemanticValue = function (name) {
9030
8798
  return name in this.semantics;
9031
8799
  };
9032
- SemanticMap.prototype.dispose = function () {
9033
- var _this = this;
9034
- Object.keys(this.semantics).forEach(function (name) {
9035
- delete _this.semantics[name];
9036
- });
8800
+ SemanticMap.prototype.dispose = function () {
8801
+ var _this = this;
8802
+ Object.keys(this.semantics).forEach(function (name) {
8803
+ delete _this.semantics[name];
8804
+ });
8805
+ };
8806
+ return SemanticMap;
8807
+ }());
8808
+
8809
+ var _a$5;
8810
+ var BYTES_TYPE_MAP = (_a$5 = {},
8811
+ _a$5[glContext.FLOAT] = Float32Array.BYTES_PER_ELEMENT,
8812
+ _a$5[glContext.INT] = Int32Array.BYTES_PER_ELEMENT,
8813
+ _a$5[glContext.SHORT] = Int16Array.BYTES_PER_ELEMENT,
8814
+ _a$5[glContext.BYTE] = Int8Array.BYTES_PER_ELEMENT,
8815
+ _a$5);
8816
+ /**
8817
+ * Geometry 抽象类
8818
+ */
8819
+ var Geometry = /** @class */ (function (_super) {
8820
+ __extends(Geometry, _super);
8821
+ function Geometry() {
8822
+ return _super !== null && _super.apply(this, arguments) || this;
8823
+ }
8824
+ /**
8825
+ * 初始化 GPU 资源
8826
+ * @override
8827
+ */
8828
+ Geometry.prototype.initialize = function () {
8829
+ // OVERRIDE
8830
+ };
8831
+ /**
8832
+ * 几何数据刷新
8833
+ */
8834
+ Geometry.prototype.flush = function () {
8835
+ // OVERRIDE
8836
+ };
8837
+ return Geometry;
8838
+ }(EffectsObject));
8839
+ function generateEmptyTypedArray(type) {
8840
+ if (type === glContext.INT) {
8841
+ return new Int32Array(0);
8842
+ }
8843
+ if (type === glContext.SHORT) {
8844
+ return new Int16Array(0);
8845
+ }
8846
+ return new Float32Array(0);
8847
+ }
8848
+
8849
+ /**
8850
+ * @since 2.0.0
8851
+ * @internal
8852
+ */
8853
+ var Component = /** @class */ (function (_super) {
8854
+ __extends(Component, _super);
8855
+ function Component() {
8856
+ return _super !== null && _super.apply(this, arguments) || this;
8857
+ }
8858
+ Object.defineProperty(Component.prototype, "transform", {
8859
+ /**
8860
+ * 附加到的 VFXItem 对象 Transform 组件
8861
+ */
8862
+ get: function () {
8863
+ return this.item.transform;
8864
+ },
8865
+ enumerable: false,
8866
+ configurable: true
8867
+ });
8868
+ Component.prototype.onAttached = function () { };
8869
+ Component.prototype.onDestroy = function () { };
8870
+ Component.prototype.fromData = function (data) {
8871
+ _super.prototype.fromData.call(this, data);
8872
+ if (data.item) {
8873
+ this.item = data.item;
8874
+ }
8875
+ };
8876
+ Component.prototype.dispose = function () {
8877
+ this.onDestroy();
8878
+ if (this.item) {
8879
+ removeItem(this.item.components, this);
8880
+ }
8881
+ };
8882
+ return Component;
8883
+ }(EffectsObject));
8884
+ /**
8885
+ * @since 2.0.0
8886
+ * @internal
8887
+ */
8888
+ var Behaviour = /** @class */ (function (_super) {
8889
+ __extends(Behaviour, _super);
8890
+ function Behaviour() {
8891
+ var _this = _super !== null && _super.apply(this, arguments) || this;
8892
+ _this._enabled = true;
8893
+ return _this;
8894
+ }
8895
+ Object.defineProperty(Behaviour.prototype, "isActiveAndEnabled", {
8896
+ /**
8897
+ * 组件是否可以更新,true 更新,false 不更新
8898
+ */
8899
+ get: function () {
8900
+ return this.item.getVisible() && this.enabled;
8901
+ },
8902
+ enumerable: false,
8903
+ configurable: true
8904
+ });
8905
+ Object.defineProperty(Behaviour.prototype, "enabled", {
8906
+ get: function () {
8907
+ return this._enabled;
8908
+ },
8909
+ set: function (value) {
8910
+ this._enabled = value;
8911
+ if (value) {
8912
+ this.onBehaviourEnable();
8913
+ }
8914
+ },
8915
+ enumerable: false,
8916
+ configurable: true
8917
+ });
8918
+ Behaviour.prototype.onBehaviourEnable = function () { };
8919
+ Behaviour.prototype.fromData = function (data) {
8920
+ _super.prototype.fromData.call(this, data);
8921
+ };
8922
+ Behaviour.prototype.toData = function () {
8923
+ _super.prototype.toData.call(this);
9037
8924
  };
9038
- return SemanticMap;
9039
- }());
9040
-
9041
- var _a$5;
9042
- var BYTES_TYPE_MAP = (_a$5 = {},
9043
- _a$5[glContext.FLOAT] = Float32Array.BYTES_PER_ELEMENT,
9044
- _a$5[glContext.INT] = Int32Array.BYTES_PER_ELEMENT,
9045
- _a$5[glContext.SHORT] = Int16Array.BYTES_PER_ELEMENT,
9046
- _a$5[glContext.BYTE] = Int8Array.BYTES_PER_ELEMENT,
9047
- _a$5);
8925
+ __decorate([
8926
+ serialize()
8927
+ ], Behaviour.prototype, "_enabled", void 0);
8928
+ return Behaviour;
8929
+ }(Component));
9048
8930
  /**
9049
- * Geometry 抽象类
8931
+ * @since 2.0.0
8932
+ * @internal
9050
8933
  */
9051
- var Geometry = /** @class */ (function (_super) {
9052
- __extends(Geometry, _super);
9053
- function Geometry() {
9054
- return _super !== null && _super.apply(this, arguments) || this;
8934
+ var ItemBehaviour = /** @class */ (function (_super) {
8935
+ __extends(ItemBehaviour, _super);
8936
+ function ItemBehaviour() {
8937
+ var _this = _super !== null && _super.apply(this, arguments) || this;
8938
+ _this.started = false;
8939
+ return _this;
9055
8940
  }
8941
+ // /**
8942
+ // * 生命周期函数,初始化后调用,生命周期内只调用一次
8943
+ // */
8944
+ // awake () {
8945
+ // // OVERRIDE
8946
+ // }
9056
8947
  /**
9057
- * 初始化 GPU 资源
9058
- * @override
8948
+ * 在每次设置 enabled 为 true 时触发
9059
8949
  */
9060
- Geometry.prototype.initialize = function () {
8950
+ ItemBehaviour.prototype.onEnable = function () { };
8951
+ /**
8952
+ * 生命周期函数,在第一次 update 前调用,生命周期内只调用一次
8953
+ */
8954
+ ItemBehaviour.prototype.start = function () {
9061
8955
  // OVERRIDE
9062
8956
  };
9063
8957
  /**
9064
- * 几何数据刷新
8958
+ * 生命周期函数,每帧调用一次
9065
8959
  */
9066
- Geometry.prototype.flush = function () {
8960
+ ItemBehaviour.prototype.update = function (dt) {
9067
8961
  // OVERRIDE
9068
8962
  };
9069
- return Geometry;
9070
- }(EffectsObject));
9071
- function generateEmptyTypedArray(type) {
9072
- if (type === glContext.INT) {
9073
- return new Int32Array(0);
9074
- }
9075
- if (type === glContext.SHORT) {
9076
- return new Int16Array(0);
8963
+ /**
8964
+ * 生命周期函数,每帧调用一次,在 update 之后调用
8965
+ */
8966
+ ItemBehaviour.prototype.lateUpdate = function (dt) {
8967
+ // OVERRIDE
8968
+ };
8969
+ ItemBehaviour.prototype.onAttached = function () {
8970
+ this.item.itemBehaviours.push(this);
8971
+ };
8972
+ ItemBehaviour.prototype.dispose = function () {
8973
+ if (this.item) {
8974
+ removeItem(this.item.itemBehaviours, this);
8975
+ }
8976
+ _super.prototype.dispose.call(this);
8977
+ };
8978
+ ItemBehaviour.prototype.onBehaviourEnable = function () {
8979
+ this.onEnable();
8980
+ if (!this.started) {
8981
+ this.start();
8982
+ this.started = true;
8983
+ }
8984
+ };
8985
+ return ItemBehaviour;
8986
+ }(Behaviour));
8987
+
8988
+ /**
8989
+ * 所有渲染组件的基类
8990
+ * @since 2.0.0
8991
+ */
8992
+ var RendererComponent = /** @class */ (function (_super) {
8993
+ __extends(RendererComponent, _super);
8994
+ function RendererComponent() {
8995
+ var _this = _super !== null && _super.apply(this, arguments) || this;
8996
+ _this.started = false;
8997
+ _this.materials = [];
8998
+ _this._enabled = true;
8999
+ return _this;
9077
9000
  }
9078
- return new Float32Array(0);
9079
- }
9001
+ Object.defineProperty(RendererComponent.prototype, "priority", {
9002
+ get: function () {
9003
+ return this._priority;
9004
+ },
9005
+ set: function (value) {
9006
+ this._priority = value;
9007
+ },
9008
+ enumerable: false,
9009
+ configurable: true
9010
+ });
9011
+ Object.defineProperty(RendererComponent.prototype, "enabled", {
9012
+ get: function () {
9013
+ return this._enabled;
9014
+ },
9015
+ set: function (value) {
9016
+ this._enabled = value;
9017
+ if (value) {
9018
+ this.onEnable();
9019
+ }
9020
+ },
9021
+ enumerable: false,
9022
+ configurable: true
9023
+ });
9024
+ Object.defineProperty(RendererComponent.prototype, "isActiveAndEnabled", {
9025
+ /**
9026
+ * 组件是否可以更新,true 更新,false 不更新
9027
+ */
9028
+ get: function () {
9029
+ return this.item.getVisible() && this.enabled;
9030
+ },
9031
+ enumerable: false,
9032
+ configurable: true
9033
+ });
9034
+ Object.defineProperty(RendererComponent.prototype, "material", {
9035
+ get: function () {
9036
+ return this.materials[0];
9037
+ },
9038
+ set: function (material) {
9039
+ if (this.materials.length === 0) {
9040
+ this.materials.push(material);
9041
+ }
9042
+ else {
9043
+ this.materials[0] = material;
9044
+ }
9045
+ },
9046
+ enumerable: false,
9047
+ configurable: true
9048
+ });
9049
+ RendererComponent.prototype.onEnable = function () { };
9050
+ RendererComponent.prototype.start = function () { };
9051
+ RendererComponent.prototype.update = function (dt) { };
9052
+ RendererComponent.prototype.lateUpdate = function (dt) { };
9053
+ RendererComponent.prototype.render = function (renderer) { };
9054
+ RendererComponent.prototype.onAttached = function () {
9055
+ this.item.rendererComponents.push(this);
9056
+ };
9057
+ RendererComponent.prototype.fromData = function (data) {
9058
+ _super.prototype.fromData.call(this, data);
9059
+ };
9060
+ RendererComponent.prototype.toData = function () {
9061
+ _super.prototype.toData.call(this);
9062
+ };
9063
+ RendererComponent.prototype.dispose = function () {
9064
+ if (this.item) {
9065
+ removeItem(this.item.rendererComponents, this);
9066
+ }
9067
+ _super.prototype.dispose.call(this);
9068
+ };
9069
+ __decorate([
9070
+ serialize()
9071
+ ], RendererComponent.prototype, "materials", void 0);
9072
+ __decorate([
9073
+ serialize()
9074
+ ], RendererComponent.prototype, "_priority", void 0);
9075
+ __decorate([
9076
+ serialize()
9077
+ ], RendererComponent.prototype, "_enabled", void 0);
9078
+ return RendererComponent;
9079
+ }(Component));
9080
9080
 
9081
9081
  var seed$8 = 1;
9082
9082
  /**
@@ -11313,7 +11313,7 @@ var SerializationHelper = /** @class */ (function () {
11313
11313
  };
11314
11314
  SerializationHelper.deserializeProperty = function (property, engine, level) {
11315
11315
  var e_11, _a, e_12, _b;
11316
- if (level > 10) {
11316
+ if (level > 14) {
11317
11317
  console.error('序列化数据的内嵌对象层数大于上限');
11318
11318
  return;
11319
11319
  }
@@ -11374,7 +11374,7 @@ var SerializationHelper = /** @class */ (function () {
11374
11374
  return __generator(this, function (_j) {
11375
11375
  switch (_j.label) {
11376
11376
  case 0:
11377
- if (level > 10) {
11377
+ if (level > 14) {
11378
11378
  console.error('序列化数据的内嵌对象层数大于上限');
11379
11379
  return [2 /*return*/];
11380
11380
  }
@@ -11465,7 +11465,7 @@ var SerializationHelper = /** @class */ (function () {
11465
11465
  };
11466
11466
  SerializationHelper.serializeObjectProperty = function (objectProperty, serializedData, level) {
11467
11467
  var e_15, _a;
11468
- if (level > 10) {
11468
+ if (level > 14) {
11469
11469
  console.error('序列化数据的内嵌对象层数大于上限');
11470
11470
  return;
11471
11471
  }
@@ -11510,7 +11510,7 @@ var SerializationHelper = /** @class */ (function () {
11510
11510
  }
11511
11511
  };
11512
11512
  SerializationHelper.serializeArrayProperty = function (arrayProperty, serializedData, level) {
11513
- if (level > 10) {
11513
+ if (level > 14) {
11514
11514
  console.error('序列化数据的内嵌对象层数大于上限');
11515
11515
  return;
11516
11516
  }
@@ -11676,24 +11676,24 @@ var Database = /** @class */ (function () {
11676
11676
  }());
11677
11677
  exports.DataType = void 0;
11678
11678
  (function (DataType) {
11679
- DataType[DataType["VFXItemData"] = 0] = "VFXItemData";
11680
- DataType[DataType["EffectComponent"] = 1] = "EffectComponent";
11681
- DataType[DataType["Material"] = 2] = "Material";
11682
- DataType[DataType["Shader"] = 3] = "Shader";
11683
- DataType[DataType["SpriteComponent"] = 4] = "SpriteComponent";
11684
- DataType[DataType["ParticleSystem"] = 5] = "ParticleSystem";
11685
- DataType[DataType["InteractComponent"] = 6] = "InteractComponent";
11686
- DataType[DataType["CameraController"] = 7] = "CameraController";
11687
- DataType[DataType["Geometry"] = 8] = "Geometry";
11688
- DataType[DataType["Texture"] = 9] = "Texture";
11689
- DataType[DataType["TextComponent"] = 10] = "TextComponent";
11679
+ DataType["VFXItemData"] = "VFXItemData";
11680
+ DataType["EffectComponent"] = "EffectComponent";
11681
+ DataType["Material"] = "Material";
11682
+ DataType["Shader"] = "Shader";
11683
+ DataType["SpriteComponent"] = "SpriteComponent";
11684
+ DataType["ParticleSystem"] = "ParticleSystem";
11685
+ DataType["InteractComponent"] = "InteractComponent";
11686
+ DataType["CameraController"] = "CameraController";
11687
+ DataType["Geometry"] = "Geometry";
11688
+ DataType["Texture"] = "Texture";
11689
+ DataType["TextComponent"] = "TextComponent";
11690
11690
  // FIXME: 先完成ECS的场景转换,后面移到spec中
11691
- DataType[DataType["MeshComponent"] = 10000] = "MeshComponent";
11692
- DataType[DataType["SkyboxComponent"] = 10001] = "SkyboxComponent";
11693
- DataType[DataType["LightComponent"] = 10002] = "LightComponent";
11694
- DataType[DataType["CameraComponent"] = 10003] = "CameraComponent";
11695
- DataType[DataType["ModelPluginComponent"] = 10004] = "ModelPluginComponent";
11696
- DataType[DataType["TreeComponent"] = 10005] = "TreeComponent";
11691
+ DataType["MeshComponent"] = "MeshComponent";
11692
+ DataType["SkyboxComponent"] = "SkyboxComponent";
11693
+ DataType["LightComponent"] = "LightComponent";
11694
+ DataType["CameraComponent"] = "CameraComponent";
11695
+ DataType["ModelPluginComponent"] = "ModelPluginComponent";
11696
+ DataType["TreeComponent"] = "TreeComponent";
11697
11697
  })(exports.DataType || (exports.DataType = {}));
11698
11698
 
11699
11699
  /**
@@ -13960,15 +13960,25 @@ var PlayableOutput = /** @class */ (function () {
13960
13960
  };
13961
13961
  return PlayableOutput;
13962
13962
  }());
13963
+ var PlayableAsset = /** @class */ (function () {
13964
+ function PlayableAsset() {
13965
+ }
13966
+ PlayableAsset.prototype.fromData = function (data) {
13967
+ };
13968
+ return PlayableAsset;
13969
+ }());
13963
13970
 
13964
13971
  /**
13965
13972
  * @since 2.0.0
13966
13973
  * @internal
13967
13974
  */
13968
- var Track = /** @class */ (function () {
13975
+ var Track = /** @class */ (function (_super) {
13976
+ __extends(Track, _super);
13969
13977
  function Track() {
13970
- this.clips = [];
13971
- this.clipSeed = 0;
13978
+ var _this = _super !== null && _super.apply(this, arguments) || this;
13979
+ _this.clips = [];
13980
+ _this.clipSeed = 0;
13981
+ return _this;
13972
13982
  }
13973
13983
  Track.prototype.createOutput = function () {
13974
13984
  var output = new PlayableOutput();
@@ -13980,7 +13990,7 @@ var Track = /** @class */ (function () {
13980
13990
  Track.prototype.createMixerPlayable = function () {
13981
13991
  return new Playable();
13982
13992
  };
13983
- Track.prototype.createPlayebleTree = function () {
13993
+ Track.prototype.createPlayable = function () {
13984
13994
  var e_1, _a;
13985
13995
  var defaultMixPlayable = this.createMixerPlayable();
13986
13996
  try {
@@ -14032,7 +14042,7 @@ var Track = /** @class */ (function () {
14032
14042
  this.clips.push(clip);
14033
14043
  };
14034
14044
  return Track;
14035
- }());
14045
+ }(PlayableAsset));
14036
14046
  /**
14037
14047
  * @since 2.0.0
14038
14048
  * @internal
@@ -14088,12 +14098,12 @@ var tempPos = new Vector3();
14088
14098
  * @since 2.0.0
14089
14099
  * @internal
14090
14100
  */
14091
- var AnimationClipPlayable = /** @class */ (function (_super) {
14092
- __extends(AnimationClipPlayable, _super);
14093
- function AnimationClipPlayable() {
14101
+ var TransformAnimationPlayable = /** @class */ (function (_super) {
14102
+ __extends(TransformAnimationPlayable, _super);
14103
+ function TransformAnimationPlayable() {
14094
14104
  return _super !== null && _super.apply(this, arguments) || this;
14095
14105
  }
14096
- AnimationClipPlayable.prototype.processFrame = function (dt) {
14106
+ TransformAnimationPlayable.prototype.processFrame = function (dt) {
14097
14107
  if (this.bindingItem.composition) {
14098
14108
  this.sampleAnimation();
14099
14109
  }
@@ -14101,7 +14111,7 @@ var AnimationClipPlayable = /** @class */ (function (_super) {
14101
14111
  /**
14102
14112
  * 应用时间轴K帧数据到对象
14103
14113
  */
14104
- AnimationClipPlayable.prototype.sampleAnimation = function () {
14114
+ TransformAnimationPlayable.prototype.sampleAnimation = function () {
14105
14115
  var _this = this;
14106
14116
  var duration = this.bindingItem.duration;
14107
14117
  var life = this.time / duration;
@@ -14146,7 +14156,7 @@ var AnimationClipPlayable = /** @class */ (function (_super) {
14146
14156
  // this.animationStream.setCurveValue('transform', 'position.z', pos.z);
14147
14157
  }
14148
14158
  };
14149
- AnimationClipPlayable.prototype.fromData = function (data) {
14159
+ TransformAnimationPlayable.prototype.fromData = function (data) {
14150
14160
  var _a;
14151
14161
  var scale = this.bindingItem.transform.scale;
14152
14162
  this.originalTransform = {
@@ -14217,30 +14227,45 @@ var AnimationClipPlayable = /** @class */ (function (_super) {
14217
14227
  this.velocity = this.direction.clone();
14218
14228
  this.velocity.multiply(this.startSpeed);
14219
14229
  };
14220
- return AnimationClipPlayable;
14230
+ return TransformAnimationPlayable;
14221
14231
  }(AnimationPlayable));
14232
+ var TransformAnimationPlayableAsset = /** @class */ (function (_super) {
14233
+ __extends(TransformAnimationPlayableAsset, _super);
14234
+ function TransformAnimationPlayableAsset() {
14235
+ return _super !== null && _super.apply(this, arguments) || this;
14236
+ }
14237
+ TransformAnimationPlayableAsset.prototype.createPlayable = function () {
14238
+ var transformAnimationPlayable = new TransformAnimationPlayable();
14239
+ transformAnimationPlayable.fromData(this.transformAnimationData);
14240
+ return transformAnimationPlayable;
14241
+ };
14242
+ TransformAnimationPlayableAsset.prototype.fromData = function (data) {
14243
+ this.transformAnimationData = data;
14244
+ };
14245
+ return TransformAnimationPlayableAsset;
14246
+ }(PlayableAsset));
14222
14247
  /**
14223
14248
  * @since 2.0.0
14224
14249
  * @internal
14225
14250
  */
14226
- var ActivationClipPlayable = /** @class */ (function (_super) {
14227
- __extends(ActivationClipPlayable, _super);
14228
- function ActivationClipPlayable() {
14251
+ var ActivationPlayable = /** @class */ (function (_super) {
14252
+ __extends(ActivationPlayable, _super);
14253
+ function ActivationPlayable() {
14229
14254
  return _super !== null && _super.apply(this, arguments) || this;
14230
14255
  }
14231
- ActivationClipPlayable.prototype.onGraphStart = function () {
14256
+ ActivationPlayable.prototype.onGraphStart = function () {
14232
14257
  this.bindingItem.transform.setValid(false);
14233
14258
  this.hideRendererComponents();
14234
14259
  };
14235
- ActivationClipPlayable.prototype.onPlayablePlay = function () {
14260
+ ActivationPlayable.prototype.onPlayablePlay = function () {
14236
14261
  this.bindingItem.transform.setValid(true);
14237
14262
  this.showRendererComponents();
14238
14263
  };
14239
- ActivationClipPlayable.prototype.onPlayableDestroy = function () {
14264
+ ActivationPlayable.prototype.onPlayableDestroy = function () {
14240
14265
  this.bindingItem.transform.setValid(false);
14241
14266
  this.hideRendererComponents();
14242
14267
  };
14243
- ActivationClipPlayable.prototype.hideRendererComponents = function () {
14268
+ ActivationPlayable.prototype.hideRendererComponents = function () {
14244
14269
  var e_1, _a;
14245
14270
  try {
14246
14271
  for (var _b = __values$1(this.bindingItem.rendererComponents), _c = _b.next(); !_c.done; _c = _b.next()) {
@@ -14258,7 +14283,7 @@ var ActivationClipPlayable = /** @class */ (function (_super) {
14258
14283
  finally { if (e_1) throw e_1.error; }
14259
14284
  }
14260
14285
  };
14261
- ActivationClipPlayable.prototype.showRendererComponents = function () {
14286
+ ActivationPlayable.prototype.showRendererComponents = function () {
14262
14287
  var e_2, _a;
14263
14288
  try {
14264
14289
  for (var _b = __values$1(this.bindingItem.rendererComponents), _c = _b.next(); !_c.done; _c = _b.next()) {
@@ -14276,7 +14301,7 @@ var ActivationClipPlayable = /** @class */ (function (_super) {
14276
14301
  finally { if (e_2) throw e_2.error; }
14277
14302
  }
14278
14303
  };
14279
- return ActivationClipPlayable;
14304
+ return ActivationPlayable;
14280
14305
  }(Playable));
14281
14306
 
14282
14307
  /**
@@ -14531,7 +14556,7 @@ var TimelineComponent = /** @class */ (function (_super) {
14531
14556
  try {
14532
14557
  for (var _b = __values$1(this.tracks), _c = _b.next(); !_c.done; _c = _b.next()) {
14533
14558
  var track = _c.value;
14534
- var trackMixPlayable = track.createPlayebleTree();
14559
+ var trackMixPlayable = track.createPlayable();
14535
14560
  var trackOutput = track.createOutput();
14536
14561
  graph.addOutput(trackOutput);
14537
14562
  trackOutput.setSourcePlayeble(trackMixPlayable);
@@ -14546,6 +14571,7 @@ var TimelineComponent = /** @class */ (function (_super) {
14546
14571
  }
14547
14572
  };
14548
14573
  TimelineComponent.prototype.fromData = function (data) {
14574
+ var e_13, _a, e_14, _b;
14549
14575
  _super.prototype.fromData.call(this, data);
14550
14576
  this.options = {
14551
14577
  start: this.item.start,
@@ -14556,7 +14582,47 @@ var TimelineComponent = /** @class */ (function (_super) {
14556
14582
  this.id = this.item.id;
14557
14583
  this.name = this.item.name;
14558
14584
  var activationTrack = this.createTrack(Track, 'ActivationTrack');
14559
- activationTrack.createClip(ActivationClipPlayable, 'ActivationTimelineClip');
14585
+ activationTrack.createClip(ActivationPlayable, 'ActivationTimelineClip');
14586
+ //@ts-expect-error
14587
+ if (data.tracks) {
14588
+ //@ts-expect-error
14589
+ var tracks = data.tracks;
14590
+ try {
14591
+ for (var tracks_1 = __values$1(tracks), tracks_1_1 = tracks_1.next(); !tracks_1_1.done; tracks_1_1 = tracks_1.next()) {
14592
+ var track = tracks_1_1.value;
14593
+ var newTrack = this.createTrack(Track);
14594
+ try {
14595
+ for (var _c = (e_14 = void 0, __values$1(track.clips)), _d = _c.next(); !_d.done; _d = _c.next()) {
14596
+ var clipAsset = _d.value;
14597
+ switch (clipAsset.dataType) {
14598
+ case 'TransformAnimationPlayableAsset':
14599
+ newTrack.name = 'AnimationTrack';
14600
+ newTrack.createClip(TransformAnimationPlayable, 'AnimationTimelineClip').playable.fromData(clipAsset.animationClip);
14601
+ break;
14602
+ case 'SpriteColorAnimationPlayableAsset':
14603
+ newTrack.name = 'SpriteColorTrack';
14604
+ newTrack.createClip(SpriteColorPlayable, 'SpriteColorClip').playable.fromData(clipAsset.animationClip);
14605
+ break;
14606
+ }
14607
+ }
14608
+ }
14609
+ catch (e_14_1) { e_14 = { error: e_14_1 }; }
14610
+ finally {
14611
+ try {
14612
+ if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
14613
+ }
14614
+ finally { if (e_14) throw e_14.error; }
14615
+ }
14616
+ }
14617
+ }
14618
+ catch (e_13_1) { e_13 = { error: e_13_1 }; }
14619
+ finally {
14620
+ try {
14621
+ if (tracks_1_1 && !tracks_1_1.done && (_a = tracks_1.return)) _a.call(tracks_1);
14622
+ }
14623
+ finally { if (e_13) throw e_13.error; }
14624
+ }
14625
+ }
14560
14626
  };
14561
14627
  TimelineComponent.prototype.toData = function () {
14562
14628
  _super.prototype.toData.call(this);
@@ -14970,9 +15036,6 @@ var SpriteComponent = /** @class */ (function (_super) {
14970
15036
  this.material.setVector4('_Color', new Vector4().setFromArray(startColor));
14971
15037
  this.material.setVector4('_TexOffset', new Vector4().setFromArray([0, 0, 1, 1]));
14972
15038
  this.setItem();
14973
- // 添加K帧动画
14974
- var colorTrack = this.item.getComponent(TimelineComponent).createTrack(Track, 'SpriteColorTrack');
14975
- colorTrack.createClip(SpriteColorPlayable, 'SpriteColorClip').playable.fromData({ colorOverLifetime: data.colorOverLifetime, startColor: data.options.startColor });
14976
15039
  };
14977
15040
  SpriteComponent.prototype.toData = function () {
14978
15041
  _super.prototype.toData.call(this);
@@ -20629,10 +20692,6 @@ var VFXItem = /** @class */ (function (_super) {
20629
20692
  }
20630
20693
  var timelineComponent = this.getComponent(TimelineComponent);
20631
20694
  timelineComponent.fromData(data.content);
20632
- if (this.type !== ItemType$1.particle) {
20633
- var track = timelineComponent.createTrack(Track, 'AnimationTrack');
20634
- track.createClip(AnimationClipPlayable, 'AnimationTimelineClip').playable.fromData(data.content);
20635
- }
20636
20695
  if (duration <= 0) {
20637
20696
  throw Error("Item duration can't be less than 0, see ".concat(HELP_LINK['Item duration can\'t be less than 0']));
20638
20697
  }
@@ -22844,6 +22903,49 @@ function version3Migration(scene) {
22844
22903
  if (item.endBehavior === END_BEHAVIOR_PAUSE_AND_DESTROY$1 || item.endBehavior === END_BEHAVIOR_PAUSE$1) {
22845
22904
  item.endBehavior = END_BEHAVIOR_FREEZE$1;
22846
22905
  }
22906
+ // 动画数据转化 TODO: 动画数据移到 TimelineComponentData
22907
+ //@ts-expect-error
22908
+ item.content.tracks = [];
22909
+ //@ts-expect-error
22910
+ var tracks = item.content.tracks;
22911
+ if (item.type !== ItemType$1.particle) {
22912
+ tracks.push({
22913
+ clips: [
22914
+ {
22915
+ dataType: 'TransformAnimationPlayableAsset',
22916
+ animationClip: {
22917
+ //@ts-expect-error
22918
+ sizeOverLifetime: item.content.sizeOverLifetime,
22919
+ //@ts-expect-error
22920
+ rotationOverLifetime: item.content.rotationOverLifetime,
22921
+ //@ts-expect-error
22922
+ positionOverLifetime: item.content.positionOverLifetime,
22923
+ },
22924
+ },
22925
+ ],
22926
+ });
22927
+ }
22928
+ if (item.type === ItemType$1.sprite) {
22929
+ tracks.push({
22930
+ clips: [
22931
+ {
22932
+ dataType: 'SpriteColorAnimationPlayableAsset',
22933
+ animationClip: {
22934
+ //@ts-expect-error
22935
+ colorOverLifetime: item.content.colorOverLifetime,
22936
+ //@ts-expect-error
22937
+ startColor: item.content.options.startColor,
22938
+ },
22939
+ },
22940
+ ],
22941
+ });
22942
+ }
22943
+ // gizmo 的 target id 转换为新的 item guid
22944
+ //@ts-expect-error
22945
+ if (item.content.options.target) {
22946
+ //@ts-expect-error
22947
+ item.content.options.target = itemGuidMap[item.content.options.target];
22948
+ }
22847
22949
  // item 的 content 转为 component data 加入 JSONScene.components
22848
22950
  var uuid = v4().replace(/-/g, '');
22849
22951
  if (item.type === ItemType$1.sprite) {
@@ -27542,12 +27644,11 @@ Geometry.create = function (engine, options) {
27542
27644
  Mesh.create = function (engine, props) {
27543
27645
  return new ThreeMesh(engine, props);
27544
27646
  };
27545
- var version = "2.0.0-alpha.1";
27647
+ var version = "2.0.0-alpha.3";
27546
27648
  logger.info('THREEJS plugin version: ' + version);
27547
27649
 
27548
27650
  exports.AbstractPlugin = AbstractPlugin;
27549
- exports.ActivationClipPlayable = ActivationClipPlayable;
27550
- exports.AnimationClipPlayable = AnimationClipPlayable;
27651
+ exports.ActivationPlayable = ActivationPlayable;
27551
27652
  exports.AssetLoader = AssetLoader;
27552
27653
  exports.AssetManager = AssetManager;
27553
27654
  exports.BYTES_TYPE_MAP = BYTES_TYPE_MAP;
@@ -27657,6 +27758,8 @@ exports.TimelineClip = TimelineClip;
27657
27758
  exports.TimelineComponent = TimelineComponent;
27658
27759
  exports.Track = Track;
27659
27760
  exports.Transform = Transform;
27761
+ exports.TransformAnimationPlayable = TransformAnimationPlayable;
27762
+ exports.TransformAnimationPlayableAsset = TransformAnimationPlayableAsset;
27660
27763
  exports.VFXItem = VFXItem;
27661
27764
  exports.ValueGetter = ValueGetter;
27662
27765
  exports.addByOrder = addByOrder;