@galacean/effects-threejs 2.5.0-alpha.1 → 2.5.0-alpha.3

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.3
7
7
  */
8
8
 
9
9
  'use strict';
@@ -12893,7 +12893,40 @@ var singleSplits = [
12893
12893
  };
12894
12894
  this.configureMaterial(this.renderer);
12895
12895
  if (baseRenderComponentData.geometry) {
12896
- this.geometry = this.engine.findObject(baseRenderComponentData.geometry);
12896
+ var baseGeometry = 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 = baseGeometry.getAttributeData("aUV");
12904
+ var aPos = baseGeometry.getAttributeData("aPos");
12905
+ var indices = baseGeometry.getIndexData();
12906
+ if (aUV && aPos && indices) {
12907
+ var vertexCount = aUV.length / 2;
12908
+ for(var i = 0; i < vertexCount; i++){
12909
+ var positionOffset = i * 3;
12910
+ var uvOffset = i * 2;
12911
+ var positionX = aPos[positionOffset];
12912
+ var positionY = aPos[positionOffset + 1];
12913
+ aUV[uvOffset] = (positionX + 0.5) * width + x;
12914
+ aUV[uvOffset + 1] = (positionY + 0.5) * height + y;
12915
+ }
12916
+ this.geometry.setAttributeData("aPos", aPos.slice());
12917
+ this.geometry.setAttributeData("aUV", aUV.slice());
12918
+ this.geometry.setIndexData(indices.slice());
12919
+ this.geometry.setDrawCount(indices.length);
12920
+ }
12921
+ this.geometry.subMeshes.length = 0;
12922
+ for(var _iterator = _create_for_of_iterator_helper_loose(baseGeometry.subMeshes), _step; !(_step = _iterator()).done;){
12923
+ var subMesh = _step.value;
12924
+ this.geometry.subMeshes.push({
12925
+ offset: subMesh.offset,
12926
+ indexCount: subMesh.indexCount,
12927
+ vertexCount: subMesh.vertexCount
12928
+ });
12929
+ }
12897
12930
  } else {
12898
12931
  this.geometry = this.defaultGeometry;
12899
12932
  this.configureDefaultGeometry(this.renderer);
@@ -20256,7 +20289,7 @@ var RuntimeClip = /*#__PURE__*/ function() {
20256
20289
  this.playable.play();
20257
20290
  }
20258
20291
  this.parentMixer.setClipWeight(this.playable, weight);
20259
- var clipTime = parseFloat(clip.toLocalTime(localTime).toFixed(3));
20292
+ var clipTime = clip.toLocalTime(localTime);
20260
20293
  this.playable.setTime(clipTime);
20261
20294
  // 判断动画是否结束
20262
20295
  if (ended) {
@@ -21251,7 +21284,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
21251
21284
  /**
21252
21285
  * 合成暂停/播放 标识
21253
21286
  */ _this.paused = false;
21254
- _this.lastVideoUpdateTime = 0;
21255
21287
  _this.isEndCalled = false;
21256
21288
  _this._textures = [];
21257
21289
  var _props_reusable = props.reusable, reusable = _props_reusable === void 0 ? false : _props_reusable, _props_speed = props.speed, speed = _props_speed === void 0 ? 1 : _props_speed, _props_baseRenderOrder = props.baseRenderOrder, baseRenderOrder = _props_baseRenderOrder === void 0 ? 0 : _props_baseRenderOrder, renderer = props.renderer, event = props.event, width = props.width, height = props.height, handleItemMessage = props.handleItemMessage;
@@ -21445,11 +21477,12 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
21445
21477
  * 前进合成到指定时间
21446
21478
  * @param time - 相对0时刻的时间
21447
21479
  */ _proto.forwardTime = function forwardTime(time) {
21448
- var deltaTime = time * 1000 - this.rootComposition.time * 1000;
21480
+ var deltaTime = time * 1000 - this.time * 1000;
21449
21481
  var reverse = deltaTime < 0;
21450
21482
  var step = 15;
21451
21483
  var t = Math.abs(deltaTime);
21452
21484
  var ss = reverse ? -step : step;
21485
+ // FIXME Update 中可能会修改合成时间,这边需要优化更新逻辑
21453
21486
  for(t; t > step; t -= step){
21454
21487
  this.update(ss);
21455
21488
  }
@@ -21489,13 +21522,13 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
21489
21522
  this.callAwake(this.rootItem);
21490
21523
  this.rootItem.beginPlay();
21491
21524
  }
21492
- var dt = parseFloat(this.getUpdateTime(deltaTime * this.speed).toFixed(0));
21493
- this.updateRootComposition(dt / 1000);
21494
- this.updateVideo();
21525
+ var previousCompositionTime = this.time;
21526
+ this.updateCompositionTime(deltaTime * this.speed / 1000);
21527
+ var deltaTimeInMs = (this.time - previousCompositionTime) * 1000;
21495
21528
  // 更新 model-tree-plugin
21496
- this.updatePluginLoaders(deltaTime);
21497
- this.sceneTicking.update.tick(dt);
21498
- this.sceneTicking.lateUpdate.tick(dt);
21529
+ this.updatePluginLoaders(deltaTimeInMs);
21530
+ this.sceneTicking.update.tick(deltaTimeInMs);
21531
+ this.sceneTicking.lateUpdate.tick(deltaTimeInMs);
21499
21532
  this.updateCamera();
21500
21533
  this.prepareRender();
21501
21534
  if (this.isEnded && !this.isEndCalled) {
@@ -21511,14 +21544,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
21511
21544
  _proto.shouldDispose = function shouldDispose() {
21512
21545
  return this.isEnded && this.rootItem.endBehavior === EndBehavior.destroy && !this.reusable;
21513
21546
  };
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
21547
  _proto.callAwake = function callAwake(item) {
21523
21548
  for(var _iterator = _create_for_of_iterator_helper_loose(item.components), _step; !(_step = _iterator()).done;){
21524
21549
  var component = _step.value;
@@ -21533,20 +21558,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
21533
21558
  }
21534
21559
  };
21535
21560
  /**
21536
- * 更新视频数据到纹理
21537
- * @override
21538
- */ _proto.updateVideo = function updateVideo() {
21539
- var now = performance.now();
21540
- // 视频固定30帧更新
21541
- if (now - this.lastVideoUpdateTime > 33) {
21542
- var _this_textures;
21543
- ((_this_textures = this.textures) != null ? _this_textures : []).forEach(function(tex) {
21544
- return tex == null ? void 0 : tex.uploadCurrentVideoFrame();
21545
- });
21546
- this.lastVideoUpdateTime = now;
21547
- }
21548
- };
21549
- /**
21550
21561
  * 更新相机
21551
21562
  * @override
21552
21563
  */ _proto.updateCamera = function updateCamera() {
@@ -21563,14 +21574,18 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
21563
21574
  };
21564
21575
  /**
21565
21576
  * 更新主合成组件
21566
- */ _proto.updateRootComposition = function updateRootComposition(deltaTime) {
21577
+ */ _proto.updateCompositionTime = function updateCompositionTime(deltaTime) {
21567
21578
  if (this.rootComposition.state === PlayState.Paused || !this.rootComposition.isActiveAndEnabled) {
21568
21579
  return;
21569
21580
  }
21570
- var localTime = parseFloat((this.time + deltaTime - this.rootItem.start).toFixed(3));
21571
- var isEnded = false;
21581
+ // 相对于合成开始时间的时间
21582
+ var localTime = this.time + deltaTime - this.startTime;
21583
+ if (deltaTime < 0 && localTime < 0) {
21584
+ localTime = 0;
21585
+ }
21572
21586
  var duration = this.rootItem.duration;
21573
21587
  var endBehavior = this.rootItem.endBehavior;
21588
+ var isEnded = false;
21574
21589
  if (localTime - duration > 0.001) {
21575
21590
  isEnded = true;
21576
21591
  switch(endBehavior){
@@ -21595,7 +21610,7 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
21595
21610
  }
21596
21611
  }
21597
21612
  }
21598
- this.rootComposition.time = localTime;
21613
+ this.rootComposition.time = localTime + this.startTime;
21599
21614
  // end state changed, handle onEnd flags
21600
21615
  if (this.isEnded !== isEnded) {
21601
21616
  if (isEnded) {
@@ -22802,6 +22817,7 @@ exports.SpriteComponent = /*#__PURE__*/ function(BaseRenderComponent) {
22802
22817
  _this.engine.renderErrors.add(e);
22803
22818
  });
22804
22819
  }
22820
+ this.renderer.texture.uploadCurrentVideoFrame();
22805
22821
  }
22806
22822
  if (ta) {
22807
22823
  var _this_material_getVector4;
@@ -26815,10 +26831,10 @@ var SerializationHelper = /*#__PURE__*/ function() {
26815
26831
  }
26816
26832
  var _proto = AssetLoader.prototype;
26817
26833
  _proto.loadGUID = function loadGUID(dataPath) {
26818
- var guid = dataPath.id;
26819
26834
  if (!dataPath) {
26820
26835
  return null;
26821
26836
  }
26837
+ var guid = dataPath.id;
26822
26838
  var effectsObjectData = this.findData(guid);
26823
26839
  var effectsObject;
26824
26840
  if (!effectsObjectData) {
@@ -28398,7 +28414,7 @@ function getStandardSpriteContent(sprite, transform) {
28398
28414
  return ret;
28399
28415
  }
28400
28416
 
28401
- var version$2 = "2.5.0-alpha.1";
28417
+ var version$2 = "2.5.0-alpha.3";
28402
28418
  var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
28403
28419
  var standardVersion = /^(\d+)\.(\d+)$/;
28404
28420
  var reverseParticle = false;
@@ -31648,7 +31664,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem);
31648
31664
  registerPlugin("particle", ParticleLoader, exports.VFXItem);
31649
31665
  registerPlugin("cal", CalculateLoader, exports.VFXItem);
31650
31666
  registerPlugin("interact", InteractLoader, exports.VFXItem);
31651
- var version$1 = "2.5.0-alpha.1";
31667
+ var version$1 = "2.5.0-alpha.3";
31652
31668
  logger.info("Core version: " + version$1 + ".");
31653
31669
 
31654
31670
  var _obj;
@@ -33250,7 +33266,7 @@ setMaxSpriteMeshItemCount(8);
33250
33266
  */ Mesh.create = function(engine, props) {
33251
33267
  return new ThreeMesh(engine, props);
33252
33268
  };
33253
- var version = "2.5.0-alpha.1";
33269
+ var version = "2.5.0-alpha.3";
33254
33270
  logger.info("THREEJS plugin version: " + version + ".");
33255
33271
 
33256
33272
  exports.AbstractPlugin = AbstractPlugin;