diff --git a/src/jlmap3d/jl3ddrive/jl3ddrive.js b/src/jlmap3d/jl3ddrive/jl3ddrive.js index 86fc1bda0..bab7f38c1 100644 --- a/src/jlmap3d/jl3ddrive/jl3ddrive.js +++ b/src/jlmap3d/jl3ddrive/jl3ddrive.js @@ -141,66 +141,10 @@ export function JLmapDriving(dom,data,mapId,storemod,translation,routegroup,proj let cameracctv = new THREE.PerspectiveCamera(70, dom.clientWidth/dom.clientHeight, 1, 50); cameracctv.position.set( 2, -1,27 ); - cameracctv.rotation.y = Math.PI/5*3; + cameracctv.rotation.y = Math.PI/2; camera.add(cameracctv); - // let spotLight = new THREE.SpotLight( 0xffffff, 1 ); - // // spotLight.position.set( 15, 40, 35 ); - // spotLight.angle = Math.PI / 5; - // spotLight.penumbra = 0.05; - // spotLight.decay = 1; - // spotLight.distance = 30; - // - // spotLight.castShadow = true; - // spotLight.shadow.mapSize.width = 1024; - // spotLight.shadow.mapSize.height = 1024; - // spotLight.shadow.camera.near = 10; - // spotLight.shadow.camera.far = 50; - // spotLight.rotation.y = Math.PI; - // spotLight.position.y = -1; - // console.log(spotLight); - // controls3.getObject().add( spotLight ); - // 订阅仿真socket - var timer = setInterval(function() { - if(trainlisttest){ - if(trainlisttest.group){ - if(trainlisttest.group.children[0]){ - console.log(trainlisttest.group.children[0].name); - updatemmi.updatedrivingcode(trainlisttest.group.children[0].name); - scope.Subscribe.initdrivercode(trainlisttest.group.children[0].name); - 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); // 初始化加载数据和模型 getPublishMapDetail(mapId).then(data => { let mapnetdata = data.data; @@ -215,16 +159,67 @@ export function JLmapDriving(dom,data,mapId,storemod,translation,routegroup,proj scope.Subscribe.socketon(scope.Subscribe.topic); DriverLoad(data,scope,netdata.data,sectionlist,linklist,signallist,stationstandlist,trainlisttest,realsectionlist,rails, camera, controls3, scene,mixers,storemod); + var timer = setInterval(function() { + if(trainlisttest){ + if(trainlisttest.group){ + if(trainlisttest.group.children[0]){ + console.log(trainlisttest.group.children[0].name); + updatemmi.updatedrivingcode(trainlisttest.group.children[0].name); + scope.Subscribe.initdrivercode(trainlisttest.group.children[0].name); + 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); }else{ scope.datatype = "new"; - scope.Subscribe = new Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup); + scope.Subscribe = new Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup,stats); + - scope.Subscribe.socketon(scope.Subscribe.topic); // scope.jsonwebworknew = new Worker("../../static/workertest/jsonworkernew.js"); // scope.Subscribe = new Jlmap3dSubscribeNew(scope,routegroup,scope.jsonwebworknew); // scope.Subscribe.socketon(scope.Subscribe.topic); DriverLoadNew(mapnetdata,scope,netdata.data,mapdata,sectionlist,signallist,switchlist,stationstandlist,trainlisttest,rails,camera,controls3,scene,mixers); + var timer = setInterval(function() { + if(trainlisttest){ + if(trainlisttest.group){ + if(trainlisttest.group.children[0]){ + updatemmi.updatedrivingcodenew(trainlisttest.group.children[0].code); + scope.Subscribe.initdrivercode(trainlisttest.group.children[0].code); + scope.Subscribe.socketon(scope.Subscribe.topic); + clearInterval(timer); + } + } + } + + }, 2000); } @@ -234,8 +229,8 @@ export function JLmapDriving(dom,data,mapId,storemod,translation,routegroup,proj // getPublish3dMapDetail(mapId).then(netdata => { // DriverLoad(data, scope, netdata.data, sectionlist,linklist,signallist,stationstandlist,trainlisttest,realsectionlist,rails, camera, controls3, scene,mixers,storemod); // }); - // let stats = new Stats(); - // dom.appendChild( stats.dom ); + let stats = new Stats(); + dom.appendChild( stats.dom ); // 开启渲染 animate(); startWorker(); @@ -280,7 +275,10 @@ export function JLmapDriving(dom,data,mapId,storemod,translation,routegroup,proj scope.webwork.onmessage = function (event) { // 更新列车位置 - UpdateTrain(camera, trainlisttest); + if(scope.datatype == "old"){ + UpdateTrain(camera, trainlisttest); + } + // delta = clock.getDelta(); for (let i=mixers.length-1; i>=0; i--) { mixers[i].update( delta ); @@ -316,9 +314,19 @@ export function JLmapDriving(dom,data,mapId,storemod,translation,routegroup,proj }; updatemmi.updatedrivingcode = function(code) { - // console.log(trainlisttest); + console.log(trainlisttest); drivingcode = code; - trainlisttest.list[drivingcode].children[0].add(controls3.getObject()); + trainlisttest.group.children[0].children[0].add(controls3.getObject()); + controls3.getObject().position.x = 10; + controls3.getObject().position.y = 0; + controls3.getObject().position.z = 1.5; + controls3.getObject().rotation.x = Math.PI/2; + controls3.getObject().rotation.y = -Math.PI/2; + }; + + updatemmi.updatedrivingcodenew = function(code) { + drivingcode = code; + trainlisttest.group.children[0].children[0].add(controls3.getObject()); controls3.getObject().position.x = 10; controls3.getObject().position.y = 0; controls3.getObject().position.z = 1.5; diff --git a/src/jlmap3d/jl3ddrive/moveupdate/DrivingConnect.js b/src/jlmap3d/jl3ddrive/moveupdate/DrivingConnect.js index e139b1b0b..65802534c 100644 --- a/src/jlmap3d/jl3ddrive/moveupdate/DrivingConnect.js +++ b/src/jlmap3d/jl3ddrive/moveupdate/DrivingConnect.js @@ -92,7 +92,6 @@ export function Jl3dDriving(mixers,updatemmi,sound,translation,routegroup) { // console.log(Response); // 对象化数据 let data = JSON.parse(Response.body); - console.log(data); // 遍历后台数据 // 判断消息类型 diff --git a/src/jlmap3d/jl3ddrive/moveupdate/DrivingConnectNew.js b/src/jlmap3d/jl3ddrive/moveupdate/DrivingConnectNew.js index 41ded03d3..554c3679a 100644 --- a/src/jlmap3d/jl3ddrive/moveupdate/DrivingConnectNew.js +++ b/src/jlmap3d/jl3ddrive/moveupdate/DrivingConnectNew.js @@ -7,7 +7,7 @@ import { getToken } from '@/utils/auth'; import router from '@/router'; // 定于仿真socket接口 -export function Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup) { +export function Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup,stats) { let scope = this; this.map = null; @@ -22,6 +22,7 @@ export function Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup) { var rails = null; var links = null; + let trainmodel = null; var scenes = null; var code = null; @@ -39,12 +40,13 @@ export function Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup) { // reset = 02; var datatype = '00'; this.teststomp = new StompClient(); - this.topic = '/user/queue/simulation/jl3d/'+routegroup; + this.topic = '/user/queue/simulation/drive/'+routegroup; let header = {'X-Token': getToken() }; this.updatamap = function(newsectionlist,newlinklist,newsignallist,newstationstandlist,newtrainlisttest,newrealsectionlist,newrails, materiallist, nowaction, scene) { // console.log(mapdata); // console.log(newtrainlisttest); + trainmodel = newtrainlisttest.group.children[0]; trainlisttest = newtrainlisttest; sectionlist = newsectionlist; signallist = newsignallist; @@ -75,9 +77,9 @@ export function Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup) { for (let i=0; i 0 || trainmodel.children[2].rotalist.length > 0 || trainmodel.children[3].rotalist.length > 0 || trainmodel.children[4].rotalist.length > 0|| trainmodel.children[5].rotalist.length > 0){ + + for(let rs = 1;rs<6;rs++){ + //console.log(rs); + if(trainmodel.children[rs].rotalist[0]){ + + let offsetz = parseFloat(trainmodel.children[rs].rotalist[0].posr.z) + parseFloat(trainmodel.children[rs].position.z); + trainmodel.children[rs].position.z -= offsetz; + + for(let xh=0;xh=trainmodel.children[rs].rotalist[0].posr.x){ + + if(rs != 5){ + let asd = trainmodel.children[rs].rotalist[0]; + trainmodel.children[rs+1].rotalist.push(asd); + + } + //let offsetx = trainmodel.children[1].matrixWorld.elements[12]-trainmodel.children[0].children[3].matrixWorld.elements[12]; + + trainmodel.children[rs].rotation.z = trainmodel.children[rs].rotalist[0].rota; + trainmodel.children[rs].rotalist.splice(0,1) + xh--; + }else{ + xh = trainmodel.children[rs].rotalist.length; + } + } + //console.log(trainmodel.children[rs].rotalist.length); + + } + + + } + // console.log(trainmodel.rotalist); + } + + }else{ + if(trainmodel.children[0].position.z != pos.z){ + trainmodel.children[0].up = new THREE.Vector3(-1,0,0); + let tangent = trainmodel.curve.getTangentAt(data.offset).normalize(); + trainmodel.children[0].axis.crossVectors(trainmodel.children[0].up, tangent).normalize(); + let radians = Math.acos(trainmodel.children[0].up.dot(tangent)); + trainmodel.children[0].quaternion.setFromAxisAngle(trainmodel.children[0].axis, radians); + trainmodel.children[0].rotation.x = -Math.PI/2; + trainmodel.children[0].rotation.z = trainmodel.children[0].rotation.y; + trainmodel.children[0].rotation.y = 0; + let rotas = { + posr:pos, + rota:trainmodel.children[0].rotation.z + } + trainmodel.children[1].rotalist.push(rotas); + + + let offsetz = parseFloat(pos.z) - parseFloat(trainmodel.children[0].position.z); + trainmodel.children[0].position.z += offsetz; + } + if(trainmodel.children[1].rotalist.length > 0 || trainmodel.children[2].rotalist.length > 0 || trainmodel.children[3].rotalist.length > 0 || trainmodel.children[4].rotalist.length > 0|| trainmodel.children[5].rotalist.length > 0){ + for(let rs = 1;rs<6;rs++){ + //console.log(rs); + if(trainmodel.children[rs].rotalist[0]){ + let offsetz = parseFloat(trainmodel.children[rs].rotalist[0].posr.z) - parseFloat(trainmodel.children[rs].matrixWorld.elements[14]); + + trainmodel.children[rs].position.z += offsetz; + + for(let xh=0;xh=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(); + if(trainmodel.code == data.code){ + + if(data.doorCode == "0"){ + + if(trainmodel.open != data.open && data.open == "0"){ + trainmodel.open = "0"; + for(let an=actions["traindoor"].down.length-1;an>=0;an--){ + actions["traindoor"].down[an].reset(); + actions["traindoor"].down[an].time = actions["traindoor"].top[an]._clip.duration; + actions["traindoor"].down[an].timeScale = -1; + actions["traindoor"].down[an].play(); + } + }else if(trainmodel.open != data.open && data.open == "1"){ + trainmodel.open = "1"; + for(let an=actions["traindoor"].down.length-1;an>=0;an--){ + actions["traindoor"].down[an].reset(); + actions["traindoor"].down[an].time = 0; + actions["traindoor"].down[an].timeScale = 1; + actions["traindoor"].down[an].play(); + } } - }else if(trainlisttest.list[code].open != data.open && data.open == "1"){ - trainlisttest.list[code].open = "1"; - 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(); - } - } - }else{ - if (trainlisttest.list[code].open != data.open && data.open == '0') { - trainlisttest.list[code].open = '0'; - 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].open != data.open && data.open == '1') { - trainlisttest.list[code].open = "1"; - 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(); + }else{ + + + if (trainmodel.open != data.open && data.open == '0') { + trainmodel.open = '0'; + for (let an=actions["traindoor"].top.length-1; an>=0; an--) { + actions["traindoor"].top[an].reset(); + actions["traindoor"].top[an].time = actions["traindoor"].top[an]._clip.duration; + actions["traindoor"].top[an].timeScale = -1; + actions["traindoor"].top[an].play(); + } + } else if (trainmodel.open != data.open && data.open == '1') { + trainmodel.open = "1"; + for(let an=actions["traindoor"].top.length-1;an>=0;an--){ + actions["traindoor"].top[an].reset(); + actions["traindoor"].top[an].time = 0; + actions["traindoor"].top[an].timeScale = 1; + actions["traindoor"].top[an].play(); + } } + } } @@ -327,48 +419,48 @@ export function Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup) { code = data.code; // 剔除不显示的车 // 找到对应列车 - if ( trainlisttest.list[code]) { + if ( trainmodel) { - trainlisttest.list[code].driveMode = data.driveMode; - trainlisttest.list[code].status = data.right; + trainmodel.driveMode = data.driveMode; + trainmodel.status = data.right; // 车门开关验证 // 遍历获取所在轨道 - if (trainlisttest.list[code].dispose != data.dispose && data.dispose == "0") { + if (trainmodel.dispose != data.dispose && data.dispose == "0") { if (rails.sectionrail[data.sectionCode]) { - trainlisttest.group.add(trainlisttest.list[code]); - trainlisttest.list[code].position.y = 0; - // trainlisttest.list[code].progress = 0; - trainlisttest.list[code].dispose = "0"; - trainlisttest.list[code].nowcode = data.sectionCode; - trainlisttest.list[code].nextcode = null; - trainlisttest.list[code].curve = null; - trainlisttest.list[code].nextcurve = null; - trainlisttest.list[code].pc = 1; + trainlisttest.group.add(trainmodel); + trainmodel.position.y = 0; + // trainmodel.progress = 0; + trainmodel.dispose = "0"; + trainmodel.nowcode = data.sectionCode; + trainmodel.nextcode = null; + trainmodel.curve = null; + trainmodel.nextcurve = null; + trainmodel.pc = 1; - if(trainlisttest.list[code].mixerpush == false){ - for(let mi=0,lenmi=trainlisttest.list[code].mixer.length;mi=0;n--){ + if(assetloader.modellist[n].deviceType == "train"){ + + selectmesh = assetloader.modellist[n].mesh + + ntracks1 = assetloader.modellist[n].animations.slice(16,27); + + tclip = new THREE.AnimationClip("three",2,ntracks1); + + ntracks2 = assetloader.modellist[n].animations.slice(0,15); + + fclip = new THREE.AnimationClip("four",2,ntracks2); + + n = 0; + } + } + + actionss["traindoor"] = { + top:[], + down:[] + }; + let newmesh = selectmesh.clone(true); + newmesh.mixer = []; + + for(let j=0;j