@galacean/effects-core 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/camera.d.ts CHANGED
@@ -61,7 +61,7 @@ export declare class Camera {
61
61
  /**
62
62
  * 编辑器用于缩放画布
63
63
  */
64
- private fovScaleRatio;
64
+ private viewportMatrix;
65
65
  private options;
66
66
  private viewMatrix;
67
67
  private projectionMatrix;
@@ -118,8 +118,8 @@ export declare class Camera {
118
118
  */
119
119
  set rotation(value: Euler);
120
120
  get rotation(): Euler;
121
- setFovScaleRatio(value: number): void;
122
- getFovScaleRatio(): number;
121
+ setViewportMatrix(matrix: Matrix4): void;
122
+ getViewportMatrix(): Matrix4;
123
123
  /**
124
124
  * 获取相机的视图变换矩阵
125
125
  * @return
@@ -13,6 +13,7 @@ import type { Texture } from './texture';
13
13
  import type { Disposable, LostHandler } from './utils';
14
14
  import type { VFXItemProps } from './vfx-item';
15
15
  import { VFXItem } from './vfx-item';
16
+ import { type Matrix4 } from '@galacean/effects-math/es/core';
16
17
  export interface CompositionStatistic {
17
18
  loadTime: number;
18
19
  loadStart: number;
@@ -225,8 +226,8 @@ export declare class Composition implements Disposable, LostHandler {
225
226
  * 获取销毁状态
226
227
  */
227
228
  get isDestroyed(): boolean;
228
- set editorScaleRatio(value: number);
229
- get editorScaleRatio(): number;
229
+ set viewportMatrix(matrix: Matrix4);
230
+ get viewportMatrix(): Matrix4;
230
231
  /**
231
232
  * 获取合成的时长
232
233
  */
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.0.0-alpha.23
6
+ * Version: v2.0.0-alpha.25
7
7
  */
8
8
 
9
9
  'use strict';
@@ -8875,6 +8875,7 @@ exports.MaterialRenderType = void 0;
8875
8875
  var _this;
8876
8876
  _this = EffectsObject.call(this, engine) || this;
8877
8877
  _this.stringTags = {};
8878
+ _this.enabledMacros = {};
8878
8879
  _this.destroyed = false;
8879
8880
  _this.initialized = false;
8880
8881
  if (props) {
@@ -16391,6 +16392,9 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
16391
16392
  return _this;
16392
16393
  }
16393
16394
  var _proto = ParticleSystem.prototype;
16395
+ _proto.isFrozen = function isFrozen() {
16396
+ return this.frozen;
16397
+ };
16394
16398
  _proto.initEmitterTransform = function initEmitterTransform() {
16395
16399
  var position = this.item.transform.position.clone();
16396
16400
  var rotation = this.item.transform.rotation.clone();
@@ -16524,6 +16528,7 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
16524
16528
  return b.reset();
16525
16529
  });
16526
16530
  this.frozen = false;
16531
+ this.ended = false;
16527
16532
  };
16528
16533
  _proto.onUpdate = function onUpdate(delta) {
16529
16534
  var _this = this;
@@ -17307,10 +17312,7 @@ function randomArrItem(arr, keepArr) {
17307
17312
  */ var ParticleBehaviourPlayable = /*#__PURE__*/ function(Playable) {
17308
17313
  _inherits(ParticleBehaviourPlayable, Playable);
17309
17314
  function ParticleBehaviourPlayable() {
17310
- var _this;
17311
- _this = Playable.apply(this, arguments) || this;
17312
- _this.lastTime = 0;
17313
- return _this;
17315
+ return Playable.apply(this, arguments);
17314
17316
  }
17315
17317
  var _proto = ParticleBehaviourPlayable.prototype;
17316
17318
  _proto.start = function start(context) {
@@ -17335,13 +17337,11 @@ function randomArrItem(arr, keepArr) {
17335
17337
  // particleSystem.setParentTransform(parentItem.transform);
17336
17338
  particleSystem.setVisible(true);
17337
17339
  var deltaTime = context.deltaTime;
17338
- // 直接用 this.lastTime - this.time 获取 deltaTime 会有精度问题
17339
- if (this.lastTime === this.time) {
17340
- deltaTime = 0;
17340
+ if (this.time < particleSystem.item.duration && particleSystem.isFrozen()) {
17341
+ particleSystem.reset();
17341
17342
  }
17342
17343
  particleSystem.onUpdate(deltaTime);
17343
17344
  }
17344
- this.lastTime = this.time;
17345
17345
  };
17346
17346
  return ParticleBehaviourPlayable;
17347
17347
  }(Playable);
@@ -18721,9 +18721,9 @@ var AnimationClipPlayable = /*#__PURE__*/ function(Playable) {
18721
18721
  var localTime = time - this.start;
18722
18722
  var duration = this.duration;
18723
18723
  if (localTime - duration > 0.001) {
18724
- if (this.endBehaviour === ItemEndBehavior.loop) {
18724
+ if (this.endBehavior === ItemEndBehavior.loop) {
18725
18725
  localTime = localTime % duration;
18726
- } else if (this.endBehaviour === ItemEndBehavior.freeze) {
18726
+ } else if (this.endBehavior === ItemEndBehavior.freeze) {
18727
18727
  localTime = Math.min(duration, localTime);
18728
18728
  }
18729
18729
  }
@@ -18848,9 +18848,9 @@ var RuntimeClip = /*#__PURE__*/ function() {
18848
18848
  var weight = 1.0;
18849
18849
  var ended = false;
18850
18850
  var started = false;
18851
- var boundItem = this.track.binding;
18852
- if (localTime > clip.start + clip.duration + 0.001 && clip.endBehaviour === ItemEndBehavior.destroy) {
18853
- if (exports.VFXItem.isParticle(boundItem) && this.particleSystem && !this.particleSystem.destroyed) {
18851
+ var boundObject = this.track.binding;
18852
+ if (localTime > clip.start + clip.duration + 0.001 && clip.endBehavior === ItemEndBehavior.destroy) {
18853
+ if (_instanceof1(boundObject, exports.VFXItem) && exports.VFXItem.isParticle(boundObject) && this.particleSystem && !this.particleSystem.destroyed) {
18854
18854
  weight = 1.0;
18855
18855
  } else {
18856
18856
  weight = 0.0;
@@ -18867,25 +18867,22 @@ var RuntimeClip = /*#__PURE__*/ function() {
18867
18867
  }
18868
18868
  this.parentMixer.setInputWeight(this.playable, weight);
18869
18869
  // 判断动画是否结束
18870
- if (ended && !boundItem.ended) {
18871
- boundItem.ended = true;
18872
- boundItem.onEnd();
18873
- }
18874
- if (ended && this.playable.getPlayState() === PlayState.Playing) {
18875
- this.playable.pause();
18876
- this.onClipEnd();
18870
+ if (ended) {
18871
+ if (_instanceof1(boundObject, exports.VFXItem) && !boundObject.ended) {
18872
+ boundObject.ended = true;
18873
+ boundObject.onEnd();
18874
+ if (!boundObject.compositionReusable && !boundObject.reusable) {
18875
+ boundObject.dispose();
18876
+ this.playable.dispose();
18877
+ }
18878
+ }
18879
+ if (this.playable.getPlayState() === PlayState.Playing) {
18880
+ this.playable.pause();
18881
+ }
18877
18882
  }
18878
18883
  var clipTime = clip.toLocalTime(localTime);
18879
18884
  this.playable.setTime(clipTime);
18880
18885
  };
18881
- _proto.onClipEnd = function onClipEnd() {
18882
- var boundItem = this.track.binding;
18883
- if (!boundItem.compositionReusable && !boundItem.reusable) {
18884
- boundItem.dispose();
18885
- this.playable.dispose();
18886
- return;
18887
- }
18888
- };
18889
18886
  _create_class(RuntimeClip, [
18890
18887
  {
18891
18888
  key: "enable",
@@ -18917,7 +18914,7 @@ exports.ObjectBindingTrack = /*#__PURE__*/ function(TrackAsset1) {
18917
18914
  var particleClip = particleTrack.createClip(ParticleBehaviourPlayableAsset);
18918
18915
  particleClip.start = boundItem.start;
18919
18916
  particleClip.duration = boundItem.duration;
18920
- particleClip.endBehaviour = boundItem.endBehavior;
18917
+ particleClip.endBehavior = boundItem.endBehavior;
18921
18918
  }
18922
18919
  };
18923
18920
  return ObjectBindingTrack;
@@ -19218,7 +19215,7 @@ function compareTracks(a, b) {
19218
19215
  if (!props) {
19219
19216
  throw new Error("Referenced precomposition with Id: " + refId + " does not exist.");
19220
19217
  }
19221
- // endBehaviour 类型需优化
19218
+ // endBehavior 类型需优化
19222
19219
  props.content = itemData.content;
19223
19220
  item = assetLoader.loadGUID(itemData.id);
19224
19221
  item.composition = this.item.composition;
@@ -22230,7 +22227,7 @@ function getStandardCameraContent(model) {
22230
22227
  */ function version30Migration(json) {
22231
22228
  var _loop = function() {
22232
22229
  var composition = _step1.value;
22233
- // composition 的 endbehaviour 兼容
22230
+ // composition 的 endBehavior 兼容
22234
22231
  if (composition.endBehavior === CompositionEndBehavior.pause_destroy || composition.endBehavior === CompositionEndBehavior.pause) {
22235
22232
  composition.endBehavior = END_BEHAVIOR_FREEZE;
22236
22233
  }
@@ -22616,7 +22613,7 @@ function convertTimelineAsset(composition, guidToItemMap, jsonScene) {
22616
22613
  {
22617
22614
  start: item.delay,
22618
22615
  duration: item.duration,
22619
- endBehaviour: item.endBehavior,
22616
+ endBehavior: item.endBehavior,
22620
22617
  asset: {
22621
22618
  id: newActivationPlayableAsset.id
22622
22619
  }
@@ -22647,7 +22644,7 @@ function convertTimelineAsset(composition, guidToItemMap, jsonScene) {
22647
22644
  {
22648
22645
  start: item.delay,
22649
22646
  duration: item.duration,
22650
- endBehaviour: item.endBehavior,
22647
+ endBehavior: item.endBehavior,
22651
22648
  asset: {
22652
22649
  id: newTransformPlayableAssetData.id
22653
22650
  }
@@ -22675,7 +22672,7 @@ function convertTimelineAsset(composition, guidToItemMap, jsonScene) {
22675
22672
  {
22676
22673
  start: item.delay,
22677
22674
  duration: item.duration,
22678
- endBehaviour: item.endBehavior,
22675
+ endBehavior: item.endBehavior,
22679
22676
  asset: {
22680
22677
  id: newSpriteColorPlayableAssetData.id
22681
22678
  }
@@ -22701,7 +22698,7 @@ function convertTimelineAsset(composition, guidToItemMap, jsonScene) {
22701
22698
  {
22702
22699
  start: item.delay,
22703
22700
  duration: item.duration,
22704
- endBehaviour: item.endBehavior,
22701
+ endBehavior: item.endBehavior,
22705
22702
  asset: {
22706
22703
  id: newSubCompositionPlayableAssetData.id
22707
22704
  }
@@ -24043,7 +24040,7 @@ var tmpScale = new Vector3(1, 1, 1);
24043
24040
  function Camera(name, options) {
24044
24041
  if (options === void 0) options = {};
24045
24042
  this.name = name;
24046
- this.fovScaleRatio = 1.0;
24043
+ this.viewportMatrix = Matrix4.fromIdentity();
24047
24044
  this.viewMatrix = Matrix4.fromIdentity();
24048
24045
  this.projectionMatrix = Matrix4.fromIdentity();
24049
24046
  this.viewProjectionMatrix = Matrix4.fromIdentity();
@@ -24071,12 +24068,12 @@ var tmpScale = new Vector3(1, 1, 1);
24071
24068
  this.updateMatrix();
24072
24069
  }
24073
24070
  var _proto = Camera.prototype;
24074
- _proto.setFovScaleRatio = function setFovScaleRatio(value) {
24075
- this.fovScaleRatio = value;
24071
+ _proto.setViewportMatrix = function setViewportMatrix(matrix) {
24072
+ this.viewportMatrix = matrix.clone();
24076
24073
  this.dirty = true;
24077
24074
  };
24078
- _proto.getFovScaleRatio = function getFovScaleRatio() {
24079
- return this.fovScaleRatio;
24075
+ _proto.getViewportMatrix = function getViewportMatrix() {
24076
+ return this.viewportMatrix;
24080
24077
  };
24081
24078
  /**
24082
24079
  * 获取相机的视图变换矩阵
@@ -24198,7 +24195,8 @@ var tmpScale = new Vector3(1, 1, 1);
24198
24195
  */ _proto.updateMatrix = function updateMatrix() {
24199
24196
  if (this.dirty) {
24200
24197
  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;
24201
- this.projectionMatrix.perspective(fov * DEG2RAD * this.fovScaleRatio, aspect, near, far, clipMode === CameraClipMode.portrait);
24198
+ this.projectionMatrix.perspective(fov * DEG2RAD, aspect, near, far, clipMode === CameraClipMode.portrait);
24199
+ this.projectionMatrix.premultiply(this.viewportMatrix);
24202
24200
  this.inverseViewMatrix.compose(position, this.getQuat(), tmpScale);
24203
24201
  this.viewMatrix.copyFrom(this.inverseViewMatrix).invert();
24204
24202
  this.viewProjectionMatrix.multiplyMatrices(this.projectionMatrix, this.viewMatrix);
@@ -25313,12 +25311,12 @@ var listOrder = 0;
25313
25311
  }
25314
25312
  },
25315
25313
  {
25316
- key: "editorScaleRatio",
25314
+ key: "viewportMatrix",
25317
25315
  get: function get() {
25318
- return this.camera.getFovScaleRatio();
25316
+ return this.camera.getViewportMatrix();
25319
25317
  },
25320
- set: function set(value) {
25321
- this.camera.setFovScaleRatio(value);
25318
+ set: function set(matrix) {
25319
+ this.camera.setViewportMatrix(matrix);
25322
25320
  }
25323
25321
  }
25324
25322
  ]);
@@ -25717,7 +25715,7 @@ registerPlugin("sprite", SpriteLoader, exports.VFXItem, true);
25717
25715
  registerPlugin("particle", ParticleLoader, exports.VFXItem, true);
25718
25716
  registerPlugin("cal", CalculateLoader, exports.VFXItem, true);
25719
25717
  registerPlugin("interact", InteractLoader, exports.VFXItem, true);
25720
- var version = "2.0.0-alpha.23";
25718
+ var version = "2.0.0-alpha.25";
25721
25719
  logger.info("Core version: " + version + ".");
25722
25720
 
25723
25721
  exports.AbstractPlugin = AbstractPlugin;