@galacean/effects-threejs 2.5.0-alpha.1 → 2.5.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.5.0-alpha.1
6
+ * Version: v2.5.0-alpha.2
7
7
  */
8
8
 
9
9
  'use strict';
@@ -12894,6 +12894,25 @@ var singleSplits = [
12894
12894
  this.configureMaterial(this.renderer);
12895
12895
  if (baseRenderComponentData.geometry) {
12896
12896
  this.geometry = this.engine.findObject(baseRenderComponentData.geometry);
12897
+ var uvTransform = baseRenderComponentData.splits && !baseRenderComponentData.textureSheetAnimation ? baseRenderComponentData.splits[0] : singleSplits[0];
12898
+ var x = uvTransform[0];
12899
+ var y = uvTransform[1];
12900
+ var isRotate90 = uvTransform[4];
12901
+ var width = isRotate90 ? uvTransform[3] : uvTransform[2];
12902
+ var height = isRotate90 ? uvTransform[2] : uvTransform[3];
12903
+ var aUV = this.geometry.getAttributeData("aUV");
12904
+ var aPos = this.geometry.getAttributeData("aPos");
12905
+ if (aUV && aPos) {
12906
+ var vertexCount = aUV.length / 2;
12907
+ for(var i = 0; i < vertexCount; i++){
12908
+ var positionOffset = i * 3;
12909
+ var uvOffset = i * 2;
12910
+ var positionX = aPos[positionOffset];
12911
+ var positionY = aPos[positionOffset + 1];
12912
+ aUV[uvOffset] = (positionX + 0.5) * width + x;
12913
+ aUV[uvOffset + 1] = (positionY + 0.5) * height + y;
12914
+ }
12915
+ }
12897
12916
  } else {
12898
12917
  this.geometry = this.defaultGeometry;
12899
12918
  this.configureDefaultGeometry(this.renderer);
@@ -20256,7 +20275,7 @@ var RuntimeClip = /*#__PURE__*/ function() {
20256
20275
  this.playable.play();
20257
20276
  }
20258
20277
  this.parentMixer.setClipWeight(this.playable, weight);
20259
- var clipTime = parseFloat(clip.toLocalTime(localTime).toFixed(3));
20278
+ var clipTime = clip.toLocalTime(localTime);
20260
20279
  this.playable.setTime(clipTime);
20261
20280
  // 判断动画是否结束
20262
20281
  if (ended) {
@@ -21445,11 +21464,12 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
21445
21464
  * 前进合成到指定时间
21446
21465
  * @param time - 相对0时刻的时间
21447
21466
  */ _proto.forwardTime = function forwardTime(time) {
21448
- var deltaTime = time * 1000 - this.rootComposition.time * 1000;
21467
+ var deltaTime = time * 1000 - this.time * 1000;
21449
21468
  var reverse = deltaTime < 0;
21450
21469
  var step = 15;
21451
21470
  var t = Math.abs(deltaTime);
21452
21471
  var ss = reverse ? -step : step;
21472
+ // FIXME Update 中可能会修改合成时间,这边需要优化更新逻辑
21453
21473
  for(t; t > step; t -= step){
21454
21474
  this.update(ss);
21455
21475
  }
@@ -21489,13 +21509,14 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
21489
21509
  this.callAwake(this.rootItem);
21490
21510
  this.rootItem.beginPlay();
21491
21511
  }
21492
- var dt = parseFloat(this.getUpdateTime(deltaTime * this.speed).toFixed(0));
21493
- this.updateRootComposition(dt / 1000);
21512
+ var previousCompositionTime = this.time;
21513
+ this.updateCompositionTime(deltaTime * this.speed / 1000);
21514
+ var deltaTimeInMs = (this.time - previousCompositionTime) * 1000;
21494
21515
  this.updateVideo();
21495
21516
  // 更新 model-tree-plugin
21496
- this.updatePluginLoaders(deltaTime);
21497
- this.sceneTicking.update.tick(dt);
21498
- this.sceneTicking.lateUpdate.tick(dt);
21517
+ this.updatePluginLoaders(deltaTimeInMs);
21518
+ this.sceneTicking.update.tick(deltaTimeInMs);
21519
+ this.sceneTicking.lateUpdate.tick(deltaTimeInMs);
21499
21520
  this.updateCamera();
21500
21521
  this.prepareRender();
21501
21522
  if (this.isEnded && !this.isEndCalled) {
@@ -21511,14 +21532,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
21511
21532
  _proto.shouldDispose = function shouldDispose() {
21512
21533
  return this.isEnded && this.rootItem.endBehavior === EndBehavior.destroy && !this.reusable;
21513
21534
  };
21514
- _proto.getUpdateTime = function getUpdateTime(t) {
21515
- var startTimeInMs = this.startTime * 1000;
21516
- var now = this.rootComposition.time * 1000;
21517
- if (t < 0 && now + t < startTimeInMs) {
21518
- return startTimeInMs - now;
21519
- }
21520
- return t;
21521
- };
21522
21535
  _proto.callAwake = function callAwake(item) {
21523
21536
  for(var _iterator = _create_for_of_iterator_helper_loose(item.components), _step; !(_step = _iterator()).done;){
21524
21537
  var component = _step.value;
@@ -21563,14 +21576,18 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
21563
21576
  };
21564
21577
  /**
21565
21578
  * 更新主合成组件
21566
- */ _proto.updateRootComposition = function updateRootComposition(deltaTime) {
21579
+ */ _proto.updateCompositionTime = function updateCompositionTime(deltaTime) {
21567
21580
  if (this.rootComposition.state === PlayState.Paused || !this.rootComposition.isActiveAndEnabled) {
21568
21581
  return;
21569
21582
  }
21570
- var localTime = parseFloat((this.time + deltaTime - this.rootItem.start).toFixed(3));
21571
- var isEnded = false;
21583
+ // 相对于合成开始时间的时间
21584
+ var localTime = this.time + deltaTime - this.startTime;
21585
+ if (deltaTime < 0 && localTime < 0) {
21586
+ localTime = 0;
21587
+ }
21572
21588
  var duration = this.rootItem.duration;
21573
21589
  var endBehavior = this.rootItem.endBehavior;
21590
+ var isEnded = false;
21574
21591
  if (localTime - duration > 0.001) {
21575
21592
  isEnded = true;
21576
21593
  switch(endBehavior){
@@ -21595,7 +21612,7 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
21595
21612
  }
21596
21613
  }
21597
21614
  }
21598
- this.rootComposition.time = localTime;
21615
+ this.rootComposition.time = localTime + this.startTime;
21599
21616
  // end state changed, handle onEnd flags
21600
21617
  if (this.isEnded !== isEnded) {
21601
21618
  if (isEnded) {
@@ -28398,7 +28415,7 @@ function getStandardSpriteContent(sprite, transform) {
28398
28415
  return ret;
28399
28416
  }
28400
28417
 
28401
- var version$2 = "2.5.0-alpha.1";
28418
+ var version$2 = "2.5.0-alpha.2";
28402
28419
  var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
28403
28420
  var standardVersion = /^(\d+)\.(\d+)$/;
28404
28421
  var reverseParticle = false;
@@ -31648,7 +31665,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem);
31648
31665
  registerPlugin("particle", ParticleLoader, exports.VFXItem);
31649
31666
  registerPlugin("cal", CalculateLoader, exports.VFXItem);
31650
31667
  registerPlugin("interact", InteractLoader, exports.VFXItem);
31651
- var version$1 = "2.5.0-alpha.1";
31668
+ var version$1 = "2.5.0-alpha.2";
31652
31669
  logger.info("Core version: " + version$1 + ".");
31653
31670
 
31654
31671
  var _obj;
@@ -33250,7 +33267,7 @@ setMaxSpriteMeshItemCount(8);
33250
33267
  */ Mesh.create = function(engine, props) {
33251
33268
  return new ThreeMesh(engine, props);
33252
33269
  };
33253
- var version = "2.5.0-alpha.1";
33270
+ var version = "2.5.0-alpha.2";
33254
33271
  logger.info("THREEJS plugin version: " + version + ".");
33255
33272
 
33256
33273
  exports.AbstractPlugin = AbstractPlugin;