From 92eed74c946c14b1e8477ec8585d69972b74148b Mon Sep 17 00:00:00 2001 From: sunzhenyu Date: Wed, 13 May 2020 14:34:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=80=81=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=9C=B0=E5=9B=BE=E4=B8=89=E7=BB=B4=E8=AE=BE=E5=A4=87=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E4=BA=A4=E4=BA=92=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/jlmap3d/jl3ddevice/jl3ddevice.js | 291 +++++++++++++++++++++++- src/jlmap3d/jl3ddevice/loader.js | 3 - src/utils/baseUrl.js | 4 +- src/views/display/index.vue | 2 +- src/views/jlmap3d/device/jl3ddevice.vue | 31 +-- 5 files changed, 308 insertions(+), 23 deletions(-) diff --git a/src/jlmap3d/jl3ddevice/jl3ddevice.js b/src/jlmap3d/jl3ddevice/jl3ddevice.js index d679379a2..0b303cc32 100644 --- a/src/jlmap3d/jl3ddevice/jl3ddevice.js +++ b/src/jlmap3d/jl3ddevice/jl3ddevice.js @@ -5,6 +5,8 @@ import { OrbitControls } from '@/jlmap3d/main/control/OrbitControls'; import { ModelManager } from '@/jlmap3d/jl3ddevice/loader.js'; import { Signallightload } from '@/jlmap3d/jl3ddevice/component/signallight.js'; +import { Moveanimate } from '@/jlmap3d/jl3ddevice/component/moveanimate.js'; +import { Textconfig } from '@/jlmap3d/jl3ddevice/component/textconfig.js'; import StompClient from '@/utils/sock'; @@ -19,6 +21,21 @@ export function Jl3ddevice(dom,group,token) { Signallightload(this.signallights); this.mixers = []; this.showmodel = null; + + //新数据交互 + let helpbox,textplane; + let daochamodel; + //点击事件状态 + this.raycasterstatus = false; + //动画状态 + this.animastats = false; + //当前选中模型 + this.nowobject = null; + //当前动画播放模型 + this.animationmodel = null; + this.devicetext = new Textconfig(); + this.windowstatus = '0'; + //初始化webgl渲染 this.renderer = new THREE.WebGLRenderer({ antialias: true }); @@ -70,6 +87,10 @@ export function Jl3ddevice(dom,group,token) { this.controls.update(); this.selectmodel = null; + let moveanima = new Moveanimate(scope); + document.addEventListener( "mousedown", onselect, false ); + + let teststomp = new StompClient(); let topic = '/user/topic/simulation/assistant/'+group; // let topic = '/user/queue/simulation/jl3d/'+group; @@ -83,7 +104,6 @@ export function Jl3ddevice(dom,group,token) { function callback(Response) { let data = JSON.parse(Response.body); - console.log(data); if(scope.nowcode != data.body.code){ scope.nowcode = data.body.code; scope.selectmodel(data); @@ -97,11 +117,18 @@ export function Jl3ddevice(dom,group,token) { scope.camera.updateProjectionMatrix(); scope.renderer.setSize(scope.dom.offsetWidth, scope.dom.offsetHeight); } - + this.domresize = function(){ + scope.camera.aspect = scope.dom.offsetWidth / scope.dom.offsetHeight; + scope.camera.updateProjectionMatrix(); + scope.renderer.setSize(scope.dom.offsetWidth, scope.dom.offsetHeight); + } this.anime = null; this.modelmanager = new ModelManager(); this.modelmanager.loadpromise(Staticmodel, scope.mixers).then(function (data) { + moveanima.initlistnew(scope.modelmanager.switchmodel.mesh); + daochamodel = scope.modelmanager.switchmodel.mesh.getObjectByName("DAOCHA"); + animate(); }) @@ -113,6 +140,7 @@ export function Jl3ddevice(dom,group,token) { scope.controls.update(); //scope.camera.lookAt(plane); // + moveanima.animateupdate(); let delta = clock.getDelta(); if (scope.mixers) { for (let i = 0; i < scope.mixers.length; i++) { @@ -139,7 +167,17 @@ export function Jl3ddevice(dom,group,token) { scope.showmodel = scope.modelmanager.switchmodel.mesh; scope.scene.add(scope.showmodel); + scope.devicetext.initdevicetext(scope.modelmanager.switchmodel.mesh); + scope.nowobject = scope.modelmanager.switchmodel.mesh; + updatemenulist(scope.devicetext.devicelist); + scope.raycasterstatus = true; + + }else{ + scope.raycasterstatus = false; + scope.nowobject = ""; + updatemenulist(); } + if (data.body._type == "Signal") { scope.modelmanager.signalmodel.code = data.body.code; @@ -155,8 +193,13 @@ export function Jl3ddevice(dom,group,token) { scope.showmodel = scope.modelmanager.standmodel.mesh; scope.scene.add(scope.showmodel); } - scope.showmodel.code = data.body.code; - initstatus(data); + + if(scope.showmodel){ + scope.resetmodel(); + scope.showmodel.code = data.code; + initstatus(data); + } + } } else { if (data.body._type == "Switch") { @@ -164,6 +207,11 @@ export function Jl3ddevice(dom,group,token) { scope.modelmanager.switchmodel.code = data.body.code; scope.showmodel = scope.modelmanager.switchmodel.mesh; scope.scene.add(scope.showmodel); + + scope.devicetext.initdevicetext(scope.modelmanager.switchmodel.mesh); + scope.nowobject = scope.modelmanager.switchmodel.mesh; + updatemenulist(scope.devicetext.devicelist); + scope.raycasterstatus = true; if (data.body.locateType == "01") { scope.modelmanager.switchmodel.locateType = "01"; scope.modelmanager.switchmodel.action.reset(); @@ -180,6 +228,10 @@ export function Jl3ddevice(dom,group,token) { } + }else{ + scope.raycasterstatus = false; + scope.nowobject = ""; + updatemenulist(); } if (data.body._type == "Signal") { scope.modelmanager.signalmodel.code = data.body.code; @@ -442,4 +494,235 @@ export function Jl3ddevice(dom,group,token) { } } + + //设备分解、归位动画按钮 + this.disperdevice1 = function(){ + if(scope.nowobject.animacode){ + if(moveanima.status == true){ + if(scope.animastats == false){ + scope.animastats = true; + moveanima.setplaylist(moveanima.animatelist[scope.nowobject.animacode+"on"],true) + } else if(scope.animastats == true){ + scope.animastats = false; + moveanima.setplaylist(moveanima.animatelist[scope.nowobject.animacode+"off"],true); + } + } + } + + + }; + + this.disperdevice2 = function(){ + if(scope.nowobject.animacode){ + if(moveanima.status == true){ + if(scope.animastats == false){ + scope.animastats = true; + moveanima.setplaylist(moveanima.animatelist[scope.nowobject.animacode+"chaijie"],true); + } else if(scope.animastats == true){ + scope.animastats = false; + moveanima.setplaylist(moveanima.animatelist[scope.nowobject.animacode+"fuwei"],true); + } + } + } + + }; + + this.resetmodel = function(){ + if(scope.nowobject.animacode){ + scope.animastats = false; + moveanima.setplaylist(moveanima.animatelist[scope.nowobject.animacode+"fuwei"],true); + } + + }; + + this.animationmsgshowon = function(nowobject){ + scope.animationmodel = nowobject; + if(helpbox){ + scope.animationmodel.helpbox = null; + scope.scene.remove( helpbox ); + helpbox = undefined; + } + + settext(scope.animationmodel,scope.animationmodel.position); + // console.log(scope.animationmodel); + helpbox = new THREE.BoxHelper( scope.animationmodel, 0xff0000 ); + moveanima.updatehelpbox(helpbox,textplane); + // settext(intersects[0].object,intersects[0].point); + // getdevicemsg(intersects[0].object.name); + scope.scene.add( helpbox ); + getdevicemsg(nowobject.name); + } + + this.animationmsgshowoff = function(nowobject){ + if(helpbox){ + scope.animationmodel.helpbox = null; + scope.scene.remove( helpbox ); + helpbox = undefined; + } + if(textplane){ + scope.scene.remove(textplane); + textplane.geometry.dispose(); + textplane.material.dispose(); + } + scope.animationmodel = null; + } + + this.updateselect = function(updata){ + // console.log(updata); + if(helpbox){ + scope.scene.remove( helpbox ); + helpbox = null; + } + helpbox = new THREE.BoxHelper( updata.mesh, 0xff0000 ); + // console.log(updata.mesh); + let point = { + x:updata.mesh.matrixWorld.elements[12], + y:updata.mesh.matrixWorld.elements[13], + z:updata.mesh.matrixWorld.elements[14] + }; + settext(updata.mesh,point) + getdevicemsg(updata.mesh.name); + scope.scene.add( helpbox ); + } + + function getdevicemsg(selectname){ + // console.log(selectname); + for(let i=0,leni=scope.devicetext.devicelist.length;i --> - + diff --git a/src/views/jlmap3d/device/jl3ddevice.vue b/src/views/jlmap3d/device/jl3ddevice.vue index 70507691a..19f9fea27 100644 --- a/src/views/jlmap3d/device/jl3ddevice.vue +++ b/src/views/jlmap3d/device/jl3ddevice.vue @@ -33,6 +33,7 @@ }, data() { return { + datastatus:"", jl3d: null, psdlist:this.$store.state.map.map.psdList, windowstatus:false, @@ -63,24 +64,24 @@ }, '$store.state.menuOperation.selectedCount': { handler: function (newVal, oldVal) { - if (newVal != oldVal) { - if(this.$store.state.menuOperation.selected._type){ - if(this.$store.state.menuOperation.selected._type == "StationStand"){ - let standcode = this.$store.state.menuOperation.selected.code; - for(let i=0,leni=this.psdlist.length;i