@galacean/effects-threejs 2.0.0-alpha.0 → 2.0.0-alpha.2

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.mjs 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.0
6
+ * Version: v2.0.0-alpha.2
7
7
  */
8
8
 
9
9
  import * as THREE from 'three';
@@ -8195,7 +8195,7 @@ function loadMipmapImage(pointer, bins) {
8195
8195
  });
8196
8196
  }
8197
8197
 
8198
- var seed$b = 1;
8198
+ var seed$a = 1;
8199
8199
  /**
8200
8200
  * Texture 抽象类
8201
8201
  */
@@ -8204,7 +8204,7 @@ var Texture = /** @class */ (function (_super) {
8204
8204
  function Texture(engine) {
8205
8205
  var _this = _super.call(this, engine) || this;
8206
8206
  _this.destroyed = false;
8207
- _this.id = 'Tex' + seed$b++;
8207
+ _this.id = 'Tex' + seed$a++;
8208
8208
  return _this;
8209
8209
  }
8210
8210
  Object.defineProperty(Texture.prototype, "isDestroyed", {
@@ -8606,7 +8606,7 @@ var MaterialRenderType;
8606
8606
  * 用于设置材质默认名称的自增序号
8607
8607
  * @internal
8608
8608
  */
8609
- var seed$a = 1;
8609
+ var seed$9 = 1;
8610
8610
  /**
8611
8611
  * Material 抽象类
8612
8612
  */
@@ -8621,7 +8621,7 @@ var Material = /** @class */ (function (_super) {
8621
8621
  _this.destroyed = false;
8622
8622
  _this.initialized = false;
8623
8623
  if (props) {
8624
- var _a = props.name, name_1 = _a === void 0 ? 'Material' + seed$a++ : _a, _b = props.renderType, renderType = _b === void 0 ? MaterialRenderType.normal : _b, shader = props.shader, uniformSemantics = props.uniformSemantics;
8624
+ var _a = props.name, name_1 = _a === void 0 ? 'Material' + seed$9++ : _a, _b = props.renderType, renderType = _b === void 0 ? MaterialRenderType.normal : _b, shader = props.shader, uniformSemantics = props.uniformSemantics;
8625
8625
  _this.name = name_1;
8626
8626
  _this.renderType = renderType; // TODO 没有地方用到
8627
8627
  _this.shaderSource = shader;
@@ -8629,7 +8629,7 @@ var Material = /** @class */ (function (_super) {
8629
8629
  _this.uniformSemantics = __assign$1({}, uniformSemantics); // TODO 废弃,待移除
8630
8630
  }
8631
8631
  else {
8632
- _this.name = 'Material' + seed$a++;
8632
+ _this.name = 'Material' + seed$9++;
8633
8633
  _this.renderType = MaterialRenderType.normal;
8634
8634
  }
8635
8635
  return _this;
@@ -9054,7 +9054,7 @@ function generateEmptyTypedArray(type) {
9054
9054
  return new Float32Array(0);
9055
9055
  }
9056
9056
 
9057
- var seed$9 = 1;
9057
+ var seed$8 = 1;
9058
9058
  /**
9059
9059
  * Mesh 抽象类
9060
9060
  */
@@ -9066,7 +9066,7 @@ var Mesh = /** @class */ (function (_super) {
9066
9066
  _this.visible = true;
9067
9067
  if (props) {
9068
9068
  var material = props.material, geometry = props.geometry, _a = props.name, name_1 = _a === void 0 ? '<unnamed>' : _a, _b = props.priority, priority = _b === void 0 ? 0 : _b, _c = props.worldMatrix, worldMatrix = _c === void 0 ? Matrix4.fromIdentity() : _c;
9069
- _this.id = 'Mesh' + seed$9++;
9069
+ _this.id = 'Mesh' + seed$8++;
9070
9070
  _this.name = name_1;
9071
9071
  _this.geometry = geometry;
9072
9072
  _this.material = material;
@@ -9074,7 +9074,7 @@ var Mesh = /** @class */ (function (_super) {
9074
9074
  _this.worldMatrix = worldMatrix;
9075
9075
  }
9076
9076
  else {
9077
- _this.id = 'Mesh' + seed$9++;
9077
+ _this.id = 'Mesh' + seed$8++;
9078
9078
  _this.name = '<unnamed>';
9079
9079
  _this.worldMatrix = Matrix4.fromIdentity();
9080
9080
  _this._priority = 0;
@@ -9294,7 +9294,7 @@ var RenderPassDestroyAttachmentType;
9294
9294
  */
9295
9295
  RenderPassDestroyAttachmentType[RenderPassDestroyAttachmentType["destroy"] = 0] = "destroy";
9296
9296
  })(RenderPassDestroyAttachmentType || (RenderPassDestroyAttachmentType = {}));
9297
- var seed$8 = 1;
9297
+ var seed$7 = 1;
9298
9298
  /**
9299
9299
  * RenderPass 抽象类
9300
9300
  */
@@ -9306,7 +9306,7 @@ var RenderPass = /** @class */ (function () {
9306
9306
  this.attachments = [];
9307
9307
  this.destroyed = false;
9308
9308
  this.initialized = false;
9309
- var _a = options.name, name = _a === void 0 ? 'RenderPass_' + seed$8++ : _a, clearAction = options.clearAction, semantics = options.semantics, depthStencilAttachment = options.depthStencilAttachment, storeAction = options.storeAction, _b = options.priority, priority = _b === void 0 ? 0 : _b, _c = options.meshOrder, meshOrder = _c === void 0 ? OrderType.ascending : _c, _d = options.meshes, meshes = _d === void 0 ? [] : _d, _e = options.delegate, delegate = _e === void 0 ? {} : _e;
9309
+ var _a = options.name, name = _a === void 0 ? 'RenderPass_' + seed$7++ : _a, clearAction = options.clearAction, semantics = options.semantics, depthStencilAttachment = options.depthStencilAttachment, storeAction = options.storeAction, _b = options.priority, priority = _b === void 0 ? 0 : _b, _c = options.meshOrder, meshOrder = _c === void 0 ? OrderType.ascending : _c, _d = options.meshes, meshes = _d === void 0 ? [] : _d, _e = options.delegate, delegate = _e === void 0 ? {} : _e;
9310
9310
  this.name = name;
9311
9311
  this.renderer = renderer;
9312
9312
  this.priority = priority;
@@ -9923,7 +9923,7 @@ var defaultGlobalVolume = {
9923
9923
  };
9924
9924
 
9925
9925
  var RENDER_PASS_NAME_PREFIX = '_effects_default_';
9926
- var seed$7 = 1;
9926
+ var seed$6 = 1;
9927
9927
  /**
9928
9928
  * RenderFrame 抽象类
9929
9929
  */
@@ -10058,7 +10058,7 @@ var RenderFrame = /** @class */ (function () {
10058
10058
  }
10059
10059
  this.semantics = new SemanticMap(options.semantics);
10060
10060
  this.clearAction = clearAction;
10061
- this.name = "RenderFrame".concat(seed$7++);
10061
+ this.name = "RenderFrame".concat(seed$6++);
10062
10062
  var firstRP = renderPasses[0];
10063
10063
  var sourceOpts = {
10064
10064
  type: glContext.UNSIGNED_BYTE,
@@ -11281,6 +11281,12 @@ var SerializationHelper = /** @class */ (function () {
11281
11281
  value.id &&
11282
11282
  value.id.length === 32;
11283
11283
  };
11284
+ // TODO 测试函数,2.0 上线后移除
11285
+ SerializationHelper.checkGLTFNode = function (value) {
11286
+ return value instanceof Object &&
11287
+ value.nodeIndex !== undefined &&
11288
+ value.isJoint !== undefined;
11289
+ };
11284
11290
  SerializationHelper.deserializeProperty = function (property, engine, level) {
11285
11291
  var e_11, _a, e_12, _b;
11286
11292
  if (level > 10) {
@@ -11313,7 +11319,9 @@ var SerializationHelper = /** @class */ (function () {
11313
11319
  else if (SerializationHelper.checkDataPath(property)) {
11314
11320
  return engine.assetLoader.loadGUID(property.id);
11315
11321
  }
11316
- else if (property instanceof EffectsObject || SerializationHelper.checkTypedArray(property)) {
11322
+ else if (property instanceof EffectsObject ||
11323
+ SerializationHelper.checkTypedArray(property) ||
11324
+ SerializationHelper.checkGLTFNode(property)) {
11317
11325
  return property;
11318
11326
  }
11319
11327
  else if (property instanceof Object) {
@@ -11388,7 +11396,9 @@ var SerializationHelper = /** @class */ (function () {
11388
11396
  res = _j.sent();
11389
11397
  return [2 /*return*/, res];
11390
11398
  case 12:
11391
- if (!(property instanceof EffectsObject || SerializationHelper.checkTypedArray(property))) return [3 /*break*/, 13];
11399
+ if (!(property instanceof EffectsObject ||
11400
+ SerializationHelper.checkTypedArray(property) ||
11401
+ SerializationHelper.checkGLTFNode(property))) return [3 /*break*/, 13];
11392
11402
  return [2 /*return*/, property];
11393
11403
  case 13:
11394
11404
  if (!(property instanceof Object)) return [3 /*break*/, 22];
@@ -11876,20 +11886,6 @@ var particleOriginTranslateMap = (_a$4 = {},
11876
11886
  _a$4[ParticleOrigin$1.PARTICLE_ORIGIN_RIGHT_BOTTOM] = [0.5, -0.5],
11877
11887
  _a$4[ParticleOrigin$1.PARTICLE_ORIGIN_RIGHT_TOP] = [0.5, 0.5],
11878
11888
  _a$4);
11879
- /**
11880
- * 提取并转换 JSON 数据中的 anchor 值
11881
- */
11882
- function convertAnchor(anchor, particleOrigin) {
11883
- if (anchor) {
11884
- return [anchor[0] - 0.5, 0.5 - anchor[1]];
11885
- }
11886
- else if (particleOrigin) {
11887
- return particleOriginTranslateMap[particleOrigin];
11888
- }
11889
- else {
11890
- return [0, 0];
11891
- }
11892
- }
11893
11889
  function nearestPowerOfTwo(value) {
11894
11890
  return Math.pow(2, Math.round(Math.log(value) / Math.LN2));
11895
11891
  }
@@ -12585,7 +12581,7 @@ function createKeyFrameMeta() {
12585
12581
  }
12586
12582
 
12587
12583
  var tempQuat$1 = new Quaternion();
12588
- var seed$6 = 1;
12584
+ var seed$5 = 1;
12589
12585
  // TODO 继承 Component
12590
12586
  var Transform = /** @class */ (function () {
12591
12587
  function Transform(props, parent) {
@@ -12648,7 +12644,7 @@ var Transform = /** @class */ (function () {
12648
12644
  * 最终模型矩阵对应变换的缓存,当自身矩阵或父矩阵有修改时需要更新
12649
12645
  */
12650
12646
  this.worldTRSCache = { position: new Vector3(0, 0, 0), quat: new Quaternion(0, 0, 0, 1), scale: new Vector3(1, 1, 1) };
12651
- this.name = "transform_".concat(seed$6++);
12647
+ this.name = "transform_".concat(seed$5++);
12652
12648
  if (props) {
12653
12649
  this.setTransform(props);
12654
12650
  }
@@ -12828,13 +12824,11 @@ var Transform = /** @class */ (function () {
12828
12824
  * 设置锚点
12829
12825
  * @param x
12830
12826
  * @param y
12831
- * @param z
12832
12827
  */
12833
- Transform.prototype.setAnchor = function (x, y, z) {
12834
- if (this.anchor.x !== x || this.anchor.y !== y || this.anchor.z !== z) {
12828
+ Transform.prototype.setAnchor = function (x, y) {
12829
+ if (this.anchor.x !== x || this.anchor.y !== y) {
12835
12830
  this.anchor.x = x;
12836
12831
  this.anchor.y = y;
12837
- this.anchor.z = z;
12838
12832
  this.dirtyFlags.localData = true;
12839
12833
  this.dispatchValueChange();
12840
12834
  }
@@ -12845,8 +12839,7 @@ var Transform = /** @class */ (function () {
12845
12839
  * @param reverseEuler - 设置 rotation时,欧拉角是否需要取负值
12846
12840
  */
12847
12841
  Transform.prototype.setTransform = function (props, reverseEuler) {
12848
- var _a;
12849
- var position = props.position, rotation = props.rotation, scale = props.scale, quat = props.quat, name = props.name, anchor = props.anchor;
12842
+ var position = props.position, rotation = props.rotation, scale = props.scale, size = props.size, quat = props.quat, name = props.name, anchor = props.anchor;
12850
12843
  if (name) {
12851
12844
  this.name = name;
12852
12845
  }
@@ -12883,12 +12876,15 @@ var Transform = /** @class */ (function () {
12883
12876
  this.setScale(scale[0], scale[1], scale[2]);
12884
12877
  }
12885
12878
  }
12879
+ if (size) {
12880
+ this.setSize(size.x, size.y);
12881
+ }
12886
12882
  if (anchor) {
12887
- if (anchor instanceof Vector3) {
12888
- this.setAnchor(anchor.x, anchor.y, anchor.z);
12883
+ if (anchor instanceof Vector2) {
12884
+ this.setAnchor(anchor.x, anchor.y);
12889
12885
  }
12890
12886
  else {
12891
- this.setAnchor(anchor[0], anchor[1], (_a = anchor[2]) !== null && _a !== void 0 ? _a : 0);
12887
+ this.setAnchor(anchor[0], anchor[1]);
12892
12888
  }
12893
12889
  }
12894
12890
  };
@@ -13382,7 +13378,7 @@ var HELP_LINK = {
13382
13378
 
13383
13379
  var vertex = "\nprecision highp float;\n\nattribute vec2 aPoint;\nuniform vec4 uPos;\nuniform vec2 uSize;\nuniform vec4 uQuat;\nuniform vec4 uColor;\nuniform mat4 effects_ObjectToWorld;\nuniform mat4 effects_MatrixInvV;\nuniform mat4 effects_MatrixVP;\nvarying vec4 vColor;\n#ifdef ENV_EDITOR\n uniform vec4 uEditorTransform;\n#endif\n\nvec3 rotateByQuat(vec3 a, vec4 quat){\n vec3 qvec = quat.xyz;\n vec3 uv = cross(qvec, a);\n vec3 uuv = cross(qvec, uv) * 2.;\n return a +(uv * 2. * quat.w + uuv);\n}\n\nvoid main() {\n vec4 _pos = uPos;\n vec3 point = rotateByQuat(vec3(aPoint.xy * uSize, 0.),uQuat);\n vec4 pos = vec4(_pos.xyz, 1.0);\n pos = effects_ObjectToWorld * pos;\n pos.xyz += effects_MatrixInvV[0].xyz * point.x+ effects_MatrixInvV[1].xyz * point.y;\n gl_Position = effects_MatrixVP * pos;\n vColor = uColor;\n #ifdef ENV_EDITOR\n gl_Position = vec4(gl_Position.xy * uEditorTransform.xy + uEditorTransform.zw * gl_Position.w, gl_Position.zw);\n #endif\n}\n";
13384
13380
  var fragment = "\nprecision highp float;\n\n#define fragColor gl_FragColor\n\nvarying vec4 vColor;\nvoid main() {\n gl_FragColor = vColor;\n}\n";
13385
- var seed$5 = 1;
13381
+ var seed$4 = 1;
13386
13382
  var InteractMesh = /** @class */ (function () {
13387
13383
  function InteractMesh(props, rendererOptions, transform, engine) {
13388
13384
  this.transform = transform;
@@ -13460,7 +13456,7 @@ var InteractMesh = /** @class */ (function () {
13460
13456
  };
13461
13457
  InteractMesh.prototype.createMesh = function (geometry, material) {
13462
13458
  return Mesh.create(this.engine, {
13463
- name: 'Interact_preview' + seed$5++,
13459
+ name: 'Interact_preview' + seed$4++,
13464
13460
  priority: 0,
13465
13461
  worldMatrix: Matrix4.fromIdentity(),
13466
13462
  geometry: geometry,
@@ -13945,171 +13941,489 @@ var PlayableOutput = /** @class */ (function () {
13945
13941
  * @since 2.0.0
13946
13942
  * @internal
13947
13943
  */
13948
- var TimelineComponent = /** @class */ (function (_super) {
13949
- __extends(TimelineComponent, _super);
13950
- function TimelineComponent(engine) {
13951
- var _this = _super.call(this, engine) || this;
13952
- _this.reusable = false;
13953
- _this.timelineStarted = false;
13954
- _this.playableGraph = new PlayableGraph();
13955
- /**
13956
- * 元素动画已经播放的时间
13957
- */
13958
- _this.time = 0;
13959
- _this.tracks = [];
13960
- _this.trackSeed = 0;
13961
- return _this;
13944
+ var Track = /** @class */ (function () {
13945
+ function Track() {
13946
+ this.clips = [];
13947
+ this.clipSeed = 0;
13962
13948
  }
13963
- TimelineComponent.prototype.start = function () {
13964
- var e_1, _a, e_2, _b;
13949
+ Track.prototype.createOutput = function () {
13950
+ var output = new PlayableOutput();
13951
+ return output;
13952
+ };
13953
+ /**
13954
+ * 重写该方法以创建自定义混合器
13955
+ */
13956
+ Track.prototype.createMixerPlayable = function () {
13957
+ return new Playable();
13958
+ };
13959
+ Track.prototype.createPlayebleTree = function () {
13960
+ var e_1, _a;
13961
+ var defaultMixPlayable = this.createMixerPlayable();
13965
13962
  try {
13966
- // TODO TimelineClip 需要传入 start duration 数据
13967
- for (var _c = __values$1(this.tracks), _d = _c.next(); !_d.done; _d = _c.next()) {
13968
- var track = _d.value;
13969
- try {
13970
- for (var _e = (e_2 = void 0, __values$1(track.getClips())), _f = _e.next(); !_f.done; _f = _e.next()) {
13971
- var clip = _f.value;
13972
- clip.start = this.item.start;
13973
- clip.duration = this.item.duration;
13974
- }
13975
- }
13976
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
13977
- finally {
13978
- try {
13979
- if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
13980
- }
13981
- finally { if (e_2) throw e_2.error; }
13982
- }
13963
+ for (var _b = __values$1(this.clips), _c = _b.next(); !_c.done; _c = _b.next()) {
13964
+ var clip = _c.value;
13965
+ defaultMixPlayable.connect(clip.playable);
13983
13966
  }
13984
13967
  }
13985
13968
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
13986
13969
  finally {
13987
13970
  try {
13988
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
13971
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
13989
13972
  }
13990
13973
  finally { if (e_1) throw e_1.error; }
13991
13974
  }
13992
- this.compileTracks(this.playableGraph);
13975
+ return defaultMixPlayable;
13993
13976
  };
13994
- // TODO: [1.31] @十弦 vfx-item onUpdate 的改动验证
13995
- TimelineComponent.prototype.update = function (dt) {
13996
- var e_3, _a, e_4, _b, e_5, _c, e_6, _d, e_7, _e, e_8, _f, e_9, _g, e_10, _h;
13997
- if (this.item.stopped || !this.item.composition) {
13998
- return;
13999
- }
14000
- if (!this.timelineStarted) {
14001
- try {
14002
- for (var _j = __values$1(this.tracks), _k = _j.next(); !_k.done; _k = _j.next()) {
14003
- var track = _k.value;
14004
- try {
14005
- for (var _l = (e_4 = void 0, __values$1(track.getClips())), _m = _l.next(); !_m.done; _m = _l.next()) {
14006
- var clip = _m.value;
14007
- clip.playable.onGraphStart();
14008
- }
14009
- }
14010
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
14011
- finally {
14012
- try {
14013
- if (_m && !_m.done && (_b = _l.return)) _b.call(_l);
14014
- }
14015
- finally { if (e_4) throw e_4.error; }
14016
- }
14017
- }
14018
- }
14019
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
14020
- finally {
14021
- try {
14022
- if (_k && !_k.done && (_a = _j.return)) _a.call(_j);
13977
+ Track.prototype.createClip = function (classConstructor, name) {
13978
+ var newClip = new TimelineClip();
13979
+ newClip.playable = new classConstructor();
13980
+ newClip.name = name ? name : 'TimelineClip' + newClip.id;
13981
+ this.addClip(newClip);
13982
+ return newClip;
13983
+ };
13984
+ Track.prototype.getClips = function () {
13985
+ return this.clips;
13986
+ };
13987
+ Track.prototype.findClip = function (name) {
13988
+ var e_2, _a;
13989
+ try {
13990
+ for (var _b = __values$1(this.clips), _c = _b.next(); !_c.done; _c = _b.next()) {
13991
+ var clip = _c.value;
13992
+ if (clip.name === name) {
13993
+ return clip;
14023
13994
  }
14024
- finally { if (e_3) throw e_3.error; }
14025
13995
  }
14026
- this.timelineStarted = true;
14027
13996
  }
14028
- var now = this.time;
14029
- // 判断动画是否开始
14030
- if (this.item.delaying && now >= 0 && now <= this.item.duration) {
14031
- this.item.delaying = false;
13997
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
13998
+ finally {
14032
13999
  try {
14033
- for (var _o = __values$1(this.tracks), _p = _o.next(); !_p.done; _p = _o.next()) {
14034
- var track = _p.value;
14035
- try {
14036
- for (var _q = (e_6 = void 0, __values$1(track.getClips())), _r = _q.next(); !_r.done; _r = _q.next()) {
14037
- var clip = _r.value;
14038
- clip.playable.onPlayablePlay();
14039
- }
14040
- }
14041
- catch (e_6_1) { e_6 = { error: e_6_1 }; }
14042
- finally {
14043
- try {
14044
- if (_r && !_r.done && (_d = _q.return)) _d.call(_q);
14045
- }
14046
- finally { if (e_6) throw e_6.error; }
14047
- }
14048
- }
14049
- }
14050
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
14051
- finally {
14052
- try {
14053
- if (_p && !_p.done && (_c = _o.return)) _c.call(_o);
14054
- }
14055
- finally { if (e_5) throw e_5.error; }
14000
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
14056
14001
  }
14002
+ finally { if (e_2) throw e_2.error; }
14057
14003
  }
14058
- // 判断动画是否结束
14059
- var ended;
14060
- if (VFXItem.isParticle(this.item)) {
14061
- ended = this.item.isEnded(now) && this.item.content.destoryed;
14004
+ };
14005
+ Track.prototype.addClip = function (clip) {
14006
+ clip.playable.bindingItem = this.bindingItem;
14007
+ clip.id = (this.clipSeed++).toString();
14008
+ this.clips.push(clip);
14009
+ };
14010
+ return Track;
14011
+ }());
14012
+ /**
14013
+ * @since 2.0.0
14014
+ * @internal
14015
+ */
14016
+ var TimelineClip = /** @class */ (function () {
14017
+ function TimelineClip() {
14018
+ this.start = 0;
14019
+ this.duration = 0;
14020
+ }
14021
+ return TimelineClip;
14022
+ }());
14023
+
14024
+ var AnimationStream = /** @class */ (function () {
14025
+ function AnimationStream(playable) {
14026
+ this.curveValues = {};
14027
+ this.playable = playable;
14028
+ }
14029
+ AnimationStream.prototype.setCurveValue = function (componentType, propertyName, value) {
14030
+ if (!this.findCurveValue(componentType, propertyName)) {
14031
+ this.curveValues[componentType + propertyName] = { componentType: componentType, propertyName: propertyName, value: value };
14062
14032
  }
14063
14033
  else {
14064
- ended = this.item.isEnded(now);
14034
+ this.curveValues[componentType + propertyName].value = value;
14065
14035
  }
14066
- if (ended) {
14067
- var endBehavior = this.item.endBehavior;
14068
- if (!this.item.ended) {
14069
- this.item.ended = true;
14070
- this.item.onEnd();
14071
- if (endBehavior === END_BEHAVIOR_DESTROY$1) {
14072
- try {
14073
- for (var _s = __values$1(this.tracks), _t = _s.next(); !_t.done; _t = _s.next()) {
14074
- var track = _t.value;
14075
- try {
14076
- for (var _u = (e_8 = void 0, __values$1(track.getClips())), _v = _u.next(); !_v.done; _v = _u.next()) {
14077
- var clip = _v.value;
14078
- clip.playable.onPlayableDestroy();
14079
- }
14080
- }
14081
- catch (e_8_1) { e_8 = { error: e_8_1 }; }
14082
- finally {
14083
- try {
14084
- if (_v && !_v.done && (_f = _u.return)) _f.call(_u);
14085
- }
14086
- finally { if (e_8) throw e_8.error; }
14087
- }
14088
- }
14089
- }
14090
- catch (e_7_1) { e_7 = { error: e_7_1 }; }
14091
- finally {
14092
- try {
14093
- if (_t && !_t.done && (_e = _s.return)) _e.call(_s);
14094
- }
14095
- finally { if (e_7) throw e_7.error; }
14096
- }
14097
- this.item.delaying = true;
14098
- if (!this.item.reusable && !this.reusable) {
14099
- this.item.dispose();
14100
- return;
14101
- }
14102
- }
14103
- }
14036
+ return this.curveValues[componentType + propertyName];
14037
+ };
14038
+ AnimationStream.prototype.findCurveValue = function (componentType, propertyName) {
14039
+ return this.curveValues[componentType + propertyName];
14040
+ };
14041
+ AnimationStream.prototype.getInputStream = function (index) {
14042
+ var inputPlayable = this.playable.getInput(index);
14043
+ if (inputPlayable instanceof AnimationPlayable) {
14044
+ return inputPlayable.animationStream;
14104
14045
  }
14105
- // TODO: [1.31] @茂安 验证 https://github.com/galacean/effects-runtime/commits/main/packages/effects-core/src/vfx-item.ts
14106
- // 在生命周期内更新动画
14107
- if (!this.item.delaying) {
14108
- var lifetime = this.time / this.item.duration;
14109
- this.item.lifetime = lifetime;
14110
- try {
14111
- for (var _w = __values$1(this.tracks), _x = _w.next(); !_x.done; _x = _w.next()) {
14112
- var track = _x.value;
14046
+ };
14047
+ return AnimationStream;
14048
+ }());
14049
+
14050
+ var AnimationPlayable = /** @class */ (function (_super) {
14051
+ __extends(AnimationPlayable, _super);
14052
+ function AnimationPlayable() {
14053
+ var _this = _super.call(this) || this;
14054
+ _this.animationStream = new AnimationStream(_this);
14055
+ return _this;
14056
+ }
14057
+ return AnimationPlayable;
14058
+ }(Playable));
14059
+
14060
+ var tempRot$1 = new Euler();
14061
+ var tempSize$1 = new Vector3(1, 1, 1);
14062
+ var tempPos = new Vector3();
14063
+ /**
14064
+ * @since 2.0.0
14065
+ * @internal
14066
+ */
14067
+ var AnimationClipPlayable = /** @class */ (function (_super) {
14068
+ __extends(AnimationClipPlayable, _super);
14069
+ function AnimationClipPlayable() {
14070
+ return _super !== null && _super.apply(this, arguments) || this;
14071
+ }
14072
+ AnimationClipPlayable.prototype.processFrame = function (dt) {
14073
+ if (this.bindingItem.composition) {
14074
+ this.sampleAnimation();
14075
+ }
14076
+ };
14077
+ /**
14078
+ * 应用时间轴K帧数据到对象
14079
+ */
14080
+ AnimationClipPlayable.prototype.sampleAnimation = function () {
14081
+ var _this = this;
14082
+ var duration = this.bindingItem.duration;
14083
+ var life = this.time / duration;
14084
+ life = life < 0 ? 0 : (life > 1 ? 1 : life);
14085
+ if (this.sizeXOverLifetime) {
14086
+ tempSize$1.x = this.sizeXOverLifetime.getValue(life);
14087
+ if (this.sizeSeparateAxes) {
14088
+ tempSize$1.y = this.sizeYOverLifetime.getValue(life);
14089
+ tempSize$1.z = this.sizeZOverLifetime.getValue(life);
14090
+ }
14091
+ else {
14092
+ tempSize$1.z = tempSize$1.y = tempSize$1.x;
14093
+ }
14094
+ var startSize = this.originalTransform.scale;
14095
+ this.bindingItem.transform.setScale(tempSize$1.x * startSize.x, tempSize$1.y * startSize.y, tempSize$1.z * startSize.z);
14096
+ // this.animationStream.setCurveValue('transform', 'scale.x', tempSize.x * startSize.x);
14097
+ // this.animationStream.setCurveValue('transform', 'scale.y', tempSize.y * startSize.y);
14098
+ // this.animationStream.setCurveValue('transform', 'scale.z', tempSize.z * startSize.z);
14099
+ }
14100
+ if (this.rotationOverLifetime) {
14101
+ var func = function (v) { return _this.rotationOverLifetime.asRotation ? v.getValue(life) : v.getIntegrateValue(0, life, duration); };
14102
+ var incZ = func(this.rotationOverLifetime.z);
14103
+ var separateAxes = this.rotationOverLifetime.separateAxes;
14104
+ tempRot$1.x = separateAxes ? func(this.rotationOverLifetime.x) : 0;
14105
+ tempRot$1.y = separateAxes ? func(this.rotationOverLifetime.y) : 0;
14106
+ tempRot$1.z = incZ;
14107
+ var rot = tempRot$1.addEulers(this.originalTransform.rotation, tempRot$1);
14108
+ this.bindingItem.transform.setRotation(rot.x, rot.y, rot.z);
14109
+ // this.animationStream.setCurveValue('transform', 'rotation.x', rot.x);
14110
+ // this.animationStream.setCurveValue('transform', 'rotation.y', rot.y);
14111
+ // this.animationStream.setCurveValue('transform', 'rotation.z', rot.z);
14112
+ }
14113
+ if (this.positionOverLifetime) {
14114
+ var pos = tempPos;
14115
+ calculateTranslation(pos, this, this.gravity, this.time, duration, this.originalTransform.position, this.velocity);
14116
+ if (this.originalTransform.path) {
14117
+ pos.add(this.originalTransform.path.getValue(life));
14118
+ }
14119
+ this.bindingItem.transform.setPosition(pos.x, pos.y, pos.z);
14120
+ // this.animationStream.setCurveValue('transform', 'position.x', pos.x);
14121
+ // this.animationStream.setCurveValue('transform', 'position.y', pos.y);
14122
+ // this.animationStream.setCurveValue('transform', 'position.z', pos.z);
14123
+ }
14124
+ };
14125
+ AnimationClipPlayable.prototype.fromData = function (data) {
14126
+ var _a;
14127
+ var scale = this.bindingItem.transform.scale;
14128
+ this.originalTransform = {
14129
+ position: this.bindingItem.transform.position.clone(),
14130
+ rotation: this.bindingItem.transform.getRotation().clone(),
14131
+ // TODO 编辑器 scale 没有z轴控制
14132
+ scale: new Vector3(scale.x, scale.y, scale.x),
14133
+ };
14134
+ var positionOverLifetime = data.positionOverLifetime;
14135
+ var rotationOverLifetime = data.rotationOverLifetime;
14136
+ var sizeOverLifetime = data.sizeOverLifetime;
14137
+ // TODO: 没有 K 帧数据的不需要传 positionOverLifetime 空对象
14138
+ if (positionOverLifetime && Object.keys(positionOverLifetime).length !== 0) {
14139
+ this.positionOverLifetime = positionOverLifetime;
14140
+ if (positionOverLifetime.path) {
14141
+ this.originalTransform.path = createValueGetter(positionOverLifetime.path);
14142
+ }
14143
+ var linearVelEnable = positionOverLifetime.linearX || positionOverLifetime.linearY || positionOverLifetime.linearZ;
14144
+ if (linearVelEnable) {
14145
+ this.linearVelOverLifetime = {
14146
+ x: positionOverLifetime.linearX && createValueGetter(positionOverLifetime.linearX),
14147
+ y: positionOverLifetime.linearY && createValueGetter(positionOverLifetime.linearY),
14148
+ z: positionOverLifetime.linearZ && createValueGetter(positionOverLifetime.linearZ),
14149
+ asMovement: positionOverLifetime.asMovement,
14150
+ enabled: !!linearVelEnable,
14151
+ };
14152
+ }
14153
+ var orbitalVelEnable = positionOverLifetime.orbitalX || positionOverLifetime.orbitalY || positionOverLifetime.orbitalZ;
14154
+ if (orbitalVelEnable) {
14155
+ this.orbitalVelOverLifetime = {
14156
+ x: positionOverLifetime.orbitalX && createValueGetter(positionOverLifetime.orbitalX),
14157
+ y: positionOverLifetime.orbitalY && createValueGetter(positionOverLifetime.orbitalY),
14158
+ z: positionOverLifetime.orbitalZ && createValueGetter(positionOverLifetime.orbitalZ),
14159
+ center: ensureVec3(positionOverLifetime.orbCenter),
14160
+ asRotation: positionOverLifetime.asRotation,
14161
+ enabled: !!orbitalVelEnable,
14162
+ };
14163
+ }
14164
+ this.speedOverLifetime = positionOverLifetime.speedOverLifetime && createValueGetter(positionOverLifetime.speedOverLifetime);
14165
+ }
14166
+ if (sizeOverLifetime) {
14167
+ if (sizeOverLifetime.separateAxes) {
14168
+ this.sizeSeparateAxes = true;
14169
+ this.sizeXOverLifetime = createValueGetter(sizeOverLifetime.x || 1);
14170
+ this.sizeYOverLifetime = createValueGetter(sizeOverLifetime.y || 1);
14171
+ this.sizeZOverLifetime = createValueGetter(sizeOverLifetime.z || 1);
14172
+ }
14173
+ else {
14174
+ this.sizeXOverLifetime = createValueGetter(sizeOverLifetime.size || 1);
14175
+ }
14176
+ }
14177
+ if (rotationOverLifetime) {
14178
+ this.rotationOverLifetime = {
14179
+ asRotation: rotationOverLifetime.asRotation,
14180
+ separateAxes: rotationOverLifetime.separateAxes,
14181
+ z: createValueGetter(rotationOverLifetime.z || 0),
14182
+ };
14183
+ if (rotationOverLifetime.separateAxes) {
14184
+ var rotLt = this.rotationOverLifetime;
14185
+ rotLt.x = createValueGetter(rotationOverLifetime.x || 0);
14186
+ rotLt.y = createValueGetter(rotationOverLifetime.y || 0);
14187
+ }
14188
+ }
14189
+ this.gravity = Vector3.fromArray((positionOverLifetime === null || positionOverLifetime === void 0 ? void 0 : positionOverLifetime.gravity) || []);
14190
+ this.gravityModifier = createValueGetter((_a = positionOverLifetime === null || positionOverLifetime === void 0 ? void 0 : positionOverLifetime.gravityOverLifetime) !== null && _a !== void 0 ? _a : 0);
14191
+ this.direction = (positionOverLifetime === null || positionOverLifetime === void 0 ? void 0 : positionOverLifetime.direction) ? Vector3.fromArray(positionOverLifetime.direction).normalize() : new Vector3();
14192
+ this.startSpeed = (positionOverLifetime === null || positionOverLifetime === void 0 ? void 0 : positionOverLifetime.startSpeed) || 0;
14193
+ this.velocity = this.direction.clone();
14194
+ this.velocity.multiply(this.startSpeed);
14195
+ };
14196
+ return AnimationClipPlayable;
14197
+ }(AnimationPlayable));
14198
+ /**
14199
+ * @since 2.0.0
14200
+ * @internal
14201
+ */
14202
+ var ActivationClipPlayable = /** @class */ (function (_super) {
14203
+ __extends(ActivationClipPlayable, _super);
14204
+ function ActivationClipPlayable() {
14205
+ return _super !== null && _super.apply(this, arguments) || this;
14206
+ }
14207
+ ActivationClipPlayable.prototype.onGraphStart = function () {
14208
+ this.bindingItem.transform.setValid(false);
14209
+ this.hideRendererComponents();
14210
+ };
14211
+ ActivationClipPlayable.prototype.onPlayablePlay = function () {
14212
+ this.bindingItem.transform.setValid(true);
14213
+ this.showRendererComponents();
14214
+ };
14215
+ ActivationClipPlayable.prototype.onPlayableDestroy = function () {
14216
+ this.bindingItem.transform.setValid(false);
14217
+ this.hideRendererComponents();
14218
+ };
14219
+ ActivationClipPlayable.prototype.hideRendererComponents = function () {
14220
+ var e_1, _a;
14221
+ try {
14222
+ for (var _b = __values$1(this.bindingItem.rendererComponents), _c = _b.next(); !_c.done; _c = _b.next()) {
14223
+ var rendererComponent = _c.value;
14224
+ if (rendererComponent.enabled) {
14225
+ rendererComponent.enabled = false;
14226
+ }
14227
+ }
14228
+ }
14229
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
14230
+ finally {
14231
+ try {
14232
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
14233
+ }
14234
+ finally { if (e_1) throw e_1.error; }
14235
+ }
14236
+ };
14237
+ ActivationClipPlayable.prototype.showRendererComponents = function () {
14238
+ var e_2, _a;
14239
+ try {
14240
+ for (var _b = __values$1(this.bindingItem.rendererComponents), _c = _b.next(); !_c.done; _c = _b.next()) {
14241
+ var rendererComponent = _c.value;
14242
+ if (!rendererComponent.enabled) {
14243
+ rendererComponent.enabled = true;
14244
+ }
14245
+ }
14246
+ }
14247
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
14248
+ finally {
14249
+ try {
14250
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
14251
+ }
14252
+ finally { if (e_2) throw e_2.error; }
14253
+ }
14254
+ };
14255
+ return ActivationClipPlayable;
14256
+ }(Playable));
14257
+
14258
+ /**
14259
+ * @since 2.0.0
14260
+ * @internal
14261
+ */
14262
+ var TimelineComponent = /** @class */ (function (_super) {
14263
+ __extends(TimelineComponent, _super);
14264
+ function TimelineComponent(engine) {
14265
+ var _this = _super.call(this, engine) || this;
14266
+ _this.reusable = false;
14267
+ _this.timelineStarted = false;
14268
+ _this.playableGraph = new PlayableGraph();
14269
+ /**
14270
+ * 元素动画已经播放的时间
14271
+ */
14272
+ _this.time = 0;
14273
+ _this.tracks = [];
14274
+ _this.trackSeed = 0;
14275
+ return _this;
14276
+ }
14277
+ TimelineComponent.prototype.start = function () {
14278
+ var e_1, _a, e_2, _b;
14279
+ try {
14280
+ // TODO TimelineClip 需要传入 start 和 duration 数据
14281
+ for (var _c = __values$1(this.tracks), _d = _c.next(); !_d.done; _d = _c.next()) {
14282
+ var track = _d.value;
14283
+ try {
14284
+ for (var _e = (e_2 = void 0, __values$1(track.getClips())), _f = _e.next(); !_f.done; _f = _e.next()) {
14285
+ var clip = _f.value;
14286
+ clip.start = this.item.start;
14287
+ clip.duration = this.item.duration;
14288
+ }
14289
+ }
14290
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
14291
+ finally {
14292
+ try {
14293
+ if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
14294
+ }
14295
+ finally { if (e_2) throw e_2.error; }
14296
+ }
14297
+ }
14298
+ }
14299
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
14300
+ finally {
14301
+ try {
14302
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
14303
+ }
14304
+ finally { if (e_1) throw e_1.error; }
14305
+ }
14306
+ this.compileTracks(this.playableGraph);
14307
+ };
14308
+ // TODO: [1.31] @十弦 vfx-item 下 onUpdate 的改动验证
14309
+ TimelineComponent.prototype.update = function (dt) {
14310
+ var e_3, _a, e_4, _b, e_5, _c, e_6, _d, e_7, _e, e_8, _f, e_9, _g, e_10, _h;
14311
+ if (this.item.stopped || !this.item.composition) {
14312
+ return;
14313
+ }
14314
+ if (!this.timelineStarted) {
14315
+ try {
14316
+ for (var _j = __values$1(this.tracks), _k = _j.next(); !_k.done; _k = _j.next()) {
14317
+ var track = _k.value;
14318
+ try {
14319
+ for (var _l = (e_4 = void 0, __values$1(track.getClips())), _m = _l.next(); !_m.done; _m = _l.next()) {
14320
+ var clip = _m.value;
14321
+ clip.playable.onGraphStart();
14322
+ }
14323
+ }
14324
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
14325
+ finally {
14326
+ try {
14327
+ if (_m && !_m.done && (_b = _l.return)) _b.call(_l);
14328
+ }
14329
+ finally { if (e_4) throw e_4.error; }
14330
+ }
14331
+ }
14332
+ }
14333
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
14334
+ finally {
14335
+ try {
14336
+ if (_k && !_k.done && (_a = _j.return)) _a.call(_j);
14337
+ }
14338
+ finally { if (e_3) throw e_3.error; }
14339
+ }
14340
+ this.timelineStarted = true;
14341
+ }
14342
+ var now = this.time;
14343
+ // 判断动画是否开始
14344
+ if (this.item.delaying && now >= 0 && now <= this.item.duration) {
14345
+ this.item.delaying = false;
14346
+ try {
14347
+ for (var _o = __values$1(this.tracks), _p = _o.next(); !_p.done; _p = _o.next()) {
14348
+ var track = _p.value;
14349
+ try {
14350
+ for (var _q = (e_6 = void 0, __values$1(track.getClips())), _r = _q.next(); !_r.done; _r = _q.next()) {
14351
+ var clip = _r.value;
14352
+ clip.playable.onPlayablePlay();
14353
+ }
14354
+ }
14355
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
14356
+ finally {
14357
+ try {
14358
+ if (_r && !_r.done && (_d = _q.return)) _d.call(_q);
14359
+ }
14360
+ finally { if (e_6) throw e_6.error; }
14361
+ }
14362
+ }
14363
+ }
14364
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
14365
+ finally {
14366
+ try {
14367
+ if (_p && !_p.done && (_c = _o.return)) _c.call(_o);
14368
+ }
14369
+ finally { if (e_5) throw e_5.error; }
14370
+ }
14371
+ }
14372
+ // 判断动画是否结束
14373
+ var ended;
14374
+ if (VFXItem.isParticle(this.item)) {
14375
+ ended = this.item.isEnded(now) && this.item.content.destoryed;
14376
+ }
14377
+ else {
14378
+ ended = this.item.isEnded(now);
14379
+ }
14380
+ if (ended) {
14381
+ var endBehavior = this.item.endBehavior;
14382
+ if (!this.item.ended) {
14383
+ this.item.ended = true;
14384
+ this.item.onEnd();
14385
+ if (endBehavior === END_BEHAVIOR_DESTROY$1) {
14386
+ try {
14387
+ for (var _s = __values$1(this.tracks), _t = _s.next(); !_t.done; _t = _s.next()) {
14388
+ var track = _t.value;
14389
+ try {
14390
+ for (var _u = (e_8 = void 0, __values$1(track.getClips())), _v = _u.next(); !_v.done; _v = _u.next()) {
14391
+ var clip = _v.value;
14392
+ clip.playable.onPlayableDestroy();
14393
+ }
14394
+ }
14395
+ catch (e_8_1) { e_8 = { error: e_8_1 }; }
14396
+ finally {
14397
+ try {
14398
+ if (_v && !_v.done && (_f = _u.return)) _f.call(_u);
14399
+ }
14400
+ finally { if (e_8) throw e_8.error; }
14401
+ }
14402
+ }
14403
+ }
14404
+ catch (e_7_1) { e_7 = { error: e_7_1 }; }
14405
+ finally {
14406
+ try {
14407
+ if (_t && !_t.done && (_e = _s.return)) _e.call(_s);
14408
+ }
14409
+ finally { if (e_7) throw e_7.error; }
14410
+ }
14411
+ this.item.delaying = true;
14412
+ if (!this.item.reusable && !this.reusable) {
14413
+ this.item.dispose();
14414
+ return;
14415
+ }
14416
+ }
14417
+ }
14418
+ }
14419
+ // TODO: [1.31] @茂安 验证 https://github.com/galacean/effects-runtime/commits/main/packages/effects-core/src/vfx-item.ts
14420
+ // 在生命周期内更新动画
14421
+ if (!this.item.delaying) {
14422
+ var lifetime = this.time / this.item.duration;
14423
+ this.item.lifetime = lifetime;
14424
+ try {
14425
+ for (var _w = __values$1(this.tracks), _x = _w.next(); !_x.done; _x = _w.next()) {
14426
+ var track = _x.value;
14113
14427
  try {
14114
14428
  for (var _y = (e_10 = void 0, __values$1(track.getClips())), _z = _y.next(); !_z.done; _z = _y.next()) {
14115
14429
  var clip = _z.value;
@@ -14185,135 +14499,53 @@ var TimelineComponent = /** @class */ (function (_super) {
14185
14499
  }
14186
14500
  };
14187
14501
  TimelineComponent.prototype.rebuildGraph = function () {
14188
- this.playableGraph = new PlayableGraph();
14189
- this.compileTracks(this.playableGraph);
14190
- };
14191
- TimelineComponent.prototype.compileTracks = function (graph) {
14192
- var e_12, _a;
14193
- try {
14194
- for (var _b = __values$1(this.tracks), _c = _b.next(); !_c.done; _c = _b.next()) {
14195
- var track = _c.value;
14196
- var trackMixPlayable = track.createPlayebleTree();
14197
- var trackOutput = track.createOutput();
14198
- graph.addOutput(trackOutput);
14199
- trackOutput.setSourcePlayeble(trackMixPlayable);
14200
- }
14201
- }
14202
- catch (e_12_1) { e_12 = { error: e_12_1 }; }
14203
- finally {
14204
- try {
14205
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
14206
- }
14207
- finally { if (e_12) throw e_12.error; }
14208
- }
14209
- };
14210
- TimelineComponent.prototype.fromData = function (data) {
14211
- _super.prototype.fromData.call(this, data);
14212
- this.options = {
14213
- start: this.item.start,
14214
- duration: this.item.duration,
14215
- looping: this.item.endBehavior === END_BEHAVIOR_RESTART$1,
14216
- endBehavior: this.item.endBehavior || END_BEHAVIOR_DESTROY$1,
14217
- };
14218
- this.id = this.item.id;
14219
- this.name = this.item.name;
14220
- };
14221
- TimelineComponent.prototype.toData = function () {
14222
- _super.prototype.toData.call(this);
14223
- };
14224
- __decorate([
14225
- serialize()
14226
- ], TimelineComponent.prototype, "time", void 0);
14227
- return TimelineComponent;
14228
- }(ItemBehaviour));
14229
-
14230
- /**
14231
- * @since 2.0.0
14232
- * @internal
14233
- */
14234
- var Track = /** @class */ (function () {
14235
- function Track() {
14236
- this.clips = [];
14237
- this.clipSeed = 0;
14238
- }
14239
- Track.prototype.createOutput = function () {
14240
- var output = new PlayableOutput();
14241
- return output;
14242
- };
14243
- /**
14244
- * 重写该方法以创建自定义混合器
14245
- */
14246
- Track.prototype.createMixerPlayable = function () {
14247
- return new Playable();
14248
- };
14249
- Track.prototype.createPlayebleTree = function () {
14250
- var e_1, _a;
14251
- var defaultMixPlayable = this.createMixerPlayable();
14252
- try {
14253
- for (var _b = __values$1(this.clips), _c = _b.next(); !_c.done; _c = _b.next()) {
14254
- var clip = _c.value;
14255
- defaultMixPlayable.connect(clip.playable);
14256
- }
14257
- }
14258
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
14259
- finally {
14260
- try {
14261
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
14262
- }
14263
- finally { if (e_1) throw e_1.error; }
14264
- }
14265
- return defaultMixPlayable;
14266
- };
14267
- Track.prototype.createClip = function (classConstructor, name) {
14268
- var newClip = new TimelineClip();
14269
- newClip.playable = new classConstructor();
14270
- newClip.name = name ? name : 'TimelineClip' + newClip.id;
14271
- this.addClip(newClip);
14272
- return newClip;
14273
- };
14274
- Track.prototype.getClips = function () {
14275
- return this.clips;
14502
+ this.playableGraph = new PlayableGraph();
14503
+ this.compileTracks(this.playableGraph);
14276
14504
  };
14277
- Track.prototype.findClip = function (name) {
14278
- var e_2, _a;
14505
+ TimelineComponent.prototype.compileTracks = function (graph) {
14506
+ var e_12, _a;
14279
14507
  try {
14280
- for (var _b = __values$1(this.clips), _c = _b.next(); !_c.done; _c = _b.next()) {
14281
- var clip = _c.value;
14282
- if (clip.name === name) {
14283
- return clip;
14284
- }
14508
+ for (var _b = __values$1(this.tracks), _c = _b.next(); !_c.done; _c = _b.next()) {
14509
+ var track = _c.value;
14510
+ var trackMixPlayable = track.createPlayebleTree();
14511
+ var trackOutput = track.createOutput();
14512
+ graph.addOutput(trackOutput);
14513
+ trackOutput.setSourcePlayeble(trackMixPlayable);
14285
14514
  }
14286
14515
  }
14287
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
14516
+ catch (e_12_1) { e_12 = { error: e_12_1 }; }
14288
14517
  finally {
14289
14518
  try {
14290
14519
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
14291
14520
  }
14292
- finally { if (e_2) throw e_2.error; }
14521
+ finally { if (e_12) throw e_12.error; }
14293
14522
  }
14294
14523
  };
14295
- Track.prototype.addClip = function (clip) {
14296
- clip.playable.bindingItem = this.bindingItem;
14297
- clip.id = (this.clipSeed++).toString();
14298
- this.clips.push(clip);
14524
+ TimelineComponent.prototype.fromData = function (data) {
14525
+ _super.prototype.fromData.call(this, data);
14526
+ this.options = {
14527
+ start: this.item.start,
14528
+ duration: this.item.duration,
14529
+ looping: this.item.endBehavior === END_BEHAVIOR_RESTART$1,
14530
+ endBehavior: this.item.endBehavior || END_BEHAVIOR_DESTROY$1,
14531
+ };
14532
+ this.id = this.item.id;
14533
+ this.name = this.item.name;
14534
+ var activationTrack = this.createTrack(Track, 'ActivationTrack');
14535
+ activationTrack.createClip(ActivationClipPlayable, 'ActivationTimelineClip');
14299
14536
  };
14300
- return Track;
14301
- }());
14302
- /**
14303
- * @since 2.0.0
14304
- * @internal
14305
- */
14306
- var TimelineClip = /** @class */ (function () {
14307
- function TimelineClip() {
14308
- this.start = 0;
14309
- this.duration = 0;
14310
- }
14311
- return TimelineClip;
14312
- }());
14537
+ TimelineComponent.prototype.toData = function () {
14538
+ _super.prototype.toData.call(this);
14539
+ };
14540
+ __decorate([
14541
+ serialize()
14542
+ ], TimelineComponent.prototype, "time", void 0);
14543
+ return TimelineComponent;
14544
+ }(ItemBehaviour));
14313
14545
 
14314
14546
  var singleSplits = [[0, 0, 1, 1, undefined]];
14315
14547
  var tempColor = [1, 1, 1, 1];
14316
- var seed$4 = 0;
14548
+ var seed$3 = 0;
14317
14549
  var SpriteColorPlayable = /** @class */ (function (_super) {
14318
14550
  __extends(SpriteColorPlayable, _super);
14319
14551
  function SpriteColorPlayable() {
@@ -14709,7 +14941,7 @@ var SpriteComponent = /** @class */ (function (_super) {
14709
14941
  this.worldMatrix = Matrix4.fromIdentity();
14710
14942
  this.material = material;
14711
14943
  this.geometry = geometry;
14712
- this.name = 'MSprite' + seed$4++;
14944
+ this.name = 'MSprite' + seed$3++;
14713
14945
  var startColor = options.startColor || [1, 1, 1, 1];
14714
14946
  this.material.setVector4('_Color', new Vector4().setFromArray(startColor));
14715
14947
  this.material.setVector4('_TexOffset', new Vector4().setFromArray([0, 0, 1, 1]));
@@ -17714,7 +17946,7 @@ var ParticleSystem = /** @class */ (function (_super) {
17714
17946
  sprite[1] = tsa.animationDuration.getValue(lifetime);
17715
17947
  sprite[2] = tsa.cycles.getValue(lifetime);
17716
17948
  }
17717
- var rot = tempRot$1;
17949
+ var rot = tempRot;
17718
17950
  if (options.start3DRotation) {
17719
17951
  // @ts-expect-error
17720
17952
  rot.set(options.startRotationX.getValue(lifetime), options.startRotationY.getValue(lifetime), options.startRotationZ.getValue(lifetime));
@@ -17730,7 +17962,7 @@ var ParticleSystem = /** @class */ (function (_super) {
17730
17962
  if (color.length === 3) {
17731
17963
  color[3] = 1;
17732
17964
  }
17733
- var size = tempSize$1;
17965
+ var size = tempSize;
17734
17966
  if (options.start3DSize) {
17735
17967
  size.x = options.startSizeX.getValue(lifetime);
17736
17968
  size.y = options.startSizeY.getValue(lifetime);
@@ -17892,7 +18124,8 @@ var ParticleSystem = /** @class */ (function (_super) {
17892
18124
  separateAxes: false,
17893
18125
  x: createValueGetter(('size' in sizeOverLifetime ? sizeOverLifetime.size : sizeOverLifetime.x) || 1),
17894
18126
  };
17895
- var anchor = Vector2.fromArray(convertAnchor(renderer.anchor, renderer.particleOrigin));
18127
+ renderer.anchor = renderer.anchor || [0, 0];
18128
+ var anchor = Vector2.fromArray(renderer.anchor);
17896
18129
  this.options = {
17897
18130
  particleFollowParent: !!options.particleFollowParent,
17898
18131
  startLifetime: createValueGetter(options.startLifetime),
@@ -18073,8 +18306,8 @@ var ParticleSystem = /** @class */ (function (_super) {
18073
18306
  }(Component));
18074
18307
  // array performance better for small memory than Float32Array
18075
18308
  var tempDir = new Vector3();
18076
- var tempSize$1 = new Vector2();
18077
- var tempRot$1 = new Euler();
18309
+ var tempSize = new Vector2();
18310
+ var tempRot = new Euler();
18078
18311
  var tmpDirX = new Vector3();
18079
18312
  var tmpDirY = new Vector3();
18080
18313
  var tempVec3 = new Vector3();
@@ -18089,299 +18322,65 @@ function getBurstOffsets(burstOffsets) {
18089
18322
  var index = isArr ? arr[0] : arr.index;
18090
18323
  var offsets = ret[index];
18091
18324
  if (!offsets) {
18092
- offsets = ret[index] = [];
18093
- }
18094
- if (isArr) {
18095
- offsets.push(arr.slice(1, 4));
18096
- }
18097
- else {
18098
- offsets.push([+arr.x, +arr.y, +arr.z]);
18099
- }
18100
- });
18101
- }
18102
- return ret;
18103
- }
18104
- function randomArrItem(arr, keepArr) {
18105
- var index = Math.floor(Math.random() * arr.length);
18106
- var item = arr[index];
18107
- if (!keepArr) {
18108
- arr.splice(index, 1);
18109
- }
18110
- return item;
18111
- }
18112
-
18113
- /**
18114
- * @since 2.0.0
18115
- * @internal
18116
- */
18117
- var ParticleBehaviourPlayable = /** @class */ (function (_super) {
18118
- __extends(ParticleBehaviourPlayable, _super);
18119
- function ParticleBehaviourPlayable() {
18120
- return _super !== null && _super.apply(this, arguments) || this;
18121
- }
18122
- ParticleBehaviourPlayable.prototype.onPlayablePlay = function () {
18123
- this.particleSystem = this.bindingItem.getComponent(ParticleSystem);
18124
- if (this.particleSystem) {
18125
- this.particleSystem.name = this.bindingItem.name;
18126
- this.particleSystem.start();
18127
- this.particleSystem.initEmitterTransform();
18128
- }
18129
- };
18130
- ParticleBehaviourPlayable.prototype.processFrame = function (dt) {
18131
- var particleSystem = this.particleSystem;
18132
- if (particleSystem) {
18133
- this.bindingItem.parent;
18134
- // TODO: [1.31] @十弦 验证 https://github.com/galacean/effects-runtime/commit/3e7d73d37b7d98c2a25e4544e80e928b17801ccd#diff-fae062f28caf3771cfedd3a20dc22f9749bd054c7541bf2fd50a9a5e413153d4
18135
- // particleSystem.setParentTransform(parentItem.transform);
18136
- particleSystem.setVisible(true);
18137
- particleSystem.onUpdate(dt);
18138
- }
18139
- };
18140
- return ParticleBehaviourPlayable;
18141
- }(Playable));
18142
-
18143
- var CalculateLoader = /** @class */ (function (_super) {
18144
- __extends(CalculateLoader, _super);
18145
- function CalculateLoader() {
18146
- return _super !== null && _super.apply(this, arguments) || this;
18147
- }
18148
- return CalculateLoader;
18149
- }(AbstractPlugin));
18150
-
18151
- var AnimationStream = /** @class */ (function () {
18152
- function AnimationStream(playable) {
18153
- this.curveValues = {};
18154
- this.playable = playable;
18155
- }
18156
- AnimationStream.prototype.setCurveValue = function (componentType, propertyName, value) {
18157
- if (!this.findCurveValue(componentType, propertyName)) {
18158
- this.curveValues[componentType + propertyName] = { componentType: componentType, propertyName: propertyName, value: value };
18159
- }
18160
- else {
18161
- this.curveValues[componentType + propertyName].value = value;
18162
- }
18163
- return this.curveValues[componentType + propertyName];
18164
- };
18165
- AnimationStream.prototype.findCurveValue = function (componentType, propertyName) {
18166
- return this.curveValues[componentType + propertyName];
18167
- };
18168
- AnimationStream.prototype.getInputStream = function (index) {
18169
- var inputPlayable = this.playable.getInput(index);
18170
- if (inputPlayable instanceof AnimationPlayable) {
18171
- return inputPlayable.animationStream;
18172
- }
18173
- };
18174
- return AnimationStream;
18175
- }());
18176
-
18177
- var AnimationPlayable = /** @class */ (function (_super) {
18178
- __extends(AnimationPlayable, _super);
18179
- function AnimationPlayable() {
18180
- var _this = _super.call(this) || this;
18181
- _this.animationStream = new AnimationStream(_this);
18182
- return _this;
18183
- }
18184
- return AnimationPlayable;
18185
- }(Playable));
18186
-
18187
- var tempRot = new Euler();
18188
- var tempSize = new Vector3(1, 1, 1);
18189
- var tempPos = new Vector3();
18190
- /**
18191
- * @since 2.0.0
18192
- * @internal
18193
- */
18194
- var AnimationClipPlayable = /** @class */ (function (_super) {
18195
- __extends(AnimationClipPlayable, _super);
18196
- function AnimationClipPlayable() {
18197
- return _super !== null && _super.apply(this, arguments) || this;
18198
- }
18199
- AnimationClipPlayable.prototype.processFrame = function (dt) {
18200
- if (this.bindingItem.composition) {
18201
- this.sampleAnimation();
18202
- }
18203
- };
18204
- /**
18205
- * 应用时间轴K帧数据到对象
18206
- */
18207
- AnimationClipPlayable.prototype.sampleAnimation = function () {
18208
- var _this = this;
18209
- var duration = this.bindingItem.duration;
18210
- var life = this.time / duration;
18211
- life = life < 0 ? 0 : (life > 1 ? 1 : life);
18212
- if (this.sizeXOverLifetime) {
18213
- tempSize.x = this.sizeXOverLifetime.getValue(life);
18214
- if (this.sizeSeparateAxes) {
18215
- tempSize.y = this.sizeYOverLifetime.getValue(life);
18216
- tempSize.z = this.sizeZOverLifetime.getValue(life);
18217
- }
18218
- else {
18219
- tempSize.z = tempSize.y = tempSize.x;
18220
- }
18221
- var startSize = this.originalTransform.scale;
18222
- this.bindingItem.transform.setScale(tempSize.x * startSize.x, tempSize.y * startSize.y, tempSize.z * startSize.z);
18223
- // this.animationStream.setCurveValue('transform', 'scale.x', tempSize.x * startSize.x);
18224
- // this.animationStream.setCurveValue('transform', 'scale.y', tempSize.y * startSize.y);
18225
- // this.animationStream.setCurveValue('transform', 'scale.z', tempSize.z * startSize.z);
18226
- }
18227
- if (this.rotationOverLifetime) {
18228
- var func = function (v) { return _this.rotationOverLifetime.asRotation ? v.getValue(life) : v.getIntegrateValue(0, life, duration); };
18229
- var incZ = func(this.rotationOverLifetime.z);
18230
- var separateAxes = this.rotationOverLifetime.separateAxes;
18231
- tempRot.x = separateAxes ? func(this.rotationOverLifetime.x) : 0;
18232
- tempRot.y = separateAxes ? func(this.rotationOverLifetime.y) : 0;
18233
- tempRot.z = incZ;
18234
- var rot = tempRot.addEulers(this.originalTransform.rotation, tempRot);
18235
- this.bindingItem.transform.setRotation(rot.x, rot.y, rot.z);
18236
- // this.animationStream.setCurveValue('transform', 'rotation.x', rot.x);
18237
- // this.animationStream.setCurveValue('transform', 'rotation.y', rot.y);
18238
- // this.animationStream.setCurveValue('transform', 'rotation.z', rot.z);
18239
- }
18240
- if (this.positionOverLifetime) {
18241
- var pos = tempPos;
18242
- calculateTranslation(pos, this, this.gravity, this.time, duration, this.originalTransform.position, this.velocity);
18243
- if (this.originalTransform.path) {
18244
- pos.add(this.originalTransform.path.getValue(life));
18245
- }
18246
- this.bindingItem.transform.setPosition(pos.x, pos.y, pos.z);
18247
- // this.animationStream.setCurveValue('transform', 'position.x', pos.x);
18248
- // this.animationStream.setCurveValue('transform', 'position.y', pos.y);
18249
- // this.animationStream.setCurveValue('transform', 'position.z', pos.z);
18250
- }
18251
- };
18252
- AnimationClipPlayable.prototype.fromData = function (data) {
18253
- var _a;
18254
- var scale = this.bindingItem.transform.scale;
18255
- this.originalTransform = {
18256
- position: this.bindingItem.transform.position.clone(),
18257
- rotation: this.bindingItem.transform.getRotation().clone(),
18258
- // TODO 编辑器 scale 没有z轴控制
18259
- scale: new Vector3(scale.x, scale.y, scale.x),
18260
- };
18261
- var positionOverLifetime = data.positionOverLifetime;
18262
- var rotationOverLifetime = data.rotationOverLifetime;
18263
- var sizeOverLifetime = data.sizeOverLifetime;
18264
- // TODO: 没有 K 帧数据的不需要传 positionOverLifetime 空对象
18265
- if (positionOverLifetime && Object.keys(positionOverLifetime).length !== 0) {
18266
- this.positionOverLifetime = positionOverLifetime;
18267
- if (positionOverLifetime.path) {
18268
- this.originalTransform.path = createValueGetter(positionOverLifetime.path);
18269
- }
18270
- var linearVelEnable = positionOverLifetime.linearX || positionOverLifetime.linearY || positionOverLifetime.linearZ;
18271
- if (linearVelEnable) {
18272
- this.linearVelOverLifetime = {
18273
- x: positionOverLifetime.linearX && createValueGetter(positionOverLifetime.linearX),
18274
- y: positionOverLifetime.linearY && createValueGetter(positionOverLifetime.linearY),
18275
- z: positionOverLifetime.linearZ && createValueGetter(positionOverLifetime.linearZ),
18276
- asMovement: positionOverLifetime.asMovement,
18277
- enabled: !!linearVelEnable,
18278
- };
18279
- }
18280
- var orbitalVelEnable = positionOverLifetime.orbitalX || positionOverLifetime.orbitalY || positionOverLifetime.orbitalZ;
18281
- if (orbitalVelEnable) {
18282
- this.orbitalVelOverLifetime = {
18283
- x: positionOverLifetime.orbitalX && createValueGetter(positionOverLifetime.orbitalX),
18284
- y: positionOverLifetime.orbitalY && createValueGetter(positionOverLifetime.orbitalY),
18285
- z: positionOverLifetime.orbitalZ && createValueGetter(positionOverLifetime.orbitalZ),
18286
- center: ensureVec3(positionOverLifetime.orbCenter),
18287
- asRotation: positionOverLifetime.asRotation,
18288
- enabled: !!orbitalVelEnable,
18289
- };
18290
- }
18291
- this.speedOverLifetime = positionOverLifetime.speedOverLifetime && createValueGetter(positionOverLifetime.speedOverLifetime);
18292
- }
18293
- if (sizeOverLifetime) {
18294
- if (sizeOverLifetime.separateAxes) {
18295
- this.sizeSeparateAxes = true;
18296
- this.sizeXOverLifetime = createValueGetter(sizeOverLifetime.x || 1);
18297
- this.sizeYOverLifetime = createValueGetter(sizeOverLifetime.y || 1);
18298
- this.sizeZOverLifetime = createValueGetter(sizeOverLifetime.z || 1);
18325
+ offsets = ret[index] = [];
18299
18326
  }
18300
- else {
18301
- this.sizeXOverLifetime = createValueGetter(sizeOverLifetime.size || 1);
18327
+ if (isArr) {
18328
+ offsets.push(arr.slice(1, 4));
18302
18329
  }
18303
- }
18304
- if (rotationOverLifetime) {
18305
- this.rotationOverLifetime = {
18306
- asRotation: rotationOverLifetime.asRotation,
18307
- separateAxes: rotationOverLifetime.separateAxes,
18308
- z: createValueGetter(rotationOverLifetime.z || 0),
18309
- };
18310
- if (rotationOverLifetime.separateAxes) {
18311
- var rotLt = this.rotationOverLifetime;
18312
- rotLt.x = createValueGetter(rotationOverLifetime.x || 0);
18313
- rotLt.y = createValueGetter(rotationOverLifetime.y || 0);
18330
+ else {
18331
+ offsets.push([+arr.x, +arr.y, +arr.z]);
18314
18332
  }
18315
- }
18316
- this.gravity = Vector3.fromArray((positionOverLifetime === null || positionOverLifetime === void 0 ? void 0 : positionOverLifetime.gravity) || []);
18317
- this.gravityModifier = createValueGetter((_a = positionOverLifetime === null || positionOverLifetime === void 0 ? void 0 : positionOverLifetime.gravityOverLifetime) !== null && _a !== void 0 ? _a : 0);
18318
- this.direction = (positionOverLifetime === null || positionOverLifetime === void 0 ? void 0 : positionOverLifetime.direction) ? Vector3.fromArray(positionOverLifetime.direction).normalize() : new Vector3();
18319
- this.startSpeed = (positionOverLifetime === null || positionOverLifetime === void 0 ? void 0 : positionOverLifetime.startSpeed) || 0;
18320
- this.velocity = this.direction.clone();
18321
- this.velocity.multiply(this.startSpeed);
18322
- };
18323
- return AnimationClipPlayable;
18324
- }(AnimationPlayable));
18333
+ });
18334
+ }
18335
+ return ret;
18336
+ }
18337
+ function randomArrItem(arr, keepArr) {
18338
+ var index = Math.floor(Math.random() * arr.length);
18339
+ var item = arr[index];
18340
+ if (!keepArr) {
18341
+ arr.splice(index, 1);
18342
+ }
18343
+ return item;
18344
+ }
18345
+
18325
18346
  /**
18326
18347
  * @since 2.0.0
18327
18348
  * @internal
18328
18349
  */
18329
- var ActivationClipPlayable = /** @class */ (function (_super) {
18330
- __extends(ActivationClipPlayable, _super);
18331
- function ActivationClipPlayable() {
18350
+ var ParticleBehaviourPlayable = /** @class */ (function (_super) {
18351
+ __extends(ParticleBehaviourPlayable, _super);
18352
+ function ParticleBehaviourPlayable() {
18332
18353
  return _super !== null && _super.apply(this, arguments) || this;
18333
18354
  }
18334
- ActivationClipPlayable.prototype.onGraphStart = function () {
18335
- this.bindingItem.transform.setValid(false);
18336
- this.hideRendererComponents();
18337
- };
18338
- ActivationClipPlayable.prototype.onPlayablePlay = function () {
18339
- this.bindingItem.transform.setValid(true);
18340
- this.showRendererComponents();
18341
- };
18342
- ActivationClipPlayable.prototype.onPlayableDestroy = function () {
18343
- this.bindingItem.transform.setValid(false);
18344
- this.hideRendererComponents();
18345
- };
18346
- ActivationClipPlayable.prototype.hideRendererComponents = function () {
18347
- var e_1, _a;
18348
- try {
18349
- for (var _b = __values$1(this.bindingItem.rendererComponents), _c = _b.next(); !_c.done; _c = _b.next()) {
18350
- var rendererComponent = _c.value;
18351
- if (rendererComponent.enabled) {
18352
- rendererComponent.enabled = false;
18353
- }
18354
- }
18355
- }
18356
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
18357
- finally {
18358
- try {
18359
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
18360
- }
18361
- finally { if (e_1) throw e_1.error; }
18355
+ ParticleBehaviourPlayable.prototype.onPlayablePlay = function () {
18356
+ this.particleSystem = this.bindingItem.getComponent(ParticleSystem);
18357
+ if (this.particleSystem) {
18358
+ this.particleSystem.name = this.bindingItem.name;
18359
+ this.particleSystem.start();
18360
+ this.particleSystem.initEmitterTransform();
18362
18361
  }
18363
18362
  };
18364
- ActivationClipPlayable.prototype.showRendererComponents = function () {
18365
- var e_2, _a;
18366
- try {
18367
- for (var _b = __values$1(this.bindingItem.rendererComponents), _c = _b.next(); !_c.done; _c = _b.next()) {
18368
- var rendererComponent = _c.value;
18369
- if (!rendererComponent.enabled) {
18370
- rendererComponent.enabled = true;
18371
- }
18372
- }
18373
- }
18374
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
18375
- finally {
18376
- try {
18377
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
18378
- }
18379
- finally { if (e_2) throw e_2.error; }
18363
+ ParticleBehaviourPlayable.prototype.processFrame = function (dt) {
18364
+ var particleSystem = this.particleSystem;
18365
+ if (particleSystem) {
18366
+ this.bindingItem.parent;
18367
+ // TODO: [1.31] @十弦 验证 https://github.com/galacean/effects-runtime/commit/3e7d73d37b7d98c2a25e4544e80e928b17801ccd#diff-fae062f28caf3771cfedd3a20dc22f9749bd054c7541bf2fd50a9a5e413153d4
18368
+ // particleSystem.setParentTransform(parentItem.transform);
18369
+ particleSystem.setVisible(true);
18370
+ particleSystem.onUpdate(dt);
18380
18371
  }
18381
18372
  };
18382
- return ActivationClipPlayable;
18373
+ return ParticleBehaviourPlayable;
18383
18374
  }(Playable));
18384
18375
 
18376
+ var CalculateLoader = /** @class */ (function (_super) {
18377
+ __extends(CalculateLoader, _super);
18378
+ function CalculateLoader() {
18379
+ return _super !== null && _super.apply(this, arguments) || this;
18380
+ }
18381
+ return CalculateLoader;
18382
+ }(AbstractPlugin));
18383
+
18385
18384
  var TextLayout = /** @class */ (function () {
18386
18385
  function TextLayout(options) {
18387
18386
  this.width = 0;
@@ -19679,9 +19678,10 @@ var TextComponent = /** @class */ (function (_super) {
19679
19678
  if (this.textStyle.fontSize === value) {
19680
19679
  return;
19681
19680
  }
19681
+ // 保证字号变化后位置正常
19682
+ var diff = this.textStyle.fontSize - value;
19683
+ this.textLayout.lineHeight += diff;
19682
19684
  this.textStyle.fontSize = value;
19683
- // 1.5175 = 31.43 / 20
19684
- this.textLayout.lineHeight = this.textStyle.fontSize * 1.5175;
19685
19685
  this.isDirty = true;
19686
19686
  };
19687
19687
  /**
@@ -20007,7 +20007,7 @@ var TextLoader = /** @class */ (function (_super) {
20007
20007
  return TextLoader;
20008
20008
  }(AbstractPlugin));
20009
20009
 
20010
- var seed$3 = 1;
20010
+ var seed$2 = 1;
20011
20011
  /**
20012
20012
  * @since 2.0.0
20013
20013
  * @internal
@@ -20033,24 +20033,9 @@ var EffectComponent = /** @class */ (function (_super) {
20033
20033
  };
20034
20034
  }
20035
20035
  };
20036
- _this.id = 'Mesh' + seed$3++;
20036
+ _this.id = 'Mesh' + seed$2++;
20037
20037
  _this.name = '<unnamed>';
20038
20038
  _this._priority = 0;
20039
- _this.geometry = Geometry.create(_this.engine);
20040
- var geometryData = {
20041
- vertices: [
20042
- -1, 1, 0,
20043
- -1, -1, 0,
20044
- 1, 1, 0,
20045
- 1, -1, 0, //右下
20046
- ],
20047
- uvs: [0, 1, 0, 0, 1, 1, 1, 0],
20048
- indices: [0, 1, 2, 2, 1, 3],
20049
- dataType: DataType.Geometry,
20050
- id: generateGUID(),
20051
- };
20052
- _this.geometry.fromData(geometryData);
20053
- _this.triangles = geometryToTriangles(_this.geometry);
20054
20039
  return _this;
20055
20040
  }
20056
20041
  Object.defineProperty(EffectComponent.prototype, "isDestroyed", {
@@ -20587,11 +20572,6 @@ var VFXItem = /** @class */ (function (_super) {
20587
20572
  this.id = id.toString(); // TODO 老数据 id 是 number,需要转换
20588
20573
  this.name = name;
20589
20574
  this.start = delay ? delay : this.start;
20590
- // TODO spec 数据需要区分 scale 和 size
20591
- if (transform && transform.scale && data.type !== 'ECS') {
20592
- //@ts-expect-error TODO 数据改造后移除 expect-error
20593
- transform.scale.z = transform.scale.x;
20594
- }
20595
20575
  if (transform) {
20596
20576
  //@ts-expect-error TODO 数据改造后移除 expect-error
20597
20577
  transform.position = new Vector3().copyFrom(transform.position);
@@ -20599,51 +20579,36 @@ var VFXItem = /** @class */ (function (_super) {
20599
20579
  transform.rotation = new Euler().copyFrom(transform.rotation);
20600
20580
  //@ts-expect-error
20601
20581
  transform.scale = new Vector3().copyFrom(transform.scale);
20582
+ //@ts-expect-error
20583
+ if (transform.size) {
20584
+ //@ts-expect-error
20585
+ transform.size = new Vector2().copyFrom(transform.size);
20586
+ }
20587
+ //@ts-expect-error
20588
+ if (transform.anchor) {
20589
+ //@ts-expect-error
20590
+ transform.anchor = new Vector2().copyFrom(transform.anchor);
20591
+ }
20602
20592
  this.transform.setTransform(transform);
20603
20593
  }
20604
20594
  this.transform.name = this.name;
20605
20595
  this.transform.engine = this.engine;
20606
- // TODO spec 数据需要区分 scale 和 size
20607
- if (data.type === ItemType$1.sprite && transform) {
20608
- this.transform.setSize(this.transform.scale.x, this.transform.scale.y);
20609
- this.transform.setScale(1, 1, 1);
20610
- }
20611
20596
  this.parentId = parentId;
20612
20597
  this.duration = duration;
20613
20598
  this.endBehavior = endBehavior;
20614
- // TODO: 放到 Spec 处理
20615
- if (this.endBehavior === END_BEHAVIOR_PAUSE_AND_DESTROY$1 || this.endBehavior === END_BEHAVIOR_PAUSE$1) {
20616
- this.endBehavior = END_BEHAVIOR_FREEZE$1;
20617
- }
20618
20599
  this.lifetime = -(this.start / this.duration);
20619
20600
  this.listIndex = listIndex;
20601
+ //@ts-expect-error
20602
+ this.oldId = data.oldId;
20620
20603
  if (!data.content) {
20621
20604
  data.content = { options: {} };
20622
20605
  }
20623
20606
  var timelineComponent = this.getComponent(TimelineComponent);
20624
20607
  timelineComponent.fromData(data.content);
20625
- // TODO anchor 应该放在 transform data
20626
- if (data.type === ItemType$1.sprite) {
20627
- var content = data.content;
20628
- if (!content.renderer) {
20629
- //@ts-expect-error
20630
- content.renderer = {};
20631
- }
20632
- var realAnchor = convertAnchor(content.renderer.anchor, content.renderer.particleOrigin);
20633
- var startSize = this.transform.size;
20634
- // 兼容旧JSON(anchor和particleOrigin可能同时存在)
20635
- if (!content.renderer.anchor && content.renderer.particleOrigin !== undefined) {
20636
- this.transform.position.add([-realAnchor[0] * startSize.x, -realAnchor[1] * startSize.y, 0]);
20637
- }
20638
- this.transform.setAnchor(realAnchor[0] * startSize.x, realAnchor[1] * startSize.y, 0);
20639
- }
20640
- // TODO 要放在上面的 if 后面添加,否则会 position 初始化错误
20641
20608
  if (this.type !== ItemType$1.particle) {
20642
20609
  var track = timelineComponent.createTrack(Track, 'AnimationTrack');
20643
20610
  track.createClip(AnimationClipPlayable, 'AnimationTimelineClip').playable.fromData(data.content);
20644
20611
  }
20645
- var activationTrack = timelineComponent.createTrack(Track, 'ActivationTrack');
20646
- activationTrack.createClip(ActivationClipPlayable, 'ActivationTimelineClip');
20647
20612
  if (duration <= 0) {
20648
20613
  throw Error("Item duration can't be less than 0, see ".concat(HELP_LINK['Item duration can\'t be less than 0']));
20649
20614
  }
@@ -22658,7 +22623,7 @@ function isScene(scene) {
22658
22623
 
22659
22624
  function version3Migration(scene) {
22660
22625
  var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e, e_6, _f;
22661
- scene.jsonScene.version = 3.0;
22626
+ scene.jsonScene.version = '3.0';
22662
22627
  var ecScene = scene.jsonScene;
22663
22628
  if (!ecScene.items) {
22664
22629
  ecScene.items = [];
@@ -22670,6 +22635,10 @@ function version3Migration(scene) {
22670
22635
  for (var i = 0; i < composition.items.length; i++) {
22671
22636
  ecScene.items.push(composition.items[i]);
22672
22637
  }
22638
+ // composition 的 endbehaviour 兼容
22639
+ if (composition.endBehavior === END_BEHAVIOR_PAUSE_AND_DESTROY$1 || composition.endBehavior === END_BEHAVIOR_PAUSE$1) {
22640
+ composition.endBehavior = END_BEHAVIOR_FREEZE$1;
22641
+ }
22673
22642
  }
22674
22643
  }
22675
22644
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
@@ -22685,6 +22654,9 @@ function version3Migration(scene) {
22685
22654
  for (var _j = __values$1(ecScene.items), _k = _j.next(); !_k.done; _k = _j.next()) {
22686
22655
  var item = _k.value;
22687
22656
  itemGuidMap[item.id] = generateGUID();
22657
+ // TODO: 编辑器测试用,上线后删除
22658
+ //@ts-expect-error
22659
+ item.oldId = item.id;
22688
22660
  item.id = itemGuidMap[item.id];
22689
22661
  }
22690
22662
  }
@@ -22792,12 +22764,61 @@ function version3Migration(scene) {
22792
22764
  if (!scale) {
22793
22765
  scale = [1, 1, 1];
22794
22766
  }
22767
+ item.transform = {
22768
+ //@ts-expect-error
22769
+ position: { x: position[0], y: position[1], z: position[2] },
22770
+ //@ts-expect-error
22771
+ rotation: { x: rotation[0], y: rotation[1], z: rotation[2] },
22772
+ //@ts-expect-error
22773
+ scale: { x: scale[0], y: scale[1], z: scale[0] },
22774
+ };
22775
+ // sprite 的 scale 转为 size
22776
+ if (item.type === ItemType$1.sprite) {
22777
+ //@ts-expect-error
22778
+ item.transform.size = { x: scale[0], y: scale[1] };
22779
+ //@ts-expect-error
22780
+ item.transform.scale = { x: 1, y: 1, z: 1 };
22781
+ }
22782
+ // sprite 的 anchor 修正
22783
+ if (item.type === ItemType$1.sprite) {
22784
+ var content = item.content;
22785
+ //@ts-expect-error
22786
+ if (!content.renderer) {
22787
+ //@ts-expect-error
22788
+ content.renderer = {};
22789
+ }
22790
+ //@ts-expect-error
22791
+ var renderer = content.renderer;
22792
+ var realAnchor = convertAnchor(renderer.anchor, renderer.particleOrigin);
22793
+ //@ts-expect-error
22794
+ var startSize = item.transform.size;
22795
+ // 兼容旧JSON(anchor和particleOrigin可能同时存在)
22796
+ if (!renderer.anchor && renderer.particleOrigin !== undefined) {
22797
+ //@ts-expect-error
22798
+ item.transform.position.x += -realAnchor[0] * startSize.x;
22799
+ //@ts-expect-error
22800
+ item.transform.position.y += -realAnchor[1] * startSize.y;
22801
+ }
22802
+ //@ts-expect-error
22803
+ item.transform.anchor = { x: realAnchor[0] * startSize.x, y: realAnchor[1] * startSize.y };
22804
+ }
22805
+ }
22806
+ if (item.type === ItemType$1.particle) {
22807
+ var content = item.content;
22795
22808
  //@ts-expect-error
22796
- item.transform.position = { x: position[0], y: position[1], z: position[2] };
22809
+ if (!content.renderer) {
22810
+ //@ts-expect-error
22811
+ content.renderer = {};
22812
+ }
22797
22813
  //@ts-expect-error
22798
- item.transform.rotation = { x: rotation[0], y: rotation[1], z: rotation[2] };
22814
+ var renderer = content.renderer;
22799
22815
  //@ts-expect-error
22800
- item.transform.scale = { x: scale[0], y: scale[1], z: scale[2] };
22816
+ content.renderer.anchor = convertAnchor(renderer.anchor, renderer.particleOrigin);
22817
+ }
22818
+ // item 的 endbehaviour 兼容
22819
+ // @ts-expect-error
22820
+ if (item.endBehavior === END_BEHAVIOR_PAUSE_AND_DESTROY$1 || item.endBehavior === END_BEHAVIOR_PAUSE$1) {
22821
+ item.endBehavior = END_BEHAVIOR_FREEZE$1;
22801
22822
  }
22802
22823
  // item 的 content 转为 component data 加入 JSONScene.components
22803
22824
  var uuid = v4().replace(/-/g, '');
@@ -22972,8 +22993,22 @@ function version3Migration(scene) {
22972
22993
  }
22973
22994
  return scene;
22974
22995
  }
22996
+ /**
22997
+ * 提取并转换 JSON 数据中的 anchor 值
22998
+ */
22999
+ function convertAnchor(anchor, particleOrigin) {
23000
+ if (anchor) {
23001
+ return [anchor[0] - 0.5, 0.5 - anchor[1]];
23002
+ }
23003
+ else if (particleOrigin) {
23004
+ return particleOriginTranslateMap[particleOrigin];
23005
+ }
23006
+ else {
23007
+ return [0, 0];
23008
+ }
23009
+ }
22975
23010
 
22976
- var seed$2 = 1;
23011
+ var seed$1 = 1;
22977
23012
  /**
22978
23013
  * 资源管理器
22979
23014
  * 用于加载和动效中所有的资源文件,包括图片、插件、图层粒子数据等
@@ -22993,7 +23028,7 @@ var AssetManager = /** @class */ (function () {
22993
23028
  * 图像资源,用于创建和释放GPU纹理资源
22994
23029
  */
22995
23030
  this.assets = {};
22996
- this.id = seed$2++;
23031
+ this.id = seed$1++;
22997
23032
  /**
22998
23033
  * 场景加载的超时定时器
22999
23034
  */
@@ -23009,6 +23044,26 @@ var AssetManager = /** @class */ (function () {
23009
23044
  var _a = options.timeout, timeout = _a === void 0 ? 10 : _a;
23010
23045
  this.timeout = timeout;
23011
23046
  };
23047
+ /**
23048
+ * 根据用户传入的参数修改场景数据
23049
+ */
23050
+ AssetManager.prototype.updateSceneData = function (compositions) {
23051
+ var variables = this.options.variables;
23052
+ if (!variables || Object.keys(variables).length <= 0) {
23053
+ return compositions;
23054
+ }
23055
+ compositions.forEach(function (composition) {
23056
+ composition.items.forEach(function (item) {
23057
+ if (item.type === ItemType$1.text) {
23058
+ var textVariable = variables[item.name];
23059
+ if (textVariable) {
23060
+ item.content.options.text = textVariable;
23061
+ }
23062
+ }
23063
+ });
23064
+ });
23065
+ return compositions;
23066
+ };
23012
23067
  /**
23013
23068
  * 场景创建,通过 json 创建出场景对象,并进行提前编译等工作
23014
23069
  * @param url - json 的 URL 链接或者 json 对象
@@ -23100,6 +23155,7 @@ var AssetManager = /** @class */ (function () {
23100
23155
  for (i = 0; i < scene.images.length; i++) {
23101
23156
  scene.textureOptions[i].image = scene.images[i];
23102
23157
  }
23158
+ scene.jsonScene.compositions = this.updateSceneData(scene.jsonScene.compositions);
23103
23159
  _e.label = 5;
23104
23160
  case 5: return [3 /*break*/, 12];
23105
23161
  case 6: return [4 /*yield*/, hookTimeInfo('processJSON', function () { return _this.processJSON(rawJSON); })];
@@ -23119,6 +23175,7 @@ var AssetManager = /** @class */ (function () {
23119
23175
  return [4 /*yield*/, hookTimeInfo('processTextures', function () { return _this.processTextures(loadedImages_1, loadedBins_1, jsonScene_1); })];
23120
23176
  case 10:
23121
23177
  loadedTextures = _e.sent();
23178
+ jsonScene_1.compositions = this.updateSceneData(jsonScene_1.compositions);
23122
23179
  scene = {
23123
23180
  url: url,
23124
23181
  renderLevel: this.options.renderLevel,
@@ -23965,7 +24022,9 @@ var CompositionComponent = /** @class */ (function (_super) {
23965
24022
  }
23966
24023
  // endBehaviour 类型需优化
23967
24024
  props.content = itemData.content;
23968
- item = new VFXItem(this.engine, __assign$1(__assign$1({}, props), { id: itemData.id, name: itemData.name, delay: itemData.delay, duration: itemData.duration, endBehavior: itemData.endBehavior, parentId: itemData.parentId, transform: itemData.transform }));
24025
+ item = new VFXItem(this.engine, __assign$1(__assign$1({}, props), { id: itemData.id, name: itemData.name, delay: itemData.delay, duration: itemData.duration, endBehavior: itemData.endBehavior, parentId: itemData.parentId, transform: itemData.transform,
24026
+ // @ts-expect-error TODO: 2.0 编辑器测试代码,后续移除
24027
+ oldId: itemData.oldId }));
23969
24028
  // TODO 编辑器数据传入 composition type 后移除
23970
24029
  item.type = ItemType$1.composition;
23971
24030
  item.composition = this.item.composition;
@@ -24100,7 +24159,6 @@ var CompositionComponent = /** @class */ (function (_super) {
24100
24159
  return CompositionComponent;
24101
24160
  }(ItemBehaviour));
24102
24161
 
24103
- var seed$1 = 1;
24104
24162
  /**
24105
24163
  * 合成抽象类:核心对象,通常一个场景只包含一个合成,可能会有多个合成。
24106
24164
  * 合成中包含了相关的 Item 元素,支持对 Item 元素的创建、更新和销毁。
@@ -24173,7 +24231,7 @@ var Composition = /** @class */ (function () {
24173
24231
  this.width = width;
24174
24232
  this.height = height;
24175
24233
  this.renderOrder = baseRenderOrder;
24176
- this.id = seed$1++;
24234
+ this.id = sourceContent.id;
24177
24235
  this.renderer = renderer;
24178
24236
  this.texInfo = imageUsage !== null && imageUsage !== void 0 ? imageUsage : {};
24179
24237
  this.event = event;
@@ -24200,7 +24258,7 @@ var Composition = /** @class */ (function () {
24200
24258
  this.rootItem.onEnd = function () {
24201
24259
  window.setTimeout(function () {
24202
24260
  var _a;
24203
- (_a = _this.handleEnd) === null || _a === void 0 ? void 0 : _a.call(_this, _this);
24261
+ (_a = _this.onEnd) === null || _a === void 0 ? void 0 : _a.call(_this, _this);
24204
24262
  }, 0);
24205
24263
  };
24206
24264
  this.pluginSystem.resetComposition(this, this.renderFrame);
@@ -24279,9 +24337,9 @@ var Composition = /** @class */ (function () {
24279
24337
  * 重新开始合成
24280
24338
  */
24281
24339
  Composition.prototype.restart = function () {
24282
- var contentItems = this.rootComposition.items;
24283
- contentItems.forEach(function (item) { return item.dispose(); });
24284
- contentItems.length = 0;
24340
+ this.rootComposition.items;
24341
+ // contentItems.forEach(item => item.dispose());
24342
+ // contentItems.length = 0;
24285
24343
  this.prepareRender();
24286
24344
  this.reset();
24287
24345
  this.transform.setValid(true);
@@ -24564,7 +24622,8 @@ var Composition = /** @class */ (function () {
24564
24622
  var time = this.getUpdateTime(deltaTime * this.speed);
24565
24623
  this.globalTime += time;
24566
24624
  if (this.rootTimeline.isActiveAndEnabled) {
24567
- this.rootTimeline.setTime(this.globalTime / 1000);
24625
+ var localTime = this.rootTimeline.toLocalTime(this.globalTime / 1000);
24626
+ this.rootTimeline.setTime(localTime);
24568
24627
  }
24569
24628
  this.updateVideo();
24570
24629
  // 更新 model-tree-plugin
@@ -25029,6 +25088,9 @@ var Composition = /** @class */ (function () {
25029
25088
  }
25030
25089
  this.compositionSourceManager.dispose();
25031
25090
  this.refCompositionProps.clear();
25091
+ if (this.renderer.env === PLAYER_OPTIONS_ENV_EDITOR) {
25092
+ return;
25093
+ }
25032
25094
  this.renderer.clear({
25033
25095
  stencilAction: TextureLoadAction.clear,
25034
25096
  clearStencil: 0,
@@ -25699,9 +25761,20 @@ var Ticker = /** @class */ (function () {
25699
25761
  if (fps === void 0) { fps = 60; }
25700
25762
  this.paused = true;
25701
25763
  this.lastTime = 0;
25764
+ this._deltaTime = 0;
25702
25765
  this.setFPS(fps);
25703
25766
  this.tickers = [];
25704
25767
  }
25768
+ Object.defineProperty(Ticker.prototype, "deltaTime", {
25769
+ /**
25770
+ * 获取定时器当前帧更新的时间
25771
+ */
25772
+ get: function () {
25773
+ return this._deltaTime;
25774
+ },
25775
+ enumerable: false,
25776
+ configurable: true
25777
+ });
25705
25778
  /**
25706
25779
  * FPS 帧率设置
25707
25780
  */
@@ -25728,6 +25801,7 @@ var Ticker = /** @class */ (function () {
25728
25801
  Ticker.prototype.start = function () {
25729
25802
  var _this = this;
25730
25803
  this.paused = false;
25804
+ this._deltaTime = 0;
25731
25805
  if (!this.intervalId) {
25732
25806
  this.lastTime = performance.now();
25733
25807
  var raf_1 = requestAnimationFrame || function (func) {
@@ -25750,6 +25824,7 @@ var Ticker = /** @class */ (function () {
25750
25824
  this.intervalId = 0;
25751
25825
  this.lastTime = 0;
25752
25826
  this.paused = true;
25827
+ this._deltaTime = 0;
25753
25828
  this.tickers = [];
25754
25829
  };
25755
25830
  /**
@@ -25757,12 +25832,14 @@ var Ticker = /** @class */ (function () {
25757
25832
  */
25758
25833
  Ticker.prototype.pause = function () {
25759
25834
  this.paused = true;
25835
+ this._deltaTime = 0;
25760
25836
  };
25761
25837
  /**
25762
25838
  * 定时器恢复方法
25763
25839
  */
25764
25840
  Ticker.prototype.resume = function () {
25765
25841
  this.paused = false;
25842
+ this._deltaTime = 0;
25766
25843
  };
25767
25844
  /**
25768
25845
  * 定时器 tick 方法
@@ -25772,8 +25849,8 @@ var Ticker = /** @class */ (function () {
25772
25849
  return;
25773
25850
  }
25774
25851
  var startTime = performance.now();
25775
- var deltaTime = startTime - this.lastTime;
25776
- if (deltaTime >= this.interval) {
25852
+ this._deltaTime = startTime - this.lastTime;
25853
+ if (this._deltaTime >= this.interval) {
25777
25854
  this.lastTime = startTime;
25778
25855
  if (this.resetTickers) {
25779
25856
  this.tickers = this.tickers.filter(function (tick) { return tick; });
@@ -25781,7 +25858,7 @@ var Ticker = /** @class */ (function () {
25781
25858
  }
25782
25859
  for (var i = 0, len = this.tickers.length; i < len; i++) {
25783
25860
  var tick = this.tickers[i];
25784
- tick(deltaTime);
25861
+ tick(this._deltaTime);
25785
25862
  }
25786
25863
  }
25787
25864
  };
@@ -27297,6 +27374,103 @@ function isSceneWithOptions(scene) {
27297
27374
  return isObject(scene) && 'scene' in scene;
27298
27375
  }
27299
27376
 
27377
+ var ThreeSpriteComponent = /** @class */ (function (_super) {
27378
+ __extends(ThreeSpriteComponent, _super);
27379
+ function ThreeSpriteComponent() {
27380
+ return _super !== null && _super.apply(this, arguments) || this;
27381
+ }
27382
+ Object.defineProperty(ThreeSpriteComponent.prototype, "priority", {
27383
+ /**
27384
+ * 获取 mesh 的渲染顺序
27385
+ */
27386
+ get: function () {
27387
+ return this.threeMesh.renderOrder;
27388
+ },
27389
+ /**
27390
+ * 设置 mesh 的渲染顺序
27391
+ *
27392
+ * @param v - 顺序 index
27393
+ */
27394
+ set: function (v) {
27395
+ if (this.threeMesh) {
27396
+ this.threeMesh.renderOrder = v;
27397
+ }
27398
+ },
27399
+ enumerable: false,
27400
+ configurable: true
27401
+ });
27402
+ /**
27403
+ * TODO: 待移除
27404
+ * 设置 mesh 可见性
27405
+ *
27406
+ * @param val - 可见性开关
27407
+ */
27408
+ ThreeSpriteComponent.prototype.setVisible = function (val) {
27409
+ this.threeMesh.visible = val;
27410
+ };
27411
+ /**
27412
+ * TODO: 待移除
27413
+ * 获取 mesh 的可见性
27414
+ *
27415
+ * @returns
27416
+ */
27417
+ ThreeSpriteComponent.prototype.getVisible = function () {
27418
+ return this.threeMesh.visible;
27419
+ };
27420
+ Object.defineProperty(ThreeSpriteComponent.prototype, "enabled", {
27421
+ get: function () {
27422
+ return this.threeMesh.visible;
27423
+ },
27424
+ set: function (value) {
27425
+ this.threeMesh.visible = value;
27426
+ if (value) {
27427
+ this.onEnable();
27428
+ }
27429
+ },
27430
+ enumerable: false,
27431
+ configurable: true
27432
+ });
27433
+ /**
27434
+ * 销毁方法
27435
+ *
27436
+ */
27437
+ ThreeSpriteComponent.prototype.dispose = function () {
27438
+ _super.prototype.dispose.call(this);
27439
+ if (!this.isActiveAndEnabled) {
27440
+ this.threeMesh.clear();
27441
+ }
27442
+ };
27443
+ ThreeSpriteComponent.prototype.fromData = function (data) {
27444
+ _super.prototype.fromData.call(this, data);
27445
+ if (!this.threeMesh) {
27446
+ if (this.geometry.mode === glContext.LINES) {
27447
+ this.threeMesh = new THREE.LineSegments(this.geometry.geometry, this.material.material);
27448
+ }
27449
+ else {
27450
+ this.threeMesh = new THREE.Mesh(this.geometry.geometry, this.material.material);
27451
+ }
27452
+ }
27453
+ };
27454
+ ThreeSpriteComponent.prototype.start = function () {
27455
+ _super.prototype.start.call(this);
27456
+ this.engine.threeGroup.add(this.threeMesh);
27457
+ };
27458
+ ThreeSpriteComponent.prototype.render = function (renderer) {
27459
+ if (!this.isActiveAndEnabled) {
27460
+ return;
27461
+ }
27462
+ this.material.setMatrix('effects_ObjectToWorld', this.transform.getWorldMatrix());
27463
+ this.material.use(renderer, renderer.renderingData.currentFrame.globalUniforms);
27464
+ };
27465
+ ThreeSpriteComponent.prototype.onDestroy = function () {
27466
+ this.threeMesh.clear();
27467
+ };
27468
+ ThreeSpriteComponent = __decorate([
27469
+ effectsClass(DataType.SpriteComponent)
27470
+ ], ThreeSpriteComponent);
27471
+ return ThreeSpriteComponent;
27472
+ }(SpriteComponent));
27473
+
27300
27474
  setMaxSpriteMeshItemCount(8);
27301
27475
  /**
27302
27476
  * 图片的创建方法
@@ -27344,8 +27518,8 @@ Geometry.create = function (engine, options) {
27344
27518
  Mesh.create = function (engine, props) {
27345
27519
  return new ThreeMesh(engine, props);
27346
27520
  };
27347
- var version = "2.0.0-alpha.0";
27521
+ var version = "2.0.0-alpha.2";
27348
27522
  logger.info('THREEJS plugin version: ' + version);
27349
27523
 
27350
- export { AbstractPlugin, ActivationClipPlayable, AnimationClipPlayable, AssetLoader, AssetManager, BYTES_TYPE_MAP, Behaviour, BezierSegments, COMPRESSED_TEXTURE, CONSTANT_MAP_BLEND, CONSTANT_MAP_DEPTH, CONSTANT_MAP_STENCIL_FUNC, CONSTANT_MAP_STENCIL_OP, COPY_FRAGMENT_SHADER, COPY_MESH_SHADER_ID, COPY_VERTEX_SHADER, CalculateLoader, Camera, CameraController, CameraVFXItemLoader, Component, Composition, CompositionComponent, CompositionSourceManager, CurveValue, DEFAULT_FONTS, DataType, 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, FILTER_NAME_NONE, FilterMode, Float16ArrayWrapper, FrameBuffer, GLSLVersion, GPUCapability, Geometry, GlobalUniforms, GradientValue, HELP_LINK, HitTestType, InteractBehavior$1 as InteractBehavior, InteractComponent, InteractLoader, InteractMesh, Item, ItemBehaviour, KTXTexture, LineSegments, LinearValue, Material, MaterialDataBlock, MaterialRenderType, Mesh, OrderType, PLAYER_OPTIONS_ENV_EDITOR, POST_PROCESS_SETTINGS, ParticleBehaviourPlayable, ParticleLoader, ParticleMesh, ParticleSystem, ParticleSystemRenderer, PassTextureCache, PathSegments, PluginSystem, QCanvasViewer, QText, QTextWrapMode, RENDER_PASS_NAME_PREFIX, RENDER_PREFER_LOOKUP_TEXTURE, RUNTIME_ENV, RandomSetValue, RandomValue, RandomVectorValue, RenderBuffer, RenderFrame, RenderPass, RenderPassAttachmentStorageType, RenderPassDestroyAttachmentType, RenderPassPriorityNormal, RenderPassPriorityPostprocess, RenderPassPriorityPrepare, RenderTargetHandle, RenderTextureFormat, Renderer, RendererComponent, 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, SpriteColorPlayable, SpriteComponent, SpriteLoader, StaticValue, TEMPLATE_USE_OFFSCREEN_CANVAS, TEXTURE_UNIFORM_MAP, TextComponent, TextLoader, Texture, TextureFactory, TextureLoadAction, TextureSourceType, TextureStoreAction, ThreeComposition, ThreeDisplayObject, ThreeEngine, ThreeMaterial, ThreeTexture, Ticker, TimelineClip, TimelineComponent, Track, Transform, VFXItem, ValueGetter, addByOrder, addItem, addItemWithOrder, alphaFrame_frag as alphaFrameFrag, alphaMask_frag as alphaMaskFrag, assertExist, asserts, blend, bloomMix_frag as bloomMixVert, bloomThreshold_frag as bloomThresholdVert, calculateTranslation, cameraMove_frag as cameraMoveFrag, cameraMove_vert as cameraMoveVert, canvasPool, colorGradingFrag, colorStopsFromGradient, colorToArr$1 as colorToArr, combineImageTemplate, combineImageTemplate1, combineImageTemplate1Async, combineImageTemplate2, combineImageTemplate2Async, combineImageTemplateAsync, compatible_frag as compatibleFrag, compatible_vert as compatibleVert, convertAnchor, copy as copyFrag, createCopyShader, createGLContext, createKeyFrameMeta, createShaderWithMarcos, createShape, createVFXItem, createValueGetter, deepClone, defaultGlobalVolume, defaultPlugins, delay_frag as delayFrag, deserializeMipmapTexture, distortion_frag as distortionFrag, distortion_vert as distortionVert, earcut, effectsClass, effectsClassStore, enlargeBuffer, ensureVec3, findPreviousRenderPass, gaussianDown_frag as gaussianDownFrag, gaussianDownHFrag, gaussianDownVFrag, gaussianUpFrag, generateEmptyTypedArray, generateGUID, generateHalfFloatTexture, getBackgroundImage, getColorFromGradientStops, getConfig, getDefaultTemplateCanvasPool, getDefaultTextureFactory, getGeometryByShape, getGeometryTriangles, getImageItemRenderInfo, getKTXTextureOptions, getKeyFrameMetaByRawValue, getMergedStore, getParticleMeshShader, getPixelRatio, getPreMultiAlpha, getStandardComposition, getStandardImage, getStandardItem, getStandardJSON, getTextureSize, glContext, gpuTimer, imageDataFromColor, imageDataFromGradient, initErrors, initGLContext, integrate, interpolateColor, isAndroid, isArray, isFunction, isIOS, isObject, isScene, isSceneWithOptions, isSimulatorCellPhone, isString, isUniformStruct, isUniformStructArray, isWebGL2, item_define as itemDefine, itemFrag, itemFrameFrag, itemVert, loadBinary, loadBlob, loadImage, loadVideo, loadWebPOptional, logger, index$1 as math, maxSpriteMeshItemCount, maxSpriteTextureCount, modifyMaxKeyframeShader, nearestPowerOfTwo, noop, parsePercent$1 as parsePercent, particleFrag, particleOriginTranslateMap, particleVert, pluginLoaderMap, random, registerPlugin, removeItem, requestAsync, rotateVec2, screenMeshVert, serialize, setBlendMode, setConfig, setDefaultTextureFactory, setMaskMode, setMaxSpriteMeshItemCount, setRayFromCamera, setSideMode, setSpriteMeshMaxFragmentTextures, setSpriteMeshMaxItemCountByGPU, setUniformValue, sortByOrder, index as spec, spriteMeshShaderFromFilter, spriteMeshShaderFromRenderInfo, spriteMeshShaderIdFromRenderInfo, thresholdFrag, throwDestroyedError, trailVert, translatePoint, trianglesFromRect, unregisterPlugin, valIfUndefined, value, valueDefine, vecAssign, vecFill, vecMulCombine, vecNormalize, version };
27524
+ export { AbstractPlugin, ActivationClipPlayable, AnimationClipPlayable, AssetLoader, AssetManager, BYTES_TYPE_MAP, Behaviour, BezierSegments, COMPRESSED_TEXTURE, CONSTANT_MAP_BLEND, CONSTANT_MAP_DEPTH, CONSTANT_MAP_STENCIL_FUNC, CONSTANT_MAP_STENCIL_OP, COPY_FRAGMENT_SHADER, COPY_MESH_SHADER_ID, COPY_VERTEX_SHADER, CalculateLoader, Camera, CameraController, CameraVFXItemLoader, Component, Composition, CompositionComponent, CompositionSourceManager, CurveValue, DEFAULT_FONTS, DataType, 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, FILTER_NAME_NONE, FilterMode, Float16ArrayWrapper, FrameBuffer, GLSLVersion, GPUCapability, Geometry, GlobalUniforms, GradientValue, HELP_LINK, HitTestType, InteractBehavior$1 as InteractBehavior, InteractComponent, InteractLoader, InteractMesh, Item, ItemBehaviour, KTXTexture, LineSegments, LinearValue, Material, MaterialDataBlock, MaterialRenderType, Mesh, OrderType, PLAYER_OPTIONS_ENV_EDITOR, POST_PROCESS_SETTINGS, ParticleBehaviourPlayable, ParticleLoader, ParticleMesh, ParticleSystem, ParticleSystemRenderer, PassTextureCache, PathSegments, PluginSystem, QCanvasViewer, QText, QTextWrapMode, RENDER_PASS_NAME_PREFIX, RENDER_PREFER_LOOKUP_TEXTURE, RUNTIME_ENV, RandomSetValue, RandomValue, RandomVectorValue, RenderBuffer, RenderFrame, RenderPass, RenderPassAttachmentStorageType, RenderPassDestroyAttachmentType, RenderPassPriorityNormal, RenderPassPriorityPostprocess, RenderPassPriorityPrepare, RenderTargetHandle, RenderTextureFormat, Renderer, RendererComponent, 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, SpriteColorPlayable, SpriteComponent, SpriteLoader, StaticValue, TEMPLATE_USE_OFFSCREEN_CANVAS, TEXTURE_UNIFORM_MAP, TextComponent, TextLoader, Texture, TextureFactory, TextureLoadAction, TextureSourceType, TextureStoreAction, ThreeComposition, ThreeDisplayObject, ThreeEngine, ThreeMaterial, ThreeSpriteComponent, ThreeTexture, Ticker, TimelineClip, TimelineComponent, Track, Transform, VFXItem, ValueGetter, addByOrder, addItem, addItemWithOrder, alphaFrame_frag as alphaFrameFrag, alphaMask_frag as alphaMaskFrag, assertExist, asserts, blend, bloomMix_frag as bloomMixVert, bloomThreshold_frag as bloomThresholdVert, calculateTranslation, cameraMove_frag as cameraMoveFrag, cameraMove_vert as cameraMoveVert, canvasPool, colorGradingFrag, colorStopsFromGradient, colorToArr$1 as colorToArr, combineImageTemplate, combineImageTemplate1, combineImageTemplate1Async, combineImageTemplate2, combineImageTemplate2Async, combineImageTemplateAsync, compatible_frag as compatibleFrag, compatible_vert as compatibleVert, copy as copyFrag, createCopyShader, createGLContext, createKeyFrameMeta, createShaderWithMarcos, createShape, createVFXItem, createValueGetter, deepClone, defaultGlobalVolume, defaultPlugins, delay_frag as delayFrag, deserializeMipmapTexture, distortion_frag as distortionFrag, distortion_vert as distortionVert, earcut, effectsClass, effectsClassStore, enlargeBuffer, ensureVec3, findPreviousRenderPass, gaussianDown_frag as gaussianDownFrag, gaussianDownHFrag, gaussianDownVFrag, gaussianUpFrag, generateEmptyTypedArray, generateGUID, generateHalfFloatTexture, getBackgroundImage, getColorFromGradientStops, getConfig, getDefaultTemplateCanvasPool, getDefaultTextureFactory, getGeometryByShape, getGeometryTriangles, getImageItemRenderInfo, getKTXTextureOptions, getKeyFrameMetaByRawValue, getMergedStore, getParticleMeshShader, getPixelRatio, getPreMultiAlpha, getStandardComposition, getStandardImage, getStandardItem, getStandardJSON, getTextureSize, glContext, gpuTimer, imageDataFromColor, imageDataFromGradient, initErrors, initGLContext, integrate, interpolateColor, isAndroid, isArray, isFunction, isIOS, isObject, isScene, isSceneWithOptions, isSimulatorCellPhone, isString, isUniformStruct, isUniformStructArray, isWebGL2, item_define as itemDefine, itemFrag, itemFrameFrag, itemVert, loadBinary, loadBlob, loadImage, loadVideo, loadWebPOptional, logger, index$1 as math, maxSpriteMeshItemCount, maxSpriteTextureCount, modifyMaxKeyframeShader, nearestPowerOfTwo, noop, parsePercent$1 as parsePercent, particleFrag, particleOriginTranslateMap, particleVert, pluginLoaderMap, random, registerPlugin, removeItem, requestAsync, rotateVec2, screenMeshVert, serialize, setBlendMode, setConfig, setDefaultTextureFactory, setMaskMode, setMaxSpriteMeshItemCount, setRayFromCamera, setSideMode, setSpriteMeshMaxFragmentTextures, setSpriteMeshMaxItemCountByGPU, setUniformValue, sortByOrder, index as spec, spriteMeshShaderFromFilter, spriteMeshShaderFromRenderInfo, spriteMeshShaderIdFromRenderInfo, thresholdFrag, throwDestroyedError, trailVert, translatePoint, trianglesFromRect, unregisterPlugin, valIfUndefined, value, valueDefine, vecAssign, vecFill, vecMulCombine, vecNormalize, version };
27351
27525
  //# sourceMappingURL=index.mjs.map