@galacean/effects-threejs 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.
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.4.7
6
+ * Version: v2.4.8
7
7
  */
8
8
 
9
9
  'use strict';
@@ -20161,7 +20161,7 @@ var RuntimeClip = /*#__PURE__*/ function() {
20161
20161
  this.playable.play();
20162
20162
  }
20163
20163
  this.parentMixer.setClipWeight(this.playable, weight);
20164
- var clipTime = parseFloat(clip.toLocalTime(localTime).toFixed(3));
20164
+ var clipTime = clip.toLocalTime(localTime);
20165
20165
  this.playable.setTime(clipTime);
20166
20166
  // 判断动画是否结束
20167
20167
  if (ended) {
@@ -21350,11 +21350,12 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
21350
21350
  * 前进合成到指定时间
21351
21351
  * @param time - 相对0时刻的时间
21352
21352
  */ _proto.forwardTime = function forwardTime(time) {
21353
- var deltaTime = time * 1000 - this.rootComposition.time * 1000;
21353
+ var deltaTime = time * 1000 - this.time * 1000;
21354
21354
  var reverse = deltaTime < 0;
21355
21355
  var step = 15;
21356
21356
  var t = Math.abs(deltaTime);
21357
21357
  var ss = reverse ? -step : step;
21358
+ // FIXME Update 中可能会修改合成时间,这边需要优化更新逻辑
21358
21359
  for(t; t > step; t -= step){
21359
21360
  this.update(ss);
21360
21361
  }
@@ -21394,13 +21395,14 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
21394
21395
  this.callAwake(this.rootItem);
21395
21396
  this.rootItem.beginPlay();
21396
21397
  }
21397
- var dt = parseFloat(this.getUpdateTime(deltaTime * this.speed).toFixed(0));
21398
- this.updateRootComposition(dt / 1000);
21398
+ var previousCompositionTime = this.time;
21399
+ this.updateCompositionTime(deltaTime * this.speed / 1000);
21400
+ var deltaTimeInMs = (this.time - previousCompositionTime) * 1000;
21399
21401
  this.updateVideo();
21400
21402
  // 更新 model-tree-plugin
21401
- this.updatePluginLoaders(deltaTime);
21402
- this.sceneTicking.update.tick(dt);
21403
- this.sceneTicking.lateUpdate.tick(dt);
21403
+ this.updatePluginLoaders(deltaTimeInMs);
21404
+ this.sceneTicking.update.tick(deltaTimeInMs);
21405
+ this.sceneTicking.lateUpdate.tick(deltaTimeInMs);
21404
21406
  this.updateCamera();
21405
21407
  this.prepareRender();
21406
21408
  if (this.isEnded && !this.isEndCalled) {
@@ -21416,14 +21418,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
21416
21418
  _proto.shouldDispose = function shouldDispose() {
21417
21419
  return this.isEnded && this.rootItem.endBehavior === EndBehavior.destroy && !this.reusable;
21418
21420
  };
21419
- _proto.getUpdateTime = function getUpdateTime(t) {
21420
- var startTimeInMs = this.startTime * 1000;
21421
- var now = this.rootComposition.time * 1000;
21422
- if (t < 0 && now + t < startTimeInMs) {
21423
- return startTimeInMs - now;
21424
- }
21425
- return t;
21426
- };
21427
21421
  _proto.callAwake = function callAwake(item) {
21428
21422
  for(var _iterator = _create_for_of_iterator_helper_loose(item.components), _step; !(_step = _iterator()).done;){
21429
21423
  var component = _step.value;
@@ -21468,14 +21462,18 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
21468
21462
  };
21469
21463
  /**
21470
21464
  * 更新主合成组件
21471
- */ _proto.updateRootComposition = function updateRootComposition(deltaTime) {
21465
+ */ _proto.updateCompositionTime = function updateCompositionTime(deltaTime) {
21472
21466
  if (this.rootComposition.state === PlayState.Paused || !this.rootComposition.isActiveAndEnabled) {
21473
21467
  return;
21474
21468
  }
21475
- var localTime = parseFloat((this.time + deltaTime - this.rootItem.start).toFixed(3));
21476
- var isEnded = false;
21469
+ // 相对于合成开始时间的时间
21470
+ var localTime = this.time + deltaTime - this.startTime;
21471
+ if (deltaTime < 0 && localTime < 0) {
21472
+ localTime = 0;
21473
+ }
21477
21474
  var duration = this.rootItem.duration;
21478
21475
  var endBehavior = this.rootItem.endBehavior;
21476
+ var isEnded = false;
21479
21477
  if (localTime - duration > 0.001) {
21480
21478
  isEnded = true;
21481
21479
  switch(endBehavior){
@@ -21500,7 +21498,7 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
21500
21498
  }
21501
21499
  }
21502
21500
  }
21503
- this.rootComposition.time = localTime;
21501
+ this.rootComposition.time = localTime + this.startTime;
21504
21502
  // end state changed, handle onEnd flags
21505
21503
  if (this.isEnded !== isEnded) {
21506
21504
  if (isEnded) {
@@ -31650,7 +31648,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem);
31650
31648
  registerPlugin("particle", ParticleLoader, exports.VFXItem);
31651
31649
  registerPlugin("cal", CalculateLoader, exports.VFXItem);
31652
31650
  registerPlugin("interact", InteractLoader, exports.VFXItem);
31653
- var version$1 = "2.4.7";
31651
+ var version$1 = "2.4.8";
31654
31652
  logger.info("Core version: " + version$1 + ".");
31655
31653
 
31656
31654
  var _obj;
@@ -33252,7 +33250,7 @@ setMaxSpriteMeshItemCount(8);
33252
33250
  */ Mesh.create = function(engine, props) {
33253
33251
  return new ThreeMesh(engine, props);
33254
33252
  };
33255
- var version = "2.4.7";
33253
+ var version = "2.4.8";
33256
33254
  logger.info("THREEJS plugin version: " + version + ".");
33257
33255
 
33258
33256
  exports.AbstractPlugin = AbstractPlugin;