diff --git a/src/jlmap3d/edit/connect/initDataSave.js b/src/jlmap3d/edit/connect/initDataSave.js index 755c4fc4b..ab1b3749d 100644 --- a/src/jlmap3d/edit/connect/initDataSave.js +++ b/src/jlmap3d/edit/connect/initDataSave.js @@ -32,23 +32,32 @@ export function initDataSave(data) { let sections = []; // console.log(data.mapdata.sectionlist.sections.datalist); for(let i in data.mapdata.sectionlist.sections.datalist){ - console.log(data.mapdata.sectionlist.sections.datalist[i].mesh.railpoint); + let section = { // uuid:data.mapdata.sectionlist.sections.modellist[i].uuid, code:data.mapdata.sectionlist.sections.datalist[i].code, name:data.mapdata.sectionlist.sections.datalist[i].name, - lengthFact:data.mapdata.sectionlist.sections.datalist[i].mesh.lengthFact, + lengthFact:null, standTrack:data.mapdata.sectionlist.sections.datalist[i].standTrack, rp:data.mapdata.sectionlist.sections.datalist[i].rp, lp:data.mapdata.sectionlist.sections.datalist[i].lp, - railpoint:data.mapdata.sectionlist.sections.datalist[i].mesh.railpoint, + railpoint:null, rail:data.mapdata.sectionlist.sections.datalist[i].rail, - position:data.mapdata.sectionlist.sections.datalist[i].mesh.position, - rotation:data.mapdata.sectionlist.sections.datalist[i].mesh.rotation, - scale:data.mapdata.sectionlist.sections.datalist[i].mesh.scale, + position:null, + rotation:null, + scale:null, } - let nowmesh = data.mapdata.sectionlist.sectiongroup.getObjectByProperty("code",section.code); - section.railpoint = nowmesh.railpoint; + if(data.mapdata.sectionlist.sections.datalist[i].mesh){ + console.log(data.mapdata.sectionlist.sections.datalist[i].mesh.railpoint); + let nowmesh = data.mapdata.sectionlist.sectiongroup.getObjectByProperty("code",section.code); + section.railpoint = nowmesh.railpoint; + section.lengthFact = data.mapdata.sectionlist.sections.datalist[i].mesh.lengthFact; + section.position = data.mapdata.sectionlist.sections.datalist[i].mesh.position; + section.rotation = data.mapdata.sectionlist.sections.datalist[i].mesh.rotation; + section.scale = data.mapdata.sectionlist.sections.datalist[i].mesh.scale; + sections.push(section); + } + // console.log(nowmesh.railpoint); // if(data.mapdata.sectionlist.sections.datalist[i].rsection){ // section.rsection = data.mapdata.sectionlist.sections.datalist[i].rsection; @@ -62,7 +71,7 @@ export function initDataSave(data) { // testmesh1.position.z = link.position.z; - sections.push(section); + } let arrray = { section:sections, diff --git a/src/jlmap3d/edit/jlmap3dedit.js b/src/jlmap3d/edit/jlmap3dedit.js index e99031062..8a2487794 100644 --- a/src/jlmap3d/edit/jlmap3dedit.js +++ b/src/jlmap3d/edit/jlmap3dedit.js @@ -423,63 +423,12 @@ export function JLmap3dEdit(dom, data, mapid) { for(let i=0;i2){ - newAlignmentSection.lengthFact = newAlignmentSection.lengthFact/5; - } - - let len = newAlignmentSection.lengthFact; - // closedSpline.arcLengthDivisions; - let count = newAlignmentSection.geometry.attributes.position.count/3; - - for(let i=0;i2){ newAlignmentSection.lengthFact = newAlignmentSection.lengthFact/5; } - let len = newAlignmentSection.lengthFact; // closedSpline.arcLengthDivisions; let count = newAlignmentSection.geometry.attributes.position.count/3; + for(let i=0;i section.lengthFact/2){ - posx = section.mesh.position.x + data[i].sectionOffset - section.lengthFact/2; - }else{ - posx = section.mesh.position.x - (section.lengthFact/2 - data[i].sectionOffset); + if(section.lsection == undefined){ + section = sectiondata[section.rsection]; + data[i].sectionOffset = section.lengthFact; + data[i].sectionCode = section.rsection; } - //根据线路方向修改信号灯位置 - if(data[i].right == false){ - if(section.standTrack == true){ - posx = posx - 7; - } - - newmesh.position.set(posx,0,section.mesh.position.z-3); - newmesh.rotation.z = ( Math.PI / 2 ); - }else if(data[i].right == true){ - if(section.standTrack == true){ - posx = posx + 7; - } - newmesh.position.set(posx,0,section.mesh.position.z+3); - newmesh.rotation.z = ( - Math.PI / 2 ); + if(section.rsection == undefined){ + section = sectiondata[section.lsection]; + data[i].sectionOffset = 0; + data[i].sectionCode = section.rsection; } - newmesh.scale.x = 0.05; - newmesh.scale.y = 0.05; - newmesh.scale.z = 0.05; - newmesh.sectionOffset = data[i].sectionOffset; - newmesh.sectionCode = data[i].sectionCode; - newmesh.right = data[i].right; - newsignal.mesh = newmesh; - newsignal.sectionOffset = data[i].sectionOffset; - newsignal.mesh.status = "01"; - newsignal.name = data[i].name; - newsignal.modelid = assetloader.modellist[num].id; - newsignal.code = data[i].code; - newsignal.sectionCode = data[i].sectionCode; - newsignal.right = data[i].right; - scope.group.add(newmesh); - scope.list.push(newsignal); + if(data[i].sectionOffset > section.lengthFact/2){ + posx = section.mesh.position.x + data[i].sectionOffset - section.lengthFact/2; + }else{ + posx = section.mesh.position.x - (section.lengthFact/2 - data[i].sectionOffset); + } + //根据线路方向修改信号灯位置 + if(data[i].right == false){ + if(section.standTrack == true){ + posx = posx - 7; + } + + newmesh.position.set(posx,0,section.mesh.position.z-3); + newmesh.rotation.z = ( Math.PI / 2 ); + }else if(data[i].right == true){ + if(section.standTrack == true){ + posx = posx + 7; + } + newmesh.position.set(posx,0,section.mesh.position.z+3); + newmesh.rotation.z = ( - Math.PI / 2 ); + } + newmesh.scale.x = 0.05; + newmesh.scale.y = 0.05; + newmesh.scale.z = 0.05; + newmesh.sectionOffset = data[i].sectionOffset; + newmesh.sectionCode = data[i].sectionCode; + newmesh.right = data[i].right; + newsignal.mesh = newmesh; + + newsignal.sectionOffset = data[i].sectionOffset; + newsignal.mesh.status = "01"; + newsignal.name = data[i].name; + newsignal.modelid = assetloader.modellist[num].id; + newsignal.code = data[i].code; + newsignal.sectionCode = data[i].sectionCode; + newsignal.right = data[i].right; + scope.group.add(newmesh); + scope.list.push(newsignal); + }else{ for(let j=0;j= scope.playlist[scope.playorder].length-1){ if(scope.playorder >= scope.playlist.length-1 ){ scope.playlist = null; @@ -340,7 +329,6 @@ export function Moveanimate(main){ } } - }else{ // console.log(scope.animatelist[k].connectmodel); if(scope.nowmodelname != scope.playlist[scope.playorder][i].connectmodel.name){ @@ -383,5 +371,4 @@ export function Moveanimate(main){ } } - } diff --git a/src/jlmap3d/jl3ddevice/component/signallight.js b/src/jlmap3d/jl3ddevice/component/signallight.js index 6bb3178f4..9648653c5 100644 --- a/src/jlmap3d/jl3ddevice/component/signallight.js +++ b/src/jlmap3d/jl3ddevice/component/signallight.js @@ -1,8 +1,8 @@ import { JL3D_LOCAL_STATIC } from '@/api/jlmap3d/assets3d.js'; +//信号机贴图 export function Signallightload(lights) { - settexture(lights, "red", JL3D_LOCAL_STATIC+'/MODEL/device/signal/1.jpg'); settexture(lights, "yellow", JL3D_LOCAL_STATIC+'/MODEL/device/signal/2.jpg'); @@ -12,6 +12,7 @@ export function Signallightload(lights) { settexture(lights, "black", JL3D_LOCAL_STATIC+'/MODEL/device/signal/4.jpg'); } +//加载贴图 function settexture(lights, name, textureurl) { var loader = new THREE.TextureLoader(); diff --git a/src/jlmap3d/jl3ddevice/component/textconfig.js b/src/jlmap3d/jl3ddevice/component/textconfig.js index 1c6545f04..1c9a86ca5 100644 --- a/src/jlmap3d/jl3ddevice/component/textconfig.js +++ b/src/jlmap3d/jl3ddevice/component/textconfig.js @@ -4,13 +4,6 @@ export function Textconfig(){ this.devicelist = []; - this.jdqinit = function(){ - - } - - this.jdqraycast = function(){ - - } //配置继电器文字信息 this.initdevicetext = function(selectmodel){ diff --git a/src/jlmap3d/jl3ddevice/jl3ddevice.js b/src/jlmap3d/jl3ddevice/jl3ddevice.js deleted file mode 100644 index cdb2723cb..000000000 --- a/src/jlmap3d/jl3ddevice/jl3ddevice.js +++ /dev/null @@ -1,729 +0,0 @@ -import { Staticmodel } from '@/jlmap3d/jl3ddevice/config.js'; -import { JL3D_LOCAL_STATIC } from '@/api/jlmap3d/assets3d.js'; - -//loader -import { FBXLoader } from '@/jlmap3d/main/loaders/FBXLoader'; -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'; - -var clock = new THREE.Clock(); -export function Jl3ddevice(dom,group,token) { - var scope = this; - - this.dom = dom; - this.nowcode = null; - this.animateswitch = false; - this.signallights = []; - 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 }); - - this.renderer.setClearColor(new THREE.Color(0x000000)); - this.renderer.setSize(dom.offsetWidth, dom.offsetHeight); - this.renderer.shadowMap.enabled = true; - this.renderer.shadowMap.type = THREE.PCFSoftShadowMap; - this.dom.appendChild(this.renderer.domElement); - - //定义相机 - - this.camera = new THREE.PerspectiveCamera(70, dom.offsetWidth / dom.offsetHeight, 0.01, 120); - this.camera.position.set(0, 20, 30); - this.camera.aspect = dom.offsetWidth / dom.offsetHeight; - this.camera.updateProjectionMatrix(); - //定义场景(渲染容器) - this.scene = new THREE.Scene(); - this.scene.background = new THREE.Color(0xa0a0a0); - - var mesh = new THREE.Mesh(new THREE.PlaneBufferGeometry(200, 200), new THREE.MeshPhongMaterial({ color: 0x999999, depthWrite: false })); - mesh.rotation.x = - Math.PI / 2; - mesh.receiveShadow = true; - this.scene.add(mesh); - - var grid = new THREE.GridHelper(200, 20, 0x000000, 0x000000); - grid.material.opacity = 0.2; - grid.material.transparent = true; - this.scene.add(grid); - - - //定义全局光 - let ambientLight = new THREE.AmbientLight(0xffffff, 1.3); - this.scene.add(ambientLight); - - - var spotLight = new THREE.SpotLight(0xffffff); - spotLight.position.set(-50, 60, 15); - spotLight.castShadow = true; - spotLight.shadow.mapSize.width = 1024; - spotLight.shadow.mapSize.height = 1024; - this.scene.add(spotLight); - - - - this.controls = new THREE.OrbitControls(this.camera, dom); - this.controls.maxPolarAngle = Math.PI / 2; - this.controls.minPolarangle = Math.PI / 5; - this.controls.maxDistance = 80; - 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; - let header = {'X-Token': token}; - try { - // console.log("teststomp"); - teststomp.subscribe(topic, callback, header); - } catch (error) { - console.error('websocket订阅失败'); - } - - function callback(Response) { - let data = JSON.parse(Response.body); - if(scope.nowcode != data.body.code){ - scope.nowcode = data.body.code; - scope.selectmodel(data); - }else{ - scope.updateaction(data); - } - - } - window.onresize = function () { - scope.camera.aspect = scope.dom.offsetWidth / scope.dom.offsetHeight; - 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(); - }) - - //循环渲染函数 - function animate() { - - scope.anime = requestAnimationFrame(animate); - scope.renderer.render(scope.scene, scope.camera); - 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++) { - if (scope.mixers[i]) { - scope.mixers[i].update(delta); - } - } - } - - - } - - this.selectmodel = function (data) { - if (scope.showmodel) { - scope.nowcode = data.body.code; - if (scope.showmodel.code != data.body.code) { - scope.scene.remove(scope.showmodel); - scope.showmodel = null - - if (data.body._type == "Switch") { - scope.modelmanager.switchmodel.locateType = data.body.locateType; - 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; - - }else{ - scope.raycasterstatus = false; - scope.nowobject = ""; - updatemenulist(); - } - - if (data.body._type == "Signal") { - scope.modelmanager.signalmodel.code = data.body.code; - - scope.showmodel = scope.modelmanager.signalmodel.mesh; - scope.scene.add(scope.showmodel); - - } - - if (data.body._type == "StationStand") { - - scope.modelmanager.standmodel.code = data.body.code; - - scope.showmodel = scope.modelmanager.standmodel.mesh; - scope.scene.add(scope.showmodel); - } - - if(scope.showmodel){ - scope.resetmodel(); - scope.showmodel.code = data.code; - initstatus(data); - } - - } - } else { - if (data.body._type == "Switch") { - scope.modelmanager.switchmodel.locateType = data.body.locateType; - 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(); - scope.modelmanager.switchmodel.action.time = 0; - scope.modelmanager.switchmodel.action.timeScale = -1; - scope.modelmanager.switchmodel.action.play(); - - } else if (data.body.locateType == "02") { - scope.modelmanager.switchmodel.locateType = "02"; - scope.modelmanager.switchmodel.action.reset(); - scope.modelmanager.switchmodel.action.time = scope.modelmanager.switchmodel.action._clip.duration; - scope.modelmanager.switchmodel.action.timeScale = 1; - scope.modelmanager.switchmodel.action.play(); - - } - - }else{ - scope.raycasterstatus = false; - scope.nowobject = ""; - updatemenulist(); - } - if (data.body._type == "Signal") { - scope.modelmanager.signalmodel.code = data.body.code; - scope.showmodel = scope.modelmanager.signalmodel.mesh; - scope.scene.add(scope.showmodel); - } - - if (data.body._type == "StationStand") { - scope.modelmanager.standmodel.code = data.body.code; - scope.showmodel = scope.modelmanager.standmodel.mesh; - scope.scene.add(scope.showmodel); - } - initstatus(data); - } - - - } - - this.updateaction = function (data) { - - if (data.body._type == "Switch") { - if (data.body.code == scope.modelmanager.switchmodel.code) { - if (scope.modelmanager.switchmodel.locateType != data.body.locateType) { - if (data.body.locateType == "03" && scope.modelmanager.switchmodel.locateType == "01") { - - scope.modelmanager.switchmodel.locateType = "02"; - scope.modelmanager.switchmodel.action.reset(); - scope.modelmanager.switchmodel.action.time = 0; - scope.modelmanager.switchmodel.action.timeScale = 1; - scope.modelmanager.switchmodel.action.play(); - - } else if (data.body.locateType == "03" && scope.modelmanager.switchmodel.locateType == "02") { - - scope.modelmanager.switchmodel.locateType = "01"; - scope.modelmanager.switchmodel.action.reset(); - scope.modelmanager.switchmodel.action.time = scope.modelmanager.switchmodel.action._clip.duration; - scope.modelmanager.switchmodel.action.timeScale = -1; - scope.modelmanager.switchmodel.action.play(); - - } - } - } - - } - if (data.body._type == "Signal") {//从上往下红绿黄 - if (data.body.code == scope.modelmanager.signalmodel.code) { - scope.modelmanager.signalmodel.status = data.body.status; - - if (data.body.lightType == "01") { - - if (data.body.status == "01") { - scope.modelmanager.signalmodel.mesh.children[0].material.map = scope.signallights["red"]; - scope.modelmanager.signalmodel.mesh.children[0].material.map.needsUpdate = true; - scope.modelmanager.signalmodel.mesh.children[1].material.map = scope.signallights["black"]; - scope.modelmanager.signalmodel.mesh.children[1].material.map.needsUpdate = true; - scope.modelmanager.signalmodel.mesh.children[2].material.map = scope.signallights["black"]; - scope.modelmanager.signalmodel.mesh.children[2].material.map.needsUpdate = true; - } - //开放 - if (data.body.status == "02") { - scope.modelmanager.signalmodel.mesh.children[0].material.map = scope.signallights["black"]; - scope.modelmanager.signalmodel.mesh.children[0].material.map.needsUpdate = true; - scope.modelmanager.signalmodel.mesh.children[1].material.map = scope.signallights["black"]; - scope.modelmanager.signalmodel.mesh.children[1].material.map.needsUpdate = true; - scope.modelmanager.signalmodel.mesh.children[2].material.map = scope.signallights["green"]; - scope.modelmanager.signalmodel.mesh.children[2].material.map.needsUpdate = true; - } - //开放侧向 - if (data.body.status == "03") { - scope.modelmanager.signalmodel.mesh.children[0].material.map = scope.signallights["black"]; - scope.modelmanager.signalmodel.mesh.children[0].material.map.needsUpdate = true; - scope.modelmanager.signalmodel.mesh.children[1].material.map = scope.signallights["yellow"]; - scope.modelmanager.signalmodel.mesh.children[1].material.map.needsUpdate = true; - scope.modelmanager.signalmodel.mesh.children[2].material.map = scope.signallights["black"]; - scope.modelmanager.signalmodel.mesh.children[2].material.map.needsUpdate = true; - } - //引导 - if (data.body.status == "04") { - scope.modelmanager.signalmodel.mesh.children[0].material.map = scope.signallights["red"]; - scope.modelmanager.signalmodel.mesh.children[0].material.map.needsUpdate = true; - scope.modelmanager.signalmodel.mesh.children[1].material.map = scope.signallights["yellow"]; - scope.modelmanager.signalmodel.mesh.children[1].material.map.needsUpdate = true; - scope.modelmanager.signalmodel.mesh.children[2].material.map = scope.signallights["black"]; - scope.modelmanager.signalmodel.mesh.children[2].material.map.needsUpdate = true; - } - //封锁 - if (data.body.status == "05") { - scope.modelmanager.signalmodel.mesh.children[0].material.map = scope.signallights["black"]; - scope.modelmanager.signalmodel.mesh.children[0].material.map.needsUpdate = true; - scope.modelmanager.signalmodel.mesh.children[1].material.map = scope.signallights["black"]; - scope.modelmanager.signalmodel.mesh.children[1].material.map.needsUpdate = true; - scope.modelmanager.signalmodel.mesh.children[2].material.map = scope.signallights["black"]; - scope.modelmanager.signalmodel.mesh.children[2].material.map.needsUpdate = true; - } - //故障 - if (data.body.status == "06") { - scope.modelmanager.signalmodel.mesh.children[0].material.map = scope.signallights["black"]; - scope.modelmanager.signalmodel.mesh.children[0].material.map.needsUpdate = true; - scope.modelmanager.signalmodel.mesh.children[1].material.map = scope.signallights["black"]; - scope.modelmanager.signalmodel.mesh.children[1].material.map.needsUpdate = true; - scope.modelmanager.signalmodel.mesh.children[2].material.map = scope.signallights["black"]; - scope.modelmanager.signalmodel.mesh.children[2].material.map.needsUpdate = true; - } - - } else if (data.body.lightType == "02") { - scope.modelmanager.signalmodel.mesh.children[0].material.map = scope.signallights["black"]; - scope.modelmanager.signalmodel.mesh.children[0].material.map.needsUpdate = true; - scope.modelmanager.signalmodel.mesh.children[1].material.map = scope.signallights["black"]; - scope.modelmanager.signalmodel.mesh.children[1].material.map.needsUpdate = true; - scope.modelmanager.signalmodel.mesh.children[2].material.map = scope.signallights["black"]; - scope.modelmanager.signalmodel.mesh.children[2].material.map.needsUpdate = true; - } - } - - } - - - if (data.body._type == "StationStand") { - if (data.body.code == scope.modelmanager.standmodel.code) { - if (data.body.screenDoorOpenStatus == "02" && scope.modelmanager.standmodel.screenDoorOpenStatus == "01") { - scope.modelmanager.standmodel.screenDoorOpenStatus = "00"; - } - if (data.body.screenDoorOpenStatus == "02" && scope.modelmanager.standmodel.screenDoorOpenStatus == "00") { - scope.modelmanager.standmodel.screenDoorOpenStatus = "02"; - - scope.modelmanager.standmodel.action.reset(); - scope.modelmanager.standmodel.action.time = 0; - scope.modelmanager.standmodel.action.timeScale = 1; - scope.modelmanager.standmodel.action.play(); - } - - if (data.body.screenDoorOpenStatus == "01" && scope.modelmanager.standmodel.screenDoorOpenStatus == "02") { - scope.modelmanager.standmodel.screenDoorOpenStatus = "00"; - } - if (data.body.screenDoorOpenStatus == "01" && scope.modelmanager.standmodel.screenDoorOpenStatus == "00") { - scope.modelmanager.standmodel.screenDoorOpenStatus = "01"; - - scope.modelmanager.standmodel.action.reset(); - scope.modelmanager.standmodel.action.time = scope.modelmanager.standmodel.action._clip.duration; - scope.modelmanager.standmodel.action.timeScale = -1; - scope.modelmanager.standmodel.action.play(); - } - } - - } - // scope.showmodel. - } - - function initstatus(data) { - - if (data.body._type == "Switch") { - - if (data.body.locateType == "01") { - scope.modelmanager.switchmodel.locateType = "01"; - scope.modelmanager.switchmodel.action.reset(); - scope.modelmanager.switchmodel.action.time = 0; - scope.modelmanager.switchmodel.action.timeScale = -1; - scope.modelmanager.switchmodel.action.play(); - - } else if (data.body.locateType == "02") { - scope.modelmanager.switchmodel.locateType = "02"; - scope.modelmanager.switchmodel.action.reset(); - scope.modelmanager.switchmodel.action.time = scope.modelmanager.switchmodel.action._clip.duration; - scope.modelmanager.switchmodel.action.timeScale = 1; - scope.modelmanager.switchmodel.action.play(); - - } - - - } - - if (data.body._type == "Signal") { - if (data.body.lightType == "01") { - - if (data.body.status == "01") { - scope.modelmanager.signalmodel.mesh.children[0].material.map = scope.signallights["red"]; - scope.modelmanager.signalmodel.mesh.children[0].material.map.needsUpdate = true; - scope.modelmanager.signalmodel.mesh.children[1].material.map = scope.signallights["black"]; - scope.modelmanager.signalmodel.mesh.children[1].material.map.needsUpdate = true; - scope.modelmanager.signalmodel.mesh.children[2].material.map = scope.signallights["black"]; - scope.modelmanager.signalmodel.mesh.children[2].material.map.needsUpdate = true; - } - //开放 - if (data.body.status == "02") { - scope.modelmanager.signalmodel.mesh.children[0].material.map = scope.signallights["black"]; - scope.modelmanager.signalmodel.mesh.children[0].material.map.needsUpdate = true; - scope.modelmanager.signalmodel.mesh.children[1].material.map = scope.signallights["green"]; - scope.modelmanager.signalmodel.mesh.children[1].material.map.needsUpdate = true; - scope.modelmanager.signalmodel.mesh.children[2].material.map = scope.signallights["black"]; - scope.modelmanager.signalmodel.mesh.children[2].material.map.needsUpdate = true; - } - if (data.body.switchLocateType == "03") { - scope.modelmanager.signalmodel.mesh.children[0].material.map = scope.signallights["black"]; - scope.modelmanager.signalmodel.mesh.children[0].material.map.needsUpdate = true; - scope.modelmanager.signalmodel.mesh.children[1].material.map = scope.signallights["black"]; - scope.modelmanager.signalmodel.mesh.children[1].material.map.needsUpdate = true; - scope.modelmanager.signalmodel.mesh.children[2].material.map = scope.signallights["yellow"]; - scope.modelmanager.signalmodel.mesh.children[2].material.map.needsUpdate = true; - } - //引导 - if (data.body.status == "03") { - scope.modelmanager.signalmodel.mesh.children[0].material.map = scope.signallights["red"]; - scope.modelmanager.signalmodel.mesh.children[0].material.map.needsUpdate = true; - scope.modelmanager.signalmodel.mesh.children[1].material.map = scope.signallights["black"]; - scope.modelmanager.signalmodel.mesh.children[1].material.map.needsUpdate = true; - scope.modelmanager.signalmodel.mesh.children[2].material.map = scope.signallights["yellow"]; - scope.modelmanager.signalmodel.mesh.children[2].material.map.needsUpdate = true; - } - //封锁 - if (data.body.status == "04") { - scope.modelmanager.signalmodel.mesh.children[0].material.map = scope.signallights["black"]; - scope.modelmanager.signalmodel.mesh.children[0].material.map.needsUpdate = true; - scope.modelmanager.signalmodel.mesh.children[1].material.map = scope.signallights["black"]; - scope.modelmanager.signalmodel.mesh.children[1].material.map.needsUpdate = true; - scope.modelmanager.signalmodel.mesh.children[2].material.map = scope.signallights["black"]; - scope.modelmanager.signalmodel.mesh.children[2].material.map.needsUpdate = true; - } - //故障 - if (data.body.status == "05") { - scope.modelmanager.signalmodel.mesh.children[0].material.map = scope.signallights["black"]; - scope.modelmanager.signalmodel.mesh.children[0].material.map.needsUpdate = true; - scope.modelmanager.signalmodel.mesh.children[1].material.map = scope.signallights["black"]; - scope.modelmanager.signalmodel.mesh.children[1].material.map.needsUpdate = true; - scope.modelmanager.signalmodel.mesh.children[2].material.map = scope.signallights["black"]; - scope.modelmanager.signalmodel.mesh.children[2].material.map.needsUpdate = true; - } - - } else if (data.body.lightType == "02") { - scope.modelmanager.signalmodel.mesh.children[0].material.map = scope.signallights["black"]; - scope.modelmanager.signalmodel.mesh.children[0].material.map.needsUpdate = true; - scope.modelmanager.signalmodel.mesh.children[1].material.map = scope.signallights["black"]; - scope.modelmanager.signalmodel.mesh.children[1].material.map.needsUpdate = true; - scope.modelmanager.signalmodel.mesh.children[2].material.map = scope.signallights["black"]; - scope.modelmanager.signalmodel.mesh.children[2].material.map.needsUpdate = true; - } - } - - if (data.body._type == "StationStand") { - if (data.body.code == scope.modelmanager.standmodel.code) { - - if (data.body.screenDoorOpenStatus == "02") { - scope.modelmanager.standmodel.screenDoorOpenStatus = "02"; - - scope.modelmanager.standmodel.action.reset(); - scope.modelmanager.standmodel.action.time = scope.modelmanager.standmodel.action._clip.duration; - scope.modelmanager.standmodel.action.timeScale = 1; - scope.modelmanager.standmodel.action.play(); - } - - if (data.body.screenDoorOpenStatus == "01") { - scope.modelmanager.standmodel.screenDoorOpenStatus = "01"; - - scope.modelmanager.standmodel.action.reset(); - scope.modelmanager.standmodel.action.time = 0; - scope.modelmanager.standmodel.action.timeScale = -1; - scope.modelmanager.standmodel.action.play(); - } - } - - } - - } - - //设备分解、归位动画按钮 - 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 { let netDataAssets = JSON.parse(netdata.data.assets); @@ -283,6 +275,7 @@ export function Jl3ddeviceNew(dom,group,token,skinCode) { }); + //初始化屏蔽门贴图 function setpsdstationmap(stationlist){ for(let i=0,leni=stationlist.length;i=0;j--){ diff --git a/src/jlmap3d/jl3dsimulation/jlmap3d.js b/src/jlmap3d/jl3dsimulation/jlmap3d.js index 5ffb6ccb0..596e6f7d4 100644 --- a/src/jlmap3d/jl3dsimulation/jlmap3d.js +++ b/src/jlmap3d/jl3dsimulation/jlmap3d.js @@ -37,7 +37,6 @@ var clock = new THREE.Clock(); export function JLmap3d(dom, data,skinCode,storemod,routegroup,project) { - let scope = this; this.dom = dom; @@ -46,8 +45,10 @@ export function JLmap3d(dom, data,skinCode,storemod,routegroup,project) { renderer.domElement.style.position = "absolute"; renderer.domElement.style.top = "0"; document.getElementById('testjlmap3d').appendChild(renderer.domElement); + //定义相机 let camera = SetCamera(dom); + //定义场景(渲染容器) let scene = SetScene(project); let scenesimulation = new THREE.Group(); @@ -79,6 +80,7 @@ export function JLmap3d(dom, data,skinCode,storemod,routegroup,project) { //模型操作命令组 this.actions = {}; + //设备数据 let sectionlist = null; let linklist = null; let signallist = null; @@ -87,16 +89,17 @@ export function JLmap3d(dom, data,skinCode,storemod,routegroup,project) { let realsectionlist = null; let rails = null; + //轨道相机 let camerarail = { curve:null, progress:0, moveswitch:false }; + //地图模型数据 let mapdata = new Jl3ddata(); + //订阅仿真socket - - this.webwork = new Worker(JL3D_LOCAL_STATIC+"/workertest/trainworker.js"); //初始化加载数据和模型getPublishMapDetail getPublishMapDetail(skinCode).then(data => { @@ -110,46 +113,7 @@ export function JLmap3d(dom, data,skinCode,storemod,routegroup,project) { SimulationLoadNew(mapnetdata,scope,netdata.data,mapdata,camera,controls,scenesimulation,storemod); }); }); - // - // let stats = new Stats(); - // dom.appendChild( stats.dom ); - // var timer = setInterval(function() { - // if(trainlisttest){ - // if(trainlisttest.group){ - // if(trainlisttest.group.children[0]){ - // for(let k in rails.switchrail){ - // const ddd = storemod.getters['map/getDeviceByCode'](k); - // let switchdata = rails.switchrail[k]; - // rails.switchrail[k].locateType = ddd.locateType; - // - // if(ddd.locateType == "01"){ - // //1--向左 2--向右 - // //__\__ __/__ - // if(rails.switchrail[k].directtype == "1"){ - // rails.linkrail[switchdata.alink].lconnect = switchdata.blink; - // rails.linkrail[switchdata.blink].rconnect = switchdata.alink; - // }else if(rails.switchrail[k].directtype == "2"){ - // rails.linkrail[switchdata.alink].rconnect = switchdata.blink; - // rails.linkrail[switchdata.blink].lconnect = switchdata.alink; - // } - // - // }else if(ddd.locateType == "02"){ - // if(rails.switchrail[k].directtype == "1"){ - // rails.linkrail[switchdata.alink].lconnect = switchdata.clink; - // rails.linkrail[switchdata.clink].rconnect = switchdata.alink; - // }else if(rails.switchrail[k].directtype == "2"){ - // rails.linkrail[switchdata.alink].rconnect = switchdata.clink; - // rails.linkrail[switchdata.clink].lconnect = switchdata.alink; - // } - // } - // } - // clearInterval(timer); - // } - // } - // } - // - // }, 2000); //开启渲染 animate(); startWorker(scope.webwork); @@ -158,18 +122,13 @@ export function JLmap3d(dom, data,skinCode,storemod,routegroup,project) { //循环渲染函数 function animate() { //循环渲染 - //requestAnimationFrame(animate); - //renderer.setAnimationLoop(animate); requestAnimationFrame(animate); - //判断渲染是否开启 - //根据相机渲染场景 + //根据相机渲染场景 renderer.render(scene,camera); - //检测动画构造器播放动画 - - // } // stats.update(); } + //利用webworker当做定时器驱动设备动画,更新列车状态,车站漫游动画 function startWorker(webwork){ if(typeof(Worker)!=="undefined"){ @@ -181,6 +140,15 @@ export function JLmap3d(dom, data,skinCode,storemod,routegroup,project) { UpdateTrain(camera,trainlisttest); } + delta = clock.getDelta(); + for(let i=scope.mixers.length-1;i>=0;i--){ + if(scope.mixers[i]._actions[0].isRunning()){ + // console.log(scope.mixers[i]._actions[0].isRunning()); + scope.mixers[i].update( delta ); + } + } + + //开启车站漫游 if(camerarail.moveswitch == true){ // console.log(camerarail.progress); if(camerarail.progress>=0.99){ @@ -201,18 +169,12 @@ export function JLmap3d(dom, data,skinCode,storemod,routegroup,project) { } - delta = clock.getDelta(); - for(let i=scope.mixers.length-1;i>=0;i--){ - if(scope.mixers[i]._actions[0].isRunning()){ - // console.log(scope.mixers[i]._actions[0].isRunning()); - scope.mixers[i].update( delta ); - } - } }; } } + //释放场景缓存关闭渲染循环 this.dispose = function(){ renderer.setAnimationLoop(null); renderer.dispose(); @@ -242,6 +204,7 @@ export function JLmap3d(dom, data,skinCode,storemod,routegroup,project) { } }; + //切换显示车站信息 this.showstationmsg = function(showtype){ if(showtype == "show"){ for(let st=0;st import Vue from 'vue'; import { JL3D_LOCAL_STATIC } from '@/api/jlmap3d/assets3d.js'; - import { Jl3ddevice } from '@/jlmap3d/jl3ddevice/jl3ddevice.js'; import { Jl3ddeviceNew } from '@/jlmap3d/jl3ddevice/jl3ddeviceNew.js'; import Jl3ddeviceMsg from '@/views/jlmap3d/device/component/devicemsg'; @@ -135,13 +134,10 @@ this.windowstatus = true; // this.jl3d.updatewindowstatus('1'); } - if(this.$store.state.map.map.linkList){ - this.datastatus = "old"; - this.initolddata(group,header); - }else{ - this.datastatus = "new"; - this.initnewdata(group,header); - } + //定义转辙机动画 + this.datastatus = "new"; + this.initnewdata(group,header); + if(this.$route.query.type == "VR_PSD"){ this.jl3d.updatewindowstatus('1'); this.psdCode = this.$route.query.psdCode; @@ -156,11 +152,6 @@ beforeDestroy() { }, methods: { - initolddata: function (group,header) { - // let mapdata = this.$store.state.socket.device; - let dom = document.getElementById('jl3d'); - this.jl3d = new Jl3ddevice(dom,group,header,this.mapId); - }, initnewdata: function (group,header){ let dom = document.getElementById('jl3d'); this.jl3d = new Jl3ddeviceNew(dom,group,header,this.mapId); diff --git a/src/views/jlmap3d/drive/drivecontrol/toprightpane.vue b/src/views/jlmap3d/drive/drivecontrol/toprightpane.vue index 29794f493..70fb4dc5b 100644 --- a/src/views/jlmap3d/drive/drivecontrol/toprightpane.vue +++ b/src/views/jlmap3d/drive/drivecontrol/toprightpane.vue @@ -17,7 +17,7 @@
BM/CBTC
-
--> +
@@ -83,20 +83,20 @@
--> - + - + +
@@ -193,6 +193,11 @@ doorleftimg:JL3D_LOCAL_STATIC+"/jl3d/control/green.png", doorrightimg:JL3D_LOCAL_STATIC+"/jl3d/control/green.png", + //升降弓灯亮light暗dark + sgl:JL3D_LOCAL_STATIC+"/jl3d/control/greenz.png", + jgl:JL3D_LOCAL_STATIC+"/jl3d/control/redz.png", + sgd:JL3D_LOCAL_STATIC+"/jl3d/control/greenz.png", + jgd:JL3D_LOCAL_STATIC+"/jl3d/control/redz.png", } }, watch: { diff --git a/src/views/jlmap3d/drive/sceneview/tmscomponent/tmsfault.vue b/src/views/jlmap3d/drive/sceneview/tmscomponent/tmsfault.vue new file mode 100644 index 000000000..cce1a2b75 --- /dev/null +++ b/src/views/jlmap3d/drive/sceneview/tmscomponent/tmsfault.vue @@ -0,0 +1,95 @@ + + + + + + diff --git a/src/views/jlmap3d/drive/sceneview/tmsview.vue b/src/views/jlmap3d/drive/sceneview/tmsview.vue index 9d2b603f4..cc3b0e810 100644 --- a/src/views/jlmap3d/drive/sceneview/tmsview.vue +++ b/src/views/jlmap3d/drive/sceneview/tmsview.vue @@ -1,6 +1,7 @@