Browse Source

各模块间视角保存与还原,完成

dev
刘向辉 3 years ago
parent
commit
ac9a7471c6
  1. 1
      src/app/babylon/controller/scene-manager.ts
  2. 9
      src/app/babylon/model/data/camera-data.ts
  3. 7
      src/app/babylon/model/data/institution/jyz-show-data.ts
  4. 3
      src/app/babylon/tool/babylon-tool.ts
  5. 33
      src/app/babylon/view/building-window/building-window.ts

1
src/app/babylon/controller/scene-manager.ts

@ -138,6 +138,7 @@ export class SceneManager {
// camera.upperBetaLimit = 1.5; //beta方向上的旋转限制(防止看到模型底面)
camera.lowerRadiusLimit = 1; //相机距离拍摄目标的最小距离(防止穿插)
camera.setTarget(Vector3.Zero()); //设置拍摄目标
camera.radius = 100;
camera.attachControl(this.canvas, true); //把相机连接到画布
this.defaultCamera = camera;

9
src/app/babylon/model/data/camera-data.ts

@ -12,13 +12,18 @@ export class ArcRotateCameraData {
alpha: number;
beta: number;
constructor() {
this.target = new Vector3();
}
/**
*
* @param camera
*/
setDataToCamera(camera: ArcRotateCamera) {
camera._scene.stopAnimation(camera);
camera.target = this.target;
camera.target = this.target.clone();
camera.radius = this.radius;
camera.alpha = this.alpha;
camera.beta = this.beta;
@ -29,7 +34,7 @@ export class ArcRotateCameraData {
* @param camera
*/
getDataFromCamera(camera: ArcRotateCamera) {
this.target = camera.target;
this.target = camera.target.clone();
this.radius = camera.radius;
this.alpha = camera.alpha;
this.beta = camera.beta;

7
src/app/babylon/model/data/institution/jyz-show-data.ts

@ -16,7 +16,7 @@ export class JYZShowData {
*
*/
@Type(() => ArcRotateCameraData)
cameraData: ArcRotateCameraData;
cameraData: ArcRotateCameraData = new ArcRotateCameraData();
/**
*
@ -26,7 +26,10 @@ export class JYZShowData {
constructor(moudleType: JYZInfoMoudleType, camera: ArcRotateCamera, showZP: boolean) {
this.moudleType = moudleType;
this.cameraData = new ArcRotateCameraData();
this.cameraData.getDataFromCamera(camera);
if (camera != null) {
this.cameraData.getDataFromCamera(camera);
}
}
}

3
src/app/babylon/tool/babylon-tool.ts

@ -288,6 +288,9 @@ export class BabylonTool {
}
/**
* targetalphabeta
*/
public static AnimMoveCameraTargetAB(
camera: ArcRotateCamera,
allFrame: number,

33
src/app/babylon/view/building-window/building-window.ts

@ -239,15 +239,7 @@ export class BuildingWindow extends UIBase {
//进入应急处置
}
else {//恢复查看状态
let showData = DataManager.institutionData.getMoudleShowData(type);
if (showData != null) {
let camera = SceneManager.Instance.defaultCamera;
//showData.cameraData.setDataToCamera(camera);
let cameraData = showData.cameraData;
BabylonTool.AnimMoveCameraTargetAB(camera, 60, cameraData.target, cameraData.radius, cameraData.alpha, cameraData.beta);
this.showZP(showData.showZP);
PlanComponent.instance.isOpenAwning = showData.showZP;
}
this.recoverMoudleShow(type);
}
}
else {
@ -259,6 +251,24 @@ export class BuildingWindow extends UIBase {
}
/**
*
* @param type
*/
recoverMoudleShow(type: JYZInfoMoudleType) {
let showData = DataManager.institutionData.getMoudleShowData(type);
console.log("恢复模块状态", showData);
if (showData != null) {
let camera = SceneManager.Instance.defaultCamera;
//showData.cameraData.setDataToCamera(camera);
let cameraData = showData.cameraData;
BabylonTool.AnimMoveCameraTargetAB(camera, 60, cameraData.target, cameraData.radius, cameraData.alpha, cameraData.beta);
this.showZP(showData.showZP);
PlanComponent.instance.isOpenAwning = showData.showZP;
}
}
//#endregion
@ -345,6 +355,7 @@ export class BuildingWindow extends UIBase {
this.showJYZModules(JYZInfoMoudleType.AQSS, false);
this.showJYZModules(JYZInfoMoudleType.YQHSGX, false);
this.showJYZModules(JYZInfoMoudleType.YQHSGX, false);
this.recoverMoudleShow(null);
//this.onChangeCurrentBuildingItem(item);
@ -503,7 +514,7 @@ export class BuildingWindow extends UIBase {
instance.addBuildings(BuildingType.Normal, 0, (uiItem, index) => {
if (index == 0 && uiItem.buildingInfo.isEnable) {
instance.onChangeCurrentBuildingItem(uiItem, false);
uiItem.lookAt(false);
//uiItem.lookAt(false);
// console.log("默认选中" + uiItem.buildingInfo.buildingData.normalData.key);
}
});
@ -936,10 +947,12 @@ export class BuildingWindow extends UIBase {
}
if (jyzShowData == null) {
jyzShowData = new JYZShowData(moudleType, camera, showZP);
DataManager.institutionData.JYZShowDatas.push(jyzShowData);
}
jyzShowData.moudleType = moudleType;
jyzShowData.cameraData.getDataFromCamera(camera);
jyzShowData.showZP = showZP;
console.log("保存展示数据", DataManager.institutionData.JYZShowDatas);
}

Loading…
Cancel
Save