Browse Source

记录和还原视角

dev
刘向辉 3 years ago
parent
commit
83e4806bbf
  1. 83
      src/app/babylon/tool/babylon-tool.ts
  2. 7
      src/app/babylon/view/building-window/building-window.ts
  3. 1
      src/app/babylon/view/toolbar-window/toobar-window.ts

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

@ -288,6 +288,89 @@ export class BabylonTool {
}
public static AnimMoveCameraTargetAB(
camera: ArcRotateCamera,
allFrame: number,
target: Vector3,
radius: number,
alpha: number,
beta: number,
) {
//缓动动画
let easingFunction = new QuadraticEase();
easingFunction.setEasingMode(EasingFunction.EASINGMODE_EASEOUT);
//target
let anim_target = new Animation(
'CameraAnim_target',
'target',
60,
Animation.ANIMATIONTYPE_VECTOR3,
Animation.ANIMATIONLOOPMODE_CYCLE
);
let keys_target = [
{ frame: 0, value: camera.target },
{ frame: allFrame, value: target },
];
anim_target.setKeys(keys_target);
anim_target.setEasingFunction(easingFunction);
//radius
let anim_radius = new Animation(
'CameraAnim_radius',
'radius',
60,
Animation.ANIMATIONTYPE_FLOAT,
Animation.ANIMATIONLOOPMODE_CYCLE
);
let keys_radius = [
{ frame: 0, value: camera.radius },
{ frame: allFrame, value: radius },
];
anim_radius.setKeys(keys_radius);
anim_radius.setEasingFunction(easingFunction);
//beta
let anim_a = new Animation(
'CameraAnim_a',
'alpha',
60,
Animation.ANIMATIONTYPE_FLOAT,
Animation.ANIMATIONLOOPMODE_CYCLE
);
let keys_a = [
{ frame: 0, value: camera.alpha },
{ frame: allFrame, value: alpha },
];
anim_a.setKeys(keys_a);
//beta
let anim_b = new Animation(
'CameraAnim_b',
'beta',
60,
Animation.ANIMATIONTYPE_FLOAT,
Animation.ANIMATIONLOOPMODE_CYCLE
);
let keys_b = [
{ frame: 0, value: camera.beta },
{ frame: allFrame, value: beta },
];
anim_b.setKeys(keys_b);
camera.animations = [];
camera.animations.push(anim_target);
camera.animations.push(anim_radius);
camera.animations.push(anim_a);
camera.animations.push(anim_b);
camera._scene.beginAnimation(camera, 0, allFrame, false);
}
//动画移动摄像机target
public static AnimMoveCameraTarget(
camera: ArcRotateCamera,

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

@ -18,6 +18,7 @@ import { BuildingInfo_Environment } from "../../model/info/building/building-inf
import { BuildingInfo_Normal } from "../../model/info/building/building-info-normal";
import { ModelInfo_building } from "../../model/info/model/model-info-building";
import { FacilityInfoByType } from "../../model/info/model/model-info-facility";
import { BabylonTool } from "../../tool/babylon-tool";
import { TsTool } from "../../tool/ts-tool";
import { UIBase } from "../window-base/ui-base";
import { BuildingUIItem } from "./building-ui-item";
@ -240,8 +241,12 @@ export class BuildingWindow extends UIBase {
else {//恢复查看状态
let showData = DataManager.institutionData.getMoudleShowData(type);
if (showData != null) {
showData.cameraData.setDataToCamera(SceneManager.Instance.defaultCamera);
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;
}
}
}

1
src/app/babylon/view/toolbar-window/toobar-window.ts

@ -125,6 +125,7 @@ export class ToolbarWindow extends UIBase {
*/
saveShowMoudleData() {
BuildingWindow.instance.saveShowMoudleData();
PlanComponent.instance.openSnackBar("记录当前视角");
}
//#endregion

Loading…
Cancel
Save