diff --git a/src/jlmap3d/config/SetScene.js b/src/jlmap3d/config/SetScene.js index c2d61f955..d7aa434a0 100644 --- a/src/jlmap3d/config/SetScene.js +++ b/src/jlmap3d/config/SetScene.js @@ -2,12 +2,12 @@ export function SetScene() { var scene = new THREE.Scene(); var cubeTextureLoader = new THREE.CubeTextureLoader(); - cubeTextureLoader.setPath( '../../static/skybox/city/' ); + cubeTextureLoader.setPath( '../../static/skybox/star/' ); var cubeTexture = cubeTextureLoader.load( [ - 'px.jpg', 'nx.jpg', - 'py.jpg', 'ny.jpg', - 'pz.jpg', 'nz.jpg', + 'px.png', 'nx.png', + 'py.png', 'ny.png', + 'pz.png', 'nz.png', ] ); scene.background = cubeTexture; diff --git a/src/jlmap3d/jl3ddrive/jl3ddrive.js b/src/jlmap3d/jl3ddrive/jl3ddrive.js index 24a1288c2..99efbe887 100644 --- a/src/jlmap3d/jl3ddrive/jl3ddrive.js +++ b/src/jlmap3d/jl3ddrive/jl3ddrive.js @@ -41,9 +41,13 @@ var clock = new THREE.Clock(); export function JLmapDriving(dom, data, skinCode) { const scope = this; + + //界面更新函数 + let updatemmi = {}; this.dom = dom; // 渲染循环开关 this.animateswitch = false; + this.cctvswitch = false; // 初始化webgl渲染 const renderer = SetRender(dom); renderer.domElement.style.position = 'absolute'; @@ -57,7 +61,7 @@ export function JLmapDriving(dom, data, skinCode) { document.getElementById('jlsimulation').appendChild(renderer.domElement); document.getElementById('jlcctv').appendChild(renderercctv.domElement); // 定义相机 - // let camera = SetCamera(dom); + //let camera = SetCamera(dom); // 定义场景(渲染容器) const scene = SetScene(); @@ -78,7 +82,7 @@ export function JLmapDriving(dom, data, skinCode) { // 选中物体描边方框 this.helpbox = null; // 车门,站台门道岔动画构造器 - this.mixers = []; + let mixers = []; // 模型操作命令组 this.actions = {}; this.nowspeed = null; @@ -103,21 +107,20 @@ export function JLmapDriving(dom, data, skinCode) { controls3.enabled = true; scene.add(controls3.getObject()); - const cameracctv = new THREE.PerspectiveCamera(70, dom.clientWidth/dom.clientHeight, 1, 150); - cameracctv.position.set( 5, -3, 27 ); + let cameracctv = new THREE.PerspectiveCamera(70, dom.clientWidth/dom.clientHeight, 1, 120); + cameracctv.position.set( 5, -3,27 ); cameracctv.rotation.y = Math.PI/5*3; camera.add(cameracctv); // 订阅仿真socket - this.Subscribe = new Jl3dDriving(scope); + this.Subscribe = new Jl3dDriving(updatemmi); this.Subscribe.socketon(scope.Subscribe.topic); // 初始化加载数据和模型 getPublish3dMapDetail(skinCode).then(netdata => { - ModelLoad(data, scope, netdata.data, mapdata, camera, controls3, scene); + ModelLoad(data, scope, netdata.data, mapdata, camera, controls3, scene,mixers); }); - // let stats = new Stats(); // dom.appendChild( stats.dom ); // 开启渲染 @@ -135,12 +138,19 @@ export function JLmapDriving(dom, data, skinCode) { if (scope.animateswitch == true) { // 根据相机渲染场景 renderer.render(scene, camera); - renderercctv.render(scene, cameracctv); - // updatcontrols(); - // renderercctv - controls3.update(); - // 检测动画构造器播放动画 + //cctv渲染 + + if(scope.cctvswitch == true){ + renderercctv.render(scene,cameracctv); + } + //相机按键位移 + //controls3.update(); + delta = clock.getDelta(); + for (let i=mixers.length-1; i>=0; i--) { + mixers[i].update( delta ); + } + // stats.update(); } } @@ -160,43 +170,36 @@ export function JLmapDriving(dom, data, skinCode) { scope.webwork.onmessage = function (event) { // 更新列车位置 - // stats.update(); UpdateTrain(camera, mapdata.trainlisttest); - delta = clock.getDelta(); - for (let i=scope.mixers.length-1; i>=0; i--) { - if ( scope.mixers[i] ) { - scope.mixers[i].update( delta ); - } - } }; } } - this.updatenowspeed = function(speed) { + updatemmi.updatenowspeed = function(speed) { scope.nowspeed = speed; }; - this.updatenowlen = function(maLen) { + updatemmi.updatenowlen = function(maLen) { scope.nowmxlen = maLen; }; - this.updateatpspeed = function(atpspeed) { + updatemmi.updateatpspeed = function(atpspeed) { scope.atpspeed = atpspeed; }; - this.updateatospeed = function(atospeed) { + updatemmi.updateatospeed = function(atospeed) { scope.atospeed = atospeed; }; - this.updatetrainnum = function(trainnum) { + updatemmi.updatetrainnum = function(trainnum) { scope.trainnum = trainnum; }; - this.updatestoptime = function(stime) { + updatemmi.updatestoptime = function(stime) { scope.stime = stime; }; - this.updatedrivedata = function(drivedata) { + updatemmi.updatedrivedata = function(drivedata) { scope.drivecount += 1; scope.drivedata = drivedata; }; - this.updatedrivingcode = function(code) { + updatemmi.updatedrivingcode = function(code) { drivingcode = code; mapdata.trainlisttest.list[drivingcode].children[0].add(controls3.getObject()); mapdata.trainlisttest.list[drivingcode].children[0].add(scope.assetloader.modellist[4].mesh); @@ -221,7 +224,7 @@ export function JLmapDriving(dom, data, skinCode) { scope.materiallist = null; scope.selectmodel = null; scope.helpbox = null; - scope.mixers = null; + mixers = null; scope.actions = null; scope.Subscribe = null; // console.log(scope); @@ -274,6 +277,14 @@ export function JLmapDriving(dom, data, skinCode) { scope.animateswitch = false; }; + this.cctvon = function() { + scope.cctvswitch = true; + }; + + this.cctvoff = function() { + scope.cctvswitch = false; + }; + this.endsocket = function() { scope.Subscribe.socketoff(scope.Subscribe.topic); }; diff --git a/src/jlmap3d/jl3ddrive/moveupdate/DrivingConnect.js b/src/jlmap3d/jl3ddrive/moveupdate/DrivingConnect.js index 592dd0722..c26392350 100644 --- a/src/jlmap3d/jl3ddrive/moveupdate/DrivingConnect.js +++ b/src/jlmap3d/jl3ddrive/moveupdate/DrivingConnect.js @@ -7,9 +7,9 @@ import { handleToken } from '@/utils/auth'; import router from '@/router'; // 定于仿真socket接口 -export function Jl3dDriving(jlmap3d) { +export function Jl3dDriving(updatemmi) { - const scope = this; + let scope = this; this.map = null; var trainlisttest = null; @@ -29,16 +29,16 @@ export function Jl3dDriving(jlmap3d) { let driverswitch = false; - const stoptimer = null; - const num = 30; - const pointstand = null; + let stoptimer = null; + let num = 30; + let pointstand = null; // run as plane = 01; // reset = 02; var datatype = '00'; this.teststomp = new StompClient(); this.topic = '/user/queue/simulation/jl3d'; - const header = {'X-Token': handleToken() }; + let header = {'X-Token': handleToken() }; this.updatamap = function(mapdata, materiallist, nowaction, scene) { // console.log(mapdata); @@ -85,7 +85,7 @@ export function Jl3dDriving(jlmap3d) { // 仿真socket接口回调函数 function callback(Response) { // 对象化数据 - const data = JSON.parse(Response.body); + let data = JSON.parse(Response.body); // 遍历后台数据 // 判断消息类型 @@ -93,26 +93,63 @@ export function Jl3dDriving(jlmap3d) { // // // } - if (data.type == 'Simulation_Driver_Change') { - drivingcode = data.body.code; - jlmap3d.updatedrivingcode( data.body.code); - } - if(data.type == 'Simulation_Drive_Data_Routing'){ - jlmap3d.updatedrivedata(data.body); - } - if (data.type == 'Simulation_TrainSpeed') { + switch (data.type) { + case 'Simulation_TrainSpeed': + trainspeed(data); + break; + case 'Simulation_Drive_Data_Routing': + updatemmi.updatedrivedata(data.body); + break; + case 'Simulation_Driver_Change': + drivingcode = data.body.code; + updatemmi.updatedrivingcode( data.body.code); + break; + case 'SJL3D_TrainStatus': + trainstatus(data); + break; + case 'Simulation_DeviceStatus': + devicestatus(data); + break; + default : + //TODO + } - if (trainlisttest) { + // if(data.type == 'Simulation_Drive_Data_Routing'){ + // updatemmi.updatedrivedata(data.body); + // } + // + // if (data.type == 'Simulation_Driver_Change') { + // drivingcode = data.body.code; + // updatemmi.updatedrivingcode( data.body.code); + // } + // + // if (data.type == 'Simulation_TrainSpeed') { + // trainspeed(data); + // } + // + // if (data.type == 'SJL3D_TrainStatus') { + // trainstatus(data); + // } + // + // if (data.type == 'Simulation_DeviceStatus') { + // devicestatus(data); + // } - for (let tl = 0; tl0) { - jlmap3d.updatenowspeed(data.body[tl].v); - } else { - jlmap3d.updatenowspeed(Math.abs(data.body[tl].v)); - } + // if (data.body[tl].v >0) { + // updatemmi.updatenowspeed(data.body[tl].v); + // } else { + updatemmi.updatenowspeed(Math.abs(data.body[tl].v)); + // } + } + } - if (data.body[tl].atpv) { - jlmap3d.updateatpspeed(data.body[tl].atpv); - } else { - jlmap3d.updateatpspeed(-1); - } - if (data.body[tl].atov) { - jlmap3d.updateatospeed(data.body[tl].atov); - } else { - jlmap3d.updateatospeed(-1); - } + + + if (code == drivingcode) { + if (data.body[tl].atpv) { + updatemmi.updateatpspeed(data.body[tl].atpv); + } else { + updatemmi.updateatpspeed(-1); + } + if (data.body[tl].atov) { + updatemmi.updateatospeed(data.body[tl].atov); + } else { + updatemmi.updateatospeed(-1); } } } } + } - if (data.type == 'SJL3D_TrainStatus') { - for (let i=data.body.length-1; i>=0; i--) { - if (data.body[i]._type == 'Train') { - // 遍历列车对象组 - if (trainlisttest) { - code = data.body[i].code; - // 剔除不显示的车 - // 找到对应列车 + function trainstatus(data){ + for (let i=data.body.length-1; i>=0; i--) { + // 遍历列车对象组 + if (trainlisttest) { + code = data.body[i].code; + // 剔除不显示的车 + // 找到对应列车 - if ( trainlisttest.list[code]) { - if (code == drivingcode) { - driverswitch = data.body[i].runMode; - jlmap3d.updatetrainnum(data.body[i].groupNumber); - // console.log(trainlisttest.list[code].progress); - const syncdata = { - type: 'Train', - code: code, - sectionCode: data.body[i].sectionCode, - percent: 0 - }; + if ( trainlisttest.list[code]) { + if (code == drivingcode) { + driverswitch = data.body[i].runMode; + //更新车组号 + updatemmi.updatetrainnum(data.body[i].groupNumber); + //更新列车 + let syncdata = { + type: 'Train', + code: code, + sectionCode: data.body[i].sectionCode, + percent: 0 + }; - if (trainlisttest.list[code].isStandTrack == true && trainlisttest.list[code].progress>0.95 && trainlisttest.list[code].speed<=0) { - if (data.body[i].directionType == '02') { - syncdata.percent = 1-(sectionlist.sections.datalist[data.body[i].sectionCode].rstop/trainlisttest.list[code].len); - } else { - syncdata.percent = sectionlist.sections.datalist[data.body[i].sectionCode].lstop/trainlisttest.list[code].len; - } - //scope.teststomp.send('/app/topic/simulation/wgu3d', syncdata); + if (trainlisttest.list[code].isStandTrack == true && trainlisttest.list[code].progress>0.95 && trainlisttest.list[code].speed<=0) { + if (data.body[i].directionType == '02') { + syncdata.percent = 1-(sectionlist.sections.datalist[data.body[i].sectionCode].rstop/trainlisttest.list[code].len); } else { - if (data.body[i].directionType == '02') { - syncdata.percent = trainlisttest.list[code].progress; - } else { - syncdata.percent = 1 - trainlisttest.list[code].progress; - } - //scope.teststomp.send('/app/topic/simulation/wgu3d', syncdata); + syncdata.percent = sectionlist.sections.datalist[data.body[i].sectionCode].lstop/trainlisttest.list[code].len; } - - if (data.body[i].parkRemainTime>0) { - jlmap3d.updatestoptime('停站时间:'+parseInt(data.body[i].parkRemainTime)); + //scope.teststomp.send('/app/topic/simulation/wgu3d', syncdata); + } else { + if (data.body[i].directionType == '02') { + syncdata.percent = trainlisttest.list[code].progress; } else { - if (data.body[i].runMode == '02') { - jlmap3d.updatestoptime('列车自动驾驶中'); - } else { - if (trainlisttest.list[code].isStandTrack == true && trainlisttest.list[code].progress>0.95 && trainlisttest.list[code].speed<=0) { - // if(stoptimer){ - // - // }else{ - // stoptimer = setInterval(function(){ - // if(num >=0){ - // jlmap3d.updatestoptime("停站时间:"+num); - // num --; - // } - // },1000); - // } - - } else { - jlmap3d.updatestoptime('列车人工驾驶中'); - } - - } + syncdata.percent = 1 - trainlisttest.list[code].progress; } - // if(trainlisttest.list[code].speed > 0){ - // if(stoptimer){ - // clearInterval( stoptimer ); - // stoptimer = null; - // num = 30; - // } - // } - + //scope.teststomp.send('/app/topic/simulation/wgu3d', syncdata); } - trainlisttest.list[code].runMode = data.body[i].runMode; - // 车门开关验证 - if (trainlisttest.list[code].doorStatus != data.body[i].doorStatus && data.body[i].doorStatus == '01') { - // console.log("close"); - trainlisttest.list[code].doorStatus = '01'; - for (let an=actions[code].top.length-1; an>=0; an--) { - actions[code].top[an].reset(); - actions[code].top[an].time = actions[code].top[an]._clip.duration; - actions[code].top[an].timeScale = -1; - actions[code].top[an].play(); - } - } else if (trainlisttest.list[code].doorStatus != data.body[i].doorStatus && data.body[i].doorStatus == '02') { - // console.log("open"); - trainlisttest.list[code].doorStatus = '02'; - for (let an=actions[code].top.length-1; an>=0; an--) { - actions[code].top[an].reset(); - actions[code].top[an].time = 0; - actions[code].top[an].timeScale = 1; - actions[code].top[an].play(); + + if (data.body[i].parkRemainTime>0) { + updatemmi.updatestoptime('停站时间:'+parseInt(data.body[i].parkRemainTime)); + } else { + if (data.body[i].runMode == '02') { + updatemmi.updatestoptime('列车自动驾驶中'); + } else { + if (trainlisttest.list[code].isStandTrack == true && trainlisttest.list[code].progress>0.95 && trainlisttest.list[code].speed<=0) { + // if(stoptimer){ + // + // }else{ + // stoptimer = setInterval(function(){ + // if(num >=0){ + // updatemmi.updatestoptime("停站时间:"+num); + // num --; + // } + // },1000); + // } + + } else { + updatemmi.updatestoptime('列车人工驾驶中'); + } } } - // if (data.body[i].directionType == '02') { - // - // } else { - // if (trainlisttest.list[code].doorStatus != data.body[i].doorStatus && data.body[i].doorStatus == '01') { - // // console.log("close"); - // trainlisttest.list[code].doorStatus = '01'; - // for (let an=actions[code].down.length-1; an>=0; an--) { - // actions[code].down[an].reset(); - // actions[code].down[an].time = actions[code].top[an]._clip.duration; - // actions[code].down[an].timeScale = -1; - // actions[code].down[an].play(); - // } - // } else if (trainlisttest.list[code].doorStatus != data.body[i].doorStatus && data.body[i].doorStatus == '02') { - // // console.log("open"); - // trainlisttest.list[code].doorStatus = '02'; - // for (let an=actions[code].down.length-1; an>=0; an--) { - // actions[code].down[an].reset(); - // actions[code].down[an].time = 0; - // actions[code].down[an].timeScale = 1; - // actions[code].down[an].play(); - // } - // } - // } - // 遍历获取所在轨道 + } + trainlisttest.list[code].runMode = data.body[i].runMode; - if (trainlisttest.list[code].dispose != data.body[i].dispose && data.body[i].dispose == false) { + // 车门开关验证 + if (trainlisttest.list[code].doorStatus != data.body[i].doorStatus && data.body[i].doorStatus == '01') { + // console.log("close"); + trainlisttest.list[code].doorStatus = '01'; + for (let an=actions[code].top.length-1; an>=0; an--) { + actions[code].top[an].reset(); + actions[code].top[an].time = actions[code].top[an]._clip.duration; + actions[code].top[an].timeScale = -1; + actions[code].top[an].play(); + } + } else if (trainlisttest.list[code].doorStatus != data.body[i].doorStatus && data.body[i].doorStatus == '02') { + // console.log("open"); + trainlisttest.list[code].doorStatus = '02'; + for (let an=actions[code].top.length-1; an>=0; an--) { + actions[code].top[an].reset(); + actions[code].top[an].time = 0; + actions[code].top[an].timeScale = 1; + actions[code].top[an].play(); + } + } + // if (data.body[i].directionType == '02') { + // + // } else { + // if (trainlisttest.list[code].doorStatus != data.body[i].doorStatus && data.body[i].doorStatus == '01') { + // // console.log("close"); + // trainlisttest.list[code].doorStatus = '01'; + // for (let an=actions[code].down.length-1; an>=0; an--) { + // actions[code].down[an].reset(); + // actions[code].down[an].time = actions[code].top[an]._clip.duration; + // actions[code].down[an].timeScale = -1; + // actions[code].down[an].play(); + // } + // } else if (trainlisttest.list[code].doorStatus != data.body[i].doorStatus && data.body[i].doorStatus == '02') { + // // console.log("open"); + // trainlisttest.list[code].doorStatus = '02'; + // for (let an=actions[code].down.length-1; an>=0; an--) { + // actions[code].down[an].reset(); + // actions[code].down[an].time = 0; + // actions[code].down[an].timeScale = 1; + // actions[code].down[an].play(); + // } + // } + // } + // 遍历获取所在轨道 - if (sectionlist.sections.datalist[data.body[i].sectionCode].code) { - trainlisttest.group.add(trainlisttest.list[code]); + if (trainlisttest.list[code].dispose != data.body[i].dispose && data.body[i].dispose == false) { + + if (sectionlist.sections.datalist[data.body[i].sectionCode].code) { + trainlisttest.group.add(trainlisttest.list[code]); + trainlisttest.list[code].position.y = 0; + trainlisttest.list[code].progress = 0; + trainlisttest.list[code].oldoffset = data.body[i].sectionOffsetPercent; + trainlisttest.list[code].dispose = false; + trainlisttest.list[code].nowcode = data.body[i].sectionCode; + trainlisttest.list[code].nextcode = data.body[i].nextSectionCode; + let vexlist = []; + let endrotation = null; + + if (data.body[i].directionType == '02') { // 向右 + let offset = null; + let rotaposx = null; + + if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x>sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) { + offset = sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x-sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x; + rotaposx = sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x+offset*data.body[i].sectionOffsetPercent; + } else { + offset = sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x-sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x; + rotaposx = sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x+offset*data.body[i].sectionOffsetPercent; + } + + let rotaposz = sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].z; + + trainlisttest.list[code].rotation.y = 0; + trainlisttest.list[code].position.x = rotaposx; trainlisttest.list[code].position.y = 0; - trainlisttest.list[code].progress = 0; - trainlisttest.list[code].oldoffset = data.body[i].sectionOffsetPercent; + for (let tl=0; tl<6; tl++) { + trainlisttest.list[code].children[tl].position.z = rotaposz; + } + + if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x>sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) { + vexlist.push(new THREE.Vector3(rotaposx, 0, rotaposz)); + for (let m=sectionlist.sections.datalist[data.body[i].sectionCode].rail.length-1; m>=0; m--) { + if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[m].x>rotaposx) { + vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]); + } + + } + } else { + vexlist.push(new THREE.Vector3(rotaposx, 0, rotaposz)); + for (let m=0; mrotaposx) { + vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]); + } + } + } + trainlisttest.list[code].status = '02'; + + } else if (data.body[i].directionType == '03') { // 向左 + trainlisttest.list[code].dispose = false; + trainlisttest.group.add(trainlisttest.list[code]); + let offset = null; + let rotaposx = null; + + if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x>sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) { + + offset = sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x-sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x; + rotaposx = sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x+offset*data.body[i].sectionOffsetPercent; + } else { + + offset = sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x-sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x; + rotaposx = sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x+offset*data.body[i].sectionOffsetPercent; + } + let rotaposz = sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].z; + + trainlisttest.list[code].rotation.y = Math.PI; + trainlisttest.list[code].position.x = rotaposx; + trainlisttest.list[code].position.y = 0; + + for (let tl=0; tl<6; tl++) { + trainlisttest.list[code].children[tl].position.z = -rotaposz; + } + if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x=0; m--) { + if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[m].xsectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) { - offset = sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x-sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x; - rotaposx = sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x+offset*data.body[i].sectionOffsetPercent; - } else { - offset = sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x-sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x; - rotaposx = sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x+offset*data.body[i].sectionOffsetPercent; - } - - const rotaposz = sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].z; - - trainlisttest.list[code].rotation.y = 0; - trainlisttest.list[code].position.x = rotaposx; - trainlisttest.list[code].position.y = 0; - for (let tl=0; tl<6; tl++) { - trainlisttest.list[code].children[tl].position.z = rotaposz; - } - - if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x>sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) { - vexlist.push(new THREE.Vector3(rotaposx, 0, rotaposz)); - for (let m=sectionlist.sections.datalist[data.body[i].sectionCode].rail.length-1; m>=0; m--) { - if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[m].x>rotaposx) { - vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]); + //转向 + if (trainlisttest.list[code].status != data.body[i].directionType) { + let rotaposx = trainlisttest.list[code].children[5].matrixWorld.elements[12]; + let rotaposz = trainlisttest.list[code].children[0].matrixWorld.elements[14]; + trainlisttest.list[code].rotation.y = 0; + trainlisttest.list[code].position.x = rotaposx; + for (let tl=0; tl<6; tl++) { + trainlisttest.list[code].children[tl].position.z = rotaposz; + } + if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x>sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) { + vexlist.push(new THREE.Vector3(trainlisttest.list[code].position.x, 0, trainlisttest.list[code].children[0].matrixWorld.elements[14])); + for (let m=sectionlist.sections.datalist[data.body[i].sectionCode].rail.length-1; m>=0; m--) { + if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[m].x>trainlisttest.list[code].position.x) { + vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]); + } + } + } else { + vexlist.push(new THREE.Vector3(trainlisttest.list[code].position.x, 0, trainlisttest.list[code].children[0].matrixWorld.elements[14])); + for (let m=0; mtrainlisttest.list[code].position.x) { + vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]); + } } - } } else { - vexlist.push(new THREE.Vector3(rotaposx, 0, rotaposz)); - for (let m=0; mrotaposx) { + if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x>sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) { + for (let m=sectionlist.sections.datalist[data.body[i].sectionCode].rail.length-1; m>=0; m--) { + vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]); + } + } else { + for (let m=0; msectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) { - - offset = sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x-sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x; - rotaposx = sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x+offset*data.body[i].sectionOffsetPercent; - } else { - - offset = sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x-sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x; - rotaposx = sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x+offset*data.body[i].sectionOffsetPercent; - } - const rotaposz = sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].z; - - trainlisttest.list[code].rotation.y = Math.PI; - trainlisttest.list[code].position.x = rotaposx; - trainlisttest.list[code].position.y = 0; - - for (let tl=0; tl<6; tl++) { - trainlisttest.list[code].children[tl].position.z = -rotaposz; - } - if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x=0; m--) { - if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[m].x=0; m--) { + if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[m].x=0; m--) { + vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]); + } + + } else { + for (let m=0; msectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) { - vexlist.push(new THREE.Vector3(trainlisttest.list[code].position.x, 0, trainlisttest.list[code].children[0].matrixWorld.elements[14])); - for (let m=sectionlist.sections.datalist[data.body[i].sectionCode].rail.length-1; m>=0; m--) { - if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[m].x>trainlisttest.list[code].position.x) { - vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]); - } - } - } else { - vexlist.push(new THREE.Vector3(trainlisttest.list[code].position.x, 0, trainlisttest.list[code].children[0].matrixWorld.elements[14])); - for (let m=0; mtrainlisttest.list[code].position.x) { - vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]); - } - } - } - } else { - if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x>sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) { - for (let m=sectionlist.sections.datalist[data.body[i].sectionCode].rail.length-1; m>=0; m--) { - vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]); - } - } else { - for (let m=0; m=0; m--) { - if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[m].x=0; m--) { - vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]); - } - - } else { - for (let m=0; m=0; i--) { - // 0xFFFFFF - // 0xCD0000 红 - // 0xEEEE00 黄 - // 0x32CD32 绿 - if (data.body[i]._type == 'Signal') { - if (signallist) { - signalupdate(data.body[i]); - } + function devicestatus(data){ + for (let i=data.body.length-1; i>=0; i--) { + // 0xFFFFFF + // 0xCD0000 红 + // 0xEEEE00 黄 + // 0x32CD32 绿 + if (data.body[i]._type == 'Signal') { + if (signallist) { + signalupdate(data.body[i]); } - - if (data.body[i]._type == 'StationStand') { - if (actions) { - standupdate(data.body[i]); - } - } - - if (data.body[i]._type == 'Switch') { - if (sectionlist) { - switchupdate(data.body[i]); - } - } - } + + if (data.body[i]._type == 'StationStand') { + if (actions) { + standupdate(data.body[i]); + } + } + + if (data.body[i]._type == 'Switch') { + if (sectionlist) { + switchupdate(data.body[i]); + } + } + } } diff --git a/src/jlmap3d/jl3dsimulation/connect/TrainingConnect.js b/src/jlmap3d/jl3dsimulation/connect/TrainingConnect.js index 22e541c00..51537cf24 100644 --- a/src/jlmap3d/jl3dsimulation/connect/TrainingConnect.js +++ b/src/jlmap3d/jl3dsimulation/connect/TrainingConnect.js @@ -263,8 +263,8 @@ export function Jlmap3dSubscribe(jlmap3d) { trainlisttest.list[code].dispose = false; trainlisttest.list[code].nowcode = data.body[i].sectionCode; trainlisttest.list[code].nextcode = data.body[i].nextSectionCode; - const vexlist = []; - const endrotation = null; + let vexlist = []; + let endrotation = null; if (data.body[i].directionType == '02') { // 向右 let offset = null; @@ -278,13 +278,15 @@ export function Jlmap3dSubscribe(jlmap3d) { rotaposx = sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x+offset*data.body[i].sectionOffsetPercent; } - const rotaposz = sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].z; + let rotaposz = sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].z; + trainlisttest.list[code].rotation.y = 0; trainlisttest.list[code].position.x = rotaposx; trainlisttest.list[code].position.y = 0; for (let tl=0; tl<6; tl++) { trainlisttest.list[code].children[tl].position.z = rotaposz; } + if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x>sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) { vexlist.push(new THREE.Vector3(rotaposx, 0, rotaposz)); for (let m=sectionlist.sections.datalist[data.body[i].sectionCode].rail.length-1; m>=0; m--) { @@ -319,16 +321,15 @@ export function Jlmap3dSubscribe(jlmap3d) { offset = sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x-sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x; rotaposx = sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x+offset*data.body[i].sectionOffsetPercent; } - const rotaposz = sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].z; + let rotaposz = sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].z; + trainlisttest.list[code].rotation.y = Math.PI; trainlisttest.list[code].position.x = rotaposx; trainlisttest.list[code].position.y = 0; - for (let tl=0; tl<6; tl++) { - trainlisttest.list[code].children[tl].position.z = rotaposz; - } - if (data.body[i].groupNumber == '001') { - } + for (let tl=0; tl<6; tl++) { + trainlisttest.list[code].children[tl].position.z = -rotaposz; + } if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x=0; m--) { @@ -344,17 +345,25 @@ export function Jlmap3dSubscribe(jlmap3d) { } } } - trainlisttest.list[code].status = '03'; } + trainlisttest.list[code].curve = new THREE.CatmullRomCurve3(vexlist); trainlisttest.list[code].isStandTrack = sectionlist.sections.datalist[data.body[i].sectionCode].isStandTrack; trainlisttest.list[code].progress = 0; trainlisttest.list[code].len = sectionlist.sections.datalist[data.body[i].sectionCode].distance; - trainlisttest.list[code].speed = data.body[i].speed; - trainlisttest.list[code].speeds = parseFloat(data.body[i].speed*10/36/20/trainlisttest.list[code].len); - } + + if(data.body[i].speed == 0){ + trainlisttest.list[code].speeds = data.body[i].speed; + trainlisttest.list[code].speeds = 0; + // trainlisttest.list[code].startmark = 1; + }else{ + trainlisttest.list[code].speeds = data.body[i].speed; + trainlisttest.list[code].speeds = parseFloat(data.body[i].speed*10/36/20/trainlisttest.list[code].len); + } + + } } else if (trainlisttest.list[code].dispose != data.body[i].dispose && data.body[i].dispose == true) { trainlisttest.group.remove(trainlisttest.list[code]); trainlisttest.list[code].progress = null; diff --git a/src/jlmap3d/main/loaders/simulationloader.js b/src/jlmap3d/main/loaders/simulationloader.js index f301c4df1..5bc9be451 100644 --- a/src/jlmap3d/main/loaders/simulationloader.js +++ b/src/jlmap3d/main/loaders/simulationloader.js @@ -10,7 +10,7 @@ import {Materialload} from '@/jlmap3d/main/loaders/Materialload.js'; import { Loading } from 'element-ui'; // import {SwitchModel} from '@/jlmap3d/model/SwitchModel.js'; -export function ModelLoad(data,scope,netdata,mapdata,camera,controls,scene){ +export function ModelLoad(data,scope,netdata,mapdata,camera,controls,scene,mixerss){ //console.log(mapdata); Materialload(scope); //console.log(data); @@ -20,7 +20,7 @@ export function ModelLoad(data,scope,netdata,mapdata,camera,controls,scene){ let assetloader = scope.assetloader; let animateswitch = scope.animateswitch; - let mixers = scope.mixers; + let mixers = mixerss; let actions = scope.actions; let loadingInstance = Loading.service({ fullscreen: true }); diff --git a/src/jlmap3d/main/model/StationStandList.js b/src/jlmap3d/main/model/StationStandList.js index b02f76b5b..367b644b6 100644 --- a/src/jlmap3d/main/model/StationStandList.js +++ b/src/jlmap3d/main/model/StationStandList.js @@ -340,33 +340,33 @@ stationcanvas.src = "../../static/texture/msgt.png"; function getTextCanvas(text){ let canvas = document.getElementById('canvastexture'); - canvas.width = 300; - canvas.height = 374; + canvas.width = 256; + canvas.height = 512; // canvas.style.width = width; // canvas.style.height = height; let ctx = canvas.getContext('2d'); //ctx.fillStyle = '#FFFFFF'; - ctx.fillRect(0, 0,300,374); + ctx.fillRect(0, 0,256,512); ctx.fillStyle = '#FFFFFF'; // ctx.textAlign = 'center'; // ctx.textBaseline = 'middle'; - ctx.clearRect(0,0,300,374); + ctx.clearRect(0,0,256,512); - ctx.drawImage(stationcanvas,0,0,300,374); + ctx.drawImage(stationcanvas,0,0,256,512); ctx.font = "20px Verdana"; - ctx.fillText("车站名称: "+text.runPlanName, 40,58); + ctx.fillText("车站名称: "+text.runPlanName, 20,58); - ctx.fillText("漫游", 40,110); - ctx.fillText("信息", 124,110); - ctx.fillText("备忘", 210,110); + ctx.fillText("漫游", 30,100); + ctx.fillText("信息", 114,100); + ctx.fillText("备忘", 190,100); ctx.fillText("车站序号: "+text.name, 40,155); ctx.fillText("公里标记:"+text.kmPost,40 ,256*3/4); - let data = ctx.getImageData(0, 0,300,374); + let data = ctx.getImageData(0, 0,256,512); return data; } diff --git a/src/views/jlmap3d/drive/jl3ddrive.vue b/src/views/jlmap3d/drive/jl3ddrive.vue index 0f9b91794..a490c6921 100644 --- a/src/views/jlmap3d/drive/jl3ddrive.vue +++ b/src/views/jlmap3d/drive/jl3ddrive.vue @@ -8,6 +8,7 @@
+ {{ cctvbuttonmsg }} {{ showbuttonmsg }} 返回 @@ -19,7 +20,7 @@
-
+
@@ -70,6 +71,8 @@ export default { mapdata: null, jlmap3d: null, selectmodel: null, + cctvshow:true, + cctvbuttonmsg: '车内监控——隐藏', mmishow: false, showbuttonmsg: '列车仪表——显示', trainnum: '', @@ -171,6 +174,7 @@ export default { const dom = document.getElementById('app'); this.jlmap3d = new JLmapDriving(dom, mapdata, skinCode); this.jlmap3d.eventon(); + this.cctvshow = false; }, raystand() { @@ -213,6 +217,18 @@ export default { this.mmishow = true; } + }, + cctvplane() { + if (this.cctvshow == true) { + this.cctvbuttonmsg = '车内监控——隐藏'; + this.cctvshow = false; + this.jlmap3d.cctvoff(); + } else { + this.cctvbuttonmsg = '车内监控——显示'; + this.cctvshow = true; + this.jlmap3d.cctvon(); + } + } } @@ -283,7 +299,7 @@ export default { width: 100%; height: 100%; top:0; - z-index: 3000; + z-index: 1500; } .jlmap3ddraw { diff --git a/static/material/signal/1.jpg b/static/material/signal/1.jpg index 42c44f807..9a7e8ff3c 100644 Binary files a/static/material/signal/1.jpg and b/static/material/signal/1.jpg differ diff --git a/static/material/signal/2.jpg b/static/material/signal/2.jpg index 1e59ffecd..105c81620 100644 Binary files a/static/material/signal/2.jpg and b/static/material/signal/2.jpg differ diff --git a/static/material/signal/3.jpg b/static/material/signal/3.jpg index db99e470b..ca99a7faa 100644 Binary files a/static/material/signal/3.jpg and b/static/material/signal/3.jpg differ diff --git a/static/material/signal/5.jpg b/static/material/signal/5.jpg index 365a0368f..c21257e03 100644 Binary files a/static/material/signal/5.jpg and b/static/material/signal/5.jpg differ diff --git a/static/model/suidao/suidao.FBX b/static/model/suidao/suidao.FBX index 33ef99367..562e67b84 100644 Binary files a/static/model/suidao/suidao.FBX and b/static/model/suidao/suidao.FBX differ diff --git a/static/skybox/star/nx.png b/static/skybox/star/nx.png new file mode 100644 index 000000000..f64ddb627 Binary files /dev/null and b/static/skybox/star/nx.png differ diff --git a/static/skybox/star/ny.png b/static/skybox/star/ny.png new file mode 100644 index 000000000..c1d49130d Binary files /dev/null and b/static/skybox/star/ny.png differ diff --git a/static/skybox/star/nz.png b/static/skybox/star/nz.png new file mode 100644 index 000000000..641a47f9b Binary files /dev/null and b/static/skybox/star/nz.png differ diff --git a/static/skybox/star/px.png b/static/skybox/star/px.png new file mode 100644 index 000000000..0251a38ca Binary files /dev/null and b/static/skybox/star/px.png differ diff --git a/static/skybox/star/py.png b/static/skybox/star/py.png new file mode 100644 index 000000000..90f64eea4 Binary files /dev/null and b/static/skybox/star/py.png differ diff --git a/static/skybox/star/pz.png b/static/skybox/star/pz.png new file mode 100644 index 000000000..3e89edcfa Binary files /dev/null and b/static/skybox/star/pz.png differ diff --git a/static/texture/msgf.png b/static/texture/msgf.png index 9ba4f91c9..357627ca1 100644 Binary files a/static/texture/msgf.png and b/static/texture/msgf.png differ diff --git a/static/texture/msgfo.png b/static/texture/msgfo.png new file mode 100644 index 000000000..9ba4f91c9 Binary files /dev/null and b/static/texture/msgfo.png differ diff --git a/static/texture/msgt.png b/static/texture/msgt.png index 715e0e50d..f5d579317 100644 Binary files a/static/texture/msgt.png and b/static/texture/msgt.png differ diff --git a/static/texture/msgto.png b/static/texture/msgto.png new file mode 100644 index 000000000..715e0e50d Binary files /dev/null and b/static/texture/msgto.png differ