@galacean/effects-threejs 2.0.0-alpha.23 → 2.0.0-alpha.25

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.23
6
+ * Version: v2.0.0-alpha.25
7
7
  */
8
8
 
9
9
  'use strict';
@@ -8897,6 +8897,7 @@ exports.MaterialRenderType = void 0;
8897
8897
  var _this;
8898
8898
  _this = EffectsObject.call(this, engine) || this;
8899
8899
  _this.stringTags = {};
8900
+ _this.enabledMacros = {};
8900
8901
  _this.destroyed = false;
8901
8902
  _this.initialized = false;
8902
8903
  if (props) {
@@ -16413,6 +16414,9 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
16413
16414
  return _this;
16414
16415
  }
16415
16416
  var _proto = ParticleSystem.prototype;
16417
+ _proto.isFrozen = function isFrozen() {
16418
+ return this.frozen;
16419
+ };
16416
16420
  _proto.initEmitterTransform = function initEmitterTransform() {
16417
16421
  var position = this.item.transform.position.clone();
16418
16422
  var rotation = this.item.transform.rotation.clone();
@@ -16546,6 +16550,7 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
16546
16550
  return b.reset();
16547
16551
  });
16548
16552
  this.frozen = false;
16553
+ this.ended = false;
16549
16554
  };
16550
16555
  _proto.onUpdate = function onUpdate(delta) {
16551
16556
  var _this = this;
@@ -17329,10 +17334,7 @@ function randomArrItem(arr, keepArr) {
17329
17334
  */ var ParticleBehaviourPlayable = /*#__PURE__*/ function(Playable) {
17330
17335
  _inherits(ParticleBehaviourPlayable, Playable);
17331
17336
  function ParticleBehaviourPlayable() {
17332
- var _this;
17333
- _this = Playable.apply(this, arguments) || this;
17334
- _this.lastTime = 0;
17335
- return _this;
17337
+ return Playable.apply(this, arguments);
17336
17338
  }
17337
17339
  var _proto = ParticleBehaviourPlayable.prototype;
17338
17340
  _proto.start = function start(context) {
@@ -17357,13 +17359,11 @@ function randomArrItem(arr, keepArr) {
17357
17359
  // particleSystem.setParentTransform(parentItem.transform);
17358
17360
  particleSystem.setVisible(true);
17359
17361
  var deltaTime = context.deltaTime;
17360
- // 直接用 this.lastTime - this.time 获取 deltaTime 会有精度问题
17361
- if (this.lastTime === this.time) {
17362
- deltaTime = 0;
17362
+ if (this.time < particleSystem.item.duration && particleSystem.isFrozen()) {
17363
+ particleSystem.reset();
17363
17364
  }
17364
17365
  particleSystem.onUpdate(deltaTime);
17365
17366
  }
17366
- this.lastTime = this.time;
17367
17367
  };
17368
17368
  return ParticleBehaviourPlayable;
17369
17369
  }(Playable);
@@ -18743,9 +18743,9 @@ var AnimationClipPlayable = /*#__PURE__*/ function(Playable) {
18743
18743
  var localTime = time - this.start;
18744
18744
  var duration = this.duration;
18745
18745
  if (localTime - duration > 0.001) {
18746
- if (this.endBehaviour === ItemEndBehavior.loop) {
18746
+ if (this.endBehavior === ItemEndBehavior.loop) {
18747
18747
  localTime = localTime % duration;
18748
- } else if (this.endBehaviour === ItemEndBehavior.freeze) {
18748
+ } else if (this.endBehavior === ItemEndBehavior.freeze) {
18749
18749
  localTime = Math.min(duration, localTime);
18750
18750
  }
18751
18751
  }
@@ -18870,9 +18870,9 @@ var RuntimeClip = /*#__PURE__*/ function() {
18870
18870
  var weight = 1.0;
18871
18871
  var ended = false;
18872
18872
  var started = false;
18873
- var boundItem = this.track.binding;
18874
- if (localTime > clip.start + clip.duration + 0.001 && clip.endBehaviour === ItemEndBehavior.destroy) {
18875
- if (exports.VFXItem.isParticle(boundItem) && this.particleSystem && !this.particleSystem.destroyed) {
18873
+ var boundObject = this.track.binding;
18874
+ if (localTime > clip.start + clip.duration + 0.001 && clip.endBehavior === ItemEndBehavior.destroy) {
18875
+ if (_instanceof1(boundObject, exports.VFXItem) && exports.VFXItem.isParticle(boundObject) && this.particleSystem && !this.particleSystem.destroyed) {
18876
18876
  weight = 1.0;
18877
18877
  } else {
18878
18878
  weight = 0.0;
@@ -18889,25 +18889,22 @@ var RuntimeClip = /*#__PURE__*/ function() {
18889
18889
  }
18890
18890
  this.parentMixer.setInputWeight(this.playable, weight);
18891
18891
  // 判断动画是否结束
18892
- if (ended && !boundItem.ended) {
18893
- boundItem.ended = true;
18894
- boundItem.onEnd();
18895
- }
18896
- if (ended && this.playable.getPlayState() === PlayState.Playing) {
18897
- this.playable.pause();
18898
- this.onClipEnd();
18892
+ if (ended) {
18893
+ if (_instanceof1(boundObject, exports.VFXItem) && !boundObject.ended) {
18894
+ boundObject.ended = true;
18895
+ boundObject.onEnd();
18896
+ if (!boundObject.compositionReusable && !boundObject.reusable) {
18897
+ boundObject.dispose();
18898
+ this.playable.dispose();
18899
+ }
18900
+ }
18901
+ if (this.playable.getPlayState() === PlayState.Playing) {
18902
+ this.playable.pause();
18903
+ }
18899
18904
  }
18900
18905
  var clipTime = clip.toLocalTime(localTime);
18901
18906
  this.playable.setTime(clipTime);
18902
18907
  };
18903
- _proto.onClipEnd = function onClipEnd() {
18904
- var boundItem = this.track.binding;
18905
- if (!boundItem.compositionReusable && !boundItem.reusable) {
18906
- boundItem.dispose();
18907
- this.playable.dispose();
18908
- return;
18909
- }
18910
- };
18911
18908
  _create_class(RuntimeClip, [
18912
18909
  {
18913
18910
  key: "enable",
@@ -18939,7 +18936,7 @@ exports.ObjectBindingTrack = /*#__PURE__*/ function(TrackAsset1) {
18939
18936
  var particleClip = particleTrack.createClip(ParticleBehaviourPlayableAsset);
18940
18937
  particleClip.start = boundItem.start;
18941
18938
  particleClip.duration = boundItem.duration;
18942
- particleClip.endBehaviour = boundItem.endBehavior;
18939
+ particleClip.endBehavior = boundItem.endBehavior;
18943
18940
  }
18944
18941
  };
18945
18942
  return ObjectBindingTrack;
@@ -19240,7 +19237,7 @@ function compareTracks(a, b) {
19240
19237
  if (!props) {
19241
19238
  throw new Error("Referenced precomposition with Id: " + refId + " does not exist.");
19242
19239
  }
19243
- // endBehaviour 类型需优化
19240
+ // endBehavior 类型需优化
19244
19241
  props.content = itemData.content;
19245
19242
  item = assetLoader.loadGUID(itemData.id);
19246
19243
  item.composition = this.item.composition;
@@ -22252,7 +22249,7 @@ function getStandardCameraContent(model) {
22252
22249
  */ function version30Migration(json) {
22253
22250
  var _loop = function() {
22254
22251
  var composition = _step1.value;
22255
- // composition 的 endbehaviour 兼容
22252
+ // composition 的 endBehavior 兼容
22256
22253
  if (composition.endBehavior === CompositionEndBehavior.pause_destroy || composition.endBehavior === CompositionEndBehavior.pause) {
22257
22254
  composition.endBehavior = END_BEHAVIOR_FREEZE;
22258
22255
  }
@@ -22638,7 +22635,7 @@ function convertTimelineAsset(composition, guidToItemMap, jsonScene) {
22638
22635
  {
22639
22636
  start: item.delay,
22640
22637
  duration: item.duration,
22641
- endBehaviour: item.endBehavior,
22638
+ endBehavior: item.endBehavior,
22642
22639
  asset: {
22643
22640
  id: newActivationPlayableAsset.id
22644
22641
  }
@@ -22669,7 +22666,7 @@ function convertTimelineAsset(composition, guidToItemMap, jsonScene) {
22669
22666
  {
22670
22667
  start: item.delay,
22671
22668
  duration: item.duration,
22672
- endBehaviour: item.endBehavior,
22669
+ endBehavior: item.endBehavior,
22673
22670
  asset: {
22674
22671
  id: newTransformPlayableAssetData.id
22675
22672
  }
@@ -22697,7 +22694,7 @@ function convertTimelineAsset(composition, guidToItemMap, jsonScene) {
22697
22694
  {
22698
22695
  start: item.delay,
22699
22696
  duration: item.duration,
22700
- endBehaviour: item.endBehavior,
22697
+ endBehavior: item.endBehavior,
22701
22698
  asset: {
22702
22699
  id: newSpriteColorPlayableAssetData.id
22703
22700
  }
@@ -22723,7 +22720,7 @@ function convertTimelineAsset(composition, guidToItemMap, jsonScene) {
22723
22720
  {
22724
22721
  start: item.delay,
22725
22722
  duration: item.duration,
22726
- endBehaviour: item.endBehavior,
22723
+ endBehavior: item.endBehavior,
22727
22724
  asset: {
22728
22725
  id: newSubCompositionPlayableAssetData.id
22729
22726
  }
@@ -24065,7 +24062,7 @@ var tmpScale = new Vector3(1, 1, 1);
24065
24062
  function Camera(name, options) {
24066
24063
  if (options === void 0) options = {};
24067
24064
  this.name = name;
24068
- this.fovScaleRatio = 1.0;
24065
+ this.viewportMatrix = Matrix4.fromIdentity();
24069
24066
  this.viewMatrix = Matrix4.fromIdentity();
24070
24067
  this.projectionMatrix = Matrix4.fromIdentity();
24071
24068
  this.viewProjectionMatrix = Matrix4.fromIdentity();
@@ -24093,12 +24090,12 @@ var tmpScale = new Vector3(1, 1, 1);
24093
24090
  this.updateMatrix();
24094
24091
  }
24095
24092
  var _proto = Camera.prototype;
24096
- _proto.setFovScaleRatio = function setFovScaleRatio(value) {
24097
- this.fovScaleRatio = value;
24093
+ _proto.setViewportMatrix = function setViewportMatrix(matrix) {
24094
+ this.viewportMatrix = matrix.clone();
24098
24095
  this.dirty = true;
24099
24096
  };
24100
- _proto.getFovScaleRatio = function getFovScaleRatio() {
24101
- return this.fovScaleRatio;
24097
+ _proto.getViewportMatrix = function getViewportMatrix() {
24098
+ return this.viewportMatrix;
24102
24099
  };
24103
24100
  /**
24104
24101
  * 获取相机的视图变换矩阵
@@ -24220,7 +24217,8 @@ var tmpScale = new Vector3(1, 1, 1);
24220
24217
  */ _proto.updateMatrix = function updateMatrix() {
24221
24218
  if (this.dirty) {
24222
24219
  var _this_options = this.options, fov = _this_options.fov, aspect = _this_options.aspect, near = _this_options.near, far = _this_options.far, clipMode = _this_options.clipMode, position = _this_options.position;
24223
- this.projectionMatrix.perspective(fov * DEG2RAD * this.fovScaleRatio, aspect, near, far, clipMode === CameraClipMode.portrait);
24220
+ this.projectionMatrix.perspective(fov * DEG2RAD, aspect, near, far, clipMode === CameraClipMode.portrait);
24221
+ this.projectionMatrix.premultiply(this.viewportMatrix);
24224
24222
  this.inverseViewMatrix.compose(position, this.getQuat(), tmpScale);
24225
24223
  this.viewMatrix.copyFrom(this.inverseViewMatrix).invert();
24226
24224
  this.viewProjectionMatrix.multiplyMatrices(this.projectionMatrix, this.viewMatrix);
@@ -25335,12 +25333,12 @@ var listOrder = 0;
25335
25333
  }
25336
25334
  },
25337
25335
  {
25338
- key: "editorScaleRatio",
25336
+ key: "viewportMatrix",
25339
25337
  get: function get() {
25340
- return this.camera.getFovScaleRatio();
25338
+ return this.camera.getViewportMatrix();
25341
25339
  },
25342
- set: function set(value) {
25343
- this.camera.setFovScaleRatio(value);
25340
+ set: function set(matrix) {
25341
+ this.camera.setViewportMatrix(matrix);
25344
25342
  }
25345
25343
  }
25346
25344
  ]);
@@ -25739,7 +25737,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem, true);
25739
25737
  registerPlugin("particle", ParticleLoader, exports.VFXItem, true);
25740
25738
  registerPlugin("cal", CalculateLoader, exports.VFXItem, true);
25741
25739
  registerPlugin("interact", InteractLoader, exports.VFXItem, true);
25742
- var version$1 = "2.0.0-alpha.23";
25740
+ var version$1 = "2.0.0-alpha.25";
25743
25741
  logger.info("Core version: " + version$1 + ".");
25744
25742
 
25745
25743
  var _obj;
@@ -27372,7 +27370,7 @@ setMaxSpriteMeshItemCount(8);
27372
27370
  */ Mesh.create = function(engine, props) {
27373
27371
  return new ThreeMesh(engine, props);
27374
27372
  };
27375
- var version = "2.0.0-alpha.23";
27373
+ var version = "2.0.0-alpha.25";
27376
27374
  logger.info("THREEJS plugin version: " + version + ".");
27377
27375
 
27378
27376
  exports.AbstractPlugin = AbstractPlugin;