@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.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * Description: Galacean Effects runtime threejs plugin for the web
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
6
- * Version: v2.0.0-alpha.0
6
+ * Version: v2.0.0-alpha.2
7
7
  */
8
8
 
9
9
  'use strict';
@@ -8219,7 +8219,7 @@ function loadMipmapImage(pointer, bins) {
8219
8219
  });
8220
8220
  }
8221
8221
 
8222
- var seed$b = 1;
8222
+ var seed$a = 1;
8223
8223
  /**
8224
8224
  * Texture 抽象类
8225
8225
  */
@@ -8228,7 +8228,7 @@ var Texture = /** @class */ (function (_super) {
8228
8228
  function Texture(engine) {
8229
8229
  var _this = _super.call(this, engine) || this;
8230
8230
  _this.destroyed = false;
8231
- _this.id = 'Tex' + seed$b++;
8231
+ _this.id = 'Tex' + seed$a++;
8232
8232
  return _this;
8233
8233
  }
8234
8234
  Object.defineProperty(Texture.prototype, "isDestroyed", {
@@ -8630,7 +8630,7 @@ exports.MaterialRenderType = void 0;
8630
8630
  * 用于设置材质默认名称的自增序号
8631
8631
  * @internal
8632
8632
  */
8633
- var seed$a = 1;
8633
+ var seed$9 = 1;
8634
8634
  /**
8635
8635
  * Material 抽象类
8636
8636
  */
@@ -8645,7 +8645,7 @@ var Material = /** @class */ (function (_super) {
8645
8645
  _this.destroyed = false;
8646
8646
  _this.initialized = false;
8647
8647
  if (props) {
8648
- var _a = props.name, name_1 = _a === void 0 ? 'Material' + seed$a++ : _a, _b = props.renderType, renderType = _b === void 0 ? exports.MaterialRenderType.normal : _b, shader = props.shader, uniformSemantics = props.uniformSemantics;
8648
+ var _a = props.name, name_1 = _a === void 0 ? 'Material' + seed$9++ : _a, _b = props.renderType, renderType = _b === void 0 ? exports.MaterialRenderType.normal : _b, shader = props.shader, uniformSemantics = props.uniformSemantics;
8649
8649
  _this.name = name_1;
8650
8650
  _this.renderType = renderType; // TODO 没有地方用到
8651
8651
  _this.shaderSource = shader;
@@ -8653,7 +8653,7 @@ var Material = /** @class */ (function (_super) {
8653
8653
  _this.uniformSemantics = __assign$1({}, uniformSemantics); // TODO 废弃,待移除
8654
8654
  }
8655
8655
  else {
8656
- _this.name = 'Material' + seed$a++;
8656
+ _this.name = 'Material' + seed$9++;
8657
8657
  _this.renderType = exports.MaterialRenderType.normal;
8658
8658
  }
8659
8659
  return _this;
@@ -9078,7 +9078,7 @@ function generateEmptyTypedArray(type) {
9078
9078
  return new Float32Array(0);
9079
9079
  }
9080
9080
 
9081
- var seed$9 = 1;
9081
+ var seed$8 = 1;
9082
9082
  /**
9083
9083
  * Mesh 抽象类
9084
9084
  */
@@ -9090,7 +9090,7 @@ var Mesh = /** @class */ (function (_super) {
9090
9090
  _this.visible = true;
9091
9091
  if (props) {
9092
9092
  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;
9093
- _this.id = 'Mesh' + seed$9++;
9093
+ _this.id = 'Mesh' + seed$8++;
9094
9094
  _this.name = name_1;
9095
9095
  _this.geometry = geometry;
9096
9096
  _this.material = material;
@@ -9098,7 +9098,7 @@ var Mesh = /** @class */ (function (_super) {
9098
9098
  _this.worldMatrix = worldMatrix;
9099
9099
  }
9100
9100
  else {
9101
- _this.id = 'Mesh' + seed$9++;
9101
+ _this.id = 'Mesh' + seed$8++;
9102
9102
  _this.name = '<unnamed>';
9103
9103
  _this.worldMatrix = Matrix4.fromIdentity();
9104
9104
  _this._priority = 0;
@@ -9318,7 +9318,7 @@ exports.RenderPassDestroyAttachmentType = void 0;
9318
9318
  */
9319
9319
  RenderPassDestroyAttachmentType[RenderPassDestroyAttachmentType["destroy"] = 0] = "destroy";
9320
9320
  })(exports.RenderPassDestroyAttachmentType || (exports.RenderPassDestroyAttachmentType = {}));
9321
- var seed$8 = 1;
9321
+ var seed$7 = 1;
9322
9322
  /**
9323
9323
  * RenderPass 抽象类
9324
9324
  */
@@ -9330,7 +9330,7 @@ var RenderPass = /** @class */ (function () {
9330
9330
  this.attachments = [];
9331
9331
  this.destroyed = false;
9332
9332
  this.initialized = false;
9333
- 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 ? exports.OrderType.ascending : _c, _d = options.meshes, meshes = _d === void 0 ? [] : _d, _e = options.delegate, delegate = _e === void 0 ? {} : _e;
9333
+ 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 ? exports.OrderType.ascending : _c, _d = options.meshes, meshes = _d === void 0 ? [] : _d, _e = options.delegate, delegate = _e === void 0 ? {} : _e;
9334
9334
  this.name = name;
9335
9335
  this.renderer = renderer;
9336
9336
  this.priority = priority;
@@ -9947,7 +9947,7 @@ var defaultGlobalVolume = {
9947
9947
  };
9948
9948
 
9949
9949
  var RENDER_PASS_NAME_PREFIX = '_effects_default_';
9950
- var seed$7 = 1;
9950
+ var seed$6 = 1;
9951
9951
  /**
9952
9952
  * RenderFrame 抽象类
9953
9953
  */
@@ -10082,7 +10082,7 @@ var RenderFrame = /** @class */ (function () {
10082
10082
  }
10083
10083
  this.semantics = new SemanticMap(options.semantics);
10084
10084
  this.clearAction = clearAction;
10085
- this.name = "RenderFrame".concat(seed$7++);
10085
+ this.name = "RenderFrame".concat(seed$6++);
10086
10086
  var firstRP = renderPasses[0];
10087
10087
  var sourceOpts = {
10088
10088
  type: glContext.UNSIGNED_BYTE,
@@ -11305,6 +11305,12 @@ var SerializationHelper = /** @class */ (function () {
11305
11305
  value.id &&
11306
11306
  value.id.length === 32;
11307
11307
  };
11308
+ // TODO 测试函数,2.0 上线后移除
11309
+ SerializationHelper.checkGLTFNode = function (value) {
11310
+ return value instanceof Object &&
11311
+ value.nodeIndex !== undefined &&
11312
+ value.isJoint !== undefined;
11313
+ };
11308
11314
  SerializationHelper.deserializeProperty = function (property, engine, level) {
11309
11315
  var e_11, _a, e_12, _b;
11310
11316
  if (level > 10) {
@@ -11337,7 +11343,9 @@ var SerializationHelper = /** @class */ (function () {
11337
11343
  else if (SerializationHelper.checkDataPath(property)) {
11338
11344
  return engine.assetLoader.loadGUID(property.id);
11339
11345
  }
11340
- else if (property instanceof EffectsObject || SerializationHelper.checkTypedArray(property)) {
11346
+ else if (property instanceof EffectsObject ||
11347
+ SerializationHelper.checkTypedArray(property) ||
11348
+ SerializationHelper.checkGLTFNode(property)) {
11341
11349
  return property;
11342
11350
  }
11343
11351
  else if (property instanceof Object) {
@@ -11412,7 +11420,9 @@ var SerializationHelper = /** @class */ (function () {
11412
11420
  res = _j.sent();
11413
11421
  return [2 /*return*/, res];
11414
11422
  case 12:
11415
- if (!(property instanceof EffectsObject || SerializationHelper.checkTypedArray(property))) return [3 /*break*/, 13];
11423
+ if (!(property instanceof EffectsObject ||
11424
+ SerializationHelper.checkTypedArray(property) ||
11425
+ SerializationHelper.checkGLTFNode(property))) return [3 /*break*/, 13];
11416
11426
  return [2 /*return*/, property];
11417
11427
  case 13:
11418
11428
  if (!(property instanceof Object)) return [3 /*break*/, 22];
@@ -11900,20 +11910,6 @@ var particleOriginTranslateMap = (_a$4 = {},
11900
11910
  _a$4[ParticleOrigin$1.PARTICLE_ORIGIN_RIGHT_BOTTOM] = [0.5, -0.5],
11901
11911
  _a$4[ParticleOrigin$1.PARTICLE_ORIGIN_RIGHT_TOP] = [0.5, 0.5],
11902
11912
  _a$4);
11903
- /**
11904
- * 提取并转换 JSON 数据中的 anchor 值
11905
- */
11906
- function convertAnchor(anchor, particleOrigin) {
11907
- if (anchor) {
11908
- return [anchor[0] - 0.5, 0.5 - anchor[1]];
11909
- }
11910
- else if (particleOrigin) {
11911
- return particleOriginTranslateMap[particleOrigin];
11912
- }
11913
- else {
11914
- return [0, 0];
11915
- }
11916
- }
11917
11913
  function nearestPowerOfTwo(value) {
11918
11914
  return Math.pow(2, Math.round(Math.log(value) / Math.LN2));
11919
11915
  }
@@ -12609,7 +12605,7 @@ function createKeyFrameMeta() {
12609
12605
  }
12610
12606
 
12611
12607
  var tempQuat$1 = new Quaternion();
12612
- var seed$6 = 1;
12608
+ var seed$5 = 1;
12613
12609
  // TODO 继承 Component
12614
12610
  var Transform = /** @class */ (function () {
12615
12611
  function Transform(props, parent) {
@@ -12672,7 +12668,7 @@ var Transform = /** @class */ (function () {
12672
12668
  * 最终模型矩阵对应变换的缓存,当自身矩阵或父矩阵有修改时需要更新
12673
12669
  */
12674
12670
  this.worldTRSCache = { position: new Vector3(0, 0, 0), quat: new Quaternion(0, 0, 0, 1), scale: new Vector3(1, 1, 1) };
12675
- this.name = "transform_".concat(seed$6++);
12671
+ this.name = "transform_".concat(seed$5++);
12676
12672
  if (props) {
12677
12673
  this.setTransform(props);
12678
12674
  }
@@ -12852,13 +12848,11 @@ var Transform = /** @class */ (function () {
12852
12848
  * 设置锚点
12853
12849
  * @param x
12854
12850
  * @param y
12855
- * @param z
12856
12851
  */
12857
- Transform.prototype.setAnchor = function (x, y, z) {
12858
- if (this.anchor.x !== x || this.anchor.y !== y || this.anchor.z !== z) {
12852
+ Transform.prototype.setAnchor = function (x, y) {
12853
+ if (this.anchor.x !== x || this.anchor.y !== y) {
12859
12854
  this.anchor.x = x;
12860
12855
  this.anchor.y = y;
12861
- this.anchor.z = z;
12862
12856
  this.dirtyFlags.localData = true;
12863
12857
  this.dispatchValueChange();
12864
12858
  }
@@ -12869,8 +12863,7 @@ var Transform = /** @class */ (function () {
12869
12863
  * @param reverseEuler - 设置 rotation时,欧拉角是否需要取负值
12870
12864
  */
12871
12865
  Transform.prototype.setTransform = function (props, reverseEuler) {
12872
- var _a;
12873
- var position = props.position, rotation = props.rotation, scale = props.scale, quat = props.quat, name = props.name, anchor = props.anchor;
12866
+ var position = props.position, rotation = props.rotation, scale = props.scale, size = props.size, quat = props.quat, name = props.name, anchor = props.anchor;
12874
12867
  if (name) {
12875
12868
  this.name = name;
12876
12869
  }
@@ -12907,12 +12900,15 @@ var Transform = /** @class */ (function () {
12907
12900
  this.setScale(scale[0], scale[1], scale[2]);
12908
12901
  }
12909
12902
  }
12903
+ if (size) {
12904
+ this.setSize(size.x, size.y);
12905
+ }
12910
12906
  if (anchor) {
12911
- if (anchor instanceof Vector3) {
12912
- this.setAnchor(anchor.x, anchor.y, anchor.z);
12907
+ if (anchor instanceof Vector2) {
12908
+ this.setAnchor(anchor.x, anchor.y);
12913
12909
  }
12914
12910
  else {
12915
- this.setAnchor(anchor[0], anchor[1], (_a = anchor[2]) !== null && _a !== void 0 ? _a : 0);
12911
+ this.setAnchor(anchor[0], anchor[1]);
12916
12912
  }
12917
12913
  }
12918
12914
  };
@@ -13406,7 +13402,7 @@ var HELP_LINK = {
13406
13402
 
13407
13403
  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";
13408
13404
  var fragment = "\nprecision highp float;\n\n#define fragColor gl_FragColor\n\nvarying vec4 vColor;\nvoid main() {\n gl_FragColor = vColor;\n}\n";
13409
- var seed$5 = 1;
13405
+ var seed$4 = 1;
13410
13406
  var InteractMesh = /** @class */ (function () {
13411
13407
  function InteractMesh(props, rendererOptions, transform, engine) {
13412
13408
  this.transform = transform;
@@ -13484,7 +13480,7 @@ var InteractMesh = /** @class */ (function () {
13484
13480
  };
13485
13481
  InteractMesh.prototype.createMesh = function (geometry, material) {
13486
13482
  return Mesh.create(this.engine, {
13487
- name: 'Interact_preview' + seed$5++,
13483
+ name: 'Interact_preview' + seed$4++,
13488
13484
  priority: 0,
13489
13485
  worldMatrix: Matrix4.fromIdentity(),
13490
13486
  geometry: geometry,
@@ -13969,171 +13965,489 @@ var PlayableOutput = /** @class */ (function () {
13969
13965
  * @since 2.0.0
13970
13966
  * @internal
13971
13967
  */
13972
- var TimelineComponent = /** @class */ (function (_super) {
13973
- __extends(TimelineComponent, _super);
13974
- function TimelineComponent(engine) {
13975
- var _this = _super.call(this, engine) || this;
13976
- _this.reusable = false;
13977
- _this.timelineStarted = false;
13978
- _this.playableGraph = new PlayableGraph();
13979
- /**
13980
- * 元素动画已经播放的时间
13981
- */
13982
- _this.time = 0;
13983
- _this.tracks = [];
13984
- _this.trackSeed = 0;
13985
- return _this;
13968
+ var Track = /** @class */ (function () {
13969
+ function Track() {
13970
+ this.clips = [];
13971
+ this.clipSeed = 0;
13986
13972
  }
13987
- TimelineComponent.prototype.start = function () {
13988
- var e_1, _a, e_2, _b;
13973
+ Track.prototype.createOutput = function () {
13974
+ var output = new PlayableOutput();
13975
+ return output;
13976
+ };
13977
+ /**
13978
+ * 重写该方法以创建自定义混合器
13979
+ */
13980
+ Track.prototype.createMixerPlayable = function () {
13981
+ return new Playable();
13982
+ };
13983
+ Track.prototype.createPlayebleTree = function () {
13984
+ var e_1, _a;
13985
+ var defaultMixPlayable = this.createMixerPlayable();
13989
13986
  try {
13990
- // TODO TimelineClip 需要传入 start duration 数据
13991
- for (var _c = __values$1(this.tracks), _d = _c.next(); !_d.done; _d = _c.next()) {
13992
- var track = _d.value;
13993
- try {
13994
- for (var _e = (e_2 = void 0, __values$1(track.getClips())), _f = _e.next(); !_f.done; _f = _e.next()) {
13995
- var clip = _f.value;
13996
- clip.start = this.item.start;
13997
- clip.duration = this.item.duration;
13998
- }
13999
- }
14000
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
14001
- finally {
14002
- try {
14003
- if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
14004
- }
14005
- finally { if (e_2) throw e_2.error; }
14006
- }
13987
+ for (var _b = __values$1(this.clips), _c = _b.next(); !_c.done; _c = _b.next()) {
13988
+ var clip = _c.value;
13989
+ defaultMixPlayable.connect(clip.playable);
14007
13990
  }
14008
13991
  }
14009
13992
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
14010
13993
  finally {
14011
13994
  try {
14012
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
13995
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
14013
13996
  }
14014
13997
  finally { if (e_1) throw e_1.error; }
14015
13998
  }
14016
- this.compileTracks(this.playableGraph);
13999
+ return defaultMixPlayable;
14017
14000
  };
14018
- // TODO: [1.31] @十弦 vfx-item onUpdate 的改动验证
14019
- TimelineComponent.prototype.update = function (dt) {
14020
- 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;
14021
- if (this.item.stopped || !this.item.composition) {
14022
- return;
14023
- }
14024
- if (!this.timelineStarted) {
14025
- try {
14026
- for (var _j = __values$1(this.tracks), _k = _j.next(); !_k.done; _k = _j.next()) {
14027
- var track = _k.value;
14028
- try {
14029
- for (var _l = (e_4 = void 0, __values$1(track.getClips())), _m = _l.next(); !_m.done; _m = _l.next()) {
14030
- var clip = _m.value;
14031
- clip.playable.onGraphStart();
14032
- }
14033
- }
14034
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
14035
- finally {
14036
- try {
14037
- if (_m && !_m.done && (_b = _l.return)) _b.call(_l);
14038
- }
14039
- finally { if (e_4) throw e_4.error; }
14040
- }
14041
- }
14042
- }
14043
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
14044
- finally {
14045
- try {
14046
- if (_k && !_k.done && (_a = _j.return)) _a.call(_j);
14001
+ Track.prototype.createClip = function (classConstructor, name) {
14002
+ var newClip = new TimelineClip();
14003
+ newClip.playable = new classConstructor();
14004
+ newClip.name = name ? name : 'TimelineClip' + newClip.id;
14005
+ this.addClip(newClip);
14006
+ return newClip;
14007
+ };
14008
+ Track.prototype.getClips = function () {
14009
+ return this.clips;
14010
+ };
14011
+ Track.prototype.findClip = function (name) {
14012
+ var e_2, _a;
14013
+ try {
14014
+ for (var _b = __values$1(this.clips), _c = _b.next(); !_c.done; _c = _b.next()) {
14015
+ var clip = _c.value;
14016
+ if (clip.name === name) {
14017
+ return clip;
14047
14018
  }
14048
- finally { if (e_3) throw e_3.error; }
14049
14019
  }
14050
- this.timelineStarted = true;
14051
14020
  }
14052
- var now = this.time;
14053
- // 判断动画是否开始
14054
- if (this.item.delaying && now >= 0 && now <= this.item.duration) {
14055
- this.item.delaying = false;
14021
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
14022
+ finally {
14056
14023
  try {
14057
- for (var _o = __values$1(this.tracks), _p = _o.next(); !_p.done; _p = _o.next()) {
14058
- var track = _p.value;
14059
- try {
14060
- for (var _q = (e_6 = void 0, __values$1(track.getClips())), _r = _q.next(); !_r.done; _r = _q.next()) {
14061
- var clip = _r.value;
14062
- clip.playable.onPlayablePlay();
14063
- }
14064
- }
14065
- catch (e_6_1) { e_6 = { error: e_6_1 }; }
14066
- finally {
14067
- try {
14068
- if (_r && !_r.done && (_d = _q.return)) _d.call(_q);
14069
- }
14070
- finally { if (e_6) throw e_6.error; }
14071
- }
14072
- }
14073
- }
14074
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
14075
- finally {
14076
- try {
14077
- if (_p && !_p.done && (_c = _o.return)) _c.call(_o);
14078
- }
14079
- finally { if (e_5) throw e_5.error; }
14024
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
14080
14025
  }
14026
+ finally { if (e_2) throw e_2.error; }
14081
14027
  }
14082
- // 判断动画是否结束
14083
- var ended;
14084
- if (VFXItem.isParticle(this.item)) {
14085
- ended = this.item.isEnded(now) && this.item.content.destoryed;
14028
+ };
14029
+ Track.prototype.addClip = function (clip) {
14030
+ clip.playable.bindingItem = this.bindingItem;
14031
+ clip.id = (this.clipSeed++).toString();
14032
+ this.clips.push(clip);
14033
+ };
14034
+ return Track;
14035
+ }());
14036
+ /**
14037
+ * @since 2.0.0
14038
+ * @internal
14039
+ */
14040
+ var TimelineClip = /** @class */ (function () {
14041
+ function TimelineClip() {
14042
+ this.start = 0;
14043
+ this.duration = 0;
14044
+ }
14045
+ return TimelineClip;
14046
+ }());
14047
+
14048
+ var AnimationStream = /** @class */ (function () {
14049
+ function AnimationStream(playable) {
14050
+ this.curveValues = {};
14051
+ this.playable = playable;
14052
+ }
14053
+ AnimationStream.prototype.setCurveValue = function (componentType, propertyName, value) {
14054
+ if (!this.findCurveValue(componentType, propertyName)) {
14055
+ this.curveValues[componentType + propertyName] = { componentType: componentType, propertyName: propertyName, value: value };
14086
14056
  }
14087
14057
  else {
14088
- ended = this.item.isEnded(now);
14058
+ this.curveValues[componentType + propertyName].value = value;
14089
14059
  }
14090
- if (ended) {
14091
- var endBehavior = this.item.endBehavior;
14092
- if (!this.item.ended) {
14093
- this.item.ended = true;
14094
- this.item.onEnd();
14095
- if (endBehavior === END_BEHAVIOR_DESTROY$1) {
14096
- try {
14097
- for (var _s = __values$1(this.tracks), _t = _s.next(); !_t.done; _t = _s.next()) {
14098
- var track = _t.value;
14099
- try {
14100
- for (var _u = (e_8 = void 0, __values$1(track.getClips())), _v = _u.next(); !_v.done; _v = _u.next()) {
14101
- var clip = _v.value;
14102
- clip.playable.onPlayableDestroy();
14103
- }
14104
- }
14105
- catch (e_8_1) { e_8 = { error: e_8_1 }; }
14106
- finally {
14107
- try {
14108
- if (_v && !_v.done && (_f = _u.return)) _f.call(_u);
14109
- }
14110
- finally { if (e_8) throw e_8.error; }
14111
- }
14112
- }
14113
- }
14114
- catch (e_7_1) { e_7 = { error: e_7_1 }; }
14115
- finally {
14116
- try {
14117
- if (_t && !_t.done && (_e = _s.return)) _e.call(_s);
14118
- }
14119
- finally { if (e_7) throw e_7.error; }
14120
- }
14121
- this.item.delaying = true;
14122
- if (!this.item.reusable && !this.reusable) {
14123
- this.item.dispose();
14124
- return;
14125
- }
14126
- }
14127
- }
14060
+ return this.curveValues[componentType + propertyName];
14061
+ };
14062
+ AnimationStream.prototype.findCurveValue = function (componentType, propertyName) {
14063
+ return this.curveValues[componentType + propertyName];
14064
+ };
14065
+ AnimationStream.prototype.getInputStream = function (index) {
14066
+ var inputPlayable = this.playable.getInput(index);
14067
+ if (inputPlayable instanceof AnimationPlayable) {
14068
+ return inputPlayable.animationStream;
14128
14069
  }
14129
- // TODO: [1.31] @茂安 验证 https://github.com/galacean/effects-runtime/commits/main/packages/effects-core/src/vfx-item.ts
14130
- // 在生命周期内更新动画
14131
- if (!this.item.delaying) {
14132
- var lifetime = this.time / this.item.duration;
14133
- this.item.lifetime = lifetime;
14134
- try {
14135
- for (var _w = __values$1(this.tracks), _x = _w.next(); !_x.done; _x = _w.next()) {
14136
- var track = _x.value;
14070
+ };
14071
+ return AnimationStream;
14072
+ }());
14073
+
14074
+ var AnimationPlayable = /** @class */ (function (_super) {
14075
+ __extends(AnimationPlayable, _super);
14076
+ function AnimationPlayable() {
14077
+ var _this = _super.call(this) || this;
14078
+ _this.animationStream = new AnimationStream(_this);
14079
+ return _this;
14080
+ }
14081
+ return AnimationPlayable;
14082
+ }(Playable));
14083
+
14084
+ var tempRot$1 = new Euler();
14085
+ var tempSize$1 = new Vector3(1, 1, 1);
14086
+ var tempPos = new Vector3();
14087
+ /**
14088
+ * @since 2.0.0
14089
+ * @internal
14090
+ */
14091
+ var AnimationClipPlayable = /** @class */ (function (_super) {
14092
+ __extends(AnimationClipPlayable, _super);
14093
+ function AnimationClipPlayable() {
14094
+ return _super !== null && _super.apply(this, arguments) || this;
14095
+ }
14096
+ AnimationClipPlayable.prototype.processFrame = function (dt) {
14097
+ if (this.bindingItem.composition) {
14098
+ this.sampleAnimation();
14099
+ }
14100
+ };
14101
+ /**
14102
+ * 应用时间轴K帧数据到对象
14103
+ */
14104
+ AnimationClipPlayable.prototype.sampleAnimation = function () {
14105
+ var _this = this;
14106
+ var duration = this.bindingItem.duration;
14107
+ var life = this.time / duration;
14108
+ life = life < 0 ? 0 : (life > 1 ? 1 : life);
14109
+ if (this.sizeXOverLifetime) {
14110
+ tempSize$1.x = this.sizeXOverLifetime.getValue(life);
14111
+ if (this.sizeSeparateAxes) {
14112
+ tempSize$1.y = this.sizeYOverLifetime.getValue(life);
14113
+ tempSize$1.z = this.sizeZOverLifetime.getValue(life);
14114
+ }
14115
+ else {
14116
+ tempSize$1.z = tempSize$1.y = tempSize$1.x;
14117
+ }
14118
+ var startSize = this.originalTransform.scale;
14119
+ this.bindingItem.transform.setScale(tempSize$1.x * startSize.x, tempSize$1.y * startSize.y, tempSize$1.z * startSize.z);
14120
+ // this.animationStream.setCurveValue('transform', 'scale.x', tempSize.x * startSize.x);
14121
+ // this.animationStream.setCurveValue('transform', 'scale.y', tempSize.y * startSize.y);
14122
+ // this.animationStream.setCurveValue('transform', 'scale.z', tempSize.z * startSize.z);
14123
+ }
14124
+ if (this.rotationOverLifetime) {
14125
+ var func = function (v) { return _this.rotationOverLifetime.asRotation ? v.getValue(life) : v.getIntegrateValue(0, life, duration); };
14126
+ var incZ = func(this.rotationOverLifetime.z);
14127
+ var separateAxes = this.rotationOverLifetime.separateAxes;
14128
+ tempRot$1.x = separateAxes ? func(this.rotationOverLifetime.x) : 0;
14129
+ tempRot$1.y = separateAxes ? func(this.rotationOverLifetime.y) : 0;
14130
+ tempRot$1.z = incZ;
14131
+ var rot = tempRot$1.addEulers(this.originalTransform.rotation, tempRot$1);
14132
+ this.bindingItem.transform.setRotation(rot.x, rot.y, rot.z);
14133
+ // this.animationStream.setCurveValue('transform', 'rotation.x', rot.x);
14134
+ // this.animationStream.setCurveValue('transform', 'rotation.y', rot.y);
14135
+ // this.animationStream.setCurveValue('transform', 'rotation.z', rot.z);
14136
+ }
14137
+ if (this.positionOverLifetime) {
14138
+ var pos = tempPos;
14139
+ calculateTranslation(pos, this, this.gravity, this.time, duration, this.originalTransform.position, this.velocity);
14140
+ if (this.originalTransform.path) {
14141
+ pos.add(this.originalTransform.path.getValue(life));
14142
+ }
14143
+ this.bindingItem.transform.setPosition(pos.x, pos.y, pos.z);
14144
+ // this.animationStream.setCurveValue('transform', 'position.x', pos.x);
14145
+ // this.animationStream.setCurveValue('transform', 'position.y', pos.y);
14146
+ // this.animationStream.setCurveValue('transform', 'position.z', pos.z);
14147
+ }
14148
+ };
14149
+ AnimationClipPlayable.prototype.fromData = function (data) {
14150
+ var _a;
14151
+ var scale = this.bindingItem.transform.scale;
14152
+ this.originalTransform = {
14153
+ position: this.bindingItem.transform.position.clone(),
14154
+ rotation: this.bindingItem.transform.getRotation().clone(),
14155
+ // TODO 编辑器 scale 没有z轴控制
14156
+ scale: new Vector3(scale.x, scale.y, scale.x),
14157
+ };
14158
+ var positionOverLifetime = data.positionOverLifetime;
14159
+ var rotationOverLifetime = data.rotationOverLifetime;
14160
+ var sizeOverLifetime = data.sizeOverLifetime;
14161
+ // TODO: 没有 K 帧数据的不需要传 positionOverLifetime 空对象
14162
+ if (positionOverLifetime && Object.keys(positionOverLifetime).length !== 0) {
14163
+ this.positionOverLifetime = positionOverLifetime;
14164
+ if (positionOverLifetime.path) {
14165
+ this.originalTransform.path = createValueGetter(positionOverLifetime.path);
14166
+ }
14167
+ var linearVelEnable = positionOverLifetime.linearX || positionOverLifetime.linearY || positionOverLifetime.linearZ;
14168
+ if (linearVelEnable) {
14169
+ this.linearVelOverLifetime = {
14170
+ x: positionOverLifetime.linearX && createValueGetter(positionOverLifetime.linearX),
14171
+ y: positionOverLifetime.linearY && createValueGetter(positionOverLifetime.linearY),
14172
+ z: positionOverLifetime.linearZ && createValueGetter(positionOverLifetime.linearZ),
14173
+ asMovement: positionOverLifetime.asMovement,
14174
+ enabled: !!linearVelEnable,
14175
+ };
14176
+ }
14177
+ var orbitalVelEnable = positionOverLifetime.orbitalX || positionOverLifetime.orbitalY || positionOverLifetime.orbitalZ;
14178
+ if (orbitalVelEnable) {
14179
+ this.orbitalVelOverLifetime = {
14180
+ x: positionOverLifetime.orbitalX && createValueGetter(positionOverLifetime.orbitalX),
14181
+ y: positionOverLifetime.orbitalY && createValueGetter(positionOverLifetime.orbitalY),
14182
+ z: positionOverLifetime.orbitalZ && createValueGetter(positionOverLifetime.orbitalZ),
14183
+ center: ensureVec3(positionOverLifetime.orbCenter),
14184
+ asRotation: positionOverLifetime.asRotation,
14185
+ enabled: !!orbitalVelEnable,
14186
+ };
14187
+ }
14188
+ this.speedOverLifetime = positionOverLifetime.speedOverLifetime && createValueGetter(positionOverLifetime.speedOverLifetime);
14189
+ }
14190
+ if (sizeOverLifetime) {
14191
+ if (sizeOverLifetime.separateAxes) {
14192
+ this.sizeSeparateAxes = true;
14193
+ this.sizeXOverLifetime = createValueGetter(sizeOverLifetime.x || 1);
14194
+ this.sizeYOverLifetime = createValueGetter(sizeOverLifetime.y || 1);
14195
+ this.sizeZOverLifetime = createValueGetter(sizeOverLifetime.z || 1);
14196
+ }
14197
+ else {
14198
+ this.sizeXOverLifetime = createValueGetter(sizeOverLifetime.size || 1);
14199
+ }
14200
+ }
14201
+ if (rotationOverLifetime) {
14202
+ this.rotationOverLifetime = {
14203
+ asRotation: rotationOverLifetime.asRotation,
14204
+ separateAxes: rotationOverLifetime.separateAxes,
14205
+ z: createValueGetter(rotationOverLifetime.z || 0),
14206
+ };
14207
+ if (rotationOverLifetime.separateAxes) {
14208
+ var rotLt = this.rotationOverLifetime;
14209
+ rotLt.x = createValueGetter(rotationOverLifetime.x || 0);
14210
+ rotLt.y = createValueGetter(rotationOverLifetime.y || 0);
14211
+ }
14212
+ }
14213
+ this.gravity = Vector3.fromArray((positionOverLifetime === null || positionOverLifetime === void 0 ? void 0 : positionOverLifetime.gravity) || []);
14214
+ this.gravityModifier = createValueGetter((_a = positionOverLifetime === null || positionOverLifetime === void 0 ? void 0 : positionOverLifetime.gravityOverLifetime) !== null && _a !== void 0 ? _a : 0);
14215
+ this.direction = (positionOverLifetime === null || positionOverLifetime === void 0 ? void 0 : positionOverLifetime.direction) ? Vector3.fromArray(positionOverLifetime.direction).normalize() : new Vector3();
14216
+ this.startSpeed = (positionOverLifetime === null || positionOverLifetime === void 0 ? void 0 : positionOverLifetime.startSpeed) || 0;
14217
+ this.velocity = this.direction.clone();
14218
+ this.velocity.multiply(this.startSpeed);
14219
+ };
14220
+ return AnimationClipPlayable;
14221
+ }(AnimationPlayable));
14222
+ /**
14223
+ * @since 2.0.0
14224
+ * @internal
14225
+ */
14226
+ var ActivationClipPlayable = /** @class */ (function (_super) {
14227
+ __extends(ActivationClipPlayable, _super);
14228
+ function ActivationClipPlayable() {
14229
+ return _super !== null && _super.apply(this, arguments) || this;
14230
+ }
14231
+ ActivationClipPlayable.prototype.onGraphStart = function () {
14232
+ this.bindingItem.transform.setValid(false);
14233
+ this.hideRendererComponents();
14234
+ };
14235
+ ActivationClipPlayable.prototype.onPlayablePlay = function () {
14236
+ this.bindingItem.transform.setValid(true);
14237
+ this.showRendererComponents();
14238
+ };
14239
+ ActivationClipPlayable.prototype.onPlayableDestroy = function () {
14240
+ this.bindingItem.transform.setValid(false);
14241
+ this.hideRendererComponents();
14242
+ };
14243
+ ActivationClipPlayable.prototype.hideRendererComponents = function () {
14244
+ var e_1, _a;
14245
+ try {
14246
+ for (var _b = __values$1(this.bindingItem.rendererComponents), _c = _b.next(); !_c.done; _c = _b.next()) {
14247
+ var rendererComponent = _c.value;
14248
+ if (rendererComponent.enabled) {
14249
+ rendererComponent.enabled = false;
14250
+ }
14251
+ }
14252
+ }
14253
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
14254
+ finally {
14255
+ try {
14256
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
14257
+ }
14258
+ finally { if (e_1) throw e_1.error; }
14259
+ }
14260
+ };
14261
+ ActivationClipPlayable.prototype.showRendererComponents = function () {
14262
+ var e_2, _a;
14263
+ try {
14264
+ for (var _b = __values$1(this.bindingItem.rendererComponents), _c = _b.next(); !_c.done; _c = _b.next()) {
14265
+ var rendererComponent = _c.value;
14266
+ if (!rendererComponent.enabled) {
14267
+ rendererComponent.enabled = true;
14268
+ }
14269
+ }
14270
+ }
14271
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
14272
+ finally {
14273
+ try {
14274
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
14275
+ }
14276
+ finally { if (e_2) throw e_2.error; }
14277
+ }
14278
+ };
14279
+ return ActivationClipPlayable;
14280
+ }(Playable));
14281
+
14282
+ /**
14283
+ * @since 2.0.0
14284
+ * @internal
14285
+ */
14286
+ var TimelineComponent = /** @class */ (function (_super) {
14287
+ __extends(TimelineComponent, _super);
14288
+ function TimelineComponent(engine) {
14289
+ var _this = _super.call(this, engine) || this;
14290
+ _this.reusable = false;
14291
+ _this.timelineStarted = false;
14292
+ _this.playableGraph = new PlayableGraph();
14293
+ /**
14294
+ * 元素动画已经播放的时间
14295
+ */
14296
+ _this.time = 0;
14297
+ _this.tracks = [];
14298
+ _this.trackSeed = 0;
14299
+ return _this;
14300
+ }
14301
+ TimelineComponent.prototype.start = function () {
14302
+ var e_1, _a, e_2, _b;
14303
+ try {
14304
+ // TODO TimelineClip 需要传入 start 和 duration 数据
14305
+ for (var _c = __values$1(this.tracks), _d = _c.next(); !_d.done; _d = _c.next()) {
14306
+ var track = _d.value;
14307
+ try {
14308
+ for (var _e = (e_2 = void 0, __values$1(track.getClips())), _f = _e.next(); !_f.done; _f = _e.next()) {
14309
+ var clip = _f.value;
14310
+ clip.start = this.item.start;
14311
+ clip.duration = this.item.duration;
14312
+ }
14313
+ }
14314
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
14315
+ finally {
14316
+ try {
14317
+ if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
14318
+ }
14319
+ finally { if (e_2) throw e_2.error; }
14320
+ }
14321
+ }
14322
+ }
14323
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
14324
+ finally {
14325
+ try {
14326
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
14327
+ }
14328
+ finally { if (e_1) throw e_1.error; }
14329
+ }
14330
+ this.compileTracks(this.playableGraph);
14331
+ };
14332
+ // TODO: [1.31] @十弦 vfx-item 下 onUpdate 的改动验证
14333
+ TimelineComponent.prototype.update = function (dt) {
14334
+ 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;
14335
+ if (this.item.stopped || !this.item.composition) {
14336
+ return;
14337
+ }
14338
+ if (!this.timelineStarted) {
14339
+ try {
14340
+ for (var _j = __values$1(this.tracks), _k = _j.next(); !_k.done; _k = _j.next()) {
14341
+ var track = _k.value;
14342
+ try {
14343
+ for (var _l = (e_4 = void 0, __values$1(track.getClips())), _m = _l.next(); !_m.done; _m = _l.next()) {
14344
+ var clip = _m.value;
14345
+ clip.playable.onGraphStart();
14346
+ }
14347
+ }
14348
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
14349
+ finally {
14350
+ try {
14351
+ if (_m && !_m.done && (_b = _l.return)) _b.call(_l);
14352
+ }
14353
+ finally { if (e_4) throw e_4.error; }
14354
+ }
14355
+ }
14356
+ }
14357
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
14358
+ finally {
14359
+ try {
14360
+ if (_k && !_k.done && (_a = _j.return)) _a.call(_j);
14361
+ }
14362
+ finally { if (e_3) throw e_3.error; }
14363
+ }
14364
+ this.timelineStarted = true;
14365
+ }
14366
+ var now = this.time;
14367
+ // 判断动画是否开始
14368
+ if (this.item.delaying && now >= 0 && now <= this.item.duration) {
14369
+ this.item.delaying = false;
14370
+ try {
14371
+ for (var _o = __values$1(this.tracks), _p = _o.next(); !_p.done; _p = _o.next()) {
14372
+ var track = _p.value;
14373
+ try {
14374
+ for (var _q = (e_6 = void 0, __values$1(track.getClips())), _r = _q.next(); !_r.done; _r = _q.next()) {
14375
+ var clip = _r.value;
14376
+ clip.playable.onPlayablePlay();
14377
+ }
14378
+ }
14379
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
14380
+ finally {
14381
+ try {
14382
+ if (_r && !_r.done && (_d = _q.return)) _d.call(_q);
14383
+ }
14384
+ finally { if (e_6) throw e_6.error; }
14385
+ }
14386
+ }
14387
+ }
14388
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
14389
+ finally {
14390
+ try {
14391
+ if (_p && !_p.done && (_c = _o.return)) _c.call(_o);
14392
+ }
14393
+ finally { if (e_5) throw e_5.error; }
14394
+ }
14395
+ }
14396
+ // 判断动画是否结束
14397
+ var ended;
14398
+ if (VFXItem.isParticle(this.item)) {
14399
+ ended = this.item.isEnded(now) && this.item.content.destoryed;
14400
+ }
14401
+ else {
14402
+ ended = this.item.isEnded(now);
14403
+ }
14404
+ if (ended) {
14405
+ var endBehavior = this.item.endBehavior;
14406
+ if (!this.item.ended) {
14407
+ this.item.ended = true;
14408
+ this.item.onEnd();
14409
+ if (endBehavior === END_BEHAVIOR_DESTROY$1) {
14410
+ try {
14411
+ for (var _s = __values$1(this.tracks), _t = _s.next(); !_t.done; _t = _s.next()) {
14412
+ var track = _t.value;
14413
+ try {
14414
+ for (var _u = (e_8 = void 0, __values$1(track.getClips())), _v = _u.next(); !_v.done; _v = _u.next()) {
14415
+ var clip = _v.value;
14416
+ clip.playable.onPlayableDestroy();
14417
+ }
14418
+ }
14419
+ catch (e_8_1) { e_8 = { error: e_8_1 }; }
14420
+ finally {
14421
+ try {
14422
+ if (_v && !_v.done && (_f = _u.return)) _f.call(_u);
14423
+ }
14424
+ finally { if (e_8) throw e_8.error; }
14425
+ }
14426
+ }
14427
+ }
14428
+ catch (e_7_1) { e_7 = { error: e_7_1 }; }
14429
+ finally {
14430
+ try {
14431
+ if (_t && !_t.done && (_e = _s.return)) _e.call(_s);
14432
+ }
14433
+ finally { if (e_7) throw e_7.error; }
14434
+ }
14435
+ this.item.delaying = true;
14436
+ if (!this.item.reusable && !this.reusable) {
14437
+ this.item.dispose();
14438
+ return;
14439
+ }
14440
+ }
14441
+ }
14442
+ }
14443
+ // TODO: [1.31] @茂安 验证 https://github.com/galacean/effects-runtime/commits/main/packages/effects-core/src/vfx-item.ts
14444
+ // 在生命周期内更新动画
14445
+ if (!this.item.delaying) {
14446
+ var lifetime = this.time / this.item.duration;
14447
+ this.item.lifetime = lifetime;
14448
+ try {
14449
+ for (var _w = __values$1(this.tracks), _x = _w.next(); !_x.done; _x = _w.next()) {
14450
+ var track = _x.value;
14137
14451
  try {
14138
14452
  for (var _y = (e_10 = void 0, __values$1(track.getClips())), _z = _y.next(); !_z.done; _z = _y.next()) {
14139
14453
  var clip = _z.value;
@@ -14209,135 +14523,53 @@ var TimelineComponent = /** @class */ (function (_super) {
14209
14523
  }
14210
14524
  };
14211
14525
  TimelineComponent.prototype.rebuildGraph = function () {
14212
- this.playableGraph = new PlayableGraph();
14213
- this.compileTracks(this.playableGraph);
14214
- };
14215
- TimelineComponent.prototype.compileTracks = function (graph) {
14216
- var e_12, _a;
14217
- try {
14218
- for (var _b = __values$1(this.tracks), _c = _b.next(); !_c.done; _c = _b.next()) {
14219
- var track = _c.value;
14220
- var trackMixPlayable = track.createPlayebleTree();
14221
- var trackOutput = track.createOutput();
14222
- graph.addOutput(trackOutput);
14223
- trackOutput.setSourcePlayeble(trackMixPlayable);
14224
- }
14225
- }
14226
- catch (e_12_1) { e_12 = { error: e_12_1 }; }
14227
- finally {
14228
- try {
14229
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
14230
- }
14231
- finally { if (e_12) throw e_12.error; }
14232
- }
14233
- };
14234
- TimelineComponent.prototype.fromData = function (data) {
14235
- _super.prototype.fromData.call(this, data);
14236
- this.options = {
14237
- start: this.item.start,
14238
- duration: this.item.duration,
14239
- looping: this.item.endBehavior === END_BEHAVIOR_RESTART$1,
14240
- endBehavior: this.item.endBehavior || END_BEHAVIOR_DESTROY$1,
14241
- };
14242
- this.id = this.item.id;
14243
- this.name = this.item.name;
14244
- };
14245
- TimelineComponent.prototype.toData = function () {
14246
- _super.prototype.toData.call(this);
14247
- };
14248
- __decorate([
14249
- serialize()
14250
- ], TimelineComponent.prototype, "time", void 0);
14251
- return TimelineComponent;
14252
- }(ItemBehaviour));
14253
-
14254
- /**
14255
- * @since 2.0.0
14256
- * @internal
14257
- */
14258
- var Track = /** @class */ (function () {
14259
- function Track() {
14260
- this.clips = [];
14261
- this.clipSeed = 0;
14262
- }
14263
- Track.prototype.createOutput = function () {
14264
- var output = new PlayableOutput();
14265
- return output;
14266
- };
14267
- /**
14268
- * 重写该方法以创建自定义混合器
14269
- */
14270
- Track.prototype.createMixerPlayable = function () {
14271
- return new Playable();
14272
- };
14273
- Track.prototype.createPlayebleTree = function () {
14274
- var e_1, _a;
14275
- var defaultMixPlayable = this.createMixerPlayable();
14276
- try {
14277
- for (var _b = __values$1(this.clips), _c = _b.next(); !_c.done; _c = _b.next()) {
14278
- var clip = _c.value;
14279
- defaultMixPlayable.connect(clip.playable);
14280
- }
14281
- }
14282
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
14283
- finally {
14284
- try {
14285
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
14286
- }
14287
- finally { if (e_1) throw e_1.error; }
14288
- }
14289
- return defaultMixPlayable;
14290
- };
14291
- Track.prototype.createClip = function (classConstructor, name) {
14292
- var newClip = new TimelineClip();
14293
- newClip.playable = new classConstructor();
14294
- newClip.name = name ? name : 'TimelineClip' + newClip.id;
14295
- this.addClip(newClip);
14296
- return newClip;
14297
- };
14298
- Track.prototype.getClips = function () {
14299
- return this.clips;
14526
+ this.playableGraph = new PlayableGraph();
14527
+ this.compileTracks(this.playableGraph);
14300
14528
  };
14301
- Track.prototype.findClip = function (name) {
14302
- var e_2, _a;
14529
+ TimelineComponent.prototype.compileTracks = function (graph) {
14530
+ var e_12, _a;
14303
14531
  try {
14304
- for (var _b = __values$1(this.clips), _c = _b.next(); !_c.done; _c = _b.next()) {
14305
- var clip = _c.value;
14306
- if (clip.name === name) {
14307
- return clip;
14308
- }
14532
+ for (var _b = __values$1(this.tracks), _c = _b.next(); !_c.done; _c = _b.next()) {
14533
+ var track = _c.value;
14534
+ var trackMixPlayable = track.createPlayebleTree();
14535
+ var trackOutput = track.createOutput();
14536
+ graph.addOutput(trackOutput);
14537
+ trackOutput.setSourcePlayeble(trackMixPlayable);
14309
14538
  }
14310
14539
  }
14311
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
14540
+ catch (e_12_1) { e_12 = { error: e_12_1 }; }
14312
14541
  finally {
14313
14542
  try {
14314
14543
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
14315
14544
  }
14316
- finally { if (e_2) throw e_2.error; }
14545
+ finally { if (e_12) throw e_12.error; }
14317
14546
  }
14318
14547
  };
14319
- Track.prototype.addClip = function (clip) {
14320
- clip.playable.bindingItem = this.bindingItem;
14321
- clip.id = (this.clipSeed++).toString();
14322
- this.clips.push(clip);
14548
+ TimelineComponent.prototype.fromData = function (data) {
14549
+ _super.prototype.fromData.call(this, data);
14550
+ this.options = {
14551
+ start: this.item.start,
14552
+ duration: this.item.duration,
14553
+ looping: this.item.endBehavior === END_BEHAVIOR_RESTART$1,
14554
+ endBehavior: this.item.endBehavior || END_BEHAVIOR_DESTROY$1,
14555
+ };
14556
+ this.id = this.item.id;
14557
+ this.name = this.item.name;
14558
+ var activationTrack = this.createTrack(Track, 'ActivationTrack');
14559
+ activationTrack.createClip(ActivationClipPlayable, 'ActivationTimelineClip');
14323
14560
  };
14324
- return Track;
14325
- }());
14326
- /**
14327
- * @since 2.0.0
14328
- * @internal
14329
- */
14330
- var TimelineClip = /** @class */ (function () {
14331
- function TimelineClip() {
14332
- this.start = 0;
14333
- this.duration = 0;
14334
- }
14335
- return TimelineClip;
14336
- }());
14561
+ TimelineComponent.prototype.toData = function () {
14562
+ _super.prototype.toData.call(this);
14563
+ };
14564
+ __decorate([
14565
+ serialize()
14566
+ ], TimelineComponent.prototype, "time", void 0);
14567
+ return TimelineComponent;
14568
+ }(ItemBehaviour));
14337
14569
 
14338
14570
  var singleSplits = [[0, 0, 1, 1, undefined]];
14339
14571
  var tempColor = [1, 1, 1, 1];
14340
- var seed$4 = 0;
14572
+ var seed$3 = 0;
14341
14573
  var SpriteColorPlayable = /** @class */ (function (_super) {
14342
14574
  __extends(SpriteColorPlayable, _super);
14343
14575
  function SpriteColorPlayable() {
@@ -14733,7 +14965,7 @@ var SpriteComponent = /** @class */ (function (_super) {
14733
14965
  this.worldMatrix = Matrix4.fromIdentity();
14734
14966
  this.material = material;
14735
14967
  this.geometry = geometry;
14736
- this.name = 'MSprite' + seed$4++;
14968
+ this.name = 'MSprite' + seed$3++;
14737
14969
  var startColor = options.startColor || [1, 1, 1, 1];
14738
14970
  this.material.setVector4('_Color', new Vector4().setFromArray(startColor));
14739
14971
  this.material.setVector4('_TexOffset', new Vector4().setFromArray([0, 0, 1, 1]));
@@ -17738,7 +17970,7 @@ var ParticleSystem = /** @class */ (function (_super) {
17738
17970
  sprite[1] = tsa.animationDuration.getValue(lifetime);
17739
17971
  sprite[2] = tsa.cycles.getValue(lifetime);
17740
17972
  }
17741
- var rot = tempRot$1;
17973
+ var rot = tempRot;
17742
17974
  if (options.start3DRotation) {
17743
17975
  // @ts-expect-error
17744
17976
  rot.set(options.startRotationX.getValue(lifetime), options.startRotationY.getValue(lifetime), options.startRotationZ.getValue(lifetime));
@@ -17754,7 +17986,7 @@ var ParticleSystem = /** @class */ (function (_super) {
17754
17986
  if (color.length === 3) {
17755
17987
  color[3] = 1;
17756
17988
  }
17757
- var size = tempSize$1;
17989
+ var size = tempSize;
17758
17990
  if (options.start3DSize) {
17759
17991
  size.x = options.startSizeX.getValue(lifetime);
17760
17992
  size.y = options.startSizeY.getValue(lifetime);
@@ -17916,7 +18148,8 @@ var ParticleSystem = /** @class */ (function (_super) {
17916
18148
  separateAxes: false,
17917
18149
  x: createValueGetter(('size' in sizeOverLifetime ? sizeOverLifetime.size : sizeOverLifetime.x) || 1),
17918
18150
  };
17919
- var anchor = Vector2.fromArray(convertAnchor(renderer.anchor, renderer.particleOrigin));
18151
+ renderer.anchor = renderer.anchor || [0, 0];
18152
+ var anchor = Vector2.fromArray(renderer.anchor);
17920
18153
  this.options = {
17921
18154
  particleFollowParent: !!options.particleFollowParent,
17922
18155
  startLifetime: createValueGetter(options.startLifetime),
@@ -18097,8 +18330,8 @@ var ParticleSystem = /** @class */ (function (_super) {
18097
18330
  }(Component));
18098
18331
  // array performance better for small memory than Float32Array
18099
18332
  var tempDir = new Vector3();
18100
- var tempSize$1 = new Vector2();
18101
- var tempRot$1 = new Euler();
18333
+ var tempSize = new Vector2();
18334
+ var tempRot = new Euler();
18102
18335
  var tmpDirX = new Vector3();
18103
18336
  var tmpDirY = new Vector3();
18104
18337
  var tempVec3 = new Vector3();
@@ -18113,299 +18346,65 @@ function getBurstOffsets(burstOffsets) {
18113
18346
  var index = isArr ? arr[0] : arr.index;
18114
18347
  var offsets = ret[index];
18115
18348
  if (!offsets) {
18116
- offsets = ret[index] = [];
18117
- }
18118
- if (isArr) {
18119
- offsets.push(arr.slice(1, 4));
18120
- }
18121
- else {
18122
- offsets.push([+arr.x, +arr.y, +arr.z]);
18123
- }
18124
- });
18125
- }
18126
- return ret;
18127
- }
18128
- function randomArrItem(arr, keepArr) {
18129
- var index = Math.floor(Math.random() * arr.length);
18130
- var item = arr[index];
18131
- if (!keepArr) {
18132
- arr.splice(index, 1);
18133
- }
18134
- return item;
18135
- }
18136
-
18137
- /**
18138
- * @since 2.0.0
18139
- * @internal
18140
- */
18141
- var ParticleBehaviourPlayable = /** @class */ (function (_super) {
18142
- __extends(ParticleBehaviourPlayable, _super);
18143
- function ParticleBehaviourPlayable() {
18144
- return _super !== null && _super.apply(this, arguments) || this;
18145
- }
18146
- ParticleBehaviourPlayable.prototype.onPlayablePlay = function () {
18147
- this.particleSystem = this.bindingItem.getComponent(ParticleSystem);
18148
- if (this.particleSystem) {
18149
- this.particleSystem.name = this.bindingItem.name;
18150
- this.particleSystem.start();
18151
- this.particleSystem.initEmitterTransform();
18152
- }
18153
- };
18154
- ParticleBehaviourPlayable.prototype.processFrame = function (dt) {
18155
- var particleSystem = this.particleSystem;
18156
- if (particleSystem) {
18157
- this.bindingItem.parent;
18158
- // TODO: [1.31] @十弦 验证 https://github.com/galacean/effects-runtime/commit/3e7d73d37b7d98c2a25e4544e80e928b17801ccd#diff-fae062f28caf3771cfedd3a20dc22f9749bd054c7541bf2fd50a9a5e413153d4
18159
- // particleSystem.setParentTransform(parentItem.transform);
18160
- particleSystem.setVisible(true);
18161
- particleSystem.onUpdate(dt);
18162
- }
18163
- };
18164
- return ParticleBehaviourPlayable;
18165
- }(Playable));
18166
-
18167
- var CalculateLoader = /** @class */ (function (_super) {
18168
- __extends(CalculateLoader, _super);
18169
- function CalculateLoader() {
18170
- return _super !== null && _super.apply(this, arguments) || this;
18171
- }
18172
- return CalculateLoader;
18173
- }(AbstractPlugin));
18174
-
18175
- var AnimationStream = /** @class */ (function () {
18176
- function AnimationStream(playable) {
18177
- this.curveValues = {};
18178
- this.playable = playable;
18179
- }
18180
- AnimationStream.prototype.setCurveValue = function (componentType, propertyName, value) {
18181
- if (!this.findCurveValue(componentType, propertyName)) {
18182
- this.curveValues[componentType + propertyName] = { componentType: componentType, propertyName: propertyName, value: value };
18183
- }
18184
- else {
18185
- this.curveValues[componentType + propertyName].value = value;
18186
- }
18187
- return this.curveValues[componentType + propertyName];
18188
- };
18189
- AnimationStream.prototype.findCurveValue = function (componentType, propertyName) {
18190
- return this.curveValues[componentType + propertyName];
18191
- };
18192
- AnimationStream.prototype.getInputStream = function (index) {
18193
- var inputPlayable = this.playable.getInput(index);
18194
- if (inputPlayable instanceof AnimationPlayable) {
18195
- return inputPlayable.animationStream;
18196
- }
18197
- };
18198
- return AnimationStream;
18199
- }());
18200
-
18201
- var AnimationPlayable = /** @class */ (function (_super) {
18202
- __extends(AnimationPlayable, _super);
18203
- function AnimationPlayable() {
18204
- var _this = _super.call(this) || this;
18205
- _this.animationStream = new AnimationStream(_this);
18206
- return _this;
18207
- }
18208
- return AnimationPlayable;
18209
- }(Playable));
18210
-
18211
- var tempRot = new Euler();
18212
- var tempSize = new Vector3(1, 1, 1);
18213
- var tempPos = new Vector3();
18214
- /**
18215
- * @since 2.0.0
18216
- * @internal
18217
- */
18218
- var AnimationClipPlayable = /** @class */ (function (_super) {
18219
- __extends(AnimationClipPlayable, _super);
18220
- function AnimationClipPlayable() {
18221
- return _super !== null && _super.apply(this, arguments) || this;
18222
- }
18223
- AnimationClipPlayable.prototype.processFrame = function (dt) {
18224
- if (this.bindingItem.composition) {
18225
- this.sampleAnimation();
18226
- }
18227
- };
18228
- /**
18229
- * 应用时间轴K帧数据到对象
18230
- */
18231
- AnimationClipPlayable.prototype.sampleAnimation = function () {
18232
- var _this = this;
18233
- var duration = this.bindingItem.duration;
18234
- var life = this.time / duration;
18235
- life = life < 0 ? 0 : (life > 1 ? 1 : life);
18236
- if (this.sizeXOverLifetime) {
18237
- tempSize.x = this.sizeXOverLifetime.getValue(life);
18238
- if (this.sizeSeparateAxes) {
18239
- tempSize.y = this.sizeYOverLifetime.getValue(life);
18240
- tempSize.z = this.sizeZOverLifetime.getValue(life);
18241
- }
18242
- else {
18243
- tempSize.z = tempSize.y = tempSize.x;
18244
- }
18245
- var startSize = this.originalTransform.scale;
18246
- this.bindingItem.transform.setScale(tempSize.x * startSize.x, tempSize.y * startSize.y, tempSize.z * startSize.z);
18247
- // this.animationStream.setCurveValue('transform', 'scale.x', tempSize.x * startSize.x);
18248
- // this.animationStream.setCurveValue('transform', 'scale.y', tempSize.y * startSize.y);
18249
- // this.animationStream.setCurveValue('transform', 'scale.z', tempSize.z * startSize.z);
18250
- }
18251
- if (this.rotationOverLifetime) {
18252
- var func = function (v) { return _this.rotationOverLifetime.asRotation ? v.getValue(life) : v.getIntegrateValue(0, life, duration); };
18253
- var incZ = func(this.rotationOverLifetime.z);
18254
- var separateAxes = this.rotationOverLifetime.separateAxes;
18255
- tempRot.x = separateAxes ? func(this.rotationOverLifetime.x) : 0;
18256
- tempRot.y = separateAxes ? func(this.rotationOverLifetime.y) : 0;
18257
- tempRot.z = incZ;
18258
- var rot = tempRot.addEulers(this.originalTransform.rotation, tempRot);
18259
- this.bindingItem.transform.setRotation(rot.x, rot.y, rot.z);
18260
- // this.animationStream.setCurveValue('transform', 'rotation.x', rot.x);
18261
- // this.animationStream.setCurveValue('transform', 'rotation.y', rot.y);
18262
- // this.animationStream.setCurveValue('transform', 'rotation.z', rot.z);
18263
- }
18264
- if (this.positionOverLifetime) {
18265
- var pos = tempPos;
18266
- calculateTranslation(pos, this, this.gravity, this.time, duration, this.originalTransform.position, this.velocity);
18267
- if (this.originalTransform.path) {
18268
- pos.add(this.originalTransform.path.getValue(life));
18269
- }
18270
- this.bindingItem.transform.setPosition(pos.x, pos.y, pos.z);
18271
- // this.animationStream.setCurveValue('transform', 'position.x', pos.x);
18272
- // this.animationStream.setCurveValue('transform', 'position.y', pos.y);
18273
- // this.animationStream.setCurveValue('transform', 'position.z', pos.z);
18274
- }
18275
- };
18276
- AnimationClipPlayable.prototype.fromData = function (data) {
18277
- var _a;
18278
- var scale = this.bindingItem.transform.scale;
18279
- this.originalTransform = {
18280
- position: this.bindingItem.transform.position.clone(),
18281
- rotation: this.bindingItem.transform.getRotation().clone(),
18282
- // TODO 编辑器 scale 没有z轴控制
18283
- scale: new Vector3(scale.x, scale.y, scale.x),
18284
- };
18285
- var positionOverLifetime = data.positionOverLifetime;
18286
- var rotationOverLifetime = data.rotationOverLifetime;
18287
- var sizeOverLifetime = data.sizeOverLifetime;
18288
- // TODO: 没有 K 帧数据的不需要传 positionOverLifetime 空对象
18289
- if (positionOverLifetime && Object.keys(positionOverLifetime).length !== 0) {
18290
- this.positionOverLifetime = positionOverLifetime;
18291
- if (positionOverLifetime.path) {
18292
- this.originalTransform.path = createValueGetter(positionOverLifetime.path);
18293
- }
18294
- var linearVelEnable = positionOverLifetime.linearX || positionOverLifetime.linearY || positionOverLifetime.linearZ;
18295
- if (linearVelEnable) {
18296
- this.linearVelOverLifetime = {
18297
- x: positionOverLifetime.linearX && createValueGetter(positionOverLifetime.linearX),
18298
- y: positionOverLifetime.linearY && createValueGetter(positionOverLifetime.linearY),
18299
- z: positionOverLifetime.linearZ && createValueGetter(positionOverLifetime.linearZ),
18300
- asMovement: positionOverLifetime.asMovement,
18301
- enabled: !!linearVelEnable,
18302
- };
18303
- }
18304
- var orbitalVelEnable = positionOverLifetime.orbitalX || positionOverLifetime.orbitalY || positionOverLifetime.orbitalZ;
18305
- if (orbitalVelEnable) {
18306
- this.orbitalVelOverLifetime = {
18307
- x: positionOverLifetime.orbitalX && createValueGetter(positionOverLifetime.orbitalX),
18308
- y: positionOverLifetime.orbitalY && createValueGetter(positionOverLifetime.orbitalY),
18309
- z: positionOverLifetime.orbitalZ && createValueGetter(positionOverLifetime.orbitalZ),
18310
- center: ensureVec3(positionOverLifetime.orbCenter),
18311
- asRotation: positionOverLifetime.asRotation,
18312
- enabled: !!orbitalVelEnable,
18313
- };
18314
- }
18315
- this.speedOverLifetime = positionOverLifetime.speedOverLifetime && createValueGetter(positionOverLifetime.speedOverLifetime);
18316
- }
18317
- if (sizeOverLifetime) {
18318
- if (sizeOverLifetime.separateAxes) {
18319
- this.sizeSeparateAxes = true;
18320
- this.sizeXOverLifetime = createValueGetter(sizeOverLifetime.x || 1);
18321
- this.sizeYOverLifetime = createValueGetter(sizeOverLifetime.y || 1);
18322
- this.sizeZOverLifetime = createValueGetter(sizeOverLifetime.z || 1);
18349
+ offsets = ret[index] = [];
18323
18350
  }
18324
- else {
18325
- this.sizeXOverLifetime = createValueGetter(sizeOverLifetime.size || 1);
18351
+ if (isArr) {
18352
+ offsets.push(arr.slice(1, 4));
18326
18353
  }
18327
- }
18328
- if (rotationOverLifetime) {
18329
- this.rotationOverLifetime = {
18330
- asRotation: rotationOverLifetime.asRotation,
18331
- separateAxes: rotationOverLifetime.separateAxes,
18332
- z: createValueGetter(rotationOverLifetime.z || 0),
18333
- };
18334
- if (rotationOverLifetime.separateAxes) {
18335
- var rotLt = this.rotationOverLifetime;
18336
- rotLt.x = createValueGetter(rotationOverLifetime.x || 0);
18337
- rotLt.y = createValueGetter(rotationOverLifetime.y || 0);
18354
+ else {
18355
+ offsets.push([+arr.x, +arr.y, +arr.z]);
18338
18356
  }
18339
- }
18340
- this.gravity = Vector3.fromArray((positionOverLifetime === null || positionOverLifetime === void 0 ? void 0 : positionOverLifetime.gravity) || []);
18341
- this.gravityModifier = createValueGetter((_a = positionOverLifetime === null || positionOverLifetime === void 0 ? void 0 : positionOverLifetime.gravityOverLifetime) !== null && _a !== void 0 ? _a : 0);
18342
- this.direction = (positionOverLifetime === null || positionOverLifetime === void 0 ? void 0 : positionOverLifetime.direction) ? Vector3.fromArray(positionOverLifetime.direction).normalize() : new Vector3();
18343
- this.startSpeed = (positionOverLifetime === null || positionOverLifetime === void 0 ? void 0 : positionOverLifetime.startSpeed) || 0;
18344
- this.velocity = this.direction.clone();
18345
- this.velocity.multiply(this.startSpeed);
18346
- };
18347
- return AnimationClipPlayable;
18348
- }(AnimationPlayable));
18357
+ });
18358
+ }
18359
+ return ret;
18360
+ }
18361
+ function randomArrItem(arr, keepArr) {
18362
+ var index = Math.floor(Math.random() * arr.length);
18363
+ var item = arr[index];
18364
+ if (!keepArr) {
18365
+ arr.splice(index, 1);
18366
+ }
18367
+ return item;
18368
+ }
18369
+
18349
18370
  /**
18350
18371
  * @since 2.0.0
18351
18372
  * @internal
18352
18373
  */
18353
- var ActivationClipPlayable = /** @class */ (function (_super) {
18354
- __extends(ActivationClipPlayable, _super);
18355
- function ActivationClipPlayable() {
18374
+ var ParticleBehaviourPlayable = /** @class */ (function (_super) {
18375
+ __extends(ParticleBehaviourPlayable, _super);
18376
+ function ParticleBehaviourPlayable() {
18356
18377
  return _super !== null && _super.apply(this, arguments) || this;
18357
18378
  }
18358
- ActivationClipPlayable.prototype.onGraphStart = function () {
18359
- this.bindingItem.transform.setValid(false);
18360
- this.hideRendererComponents();
18361
- };
18362
- ActivationClipPlayable.prototype.onPlayablePlay = function () {
18363
- this.bindingItem.transform.setValid(true);
18364
- this.showRendererComponents();
18365
- };
18366
- ActivationClipPlayable.prototype.onPlayableDestroy = function () {
18367
- this.bindingItem.transform.setValid(false);
18368
- this.hideRendererComponents();
18369
- };
18370
- ActivationClipPlayable.prototype.hideRendererComponents = function () {
18371
- var e_1, _a;
18372
- try {
18373
- for (var _b = __values$1(this.bindingItem.rendererComponents), _c = _b.next(); !_c.done; _c = _b.next()) {
18374
- var rendererComponent = _c.value;
18375
- if (rendererComponent.enabled) {
18376
- rendererComponent.enabled = false;
18377
- }
18378
- }
18379
- }
18380
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
18381
- finally {
18382
- try {
18383
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
18384
- }
18385
- finally { if (e_1) throw e_1.error; }
18379
+ ParticleBehaviourPlayable.prototype.onPlayablePlay = function () {
18380
+ this.particleSystem = this.bindingItem.getComponent(ParticleSystem);
18381
+ if (this.particleSystem) {
18382
+ this.particleSystem.name = this.bindingItem.name;
18383
+ this.particleSystem.start();
18384
+ this.particleSystem.initEmitterTransform();
18386
18385
  }
18387
18386
  };
18388
- ActivationClipPlayable.prototype.showRendererComponents = function () {
18389
- var e_2, _a;
18390
- try {
18391
- for (var _b = __values$1(this.bindingItem.rendererComponents), _c = _b.next(); !_c.done; _c = _b.next()) {
18392
- var rendererComponent = _c.value;
18393
- if (!rendererComponent.enabled) {
18394
- rendererComponent.enabled = true;
18395
- }
18396
- }
18397
- }
18398
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
18399
- finally {
18400
- try {
18401
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
18402
- }
18403
- finally { if (e_2) throw e_2.error; }
18387
+ ParticleBehaviourPlayable.prototype.processFrame = function (dt) {
18388
+ var particleSystem = this.particleSystem;
18389
+ if (particleSystem) {
18390
+ this.bindingItem.parent;
18391
+ // TODO: [1.31] @十弦 验证 https://github.com/galacean/effects-runtime/commit/3e7d73d37b7d98c2a25e4544e80e928b17801ccd#diff-fae062f28caf3771cfedd3a20dc22f9749bd054c7541bf2fd50a9a5e413153d4
18392
+ // particleSystem.setParentTransform(parentItem.transform);
18393
+ particleSystem.setVisible(true);
18394
+ particleSystem.onUpdate(dt);
18404
18395
  }
18405
18396
  };
18406
- return ActivationClipPlayable;
18397
+ return ParticleBehaviourPlayable;
18407
18398
  }(Playable));
18408
18399
 
18400
+ var CalculateLoader = /** @class */ (function (_super) {
18401
+ __extends(CalculateLoader, _super);
18402
+ function CalculateLoader() {
18403
+ return _super !== null && _super.apply(this, arguments) || this;
18404
+ }
18405
+ return CalculateLoader;
18406
+ }(AbstractPlugin));
18407
+
18409
18408
  var TextLayout = /** @class */ (function () {
18410
18409
  function TextLayout(options) {
18411
18410
  this.width = 0;
@@ -19703,9 +19702,10 @@ var TextComponent = /** @class */ (function (_super) {
19703
19702
  if (this.textStyle.fontSize === value) {
19704
19703
  return;
19705
19704
  }
19705
+ // 保证字号变化后位置正常
19706
+ var diff = this.textStyle.fontSize - value;
19707
+ this.textLayout.lineHeight += diff;
19706
19708
  this.textStyle.fontSize = value;
19707
- // 1.5175 = 31.43 / 20
19708
- this.textLayout.lineHeight = this.textStyle.fontSize * 1.5175;
19709
19709
  this.isDirty = true;
19710
19710
  };
19711
19711
  /**
@@ -20031,7 +20031,7 @@ var TextLoader = /** @class */ (function (_super) {
20031
20031
  return TextLoader;
20032
20032
  }(AbstractPlugin));
20033
20033
 
20034
- var seed$3 = 1;
20034
+ var seed$2 = 1;
20035
20035
  /**
20036
20036
  * @since 2.0.0
20037
20037
  * @internal
@@ -20057,24 +20057,9 @@ var EffectComponent = /** @class */ (function (_super) {
20057
20057
  };
20058
20058
  }
20059
20059
  };
20060
- _this.id = 'Mesh' + seed$3++;
20060
+ _this.id = 'Mesh' + seed$2++;
20061
20061
  _this.name = '<unnamed>';
20062
20062
  _this._priority = 0;
20063
- _this.geometry = Geometry.create(_this.engine);
20064
- var geometryData = {
20065
- vertices: [
20066
- -1, 1, 0,
20067
- -1, -1, 0,
20068
- 1, 1, 0,
20069
- 1, -1, 0, //右下
20070
- ],
20071
- uvs: [0, 1, 0, 0, 1, 1, 1, 0],
20072
- indices: [0, 1, 2, 2, 1, 3],
20073
- dataType: exports.DataType.Geometry,
20074
- id: generateGUID(),
20075
- };
20076
- _this.geometry.fromData(geometryData);
20077
- _this.triangles = geometryToTriangles(_this.geometry);
20078
20063
  return _this;
20079
20064
  }
20080
20065
  Object.defineProperty(EffectComponent.prototype, "isDestroyed", {
@@ -20611,11 +20596,6 @@ var VFXItem = /** @class */ (function (_super) {
20611
20596
  this.id = id.toString(); // TODO 老数据 id 是 number,需要转换
20612
20597
  this.name = name;
20613
20598
  this.start = delay ? delay : this.start;
20614
- // TODO spec 数据需要区分 scale 和 size
20615
- if (transform && transform.scale && data.type !== 'ECS') {
20616
- //@ts-expect-error TODO 数据改造后移除 expect-error
20617
- transform.scale.z = transform.scale.x;
20618
- }
20619
20599
  if (transform) {
20620
20600
  //@ts-expect-error TODO 数据改造后移除 expect-error
20621
20601
  transform.position = new Vector3().copyFrom(transform.position);
@@ -20623,51 +20603,36 @@ var VFXItem = /** @class */ (function (_super) {
20623
20603
  transform.rotation = new Euler().copyFrom(transform.rotation);
20624
20604
  //@ts-expect-error
20625
20605
  transform.scale = new Vector3().copyFrom(transform.scale);
20606
+ //@ts-expect-error
20607
+ if (transform.size) {
20608
+ //@ts-expect-error
20609
+ transform.size = new Vector2().copyFrom(transform.size);
20610
+ }
20611
+ //@ts-expect-error
20612
+ if (transform.anchor) {
20613
+ //@ts-expect-error
20614
+ transform.anchor = new Vector2().copyFrom(transform.anchor);
20615
+ }
20626
20616
  this.transform.setTransform(transform);
20627
20617
  }
20628
20618
  this.transform.name = this.name;
20629
20619
  this.transform.engine = this.engine;
20630
- // TODO spec 数据需要区分 scale 和 size
20631
- if (data.type === ItemType$1.sprite && transform) {
20632
- this.transform.setSize(this.transform.scale.x, this.transform.scale.y);
20633
- this.transform.setScale(1, 1, 1);
20634
- }
20635
20620
  this.parentId = parentId;
20636
20621
  this.duration = duration;
20637
20622
  this.endBehavior = endBehavior;
20638
- // TODO: 放到 Spec 处理
20639
- if (this.endBehavior === END_BEHAVIOR_PAUSE_AND_DESTROY$1 || this.endBehavior === END_BEHAVIOR_PAUSE$1) {
20640
- this.endBehavior = END_BEHAVIOR_FREEZE$1;
20641
- }
20642
20623
  this.lifetime = -(this.start / this.duration);
20643
20624
  this.listIndex = listIndex;
20625
+ //@ts-expect-error
20626
+ this.oldId = data.oldId;
20644
20627
  if (!data.content) {
20645
20628
  data.content = { options: {} };
20646
20629
  }
20647
20630
  var timelineComponent = this.getComponent(TimelineComponent);
20648
20631
  timelineComponent.fromData(data.content);
20649
- // TODO anchor 应该放在 transform data
20650
- if (data.type === ItemType$1.sprite) {
20651
- var content = data.content;
20652
- if (!content.renderer) {
20653
- //@ts-expect-error
20654
- content.renderer = {};
20655
- }
20656
- var realAnchor = convertAnchor(content.renderer.anchor, content.renderer.particleOrigin);
20657
- var startSize = this.transform.size;
20658
- // 兼容旧JSON(anchor和particleOrigin可能同时存在)
20659
- if (!content.renderer.anchor && content.renderer.particleOrigin !== undefined) {
20660
- this.transform.position.add([-realAnchor[0] * startSize.x, -realAnchor[1] * startSize.y, 0]);
20661
- }
20662
- this.transform.setAnchor(realAnchor[0] * startSize.x, realAnchor[1] * startSize.y, 0);
20663
- }
20664
- // TODO 要放在上面的 if 后面添加,否则会 position 初始化错误
20665
20632
  if (this.type !== ItemType$1.particle) {
20666
20633
  var track = timelineComponent.createTrack(Track, 'AnimationTrack');
20667
20634
  track.createClip(AnimationClipPlayable, 'AnimationTimelineClip').playable.fromData(data.content);
20668
20635
  }
20669
- var activationTrack = timelineComponent.createTrack(Track, 'ActivationTrack');
20670
- activationTrack.createClip(ActivationClipPlayable, 'ActivationTimelineClip');
20671
20636
  if (duration <= 0) {
20672
20637
  throw Error("Item duration can't be less than 0, see ".concat(HELP_LINK['Item duration can\'t be less than 0']));
20673
20638
  }
@@ -22682,7 +22647,7 @@ function isScene(scene) {
22682
22647
 
22683
22648
  function version3Migration(scene) {
22684
22649
  var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e, e_6, _f;
22685
- scene.jsonScene.version = 3.0;
22650
+ scene.jsonScene.version = '3.0';
22686
22651
  var ecScene = scene.jsonScene;
22687
22652
  if (!ecScene.items) {
22688
22653
  ecScene.items = [];
@@ -22694,6 +22659,10 @@ function version3Migration(scene) {
22694
22659
  for (var i = 0; i < composition.items.length; i++) {
22695
22660
  ecScene.items.push(composition.items[i]);
22696
22661
  }
22662
+ // composition 的 endbehaviour 兼容
22663
+ if (composition.endBehavior === END_BEHAVIOR_PAUSE_AND_DESTROY$1 || composition.endBehavior === END_BEHAVIOR_PAUSE$1) {
22664
+ composition.endBehavior = END_BEHAVIOR_FREEZE$1;
22665
+ }
22697
22666
  }
22698
22667
  }
22699
22668
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
@@ -22709,6 +22678,9 @@ function version3Migration(scene) {
22709
22678
  for (var _j = __values$1(ecScene.items), _k = _j.next(); !_k.done; _k = _j.next()) {
22710
22679
  var item = _k.value;
22711
22680
  itemGuidMap[item.id] = generateGUID();
22681
+ // TODO: 编辑器测试用,上线后删除
22682
+ //@ts-expect-error
22683
+ item.oldId = item.id;
22712
22684
  item.id = itemGuidMap[item.id];
22713
22685
  }
22714
22686
  }
@@ -22816,12 +22788,61 @@ function version3Migration(scene) {
22816
22788
  if (!scale) {
22817
22789
  scale = [1, 1, 1];
22818
22790
  }
22791
+ item.transform = {
22792
+ //@ts-expect-error
22793
+ position: { x: position[0], y: position[1], z: position[2] },
22794
+ //@ts-expect-error
22795
+ rotation: { x: rotation[0], y: rotation[1], z: rotation[2] },
22796
+ //@ts-expect-error
22797
+ scale: { x: scale[0], y: scale[1], z: scale[0] },
22798
+ };
22799
+ // sprite 的 scale 转为 size
22800
+ if (item.type === ItemType$1.sprite) {
22801
+ //@ts-expect-error
22802
+ item.transform.size = { x: scale[0], y: scale[1] };
22803
+ //@ts-expect-error
22804
+ item.transform.scale = { x: 1, y: 1, z: 1 };
22805
+ }
22806
+ // sprite 的 anchor 修正
22807
+ if (item.type === ItemType$1.sprite) {
22808
+ var content = item.content;
22809
+ //@ts-expect-error
22810
+ if (!content.renderer) {
22811
+ //@ts-expect-error
22812
+ content.renderer = {};
22813
+ }
22814
+ //@ts-expect-error
22815
+ var renderer = content.renderer;
22816
+ var realAnchor = convertAnchor(renderer.anchor, renderer.particleOrigin);
22817
+ //@ts-expect-error
22818
+ var startSize = item.transform.size;
22819
+ // 兼容旧JSON(anchor和particleOrigin可能同时存在)
22820
+ if (!renderer.anchor && renderer.particleOrigin !== undefined) {
22821
+ //@ts-expect-error
22822
+ item.transform.position.x += -realAnchor[0] * startSize.x;
22823
+ //@ts-expect-error
22824
+ item.transform.position.y += -realAnchor[1] * startSize.y;
22825
+ }
22826
+ //@ts-expect-error
22827
+ item.transform.anchor = { x: realAnchor[0] * startSize.x, y: realAnchor[1] * startSize.y };
22828
+ }
22829
+ }
22830
+ if (item.type === ItemType$1.particle) {
22831
+ var content = item.content;
22819
22832
  //@ts-expect-error
22820
- item.transform.position = { x: position[0], y: position[1], z: position[2] };
22833
+ if (!content.renderer) {
22834
+ //@ts-expect-error
22835
+ content.renderer = {};
22836
+ }
22821
22837
  //@ts-expect-error
22822
- item.transform.rotation = { x: rotation[0], y: rotation[1], z: rotation[2] };
22838
+ var renderer = content.renderer;
22823
22839
  //@ts-expect-error
22824
- item.transform.scale = { x: scale[0], y: scale[1], z: scale[2] };
22840
+ content.renderer.anchor = convertAnchor(renderer.anchor, renderer.particleOrigin);
22841
+ }
22842
+ // item 的 endbehaviour 兼容
22843
+ // @ts-expect-error
22844
+ if (item.endBehavior === END_BEHAVIOR_PAUSE_AND_DESTROY$1 || item.endBehavior === END_BEHAVIOR_PAUSE$1) {
22845
+ item.endBehavior = END_BEHAVIOR_FREEZE$1;
22825
22846
  }
22826
22847
  // item 的 content 转为 component data 加入 JSONScene.components
22827
22848
  var uuid = v4().replace(/-/g, '');
@@ -22996,8 +23017,22 @@ function version3Migration(scene) {
22996
23017
  }
22997
23018
  return scene;
22998
23019
  }
23020
+ /**
23021
+ * 提取并转换 JSON 数据中的 anchor 值
23022
+ */
23023
+ function convertAnchor(anchor, particleOrigin) {
23024
+ if (anchor) {
23025
+ return [anchor[0] - 0.5, 0.5 - anchor[1]];
23026
+ }
23027
+ else if (particleOrigin) {
23028
+ return particleOriginTranslateMap[particleOrigin];
23029
+ }
23030
+ else {
23031
+ return [0, 0];
23032
+ }
23033
+ }
22999
23034
 
23000
- var seed$2 = 1;
23035
+ var seed$1 = 1;
23001
23036
  /**
23002
23037
  * 资源管理器
23003
23038
  * 用于加载和动效中所有的资源文件,包括图片、插件、图层粒子数据等
@@ -23017,7 +23052,7 @@ var AssetManager = /** @class */ (function () {
23017
23052
  * 图像资源,用于创建和释放GPU纹理资源
23018
23053
  */
23019
23054
  this.assets = {};
23020
- this.id = seed$2++;
23055
+ this.id = seed$1++;
23021
23056
  /**
23022
23057
  * 场景加载的超时定时器
23023
23058
  */
@@ -23033,6 +23068,26 @@ var AssetManager = /** @class */ (function () {
23033
23068
  var _a = options.timeout, timeout = _a === void 0 ? 10 : _a;
23034
23069
  this.timeout = timeout;
23035
23070
  };
23071
+ /**
23072
+ * 根据用户传入的参数修改场景数据
23073
+ */
23074
+ AssetManager.prototype.updateSceneData = function (compositions) {
23075
+ var variables = this.options.variables;
23076
+ if (!variables || Object.keys(variables).length <= 0) {
23077
+ return compositions;
23078
+ }
23079
+ compositions.forEach(function (composition) {
23080
+ composition.items.forEach(function (item) {
23081
+ if (item.type === ItemType$1.text) {
23082
+ var textVariable = variables[item.name];
23083
+ if (textVariable) {
23084
+ item.content.options.text = textVariable;
23085
+ }
23086
+ }
23087
+ });
23088
+ });
23089
+ return compositions;
23090
+ };
23036
23091
  /**
23037
23092
  * 场景创建,通过 json 创建出场景对象,并进行提前编译等工作
23038
23093
  * @param url - json 的 URL 链接或者 json 对象
@@ -23124,6 +23179,7 @@ var AssetManager = /** @class */ (function () {
23124
23179
  for (i = 0; i < scene.images.length; i++) {
23125
23180
  scene.textureOptions[i].image = scene.images[i];
23126
23181
  }
23182
+ scene.jsonScene.compositions = this.updateSceneData(scene.jsonScene.compositions);
23127
23183
  _e.label = 5;
23128
23184
  case 5: return [3 /*break*/, 12];
23129
23185
  case 6: return [4 /*yield*/, hookTimeInfo('processJSON', function () { return _this.processJSON(rawJSON); })];
@@ -23143,6 +23199,7 @@ var AssetManager = /** @class */ (function () {
23143
23199
  return [4 /*yield*/, hookTimeInfo('processTextures', function () { return _this.processTextures(loadedImages_1, loadedBins_1, jsonScene_1); })];
23144
23200
  case 10:
23145
23201
  loadedTextures = _e.sent();
23202
+ jsonScene_1.compositions = this.updateSceneData(jsonScene_1.compositions);
23146
23203
  scene = {
23147
23204
  url: url,
23148
23205
  renderLevel: this.options.renderLevel,
@@ -23989,7 +24046,9 @@ var CompositionComponent = /** @class */ (function (_super) {
23989
24046
  }
23990
24047
  // endBehaviour 类型需优化
23991
24048
  props.content = itemData.content;
23992
- 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 }));
24049
+ 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,
24050
+ // @ts-expect-error TODO: 2.0 编辑器测试代码,后续移除
24051
+ oldId: itemData.oldId }));
23993
24052
  // TODO 编辑器数据传入 composition type 后移除
23994
24053
  item.type = ItemType$1.composition;
23995
24054
  item.composition = this.item.composition;
@@ -24124,7 +24183,6 @@ var CompositionComponent = /** @class */ (function (_super) {
24124
24183
  return CompositionComponent;
24125
24184
  }(ItemBehaviour));
24126
24185
 
24127
- var seed$1 = 1;
24128
24186
  /**
24129
24187
  * 合成抽象类:核心对象,通常一个场景只包含一个合成,可能会有多个合成。
24130
24188
  * 合成中包含了相关的 Item 元素,支持对 Item 元素的创建、更新和销毁。
@@ -24197,7 +24255,7 @@ var Composition = /** @class */ (function () {
24197
24255
  this.width = width;
24198
24256
  this.height = height;
24199
24257
  this.renderOrder = baseRenderOrder;
24200
- this.id = seed$1++;
24258
+ this.id = sourceContent.id;
24201
24259
  this.renderer = renderer;
24202
24260
  this.texInfo = imageUsage !== null && imageUsage !== void 0 ? imageUsage : {};
24203
24261
  this.event = event;
@@ -24224,7 +24282,7 @@ var Composition = /** @class */ (function () {
24224
24282
  this.rootItem.onEnd = function () {
24225
24283
  window.setTimeout(function () {
24226
24284
  var _a;
24227
- (_a = _this.handleEnd) === null || _a === void 0 ? void 0 : _a.call(_this, _this);
24285
+ (_a = _this.onEnd) === null || _a === void 0 ? void 0 : _a.call(_this, _this);
24228
24286
  }, 0);
24229
24287
  };
24230
24288
  this.pluginSystem.resetComposition(this, this.renderFrame);
@@ -24303,9 +24361,9 @@ var Composition = /** @class */ (function () {
24303
24361
  * 重新开始合成
24304
24362
  */
24305
24363
  Composition.prototype.restart = function () {
24306
- var contentItems = this.rootComposition.items;
24307
- contentItems.forEach(function (item) { return item.dispose(); });
24308
- contentItems.length = 0;
24364
+ this.rootComposition.items;
24365
+ // contentItems.forEach(item => item.dispose());
24366
+ // contentItems.length = 0;
24309
24367
  this.prepareRender();
24310
24368
  this.reset();
24311
24369
  this.transform.setValid(true);
@@ -24588,7 +24646,8 @@ var Composition = /** @class */ (function () {
24588
24646
  var time = this.getUpdateTime(deltaTime * this.speed);
24589
24647
  this.globalTime += time;
24590
24648
  if (this.rootTimeline.isActiveAndEnabled) {
24591
- this.rootTimeline.setTime(this.globalTime / 1000);
24649
+ var localTime = this.rootTimeline.toLocalTime(this.globalTime / 1000);
24650
+ this.rootTimeline.setTime(localTime);
24592
24651
  }
24593
24652
  this.updateVideo();
24594
24653
  // 更新 model-tree-plugin
@@ -25053,6 +25112,9 @@ var Composition = /** @class */ (function () {
25053
25112
  }
25054
25113
  this.compositionSourceManager.dispose();
25055
25114
  this.refCompositionProps.clear();
25115
+ if (this.renderer.env === PLAYER_OPTIONS_ENV_EDITOR) {
25116
+ return;
25117
+ }
25056
25118
  this.renderer.clear({
25057
25119
  stencilAction: exports.TextureLoadAction.clear,
25058
25120
  clearStencil: 0,
@@ -25723,9 +25785,20 @@ var Ticker = /** @class */ (function () {
25723
25785
  if (fps === void 0) { fps = 60; }
25724
25786
  this.paused = true;
25725
25787
  this.lastTime = 0;
25788
+ this._deltaTime = 0;
25726
25789
  this.setFPS(fps);
25727
25790
  this.tickers = [];
25728
25791
  }
25792
+ Object.defineProperty(Ticker.prototype, "deltaTime", {
25793
+ /**
25794
+ * 获取定时器当前帧更新的时间
25795
+ */
25796
+ get: function () {
25797
+ return this._deltaTime;
25798
+ },
25799
+ enumerable: false,
25800
+ configurable: true
25801
+ });
25729
25802
  /**
25730
25803
  * FPS 帧率设置
25731
25804
  */
@@ -25752,6 +25825,7 @@ var Ticker = /** @class */ (function () {
25752
25825
  Ticker.prototype.start = function () {
25753
25826
  var _this = this;
25754
25827
  this.paused = false;
25828
+ this._deltaTime = 0;
25755
25829
  if (!this.intervalId) {
25756
25830
  this.lastTime = performance.now();
25757
25831
  var raf_1 = requestAnimationFrame || function (func) {
@@ -25774,6 +25848,7 @@ var Ticker = /** @class */ (function () {
25774
25848
  this.intervalId = 0;
25775
25849
  this.lastTime = 0;
25776
25850
  this.paused = true;
25851
+ this._deltaTime = 0;
25777
25852
  this.tickers = [];
25778
25853
  };
25779
25854
  /**
@@ -25781,12 +25856,14 @@ var Ticker = /** @class */ (function () {
25781
25856
  */
25782
25857
  Ticker.prototype.pause = function () {
25783
25858
  this.paused = true;
25859
+ this._deltaTime = 0;
25784
25860
  };
25785
25861
  /**
25786
25862
  * 定时器恢复方法
25787
25863
  */
25788
25864
  Ticker.prototype.resume = function () {
25789
25865
  this.paused = false;
25866
+ this._deltaTime = 0;
25790
25867
  };
25791
25868
  /**
25792
25869
  * 定时器 tick 方法
@@ -25796,8 +25873,8 @@ var Ticker = /** @class */ (function () {
25796
25873
  return;
25797
25874
  }
25798
25875
  var startTime = performance.now();
25799
- var deltaTime = startTime - this.lastTime;
25800
- if (deltaTime >= this.interval) {
25876
+ this._deltaTime = startTime - this.lastTime;
25877
+ if (this._deltaTime >= this.interval) {
25801
25878
  this.lastTime = startTime;
25802
25879
  if (this.resetTickers) {
25803
25880
  this.tickers = this.tickers.filter(function (tick) { return tick; });
@@ -25805,7 +25882,7 @@ var Ticker = /** @class */ (function () {
25805
25882
  }
25806
25883
  for (var i = 0, len = this.tickers.length; i < len; i++) {
25807
25884
  var tick = this.tickers[i];
25808
- tick(deltaTime);
25885
+ tick(this._deltaTime);
25809
25886
  }
25810
25887
  }
25811
25888
  };
@@ -27321,6 +27398,103 @@ function isSceneWithOptions(scene) {
27321
27398
  return isObject(scene) && 'scene' in scene;
27322
27399
  }
27323
27400
 
27401
+ var ThreeSpriteComponent = /** @class */ (function (_super) {
27402
+ __extends(ThreeSpriteComponent, _super);
27403
+ function ThreeSpriteComponent() {
27404
+ return _super !== null && _super.apply(this, arguments) || this;
27405
+ }
27406
+ Object.defineProperty(ThreeSpriteComponent.prototype, "priority", {
27407
+ /**
27408
+ * 获取 mesh 的渲染顺序
27409
+ */
27410
+ get: function () {
27411
+ return this.threeMesh.renderOrder;
27412
+ },
27413
+ /**
27414
+ * 设置 mesh 的渲染顺序
27415
+ *
27416
+ * @param v - 顺序 index
27417
+ */
27418
+ set: function (v) {
27419
+ if (this.threeMesh) {
27420
+ this.threeMesh.renderOrder = v;
27421
+ }
27422
+ },
27423
+ enumerable: false,
27424
+ configurable: true
27425
+ });
27426
+ /**
27427
+ * TODO: 待移除
27428
+ * 设置 mesh 可见性
27429
+ *
27430
+ * @param val - 可见性开关
27431
+ */
27432
+ ThreeSpriteComponent.prototype.setVisible = function (val) {
27433
+ this.threeMesh.visible = val;
27434
+ };
27435
+ /**
27436
+ * TODO: 待移除
27437
+ * 获取 mesh 的可见性
27438
+ *
27439
+ * @returns
27440
+ */
27441
+ ThreeSpriteComponent.prototype.getVisible = function () {
27442
+ return this.threeMesh.visible;
27443
+ };
27444
+ Object.defineProperty(ThreeSpriteComponent.prototype, "enabled", {
27445
+ get: function () {
27446
+ return this.threeMesh.visible;
27447
+ },
27448
+ set: function (value) {
27449
+ this.threeMesh.visible = value;
27450
+ if (value) {
27451
+ this.onEnable();
27452
+ }
27453
+ },
27454
+ enumerable: false,
27455
+ configurable: true
27456
+ });
27457
+ /**
27458
+ * 销毁方法
27459
+ *
27460
+ */
27461
+ ThreeSpriteComponent.prototype.dispose = function () {
27462
+ _super.prototype.dispose.call(this);
27463
+ if (!this.isActiveAndEnabled) {
27464
+ this.threeMesh.clear();
27465
+ }
27466
+ };
27467
+ ThreeSpriteComponent.prototype.fromData = function (data) {
27468
+ _super.prototype.fromData.call(this, data);
27469
+ if (!this.threeMesh) {
27470
+ if (this.geometry.mode === glContext.LINES) {
27471
+ this.threeMesh = new THREE__namespace.LineSegments(this.geometry.geometry, this.material.material);
27472
+ }
27473
+ else {
27474
+ this.threeMesh = new THREE__namespace.Mesh(this.geometry.geometry, this.material.material);
27475
+ }
27476
+ }
27477
+ };
27478
+ ThreeSpriteComponent.prototype.start = function () {
27479
+ _super.prototype.start.call(this);
27480
+ this.engine.threeGroup.add(this.threeMesh);
27481
+ };
27482
+ ThreeSpriteComponent.prototype.render = function (renderer) {
27483
+ if (!this.isActiveAndEnabled) {
27484
+ return;
27485
+ }
27486
+ this.material.setMatrix('effects_ObjectToWorld', this.transform.getWorldMatrix());
27487
+ this.material.use(renderer, renderer.renderingData.currentFrame.globalUniforms);
27488
+ };
27489
+ ThreeSpriteComponent.prototype.onDestroy = function () {
27490
+ this.threeMesh.clear();
27491
+ };
27492
+ ThreeSpriteComponent = __decorate([
27493
+ effectsClass(exports.DataType.SpriteComponent)
27494
+ ], ThreeSpriteComponent);
27495
+ return ThreeSpriteComponent;
27496
+ }(SpriteComponent));
27497
+
27324
27498
  setMaxSpriteMeshItemCount(8);
27325
27499
  /**
27326
27500
  * 图片的创建方法
@@ -27368,7 +27542,7 @@ Geometry.create = function (engine, options) {
27368
27542
  Mesh.create = function (engine, props) {
27369
27543
  return new ThreeMesh(engine, props);
27370
27544
  };
27371
- var version = "2.0.0-alpha.0";
27545
+ var version = "2.0.0-alpha.2";
27372
27546
  logger.info('THREEJS plugin version: ' + version);
27373
27547
 
27374
27548
  exports.AbstractPlugin = AbstractPlugin;
@@ -27476,6 +27650,7 @@ exports.ThreeComposition = ThreeComposition;
27476
27650
  exports.ThreeDisplayObject = ThreeDisplayObject;
27477
27651
  exports.ThreeEngine = ThreeEngine;
27478
27652
  exports.ThreeMaterial = ThreeMaterial;
27653
+ exports.ThreeSpriteComponent = ThreeSpriteComponent;
27479
27654
  exports.ThreeTexture = ThreeTexture;
27480
27655
  exports.Ticker = Ticker;
27481
27656
  exports.TimelineClip = TimelineClip;
@@ -27509,7 +27684,6 @@ exports.combineImageTemplate2Async = combineImageTemplate2Async;
27509
27684
  exports.combineImageTemplateAsync = combineImageTemplateAsync;
27510
27685
  exports.compatibleFrag = compatible_frag;
27511
27686
  exports.compatibleVert = compatible_vert;
27512
- exports.convertAnchor = convertAnchor;
27513
27687
  exports.copyFrag = copy;
27514
27688
  exports.createCopyShader = createCopyShader;
27515
27689
  exports.createGLContext = createGLContext;