@galacean/effects-plugin-model 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.
@@ -1,12 +1,12 @@
1
1
  import { spec, Downloader } from '@galacean/effects';
2
- import type { Engine, Player, Renderer, GeometryProps } from '@galacean/effects';
2
+ import type { Engine, Renderer, GeometryProps } from '@galacean/effects';
3
3
  export declare class JSONConverter {
4
+ renderer: Renderer;
4
5
  newScene: spec.JSONScene;
5
6
  engine: Engine;
6
- renderer: Renderer;
7
7
  downloader: Downloader;
8
8
  treeInfo: TreeInfo;
9
- constructor(player: Player);
9
+ constructor(renderer: Renderer);
10
10
  processScene(sceneData: string | Record<string | symbol, unknown>): Promise<spec.JSONScene>;
11
11
  setImage(newScene: spec.JSONScene, oldScene: spec.JSONScene): void;
12
12
  setTexture(newScene: spec.JSONScene, oldScene: spec.JSONScene): Promise<void>;
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * Description: Galacean Effects player model plugin
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';
@@ -1898,6 +1898,9 @@ var deg2rad = Math.PI / 180;
1898
1898
  * Y 轴上视角
1899
1899
  */ _this.fov = 45;
1900
1900
  /**
1901
+ * 视图矩阵
1902
+ */ _this.viewportMatrix = Matrix4.fromIdentity();
1903
+ /**
1901
1904
  * 纵横比
1902
1905
  */ _this.aspect = 1.0;
1903
1906
  /**
@@ -1938,6 +1941,7 @@ var deg2rad = Math.PI / 180;
1938
1941
  }
1939
1942
  var reverse = this.clipMode === EFFECTS.spec.CameraClipMode.portrait;
1940
1943
  this.projectionMatrix.perspective(this.fov * deg2rad, this.aspect, this.nearPlane, this.farPlane, reverse);
1944
+ this.projectionMatrix.premultiply(this.viewportMatrix);
1941
1945
  this.viewMatrix = this.matrix.invert();
1942
1946
  };
1943
1947
  /**
@@ -1946,7 +1950,7 @@ var deg2rad = Math.PI / 180;
1946
1950
  * @returns 投影矩阵
1947
1951
  */ _proto.getNewProjectionMatrix = function getNewProjectionMatrix(fov) {
1948
1952
  var reverse = this.clipMode === EFFECTS.spec.CameraClipMode.portrait;
1949
- return new Matrix4().perspective(Math.min(fov * 1.25, 140) * deg2rad, this.aspect, this.nearPlane, this.farPlane, reverse);
1953
+ return new Matrix4().perspective(Math.min(fov * 1.25, 140) * deg2rad, this.aspect, this.nearPlane, this.farPlane, reverse).premultiply(this.viewportMatrix);
1950
1954
  };
1951
1955
  /**
1952
1956
  * 计算视角中的包围盒大小
@@ -2083,15 +2087,17 @@ var deg2rad = Math.PI / 180;
2083
2087
  };
2084
2088
  /**
2085
2089
  * 更新默认相机状态,并计算新的透视和相机矩阵
2086
- * @param fovy - 视角
2090
+ * @param fov - 视角
2091
+ * @param viewportMatrix - 视图矩阵
2087
2092
  * @param aspect - 纵横比
2088
2093
  * @param nearPlane - 近裁剪平面
2089
2094
  * @param farPlane - 远裁剪平面
2090
2095
  * @param position - 位置
2091
2096
  * @param rotation - 旋转
2092
2097
  * @param clipMode - 剪裁模式
2093
- */ _proto.updateDefaultCamera = function updateDefaultCamera(fovy, aspect, nearPlane, farPlane, position, rotation, clipMode) {
2094
- this.defaultCamera.fov = fovy;
2098
+ */ _proto.updateDefaultCamera = function updateDefaultCamera(fov, viewportMatrix, aspect, nearPlane, farPlane, position, rotation, clipMode) {
2099
+ this.defaultCamera.fov = fov;
2100
+ this.defaultCamera.viewportMatrix = viewportMatrix.clone();
2095
2101
  this.defaultCamera.aspect = aspect;
2096
2102
  this.defaultCamera.nearPlane = nearPlane;
2097
2103
  this.defaultCamera.farPlane = farPlane;
@@ -3759,12 +3765,12 @@ var EffectsMeshProxy = /*#__PURE__*/ function() {
3759
3765
  /**
3760
3766
  * 更新默认相机状态,根据传入的相机参数
3761
3767
  * @param camera - 相机参数
3762
- */ _proto.updateDefaultCamera = function updateDefaultCamera(camera) {
3768
+ */ _proto.updateDefaultCamera = function updateDefaultCamera(camera, viewportMatrix) {
3763
3769
  var effectsTransfrom = new EFFECTS.Transform(_extends({}, camera, {
3764
3770
  valid: true
3765
3771
  }));
3766
3772
  var newTransform = new PTransform().fromEffectsTransform(effectsTransfrom);
3767
- this.cameraManager.updateDefaultCamera(camera.fov, camera.aspect, camera.near, camera.far, newTransform.getPosition(), newTransform.getRotation(), camera.clipMode);
3773
+ this.cameraManager.updateDefaultCamera(camera.fov, viewportMatrix, camera.aspect, camera.near, camera.far, newTransform.getPosition(), newTransform.getRotation(), camera.clipMode);
3768
3774
  };
3769
3775
  /**
3770
3776
  * 更新插件场景,需要更新内部的相关的插件对象,特别是 Mesh 对象的骨骼动画
@@ -9906,7 +9912,7 @@ exports.ModelPluginComponent = /*#__PURE__*/ function(ItemBehaviour) {
9906
9912
  * @param composition - 当前合成对象
9907
9913
  * @param sceneManager - 当前合成对象绑定的 SceneManager
9908
9914
  */ _proto.updateSceneCamera = function updateSceneCamera(composition) {
9909
- this.scene.updateDefaultCamera(composition.camera.getOptions());
9915
+ this.scene.updateDefaultCamera(composition.camera.getOptions(), composition.camera.getViewportMatrix());
9910
9916
  };
9911
9917
  _proto.getLightItemCount = function getLightItemCount() {
9912
9918
  var _this_item_composition;
@@ -10661,10 +10667,10 @@ var LoaderHelper = /*#__PURE__*/ function() {
10661
10667
  }();
10662
10668
 
10663
10669
  var JSONConverter = /*#__PURE__*/ function() {
10664
- function JSONConverter(player) {
10670
+ function JSONConverter(renderer) {
10671
+ this.renderer = renderer;
10665
10672
  this.treeInfo = new TreeInfo();
10666
- this.engine = player.renderer.engine;
10667
- this.renderer = player.renderer;
10673
+ this.engine = renderer.engine;
10668
10674
  this.downloader = new EFFECTS.Downloader();
10669
10675
  }
10670
10676
  var _proto = JSONConverter.prototype;
@@ -13782,7 +13788,7 @@ var GLTFHelper = /*#__PURE__*/ function() {
13782
13788
 
13783
13789
  EFFECTS.registerPlugin("tree", ModelTreePlugin, EFFECTS.VFXItem, true);
13784
13790
  EFFECTS.registerPlugin("model", ModelPlugin, EFFECTS.VFXItem);
13785
- var version = "2.0.0-alpha.23";
13791
+ var version = "2.0.0-alpha.25";
13786
13792
  EFFECTS.logger.info("Plugin model version: " + version + ".");
13787
13793
  if (version !== EFFECTS__namespace.version) {
13788
13794
  console.error("注意:请统一 Model 插件与 Player 版本,不统一的版本混用会有不可预知的后果!", "\nAttention: Please ensure the Model plugin is synchronized with the Player version. Mixing and matching incompatible versions may result in unpredictable consequences!");