Merge remote-tracking branch 'origin/test'
This commit is contained in:
commit
87e4dbfbf5
@ -113,29 +113,32 @@ export function initDataSave(data) {
|
||||
postmap.signals = JSON.stringify(signals);
|
||||
//车站
|
||||
let stands = [];
|
||||
|
||||
for(let i=0;i<data.mapdata.stationstandlist.list.length;i++){
|
||||
let station = {
|
||||
// uuid:data.mapdata.stationstandlist.list[i].uuid,
|
||||
code:data.mapdata.stationstandlist.list[i].code,
|
||||
name:data.mapdata.stationstandlist.list[i].name,
|
||||
// modelid:data.mapdata.stationstandlist.list[i].modelid,
|
||||
position:data.mapdata.stationstandlist.list[i].mesh.position,
|
||||
rotation:data.mapdata.stationstandlist.list[i].mesh.rotation,
|
||||
scale:data.mapdata.stationstandlist.list[i].mesh.scale,
|
||||
inside:data.mapdata.stationstandlist.list[i].inside,
|
||||
stands:data.mapdata.stationstandlist.list[i].stands,
|
||||
// direction1:{
|
||||
// name:data.mapdata.stationstandlist.list[i].direction1.name,
|
||||
// code:data.mapdata.stationstandlist.list[i].direction1.code
|
||||
// },
|
||||
// direction2:{
|
||||
// name:data.mapdata.stationstandlist.list[i].direction2.name,
|
||||
// code:data.mapdata.stationstandlist.list[i].direction2.code
|
||||
// }
|
||||
console.log(data.mapdata.stationstandlist);
|
||||
if(data.mapdata.stationstandlist){
|
||||
for(let i=0;i<data.mapdata.stationstandlist.list.length;i++){
|
||||
let station = {
|
||||
// uuid:data.mapdata.stationstandlist.list[i].uuid,
|
||||
code:data.mapdata.stationstandlist.list[i].code,
|
||||
name:data.mapdata.stationstandlist.list[i].name,
|
||||
// modelid:data.mapdata.stationstandlist.list[i].modelid,
|
||||
position:data.mapdata.stationstandlist.list[i].mesh.position,
|
||||
rotation:data.mapdata.stationstandlist.list[i].mesh.rotation,
|
||||
scale:data.mapdata.stationstandlist.list[i].mesh.scale,
|
||||
inside:data.mapdata.stationstandlist.list[i].inside,
|
||||
stands:data.mapdata.stationstandlist.list[i].stands,
|
||||
// direction1:{
|
||||
// name:data.mapdata.stationstandlist.list[i].direction1.name,
|
||||
// code:data.mapdata.stationstandlist.list[i].direction1.code
|
||||
// },
|
||||
// direction2:{
|
||||
// name:data.mapdata.stationstandlist.list[i].direction2.name,
|
||||
// code:data.mapdata.stationstandlist.list[i].direction2.code
|
||||
// }
|
||||
}
|
||||
stands.push(station);
|
||||
}
|
||||
stands.push(station);
|
||||
}
|
||||
|
||||
postmap.stands = JSON.stringify(stands);
|
||||
//列车
|
||||
let trains = [];
|
||||
|
@ -144,29 +144,31 @@ export function specilDataSave(data) {
|
||||
postmap.signals = JSON.stringify(signals);
|
||||
//车站
|
||||
let stands = [];
|
||||
|
||||
for(let i=0;i<data.mapdata.stationstandlist.list.length;i++){
|
||||
let station = {
|
||||
// uuid:data.mapdata.stationstandlist.list[i].uuid,
|
||||
code:data.mapdata.stationstandlist.list[i].code,
|
||||
name:data.mapdata.stationstandlist.list[i].name,
|
||||
// modelid:data.mapdata.stationstandlist.list[i].modelid,
|
||||
position:data.mapdata.stationstandlist.list[i].mesh.position,
|
||||
rotation:data.mapdata.stationstandlist.list[i].mesh.rotation,
|
||||
scale:data.mapdata.stationstandlist.list[i].mesh.scale,
|
||||
inside:data.mapdata.stationstandlist.list[i].inside,
|
||||
stands:data.mapdata.stationstandlist.list[i].stands,
|
||||
// direction1:{
|
||||
// name:data.mapdata.stationstandlist.list[i].direction1.name,
|
||||
// code:data.mapdata.stationstandlist.list[i].direction1.code
|
||||
// },
|
||||
// direction2:{
|
||||
// name:data.mapdata.stationstandlist.list[i].direction2.name,
|
||||
// code:data.mapdata.stationstandlist.list[i].direction2.code
|
||||
// }
|
||||
if(data.mapdata.stationstandlist){
|
||||
for(let i=0;i<data.mapdata.stationstandlist.list.length;i++){
|
||||
let station = {
|
||||
// uuid:data.mapdata.stationstandlist.list[i].uuid,
|
||||
code:data.mapdata.stationstandlist.list[i].code,
|
||||
name:data.mapdata.stationstandlist.list[i].name,
|
||||
// modelid:data.mapdata.stationstandlist.list[i].modelid,
|
||||
position:data.mapdata.stationstandlist.list[i].mesh.position,
|
||||
rotation:data.mapdata.stationstandlist.list[i].mesh.rotation,
|
||||
scale:data.mapdata.stationstandlist.list[i].mesh.scale,
|
||||
inside:data.mapdata.stationstandlist.list[i].inside,
|
||||
stands:data.mapdata.stationstandlist.list[i].stands,
|
||||
// direction1:{
|
||||
// name:data.mapdata.stationstandlist.list[i].direction1.name,
|
||||
// code:data.mapdata.stationstandlist.list[i].direction1.code
|
||||
// },
|
||||
// direction2:{
|
||||
// name:data.mapdata.stationstandlist.list[i].direction2.name,
|
||||
// code:data.mapdata.stationstandlist.list[i].direction2.code
|
||||
// }
|
||||
}
|
||||
stands.push(station);
|
||||
}
|
||||
stands.push(station);
|
||||
}
|
||||
|
||||
postmap.stands = JSON.stringify(stands);
|
||||
//列车
|
||||
let trains = [];
|
||||
|
@ -9,6 +9,10 @@ import {StationStandList} from '@/jlmap3d/edit/testEditorModel/StationStandList.
|
||||
import {SwitchList} from '@/jlmap3d/edit/testEditorModel/SwitchList.js';
|
||||
import {RailList} from '@/jlmap3d/edit/testEditorModel/RailList.js';
|
||||
|
||||
import {rSectionList} from '@/jlmap3d/edit/railwayModel/rSectionList.js';
|
||||
import {rSignalList} from '@/jlmap3d/edit/railwayModel/rSignalList.js';
|
||||
import {rSwitchList} from '@/jlmap3d/edit/railwayModel/rSwitchList.js';
|
||||
|
||||
import axios from 'axios';
|
||||
import { Loading } from 'element-ui';
|
||||
// import {SwitchModel} from '@/jlmap3d/model/SwitchModel.js';
|
||||
@ -23,6 +27,7 @@ export function jl3dEditorLoader(mapid,scope){
|
||||
get3dMapData(editmapid).then(data => {
|
||||
|
||||
if(data.data ){
|
||||
console.log(data);
|
||||
if(data.data.assets){
|
||||
// initData(editmapid,data.data.id);
|
||||
loadData(editmapid,data.data);
|
||||
@ -58,39 +63,65 @@ export function jl3dEditorLoader(mapid,scope){
|
||||
jlmap3ddata.id = data3did;
|
||||
jlmap3ddata.mapId = mapid;
|
||||
|
||||
// //初始化站台
|
||||
jlmap3ddata.stationstandlist = new StationStandList();
|
||||
//初始化轨道和道岔 暂时
|
||||
jlmap3ddata.sectionlist = new SectionList();
|
||||
if(mapdata.skinVO.name == "大铁线路"){
|
||||
jlmap3ddata.sectionlist = new rSectionList();
|
||||
|
||||
jlmap3ddata.signallist = new SignalList();
|
||||
jlmap3ddata.signallist = new rSignalList();
|
||||
|
||||
jlmap3ddata.switchlist = new SwitchList();
|
||||
//
|
||||
jlmap3ddata.raillist = new RailList();
|
||||
jlmap3ddata.raillist.setrail();
|
||||
jlmap3ddata.switchlist = new rSwitchList();
|
||||
assetloader.assetinit(scene)
|
||||
.then(function(data){
|
||||
//console.log(data);
|
||||
return jlmap3ddata.sectionlist.initpromise(jlmap3ddata,assetloader,mapdata.sectionList,mapdata.switchList,scene);
|
||||
})
|
||||
.then(function(data){
|
||||
//console.log(data);
|
||||
return jlmap3ddata.signallist.initpromise(jlmap3ddata,mapdata.signalList,scene,assetloader);
|
||||
})
|
||||
.then(function(data){
|
||||
return jlmap3ddata.switchlist.initpromise(jlmap3ddata,mapdata.switchList,scene,assetloader);
|
||||
})
|
||||
|
||||
.then(function(data){
|
||||
//console.log(data);
|
||||
loadingInstance.close();
|
||||
});
|
||||
}else{
|
||||
// //初始化站台
|
||||
jlmap3ddata.stationstandlist = new StationStandList();
|
||||
//初始化轨道和道岔 暂时
|
||||
jlmap3ddata.sectionlist = new SectionList();
|
||||
|
||||
jlmap3ddata.signallist = new SignalList();
|
||||
|
||||
jlmap3ddata.switchlist = new SwitchList();
|
||||
//
|
||||
jlmap3ddata.raillist = new RailList();
|
||||
jlmap3ddata.raillist.setrail();
|
||||
assetloader.assetinit(scene)
|
||||
.then(function(data){
|
||||
//console.log(data);
|
||||
return jlmap3ddata.stationstandlist.initpromise(jlmap3ddata,mapdata.stationList,mapdata.stationStandList,scene,assetloader);
|
||||
})
|
||||
.then(function(data){
|
||||
//console.log(data);
|
||||
return jlmap3ddata.sectionlist.initpromise(jlmap3ddata,assetloader,mapdata.sectionList,mapdata.switchList,scene);
|
||||
})
|
||||
.then(function(data){
|
||||
//console.log(data);
|
||||
return jlmap3ddata.signallist.initpromise(jlmap3ddata,mapdata.signalList,scene,assetloader);
|
||||
})
|
||||
.then(function(data){
|
||||
return jlmap3ddata.switchlist.initpromise(jlmap3ddata,mapdata.switchList,scene,assetloader);
|
||||
})
|
||||
|
||||
.then(function(data){
|
||||
//console.log(data);
|
||||
loadingInstance.close();
|
||||
});
|
||||
}
|
||||
|
||||
assetloader.assetinit(scene)
|
||||
.then(function(data){
|
||||
//console.log(data);
|
||||
return jlmap3ddata.stationstandlist.initpromise(jlmap3ddata,mapdata.stationList,mapdata.stationStandList,scene,assetloader);
|
||||
})
|
||||
.then(function(data){
|
||||
//console.log(data);
|
||||
return jlmap3ddata.sectionlist.initpromise(jlmap3ddata,assetloader,mapdata.sectionList,mapdata.switchList,scene);
|
||||
})
|
||||
.then(function(data){
|
||||
//console.log(data);
|
||||
return jlmap3ddata.signallist.initpromise(jlmap3ddata,mapdata.signalList,scene,assetloader);
|
||||
})
|
||||
.then(function(data){
|
||||
return jlmap3ddata.switchlist.initpromise(jlmap3ddata,mapdata.switchList,scene,assetloader);
|
||||
})
|
||||
|
||||
.then(function(data){
|
||||
//console.log(data);
|
||||
loadingInstance.close();
|
||||
});
|
||||
//初始化信号
|
||||
//SetObj(mapdata,scope);
|
||||
|
||||
@ -104,58 +135,21 @@ export function jl3dEditorLoader(mapid,scope){
|
||||
jlmap3ddata.mapId = mapid;
|
||||
let mapdata = data.data;
|
||||
|
||||
// //初始化站台
|
||||
jlmap3ddata.stationstandlist = new StationStandList();
|
||||
//初始化轨道和道岔 暂时
|
||||
jlmap3ddata.sectionlist = new SectionList();
|
||||
if(mapdata.skinVO.name == "大铁线路"){
|
||||
jlmap3ddata.sectionlist = new rSectionList();
|
||||
|
||||
jlmap3ddata.signallist = new SignalList();
|
||||
jlmap3ddata.signallist = new rSignalList();
|
||||
|
||||
jlmap3ddata.switchlist = new SwitchList();
|
||||
jlmap3ddata.switchlist = new rSwitchList();
|
||||
|
||||
jlmap3ddata.raillist = new RailList();
|
||||
console.log(netdata);
|
||||
let sectiondata = JSON.parse(netdata.sections);
|
||||
let switchdata = JSON.parse(netdata.switchs);
|
||||
let signaldata = JSON.parse(netdata.signals);
|
||||
let standsdata = JSON.parse(netdata.stands);
|
||||
jlmap3dasset = JSON.parse(netdata.assets);
|
||||
let sectiondata = JSON.parse(netdata.sections);
|
||||
let switchdata = JSON.parse(netdata.switchs);
|
||||
let signaldata = JSON.parse(netdata.signals);
|
||||
jlmap3dasset = JSON.parse(netdata.assets);
|
||||
|
||||
if(jlmap3dasset.sceneAssetList == undefined){
|
||||
|
||||
// loadEditAllAsset(jlmap3dasset);
|
||||
assetloader.setmodellistnew(netdata.assets,5);
|
||||
assetloader.assetpromise(scene)
|
||||
.then(function(data){
|
||||
// return jlmap3ddata.stationstandlist.initpromise(jlmap3ddata,mapdata.stationList,mapdata.stationStandList,scene,assetloader);
|
||||
return jlmap3ddata.stationstandlist.loadpromise(jlmap3ddata,standsdata,mapdata.stationStandList,scene,assetloader);
|
||||
})
|
||||
.then(function(data){
|
||||
//console.log(data);
|
||||
// return jlmap3ddata.sectionlist.initpromise(jlmap3ddata,assetloader,mapdata.sectionList,mapdata.switchList,scene);
|
||||
return jlmap3ddata.sectionlist.loadpromise(jlmap3ddata,assetloader,sectiondata.section,scene);
|
||||
})
|
||||
.then(function(data){
|
||||
//console.log(data);
|
||||
// return jlmap3ddata.signallist.initpromise(jlmap3ddata,mapdata.signalList,scene,assetloader);
|
||||
return jlmap3ddata.signallist.loadpromise(signaldata,scene,assetloader,mapdata.signalList);
|
||||
})
|
||||
.then(function(data){
|
||||
// return jlmap3ddata.switchlist.initpromise(jlmap3ddata,mapdata.switchList,scene,assetloader);
|
||||
return jlmap3ddata.switchlist.loadpromise(jlmap3ddata,switchdata,scene,assetloader);
|
||||
})
|
||||
.then(function(data){
|
||||
//console.log(data);
|
||||
loadingInstance.close();
|
||||
});
|
||||
}else{
|
||||
loadEditAllAsset(jlmap3dasset);
|
||||
assetloader.setModelListOver(jlmap3dasset.sceneAssetList,5,jlmap3dasset.others);
|
||||
assetloader.assetPromiseOver(scene)
|
||||
.then(function(data){
|
||||
// return jlmap3ddata.stationstandlist.initpromise(jlmap3ddata,mapdata.stationList,mapdata.stationStandList,scene,assetloader);
|
||||
return jlmap3ddata.stationstandlist.loadpromise(jlmap3ddata,standsdata,mapdata,scene,assetloader,jlmap3dasset.others);
|
||||
})
|
||||
.then(function(data){
|
||||
//console.log(data);
|
||||
// return jlmap3ddata.sectionlist.initpromise(jlmap3ddata,assetloader,mapdata.sectionList,mapdata.switchList,scene);
|
||||
@ -174,9 +168,82 @@ export function jl3dEditorLoader(mapid,scope){
|
||||
//console.log(data);
|
||||
loadingInstance.close();
|
||||
});
|
||||
}else{
|
||||
// //初始化站台
|
||||
jlmap3ddata.stationstandlist = new StationStandList();
|
||||
//初始化轨道和道岔 暂时
|
||||
jlmap3ddata.sectionlist = new SectionList();
|
||||
|
||||
jlmap3ddata.signallist = new SignalList();
|
||||
|
||||
jlmap3ddata.switchlist = new SwitchList();
|
||||
|
||||
jlmap3ddata.raillist = new RailList();
|
||||
console.log(netdata);
|
||||
let sectiondata = JSON.parse(netdata.sections);
|
||||
let switchdata = JSON.parse(netdata.switchs);
|
||||
let signaldata = JSON.parse(netdata.signals);
|
||||
let standsdata = JSON.parse(netdata.stands);
|
||||
jlmap3dasset = JSON.parse(netdata.assets);
|
||||
|
||||
if(jlmap3dasset.sceneAssetList == undefined){
|
||||
|
||||
// loadEditAllAsset(jlmap3dasset);
|
||||
assetloader.setmodellistnew(netdata.assets,5);
|
||||
assetloader.assetpromise(scene)
|
||||
.then(function(data){
|
||||
// return jlmap3ddata.stationstandlist.initpromise(jlmap3ddata,mapdata.stationList,mapdata.stationStandList,scene,assetloader);
|
||||
return jlmap3ddata.stationstandlist.loadpromise(jlmap3ddata,standsdata,mapdata.stationStandList,scene,assetloader);
|
||||
})
|
||||
.then(function(data){
|
||||
//console.log(data);
|
||||
// return jlmap3ddata.sectionlist.initpromise(jlmap3ddata,assetloader,mapdata.sectionList,mapdata.switchList,scene);
|
||||
return jlmap3ddata.sectionlist.loadpromise(jlmap3ddata,assetloader,sectiondata.section,scene);
|
||||
})
|
||||
.then(function(data){
|
||||
//console.log(data);
|
||||
// return jlmap3ddata.signallist.initpromise(jlmap3ddata,mapdata.signalList,scene,assetloader);
|
||||
return jlmap3ddata.signallist.loadpromise(signaldata,scene,assetloader,mapdata.signalList);
|
||||
})
|
||||
.then(function(data){
|
||||
// return jlmap3ddata.switchlist.initpromise(jlmap3ddata,mapdata.switchList,scene,assetloader);
|
||||
return jlmap3ddata.switchlist.loadpromise(jlmap3ddata,switchdata,scene,assetloader);
|
||||
})
|
||||
.then(function(data){
|
||||
//console.log(data);
|
||||
loadingInstance.close();
|
||||
});
|
||||
}else{
|
||||
loadEditAllAsset(jlmap3dasset);
|
||||
assetloader.setModelListOver(jlmap3dasset.sceneAssetList,5,jlmap3dasset.others);
|
||||
assetloader.assetPromiseOver(scene)
|
||||
.then(function(data){
|
||||
// return jlmap3ddata.stationstandlist.initpromise(jlmap3ddata,mapdata.stationList,mapdata.stationStandList,scene,assetloader);
|
||||
return jlmap3ddata.stationstandlist.loadpromise(jlmap3ddata,standsdata,mapdata,scene,assetloader,jlmap3dasset.others);
|
||||
})
|
||||
.then(function(data){
|
||||
//console.log(data);
|
||||
// return jlmap3ddata.sectionlist.initpromise(jlmap3ddata,assetloader,mapdata.sectionList,mapdata.switchList,scene);
|
||||
return jlmap3ddata.sectionlist.loadpromise(jlmap3ddata,assetloader,sectiondata.section,mapdata.sectionList,mapdata.switchList,scene);
|
||||
})
|
||||
.then(function(data){
|
||||
//console.log(data);
|
||||
// return jlmap3ddata.signallist.initpromise(jlmap3ddata,mapdata.signalList,scene,assetloader);
|
||||
return jlmap3ddata.signallist.loadpromise(signaldata,scene,assetloader,mapdata.signalList);
|
||||
})
|
||||
.then(function(data){
|
||||
// return jlmap3ddata.switchlist.initpromise(jlmap3ddata,mapdata.switchList,scene,assetloader);
|
||||
return jlmap3ddata.switchlist.loadpromise(jlmap3ddata,switchdata,scene,assetloader);
|
||||
})
|
||||
.then(function(data){
|
||||
//console.log(data);
|
||||
loadingInstance.close();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -188,9 +188,12 @@ export function JLmap3dEdit(dom, data, mapid) {
|
||||
// let exportmodels = scope.mapdata.stationstandlist.group;
|
||||
let exportSectionModel = scope.mapdata.sectionlist.sectiongroup;
|
||||
objDownload("section",exporter.parse( exportSectionModel ));
|
||||
|
||||
if(scope.mapdata.stationstandlist){
|
||||
let exportStationModel = scope.mapdata.stationstandlist.group;
|
||||
objDownload("station",exporter.parse( exportStationModel ));
|
||||
}
|
||||
|
||||
let exportStationModel = scope.mapdata.stationstandlist.group;
|
||||
objDownload("station",exporter.parse( exportStationModel ));
|
||||
|
||||
}
|
||||
|
||||
|
846
src/jlmap3d/edit/railwayModel/rSectionList.js
Normal file
846
src/jlmap3d/edit/railwayModel/rSectionList.js
Normal file
@ -0,0 +1,846 @@
|
||||
import {SectionModel} from '@/jlmap3d/edit/testEditorModel/SectionModel.js';
|
||||
import {SwitchModel} from '@/jlmap3d/edit/testEditorModel/SwitchModel.js';
|
||||
import { JL3D_LOCAL_STATIC } from '@/api/jlmap3d/assets3d.js';
|
||||
|
||||
export function rSectionList() {
|
||||
|
||||
let scope = this;
|
||||
this.type = "sectionlist";
|
||||
this.sectiongroup = new THREE.Group();
|
||||
this.sectiongroup.name = "section";
|
||||
this.sections = {
|
||||
datalist:[],
|
||||
modellist:[]
|
||||
};
|
||||
this.stopsection = [];
|
||||
this.standtrack = [];
|
||||
var autorail;
|
||||
|
||||
var color = new THREE.Color(0xFF0000);
|
||||
var colorArray = new Float32Array([Math.random(),Math.random(),Math.random()]);
|
||||
|
||||
|
||||
|
||||
this.initpromise = function(jlmap3ddata,assetloader,sectiondata,switchdata,scene){
|
||||
var texture = new THREE.TextureLoader().load( JL3D_LOCAL_STATIC+'/test/z0251.png' );
|
||||
texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
|
||||
texture.repeat.set( 1,1);
|
||||
|
||||
var selectmaterial = new THREE.MeshPhongMaterial( { map: texture,transparent:true,alphaTest:0.1 } );
|
||||
|
||||
|
||||
scene.add(scope.sectiongroup);
|
||||
return new Promise(function(resolve, reject){
|
||||
//收集需要显示区段
|
||||
for(let i=0;i<sectiondata.length;i++){
|
||||
if(sectiondata[i].type == "01" || sectiondata[i].type == "03"){
|
||||
//初始化区段对象数据
|
||||
let newsection = new SectionModel(sectiondata[i]);
|
||||
// console.log(sectiondata[i]);
|
||||
newsection.name = sectiondata[i].name;
|
||||
newsection.code = sectiondata[i].code;
|
||||
newsection.index = i;
|
||||
newsection.type = sectiondata[i].type;
|
||||
newsection.lengthFact = sectiondata[i].lengthFact;
|
||||
|
||||
newsection.stationcode = sectiondata[i].stationCode;
|
||||
newsection.rsection = sectiondata[i].rightSectionCode;
|
||||
newsection.lsection = sectiondata[i].leftSectionCode;
|
||||
newsection.points = sectiondata[i].points;
|
||||
newsection.pointslength = sectiondata[i].points.length-1;
|
||||
newsection.railpoint = [];
|
||||
// console.log(sectiondata[i].points.length);
|
||||
newsection.standTrack = sectiondata[i].standTrack;
|
||||
|
||||
newsection.endbuild = false;
|
||||
newsection.rp = {
|
||||
x:0,
|
||||
y:0,
|
||||
z:0
|
||||
};
|
||||
newsection.lp = {
|
||||
x:0,
|
||||
y:0,
|
||||
z:0
|
||||
};
|
||||
scope.sections.datalist[sectiondata[i].code] = newsection;
|
||||
|
||||
// sections.modellist.push("");
|
||||
}
|
||||
}
|
||||
|
||||
//连接区段
|
||||
for(let i=0;i<switchdata.length;i++){
|
||||
let acode = switchdata[i].sectionACode;
|
||||
let bcode = switchdata[i].sectionBCode;
|
||||
let ccode = switchdata[i].sectionCCode;
|
||||
// console.log(switchdata[i]);
|
||||
|
||||
|
||||
let aposx = (scope.sections.datalist[acode].points[0].x + scope.sections.datalist[acode].points[scope.sections.datalist[acode].pointslength].x)/2;
|
||||
let cposx = (scope.sections.datalist[ccode].points[0].x + scope.sections.datalist[ccode].points[scope.sections.datalist[ccode].pointslength].x)/2;
|
||||
|
||||
let aposy = (scope.sections.datalist[acode].points[0].y + scope.sections.datalist[acode].points[scope.sections.datalist[acode].pointslength].y)/2;
|
||||
let cposy = (scope.sections.datalist[ccode].points[0].y + scope.sections.datalist[ccode].points[scope.sections.datalist[ccode].pointslength].y)/2;
|
||||
|
||||
// console.log("----------------");
|
||||
if(aposx > cposx){
|
||||
if(aposy < cposy){
|
||||
// ——A
|
||||
// /C
|
||||
scope.sections.datalist[ccode].ctype = 1;
|
||||
}else{
|
||||
// \C
|
||||
// ——A
|
||||
scope.sections.datalist[ccode].ctype = 2;
|
||||
}
|
||||
}else{
|
||||
if(aposy < cposy){
|
||||
// A——
|
||||
// \C
|
||||
scope.sections.datalist[ccode].ctype = 3;
|
||||
}else{
|
||||
// /C
|
||||
// A——
|
||||
scope.sections.datalist[ccode].ctype = 4;
|
||||
}
|
||||
}
|
||||
|
||||
scope.sections.datalist[acode].csection = ccode;
|
||||
|
||||
if(scope.sections.datalist[ccode].ctype == 1 || scope.sections.datalist[ccode].ctype == 2){
|
||||
if(scope.sections.datalist[acode].lsection == "" || scope.sections.datalist[acode].lsection == undefined){
|
||||
scope.sections.datalist[acode].lsection = bcode;
|
||||
}
|
||||
|
||||
if(scope.sections.datalist[bcode].rsection == "" || scope.sections.datalist[bcode].rsection == undefined){
|
||||
scope.sections.datalist[bcode].rsection = acode;
|
||||
}
|
||||
|
||||
if(scope.sections.datalist[ccode].rsection == "" || scope.sections.datalist[ccode].rsection == undefined){
|
||||
scope.sections.datalist[ccode].rsection = acode;
|
||||
}else if(scope.sections.datalist[ccode].lsection == "" || scope.sections.datalist[ccode].lsection == undefined){
|
||||
scope.sections.datalist[ccode].lsection = acode;
|
||||
}
|
||||
}
|
||||
|
||||
if(scope.sections.datalist[ccode].ctype == 3 || scope.sections.datalist[ccode].ctype == 4){
|
||||
if(scope.sections.datalist[acode].rsection == "" || scope.sections.datalist[acode].rsection == undefined){
|
||||
scope.sections.datalist[acode].rsection = bcode;
|
||||
}
|
||||
|
||||
if(scope.sections.datalist[bcode].lsection == "" ||scope.sections.datalist[bcode].lsection == undefined ){
|
||||
scope.sections.datalist[bcode].lsection = acode;
|
||||
}
|
||||
|
||||
if(scope.sections.datalist[ccode].rsection == "" || scope.sections.datalist[ccode].rsection == undefined){
|
||||
scope.sections.datalist[ccode].rsection = acode;
|
||||
}else if(scope.sections.datalist[ccode].lsection == "" || scope.sections.datalist[ccode].lsection == undefined){
|
||||
scope.sections.datalist[ccode].lsection = acode;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
scope.sections.datalist["T1"].railpoint.push({
|
||||
x:0,
|
||||
y:0,
|
||||
z:0
|
||||
});
|
||||
scope.sections.datalist["T1"].railpoint.push({
|
||||
x:50,
|
||||
y:0,
|
||||
z:0
|
||||
});
|
||||
scope.sections.datalist["T1"].railpoint.push({
|
||||
x:100,
|
||||
y:0,
|
||||
z:0
|
||||
});
|
||||
console.log(scope.sections.datalist);
|
||||
console.log("START BUILD !!!!!!!!!!!!!!!!!");
|
||||
buildsectionall(scope.sections.datalist["T1"]);
|
||||
resolve("loadersection");
|
||||
});
|
||||
};
|
||||
|
||||
function createsection(origin,position,start,py){
|
||||
var texture = new THREE.TextureLoader().load( JL3D_LOCAL_STATIC+'/test/z0251.png' );
|
||||
texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
|
||||
texture.repeat.set( 1,1);
|
||||
|
||||
var selectmaterial = new THREE.MeshPhongMaterial( { map: texture,transparent:true,alphaTest:0.1 } );
|
||||
|
||||
position.z = py;
|
||||
let len = scope.sections.datalist[start].lengthFact;
|
||||
let height = Math.random()/1000;
|
||||
|
||||
scope.sections.datalist[start].railpoint = [
|
||||
new THREE.Vector3(position.x,height,position.z),
|
||||
new THREE.Vector3(position.x+0.5,height,position.z+0.0001),
|
||||
new THREE.Vector3(position.x+len,height,position.z),
|
||||
];
|
||||
|
||||
let closedSpline = new THREE.CatmullRomCurve3( [
|
||||
new THREE.Vector3(position.x,height,position.z),
|
||||
new THREE.Vector3(position.x+0.5,height,position.z+0.0001),
|
||||
new THREE.Vector3(position.x+len,height,position.z),
|
||||
] );
|
||||
closedSpline.type = 'catmullrom';
|
||||
closedSpline.closed = false;
|
||||
var extrudeSettings = {
|
||||
steps : 5,
|
||||
curveSegments : 1,
|
||||
bevelSegments : 1,
|
||||
bevelEnabled : false,
|
||||
extrudePath : closedSpline,
|
||||
};
|
||||
var shape = new THREE.Shape();
|
||||
shape.moveTo( 0,-2 );
|
||||
shape.lineTo( 0, 2 );
|
||||
var geometry = new THREE.ExtrudeBufferGeometry( shape, extrudeSettings );
|
||||
|
||||
|
||||
var randomMaterail = new THREE.MeshLambertMaterial({
|
||||
//color:color.fromArray(colorArray)
|
||||
color:0xFFFFFF*Math.random()
|
||||
})
|
||||
let testmesh2;
|
||||
if(scope.sections.datalist[start].standTrack == false){
|
||||
testmesh2 = new THREE.Mesh( geometry, selectmaterial );
|
||||
}else{
|
||||
testmesh2 = new THREE.Mesh( geometry, selectmaterial );
|
||||
}
|
||||
|
||||
// closedSpline.arcLengthDivisions;
|
||||
let count = testmesh2.geometry.attributes.position.count/3;
|
||||
|
||||
for(let i=0;i<count;i++){
|
||||
let ui=i*6;
|
||||
if(i%2 != 0){
|
||||
testmesh2.geometry.attributes.uv.array[ui] = 0;
|
||||
testmesh2.geometry.attributes.uv.array[ui+1] = 1;
|
||||
testmesh2.geometry.attributes.uv.array[ui+2] = len/5;
|
||||
testmesh2.geometry.attributes.uv.array[ui+3] = 1;
|
||||
testmesh2.geometry.attributes.uv.array[ui+4] = len/5;
|
||||
testmesh2.geometry.attributes.uv.array[ui+5] = 0;
|
||||
}else{
|
||||
testmesh2.geometry.attributes.uv.array[ui] = 0;
|
||||
testmesh2.geometry.attributes.uv.array[ui+1] = 0;
|
||||
testmesh2.geometry.attributes.uv.array[ui+2] = 0;
|
||||
testmesh2.geometry.attributes.uv.array[ui+3] = 1;
|
||||
testmesh2.geometry.attributes.uv.array[ui+4] = len/5;
|
||||
testmesh2.geometry.attributes.uv.array[ui+5] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
testmesh2.code = start;
|
||||
testmesh2.railpoint = scope.sections.datalist[start].railpoint;
|
||||
testmesh2.lengthFact = scope.sections.datalist[start].railpoint.lengthFact;
|
||||
scope.sections.datalist[start].mesh = testmesh2;
|
||||
scope.sectiongroup.add( testmesh2 );
|
||||
|
||||
let topstartpoint = {
|
||||
x:position.x+scope.sections.datalist[start].lengthFact,
|
||||
y:0,
|
||||
z:position.z
|
||||
};
|
||||
// console.log(origin+"******************************");
|
||||
// console.log(start);
|
||||
// console.log(origin);
|
||||
if(scope.sections.datalist[start].standTrack == true && start != origin){
|
||||
// console.log(start+"到达");
|
||||
// console.log("++++++++++++++++++++++++");
|
||||
return ;
|
||||
}else if(scope.sections.datalist[start].rsection == undefined){
|
||||
return ;
|
||||
}else{
|
||||
return createsection(origin,topstartpoint,scope.sections.datalist[start].rsection,py);
|
||||
}
|
||||
}
|
||||
|
||||
function findnextsection(findarray,start){
|
||||
|
||||
if(start == undefined){
|
||||
return findarray;
|
||||
}
|
||||
if(scope.sections.datalist[start].rsection == undefined){
|
||||
return null;
|
||||
}
|
||||
|
||||
if(scope.sections.datalist[start].standTrack == true){
|
||||
|
||||
findarray.endSection = scope.sections.datalist[start];
|
||||
return findarray;
|
||||
}else{
|
||||
findarray.sectionArrays.push(scope.sections.datalist[start]);
|
||||
findarray.distance = findarray.distance + scope.sections.datalist[start].lengthFact;
|
||||
return findnextsection(findarray,scope.sections.datalist[start].rsection);
|
||||
// }
|
||||
}
|
||||
}
|
||||
function compare(property){
|
||||
return function(a,b){
|
||||
var value1 = a[property];
|
||||
var value2 = b[property];
|
||||
return value1 - value2;
|
||||
}
|
||||
}
|
||||
function buildsectionall(origin){
|
||||
if(origin.rsection){
|
||||
if(scope.sections.datalist[origin.rsection].endbuild == false){
|
||||
scope.sections.datalist[origin.rsection].endbuild = true;
|
||||
if(scope.sections.datalist[origin.rsection].mesh == null){
|
||||
buildsection(origin,scope.sections.datalist[origin.rsection],"right");
|
||||
buildsectionall(scope.sections.datalist[origin.rsection]);
|
||||
}else{
|
||||
buildsectionall(scope.sections.datalist[origin.rsection]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if(origin.lsection){
|
||||
if(scope.sections.datalist[origin.lsection].endbuild == false){
|
||||
scope.sections.datalist[origin.lsection].endbuild = true;
|
||||
if(scope.sections.datalist[origin.lsection].mesh == null){
|
||||
buildsection(origin,scope.sections.datalist[origin.lsection],"left");
|
||||
buildsectionall(scope.sections.datalist[origin.lsection]);
|
||||
}else{
|
||||
buildsectionall(scope.sections.datalist[origin.lsection]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(origin.csection){
|
||||
if(scope.sections.datalist[origin.csection].endbuild == false){
|
||||
scope.sections.datalist[origin.csection].endbuild = true;
|
||||
if(scope.sections.datalist[origin.csection].mesh == null){
|
||||
buildsection(origin,scope.sections.datalist[origin.csection],"cross");
|
||||
buildsectionall(scope.sections.datalist[origin.csection]);
|
||||
}else{
|
||||
buildsectionall(scope.sections.datalist[origin.csection]);
|
||||
}
|
||||
}
|
||||
}
|
||||
// return ;
|
||||
}
|
||||
|
||||
function buildsection(origin,data,type){
|
||||
|
||||
let len = data.lengthFact;
|
||||
let height = Math.random()/1000;
|
||||
var closedSpline;
|
||||
let initRotation;
|
||||
|
||||
if(data.points[0].x == data.points[data.pointslength].x && data.points[0].y == data.points[data.pointslength].y){
|
||||
|
||||
}else{
|
||||
|
||||
if(type == "right"){
|
||||
let dx = Math.abs(data.points[0].x - data.points[data.pointslength].x);
|
||||
let dy = Math.abs(data.points[0].y - data.points[data.pointslength].y);
|
||||
let distance = Math.sqrt(Math.pow(dx,2)+Math.pow(dy,2));
|
||||
|
||||
data.rp.x = (data.points[data.pointslength].x-data.points[0].x)*data.lengthFact/distance+origin.railpoint[2].x;
|
||||
data.rp.z = (data.points[data.pointslength].y-data.points[0].y)*data.lengthFact/distance+origin.railpoint[2].z;
|
||||
|
||||
data.lp.x = origin.railpoint[2].x;
|
||||
data.lp.z = origin.railpoint[2].z;
|
||||
let axix = new THREE.Vector3(1,0,0);
|
||||
let axixnow = new THREE.Vector3(data.rp.x-data.lp.x,0,data.rp.z-data.lp.z);
|
||||
let rotenum = axixnow.angleTo(axix);
|
||||
//不同坐标系方向值不同
|
||||
if(data.points[0].y>data.points[data.pointslength].y){
|
||||
initRotation = 0.2678;
|
||||
data.rp.x = data.lp.x+(data.lengthFact)*Math.cos(initRotation);
|
||||
data.rp.z = data.lp.z-(data.lengthFact)*Math.sin(initRotation);
|
||||
|
||||
}else if(data.points[0].y<data.points[data.pointslength].y){
|
||||
initRotation = -0.2678;
|
||||
data.rp.x = data.lp.x+(data.lengthFact)*Math.cos(initRotation);
|
||||
data.rp.z = data.lp.z-(data.lengthFact)*Math.sin(initRotation);
|
||||
|
||||
}else{
|
||||
data.rp.z = data.lp.z;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
closedSpline = new THREE.CatmullRomCurve3( [
|
||||
new THREE.Vector3(data.lp.x,0,data.lp.z),
|
||||
new THREE.Vector3((data.lp.x+data.rp.x)/2,0,(data.lp.z+data.rp.z)/2-0.001),
|
||||
new THREE.Vector3(data.rp.x,0,data.rp.z),
|
||||
] );
|
||||
data.railpoint = [
|
||||
new THREE.Vector3(data.lp.x,0,data.lp.z),
|
||||
new THREE.Vector3((data.lp.x+data.rp.x)/2,0,(data.lp.z+data.rp.z)/2-0.001),
|
||||
new THREE.Vector3(data.rp.x,0,data.rp.z),
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
if(type == "left"){
|
||||
let dx = Math.abs(data.points[0].x - data.points[data.pointslength].x);
|
||||
let dy = Math.abs(data.points[0].y - data.points[data.pointslength].y);
|
||||
let distance = Math.sqrt(Math.pow(dx,2)+Math.pow(dy,2));
|
||||
|
||||
data.lp.x = (data.points[0].x-data.points[data.pointslength].x)*data.lengthFact/distance+origin.railpoint[0].x;
|
||||
data.lp.z = (data.points[0].y-data.points[data.pointslength].y)*data.lengthFact/distance+origin.railpoint[0].z;
|
||||
|
||||
data.rp.x = origin.railpoint[0].x;
|
||||
data.rp.z = origin.railpoint[0].z;
|
||||
|
||||
|
||||
let axix = new THREE.Vector3(1,0,0);
|
||||
let axixnow = new THREE.Vector3(data.rp.x-data.lp.x,0,data.rp.z-data.lp.z);
|
||||
|
||||
let rotenum = axixnow.angleTo(axix);
|
||||
//不同坐标系方向值不同
|
||||
if(data.points[0].y>data.points[data.pointslength].y){
|
||||
initRotation = 0.2678;
|
||||
data.lp.x = data.rp.x - (data.lengthFact)*Math.cos(initRotation);
|
||||
data.lp.z = data.rp.z + (data.lengthFact)*Math.sin(initRotation);
|
||||
}else if(data.points[0].y<data.points[data.pointslength].y){
|
||||
initRotation = -0.2678;
|
||||
data.lp.x = data.rp.x - (data.lengthFact)*Math.cos(initRotation);
|
||||
data.lp.z = data.rp.z + (data.lengthFact)*Math.sin(initRotation);
|
||||
}else{
|
||||
data.lp.z = data.rp.z;
|
||||
}
|
||||
closedSpline = new THREE.CatmullRomCurve3( [
|
||||
new THREE.Vector3(data.lp.x,0,data.lp.z),
|
||||
new THREE.Vector3((data.lp.x+data.rp.x)/2,0,(data.lp.z+data.rp.z)/2-0.001),
|
||||
new THREE.Vector3(data.rp.x,0,data.rp.z),
|
||||
] );
|
||||
data.railpoint = [
|
||||
new THREE.Vector3(data.lp.x,0,data.lp.z),
|
||||
new THREE.Vector3((data.lp.x+data.rp.x)/2,0,(data.lp.z+data.rp.z)/2-0.001),
|
||||
new THREE.Vector3(data.rp.x,0,data.rp.z),
|
||||
];
|
||||
}
|
||||
|
||||
// console.log(data.ctype);
|
||||
if(type == "cross"){
|
||||
// console.log(data.ctype);
|
||||
// console.log(scope.sections.datalist[data.code].points.length);
|
||||
// console.log(scope.sections.datalist[data.code]);
|
||||
if(data.ctype == "1"||data.ctype == "2" ){
|
||||
|
||||
|
||||
let dx = Math.abs(data.points[0].x - data.points[data.pointslength].x);
|
||||
let dy = Math.abs(data.points[0].y - data.points[data.pointslength].y);
|
||||
let distance = Math.sqrt(Math.pow(dx,2)+Math.pow(dy,2));
|
||||
|
||||
data.lp.x = (data.points[0].x-data.points[data.pointslength].x)*data.lengthFact/distance+origin.railpoint[0].x;
|
||||
data.lp.z = (data.points[0].y-data.points[data.pointslength].y)*data.lengthFact/distance+origin.railpoint[0].z;
|
||||
|
||||
data.rp.x = origin.railpoint[0].x;
|
||||
data.rp.z = origin.railpoint[0].z;
|
||||
|
||||
|
||||
let axix = new THREE.Vector3(1,0,0);
|
||||
let axixnow = new THREE.Vector3(data.rp.x-data.lp.x,0,data.rp.z-data.lp.z);
|
||||
let rotenum = axixnow.angleTo(axix);
|
||||
//不同坐标系方向值不同
|
||||
if(data.points[0].y>data.points[data.pointslength].y){
|
||||
initRotation = 0.2678;
|
||||
data.lp.x = data.rp.x - (data.lengthFact)*Math.cos(initRotation);
|
||||
data.lp.z = data.rp.z + (data.lengthFact)*Math.sin(initRotation);
|
||||
}else if(data.points[0].y<data.points[data.pointslength].y){
|
||||
initRotation = -0.2678;
|
||||
data.lp.x = data.rp.x - (data.lengthFact)*Math.cos(initRotation);
|
||||
data.lp.z = data.rp.z + (data.lengthFact)*Math.sin(initRotation);
|
||||
}else{
|
||||
data.lp.z = data.rp.z;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if(data.ctype == "3" || data.ctype == "4"){
|
||||
let dx = Math.abs(data.points[0].x - data.points[data.pointslength].x);
|
||||
let dy = Math.abs(data.points[0].y - data.points[data.pointslength].y);
|
||||
let distance = Math.sqrt(Math.pow(dx,2)+Math.pow(dy,2));
|
||||
|
||||
data.rp.x = (data.points[data.pointslength].x-data.points[0].x)*data.lengthFact/distance+origin.railpoint[2].x;
|
||||
data.rp.z = (data.points[data.pointslength].y-data.points[0].y)*data.lengthFact/distance+origin.railpoint[2].z;
|
||||
|
||||
data.lp.x = origin.railpoint[2].x;
|
||||
data.lp.z = origin.railpoint[2].z;
|
||||
let axix = new THREE.Vector3(1,0,0);
|
||||
let axixnow = new THREE.Vector3(data.rp.x-data.lp.x,0,data.rp.z-data.lp.z);
|
||||
let rotenum = axixnow.angleTo(axix);
|
||||
//不同坐标系方向值不同
|
||||
if(data.points[0].y>data.points[data.pointslength].y){
|
||||
initRotation = 0.2678;
|
||||
data.rp.x = data.lp.x+(data.lengthFact)*Math.cos(initRotation);
|
||||
data.rp.z = data.lp.z-(data.lengthFact)*Math.sin(initRotation);
|
||||
}else if(data.points[0].y<data.points[data.pointslength].y){
|
||||
initRotation = -0.2678;
|
||||
data.rp.x = data.lp.x+(data.lengthFact)*Math.cos(initRotation);
|
||||
data.rp.z = data.lp.z-(data.lengthFact)*Math.sin(initRotation);
|
||||
}else{
|
||||
data.lp.z = data.rp.z;
|
||||
}
|
||||
}
|
||||
closedSpline = new THREE.CatmullRomCurve3( [
|
||||
new THREE.Vector3(data.lp.x,0,data.lp.z),
|
||||
new THREE.Vector3((data.lp.x+data.rp.x)/2,0,(data.lp.z+data.rp.z)/2-0.001),
|
||||
new THREE.Vector3(data.rp.x,0,data.rp.z),
|
||||
] );
|
||||
data.railpoint = [
|
||||
new THREE.Vector3(data.lp.x,0,data.lp.z),
|
||||
new THREE.Vector3((data.lp.x+data.rp.x)/2,0,(data.lp.z+data.rp.z)/2-0.001),
|
||||
new THREE.Vector3(data.rp.x,0,data.rp.z),
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
closedSpline.type = 'catmullrom';
|
||||
closedSpline.closed = false;
|
||||
var extrudeSettings = {
|
||||
steps : 5,
|
||||
curveSegments : 1,
|
||||
bevelSegments : 1,
|
||||
bevelEnabled : false,
|
||||
extrudePath : closedSpline,
|
||||
};
|
||||
var shape = new THREE.Shape();
|
||||
shape.moveTo( 0,-2 );
|
||||
shape.lineTo( 0, 2 );
|
||||
var geometry = new THREE.ExtrudeBufferGeometry( shape, extrudeSettings );
|
||||
|
||||
|
||||
var randomMaterail = new THREE.MeshLambertMaterial({
|
||||
//color:color.fromArray(colorArray)
|
||||
color:0xFFFFFF*Math.random()
|
||||
})
|
||||
let testmesh2 = new THREE.Mesh( geometry, randomMaterail );
|
||||
testmesh2.railpoint = data.railpoint;
|
||||
|
||||
testmesh2.lengthFact = data.lengthFact;
|
||||
// closedSpline.arcLengthDivisions;
|
||||
let count = testmesh2.geometry.attributes.position.count/3;
|
||||
|
||||
for(let i=0;i<count;i++){
|
||||
let ui=i*6;
|
||||
if(i%2 != 0){
|
||||
testmesh2.geometry.attributes.uv.array[ui] = 0;
|
||||
testmesh2.geometry.attributes.uv.array[ui+1] = 1;
|
||||
testmesh2.geometry.attributes.uv.array[ui+2] = len/5;
|
||||
testmesh2.geometry.attributes.uv.array[ui+3] = 1;
|
||||
testmesh2.geometry.attributes.uv.array[ui+4] = len/5;
|
||||
testmesh2.geometry.attributes.uv.array[ui+5] = 0;
|
||||
}else{
|
||||
testmesh2.geometry.attributes.uv.array[ui] = 0;
|
||||
testmesh2.geometry.attributes.uv.array[ui+1] = 0;
|
||||
testmesh2.geometry.attributes.uv.array[ui+2] = 0;
|
||||
testmesh2.geometry.attributes.uv.array[ui+3] = 1;
|
||||
testmesh2.geometry.attributes.uv.array[ui+4] = len/5;
|
||||
testmesh2.geometry.attributes.uv.array[ui+5] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
testmesh2.code = data.code;
|
||||
testmesh2.lengthFact = data.lengthFact;
|
||||
scope.sectiongroup.add( testmesh2 );
|
||||
|
||||
|
||||
data.mesh = testmesh2;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
this.loadpromise = function(jlmap3ddata,assetloader,sectiondata,section2d,switch2d,scene){
|
||||
|
||||
var texture = new THREE.TextureLoader().load( JL3D_LOCAL_STATIC+'/test/z0251.png' );
|
||||
texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
|
||||
texture.repeat.set( 1,1);
|
||||
|
||||
var selectmaterial = new THREE.MeshPhongMaterial( { map: texture,transparent:true,alphaTest:0.1 } );
|
||||
|
||||
scene.add(scope.sectiongroup);
|
||||
return new Promise(function(resolve, reject){
|
||||
for(let i=0,leni = sectiondata.length;i<leni;i++){
|
||||
let newsection = {
|
||||
code:sectiondata[i].code,
|
||||
name:sectiondata[i].name,
|
||||
standTrack:sectiondata[i].standTrack,
|
||||
// rail:sectiondata[i].rail,
|
||||
lengthFact:sectiondata[i].lengthFact,
|
||||
// rp:sectiondata[i].rp,
|
||||
// lp:sectiondata[i].lp,
|
||||
railpoint:sectiondata[i].railpoint,
|
||||
mesh:null
|
||||
};
|
||||
|
||||
let testmesh2 = null;
|
||||
|
||||
if(newsection.railpoint.length>2){
|
||||
|
||||
let height = Math.random()/1000;
|
||||
var closedSpline = new THREE.CatmullRomCurve3( [
|
||||
new THREE.Vector3(newsection.railpoint[0].x,newsection.railpoint[0].y,newsection.railpoint[0].z),
|
||||
new THREE.Vector3(newsection.railpoint[1].x,newsection.railpoint[1].y,newsection.railpoint[1].z+0.0001),
|
||||
new THREE.Vector3(newsection.railpoint[2].x,newsection.railpoint[2].y,newsection.railpoint[2].z)
|
||||
] );
|
||||
closedSpline.type = 'catmullrom';
|
||||
closedSpline.closed = false;
|
||||
var extrudeSettings = {
|
||||
steps : 5,
|
||||
curveSegments : 1,
|
||||
bevelSegments : 1,
|
||||
bevelEnabled : false,
|
||||
extrudePath : closedSpline,
|
||||
};
|
||||
var shape = new THREE.Shape();
|
||||
|
||||
if(newsection.railpoint[0].y != newsection.railpoint[2].y){
|
||||
shape.moveTo( -2, 0 );
|
||||
shape.lineTo( 2, 0 );
|
||||
}else{
|
||||
shape.moveTo( 0,-2 );
|
||||
shape.lineTo( 0, 2 );
|
||||
}
|
||||
|
||||
var geometry = new THREE.ExtrudeBufferGeometry( shape, extrudeSettings );
|
||||
|
||||
var randomMaterail = new THREE.MeshLambertMaterial({
|
||||
//color:color.fromArray(colorArray)
|
||||
color:0xFFFFFF*Math.random()
|
||||
});
|
||||
|
||||
if(newsection.standTrack == false){
|
||||
testmesh2 = new THREE.Mesh( geometry, selectmaterial );
|
||||
}else{
|
||||
testmesh2 = new THREE.Mesh( geometry, selectmaterial );
|
||||
}
|
||||
|
||||
testmesh2.railpoint = [
|
||||
{x:newsection.railpoint[0].x,y:newsection.railpoint[0].y,z:newsection.railpoint[0].z},
|
||||
{x:newsection.railpoint[1].x,y:newsection.railpoint[1].y,z:newsection.railpoint[1].z},
|
||||
{x:newsection.railpoint[2].x,y:newsection.railpoint[2].y,z:newsection.railpoint[2].z},
|
||||
];
|
||||
testmesh2.lengthFact = newsection.railpoint[2].x-newsection.railpoint[0].x;
|
||||
let len = testmesh2.lengthFact;
|
||||
// testmesh2.lengthFact = newsection.lengthFact;
|
||||
// let len = newsection.lengthFact;
|
||||
// closedSpline.arcLengthDivisions;
|
||||
let count = testmesh2.geometry.attributes.position.count/3;
|
||||
|
||||
for(let i=0;i<count;i++){
|
||||
let ui=i*6;
|
||||
if(i%2 != 0){
|
||||
testmesh2.geometry.attributes.uv.array[ui] = 0;
|
||||
testmesh2.geometry.attributes.uv.array[ui+1] = 1;
|
||||
testmesh2.geometry.attributes.uv.array[ui+2] = len/5;
|
||||
testmesh2.geometry.attributes.uv.array[ui+3] = 1;
|
||||
testmesh2.geometry.attributes.uv.array[ui+4] = len/5;
|
||||
testmesh2.geometry.attributes.uv.array[ui+5] = 0;
|
||||
}else{
|
||||
testmesh2.geometry.attributes.uv.array[ui] = 0;
|
||||
testmesh2.geometry.attributes.uv.array[ui+1] = 0;
|
||||
testmesh2.geometry.attributes.uv.array[ui+2] = 0;
|
||||
testmesh2.geometry.attributes.uv.array[ui+3] = 1;
|
||||
testmesh2.geometry.attributes.uv.array[ui+4] = len/5;
|
||||
testmesh2.geometry.attributes.uv.array[ui+5] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(testmesh2){
|
||||
testmesh2.code = newsection.code;
|
||||
testmesh2.standTrack = newsection.standTrack;
|
||||
testmesh2.meshtype = "section";
|
||||
|
||||
// testmesh2.geometry.computeBoundingBox();
|
||||
// testmesh2.geometry.center()
|
||||
// testmesh2.position.set(sectiondata[i].position.x,sectiondata[i].position.y,sectiondata[i].position.z);
|
||||
scope.sectiongroup.add(testmesh2);
|
||||
newsection.mesh = testmesh2;
|
||||
scope.sections.datalist[newsection.code] = newsection;
|
||||
}
|
||||
|
||||
}else{
|
||||
let height = Math.random()/1000;
|
||||
var closedSpline = new THREE.CatmullRomCurve3( [
|
||||
new THREE.Vector3(newsection.railpoint[0].x,height,newsection.railpoint[0].z),
|
||||
new THREE.Vector3((newsection.railpoint[0].x+newsection.railpoint[1].x)/2,height,newsection.railpoint[0].z+0.0001),
|
||||
new THREE.Vector3(newsection.railpoint[1].x,height,newsection.railpoint[1].z)
|
||||
] );
|
||||
closedSpline.type = 'catmullrom';
|
||||
closedSpline.closed = false;
|
||||
var extrudeSettings = {
|
||||
steps : 5,
|
||||
curveSegments : 1,
|
||||
bevelSegments : 1,
|
||||
bevelEnabled : false,
|
||||
extrudePath : closedSpline,
|
||||
};
|
||||
var shape = new THREE.Shape();
|
||||
shape.moveTo( 0,-2 );
|
||||
shape.lineTo( 0, 2 );
|
||||
var geometry = new THREE.ExtrudeBufferGeometry( shape, extrudeSettings );
|
||||
var randomMaterail = new THREE.MeshLambertMaterial({
|
||||
//color:color.fromArray(colorArray)
|
||||
color:0xFFFFFF*Math.random()
|
||||
});
|
||||
|
||||
if(newsection.standTrack == false){
|
||||
testmesh2 = new THREE.Mesh( geometry, randomMaterail );
|
||||
}else{
|
||||
testmesh2 = new THREE.Mesh( geometry, selectmaterial );
|
||||
}
|
||||
|
||||
testmesh2.railpoint = [
|
||||
{x:newsection.railpoint[0].x,y:height,z:newsection.railpoint[0].z},
|
||||
{x:(newsection.railpoint[0].x+newsection.railpoint[1].x)/2,y:height,z:newsection.railpoint[1].z},
|
||||
{x:newsection.railpoint[1].x,y:height,z:newsection.railpoint[1].z},
|
||||
];
|
||||
testmesh2.lengthFact = newsection.railpoint[1].x-newsection.railpoint[0].x;
|
||||
let len = testmesh2.lengthFact;
|
||||
// closedSpline.arcLengthDivisions;
|
||||
let count = testmesh2.geometry.attributes.position.count/3;
|
||||
|
||||
for(let i=0;i<count;i++){
|
||||
let ui=i*6;
|
||||
if(i%2 != 0){
|
||||
testmesh2.geometry.attributes.uv.array[ui] = 0;
|
||||
testmesh2.geometry.attributes.uv.array[ui+1] = 1;
|
||||
testmesh2.geometry.attributes.uv.array[ui+2] = len/5;
|
||||
testmesh2.geometry.attributes.uv.array[ui+3] = 1;
|
||||
testmesh2.geometry.attributes.uv.array[ui+4] = len/5;
|
||||
testmesh2.geometry.attributes.uv.array[ui+5] = 0;
|
||||
}else{
|
||||
testmesh2.geometry.attributes.uv.array[ui] = 0;
|
||||
testmesh2.geometry.attributes.uv.array[ui+1] = 0;
|
||||
testmesh2.geometry.attributes.uv.array[ui+2] = 0;
|
||||
testmesh2.geometry.attributes.uv.array[ui+3] = 1;
|
||||
testmesh2.geometry.attributes.uv.array[ui+4] = len/5;
|
||||
testmesh2.geometry.attributes.uv.array[ui+5] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(testmesh2){
|
||||
testmesh2.code = newsection.code;
|
||||
testmesh2.standTrack = newsection.standTrack;
|
||||
testmesh2.meshtype = "section";
|
||||
|
||||
// testmesh2.geometry.computeBoundingBox();
|
||||
// testmesh2.geometry.center()
|
||||
// testmesh2.position.set(sectiondata[i].position.x,sectiondata[i].position.y,sectiondata[i].position.z);
|
||||
scope.sectiongroup.add(testmesh2);
|
||||
newsection.mesh = testmesh2;
|
||||
scope.sections.datalist[newsection.code] = newsection;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
for(let i=0;i<section2d.length;i++){
|
||||
if(section2d[i].type == "01" || section2d[i].type == "03"){
|
||||
if(scope.sections.datalist[section2d[i].code]){
|
||||
scope.sections.datalist[section2d[i].code].rsection = section2d[i].rightSectionCode;
|
||||
scope.sections.datalist[section2d[i].code].lsection = section2d[i].leftSectionCode;
|
||||
scope.sections.datalist[section2d[i].code].points = section2d[i].points;
|
||||
scope.sections.datalist[section2d[i].code].pointslength = section2d[i].points.length-1;
|
||||
if(section2d[i].standTrack == true){
|
||||
|
||||
scope.sections.datalist[section2d[i].code].standLeftX = section2d[i].points[0].x;
|
||||
scope.sections.datalist[section2d[i].code].standLeftY = section2d[i].points[0].y;
|
||||
scope.sections.datalist[section2d[i].code].standRightLeftX = section2d[i].points[1].x;
|
||||
scope.sections.datalist[section2d[i].code].standRightRightY = section2d[i].points[1].y;
|
||||
|
||||
scope.sections.datalist[section2d[i].code].leftStopPointOffset = section2d[i].leftStopPointOffset;
|
||||
scope.sections.datalist[section2d[i].code].rightStopPointOffset = section2d[i].leftStopPointOffset+120;
|
||||
scope.sections.datalist[section2d[i].code].leftStopPercent = section2d[i].leftStopPointOffset/section2d[i].lengthFact;
|
||||
scope.sections.datalist[section2d[i].code].rightStopPercent = section2d[i].rightStopPointOffset/section2d[i].lengthFact;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//连接区段
|
||||
for(let i=0;i<switch2d.length;i++){
|
||||
let acode = switch2d[i].sectionACode;
|
||||
let bcode = switch2d[i].sectionBCode;
|
||||
let ccode = switch2d[i].sectionCCode;
|
||||
// console.log(switchdata[i]);
|
||||
|
||||
// console.log(scope.sections.datalist[acode]);
|
||||
let aposx = (scope.sections.datalist[acode].points[0].x + scope.sections.datalist[acode].points[scope.sections.datalist[acode].pointslength].x)/2;
|
||||
let cposx = (scope.sections.datalist[ccode].points[0].x + scope.sections.datalist[ccode].points[scope.sections.datalist[ccode].pointslength].x)/2;
|
||||
|
||||
let aposy = (scope.sections.datalist[acode].points[0].y + scope.sections.datalist[acode].points[scope.sections.datalist[acode].pointslength].y)/2;
|
||||
let cposy = (scope.sections.datalist[ccode].points[0].y + scope.sections.datalist[ccode].points[scope.sections.datalist[ccode].pointslength].y)/2;
|
||||
|
||||
// console.log("----------------");
|
||||
if(aposx > cposx){
|
||||
if(aposy < cposy){
|
||||
// ——A
|
||||
// /C
|
||||
scope.sections.datalist[ccode].ctype = 1;
|
||||
}else{
|
||||
// \C
|
||||
// ——A
|
||||
scope.sections.datalist[ccode].ctype = 2;
|
||||
}
|
||||
}else{
|
||||
if(aposy < cposy){
|
||||
// A——
|
||||
// \C
|
||||
scope.sections.datalist[ccode].ctype = 3;
|
||||
}else{
|
||||
// /C
|
||||
// A——
|
||||
scope.sections.datalist[ccode].ctype = 4;
|
||||
}
|
||||
}
|
||||
|
||||
scope.sections.datalist[acode].csection = ccode;
|
||||
|
||||
if(scope.sections.datalist[ccode].ctype == 1 || scope.sections.datalist[ccode].ctype == 2){
|
||||
if(scope.sections.datalist[acode].lsection == "" || scope.sections.datalist[acode].lsection == undefined){
|
||||
scope.sections.datalist[acode].lsection = bcode;
|
||||
}
|
||||
|
||||
if(scope.sections.datalist[bcode].rsection == "" || scope.sections.datalist[bcode].rsection == undefined){
|
||||
scope.sections.datalist[bcode].rsection = acode;
|
||||
}
|
||||
|
||||
if(scope.sections.datalist[ccode].rsection == "" || scope.sections.datalist[ccode].rsection == undefined){
|
||||
scope.sections.datalist[ccode].rsection = acode;
|
||||
}else if(scope.sections.datalist[ccode].lsection == "" || scope.sections.datalist[ccode].lsection == undefined){
|
||||
scope.sections.datalist[ccode].lsection = acode;
|
||||
}
|
||||
}
|
||||
|
||||
if(scope.sections.datalist[ccode].ctype == 3 || scope.sections.datalist[ccode].ctype == 4){
|
||||
if(scope.sections.datalist[acode].rsection == "" || scope.sections.datalist[acode].rsection == undefined){
|
||||
scope.sections.datalist[acode].rsection = bcode;
|
||||
}
|
||||
|
||||
if(scope.sections.datalist[bcode].lsection == "" ||scope.sections.datalist[bcode].lsection == undefined ){
|
||||
scope.sections.datalist[bcode].lsection = acode;
|
||||
}
|
||||
|
||||
if(scope.sections.datalist[ccode].rsection == "" || scope.sections.datalist[ccode].rsection == undefined){
|
||||
scope.sections.datalist[ccode].rsection = acode;
|
||||
}else if(scope.sections.datalist[ccode].lsection == "" || scope.sections.datalist[ccode].lsection == undefined){
|
||||
scope.sections.datalist[ccode].lsection = acode;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
resolve("loadersection");
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
30
src/jlmap3d/edit/railwayModel/rSectionModel.js
Normal file
30
src/jlmap3d/edit/railwayModel/rSectionModel.js
Normal file
@ -0,0 +1,30 @@
|
||||
export function rSectionModel(data) {
|
||||
var scope = this;
|
||||
//命名
|
||||
this.name = null;
|
||||
//code
|
||||
this.code = null;
|
||||
//索引位置
|
||||
this.index = null;
|
||||
//轨迹点
|
||||
this.rail = [];
|
||||
|
||||
this.railline = null;
|
||||
//长度
|
||||
this.distance = [];
|
||||
|
||||
this.isStandTrack = null;
|
||||
|
||||
this.rsection = null;
|
||||
|
||||
this.lsection = null;
|
||||
|
||||
this.type = null;
|
||||
//指向模型
|
||||
this.mesh = null;
|
||||
// //模型地址
|
||||
// this.meshurl = null;
|
||||
// //贴图地址
|
||||
// this.picurl = null;
|
||||
|
||||
}
|
281
src/jlmap3d/edit/railwayModel/rSignalList.js
Normal file
281
src/jlmap3d/edit/railwayModel/rSignalList.js
Normal file
@ -0,0 +1,281 @@
|
||||
import {SignalModel} from '@/jlmap3d/edit/testEditorModel/SignalModel.js';
|
||||
|
||||
export function rSignalList() {
|
||||
|
||||
let scope = this;
|
||||
|
||||
this.type = "signallist";
|
||||
|
||||
this.list = [];
|
||||
|
||||
this.group = new THREE.Group();
|
||||
|
||||
this.initpromise = function(jlmap3ddata,data,scene,assetloader,netdata){
|
||||
return new Promise(function(resolve, reject){
|
||||
scope.group.name = "signal";
|
||||
// console.log(data);
|
||||
//遍历信号数据
|
||||
let netsignal = null;
|
||||
let haddata = false;
|
||||
if(netdata){
|
||||
netsignal = JSON.parse(netdata);
|
||||
haddata = true;
|
||||
}
|
||||
let sectiondata = jlmap3ddata.sectionlist.sections.datalist;
|
||||
let num;
|
||||
for(let j=0;j<assetloader.modellist.length;j++){
|
||||
if(assetloader.modellist[j].deviceType == "signal"){
|
||||
num = j;
|
||||
}
|
||||
}
|
||||
for(let i=0;i<data.length;i++){
|
||||
if(data[i].virtual == false){
|
||||
let newsignal = new SignalModel(data[i]);
|
||||
if(haddata == false){
|
||||
// console.log(data[i])
|
||||
let newmesh = assetloader.modellist[num].mesh.clone(true);
|
||||
|
||||
newmesh.name = data[i].name;
|
||||
newmesh.modelid = assetloader.modellist[num].id;
|
||||
newmesh.code = data[i].code;
|
||||
newmesh.sectionCode = data[i].sectionCode;
|
||||
newmesh.right = data[i].right;
|
||||
newmesh.virtual = data[i].virtual;
|
||||
for(let j=0;j<newmesh.children.length;j++){
|
||||
newmesh.children[j].code = data[i].code;
|
||||
}
|
||||
let section = sectiondata[data[i].sectionCode];
|
||||
let posx = null;
|
||||
if(section.lsection == undefined){
|
||||
section = sectiondata[section.rsection];
|
||||
data[i].sectionOffset = section.lengthFact;
|
||||
data[i].sectionCode = section.rsection;
|
||||
}
|
||||
if(section.rsection == undefined){
|
||||
section = sectiondata[section.lsection];
|
||||
data[i].sectionOffset = 0;
|
||||
data[i].sectionCode = section.rsection;
|
||||
}
|
||||
|
||||
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<assetloader.modellist.length;j++){
|
||||
if(assetloader.modellist[j].id == netsignal[i].modelid){
|
||||
num = j;
|
||||
}
|
||||
}
|
||||
let newmesh = assetloader.modellist[num].mesh.clone(true);
|
||||
|
||||
newmesh.uuid = netsignal[i].id;
|
||||
newmesh.name = netsignal[i].name;
|
||||
newmesh.modelid = assetloader.modellist[num].id;
|
||||
newmesh.code = netsignal[i].code;
|
||||
newmesh.virtual = data[i].virtual;
|
||||
for(let j=0;j<newmesh.children.length;j++){
|
||||
newmesh.children[j].code = netsignal[i].code;
|
||||
}
|
||||
newmesh.position.x = netsignal[i].position.x;
|
||||
newmesh.position.y = netsignal[i].position.y;
|
||||
newmesh.position.z = netsignal[i].position.z;
|
||||
newmesh.rotation.x = netsignal[i].rotation._x;
|
||||
newmesh.rotation.y = netsignal[i].rotation._y;
|
||||
newmesh.rotation.z = netsignal[i].rotation._z;
|
||||
newmesh.scale.x = netsignal[i].scale.x;
|
||||
newmesh.scale.y = netsignal[i].scale.y;
|
||||
newmesh.scale.z = netsignal[i].scale.z;
|
||||
|
||||
|
||||
// newsignal.mesh = newmesh;
|
||||
newsignal.mesh.status = "01";
|
||||
scope.group.add(newmesh);
|
||||
scope.list.push(newsignal);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
scene.add(scope.group);
|
||||
resolve("loadedsignal");
|
||||
});
|
||||
}
|
||||
|
||||
this.loadpromise = function(signaldata,scene,assetloader,data){
|
||||
return new Promise(function(resolve, reject){
|
||||
let num;
|
||||
for(let j=0;j<assetloader.modellist.length;j++){
|
||||
if(assetloader.modellist[j].type == "signal"){
|
||||
num = j;
|
||||
}
|
||||
}
|
||||
for(let i=0;i<signaldata.length;i++){
|
||||
//signaldata[i].virtual == "false"
|
||||
for(let n=0;n<data.length;n++){
|
||||
if(signaldata[i].code == data[n].code){
|
||||
if(data[n].virtual == false){
|
||||
let newsignal = new SignalModel(signaldata[i]);
|
||||
|
||||
// console.log(signaldata[i]);
|
||||
let newmesh = assetloader.modellist[num].mesh.clone(true);
|
||||
newmesh.sectionCode = data[n].sectionCode;
|
||||
newmesh.sectionOffset = data[n].sectionOffset;
|
||||
// newmesh.uuid = signaldata[i].id;
|
||||
for(let j=0;j<newmesh.children.length;j++){
|
||||
newmesh.children[j].code = signaldata[i].code;
|
||||
}
|
||||
newmesh.name = signaldata[i].name;
|
||||
newmesh.modelid = assetloader.modellist[num].id;
|
||||
newmesh.code = signaldata[i].code;
|
||||
newmesh.right = data[n].right;
|
||||
newmesh.virtual = data[n].virtual;
|
||||
newmesh.position.x = signaldata[i].position.x;
|
||||
newmesh.position.y = signaldata[i].position.y;
|
||||
newmesh.position.z = signaldata[i].position.z;
|
||||
newmesh.rotation.x = signaldata[i].rotation._x;
|
||||
newmesh.rotation.y = signaldata[i].rotation._y;
|
||||
newmesh.rotation.z = signaldata[i].rotation._z;
|
||||
newsignal.mesh = newmesh;
|
||||
newsignal.mesh.status = "01";
|
||||
|
||||
scope.group.add(newsignal.mesh);
|
||||
scope.list.push(newsignal);
|
||||
n = data.length;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
scene.add(scope.group);
|
||||
resolve("loadedsignal");
|
||||
});
|
||||
};
|
||||
this.resetsignal = function(jlmap3ddata){
|
||||
// console.log(jlmap3ddata.linksgroup);
|
||||
let sectiondata = jlmap3ddata.sectionlist.sectiongroup.children;
|
||||
for(let i=0;i<scope.group.children.length;i++){
|
||||
let signaldata = scope.group.children[i];
|
||||
|
||||
for(let j=0;j<sectiondata.length;j++){
|
||||
if(sectiondata[j].code == signaldata.sectionCode){
|
||||
let section = sectiondata[j];
|
||||
let posx = null;
|
||||
// console.log(section);
|
||||
|
||||
posx = section.railpoint[0].x + signaldata.sectionOffset;
|
||||
|
||||
//根据线路方向修改信号灯位置
|
||||
if(signaldata.right == false){
|
||||
if(section.standTrack == true){
|
||||
posx = posx - 7;
|
||||
}
|
||||
|
||||
signaldata.position.set(posx,0,section.railpoint[0].z-3);
|
||||
signaldata.rotation.z = ( Math.PI / 2 );
|
||||
}else if(signaldata.right == true){
|
||||
if(section.standTrack == true){
|
||||
posx = posx + 7;
|
||||
}
|
||||
signaldata.position.set(posx,0,section.railpoint[0].z+3);
|
||||
signaldata.rotation.z = ( - Math.PI / 2 );
|
||||
}
|
||||
j = sectiondata.length;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
this.init = function(data,realsectionlist,scene,assetloader){
|
||||
|
||||
|
||||
scope.group.name = "signal";
|
||||
//遍历信号数据
|
||||
for(let i=0;i<data.length;i++){
|
||||
let newsignal = new SignalModel(data);
|
||||
|
||||
let newmesh = assetloader.modellist[0].mesh.clone(true);
|
||||
|
||||
newmesh.name = assetloader.modellist[0].id;
|
||||
newmesh.code = data[i].code;
|
||||
for(let j=0;j<newmesh.children.length;j++){
|
||||
newmesh.children[j].code = data[i].code;
|
||||
}
|
||||
|
||||
//根据线路方向修改信号灯位置
|
||||
if(data[i].directionType == "01"){
|
||||
newmesh.position.set(data[i].position.x,1,data[i].position.y-10);
|
||||
newmesh.rotation.z = ( Math.PI / 2 );
|
||||
}else if(data[i].directionType == "02"){
|
||||
newmesh.position.set(data[i].position.x,1,data[i].position.y+10);
|
||||
newmesh.rotation.z = ( - Math.PI / 2 );
|
||||
}
|
||||
//newmesh.scale.set(0.1,0.1,0.1);
|
||||
newsignal.mesh = newmesh;
|
||||
newsignal.mesh.status = "01";
|
||||
scope.group.add(newsignal.mesh);
|
||||
scope.list.push(newsignal);
|
||||
|
||||
}
|
||||
scene.add(scope.group);
|
||||
}
|
||||
|
||||
this.reposition = function(){
|
||||
|
||||
}
|
||||
|
||||
this.update = function(){
|
||||
|
||||
}
|
||||
|
||||
this.renderon = function(){
|
||||
|
||||
}
|
||||
|
||||
this.renderoff = function(){
|
||||
|
||||
}
|
||||
|
||||
this.dispose = function(){
|
||||
|
||||
}
|
||||
}
|
36
src/jlmap3d/edit/railwayModel/rSignalModel.js
Normal file
36
src/jlmap3d/edit/railwayModel/rSignalModel.js
Normal file
@ -0,0 +1,36 @@
|
||||
export function rSignalModel(data) {
|
||||
|
||||
this.uuid = null;
|
||||
this.code = null;
|
||||
this.name = null;
|
||||
this.modelid = null;
|
||||
this.type = null;
|
||||
this.direction = null;
|
||||
this.ismodel = false;
|
||||
this.istexture = false;
|
||||
this.modelurl = null;
|
||||
// this.textures = {
|
||||
// red:null,
|
||||
// yellor:null,
|
||||
// green:null
|
||||
// }
|
||||
// this.position = {
|
||||
// x:0,
|
||||
// y:0,
|
||||
// z:0
|
||||
// };
|
||||
// this.rotation = {
|
||||
// x:0,
|
||||
// y:0,
|
||||
// z:0
|
||||
// };
|
||||
// this.scale = {
|
||||
// x:0,
|
||||
// y:0,
|
||||
// z:0
|
||||
// }
|
||||
|
||||
this.mesh = null;
|
||||
this.meshurl = null;
|
||||
this.picurl = null;
|
||||
}
|
135
src/jlmap3d/edit/railwayModel/rSwitchList.js
Normal file
135
src/jlmap3d/edit/railwayModel/rSwitchList.js
Normal file
@ -0,0 +1,135 @@
|
||||
import {SwitchModel} from '@/jlmap3d/edit/testEditorModel/SwitchModel.js';
|
||||
|
||||
export function rSwitchList() {
|
||||
|
||||
let scope = this;
|
||||
this.type = "switchlist";
|
||||
|
||||
this.switchgroup = new THREE.Group();
|
||||
this.switchgroup.name = "switch";
|
||||
|
||||
this.switchs = {
|
||||
datalist:[],
|
||||
modellist:[]
|
||||
};
|
||||
|
||||
this.initpromise = function(jlmap3ddata,data,scene,assetloader,netdata){
|
||||
// console.log(jlmap3ddata);
|
||||
return new Promise(function(resolve, reject){
|
||||
scene.add( scope.switchgroup );
|
||||
let sectiondata = jlmap3ddata.sectionlist.sections.datalist;
|
||||
// console.log(sectiondata);
|
||||
let num;
|
||||
for(let j=0;j<assetloader.modellist.length;j++){
|
||||
if(assetloader.modellist[j].deviceType == "autoswitch"){
|
||||
num = j;
|
||||
}
|
||||
};
|
||||
for(let i=0,leni = data.length;i<leni;i++){
|
||||
|
||||
let newswitch = {
|
||||
code:data[i].code,
|
||||
name:data[i].name,
|
||||
pa:data[i].sectionACode,
|
||||
pb:data[i].sectionBCode,
|
||||
pc:data[i].sectionCCode
|
||||
};
|
||||
|
||||
let autoswitch = assetloader.modellist[num].mesh.clone(true);
|
||||
autoswitch.code = data[i].code;
|
||||
scope.switchs.datalist.push(newswitch);
|
||||
scope.switchs.modellist.push(autoswitch);
|
||||
scope.switchgroup.add(autoswitch);
|
||||
if(sectiondata[data[i].sectionACode].mesh.position.x >sectiondata[data[i].sectionBCode].mesh.position.x){
|
||||
autoswitch.position.set(sectiondata[data[i].sectionACode].lp.x,0,sectiondata[data[i].sectionACode].lp.z);
|
||||
autoswitch.rotation.z = Math.PI;
|
||||
}else{
|
||||
autoswitch.position.set(sectiondata[data[i].sectionACode].rp.x,0,sectiondata[data[i].sectionACode].rp.z);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
resolve("loadedswitch");
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
this.loadpromise = function(jlmap3ddata,switchdata,scene,assetloader){
|
||||
return new Promise(function(resolve, reject){
|
||||
scene.add( scope.switchgroup );
|
||||
// let sectiondata = jlmap3ddata.sectionlist.sections.datalist;
|
||||
// console.log(sectiondata);
|
||||
let num;
|
||||
for(let j=0;j<assetloader.modellist.length;j++){
|
||||
if(assetloader.modellist[j].type == "switch"){
|
||||
num = j;
|
||||
}
|
||||
|
||||
if(assetloader.modellist[j].deviceType == "autoswitch"){
|
||||
num = j;
|
||||
}
|
||||
};
|
||||
for(let i=0,leni = switchdata.length;i<leni;i++){
|
||||
// console.log(switchdata[i]);
|
||||
let newswitch = {
|
||||
code:switchdata[i].code,
|
||||
name:switchdata[i].name,
|
||||
pa:switchdata[i].pa,
|
||||
pb:switchdata[i].pb,
|
||||
pc:switchdata[i].pc
|
||||
};
|
||||
|
||||
// console.log(newswitch.pa);
|
||||
let autoswitch = assetloader.modellist[num].mesh.clone(true);
|
||||
autoswitch.code = switchdata[i].code;
|
||||
for(let j=0;j<autoswitch.children.length;j++){
|
||||
autoswitch.children[j].code = switchdata[i].code;
|
||||
}
|
||||
scope.switchs.datalist.push(newswitch);
|
||||
scope.switchs.modellist.push(autoswitch);
|
||||
scope.switchgroup.add(autoswitch);
|
||||
autoswitch.position.set(switchdata[i].position.x,switchdata[i].position.y,switchdata[i].position.z);
|
||||
autoswitch.rotation.x = switchdata[i].rotation._x;
|
||||
autoswitch.rotation.y = switchdata[i].rotation._y;
|
||||
autoswitch.rotation.z = switchdata[i].rotation._z;
|
||||
|
||||
}
|
||||
|
||||
resolve("loadedswitch");
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
this.resetswitch = function(data){
|
||||
// console.log("reset");
|
||||
let sectiondata = data.sectionlist.sectiongroup;
|
||||
for(let i=0;i<scope.switchs.datalist.length;i++){
|
||||
|
||||
let sectionA = sectiondata.getObjectByProperty("code",scope.switchs.datalist[i].pa);
|
||||
let sectionB = sectiondata.getObjectByProperty("code",scope.switchs.datalist[i].pb);
|
||||
|
||||
if(sectionA.railpoint[0].x > sectionB.railpoint[0].x){
|
||||
scope.switchs.modellist[i].position.set(sectionA.railpoint[0].x,0,sectionA.railpoint[0].z);
|
||||
}else{
|
||||
scope.switchs.modellist[i].position.set(sectionA.railpoint[1].x,0,sectionA.railpoint[1].z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.update = function(){
|
||||
|
||||
}
|
||||
|
||||
this.renderon = function(){
|
||||
|
||||
}
|
||||
|
||||
this.renderoff = function(){
|
||||
|
||||
}
|
||||
|
||||
this.dispose = function(){
|
||||
|
||||
}
|
||||
|
||||
}
|
22
src/jlmap3d/edit/railwayModel/rSwitchModel.js
Normal file
22
src/jlmap3d/edit/railwayModel/rSwitchModel.js
Normal file
@ -0,0 +1,22 @@
|
||||
export function rSwitchModel() {
|
||||
|
||||
var scope = this;
|
||||
//命名
|
||||
this.name = null;
|
||||
//code
|
||||
this.code = null;
|
||||
//索引位置
|
||||
this.index = null;
|
||||
//轨迹点
|
||||
this.rail = [];
|
||||
//长度
|
||||
this.distance = null;
|
||||
|
||||
this.action = null;
|
||||
//指向模型
|
||||
this.mesh = null;
|
||||
// //模型地址
|
||||
// this.meshurl = null;
|
||||
// //贴图地址
|
||||
// this.picurl = null;
|
||||
}
|
133
src/jlmap3d/jl3drailwaydrive/drivecontrol/simulation.js
Normal file
133
src/jlmap3d/jl3drailwaydrive/drivecontrol/simulation.js
Normal file
@ -0,0 +1,133 @@
|
||||
import request from '@/utils/request';
|
||||
// 获取仿真成员列表(新版地图)
|
||||
export function getSimulationMembersNew(group) {
|
||||
return request({
|
||||
url: `/simulation/${group}/members`,
|
||||
method: 'get'
|
||||
});
|
||||
}
|
||||
|
||||
// 获取仿真会话消息列表(新版地图)
|
||||
export function getSimulationContextListNew(group, conversationId) {
|
||||
return request({
|
||||
url: `/simulation/${group}/conversation/${conversationId}`,
|
||||
method: 'get'
|
||||
});
|
||||
}
|
||||
|
||||
// 获取客户端已经进入仿真的用户仿真所在group(新版地图)
|
||||
export function getSimulationRunningNew(params) {
|
||||
return request({
|
||||
url: `/simulation/running`,
|
||||
method: 'get',
|
||||
params
|
||||
});
|
||||
}
|
||||
|
||||
// 根据group获取仿真对象(新版地图)
|
||||
export function getSimulationByGroupNew(group) {
|
||||
return request({
|
||||
url: `/simulation/${group}`,
|
||||
method: 'get'
|
||||
});
|
||||
}
|
||||
|
||||
// 获取/创建仿真会话(新版地图)
|
||||
export function getSimulationConversationIdNew(params, group) {
|
||||
return request({
|
||||
url: `/simulation/${group}/wx/conversation`,
|
||||
method: 'get',
|
||||
params: params
|
||||
});
|
||||
}
|
||||
|
||||
// 仿真驾驶车辆列表(新版地图)
|
||||
export function getSimulationTrainlistNew(group) {
|
||||
return request({
|
||||
url: `/simulation/driving/${group}/trainList`,
|
||||
method: 'get',
|
||||
params: ''
|
||||
});
|
||||
}
|
||||
|
||||
// 新版仿真驾驶发送命令
|
||||
export function bindSimulationTrain(group, groupNumber) {
|
||||
return request({
|
||||
url: `/simulation/driving/${group}/bindTrain/${groupNumber}`,
|
||||
method: 'post',
|
||||
params: ''
|
||||
});
|
||||
}
|
||||
// EB紧急制动
|
||||
export function trainSimulationEb(group, data) {
|
||||
return request({
|
||||
url: `/simulation/${group}/operate/Driver_EB`,
|
||||
method: 'post',
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
// 改变列车牵引/制动力
|
||||
export function trainSimulationForce(group,memberId, data) {
|
||||
return request({
|
||||
url: `/common/simulation/${group}/member/${memberId}/operate/Train_Drive_Speed_Control`,
|
||||
method: 'post',
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 改变列车档位
|
||||
export function trainSimulationGear(group, data) {
|
||||
return request({
|
||||
url: `/simulation/${group}/operate/Driver_Gear_Change`,
|
||||
method: 'post',
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
// 改变列车运行级别
|
||||
export function trainSimulationDriveMode(group, data) {
|
||||
return request({
|
||||
url: `/simulation/${group}/operate/Driver_Drive_Mode_Change`,
|
||||
method: 'post',
|
||||
data: data
|
||||
});
|
||||
}
|
||||
// ATP切除
|
||||
// ATO
|
||||
export function trainSimulationAtp(group, data) {
|
||||
return request({
|
||||
url: `/simulation/${group}/operate/Driver_ATP_Change`,
|
||||
method: 'post',
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
// ATO
|
||||
export function trainSimulationAto(group, data) {
|
||||
return request({
|
||||
url: `/simulation/${group}/operate/Driver_ATO_Open`,
|
||||
method: 'post',
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
// 换端
|
||||
export function trainSimulationChangeHead(group, data) {
|
||||
return request({
|
||||
url: `/simulation/${group}/operate/Driver_Change_Head`,
|
||||
method: 'post',
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
//
|
||||
export function trainSimulationDoorControl(group, data) {
|
||||
return request({
|
||||
url: `/simulation/${group}/operate/Driver_Door_On_Off`,
|
||||
method: 'post',
|
||||
data: data
|
||||
});
|
||||
}
|
519
src/jlmap3d/jl3drailwaydrive/jl3drailwaydrive.js
Normal file
519
src/jlmap3d/jl3drailwaydrive/jl3drailwaydrive.js
Normal file
@ -0,0 +1,519 @@
|
||||
import Vue from 'vue';
|
||||
import { JL3D_LOCAL_STATIC } from '@/api/jlmap3d/assets3d.js';
|
||||
// 模型loader
|
||||
import { AssetLoader } from '@/jlmap3d/main/loaders/AssetLoader.js';
|
||||
import {DDSLoader} from '@/jlmap3d/main/loaders/DDSLoader.js';
|
||||
import {OBJLoader} from '@/jlmap3d/main/loaders/OBJLoader.js';
|
||||
import {MTLLoader} from '@/jlmap3d/main/loaders/MTLLoader.js';
|
||||
import { FBXLoader } from '@/jlmap3d/main/loaders/FBXLoader.js';
|
||||
|
||||
// data
|
||||
import { Jl3ddata } from '@/jlmap3d/main/newmodel/jl3ddata';
|
||||
|
||||
// setconfig
|
||||
import { SetCamera } from '@/jlmap3d/config/SetCamera';
|
||||
import { SetRender } from '@/jlmap3d/config/SetRender';
|
||||
import { SetScene } from '@/jlmap3d/config/SetScene';
|
||||
import { SetLights } from '@/jlmap3d/config/SetLights';
|
||||
|
||||
// controls
|
||||
import {OrbitControls} from '@/jlmap3d/main/control/OrbitControls.js';
|
||||
import { DragControls } from '@/jlmap3d/main/control/DragControls.js';
|
||||
|
||||
// 加载器
|
||||
import { DriverLoadNew } from '@/jlmap3d/jl3drailwaydrive/loader/DriverLoadNew';
|
||||
// connect
|
||||
import {Jl3dDrivingNew} from '@/jlmap3d/jl3drailwaydrive/moveupdate/DrivingConnectNew';
|
||||
|
||||
import { getPublishMapVersion, getPublishMapDetail, getPublish3dMapDetail} from '@/api/jlmap3d/load3ddata';
|
||||
|
||||
// utils
|
||||
import { UpdateTrain } from '@/jlmap3d/jl3drailwaydrive/moveupdate/UpdateTrain';
|
||||
// import { UpdateTrain } from '@/jlmap3d/main/utils/UpdateTrainTest';
|
||||
import { ReStart } from '@/jlmap3d/main/utils/ReStart';
|
||||
|
||||
import {Stats} from '@/jlmap3d/main/lib/stats.min.js';
|
||||
|
||||
import {MouseControls} from '@/jlmap3d/main/control/FirstControls';
|
||||
|
||||
var clock = new THREE.Clock();
|
||||
|
||||
export function JLmapDriving(dom,data,mapId,storemod,translation,routegroup,project) {
|
||||
|
||||
let scope = this;
|
||||
let stats =null;
|
||||
// let driverWebWorker = null;
|
||||
// let stats = new Stats();
|
||||
// dom.appendChild( stats.dom );
|
||||
//界面更新函数
|
||||
let updatemmi = {};
|
||||
this.dom = dom;
|
||||
// 渲染循环开关
|
||||
this.animateswitch = false;
|
||||
this.cctvswitch = false;
|
||||
// 初始化webgl渲染
|
||||
let renderer = SetRender(dom);
|
||||
renderer.domElement.style.position = 'absolute';
|
||||
renderer.domElement.style.top = '0';
|
||||
|
||||
var renderercctv = new THREE.WebGLRenderer();
|
||||
renderercctv.setSize(dom.offsetWidth*0.2, dom.offsetHeight*0.2);
|
||||
renderercctv.domElement.style.position = 'absolute';
|
||||
renderercctv.domElement.style.top = '0';
|
||||
|
||||
document.getElementById('jlsimulation').appendChild(renderer.domElement);
|
||||
document.getElementById('jlcctv').appendChild(renderercctv.domElement);
|
||||
// 定义相机
|
||||
//let camera = SetCamera(dom);
|
||||
// 定义场景(渲染容器)
|
||||
let scene = SetScene(project);
|
||||
|
||||
let speed = 0;
|
||||
|
||||
let drivingcode = null;
|
||||
|
||||
// 模型加载器
|
||||
this.assetloader = new AssetLoader();
|
||||
// 替换材质组,例:信号机不同灯光
|
||||
this.materiallist = [];
|
||||
//替换材质组(站台的)
|
||||
this.stationtexture = [];
|
||||
// 初始化场景线框和灯光 暂时
|
||||
SetLights(scene);
|
||||
// 点击选中的模型
|
||||
this.selectmodel = null;
|
||||
// 鼠标点击模型切换
|
||||
this.raycasterswitch = 'stand';
|
||||
// 选中物体描边方框
|
||||
this.helpbox = null;
|
||||
// 车门,站台门道岔动画构造器
|
||||
let mixers = [];
|
||||
// 模型操作命令组
|
||||
this.actions = {};
|
||||
this.nowspeed = null;
|
||||
this.nowmxlen = null;
|
||||
this.atpspeed = null;
|
||||
this.atospeed = null;
|
||||
// this.trainnum = null;
|
||||
this.stime = null;
|
||||
this.drivecount = 0;
|
||||
this.drivedata = null;
|
||||
|
||||
var sectionlist = null;
|
||||
var linklist = null;
|
||||
var signallist = null;
|
||||
var stationstandlist = null;
|
||||
var switchlist = null;
|
||||
var trainlisttest = null;
|
||||
var realsectionlist = null;
|
||||
var rails = null;
|
||||
|
||||
|
||||
this.webwork=new Worker(JL3D_LOCAL_STATIC+'/workertest/trainworker.js');
|
||||
// 地图模型数据
|
||||
let mapdata = new Jl3ddata();
|
||||
|
||||
let camera = new THREE.PerspectiveCamera(70, dom.clientWidth/dom.clientHeight, 0.1, 400000);
|
||||
camera.position.set( 0, 0, 0 );
|
||||
camera.aspect = window.innerWidth / window.innerHeight;
|
||||
camera.updateProjectionMatrix();
|
||||
camera.rotation.x = 0;
|
||||
let listener = new THREE.AudioListener();
|
||||
listener.position.y = -2;
|
||||
camera.add( listener );
|
||||
|
||||
|
||||
let sound = new THREE.Audio( listener );
|
||||
|
||||
// load a sound and set it as the Audio object's buffer
|
||||
// let audioLoader = new THREE.AudioLoader();
|
||||
// audioLoader.load( JL3D_LOCAL_STATIC+'/audio/trainmove.ogg', function( buffer ) {
|
||||
// sound.setBuffer( buffer );
|
||||
// sound.setLoop( true );
|
||||
// sound.setVolume( 0 );
|
||||
// sound.volswitch = false;
|
||||
// sound.play();
|
||||
// });
|
||||
|
||||
let controls3 = new MouseControls(camera, 1.6);
|
||||
controls3.enabled = false;
|
||||
// controls3.getObject().rotation.x = Math.PI/2;
|
||||
scene.add(controls3.getObject());
|
||||
|
||||
let cameracctv = new THREE.PerspectiveCamera(50, dom.clientWidth/dom.clientHeight, 0.1, 50);
|
||||
cameracctv.position.set( -3, 0,4.5 );
|
||||
|
||||
cameracctv.rotation.y = -Math.PI/2;
|
||||
cameracctv.rotation.x = Math.PI/2;
|
||||
// camera.add(cameracctv);
|
||||
|
||||
|
||||
// 初始化加载数据和模型
|
||||
getPublishMapDetail(mapId).then(data => {
|
||||
let mapnetdata = data.data;
|
||||
getPublish3dMapDetail(mapId).then(netdata => {
|
||||
// console.log(netdata);
|
||||
let assetsdata = JSON.parse(netdata.data.sections);
|
||||
|
||||
scope.datatype = "new";
|
||||
// driverWebWorker = new Worker(JL3D_LOCAL_STATIC+"/workertest/railwayWorker.js");
|
||||
scope.Subscribe = new Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup,stats);
|
||||
|
||||
// datanew();
|
||||
|
||||
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();
|
||||
clearInterval(timer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}, 2000);
|
||||
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
// getPublish3dMapDetail(mapId).then(netdata => {
|
||||
// DriverLoad(data, scope, netdata.data, sectionlist,linklist,signallist,stationstandlist,trainlisttest,realsectionlist,rails, camera, controls3, scene,mixers,storemod);
|
||||
// });
|
||||
|
||||
// 开启渲染
|
||||
animate();
|
||||
startWorker();
|
||||
// 动画时间
|
||||
let delta;
|
||||
// 循环渲染函数
|
||||
function animate() {
|
||||
// 循环渲染
|
||||
// requestAnimationFrame(animate);
|
||||
// renderer.setAnimationLoop(animate);
|
||||
requestAnimationFrame(animate);
|
||||
// 判断渲染是否开启
|
||||
if (scope.animateswitch == true) {
|
||||
// 根据相机渲染场景
|
||||
renderer.render(scene, camera);
|
||||
//cctv渲染
|
||||
|
||||
if(scope.cctvswitch == true){
|
||||
renderercctv.render(scene,cameracctv);
|
||||
}
|
||||
|
||||
//相机按键位移
|
||||
// controls3.update();
|
||||
|
||||
// stats.update();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function updatcontrols() {
|
||||
if (drivingcode) {
|
||||
controls3.getObject().position.x = trainlisttest.list[drivingcode].matrixWorld.elements[12]-27;
|
||||
controls3.getObject().position.y=5;
|
||||
controls3.getObject().position.z = trainlisttest.list[drivingcode].children[0].matrixWorld.elements[14]+5;
|
||||
}
|
||||
}
|
||||
|
||||
function startWorker() {
|
||||
|
||||
if (typeof (Worker)!=='undefined') {
|
||||
|
||||
scope.webwork.onmessage = function (event) {
|
||||
// 更新列车位置
|
||||
if(scope.datatype == "old"){
|
||||
UpdateTrain(camera, trainlisttest);
|
||||
}
|
||||
//
|
||||
delta = clock.getDelta();
|
||||
for (let i=mixers.length-1; i>=0; i--) {
|
||||
if(mixers[i]._actions[0].isRunning()){
|
||||
mixers[i].update( delta );
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
updatemmi.updatenowspeed = function(speed) {
|
||||
scope.nowspeed = speed;
|
||||
};
|
||||
updatemmi.updatenowlen = function(maLen) {
|
||||
scope.nowmxlen = maLen;
|
||||
};
|
||||
updatemmi.updateatpspeed = function(atpspeed) {
|
||||
scope.atpspeed = atpspeed;
|
||||
};
|
||||
updatemmi.updateatospeed = function(atospeed) {
|
||||
scope.atospeed = atospeed;
|
||||
};
|
||||
// updatemmi.updatetrainnum = function(trainnum) {
|
||||
// scope.trainnum = trainnum;
|
||||
// };
|
||||
// updatemmi.updatestoptime = function(stime) {
|
||||
// scope.stime = stime;
|
||||
// };
|
||||
// updatemmi.updatedrivedata = function(drivedata) {
|
||||
// scope.drivecount += 1;
|
||||
// scope.drivedata = drivedata;
|
||||
// };
|
||||
|
||||
updatemmi.updatedrivingcode = function(code) {
|
||||
// console.log(trainlisttest);
|
||||
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 = 4.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 = 4.5;
|
||||
controls3.getObject().rotation.x = Math.PI/2;
|
||||
controls3.getObject().rotation.y = -Math.PI/2;
|
||||
};
|
||||
|
||||
this.dispose = function() {
|
||||
renderer.setAnimationLoop(null);
|
||||
renderer.dispose();
|
||||
scene.dispose();
|
||||
// controls.dispose();
|
||||
camera = null;
|
||||
scope.assetloader = null;
|
||||
|
||||
mapdata = null;
|
||||
scope.selectmodel = null;
|
||||
|
||||
scope.materiallist = null;
|
||||
scope.selectmodel = null;
|
||||
scope.helpbox = null;
|
||||
mixers = null;
|
||||
scope.actions = null;
|
||||
scope.Subscribe = null;
|
||||
// sound.stop();
|
||||
scope.webwork.terminate();
|
||||
|
||||
};
|
||||
|
||||
this.rayswitch = function(value) {
|
||||
this.raycasterswitch = value;
|
||||
if (scope.helpbox) {
|
||||
scene.remove( scope.helpbox );
|
||||
scope.helpbox = null;
|
||||
}
|
||||
};
|
||||
|
||||
this.showstationmsg = function(showtype) {
|
||||
if (showtype == 'show') {
|
||||
for (let st=0; st<stationstandlist.group.children.length; st++) {
|
||||
stationstandlist.group.children[st].add(stationstandlist.textlist[st]);
|
||||
}
|
||||
} else {
|
||||
for (let st=0; st<stationstandlist.group.children.length; st++) {
|
||||
stationstandlist.group.children[st].remove(stationstandlist.textlist[st]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.showtrainmsg = function(showtype) {
|
||||
if (showtype == 'show') {
|
||||
for (let st=0; st<trainlisttest.textlist.length; st++) {
|
||||
trainlisttest.list[trainlisttest.textlist[st].tcode].children[0].add(trainlisttest.textlist[st]);
|
||||
}
|
||||
} else {
|
||||
for (let st=0; st<trainlisttest.textlist.length; st++) {
|
||||
trainlisttest.list[trainlisttest.textlist[st].tcode].children[0].remove(trainlisttest.textlist[st]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.restart = function() {
|
||||
ReStart(mapdata);
|
||||
};
|
||||
|
||||
this.animateon = function() {
|
||||
// controls.enabled = false;
|
||||
scope.animateswitch = true;
|
||||
};
|
||||
|
||||
this.animateoff = function() {
|
||||
// controls.enabled = false;
|
||||
scope.animateswitch = false;
|
||||
};
|
||||
|
||||
this.cctvon = function() {
|
||||
scope.cctvswitch = true;
|
||||
};
|
||||
|
||||
this.cctvoff = function() {
|
||||
scope.cctvswitch = false;
|
||||
};
|
||||
|
||||
this.endsocket = function() {
|
||||
scope.Subscribe.socketoff(scope.Subscribe.topic);
|
||||
|
||||
};
|
||||
|
||||
this.loaderdata = function(loadsectionlist,loadlinklist,loadsignallist,loadstationstandlist,loadtrainlisttest,loadrealsectionlist,loadrails){
|
||||
|
||||
sectionlist = loadsectionlist;
|
||||
linklist = loadlinklist;
|
||||
signallist = loadsignallist;
|
||||
stationstandlist = loadstationstandlist;
|
||||
trainlisttest = loadtrainlisttest;
|
||||
realsectionlist = loadrealsectionlist;
|
||||
rails = loadrails;
|
||||
|
||||
console.log(trainlisttest.group);
|
||||
trainlisttest.group.children[0].add(cameracctv);
|
||||
}
|
||||
|
||||
this.eventon = function() {
|
||||
// raycaster交互模型点击事件
|
||||
document.getElementById('jlsimulation').addEventListener( 'mousedown', onselect, false );
|
||||
// 窗口自适应
|
||||
window.addEventListener( 'resize', onWindowResized, false );
|
||||
|
||||
// sound.volswitch = true;
|
||||
// controls.update();
|
||||
};
|
||||
|
||||
this.eventoff = function() {
|
||||
// console.log("off");
|
||||
// raycaster交互模型点击事件
|
||||
document.getElementById('jlsimulation').removeEventListener( 'mousedown', onselect, false );
|
||||
// 窗口自适应
|
||||
window.removeEventListener( 'resize', onWindowResized, false );
|
||||
|
||||
// sound.volswitch = false;
|
||||
// sound.setVolume( 0 );
|
||||
};
|
||||
|
||||
this.updatecamera = function(mesh, type) {
|
||||
|
||||
if (type == 'simulation') {
|
||||
|
||||
camera.position.x = mesh.position.x-300;
|
||||
camera.position.y = 100;
|
||||
camera.position.z = mesh.children[0].position.z;
|
||||
// controls.target = new THREE.Vector3(mesh.position.x,0,mesh.children[0].position.z);
|
||||
}
|
||||
// console.log(mesh);
|
||||
if (type == 'station') {
|
||||
camera.position.x = mesh.position.x;
|
||||
camera.position.y = mesh.position.y+800;
|
||||
camera.position.z = mesh.position.z+300;
|
||||
// 更新相机方向
|
||||
// controls.target = new THREE.Vector3(mesh.position.x,mesh.position.y,mesh.position.z);
|
||||
}
|
||||
if (type == 'train') {
|
||||
camera.position.x = mesh.position.x;
|
||||
camera.position.y = mesh.position.y+800;
|
||||
camera.position.z = mesh.children[2].matrixWorld.elements[14]+300;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
function onWindowResized() {
|
||||
// 窗口自适应
|
||||
camera.aspect = window.innerWidth / window.innerHeight;
|
||||
camera.updateProjectionMatrix();
|
||||
renderer.setSize( window.innerWidth, window.innerHeight );
|
||||
}
|
||||
|
||||
// 三维交互点击事件函数
|
||||
function onselect(event) {
|
||||
if (event.button == '0') {
|
||||
|
||||
// 定义光线
|
||||
let raycaster = new THREE.Raycaster();
|
||||
// 定义平面鼠标点击坐标
|
||||
let mouse = new THREE.Vector2();
|
||||
mouse.x = (event.clientX / window.innerWidth) * 2 - 1;
|
||||
mouse.y = -(event.clientY / window.innerHeight) * 2 + 1;
|
||||
|
||||
raycaster.setFromCamera( mouse, camera );
|
||||
if (scope.helpbox) {
|
||||
scene.remove( scope.helpbox );
|
||||
scope.helpbox = null;
|
||||
}
|
||||
|
||||
if (scope.raycasterswitch == 'stand') {
|
||||
// 从站台对象组获取点击目标
|
||||
let intersects1 = raycaster.intersectObjects( stationstandlist.textlist);
|
||||
// 获取最近处点击到的模型对象
|
||||
if (intersects1[0]) {
|
||||
// 遍历对象组获取对象坐标更新相机数据
|
||||
for (let j=0; j<stationstandlist.list.length; j++) {
|
||||
if (intersects1[0].object.name == stationstandlist.list[j].mesh.code) {
|
||||
camera.position.x = stationstandlist.list[j].mesh.position.x;
|
||||
camera.position.y = stationstandlist.list[j].mesh.position.y+200;
|
||||
camera.position.z = stationstandlist.list[j].mesh.position.z+300;
|
||||
// 更新相机方向
|
||||
// controls.target = new THREE.Vector3(stationstandlist.list[j].mesh.position.x,stationstandlist.list[j].mesh.position.y,stationstandlist.list[j].mesh.position.z);
|
||||
// controls.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (scope.raycasterswitch == 'train') {
|
||||
let intersects = raycaster.intersectObjects( trainlisttest.textlist);
|
||||
if (intersects[0]) {
|
||||
for (let j=0; j<trainlisttest.list.length; j++) {
|
||||
if (intersects[0].object.name == trainlisttest.list[j].name) {
|
||||
camera.position.x = trainlisttest.list[j].position.x;
|
||||
camera.position.y = 200;
|
||||
camera.position.z = trainlisttest.list[j].children[2].matrixWorld.elements[14]+300;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (scope.raycasterswitch == 'section') {
|
||||
// console.log(sectionlist.sections.modellist);
|
||||
let intersects = raycaster.intersectObjects( sectionlist.sections.modellist, true);
|
||||
if (intersects[0]) {
|
||||
|
||||
scope.helpbox = new THREE.BoxHelper( intersects[0].object, 0xff0000 );
|
||||
scene.add( scope.helpbox );
|
||||
}
|
||||
}
|
||||
|
||||
if (scope.raycasterswitch == 'signal') {
|
||||
|
||||
let intersects = raycaster.intersectObjects( signallist.group.children, true);
|
||||
|
||||
if (intersects[0]) {
|
||||
scope.helpbox = new THREE.BoxHelper( intersects[0].object, 0xff0000 );
|
||||
scene.add( scope.helpbox );
|
||||
}
|
||||
}
|
||||
|
||||
if (scope.raycasterswitch == 'switch') {
|
||||
let intersects = raycaster.intersectObjects( sectionlist.switchs.modellist, true);
|
||||
|
||||
if (intersects[0]) {
|
||||
scope.helpbox = new THREE.BoxHelper( intersects[0].object, 0xff0000 );
|
||||
|
||||
scene.add( scope.helpbox );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
176
src/jlmap3d/jl3drailwaydrive/loader/DriverLoadNew.js
Normal file
176
src/jlmap3d/jl3drailwaydrive/loader/DriverLoadNew.js
Normal file
@ -0,0 +1,176 @@
|
||||
//componnent
|
||||
|
||||
|
||||
import {Materialload} from '@/jlmap3d/main/loaders/Materialload.js';
|
||||
|
||||
import {SectionListN} from '@/jlmap3d/main/newmodel/SectionListN';
|
||||
import {SignalListN} from '@/jlmap3d/main/newmodel/SignalListN';
|
||||
import {StationStandListN} from '@/jlmap3d/main/newmodel/StationStandListN';
|
||||
import {SwitchListN} from '@/jlmap3d/main/newmodel/SwitchListN';
|
||||
import {RailListN} from '@/jlmap3d/main/newmodel/RailListN.js';
|
||||
import {TrainListN} from '@/jlmap3d/main/newmodel/TrainListN.js';
|
||||
import {TdtList} from '@/jlmap3d/main/newmodel/TdtList.js';
|
||||
|
||||
import { Loading } from 'element-ui';
|
||||
// import {SwitchModel} from '@/jlmap3d/model/SwitchModel.js';
|
||||
|
||||
export function DriverLoadNew(data,scope,netdata,mapdata,sectionlist,signallist,switchlist,stationstandlist,trainlisttest,rails,camera,controls,scene,mixerss){
|
||||
//console.log(mapdata);
|
||||
|
||||
//console.log(data);
|
||||
//console.log(scope);
|
||||
let sceneload = scene;
|
||||
let backdata = scope;
|
||||
let assetloader = scope.assetloader;
|
||||
let animateswitch = scope.animateswitch;
|
||||
|
||||
let mixers = mixerss;
|
||||
let actions = scope.actions;
|
||||
let linklist,realsectionlist;
|
||||
let loadingInstance = Loading.service({ fullscreen: true });
|
||||
|
||||
let isSection = false;
|
||||
let isNewdata = false;
|
||||
if(netdata.assets){
|
||||
let assetsdata = JSON.parse(netdata.sections);
|
||||
// console.log(assetsdata.link);
|
||||
if(assetsdata.link){
|
||||
isSection = true;
|
||||
}else{
|
||||
isNewdata = true;
|
||||
}
|
||||
}
|
||||
// console.log(isNewdata);
|
||||
// console.log(netdata);
|
||||
if(isNewdata == true){
|
||||
initnew3d(data,netdata);
|
||||
}else{
|
||||
loadingInstance.close();
|
||||
alert("没有三维数据");
|
||||
}
|
||||
|
||||
function initnew3d(data,netdata){
|
||||
Materialload(scope,JSON.parse(netdata.assets).stationTextureList[0]);
|
||||
let mapdata = data;
|
||||
//初始化轨道和道岔
|
||||
sectionlist = new SectionListN();
|
||||
signallist = new SignalListN();
|
||||
switchlist = new SwitchListN();
|
||||
//初始化站台
|
||||
stationstandlist = new StationStandListN();
|
||||
//初始化测试列车
|
||||
trainlisttest = new TrainListN();
|
||||
// realsectionlist = new RealSectionList();
|
||||
|
||||
rails = new RailListN();
|
||||
let tdt = new TdtList();
|
||||
|
||||
let sectiondata = JSON.parse(netdata.sections);
|
||||
let switchdata = JSON.parse(netdata.switchs);
|
||||
let signaldata = JSON.parse(netdata.signals);
|
||||
let standsdata = JSON.parse(netdata.stands);
|
||||
let psddata = data.psdList;
|
||||
|
||||
for(let i=0;i<standsdata.length;i++){
|
||||
for(let j=0;j<mapdata.stationStandList.length;j++){
|
||||
if(standsdata[i].code == mapdata.stationStandList[j].stationCode){
|
||||
standsdata[i].inside = mapdata.stationStandList[j].inside;
|
||||
j = mapdata.stationStandList.length;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
assetloader.setModelListOver(JSON.parse(netdata.assets).sceneAssetList,0,JSON.parse(netdata.assets).others);
|
||||
|
||||
assetloader.assetPromiseOver(sceneload)
|
||||
// .then(function(data){
|
||||
// return stationstandlist.loadpromise(mapdata.stationList,standsdata,psddata,sceneload,assetloader,mixers,actions,"01",JSON.parse(netdata.assets).others);
|
||||
// })
|
||||
.then(function(data){
|
||||
return sectionlist.loadpromise(mapdata.sectionList,sectiondata.section,rails,scene,assetloader);
|
||||
})
|
||||
.then(function(data){
|
||||
return signallist.loadpromise(mapdata.signalList,signaldata,sceneload,assetloader);
|
||||
})
|
||||
.then(function(data){
|
||||
return switchlist.loadpromise(mapdata.switchList,switchdata,sceneload,assetloader,mixers,actions);
|
||||
})
|
||||
.then(function(data){
|
||||
return trainlisttest.drivertrain(mapdata.trainList,sceneload,assetloader,mixers,actions,"01");
|
||||
})
|
||||
// .then(function(data){
|
||||
// //console.log(data);
|
||||
// //console.log(assetloader);
|
||||
// console.log(stationstandlist);
|
||||
// return tdt.initTdt(stationstandlist.list,mapdata.sectionList,rails.sectionrail,sceneload);
|
||||
// })
|
||||
.then(function(data){
|
||||
return new Promise(function(resolve, reject){
|
||||
|
||||
for(let mn=0;mn<scope.assetloader.modellist.length;mn++){
|
||||
if(scope.assetloader.modellist[mn].deviceType && scope.assetloader.modellist[mn].type == "suidao"){
|
||||
// scope.assetloader.modellist[mn].mesh.deviceType = "suidaobg";
|
||||
|
||||
// scope.assetloader.modellist[mn].mesh.position.y = 10;
|
||||
scene.add(scope.assetloader.modellist[mn].mesh);
|
||||
}
|
||||
}
|
||||
|
||||
resolve("loadedsuidao");
|
||||
});
|
||||
})
|
||||
// .then(function(data){
|
||||
// return new Promise(function(resolve, reject){
|
||||
//
|
||||
// if(scope.stationtexture["stationlist"]){
|
||||
// for(let mm=0;mm< stationstandlist.group.children.length;mm++){
|
||||
// let stationname = stationstandlist.group.children[mm].name;
|
||||
// if(stationstandlist.group.children[mm].getObjectByName("zhantailiebiao")){
|
||||
// stationstandlist.group.children[mm].getObjectByName("zhantailiebiao").material.map =scope.stationtexture["stationlist"];
|
||||
// stationstandlist.group.children[mm].getObjectByName("zhantailiebiao").material.map.needsUpdate = true;
|
||||
//
|
||||
// }
|
||||
// if(stationstandlist.group.children[mm].getObjectByName("menkuangyanse")){
|
||||
// stationstandlist.group.children[mm].getObjectByName("menkuangyanse").material.map =scope.stationtexture["pingbimen"];
|
||||
// stationstandlist.group.children[mm].getObjectByName("menkuangyanse").material.map.needsUpdate = true;
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
// if(stationstandlist.group.children[mm].getObjectByName("zhantaiming")){
|
||||
// let newmaterial = stationstandlist.group.children[mm].getObjectByName("zhantaiming").material.clone();
|
||||
// newmaterial.map =scope.stationtexture[stationname];
|
||||
// stationstandlist.group.children[mm].getObjectByName("zhantaiming").material = newmaterial;
|
||||
// stationstandlist.group.children[mm].getObjectByName("zhantaiming").material.map.needsUpdate = true;
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// resolve("mergemodel");
|
||||
// });
|
||||
// })
|
||||
.then(function(data){
|
||||
|
||||
scope.animateswitch = true;
|
||||
backdata.loaderdata(sectionlist,linklist,signallist,stationstandlist,trainlisttest,realsectionlist,rails);
|
||||
scope.Subscribe.updatamap(sectionlist,linklist,signallist,stationstandlist,trainlisttest,realsectionlist,rails,tdt,scope.materiallist,scope.actions,scope.sceneload);
|
||||
scope.webwork.postMessage("on");
|
||||
loadingInstance.close();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function onProgress( xhr ) {
|
||||
|
||||
if ( xhr.lengthComputable ) {
|
||||
let percentComplete = xhr.loaded / xhr.total * 100;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function onError() {}
|
||||
|
||||
|
||||
}
|
874
src/jlmap3d/jl3drailwaydrive/moveupdate/DrivingConnectNew.js
Normal file
874
src/jlmap3d/jl3drailwaydrive/moveupdate/DrivingConnectNew.js
Normal file
@ -0,0 +1,874 @@
|
||||
import StompClient from '@/utils/sock';
|
||||
|
||||
import { getBaseUrl } from '@/utils/baseUrl'
|
||||
import { getToken } from '@/utils/auth';
|
||||
|
||||
// 定于仿真socket接口
|
||||
export function Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup,stats) {
|
||||
|
||||
let scope = this;
|
||||
this.map = null;
|
||||
var trainlisttest = null;
|
||||
var sectionlist = null;
|
||||
var signallist = null;
|
||||
var stationstandlist = null;
|
||||
var sectionlist = null;
|
||||
var materials = null;
|
||||
var actions = null;
|
||||
var rails = null;
|
||||
var links = null;
|
||||
let tdt = null;
|
||||
|
||||
let trainmodel = null;
|
||||
var scenes = null;
|
||||
|
||||
var code = null;
|
||||
|
||||
var drivingcode = null;
|
||||
var drivingspeed = null;
|
||||
var drivingaptspeed = null;
|
||||
|
||||
let driverswitch = false;
|
||||
|
||||
let stoptimer = null;
|
||||
let num = 30;
|
||||
let pointstand = null;
|
||||
// run as plane = 01;
|
||||
// reset = 02;
|
||||
var datatype = '00';
|
||||
this.teststomp = new StompClient();
|
||||
// let toppic = '/app/topic/simulation/client/'+routegroup+'/drive';
|
||||
console.log(routegroup);
|
||||
this.topic = '/user/queue/simulation/'+routegroup+'/trainPosition';
|
||||
let header = {'X-Token': getToken() };
|
||||
let connectmsg = {
|
||||
type:'init',
|
||||
baseurl:getBaseUrl(),
|
||||
topic:this.topic,
|
||||
token:getToken(),
|
||||
};
|
||||
|
||||
//切换车辆修改列车属性
|
||||
function changeNowTrain(data){
|
||||
if(data[i][3] == "0"){
|
||||
|
||||
if(data.rightDoorCanClose == false){
|
||||
trainmodel.openright = '0';
|
||||
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{
|
||||
trainmodel.openright = "1";
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(data.leftDoorCanClose == false){
|
||||
trainmodel.openleft = "0";
|
||||
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();
|
||||
}
|
||||
}else{
|
||||
trainmodel.openleft = "1";
|
||||
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(data.leftDoorCanClose == false){
|
||||
|
||||
trainmodel.openleft = "0";
|
||||
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();
|
||||
}
|
||||
}else{
|
||||
trainmodel.openleft = "1";
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
if(data.rightDoorCanClose == false){
|
||||
trainmodel.openright = '0';
|
||||
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{
|
||||
trainmodel.openright = "1";
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
this.updatamap = function(newsectionlist,newlinklist,newsignallist,newstationstandlist,newtrainlisttest,newrealsectionlist,newrails,newtdt, materiallist, nowaction, scene) {
|
||||
// console.log(mapdata);
|
||||
// console.log(newtrainlisttest);
|
||||
trainmodel = newtrainlisttest.group.children[0];
|
||||
trainlisttest = newtrainlisttest;
|
||||
sectionlist = newsectionlist;
|
||||
signallist = newsignallist;
|
||||
stationstandlist = newstationstandlist;
|
||||
materials = materiallist;
|
||||
scenes = scene;
|
||||
actions = nowaction;
|
||||
links = newlinklist;
|
||||
rails = newrails;
|
||||
tdt = newtdt;
|
||||
};
|
||||
|
||||
this.initdrivercode = function(code) {
|
||||
drivingcode = code;
|
||||
};
|
||||
|
||||
this.socketon = function() {
|
||||
try {
|
||||
// console.log("teststomp");
|
||||
scope.teststomp.subscribe(scope.topic, callback, header);
|
||||
} catch (error) {
|
||||
console.error('websocket订阅失败');
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
this.socketoff = function() {
|
||||
scope.teststomp.unsubscribe(scope.topic);
|
||||
for (let i=0; i<trainlisttest.group.children.length; i++) {
|
||||
if (trainlisttest.group.children[i].dispose == false) {
|
||||
code = trainlisttest.group.children[i].name;
|
||||
trainmodel.rotation.y = 0;
|
||||
trainmodel.doorStatus = '01';
|
||||
trainmodel.speed = 0;
|
||||
trainlisttest.group.children[i].dispose = true;
|
||||
trainlisttest.group.children[i].position.x = -50000;
|
||||
trainlisttest.group.children[i].position.y = -50000;
|
||||
trainlisttest.group.remove(trainlisttest.group.children[i]);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 仿真socket接口回调函数
|
||||
function callback(Response) {
|
||||
// console.log(Response);
|
||||
// 对象化数据
|
||||
|
||||
let data = JSON.parse(Response.body);
|
||||
if(data.trainPosList){
|
||||
// console.log(data.trainPosList);
|
||||
// console.log(data.trainPosList);
|
||||
nowTrainRun(data.trainPosList);
|
||||
return;
|
||||
}
|
||||
// stats.update();
|
||||
// 遍历后台数据
|
||||
// console.log(data);
|
||||
|
||||
|
||||
}
|
||||
|
||||
function DeviceDestroy(data){
|
||||
// console.log(data);
|
||||
for(let i=0,leni=data.length;i<leni;i++){
|
||||
|
||||
if(data[i].type == "SIGNAL"){
|
||||
signalupdate(data[i]);
|
||||
}
|
||||
if(data[i].type == "SWITCH"){
|
||||
switchupdate(data[i]);
|
||||
}
|
||||
if(data[i].type == "PSD"){
|
||||
standupdate(data[i]);
|
||||
}
|
||||
if(data[i].type == "TRAIN_DOOR"){
|
||||
traindoorupdate(data[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function tdtUpdate(data){
|
||||
|
||||
tdt.updateTdt(data.body);
|
||||
}
|
||||
|
||||
function otherTrainRun(data){
|
||||
if(data.length > trainlisttest.otherTrainmodels.length && trainlisttest.updatStatus == false){
|
||||
trainlisttest.addDriveTrain(data);
|
||||
}else if(data.length < trainlisttest.otherTrainmodels.length){
|
||||
|
||||
let removelength = trainlisttest.otherTrainmodels.length - data.length;
|
||||
trainlisttest.removeDriveTrain(removelength);
|
||||
}else{
|
||||
|
||||
for(let i=0,leni=data.length;i<leni;i++){
|
||||
let updateTrain = trainlisttest.otherTrainmodels[i];
|
||||
|
||||
if(data[i].code != trainmodel.code){
|
||||
|
||||
otherTrainUpdate(data[i],updateTrain);
|
||||
}else{
|
||||
updateTrain.position.x = -99999;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
function otherTrainUpdate(data,updateTrainModel){
|
||||
// console.log(data);
|
||||
// if(data.code = "336"){
|
||||
// console.log(data);
|
||||
// }
|
||||
|
||||
if(data.section != updateTrainModel.nowsection){
|
||||
updateTrainModel.nowsection = data.section;
|
||||
updateTrainModel.curve = rails.sectionrail[data.section].lineleft;
|
||||
}
|
||||
|
||||
if(updateTrainModel.right != data[i][3]){
|
||||
if(data[i][3] == "0"){
|
||||
updateTrainModel.right = "0";
|
||||
updateTrainModel.rotation.y = Math.PI;
|
||||
let point = updateTrainModel.curve.getPointAt(data[i][2]);
|
||||
updateTrainModel.position.x = point.x;
|
||||
for (let tl=0; tl<updateTrainModel.children.length; tl++) {
|
||||
updateTrainModel.children[tl].position.z = point.z;
|
||||
}
|
||||
}else{
|
||||
updateTrainModel.right = "1";
|
||||
updateTrainModel.rotation.y = 0;
|
||||
let point = updateTrainModel.curve.getPointAt(data[i][2]);
|
||||
updateTrainModel.position.x = point.x;
|
||||
for (let tl=0; tl<updateTrainModel.children.length; tl++) {
|
||||
updateTrainModel.children[tl].position.z = point.z;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(updateTrainModel.curve && updateTrainModel.offset != data[i][2]){
|
||||
updateTrainModel.offset = data[i][2];
|
||||
let pos = updateTrainModel.curve.getPointAt(data[i][2]);
|
||||
updateTrainModel.position.x = pos.x;
|
||||
// trainmodel.children[0].position.z = pos.z;
|
||||
if(data[i][3] == "0"){
|
||||
if(-updateTrainModel.children[0].position.z != pos.z){
|
||||
updateTrainModel.children[0].up = new THREE.Vector3(1,0,0);
|
||||
let tangent = updateTrainModel.curve.getTangentAt(data[i][2]).normalize();
|
||||
updateTrainModel.children[0].axis.crossVectors(updateTrainModel.children[0].up, tangent).normalize();
|
||||
let radians = Math.acos(updateTrainModel.children[0].up.dot(tangent));
|
||||
updateTrainModel.children[0].quaternion.setFromAxisAngle(updateTrainModel.children[0].axis, radians);
|
||||
updateTrainModel.children[0].rotation.x = -Math.PI/2;
|
||||
updateTrainModel.children[0].rotation.z = updateTrainModel.children[0].rotation.y;
|
||||
updateTrainModel.children[0].rotation.y = 0;
|
||||
|
||||
let rotas = {
|
||||
posr:pos,
|
||||
rota:updateTrainModel.children[0].rotation.z
|
||||
}
|
||||
updateTrainModel.children[1].rotalist.push(rotas);
|
||||
let offsetz = pos.z + updateTrainModel.children[0].position.z;
|
||||
updateTrainModel.children[0].position.z -= offsetz;
|
||||
// trainmodel.position.z = point.z;
|
||||
|
||||
}
|
||||
// if(updateTrainModel.children[1].rotalist.length > 0 || updateTrainModel.children[2].rotalist.length > 0 || updateTrainModel.children[3].rotalist.length > 0 || updateTrainModel.children[4].rotalist.length > 0|| updateTrainModel.children[5].rotalist.length > 0){
|
||||
|
||||
for(let rs = 1;rs<updateTrainModel.children.length;rs++){
|
||||
//console.log(rs);
|
||||
if(updateTrainModel.children[rs].rotalist[0]){
|
||||
|
||||
let offsetz = parseFloat(updateTrainModel.children[rs].rotalist[0].posr.z) + parseFloat(updateTrainModel.children[rs].position.z);
|
||||
updateTrainModel.children[rs].position.z -= offsetz;
|
||||
|
||||
for(let xh=0;xh<updateTrainModel.children[rs].rotalist.length;xh++){
|
||||
if((updateTrainModel.children[rs].matrixWorld.elements[12]+10)>=updateTrainModel.children[rs].rotalist[0].posr.x){
|
||||
|
||||
if(rs != updateTrainModel.children.length-1){
|
||||
let asd = updateTrainModel.children[rs].rotalist[0];
|
||||
updateTrainModel.children[rs+1].rotalist.push(asd);
|
||||
|
||||
}
|
||||
//let offsetx = trainmodel.children[1].matrixWorld.elements[12]-trainmodel.children[0].children[3].matrixWorld.elements[12];
|
||||
|
||||
updateTrainModel.children[rs].rotation.z = updateTrainModel.children[rs].rotalist[0].rota;
|
||||
updateTrainModel.children[rs].rotalist.splice(0,1)
|
||||
xh--;
|
||||
}else{
|
||||
xh = updateTrainModel.children[rs].rotalist.length;
|
||||
}
|
||||
}
|
||||
//console.log(trainmodel.children[rs].rotalist.length);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// console.log(trainmodel.rotalist);
|
||||
// }
|
||||
|
||||
}else{
|
||||
//
|
||||
if(updateTrainModel.children[0].position.z < pos.z){
|
||||
updateTrainModel.children[0].up = new THREE.Vector3(-1,0,0);
|
||||
let tangent = updateTrainModel.curve.getTangentAt(data[i][2]).normalize();
|
||||
updateTrainModel.children[0].axis.crossVectors(updateTrainModel.children[0].up, tangent).normalize();
|
||||
let radians = Math.acos(updateTrainModel.children[0].up.dot(tangent));
|
||||
updateTrainModel.children[0].quaternion.setFromAxisAngle(updateTrainModel.children[0].axis, radians);
|
||||
updateTrainModel.children[0].rotation.x = -Math.PI/2;
|
||||
updateTrainModel.children[0].rotation.z = updateTrainModel.children[0].rotation.y;
|
||||
updateTrainModel.children[0].rotation.y = 0;
|
||||
let rotas = {
|
||||
posr:pos,
|
||||
rota:updateTrainModel.children[0].rotation.z
|
||||
}
|
||||
updateTrainModel.children[1].rotalist.push(rotas);
|
||||
|
||||
|
||||
let offsetz = parseFloat(pos.z) - parseFloat(updateTrainModel.children[0].position.z);
|
||||
updateTrainModel.children[0].position.z += offsetz;
|
||||
}else if(updateTrainModel.children[0].position.z > pos.z){
|
||||
updateTrainModel.children[0].up = new THREE.Vector3(1,0,0);
|
||||
let tangent = updateTrainModel.curve.getTangentAt(data[i][2]).normalize();
|
||||
updateTrainModel.children[0].axis.crossVectors(updateTrainModel.children[0].up, tangent).normalize();
|
||||
let radians = Math.acos(updateTrainModel.children[0].up.dot(tangent));
|
||||
updateTrainModel.children[0].quaternion.setFromAxisAngle(updateTrainModel.children[0].axis, radians);
|
||||
updateTrainModel.children[0].rotation.x = -Math.PI/2;
|
||||
updateTrainModel.children[0].rotation.z = updateTrainModel.children[0].rotation.y;
|
||||
updateTrainModel.children[0].rotation.y = 0;
|
||||
let rotas = {
|
||||
posr:pos,
|
||||
rota:updateTrainModel.children[0].rotation.z
|
||||
}
|
||||
updateTrainModel.children[1].rotalist.push(rotas);
|
||||
|
||||
|
||||
let offsetz = parseFloat(pos.z) - parseFloat(updateTrainModel.children[0].position.z);
|
||||
updateTrainModel.children[0].position.z += offsetz;
|
||||
}
|
||||
|
||||
|
||||
// if(updateTrainModel.children[1].rotalist.length > 0 || updateTrainModel.children[2].rotalist.length > 0 || updateTrainModel.children[3].rotalist.length > 0 || updateTrainModel.children[4].rotalist.length > 0|| updateTrainModel.children[5].rotalist.length > 0){
|
||||
for(let rs = 1;rs<updateTrainModel.children.length;rs++){
|
||||
//console.log(rs);
|
||||
if(updateTrainModel.children[rs].rotalist[0]){
|
||||
let offsetz = parseFloat(updateTrainModel.children[rs].rotalist[0].posr.z) - parseFloat(updateTrainModel.children[rs].matrixWorld.elements[14]);
|
||||
|
||||
updateTrainModel.children[rs].position.z += offsetz;
|
||||
|
||||
for(let xh=0;xh<updateTrainModel.children[rs].rotalist.length;xh++){
|
||||
if((updateTrainModel.children[rs].matrixWorld.elements[12]-10)<=updateTrainModel.children[rs].rotalist[0].posr.x){
|
||||
|
||||
if(rs != updateTrainModel.children.length-1){
|
||||
let asd = updateTrainModel.children[rs].rotalist[0];
|
||||
updateTrainModel.children[rs+1].rotalist.push(asd);
|
||||
|
||||
}
|
||||
|
||||
updateTrainModel.children[rs].rotation.z = updateTrainModel.children[rs].rotalist[0].rota;
|
||||
updateTrainModel.children[rs].rotalist.splice(0,1)
|
||||
xh--;
|
||||
}else{
|
||||
xh = updateTrainModel.children[rs].rotalist.length;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//更新当前驾驶车辆
|
||||
function nowTrainRun(data){
|
||||
console.log(data);
|
||||
for(let i=0;i<data.length;i++){
|
||||
//改变当前列车code
|
||||
if(data[0][0] != trainmodel.code){
|
||||
if(trainlisttest.otherTrainList[trainmodel.code] && trainmodel.code){
|
||||
trainlisttest.otherTrainList[trainmodel.code].offset = 0;
|
||||
}
|
||||
|
||||
trainmodel.code = data[0][0];
|
||||
trainmodel.nowcode = data[0][0];
|
||||
}
|
||||
|
||||
//改变当前列车行驶的区段code
|
||||
if(data[i][1] != trainmodel.nowsection){
|
||||
trainmodel.nowsection = data[i][1] ;
|
||||
trainmodel.curve = rails.sectionrail[data[i][1]].lineleft;
|
||||
}
|
||||
|
||||
//判断转向
|
||||
if(trainmodel.right != data[i][3] ){
|
||||
|
||||
if(data[i][3] == "0"){
|
||||
trainmodel.right = "0";
|
||||
trainmodel.rotation.y = Math.PI;
|
||||
let point = trainmodel.curve.getPointAt(data[i][2] );
|
||||
trainmodel.position.x = point.x;
|
||||
for (let tl=0; tl<trainmodel.children.length; tl++) {
|
||||
trainmodel.children[tl].position.z = point.z;
|
||||
}
|
||||
}else{
|
||||
trainmodel.right = "1";
|
||||
trainmodel.rotation.y = 0;
|
||||
let point = trainmodel.curve.getPointAt(data[i][2] );
|
||||
trainmodel.position.x = point.x;
|
||||
for (let tl=0; tl<trainmodel.children.length; tl++) {
|
||||
trainmodel.children[tl].position.z = point.z;
|
||||
}
|
||||
|
||||
if(trainmodel.openleft == "1"){
|
||||
trainmodel.openleft = "0";
|
||||
for(let an=actions["traindoor"].top.length-1;an>=0;an--){
|
||||
actions["traindoor"].top[an].stop();
|
||||
}
|
||||
trainmodel.openright = "1";
|
||||
for(let an=actions["traindoor"].down.length-1;an>=0;an--){
|
||||
actions["traindoor"].down[an].reset();
|
||||
actions["traindoor"].down[an].time = actions["traindoor"].down[an]._clip.duration;
|
||||
actions["traindoor"].down[an].timeScale = 1;
|
||||
actions["traindoor"].down[an].play();
|
||||
}
|
||||
}else if(trainmodel.openright == "1"){
|
||||
trainmodel.openright = "0";
|
||||
for(let an=actions["traindoor"].down.length-1;an>=0;an--){
|
||||
actions["traindoor"].down[an].stop();
|
||||
}
|
||||
trainmodel.openleft = "1";
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if(trainmodel.curve && trainmodel.offset != data[i][2]){
|
||||
trainmodel.offset = data[i][2];
|
||||
let pos = trainmodel.curve.getPointAt(data[i][2]);
|
||||
trainmodel.position.x = pos.x;
|
||||
// trainmodel.children[0].position.z = pos.z;
|
||||
if(data[i][3] == "0"){
|
||||
if(-trainmodel.children[0].position.z != pos.z || trainmodel.children[0].position.y != pos.y){
|
||||
trainmodel.children[0].up = new THREE.Vector3(1,0,0);
|
||||
let tangent = trainmodel.curve.getTangentAt(data[i][2]).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;
|
||||
let newRotationZ = trainmodel.children[0].rotation.z;
|
||||
trainmodel.children[0].rotation.z = trainmodel.children[0].rotation.y;
|
||||
trainmodel.children[0].rotation.y = -newRotationZ;
|
||||
|
||||
let rotas = {
|
||||
posr:pos,
|
||||
roty:trainmodel.children[0].rotation.y,
|
||||
rotz:trainmodel.children[0].rotation.z
|
||||
}
|
||||
let offsetz = pos.z + trainmodel.children[0].position.z;
|
||||
trainmodel.children[0].position.z -= offsetz;
|
||||
|
||||
}
|
||||
|
||||
}else{
|
||||
//
|
||||
let rotas = {
|
||||
posr:null,
|
||||
roty:null,
|
||||
rotz:null,
|
||||
};
|
||||
if(trainmodel.children[0].position.z < pos.z ){
|
||||
trainmodel.children[0].up = new THREE.Vector3(-1,0,0);
|
||||
let tangent = trainmodel.curve.getTangentAt(data[i][2]).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;
|
||||
|
||||
rotas.posr = pos;
|
||||
// rotas.roty = trainmodel.children[0].rotation.y;
|
||||
rotas.rotz = trainmodel.children[0].rotation.z;
|
||||
|
||||
let offsetz = parseFloat(pos.z) - parseFloat(trainmodel.children[0].position.z);
|
||||
trainmodel.children[0].position.z += offsetz;
|
||||
}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[i][2]).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;
|
||||
|
||||
rotas.posr = pos;
|
||||
// rotas.roty = trainmodel.children[0].rotation.y;
|
||||
rotas.rotz = trainmodel.children[0].rotation.z;
|
||||
|
||||
let offsetz = parseFloat(pos.z) - parseFloat(trainmodel.children[0].position.z);
|
||||
trainmodel.children[0].position.z += offsetz;
|
||||
}
|
||||
|
||||
if(trainmodel.children[0].position.y != pos.y){
|
||||
if(rotas.posr == null){
|
||||
trainmodel.children[0].up = new THREE.Vector3(-1,0,0);
|
||||
let tangent = trainmodel.curve.getTangentAt(data[i][2]).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;
|
||||
|
||||
rotas.posr = pos;
|
||||
rotas.roty = trainmodel.children[0].rotation.y;
|
||||
rotas.rotz = trainmodel.children[0].rotation.z;
|
||||
|
||||
let offsetz = parseFloat(pos.z) - parseFloat(trainmodel.children[0].position.z);
|
||||
trainmodel.children[0].position.z += offsetz;
|
||||
let offsety = parseFloat(pos.y) - parseFloat(trainmodel.children[0].position.y);
|
||||
trainmodel.children[0].position.y += offsety;
|
||||
}else{
|
||||
rotas.roty = trainmodel.children[0].rotation.y;
|
||||
let offsety = parseFloat(rotas.posr.y) - parseFloat(trainmodel.children[0].position.y);
|
||||
trainmodel.children[0].position.y += offsety;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function initall(data){
|
||||
for(let i=0,leni=data.length;i<leni;i++){
|
||||
if(data[i].deviceType == "SWITCH"){
|
||||
initswitch(data[i]);
|
||||
}
|
||||
if(data[i].deviceType == "PSD"){
|
||||
initstand(data[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function traindoorupdate(data){
|
||||
// console.log(data);
|
||||
// console.log("direct:"+trainmodel.right);
|
||||
// console.log(trainmodel.openleft);
|
||||
// console.log(trainmodel.openright);
|
||||
if(trainmodel.code == data.code){
|
||||
|
||||
if(trainmodel.right == "0"){
|
||||
if(data.doorCode == "2"){
|
||||
|
||||
if(trainmodel.openleft != data.open && data.open == "0"){
|
||||
trainmodel.openleft = "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.openleft != data.open && data.open == "1"){
|
||||
trainmodel.openleft = "1";
|
||||
console.log(data);
|
||||
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();
|
||||
}
|
||||
}
|
||||
}else{
|
||||
|
||||
|
||||
if (trainmodel.openright != data.open && data.open == '0') {
|
||||
trainmodel.openright = '0';
|
||||
for (let an=actions["traindoor"].down.length-1; an>=0; an--) {
|
||||
actions["traindoor"].down[an].reset();
|
||||
actions["traindoor"].down[an].time = actions["traindoor"].down[an]._clip.duration;
|
||||
actions["traindoor"].down[an].timeScale = -1;
|
||||
actions["traindoor"].down[an].play();
|
||||
}
|
||||
} else if (trainmodel.openright != data.open && data.open == '1') {
|
||||
trainmodel.openright = "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(data.doorCode == "1"){
|
||||
|
||||
if(trainmodel.openleft != data.open && data.open == "0"){
|
||||
trainmodel.openleft = "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.openleft != data.open && data.open == "1"){
|
||||
trainmodel.openleft = "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();
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if (trainmodel.openright != data.open && data.open == '0') {
|
||||
trainmodel.openright = '0';
|
||||
for (let an=actions["traindoor"].down.length-1; an>=0; an--) {
|
||||
actions["traindoor"].down[an].reset();
|
||||
actions["traindoor"].down[an].time = actions["traindoor"].down[an]._clip.duration;
|
||||
actions["traindoor"].down[an].timeScale = -1;
|
||||
actions["traindoor"].down[an].play();
|
||||
}
|
||||
} else if (trainmodel.openright != data.open && data.open == '1') {
|
||||
trainmodel.openright = "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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function trainstatus(data){
|
||||
// 遍历列车对象组
|
||||
if (trainlisttest) {
|
||||
|
||||
code = data.code;
|
||||
// 剔除不显示的车
|
||||
// 找到对应列车
|
||||
if ( trainmodel) {
|
||||
|
||||
trainmodel.driveMode = data.driveMode;
|
||||
trainmodel.status = data[i][3];
|
||||
// 车门开关验证
|
||||
|
||||
|
||||
// 遍历获取所在轨道
|
||||
if (trainmodel.dispose != data.dispose && data.dispose == "0") {
|
||||
if (rails.sectionrail[data.sectionCode]) {
|
||||
|
||||
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(trainmodel.mixerpush == false){
|
||||
for(let mi=0,lenmi=trainmodel.mixer.length;mi<lenmi;mi++){
|
||||
jlmap3d.mixers.push(trainmodel.mixer[mi]);
|
||||
}
|
||||
trainmodel.mixerpush = true;
|
||||
}
|
||||
}
|
||||
} else if (trainmodel.dispose != data.dispose && data.dispose == "1") {
|
||||
trainmodel.status = 1;
|
||||
trainlisttest.group.remove(trainmodel);
|
||||
trainmodel.progress = null;
|
||||
trainmodel.dispose = "1";
|
||||
code = trainlisttest.group.children[i].name;
|
||||
trainmodel.rotation.y = 0;
|
||||
trainmodel.openleft = '1';
|
||||
trainmodel.openright = '1';
|
||||
trainmodel.curve = null;
|
||||
trainmodel.nextcurve = null;
|
||||
trainmodel.speed = 0;
|
||||
trainmodel.position.x = -50000;
|
||||
trainmodel.position.y = -50000;
|
||||
trainmodel.pc = 1;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function initstand(data) {
|
||||
code = data.code;
|
||||
if ( actions[code]) {
|
||||
if (data.close == '1') {
|
||||
actions[code].status = '1';
|
||||
actions[code].action.reset();
|
||||
actions[code].action.time = 0;
|
||||
actions[code].action.timeScale = 1;
|
||||
actions[code].action.play();
|
||||
}
|
||||
if (data.close == '0') {
|
||||
actions[code].status = '0';
|
||||
actions[code].action.reset();
|
||||
actions[code].action.time = actions[code].action._clip.duration;
|
||||
actions[code].action.timeScale = -1;
|
||||
actions[code].action.play();
|
||||
}
|
||||
}
|
||||
}
|
||||
function standupdate(data) {
|
||||
code = data.code;
|
||||
if ( actions[code]) {
|
||||
if (data.open == '1') {
|
||||
actions[code].status = '1';
|
||||
actions[code].action.reset();
|
||||
actions[code].action.time = 0;
|
||||
actions[code].action.timeScale = 1;
|
||||
actions[code].action.play();
|
||||
}
|
||||
if (data.open == '0') {
|
||||
actions[code].status = '0';
|
||||
actions[code].action.reset();
|
||||
actions[code].action.time = actions[code].action._clip.duration;
|
||||
actions[code].action.timeScale = -1;
|
||||
actions[code].action.play();
|
||||
}
|
||||
}
|
||||
}
|
||||
function signalupdate(data) {
|
||||
code = data.code;
|
||||
if(data.red == 1){
|
||||
signallist.list[code].mesh.getObjectByName("red").material.map = materials[0];
|
||||
signallist.list[code].mesh.getObjectByName("red").material.map.needsUpdate = true;
|
||||
}else{
|
||||
signallist.list[code].mesh.getObjectByName("red").material.map = materials[3];
|
||||
signallist.list[code].mesh.getObjectByName("red").material.map.needsUpdate = true;
|
||||
}
|
||||
|
||||
if(data.yellow == 1){
|
||||
signallist.list[code].mesh.getObjectByName("yellow").material.map = materials[1];
|
||||
signallist.list[code].mesh.getObjectByName("yellow").material.map.needsUpdate = true;
|
||||
|
||||
}else{
|
||||
signallist.list[code].mesh.getObjectByName("yellow").material.map = materials[3];
|
||||
signallist.list[code].mesh.getObjectByName("yellow").material.map.needsUpdate = true;
|
||||
|
||||
}
|
||||
|
||||
if(data.green == 1){
|
||||
signallist.list[code].mesh.getObjectByName("green").material.map = materials[2];
|
||||
signallist.list[code].mesh.getObjectByName("green").material.map.needsUpdate = true;
|
||||
|
||||
}else{
|
||||
signallist.list[code].mesh.getObjectByName("green").material.map = materials[3];
|
||||
signallist.list[code].mesh.getObjectByName("green").material.map.needsUpdate = true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function initswitch(data) {
|
||||
code = data.code;
|
||||
if (data.routeLock == '0') {
|
||||
// sectionlist.switchs.modellist[j].normal = data.normal;
|
||||
actions[code].action.reset();
|
||||
actions[code].action.time = 0;
|
||||
actions[code].action.timeScale = 1;
|
||||
actions[code].action.play();
|
||||
actions[code].normal = "02";
|
||||
} else if (data.routeLock == '1') {
|
||||
// sectionlist.switchs.modellist[j].normal = data.normal;
|
||||
actions[code].action.reset();
|
||||
actions[code].action.time = actions[code].action._clip.duration;
|
||||
actions[code].action.timeScale = -1;
|
||||
actions[code].action.play();
|
||||
actions[code].normal = "01";
|
||||
}
|
||||
}
|
||||
|
||||
function switchupdate(data) {
|
||||
code = data.code;
|
||||
if (actions[code].normal != data.normal) {
|
||||
if (data.normal == '02') {
|
||||
// sectionlist.switchs.modellist[j].normal = data.normal;
|
||||
actions[code].action.reset();
|
||||
actions[code].action.time = 0;
|
||||
actions[code].action.timeScale = 1;
|
||||
actions[code].action.play();
|
||||
actions[code].normal = "02";
|
||||
} else if (data.normal == '01') {
|
||||
// sectionlist.switchs.modellist[j].normal = data.normal;
|
||||
actions[code].action.reset();
|
||||
actions[code].action.time = actions[code].action._clip.duration;
|
||||
actions[code].action.timeScale = -1;
|
||||
actions[code].action.play();
|
||||
actions[code].normal = "01";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function simulationreset(data){
|
||||
for(let i=0;i<trainlisttest.group.children.length;i++){
|
||||
trainlisttest.group.children[i].dispose = true;
|
||||
trainlisttest.group.children[i].stopstation = null;
|
||||
trainlisttest.group.children[i].pc = null;
|
||||
trainlisttest.group.children[i].targetpercent = null;
|
||||
trainlisttest.group.children[i].progress = null;
|
||||
trainlisttest.group.children[i].linkOffsetPercent = null;
|
||||
trainlisttest.group.children[i].targetLink = null;
|
||||
trainlisttest.group.remove(trainlisttest.group.children[i]);
|
||||
i--;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
307
src/jlmap3d/jl3drailwaydrive/moveupdate/UpdateTrain.js
Normal file
307
src/jlmap3d/jl3drailwaydrive/moveupdate/UpdateTrain.js
Normal file
@ -0,0 +1,307 @@
|
||||
|
||||
export function UpdateTrain(camera,traindata,control){
|
||||
|
||||
if(traindata != undefined && traindata.group.children[0]){//traindata.group.children[0].dispose == false
|
||||
|
||||
if(traindata.group.children[0].progress != null){
|
||||
// console.log(traindata.group);
|
||||
let trainmodel = traindata.group.children[0];
|
||||
if(trainmodel.speeds > 0 && trainmodel.speeds){
|
||||
let speed = null;
|
||||
// console.log(traindata.group.children[0].progress);
|
||||
if(traindata.group.children[0].progress >=0&&traindata.group.children[0].progress<=1){
|
||||
|
||||
let movecurve = trainmodel.curve;
|
||||
|
||||
if(trainmodel.status == "03" && movecurve.points.length>1){
|
||||
|
||||
let point = movecurve.getPointAt(traindata.group.children[0].progress);
|
||||
trainmodel.position.x = point.x;
|
||||
trainmodel.position.y = 0;
|
||||
if(Math.abs( point.z -trainmodel.children[0].matrixWorld.elements[14]) >0.005){
|
||||
trainmodel.children[0].up = new THREE.Vector3(-1,0,0);
|
||||
let tangent = movecurve.getTangentAt(traindata.group.children[0].progress).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:point,
|
||||
rota:trainmodel.children[0].rotation.z
|
||||
}
|
||||
trainmodel.children[1].rotalist.push(rotas);
|
||||
|
||||
let offsetz = parseFloat(trainmodel.children[0].matrixWorld.elements[14]) - parseFloat(point.z);
|
||||
trainmodel.children[0].position.z += offsetz;
|
||||
|
||||
// trainmodel.position.z = point.z;
|
||||
}
|
||||
|
||||
trainmodel.position.x = point.x;
|
||||
trainmodel.position.y = 0;
|
||||
|
||||
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].matrixWorld.elements[14]) - parseFloat(trainmodel.children[rs].rotalist[0].posr.z);
|
||||
|
||||
trainmodel.children[rs].position.z += offsetz;
|
||||
|
||||
for(let xh=0;xh<trainmodel.children[rs].rotalist.length;xh++){
|
||||
if((trainmodel.children[rs].matrixWorld.elements[12]-10)<=trainmodel.children[rs].rotalist[0].posr.x){
|
||||
|
||||
if(rs != 5){
|
||||
let asd = trainmodel.children[rs].rotalist[0];
|
||||
trainmodel.children[rs+1].rotalist.push(asd);
|
||||
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
trainmodel.progress += trainmodel.speeds;
|
||||
|
||||
}
|
||||
|
||||
if(trainmodel.status == "02" && movecurve.points.length>1){
|
||||
let point = movecurve.getPointAt(trainmodel.progress);
|
||||
trainmodel.position.x = point.x;
|
||||
trainmodel.position.y = 0;
|
||||
if(Math.abs( point.z -trainmodel.children[0].matrixWorld.elements[14]) >0.005){
|
||||
trainmodel.children[0].up = new THREE.Vector3(1,0,0);
|
||||
let tangent = movecurve.getTangentAt(traindata.group.children[0].progress).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:point,
|
||||
rota:trainmodel.children[0].rotation.z
|
||||
}
|
||||
trainmodel.children[1].rotalist.push(rotas);
|
||||
let offsetz = parseFloat(point.z) - parseFloat(trainmodel.children[0].matrixWorld.elements[14]);
|
||||
|
||||
trainmodel.children[0].position.z += offsetz;
|
||||
// trainmodel.position.z = point.z;
|
||||
}
|
||||
trainmodel.position.x = point.x;
|
||||
trainmodel.position.y = 0;
|
||||
|
||||
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<trainmodel.children[rs].rotalist.length;xh++){
|
||||
if((trainmodel.children[rs].matrixWorld.elements[12]+10)>=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);
|
||||
}
|
||||
trainmodel.progress += trainmodel.speeds;
|
||||
}
|
||||
|
||||
}else{
|
||||
if(trainmodel.nextcurve){
|
||||
// if(trainmodel.status == '02'){
|
||||
// }else if(trainmodel.status == '03'){
|
||||
// }
|
||||
trainmodel.progress = 0;
|
||||
trainmodel.len = trainmodel.nextlen;
|
||||
trainmodel.nowcode = trainmodel.nextcode;
|
||||
trainmodel.speeds = parseFloat(trainmodel.speed*10/36/25/trainmodel.len);
|
||||
trainmodel.curve = trainmodel.nextcurve;
|
||||
trainmodel.nextcurve = null;
|
||||
trainmodel.nextlen = null;
|
||||
trainmodel.nextcode = null;
|
||||
}
|
||||
|
||||
// console.log(trainmodel.name);
|
||||
// console.log(trainmodel.progress);
|
||||
// console.log(trainmodel.nextcurve);
|
||||
// if(trainmodel.status == "02"){
|
||||
// trainmodel.progress = 0;
|
||||
// }else if(trainmodel.status == "03"){
|
||||
// trainmodel.progress = 1;
|
||||
// }
|
||||
// trainmodel.curve = trainmodel.nextcurve;
|
||||
|
||||
}
|
||||
|
||||
}else if(trainmodel.speeds < 0 && trainmodel.speeds){
|
||||
let speed = null;
|
||||
if(traindata.group.children[0].progress >=0&&traindata.group.children[0].progress<=1){
|
||||
|
||||
let movecurve = trainmodel.curve;
|
||||
|
||||
if(trainmodel.status == "03" && trainmodel.progress>0 && movecurve.points.length>1){
|
||||
let point = movecurve.getPointAt(traindata.group.children[0].progress);
|
||||
if(Math.abs( point.z -trainmodel.children[0].matrixWorld.elements[14]) >0.005){
|
||||
trainmodel.children[0].up = new THREE.Vector3(-1,0,0);
|
||||
let tangent = movecurve.getTangentAt(traindata.group.children[0].progress).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:point,
|
||||
rota:trainmodel.children[0].rotation.z
|
||||
}
|
||||
trainmodel.children[1].rotalist.push(rotas);
|
||||
|
||||
let offsetz = parseFloat(trainmodel.children[0].matrixWorld.elements[14]) - parseFloat(point.z);
|
||||
trainmodel.children[0].position.z += offsetz;
|
||||
//trainmodel.position.z = point.z;
|
||||
}
|
||||
|
||||
trainmodel.position.x = point.x;
|
||||
trainmodel.position.y = 0;
|
||||
|
||||
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].matrixWorld.elements[14]) - parseFloat(trainmodel.children[rs].rotalist[0].posr.z);
|
||||
|
||||
trainmodel.children[rs].position.z += offsetz;
|
||||
|
||||
for(let xh=0;xh<trainmodel.children[rs].rotalist.length;xh++){
|
||||
if((trainmodel.children[rs].matrixWorld.elements[12]-9)<=trainmodel.children[rs].rotalist[0].posr.x){
|
||||
|
||||
if(rs != 5){
|
||||
let asd = trainmodel.children[rs].rotalist[0];
|
||||
trainmodel.children[rs+1].rotalist.push(asd);
|
||||
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(trainmodel.progress > -(trainmodel.speeds)){
|
||||
trainmodel.progress += trainmodel.speeds;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(trainmodel.status == "02" && movecurve.points.length>1 && trainmodel.progress>0){
|
||||
|
||||
let point = movecurve.getPointAt(trainmodel.progress);
|
||||
if(Math.abs( point.z -trainmodel.children[0].matrixWorld.elements[14]) >0.005){
|
||||
trainmodel.children[0].up = new THREE.Vector3(1,0,0);
|
||||
let tangent = movecurve.getTangentAt(traindata.group.children[0].progress).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:point,
|
||||
rota:trainmodel.children[0].rotation.z
|
||||
}
|
||||
trainmodel.children[1].rotalist.push(rotas);
|
||||
let offsetz = parseFloat(point.z) - parseFloat(trainmodel.children[0].matrixWorld.elements[14]);
|
||||
trainmodel.children[0].position.z += offsetz;
|
||||
//trainmodel.position.z = point.z;
|
||||
}
|
||||
|
||||
trainmodel.position.x = point.x;
|
||||
trainmodel.position.y = 0;
|
||||
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<trainmodel.children[rs].rotalist.length;xh++){
|
||||
if((trainmodel.children[rs].matrixWorld.elements[12]+6)>=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);
|
||||
}
|
||||
|
||||
// console.log(trainmodel.nextcurve);
|
||||
if(trainmodel.progress > -(trainmodel.speeds)){
|
||||
trainmodel.progress += trainmodel.speeds;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// }
|
||||
|
||||
}
|
@ -589,7 +589,7 @@ export function AssetLoader(){
|
||||
// node.frustumCulled = true;
|
||||
//});
|
||||
|
||||
if(asset.deviceType == "train"){
|
||||
if(asset.deviceType == "train" ){
|
||||
|
||||
let realtrain = new THREE.Group();
|
||||
for(let j=6;j>0;j--){
|
||||
@ -665,10 +665,12 @@ export function AssetLoader(){
|
||||
//object.traverse(function (node) {//获取其中对象
|
||||
// node.frustumCulled = true;
|
||||
//});
|
||||
console.log(asset.type);
|
||||
console.log(object);
|
||||
if(asset.code){
|
||||
scope.modelgroup[asset.code] = object;
|
||||
}else{
|
||||
if(asset.type == "train"){
|
||||
if(asset.type == "train" && object.children.length>4){
|
||||
|
||||
let realtrain = new THREE.Group();
|
||||
let j = object.children.length;
|
||||
@ -687,6 +689,11 @@ export function AssetLoader(){
|
||||
asset.mesh = realtrain;
|
||||
asset.animations = object.animations[0].tracks;
|
||||
|
||||
}else if(asset.type == "train" && object.name == "C6"){
|
||||
let realtrain = new THREE.Group();
|
||||
object.position.x = object.position.x+scope.trainoffset;
|
||||
realtrain.add(object);
|
||||
asset.mesh = realtrain;
|
||||
}else{
|
||||
asset.mesh = object;
|
||||
|
||||
|
@ -2,9 +2,9 @@ export function getBaseUrl() {
|
||||
let BASE_API;
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
// BASE_API = 'https://joylink.club/jlcloud';
|
||||
BASE_API = 'https://test.joylink.club/jlcloud';
|
||||
// BASE_API = 'https://test.joylink.club/jlcloud';
|
||||
// BASE_API = 'http://192.168.8.107:9000'; // 袁琪
|
||||
// BASE_API = 'http://192.168.3.83:9000'; // 旭强 有线
|
||||
BASE_API = 'http://192.168.3.83:9000'; // 旭强 有线
|
||||
// BASE_API = 'http://192.168.8.114:9000'; // 旭强 无线
|
||||
// BASE_API = 'http://192.168.3.120:9000'; // 张赛
|
||||
// BASE_API = 'http://192.168.8.140:9000'; // 杜康
|
||||
|
@ -249,11 +249,12 @@ export default {
|
||||
if (this.loadingProjectList.includes(this.project)) {
|
||||
this.$store.dispatch('app/transitionAnimations');
|
||||
}
|
||||
if (this.currentPrdType === '02' && this.courseModel.lineCode === '14') {
|
||||
this.$router.push({ path: `/displayBaSiDi/demon`, query: query });
|
||||
} else {
|
||||
this.$router.push({ path: `${UrlConfig.displayNew}/demon`, query: query });
|
||||
}
|
||||
// if (this.currentPrdType === '02' && this.courseModel.lineCode === '14') {
|
||||
// this.$router.push({ path: `/displayBaSiDi/demon`, query: query });
|
||||
// } else {
|
||||
// this.$router.push({ path: `${UrlConfig.displayNew}/demon`, query: query });
|
||||
// }
|
||||
this.$router.push({ path: `${UrlConfig.displayNew}/demon`, query: query });
|
||||
launchFullscreen();
|
||||
}).catch(error=>{
|
||||
if (error.code == 10003) {
|
||||
|
436
src/views/jlmap3d/railwaydrive/drivecontrol/centerpane.vue
Normal file
436
src/views/jlmap3d/railwaydrive/drivecontrol/centerpane.vue
Normal file
@ -0,0 +1,436 @@
|
||||
<template>
|
||||
<div style="width:100%;height:50%;position:absolute;bottom:4%">
|
||||
<div id="start" class="panebutton2" style="bottom:1%;left:5%;" >
|
||||
<img class="buttonimg2" :src="start" />
|
||||
</div>
|
||||
|
||||
<div id="direct" class="panebutton2" style="bottom:1%;left:25%;">
|
||||
<img class="buttonimg2" :src="direct" />
|
||||
<img id="directimg" class="buttonimg2" :src="directoffpng" :style="{transform:toutransform}" @mousedown="touchstart" />
|
||||
<div class="directbutton" style="top:0px;right:0;">{{ $t('jlmap3d.front') }}</div>
|
||||
<div class="directbutton" style="top:18px;right:0;">0</div>
|
||||
<div class="directbutton" style="top:36px;right:0;">{{ $t('jlmap3d.later') }}</div>
|
||||
</div>
|
||||
|
||||
<div id="div1" class ="pane-box">
|
||||
<img class="paneimg" :src="pane"/>
|
||||
<div class="panelb" :style="{right: isZh? '80px': '80px', top: isZh? '0px': '0px'}">{{ $t('jlmap3d.traction') }}</div>
|
||||
<div class="panelb" :style="{right: isZh? '80px': '80px', top: '70px'}">0</div>
|
||||
<div class="panelb" :style="{right: isZh? '80px': '80px', top: isZh? '130px': '130px'}">{{ $t('jlmap3d.braking') }}</div>
|
||||
<div class="panelb" :style="{right: isZh? '80px': '80px', top: isZh? '145px': '145px'}">{{ $t('jlmap3d.quick') }}</div>
|
||||
<img id="div2" class="lgimg" :src="lg" :style="{top:movex}" @mousedown="speedstart" />
|
||||
<!-- @mouseup="speedend" -->
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { JL3D_LOCAL_STATIC } from '@/api/jlmap3d/assets3d.js';
|
||||
import { trainSimulationForce,trainSimulationGear } from '@/jlmap3d/jl3drailwaydrive/drivecontrol/simulation.js';
|
||||
|
||||
import store from '@/store/index';
|
||||
import { throttle } from '@/utils/throttle.js';
|
||||
export default {
|
||||
name: 'CentercPane',
|
||||
components: {
|
||||
|
||||
},
|
||||
props: {
|
||||
groupNum: {
|
||||
type: String,
|
||||
default: null
|
||||
},
|
||||
userRole: {
|
||||
type: String,
|
||||
default: null
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
move:0,
|
||||
movex:"73px",
|
||||
apoimg:"",
|
||||
touchcontrol:true,
|
||||
touchstate:"Neutral",
|
||||
toutransform:"rotate(175deg)",
|
||||
start:JL3D_LOCAL_STATIC+"/jl3d/control/start.png",
|
||||
direct:JL3D_LOCAL_STATIC+"/jl3d/control/direct.png",
|
||||
directz:JL3D_LOCAL_STATIC+"/jl3d/control/directfront.png",
|
||||
directoffpng:JL3D_LOCAL_STATIC+"/jl3d/control/directoff.png",
|
||||
pane:JL3D_LOCAL_STATIC+"/jl3d/control/pane.png",
|
||||
lg:JL3D_LOCAL_STATIC+"/jl3d/control/lg.png",
|
||||
|
||||
iconrotate:45,//旋转deg
|
||||
icontranslateX:100,//沿x轴位移px
|
||||
icontranslateY:100,//沿y轴位移px
|
||||
mouseX:0,
|
||||
mouseY:0,
|
||||
objX:0,
|
||||
objY:0,
|
||||
isDown:false,
|
||||
|
||||
angleoffset: {
|
||||
x: null,
|
||||
y: null
|
||||
},
|
||||
movelimit: {
|
||||
x: null,
|
||||
y: null
|
||||
},
|
||||
moveheight:null,
|
||||
speedlimit:160,
|
||||
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
// move:function(val,oldval) {
|
||||
// if(val != oldval){
|
||||
// let command ={
|
||||
// code:this.groupNum,
|
||||
// operation:"602",
|
||||
// type:"07",
|
||||
// param:val
|
||||
// };
|
||||
// // if(this.drawWay == 'true'){
|
||||
// throttle(trainSimulationForce(this.group,this.groupNum,val),200,true);
|
||||
// //
|
||||
// // }else{
|
||||
// // throttle(sendSimulationCommand(this.group,command),200,true);
|
||||
// // }
|
||||
//
|
||||
// }
|
||||
// },
|
||||
touchstate:function(val,oldval){
|
||||
if(val != oldval){
|
||||
// if(this.userRole == "DRIVER"){
|
||||
// trainSimulationGear(this.group,this.groupNum,this.touchstate).then(netdata => {
|
||||
//
|
||||
// });
|
||||
// }
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
group() {
|
||||
return this.$route.query.group;
|
||||
},
|
||||
code() {
|
||||
return this.$store.state.app.code;
|
||||
},
|
||||
traincode() {
|
||||
return this.$store.state.app.driverTrain;
|
||||
},
|
||||
atostate(){
|
||||
return this.$store.state.app.atostate;
|
||||
},
|
||||
iconstyle:function(){//图标动态样式
|
||||
let arr = new Array();
|
||||
arr.push('transform:');//注意:先移动后旋转,实现原地旋转;先旋转后移动,位置按照旋转后的新坐标系确定
|
||||
arr.push('translateX('+this.icontranslateX+'px) ');
|
||||
arr.push('translateY('+this.icontranslateY+'px) ');
|
||||
arr.push('rotate('+this.iconrotate+'deg) ');
|
||||
return arr.join("");
|
||||
},
|
||||
isZh() {
|
||||
return this._i18n.locale == 'zh';
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
|
||||
},
|
||||
beforeDestroy() {
|
||||
|
||||
},
|
||||
methods: {
|
||||
centerstate : function(gear){
|
||||
this.touchstate = gear;
|
||||
if(this.touchstate == "Drive"){
|
||||
this.toutransform = "rotate(140deg)";
|
||||
}else if(this.touchstate == "Neutral"){
|
||||
this.toutransform = "rotate(175deg)";
|
||||
}else if(this.touchstate == "Reverse"){
|
||||
this.toutransform = "rotate(205deg)";
|
||||
}
|
||||
},
|
||||
centercontrol : function(){
|
||||
|
||||
},
|
||||
setData : function(){
|
||||
this.msgshow = false;
|
||||
},
|
||||
showcontrolmsg:function(data,callback){
|
||||
this.controlmsg = data;
|
||||
this.msgshow = true;
|
||||
|
||||
callback = callback || function(){
|
||||
this.setData();
|
||||
};
|
||||
setTimeout( callback.bind(this),2000);
|
||||
|
||||
},
|
||||
startclick: function (e){
|
||||
this.showcontrolmsg(this.$t('jlmap3d.drive'));
|
||||
},
|
||||
onChange: function(e){
|
||||
this.move = e.detail.x;
|
||||
},
|
||||
|
||||
controlsend:function(traincode,operation,type,param){
|
||||
if(this.userRole == "Driver"){
|
||||
let command ={
|
||||
code:traincode,
|
||||
operation:operation,
|
||||
type:type,
|
||||
param:param
|
||||
};
|
||||
// sendSimulationCommand(this.group,command);
|
||||
}else{
|
||||
|
||||
}
|
||||
},
|
||||
speedstart: function(event){
|
||||
let domoffset = document.getElementById("div1").getBoundingClientRect();
|
||||
// movelimit
|
||||
this.movelimit.x = domoffset.x;
|
||||
this.movelimit.y = domoffset.y;
|
||||
event.preventDefault();
|
||||
document.getElementById("div1").onmousemove = this.speedchange;
|
||||
document.getElementById("div2").onmouseup = this.speedend;
|
||||
},
|
||||
speedchange: function(event){
|
||||
this.moveheight = event.pageY-this.movelimit.y;
|
||||
this.movex = this.moveheight-7 +"px";
|
||||
// if(this.atostate == true){
|
||||
// this.$store.dispatch('app/setAtoState', false);
|
||||
// }
|
||||
if(this.moveheight<=1){
|
||||
this.moveheight=1;
|
||||
this.movex=-6+"px";
|
||||
}
|
||||
if(this.moveheight>=159){
|
||||
this.moveheight=159;
|
||||
this.movex=153+"px";
|
||||
}
|
||||
if(this.moveheight<86&&this.moveheight>73){
|
||||
this.movex=72+"px";
|
||||
this.move = 0;
|
||||
}else if(this.moveheight<0&&this.moveheight>159){
|
||||
|
||||
}else{
|
||||
|
||||
if(this.moveheight>=86){
|
||||
this.move = -(this.moveheight-82)/65;
|
||||
}
|
||||
if(this.moveheight<=73){
|
||||
this.move = (73 - this.moveheight)/75;
|
||||
}
|
||||
this.movex=this.moveheight-7+"px";
|
||||
if(this.moveheight>=145){
|
||||
this.movex= 150+"px";
|
||||
this.move = -1;
|
||||
}
|
||||
|
||||
}
|
||||
let param = {
|
||||
// id:this.groupNum,
|
||||
id:"001",
|
||||
p:parseInt(this.move*100)
|
||||
};
|
||||
console.log(param.p);
|
||||
const userInfo = store.state.training.simulationUserList.find(el => el.id == store.state.user.id);
|
||||
console.log(this.group);
|
||||
console.log(userInfo.memberId);
|
||||
throttle(
|
||||
trainSimulationForce(this.group,userInfo.memberId,param).then(res => {
|
||||
// console.log(res);
|
||||
}).catch((error) => {
|
||||
console.log(error);
|
||||
})
|
||||
,200,true);
|
||||
// updatemmic1(param.percent);
|
||||
},
|
||||
speedend: function(event){
|
||||
document.getElementById("div1").onmousemove = null;
|
||||
document.getElementById("div2").onmouseup = null;
|
||||
},
|
||||
|
||||
|
||||
|
||||
click:function(){//图标点击事件
|
||||
if (this.iconrotate==0) {
|
||||
this.iconrotate=315;
|
||||
}else {
|
||||
this.iconrotate=0;
|
||||
}
|
||||
},
|
||||
touchstart:function(e){
|
||||
|
||||
|
||||
let domoffset = document.getElementById("directimg").getBoundingClientRect();
|
||||
// movelimit
|
||||
this.angleoffset.x = domoffset.x;
|
||||
this.angleoffset.y = domoffset.y;
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
document.getElementById("directimg").onmousemove = this.touchmove;
|
||||
document.getElementById("directimg").onmouseup = this.touchend;
|
||||
|
||||
|
||||
},
|
||||
touchmove:function(e){//finger move 触发
|
||||
// console.log(e);
|
||||
this.getAngle(e.pageX-this.angleoffset.x ,e.pageY-this.angleoffset.y);
|
||||
},
|
||||
touchend:function(e){
|
||||
document.getElementById("directimg").onmousemove = null;
|
||||
document.getElementById("directimg").onmouseup = null;
|
||||
},
|
||||
getAngle:function(mx,my){
|
||||
//圆心坐标
|
||||
// console.log(mx);
|
||||
// console.log(my);
|
||||
let px=30;
|
||||
let py=30;
|
||||
let x = Math.abs(px-mx);
|
||||
let y = Math.abs(py-my);
|
||||
let z = Math.sqrt(Math.pow(x,2)+Math.pow(y,2));
|
||||
let cos = y/z;
|
||||
let radina = Math.acos(cos);//用反三角函数求弧度
|
||||
let angle = Math.floor(180/(Math.PI/radina));//将弧度转换成角度
|
||||
|
||||
if(mx>px&&my>py){//鼠标在第四象限
|
||||
angle = 180 - angle;
|
||||
}
|
||||
|
||||
if(mx==px&&my>py){//鼠标在y轴负方向上
|
||||
angle = 180;
|
||||
}
|
||||
|
||||
if(mx>px&&my==py){//鼠标在x轴正方向上
|
||||
angle = 90;
|
||||
}
|
||||
|
||||
if(mx<px&&my>py){//鼠标在第三象限
|
||||
angle = 180+angle;
|
||||
}
|
||||
|
||||
if(mx<px&&my==py){//鼠标在x轴负方向
|
||||
angle = 270;
|
||||
}
|
||||
|
||||
if(mx<px&&my<py){//鼠标在第二象限
|
||||
angle = 360 - angle;
|
||||
}
|
||||
console.log(angle);
|
||||
console.log(this.userRole );
|
||||
if(angle<127 && angle>46){
|
||||
if(angle<63 && angle>46){
|
||||
if(this.touchstate != "Drive"){
|
||||
let data = {
|
||||
groupNumber:this.groupNum,
|
||||
gear:"Drive"
|
||||
};
|
||||
trainSimulationGear(this.group,data).then(netdata => {
|
||||
console.log(netdata);
|
||||
if(netdata.code == "200"){
|
||||
this.toutransform = "rotate(140deg)";
|
||||
this.touchstate = "Drive";
|
||||
document.getElementById("directimg").onmousemove = null;
|
||||
document.getElementById("directimg").onmouseup = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}else if(angle<93 && angle>68){
|
||||
if(this.touchstate != "Neutral"){
|
||||
let data = {
|
||||
groupNumber:this.groupNum,
|
||||
gear:"Neutral"
|
||||
};
|
||||
trainSimulationGear(this.group,data).then(netdata => {
|
||||
if(netdata.code == "200"){
|
||||
this.toutransform = "rotate(175deg)";
|
||||
this.touchstate = "Neutral";
|
||||
document.getElementById("directimg").onmousemove = null;
|
||||
document.getElementById("directimg").onmouseup = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}else if(angle<127 && angle>101){
|
||||
if(this.touchstate != "Reverse"){
|
||||
let data = {
|
||||
groupNumber:this.groupNum,
|
||||
gear:"Reverse"
|
||||
};
|
||||
trainSimulationGear(this.group,data).then(netdata => {
|
||||
if(netdata.code == "200"){
|
||||
this.toutransform = "rotate(205deg)";
|
||||
this.touchstate = "Reverse";
|
||||
document.getElementById("directimg").onmousemove = null;
|
||||
document.getElementById("directimg").onmouseup = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style >
|
||||
.pane-box{
|
||||
right: 30px;
|
||||
top: 0px;
|
||||
width:120px;
|
||||
height:160px;
|
||||
overflow: hidden;
|
||||
position: absolute;
|
||||
|
||||
}
|
||||
.lgimg{
|
||||
width: 60px;
|
||||
right:4px;
|
||||
bottom:0px;
|
||||
height: 15px;
|
||||
position: absolute;
|
||||
cursor:pointer;
|
||||
}
|
||||
|
||||
.panelb {
|
||||
position: absolute;
|
||||
font-size: 24rpx;
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
/* transform: rotate(90deg); */
|
||||
}
|
||||
.paneimg{
|
||||
position: absolute;
|
||||
right: 0px;
|
||||
bottom: 0px;
|
||||
width:100px;
|
||||
height:160px;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
|
||||
.directbutton{
|
||||
color:#FFFFFF;
|
||||
font-size: 13px;
|
||||
position:absolute;
|
||||
}
|
||||
|
||||
.tfbutton{
|
||||
color:#000000;
|
||||
font-size: 1px;
|
||||
position:absolute;
|
||||
}
|
||||
|
||||
</style>
|
457
src/views/jlmap3d/railwaydrive/drivecontrol/drivecontrol.vue
Normal file
457
src/views/jlmap3d/railwaydrive/drivecontrol/drivecontrol.vue
Normal file
@ -0,0 +1,457 @@
|
||||
<template>
|
||||
<div class="drivepane" :style="{'background-image': 'url('+localStatic+'/jl3d/control/scene.png)'}">
|
||||
|
||||
|
||||
<div style="position: absolute;right:50%;top:50%;z-index:10;background: #EBEBEB;" v-show="tuoguanbutton" @click="tuoguan">{{ tuoguanbuttonmsg }}</div>
|
||||
<div style="position: absolute;right:50%;top:60%;z-index:10;background: #EBEBEB;" v-show="isTraining" >
|
||||
<el-select v-model="value" :placeholder="initMsg" @change="currentsel" @visible-change="clickselect" >
|
||||
<el-option
|
||||
v-for="item in options"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
:disabled="item.disabled"
|
||||
>
|
||||
</el-option>
|
||||
</el-select>
|
||||
</div>
|
||||
|
||||
<Centerc-Pane ref="centercontrol" :group-num="groupnum" :user-role="userrole" />
|
||||
|
||||
<!-- <Left-Pane ref="leftcontrol" /> -->
|
||||
|
||||
<!-- <Right-Pane ref="rightcontrol" /> -->
|
||||
|
||||
<TopRight-Pane ref="topcontrol" :group-num="groupnum" />
|
||||
|
||||
|
||||
|
||||
<!--
|
||||
|
||||
|
||||
<div class="switchpane" style="left:0;top:47.5%;transform: rotate(90deg);" v-show="switchleft" @tap="switchl">
|
||||
<image class="switchimg" :src="jiantou" />
|
||||
</div>
|
||||
|
||||
<div class="switchpane" style="left:47.5%;top:0;transform: rotate(180deg);" v-show="switchtop" @tap="switcht">
|
||||
<image class="switchimg" :src="jiantou" />
|
||||
</div>
|
||||
|
||||
<div class="switchpane" style="right:0;top:47.5%;transform: rotate(270deg);" v-show="switchright" @tap="switchr">
|
||||
<image class="switchimg" :src="jiantou" />
|
||||
</div>
|
||||
|
||||
<div class="switchpane" style="right:47.5%;bottom:0;" v-show="switchbottom" @tap="switchb">
|
||||
<image class="switchimg" :src="jiantou" />
|
||||
</div> -->
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { JL3D_LOCAL_STATIC } from '@/api/jlmap3d/assets3d.js';
|
||||
|
||||
import CentercPane from '@/views/jlmap3d/railwaydrive/drivecontrol/centerpane';
|
||||
import LeftPane from '@/views/jlmap3d/railwaydrive/drivecontrol/leftpane';
|
||||
import RightPane from '@/views/jlmap3d/railwaydrive/drivecontrol/rightpane';
|
||||
import TopRightPane from '@/views/jlmap3d/railwaydrive/drivecontrol/toprightpane';
|
||||
|
||||
import StompClient from '@/utils/sock';
|
||||
|
||||
import { creatSubscribe, clearSubscribe, displayTopic, screenTopic } from '@/utils/stomp';
|
||||
import { bindSimulationTrain,getSimulationTrainlistNew,getSimulationMembersNew,trainSimulationEb,trainSimulationForce,trainSimulationGear} from '@/jlmap3d/jl3drailwaydrive/drivecontrol/simulation.js';
|
||||
import { getSimulationInfoNew } from '@/api/simulation';
|
||||
import { tuoguan3ddrive } from '@/api/jlmap3d/load3ddata';
|
||||
|
||||
import { getToken } from '@/utils/auth';
|
||||
// import Vue from 'vue';
|
||||
// import StompClient from '@/utils/stompclient.js';
|
||||
import axios from 'axios';
|
||||
export default {
|
||||
name: 'DriveControl',
|
||||
components: {
|
||||
CentercPane,
|
||||
LeftPane,
|
||||
RightPane,
|
||||
TopRightPane,
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
isTraining:true,
|
||||
localStatic:JL3D_LOCAL_STATIC,
|
||||
options: [],
|
||||
initMsg:"请选择列车",
|
||||
value: '',
|
||||
teststomp:null,
|
||||
topid:null,
|
||||
trainlist:null,
|
||||
groupnum:"",
|
||||
userrole:'',
|
||||
nowdrive:null,
|
||||
|
||||
tuoguanbutton:false,
|
||||
tuoguanbuttonmsg:"托管",
|
||||
tuoguanstatus:false,
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
// '$store.state.training.memberData':{
|
||||
// handler(val){
|
||||
// if(this.tuoguanbutton == true){
|
||||
// console.log(val);
|
||||
// }
|
||||
// },
|
||||
// deep:true //true 深度监听
|
||||
// }
|
||||
|
||||
},
|
||||
onLoad(e) {
|
||||
},
|
||||
onReady() {
|
||||
|
||||
},
|
||||
computed: {
|
||||
group() {
|
||||
return this.$route.query.group;
|
||||
},
|
||||
userId() {
|
||||
return this.$store.state.user ? this.$store.state.user.id : '';
|
||||
},
|
||||
},
|
||||
async mounted() {
|
||||
// if(this.$route.query.group){
|
||||
// getSimulationInfoNew(this.$route.query.group).then(netdata => {
|
||||
//
|
||||
// if(netdata.data.type == "SCRIPT_MAKING"){
|
||||
// this.tuoguanbutton = true;
|
||||
// }
|
||||
// this.inittrainlist();
|
||||
// });
|
||||
// }
|
||||
|
||||
window.updateDriverTrust = this.updateDriverTrust;
|
||||
window.updateDriveValue = this.updateDriveValue;
|
||||
// this.teststomp = new StompClient();
|
||||
|
||||
|
||||
},
|
||||
beforeDestroy() {
|
||||
},
|
||||
methods: {
|
||||
changeTrainSelect(mode){
|
||||
if(mode == "isTraining"){
|
||||
this.isTraining = false;
|
||||
}
|
||||
},
|
||||
currentsel(selVal){
|
||||
let oldgroupnum = this.groupnum;
|
||||
this.groupnum = selVal;
|
||||
bindSimulationTrain(this.group,this.groupnum).then(netdata => {
|
||||
this.selVal = selVal;
|
||||
this.dialogVisible = true;
|
||||
// this.groupnum = selVal;
|
||||
for(let i=0;i<this.trainlist.length;i++){
|
||||
if(this.trainlist[i].groupNumber == this.groupnum){
|
||||
// console.log(this.trainlist[i].gear);
|
||||
// this.groupnum
|
||||
this.$refs.centercontrol.centerstate(this.trainlist[i].gear);
|
||||
}
|
||||
}
|
||||
|
||||
this.nowdrive = this.groupnum;
|
||||
}).catch(error => {
|
||||
this.groupnum = oldgroupnum;
|
||||
this.selVal = oldgroupnum;
|
||||
this.$emit('warningmsg',error.message);
|
||||
this.value = this.nowdrive;
|
||||
});
|
||||
},
|
||||
clickselect(e){
|
||||
if(e == true){
|
||||
|
||||
this.updatetrainlist();
|
||||
}
|
||||
},
|
||||
tuoguan(){
|
||||
let posttrust = null;
|
||||
if(this.tuoguanstatus){
|
||||
posttrust = false;
|
||||
}else{
|
||||
posttrust = true;
|
||||
}
|
||||
|
||||
tuoguan3ddrive(this.$route.query.group,{}).then(netdata => {
|
||||
// this.$store.dispatch('training/updateMemberListInScript', {oldMemberId:this.oldMemberId, newMemberId:role, userId:this.userId});
|
||||
this.tuoguanstatus = posttrust;
|
||||
if(this.tuoguanstatus){
|
||||
this.tuoguanbuttonmsg = "取消托管";
|
||||
}else{
|
||||
this.tuoguanbuttonmsg = "托管";
|
||||
}
|
||||
}).catch((error) => {
|
||||
|
||||
});
|
||||
},
|
||||
updateDriverTrust(code,trustStatus){
|
||||
if(this.tuoguanstatus != trustStatus){
|
||||
this.tuoguanstatus = trustStatus;
|
||||
if(this.tuoguanstatus){
|
||||
this.tuoguanbuttonmsg = "取消托管";
|
||||
}else{
|
||||
this.tuoguanbuttonmsg = "托管";
|
||||
}
|
||||
this.$store.dispatch('training/updateMemberTrust', {deviceCode:code,trust:trustStatus});
|
||||
}
|
||||
},
|
||||
inittrainlist(){
|
||||
getSimulationTrainlistNew(this.group).then(netdata => {
|
||||
this.options = [];
|
||||
this.trainlist = netdata.data;
|
||||
for(let i=0;i<netdata.data.length;i++){
|
||||
let option= {
|
||||
value: netdata.data[i].groupNumber,
|
||||
label: netdata.data[i].groupNumber,
|
||||
name:null,
|
||||
}
|
||||
option.disabled = false;
|
||||
|
||||
if(netdata.data[i].name){
|
||||
option.label = netdata.data[i].name+"正在驾驶"+netdata.data[i].groupNumber;
|
||||
this.initMsg = netdata.data[i].name+"正在驾驶"+netdata.data[i].groupNumber;
|
||||
this.groupNumber = netdata.data[i].groupNumber;
|
||||
option.disabled = true;
|
||||
}
|
||||
|
||||
|
||||
if(netdata.data[i].driverId){
|
||||
if(netdata.data[i].driverId == this.userId){
|
||||
|
||||
this.selVal = netdata.data[i].groupNumber;
|
||||
this.groupnum = netdata.data[i].groupNumber;
|
||||
this.dialogVisible = true;
|
||||
for(let i=0;i<this.trainlist.length;i++){
|
||||
if(this.trainlist[i].groupNumber == this.groupnum){
|
||||
// console.log(this.trainlist[i].gear);
|
||||
// this.groupnum
|
||||
this.$refs.centercontrol.centerstate(this.trainlist[i].gear);
|
||||
}
|
||||
}
|
||||
|
||||
this.value = this.groupnum;
|
||||
this.nowdrive = this.groupnum;
|
||||
// bindSimulationTrain(this.group,this.selVal).then(netdata => {
|
||||
//
|
||||
//
|
||||
// }).catch(error => {
|
||||
// });
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.options.push(option);
|
||||
}
|
||||
this.options.sort(
|
||||
function(obj1,obj2) {
|
||||
let val1 = obj1.value;
|
||||
let val2 = obj2.value;
|
||||
return val1 - val2;
|
||||
}
|
||||
);
|
||||
});
|
||||
//获取当前录制托管状态
|
||||
if(this.tuoguanbutton == true){
|
||||
|
||||
let netdata = this.$store.state.training.memberData;
|
||||
for(let k in netdata){
|
||||
if(netdata[k].userId == this.userId){
|
||||
// console.log(this.$store.state.scriptRecord.type);
|
||||
this.userrole = netdata[k].type;
|
||||
if(netdata[k].trust){
|
||||
this.tuoguanstatus = netdata[k].trust;
|
||||
if(this.tuoguanstatus){
|
||||
this.tuoguanbuttonmsg = "取消托管";
|
||||
}else{
|
||||
this.tuoguanbuttonmsg = "托管";
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
updateDriveValue(newvalue){
|
||||
|
||||
if(newvalue != this.value){
|
||||
this.value = newvalue;
|
||||
this.groupnum = newvalue;
|
||||
}
|
||||
},
|
||||
updatetrainlist(){
|
||||
getSimulationTrainlistNew(this.group).then(netdata => {
|
||||
this.options = [];
|
||||
this.trainlist = netdata.data;
|
||||
for(let i=0;i<netdata.data.length;i++){
|
||||
let option= {
|
||||
value: netdata.data[i].groupNumber,
|
||||
label: netdata.data[i].groupNumber,
|
||||
name:null,
|
||||
}
|
||||
option.disabled = false;
|
||||
|
||||
if(netdata.data[i].name){
|
||||
option.label = netdata.data[i].name+"正在驾驶"+netdata.data[i].groupNumber;
|
||||
this.initMsg = netdata.data[i].name+"正在驾驶"+netdata.data[i].groupNumber;
|
||||
this.groupNumber = netdata.data[i].groupNumber;
|
||||
option.disabled = true;
|
||||
}
|
||||
if(netdata.data[i].driverId){
|
||||
if(netdata.data[i].driverId == this.userId){
|
||||
this.selVal = netdata.data[i].groupNumber;
|
||||
this.groupnum = netdata.data[i].groupNumber;
|
||||
}
|
||||
}
|
||||
this.options.push(option);
|
||||
}
|
||||
this.options.sort(
|
||||
function(obj1,obj2) {
|
||||
let val1 = obj1.value;
|
||||
let val2 = obj2.value;
|
||||
return val1 - val2;
|
||||
}
|
||||
);
|
||||
});
|
||||
//获取当前录制托管状态
|
||||
if(this.tuoguanbutton == true){
|
||||
|
||||
let netdata = this.$store.state.training.memberData;
|
||||
for(let k in netdata){
|
||||
if(netdata[k].userId == this.userId){
|
||||
// console.log(this.$store.state.scriptRecord.type);
|
||||
this.userrole = netdata[k].type;
|
||||
if(netdata[k].trust){
|
||||
this.tuoguanstatus = netdata[k].trust;
|
||||
if(this.tuoguanstatus){
|
||||
this.tuoguanbuttonmsg = "取消托管";
|
||||
}else{
|
||||
this.tuoguanbuttonmsg = "托管";
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
// getSimulationMembersNew(this.group).then(netdata => {
|
||||
|
||||
// for(let i=0,leni=netdata.data.length;i<leni;i++){
|
||||
// if(netdata.data[i].userId){
|
||||
// if(netdata.data[i].userId == this.userId){
|
||||
// this.userrole = netdata.data[i].role;
|
||||
// if(netdata.data[i].trust){
|
||||
// this.tuoguanstatus = netdata.data[i].trust;
|
||||
// if(this.tuoguanstatus){
|
||||
// this.tuoguanbuttonmsg = "取消托管";
|
||||
// }else{
|
||||
// this.tuoguanbuttonmsg = "托管";
|
||||
// }
|
||||
// }
|
||||
// i=leni;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// this.userrole = netdata.data.role;
|
||||
// if(netdata.data.trust){
|
||||
// this.tuoguanstatus = netdata.data.trust;
|
||||
// if(this.tuoguanstatus){
|
||||
// this.tuoguanbuttonmsg = "取消托管";
|
||||
// }else{
|
||||
// this.tuoguanbuttonmsg = "托管";
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.drivepane{
|
||||
width:30%;
|
||||
height:320px;
|
||||
right:500px;
|
||||
bottom:0;
|
||||
position: absolute;
|
||||
background-size: 100% 100%;
|
||||
border-radius:10px;
|
||||
}
|
||||
.panebutton{
|
||||
height: 73px;
|
||||
width: 60px;
|
||||
position: absolute;
|
||||
text-align: center;
|
||||
cursor:pointer;
|
||||
}
|
||||
|
||||
.panebutton2{
|
||||
height: 73px;
|
||||
width: 80px;
|
||||
position: absolute;
|
||||
text-align: center;
|
||||
cursor:pointer;
|
||||
}
|
||||
|
||||
.buttonimg{
|
||||
top:0;
|
||||
/* position: absolute; */
|
||||
height: 40px;
|
||||
width: 40px;
|
||||
}
|
||||
|
||||
.buttonimg2{
|
||||
top:0;
|
||||
left:10px;
|
||||
position: absolute;
|
||||
height: 60px;
|
||||
width: 60px;
|
||||
}
|
||||
|
||||
.buttontext{
|
||||
width:100%;
|
||||
bottom:0px;
|
||||
|
||||
/* position: absolute; */
|
||||
color: #FFFFFF;
|
||||
font-size: 4px;
|
||||
}
|
||||
.buttontext2{
|
||||
width:100%;
|
||||
bottom:0px;
|
||||
|
||||
position: absolute;
|
||||
color: #FFFFFF;
|
||||
font-size: 4px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.switchpane{
|
||||
width:30px;
|
||||
height:30px;
|
||||
position:absolute;
|
||||
cursor:pointer;
|
||||
}
|
||||
|
||||
.switchimg{
|
||||
width:100%;
|
||||
height:100%;
|
||||
}
|
||||
|
||||
.selecttraintext{
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
</style>
|
415
src/views/jlmap3d/railwaydrive/drivecontrol/leftpane.vue
Normal file
415
src/views/jlmap3d/railwaydrive/drivecontrol/leftpane.vue
Normal file
@ -0,0 +1,415 @@
|
||||
<template>
|
||||
<div style="width:25%;height:100%;position:absolute;bottom:0;left:0;">
|
||||
|
||||
<!-- ATB启动 -->
|
||||
<!-- <div id="atb" class="panebutton" style="top:3%;left:42%;" @tap="atbclick">
|
||||
<img class="buttonimg" :src="greenimg" />
|
||||
<div class="buttontext">{{ $t('jlmap3d.ATBStart') }}</div>
|
||||
</div> -->
|
||||
<!-- BM/CBTC -->
|
||||
<!-- <div id="bmcbtc" class="panebutton" style="top:3%;left:56%;" @tap="bmcbtcclick">
|
||||
<img class="buttonimg" :src="greenimg" />
|
||||
<div class="buttontext">BM/CBTC</div>
|
||||
</div> -->
|
||||
<!-- RM -->
|
||||
<!-- <div id="rm" class="panebutton" style="top:3%;left:70%;" @tap="rmclick">
|
||||
<img class="buttonimg" :src="greenimg" />
|
||||
<div class="buttontext">RM</div>
|
||||
</div> -->
|
||||
|
||||
<!-- 关左门 -->
|
||||
<!-- <div id="dlclose" class="panebutton" style="bottom:3%;left:3%;" @tap="dlcclick">
|
||||
<img class="buttonimg" :src="greenimg" />
|
||||
<div class="buttontext">{{ $t('jlmap3d.closeLeftDoor') }}</div>
|
||||
</div> -->
|
||||
<!-- 开左门A -->
|
||||
<!-- <div id="dlopen" class="panebutton" style="bottom:3%;left:14%;" @tap="dloclick">
|
||||
<img class="buttonimg" :src="redimg" />
|
||||
<div class="buttontext">{{ $t('jlmap3d.openLeftDoor') }}</div>
|
||||
</div> -->
|
||||
|
||||
<!-- ATO启动A -->
|
||||
<!-- <div id="atoa" class="panebutton" style="bottom:3%;left:42%;" @tap="atoaclick">
|
||||
<img class="buttonimg" :src="apoimg" />
|
||||
<div class="buttontext">{{ $t('jlmap3d.ATOStart') }}</div>
|
||||
</div> -->
|
||||
|
||||
|
||||
<!-- cbtc -->
|
||||
<!-- <div id="cbtc" class="panebutton" style="bottom:3%;left:70%;" @tap="cbtcclick">
|
||||
<img class="buttonimg" :src="greenimg" />
|
||||
<div class="buttontext">CBTC</div>
|
||||
</div> -->
|
||||
<!-- 电笛按钮 -->
|
||||
<!-- <div id="elflute" class="panebutton" style="bottom:3%;left:84%;" @tap="elfluteclick">
|
||||
<img class="buttonimg" :src="grayimg" />
|
||||
<div class="buttontext">{{ $t('jlmap3d.electricHornButton') }}</div>
|
||||
</div> -->
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import Vue from 'vue';
|
||||
// import { sendSimulationCommand } from '@/api/simulation.js';
|
||||
|
||||
import { JL3D_LOCAL_STATIC } from '@/api/jlmap3d/assets3d.js';
|
||||
|
||||
export default {
|
||||
name: 'LeftPane',
|
||||
components: {
|
||||
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
||||
apoimg:JL3D_LOCAL_STATIC+"/jl3d/control/green.png",
|
||||
greenzimg:JL3D_LOCAL_STATIC+"/jl3d/control/greenz.png",
|
||||
redzimg:JL3D_LOCAL_STATIC+"/jl3d/control/redz.png",
|
||||
greenimg:JL3D_LOCAL_STATIC+"/jl3d/control/green.png",
|
||||
redimg:JL3D_LOCAL_STATIC+"/jl3d/control/red.png",
|
||||
greenlimg:JL3D_LOCAL_STATIC+"/jl3d/control/greenl.png",
|
||||
grayimg:JL3D_LOCAL_STATIC+"/jl3d/control/gray.png",
|
||||
zuoimg:JL3D_LOCAL_STATIC+"/jl3d/control/zuo.png",
|
||||
niuimg:JL3D_LOCAL_STATIC+"/jl3d/control/niu.png",
|
||||
aircomimg:JL3D_LOCAL_STATIC+"/jl3d/control/aircom.png",
|
||||
passlighttf:"rotate(0deg)",
|
||||
sivtf:"rotate(0deg)",
|
||||
driverlighttf:"rotate(0deg)",
|
||||
headlighttf:"rotate(0deg)",
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
'$store.state.app.atostate': function (val,newval) {
|
||||
if(val != newval){
|
||||
if(newval == true){
|
||||
this.apoimg = this.greenimg;
|
||||
this.$store.dispatch('app/setAtoState', false);
|
||||
}else{
|
||||
this.apoimg = this.greenlimg;
|
||||
this.$store.dispatch('app/setAtoState', true);
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
group() {
|
||||
return this.$store.state.app.group;
|
||||
},
|
||||
code() {
|
||||
return this.$store.state.app.code;
|
||||
},
|
||||
traincode() {
|
||||
return this.$store.state.app.driverTrain;
|
||||
},
|
||||
movespeed() {
|
||||
return this.$store.state.app.movespeed;
|
||||
},
|
||||
drivedirect() {
|
||||
return this.$store.state.app.drivedirect;
|
||||
},
|
||||
atostate(){
|
||||
return this.$store.state.app.atostate;
|
||||
}
|
||||
|
||||
},
|
||||
mounted() {
|
||||
|
||||
},
|
||||
beforeDestroy() {
|
||||
|
||||
},
|
||||
methods: {
|
||||
leftstate : function(lefts){
|
||||
if(lefts.ato == true){
|
||||
this.apoimg = this.greenlimg;
|
||||
this.$store.dispatch('app/setAtoState', true);
|
||||
}else{
|
||||
this.apoimg = this.greenimg;
|
||||
this.$store.dispatch('app/setAtoState', false);
|
||||
|
||||
}
|
||||
},
|
||||
leftcontrol : function(){
|
||||
|
||||
},
|
||||
showmsg:function(data){
|
||||
wx.showToast({
|
||||
title: data,
|
||||
icon: 'loading',
|
||||
duration: 2000
|
||||
});
|
||||
},
|
||||
setData : function(){
|
||||
this.msgshow = false;
|
||||
},
|
||||
showcontrolmsg:function(data,callback){
|
||||
this.controlmsg = data;
|
||||
this.msgshow = true;
|
||||
|
||||
callback = callback || function(){
|
||||
this.setData();
|
||||
};
|
||||
setTimeout( callback.bind(this),2000);
|
||||
|
||||
},
|
||||
//左侧车门开
|
||||
dloclick: function (e){
|
||||
console.log(this.$t('jlmap3d.leftDoorOpen'));
|
||||
if(this.movespeed == 0){
|
||||
//this.showcontrolmsg("左侧车门开");
|
||||
this.controlsend(this.traincode,"603","07","");
|
||||
}
|
||||
},
|
||||
//左侧车门关
|
||||
dlcclick: function (e){
|
||||
console.log(this.$t('jlmap3d.leftDoorClose'));
|
||||
if(this.movespeed == 0){
|
||||
//this.showcontrolmsg("左侧车门关");
|
||||
this.controlsend(this.traincode,"605","07","");
|
||||
}
|
||||
},
|
||||
//断路器
|
||||
breakerclick: function (e){
|
||||
Vue.prototype.$stomp.send("/app/topic/simulation/drive","breaker");
|
||||
},
|
||||
//洗车模式
|
||||
carwashclick: function (e){
|
||||
Vue.prototype.$stomp.send("/app/topic/simulation/drive","carwash");
|
||||
},
|
||||
//空压机
|
||||
aircomclick : function (e){
|
||||
Vue.prototype.$stomp.send("/app/topic/simulation/drive","aircom");
|
||||
},
|
||||
//ATB
|
||||
atbclick : function (e){
|
||||
Vue.prototype.$stomp.send("/app/topic/simulation/drive","atb");
|
||||
},
|
||||
//BMCBTC
|
||||
bmcbtcclick : function (e){
|
||||
Vue.prototype.$stomp.send("/app/topic/simulation/drive","bm");
|
||||
},
|
||||
//RM
|
||||
rmclick : function (e){
|
||||
Vue.prototype.$stomp.send("/app/topic/simulation/drive","rm");
|
||||
},
|
||||
//强迫缓解
|
||||
relieveclick : function (e){
|
||||
Vue.prototype.$stomp.send("/app/topic/simulation/drive","relieve");
|
||||
},
|
||||
//ATOA
|
||||
atoaclick : function (e){
|
||||
//console.log("ato自动驾驶");
|
||||
if(this.movespeed == 0){
|
||||
if(this.drivedirect == "Drive"){
|
||||
this.controlsend(this.traincode,"601","07","");
|
||||
this.apoimg = this.greenlimg;
|
||||
this.showcontrolmsg(this.$t('jlmap3d.ATOStart'));
|
||||
this.$store.dispatch('app/setAtoState', true);
|
||||
}
|
||||
}
|
||||
},
|
||||
//ATOB
|
||||
atobclick : function (e){
|
||||
if(this.movespeed == 0){
|
||||
if(this.drivedirect == "Drive"){
|
||||
this.controlsend(this.traincode,"601","07","");
|
||||
this.apoimg = this.greenimg;
|
||||
this.showcontrolmsg(this.$t('jlmap3d.ATOStart'));
|
||||
this.$store.dispatch('app/setAtoState', true);
|
||||
}
|
||||
}
|
||||
},
|
||||
//CBTC
|
||||
cbtcclick : function (e){
|
||||
Vue.prototype.$stomp.send("/app/topic/simulation/drive","cbtc");
|
||||
},
|
||||
//电笛
|
||||
elfluteclick : function (e){
|
||||
Vue.prototype.$stomp.send("/app/topic/simulation/drive","elflute");
|
||||
},
|
||||
controlsend:function(traincode,operation,type,param){
|
||||
if(this.$store.state.app.userRole == "Driver"){
|
||||
let command ={
|
||||
code: traincode,
|
||||
operation: operation,
|
||||
type: type,
|
||||
param: param
|
||||
};
|
||||
// sendSimulationCommand(this.group,command);
|
||||
}else{
|
||||
|
||||
}
|
||||
},
|
||||
passlighttouchstart:function(e){
|
||||
// let command ={
|
||||
// code:this.traincode,
|
||||
// operation:"607",
|
||||
// type:"07",
|
||||
// param:""
|
||||
// };
|
||||
// command.param = this.touchstate;
|
||||
// sendSimulationCommand(this.group,command).then(netdata => {
|
||||
// if(netdata.data == true){
|
||||
this.touchcontrol = true;
|
||||
// }
|
||||
// });
|
||||
},
|
||||
passlighttouchmove:function(e){//finger move 触发
|
||||
if(this.touchcontrol == true){
|
||||
let px=75;
|
||||
let py=155;
|
||||
let angle = this.getAngle(px,py,e.changedTouches[0].clientX,e.changedTouches[0].clientY);
|
||||
if(angle<360 && angle>245){
|
||||
if(angle<327 && angle>245){
|
||||
this.passlighttf = "rotate(359deg)";
|
||||
}else if(angle<360 && angle>327){
|
||||
this.passlighttf = "rotate(90deg)";
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
passlighttouchend:function(e){
|
||||
this.touchcontrol = false;
|
||||
},
|
||||
sivtouchstart:function(e){
|
||||
// let command ={
|
||||
// code:this.traincode,
|
||||
// operation:"607",
|
||||
// type:"07",
|
||||
// param:""
|
||||
// };
|
||||
// command.param = this.touchstate;
|
||||
// sendSimulationCommand(this.group,command).then(netdata => {
|
||||
// if(netdata.data == true){
|
||||
this.touchcontrol = true;
|
||||
// }
|
||||
// });
|
||||
},
|
||||
sivtouchmove:function(e){//finger move 触发
|
||||
if(this.touchcontrol == true){
|
||||
let px=75;
|
||||
let py=255;
|
||||
let angle = this.getAngle(px,py,e.changedTouches[0].clientX,e.changedTouches[0].clientY);
|
||||
if(angle<360 && angle>245){
|
||||
if(angle<327 && angle>245){
|
||||
this.sivtf = "rotate(359deg)";
|
||||
}else if(angle<360 && angle>327){
|
||||
this.sivtf = "rotate(90deg)";
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
sivtouchend:function(e){
|
||||
this.touchcontrol = false;
|
||||
},
|
||||
driverlighttouchstart:function(e){
|
||||
// let command ={
|
||||
// code:this.traincode,
|
||||
// operation:"607",
|
||||
// type:"07",
|
||||
// param:""
|
||||
// };
|
||||
// command.param = this.touchstate;
|
||||
// sendSimulationCommand(this.group,command).then(netdata => {
|
||||
// if(netdata.data == true){
|
||||
this.touchcontrol = true;
|
||||
// }
|
||||
// });
|
||||
},
|
||||
driverlighttouchmove:function(e){//finger move 触发
|
||||
if(this.touchcontrol == true){
|
||||
let px=75;
|
||||
let py=355;
|
||||
let angle = this.getAngle(px,py,e.changedTouches[0].clientX,e.changedTouches[0].clientY);
|
||||
if(angle<360 && angle>245){
|
||||
if(angle<327 && angle>245){
|
||||
this.driverlighttf = "rotate(359deg)";
|
||||
}else if(angle<360 && angle>327){
|
||||
this.driverlighttf = "rotate(90deg)";
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
driverlighttouchend:function(e){
|
||||
this.touchcontrol = false;
|
||||
},
|
||||
headlighttouchstart:function(e){
|
||||
// let command ={
|
||||
// code:this.traincode,
|
||||
// operation:"607",
|
||||
// type:"07",
|
||||
// param:""
|
||||
// };
|
||||
// command.param = this.touchstate;
|
||||
// sendSimulationCommand(this.group,command).then(netdata => {
|
||||
// if(netdata.data == true){
|
||||
this.touchcontrol = true;
|
||||
// }
|
||||
// });
|
||||
},
|
||||
headlighttouchmove:function(e){//finger move 触发
|
||||
if(this.touchcontrol == true){
|
||||
let px=75;
|
||||
let py=455;
|
||||
let angle = this.getAngle(px,py,e.changedTouches[0].clientX,e.changedTouches[0].clientY);
|
||||
if(angle<360 && angle>245){
|
||||
if(angle<295 && angle>245){
|
||||
this.headlighttf = "rotate(359deg)";
|
||||
}else if(angle<338 && angle>295){
|
||||
this.headlighttf = "rotate(405deg)";
|
||||
}else if(angle<360 && angle>338){
|
||||
this.headlighttf = "rotate(90deg)";
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
headlighttouchend:function(e){
|
||||
this.touchcontrol = false;
|
||||
},
|
||||
getAngle:function(px,py,mx,my){
|
||||
//圆心坐标
|
||||
let x = Math.abs(px-mx);
|
||||
let y = Math.abs(py-my);
|
||||
let z = Math.sqrt(Math.pow(x,2)+Math.pow(y,2));
|
||||
let cos = y/z;
|
||||
let radina = Math.acos(cos);//用反三角函数求弧度
|
||||
let angle = Math.floor(180/(Math.PI/radina));//将弧度转换成角度
|
||||
|
||||
if(mx>px&&my>py){//鼠标在第四象限
|
||||
angle = 180 - angle;
|
||||
}
|
||||
|
||||
if(mx==px&&my>py){//鼠标在y轴负方向上
|
||||
angle = 180;
|
||||
}
|
||||
|
||||
if(mx>px&&my==py){//鼠标在x轴正方向上
|
||||
angle = 90;
|
||||
}
|
||||
|
||||
if(mx<px&&my>py){//鼠标在第三象限
|
||||
angle = 180+angle;
|
||||
}
|
||||
|
||||
if(mx<px&&my==py){//鼠标在x轴负方向
|
||||
angle = 270;
|
||||
}
|
||||
|
||||
if(mx<px&&my<py){//鼠标在第二象限
|
||||
angle = 360 - angle;
|
||||
}
|
||||
return angle;
|
||||
},
|
||||
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
308
src/views/jlmap3d/railwaydrive/drivecontrol/rightpane.vue
Normal file
308
src/views/jlmap3d/railwaydrive/drivecontrol/rightpane.vue
Normal file
@ -0,0 +1,308 @@
|
||||
<template>
|
||||
<!-- <div style="width:25%;height:100%;position:absolute;left:75%;">
|
||||
|
||||
<div id="dropen" class="panebutton" style="bottom:1%;left:1%;" @tap="droclick">
|
||||
<img class="buttonimg" :src="redlimg" />
|
||||
<div class="buttontext">{{ $t('jlmap3d.openRightDoor') }}</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="drclose" class="panebutton" style="bottom:1%;left:41%;" @tap="drcclick">
|
||||
<img class="buttonimg" :src="greenimg" />
|
||||
<div class="buttontext">{{ $t('jlmap3d.closeRightDoor') }}</div>
|
||||
</div>
|
||||
|
||||
<div id="urgestop" class="panebutton" style="top:1%;left:1%;">
|
||||
<img class="buttonimg" :src="urgestopimg" />
|
||||
<div class="buttontext">{{ $t('jlmap3d.emergencyBraking') }}</div>
|
||||
</div>
|
||||
|
||||
<div id="doorpick" class="panebutton2" style="top:1%;left:33%;">
|
||||
<img class="buttonimg2" :src="zuoimg" />
|
||||
<img class="buttonimg2" :src="niuimg" :style="{transform:doordirecttou}" @touchstart='doordirecttouchstart' @touchmove='doordirecttouchmove' @touchend='doordirecttouchend'/>
|
||||
<div class="tfbutton" style="font-size:1px;top:13px;left:5px;">{{ $t('jlmap3d.leftSide') }}</div>
|
||||
<div class="tfbutton" style="font-size:1px;top:5px;left:33px;">{{ $t('jlmap3d.location0') }}</div>
|
||||
<div class="tfbutton" style="font-size:1px;top:13px;left:50px;">{{ $t('jlmap3d.rightSide') }}</div>
|
||||
<div class="buttontext2">{{ $t('jlmap3d.doorSideChoose') }}</div>
|
||||
</div> -->
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import Vue from 'vue';
|
||||
// import { sendSimulationCommand } from '@/api/simulation.js';
|
||||
import { JL3D_LOCAL_STATIC } from '@/api/jlmap3d/assets3d.js';
|
||||
export default {
|
||||
name: 'RightPane',
|
||||
components: {
|
||||
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
redlimg:JL3D_LOCAL_STATIC+"/jl3d/control/redl.png",
|
||||
greenimg:JL3D_LOCAL_STATIC+"/jl3d/control/green.png",
|
||||
zuoimg:JL3D_LOCAL_STATIC+"/jl3d/control/zuo.png",
|
||||
niuimg:JL3D_LOCAL_STATIC+"/jl3d/control/niu.png",
|
||||
urgestopimg:JL3D_LOCAL_STATIC+"/jl3d/control/urgestop.png",
|
||||
doordirecttou:"rotate(0deg)",
|
||||
doormodetou:"rotate(0deg)",
|
||||
watertou:"rotate(0deg)",
|
||||
washtou:"rotate(0deg)",
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
||||
},
|
||||
computed: {
|
||||
group() {
|
||||
return this.$store.state.app.group;
|
||||
},
|
||||
code() {
|
||||
return this.$store.state.app.code;
|
||||
},
|
||||
traincode() {
|
||||
return this.$store.state.app.driverTrain;
|
||||
},
|
||||
movespeed() {
|
||||
return this.$store.state.app.movespeed;
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
|
||||
},
|
||||
beforeDestroy() {
|
||||
|
||||
},
|
||||
methods: {
|
||||
rightstate : function(rights){
|
||||
|
||||
},
|
||||
rightcontrol : function(){
|
||||
|
||||
},
|
||||
showmsg:function(data){
|
||||
wx.showToast({
|
||||
title: data,
|
||||
icon: 'loading',
|
||||
duration: 2000
|
||||
});
|
||||
},
|
||||
showcontrolmsg:function(data,callback){
|
||||
this.controlmsg = data;
|
||||
this.msgshow = true;
|
||||
|
||||
callback = callback || function(){
|
||||
this.setData();
|
||||
};
|
||||
setTimeout( callback.bind(this),2000);
|
||||
|
||||
},
|
||||
droclick: function (e){
|
||||
//console.log("右侧车门开");
|
||||
if(this.movespeed == 0){
|
||||
this.showcontrolmsg(this.$t('jlmap3d.rightDoorOpen'));
|
||||
this.controlsend(this.traincode,"604","07","");
|
||||
}
|
||||
},
|
||||
drcclick: function (e){
|
||||
//console.log("右侧车门关");
|
||||
if(this.movespeed == 0){
|
||||
this.showcontrolmsg(this.$t('jlmap3d.rightDoorClose'));
|
||||
this.controlsend(this.traincode,"606","07","");
|
||||
}
|
||||
},
|
||||
urgestopclick: function (e){
|
||||
|
||||
},
|
||||
controlsend:function(traincode,operation,type,param){
|
||||
if(this.$store.state.app.userRole == "Driver"){
|
||||
let command ={
|
||||
code: traincode,
|
||||
operation: operation,
|
||||
type: type,
|
||||
param: param
|
||||
};
|
||||
// sendSimulationCommand(this.group,command);
|
||||
}else{
|
||||
|
||||
}
|
||||
},
|
||||
watertouchstart:function(e){
|
||||
// let command ={
|
||||
// code:this.traincode,
|
||||
// operation:"607",
|
||||
// type:"07",
|
||||
// param:""
|
||||
// };
|
||||
// command.param = this.touchstate;
|
||||
// sendSimulationCommand(this.group,command).then(netdata => {
|
||||
// if(netdata.data == true){
|
||||
this.touchcontrol = true;
|
||||
// }
|
||||
// });
|
||||
},
|
||||
watertouchmove:function(e){//finger move 触发
|
||||
if(this.touchcontrol == true){
|
||||
let px=140;
|
||||
let py=400;
|
||||
let angle = this.getAngle(px,py,e.changedTouches[0].clientX,e.changedTouches[0].clientY);
|
||||
if(angle<338 && angle>245){
|
||||
if(angle<295 && angle>245){
|
||||
this.watertou = "rotate(359deg)";
|
||||
}else if(angle<338 && angle>295){
|
||||
this.watertou = "rotate(412deg)";
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
watertouchend:function(e){
|
||||
this.touchcontrol = false;
|
||||
},
|
||||
washtouchstart:function(e){
|
||||
// let command ={
|
||||
// code:this.traincode,
|
||||
// operation:"607",
|
||||
// type:"07",
|
||||
// param:""
|
||||
// };
|
||||
// command.param = this.touchstate;
|
||||
// sendSimulationCommand(this.group,command).then(netdata => {
|
||||
// if(netdata.data == true){
|
||||
this.touchcontrol = true;
|
||||
// }
|
||||
// });
|
||||
},
|
||||
washtouchmove:function(e){//finger move 触发
|
||||
if(this.touchcontrol == true){
|
||||
let px=140;
|
||||
let py=510;
|
||||
let angle = this.getAngle(px,py,e.changedTouches[0].clientX,e.changedTouches[0].clientY);
|
||||
// console.log(angle);
|
||||
// this.washtou = "rotate("+(angle+85)+"deg)";
|
||||
if(angle<360 && angle>245){
|
||||
if(angle<295 && angle>245){
|
||||
this.washtou = "rotate(359deg)";
|
||||
}else if(angle<338 && angle>295){
|
||||
this.washtou = "rotate(412deg)";
|
||||
}else if(angle<360 && angle>338){
|
||||
this.washtou = "rotate(90deg)";
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
washtouchend:function(e){
|
||||
this.touchcontrol = false;
|
||||
},
|
||||
doordirecttouchstart:function(e){
|
||||
// let command ={
|
||||
// code:this.traincode,
|
||||
// operation:"607",
|
||||
// type:"07",
|
||||
// param:""
|
||||
// };
|
||||
// command.param = this.touchstate;
|
||||
// sendSimulationCommand(this.group,command).then(netdata => {
|
||||
// if(netdata.data == true){
|
||||
this.touchcontrol = true;
|
||||
// }
|
||||
// });
|
||||
},
|
||||
doordirecttouchmove:function(e){//finger move 触发
|
||||
if(this.touchcontrol == true){
|
||||
let px=230;
|
||||
let py=180;
|
||||
let angle = this.getAngle(px,py,e.changedTouches[0].clientX,e.changedTouches[0].clientY);
|
||||
if(angle<338 && angle>219){
|
||||
if(angle<245 && angle>219){
|
||||
this.doordirecttou = "rotate(305deg)";
|
||||
}else if(angle<295 && angle>245){
|
||||
this.doordirecttou = "rotate(359deg)";
|
||||
}else if(angle<338 && angle>295){
|
||||
this.doordirecttou = "rotate(412deg)";
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
doordirecttouchend:function(e){
|
||||
this.touchcontrol = false;
|
||||
},
|
||||
doormodetouchstart:function(e){
|
||||
// let command ={
|
||||
// code:this.traincode,
|
||||
// operation:"607",
|
||||
// type:"07",
|
||||
// param:""
|
||||
// };
|
||||
// command.param = this.touchstate;
|
||||
// sendSimulationCommand(this.group,command).then(netdata => {
|
||||
// if(netdata.data == true){
|
||||
this.touchcontrol = true;
|
||||
// }
|
||||
// });
|
||||
},
|
||||
doormodetouchmove:function(e){//finger move 触发
|
||||
if(this.touchcontrol == true){
|
||||
let px=230;
|
||||
let py=280;
|
||||
let angle = this.getAngle(px,py,e.changedTouches[0].clientX,e.changedTouches[0].clientY);
|
||||
if(angle<338 && angle>219){
|
||||
if(angle<245 && angle>219){
|
||||
this.doormodetou = "rotate(305deg)";
|
||||
Vue.prototype.$stomp.send("/app/topic/simulation/drive","AA");
|
||||
}else if(angle<295 && angle>245){
|
||||
this.doormodetou = "rotate(359deg)";
|
||||
Vue.prototype.$stomp.send("/app/topic/simulation/drive","AM");
|
||||
}else if(angle<338 && angle>295){
|
||||
this.doormodetou = "rotate(412deg)";
|
||||
Vue.prototype.$stomp.send("/app/topic/simulation/drive","MM");
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
doormodetouchend:function(e){
|
||||
this.touchcontrol = false;
|
||||
},
|
||||
getAngle:function(px,py,mx,my){
|
||||
//圆心坐标
|
||||
let x = Math.abs(px-mx);
|
||||
let y = Math.abs(py-my);
|
||||
let z = Math.sqrt(Math.pow(x,2)+Math.pow(y,2));
|
||||
let cos = y/z;
|
||||
let radina = Math.acos(cos);//用反三角函数求弧度
|
||||
let angle = Math.floor(180/(Math.PI/radina));//将弧度转换成角度
|
||||
|
||||
if(mx>px&&my>py){//鼠标在第四象限
|
||||
angle = 180 - angle;
|
||||
}
|
||||
|
||||
if(mx==px&&my>py){//鼠标在y轴负方向上
|
||||
angle = 180;
|
||||
}
|
||||
|
||||
if(mx>px&&my==py){//鼠标在x轴正方向上
|
||||
angle = 90;
|
||||
}
|
||||
|
||||
if(mx<px&&my>py){//鼠标在第三象限
|
||||
angle = 180+angle;
|
||||
}
|
||||
|
||||
if(mx<px&&my==py){//鼠标在x轴负方向
|
||||
angle = 270;
|
||||
}
|
||||
|
||||
if(mx<px&&my<py){//鼠标在第二象限
|
||||
angle = 360 - angle;
|
||||
}
|
||||
return angle;
|
||||
},
|
||||
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
478
src/views/jlmap3d/railwaydrive/drivecontrol/toprightpane.vue
Normal file
478
src/views/jlmap3d/railwaydrive/drivecontrol/toprightpane.vue
Normal file
@ -0,0 +1,478 @@
|
||||
<template>
|
||||
<div style="width:100%;height:48%;position:absolute;top:0px;">
|
||||
|
||||
<!-- 换端 -->
|
||||
<!-- <div id="ch" class="panebutton" style="top:8%;left:3%;"@click="changehead">
|
||||
<img class="buttonimg" :src="greenimg" />
|
||||
<div class="buttontext">{{ $t('jlmap3d.ChangeHead') }}</div>
|
||||
</div> -->
|
||||
<!-- BM/CBTC -->
|
||||
|
||||
<!-- <div id="bmcbtc" class="panebutton" style="top:8%;left:17%;" @click="bmcbtcclick">
|
||||
<img class="buttonimg" :src="cbtcbuttonimg" />
|
||||
<div class="buttontext">BM/CBTC</div>
|
||||
</div> -->
|
||||
<!-- RM -->
|
||||
<!-- <div id="rm" class="panebutton" style="top:8%;left:31%;" @click="rmclick">
|
||||
<img class="buttonimg" :src="rmbuttonimg" />
|
||||
<div class="buttontext">RM</div>
|
||||
</div> -->
|
||||
<!-- 关左门 -->
|
||||
<!-- <div id="dlclose" class="panebutton" style="top:8%;left:45%;" @click="dlcclick">
|
||||
<img class="buttonimg" :src="doorleftimg" />
|
||||
<div class="buttontext">{{ $t('jlmap3d.closeLeftDoor') }}</div>
|
||||
</div> -->
|
||||
<!-- 开左门A -->
|
||||
<!-- <div id="dlopen" class="panebutton" style="top:8%;left:59%;" @click="dloclick">
|
||||
<img class="buttonimg" :src="redimg" />
|
||||
<div class="buttontext">{{ $t('jlmap3d.openLeftDoor') }}</div>
|
||||
</div> -->
|
||||
<!-- ATO启动A -->
|
||||
<!-- <div id="atoa" class="panebutton" style="top:8%;left:73%;" @click="atoaclick">
|
||||
<img class="buttonimg" :src="atobuttonimg" />
|
||||
<div class="buttontext">{{ $t('jlmap3d.ATOStart') }}</div>
|
||||
</div> -->
|
||||
|
||||
|
||||
<!-- 受电弓升 -->
|
||||
<!-- <div id="sg" class="panebutton" style="bottom:6%;left:3%;" @click="sgclink">
|
||||
<img class="buttonimg" :src="sgimg" />
|
||||
<div class="buttontext">{{ $t('jlmap3d.electricGongSheng') }}</div>
|
||||
</div> -->
|
||||
<!-- 受电弓降 -->
|
||||
<!-- <div id="jg" class="panebutton" style="bottom:6%;left:17%;" @click="jgclick">
|
||||
<img class="buttonimg" :src="jgimg" />
|
||||
<div class="buttontext">{{ $t('jlmap3d.pantographFall') }}</div>
|
||||
</div> -->
|
||||
|
||||
<!-- ATP切除 -->
|
||||
<!-- <div id="atp" class="panebutton" style="bottom:6%;left:31%;" @click="atpclick">
|
||||
<img class="buttonimg" :src="atpimg" />
|
||||
<div class="buttontext">{{ $t('jlmap3d.removalATP') }}</div>
|
||||
</div> -->
|
||||
|
||||
|
||||
<!-- <div id="dropen" class="panebutton" style="bottom:6%;left:45%;" @click="droclick">
|
||||
<img class="buttonimg" :src="redlimg" />
|
||||
<div class="buttontext">{{ $t('jlmap3d.openRightDoor') }}</div>
|
||||
</div>
|
||||
<div id="drclose" class="panebutton" style="bottom:6%;left:59%;" @click="drcclick">
|
||||
<img class="buttonimg" :src="doorrightimg" />
|
||||
<div class="buttontext">{{ $t('jlmap3d.closeRightDoor') }}</div>
|
||||
</div>
|
||||
<div id="urgestop" class="panebutton" style="bottom:6%;left:73%;" @click="ebstop">
|
||||
<img class="buttonimg" :style="urgestopStyle" :src="urgestopimg" />
|
||||
<div class="buttontext">{{ $t('jlmap3d.emergencyBraking') }}</div>
|
||||
</div>
|
||||
<div id="doorpick" class="panebutton2" style="bottom:6%;left:85%;">
|
||||
<img class="buttonimg2" :src="zuoimg" />
|
||||
<img class="buttonimg2" :src="niuimg" :style="{transform:doordirecttou}" @touchstart='doordirecttouchstart' @touchmove='doordirecttouchmove' @touchend='doordirecttouchend'/>
|
||||
<div class="tfbutton" style="font-size:1px;top:13px;left:5px;">{{ $t('jlmap3d.leftSide') }}</div>
|
||||
<div class="tfbutton" style="font-size:1px;top:8px;left:33px;">{{ $t('jlmap3d.location0') }}</div>
|
||||
<div class="tfbutton" style="font-size:1px;top:13px;left:50px;">{{ $t('jlmap3d.rightSide') }}</div>
|
||||
<div class="buttontext2">{{ $t('jlmap3d.doorSideChoose') }}</div>
|
||||
</div> -->
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Vue from 'vue';
|
||||
// import { sendSimulationCommand } from '@/api/simulation.js';
|
||||
import { trainSimulationDriveMode, trainSimulationAto ,trainSimulationAtp,trainSimulationChangeHead,trainSimulationDoorControl,trainSimulationEb } from '@/jlmap3d/jl3ddrive/drivecontrol/simulation.js';
|
||||
|
||||
import { JL3D_LOCAL_STATIC } from '@/api/jlmap3d/assets3d.js';
|
||||
|
||||
export default {
|
||||
name: 'TopRightPane',
|
||||
components: {
|
||||
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
move:0,
|
||||
movex:"20%",
|
||||
apoimg:JL3D_LOCAL_STATIC+"/jl3d/control/green.png",
|
||||
sgimg:JL3D_LOCAL_STATIC+"/jl3d/control/redz.png",
|
||||
jgimg:JL3D_LOCAL_STATIC+"/jl3d/control/greenz.png",
|
||||
atpimg:JL3D_LOCAL_STATIC+"/jl3d/control/atp.png",
|
||||
slimg:JL3D_LOCAL_STATIC+"/jl3d/control/gray.png",
|
||||
zuoimg:JL3D_LOCAL_STATIC+"/jl3d/control/zuo.png",
|
||||
niuimg:JL3D_LOCAL_STATIC+"/jl3d/control/niu.png",
|
||||
toutransform:"rotate(0deg)",
|
||||
|
||||
redlimg:JL3D_LOCAL_STATIC+"/jl3d/control/redl.png",
|
||||
greenimg:JL3D_LOCAL_STATIC+"/jl3d/control/green.png",
|
||||
urgestopimg:JL3D_LOCAL_STATIC+"/jl3d/control/urgestop.png",
|
||||
iconrotate:0,
|
||||
doordirecttou:"rotate(0deg)",
|
||||
doormodetou:"rotate(0deg)",
|
||||
watertou:"rotate(0deg)",
|
||||
washtou:"rotate(0deg)",
|
||||
|
||||
greenzimg:JL3D_LOCAL_STATIC+"/jl3d/control/greenz.png",
|
||||
redzimg:JL3D_LOCAL_STATIC+"/jl3d/control/redz.png",
|
||||
redimg:JL3D_LOCAL_STATIC+"/jl3d/control/red.png",
|
||||
greenlimg:JL3D_LOCAL_STATIC+"/jl3d/control/greenl.png",
|
||||
grayimg:JL3D_LOCAL_STATIC+"/jl3d/control/gray.png",
|
||||
aircomimg:JL3D_LOCAL_STATIC+"/jl3d/control/aircom.png",
|
||||
passlighttf:"rotate(0deg)",
|
||||
sivtf:"rotate(0deg)",
|
||||
driverlighttf:"rotate(0deg)",
|
||||
headlighttf:"rotate(0deg)",
|
||||
|
||||
// atoOn:null,
|
||||
atobuttonimg:JL3D_LOCAL_STATIC+"/jl3d/control/green.png",
|
||||
// driveMode:null,
|
||||
rmbuttonimg:JL3D_LOCAL_STATIC+"/jl3d/control/green.png",
|
||||
// runLevel:null,
|
||||
cbtcbuttonimg:JL3D_LOCAL_STATIC+"/jl3d/control/green.png",
|
||||
doorleftstatus:false,
|
||||
doorrightstatus:false,
|
||||
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: {
|
||||
|
||||
},
|
||||
props: {
|
||||
groupNum: {
|
||||
type: String,
|
||||
default: null
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
group() {
|
||||
return this.$route.query.group;
|
||||
},
|
||||
urgestopStyle:function(){
|
||||
let arr = new Array();
|
||||
arr.push('transform:');
|
||||
arr.push('rotate('+this.iconrotate+'deg) ');
|
||||
return arr.join("");
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
window.updatabuttonlight = this.updatabuttonlight;
|
||||
window.updatedoorlight = this.updatedoorlight;
|
||||
},
|
||||
beforeDestroy() {
|
||||
|
||||
},
|
||||
methods: {
|
||||
topstate : function(tops){
|
||||
if(tops.atpCutOff == true){
|
||||
|
||||
}else{
|
||||
|
||||
}
|
||||
},
|
||||
topcontrol : function(){
|
||||
|
||||
},
|
||||
showmsg:function(data){
|
||||
wx.showToast({
|
||||
title: data,
|
||||
icon: 'loading',
|
||||
duration: 2000
|
||||
});
|
||||
},
|
||||
showcontrolmsg:function(data,callback){
|
||||
this.controlmsg = data;
|
||||
this.msgshow = true;
|
||||
callback = callback || function(){
|
||||
this.setData();
|
||||
};
|
||||
setTimeout( callback.bind(this),2000);
|
||||
},
|
||||
stopmodetouchstart:function(e){
|
||||
// let command ={
|
||||
// code:this.traincode,
|
||||
// operation:"607",
|
||||
// type:"07",
|
||||
// param:""
|
||||
// };
|
||||
// command.param = this.touchstate;
|
||||
// sendSimulationCommand(this.group,command).then(netdata => {
|
||||
// if(netdata.data == true){
|
||||
this.touchcontrol = true;
|
||||
// }
|
||||
// });
|
||||
},
|
||||
stopmodetouchmove:function(e){//finger move 触发
|
||||
if(this.touchcontrol == true){
|
||||
this.getAngle(e.changedTouches[0].clientX,e.changedTouches[0].clientY);
|
||||
}
|
||||
},
|
||||
stopmodetouchend:function(e){
|
||||
this.touchcontrol = false;
|
||||
},
|
||||
getAngle:function(mx,my){
|
||||
//圆心坐标
|
||||
let px=140;
|
||||
let py=510;
|
||||
let x = Math.abs(px-mx);
|
||||
let y = Math.abs(py-my);
|
||||
let z = Math.sqrt(Math.pow(x,2)+Math.pow(y,2));
|
||||
let cos = y/z;
|
||||
let radina = Math.acos(cos);//用反三角函数求弧度
|
||||
let angle = Math.floor(180/(Math.PI/radina));//将弧度转换成角度
|
||||
|
||||
if(mx>px&&my>py){//鼠标在第四象限
|
||||
angle = 180 - angle;
|
||||
}
|
||||
|
||||
if(mx==px&&my>py){//鼠标在y轴负方向上
|
||||
angle = 180;
|
||||
}
|
||||
|
||||
if(mx>px&&my==py){//鼠标在x轴正方向上
|
||||
angle = 90;
|
||||
}
|
||||
|
||||
if(mx<px&&my>py){//鼠标在第三象限
|
||||
angle = 180+angle;
|
||||
}
|
||||
|
||||
if(mx<px&&my==py){//鼠标在x轴负方向
|
||||
angle = 270;
|
||||
}
|
||||
|
||||
if(mx<px&&my<py){//鼠标在第二象限
|
||||
angle = 360 - angle;
|
||||
}
|
||||
if(angle<338 && angle>219){
|
||||
|
||||
if(angle<245 && angle>219){
|
||||
this.toutransform = "rotate(305deg)";
|
||||
}else if(angle<295 && angle>245){
|
||||
this.toutransform = "rotate(359deg)";
|
||||
}else if(angle<338 && angle>295){
|
||||
this.toutransform = "rotate(412deg)";
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
doordirecttouchstart:function(e){
|
||||
// let command ={
|
||||
// code:this.traincode,
|
||||
// operation:"607",
|
||||
// type:"07",
|
||||
// param:""
|
||||
// };
|
||||
// command.param = this.touchstate;
|
||||
// sendSimulationCommand(this.group,command).then(netdata => {
|
||||
// if(netdata.data == true){
|
||||
this.touchcontrol = true;
|
||||
// }
|
||||
// });
|
||||
},
|
||||
doordirecttouchmove:function(e){//finger move 触发
|
||||
if(this.touchcontrol == true){
|
||||
let px=230;
|
||||
let py=180;
|
||||
let angle = this.getAngle(px,py,e.changedTouches[0].clientX,e.changedTouches[0].clientY);
|
||||
if(angle<338 && angle>219){
|
||||
if(angle<245 && angle>219){
|
||||
this.doordirecttou = "rotate(305deg)";
|
||||
}else if(angle<295 && angle>245){
|
||||
this.doordirecttou = "rotate(359deg)";
|
||||
}else if(angle<338 && angle>295){
|
||||
this.doordirecttou = "rotate(412deg)";
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
doordirecttouchend:function(e){
|
||||
this.touchcontrol = false;
|
||||
},
|
||||
sgclink: function (e){
|
||||
//console.log("升弓");
|
||||
},
|
||||
jgclick: function (e){
|
||||
//console.log("降弓");
|
||||
},
|
||||
slclick: function (e){
|
||||
//console.log("试灯");
|
||||
},
|
||||
atpclick: function (e){
|
||||
//console.log("atp");
|
||||
let data = {
|
||||
groupNumber:this.groupNum,
|
||||
cutOff:true,
|
||||
};
|
||||
trainSimulationAtp(this.group,data).then(netdata => {
|
||||
// console.log(netdata);
|
||||
});
|
||||
},
|
||||
|
||||
atbclick: function (e){
|
||||
|
||||
},
|
||||
changehead: function(e){
|
||||
let data = {
|
||||
groupNumber:this.groupNum,
|
||||
};
|
||||
trainSimulationChangeHead(this.group,data).then(netdata => {
|
||||
// console.log(netdata);
|
||||
});
|
||||
},
|
||||
bmcbtcclick: function (e){
|
||||
let data = {
|
||||
groupNumber:this.groupNum,
|
||||
driveMode:"CM"
|
||||
};
|
||||
trainSimulationDriveMode(this.group,data).then(netdata => {
|
||||
// console.log(netdata);
|
||||
});
|
||||
},
|
||||
rmclick: function (e){
|
||||
let data = {
|
||||
groupNumber:this.groupNum,
|
||||
driveMode:"RM"
|
||||
};
|
||||
trainSimulationDriveMode(this.group,data).then(netdata => {
|
||||
// console.log(netdata);
|
||||
});
|
||||
},
|
||||
updatedoorlight: function (newdata){
|
||||
if(newdata.leftDoorCanClose != undefined){
|
||||
// this.doorleftstatus = newdata.leftDoorCanClose;
|
||||
if(newdata.leftDoorCanClose == true){
|
||||
this.doorleftimg = this.greenlimg;
|
||||
}else{
|
||||
this.doorleftimg = this.greenimg;
|
||||
}
|
||||
}
|
||||
if(newdata.rightDoorCanClose != undefined){
|
||||
// this.doorrightstatus = newdata.rightDoorCanClose;
|
||||
if(newdata.rightDoorCanClose == true){
|
||||
this.doorrightimg = this.greenlimg;
|
||||
}else{
|
||||
this.doorrightimg = this.greenimg;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
dloclick: function (e){
|
||||
let data = {
|
||||
groupNumber:this.groupNum,
|
||||
right:false,
|
||||
open:true,
|
||||
};
|
||||
trainSimulationDoorControl(this.group,data).then(netdata => {
|
||||
// console.log(netdata);
|
||||
});
|
||||
},
|
||||
dlcclick: function (e){
|
||||
let data = {
|
||||
groupNumber:this.groupNum,
|
||||
right:false,
|
||||
open:false,
|
||||
};
|
||||
trainSimulationDoorControl(this.group,data).then(netdata => {
|
||||
// console.log(netdata);
|
||||
this.doorleftimg = this.greenimg;
|
||||
});
|
||||
},
|
||||
|
||||
droclick: function (e){
|
||||
let data = {
|
||||
groupNumber:this.groupNum,
|
||||
right:true,
|
||||
open:true,
|
||||
};
|
||||
trainSimulationDoorControl(this.group,data).then(netdata => {
|
||||
// console.log(netdata);
|
||||
});
|
||||
},
|
||||
drcclick: function (e){
|
||||
let data = {
|
||||
groupNumber:this.groupNum,
|
||||
right:true,
|
||||
open:false,
|
||||
};
|
||||
trainSimulationDoorControl(this.group,data).then(netdata => {
|
||||
// console.log(netdata);
|
||||
this.doorrightimg = this.greenimg;
|
||||
});
|
||||
},
|
||||
atoaclick: function (e){
|
||||
let data = {
|
||||
groupNumber:this.groupNum,
|
||||
};
|
||||
trainSimulationAto(this.group,data).then(netdata => {
|
||||
// console.log(netdata);
|
||||
});
|
||||
},
|
||||
cbtcclick: function (e){
|
||||
|
||||
},
|
||||
ebstop: function (e){
|
||||
let data = {
|
||||
groupNumber:this.groupNum,
|
||||
};
|
||||
trainSimulationEb(this.group,data).then(netdata => {
|
||||
// console.log(netdata);
|
||||
});
|
||||
},
|
||||
updatabuttonlight: function (data){
|
||||
// console.log(data);
|
||||
if(data.runLevel){
|
||||
// this.runLevel = data.runLevel;
|
||||
if(data.runLevel == "CBTC"){
|
||||
this.cbtcbuttonimg = this.greenlimg;
|
||||
}else{
|
||||
this.cbtcbuttonimg = this.greenimg;
|
||||
}
|
||||
}
|
||||
if(data.driveMode){
|
||||
// this.driveMode = data.driveMode;
|
||||
if(data.driveMode == "RM"){
|
||||
this.rmbuttonimg = this.greenlimg;
|
||||
}else{
|
||||
this.rmbuttonimg = this.greenimg;
|
||||
}
|
||||
}
|
||||
if(typeof(data.atoOn) != "undefined"){
|
||||
// console.log(data.atoOn);
|
||||
// this.atoOn = data.atoOn;
|
||||
if(data.atoOn){
|
||||
this.atobuttonimg = this.greenlimg;
|
||||
}else{
|
||||
this.atobuttonimg = this.greenimg;
|
||||
}
|
||||
}
|
||||
|
||||
if(typeof(data.circuitEB) != "undefined"){
|
||||
if(data.circuitEB){
|
||||
this.iconrotate = 0;
|
||||
}else{
|
||||
this.iconrotate = 160;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.aa{
|
||||
transition: all 2s;
|
||||
}
|
||||
.go{
|
||||
transform:rotate(-180deg);
|
||||
transition: all 2s;
|
||||
}
|
||||
</style>
|
459
src/views/jlmap3d/railwaydrive/jl3drailwaydrive.vue
Normal file
459
src/views/jlmap3d/railwaydrive/jl3drailwaydrive.vue
Normal file
@ -0,0 +1,459 @@
|
||||
<template>
|
||||
|
||||
<div id="drivediv" class="jalmap3ddiv" >
|
||||
|
||||
<!-- <div class="trainstatus">
|
||||
{{$t('jlmap3d.trainGroupNumber')}}{{ trainnum }}</br>
|
||||
{{ stoptimes }}
|
||||
</div> -->
|
||||
<div class="display-draft">
|
||||
<el-button-group>
|
||||
|
||||
<!-- <el-button type="primary" @click="raystand">站台选择</el-button> -->
|
||||
<el-button type="primary" @click="cctvplane">{{ cctvbuttonmsg }}</el-button>
|
||||
<el-button type="primary" @click="showplane">{{ showbuttonmsg }}</el-button>
|
||||
<el-button type="primary" @click="back">{{backmsg}}</el-button>
|
||||
</el-button-group>
|
||||
</div>
|
||||
|
||||
<!-- <Jlmap3d-Msg v-bind:msgdata="msgdata" >
|
||||
</Jlmap3d-Msg > -->
|
||||
|
||||
<div id="jlsimulation" class="jlmap3ddraw">
|
||||
<canvas id="canvastexture" />
|
||||
</div>
|
||||
<div id="jlcctv" v-show="cctvshow" class="jlmap3cctv">
|
||||
</div>
|
||||
|
||||
<div class="msg" v-show ="msgshow">
|
||||
<div class="msgtext">
|
||||
{{controlmsg}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Drive-Mmi v-if="mmishow" ref="mmiui" />
|
||||
|
||||
<!-- <Drive-Tms v-if="mmishow" /> -->
|
||||
<Drive-Control v-if="dcontrolshow" ref="dcontrol" @warningmsg="warningmsg" @warningmsgoff="warningmsgoff" />
|
||||
</div>
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Vue from 'vue';
|
||||
import localStore from 'storejs';
|
||||
import axios from 'axios';
|
||||
import store from '@/store/index';
|
||||
|
||||
import { mapGetters } from 'vuex';
|
||||
|
||||
// import ShowProperty from '@/views/jlmap3d/show/property';
|
||||
|
||||
import { simulationNotify, setTrainingCbtcInitTime } from '@/api/simulation';
|
||||
|
||||
import { getPublishMapDetail, getPublish3dMapDetail } from '@/api/jlmap3d/load3ddata';
|
||||
|
||||
import { UrlConfig } from '@/scripts/ConstDic';
|
||||
|
||||
import { JLmapDriving } from '@/jlmap3d/jl3drailwaydrive/jl3drailwaydrive';
|
||||
|
||||
import DriveMmi from '@/views/jlmap3d/railwaydrive/sceneview/mmiview';
|
||||
import DriveTms from '@/views/jlmap3d/railwaydrive/sceneview/tmsview';
|
||||
import DriveControl from '@/views/jlmap3d/railwaydrive/drivecontrol/drivecontrol';
|
||||
|
||||
var train;
|
||||
export default {
|
||||
name: 'Jl3dRailwayDrive',
|
||||
components: {
|
||||
DriveMmi,
|
||||
// DriveTms,
|
||||
DriveControl
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
driveIndex:1500,
|
||||
trainlist: null,
|
||||
stationlist: null,
|
||||
msgdata: null,
|
||||
training: {
|
||||
id: '',
|
||||
name: '',
|
||||
remarks: ''
|
||||
},
|
||||
mapdata: null,
|
||||
jlmap3d: null,
|
||||
selectmodel: null,
|
||||
cctvshow:true,
|
||||
cctvbuttonmsg: this.$t('jlmap3d.surveillanceHidden'),
|
||||
mmishow: false,
|
||||
showbuttonmsg: this.$t('jlmap3d.trainInstrumentationDisplay'),
|
||||
backmsg:this.$t('global.back'),
|
||||
// trainnum: '',
|
||||
// stoptimes: '',
|
||||
dcontrolshow: true,
|
||||
msgshow:false,
|
||||
controlmsg:"不能选择其它列车",
|
||||
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
'jlmap3d.nowspeed': {
|
||||
handler: function (newVal, oldVal) {
|
||||
if (newVal != oldVal) {
|
||||
if (this.mmishow == true) {
|
||||
this.$refs.mmiui.updatespeed(newVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
'jlmap3d.nowmxlen': {
|
||||
handler: function (newVal, oldVal) {
|
||||
if (newVal != oldVal) {
|
||||
if (this.mmishow == true) {
|
||||
this.$refs.mmiui.updatelen(newVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
'jlmap3d.atpspeed': {
|
||||
handler: function (newVal, oldVal) {
|
||||
if (newVal != oldVal) {
|
||||
if (this.mmishow == true) {
|
||||
this.$refs.mmiui.updateatpspeed(newVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
'jlmap3d.atospeed': {
|
||||
handler: function (newVal, oldVal) {
|
||||
if (newVal != oldVal) {
|
||||
if (this.mmishow == true) {
|
||||
this.$refs.mmiui.updateatospeed(newVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
// 'jlmap3d.trainnum': {
|
||||
// handler: function (newVal, oldVal) {
|
||||
// if (newVal != oldVal) {
|
||||
// this.trainnum = newVal;
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
// 'jlmap3d.stime': {
|
||||
// handler: function (newVal, oldVal) {
|
||||
// if (newVal != oldVal) {
|
||||
// this.stoptimes = newVal;
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
// 'jlmap3d.drivecount': {
|
||||
// handler: function (newVal, oldVal) {
|
||||
// if (newVal != oldVal) {
|
||||
// this.$refs.mmiui.updatedrivedata(this.jlmap3d.drivedata);
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
|
||||
},
|
||||
beforeDestroy() {
|
||||
if (this.jlmap3d) {
|
||||
this.jlmap3d.webwork.postMessage('off');
|
||||
this.jlmap3d.webwork.terminate();
|
||||
this.jlmap3d.endsocket();
|
||||
this.jlmap3d.dispose();
|
||||
this.jlmap3d = null;
|
||||
|
||||
// this.$destroy();
|
||||
}
|
||||
},
|
||||
destroyed(){
|
||||
// window.removeEventListener('popstate', this.goBack, false);
|
||||
},
|
||||
computed: {
|
||||
userId() {
|
||||
return this.$store.state.user ? this.$store.state.user.id : '';
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.mmishow = true;
|
||||
// window.datanew = this.datanew;
|
||||
window.updatestatus = this.updatestatus;
|
||||
|
||||
if(this.$route.query.type == "DRIVE"){
|
||||
this.backmsg = "退出";
|
||||
}
|
||||
|
||||
// if (window.history && window.history.pushState) {
|
||||
// history.pushState(null, null, document.URL);
|
||||
// window.addEventListener('popstate', this.goBack, false);
|
||||
// }
|
||||
// this.$refs.mmiui.init();
|
||||
},
|
||||
methods: {
|
||||
// goBack(){
|
||||
// console.log(this.$route);
|
||||
// if(this.$route.query.type == "DRIVE"){
|
||||
// store.dispatch('LogOut').then(() => {
|
||||
// location.reload();
|
||||
// });
|
||||
// }else{
|
||||
// this.$emit('showdriving');
|
||||
// if(this.jlmap3d){
|
||||
// this.jlmap3d.eventoff();
|
||||
// this.jlmap3d.animateoff();
|
||||
// }
|
||||
//
|
||||
// // this.jlmap3d = null;
|
||||
// }
|
||||
// },
|
||||
show: function (skinCode,group,zindex,isTraining) {
|
||||
// console.log("show");
|
||||
// console.log(skinCode);
|
||||
// console.log(this.jlmap3d);
|
||||
if(zindex){
|
||||
this.driveIndex = zindex;
|
||||
document.getElementById("drivediv").style.zIndex = zindex;
|
||||
}
|
||||
if (this.jlmap3d == null) {
|
||||
this.init(skinCode,group);
|
||||
} else {
|
||||
// this.jlmap3d.restart();
|
||||
this.jlmap3d.eventon();
|
||||
this.jlmap3d.animateon();
|
||||
}
|
||||
if(isTraining){
|
||||
this.$refs.dcontrol.changeTrainSelect(isTraining);
|
||||
}
|
||||
},
|
||||
init: function (skinCode,group) {
|
||||
const mapdata = this.$store.getters['map/map'];
|
||||
const dom = document.getElementById('app');
|
||||
let translation = {
|
||||
trainAtoOn: this.$t('jlmap3d.trainAtoOn'),
|
||||
trainAtoOff: this.$t('jlmap3d.trainAtoOff'),
|
||||
stopTime: this.$t('jlmap3d.stopTime')
|
||||
};
|
||||
|
||||
let project = this.$route.query.project;
|
||||
// console.log(project);
|
||||
if(project){
|
||||
this.jlmap3d = new JLmapDriving(dom, mapdata, skinCode,this.$store,translation,group,project);
|
||||
}else{
|
||||
this.jlmap3d = new JLmapDriving(dom, mapdata, skinCode,this.$store,translation,group,project);
|
||||
}
|
||||
|
||||
// console.log(translation);
|
||||
// this.jlmap3d = new JLmapDriving(dom, mapdata, skinCode,this.$store,translation,group);
|
||||
this.jlmap3d.eventon();
|
||||
this.cctvshow = false;
|
||||
|
||||
},
|
||||
raystand() {
|
||||
this.jlmap3d.rayswitch('stand');
|
||||
},
|
||||
raytrain() {
|
||||
this.jlmap3d.rayswitch('train');
|
||||
},
|
||||
raysection() {
|
||||
this.jlmap3d.rayswitch('section');
|
||||
},
|
||||
raysignal() {
|
||||
this.jlmap3d.rayswitch('signal');
|
||||
},
|
||||
rayswitch() {
|
||||
this.jlmap3d.rayswitch('switch');
|
||||
},
|
||||
sstation(changedata) {
|
||||
this.jlmap3d.updatecamera(changedata.mesh, 'station');
|
||||
},
|
||||
strain(changedata) {
|
||||
if (changedata.dispose == false) {
|
||||
this.jlmap3d.updatecamera(changedata, 'train');
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
back() {
|
||||
|
||||
if(this.$route.query.type == "DRIVE"){
|
||||
store.dispatch('LogOut').then(() => {
|
||||
location.reload();
|
||||
});
|
||||
}else{
|
||||
this.$emit('showdriving');
|
||||
this.jlmap3d.eventoff();
|
||||
this.jlmap3d.animateoff();
|
||||
// this.jlmap3d = null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
},
|
||||
showplane() {
|
||||
if (this.mmishow == true) {
|
||||
this.showbuttonmsg = this.$t('jlmap3d.trainInstrumentationHidden');
|
||||
this.mmishow = false;
|
||||
} else {
|
||||
this.showbuttonmsg = this.$t('jlmap3d.trainInstrumentationDisplay');
|
||||
this.mmishow = true;
|
||||
}
|
||||
|
||||
},
|
||||
datanew(){
|
||||
this.dcontrolshow = true;
|
||||
},
|
||||
cctvplane() {
|
||||
if (this.cctvshow == true) {
|
||||
this.cctvbuttonmsg = this.$t('jlmap3d.surveillanceHidden');
|
||||
this.cctvshow = false;
|
||||
this.jlmap3d.cctvoff();
|
||||
} else {
|
||||
this.cctvbuttonmsg = this.$t('jlmap3d.surveillanceDisplay');
|
||||
this.cctvshow = true;
|
||||
this.jlmap3d.cctvon();
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
updatestatus(newdata){
|
||||
// if(newdata.groupNumber){
|
||||
// this.trainnum = newdata.groupNumber;
|
||||
//
|
||||
// updateDriveValue(this.trainnum);
|
||||
// }
|
||||
updatedoorlight(newdata);
|
||||
if(this.$refs.mmiui){
|
||||
this.$refs.mmiui.updatetrainstatus(newdata);
|
||||
}
|
||||
|
||||
updatabuttonlight(newdata);
|
||||
},
|
||||
warningmsg(nowmsg){
|
||||
this.controlmsg = nowmsg;
|
||||
this.msgshow = true;
|
||||
setTimeout(this.warningmsgoff,3000);
|
||||
},
|
||||
warningmsgoff(){
|
||||
this.msgshow = false;
|
||||
|
||||
},
|
||||
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style rel="stylesheet/scss" lang="scss" scoped>
|
||||
@import "src/styles/mixin.scss";
|
||||
|
||||
.display-card {
|
||||
z-index: 9;
|
||||
display: inline;
|
||||
position: absolute;
|
||||
top: 17px;
|
||||
float: left;
|
||||
left: 160px;
|
||||
height: 32px;
|
||||
}
|
||||
|
||||
.display-card .el-row {
|
||||
line-height: 32px !important;
|
||||
}
|
||||
|
||||
.display-score {
|
||||
background-color: black;
|
||||
display: -moz-inline-box;
|
||||
display: inline-block;
|
||||
text-align: left;
|
||||
/* border: 1px solid lightskyblue; */
|
||||
/* width: 100px; */
|
||||
height: 32px;
|
||||
line-height: 24px;
|
||||
border-radius: 4px;
|
||||
padding-left: 2px;
|
||||
margin-left: 10px;
|
||||
font-family: "Microsoft" !important;
|
||||
font-size: 18px !important;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.display-draft {
|
||||
/* z-index: 1000; */
|
||||
position: absolute;
|
||||
float: right;
|
||||
right: 40px;
|
||||
top: 28px;
|
||||
}
|
||||
|
||||
#jlsimulation {
|
||||
width: 937px;
|
||||
height: 937px;
|
||||
}
|
||||
|
||||
.trainstatus{
|
||||
left:48%;
|
||||
top:0;
|
||||
width:fit-content;
|
||||
width:-webkit-fit-content;
|
||||
width:-moz-fit-content;
|
||||
height:60px;
|
||||
background: #000000;
|
||||
position:absolute;
|
||||
text-align: left;
|
||||
color:white;
|
||||
font-size:25px;
|
||||
}
|
||||
|
||||
.jalmap3ddiv {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
top:0;
|
||||
z-index: 1500;
|
||||
}
|
||||
|
||||
.jlmap3ddraw {
|
||||
float: left;
|
||||
left: 0;
|
||||
//left:20%;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position:absolute;
|
||||
z-index: -1;
|
||||
}
|
||||
|
||||
.jlmap3cctv{
|
||||
float: left;
|
||||
left: 0;
|
||||
top:0;
|
||||
//left:20%;
|
||||
width: 20%;
|
||||
height: 20%;
|
||||
position:absolute;
|
||||
z-index: -1;
|
||||
}
|
||||
|
||||
#canvastexture {
|
||||
position: absolute;
|
||||
float: left;
|
||||
left: 0;
|
||||
z-index: -12;
|
||||
}
|
||||
|
||||
.msg{
|
||||
width:40%;
|
||||
height:50px;
|
||||
left:30%;
|
||||
top:0;
|
||||
text-align: center;
|
||||
position:absolute;
|
||||
}
|
||||
.msgtext{
|
||||
width:100%;
|
||||
height:50px;
|
||||
border-radius:5px;
|
||||
background:#C0C0C0;
|
||||
color:#FFFFFF;
|
||||
font-size: 40px;
|
||||
}
|
||||
</style>
|
78
src/views/jlmap3d/railwaydrive/sceneview/mmi.css
Normal file
78
src/views/jlmap3d/railwaydrive/sceneview/mmi.css
Normal file
@ -0,0 +1,78 @@
|
||||
/* N区 跳停扣车显示 */
|
||||
.narea{
|
||||
left:0px;top:0;
|
||||
}
|
||||
|
||||
/* D区 信息设置按钮 */
|
||||
.darea{
|
||||
right:0px;top:0;
|
||||
}
|
||||
|
||||
/* M1区 当前驾驶模式显示 */
|
||||
.m1area{
|
||||
left:0px;top:12%;
|
||||
}
|
||||
|
||||
/* M2区 当前运行等级显示 */
|
||||
.m2area{
|
||||
right:0px;top:12%;
|
||||
}
|
||||
|
||||
/* M3区 折返状态显示 */
|
||||
.m3area{
|
||||
left:0px;top:24%;
|
||||
}
|
||||
|
||||
/* M4区 列车进入停车窗显示 */
|
||||
.m4area{
|
||||
right:0px;top:24%;
|
||||
}
|
||||
|
||||
/* M5区 车门状态及门允许侧显示 */
|
||||
.m5area{
|
||||
left:0px;top:36%;
|
||||
}
|
||||
|
||||
/* M6区 发车信息显示 */
|
||||
.m6area{
|
||||
right:0px;top:36%;
|
||||
}
|
||||
|
||||
/* M7区 客室门控制模式显示 */
|
||||
.m7area{
|
||||
left:0px;top:48%;
|
||||
}
|
||||
|
||||
/* M8区 屏蔽门状态显示 */
|
||||
.m8area{
|
||||
right:0px;top:48%;
|
||||
}
|
||||
|
||||
/* M9区 设备故障显示 */
|
||||
.m9area{
|
||||
left:0px;top:60%;
|
||||
}
|
||||
|
||||
/* M10区 停车场/车辆段的转换区显示 */
|
||||
.m10area{
|
||||
right:0px;top:60%;
|
||||
}
|
||||
|
||||
/* C1区 ATO牵引制动状态显示 */
|
||||
.c1area{
|
||||
}
|
||||
|
||||
/* C2区 最高预设驾驶模式显示 */
|
||||
.c2area{
|
||||
left:70px;
|
||||
}
|
||||
|
||||
/* C3区 列车完整性状态显示 */
|
||||
.c3area{
|
||||
left:140px;
|
||||
}
|
||||
|
||||
/* C5区 列车头尾设备状态显示 */
|
||||
.c5area{
|
||||
right:0;
|
||||
}
|
127
src/views/jlmap3d/railwaydrive/sceneview/mmi.js
Normal file
127
src/views/jlmap3d/railwaydrive/sceneview/mmi.js
Normal file
@ -0,0 +1,127 @@
|
||||
import Vue from 'vue';
|
||||
import { JL3D_LOCAL_STATIC } from '@/api/jlmap3d/assets3d.js';
|
||||
|
||||
export function mmirender(dom) {
|
||||
let scope = this;
|
||||
|
||||
let scene = new THREE.Scene();
|
||||
scene.add( new THREE.AmbientLight( 0xffffff ) );
|
||||
// camera
|
||||
|
||||
let camera = new THREE.PerspectiveCamera( 30, 360 / 200, 1, 100 );
|
||||
camera.position.set( 0, 0, 80 );
|
||||
|
||||
let renderer = new THREE.WebGLRenderer( );
|
||||
// renderer.setPixelRatio( window.devicePixelRatio );
|
||||
renderer.setSize( 360, 200 );
|
||||
|
||||
var geometry = new THREE.PlaneBufferGeometry( 80, 80, 2 );
|
||||
var material = new THREE.MeshBasicMaterial( {color: 0x000000, side: THREE.DoubleSide} );
|
||||
var plane = new THREE.Mesh( geometry, material );
|
||||
scene.add( plane );
|
||||
|
||||
|
||||
var texture = new THREE.TextureLoader().load( JL3D_LOCAL_STATIC+'/jl3d/biao.png' );
|
||||
var geometry = new THREE.PlaneBufferGeometry( 60, 60, 2 );
|
||||
var material = new THREE.MeshBasicMaterial( {map: texture, side: THREE.DoubleSide} );
|
||||
var kd = new THREE.Mesh( geometry, material );
|
||||
kd.position.x = -5;
|
||||
scene.add( kd );
|
||||
|
||||
var geometry = new THREE.PlaneBufferGeometry( 2, 2, 2 );
|
||||
var material = new THREE.MeshBasicMaterial( {color: 0x000000, side: THREE.DoubleSide} );
|
||||
var zc = new THREE.Mesh( geometry, material );
|
||||
zc.position.x = 2.48;
|
||||
zc.position.y = -0.34;
|
||||
zc.position.z = 1;
|
||||
//zc.rotation.y = Math.PI;
|
||||
//0刻度-Math.PI*65.8/100
|
||||
//110刻度-Math.PI*234.8/100
|
||||
zc.rotation.z = -Math.PI*65.8/100;
|
||||
scene.add( zc );
|
||||
|
||||
var geometry = new THREE.PlaneBufferGeometry( 14, 0.8, 2 );
|
||||
var material = new THREE.MeshBasicMaterial( {color: 0xffffff, side: THREE.DoubleSide} );
|
||||
var zz = new THREE.Mesh( geometry, material );
|
||||
zz.position.z = 1;
|
||||
zz.position.x = 11;
|
||||
zc.add( zz );
|
||||
|
||||
var geometry = new THREE.PlaneBufferGeometry( 2, 2, 2 );
|
||||
var material = new THREE.MeshBasicMaterial( {color: 0x000000, side: THREE.DoubleSide} );
|
||||
var atp = new THREE.Mesh( geometry, material );
|
||||
atp.position.x = 2.48;
|
||||
atp.position.y = -0.34;
|
||||
atp.position.z = 1;
|
||||
//zc.rotation.y = Math.PI;
|
||||
//0刻度-Math.PI*65.8/100
|
||||
//110刻度-Math.PI*234.8/100
|
||||
atp.rotation.z = -Math.PI*65.8/100;
|
||||
scene.add( atp );
|
||||
|
||||
var geometry = new THREE.CircleBufferGeometry(1.5, 1 );
|
||||
var material = new THREE.MeshBasicMaterial( {color: 0xea0000, side: THREE.DoubleSide} );
|
||||
var atpmark = new THREE.Mesh( geometry, material );
|
||||
atpmark.position.z = 1;
|
||||
atpmark.position.x = 21;
|
||||
atpmark.rotation.y = Math.PI;
|
||||
atp.add( atpmark );
|
||||
|
||||
var geometry = new THREE.PlaneBufferGeometry( 2, 2, 2 );
|
||||
var material = new THREE.MeshBasicMaterial( {color: 0x000000, side: THREE.DoubleSide} );
|
||||
var ato = new THREE.Mesh( geometry, material );
|
||||
ato.position.x = 2.48;
|
||||
ato.position.y = -0.34;
|
||||
ato.position.z = 1;
|
||||
//zc.rotation.y = Math.PI;
|
||||
//0刻度-Math.PI*65.8/100
|
||||
//110刻度-Math.PI*234.8/100
|
||||
ato.rotation.z = -Math.PI*65.8/100;
|
||||
scene.add( ato );
|
||||
|
||||
var geometry = new THREE.CircleBufferGeometry(1.5, 1 );
|
||||
var material = new THREE.MeshBasicMaterial( {color: 0xEEEE00, side: THREE.DoubleSide} );
|
||||
var atomark = new THREE.Mesh( geometry, material );
|
||||
atomark.position.z = 1;
|
||||
atomark.position.x = 21;
|
||||
atomark.rotation.y = Math.PI;
|
||||
ato.add( atomark );
|
||||
|
||||
|
||||
|
||||
dom.appendChild( renderer.domElement);
|
||||
renderer.render( scene, camera );
|
||||
// animate();
|
||||
|
||||
function animate() {
|
||||
//zc.rotation.z -= 0.01;
|
||||
// requestAnimationFrame(animate);
|
||||
}
|
||||
|
||||
this.updatezz = function(speed){
|
||||
zc.rotation.z = -Math.PI*(65.8+169*speed/110)/100;
|
||||
|
||||
renderer.render( scene, camera );
|
||||
}
|
||||
this.updateatp = function(atpspeed){
|
||||
if(atpspeed<0){
|
||||
atp.position.x = 10000;
|
||||
}else{
|
||||
atp.position.x = 2.48;
|
||||
atp.rotation.z = -Math.PI*(65.8+169*atpspeed/110)/100;
|
||||
}
|
||||
|
||||
// renderer.render( scene, camera );
|
||||
}
|
||||
|
||||
this.updateato = function(atospeed){
|
||||
if(atospeed<0){
|
||||
ato.position.x = 10000;
|
||||
}else{
|
||||
ato.position.x = 2.48;
|
||||
ato.rotation.z = -Math.PI*(65.8+169*atospeed/110)/100;
|
||||
}
|
||||
|
||||
// renderer.render( scene, camera );
|
||||
}
|
||||
}
|
98
src/views/jlmap3d/railwaydrive/sceneview/mmiimage.js
Normal file
98
src/views/jlmap3d/railwaydrive/sceneview/mmiimage.js
Normal file
@ -0,0 +1,98 @@
|
||||
import Vue from 'vue';
|
||||
import { JL3D_LOCAL_STATIC } from '@/api/jlmap3d/assets3d.js';
|
||||
|
||||
export function mmiimage() {
|
||||
let scope = this;
|
||||
|
||||
//n
|
||||
this.n = [];
|
||||
this.n['tiaoting'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/n-tiaoting.png';
|
||||
this.n['kouche'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/n-kouche.png';
|
||||
this.n['none'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/none.png';
|
||||
|
||||
//d
|
||||
this.d = []
|
||||
this.d['info'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/d-info.png';
|
||||
|
||||
this.m1 = [];
|
||||
this.m1['start'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/none.png';
|
||||
this.m1['am'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/m1-am.png';
|
||||
this.m1['cm'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/m1-cm.png';
|
||||
this.m1['rm'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/m1-rm.png';
|
||||
|
||||
this.m2 = [];
|
||||
this.m2['start'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/none.png';
|
||||
this.m2['il'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/m2-il.png';
|
||||
this.m2['itc'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/m2-itc.png';
|
||||
this.m2['cbtc'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/m2-cbtc.png';
|
||||
|
||||
this.m3 = [];
|
||||
this.m3['zhefan'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/m3-zhefan.png';
|
||||
this.m3['zhefanzhong'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/m3-zhefanzhong.png';
|
||||
this.m3['none'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/none.png';
|
||||
|
||||
this.m4 = [];
|
||||
this.m4['none'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/none.png';
|
||||
this.m4['out'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/m4-out.png';
|
||||
this.m4['in'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/m4-in.png';
|
||||
|
||||
this.m5 = [];
|
||||
this.m5['state15'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/m5-15.png';
|
||||
this.m5['rightdoor'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/m5-rightdoor.png';
|
||||
this.m5['leftdoor'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/m5-leftdoor.png';
|
||||
this.m5['noalloffdoor'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/m5-noalloffdoor.png';
|
||||
this.m5['noallondoor'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/m5-noallondoor.png';
|
||||
|
||||
this.m6 = [];
|
||||
this.m6['none'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/none.png';
|
||||
this.m6['fache'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/m6-fache.png';
|
||||
this.m6['closedoor'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/m6-closedoor.png';
|
||||
|
||||
this.m7 = [];
|
||||
this.m7['momc'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/m7-momc.png';
|
||||
this.m7['aomc'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/m7-aomc.png';
|
||||
this.m7['aoac'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/m7-aoac.png';
|
||||
this.m7['none'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/none.png';
|
||||
|
||||
this.m8 = [];
|
||||
this.m8['dahua'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/m8-dahua.png';
|
||||
this.m8['jinjizhidong'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/m8-jinjizhidong.png';
|
||||
this.m8['doornotclose'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/m8-doornotclose.png';
|
||||
this.m8['none'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/none.png';
|
||||
|
||||
this.m9 = [];
|
||||
this.m9['rad'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/m9-rad.png';
|
||||
this.m9['atp'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/m9-atp.png';
|
||||
this.m9['ato'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/m9-ato.png';
|
||||
this.m9['none'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/none.png';
|
||||
|
||||
this.m10 = [];
|
||||
this.m10['jinduan'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/m10-jinduan.png';
|
||||
this.m10['shiwei'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/m10-shiwei.png';
|
||||
this.m10['querenxinhao'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/m10-querenxinhao.png';
|
||||
this.m10['none'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/none.png';
|
||||
|
||||
this.c1 = [];
|
||||
this.c1['qianyin'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/c1-qianyin.png';
|
||||
this.c1['duoxing'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/c1-duoxing.png';
|
||||
this.c1['zhidong'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/c1-zhidong.png';
|
||||
this.c1['none'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/none.png';
|
||||
|
||||
|
||||
this.c2 = [];
|
||||
this.c2['rm'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/m1-rm.png';
|
||||
this.c2['cmi'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/c2-cm-i.png';
|
||||
this.c2['cmc'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/c2-cm-c.png';
|
||||
this.c2['ami'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/c2-am-i.png';
|
||||
this.c2['amc'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/c2-am-c.png';
|
||||
this.c2['none'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/none.png';
|
||||
|
||||
this.c3 = [];
|
||||
this.c3['normal'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/c3-normal.png';
|
||||
this.c3['lose'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/c3-lose.png';
|
||||
|
||||
this.c5 = [];
|
||||
this.c5['normal'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/c5-normal.png';
|
||||
this.c5['lose'] = JL3D_LOCAL_STATIC+'/jl3d/mmi/c5-lose.png';
|
||||
|
||||
}
|
647
src/views/jlmap3d/railwaydrive/sceneview/mmiview.vue
Normal file
647
src/views/jlmap3d/railwaydrive/sceneview/mmiview.vue
Normal file
@ -0,0 +1,647 @@
|
||||
<template>
|
||||
<div class = "mmi" >
|
||||
<div id="meter" class = "meter" >
|
||||
<div class="speedshow" >{{nowspeed}}</div>
|
||||
<div class="maxlenshow" :style="{height:malen}"></div>
|
||||
</div>
|
||||
|
||||
<div class = "top">
|
||||
<!-- <div style="left:5%;width:10%;height:100%;" :style="{background:a1state}">
|
||||
</div> -->
|
||||
|
||||
<!-- <div class="toptext" style="left:16%;top:15px;">
|
||||
{{$t('jlmap3d.terminal')}}{{endstation}}
|
||||
</div>
|
||||
|
||||
<div class="toptext" style="left:46%;top:15px;">
|
||||
{{$t('jlmap3d.nextStation')}}{{nextstation}}
|
||||
</div> -->
|
||||
|
||||
<!-- <div class="toptext" style="left:76%;top:15px;">
|
||||
T0002
|
||||
</div>
|
||||
|
||||
<div class="toptext" style="left:88%;top:15px;">
|
||||
C00001
|
||||
</div> -->
|
||||
</div>
|
||||
|
||||
<!-- <div class = "right">
|
||||
<div class = "rightstatus narea n-tiaoting" :style="{backgroundImage: 'url(' + nimage + ')' }">
|
||||
</div>
|
||||
<div class = "rightstatus darea d-info" :style="{backgroundImage: 'url(' + dimage + ')' }">
|
||||
</div>
|
||||
|
||||
<div class = "rightstatus m1area m1-am" :style="{backgroundImage: 'url(' + m1image + ')' }">
|
||||
</div>
|
||||
<div class = "rightstatus m2area m2-cbtc" :style="{backgroundImage: 'url(' + m2image + ')' }">
|
||||
</div>
|
||||
|
||||
<div class = "rightstatus m3area m3-zhefan" :style="{backgroundImage: 'url(' + m3image + ')' }">
|
||||
</div>
|
||||
<div class = "rightstatus m4area m4-in" :style="{backgroundImage: 'url(' + m4image + ')' }">
|
||||
</div>
|
||||
|
||||
<div class = "rightstatus m5area m5-15" :style="{backgroundImage: 'url(' + m5image + ')' }">
|
||||
</div>
|
||||
<div class = "rightstatus m6area m6-fache" :style="{backgroundImage: 'url(' + m6image + ')' }">
|
||||
</div>
|
||||
|
||||
<div class = "rightstatus m7area m7-aoac" :style="{backgroundImage: 'url(' + m7image + ')' }">
|
||||
</div>
|
||||
<div class = "rightstatus m8area m8-doornotclose" :style="{backgroundImage: 'url(' + m8image + ')' }">
|
||||
</div>
|
||||
|
||||
<div class = "rightstatus m9area m9-ato" :style="{backgroundImage: 'url(' + m9image + ')' }">
|
||||
</div>
|
||||
<div class = "rightstatus m10area m10-querenxinhao" :style="{backgroundImage: 'url(' + m10image + ')' }">
|
||||
</div>
|
||||
|
||||
<div class = "righttext" style="left:0px;bottom:0;">
|
||||
{{$t('jlmap3d.confirmSignalOpen')}}
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<div class = "down">
|
||||
<!-- <div class="trainstatus">
|
||||
<div id="ato" class="downstatus c1area c1-qianyin" :style="{backgroundImage: 'url(' + c1image + ')' }">
|
||||
</div>
|
||||
<div id="trainmode" class="downstatus c2area c2-rm" :style="{backgroundImage: 'url(' + c2image + ')' }">
|
||||
</div>
|
||||
<div id="trainintegrity" class="downstatus c3area c3-normal" :style="{backgroundImage: 'url(' + c3image + ')' }">
|
||||
</div>
|
||||
<div id="traindevice" class="downstatus c5area c5-normal" :style="{backgroundImage: 'url(' + c5image + ')' }">
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<div class="errortext">
|
||||
{{$t('jlmap3d.faultInformation')}}
|
||||
</div>
|
||||
|
||||
<div id="time" class="timetext">
|
||||
</div>
|
||||
<div id="timeupdate" class="timeup">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import axios from 'axios';
|
||||
|
||||
import { prefixIntrger } from '@/utils/date';
|
||||
|
||||
import { mmirender } from '@/views/jlmap3d/drive/sceneview/mmi';
|
||||
|
||||
import { mmiimage } from '@/views/jlmap3d/drive/sceneview/mmiimage';
|
||||
|
||||
export default {
|
||||
name: 'SimulationMmi',
|
||||
components: {
|
||||
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
timer: '',
|
||||
malen:0+"px",
|
||||
nowspeed:0,
|
||||
nowatpspeed:0,
|
||||
nowatospeed:0,
|
||||
endstation:'',
|
||||
nextstation:'',
|
||||
mmimodel:null,
|
||||
nstate:"tiaoting",
|
||||
nimage:null,
|
||||
dstate:"info",
|
||||
dimage:null,
|
||||
m1state:null,
|
||||
m1image:null,
|
||||
m2state:"null",
|
||||
m2image:null,
|
||||
m3state:"zhefan",
|
||||
m3image:null,
|
||||
m4state:"out",
|
||||
m4image:null,
|
||||
m5stateleft:false,
|
||||
m5stateright:false,
|
||||
m5image:null,
|
||||
m6state:"fache",
|
||||
m6image:null,
|
||||
m7state:"aoac",
|
||||
m7image:null,
|
||||
m8state:"jinjizhidong",
|
||||
m8image:null,
|
||||
m9state1:null,
|
||||
m9state2:null,
|
||||
m9image:null,
|
||||
m10state:"jinduan",
|
||||
m10image:null,
|
||||
newc1state:"none",
|
||||
c1state:"none",
|
||||
c1image:null,
|
||||
c2state:"rm",
|
||||
c2image:null,
|
||||
c3state:"normal",
|
||||
c3image:null,
|
||||
c5state:"normal",
|
||||
c5image:null,
|
||||
images:null,
|
||||
newa1state:"black",
|
||||
a1state:"black",
|
||||
ebStatus:false,
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
window.updatemmic1 = this.updatemmic1;
|
||||
this.init();
|
||||
},
|
||||
beforeDestroy() {
|
||||
|
||||
|
||||
},
|
||||
// watch: {
|
||||
// '$store.state.training.initTime': function (initTime) {
|
||||
// let date = new Date(initTime);
|
||||
// this.timer = `${prefixIntrger(date.getHours(), 2)}:${prefixIntrger(date.getMinutes(), 2)}:${prefixIntrger(date.getSeconds(), 2)}`;
|
||||
// document.getElementById("timeupdate").innerHTML = this.timer;
|
||||
// }
|
||||
// },
|
||||
methods: {
|
||||
init(){
|
||||
this.time();
|
||||
let dom = document.getElementById("meter");
|
||||
this.mmimodel = new mmirender(dom);
|
||||
this.images = new mmiimage();
|
||||
this.setimage();
|
||||
},
|
||||
setimage(){
|
||||
this.nimage = this.images.n['tiaoting'];
|
||||
this.dimage = this.images.d['info'];
|
||||
this.m1image = this.images.m1['rm'];
|
||||
this.m2image = this.images.m2['cbtc'];
|
||||
this.m3image = this.images.m3['zhefan'];
|
||||
this.m4image = this.images.m4['out'];
|
||||
this.m5image = this.images.m5['noalloffdoor'];
|
||||
this.m6image = this.images.m6['fache'];
|
||||
this.m7image = this.images.m7['aoac'];
|
||||
this.m8image = this.images.m8['none'];
|
||||
this.m9image = this.images.m9['ato'];
|
||||
this.m10image = this.images.m10['jinduan'];
|
||||
this.c1image = this.images.c1['none'];
|
||||
this.c2image = this.images.c2['none'];
|
||||
this.c3image = this.images.c3['normal'];
|
||||
this.c5image = this.images.c5['normal'];
|
||||
},
|
||||
time(){
|
||||
let vWeek,vWeek_s,vDay;
|
||||
vWeek = ["星期天","星期一","星期二","星期三","星期四","星期五","星期六"];
|
||||
let date = new Date();
|
||||
let year = date.getFullYear();
|
||||
let month = date.getMonth() + 1;
|
||||
let day = date.getDate();
|
||||
let hours = date.getHours();
|
||||
let minutes = date.getMinutes();
|
||||
let seconds = date.getSeconds();
|
||||
vWeek_s = date.getDay();
|
||||
document.getElementById("time").innerHTML = year + "/" + month + "/" + day + "/" + "\t" + vWeek[vWeek_s];
|
||||
|
||||
},
|
||||
updatetrainstatus(newdata){
|
||||
|
||||
if(typeof(newdata.eb) != "undefined"){
|
||||
|
||||
this.updateEbStatus(newdata.eb);
|
||||
}
|
||||
|
||||
//更新车组号
|
||||
this.updateMmiSpeedView(newdata.v,newdata.pv,newdata.tv);
|
||||
|
||||
if(newdata.maLen){
|
||||
|
||||
this.updateMmiLen(newdata.maLen);
|
||||
}
|
||||
|
||||
|
||||
|
||||
this.updatemmidrivemodelevel(newdata.runLevel,newdata.driveMode,newdata.atoOn,newdata.atpOn);
|
||||
// this.updatammirunlevel(newdata.runLevel);
|
||||
//
|
||||
// this.updatemmidrivemode(newdata.driveMode);
|
||||
//
|
||||
// this.updatemmiatoatp(newdata.atoOn,newdata.atpOn);
|
||||
if(newdata.nextStation){
|
||||
this.updateMmiNextStation(newdata.nextStation);
|
||||
}
|
||||
|
||||
if(newdata.endStation){
|
||||
this.updateMmiEndStation(newdata.endStation);
|
||||
}
|
||||
|
||||
this.updatemmidoormode(newdata.leftDoorCanClose,newdata.rightDoorCanClose);
|
||||
},
|
||||
updatemmistate(aaa){
|
||||
|
||||
},
|
||||
updateEbStatus(ebData){
|
||||
this.ebStatus = ebData;
|
||||
if(this.ebStatus){
|
||||
this.m8image = this.images.m8["jinjizhidong"];
|
||||
}else{
|
||||
this.m8image = this.images.m8["none"];
|
||||
}
|
||||
},
|
||||
updateMmiSpeedView(speed,atpspeed,atospeed) {
|
||||
|
||||
// if(this.m9state1 == false){
|
||||
// console.log(this.nowspeed);
|
||||
// console.log(this.nowatospeed);
|
||||
|
||||
if(this.ebStatus){
|
||||
this.newa1state = "red";
|
||||
this.nowspeed = 0;
|
||||
if(this.mmimodel.updatezz){
|
||||
this.mmimodel.updatezz(0);
|
||||
}
|
||||
|
||||
this.nowatpspeed = 0;
|
||||
if(this.mmimodel.updateatp){
|
||||
this.mmimodel.updateatp(0);
|
||||
}
|
||||
|
||||
this.nowatospeed = 0;
|
||||
if(this.mmimodel.updateato){
|
||||
this.mmimodel.updateato(0);
|
||||
}
|
||||
|
||||
if(this.newa1state != this.a1state){
|
||||
this.a1state = this.newa1state;
|
||||
|
||||
}
|
||||
}else{
|
||||
this.nowspeed = parseInt(speed);
|
||||
if(this.mmimodel.updatezz){
|
||||
this.mmimodel.updatezz(speed);
|
||||
}
|
||||
|
||||
this.nowatpspeed = parseInt(atpspeed);
|
||||
if(this.mmimodel.updateatp){
|
||||
this.mmimodel.updateatp(atpspeed);
|
||||
}
|
||||
|
||||
this.nowatospeed = parseInt(atospeed);
|
||||
if(this.mmimodel.updateato){
|
||||
this.mmimodel.updateato(atospeed);
|
||||
}
|
||||
if(this.nowspeed>this.nowatospeed){
|
||||
this.newa1state = "yellow";
|
||||
}else{
|
||||
this.newa1state = "black";
|
||||
}
|
||||
if(this.newa1state != this.a1state){
|
||||
this.a1state = this.newa1state;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
updatedrivedata(drivedata){
|
||||
// if(drivedata == "breaker"){
|
||||
//
|
||||
// }
|
||||
// if(drivedata == "carwash"){
|
||||
//
|
||||
// }
|
||||
// if(drivedata == "aircom"){
|
||||
//
|
||||
// }
|
||||
// if(drivedata == "atb"){
|
||||
//
|
||||
// }
|
||||
// if(drivedata == "bm"){
|
||||
//
|
||||
// }
|
||||
// if(drivedata == "rm"){
|
||||
// if(this.m1state == "start"){
|
||||
// this.m1state = 'rm';
|
||||
// this.m1image = this.images.m1[this.m1state];
|
||||
// }else if(this.m1state == "rm"){
|
||||
// this.m1state = 'am';
|
||||
// this.m1image = this.images.m1[this.m1state];
|
||||
// }else if(this.m1state == "am"){
|
||||
// this.m1state = 'cm';
|
||||
// this.m1image = this.images.m1[this.m1state];
|
||||
// }else if(this.m1state == "cm"){
|
||||
// this.m1state = 'start';
|
||||
// this.m1image = this.images.m1[this.m1state];
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// if(drivedata == "cbtc"){
|
||||
// if(this.m2state == "start"){
|
||||
// this.m2state = 'il';
|
||||
// this.m2image = this.images.m2[this.m2state];
|
||||
// }else if(this.m2state == "il"){
|
||||
// this.m2state = 'itc';
|
||||
// this.m2image = this.images.m2[this.m2state];
|
||||
// }else if(this.m2state == "itc"){
|
||||
// this.m2state = 'cbtc';
|
||||
// this.m2image = this.images.m2[this.m2state];
|
||||
// }else if(this.m2state == "cbtc"){
|
||||
// this.m2state = 'start';
|
||||
// this.m2image = this.images.m2[this.m2state];
|
||||
// }
|
||||
// }
|
||||
// //doormode
|
||||
// if(drivedata == "AA"){
|
||||
// this.m7state = 'aoac';
|
||||
// this.m7image = this.images.m7[this.m7state];
|
||||
// }
|
||||
// if(drivedata == "AM"){
|
||||
// this.m7state = 'aomc';
|
||||
// this.m7image = this.images.m7[this.m7state];
|
||||
// }
|
||||
// if(drivedata == "MM"){
|
||||
// this.m7state = 'momc';
|
||||
// this.m7image = this.images.m7[this.m7state];
|
||||
// }
|
||||
//
|
||||
// if(drivedata == "elflute"){
|
||||
//
|
||||
// }
|
||||
// if(drivedata == "relieve"){
|
||||
//
|
||||
// }
|
||||
},
|
||||
updatemmidrivemodelevel(runlevel,dirvemode,atoon,atpon){
|
||||
if(runlevel){
|
||||
if(runlevel == "CBTC"){
|
||||
this.m2state = runlevel;
|
||||
this.m2image = this.images.m2['cbtc'];
|
||||
}else if(runlevel == "IL"){
|
||||
this.m2state = runlevel;
|
||||
this.m2image = this.images.m2['il'];
|
||||
}else{
|
||||
this.m2state = runlevel;
|
||||
this.m2image = this.images.m2['start'];
|
||||
}
|
||||
}
|
||||
|
||||
if(dirvemode){
|
||||
if(dirvemode == "CM"){
|
||||
this.m1state = dirvemode;
|
||||
this.m1image = this.images.m1['cm'];
|
||||
}else if(dirvemode == "RM"){
|
||||
this.m1state = dirvemode;
|
||||
this.m1image = this.images.m1['rm'];
|
||||
}else if(dirvemode == "AM"){
|
||||
this.m1state = dirvemode;
|
||||
this.m1image = this.images.m1['am'];
|
||||
}else{
|
||||
this.m1state = null;
|
||||
this.m1image = this.images.m1['start'];
|
||||
}
|
||||
}
|
||||
//
|
||||
if(this.m9state1){
|
||||
this.m9state1 = atoon;
|
||||
if(atoon){
|
||||
|
||||
}else{
|
||||
this.m9image = this.images.m9["ato"];
|
||||
// this.c2image = this.images.c2['none'];
|
||||
}
|
||||
}
|
||||
|
||||
if(this.m9state2 != atpon){
|
||||
this.m9state2 = atpon;
|
||||
if(atpon){
|
||||
|
||||
}else{
|
||||
this.m9image = this.images.m9["atp"];
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
updatemmidoormode(leftDoorCanClose,rightDoorCanClose){
|
||||
if(leftDoorCanClose != this.m5stateleft|| rightDoorCanClose != this.m5stateright){
|
||||
this.m5stateleft = leftDoorCanClose;
|
||||
this.m5stateright = rightDoorCanClose;
|
||||
if(this.m5stateleft == this.m5stateright == true){
|
||||
this.m5image = this.images.m5['noalloffdoor'];
|
||||
}
|
||||
if(this.m5stateleft == false && this.m5stateright == false){
|
||||
this.m5image = this.images.m5['noallondoor'];
|
||||
}
|
||||
if(this.m5stateleft != this.m5stateright){
|
||||
if(this.m5stateleft){
|
||||
this.m5image = this.images.m5['leftdoor'];
|
||||
}else{
|
||||
this.m5image = this.images.m5['rightdoor'];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
updateMmiLen(len) {
|
||||
//this.malen = 150+"px";
|
||||
if(len>=750){
|
||||
this.malen = 158+"px";
|
||||
}
|
||||
if(len>=500 && len<750){
|
||||
this.malen = 146+parseInt(len-500)/250*12+"px";
|
||||
}
|
||||
if(len>=200 && len<500){
|
||||
this.malen = 128+parseInt(len-200)/300*20+"px";
|
||||
}
|
||||
if(len>=100 && len<200){
|
||||
this.malen = 111+parseInt(len-100)/100*17+"px";
|
||||
}
|
||||
if(len>=50 && len<100){
|
||||
this.malen = 95+parseInt(len-50)/50*16+"px";
|
||||
}
|
||||
if(len>=20 && len<50){
|
||||
this.malen = 73+parseInt(len-20)/30*22+"px";
|
||||
}
|
||||
if(len>=10 && len<20){
|
||||
this.malen = 57+parseInt(len-1)/10*16+"px";
|
||||
}
|
||||
if(len>=5 && len<10){
|
||||
this.malen = 40+parseInt(len-5)/5*17+"px";
|
||||
}
|
||||
if(len>=2 && len<5){
|
||||
this.malen = 20+parseInt(len-2)/3*20+"px";
|
||||
}
|
||||
if(len<2){
|
||||
this.malen = +parseInt(len)/2*10+"px";
|
||||
}
|
||||
},
|
||||
updatemmic1(qspeed){
|
||||
if(this.nowspeed != 0 ){
|
||||
this.newc1state = 'duoxing';
|
||||
}else{
|
||||
this.newc1state = 'none';
|
||||
}
|
||||
if(qspeed>0){
|
||||
|
||||
this.newc1state = 'qianyin';
|
||||
}else if(qspeed<0){
|
||||
|
||||
this.newc1state = 'zhidong';
|
||||
}
|
||||
|
||||
|
||||
if(this.c1state != this.newc1state){
|
||||
this.c1state = this.newc1state;
|
||||
this.c1image = this.images.c1[this.c1state];
|
||||
}
|
||||
},
|
||||
updateMmiNextStation(next){
|
||||
if(next){
|
||||
this.nextstation = next;
|
||||
}
|
||||
|
||||
},
|
||||
updateMmiEndStation(end){
|
||||
if(end){
|
||||
this.endstation = end;
|
||||
}
|
||||
},
|
||||
},
|
||||
beforeDestroy() {
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<style rel="stylesheet/scss" lang="scss" scoped>
|
||||
@import "src/styles/mixin.scss";
|
||||
@import "./mmi.css";
|
||||
|
||||
.mmi{
|
||||
width:500px;
|
||||
height:333px;
|
||||
background: black;
|
||||
position:absolute;
|
||||
bottom:0;
|
||||
}
|
||||
.meter{
|
||||
width:60%;
|
||||
height:56%;
|
||||
position:absolute;
|
||||
left:5%;
|
||||
top:15%;
|
||||
}
|
||||
.speedshow{
|
||||
width:30px;
|
||||
height:30px;
|
||||
position:absolute;
|
||||
top:87px;
|
||||
left:176px;
|
||||
font-size:27px;
|
||||
color:white;
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
.maxlenshow{
|
||||
width:25px;
|
||||
height:0px;
|
||||
position:absolute;
|
||||
bottom:0px;
|
||||
left:55px;
|
||||
background:green;
|
||||
}
|
||||
|
||||
.top{
|
||||
width:90%;
|
||||
height:10%;
|
||||
position:absolute;
|
||||
left:5%;
|
||||
top:2.5%;
|
||||
}
|
||||
|
||||
.toptext{
|
||||
position:absolute;
|
||||
color:white;
|
||||
font-size:13px;
|
||||
}
|
||||
|
||||
.right{
|
||||
width:25%;
|
||||
height:82.5%;
|
||||
position:absolute;
|
||||
right:5%;
|
||||
top:15%;
|
||||
}
|
||||
|
||||
.rightstatus{
|
||||
position:absolute;
|
||||
width:40%;
|
||||
height:10%;
|
||||
background-size:100% 100%;
|
||||
}
|
||||
|
||||
|
||||
.righttext{
|
||||
width:100%;
|
||||
height:60px;
|
||||
color:white;
|
||||
font-size: 18px;
|
||||
position:absolute;
|
||||
}
|
||||
|
||||
.down{
|
||||
width:65%;
|
||||
height:26%;
|
||||
position:absolute;
|
||||
left:5%;
|
||||
top:74%;
|
||||
color:white;
|
||||
}
|
||||
|
||||
.downstatus{
|
||||
width:60px;
|
||||
height:30px;
|
||||
position:absolute;
|
||||
background-size:100% 100%;
|
||||
}
|
||||
.trainstatus{
|
||||
width:90%;
|
||||
height:30%;
|
||||
top:2.5%;
|
||||
left:5%;
|
||||
position:absolute;
|
||||
}
|
||||
|
||||
.errortext{
|
||||
width:90%;
|
||||
height:25px;
|
||||
bottom:30%;
|
||||
left:0;
|
||||
font-size:20px;
|
||||
position:absolute;
|
||||
}
|
||||
|
||||
.timetext{
|
||||
width:65%;
|
||||
height:20px;
|
||||
bottom:0;
|
||||
left:0;
|
||||
position:absolute;
|
||||
text-align: center;
|
||||
}
|
||||
.timeup{
|
||||
width:30%;
|
||||
height:20px;
|
||||
bottom:0;
|
||||
right:5%;
|
||||
position:absolute;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
@ -0,0 +1,95 @@
|
||||
<template>
|
||||
<div class = "tmsfault" >
|
||||
<div class = "tmsvoltage">{{voltage}}</div>
|
||||
<div class = "tmscurrent">{{current}}</div>
|
||||
<div class = "tmslevel">{{level}}</div>
|
||||
<div class = "tmsspeed">{{speed}}</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import axios from 'axios';
|
||||
|
||||
export default {
|
||||
name: 'TmsFault',
|
||||
components: {
|
||||
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
voltage:"750V",
|
||||
current:"0A",
|
||||
level:"",
|
||||
speed:"km/h",
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
},
|
||||
beforeDestroy() {
|
||||
|
||||
|
||||
},
|
||||
watch: {
|
||||
|
||||
},
|
||||
methods: {
|
||||
init(){
|
||||
|
||||
},
|
||||
|
||||
},
|
||||
beforeDestroy() {
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<style rel="stylesheet/scss" lang="scss" scoped>
|
||||
.tmsfault{
|
||||
position: absolute;
|
||||
// border-style:solid;
|
||||
// border-color: #ffffff;
|
||||
top:7%;
|
||||
width:100%;
|
||||
height:84%;
|
||||
color:white;
|
||||
}
|
||||
.tmsvoltage{
|
||||
top:7%;
|
||||
left:3%;
|
||||
width: 15%;
|
||||
position: absolute;
|
||||
text-align: center;
|
||||
// border-style:solid;
|
||||
// border-color: #ffffff;
|
||||
}
|
||||
.tmscurrent{
|
||||
top:7%;
|
||||
left:19%;
|
||||
width: 15%;
|
||||
position: absolute;
|
||||
text-align: center;
|
||||
// border-style:solid;
|
||||
// border-color: #ffffff;
|
||||
}
|
||||
.tmslevel{
|
||||
top:7%;
|
||||
left:60%;
|
||||
width: 20%;
|
||||
position: absolute;
|
||||
text-align: center;
|
||||
// border-style:solid;
|
||||
// border-color: #ffffff;
|
||||
}
|
||||
.tmsspeed{
|
||||
top:7%;
|
||||
left:82%;
|
||||
width: 15%;
|
||||
position: absolute;
|
||||
text-align: center;
|
||||
// border-style:solid;
|
||||
// border-color: #ffffff;
|
||||
|
||||
}
|
||||
</style>
|
57
src/views/jlmap3d/railwaydrive/sceneview/tmsview.vue
Normal file
57
src/views/jlmap3d/railwaydrive/sceneview/tmsview.vue
Normal file
@ -0,0 +1,57 @@
|
||||
<template>
|
||||
<div class = "tms" :style="{'background-image': 'url('+localStatic+'/jl3d/tms.png)'}" >
|
||||
<Tms-Fault>
|
||||
</Tms-Fault>
|
||||
</div>
|
||||
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import axios from 'axios';
|
||||
import { JL3D_LOCAL_STATIC } from '@/api/jlmap3d/assets3d.js';
|
||||
|
||||
import TmsFault from '@/views/jlmap3d/drive/sceneview/tmscomponent/tmsfault';
|
||||
|
||||
export default {
|
||||
name: 'DriveTms',
|
||||
components: {
|
||||
TmsFault,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
localStatic:JL3D_LOCAL_STATIC,
|
||||
}
|
||||
},
|
||||
beforeDestroy() {
|
||||
|
||||
|
||||
},
|
||||
watch: {
|
||||
|
||||
},
|
||||
methods: {
|
||||
|
||||
},
|
||||
mounted() {
|
||||
},
|
||||
beforeDestroy() {
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<style rel="stylesheet/scss" lang="scss" scoped>
|
||||
@import "src/styles/mixin.scss";
|
||||
.tms{
|
||||
width:500px;
|
||||
height:333px;
|
||||
background-size:100% 100%;
|
||||
position:absolute;
|
||||
bottom:0;
|
||||
right:0;
|
||||
}
|
||||
|
||||
</style>
|
@ -4,6 +4,8 @@
|
||||
<div class="btn_hover" @click="menuClick">菜单</div>
|
||||
<el-button-group ref="button_group_box" class="button_group_box" :style="`margin-left:-${btnWidth}px`">
|
||||
<el-button v-if="jl3dmodelShow && !isContest && project !== 'bjd'" size="small" @click="jumpjlmap3dmodel">{{ jl3dmodel }}</el-button>
|
||||
<!-- 司机视角 -->
|
||||
<el-button v-if="$route.query.lineCode === '15'" size="small" type="jumpjlmap3d" @click="jumpjlmap3dDriver">司机视角</el-button>
|
||||
<el-button v-if="$route.query.lineCode === '15'" size="small" @click="clCaAnCall">经典案例分析</el-button>
|
||||
<el-button v-if="$route.query.lineCode === '15'" size="small" @click="normStudy">规范学习</el-button>
|
||||
</el-button-group>
|
||||
@ -15,11 +17,14 @@
|
||||
:panel-show="deviceShow"
|
||||
@closedevice3dview="jumpjlmap3dmodel"
|
||||
/>
|
||||
<Jl3dRailway-Drive v-show="drivingShow" ref="Jl3dRailwayDrive" :panel-show="drivingShow" @showdriving="showdriving" />
|
||||
<draw-select ref="drawSelect" />
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import Jl3dDevice from '@/views/jlmap3d/device/jl3ddevice';
|
||||
import Jl3dRailwayDrive from '@/views/jlmap3d/railwaydrive/jl3drailwaydrive';
|
||||
|
||||
import { getSessionStorage } from '@/utils/auth';
|
||||
import { EventBus } from '@/scripts/event-bus';
|
||||
import { getPostByProjectCode } from '@/api/learn';
|
||||
@ -29,6 +34,7 @@ export default {
|
||||
name:'DemonMenu',
|
||||
components:{
|
||||
Jl3dDevice,
|
||||
Jl3dRailwayDrive,
|
||||
DrawSelect
|
||||
},
|
||||
props:{
|
||||
@ -161,7 +167,14 @@ export default {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
showdriving() {
|
||||
this.drivingShow = false;
|
||||
},
|
||||
jumpjlmap3dDriver() {
|
||||
this.drivingShow = true;
|
||||
this.$refs.Jl3dRailwayDrive.show(this.mapId, this.group);
|
||||
},
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -15,6 +15,7 @@
|
||||
// import { mapGetters } from 'vuex';
|
||||
// import { listMap } from '@/api/jmap/mapdraft';
|
||||
import { getContinueProtectList, delContinueProtect, putContinueProtect } from '@/api/jmap/mapdraft';
|
||||
import { EventBus } from '@/scripts/event-bus';
|
||||
|
||||
export default {
|
||||
name: 'RouteDetail',
|
||||
@ -147,6 +148,7 @@ export default {
|
||||
handleUpload(index, row) {
|
||||
putContinueProtect(this.$route.params.mapId, row).then(res => {
|
||||
this.$message.success('更新成功');
|
||||
EventBus.$emit('successCI');
|
||||
}).catch(() => {
|
||||
this.$messageBox('操作异常');
|
||||
});
|
||||
|
@ -4,6 +4,12 @@
|
||||
<el-form-item label="延续保护名称:" prop="name">
|
||||
<el-input v-model="addModel.name" />
|
||||
</el-form-item>
|
||||
<el-form-item label="cbtc模式下需要办理:" prop="setInCbtc">
|
||||
<el-radio-group v-model="addModel.setInCbtc">
|
||||
<el-radio :label="true">是</el-radio>
|
||||
<el-radio :label="false">否</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="方向:" prop="right">
|
||||
<el-radio-group v-model="addModel.right">
|
||||
<el-radio :label="true">向右</el-radio>
|
||||
@ -164,6 +170,7 @@ export default {
|
||||
code: '',
|
||||
name: '',
|
||||
right: '',
|
||||
setInCbtc: false,
|
||||
mapId: '',
|
||||
unlockSectionCode:'',
|
||||
unlockTime: 0,
|
||||
@ -219,7 +226,6 @@ export default {
|
||||
}
|
||||
},
|
||||
protectData(val, old) {
|
||||
console.log(val, 'val');
|
||||
if (val) {
|
||||
this.addModel = val;
|
||||
this.addModel.pathList && this.addModel.pathList.forEach(item => {
|
||||
|
@ -12,6 +12,8 @@
|
||||
<script>
|
||||
import { putContinueProtect } from '@/api/jmap/mapdraft';
|
||||
import ProtectOperate from './protect';
|
||||
import { EventBus } from '@/scripts/event-bus';
|
||||
|
||||
export default {
|
||||
name:'BigRouteInfo',
|
||||
components: {
|
||||
@ -82,6 +84,7 @@ export default {
|
||||
this.$message.success('更新成功!');
|
||||
this.$refs.protect.clear();
|
||||
this.isModify = false;
|
||||
EventBus.$emit('successCI');
|
||||
}).catch(() => {
|
||||
this.$message.error('更新失败!');
|
||||
});
|
||||
|
@ -18,11 +18,11 @@
|
||||
|
||||
<script>
|
||||
import { mapGetters } from 'vuex';
|
||||
import { listMap, getRouteNewList, delRouteNew, putRouteNew, putSetDraftMapRouteById, getOverlapAllList } from '@/api/jmap/mapdraft';
|
||||
import { listMap, getRouteNewList, delRouteNew, putRouteNew, putSetDraftMapRouteById } from '@/api/jmap/mapdraft';
|
||||
// import ProtectDetail from './protectDetail';
|
||||
import PreViewField from './preview';
|
||||
import Related from './related';
|
||||
import { EventBus } from '@/scripts/event-bus';
|
||||
// import { EventBus } from '@/scripts/event-bus';
|
||||
|
||||
export default {
|
||||
name: 'RouteDetail',
|
||||
@ -37,6 +37,12 @@ export default {
|
||||
default() {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
overlapList: {
|
||||
type: Array,
|
||||
default() {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
},
|
||||
data() {
|
||||
@ -49,7 +55,7 @@ export default {
|
||||
RouteAutoTypeList: [],
|
||||
SwitchLocateTypeList: [],
|
||||
ContinueProtectList: [],
|
||||
overlapList: [], // 延续保护列表
|
||||
// overlapList: [], // 延续保护列表
|
||||
turnBackList: [
|
||||
{ label: '是', value: true },
|
||||
{ label: '否', value: false }
|
||||
@ -257,15 +263,12 @@ export default {
|
||||
this.SwitchLocateTypeList = list;
|
||||
});
|
||||
this.acquireMapList();
|
||||
this.initProtectData();
|
||||
EventBus.$on('successCI', () => {
|
||||
this.initProtectData();
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
doShow(showType, codeType) {
|
||||
this.show = true;
|
||||
this.reloadTable();
|
||||
// this.reloadTable();
|
||||
this.$refs.queryListPage.commitQuery();
|
||||
if (showType && codeType) {
|
||||
this.showType = showType;
|
||||
this.codeType = codeType;
|
||||
@ -274,11 +277,6 @@ export default {
|
||||
doClose() {
|
||||
this.show = false;
|
||||
},
|
||||
initProtectData() {
|
||||
getOverlapAllList(this.$route.params.mapId).then(resp => {
|
||||
this.overlapList = resp.data;
|
||||
});
|
||||
},
|
||||
queryFunction(params) {
|
||||
if (this.mapInfo && this.mapInfo.id) {
|
||||
return getRouteNewList(this.mapInfo.id, params);
|
||||
@ -295,12 +293,7 @@ export default {
|
||||
const list = data.list;
|
||||
if (list) {
|
||||
list.map(elem => {
|
||||
that.$convertSpecifiedField(elem, that.RouteAutoTypeList, 'code', 'name', ['autoType']);
|
||||
that.$convertSpecifiedField(elem, that.RouteNatureTypeList, 'code', 'name', ['natureType']);
|
||||
that.$convertSpecifiedField(elem, that.SwitchLocateTypeList, 'code', 'name', ['overlapSwitchLocateType']);
|
||||
that.$convertSpecifiedField(elem, that.switchList, 'code', 'name', ['routeOverlapSwitchList']);
|
||||
that.$convertSpecifiedField(elem, that.signalList, 'code', 'name', ['startSignalCode', 'endSignalCode']);
|
||||
that.$convertSpecifiedField(elem, that.sectionList, 'code', 'name', ['nearSectionCode', 'autoTriggerSectionCode', 'turnBackSectionCode']);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -322,11 +315,8 @@ export default {
|
||||
});
|
||||
},
|
||||
edit(index, row) {
|
||||
// getRouteNewById(row.mapId).then(response => {
|
||||
// const data = response.data;
|
||||
this.$emit('routeSelected', row);
|
||||
this.doClose();
|
||||
// });
|
||||
},
|
||||
deleteObj(index, row) {
|
||||
if (row) {
|
||||
|
@ -5,14 +5,17 @@
|
||||
:selected="selected"
|
||||
:map-info="mapInfo"
|
||||
:route-data="routeData"
|
||||
:overlap-list="overlapList"
|
||||
@setCenter="setCenter"
|
||||
/>
|
||||
<route-detail ref="routeDetail" :map-info="mapInfo" @routeSelected="routeSelected" />
|
||||
<route-detail ref="routeDetail" :map-info="mapInfo" :overlap-list="overlapList" @routeSelected="routeSelected" />
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import RouteDraft from './route';
|
||||
import RouteDetail from './detail';
|
||||
import { getOverlapAllList } from '@/api/jmap/mapdraft';
|
||||
import { EventBus } from '@/scripts/event-bus';
|
||||
|
||||
export default {
|
||||
name: 'RouteOperate',
|
||||
@ -37,10 +40,23 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
enabledTab: 'Route',
|
||||
routeData: null
|
||||
routeData: null,
|
||||
overlapList: []
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.initProtectData();
|
||||
EventBus.$on('successCI', () => {
|
||||
this.initProtectData();
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
initProtectData() {
|
||||
debugger;
|
||||
getOverlapAllList(this.$route.params.mapId).then(resp => {
|
||||
this.overlapList = resp.data;
|
||||
});
|
||||
},
|
||||
clickEvent(e, model) {
|
||||
this.onSelect(model);
|
||||
},
|
||||
|
@ -164,9 +164,9 @@
|
||||
</template>
|
||||
<script>
|
||||
import { mapGetters } from 'vuex';
|
||||
import { getRouteNewList, getFlankProtectionList, getOverlapAllList, putSetDraftMapRouteById } from '@/api/jmap/mapdraft';
|
||||
import { getRouteNewList, getFlankProtectionList, putSetDraftMapRouteById } from '@/api/jmap/mapdraft';
|
||||
import HostileData from './hostileData';
|
||||
import { EventBus } from '@/scripts/event-bus';
|
||||
// import { EventBus } from '@/scripts/event-bus';
|
||||
|
||||
export default {
|
||||
name: 'RouteOperation',
|
||||
@ -191,6 +191,12 @@ export default {
|
||||
default() {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
overlapList: {
|
||||
type: Array,
|
||||
default() {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
},
|
||||
data() {
|
||||
@ -228,7 +234,7 @@ export default {
|
||||
overlapCode:'',
|
||||
conflictingSignalList: [] // 敌对信号数据列表
|
||||
},
|
||||
overlapList: [], // 延续保护列表
|
||||
// overlapList: [], // 延续保护列表
|
||||
routeList: [] // 进路列表
|
||||
};
|
||||
},
|
||||
@ -337,10 +343,10 @@ export default {
|
||||
mounted() {
|
||||
this.getRouteList();
|
||||
this.getFlankProtectList();
|
||||
this.initProtectData();
|
||||
EventBus.$on('successCI', () => {
|
||||
this.initProtectData();
|
||||
});
|
||||
// this.initProtectData();
|
||||
// EventBus.$on('successCI', () => {
|
||||
// this.initProtectData();
|
||||
// });
|
||||
},
|
||||
methods: {
|
||||
initLoad() { // 加载联锁车站列表
|
||||
@ -426,11 +432,11 @@ export default {
|
||||
// this.addModel.delayReleaseTime = this.routeList[this.routeList.length - 1].delayReleaseTime;
|
||||
}
|
||||
},
|
||||
initProtectData() {
|
||||
getOverlapAllList(this.$route.params.mapId).then(resp => {
|
||||
this.overlapList = resp.data;
|
||||
});
|
||||
},
|
||||
// initProtectData() {
|
||||
// getOverlapAllList(this.$route.params.mapId).then(resp => {
|
||||
// this.overlapList = resp.data;
|
||||
// });
|
||||
// },
|
||||
batchSectionListFocus(flag) {
|
||||
this.changeSectionSelected(this.addModel.routeSectionList, flag, 'routePhysicalSection');
|
||||
this.changeSignalSelected(this.addModel.startSignalCode, flag, 'routeSignal');
|
||||
|
742
static/workertest/railwayWorker.js
Normal file
742
static/workertest/railwayWorker.js
Normal file
@ -0,0 +1,742 @@
|
||||
// importScripts('sockjs.js');
|
||||
// import { getToken } from '@/utils/auth';
|
||||
// import { getBaseUrl } from '@/utils/baseUrl';
|
||||
// import SockJS from 'sockjs-client';
|
||||
|
||||
// const websocketUrl = 'ws://test.joylink.club/jlcloud/joylink-websocket?token=';
|
||||
// const websocketUrl = `http://192.168.3.6:9000/joylink-websocket?token=`;
|
||||
let websocketUrl = null;
|
||||
let token = null;
|
||||
var StompClient = function (headers, token) {
|
||||
const scope = this;
|
||||
this.url = websocketUrl + token;
|
||||
this.headers = headers || {};
|
||||
this.connect();
|
||||
};
|
||||
|
||||
StompClient.prototype = {
|
||||
socket: null,
|
||||
|
||||
clientIns: null,
|
||||
|
||||
subscribeMap: null,
|
||||
|
||||
url: '',
|
||||
|
||||
status: false,
|
||||
|
||||
sockStatus: 0,
|
||||
|
||||
headers: {
|
||||
// 'X-Token': getToken()
|
||||
},
|
||||
|
||||
count: 0,
|
||||
|
||||
topic: '',
|
||||
|
||||
onmessage: null,
|
||||
|
||||
checkTimer: null,
|
||||
|
||||
// 连接服务端
|
||||
connect() {
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
// 断开已有连接
|
||||
if (this.clientIns && this.clientIns.connected) {
|
||||
this.clientIns.disconnect();
|
||||
this.clientIns = null;
|
||||
}
|
||||
|
||||
// // 建立连接对象(还未发起连接)
|
||||
// this.socket = new SockJS(websocketUrl + token);
|
||||
//
|
||||
// // 获取 STOMP 子协议的客户端对象
|
||||
// this.clientIns = Stomp.over(this.socket);
|
||||
|
||||
this.websocket = new WebSocket(this.url.replace(/https/, 'wss').replace(/http/, 'ws'));
|
||||
|
||||
this.clientIns = Stomp.over(this.websocket);
|
||||
|
||||
this.closeStompDebug();
|
||||
|
||||
// 向服务器发起websocket连接并发送CONNECT帧
|
||||
this.clientIns.connect({ 'X-Token': token }, () => {
|
||||
console.info('连接成功.');
|
||||
this.count = 0;
|
||||
this.status = true;
|
||||
|
||||
// 恢复订阅
|
||||
if (this.topic && this.onmessage) {
|
||||
this.unsubscribe(this.topic);
|
||||
this.subscribe(this.topic, this.onmessage, this.headers);
|
||||
}
|
||||
|
||||
resolve(this);
|
||||
}, () => {
|
||||
if (this.checkTimer) {
|
||||
clearInterval(this.checkTimer);
|
||||
this.checkTimer = null;
|
||||
}
|
||||
|
||||
});
|
||||
} catch (err) {
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
logOut(err) {
|
||||
if (err.code == 50008 || err.code == 50014) {
|
||||
this.url = websocketUrl + token;
|
||||
this.status = false;
|
||||
this.count++;
|
||||
this.reconnect(this.count);
|
||||
}
|
||||
},
|
||||
// 恢复链接
|
||||
reconnect(count) {
|
||||
console.info(`尝试第${count || 1}次连接.`);
|
||||
this.connect().then(() => { }).catch(() => {
|
||||
this.count++;
|
||||
this.reconnect(this.count);
|
||||
});
|
||||
},
|
||||
|
||||
closeStompDebug() {
|
||||
if (this.clientIns) {
|
||||
this.clientIns.debug = undefined;
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
// 订阅指定的topic
|
||||
subscribe(topic, onmessage, headers) {
|
||||
this.topic = topic;
|
||||
this.onmessage = onmessage;
|
||||
this.headers = headers;
|
||||
if (this.status) {
|
||||
if (!this.subscribeMap) {
|
||||
this.subscribeMap = new Map();
|
||||
}
|
||||
|
||||
try {
|
||||
var subscription = this.subscribeMap.get(topic);
|
||||
if (!subscription) {
|
||||
subscription = this.clientIns.subscribe(topic, onmessage, headers); // 接收消息通过 subscribe() 方法实现
|
||||
this.subscribeMap.set(topic, subscription);
|
||||
}
|
||||
} catch (err) {
|
||||
setTimeout(() => {
|
||||
this.subscribe(topic, onmessage, headers);
|
||||
}, 300);
|
||||
}
|
||||
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
this.subscribe(topic, onmessage, headers);
|
||||
}, 300);
|
||||
}
|
||||
},
|
||||
|
||||
unsubscribe(topic) {
|
||||
if (this.subscribeMap) {
|
||||
const subscription = this.subscribeMap.get(topic);
|
||||
if (subscription) {
|
||||
subscription.unsubscribe();
|
||||
this.subscribeMap.delete(topic);
|
||||
console.log('取消订阅');
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// 发送消息
|
||||
send(url, msg) {
|
||||
if (this.status) {
|
||||
if (msg) {
|
||||
msg = JSON.stringify(msg);
|
||||
}
|
||||
try {
|
||||
this.clientIns.send(url, {}, msg);
|
||||
} catch (err) {
|
||||
this.status = false;
|
||||
this.send(url, msg);
|
||||
}
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
this.send(url, msg);
|
||||
}, 300);
|
||||
}
|
||||
},
|
||||
|
||||
disconnect() {
|
||||
if (this.checkTimer) {
|
||||
clearInterval(this.checkTimer);
|
||||
this.checkTimer = null;
|
||||
}
|
||||
|
||||
if (this.clientIns && this.clientIns.connected) {
|
||||
this.clientIns.disconnect();
|
||||
this.clientIns = null;
|
||||
}
|
||||
this.status = false;
|
||||
console.log('断开连接');
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
var Byte; var Client; var Frame; var Stomp;
|
||||
var __hasProp = {}.hasOwnProperty;
|
||||
var __slice = [].slice;
|
||||
|
||||
Byte = {
|
||||
LF: '\x0A',
|
||||
NULL: '\x00'
|
||||
};
|
||||
|
||||
Frame = (function() {
|
||||
var unmarshallSingle;
|
||||
|
||||
function Frame(command, headers, body) {
|
||||
this.command = command;
|
||||
this.headers = headers != null ? headers : {};
|
||||
this.body = body != null ? body : '';
|
||||
}
|
||||
|
||||
Frame.prototype.toString = function() {
|
||||
var lines, name, skipContentLength, value, _ref;
|
||||
lines = [this.command];
|
||||
skipContentLength = this.headers['content-length'] === false;
|
||||
if (skipContentLength) {
|
||||
delete this.headers['content-length'];
|
||||
}
|
||||
_ref = this.headers;
|
||||
for (name in _ref) {
|
||||
if (!__hasProp.call(_ref, name)) continue;
|
||||
value = _ref[name];
|
||||
lines.push('' + name + ':' + value);
|
||||
}
|
||||
if (this.body && !skipContentLength) {
|
||||
lines.push('content-length:' + (Frame.sizeOfUTF8(this.body)));
|
||||
}
|
||||
lines.push(Byte.LF + this.body);
|
||||
return lines.join(Byte.LF);
|
||||
};
|
||||
|
||||
Frame.sizeOfUTF8 = function(s) {
|
||||
if (s) {
|
||||
return encodeURI(s).match(/%..|./g).length;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
unmarshallSingle = function(data) {
|
||||
var body, chr, command, divider, headerLines, headers, i, idx, len, line, start, trim, _i, _j, _len, _ref, _ref1;
|
||||
divider = data.search(RegExp('' + Byte.LF + Byte.LF));
|
||||
headerLines = data.substring(0, divider).split(Byte.LF);
|
||||
command = headerLines.shift();
|
||||
headers = {};
|
||||
trim = function(str) {
|
||||
return str.replace(/^\s+|\s+$/g, '');
|
||||
};
|
||||
_ref = headerLines.reverse();
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
line = _ref[_i];
|
||||
idx = line.indexOf(':');
|
||||
headers[trim(line.substring(0, idx))] = trim(line.substring(idx + 1));
|
||||
}
|
||||
body = '';
|
||||
start = divider + 2;
|
||||
if (headers['content-length']) {
|
||||
len = parseInt(headers['content-length']);
|
||||
body = ('' + data).substring(start, start + len);
|
||||
} else {
|
||||
chr = null;
|
||||
for (i = _j = start, _ref1 = data.length; start <= _ref1 ? _j < _ref1 : _j > _ref1; i = start <= _ref1 ? ++_j : --_j) {
|
||||
chr = data.charAt(i);
|
||||
if (chr === Byte.NULL) {
|
||||
break;
|
||||
}
|
||||
body += chr;
|
||||
}
|
||||
}
|
||||
return new Frame(command, headers, body);
|
||||
};
|
||||
|
||||
Frame.unmarshall = function(datas) {
|
||||
var data;
|
||||
return (function() {
|
||||
var _i, _len, _ref, _results;
|
||||
_ref = datas.split(RegExp('' + Byte.NULL + Byte.LF + '*'));
|
||||
_results = [];
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
data = _ref[_i];
|
||||
if ((data != null ? data.length : void 0) > 0) {
|
||||
_results.push(unmarshallSingle(data));
|
||||
}
|
||||
}
|
||||
return _results;
|
||||
})();
|
||||
};
|
||||
|
||||
Frame.marshall = function(command, headers, body) {
|
||||
var frame;
|
||||
frame = new Frame(command, headers, body);
|
||||
return frame.toString() + Byte.NULL;
|
||||
};
|
||||
|
||||
return Frame;
|
||||
|
||||
})();
|
||||
|
||||
Client = (function() {
|
||||
var now;
|
||||
|
||||
function Client(ws) {
|
||||
this.ws = ws;
|
||||
this.ws.binaryType = 'arraybuffer';
|
||||
this.counter = 0;
|
||||
this.connected = false;
|
||||
this.heartbeat = {
|
||||
outgoing: 10000,
|
||||
incoming: 10000
|
||||
};
|
||||
this.maxWebSocketFrameSize = 16 * 1024;
|
||||
this.subscriptions = {};
|
||||
}
|
||||
|
||||
Client.prototype.debug = function(message) {
|
||||
var _ref;
|
||||
return typeof window !== 'undefined' && window !== null ? (_ref = window.console) != null ? _ref.log(message) : void 0 : void 0;
|
||||
};
|
||||
|
||||
now = function() {
|
||||
if (Date.now) {
|
||||
return Date.now();
|
||||
} else {
|
||||
return new Date().valueOf;
|
||||
}
|
||||
};
|
||||
|
||||
Client.prototype._transmit = function(command, headers, body) {
|
||||
var out;
|
||||
out = Frame.marshall(command, headers, body);
|
||||
if (typeof this.debug === 'function') {
|
||||
this.debug('>>> ' + out);
|
||||
}
|
||||
while (true) {
|
||||
if (out.length > this.maxWebSocketFrameSize) {
|
||||
this.ws.send(out.substring(0, this.maxWebSocketFrameSize));
|
||||
out = out.substring(this.maxWebSocketFrameSize);
|
||||
if (typeof this.debug === 'function') {
|
||||
this.debug('remaining = ' + out.length);
|
||||
}
|
||||
} else {
|
||||
return this.ws.send(out);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Client.prototype._setupHeartbeat = function(headers) {
|
||||
var serverIncoming, serverOutgoing, ttl, v, _ref, _ref1;
|
||||
if ((_ref = headers.version) !== Stomp.VERSIONS.V1_1 && _ref !== Stomp.VERSIONS.V1_2) {
|
||||
return;
|
||||
}
|
||||
_ref1 = (function() {
|
||||
var _i, _len, _ref1, _results;
|
||||
_ref1 = headers['heart-beat'].split(',');
|
||||
_results = [];
|
||||
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
|
||||
v = _ref1[_i];
|
||||
_results.push(parseInt(v));
|
||||
}
|
||||
return _results;
|
||||
})(), serverOutgoing = _ref1[0], serverIncoming = _ref1[1];
|
||||
if (!(this.heartbeat.outgoing === 0 || serverIncoming === 0)) {
|
||||
ttl = Math.max(this.heartbeat.outgoing, serverIncoming);
|
||||
if (typeof this.debug === 'function') {
|
||||
this.debug('send PING every ' + ttl + 'ms');
|
||||
}
|
||||
this.pinger = Stomp.setInterval(ttl, (function(_this) {
|
||||
return function() {
|
||||
_this.ws.send(Byte.LF);
|
||||
return typeof _this.debug === 'function' ? _this.debug('>>> PING') : void 0;
|
||||
};
|
||||
})(this));
|
||||
}
|
||||
if (!(this.heartbeat.incoming === 0 || serverOutgoing === 0)) {
|
||||
ttl = Math.max(this.heartbeat.incoming, serverOutgoing);
|
||||
if (typeof this.debug === 'function') {
|
||||
this.debug('check PONG every ' + ttl + 'ms');
|
||||
}
|
||||
return this.ponger = Stomp.setInterval(ttl, (function(_this) {
|
||||
return function() {
|
||||
var delta;
|
||||
delta = now() - _this.serverActivity;
|
||||
if (delta > ttl * 2) {
|
||||
if (typeof _this.debug === 'function') {
|
||||
_this.debug('did not receive server activity for the last ' + delta + 'ms');
|
||||
}
|
||||
return _this.ws.close();
|
||||
}
|
||||
};
|
||||
})(this));
|
||||
}
|
||||
};
|
||||
|
||||
Client.prototype._parseConnect = function() {
|
||||
var args, connectCallback, errorCallback, headers;
|
||||
args = arguments.length >= 1 ? __slice.call(arguments, 0) : [];
|
||||
headers = {};
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
headers = args[0], connectCallback = args[1];
|
||||
break;
|
||||
case 3:
|
||||
if (args[1] instanceof Function) {
|
||||
headers = args[0], connectCallback = args[1], errorCallback = args[2];
|
||||
} else {
|
||||
headers.login = args[0], headers.passcode = args[1], connectCallback = args[2];
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
headers.login = args[0], headers.passcode = args[1], connectCallback = args[2], errorCallback = args[3];
|
||||
break;
|
||||
default:
|
||||
headers.login = args[0], headers.passcode = args[1], connectCallback = args[2], errorCallback = args[3], headers.host = args[4];
|
||||
}
|
||||
return [headers, connectCallback, errorCallback];
|
||||
};
|
||||
|
||||
Client.prototype.connect = function() {
|
||||
var args, errorCallback, headers, out;
|
||||
args = arguments.length >= 1 ? __slice.call(arguments, 0) : [];
|
||||
out = this._parseConnect.apply(this, args);
|
||||
headers = out[0], this.connectCallback = out[1], errorCallback = out[2];
|
||||
if (typeof this.debug === 'function') {
|
||||
this.debug('Opening Web Socket...');
|
||||
}
|
||||
this.ws.onmessage = (function(_this) {
|
||||
return function(evt) {
|
||||
var arr, c, client, data, frame, messageID, onreceive, subscription, _i, _len, _ref, _results;
|
||||
data = typeof ArrayBuffer !== 'undefined' && evt.data instanceof ArrayBuffer ? (arr = new Uint8Array(evt.data), typeof _this.debug === 'function' ? _this.debug('--- got data length: ' + arr.length) : void 0, ((function() {
|
||||
var _i, _len, _results;
|
||||
_results = [];
|
||||
for (_i = 0, _len = arr.length; _i < _len; _i++) {
|
||||
c = arr[_i];
|
||||
_results.push(String.fromCharCode(c));
|
||||
}
|
||||
return _results;
|
||||
})()).join('')) : evt.data;
|
||||
_this.serverActivity = now();
|
||||
if (data === Byte.LF) {
|
||||
if (typeof _this.debug === 'function') {
|
||||
_this.debug('<<< PONG');
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (typeof _this.debug === 'function') {
|
||||
_this.debug('<<< ' + data);
|
||||
}
|
||||
_ref = Frame.unmarshall(data);
|
||||
_results = [];
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
frame = _ref[_i];
|
||||
switch (frame.command) {
|
||||
case 'CONNECTED':
|
||||
if (typeof _this.debug === 'function') {
|
||||
_this.debug('connected to server ' + frame.headers.server);
|
||||
}
|
||||
_this.connected = true;
|
||||
_this._setupHeartbeat(frame.headers);
|
||||
_results.push(typeof _this.connectCallback === 'function' ? _this.connectCallback(frame) : void 0);
|
||||
break;
|
||||
case 'MESSAGE':
|
||||
subscription = frame.headers.subscription;
|
||||
onreceive = _this.subscriptions[subscription] || _this.onreceive;
|
||||
if (onreceive) {
|
||||
client = _this;
|
||||
messageID = frame.headers['message-id'];
|
||||
frame.ack = function(headers) {
|
||||
if (headers == null) {
|
||||
headers = {};
|
||||
}
|
||||
return client.ack(messageID, subscription, headers);
|
||||
};
|
||||
frame.nack = function(headers) {
|
||||
if (headers == null) {
|
||||
headers = {};
|
||||
}
|
||||
return client.nack(messageID, subscription, headers);
|
||||
};
|
||||
_results.push(onreceive(frame));
|
||||
} else {
|
||||
_results.push(typeof _this.debug === 'function' ? _this.debug('Unhandled received MESSAGE: ' + frame) : void 0);
|
||||
}
|
||||
break;
|
||||
case 'RECEIPT':
|
||||
_results.push(typeof _this.onreceipt === 'function' ? _this.onreceipt(frame) : void 0);
|
||||
break;
|
||||
case 'ERROR':
|
||||
_results.push(typeof errorCallback === 'function' ? errorCallback(frame) : void 0);
|
||||
break;
|
||||
default:
|
||||
_results.push(typeof _this.debug === 'function' ? _this.debug('Unhandled frame: ' + frame) : void 0);
|
||||
}
|
||||
}
|
||||
return _results;
|
||||
};
|
||||
})(this);
|
||||
this.ws.onclose = (function(_this) {
|
||||
return function() {
|
||||
var msg;
|
||||
msg = 'Whoops! Lost connection to ' + _this.ws.url;
|
||||
if (typeof _this.debug === 'function') {
|
||||
_this.debug(msg);
|
||||
}
|
||||
_this._cleanUp();
|
||||
return typeof errorCallback === 'function' ? errorCallback(msg) : void 0;
|
||||
};
|
||||
})(this);
|
||||
return this.ws.onopen = (function(_this) {
|
||||
return function() {
|
||||
if (typeof _this.debug === 'function') {
|
||||
_this.debug('Web Socket Opened...');
|
||||
}
|
||||
headers['accept-version'] = Stomp.VERSIONS.supportedVersions();
|
||||
headers['heart-beat'] = [_this.heartbeat.outgoing, _this.heartbeat.incoming].join(',');
|
||||
return _this._transmit('CONNECT', headers);
|
||||
};
|
||||
})(this);
|
||||
};
|
||||
|
||||
Client.prototype.disconnect = function(disconnectCallback, headers) {
|
||||
if (headers == null) {
|
||||
headers = {};
|
||||
}
|
||||
this._transmit('DISCONNECT', headers);
|
||||
this.ws.onclose = null;
|
||||
this.ws.close();
|
||||
this._cleanUp();
|
||||
return typeof disconnectCallback === 'function' ? disconnectCallback() : void 0;
|
||||
};
|
||||
|
||||
Client.prototype._cleanUp = function() {
|
||||
this.connected = false;
|
||||
if (this.pinger) {
|
||||
Stomp.clearInterval(this.pinger);
|
||||
}
|
||||
if (this.ponger) {
|
||||
return Stomp.clearInterval(this.ponger);
|
||||
}
|
||||
};
|
||||
|
||||
Client.prototype.send = function(destination, headers, body) {
|
||||
if (headers == null) {
|
||||
headers = {};
|
||||
}
|
||||
if (body == null) {
|
||||
body = '';
|
||||
}
|
||||
headers.destination = destination;
|
||||
return this._transmit('SEND', headers, body);
|
||||
};
|
||||
|
||||
Client.prototype.subscribe = function(destination, callback, headers) {
|
||||
var client;
|
||||
if (headers == null) {
|
||||
headers = {};
|
||||
}
|
||||
if (!headers.id) {
|
||||
headers.id = 'sub-' + this.counter++;
|
||||
}
|
||||
headers.destination = destination;
|
||||
this.subscriptions[headers.id] = callback;
|
||||
this._transmit('SUBSCRIBE', headers);
|
||||
client = this;
|
||||
return {
|
||||
id: headers.id,
|
||||
unsubscribe: function() {
|
||||
return client.unsubscribe(headers.id);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
Client.prototype.unsubscribe = function(id) {
|
||||
delete this.subscriptions[id];
|
||||
return this._transmit('UNSUBSCRIBE', {
|
||||
id: id
|
||||
});
|
||||
};
|
||||
|
||||
Client.prototype.begin = function(transaction) {
|
||||
var client, txid;
|
||||
txid = transaction || 'tx-' + this.counter++;
|
||||
this._transmit('BEGIN', {
|
||||
transaction: txid
|
||||
});
|
||||
client = this;
|
||||
return {
|
||||
id: txid,
|
||||
commit: function() {
|
||||
return client.commit(txid);
|
||||
},
|
||||
abort: function() {
|
||||
return client.abort(txid);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
Client.prototype.commit = function(transaction) {
|
||||
return this._transmit('COMMIT', {
|
||||
transaction: transaction
|
||||
});
|
||||
};
|
||||
|
||||
Client.prototype.abort = function(transaction) {
|
||||
return this._transmit('ABORT', {
|
||||
transaction: transaction
|
||||
});
|
||||
};
|
||||
|
||||
Client.prototype.ack = function(messageID, subscription, headers) {
|
||||
if (headers == null) {
|
||||
headers = {};
|
||||
}
|
||||
headers['message-id'] = messageID;
|
||||
headers.subscription = subscription;
|
||||
return this._transmit('ACK', headers);
|
||||
};
|
||||
|
||||
Client.prototype.nack = function(messageID, subscription, headers) {
|
||||
if (headers == null) {
|
||||
headers = {};
|
||||
}
|
||||
headers['message-id'] = messageID;
|
||||
headers.subscription = subscription;
|
||||
return this._transmit('NACK', headers);
|
||||
};
|
||||
|
||||
return Client;
|
||||
|
||||
})();
|
||||
|
||||
Stomp = {
|
||||
VERSIONS: {
|
||||
V1_0: '1.0',
|
||||
V1_1: '1.1',
|
||||
V1_2: '1.2',
|
||||
supportedVersions: function() {
|
||||
return '1.1,1.0';
|
||||
}
|
||||
},
|
||||
client: function(url, protocols) {
|
||||
var klass, ws;
|
||||
if (protocols == null) {
|
||||
protocols = ['v10.stomp', 'v11.stomp'];
|
||||
}
|
||||
klass = Stomp.WebSocketClass || WebSocket;
|
||||
ws = new klass(url, protocols);
|
||||
return new Client(ws);
|
||||
},
|
||||
over: function(ws) {
|
||||
return new Client(ws);
|
||||
},
|
||||
Frame: Frame
|
||||
};
|
||||
|
||||
if (typeof exports !== 'undefined' && exports !== null) {
|
||||
exports.Stomp = Stomp;
|
||||
}
|
||||
Stomp.setInterval = function(interval, f) {
|
||||
return setInterval(f, interval);
|
||||
};
|
||||
Stomp.clearInterval = function(id) {
|
||||
return clearInterval(id);
|
||||
};
|
||||
|
||||
let data = null;
|
||||
|
||||
let topic = null;
|
||||
let header = null;
|
||||
let teststomp = null;
|
||||
function timedCount() {
|
||||
|
||||
onmessage = (e) => {
|
||||
|
||||
if (e.data.type == 'init') {
|
||||
topic = e.data.topic;
|
||||
header = {'X-Token': e.data.token };
|
||||
token = e.data.token;
|
||||
websocketUrl = e.data.baseurl + '/joylink-websocket?token=';
|
||||
|
||||
}
|
||||
|
||||
if (e.data == 'connect') {
|
||||
teststomp = new StompClient(header, token);
|
||||
teststomp.subscribe(topic, callback, header);
|
||||
}
|
||||
|
||||
if (e.data == 'off') {
|
||||
teststomp.unsubscribe(topic);
|
||||
}
|
||||
|
||||
};
|
||||
function callback(Response) {
|
||||
|
||||
data = JSON.parse(Response.body);
|
||||
|
||||
console.log(data);
|
||||
|
||||
if(data.trainPosList){
|
||||
postMessage(data);
|
||||
return;
|
||||
}
|
||||
|
||||
if(data.type == "Train_Position_3D"){
|
||||
postMessage(data);
|
||||
return;
|
||||
}
|
||||
if(data.type == "Train_Hmi_3D"){
|
||||
|
||||
postMessage(data);
|
||||
return;
|
||||
}
|
||||
|
||||
if(data.type == 'TDT_3D'){
|
||||
postMessage(data);
|
||||
return;
|
||||
}
|
||||
|
||||
if(data.type == "DeviceCtrl_3D"){
|
||||
if (data.body.type== 'SIGNAL') {
|
||||
postMessage(data);
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.body.type== "PSD") {
|
||||
postMessage(data);
|
||||
return;
|
||||
}
|
||||
if (data.body.type == "SWITCH") {
|
||||
postMessage(data);
|
||||
return;
|
||||
}
|
||||
if (data.body.type == 'TRAIN_DOOR') {
|
||||
postMessage(data);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(data.type == "Device_Load_Destroy_3D"){
|
||||
postMessage(data);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
timedCount();
|
Loading…
Reference in New Issue
Block a user