From 276e3fc26c70dda851ab93dfa2dae0416b9e11e8 Mon Sep 17 00:00:00 2001 From: liuxianghui <519646741@qq.com> Date: Tue, 30 Nov 2021 10:02:51 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E8=AF=95=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/babylon/controller/mode-manager.ts | 2 +- .../babylon/controller/status/login-status.ts | 3 +-- src/app/babylon/tool/babylon-tool.ts | 20 +++++++++++++++++++ .../view/building-window/building-window.ts | 3 ++- src/app/pages/plan/plan.component.ts | 7 ++++--- 5 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/app/babylon/controller/mode-manager.ts b/src/app/babylon/controller/mode-manager.ts index 49ab662..146f793 100644 --- a/src/app/babylon/controller/mode-manager.ts +++ b/src/app/babylon/controller/mode-manager.ts @@ -23,7 +23,7 @@ export class ModeManager { /** * 制作模式代表内部编辑人员,可新增单位、上传模型,查看模式代表交付的模式 */ - public static s_isMakeMode = true; + public static s_isMakeMode = false; /** * 调试模式 diff --git a/src/app/babylon/controller/status/login-status.ts b/src/app/babylon/controller/status/login-status.ts index 2d17a32..839ebb6 100644 --- a/src/app/babylon/controller/status/login-status.ts +++ b/src/app/babylon/controller/status/login-status.ts @@ -229,11 +229,10 @@ export class LoginSatus extends StatusBase { //保存新单位信息至服务器 saveNewIns(status: LoginSatus, insData: InstitutionData, key: string, id: number, onSuccess?: (insDataSimple: InsitutionDataSimple) => void) { - console.log("准备保存新单位"); ServeManager.instance.saveInstitutionData(insData, key, id, (key, result) => { - console.log("在服务器新建单位" + key); let insDataSimple = new InsitutionDataSimple(); insDataSimple.key = key; + insDataSimple.id = id; insDataSimple.name = insData.normalData.name; status.onCreateInsSuccess(insDataSimple); if (onSuccess != null) { diff --git a/src/app/babylon/tool/babylon-tool.ts b/src/app/babylon/tool/babylon-tool.ts index e29d64f..6f49c77 100644 --- a/src/app/babylon/tool/babylon-tool.ts +++ b/src/app/babylon/tool/babylon-tool.ts @@ -348,6 +348,10 @@ export class BabylonTool { beta: number, onAnimationEnd?: () => void ) { + + camera.alpha = BabylonTool.limitPI(camera.alpha); + camera.beta = BabylonTool.limitPI(camera.beta); + //缓动动画 let easingFunction = new QuadraticEase(); easingFunction.setEasingMode(EasingFunction.EASINGMODE_EASEOUT); @@ -422,6 +426,22 @@ export class BabylonTool { } + /** + * 把本值归一化进0-2π之间 + * @param value + */ + public static limitPI(value: number) { + let result = value; + + while (result < 0) { + result += Math.PI * 2; + } + + while (result > Math.PI * 2) { + result -= Math.PI * 2; + } + return result; + } //动画移动摄像机target public static AnimMoveCameraTarget( diff --git a/src/app/babylon/view/building-window/building-window.ts b/src/app/babylon/view/building-window/building-window.ts index 8ba677c..80d4719 100644 --- a/src/app/babylon/view/building-window/building-window.ts +++ b/src/app/babylon/view/building-window/building-window.ts @@ -292,8 +292,9 @@ export class BuildingWindow extends UIBase { PlanComponent.instance.isOpenAwning = showZP; let camera = SceneManager.Instance.defaultCamera; if (cameraData != null) { + this.cameraAnim = BabylonTool.AnimMoveCameraTargetAB(camera, 60, cameraData.target, cameraData.radius, cameraData.alpha, cameraData.beta, onAnimationEnd); - if (Event_LoadingChange.isLoading) { + if (Event_LoadingChange.isLoading) { //加载中,暂停 this.cameraAnim.pause(); } } diff --git a/src/app/pages/plan/plan.component.ts b/src/app/pages/plan/plan.component.ts index 12eac89..b8b394a 100644 --- a/src/app/pages/plan/plan.component.ts +++ b/src/app/pages/plan/plan.component.ts @@ -80,7 +80,7 @@ export class PlanComponent implements OnInit { ngAfterViewInit(): void { this.getGasStationBaseInfo().then((res: any) => { //获取单位 基本信息 - console.log(res, "当前加油站信息") + // console.log(res, "当前加油站信息") let simpleData: InsitutionDataSimple = new InsitutionDataSimple(); simpleData.id = res.id || 6; //来自选中的单位的信息 ,测试:1 simpleData.key = `${res.id}` || "ceshi"; //测试:"ceshi" @@ -91,12 +91,12 @@ export class PlanComponent implements OnInit { if (ModeManager.institutionDemoKey == ModeManager.c_demoKey_null) { //无指定测试单位,则为正式启动,根据当前单位key寻找 if (has3dData) { //如果已经有三维数据,直接进入 this.beforeOneSatus = StatusManager.getStatus(LoginSatus); - // console.log("单位数据", simpleData); + // console.log("进入三维单位", simpleData); this.beforeOneSatus.onSelectInsSuccess(simpleData) } else { //如果没有三维数据 if (ModeManager.s_isMakeMode) //内部制作模式下,询问新建 { - let isAdd = confirm('没有单位' + simpleData.key + ',是否进行初始化?') + let isAdd = confirm('没有单位:' + simpleData.name + ',是否进行初始化?') if (isAdd) { let name = simpleData.name; let id = simpleData.id;// 单位id @@ -106,6 +106,7 @@ export class PlanComponent implements OnInit { else //非内部制作模式,不开启 { console.log("没有单位" + simpleData.key); + } } } else {