using Cinemachine; using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using ZenFulcrum.EmbeddedBrowser; using LitJson; using DG.Tweening; using HXSJFrameWork; using ZenFulcrum.VR.OpenVRBinding; using System.Reflection; using UnityEngine.UI; public class Main : UIBase { public Browser m_htmlPanel; public CinemachineDollyCart firstcart; public CinemachineDollyCart globalcart; public CinemachineSmoothPath firstPath; //第一人称漫游 public CinemachineSmoothPath globalpath; //俯视漫游路线 public Transform mainCamera; //public Transform mainView; //漫游速度 private float _speed = 1.5f; //public GameObject _player; public static Main intance; //public GameObject Icon3D;//异常Icon public Camera singleCam;//单体化相机 //当前单体化360观察的物体 public GameObject CurentSingleObj; public GameObject CurentSinglePage; //高斯模糊背景 public GameObject GaussianBlurPanel; //人员热力图说明UI public GameObject heatPointDes; //当前模块索引0:总体概览;1:智慧运营;2:综合管理;3:班组事务 public int curModuleIndex; //异常点位 //public GameObject[] ExpPoints; //人员点位 //public GameObject[] PeoplePoints; //设备点位 //public GameObject[] DevicePoints; //异常信息 private ExceptionInfo[] expInfo; private Vector3 camInitPos; private Vector3 camInitAngle; //切换视角时相机移动速度 private float camMoveSpeed=6; //待机时长 private float waitTime=120; Tweener t_camAnimAngle; Tweener t_camAnimPos; //右侧面板是否显示 private bool isRightPanelShow; private void Awake() { intance = this; } // Start is called before the first frame update void Start() { m_htmlPanel.Url = JsonLoad("/Json/WebPath"); m_htmlPanel.onLoad += OnLoad; m_htmlPanel.RegisterFunction("U3dRoam", U3dRoam); m_htmlPanel.RegisterFunction("U3DToVRPanel", U3DToVRPanel);//VR实景 m_htmlPanel.RegisterFunction("U3DExit", U3DExit); m_htmlPanel.RegisterFunction("U3DEnterModule", U3DEnterModule);//进入模块 m_htmlPanel.RegisterFunction("U3DDeviceViewCenter", U3DDeviceViewCenter);//锁定设备到视角中心并高亮 m_htmlPanel.RegisterFunction("U3DPeopleViewCenter", U3DPeopleViewCenter);//锁定人员或工牌到视角中心并高亮 m_htmlPanel.RegisterFunction("U3DWorkCardCenter", U3DWorkCardCenter);//锁定人员或工牌到视角中心并高亮 m_htmlPanel.RegisterFunction("U3DClientViewCenter", U3DClientViewCenter);//锁定客户到视角中心 m_htmlPanel.RegisterFunction("U3DCounterViewCenter", U3DCounterViewCenter);//锁定柜台到视角中心 m_htmlPanel.RegisterFunction("U3DExpViewCenter", U3DExpViewCenter);//锁定异常到视角中心 m_htmlPanel.RegisterFunction("U3DCamViewCenter", U3DCamViewCenter);//锁定摄像头到视角中心 m_htmlPanel.RegisterFunction("U3DClosePeopleInfo", U3DClosePeopleInfo);//关闭人物单体化展示 m_htmlPanel.RegisterFunction("U3DCloseSingleDeviceInfo", U3DCloseSingleDeviceInfo);//关闭设备单体化展示 m_htmlPanel.RegisterFunction("U3DShowDeviceType", U3DShowDeviceType);//根据类型高亮设备 m_htmlPanel.RegisterFunction("U3DLoadExceptioIcon", U3DLoadExceptioIcon);//加载异常Icon m_htmlPanel.RegisterFunction("U3DCloseExpIcon", U3DCloseExpIcon);//关闭异常Icon m_htmlPanel.RegisterFunction("U3DOpenOverlook", U3DOpenOverlook);//开启热力图 m_htmlPanel.RegisterFunction("U3DCloseOverlook", U3DCloseOverlook);//关闭热力图 m_htmlPanel.RegisterFunction("U3DBackInitView", U3DBackInitView);//返回初始视角 m_htmlPanel.RegisterFunction("U3DClosePage", U3DClosePage);//收起UI面板 m_htmlPanel.RegisterFunction("U3DShowAreaIcon", U3DShowAreaIcon);//显示隐藏分区icon m_htmlPanel.RegisterFunction("U3DShowRightBlurPage", U3DShowRightBlurPage);//右侧面板显示隐藏 m_htmlPanel.RegisterFunction("U3DShowSingleModel", U3DShowSingleModel);//显示单体化模型 camInitPos = mainCamera.position; camInitAngle = mainCamera.eulerAngles; //雨天路滑 //m_htmlPanel.CallFunction("showWeatherTips"); // //接收前端传来的数据 ReadEnvironmentData(); firstcart.m_Speed = 0; globalcart.m_Speed = 0; } /// /// 网页加载成功 /// /// void OnLoad(JSONNode args) { ShowLeftBlurPage(true); ShowRightBlurPage(true); } /// /// 获取网页传来的数据 /// void ReadEnvironmentData() { //关闭壳子程序 CloseU3DManagerProgram(); //用来接收HTML发来的数据 string[] CommandLineArgs = Environment.GetCommandLineArgs(); if (CommandLineArgs.Length < 2 || CommandLineArgs[1] == "") { Debug.Log("没有接收到参数"); if (transform.Find("Text") != null) { transform.Find("Text").GetComponent().text = "当前无参"; } } else { if(transform.Find("Text") != null) { transform.Find("Text").GetComponent().text ="当前参数为"+ CommandLineArgs[1]; } } } /// /// 关闭壳子管理程序 /// void CloseU3DManagerProgram() { CloseExe("NJYYT_Manager"); } /// /// /// /// 0:总体概览;1:智慧运营;2:综合管理;3:班组事务 void U3DEnterModule(JSONNode args) { int moduleIndex = int.Parse(args[0].Value.ToString()); curModuleIndex= moduleIndex; Debug.Log(""+moduleIndex); ModelManager.instance.ShowChangePageEffect(); switch (moduleIndex) { case 0://综合概览 ModelManager.instance.CloseExpIcon(); CanClick3DModel(false); U3DClosePeopleInfo(null); U3DCloseSingleDeviceInfo(null); ModelManager.instance.HighLightOff(); ModelManager.instance.ShowSpaceIcon(true); ShowLeftBlurPage(true); ShowRightBlurPage(true); break; case 1://智慧运营 ModelManager.instance.CloseExpIcon(); CanClick3DModel(false); U3DClosePeopleInfo(null); U3DCloseSingleDeviceInfo(null); ModelManager.instance.HighLightOff(); ModelManager.instance.ShowSpaceIcon(false); ShowLeftBlurPage(true); ShowRightBlurPage(true); //退出热力图 U3DCloseOverlook(null); //退出分区 ModelManager.instance.ShowSpaceArea(false); //退出第一人称漫游 U3dRoam(false); m_htmlPanel.CallFunction("toggleMenuActive"); break; case 2: //服务管控 CanClick3DModel(false); U3DClosePeopleInfo(null); U3DCloseSingleDeviceInfo(null); ModelManager.instance.HighLightOff(); ModelManager.instance.ShowSpaceIcon(false); ShowLeftBlurPage(true); ShowRightBlurPage(true); //退出热力图 U3DCloseOverlook(null); //退出分区 ModelManager.instance.ShowSpaceArea(false); //退出第一人称漫游 U3dRoam(false); m_htmlPanel.CallFunction("toggleMenuActive"); break; case 3://综合管理 CanClick3DModel(true); ModelManager.instance.CloseExpIcon(); ShowLeftBlurPage(true); ShowRightBlurPage(false); ModelManager.instance.ShowSpaceIcon(false); //退出热力图 U3DCloseOverlook(null); //退出分区 ModelManager.instance.ShowSpaceArea(false); //退出第一人称漫游 U3dRoam(false); m_htmlPanel.CallFunction("toggleMenuActive"); break; case 4://班组事务 ModelManager.instance.CloseExpIcon(); CanClick3DModel(false); U3DClosePeopleInfo(null); U3DCloseSingleDeviceInfo(null); ModelManager.instance.HighLightOff(); ShowLeftBlurPage(true); ShowRightBlurPage(true); ModelManager.instance.ShowSpaceIcon(false); //退出热力图 U3DCloseOverlook(null); //退出分区 ModelManager.instance.ShowSpaceArea(false); //退出第一人称漫游 U3dRoam(false); m_htmlPanel.CallFunction("toggleMenuActive"); break; } //只有首页显示设备分类 GaussianBlurPanel.transform.Find("right/devicetypebg").gameObject.SetActive(curModuleIndex == 0); CloseMenuLast4(curModuleIndex == 0); } /// /// 隐藏首页右侧菜单 后四个高斯模糊背景 /// private void CloseMenuLast4(bool isShow) { GaussianBlurPanel.transform.Find("right/menu").GetChild(2).gameObject.SetActive(isShow); GaussianBlurPanel.transform.Find("right/menu").GetChild(3).gameObject.SetActive(isShow); GaussianBlurPanel.transform.Find("right/menu").GetChild(4).gameObject.SetActive(isShow); GaussianBlurPanel.transform.Find("right/menu").GetChild(5).gameObject.SetActive(isShow); } /// /// 收起左右面板 /// private void U3DClosePage(JSONNode args) { if (args[0].IsValid) { bool value = (bool)args[0].Value; if (value) { ShowLeftBlurPage(true); if (curModuleIndex == 3) { //在综合模块,并且右侧面板有内容时,显示右侧面板 if(isRightPanelShow) ShowRightBlurPage(true); } else { ShowRightBlurPage(true); } } else { ShowLeftBlurPage(false); ShowRightBlurPage(false); } } } /// /// 根据索引滑入滑出页面 /// private void ShowLeftBlurPage(bool isShow) { //初始化左右两边的位置 Transform left = GaussianBlurPanel.transform.GetChild(0); float leftX = left.GetComponent().rect.width; if (isShow) { left.GetComponent().anchoredPosition = new Vector2(-leftX, left.GetComponent().anchoredPosition.y); //滑入 left.GetComponent().DOAnchorPosX(0, 0.5f).SetEase(Ease.Linear); } else { left.GetComponent().anchoredPosition = new Vector2(0, left.GetComponent().anchoredPosition.y); //滑出 left.GetComponent().DOAnchorPosX(-leftX, 0.5f).SetEase(Ease.Linear); } } /// /// 右侧面板显示设备人员信息等 /// private void U3DShowRightBlurPage(JSONNode args) { if (args[0].IsValid) ShowRightBlurPage((bool)args[0].Value); isRightPanelShow= (bool)args[0].Value; } /// /// 显示单体化模型 /// private void U3DShowSingleModel(JSONNode args) { if (args[0].IsValid) { DeviceType type = (DeviceType)Enum.ToObject( typeof(DeviceType), int.Parse(args[0].ToString())); GameObject obj= ModelManager.instance.FindDeviceByType(type); ModelManager.instance.SingleModel(obj); } } /// /// 根据索引滑入滑出页面 /// private void ShowRightBlurPage(bool isShow) { //初始化左右两边的位置 Transform right = GaussianBlurPanel.transform.GetChild(1); float rightX = right.GetComponent().rect.width; if (isShow) { right.GetComponent().anchoredPosition = new Vector2(rightX, right.GetComponent().anchoredPosition.y); right.GetComponent().DOAnchorPosX(0, 0.5f).SetEase(Ease.Linear); } else { right.GetComponent().anchoredPosition = new Vector2(0, right.GetComponent().anchoredPosition.y); //滑出 right.GetComponent().DOAnchorPosX(rightX, 0.5f).SetEase(Ease.Linear); } } /// /// 综合管理模块是否显示单体化模型(页面动画) /// /// public void ShowSingleModel(bool show) { if (show) { CurentSinglePage.GetComponent().DOAnchorPosX(-95f, 0.5f).SetEase(Ease.Linear); } else { CurentSinglePage.GetComponent().DOAnchorPosX(340f, 0.5f).SetEase(Ease.Linear); } } /// /// 综合管理模块允许点击模型和人物 /// /// void CanClick3DModel(bool isCan) { //综合管理允许单体化 ModelManager.instance.CanSingle(isCan); } private void U3DExit(JSONNode args) { Application.Quit(); } /// /// VR实景 /// /// private void U3DToVRPanel(JSONNode args) { Debug.Log("VR漫游"); if (args[0].IsValid) { isInFirstRoam = (bool)args[0].Value; } //Application.OpenURL(JsonLoad("/Json/VRPath")); //m_htmlPanel.CallFunction("showVRUrl"); } /// /// 记录自动漫游前相机的位置 /// private Vector3 lastPos; /// /// 记录自动漫游前相机的角度 /// private Vector3 lastAngle; /// /// 是否处于第一人称漫游,这个过程中不计算待机时长(热力图,第一人称漫游,VR,分区) /// private bool isInFirstRoam; /// /// 第一人称漫游 /// /// private void U3dRoam(JSONNode args) { bool isRoam = bool.Parse(args[0].Value.ToString()); U3dRoam(isRoam); } /// /// 第一人称漫游 /// /// private void U3dRoam(bool args) { bool isRoam = args; if (isRoam) { firstcart.m_Path = firstPath; lastPos = mainCamera.position; lastAngle = mainCamera.eulerAngles; isInFirstRoam = true; ShowLeftBlurPage(false); ShowRightBlurPage(false); CameraStartRoam(firstcart.transform.position + new Vector3(0, 1.6f, 0), Quaternion.Euler(firstcart.transform.eulerAngles), () => { mainCamera.GetComponent()._enabled = false; firstcart.m_Speed = _speed; mainCamera.parent = firstcart.transform; mainCamera.localPosition = new Vector3(0, 1.6f, 0); mainCamera.localEulerAngles = Vector3.zero; }); } else { isInFirstRoam = false; firstcart.m_Speed = 0; mainCamera.parent = null; //mainCamera.position = lastPos; //mainCamera.eulerAngles = lastAngle; //回到初始视角 CameraMoveTarget(camInitPos, Quaternion.Euler(camInitAngle)); //mainCamera.GetComponent()._enabled = true; //mainCamera.GetComponent().Init(); if (curModuleIndex == 3) { ShowLeftBlurPage(true); //综合模块,不显示右侧面板,当单体化展示时,显示右侧面板 } else { ShowLeftBlurPage(true); ShowRightBlurPage(true); m_htmlPanel.CallFunction("U3DControlShrink", true); m_htmlPanel.CallFunction("U3DCloseRoomTip"); } } } /// /// 长时间不动鼠标,全局俯视漫游 /// private void GlobalRoam(bool start) { if (t_camAnimAngle != null) t_camAnimAngle.Kill(); if (t_camAnimPos != null) t_camAnimPos.Kill(); if (start) { CameraStartRoam(globalcart.transform.position, Quaternion.Euler(globalcart.transform.eulerAngles.x + 75f, globalcart.transform.eulerAngles.y, globalcart.transform.eulerAngles.z), () => { mainCamera.GetComponent()._enabled = false; globalcart.m_Speed = _speed; mainCamera.parent = globalcart.transform; mainCamera.localPosition = Vector3.zero; mainCamera.localEulerAngles = new Vector3(75f, 0, 0); }); //UI两边面板 ShowLeftBlurPage(false); ShowRightBlurPage(false); m_htmlPanel.CallFunction("U3DControlShrink", false); //ModelManager.instance.CameraNear(false); } else { globalcart.m_Speed = 0; mainCamera.parent = null; //mainCamera.GetComponent().Init(); //mainCamera.GetComponent()._enabled = true; //回到默认视角 CameraMoveTarget(camInitPos, Quaternion.Euler(camInitAngle)); //UI两边面板 ShowLeftBlurPage(true); ShowRightBlurPage(true); m_htmlPanel.CallFunction("U3DControlShrink", true); } } private float UnFocusTime = 0; //是否开始检测鼠标状态 private bool isStartCheck; //是否在漫游过程中 private bool isInRoam; // Update is called once per frame void Update() { //if (Input.GetKeyDown(KeyCode.Alpha1)) { // m_htmlPanel.CallFunction("U3dRoam",true); //} //if (Input.GetKeyDown(KeyCode.Alpha2)) //{ // m_htmlPanel.CallFunction("U3dRoam", false); //} //测试 if (Input.GetKeyDown(KeyCode.V)) { //U3DCounterViewCenter(3); } //处于第一人称漫游和不在第一个模块时,不计算待机时长 if (isInFirstRoam || curModuleIndex != 0) return; //鼠标有动静,清空计算无动静时长 if (Input.anyKey || Input.GetAxis("Mouse X") != 0 || Input.GetAxis("Mouse Y") != 0) { UnFocusTime = 0; isStartCheck = true; if (isInRoam) { Debug.Log("停止漫游"); isInRoam = false; GlobalRoam(false); } } if (isStartCheck) { //鼠标长时间未动,自动进入漫游 UnFocusTime += Time.deltaTime; if (UnFocusTime > waitTime) { UnFocusTime = 0; Debug.Log("长时间未动鼠标!"); isStartCheck = false; isInRoam = true; GlobalRoam(true); } } } #region 相机视角 /// /// 相机直接移到目标位置(点击设备、人物等移动视角) /// /// 相机终点位置 /// 相机终点角度 public void CameraMoveTarget(Vector3 endPos, Quaternion endAngle,Action call=null) { if (t_camAnimAngle != null) t_camAnimAngle.Kill(); if (t_camAnimPos != null) t_camAnimPos.Kill(); mainCamera.GetComponent()._enabled = false; float dis=float.Parse( (mainCamera.position - endPos).magnitude.ToString("f3")); //Debug.Log(dis+"@@@@@@"); float time = dis / camMoveSpeed; t_camAnimPos= mainCamera.DOMove(endPos, time); t_camAnimAngle=mainCamera.DORotate(endAngle.eulerAngles, time).OnComplete(() => { if (call != null) call(); CameraEnable(); }); } /// /// 相机开始漫游,移动到漫游处,相机不可操作 /// /// /// /// public void CameraStartRoam(Vector3 endPos, Quaternion endAngle, Action call = null) { if (t_camAnimAngle != null) t_camAnimAngle.Kill(); if (t_camAnimPos != null) t_camAnimPos.Kill(); mainCamera.GetComponent()._enabled = false; float dis = float.Parse((mainCamera.position - endPos).magnitude.ToString("f3")); //Debug.Log(dis+"@@@@@@"); float time = dis / camMoveSpeed; t_camAnimPos = mainCamera.DOMove(endPos, time); t_camAnimAngle = mainCamera.DORotate(endAngle.eulerAngles, time).OnComplete(() => { if (call != null) call(); }); } /// /// 相机回到初始视角 /// public void InitViewAnim() { //ModelManager.instance.CameraNear(false); CameraMoveTarget(camInitPos, Quaternion.Euler(camInitAngle)); } /// /// 移动相机:先拉高,再移动到目标视角 /// /// /// public void CamerMoveAnimAfter(Vector3 endPos, Quaternion endAngle,Action call=null) { if (t_camAnimAngle != null) t_camAnimAngle.Kill(); if (t_camAnimPos != null) t_camAnimPos.Kill(); mainCamera.GetComponent()._enabled = false; float dis = (mainCamera.position - camInitPos).magnitude; float time = dis / camMoveSpeed; Vector3 hightpoint = new Vector3(mainCamera.position.x, 10f, mainCamera.position.z); t_camAnimPos = mainCamera.DOMove(hightpoint, time); t_camAnimAngle=mainCamera.DORotate(camInitAngle, time).OnComplete(() => { t_camAnimPos.Kill(); t_camAnimAngle.Kill(); t_camAnimPos =mainCamera.DOMove(endPos, time); t_camAnimAngle= mainCamera.DORotate(endAngle.eulerAngles, time).OnComplete(() => { if (call != null) call(); CameraEnable(); }); }); } /// /// 开启相机可操作性 /// private void CameraEnable() { mainCamera.GetComponent().InitTarget(); mainCamera.GetComponent()._enabled = true; } /// /// 移动相机:相机在房间内,先回到初始角度再移至目标位置,相机在房间外,直接移动到目标位置 /// /// /// public void CameraMoveAnim(Vector3 endPos, Quaternion endAngle,Action call=null) { //if (mainCamera.GetComponent().isNear) //{ // CamerMoveAnimAfter(endPos, endAngle, call); //} //else { // CameraMoveTarget(endPos, endAngle, call); //} bool inview = true; //判断物体是否在相机视角内TODO:前方是否有物体遮挡 Vector3 viewPos = mainCamera.GetComponent().WorldToViewportPoint(endPos); // z<0代表在相机背后 if (viewPos.z < 0) inview = false; //太远了!看不到了! if (viewPos.z > mainCamera.GetComponent().farClipPlane) inview = false; // x,y取值在 0~1之外时代表在视角范围外; if (viewPos.x < 0 || viewPos.y < 0 || viewPos.x > 1 || viewPos.y > 1) inview = false; if (inview) { CameraMoveTarget(endPos, endAngle, call); } else { CamerMoveAnimAfter(endPos, endAngle, call); } } /// /// 相机回到初始视角 /// /// void U3DBackInitView(JSONNode args) { //mainCamera.GetComponent().InitViewAnim(); //mainCamera.GetComponent().isUIInit = true; mainCamera.GetComponent()._enabled = false; float dis = (mainCamera.position - camInitPos).magnitude; float time = dis / camMoveSpeed; mainCamera.DOMove(camInitPos, time); mainCamera.DORotate(camInitAngle, time).OnComplete(() => { mainCamera.GetComponent().Init(); mainCamera.GetComponent()._enabled = true; //取消按钮高亮 m_htmlPanel.CallFunction("toggleMenuActive"); }); } #endregion /// /// 开启俯视视图(热力图视角) /// void U3DOpenOverlook(JSONNode args) { // mainCamera.GetComponent().InitViewAnim(); InitViewAnim(); //ModelManager.instance.ShowHeatmap(true); ModelManager.instance.ShowHeatPoint(); ModelManager.instance.ShowChangePageEffect(); ModelManager.instance.ShowSpaceEffect(false); heatPointDes.gameObject.SetActive(true); //停止计算待机时长 isInFirstRoam = true; } /// /// 关闭俯视视图(热力图视角) /// void U3DCloseOverlook(JSONNode args) { heatPointDes.gameObject.SetActive(false); ModelManager.instance.HideHeatPoint(); if (curModuleIndex == 0) ModelManager.instance.ShowSpaceEffect(true); //ModelManager.instance.ShowHeatmap(false); //开始计算待机时长 isInFirstRoam = false; } /// /// 设备视角居中——综合管理模块 /// void U3DDeviceViewCenter(JSONNode args) { //需要居中定位的模型 Debug.Log("设备视角居中设备类型:"+args[0].Value+"设备索引"+ args[1].Value); DeviceType type = (DeviceType)Enum.ToObject(typeof(DeviceType), int.Parse(args[0].Value.ToString())+1); int index = (int.Parse(args[1].Value.ToString())-1) % ModelManager.instance.devices.Count; //根据设备类型和索引找到对应的设备 Debug.Log("当前设备类型"+type.ToString()+"当前设备分类索引"+ index); GameObject curModel = ModelManager.instance.FindDeviceByTypeAndID(type, index); //显示设备详情并且单体化展示 //Main.intance.m_htmlPanel.CallFunction("showRightDetails", index); Main.intance.m_htmlPanel.CallFunction("clickShowDetails", index); Debug.Log("设备单体化名称" + curModel); ModelManager.instance.SingleModel(curModel); ViewCenterPoint(curModel, curModel.transform.right,3, () => { ModelManager.instance.LightFlashCount(curModel); }); } /// /// 摄像头视角居中 /// /// void U3DCamViewCenter(JSONNode args) { //需要居中定位的模型 Debug.Log("摄像头视角居中"+args[0].Value); int index = int.Parse(args[0].Value.ToString()) % ModelManager.instance.camList.Count; GameObject curModel = ModelManager.instance.camList[index].gameObject; ViewCenterPoint(curModel, curModel.transform.right, 3, () => { ModelManager.instance.LightFlashCount(curModel); }); } /// /// 人员视角居中 /// /// void U3DPeopleViewCenter(JSONNode args) { Debug.Log("工牌和人员视角居中" + args[0].Value); //需要居中定位的模型 int index = int.Parse(args[0].Value.ToString()) % ModelManager.instance.peoples.Count; GameObject curModel = ModelManager.instance.peoples[index].gameObject; ViewCenterPoint(curModel, curModel.transform.right, 3, () => { ModelManager.instance.LightFlashCount(curModel); }); } /// /// 工牌视角居中,高亮并显示工牌信息 /// /// void U3DWorkCardCenter(JSONNode args) { Debug.Log("工牌和人员视角居中" + args[0].Value); //需要居中定位的模型 int index = int.Parse(args[0].Value.ToString()) % ModelManager.instance.peoples.Count; GameObject curModel = ModelManager.instance.peoples[index].gameObject; //显示电子工牌信息 Main.intance.m_htmlPanel.CallFunction("clickShowDetails", 4); ViewCenterPoint(curModel, curModel.transform.right, 3, () => { ModelManager.instance.LightFlashCount(curModel); }); } /// /// 客户视角居中 /// /// void U3DClientViewCenter(JSONNode args) { Debug.Log("客户视角居中"+args[0].Value); int index = int.Parse(args[0].Value.ToString()) % ModelManager.instance.clients.Count; //需要居中定位的模型 GameObject curModel = ModelManager.instance.clients[index].gameObject; ViewCenterPoint(curModel, curModel.transform.right); } /// /// 柜台视角居中 /// /// void U3DCounterViewCenter(JSONNode args) { //Debug.Log(args[0].IsValid); Debug.Log(args[0].Value); int index = int.Parse(args[0].Value.ToString()) % ModelManager.instance.counters.Count; //需要居中定位的模型 GameObject curModel = ModelManager.instance.counters[index].gameObject; ViewCenterPoint(curModel, curModel.transform.right,8); } /// /// 异常视角居中 /// /// 0:离岗;1:人员聚集;2:防滑;3:体温;4:工单临期;5:工单逾期 void U3DExpViewCenter(JSONNode args) { int expindex = 0; Debug.Log(args[0].Value); switch (args[0].Value) { case "离岗异常": expindex = 0; break; case "人员聚集": expindex = 1; break; case "防滑设施未摆放": expindex = 2; break; case "体温异常": expindex = 3; break; case "工单临期": expindex = 4; break; case "工单逾期": expindex = 5; break; case "设备异常": expindex = 6; break; case "预受理信息预警": expindex = 4; break; case "疑似人员跌倒": expindex = 2; break; case "排队": expindex = 1; break; case "频繁临厅": expindex = 1; break; case "高温预警": expindex = 3; break; case "业务受理机已下线": expindex = 4; break; } //需要居中定位的模型 //GameObject curModel = ModelManager.instance.expPoints[expindex].gameObject; GameObject curModel = ModelManager.instance.FindExpPointByName(args[0].Value.ToString()); ViewCenterPoint(curModel, curModel.transform.right); } /// /// 视角居中 /// /// 当前居中的点位 /// 当前居中的点位 /// 当前居中的点位 void ViewCenterPoint(GameObject curPoint,Vector3 forward,float dis=3,Action call=null) { Debug.Log("web:"+ curPoint.name); //获取模型中心点位置(加上模型方向*3) Vector3 playerPos = curPoint.transform.position + forward * dis; Quaternion angle = Quaternion.LookRotation(-forward); ; Debug.Log("pos" + playerPos + ";angle" + angle); //Main.intance.mainCamera.GetComponent().CamerMoveAnim(playerPos, angle); CameraMoveAnim(playerPos, angle,call); } #region 测试可删 /// /// 测试四种异常居中视角(测试可删) /// /// 当前点位的索引 void ExpViewCenter1(int args) { //需要居中定位的模型 GameObject curModel = ModelManager.instance.expPoints[args].gameObject; ViewCenterPoint(curModel,curModel.transform.forward); } /// /// 设备视角居中(测试可删) /// void DeviceViewCenter1(int args) { //需要居中定位的模型 GameObject curModel = ModelManager.instance.devices[args].gameObject; ViewCenterPoint(curModel, curModel.transform.right); } /// /// 人员视角居中(测试可删) /// /// void PeopleViewCenter1(int args) { //需要居中定位的模型 GameObject curModel = ModelManager.instance.peoples[args].gameObject; ViewCenterPoint(curModel, curModel.transform.right); } /// /// 客户视角居中(测试可删) /// void U3DClientViewCenter(int args) { Debug.Log("客户视角居中" + args); //需要居中定位的模型 GameObject curModel = ModelManager.instance.clients[args].gameObject; ViewCenterPoint(curModel, curModel.transform.right); } /// /// 柜台视角居中(测试可删) /// /// void U3DCounterViewCenter(int args) { //需要居中定位的模型 GameObject curModel = ModelManager.instance.counters[args].gameObject; ViewCenterPoint(curModel, curModel.transform.right,10); } #endregion 测试可删 /// /// 关闭人物单体化展示信息 /// void U3DClosePeopleInfo(JSONNode args) { if (CurentSingleObj) { CurentSingleObj.layer = LayerMask.NameToLayer("Default"); CurentSingleObj = null; ShowSingleModel(false); ShowRightBlurPage(false); } } /// /// 关闭设备单体化展示信息 /// void U3DCloseSingleDeviceInfo(JSONNode args) { Debug.Log("关闭单体化模型"); if (CurentSingleObj) { Debug.Log("不为空"); CurentSingleObj.layer = LayerMask.NameToLayer("Default"); CurentSingleObj = null; ShowSingleModel(false); ShowRightBlurPage(false); } } /// /// 加载异常Icon /// void U3DLoadExceptioIcon(JSONNode args) { Debug.Log(args[0].Value); //解析数据 //ExceptionData data = JsonUtility.FromJson(args[0].Value.ToString()); ExceptionData data = JsonMapper.ToObject(args[0].Value.ToString()); Debug.Log(data.arr[0].name); expInfo = data.arr; //expIconList = new GameObject[data.infoList.Length]; //foreach (var item in data.infoList) //{ // Create3DIcon(item); //} //LoadExceptioIconTest(); ModelManager.instance.LoadExpIcon(); } /// /// 关闭异常Icon /// /// void U3DCloseExpIcon(JSONNode args) { ModelManager.instance.CloseExpIcon(); } /// /// 显示隐藏分区 /// /// bool :true显示,false:隐藏 void U3DShowAreaIcon(JSONNode args) { Debug.Log(args[0].Value); if (args[0].IsValid) { //是否开始计算待机时长 isInFirstRoam = (bool)args[0].Value; ModelManager.instance.ShowSpaceArea((bool)args[0].Value); } } /// /// 根据类型高亮设备 /// void U3DShowDeviceType(JSONNode args) { int index = int.Parse(args[0].Value.ToString())+1; bool show = (bool)args[1].Value; Debug.Log(index+"高亮"+show); if (show) { //根据传入类型高亮设备 ModelManager.instance.HighLightDeviceOn(index); } else { //根据传入类型高亮设备 ModelManager.instance.HighLightDeviceOff(index); } } }