diff --git a/src/app/babylon/tool/babylon-tool.ts b/src/app/babylon/tool/babylon-tool.ts index b340304..8369ff6 100644 --- a/src/app/babylon/tool/babylon-tool.ts +++ b/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, diff --git a/src/app/babylon/view/building-window/building-window.ts b/src/app/babylon/view/building-window/building-window.ts index e4d3f05..ccc6d04 100644 --- a/src/app/babylon/view/building-window/building-window.ts +++ b/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; } } } diff --git a/src/app/babylon/view/toolbar-window/toobar-window.ts b/src/app/babylon/view/toolbar-window/toobar-window.ts index 134ae3b..ba52b8a 100644 --- a/src/app/babylon/view/toolbar-window/toobar-window.ts +++ b/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