@galacean/effects-core 2.4.7 → 2.4.8

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.
@@ -357,7 +357,6 @@ export declare class Composition extends EventEmitter<CompositionEvent<Compositi
357
357
  */
358
358
  update(deltaTime: number): void;
359
359
  private shouldDispose;
360
- private getUpdateTime;
361
360
  private callAwake;
362
361
  /**
363
362
  * 更新视频数据到纹理
@@ -377,7 +376,7 @@ export declare class Composition extends EventEmitter<CompositionEvent<Compositi
377
376
  /**
378
377
  * 更新主合成组件
379
378
  */
380
- private updateRootComposition;
379
+ private updateCompositionTime;
381
380
  /**
382
381
  * 通过名称获取元素
383
382
  * @param name - 元素名称
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * Description: Galacean Effects runtime core for the web
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
6
- * Version: v2.4.7
6
+ * Version: v2.4.8
7
7
  */
8
8
 
9
9
  'use strict';
@@ -20139,7 +20139,7 @@ var RuntimeClip = /*#__PURE__*/ function() {
20139
20139
  this.playable.play();
20140
20140
  }
20141
20141
  this.parentMixer.setClipWeight(this.playable, weight);
20142
- var clipTime = parseFloat(clip.toLocalTime(localTime).toFixed(3));
20142
+ var clipTime = clip.toLocalTime(localTime);
20143
20143
  this.playable.setTime(clipTime);
20144
20144
  // 判断动画是否结束
20145
20145
  if (ended) {
@@ -21328,11 +21328,12 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
21328
21328
  * 前进合成到指定时间
21329
21329
  * @param time - 相对0时刻的时间
21330
21330
  */ _proto.forwardTime = function forwardTime(time) {
21331
- var deltaTime = time * 1000 - this.rootComposition.time * 1000;
21331
+ var deltaTime = time * 1000 - this.time * 1000;
21332
21332
  var reverse = deltaTime < 0;
21333
21333
  var step = 15;
21334
21334
  var t = Math.abs(deltaTime);
21335
21335
  var ss = reverse ? -step : step;
21336
+ // FIXME Update 中可能会修改合成时间,这边需要优化更新逻辑
21336
21337
  for(t; t > step; t -= step){
21337
21338
  this.update(ss);
21338
21339
  }
@@ -21372,13 +21373,14 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
21372
21373
  this.callAwake(this.rootItem);
21373
21374
  this.rootItem.beginPlay();
21374
21375
  }
21375
- var dt = parseFloat(this.getUpdateTime(deltaTime * this.speed).toFixed(0));
21376
- this.updateRootComposition(dt / 1000);
21376
+ var previousCompositionTime = this.time;
21377
+ this.updateCompositionTime(deltaTime * this.speed / 1000);
21378
+ var deltaTimeInMs = (this.time - previousCompositionTime) * 1000;
21377
21379
  this.updateVideo();
21378
21380
  // 更新 model-tree-plugin
21379
- this.updatePluginLoaders(deltaTime);
21380
- this.sceneTicking.update.tick(dt);
21381
- this.sceneTicking.lateUpdate.tick(dt);
21381
+ this.updatePluginLoaders(deltaTimeInMs);
21382
+ this.sceneTicking.update.tick(deltaTimeInMs);
21383
+ this.sceneTicking.lateUpdate.tick(deltaTimeInMs);
21382
21384
  this.updateCamera();
21383
21385
  this.prepareRender();
21384
21386
  if (this.isEnded && !this.isEndCalled) {
@@ -21394,14 +21396,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
21394
21396
  _proto.shouldDispose = function shouldDispose() {
21395
21397
  return this.isEnded && this.rootItem.endBehavior === EndBehavior.destroy && !this.reusable;
21396
21398
  };
21397
- _proto.getUpdateTime = function getUpdateTime(t) {
21398
- var startTimeInMs = this.startTime * 1000;
21399
- var now = this.rootComposition.time * 1000;
21400
- if (t < 0 && now + t < startTimeInMs) {
21401
- return startTimeInMs - now;
21402
- }
21403
- return t;
21404
- };
21405
21399
  _proto.callAwake = function callAwake(item) {
21406
21400
  for(var _iterator = _create_for_of_iterator_helper_loose(item.components), _step; !(_step = _iterator()).done;){
21407
21401
  var component = _step.value;
@@ -21446,14 +21440,18 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
21446
21440
  };
21447
21441
  /**
21448
21442
  * 更新主合成组件
21449
- */ _proto.updateRootComposition = function updateRootComposition(deltaTime) {
21443
+ */ _proto.updateCompositionTime = function updateCompositionTime(deltaTime) {
21450
21444
  if (this.rootComposition.state === PlayState.Paused || !this.rootComposition.isActiveAndEnabled) {
21451
21445
  return;
21452
21446
  }
21453
- var localTime = parseFloat((this.time + deltaTime - this.rootItem.start).toFixed(3));
21454
- var isEnded = false;
21447
+ // 相对于合成开始时间的时间
21448
+ var localTime = this.time + deltaTime - this.startTime;
21449
+ if (deltaTime < 0 && localTime < 0) {
21450
+ localTime = 0;
21451
+ }
21455
21452
  var duration = this.rootItem.duration;
21456
21453
  var endBehavior = this.rootItem.endBehavior;
21454
+ var isEnded = false;
21457
21455
  if (localTime - duration > 0.001) {
21458
21456
  isEnded = true;
21459
21457
  switch(endBehavior){
@@ -21478,7 +21476,7 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
21478
21476
  }
21479
21477
  }
21480
21478
  }
21481
- this.rootComposition.time = localTime;
21479
+ this.rootComposition.time = localTime + this.startTime;
21482
21480
  // end state changed, handle onEnd flags
21483
21481
  if (this.isEnded !== isEnded) {
21484
21482
  if (isEnded) {
@@ -31628,7 +31626,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem);
31628
31626
  registerPlugin("particle", ParticleLoader, exports.VFXItem);
31629
31627
  registerPlugin("cal", CalculateLoader, exports.VFXItem);
31630
31628
  registerPlugin("interact", InteractLoader, exports.VFXItem);
31631
- var version = "2.4.7";
31629
+ var version = "2.4.8";
31632
31630
  logger.info("Core version: " + version + ".");
31633
31631
 
31634
31632
  exports.AbstractPlugin = AbstractPlugin;