Merge remote-tracking branch 'origin/test' into dev

This commit is contained in:
fan 2019-10-25 17:09:02 +08:00
commit d5b6f172e9
61 changed files with 3453 additions and 1291 deletions

View File

@ -100,5 +100,6 @@ export default {
theDeviceTypeAlreadyExists: 'The device type already exists!',
connectToRealDeviceFailed: 'Connect to real device failed!',
getRealDeviceListFailed: 'Get real device list failed!',
deleteRealDeviceFailed: 'Delete real device failed!'
deleteRealDeviceFailed: 'Delete real device failed!',
checkTheValidityFirst: 'Please check the validity first!'
};

View File

@ -176,6 +176,7 @@ export default {
simulationSystem: 'The simulation system',
lessonSystem: 'The lesson system',
examSystem: 'The exam system',
runPlanSystem: 'The run plan system',
personalDetails: 'information',
trainingPlatformEntrance: 'Training platform entrance',
designPlatformEntrance: 'Design platform entrance'

View File

@ -11,6 +11,7 @@ export default {
saveMapAs: 'Save the map as',
create: 'establish',
dataVerification: 'data verification',
edit3d: '3D editor',
logicalView: 'logical view',
physicalView: 'Physical view',
mixedView: 'The mixed view',

View File

@ -100,5 +100,6 @@ export default {
theDeviceTypeAlreadyExists: '已存在该设备类型!',
connectToRealDeviceFailed: '关联真实设备失败!',
getRealDeviceListFailed: '获取真实设备列表失败!',
deleteRealDeviceFailed: '删除真实设备失败!'
deleteRealDeviceFailed: '删除真实设备失败!',
checkTheValidityFirst: '请先进行有效性检查!'
};

View File

@ -176,6 +176,7 @@ export default {
simulationSystem: '仿真系统',
lessonSystem: '教学系统',
examSystem: '考试系统',
runPlanSystem: '运行图系统',
personalDetails: '个人信息',
trainingPlatformEntrance: '实训平台入口',
designPlatformEntrance: '设计平台入口'

View File

@ -12,6 +12,7 @@ export default {
saveMapAs: '地图另存为',
create: '创建',
dataVerification: '数据校验',
edit3d: '三维编辑',
logicalView: '逻辑视图',
physicalView: '物理视图',
mixedView: '混合视图',
@ -119,7 +120,7 @@ export default {
editAutoRouting: '编辑自动信号',
setSwitch: '联动道岔',
pathUnit: '路径单元',
jlmap3d: '三维编辑',
jlmap3d: '三维编辑',
automaticSignalList: '自动信号列表',
automaticSignalCode: '自动信号编码',

View File

@ -9,6 +9,8 @@ import {StationStandList} from '@/jlmap3d/edit/editmodel/StationStandList.js';
import {TrainList} from '@/jlmap3d/edit/editmodel/TrainList.js';
import {TrainListTest} from '@/jlmap3d/edit/editmodel/TrainListTest.js';
import {LinkList} from '@/jlmap3d/edit/editmodel/LinkList.js';
import {RailList} from '@/jlmap3d/edit/editmodel/RailList.js';
import {RealSectionList} from '@/jlmap3d/edit/editmodel/RealSectionList.js';
@ -26,9 +28,7 @@ export function Jlmap3ddata(mapid,scope){
get3dMapData(editmapid).then(data => {
//console.log(data);
if(data.code == "200"){
//console.log("数据存在");
let isSection = false;
//console.log(data.data);
if(data.data.assets){
@ -40,13 +40,14 @@ export function Jlmap3ddata(mapid,scope){
}
}
console.log(isSection);
if(isSection == true){
init3d(editmapid,data.data);
initobj(editmapid,data.data.id);
//init3d(editmapid,data.data);
}else{
// console.log(editmapid);
// console.log(data.data.id);
initobj(editmapid,data.data.id);
init3d(editmapid,data.data);
// initobj(editmapid,data.data.id);
}
}
@ -59,7 +60,7 @@ export function Jlmap3ddata(mapid,scope){
set3dMapData(params).then(data => {
if(data.code == "200"){
//console.log("创建三维数据成功");
//console.log(data);
// console.log(data);
initobj(editmapid,data.data.id);
}
@ -71,32 +72,38 @@ export function Jlmap3ddata(mapid,scope){
});
function initobj(mapid,data3did){
console.log(mapid);
getMapDetail(mapid).then(data => {
let mapdata = data.data;
//console.log(data3did);
jlmap3ddata.id = data3did;
jlmap3ddata.mapId = mapid;
console.log(jlmap3ddata.mapId);
//初始化轨道和道岔 暂时
jlmap3ddata.linklist = new LinkList();
jlmap3ddata.sectionlist = new SectionList();
jlmap3ddata.signallist = new SignalList();
//初始化站台
jlmap3ddata.stationstandlist = new StationStandList();
jlmap3ddata.trainlisttest = new TrainListTest();
jlmap3ddata.raillist = new RailList();
assetloader.assetinit(scene)
.then(function(data){
//console.log(data);
return jlmap3ddata.sectionlist.initpromise(mapdata.sectionList,mapdata.switchList,scene);
return jlmap3ddata.linklist.initpromise(mapdata.linkList,scene,assetloader);
})
.then(function(data){
//console.log(data);
return jlmap3ddata.signallist.initpromise(mapdata.signalList,scene,assetloader);
return jlmap3ddata.sectionlist.initpromise(jlmap3ddata,assetloader,mapdata.sectionList,mapdata.switchList,scene);
})
.then(function(data){
//console.log(data);
return jlmap3ddata.stationstandlist.initpromise(mapdata.stationList,mapdata.stationStandList,scene,assetloader);
return jlmap3ddata.signallist.initpromise(jlmap3ddata,mapdata.signalList,scene,assetloader);
})
.then(function(data){
//console.log(data);
return jlmap3ddata.stationstandlist.initpromise(jlmap3ddata,mapdata.stationList,mapdata.stationStandList,scene,assetloader);
})
.then(function(data){
//console.log(data);
@ -107,56 +114,66 @@ export function Jlmap3ddata(mapid,scope){
loadingInstance.close();
});
//初始化信号
SetObj(mapdata,scope);
//SetObj(mapdata,scope);
});
}
function init3d(mapid,netdata){
console.log(netdata)
getMapDetail(mapid).then(data => {
jlmap3ddata.id = netdata.id;
jlmap3ddata.mapId = mapid;
let mapdata = data.data;
//初始化轨道和道岔 暂时
jlmap3ddata.sectionlist = new SectionList();
jlmap3ddata.signallist = new SignalList();
//初始化站台
jlmap3ddata.stationstandlist = new StationStandList();
//初始化测试列车
jlmap3ddata.trainlisttest = new TrainListTest();
jlmap3ddata.linklist = new LinkList();
//初始化轨道和道岔 暂时
jlmap3ddata.sectionlist = new SectionList();
jlmap3ddata.signallist = new SignalList();
//初始化站台
jlmap3ddata.stationstandlist = new StationStandList();
//初始化测试列车
jlmap3ddata.trainlisttest = new TrainListTest();
jlmap3ddata.realsectionlist = new RealSectionList();
jlmap3ddata.raillist = new RailList();
assetloader.setmodellist(netdata.assets);
let loaderdata = JSON.parse(netdata.sections);
let switchdata = JSON.parse(netdata.switchs);
let signaldata = JSON.parse(netdata.signals);
let standsdata = JSON.parse(netdata.stands);
assetloader.assetpromise(scene)
.then(function(data){
//console.log(data);
return jlmap3ddata.sectionlist.initpromise(mapdata.sectionList,mapdata.switchList,scene);
})
.then(function(data){
//console.log(data);
return jlmap3ddata.signallist.initpromise(mapdata.signalList,scene,assetloader,netdata.signals);
})
.then(function(data){
//console.log(data);
return jlmap3ddata.stationstandlist.initpromise(mapdata.stationList,mapdata.stationStandList,scene,assetloader,netdata.stands);
})
.then(function(data){
//console.log(data);
return jlmap3ddata.trainlisttest.initpromise(mapdata.trainList,scene,assetloader);
})
.then(function(data){
//console.log(data);
return jlmap3ddata.realsectionlist.initpromise(jlmap3ddata,scene,assetloader);
})
.then(function(data){
//console.log(data);
loadingInstance.close();
});
assetloader.setmodellist(netdata.assets);
assetloader.assetpromise(scene)
.then(function(data){
//console.log(data);
return jlmap3ddata.linklist.loadpromise(loaderdata.link,scene,assetloader);
})
.then(function(data){
//console.log(data);
return jlmap3ddata.sectionlist.loadpromise(jlmap3ddata,assetloader,loaderdata.section,switchdata,scene);
})
.then(function(data){
//console.log(data);
return jlmap3ddata.signallist.loadpromise(signaldata,scene,assetloader,mapdata.signalList);
})
.then(function(data){
//console.log(data);
return jlmap3ddata.stationstandlist.initpromise(jlmap3ddata,mapdata.stationList,mapdata.stationStandList,scene,assetloader,standsdata);
})
.then(function(data){
//console.log(data);
return jlmap3ddata.trainlisttest.initpromise(mapdata.trainList,scene,assetloader);
})
// .then(function(data){
// //console.log(data);
// return jlmap3ddata.realsectionlist.loadpromise(jlmap3ddata,scene,assetloader);
// })
.then(function(data){
//console.log(data);
loadingInstance.close();
});
});
});
}

View File

@ -36,34 +36,63 @@ export function Sectionaction(){
}
}
//点击事件
this.raycaster = function(data){
console.log();
if(scope.on == true){
this.raycaster = function(data,type){
console.log(type);
let modellist;
if(type == "test"){
modellist = data.scene.getObjectByName("link").children;
}else if(type == "suidao"){
modellist = data.scene.getObjectByName("section").children;
}else if(type == "switch"){
modellist = data.scene.getObjectByName("switch").children;
}else{
if(scope.on == true){
//定义光线
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;
//定义光线
let raycaster = new THREE.Raycaster();
//定义平面鼠标点击坐标
raycaster.setFromCamera( mouse, data.camera );
let intersects1;
console.log(data.mapdata.sectionlist.sections.modellist[0]);
for(let i=0;i<data.mapdata.sectionlist.sections.modellist.length;i++){
intersects1 = raycaster.intersectObject(data.mapdata.sectionlist.sections.modellist[i]);
if(intersects1[0]){
console.log(intersects1[0].object.code);
console.log(data.mapdata.sectionlist.sections.modellist[i].code);
if(intersects1[0].object.code == data.mapdata.sectionlist.sections.modellist[i].code){
let mouse = new THREE.Vector2();
mouse.x = (event.clientX / window.innerWidth) * 2 - 1;
mouse.y = -(event.clientY / window.innerHeight) * 2 + 1;
return data.mapdata.sectionlist.sections.modellist[i];
raycaster.setFromCamera( mouse, data.camera );
let intersects1;
for(let i=0;i<data.mapdata.sectionlist.sections.modellist.length;i++){
intersects1 = raycaster.intersectObject(data.mapdata.sectionlist.sections.modellist[i]);
if(intersects1[0]){
if(intersects1[0].object.code == data.mapdata.sectionlist.sections.modellist[i].code){
return data.mapdata.sectionlist.sections.modellist[i];
}
}
}
}
return null;
return null;
}
}
//定义光线
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, data.camera );
let intersects1;
for(let i=0;i<modellist.length;i++){
intersects1 = raycaster.intersectObject(modellist[i],true);
if(intersects1[0]){
console.log(intersects1[0].object.code);
console.log(modellist[i].code);
if(intersects1[0].object.code == modellist[i].code){
return modellist[i];
}
}
}
return null;
}
this.changemodel = function(jlmap3dedit,changedata){

View File

@ -1,7 +1,6 @@
//import request from '@/utils/request';
export function getmodels(data) {
console.log(data);
let postmap = {
id:data.mapdata.id,
mapId:data.mapdata.mapId,
@ -35,32 +34,77 @@ export function getmodels(data) {
assets.push(asset);
}
postmap.assets = JSON.stringify(assets);
//区段
//link轨道
let links = [];
for(let i=0;i<data.mapdata.linklist.linksgroup.children.length;i++){
let link = {
uuid:data.mapdata.linklist.linksgroup.children[i].uuid,
code:data.mapdata.linklist.linksgroup.children[i].code,
name:data.mapdata.linklist.linksgroup.children[i].name,
lengthfact:data.mapdata.linklist.linksgroup.children[i].lengthfact,
position:data.mapdata.linklist.linksgroup.children[i].position,
rotation:data.mapdata.linklist.linksgroup.children[i].rotation,
scale:data.mapdata.linklist.linksgroup.children[i].scale,
rightlist:data.mapdata.linklist.linksgroup.children[i].rightlist,
leftlist:data.mapdata.linklist.linksgroup.children[i].leftlist,
lp:data.mapdata.linklist.linksgroup.children[i].lp,
rp:data.mapdata.linklist.linksgroup.children[i].rp,
rail:data.mapdata.linklist.linksgroup.children[i].rail,
}
links.push(link);
}
// postmap.sections.link = JSON.stringify(links);
//section隧道
console.log(data.mapdata.sectionlist.sections);
let sections = [];
for(let i=0;i<data.mapdata.sectionlist.sections.datalist.length;i++){
let section = {
uuid:data.mapdata.sectionlist.sections.datalist[i].uuid,
name:data.mapdata.sectionlist.sections.datalist[i].name,
index:data.mapdata.sectionlist.sections.datalist[i].index,
isStandTrack:data.mapdata.sectionlist.sections.datalist[i].isStandTrack,
rail:data.mapdata.sectionlist.sections.datalist[i].rail,
distance:data.mapdata.sectionlist.sections.datalist[i].distance,
uuid:data.mapdata.sectionlist.sections.modellist[i].uuid,
code:data.mapdata.sectionlist.sections.modellist[i].code,
name:data.mapdata.sectionlist.sections.modellist[i].name,
lengthfact:data.mapdata.sectionlist.sections.modellist[i].lengthfact,
isStandTrack:data.mapdata.sectionlist.sections.modellist[i].isStandTrack,
relStandCode:data.mapdata.sectionlist.sections.datalist[i].relStandCode,
linkCode:data.mapdata.sectionlist.sections.datalist[i].linkCode,
rightlist:data.mapdata.sectionlist.sections.modellist[i].rightlist,
leftlist:data.mapdata.sectionlist.sections.modellist[i].leftlist,
rightpoint:data.mapdata.sectionlist.sections.modellist[i].rightpoint,
leftpoint:data.mapdata.sectionlist.sections.modellist[i].leftpoint,
rail:data.mapdata.sectionlist.sections.modellist[i].rail,
position:data.mapdata.sectionlist.sections.modellist[i].position,
rotation:data.mapdata.sectionlist.sections.modellist[i].rotation,
scale:data.mapdata.sectionlist.sections.modellist[i].scale
}
// testmesh1.position.z = link.position.z;
sections.push(section);
}
postmap.sections = JSON.stringify(sections);
console.log(links);
let arrray = {
link:links,
section:sections,
};
postmap.sections = JSON.stringify(arrray);
//道岔
let switchs = [];
for(let i=0;i<data.mapdata.sectionlist.switchs.datalist.length;i++){
console.log(data.mapdata.sectionlist.switchs.datalist);
for(let i=0;i<data.mapdata.sectionlist.switchs.modellist.length;i++){
let switcha = {
uuid:data.mapdata.sectionlist.switchs.datalist[i].uuid,
uuid:data.mapdata.sectionlist.switchs.modellist[i].uuid,
code:data.mapdata.sectionlist.switchs.datalist[i].code,
name:data.mapdata.sectionlist.switchs.datalist[i].name,
index:data.mapdata.sectionlist.switchs.datalist[i].index,
alink:data.mapdata.sectionlist.switchs.datalist[i].alink,
blink:data.mapdata.sectionlist.switchs.datalist[i].blink,
clink:data.mapdata.sectionlist.switchs.datalist[i].clink,
paname:data.mapdata.sectionlist.switchs.datalist[i].paname,
pbname:data.mapdata.sectionlist.switchs.datalist[i].pbname,
pcname:data.mapdata.sectionlist.switchs.datalist[i].pcname,
pa:data.mapdata.sectionlist.switchs.datalist[i].pa,
pb:data.mapdata.sectionlist.switchs.datalist[i].pb,
pc:data.mapdata.sectionlist.switchs.datalist[i].pc,
position:data.mapdata.sectionlist.switchs.modellist[i].position,
rotation:data.mapdata.sectionlist.switchs.modellist[i].rotation,
scale:data.mapdata.sectionlist.switchs.modellist[i].scale
@ -90,7 +134,6 @@ export function getmodels(data) {
let stands = [];
for(let i=0;i<data.mapdata.stationstandlist.list.length;i++){
console.log(data.mapdata.stationstandlist.list[i]);
let station = {
uuid:data.mapdata.stationstandlist.list[i].uuid,
code:data.mapdata.stationstandlist.list[i].code,

View File

@ -1,31 +1,309 @@
export function LinkList(data,scene){
export function LinkList(data){
let groups = new THREE.Group();
let linklist = [];
for(let i=0;i<data.length;i++){
let lineGeometry = new THREE.Geometry();//生成几何体
let scope = this;
lineGeometry.vertices.push(new THREE.Vector3(data[i].lp.x, 1, data[i].lp.y));//线段的两个顶点
lineGeometry.vertices.push(new THREE.Vector3(data[i].rp.x, 1, data[i].rp.y));
this.type = "linklist";
let line = new THREE.Line(lineGeometry, new THREE.LineDashedMaterial({
color: 0x080808,//线段的颜色
dashSize: 1,//短划线的大小
gapSize: 3//短划线之间的距离
}));
line.name = data[i].code;
line.lengthFact = data[i].lengthFact;
line.lp = data[i].lp;
line.rp = data[i].rp;
line.distancex = data[i].rp.x-data[i].lp.x;
line.distancey = data[i].rp.y-data[i].lp.y;
line.computeLineDistances();//不可或缺的,若无,则线段不能显示为虚线
groups.add(line);
groups.position.z = 400;
linklist.push(line);
}
scene.add(groups);
return linklist;
this.linkdata = [];
this.linksgroup = new THREE.Group();
this.linksgroup.name = "link";
this.initpromise = function(linkdata,scene,assetloader){
return new Promise(function(resolve, reject){
linkhelp(linkdata,scene);
scene.add(scope.linksgroup);
linktest(linkdata,scene,assetloader);
resolve("loadedrealsection");
});
};
this.loadpromise = function(linkdata,scene,assetloader){
return new Promise(function(resolve, reject){
scene.add(scope.linksgroup);
loadlink(linkdata,scene,assetloader);
resolve("loadedrealsection");
});
};
function linkhelp(data,scene){
let groups = new THREE.Group();
for(let i=0;i<data.length;i++){
let lineGeometry = new THREE.Geometry();//生成几何体
lineGeometry.vertices.push(new THREE.Vector3(data[i].lp.x, 1, data[i].lp.y));//线段的两个顶点
lineGeometry.vertices.push(new THREE.Vector3(data[i].rp.x, 1, data[i].rp.y));
let line = new THREE.Line(lineGeometry, new THREE.LineDashedMaterial({
color: 0xffffff,//线段的颜色
dashSize: 1,//短划线的大小
gapSize: 3//短划线之间的距离
}));
line.name = data[i].code;
line.lengthFact = data[i].lengthFact;
line.lp = data[i].lp;
line.rp = data[i].rp;
line.distancex = data[i].rp.x-data[i].lp.x;
line.distancey = data[i].rp.y-data[i].lp.y;
line.computeLineDistances();//不可或缺的,若无,则线段不能显示为虚线
groups.add(line);
}
groups.position.z = 2000;
scene.add(groups);
}
function loadlink(data,scene,assetloader){
let autorail;
for(let i=0;i<assetloader.modellist.length;i++){
if(assetloader.modellist[i].deviceType == "autorail"){
autorail = assetloader.modellist[i].mesh.children[0];
}
}
let count = autorail.geometry.attributes.position.count;
let rightlist = [];
let leftlist = [];
for(let i=0;i<count;i++){
if(autorail.geometry.attributes.position.array[i*3] >0.49){
rightlist.push(i);
}
if(autorail.geometry.attributes.position.array[i*3] <-0.49){
leftlist.push(i);
}
}
for(let i=0;i<data.length;i++){
let testmesh2 = autorail.clone(true);
testmesh2.code = data[i].code;
testmesh2.name = data[i].name;
testmesh2.rightlist = rightlist;
testmesh2.leftlist = leftlist;
testmesh2.rp = data[i].rp;
testmesh2.lp = data[i].lp;
testmesh2.lengthfact = data[i].lengthfact;
for(let i=0;i<testmesh2.rightlist.length;i++){
testmesh2.geometry.attributes.position.array[testmesh2.rightlist[i]*3] = testmesh2.lengthfact-25;
testmesh2.geometry.attributes.uv.array[testmesh2.rightlist[i]*2] = testmesh2.geometry.attributes.position.array[0]-testmesh2.geometry.attributes.position.array[3];
}
let newrail = new THREE.BufferGeometry();
newrail.copy(testmesh2.geometry);
testmesh2.geometry = newrail;
testmesh2.geometry.attributes.position.needsUpdate = true;
testmesh2.geometry.attributes.uv.needsUpdate = true;
testmesh2.geometry.computeBoundingSphere();
testmesh2.geometry.center();
testmesh2.position.x = data[i].position.x;
testmesh2.position.y = data[i].position.y;
testmesh2.position.z = data[i].position.z;
// testmesh2.rotation.x = data[i].rotation._x;
// testmesh2.rotation.y = data[i].rotation._y;
testmesh2.rotation.z = data[i].rotation._z;
scope.linkdata.push(testmesh2);
scope.linksgroup.add(testmesh2);
}
}
// return linklist;
function linktest(data,scene,assetloader){
let autorail = null;
let autosuidao = null;
for(let i=0;i<assetloader.modellist.length;i++){
if(assetloader.modellist[i].deviceType == "autorail"){
autorail = assetloader.modellist[i].mesh.children[0];
}
}
let rightlist = [];
let leftlist = [];
let count = autorail.geometry.attributes.position.count;
for(let i=0;i<count;i++){
if(autorail.geometry.attributes.position.array[i*3] >0.49){
rightlist.push(i);
}
if(autorail.geometry.attributes.position.array[i*3] <-0.49){
leftlist.push(i);
}
}
autorail.rightlist = rightlist;
autorail.leftlist = leftlist;
let reallinks = [];
let testlink;
testlink = data;
if(data){
let index,startdata;
for(let n=0;n<data.length;n++){
if(data[n].leftFdCode == undefined && data[n].leftSdCode == undefined && data[n].rightFdCode ){
if(startdata){
if(data[n].lp.x<startdata.lp.x){
startdata = data[n];
index = n;
}
}else{
startdata = data[n];
index = n;
}
}
}
buildmodel(startdata);
reallinks.push(startdata);
data.splice(index,1);
for(let i=0;i<reallinks.length;i++){
for(let j=0;j<data.length;j++){
if(reallinks[i].leftFdCode && j>=0){
if(reallinks[i].leftFdCode == data[j].code){
buildmodel(data[j],reallinks[i],j,"left");
reallinks.push(data[j]);
data.splice(j,1);
j--;
}
}
if(reallinks[i].leftSdCode && j>=0){
if(reallinks[i].leftSdCode == data[j].code){
buildmodel(data[j],reallinks[i],j,"left");
reallinks.push(data[j]);
data.splice(j,1);
j--;
}
}
if(reallinks[i].rightFdCode && j>=0){
if(reallinks[i].rightFdCode == data[j].code){
buildmodel(data[j],reallinks[i],j,"right");
reallinks.push(data[j]);
data.splice(j,1);
j--;
}
}
if(reallinks[i].rightSdCode && j>=0){
if(reallinks[i].rightSdCode == data[j].code){
buildmodel(data[j],reallinks[i],j,"right");
reallinks.push(data[j]);
data.splice(j,1);
j--;
}
}
}
}
function buildmodel(data,mdata,sx,direct){
let len = data.lengthFact;
let testmesh2 = autorail.clone(true);
for(let i=0;i<autorail.rightlist.length;i++){
testmesh2.geometry.attributes.position.array[autorail.rightlist[i]*3] = len-25;
testmesh2.geometry.attributes.uv.array[autorail.rightlist[i]*2] = testmesh2.geometry.attributes.position.array[0]-testmesh2.geometry.attributes.position.array[3];
}
let newrail = new THREE.BufferGeometry();
newrail.copy(testmesh2.geometry);
testmesh2.geometry = newrail;
testmesh2.geometry.attributes.position.needsUpdate = true;
testmesh2.geometry.attributes.uv.needsUpdate = true;
testmesh2.geometry.computeBoundingSphere();
testmesh2.geometry.center();
// data.lp.y *= 10;
// data.rp.y *= 10;
if(mdata){
if(direct == "left"){
let dx = Math.abs(data.lp.x - data.rp.x);
    let dy = Math.abs(data.lp.y - data.rp.y);
    let distance = Math.sqrt(Math.pow(dx,2)+Math.pow(dy,2));
data.lp.x = (data.lp.x-data.rp.x)*data.lengthFact/distance+mdata.lp.x;
data.lp.y = (data.lp.y-data.rp.y)*data.lengthFact/distance+mdata.lp.y;
data.rp.x = mdata.lp.x;
data.rp.y = mdata.lp.y;
let axix = new THREE.Vector3(1,0,0);
let axixnow = new THREE.Vector3(data.rp.x-data.lp.x,0,data.rp.y-data.lp.y);
let rotenum = axixnow.angleTo(axix);
//不同坐标系方向值不同
if(data.lp.y>data.rp.y){
testmesh2.rotation.z = 0.218;
data.lp.x = data.rp.x - (data.lengthFact)*Math.cos(testmesh2.rotation.z);
data.lp.y = data.rp.y + (data.lengthFact)*Math.sin(testmesh2.rotation.z);
}else if(data.lp.y<data.rp.y){
testmesh2.rotation.z = -0.218;
data.lp.x = data.rp.x - (data.lengthFact)*Math.cos(testmesh2.rotation.z);
data.lp.y = data.rp.y + (data.lengthFact)*Math.sin(testmesh2.rotation.z);
}else{
testmesh2.rotation.z = rotenum;
}
testmesh2.position.x = (data.rp.x + data.lp.x)/2;
testmesh2.position.z = (data.rp.y + data.lp.y)/2;
}
if(direct == "right"){
let dx = Math.abs(data.lp.x - data.rp.x);
    let dy = Math.abs(data.lp.y - data.rp.y);
    let distance = Math.sqrt(Math.pow(dx,2)+Math.pow(dy,2));
data.rp.x = (data.rp.x-data.lp.x)*data.lengthFact/distance+mdata.rp.x;
data.rp.y = (data.rp.y-data.lp.y)*data.lengthFact/distance+mdata.rp.y;
data.lp.x = mdata.rp.x;
data.lp.y = mdata.rp.y;
let axix = new THREE.Vector3(1,0,0);
let axixnow = new THREE.Vector3(data.rp.x-data.lp.x,0,data.rp.y-data.lp.y);
let rotenum = axixnow.angleTo(axix);
//不同坐标系方向值不同
if(data.lp.y>data.rp.y){
testmesh2.rotation.z = 0.218;
data.rp.x = data.lp.x+(data.lengthFact)*Math.cos(testmesh2.rotation.z);
data.rp.y = data.lp.y-(data.lengthFact)*Math.sin(testmesh2.rotation.z);
}else if(data.lp.y<data.rp.y){
testmesh2.rotation.z = -0.218;
data.rp.x = data.lp.x+(data.lengthFact)*Math.cos(testmesh2.rotation.z);
data.rp.y = data.lp.y-(data.lengthFact)*Math.sin(testmesh2.rotation.z);
}
testmesh2.position.x = (data.lp.x + data.rp.x)/2;
testmesh2.position.z = (data.lp.y + data.rp.y)/2;
}
}else{
data.lp.x = data.lp.x;
data.rp.x = data.lp.x + data.lengthFact;
testmesh2.position.x = (data.lp.x + data.rp.x)/2;
testmesh2.position.z = (data.lp.y + data.rp.y)/2;
}
// testmesh2.position.y = 10;
testmesh2.code = data.code;
testmesh2.name = data.name;
testmesh2.meshtype = "link";
testmesh2.lp = data.lp;
testmesh2.rp = data.rp;
testmesh2.rightlist = autorail.rightlist;
testmesh2.leftlist = autorail.leftlist;
testmesh2.lengthfact = data.lengthFact;
scope.linksgroup.add( testmesh2 );
scope.linkdata.push(testmesh2);
}
}
}
}

View File

@ -0,0 +1,69 @@
export function RailList(){
let scope = this;
this.linkrail = [];
this.switchrail = [];
this.setrail = function(){
};
this.resetrail = function(mapdata,scene){
console.log(mapdata);
let raillink = mapdata.linklist.linksgroup.children;
for(let i=0;i<raillink.length;i++){
var geometry = new THREE.PlaneBufferGeometry( raillink[i].lengthfact-25, 0.1, 0.1 );
var material = new THREE.MeshBasicMaterial( {color: 0xffff00, side: THREE.DoubleSide} );
var plane = new THREE.Mesh( geometry, material );
plane.position.x = raillink[i].position.x;
plane.position.y = 2;
plane.position.z = raillink[i].position.z;
plane.rotation.x = -Math.PI/2;
plane.rotation.z = raillink[i].rotation._z;
var geometry1 = new THREE.CircleBufferGeometry( 1, 16 );
var material1 = new THREE.MeshBasicMaterial( { color: 0xffff00 } );
var geometry2 = new THREE.CircleBufferGeometry( 1, 16 );
var material2 = new THREE.MeshBasicMaterial( { color: 0xff2000 } );
var circle1 = new THREE.Mesh( geometry1, material1 );
circle1.position.x = plane.position.x + (raillink[i].lengthfact-25)/2*Math.cos(plane.rotation.z);
circle1.position.z = plane.position.z - (raillink[i].lengthfact-25)/2*Math.sin(plane.rotation.z);
circle1.rotation.x = -Math.PI/2;
scene.add( circle1 );
var circle2 = new THREE.Mesh( geometry2, material2 );
circle2.position.x = plane.position.x - (raillink[i].lengthfact-25)/2*Math.cos(plane.rotation.z);
circle2.position.z = plane.position.z + (raillink[i].lengthfact-25)/2*Math.sin(plane.rotation.z);
circle2.rotation.x = -Math.PI/2;
mapdata.linklist.linksgroup.children[i].rail = [{
x:circle2.position.x,
z:circle2.position.z
},{
x:circle1.position.x,
z:circle1.position.z
}];
scene.add( circle2 );
scene.add( plane );
}
for(let i=0;i<mapdata.sectionlist.switchs.modellist.length;i++){
var geometry = new THREE.CircleBufferGeometry( 1, 16 );
var material = new THREE.MeshBasicMaterial( { color: 0xff00ff } );
var circle1 = new THREE.Mesh( geometry, material );
circle1.position.x = mapdata.sectionlist.switchs.modellist[i].position.x;
circle1.position.z = mapdata.sectionlist.switchs.modellist[i].position.z;
circle1.rotation.x = -Math.PI/2;
scene.add( circle1 );
}
};
this.getrail = function(){
};
}

View File

@ -12,8 +12,9 @@ export function RealSectionList(data) {
this.switch = [];
this.initpromise = function(jlmap3ddata,scene,assetloader){
this.initpromise = function(sectiondata,switchdata,scene){
return new Promise(function(resolve, reject){
console.log(jlmap3ddata);
let modelnum = null;
for(let i=0;i<assetloader.modellist.length;i++){
if(assetloader.modellist[i].deviceType == "mapSection"){
@ -22,28 +23,28 @@ export function RealSectionList(data) {
}
let newmesh = assetloader.modellist[modelnum].mesh;
//let mixer = new THREE.AnimationMixer( newmesh );
////console.log(jlmap3ddata.sectionlist);
////console.log(sectiondata.sectionlist);
for(let i=0;i<newmesh.children.length;i++){
let name = newmesh.children[i].name.split("_");
let newmeshname = name[0]+"_"+name[1]+"_"+name[2]+"."+name[3];
////console.log(newmeshname);
if(name[0] == "Switch"){
for(let j=0;j<jlmap3ddata.sectionlist.switchs.datalist.length;j++){
if(jlmap3ddata.sectionlist.switchs.datalist[j].name == newmeshname){
for(let j=0;j<sectiondata.sectionlist.switchs.datalist.length;j++){
if(sectiondata.sectionlist.switchs.datalist[j].name == newmeshname){
//绿色道岔
var box = new THREE.BoxHelper( newmesh.children[i], 0x00EE00 );
scene.add(box);
let nowname = jlmap3ddata.sectionlist.switchs.datalist[j].name;
let nowcode = jlmap3ddata.sectionlist.switchs.datalist[j].code;
let nowname = sectiondata.sectionlist.switchs.datalist[j].name;
let nowcode = sectiondata.sectionlist.switchs.datalist[j].code;
newmesh.children[i].name = nowname;
newmesh.children[i].code = nowcode;
for(let n=0;n<newmesh.children[i].children.length;n++){
newmesh.children[i].children[n].code = nowcode;
}
jlmap3ddata.sectionlist.switchs.modellist[j] = newmesh.children[i];
j = jlmap3ddata.sectionlist.switchs.datalist.length;
sectiondata.sectionlist.switchs.modellist[j] = newmesh.children[i];
j = sectiondata.sectionlist.switchs.datalist.length;
}
}
@ -52,11 +53,11 @@ export function RealSectionList(data) {
if(name[0] == "Section"){
//console.log(newmesh.children[i]);
//物理区段
for(let j=0;j<jlmap3ddata.sectionlist.sections.datalist.length;j++){
for(let j=0;j<sectiondata.sectionlist.sections.datalist.length;j++){
if(jlmap3ddata.sectionlist.sections.datalist[j].name == newmeshname){
if(sectiondata.sectionlist.sections.datalist[j].name == newmeshname){
if(jlmap3ddata.sectionlist.sections.datalist[j].isStandTrack == true){
if(sectiondata.sectionlist.sections.datalist[j].isStandTrack == true){
//红色站台区段
var box = new THREE.BoxHelper( newmesh.children[i], 0xff0000 );
}else{
@ -65,12 +66,12 @@ export function RealSectionList(data) {
}
scene.add( box );
let nowname = jlmap3ddata.sectionlist.sections.datalist[j].name;
let nowcode = jlmap3ddata.sectionlist.sections.datalist[j].code;
let nowname = sectiondata.sectionlist.sections.datalist[j].name;
let nowcode = sectiondata.sectionlist.sections.datalist[j].code;
newmesh.children[i].name = nowname;
newmesh.children[i].code = nowcode;
jlmap3ddata.sectionlist.sections.modellist[j] = newmesh.children[i];
j = jlmap3ddata.sectionlist.sections.datalist.length;
sectiondata.sectionlist.sections.modellist[j] = newmesh.children[i];
j = sectiondata.sectionlist.sections.datalist.length;
}
@ -87,32 +88,32 @@ export function RealSectionList(data) {
});
}
this.init = function(jlmap3ddata,scene,assetloader){
this.init = function(sectiondata,scene,assetloader){
let newmesh = assetloader.modellist[2].mesh;
//let mixer = new THREE.AnimationMixer( newmesh );
////console.log(jlmap3ddata.sectionlist);
////console.log(sectiondata.sectionlist);
for(let i=0;i<newmesh.children.length;i++){
let name = newmesh.children[i].name.split("_");
let newmeshname = name[0]+"_"+name[1]+"_"+name[2]+"."+name[3];
////console.log(newmeshname);
if(name[0] == "Switch"){
for(let j=0;j<jlmap3ddata.sectionlist.switchs.datalist.length;j++){
if(jlmap3ddata.sectionlist.switchs.datalist[j].name == newmeshname){
for(let j=0;j<sectiondata.sectionlist.switchs.datalist.length;j++){
if(sectiondata.sectionlist.switchs.datalist[j].name == newmeshname){
//绿色道岔
var box = new THREE.BoxHelper( newmesh.children[i], 0x00EE00 );
scene.add(box);
let nowname = jlmap3ddata.sectionlist.switchs.datalist[j].name;
let nowcode = jlmap3ddata.sectionlist.switchs.datalist[j].code;
let nowname = sectiondata.sectionlist.switchs.datalist[j].name;
let nowcode = sectiondata.sectionlist.switchs.datalist[j].code;
newmesh.children[i].name = nowname;
newmesh.children[i].code = nowcode;
for(let n=0;n<newmesh.children[i].children.length;n++){
newmesh.children[i].children[n].code = nowcode;
}
jlmap3ddata.sectionlist.switchs.modellist[j] = newmesh.children[i];
j = jlmap3ddata.sectionlist.switchs.datalist.length;
sectiondata.sectionlist.switchs.modellist[j] = newmesh.children[i];
j = sectiondata.sectionlist.switchs.datalist.length;
}
}
@ -121,11 +122,11 @@ export function RealSectionList(data) {
if(name[0] == "Section"){
//物理区段
for(let j=0;j<jlmap3ddata.sectionlist.sections.datalist.length;j++){
for(let j=0;j<sectiondata.sectionlist.sections.datalist.length;j++){
if(jlmap3ddata.sectionlist.sections.datalist[j].name == newmeshname){
if(sectiondata.sectionlist.sections.datalist[j].name == newmeshname){
if(jlmap3ddata.sectionlist.sections.datalist[j].isStandTrack == true){
if(sectiondata.sectionlist.sections.datalist[j].isStandTrack == true){
//红色站台区段
var box = new THREE.BoxHelper( newmesh.children[i], 0xff0000 );
}else{
@ -134,12 +135,12 @@ export function RealSectionList(data) {
}
scene.add( box );
let nowname = jlmap3ddata.sectionlist.sections.datalist[j].name;
let nowcode = jlmap3ddata.sectionlist.sections.datalist[j].code;
let nowname = sectiondata.sectionlist.sections.datalist[j].name;
let nowcode = sectiondata.sectionlist.sections.datalist[j].code;
newmesh.children[i].name = nowname;
newmesh.children[i].code = nowcode;
jlmap3ddata.sectionlist.sections.modellist[j] = newmesh.children[i];
j = jlmap3ddata.sectionlist.sections.datalist.length;
sectiondata.sectionlist.sections.modellist[j] = newmesh.children[i];
j = sectiondata.sectionlist.sections.datalist.length;
}
@ -148,13 +149,13 @@ export function RealSectionList(data) {
if(name[0] == "Singal"){
for(let j=0;j<jlmap3ddata.signallist.list.length;j++){
if(jlmap3ddata.signallist.list[j].mesh.code == newmeshname){
jlmap3ddata.signallist.list[j].mesh.position.x = newmesh.children[i].position.x;
jlmap3ddata.signallist.list[j].mesh.position.y = newmesh.children[i].position.y;
jlmap3ddata.signallist.list[j].mesh.position.z = newmesh.children[i].position.z;
for(let j=0;j<sectiondata.signallist.list.length;j++){
if(sectiondata.signallist.list[j].mesh.code == newmeshname){
sectiondata.signallist.list[j].mesh.position.x = newmesh.children[i].position.x;
sectiondata.signallist.list[j].mesh.position.y = newmesh.children[i].position.y;
sectiondata.signallist.list[j].mesh.position.z = newmesh.children[i].position.z;
j = jlmap3ddata.signallist.list.length;
j = sectiondata.signallist.list.length;
}
}
}

View File

@ -6,19 +6,27 @@ export function SectionList() {
this.type = "sectionlist";
this.sectiongroup = new THREE.Group();
this.sectiongroup.name = "section";
this.switchgroup = new THREE.Group();
this.switchgroup.name = "switch";
this.sections = {
datalist:[],
modellist:[]
};
this.switchs = {
datalist:[],
modellist:[]
};
this.standtrack = [];
this.initpromise = function (sectiondata,switchdata,scene){
return new Promise(function(resolve, reject){
this.initpromise = function(jlmap3ddata,assetloader,sectiondata,switchdata,scene){
return new Promise(function(resolve, reject){
scene.add(scope.sectiongroup);
scene.add(scope.switchgroup);
let linkdata = jlmap3ddata.linklist;
//遍历区段
for(let i=0;i<sectiondata.length;i++){
if(sectiondata[i].type == "01"){
@ -29,143 +37,530 @@ export function SectionList() {
newsection.code = sectiondata[i].code;
newsection.index = i;
newsection.isStandTrack = sectiondata[i].isStandTrack;
newsection.relStandCode = sectiondata[i].relStandCode;
newsection.type = sectiondata[i].type;
newsection.offsetRight = sectiondata[i].offsetRight;
newsection.offsetLeft = sectiondata[i].offsetLeft;
newsection.linkCode = sectiondata[i].linkCode;
scope.sections.datalist.push(newsection);
scope.sections.modellist.push("");
}
}
//定义区分道岔组
let switchlist = [];
//遍历道岔数据
for(let i=0;i<switchdata.length;i++){
//道岔信息
let newswitch = {
code:null,
pa:null,
pb:null,
pc:null,
paname:null,
pbname:null,
pcname:null
};
//获取道岔分辨的点 PS:可能修改动态判断
for(let j=0;j<sectiondata.length;j++){
if(switchdata[i].sectionACode == sectiondata[j].code){
newswitch.pa = sectiondata[j].points;
newswitch.paname = switchdata[i].sectionACode;
}
if(switchdata[i].sectionBCode == sectiondata[j].code){
newswitch.pb = sectiondata[j].points;
newswitch.pbname = switchdata[i].sectionBCode;
}
if(switchdata[i].sectionCCode == sectiondata[j].code){
newswitch.pc = sectiondata[j].points;
newswitch.pcname = switchdata[i].sectionCCode;
}
if(newswitch.pa != null && newswitch.pb!= null && newswitch.pc != null){
newswitch.code = switchdata[i].code;
switchlist.push(newswitch);
j = sectiondata.length;
}
// scope.sections.modellist.push("");
}
}
buildsuidao(linkdata,scope.sections,assetloader,scene);
console.log(scope.sections.datalist);
//定义区分道岔组
let switchlist = [];
//遍历道岔数据
for(let i=0;i<switchdata.length;i++){
//道岔信息
let newswitch = {
code:null,
pa:null,
pb:null,
pc:null,
paname:null,
pbname:null,
pcname:null,
alink:null,
blink:null,
clink:null
};
//获取道岔分辨的点 PS:可能修改动态判断
//道岔贴图
//遍历道岔信息组合轨道
for(let i=0;i<switchlist.length;i++){
//道岔对象组
let newswitch = new SwitchModel();
for(let j=0;j<sectiondata.length;j++){
if(switchdata[i].sectionACode == sectiondata[j].code){
newswitch.pa = sectiondata[j].points;
newswitch.paname = switchdata[i].sectionACode;
newswitch.name = switchlist[i].code;
newswitch.code = switchlist[i].code;
}
if(switchdata[i].sectionBCode == sectiondata[j].code){
newswitch.pb = sectiondata[j].points;
newswitch.pbname = switchdata[i].sectionBCode;
}
if(switchdata[i].sectionCCode == sectiondata[j].code){
newswitch.pc = sectiondata[j].points;
newswitch.pcname = switchdata[i].sectionCCode;
}
if(newswitch.pa != null && newswitch.pb!= null && newswitch.pc != null){
newswitch.code = switchdata[i].code;
switchlist.push(newswitch);
j = sectiondata.length;
}
}
newswitch.index = i;
for(let n=0;n<scope.sections.datalist.length;n++){
if(scope.sections.datalist[n].code == switchlist[i].paname){
switchlist[i].alink = scope.sections.datalist[n].linkCode;
}
if(scope.sections.datalist[n].code == switchlist[i].pbname){
switchlist[i].blink = scope.sections.datalist[n].linkCode;
}
if(scope.sections.datalist[n].code == switchlist[i].pcname){
switchlist[i].clink = scope.sections.datalist[n].linkCode;
}
if(switchlist[i].alink != null && switchlist[i].blink!= null && switchlist[i].clink != null){
n = scope.sections.datalist.length;
}
}
}
scope.switchs.datalist = switchlist;
console.log(switchlist);
//道岔贴图
let switchmesh1;
let switchmesh2;
for(let i=0;i<assetloader.modellist.length;i++){
if(assetloader.modellist[i].deviceType == "autoswitch1"){
switchmesh1 = assetloader.modellist[i].mesh;
}
if(assetloader.modellist[i].deviceType == "autoswitch2"){
switchmesh2 = assetloader.modellist[i].mesh;
}
}
scope.switchs.datalist.push(newswitch);
scope.switchs.modellist.push("");
}
//遍历道岔信息组合轨道
for(let i=0;i<switchlist.length;i++){
let sectionA,sectionB,sectionC;
for(let j=0;j<scope.sections.modellist.length;j++){
if(switchlist[i].paname == scope.sections.modellist[j].code){
sectionA = scope.sections.modellist[j];
}else if(switchlist[i].pbname == scope.sections.modellist[j].code){
sectionB = scope.sections.modellist[j];
}else if(switchlist[i].pcname == scope.sections.modellist[j].code){
sectionC = scope.sections.modellist[j];
}
}
let testswitch;
// console.log(sectionA);
// console.log(sectionB);
// console.log(sectionC);
let sarightpoint = sectionA.position.x + sectionA.geometry.attributes.position.array[sectionA.rightpoint*3];
let saleftpoint = sectionA.position.x - sectionA.geometry.attributes.position.array[sectionA.leftpoint*3];
let sbrightpoint = sectionB.position.x + sectionB.geometry.attributes.position.array[sectionB.rightpoint*3];
let sbleftpoint = sectionB.position.x - sectionB.geometry.attributes.position.array[sectionB.leftpoint*3];
let switchposz = sectionA.position.z;
let switchposx;
if(switchlist[i].code == "Switch_135_0.16369"){
console.log(switchlist[i]);
}
if(switchlist[i].pa[0].x>switchlist[i].pb[0].x){
if(((switchlist[i].pc[0].y+switchlist[i].pc[1].y)/2) < switchlist[i].pa[0].y){
if(((switchlist[i].pc[0].x+switchlist[i].pc[1].x)/2)>switchlist[i].pa[0].x){
testswitch = switchmesh1.clone(true);
}else{
testswitch = switchmesh2.clone(true);
}
}else{
if(((switchlist[i].pc[0].x+switchlist[i].pc[1].x)/2)>switchlist[i].pa[0].x){
testswitch = switchmesh2.clone(true);
}else{
testswitch = switchmesh1.clone(true);
}
testswitch.rotation.y = Math.PI;
}
switchposx = (saleftpoint+sbrightpoint)/2;
}else{
if(((switchlist[i].pc[0].y+switchlist[i].pc[1].y)/2) < switchlist[i].pa[1].y){
if(((switchlist[i].pc[0].x+switchlist[i].pc[1].x)/2)>switchlist[i].pa[1].x){
testswitch = switchmesh1.clone(true);
}else{
testswitch = switchmesh2.clone(true);
}
}else{
if(((switchlist[i].pc[0].x+switchlist[i].pc[1].x)/2)>switchlist[i].pa[1].x){
testswitch = switchmesh2.clone(true);
}else{
testswitch = switchmesh1.clone(true);
}
testswitch.rotation.y = Math.PI;
}
switchposx = (sarightpoint+sbleftpoint)/2;
}
sectionA.matrixAutoUpdate = false;
testswitch.position.x = switchposx;
testswitch.position.y = 0;
testswitch.position.z = switchposz;
scope.switchs.modellist.push(testswitch);
scope.switchgroup.add(testswitch);
}
resolve("loadersection");
});
}
//
// this.init = function(sectiondata,switchdata,scene){
//
// //遍历区段
// for(let i=0;i<sectiondata.length;i++){
// if(sectiondata[i].type == "01"){
// //初始化区段对象数据
// let newsection = new SectionModel(sectiondata);
//
// newsection.name = sectiondata[i].code;
// newsection.code = sectiondata[i].code;
// newsection.index = i;
// newsection.isStandTrack = sectiondata[i].isStandTrack;
// newsection.type = sectiondata[i].type;
//
// scope.sections.datalist.push(newsection);
// // scope.sections.modellist.push("");
// }
//
// }
//
// //定义区分道岔组
// let switchlist = [];
// //遍历道岔数据
// for(let i=0;i<switchdata.length;i++){
// //道岔信息
// let newswitch = {
// code:null,
// pa:null,
// pb:null,
// pc:null,
// paname:null,
// pbname:null,
// pcname:null
// };
// //获取道岔分辨的点 PS:可能修改动态判断
// for(let j=0;j<sectiondata.length;j++){
// if(switchdata[i].sectionACode == sectiondata[j].code){
// newswitch.pa = sectiondata[j].points;
// newswitch.paname = switchdata[i].sectionACode;
// }
// if(switchdata[i].sectionBCode == sectiondata[j].code){
// newswitch.pb = sectiondata[j].points;
// newswitch.pbname = switchdata[i].sectionBCode;
// }
// if(switchdata[i].sectionCCode == sectiondata[j].code){
// newswitch.pc = sectiondata[j].points;
// newswitch.pcname = switchdata[i].sectionCCode;
// }
// if(newswitch.pa != null && newswitch.pb!= null && newswitch.pc != null){
// newswitch.code = switchdata[i].code;
// switchlist.push(newswitch);
// j = sectiondata.length;
// }
// }
// }
//
// //道岔贴图
//
// //遍历道岔信息组合轨道
// for(let i=0;i<switchlist.length;i++){
// //道岔对象组
// let newswitch = new SwitchModel();
//
// newswitch.name = switchlist[i].code;
// newswitch.code = switchlist[i].code;
//
// newswitch.index = i;
//
// scope.switchs.datalist.push(newswitch);
// scope.switchs.modellist.push("");
// }
// }
this.init = function(sectiondata,switchdata,scene){
this.loadpromise = function(jlmap3ddata,assetloader,sectiondata,switchdata,scene){
return new Promise(function(resolve, reject){
console.log(sectiondata);
scene.add(scope.sectiongroup);
scene.add(scope.switchgroup);
let linkdata = jlmap3ddata.linklist;
for(let i=0;i<sectiondata.length;i++){
if(sectiondata[i].type == "01"){
//初始化区段对象数据
let newsection = new SectionModel(sectiondata);
newsection.name = sectiondata[i].code;
newsection.code = sectiondata[i].code;
newsection.index = i;
newsection.isStandTrack = sectiondata[i].isStandTrack;
newsection.relStandCode = sectiondata[i].relStandCode;
newsection.type = sectiondata[i].type;
newsection.offsetRight = sectiondata[i].offsetRight;
newsection.offsetLeft = sectiondata[i].offsetLeft;
newsection.linkCode = sectiondata[i].linkCode;
scope.sections.datalist.push(newsection);
// scope.sections.modellist.push("");
}
}
let autosuidao;
for(let i=0;i<assetloader.modellist.length;i++){
if(assetloader.modellist[i].deviceType == "autosuidao"){
autosuidao = assetloader.modellist[i].mesh.children[0];
}
}
for(let i = 0;i < sectiondata.length;i++){
let testmesh1 = autosuidao.clone(true);
testmesh1.code = sectiondata[i].code;
testmesh1.name = sectiondata[i].code;
if(sectiondata[i].relStandCode){
testmesh1.relStandCode = sectiondata[i].relStandCode;
}else{
testmesh1.relStandCode = "";
}
testmesh1.rightlist = sectiondata[i].rightlist;
testmesh1.leftlist = sectiondata[i].leftlist;
testmesh1.rightpoint = sectiondata[i].rightpoint;
testmesh1.leftpoint = sectiondata[i].leftpoint;
testmesh1.isStandTrack = sectiondata[i].isStandTrack;
testmesh1.lengthfact = sectiondata[i].lengthfact;
for(let i=0;i<testmesh1.rightlist.length;i++){
testmesh1.geometry.attributes.position.array[testmesh1.rightlist[i]*3] = testmesh1.lengthfact;
testmesh1.geometry.attributes.uv.array[testmesh1.rightlist[i]*2] = (testmesh1.geometry.attributes.position.array[3]-testmesh1.geometry.attributes.position.array[0])/15.3;
}
let newsuidao = new THREE.BufferGeometry();
newsuidao.copy(testmesh1.geometry);
testmesh1.geometry = newsuidao;
testmesh1.geometry.attributes.position.needsUpdate = true;
testmesh1.geometry.attributes.uv.needsUpdate = true;
testmesh1.geometry.computeBoundingSphere();
testmesh1.geometry.center();
testmesh1.position.x = sectiondata[i].position.x;
testmesh1.position.y = sectiondata[i].position.y;
testmesh1.position.z = sectiondata[i].position.z;
testmesh1.rotation.x = -Math.PI/2;
testmesh1.rotation.z = sectiondata[i].rotation._z;
//遍历区段
for(let i=0;i<sectiondata.length;i++){
if(sectiondata[i].type == "01"){
//初始化区段对象数据
let newsection = new SectionModel(sectiondata);
newsection.name = sectiondata[i].code;
newsection.code = sectiondata[i].code;
newsection.index = i;
newsection.isStandTrack = sectiondata[i].isStandTrack;
newsection.type = sectiondata[i].type;
newsection.relStandCode = sectiondata[i].relStandCode;
newsection.linkCode = sectiondata[i].linkCode;
scope.sections.datalist.push(newsection);
scope.sections.modellist.push("");
if(testmesh1.isStandTrack == false){
// scope.sectiongroup.add(testmesh1);
}else{
scope.standtrack.push(testmesh1);
var box = new THREE.BoxHelper( testmesh1, 0xff0000 );
// scope.sectiongroup.add( box );
}
scope.sections.modellist.push(testmesh1);
}
}
//定义区分道岔组
let switchlist = [];
//遍历道岔数据
for(let i=0;i<switchdata.length;i++){
//道岔信息
let newswitch = {
code:null,
pa:null,
pb:null,
pc:null,
paname:null,
pbname:null,
pcname:null
};
//获取道岔分辨的点 PS:可能修改动态判断
for(let j=0;j<sectiondata.length;j++){
if(switchdata[i].sectionACode == sectiondata[j].code){
newswitch.pa = sectiondata[j].points;
newswitch.paname = switchdata[i].sectionACode;
let switchmesh1;
let switchmesh2;
for(let i=0;i<assetloader.modellist.length;i++){
if(assetloader.modellist[i].deviceType == "autoswitch1"){
switchmesh1 = assetloader.modellist[i].mesh;
}
if(switchdata[i].sectionBCode == sectiondata[j].code){
newswitch.pb = sectiondata[j].points;
newswitch.pbname = switchdata[i].sectionBCode;
}
if(switchdata[i].sectionCCode == sectiondata[j].code){
newswitch.pc = sectiondata[j].points;
newswitch.pcname = switchdata[i].sectionCCode;
}
if(newswitch.pa != null && newswitch.pb!= null && newswitch.pc != null){
newswitch.code = switchdata[i].code;
switchlist.push(newswitch);
j = sectiondata.length;
if(assetloader.modellist[i].deviceType == "autoswitch2"){
switchmesh2 = assetloader.modellist[i].mesh;
}
}
}
// switchmesh1.rotation.x = Math.PI/2;
// switchmesh2.rotation.z = Math.PI/2;
for(let i=0;i<switchdata.length;i++){
let newswitch = {
code:switchdata[i].code,
pa:switchdata[i].pa,
pb:switchdata[i].pb,
pc:switchdata[i].pc,
paname:switchdata[i].paname,
pbname:switchdata[i].pbname,
pcname:switchdata[i].pcname,
alink:switchdata[i].alink,
blink:switchdata[i].blink,
clink:switchdata[i].clink
};
let sectionA,sectionB,sectionC;
for(let j=0;j<scope.sections.modellist.length;j++){
if(newswitch.paname == scope.sections.modellist[j].code){
sectionA = scope.sections.modellist[j];
}else if(newswitch.pbname == scope.sections.modellist[j].code){
sectionB = scope.sections.modellist[j];
}else if(newswitch.pcname == scope.sections.modellist[j].code){
sectionC = scope.sections.modellist[j];
}
}
let testswitch;
//道岔贴图
//遍历道岔信息组合轨道
for(let i=0;i<switchlist.length;i++){
//道岔对象组
let newswitch = new SwitchModel();
if(switchdata[i].pa[0].x>switchdata[i].pb[0].x){
if(((switchdata[i].pc[0].y+switchdata[i].pc[1].y)/2) < switchdata[i].pa[0].y){
if(((switchdata[i].pc[0].x+switchdata[i].pc[1].x)/2)>switchdata[i].pa[0].x){
testswitch = switchmesh1.clone(true);
}else{
testswitch = switchmesh2.clone(true);
}
}else{
if(((switchdata[i].pc[0].x+switchdata[i].pc[1].x)/2)>switchdata[i].pa[0].x){
testswitch = switchmesh2.clone(true);
}else{
testswitch = switchmesh1.clone(true);
}
testswitch.rotation.z = Math.PI;
}
}else{
if(((switchdata[i].pc[0].y+switchdata[i].pc[1].y)/2) < switchdata[i].pa[1].y){
if(((switchdata[i].pc[0].x+switchdata[i].pc[1].x)/2)>switchdata[i].pa[1].x){
testswitch = switchmesh1.clone(true);
}else{
testswitch = switchmesh2.clone(true);
}
}else{
if(((switchdata[i].pc[0].x+switchdata[i].pc[1].x)/2)>switchdata[i].pa[1].x){
testswitch = switchmesh2.clone(true);
}else{
testswitch = switchmesh1.clone(true);
}
testswitch.rotation.z = Math.PI;
}
}
newswitch.name = switchlist[i].code;
newswitch.code = switchlist[i].code;
testswitch.position.x = switchdata[i].position.x;
testswitch.position.y = switchdata[i].position.y;
testswitch.position.z = switchdata[i].position.z;
// testswitch.rotation.x = switchdata[i].rotation._x;
// testswitch.rotation.y = switchdata[i].rotation._y;
// testswitch.rotation.z = switchdata[i].rotation._z;
newswitch.index = i;
scope.switchs.datalist.push(newswitch);
scope.switchs.modellist.push(testswitch);
scope.switchgroup.add(testswitch);
}
scope.switchs.datalist.push(newswitch);
scope.switchs.modellist.push("");
}
resolve("loadersection");
});
}
function buildsuidao(linkdata,suidaodata,assetloader,scene){
let autosuidao;
for(let i=0;i<assetloader.modellist.length;i++){
if(assetloader.modellist[i].deviceType == "autosuidao"){
autosuidao = assetloader.modellist[i].mesh.children[0];
}
}
console.log(suidaodata);
let rightlist = [];
let leftlist = [];
let rightpoint = 0;
let leftpoint = 0;
let count = autosuidao.geometry.attributes.position.count;
for(let i=0;i<count;i++){
if(autosuidao.geometry.attributes.position.array[i*3] >7){
rightlist.push(i);
if(autosuidao.geometry.attributes.position.array[i*3] > rightpoint){
rightpoint = i;
}
}
if(autosuidao.geometry.attributes.position.array[i*3] <-7){
leftlist.push(i);
if(autosuidao.geometry.attributes.position.array[i*3] < rightpoint){
leftpoint = i;
}
}
}
autosuidao.rightlist = rightlist;
autosuidao.leftlist = leftlist;
autosuidao.rightpoint = rightpoint;
autosuidao.leftpoint = leftpoint;
// console.log(autosuidao);
// console.log(linkdata.linksgroup.children);
// console.log(suidaodata.datalist);
for(let i = 0;i < suidaodata.datalist.length;i++){
let link = linkdata.linksgroup.getObjectByProperty("code",suidaodata.datalist[i].linkCode);
let suidao = suidaodata.datalist[i];
let len = suidao.offsetRight-suidao.offsetLeft;
// console.log("-------------------------------------");
// console.log("name:"+link.name);
// console.log(link.lengthfact);
// console.log(len);
// console.log("ofl:"+suidao.offsetLeft+" "+"ofr:"+suidao.offsetRight);
// console.log("-------------------------------------");
let testmesh1 = autosuidao.clone(true);
for(let i=0;i<autosuidao.rightlist.length;i++){
testmesh1.geometry.attributes.position.array[autosuidao.rightlist[i]*3] = len-7.5;
testmesh1.geometry.attributes.uv.array[autosuidao.rightlist[i]*2] = (testmesh1.geometry.attributes.position.array[3]-testmesh1.geometry.attributes.position.array[0])/15.3;
}
let newsuidao = new THREE.BufferGeometry();
newsuidao.copy(testmesh1.geometry);
testmesh1.geometry = newsuidao;
testmesh1.geometry.attributes.position.needsUpdate = true;
testmesh1.geometry.attributes.uv.needsUpdate = true;
testmesh1.geometry.computeBoundingSphere();
testmesh1.geometry.center();
let lenfact = link.lengthfact;
testmesh1.rotation.x = -Math.PI/2;
testmesh1.rotation.z = link.rotation.z;
//
// console.log(link.lp.x);
// console.log(link.rp.x);
// console.log(suidao.offsetLeft*(len/lenfact));
// console.log((link.rp.x-link.lp.x)*(len/lenfact)/2);
// console.log("==============");
//
if(testmesh1.rotation.z != 0){
testmesh1.position.x = link.lp.x+suidao.offsetLeft*(len/lenfact)+ (link.rp.x-link.lp.x)*(len/lenfact)/2;
if(link.lp.y > link.rp.y){
testmesh1.position.z = link.lp.y-suidao.offsetLeft*(len/lenfact) + (link.rp.y-link.lp.y)*(len/lenfact)/2;
}else{
testmesh1.position.z = link.lp.y+suidao.offsetLeft*(len/lenfact) + (link.rp.y-link.lp.y)*(len/lenfact)/2;
}
}else{
testmesh1.position.x = link.lp.x+suidao.offsetLeft+len/2;
testmesh1.position.z = link.position.z;
}
testmesh1.position.y = 3.5;
// testmesh1.rotation.x = Math.PI/4;
testmesh1.code = suidaodata.datalist[i].code;
testmesh1.name = suidaodata.datalist[i].code;
// testmesh1.position.z = link.position.z;
testmesh1.relStandCode = suidaodata.datalist[i].relStandCode;
// testmesh1.stationCode = suidaodata.datalist[i].stationCode;
testmesh1.rightlist = autosuidao.rightlist;
testmesh1.leftlist = autosuidao.leftlist;
testmesh1.rightpoint = autosuidao.rightpoint;
testmesh1.leftpoint = autosuidao.leftpoint;
testmesh1.isStandTrack = suidaodata.datalist[i].isStandTrack;
testmesh1.lengthfact = len;
testmesh1.linkCode = suidao.linkCode;
if(suidaodata.datalist[i].isStandTrack == false){
scope.sectiongroup.add(testmesh1);
}else{
scope.standtrack.push(testmesh1);
var box = new THREE.BoxHelper( testmesh1, 0xff0000 );
scope.sectiongroup.add( box );
}
scope.sections.modellist.push(testmesh1);
}
}
this.resetsection = function(scene){
scene.remove(scope.sectiongroup);
};
this.reposition = function(){
}
this.update = function(){
}

View File

@ -10,7 +10,7 @@ export function SignalList() {
this.group = new THREE.Group();
this.initpromise = function(data,scene,assetloader,netdata){
this.initpromise = function(jlmap3ddata,data,scene,assetloader,netdata){
return new Promise(function(resolve, reject){
scope.group.name = "signal";
//遍历信号数据
@ -20,7 +20,7 @@ export function SignalList() {
netsignal = JSON.parse(netdata);
haddata = true;
}
let linkdata = jlmap3ddata.linklist;
for(let i=0;i<data.length;i++){
let newsignal = new SignalModel(data[i]);
@ -40,17 +40,29 @@ export function SignalList() {
for(let j=0;j<newmesh.children.length;j++){
newmesh.children[j].code = data[i].code;
}
let link = linkdata.linksgroup.getObjectByProperty("code",data[i].linkCode);
let posx = null;
if(data[i].offset > link.lengthfact/2){
posx = link.position.x + data[i].offset - link.lengthfact/2-10;
}else{
posx = link.position.x - (link.lengthfact/2 - data[i].offset)+10;
}
//根据线路方向修改信号灯位置
if(data[i].directionType == "01"){
newmesh.position.set(data[i].position.x,1,data[i].position.y-10);
newmesh.position.set(posx,0,link.position.z-3);
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.position.set(posx,0,link.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.offset = data[i].offset;
newmest.linkCode = data[i].linkCode;
newsignal.mesh = newmesh;
newsignal.offset = data[i].offset;
newsignal.mesh.status = "01";
scope.group.add(newsignal.mesh);
scope.list.push(newsignal);
@ -92,7 +104,65 @@ export function SignalList() {
});
}
this.loadpromise = function(signaldata,scene,assetloader,data){
return new Promise(function(resolve, reject){
for(let i=0;i<signaldata.length;i++){
let newsignal = new SignalModel(signaldata[i]);
let num;
for(let j=0;j<assetloader.modellist.length;j++){
if(assetloader.modellist[j].id == signaldata[i].modelid){
num = j;
}
}
let newmesh = assetloader.modellist[num].mesh.clone(true);
newmesh.uuid = signaldata[i].id;
newmesh.name = signaldata[i].name;
newmesh.modelid = assetloader.modellist[num].id;
newmesh.code = signaldata[i].code;
newmesh.offset = data[i].offset;
newmesh.linkCode = data[i].linkCode;
newmesh.directionType = data[i].directionType;
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);
}
scene.add(scope.group);
resolve("loadedsignal");
});
};
this.resetsignal = function(jlmap3ddata){
console.log(jlmap3ddata.linksgroup);
console.log(scope);
let linkdata = jlmap3ddata.linksgroup;
for(let i=0;i<scope.group.children.length;i++){
let signaldata = scope.group.children[i];
let link = linkdata.getObjectByProperty("code",signaldata.linkCode);
let posx = null;
if(signaldata.offset > link.lengthfact/2){
posx = link.position.x + signaldata.offset - link.lengthfact/2-10;
}else{
posx = link.position.x - (link.lengthfact/2 - signaldata.offset)+10;
}
//根据线路方向修改信号灯位置
if(signaldata.directionType == "01"){
signaldata.position.set(posx,0,link.position.z-3);
signaldata.rotation.z = ( Math.PI / 2 );
}else if(signaldata.directionType == "02"){
signaldata.position.set(posx,0,link.position.z+3);
signaldata.rotation.z = ( - Math.PI / 2 );
}
}
};
this.init = function(data,realsectionlist,scene,assetloader){
@ -127,6 +197,10 @@ export function SignalList() {
scene.add(scope.group);
}
this.reposition = function(){
}
this.update = function(){
}

View File

@ -12,16 +12,14 @@ export function StationStandList() {
this.textlist = [];
this.initpromise = function(stationdata,stationstanddata,scene,assetloader,netdata){
this.initpromise = function(jlmap3ddata,stationdata,stationstanddata,scene,assetloader,netdata){
return new Promise(function(resolve, reject){
let netstand = null;
let haddata = false;
if(netdata){
netstand = JSON.parse(netdata);
haddata = true;
}
scope.group.name = "station";
scene.add(scope.group);
//遍历车站数据
@ -69,7 +67,6 @@ export function StationStandList() {
}
}
scope.list[i].mesh = assetloader.modellist[num].mesh.clone(true);
scope.list[i].uuid = assetloader.modellist[num].uuid;
@ -80,45 +77,55 @@ export function StationStandList() {
for(let j=0;j<scope.list[i].mesh.children.length;j++){
scope.list[i].mesh.children[j].code = scope.list[i].code;
}
let standsection = [];
for(let n = 0;n<jlmap3ddata.sectionlist.standtrack.length;n++){
if(jlmap3ddata.sectionlist.standtrack[n].relStandCode == scope.list[i].direction1.name){
standsection.push(jlmap3ddata.sectionlist.standtrack[n]);
}
if(jlmap3ddata.sectionlist.standtrack[n].relStandCode == scope.list[i].direction2.name){
standsection.push(jlmap3ddata.sectionlist.standtrack[n]);
}
}
let posx = (standsection[0].position.x + standsection[1].position.x)/2;
let posz = (standsection[0].position.z + standsection[1].position.z)/2;;
scope.list[i].mesh.position.set(posx,0,posz);
scope.list[i].mesh.position.set(scope.list[i].direction1.position.x,-20000,( scope.list[i].direction2.position.y + scope.list[i].direction1.position.y)/2+scope.list[i].height/2 );
let textgeometry = new THREE.PlaneBufferGeometry( 128, 64, 1 );
let textmaterial = new THREE.MeshBasicMaterial( { side: THREE.DoubleSide,map: new THREE.CanvasTexture(getTextCanvas(stationdata[i])),transparent: true} );
let textplane = new THREE.Mesh( textgeometry, textmaterial );
textplane.name = stationdata[i].code;
textplane.position.y = 60;
textplane.rotation.x = 30;
//textplane.position.x = -30;
scope.list[i].mesh.add(textplane);
// let textgeometry = new THREE.PlaneBufferGeometry( 128, 64, 1 );
// let textmaterial = new THREE.MeshBasicMaterial( { side: THREE.DoubleSide,map: new THREE.CanvasTexture(getTextCanvas(stationdata[i])),transparent: true} );
// let textplane = new THREE.Mesh( textgeometry, textmaterial );
// textplane.name = stationdata[i].code;
// textplane.position.y = 60;
// textplane.rotation.x = 30;
// //textplane.position.x = -30;
// scope.list[i].mesh.add(textplane);
scope.group.add(scope.list[i].mesh);
}else{
for(let j=0;j<assetloader.modellist.length;j++){
if(assetloader.modellist[j].id == netstand[i].modelid){
if(assetloader.modellist[j].deviceType == "stand"){
num = j;
}
}
scope.list[i].mesh = assetloader.modellist[num].mesh.clone(true);
scope.list[i].mesh.name = netstand[i].name;
scope.list[i].mesh.code = netstand[i].code;
scope.list[i].id = netstand[i].id;
scope.list[i].modelid = netstand[i].modelid;
scope.list[i].mesh.name = netdata[i].name;
scope.list[i].mesh.code = netdata[i].code;
scope.list[i].id = netdata[i].id;
scope.list[i].modelid = netdata[i].modelid;
for(let j=0;j<scope.list[i].mesh.children.length;j++){
scope.list[i].mesh.children[j].code = netstand[i].code;
scope.list[i].mesh.children[j].code = netdata[i].code;
}
scope.list[i].mesh.position.x = netstand[i].position.x;
scope.list[i].mesh.position.y = netstand[i].position.y;
scope.list[i].mesh.position.z = netstand[i].position.z;
scope.list[i].mesh.position.x = netdata[i].position.x;
scope.list[i].mesh.position.y = netdata[i].position.y;
scope.list[i].mesh.position.z = netdata[i].position.z;
// scope.list[i].mesh.rotation.x = netstand[i].rotation._x;
// scope.list[i].mesh.rotation.y = netstand[i].rotation._y;
// scope.list[i].mesh.rotation.z = netstand[i].rotation._z;
scope.list[i].mesh.scale.x = netstand[i].scale.x;
scope.list[i].mesh.scale.y = netstand[i].scale.y;
scope.list[i].mesh.scale.z = netstand[i].scale.z;
scope.list[i].mesh.scale.x = netdata[i].scale.x;
scope.list[i].mesh.scale.y = netdata[i].scale.y;
scope.list[i].mesh.scale.z = netdata[i].scale.z;
let textgeometry = new THREE.PlaneBufferGeometry( 128, 64, 1 );
let textmaterial = new THREE.MeshBasicMaterial( { side: THREE.DoubleSide,map: new THREE.CanvasTexture(getTextCanvas(stationdata[i])),transparent: true} );

View File

@ -13,6 +13,7 @@ import { OBJExporter} from '@/jlmap3d/main/export/OBJExporter.js';
import {OrbitControlsedit} from '@/jlmap3d/main/control/OrbitControlsEdit.js';
import { TransformControls } from '@/jlmap3d/main/control/TransformControls.js';
import { DragControls } from '@/jlmap3d/main/control/DragControls.js';
import { ScalControls } from '@/jlmap3d/main/control/ScalControls.js';
//setconfig
@ -95,6 +96,18 @@ export function JLmap3dEdit(dom, data, mapid) {
Jlmap3ddata(mapid,scope);
let scalControls = new THREE.ScalControls(scope.scene,scope.camera, scope.renderer.domElement );
this.scalswitch = false;
scalControls.addEventListener( 'dragstart', function () {
scope.controls.enabled = false;
} );
scalControls.addEventListener( 'dragend', function () {
scope.controls.enabled = true;
} );
//循环渲染
animate();
@ -120,6 +133,7 @@ export function JLmap3dEdit(dom, data, mapid) {
animate();
};
this.animateoff = function(){
scope.animateswitch = false;
scope.Subscribe.socketoff(scope.Subscribe.topic);
@ -131,7 +145,7 @@ export function JLmap3dEdit(dom, data, mapid) {
document.getElementById("testdraw").addEventListener( "mousedown", onselect, false );
//窗口自适应
window.addEventListener( 'resize', onWindowResize, false );
controls.enabled = true;
scope.controls.enabled = true;
scope.controls.update();
};
@ -144,20 +158,38 @@ export function JLmap3dEdit(dom, data, mapid) {
};
this.export = function(){
var exporter = new THREE.OBJExporter();
console.log(scope.exportmodel);
var result = exporter.parse( scope.exportmodel );
let exporter = new THREE.OBJExporter();
console.log(scope.mapdata);
// let exportmodels = scope.mapdata.linklist.linksgroup;
// let exportmodels = scope.mapdata.sectionlist.switchgroup;
let exportmodels = scope.mapdata.stationstandlist.group;
let result = exporter.parse( exportmodels );
console.log(result);
}
this.actiommode = function(changedata){
console.log(changedata);
console.log(scope.editmode);
// console.log(scope.actionmode);
// console.log(changedata);
if(scope.editmode == "trackedit"){
scope.selectmodel = scope.action.sectionaction.changemodel(scope,changedata);
if(changedata == "trackreplace"){
scope.editmode = "trackedit";
scope.eventon();
}
if(changedata == "tracktexture"){
scope.editmode = "suidaoedit";
scope.eventon();
}
if(changedata == "switchreplace"){
scope.editmode = "switchedit";
scope.eventon();
}
// if(scope.editmode == "trackedit"){
// scope.selectmodel = scope.action.sectionaction.changemodel(scope,changedata);
// }
if(scope.actionmode == "signaledit"){
@ -191,6 +223,33 @@ export function JLmap3dEdit(dom, data, mapid) {
}
this.vexscal = function(){
this.scalswitch = true;
scalControls.attach(scope.selectmodel);
scope.transcontrol.detach()
};
this.vexscaloff = function(){
scalControls.detach()
};
this.testrail = function(){
console.log("testrail");
console.log(scope.mapdata.raillist);
scope.mapdata.raillist.resetrail(scope.mapdata,scope.scene);
};
this.autoss = function(){
console.log("autoss");
console.log(scope.mapdata);
scope.mapdata.signallist.resetsignal(scope.mapdata.linklist);
};
function onWindowResize() {
//窗口自适应
scope.camera.aspect = window.innerWidth / window.innerHeight;
@ -205,10 +264,18 @@ export function JLmap3dEdit(dom, data, mapid) {
if(scope.selectswitch == true){
scope.transcontrol.detach();
scalControls.detach();
//从站台对象组获取点击目标
if(scope.editmode == "trackedit"){
scope.selectmodel = scope.action.sectionaction.raycaster(scope);
scope.selectmodel = scope.action.sectionaction.raycaster(scope,"test");
}
if(scope.editmode == "suidaoedit"){
scope.selectmodel = scope.action.sectionaction.raycaster(scope,"suidao");
}
if(scope.editmode == "switchedit"){
scope.selectmodel = scope.action.sectionaction.raycaster(scope,"switch");
}
if(scope.editmode == "signaledit"){
@ -223,9 +290,9 @@ export function JLmap3dEdit(dom, data, mapid) {
scope.selectmodel = scope.action.trainaction.raycaster(scope);
}
if(scope.editmode == "switchedit"){
scope.selectmodel = scope.action.switchaction.raycaster(scope);
}
// if(scope.editmode == "switchedit"){
// scope.selectmodel = scope.action.switchaction.raycaster(scope);
// }
if(scope.editmode == "pathedit"){
scope.selectmodel = scope.action.pathaction.raycaster(scope);
@ -235,6 +302,7 @@ export function JLmap3dEdit(dom, data, mapid) {
if(scope.selectmodel != null){
//console.log(scope.selectmodel.rotation);
scope.transcontrol.attach( scope.selectmodel );
}
}

View File

@ -6,11 +6,6 @@ import {OBJLoader} from '@/jlmap3d/main/loaders/OBJLoader.js';
import {MTLLoader} from '@/jlmap3d/main/loaders/MTLLoader.js';
import { FBXLoader } from '@/jlmap3d/main/loaders/FBXLoader.js';
// controls
import {OrbitControls} from '@/jlmap3d/main/control/OrbitControls.js';
import { DragControls } from '@/jlmap3d/main/control/DragControls.js';
// component
// data
import { Jl3ddata } from '@/jlmap3d/main/model/jl3ddata';
@ -20,11 +15,14 @@ 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 { ModelLoad } from '@/jlmap3d/main/loaders/simulationloader';
// connect
import {Jl3dDriving} from '@/jlmap3d/jl3ddrive/moveupdate/DrivingConnect';
import { getPublishMapVersion, getPublishMapDetail, getPublish3dMapDetail} from '@/api/jlmap3d/load3ddata';
// utils
@ -38,9 +36,9 @@ import {MouseControls} from '@/jlmap3d/main/control/FirstControls';
var clock = new THREE.Clock();
export function JLmapDriving(dom, data, skinCode) {
export function JLmapDriving(dom, data, skinCode,storemod) {
const scope = this;
let scope = this;
//界面更新函数
let updatemmi = {};
@ -49,7 +47,7 @@ export function JLmapDriving(dom, data, skinCode) {
this.animateswitch = false;
this.cctvswitch = false;
// 初始化webgl渲染
const renderer = SetRender(dom);
let renderer = SetRender(dom);
renderer.domElement.style.position = 'absolute';
renderer.domElement.style.top = '0';
@ -63,9 +61,9 @@ export function JLmapDriving(dom, data, skinCode) {
// 定义相机
//let camera = SetCamera(dom);
// 定义场景(渲染容器)
const scene = SetScene();
let scene = SetScene();
const speed = 0;
let speed = 0;
let drivingcode = null;
@ -98,11 +96,11 @@ export function JLmapDriving(dom, data, skinCode) {
// 地图模型数据
let mapdata = new Jl3ddata();
let camera = new THREE.PerspectiveCamera(70, dom.clientWidth/dom.clientHeight, 1, 1100);
let camera = new THREE.PerspectiveCamera(70, dom.clientWidth/dom.clientHeight, 1, 1000);
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 );
@ -119,12 +117,13 @@ export function JLmapDriving(dom, data, skinCode) {
sound.play();
});
const controls3 = new MouseControls(camera, 1.6);
let controls3 = new MouseControls(camera, 1.6);
controls3.enabled = true;
// controls3.getObject().rotation.x = Math.PI/2;
scene.add(controls3.getObject());
let cameracctv = new THREE.PerspectiveCamera(70, dom.clientWidth/dom.clientHeight, 1, 120);
cameracctv.position.set( 5, -3,27 );
cameracctv.position.set( 2, -1,27 );
cameracctv.rotation.y = Math.PI/5*3;
camera.add(cameracctv);
@ -133,18 +132,46 @@ export function JLmapDriving(dom, data, skinCode) {
this.Subscribe.socketon(scope.Subscribe.topic);
var timer = setInterval(function() {
if(mapdata.trainlisttest.group){
if(mapdata.trainlisttest.group.children[0]){
if(mapdata.trainlisttest){
if(mapdata.trainlisttest.group){
if(mapdata.trainlisttest.group.children[0]){
updatemmi.updatedrivingcode(mapdata.trainlisttest.group.children[0].name);
scope.Subscribe.initdrivercode(mapdata.trainlisttest.group.children[0].name);
for(let k in mapdata.rails.switchrail){
const ddd = storemod.getters['map/getDeviceByCode'](k);
let switchdata = mapdata.rails.switchrail[k];
mapdata.rails.switchrail[k].locateType = ddd.locateType;
updatemmi.updatedrivingcode(mapdata.trainlisttest.group.children[0].name);
scope.Subscribe.initdrivercode(mapdata.trainlisttest.group.children[0].name);
clearInterval(timer);
if(ddd.locateType == "01"){
//1--向左 2--向右
//__\__ __/__
if(mapdata.rails.switchrail[k].directtype == "1"){
mapdata.rails.linkrail[switchdata.alink].lconnect = switchdata.blink;
mapdata.rails.linkrail[switchdata.blink].rconnect = switchdata.alink;
}else if(mapdata.rails.switchrail[k].directtype == "2"){
mapdata.rails.linkrail[switchdata.alink].rconnect = switchdata.blink;
mapdata.rails.linkrail[switchdata.blink].lconnect = switchdata.alink;
}
}else if(ddd.locateType == "02"){
if(mapdata.rails.switchrail[k].directtype == "1"){
mapdata.rails.linkrail[switchdata.alink].lconnect = switchdata.clink;
mapdata.rails.linkrail[switchdata.clink].rconnect = switchdata.alink;
}else if(mapdata.rails.switchrail[k].directtype == "2"){
mapdata.rails.linkrail[switchdata.alink].rconnect = switchdata.clink;
mapdata.rails.linkrail[switchdata.clink].lconnect = switchdata.alink;
}
}
}
clearInterval(timer);
}
}
}
}, 1000);
}, 2000);
// 初始化加载数据和模型
getPublish3dMapDetail(skinCode).then(netdata => {
ModelLoad(data, scope, netdata.data, mapdata, camera, controls3, scene,mixers);
ModelLoad(data, scope, netdata.data, mapdata, camera, controls3, scene,mixers,storemod);
});
// let stats = new Stats();
// dom.appendChild( stats.dom );
@ -170,7 +197,7 @@ export function JLmapDriving(dom, data, skinCode) {
renderercctv.render(scene,cameracctv);
}
//相机按键位移
//controls3.update();
// controls3.update();
delta = clock.getDelta();
for (let i=mixers.length-1; i>=0; i--) {
mixers[i].update( delta );
@ -186,6 +213,8 @@ export function JLmapDriving(dom, data, skinCode) {
controls3.getObject().position.y=10;
controls3.getObject().position.z = mapdata.trainlisttest.list[drivingcode].children[0].matrixWorld.elements[14];
console.log(controls3);
}
}
@ -227,12 +256,11 @@ export function JLmapDriving(dom, data, skinCode) {
updatemmi.updatedrivingcode = function(code) {
drivingcode = code;
mapdata.trainlisttest.list[drivingcode].children[0].add(controls3.getObject());
mapdata.trainlisttest.list[drivingcode].children[0].add(scope.assetloader.modellist[4].mesh);
controls3.getObject().position.x = 40;
controls3.getObject().position.y= 12.5;
controls3.getObject().position.x = 10;
controls3.getObject().position.y = 0;
controls3.getObject().position.z = 2.5;
controls3.getObject().rotation.x = Math.PI/2;
controls3.getObject().rotation.y = -Math.PI/2;
scope.assetloader.modellist[4].mesh.position.x = 34;
scope.assetloader.modellist[4].mesh.position.y = 0;
};
this.dispose = function() {
@ -253,6 +281,7 @@ export function JLmapDriving(dom, data, skinCode) {
scope.actions = null;
scope.Subscribe = null;
sound.stop();
scope.webwork.terminate();
// console.log(scope);
// scope = null;
};
@ -373,9 +402,9 @@ export function JLmapDriving(dom, data, skinCode) {
if (event.button == '0') {
// 定义光线
const raycaster = new THREE.Raycaster();
let raycaster = new THREE.Raycaster();
// 定义平面鼠标点击坐标
const mouse = new THREE.Vector2();
let mouse = new THREE.Vector2();
mouse.x = (event.clientX / window.innerWidth) * 2 - 1;
mouse.y = -(event.clientY / window.innerHeight) * 2 + 1;
@ -387,7 +416,7 @@ export function JLmapDriving(dom, data, skinCode) {
if (scope.raycasterswitch == 'stand') {
// 从站台对象组获取点击目标
const intersects1 = raycaster.intersectObjects( mapdata.stationstandlist.textlist);
let intersects1 = raycaster.intersectObjects( mapdata.stationstandlist.textlist);
// 获取最近处点击到的模型对象
if (intersects1[0]) {
// 遍历对象组获取对象坐标更新相机数据
@ -405,7 +434,7 @@ export function JLmapDriving(dom, data, skinCode) {
}
if (scope.raycasterswitch == 'train') {
const intersects = raycaster.intersectObjects( mapdata.trainlisttest.textlist);
let intersects = raycaster.intersectObjects( mapdata.trainlisttest.textlist);
if (intersects[0]) {
for (let j=0; j<mapdata.trainlisttest.list.length; j++) {
if (intersects[0].object.name == mapdata.trainlisttest.list[j].name) {
@ -419,7 +448,7 @@ export function JLmapDriving(dom, data, skinCode) {
if (scope.raycasterswitch == 'section') {
// console.log(mapdata.sectionlist.sections.modellist);
const intersects = raycaster.intersectObjects( mapdata.sectionlist.sections.modellist, true);
let intersects = raycaster.intersectObjects( mapdata.sectionlist.sections.modellist, true);
if (intersects[0]) {
scope.helpbox = new THREE.BoxHelper( intersects[0].object, 0xff0000 );
@ -429,7 +458,7 @@ export function JLmapDriving(dom, data, skinCode) {
if (scope.raycasterswitch == 'signal') {
const intersects = raycaster.intersectObjects( mapdata.signallist.group.children, true);
let intersects = raycaster.intersectObjects( mapdata.signallist.group.children, true);
if (intersects[0]) {
scope.helpbox = new THREE.BoxHelper( intersects[0].object, 0xff0000 );
@ -438,7 +467,7 @@ export function JLmapDriving(dom, data, skinCode) {
}
if (scope.raycasterswitch == 'switch') {
const intersects = raycaster.intersectObjects( mapdata.sectionlist.switchs.modellist, true);
let intersects = raycaster.intersectObjects( mapdata.sectionlist.switchs.modellist, true);
if (intersects[0]) {
scope.helpbox = new THREE.BoxHelper( intersects[0].object, 0xff0000 );

View File

@ -19,6 +19,9 @@ export function Jl3dDriving(updatemmi,sound) {
var sectionlist = null;
var materials = null;
var actions = null;
var rails = null;
var links = null;
var scenes = null;
var code = null;
@ -52,7 +55,8 @@ export function Jl3dDriving(updatemmi,sound) {
materials = materiallist;
scenes = scene;
actions = nowaction;
links = this.map.linklist;
rails = this.map.rails;
};
this.initdrivercode = function(code) {
@ -98,16 +102,16 @@ export function Jl3dDriving(updatemmi,sound) {
//
// }
switch (data.type) {
case 'Simulation_Driver_Change':
drivingcode = data.body.code;
// sound.volswitch = true;
updatemmi.updatedrivingcode( data.body.code);
break;
case 'Simulation_TrainSpeed':
trainspeed(data);
break;
case 'Simulation_Drive_Data_Routing':
updatemmi.updatedrivedata(data.body);
break;
case 'Simulation_Driver_Change':
drivingcode = data.body.code;
sound.volswitch = true;
updatemmi.updatedrivingcode( data.body.code);
break;
case 'SJL3D_TrainStatus':
trainstatus(data);
@ -153,13 +157,13 @@ export function Jl3dDriving(updatemmi,sound) {
if (trainlisttest.list[code].runMode == '02') {
if (trainlisttest.list[code].isStandTrack == true) {
trainlisttest.list[code].speeds = parseFloat(data.body[tl].v*10/36/19.5/trainlisttest.list[code].len);
trainlisttest.list[code].speeds = parseFloat(data.body[tl].v*10/36/24/trainlisttest.list[code].len);
} else {
trainlisttest.list[code].speeds = parseFloat(data.body[tl].v*10/36/20.3/trainlisttest.list[code].len);
trainlisttest.list[code].speeds = parseFloat(data.body[tl].v*10/36/24/trainlisttest.list[code].len);
}
} else {
trainlisttest.list[code].speeds = parseFloat(data.body[tl].v*10/36/20/trainlisttest.list[code].len);
trainlisttest.list[code].speeds = parseFloat(data.body[tl].v*10/36/24/trainlisttest.list[code].len);
}
if (code == drivingcode) {
@ -168,6 +172,8 @@ export function Jl3dDriving(updatemmi,sound) {
// } else {
updatemmi.updatenowspeed(Math.abs(data.body[tl].v));
// console.log(data.body[i]);
// }
}
}
@ -189,6 +195,25 @@ export function Jl3dDriving(updatemmi,sound) {
} else {
updatemmi.updateatospeed(-1);
}
if(trainlisttest.list[code].progress<1){
let syncdata = {
type: 'Train',
code: code,
linkCode: trainlisttest.list[code].nowcode,
percent: 0
};
if (trainlisttest.list[code].status == '02') {
syncdata.percent = trainlisttest.list[code].progress;
} else {
syncdata.percent = 1 - trainlisttest.list[code].progress;
}
// console.log(syncdata);
// console.log(trainlisttest.list[code].nextcurve);
// console.log("=============");
scope.teststomp.send('/app/topic/simulation/client/drive', syncdata);
}
}
}
}
@ -208,29 +233,6 @@ export function Jl3dDriving(updatemmi,sound) {
//更新车组号
updatemmi.updatetrainnum(data.body[i].groupNumber);
//更新列车
let syncdata = {
type: 'Train',
code: code,
sectionCode: data.body[i].sectionCode,
percent: 0
};
if (trainlisttest.list[code].isStandTrack == true && trainlisttest.list[code].progress>0.95 && trainlisttest.list[code].speed<=0) {
if (data.body[i].directionType == '02') {
syncdata.percent = 1-(sectionlist.sections.datalist[data.body[i].sectionCode].rstop/trainlisttest.list[code].len);
} else {
syncdata.percent = sectionlist.sections.datalist[data.body[i].sectionCode].lstop/trainlisttest.list[code].len;
}
//scope.teststomp.send('/app/topic/simulation/client/drive', syncdata);
} else {
if (data.body[i].directionType == '02') {
syncdata.percent = trainlisttest.list[code].progress;
} else {
syncdata.percent = 1 - trainlisttest.list[code].progress;
}
//scope.teststomp.send('/app/topic/simulation/client/drive', syncdata);
}
if (data.body[i].parkRemainTime>0) {
updatemmi.updatestoptime('停站时间:'+parseInt(data.body[i].parkRemainTime));
} else {
@ -304,91 +306,49 @@ export function Jl3dDriving(updatemmi,sound) {
if (trainlisttest.list[code].dispose != data.body[i].dispose && data.body[i].dispose == false) {
if (sectionlist.sections.datalist[data.body[i].sectionCode].code) {
if (rails.linkrail[data.body[i].linkCode]) {
trainlisttest.group.add(trainlisttest.list[code]);
trainlisttest.list[code].position.y = 0;
trainlisttest.list[code].progress = 0;
trainlisttest.list[code].oldoffset = data.body[i].sectionOffsetPercent;
trainlisttest.list[code].dispose = false;
trainlisttest.list[code].nowcode = data.body[i].sectionCode;
trainlisttest.list[code].nextcode = data.body[i].nextSectionCode;
trainlisttest.list[code].nowcode = data.body[i].linkCode;
let vexlist = [];
let endrotation = null;
if (data.body[i].directionType == '02') { // 向右
let offset = null;
let rotaposx = null;
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x>sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) {
offset = sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x-sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x;
rotaposx = sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x+offset*data.body[i].sectionOffsetPercent;
} else {
offset = sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x-sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x;
rotaposx = sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x+offset*data.body[i].sectionOffsetPercent;
}
let rotaposz = sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].z;
let point = rails.linkrail[data.body[i].linkCode].lineleft.getPointAt(data.body[i].linkOffsetPercent);
trainlisttest.list[code].rotation.y = 0;
trainlisttest.list[code].position.x = rotaposx;
trainlisttest.list[code].position.x = point.x;
trainlisttest.list[code].position.y = 0;
for (let tl=0; tl<6; tl++) {
trainlisttest.list[code].children[tl].position.z = rotaposz;
trainlisttest.list[code].children[tl].position.z = point.z;
}
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x>sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) {
for (let m=sectionlist.sections.datalist[data.body[i].sectionCode].rail.length-1; m>=0; m--) {
vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
}
} else {
for (let m=0; m<sectionlist.sections.datalist[data.body[i].sectionCode].rail.length; m++) {
vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
}
}
trainlisttest.list[code].status = '02';
trainlisttest.list[code].progress = data.body[i].sectionOffsetPercent;
trainlisttest.list[code].progress = data.body[i].linkOffsetPercent;
trainlisttest.list[code].curve = rails.linkrail[data.body[i].linkCode].lineleft;
} else if (data.body[i].directionType == '03') { // 向左
trainlisttest.list[code].dispose = false;
trainlisttest.group.add(trainlisttest.list[code]);
let offset = null;
let rotaposx = null;
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x>sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) {
offset = sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x-sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x;
rotaposx = sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x+offset*data.body[i].sectionOffsetPercent;
} else {
offset = sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x-sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x;
rotaposx = sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x+offset*data.body[i].sectionOffsetPercent;
}
let rotaposz = sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].z;
let point = rails.linkrail[data.body[i].linkCode].lineright.getPointAt((1-data.body[i].linkOffsetPercent));
trainlisttest.list[code].rotation.y = Math.PI;
trainlisttest.list[code].position.x = rotaposx;
trainlisttest.list[code].position.x = point.x;
trainlisttest.list[code].position.y = 0;
for (let tl=0; tl<6; tl++) {
trainlisttest.list[code].children[tl].position.z = -rotaposz;
}
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x<sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) {
for (let m=sectionlist.sections.datalist[data.body[i].sectionCode].rail.length-1; m>=0; m--) {
vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
}
} else {
for (let m=0; m<sectionlist.sections.datalist[data.body[i].sectionCode].rail.length; m++) {
vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
}
trainlisttest.list[code].children[tl].position.z = -point.z;
}
// if(trainlisttest.list[code].rname == "006"){
// console.log("0000000000000000");
// console.log(data.body[i].linkOffsetPercent);
// }
trainlisttest.list[code].status = '03';
trainlisttest.list[code].progress = 1-data.body[i].sectionOffsetPercent;
trainlisttest.list[code].progress = 1-data.body[i].linkOffsetPercent;
trainlisttest.list[code].curve = rails.linkrail[data.body[i].linkCode].lineright;
}
trainlisttest.list[code].len = rails.linkrail[data.body[i].linkCode].lengthfact;
// trainlisttest.list[code].isStandTrack = sectionlist.sections.datalist[data.body[i].sectionCode].isStandTrack;
trainlisttest.list[code].curve = new THREE.CatmullRomCurve3(vexlist);
trainlisttest.list[code].isStandTrack = sectionlist.sections.datalist[data.body[i].sectionCode].isStandTrack;
trainlisttest.list[code].len = sectionlist.sections.datalist[data.body[i].sectionCode].distance;
// trainlisttest.list[code].len = sectionlist.sections.datalist[data.body[i].sectionCode].distance;
if(data.body[i].speed == 0){
@ -397,9 +357,10 @@ export function Jl3dDriving(updatemmi,sound) {
// trainlisttest.list[code].startmark = 1;
}else{
trainlisttest.list[code].speeds = data.body[i].speed;
trainlisttest.list[code].speeds = parseFloat(data.body[i].speed*10/36/20/trainlisttest.list[code].len);
trainlisttest.list[code].speeds = parseFloat(data.body[i].speed*10/36/24/trainlisttest.list[code].len);
}
}
} else if (trainlisttest.list[code].dispose != data.body[i].dispose && data.body[i].dispose == true) {
@ -415,7 +376,7 @@ export function Jl3dDriving(updatemmi,sound) {
} else if (trainlisttest.list[code].dispose == data.body[i].dispose && data.body[i].dispose == false) {
if (sectionlist.sections.datalist[data.body[i].sectionCode].code) {
if (rails.linkrail[data.body[i].linkCode]) {
if (driverswitch == '02' && code == drivingcode) {
updatemmi.updatenowspeed(data.body[i].speed);
if (data.body[i].atpSpeed) {
@ -433,8 +394,19 @@ export function Jl3dDriving(updatemmi,sound) {
} else {
updatemmi.updatenowlen(0);
}
// if(trainlisttest.list[code].isStandTrack == true){
// pointstand = null;
// if(data.body[i].directionType == "02"){
// pointstand = trainlisttest.list[code].curve.getPointAt(data.body[i].sectionOffsetPercent);
// }else{
// pointstand = trainlisttest.list[code].curve.getPointAt(1-data.body[i].sectionOffsetPercent);
// }
// console.log(data.body[i].sectionOffsetPercent)
// console.log(pointstand.x);
//
// trainlisttest.list[code].position.x = pointstand.x;
// }
}
if (driverswitch == '05' && code == drivingcode) {
if (data.body[i].maLen) {
updatemmi.updatenowlen(data.body[i].maLen);
@ -442,142 +414,131 @@ export function Jl3dDriving(updatemmi,sound) {
updatemmi.updatenowlen(0);
}
}
if (data.body[i].directionType == '02') { // 向右
if (trainlisttest.list[code].nowcode != data.body[i].sectionCode) {
trainlisttest.list[code].nowcode = data.body[i].sectionCode;
trainlisttest.list[code].nextcode = data.body[i].nextSectionCode;
const vexlist = [];
const endrotation = null;
if (data.body[i].directionType == '02') { // 向右
if (trainlisttest.list[code].status != data.body[i].directionType) {
const rotaposx = trainlisttest.list[code].children[5].matrixWorld.elements[12];
const rotaposz = trainlisttest.list[code].children[0].matrixWorld.elements[14];
trainlisttest.list[code].rotation.y = 0;
trainlisttest.list[code].position.x = rotaposx;
for (let tl=0; tl<6; tl++) {
trainlisttest.list[code].children[tl].position.z = rotaposz;
}
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x>sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) {
vexlist.push(new THREE.Vector3(trainlisttest.list[code].position.x, 0, trainlisttest.list[code].children[0].matrixWorld.elements[14]));
for (let m=sectionlist.sections.datalist[data.body[i].sectionCode].rail.length-1; m>=0; m--) {
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[m].x>trainlisttest.list[code].position.x) {
vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
}
}
} else {
vexlist.push(new THREE.Vector3(trainlisttest.list[code].position.x, 0, trainlisttest.list[code].children[0].matrixWorld.elements[14]));
for (let m=0; m<sectionlist.sections.datalist[data.body[i].sectionCode].rail.length; m++) {
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[m].x>trainlisttest.list[code].position.x) {
vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
}
}
}
} else {
if(data.body[i].speed > 0){
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x>sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) {
for (let m=sectionlist.sections.datalist[data.body[i].sectionCode].rail.length-1; m>=0; m--) {
vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
}
} else {
for (let m=0; m<sectionlist.sections.datalist[data.body[i].sectionCode].rail.length; m++) {
vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
}
}
}else if(data.body[i].speed < 0){
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x<sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) {
for (let m=0; m<sectionlist.sections.datalist[data.body[i].sectionCode].rail.length; m++) {
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[m].x<trainlisttest.list[code].position.x) {
vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
}
}
vexlist.push(new THREE.Vector3(trainlisttest.list[code].position.x, 0, trainlisttest.list[code].children[0].matrixWorld.elements[14]));
} else {
for (let m=sectionlist.sections.datalist[data.body[i].sectionCode].rail.length-1; m>=0; m--) {
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[m].x<trainlisttest.list[code].position.x) {
vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
}
}
vexlist.push(new THREE.Vector3(trainlisttest.list[code].position.x, 0, trainlisttest.list[code].children[0].matrixWorld.elements[14]));
}
}
trainlisttest.list[code].rotation.y = 0;
}
trainlisttest.list[code].status = '02';
} else if (data.body[i].directionType == '03') { // 向左
if (trainlisttest.list[code].status != data.body[i].directionType) {
const rotaposx = trainlisttest.list[code].children[5].matrixWorld.elements[12];
const rotaposz = Math.abs(trainlisttest.list[code].children[0].matrixWorld.elements[14]);
trainlisttest.list[code].rotation.y = Math.PI;
trainlisttest.list[code].position.x = rotaposx;
for (let tl=0; tl<6; tl++) {
trainlisttest.list[code].children[tl].position.z = rotaposz;
}
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x<sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) {
vexlist.push(new THREE.Vector3(trainlisttest.list[code].position.x, 0, trainlisttest.list[code].children[0].matrixWorld.elements[14]));
for (let m=sectionlist.sections.datalist[data.body[i].sectionCode].rail.length-1; m>=0; m--) {
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[m].x<trainlisttest.list[code].position.x) {
vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
}
}
} else {
vexlist.push(new THREE.Vector3(trainlisttest.list[code].position.x, 0, trainlisttest.list[code].children[0].matrixWorld.elements[14]));
for (let m=0; m<sectionlist.sections.datalist[data.body[i].sectionCode].rail.length; m++) {
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[m].x<trainlisttest.list[code].position.x) {
vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
}
}
}
} else {
if(data.body[i].speed > 0){
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x<sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) {
for (let m=sectionlist.sections.datalist[data.body[i].sectionCode].rail.length-1; m>=0; m--) {
vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
}
} else {
for (let m=0; m<sectionlist.sections.datalist[data.body[i].sectionCode].rail.length; m++) {
vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
}
}
}else if(data.body[i].speed < 0){
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x<sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) {
for (let m=sectionlist.sections.datalist[data.body[i].sectionCode].rail.length-1; m>=0; m--) {
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[m].x>trainlisttest.list[code].position.x) {
vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
}
}
vexlist.push(new THREE.Vector3(trainlisttest.list[code].position.x, 0, trainlisttest.list[code].children[0].matrixWorld.elements[14]));
} else {
for (let m=0; m<sectionlist.sections.datalist[data.body[i].sectionCode].rail.length; m++) {
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[m].x>trainlisttest.list[code].position.x) {
vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
}
}
vexlist.push(new THREE.Vector3(trainlisttest.list[code].position.x, 0, trainlisttest.list[code].children[0].matrixWorld.elements[14]));
}
}
trainlisttest.list[code].rotation.y = Math.PI;
}
trainlisttest.list[code].status = '03';
}
trainlisttest.list[code].curve = new THREE.CatmullRomCurve3(vexlist);
trainlisttest.list[code].isStandTrack = sectionlist.sections.datalist[data.body[i].sectionCode].isStandTrack;
trainlisttest.list[code].len = sectionlist.sections.datalist[data.body[i].sectionCode].distance;
trainlisttest.list[code].speed = data.body[i].speed;
if(data.body[i].speed>0){
if (trainlisttest.list[code].status != data.body[i].directionType) {
trainlisttest.list[code].progress = 0;
}else if(data.body[i].speed<0){
trainlisttest.list[code].progress = 0.999;
const rotaposx = trainlisttest.list[code].children[5].matrixWorld.elements[12];
const rotaposz = trainlisttest.list[code].children[0].matrixWorld.elements[14];
trainlisttest.list[code].rotation.y = 0;
trainlisttest.list[code].position.x = rotaposx;
for (let tl=0; tl<6; tl++) {
trainlisttest.list[code].children[tl].position.z = rotaposz;
}
trainlisttest.list[code].progress = (rotaposx-rails.linkrail[data.body[i].linkCode].lp.x)/rails.linkrail[data.body[i].linkCode].lengthfact;
trainlisttest.list[code].status = '02';
trainlisttest.list[code].curve = rails.linkrail[data.body[i].linkCode].lineleft;
trainlisttest.list[code].nextcurve = null;
}
trainlisttest.list[code].speeds = parseFloat(data.body[i].speed*10/36/20/trainlisttest.list[code].len);
trainlisttest.list[code].len = rails.linkrail[data.body[i].linkCode].lengthfact;
} else if (data.body[i].directionType == '03') { // 向左
if (trainlisttest.list[code].status != data.body[i].directionType) {
trainlisttest.list[code].progress = 0;
const rotaposx = trainlisttest.list[code].children[5].matrixWorld.elements[12];
const rotaposz = Math.abs(trainlisttest.list[code].children[0].matrixWorld.elements[14]);
trainlisttest.list[code].rotation.y = Math.PI;
trainlisttest.list[code].position.x = rotaposx;
for (let tl=0; tl<6; tl++) {
trainlisttest.list[code].children[tl].position.z = -rotaposz;
}
trainlisttest.list[code].progress = 1-(rotaposx-rails.linkrail[data.body[i].linkCode].lp.x)/rails.linkrail[data.body[i].linkCode].lengthfact;
trainlisttest.list[code].status = '03';
trainlisttest.list[code].curve = rails.linkrail[data.body[i].linkCode].lineright;
trainlisttest.list[code].nextcurve = null;
}
trainlisttest.list[code].len = rails.linkrail[data.body[i].linkCode].lengthfact;
}
// console.log(data.body[i].directionType);
// console.log(data.body[i].linkCode);
// console.log(rails.linkrail[data.body[i].linkCode].lengthfact);
// console.log(rails.linkrail[data.body[i].linkCode].lconnect);
// console.log(rails.linkrail[data.body[i].linkCode].rconnect);
// console.log("--------------------");
// console.log(rails.linkrail[rails.linkrail[data.body[i].linkCode].lconnect].lconnect);
// console.log(rails.linkrail[rails.linkrail[data.body[i].linkCode].lconnect].rconnect);
// console.log("---------------------");
// console.log(trainlisttest.list[code].curve.points);
// console.log(rails.linkrail[nextcode].lineleft.points);
// console.log("***********************");
// console.log(rails.linkrail[nextcode].lineleft.points);
let nextcode;
if(code == drivingcode){
if(data.body[i].directionType == '02'){
trainlisttest.list[code].status = '02';
nextcode = rails.linkrail[data.body[i].linkCode].rconnect;
if(nextcode){
trainlisttest.list[code].nextcurve = rails.linkrail[nextcode].lineleft;
trainlisttest.list[code].nextlen = rails.linkrail[nextcode].lengthfact;
}
}else if(data.body[i].directionType == '03'){
trainlisttest.list[code].status = '03';
nextcode = rails.linkrail[data.body[i].linkCode].lconnect;
if(nextcode){
trainlisttest.list[code].nextcurve = rails.linkrail[nextcode].lineright;
trainlisttest.list[code].nextlen = rails.linkrail[nextcode].lengthfact;
}
}
trainlisttest.list[code].nextcode = nextcode;
// console.log(trainlisttest.list[code].nowcode);
// console.log(trainlisttest.list[code].nextcode);
// console.log(trainlisttest.list[code].curve.points);
// console.log(trainlisttest.list[code].nextcurve.points);
// console.log("=========================");
}else{
let nextcode;
if(data.body[i].directionType == '02'){
if(rails.linkrail[data.body[i].linkCode].lineleft){
nextcode = rails.linkrail[data.body[i].linkCode].rconnect;
trainlisttest.list[code].status = '02';
if(nextcode){
trainlisttest.list[code].nextcurve = rails.linkrail[nextcode].lineleft;
trainlisttest.list[code].nextlen = rails.linkrail[nextcode].lengthfact;
}
trainlisttest.list[code].curve = rails.linkrail[data.body[i].linkCode].lineleft;
trainlisttest.list[code].len = rails.linkrail[data.body[i].linkCode].lengthfact;
trainlisttest.list[code].progress = data.body[i].linkOffsetPercent;
trainlisttest.list[code].speeds = parseFloat(trainlisttest.list[code].speed*10/36/24/trainlisttest.list[code].len);
}
}else if(data.body[i].directionType == '03'){
if(rails.linkrail[data.body[i].linkCode].lineright){
nextcode = rails.linkrail[data.body[i].linkCode].lconnect;
trainlisttest.list[code].status = '03';
if(nextcode){
trainlisttest.list[code].nextcurve = rails.linkrail[nextcode].lineright;
trainlisttest.list[code].nextlen = rails.linkrail[nextcode].lengthfact;
}
trainlisttest.list[code].curve = rails.linkrail[data.body[i].linkCode].lineright;
trainlisttest.list[code].len = rails.linkrail[data.body[i].linkCode].lengthfact;
trainlisttest.list[code].progress = 1-data.body[i].linkOffsetPercent;
trainlisttest.list[code].speeds = parseFloat(trainlisttest.list[code].speed*10/36/24/trainlisttest.list[code].len);
}
}
trainlisttest.list[code].nextcode = nextcode;
}
// console.log(data.body[i].linkOffsetPercent);
// console.log(trainlisttest.list[code].progress);
// console.log(trainlisttest.list[code].curve.points);
// console.log(trainlisttest.list[code].nextcurve.points);
// console.log(trainlisttest.list[code].len);
// console.log(trainlisttest.list[code].nextlen);
// console.log("==========================================");
}
}
}
@ -734,9 +695,11 @@ export function Jl3dDriving(updatemmi,sound) {
function switchupdate(data) {
code = data.code;
for (let j=sectionlist.switchs.modellist.length-1; j>=0; j--) {
if (sectionlist.switchs.modellist[j].code == code) {
if (sectionlist.switchs.modellist[j].locateType != data.locateType) {
if (rails.switchrail[code]) {
if (rails.switchrail[code].locateType != data.locateType) {
// console.log("道岔变化:"+code);
if (data.locateType == '02') {
// console.log("02 反位");
if (actions[sectionlist.switchs.modellist[j].code]) {
sectionlist.switchs.modellist[j].locateType = data.locateType;
actions[sectionlist.switchs.modellist[j].code].reset();
@ -744,7 +707,26 @@ export function Jl3dDriving(updatemmi,sound) {
actions[sectionlist.switchs.modellist[j].code].timeScale = 1;
actions[sectionlist.switchs.modellist[j].code].play();
}
rails.switchrail[code].locateType = "02";
let testswitch = rails.switchrail[code];
if(rails.switchrail[code].directtype == "1"){
// console.log("道岔朝向1向左");
// console.log("aleft:"+testswitch.clink);
// console.log("cright:"+testswitch.alink);
rails.linkrail[testswitch.alink].lconnect = testswitch.clink;
rails.linkrail[testswitch.clink].rconnect = testswitch.alink;
}else if(rails.switchrail[code].directtype == "2"){
// console.log("道岔朝向2向右");
// console.log("aright:"+testswitch.clink);
// console.log("cleft:"+testswitch.alink);
rails.linkrail[testswitch.alink].rconnect = testswitch.clink;
rails.linkrail[testswitch.clink].lconnect = testswitch.alink;
}
} else if (data.locateType == '01') {
// console.log("01 定位");
if (actions[sectionlist.switchs.modellist[j].code]) {
sectionlist.switchs.modellist[j].locateType = data.locateType;
actions[sectionlist.switchs.modellist[j].code].reset();
@ -752,6 +734,23 @@ export function Jl3dDriving(updatemmi,sound) {
actions[sectionlist.switchs.modellist[j].code].timeScale = -1;
actions[sectionlist.switchs.modellist[j].code].play();
}
rails.switchrail[code].locateType = "01";
let testswitch = rails.switchrail[code];
if(rails.switchrail[code].directtype == "1"){
// console.log("道岔朝向1向左");
// console.log("aleft"+testswitch.blink);
// console.log("cright:"+testswitch.alink);
rails.linkrail[testswitch.alink].lconnect = testswitch.blink;
rails.linkrail[testswitch.blink].rconnect = testswitch.alink;
}else if(rails.switchrail[code].directtype == "2"){
// console.log("道岔朝向2向右");
// console.log("aright:"+testswitch.blink);
// console.log("cleft:"+testswitch.alink);
rails.linkrail[testswitch.alink].rconnect = testswitch.blink;
rails.linkrail[testswitch.blink].lconnect = testswitch.alink;
}
}
}
j = 0;

View File

@ -4,7 +4,7 @@ export function UpdateTrain(camera,traindata,control){
for(let j=traindata.group.children.length-1;j>=0;j--){
//判断是否有移动事件
//if(traindata.group.children[j].dispose == false){
if(traindata.group.children[j].dispose == false){
if(traindata.group.children[j].progress != null){
@ -12,22 +12,26 @@ export function UpdateTrain(camera,traindata,control){
if(trainmodel.speeds > 0 && trainmodel.speeds){
let speed = null;
if(traindata.group.children[j].progress<1){
if(traindata.group.children[j].progress >=0&&traindata.group.children[j].progress<=1){
let movecurve = trainmodel.curve;
if(trainmodel.status == "03"){
if(movecurve.points.length>1){
let point = movecurve.getPointAt(traindata.group.children[j].progress);
if(Math.abs( point.z -trainmodel.children[0].matrixWorld.elements[14]) >0.1){
if(Math.abs( point.z -trainmodel.children[0].matrixWorld.elements[14]) >0.001){
trainmodel.children[0].up = new THREE.Vector3(-1,0,0);
let tangent = movecurve.getTangentAt(traindata.group.children[j].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.y
rota:trainmodel.children[0].rotation.z
}
trainmodel.children[1].rotalist.push(rotas);
@ -48,7 +52,7 @@ export function UpdateTrain(camera,traindata,control){
trainmodel.children[rs].position.z += offsetz;
for(let xh=0;xh<trainmodel.children[rs].rotalist.length;xh++){
if((trainmodel.children[rs].matrixWorld.elements[12]-38)<=trainmodel.children[rs].rotalist[0].posr.x){
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];
@ -56,7 +60,7 @@ export function UpdateTrain(camera,traindata,control){
}
trainmodel.children[rs].rotation.y = trainmodel.children[rs].rotalist[0].rota;
trainmodel.children[rs].rotation.z = trainmodel.children[rs].rotalist[0].rota;
trainmodel.children[rs].rotalist.splice(0,1)
xh--;
}else{
@ -74,16 +78,19 @@ export function UpdateTrain(camera,traindata,control){
if(trainmodel.status == "02"){
if(movecurve.points.length>1){
let point = movecurve.getPointAt(trainmodel.progress);
if(Math.abs( point.z -trainmodel.children[0].matrixWorld.elements[14]) >0.1){
if(Math.abs( point.z -trainmodel.children[0].matrixWorld.elements[14]) >0.001){
trainmodel.children[0].up = new THREE.Vector3(1,0,0);
let tangent = movecurve.getTangentAt(traindata.group.children[j].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.y
rota:trainmodel.children[0].rotation.z
}
trainmodel.children[1].rotalist.push(rotas);
let offsetz = parseFloat(point.z) - parseFloat(trainmodel.children[0].matrixWorld.elements[14]);
@ -103,7 +110,7 @@ export function UpdateTrain(camera,traindata,control){
trainmodel.children[rs].position.z += offsetz;
for(let xh=0;xh<trainmodel.children[rs].rotalist.length;xh++){
if((trainmodel.children[rs].matrixWorld.elements[12]+38)>=trainmodel.children[rs].rotalist[0].posr.x){
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];
@ -112,7 +119,7 @@ export function UpdateTrain(camera,traindata,control){
}
//let offsetx = trainmodel.children[1].matrixWorld.elements[12]-trainmodel.children[0].children[3].matrixWorld.elements[12];
trainmodel.children[rs].rotation.y = trainmodel.children[rs].rotalist[0].rota;
trainmodel.children[rs].rotation.z = trainmodel.children[rs].rotalist[0].rota;
trainmodel.children[rs].rotalist.splice(0,1)
xh--;
}else{
@ -127,32 +134,62 @@ export function UpdateTrain(camera,traindata,control){
}
// 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/24/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[j].progress<1){
if(traindata.group.children[j].progress >=0&&traindata.group.children[j].progress<=1){
let movecurve = trainmodel.curve;
if(trainmodel.status == "03" && trainmodel.progress>0){
if(movecurve.points.length>1){
let point = movecurve.getPointAt(traindata.group.children[j].progress);
if(Math.abs( point.z -trainmodel.children[0].matrixWorld.elements[14]) >0.1){
if(Math.abs( point.z -trainmodel.children[0].matrixWorld.elements[14]) >0.01){
trainmodel.children[0].up = new THREE.Vector3(-1,0,0);
let tangent = movecurve.getTangentAt(traindata.group.children[j].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.y
rota:trainmodel.children[0].rotation.z
}
trainmodel.children[1].rotalist.push(rotas);
@ -173,7 +210,7 @@ export function UpdateTrain(camera,traindata,control){
trainmodel.children[rs].position.z += offsetz;
for(let xh=0;xh<trainmodel.children[rs].rotalist.length;xh++){
if((trainmodel.children[rs].matrixWorld.elements[12]-38)<=trainmodel.children[rs].rotalist[0].posr.x){
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];
@ -181,7 +218,7 @@ export function UpdateTrain(camera,traindata,control){
}
trainmodel.children[rs].rotation.y = trainmodel.children[rs].rotalist[0].rota;
trainmodel.children[rs].rotation.z = trainmodel.children[rs].rotalist[0].rota;
trainmodel.children[rs].rotalist.splice(0,1)
xh--;
}else{
@ -203,16 +240,18 @@ export function UpdateTrain(camera,traindata,control){
if(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.1){
if(Math.abs( point.z -trainmodel.children[0].matrixWorld.elements[14]) >0.01){
trainmodel.children[0].up = new THREE.Vector3(1,0,0);
let tangent = movecurve.getTangentAt(traindata.group.children[j].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.y
rota:trainmodel.children[0].rotation.z
}
trainmodel.children[1].rotalist.push(rotas);
let offsetz = parseFloat(point.z) - parseFloat(trainmodel.children[0].matrixWorld.elements[14]);
@ -232,7 +271,7 @@ export function UpdateTrain(camera,traindata,control){
trainmodel.children[rs].position.z += offsetz;
for(let xh=0;xh<trainmodel.children[rs].rotalist.length;xh++){
if((trainmodel.children[rs].matrixWorld.elements[12]+38)>=trainmodel.children[rs].rotalist[0].posr.x){
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];
@ -241,7 +280,7 @@ export function UpdateTrain(camera,traindata,control){
}
//let offsetx = trainmodel.children[1].matrixWorld.elements[12]-trainmodel.children[0].children[3].matrixWorld.elements[12];
trainmodel.children[rs].rotation.y = trainmodel.children[rs].rotalist[0].rota;
trainmodel.children[rs].rotation.z = trainmodel.children[rs].rotalist[0].rota;
trainmodel.children[rs].rotalist.splice(0,1)
xh--;
}else{
@ -257,7 +296,7 @@ export function UpdateTrain(camera,traindata,control){
// console.log(trainmodel.rotalist);
}
// console.log(trainmodel.nextcurve);
if(trainmodel.progress > -(trainmodel.speeds)){
trainmodel.progress += trainmodel.speeds;
}
@ -269,7 +308,7 @@ export function UpdateTrain(camera,traindata,control){
}
//}
}
}

View File

@ -19,6 +19,9 @@ export function Jlmap3dSubscribe(jlmap3d) {
var sectionlist = null;
var materials = null;
var actions = null;
var rails = null;
var links = null;
var scenes = null;
var code = null;
@ -52,6 +55,8 @@ export function Jlmap3dSubscribe(jlmap3d) {
materials = materiallist;
scenes = scene;
actions = nowaction;
links = this.map.linklist;
rails = this.map.rails;
};
@ -111,11 +116,11 @@ export function Jlmap3dSubscribe(jlmap3d) {
if (trainlisttest.list[code].isStandTrack == true) {
trainlisttest.list[code].speeds = parseFloat(data.body[tl].v*10/36/17/trainlisttest.list[code].len);
} else {
trainlisttest.list[code].speeds = parseFloat(data.body[tl].v*10/36/20/trainlisttest.list[code].len);
trainlisttest.list[code].speeds = parseFloat(data.body[tl].v*10/36/21/trainlisttest.list[code].len);
}
} else {
trainlisttest.list[code].speeds = parseFloat(data.body[tl].v*10/36/20/trainlisttest.list[code].len);
trainlisttest.list[code].speeds = parseFloat(data.body[tl].v*10/36/21/trainlisttest.list[code].len);
}
if (code == drivingcode) {
@ -150,30 +155,31 @@ export function Jlmap3dSubscribe(jlmap3d) {
if ( trainlisttest.list[code]) {
if (code == drivingcode) {
driverswitch = data.body[i].runMode;
//更新车组号
jlmap3d.updatetrainnum(data.body[i].groupNumber);
// console.log(trainlisttest.list[code].progress);
const syncdata = {
//更新列车
let syncdata = {
type: 'Train',
code: code,
sectionCode: data.body[i].sectionCode,
percent: 0
};
if (trainlisttest.list[code].isStandTrack == true && trainlisttest.list[code].progress>0.95 && trainlisttest.list[code].speed<=0) {
if (data.body[i].directionType == '02') {
syncdata.percent = 1-(sectionlist.sections.datalist[data.body[i].sectionCode].rstop/trainlisttest.list[code].len);
} else {
syncdata.percent = sectionlist.sections.datalist[data.body[i].sectionCode].lstop/trainlisttest.list[code].len;
}
scope.teststomp.send('/app/topic/simulation/client/drive', syncdata);
} else {
if (data.body[i].directionType == '02') {
syncdata.percent = trainlisttest.list[code].progress;
} else {
syncdata.percent = 1 - trainlisttest.list[code].progress;
}
scope.teststomp.send('/app/topic/simulation/client/drive', syncdata);
}
// if (trainlisttest.list[code].isStandTrack == true && trainlisttest.list[code].progress>0.95 && trainlisttest.list[code].speed<=0) {
// if (data.body[i].directionType == '02') {
// syncdata.percent = 1-(sectionlist.sections.datalist[data.body[i].sectionCode].rstop/trainlisttest.list[code].len);
// } else {
// syncdata.percent = sectionlist.sections.datalist[data.body[i].sectionCode].lstop/trainlisttest.list[code].len;
// }
// scope.teststomp.send('/app/topic/simulation/client/drive', syncdata);
// } else {
// if (data.body[i].directionType == '02') {
// syncdata.percent = trainlisttest.list[code].progress;
// } else {
// syncdata.percent = 1 - trainlisttest.list[code].progress;
// }
// scope.teststomp.send('/app/topic/simulation/client/drive', syncdata);
// }
if (data.body[i].parkRemainTime>0) {
jlmap3d.updatestoptime('停站时间:'+parseInt(data.body[i].parkRemainTime));
@ -181,21 +187,21 @@ export function Jlmap3dSubscribe(jlmap3d) {
if (data.body[i].runMode == '02') {
jlmap3d.updatestoptime('列车自动驾驶中');
} else {
if (trainlisttest.list[code].isStandTrack == true && trainlisttest.list[code].progress>0.95 && trainlisttest.list[code].speed<=0) {
// if(stoptimer){
//
// }else{
// stoptimer = setInterval(function(){
// if(num >=0){
// jlmap3d.updatestoptime("停站时间:"+num);
// num --;
// }
// },1000);
// }
} else {
jlmap3d.updatestoptime('列车人工驾驶中');
}
// if (trainlisttest.list[code].isStandTrack == true && trainlisttest.list[code].progress>0.95 && trainlisttest.list[code].speed<=0) {
// // if(stoptimer){
// //
// // }else{
// // stoptimer = setInterval(function(){
// // if(num >=0){
// // jlmap3d.updatestoptime("停站时间:"+num);
// // num --;
// // }
// // },1000);
// // }
//
// } else {
// jlmap3d.updatestoptime('列车人工驾驶中');
// }
}
}
@ -252,106 +258,53 @@ export function Jlmap3dSubscribe(jlmap3d) {
// }
// }
// 遍历获取所在轨道
if (trainlisttest.list[code].dispose != data.body[i].dispose && data.body[i].dispose == false) {
if (sectionlist.sections.datalist[data.body[i].sectionCode].code) {
if (rails.linkrail[data.body[i].linkCode]) {
trainlisttest.group.add(trainlisttest.list[code]);
trainlisttest.list[code].position.y = 0;
trainlisttest.list[code].progress = 0;
trainlisttest.list[code].oldoffset = data.body[i].sectionOffsetPercent;
trainlisttest.list[code].oldoffset = data.body[i].linkOffsetPercent;
trainlisttest.list[code].dispose = false;
trainlisttest.list[code].nowcode = data.body[i].sectionCode;
trainlisttest.list[code].nextcode = data.body[i].nextSectionCode;
trainlisttest.list[code].nowcode = data.body[i].linkCode;
trainlisttest.list[code].nextcode = rails.linkrail[data.body[i].linkCode].next;
let vexlist = [];
let endrotation = null;
if (data.body[i].directionType == '02') { // 向右
let offset = null;
let rotaposx = null;
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x>sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) {
offset = sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x-sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x;
rotaposx = sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x+offset*data.body[i].sectionOffsetPercent;
} else {
offset = sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x-sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x;
rotaposx = sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x+offset*data.body[i].sectionOffsetPercent;
}
let rotaposz = sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].z;
let point = rails.linkrail[data.body[i].linkCode].lineleft.getPointAt(data.body[i].linkOffsetPercent);
trainlisttest.list[code].rotation.y = 0;
trainlisttest.list[code].position.x = rotaposx;
trainlisttest.list[code].position.x = point.x;
trainlisttest.list[code].position.y = 0;
for (let tl=0; tl<6; tl++) {
trainlisttest.list[code].children[tl].position.z = rotaposz;
trainlisttest.list[code].children[tl].position.z = point.z;
}
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x>sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) {
vexlist.push(new THREE.Vector3(rotaposx, 0, rotaposz));
for (let m=sectionlist.sections.datalist[data.body[i].sectionCode].rail.length-1; m>=0; m--) {
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[m].x>rotaposx) {
vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
}
}
} else {
vexlist.push(new THREE.Vector3(rotaposx, 0, rotaposz));
for (let m=0; m<sectionlist.sections.datalist[data.body[i].sectionCode].rail.length; m++) {
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[m].x>rotaposx) {
vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
}
}
}
trainlisttest.list[code].status = '02';
trainlisttest.list[code].progress = data.body[i].linkOffsetPercent;
trainlisttest.list[code].curve = rails.linkrail[data.body[i].linkCode].lineleft;
} else if (data.body[i].directionType == '03') { // 向左
trainlisttest.list[code].dispose = false;
trainlisttest.group.add(trainlisttest.list[code]);
let offset = null;
let rotaposx = null;
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x>sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) {
offset = sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x-sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x;
rotaposx = sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x+offset*data.body[i].sectionOffsetPercent;
} else {
offset = sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x-sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x;
rotaposx = sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x+offset*data.body[i].sectionOffsetPercent;
}
let rotaposz = sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].z;
let point = rails.linkrail[data.body[i].linkCode].lineright.getPointAt((1-data.body[i].linkOffsetPercent));
trainlisttest.list[code].rotation.y = Math.PI;
trainlisttest.list[code].position.x = rotaposx;
trainlisttest.list[code].position.x = point.x;
trainlisttest.list[code].position.y = 0;
for (let tl=0; tl<6; tl++) {
trainlisttest.list[code].children[tl].position.z = -rotaposz;
}
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x<sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) {
vexlist.push(new THREE.Vector3(rotaposx, 0, rotaposz));
for (let m=sectionlist.sections.datalist[data.body[i].sectionCode].rail.length-1; m>=0; m--) {
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[m].x<rotaposx) {
vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
}
}
} else {
vexlist.push(new THREE.Vector3(rotaposx, 0, rotaposz));
for (let m=0; m<sectionlist.sections.datalist[data.body[i].sectionCode].rail.length; m++) {
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[m].x<rotaposx) {
vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
}
}
trainlisttest.list[code].children[tl].position.z = -point.z;
}
// if(trainlisttest.list[code].rname == "006"){
// console.log("0000000000000000");
// console.log(data.body[i].linkOffsetPercent);
// }
trainlisttest.list[code].status = '03';
trainlisttest.list[code].progress = 1-data.body[i].linkOffsetPercent;
trainlisttest.list[code].curve = rails.linkrail[data.body[i].linkCode].lineright;
}
trainlisttest.list[code].curve = new THREE.CatmullRomCurve3(vexlist);
trainlisttest.list[code].isStandTrack = sectionlist.sections.datalist[data.body[i].sectionCode].isStandTrack;
trainlisttest.list[code].progress = 0;
trainlisttest.list[code].len = sectionlist.sections.datalist[data.body[i].sectionCode].distance;
trainlisttest.list[code].len = rails.linkrail[data.body[i].linkCode].lengthfact;
// trainlisttest.list[code].isStandTrack = sectionlist.sections.datalist[data.body[i].sectionCode].isStandTrack;
// trainlisttest.list[code].len = sectionlist.sections.datalist[data.body[i].sectionCode].distance;
if(data.body[i].speed == 0){
@ -360,7 +313,7 @@ export function Jlmap3dSubscribe(jlmap3d) {
// trainlisttest.list[code].startmark = 1;
}else{
trainlisttest.list[code].speeds = data.body[i].speed;
trainlisttest.list[code].speeds = parseFloat(data.body[i].speed*10/36/20/trainlisttest.list[code].len);
trainlisttest.list[code].speeds = parseFloat(data.body[i].speed*10/36/21/trainlisttest.list[code].len);
}
}
@ -377,7 +330,7 @@ export function Jlmap3dSubscribe(jlmap3d) {
} else if (trainlisttest.list[code].dispose == data.body[i].dispose && data.body[i].dispose == false) {
if (sectionlist.sections.datalist[data.body[i].sectionCode].code) {
if (rails.linkrail[data.body[i].linkCode]) {
if (driverswitch == '02' && code == drivingcode) {
jlmap3d.updatenowspeed(data.body[i].speed);
if (data.body[i].atpSpeed) {
@ -415,13 +368,11 @@ export function Jlmap3dSubscribe(jlmap3d) {
jlmap3d.updatenowlen(0);
}
}
if (trainlisttest.list[code].nowcode != data.body[i].sectionCode || trainlisttest.list[code].nextcode != data.body[i].nextSectionCode) {
trainlisttest.list[code].nowcode = data.body[i].sectionCode;
trainlisttest.list[code].nextcode = data.body[i].nextSectionCode;
const vexlist = [];
const endrotation = null;
if(trainlisttest.list[code].nowcode != data.body[i].linkCode){
trainlisttest.list[code].nowcode = data.body[i].linkCode;
trainlisttest.list[code].nextcode = rails.linkrail[data.body[i].linkCode].next;
if (data.body[i].directionType == '02') { // 向右
trainlisttest.list[code].progress = 0;
if (trainlisttest.list[code].status != data.body[i].directionType) {
const rotaposx = trainlisttest.list[code].children[5].matrixWorld.elements[12];
const rotaposz = trainlisttest.list[code].children[0].matrixWorld.elements[14];
@ -430,81 +381,52 @@ export function Jlmap3dSubscribe(jlmap3d) {
for (let tl=0; tl<6; tl++) {
trainlisttest.list[code].children[tl].position.z = rotaposz;
}
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x>sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) {
vexlist.push(new THREE.Vector3(trainlisttest.list[code].position.x, 0, trainlisttest.list[code].children[0].matrixWorld.elements[14]));
for (let m=sectionlist.sections.datalist[data.body[i].sectionCode].rail.length-1; m>=0; m--) {
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[m].x>trainlisttest.list[code].position.x) {
vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
}
}
} else {
vexlist.push(new THREE.Vector3(trainlisttest.list[code].position.x, 0, trainlisttest.list[code].children[0].matrixWorld.elements[14]));
for (let m=0; m<sectionlist.sections.datalist[data.body[i].sectionCode].rail.length; m++) {
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[m].x>trainlisttest.list[code].position.x) {
vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
}
}
}
} else {
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x>sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) {
for (let m=sectionlist.sections.datalist[data.body[i].sectionCode].rail.length-1; m>=0; m--) {
vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
}
} else {
for (let m=0; m<sectionlist.sections.datalist[data.body[i].sectionCode].rail.length; m++) {
vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
}
}
trainlisttest.list[code].rotation.y = 0;
trainlisttest.list[code].progress = (rotaposx-rails.linkrail[data.body[i].linkCode].lp.x)/rails.linkrail[data.body[i].linkCode].lengthfact;
}
trainlisttest.list[code].status = '02';
trainlisttest.list[code].curve = rails.linkrail[data.body[i].linkCode].lineleft;
} else if (data.body[i].directionType == '03') { // 向左
trainlisttest.list[code].progress = 0;
if (trainlisttest.list[code].status != data.body[i].directionType) {
const rotaposx = trainlisttest.list[code].children[5].matrixWorld.elements[12];
const rotaposz = Math.abs(trainlisttest.list[code].children[0].matrixWorld.elements[14]);
trainlisttest.list[code].rotation.y = Math.PI;
trainlisttest.list[code].position.x = rotaposx;
for (let tl=0; tl<6; tl++) {
trainlisttest.list[code].children[tl].position.z = rotaposz;
trainlisttest.list[code].children[tl].position.z = -rotaposz;
}
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x<sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) {
vexlist.push(new THREE.Vector3(trainlisttest.list[code].position.x, 0, trainlisttest.list[code].children[0].matrixWorld.elements[14]));
for (let m=sectionlist.sections.datalist[data.body[i].sectionCode].rail.length-1; m>=0; m--) {
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[m].x<trainlisttest.list[code].position.x) {
vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
}
}
} else {
vexlist.push(new THREE.Vector3(trainlisttest.list[code].position.x, 0, trainlisttest.list[code].children[0].matrixWorld.elements[14]));
for (let m=0; m<sectionlist.sections.datalist[data.body[i].sectionCode].rail.length; m++) {
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[m].x<trainlisttest.list[code].position.x) {
vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
}
}
}
} else {
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x<sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) {
for (let m=sectionlist.sections.datalist[data.body[i].sectionCode].rail.length-1; m>=0; m--) {
vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
}
} else {
for (let m=0; m<sectionlist.sections.datalist[data.body[i].sectionCode].rail.length; m++) {
vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
}
}
trainlisttest.list[code].rotation.y = Math.PI;
trainlisttest.list[code].progress = 1-(rotaposx-rails.linkrail[data.body[i].linkCode].lp.x)/rails.linkrail[data.body[i].linkCode].lengthfact;
}
trainlisttest.list[code].status = '03';
}
trainlisttest.list[code].curve = new THREE.CatmullRomCurve3(vexlist);
trainlisttest.list[code].isStandTrack = sectionlist.sections.datalist[data.body[i].sectionCode].isStandTrack;
trainlisttest.list[code].len = sectionlist.sections.datalist[data.body[i].sectionCode].distance;
trainlisttest.list[code].progress = 0;
trainlisttest.list[code].speed = data.body[i].speed;
trainlisttest.list[code].speeds = parseFloat(data.body[i].speed*10/36/20/trainlisttest.list[code].len);
trainlisttest.list[code].status = '03';
trainlisttest.list[code].curve = rails.linkrail[data.body[i].linkCode].lineright;
}
// console.log(rails.linkrail[data.body[i].linkCode]);
// console.log(data.body[i].linkCode)
// console.log(nextcode);
trainlisttest.list[code].len = rails.linkrail[data.body[i].linkCode].lengthfact;
}
if(data.body[i].directionType == '02'){
let nextcode = rails.linkrail[data.body[i].linkCode].rconnect;
if(nextcode){
trainlisttest.list[code].nextcurve = rails.linkrail[nextcode].lineright;
}
}else if(data.body[i].directionType == '03'){
let nextcode = rails.linkrail[data.body[i].linkCode].lconnect;
if(nextcode){
trainlisttest.list[code].nextcurve = rails.linkrail[nextcode].lineleft;
}
}
}
}
}
@ -514,6 +436,7 @@ export function Jlmap3dSubscribe(jlmap3d) {
}
if (data.type == 'Simulation_DeviceStatus') {
for (let i=data.body.length-1; i>=0; i--) {
// 0xFFFFFF
// 0xCD0000 红
@ -663,8 +586,8 @@ export function Jlmap3dSubscribe(jlmap3d) {
function switchupdate(data) {
code = data.code;
for (let j=sectionlist.switchs.modellist.length-1; j>=0; j--) {
if (sectionlist.switchs.modellist[j].code == code) {
if (sectionlist.switchs.modellist[j].locateType != data.locateType) {
if (rails.switchrail[code]) {
if (rails.switchrail[code].locateType != data.locateType) {
if (data.locateType == '02') {
if (actions[sectionlist.switchs.modellist[j].code]) {
sectionlist.switchs.modellist[j].locateType = data.locateType;
@ -673,6 +596,21 @@ export function Jlmap3dSubscribe(jlmap3d) {
actions[sectionlist.switchs.modellist[j].code].timeScale = 1;
actions[sectionlist.switchs.modellist[j].code].play();
}
rails.switchrail[code].locateType = "02";
let testswitch = rails.switchrail[code];
// console.log(testswitch);
// console.log(rails.linkrail[testswitch.alink]);
// console.log(rails.linkrail[testswitch.clink]);
if(rails.switchrail[code].directtype == "1"){
rails.linkrail[testswitch.alink].lconnect = testswitch.clink;
rails.linkrail[testswitch.clink].rconnect = testswitch.alink;
}else if(rails.switchrail[code].directtype == "2"){
rails.linkrail[testswitch.alink].rconnect = testswitch.clink;
rails.linkrail[testswitch.clink].lconnect = testswitch.alink;
}
} else if (data.locateType == '01') {
if (actions[sectionlist.switchs.modellist[j].code]) {
sectionlist.switchs.modellist[j].locateType = data.locateType;
@ -681,6 +619,20 @@ export function Jlmap3dSubscribe(jlmap3d) {
actions[sectionlist.switchs.modellist[j].code].timeScale = -1;
actions[sectionlist.switchs.modellist[j].code].play();
}
rails.switchrail[code].locateType = "01";
let testswitch = rails.switchrail[code];
console.log(testswitch);
console.log(rails.linkrail[testswitch.alink]);
console.log(rails.linkrail[testswitch.clink]);
if(rails.switchrail[code].directtype == "1"){
rails.linkrail[testswitch.alink].lconnect = testswitch.blink;
rails.linkrail[testswitch.blink].rconnect = testswitch.alink;
}else if(rails.switchrail[code].directtype == "2"){
rails.linkrail[testswitch.alink].rconnect = testswitch.blink;
rails.linkrail[testswitch.blink].lconnect = testswitch.alink;
}
}
}
j = 0;

View File

@ -17,7 +17,6 @@ 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';
import { DragControls } from '@/jlmap3d/main/control/DragControls';
@ -29,15 +28,15 @@ import {Jlmap3dSubscribe } from '@/jlmap3d/jl3dsimulation/connect/TrainingConnec
import { getPublishMapVersion, getPublishMapDetail,getPublish3dMapDetail} from '@/api/jlmap3d/load3ddata';
//utils
import { UpdateTrain } from '@/jlmap3d/main/utils/UpdateTrain';
//import { UpdateTrain } from '@/jlmap3d/main/utils/UpdateTrainTest';
// import { UpdateTrain } from '@/jlmap3d/main/utils/UpdateTrain';
import { UpdateTrain } from '@/jlmap3d/main/utils/UpdateTrainTest';
// import { ReStart } from '@/jlmap3d/main/utils/ReStart';
import {Stats} from '@/jlmap3d/main/lib/stats.min.js';
var clock = new THREE.Clock();
export function JLmap3d(dom, data,skinCode) {
export function JLmap3d(dom, data,skinCode,storemod) {
let scope = this;
@ -55,7 +54,6 @@ export function JLmap3d(dom, data,skinCode) {
//定义场景(渲染容器)
let scene = SetScene();
//定义镜头操作
console.log(THREE.OrbitControls);
let controls = new THREE.OrbitControls(camera);
controls.maxPolarAngle = Math.PI/2;
//controls.minPolarAngle = Math.PI/8;
@ -83,14 +81,13 @@ export function JLmap3d(dom, data,skinCode) {
this.Subscribe = new Jlmap3dSubscribe(this.webwork);
//连接到通信
//console.log(this.Subscribe.config);
//this.webwork.postMessage(this.Subscribe.teststomp);
this.Subscribe.socketon(scope.Subscribe.topic);
//初始化加载数据和模型
getPublish3dMapDetail(skinCode).then(netdata => {
ModelLoad(data,scope,netdata.data,mapdata,camera,controls,scene);
ModelLoad(data,scope,netdata.data,mapdata,camera,controls,scene,storemod);
});
//
// let stats = new Stats();

View File

@ -0,0 +1,378 @@
/*
* @author zz85 / https://github.com/zz85
* @author mrdoob / http://mrdoob.com
* Running this will allow you to drag three.js objects around the screen.
*/
THREE.ScalControls = function ( scene,_camera, _domElement ) {
var _scene = scene;
var originposition;
var _objects = [];
var cubegroup = new THREE.Group();
var geometry = new THREE.BoxBufferGeometry( 5, 5, 5 );
var material = new THREE.MeshBasicMaterial( {color: 0x00ff00} );
var cube = new THREE.Mesh( geometry, material );
cube.position.x = 1;
cube.position.z = 0;
cube.name = "right";
cubegroup.add( cube );
_objects.push(cube);
var geometry = new THREE.BoxBufferGeometry( 5, 5, 5 );
var material = new THREE.MeshBasicMaterial( {color: 0x00ff00} );
var cube = new THREE.Mesh( geometry, material );
cube.position.x = -1;
cube.position.z = 0;
cube.name = "left";
cubegroup.add( cube );
_objects.push(cube);
if ( _objects instanceof THREE.Camera ) {
console.warn( 'THREE.ScalControls: Constructor now expects ( objects, camera, domElement )' );
var temp = _objects; _objects = _camera; _camera = temp;
}
var _movemesh;
var _plane = new THREE.Plane();
var _raycaster = new THREE.Raycaster();
var _mouse = new THREE.Vector2();
var _offset = new THREE.Vector3();
var _intersection = new THREE.Vector3();
var _worldPosition = new THREE.Vector3();
var _inverseMatrix = new THREE.Matrix4();
var _selected = null, _hovered = null;
//
var scope = this;
function activate() {
_domElement.addEventListener( 'mousemove', onDocumentMouseMove, false );
_domElement.addEventListener( 'mousedown', onDocumentMouseDown, false );
_domElement.addEventListener( 'mouseup', onDocumentMouseCancel, false );
_domElement.addEventListener( 'mouseleave', onDocumentMouseCancel, false );
_domElement.addEventListener( 'touchmove', onDocumentTouchMove, false );
_domElement.addEventListener( 'touchstart', onDocumentTouchStart, false );
_domElement.addEventListener( 'touchend', onDocumentTouchEnd, false );
}
function deactivate() {
_domElement.removeEventListener( 'mousemove', onDocumentMouseMove, false );
_domElement.removeEventListener( 'mousedown', onDocumentMouseDown, false );
_domElement.removeEventListener( 'mouseup', onDocumentMouseCancel, false );
_domElement.removeEventListener( 'mouseleave', onDocumentMouseCancel, false );
_domElement.removeEventListener( 'touchmove', onDocumentTouchMove, false );
_domElement.removeEventListener( 'touchstart', onDocumentTouchStart, false );
_domElement.removeEventListener( 'touchend', onDocumentTouchEnd, false );
}
function dispose() {
deactivate();
}
function onDocumentMouseMove( event ) {
event.preventDefault();
var rect = _domElement.getBoundingClientRect();
_mouse.x = ( ( event.clientX - rect.left ) / rect.width ) * 2 - 1;
_mouse.y = - ( ( event.clientY - rect.top ) / rect.height ) * 2 + 1;
_raycaster.setFromCamera( _mouse, _camera );
if ( _selected && scope.enabled ) {
if ( _raycaster.ray.intersectPlane( _plane, _intersection ) ) {
_selected.position.copy( _intersection.sub( _offset ).applyMatrix4( _inverseMatrix ) );
_selected.position.y = 0;
console.log(_movemesh);
if(_movemesh.meshtype == "link"){
if(_selected.name == "left"){
for(let i=0;i<_movemesh.leftlist.length;i++){
_movemesh.geometry.attributes.position.array[_movemesh.leftlist[i]*3] = _selected.position.x - originposition;
_movemesh.geometry.attributes.uv.array[_movemesh.leftlist[i]*2] = _movemesh.geometry.attributes.position.array[0]-_movemesh.geometry.attributes.position.array[3];
}
}
if(_selected.name == "right"){
for(let i=0;i<_movemesh.rightlist.length;i++){
_movemesh.geometry.attributes.position.array[_movemesh.rightlist[i]*3] = _selected.position.x - originposition;
_movemesh.geometry.attributes.uv.array[_movemesh.leftlist[i]*2] = _movemesh.geometry.attributes.position.array[0]-_movemesh.geometry.attributes.position.array[3];
}
}
}else{
if(_selected.name == "left"){
for(let i=0;i<_movemesh.leftlist.length;i++){
_movemesh.geometry.attributes.position.array[_movemesh.leftlist[i]*3] = _selected.position.x - originposition;
_movemesh.geometry.attributes.uv.array[_movemesh.leftlist[i]*2] = (_movemesh.geometry.attributes.position.array[3]-_movemesh.geometry.attributes.position.array[0])/15.3;
}
}
if(_selected.name == "right"){
for(let i=0;i<_movemesh.rightlist.length;i++){
_movemesh.geometry.attributes.position.array[_movemesh.rightlist[i]*3] = _selected.position.x - originposition;
_movemesh.geometry.attributes.uv.array[_movemesh.leftlist[i]*2] = (_movemesh.geometry.attributes.position.array[3]-_movemesh.geometry.attributes.position.array[0])/15.3;
}
}
}
// newgeometry.attributes.uv.array[7] = i;
_movemesh.geometry.attributes.position.needsUpdate = true;
_movemesh.geometry.attributes.uv.needsUpdate = true;
_movemesh.material.needsUpdate = true;
// _movemesh.geometry.computeBoundingBox();
_movemesh.geometry.computeBoundingSphere();
_movemesh.geometry.center();
_movemesh.lengthfact = (_movemesh.geometry.attributes.position.array[_movemesh.rightlist[0]] - _movemesh.geometry.attributes.position.array[_movemesh.leftlist[0]])*2+28;
// testmesh2.position.z = 50;
// testmesh2.geometry.center();
// console.log(testmesh2.geometry.attributes);
}
scope.dispatchEvent( { type: 'drag', object: _selected } );
return;
}
_raycaster.setFromCamera( _mouse, _camera );
var intersects = _raycaster.intersectObjects( _objects );
if ( intersects.length > 0 ) {
var object = intersects[ 0 ].object;
_plane.setFromNormalAndCoplanarPoint( _camera.getWorldDirection( _plane.normal ), _worldPosition.setFromMatrixPosition( object.matrixWorld ) );
if ( _hovered !== object ) {
scope.dispatchEvent( { type: 'hoveron', object: object } );
_domElement.style.cursor = 'pointer';
_hovered = object;
}
} else {
if ( _hovered !== null ) {
scope.dispatchEvent( { type: 'hoveroff', object: _hovered } );
_domElement.style.cursor = 'auto';
_hovered = null;
}
}
}
function onDocumentMouseDown( event ) {
event.preventDefault();
_raycaster.setFromCamera( _mouse, _camera );
var intersects = _raycaster.intersectObjects( _objects );
if ( intersects.length > 0 ) {
_selected = intersects[ 0 ].object;
if ( _raycaster.ray.intersectPlane( _plane, _intersection ) ) {
_inverseMatrix.getInverse( _selected.parent.matrixWorld );
_offset.copy( _intersection ).sub( _worldPosition.setFromMatrixPosition( _selected.matrixWorld ) );
}
_domElement.style.cursor = 'move';
scope.dispatchEvent( { type: 'dragstart', object: _selected } );
}
}
function onDocumentMouseCancel( event ) {
event.preventDefault();
if ( _selected ) {
scope.dispatchEvent( { type: 'dragend', object: _selected } );
_selected = null;
}
_domElement.style.cursor = _hovered ? 'pointer' : 'auto';
}
function onDocumentTouchMove( event ) {
event.preventDefault();
event = event.changedTouches[ 0 ];
var rect = _domElement.getBoundingClientRect();
_mouse.x = ( ( event.clientX - rect.left ) / rect.width ) * 2 - 1;
_mouse.y = - ( ( event.clientY - rect.top ) / rect.height ) * 2 + 1;
_raycaster.setFromCamera( _mouse, _camera );
if ( _selected && scope.enabled ) {
if ( _raycaster.ray.intersectPlane( _plane, _intersection ) ) {
_selected.position.copy( _intersection.sub( _offset ).applyMatrix4( _inverseMatrix ) );
}
scope.dispatchEvent( { type: 'drag', object: _selected } );
return;
}
}
function onDocumentTouchStart( event ) {
event.preventDefault();
event = event.changedTouches[ 0 ];
var rect = _domElement.getBoundingClientRect();
_mouse.x = ( ( event.clientX - rect.left ) / rect.width ) * 2 - 1;
_mouse.y = - ( ( event.clientY - rect.top ) / rect.height ) * 2 + 1;
_raycaster.setFromCamera( _mouse, _camera );
var intersects = _raycaster.intersectObjects( _objects );
if ( intersects.length > 0 ) {
_selected = intersects[ 0 ].object;
_plane.setFromNormalAndCoplanarPoint( _camera.getWorldDirection( _plane.normal ), _worldPosition.setFromMatrixPosition( _selected.matrixWorld ) );
if ( _raycaster.ray.intersectPlane( _plane, _intersection ) ) {
_inverseMatrix.getInverse( _selected.parent.matrixWorld );
_offset.copy( _intersection ).sub( _worldPosition.setFromMatrixPosition( _selected.matrixWorld ) );
}
_domElement.style.cursor = 'move';
scope.dispatchEvent( { type: 'dragstart', object: _selected } );
}
}
function onDocumentTouchEnd( event ) {
event.preventDefault();
if ( _selected ) {
scope.dispatchEvent( { type: 'dragend', object: _selected } );
_selected = null;
}
_domElement.style.cursor = 'auto';
}
activate();
// API
this.enabled = true;
this.activate = activate;
this.deactivate = deactivate;
this.dispose = dispose;
// Backward compatibility
this.attach = function(movemesh){
console.log(movemesh);
_movemesh = movemesh;
originposition = movemesh.position.x;
let offset = (_movemesh.geometry.attributes.position.array[movemesh.rightlist[0]*3] - _movemesh.geometry.attributes.position.array[movemesh.leftlist[0]*3])/2;
cubegroup.children[0].position.x = movemesh.position.x + offset;
cubegroup.children[0].position.y = movemesh.position.y;
cubegroup.children[0].position.z = movemesh.position.z;
cubegroup.children[1].position.x = movemesh.position.x - offset;
cubegroup.children[1].position.y = movemesh.position.y;
cubegroup.children[1].position.z = movemesh.position.z;
_scene.add(cubegroup);
}
this.detach = function(){
// _movemesh = "";
_scene.remove(cubegroup);
}
this.setObjects = function () {
console.error( 'THREE.ScalControls: setObjects() has been removed.' );
};
this.on = function ( type, listener ) {
console.warn( 'THREE.ScalControls: on() has been deprecated. Use addEventListener() instead.' );
scope.addEventListener( type, listener );
};
this.off = function ( type, listener ) {
console.warn( 'THREE.ScalControls: off() has been deprecated. Use removeEventListener() instead.' );
scope.removeEventListener( type, listener );
};
this.notify = function ( type ) {
console.error( 'THREE.ScalControls: notify() has been deprecated. Use dispatchEvent() instead.' );
scope.dispatchEvent( { type: type } );
};
};
THREE.ScalControls.prototype = Object.create( THREE.EventDispatcher.prototype );
THREE.ScalControls.prototype.constructor = THREE.ScalControls;

View File

@ -29,7 +29,9 @@ let defaultstation = {
type:"num4",
picUrl:"",
assetUrl:"https://joylink.club/oss/models/station/fuzhou/fuzhou.FBX"
}//https://joylink.club/oss/models/station/fuzhou/fuzhou.FBX
}
//https://test.joylink.club/oss/models/station/fuzhou/fuzhou.FBX
//https://joylink.club/oss/models/station/fuzhou/fuzhou.FBX
//../../static/model/station/zhantai715(2).FBX
let defaultswitch = {
@ -38,7 +40,7 @@ let defaultswitch = {
deviceType:"switch",
type:"fuzhou",
picUrl:"",
assetUrl:"../../static/model/daocha/daocha.FBX"
assetUrl:"https://test.joylink.club/oss/models/daocha/daocha.FBX"
}
let defaultdriver = {
@ -57,12 +59,46 @@ let defaultsuidao = {
type:"suidao",
picUrl:"",
assetUrl:"https://joylink.club/oss/models/suidao/suidao.FBX"
}//https://joylink.club/oss/models/suidao/suidao.FBX
}
//https://test.joylink.club/oss/models/suidao/suidao.FBX
//https://joylink.club/oss/models/suidao/suidao.FBX
//../../static/model/
let defaultautorail = {
id:"100",
name:"autorail",
deviceType:"autorail",
type:"autorail",
picUrl:"",
assetUrl:"https://joylink.club/oss/models/auto/rail.FBX"
}
let defaultautosuidao = {
id:"101",
name:"autosuidao",
deviceType:"autosuidao",
type:"autosuidao",
picUrl:"",
assetUrl:"https://joylink.club/oss/models/auto/suidao.FBX"
}
let autoswitch1 = {
id:"102",
name:"道岔1",
deviceType:"autoswitch1",
type:"fuzhou",
picUrl:"",
assetUrl:"https://joylink.club/oss/models/auto/switch1.FBX"
}
let autoswitch2 = {
id:"103",
name:"道岔2",
deviceType:"autoswitch2",
type:"fuzhou",
picUrl:"",
assetUrl:"https://joylink.club/oss/models/auto/switch2.FBX"
}
export function AssetLoader(){
@ -75,18 +111,15 @@ export function AssetLoader(){
this.materiallist = [];
//初始化资源加载器
this.setmodellist = function (data){
// console.log("setmodellist");
let defaultmodel1 = new AssetModel(defaultsignal);
scope.modellist.push(defaultmodel1);
let defaultmodel2 = new AssetModel(defaulttrain);
scope.modellist.push(defaultmodel2);
let defaultmodel3 = new AssetModel(defaultstation);
scope.modellist.push(defaultmodel3);
let defaultmodel4 = new AssetModel(defaultswitch);
scope.modellist.push(defaultmodel4);
let station = new AssetModel(defaultstation);
scope.modellist.push(station);
let driver = new AssetModel(defaultdriver);
scope.modellist.push(driver);
@ -94,6 +127,11 @@ export function AssetLoader(){
let suidao = new AssetModel(defaultsuidao);
scope.modellist.push(suidao);
let defaultswitch1 = new AssetModel(autoswitch1);
scope.modellist.push(defaultswitch1);
let defaultswitch2 = new AssetModel(autoswitch2);
scope.modellist.push(defaultswitch2);
let modeldata = JSON.parse(data);
@ -151,6 +189,18 @@ export function AssetLoader(){
let station = new AssetModel(defaultstation);
scope.modellist.push(station);
let autorail = new AssetModel(defaultautorail);
scope.modellist.push(autorail);
let autosuidao = new AssetModel(defaultautosuidao);
scope.modellist.push(autosuidao);
let defaultswitch1 = new AssetModel(autoswitch1);
scope.modellist.push(defaultswitch1);
let defaultswitch2 = new AssetModel(autoswitch2);
scope.modellist.push(defaultswitch2);
fbxpromise(signal)
.then(function(data){
////console.log(data);
@ -160,6 +210,22 @@ export function AssetLoader(){
////console.log(data);
return fbxpromise(station);
})
.then(function(data){
////console.log(data);
return fbxpromise(autorail);
})
.then(function(data){
////console.log(data);
return fbxpromise(autosuidao);
})
.then(function(data){
////console.log(data);
return fbxpromise(defaultswitch1);
})
.then(function(data){
////console.log(data);
return fbxpromise(defaultswitch2);
})
.then(function(data){
////console.log(scope.modellist);
resolve("loaderassets");
@ -381,10 +447,9 @@ export function AssetLoader(){
var loader = new THREE.FBXLoader();
loader.load( asset.assetUrl, function ( object ) {
let mixer = new THREE.AnimationMixer( object );
object.traverse(function (node) {//获取其中对象
node.frustumCulled = true;
});
//object.traverse(function (node) {//获取其中对象
// node.frustumCulled = true;
//});
if(asset.deviceType == "train"){
@ -393,7 +458,7 @@ export function AssetLoader(){
let name = "c"+j;
for(let i=0;i<object.children.length;i++){
if(object.children[i].name == name){
object.children[i].position.x = object.children[i].position.x+38.1;
object.children[i].position.x = object.children[i].position.x;
//object.children[i].position.y = j*10;
realtrain.add(object.children[i]);
i--;

View File

@ -4,13 +4,15 @@ import {SignalList} from '@/jlmap3d/main/model/SignalList.js';
import {StationStandList} from '@/jlmap3d/main/model/StationStandList.js';
import {TrainList} from '@/jlmap3d/main/model/TrainList.js';
import {RealSectionList} from '@/jlmap3d/main/model/RealSectionList.js';
import {LinkList} from '@/jlmap3d/main/model/LinkList.js';
import {RailList} from '@/jlmap3d/main/model/RailList.js';
import {Materialload} from '@/jlmap3d/main/loaders/Materialload.js';
import { Loading } from 'element-ui';
// import {SwitchModel} from '@/jlmap3d/model/SwitchModel.js';
export function ModelLoad(data,scope,netdata,mapdata,camera,controls,scene){
export function ModelLoad(data,scope,netdata,mapdata,camera,controls,scene,storemod){
//console.log(mapdata);
Materialload(scope);
//console.log(data);
@ -28,13 +30,13 @@ export function ModelLoad(data,scope,netdata,mapdata,camera,controls,scene){
let isSection = false;
if(netdata.assets){
let assetsdata = JSON.parse(netdata.assets);
for(let i=0;i<assetsdata.length;i++){
if(assetsdata[i].deviceType == "mapSection"){
isSection = true;
}
let assetsdata = JSON.parse(netdata.sections);
if(assetsdata.link){
isSection = true;
}
}
if(isSection == true){
init3d(data,netdata);
}else{
@ -48,7 +50,9 @@ export function ModelLoad(data,scope,netdata,mapdata,camera,controls,scene){
// console.log(data);
//初始化轨道和道岔 暂时
lengthfact(data);
jlmap3ddata.linklist = new LinkList();
jlmap3ddata.sectionlist = new SectionList();
//初始化信号机
jlmap3ddata.signallist = new SignalList();
//初始化站台
jlmap3ddata.stationstandlist = new StationStandList();
@ -56,10 +60,19 @@ export function ModelLoad(data,scope,netdata,mapdata,camera,controls,scene){
jlmap3ddata.trainlisttest = new TrainList();
jlmap3ddata.realsectionlist = new RealSectionList();
jlmap3ddata.rails = new RailList();
let loaderdata = JSON.parse(netdata.sections);
let switchdata = JSON.parse(netdata.switchs);
let signaldata = JSON.parse(netdata.signals);
let standsdata = JSON.parse(netdata.stands);
// console.log(netdata.assets);
assetloader.setmodellist(netdata.assets);
assetloader.assetpromise(sceneload)
.then(function(data){
//console.log(data);
return jlmap3ddata.linklist.loadpromise(loaderdata.link,scene,assetloader);
})
.then(function(data){
//console.log(data);
return jlmap3ddata.stationstandlist.initpromise(mapdata.stationList,mapdata.stationStandList,sceneload,assetloader,netdata.stands,mixers,actions);
@ -71,53 +84,31 @@ export function ModelLoad(data,scope,netdata,mapdata,camera,controls,scene){
})
.then(function(data){
//console.log(data);
return jlmap3ddata.sectionlist.initpromise(mapdata.sectionList,mapdata.switchList,sceneload);
})
.then(function(data){
//console.log(data);
return jlmap3ddata.realsectionlist.initpromise(jlmap3ddata,sceneload,assetloader,mixers,actions);
return jlmap3ddata.sectionlist.loadpromise(jlmap3ddata,assetloader,loaderdata.section,switchdata,sceneload);
})
// .then(function(data){
// //console.log(data);
// return jlmap3ddata.realsectionlist.initpromise(jlmap3ddata,sceneload,assetloader,mixers,actions);
// })
.then(function(data){
//console.log(data);
return jlmap3ddata.signallist.initpromise(mapdata.signalList,sceneload,assetloader,netdata.signals);
})
.then(function(data){
return new Promise(function(resolve, reject){
let loader = new THREE.OBJLoader( );
loader.load( '../../static/rail/fuzhoupath.obj', function ( obj ) {
let object = obj;
//console.log(object.children.length);
let rail = [];
for(let i=0;i<object.children.length;i++){
let name = object.children[i].name.split("_");
let newmeshname = name[0]+"_"+name[1]+"_"+name[2]+"."+name[3];
let vexlist = [];
//console.log( object.children[i].geometry.attributes.position.array);
for(let j=0;j<object.children[i].geometry.attributes.position.array.length;j){
//console.log(object.children[i].geometry.attributes.position.array[j]);
let ved = new THREE.Vector3( object.children[i].geometry.attributes.position.array[j], object.children[i].geometry.attributes.position.array[j+1], object.children[i].geometry.attributes.position.array[j+2] );
j=j+3;
vexlist.push(ved);
}
if(jlmap3ddata.sectionlist.sections.datalist[newmeshname].code){
jlmap3ddata.sectionlist.sections.datalist[newmeshname].rail = vexlist;
//console.log(jlmap3ddata.sectionlist.sections.datalist[n].rail.length);
}
}
resolve("loadedrealsection");
}, onProgress, onError );
jlmap3ddata.rails.init(loaderdata.link,switchdata,sceneload,storemod);
resolve("loadrail");
});
})
.then(function(data){
// for(let mn=0;mn<scope.assetloader.modellist.length;mn++){
// if(scope.assetloader.modellist[mn].name && scope.assetloader.modellist[mn].name == "suidao"){
// // scope.assetloader.modellist[mn].mesh.rotation.x = Math.PI/2;
// console.log(scope.assetloader.modellist[mn].mesh.position);
// scene.add(scope.assetloader.modellist[mn].mesh);
// }
// }
scope.animateswitch = true;

View File

@ -1,7 +1,7 @@
export function AssetModel(data){
let scope = this;
this.id = data.id;
this.name = data.name;

View File

@ -4,13 +4,15 @@ import {SignalList} from '@/jlmap3d/main/model/SignalList.js';
import {StationStandList} from '@/jlmap3d/main/model/StationStandList.js';
import {TrainList} from '@/jlmap3d/main/model/TrainList.js';
import {RealSectionList} from '@/jlmap3d/main/model/RealSectionList.js';
import {LinkList} from '@/jlmap3d/main/model/LinkList.js';
import {RailList} from '@/jlmap3d/main/model/RailList.js';
import {Materialload} from '@/jlmap3d/main/loaders/Materialload.js';
import { Loading } from 'element-ui';
// import {SwitchModel} from '@/jlmap3d/model/SwitchModel.js';
export function ModelLoad(data,scope,netdata,mapdata,camera,controls,scene,mixerss){
export function ModelLoad(data,scope,netdata,mapdata,camera,controls,scene,mixerss,storemod){
//console.log(mapdata);
Materialload(scope);
//console.log(data);
@ -27,12 +29,12 @@ export function ModelLoad(data,scope,netdata,mapdata,camera,controls,scene,mixer
let isSection = false;
if(netdata.assets){
let assetsdata = JSON.parse(netdata.assets);
for(let i=0;i<assetsdata.length;i++){
if(assetsdata[i].deviceType == "mapSection"){
isSection = true;
}
let assetsdata = JSON.parse(netdata.sections);
// console.log(netdata);
if(assetsdata.link){
isSection = true;
}
}
if(isSection == true){
@ -48,6 +50,7 @@ export function ModelLoad(data,scope,netdata,mapdata,camera,controls,scene,mixer
// console.log(data);
//初始化轨道和道岔 暂时
lengthfact(data);
jlmap3ddata.linklist = new LinkList();
jlmap3ddata.sectionlist = new SectionList();
jlmap3ddata.signallist = new SignalList();
//初始化站台
@ -56,10 +59,18 @@ export function ModelLoad(data,scope,netdata,mapdata,camera,controls,scene,mixer
jlmap3ddata.trainlisttest = new TrainList();
jlmap3ddata.realsectionlist = new RealSectionList();
jlmap3ddata.rails = new RailList();
let loaderdata = JSON.parse(netdata.sections);
let switchdata = JSON.parse(netdata.switchs);
let signaldata = JSON.parse(netdata.signals);
let standsdata = JSON.parse(netdata.stands);
assetloader.setmodellist(netdata.assets);
assetloader.assetpromise(sceneload)
.then(function(data){
//console.log(data);
return jlmap3ddata.linklist.loadpromise(loaderdata.link,scene,assetloader);
})
.then(function(data){
//console.log(data);
return jlmap3ddata.stationstandlist.initpromise(mapdata.stationList,mapdata.stationStandList,sceneload,assetloader,netdata.stands,mixers,actions);
@ -71,64 +82,34 @@ export function ModelLoad(data,scope,netdata,mapdata,camera,controls,scene,mixer
})
.then(function(data){
//console.log(data);
return jlmap3ddata.sectionlist.initpromise(mapdata.sectionList,mapdata.switchList,sceneload);
})
.then(function(data){
//console.log(data);
return jlmap3ddata.realsectionlist.initpromise(jlmap3ddata,sceneload,assetloader,mixers,actions);
return jlmap3ddata.sectionlist.loadpromise(jlmap3ddata,assetloader,loaderdata.section,switchdata,sceneload);
})
// .then(function(data){
// //console.log(data);
// return jlmap3ddata.realsectionlist.initpromise(jlmap3ddata,sceneload,assetloader,mixers,actions);
// })
.then(function(data){
//console.log(data);
return jlmap3ddata.signallist.initpromise(mapdata.signalList,sceneload,assetloader,netdata.signals);
})
.then(function(data){
return new Promise(function(resolve, reject){
let loader = new THREE.OBJLoader( );
loader.load( '../../static/rail/fuzhoupath.obj', function ( obj ) {
let object = obj;
//console.log(object.children.length);
let rail = [];
for(let i=0;i<object.children.length;i++){
let name = object.children[i].name.split("_");
let newmeshname = name[0]+"_"+name[1]+"_"+name[2]+"."+name[3];
let vexlist = [];
//console.log( object.children[i].geometry.attributes.position.array);
for(let j=0;j<object.children[i].geometry.attributes.position.array.length;j){
//console.log(object.children[i].geometry.attributes.position.array[j]);
let ved = new THREE.Vector3( object.children[i].geometry.attributes.position.array[j], object.children[i].geometry.attributes.position.array[j+1], object.children[i].geometry.attributes.position.array[j+2] );
j=j+3;
vexlist.push(ved);
}
if(jlmap3ddata.sectionlist.sections.datalist[newmeshname].code){
jlmap3ddata.sectionlist.sections.datalist[newmeshname].rail = vexlist;
//console.log(jlmap3ddata.sectionlist.sections.datalist[n].rail.length);
}
}
resolve("loadedrealsection");
}, onProgress, onError );
jlmap3ddata.rails.init(loaderdata.link,switchdata,sceneload,storemod);
resolve("loadrail");
});
})
.then(function(data){
.then(function(data){
for(let mn=0;mn<scope.assetloader.modellist.length;mn++){
if(scope.assetloader.modellist[mn].name && scope.assetloader.modellist[mn].name == "驾驶台"){
scope.assetloader.modellist[mn].mesh.position.y = -50000;
scene.add(scope.assetloader.modellist[mn].mesh);
}
if(scope.assetloader.modellist[mn].name && scope.assetloader.modellist[mn].name == "suidao"){
// scope.assetloader.modellist[mn].mesh.rotation.x = Math.PI/2;
scope.assetloader.modellist[mn].mesh.position.y -=0.1;
scene.add(scope.assetloader.modellist[mn].mesh);
}
}
scope.animateswitch = true;
mapdata = jlmap3ddata;

View File

@ -0,0 +1,309 @@
export function LinkList(data){
let scope = this;
this.type = "linklist";
this.linkdata = [];
this.linksgroup = new THREE.Group();
this.linksgroup.name = "link";
this.initpromise = function(linkdata,scene,assetloader){
return new Promise(function(resolve, reject){
linkhelp(linkdata,scene);
scene.add(scope.linksgroup);
linktest(linkdata,scene,assetloader);
resolve("loadedrealsection");
});
};
this.loadpromise = function(linkdata,scene,assetloader){
return new Promise(function(resolve, reject){
scene.add(scope.linksgroup);
loadlink(linkdata,scene,assetloader);
resolve("loadedrealsection");
});
};
function linkhelp(data,scene){
let groups = new THREE.Group();
for(let i=0;i<data.length;i++){
let lineGeometry = new THREE.Geometry();//生成几何体
lineGeometry.vertices.push(new THREE.Vector3(data[i].lp.x, 1, data[i].lp.y));//线段的两个顶点
lineGeometry.vertices.push(new THREE.Vector3(data[i].rp.x, 1, data[i].rp.y));
let line = new THREE.Line(lineGeometry, new THREE.LineDashedMaterial({
color: 0xffffff,//线段的颜色
dashSize: 1,//短划线的大小
gapSize: 3//短划线之间的距离
}));
line.name = data[i].code;
line.lengthFact = data[i].lengthFact;
line.lp = data[i].lp;
line.rp = data[i].rp;
line.distancex = data[i].rp.x-data[i].lp.x;
line.distancey = data[i].rp.y-data[i].lp.y;
line.computeLineDistances();//不可或缺的,若无,则线段不能显示为虚线
groups.add(line);
}
groups.position.z = 2000;
scene.add(groups);
}
function loadlink(data,scene,assetloader){
let autorail;
for(let i=0;i<assetloader.modellist.length;i++){
if(assetloader.modellist[i].deviceType == "autorail"){
autorail = assetloader.modellist[i].mesh.children[0];
}
}
let count = autorail.geometry.attributes.position.count;
let rightlist = [];
let leftlist = [];
for(let i=0;i<count;i++){
if(autorail.geometry.attributes.position.array[i*3] >0.49){
rightlist.push(i);
}
if(autorail.geometry.attributes.position.array[i*3] <-0.49){
leftlist.push(i);
}
}
for(let i=0;i<data.length;i++){
let testmesh2 = autorail.clone(true);
testmesh2.code = data[i].code;
testmesh2.name = data[i].name;
testmesh2.rightlist = rightlist;
testmesh2.leftlist = leftlist;
testmesh2.rp = data[i].rp;
testmesh2.lp = data[i].lp;
testmesh2.lengthfact = data[i].lengthfact;
for(let i=0;i<testmesh2.rightlist.length;i++){
testmesh2.geometry.attributes.position.array[testmesh2.rightlist[i]*3] = testmesh2.lengthfact-25;
testmesh2.geometry.attributes.uv.array[testmesh2.rightlist[i]*2] = testmesh2.geometry.attributes.position.array[0]-testmesh2.geometry.attributes.position.array[3];
}
let newrail = new THREE.BufferGeometry();
newrail.copy(testmesh2.geometry);
testmesh2.geometry = newrail;
testmesh2.geometry.attributes.position.needsUpdate = true;
testmesh2.geometry.attributes.uv.needsUpdate = true;
testmesh2.geometry.computeBoundingSphere();
testmesh2.geometry.center();
testmesh2.position.x = data[i].position.x;
testmesh2.position.y = data[i].position.y;
testmesh2.position.z = data[i].position.z;
// testmesh2.rotation.x = data[i].rotation._x;
// testmesh2.rotation.y = data[i].rotation._y;
testmesh2.rotation.z = data[i].rotation._z;
scope.linkdata.push(testmesh2);
scope.linksgroup.add(testmesh2);
}
}
// return linklist;
function linktest(data,scene,assetloader){
let autorail = null;
let autosuidao = null;
for(let i=0;i<assetloader.modellist.length;i++){
if(assetloader.modellist[i].deviceType == "autorail"){
autorail = assetloader.modellist[i].mesh.children[0];
}
}
let rightlist = [];
let leftlist = [];
let count = autorail.geometry.attributes.position.count;
for(let i=0;i<count;i++){
if(autorail.geometry.attributes.position.array[i*3] >0.49){
rightlist.push(i);
}
if(autorail.geometry.attributes.position.array[i*3] <-0.49){
leftlist.push(i);
}
}
autorail.rightlist = rightlist;
autorail.leftlist = leftlist;
let reallinks = [];
let testlink;
testlink = data;
if(data){
let index,startdata;
for(let n=0;n<data.length;n++){
if(data[n].leftFdCode == undefined && data[n].leftSdCode == undefined && data[n].rightFdCode ){
if(startdata){
if(data[n].lp.x<startdata.lp.x){
startdata = data[n];
index = n;
}
}else{
startdata = data[n];
index = n;
}
}
}
buildmodel(startdata);
reallinks.push(startdata);
data.splice(index,1);
for(let i=0;i<reallinks.length;i++){
for(let j=0;j<data.length;j++){
if(reallinks[i].leftFdCode && j>=0){
if(reallinks[i].leftFdCode == data[j].code){
buildmodel(data[j],reallinks[i],j,"left");
reallinks.push(data[j]);
data.splice(j,1);
j--;
}
}
if(reallinks[i].leftSdCode && j>=0){
if(reallinks[i].leftSdCode == data[j].code){
buildmodel(data[j],reallinks[i],j,"left");
reallinks.push(data[j]);
data.splice(j,1);
j--;
}
}
if(reallinks[i].rightFdCode && j>=0){
if(reallinks[i].rightFdCode == data[j].code){
buildmodel(data[j],reallinks[i],j,"right");
reallinks.push(data[j]);
data.splice(j,1);
j--;
}
}
if(reallinks[i].rightSdCode && j>=0){
if(reallinks[i].rightSdCode == data[j].code){
buildmodel(data[j],reallinks[i],j,"right");
reallinks.push(data[j]);
data.splice(j,1);
j--;
}
}
}
}
function buildmodel(data,mdata,sx,direct){
let len = data.lengthFact;
let testmesh2 = autorail.clone(true);
for(let i=0;i<autorail.rightlist.length;i++){
testmesh2.geometry.attributes.position.array[autorail.rightlist[i]*3] = len-25;
testmesh2.geometry.attributes.uv.array[autorail.rightlist[i]*2] = testmesh2.geometry.attributes.position.array[0]-testmesh2.geometry.attributes.position.array[3];
}
let newrail = new THREE.BufferGeometry();
newrail.copy(testmesh2.geometry);
testmesh2.geometry = newrail;
testmesh2.geometry.attributes.position.needsUpdate = true;
testmesh2.geometry.attributes.uv.needsUpdate = true;
testmesh2.geometry.computeBoundingSphere();
testmesh2.geometry.center();
// data.lp.y *= 10;
// data.rp.y *= 10;
if(mdata){
if(direct == "left"){
let dx = Math.abs(data.lp.x - data.rp.x);
    let dy = Math.abs(data.lp.y - data.rp.y);
    let distance = Math.sqrt(Math.pow(dx,2)+Math.pow(dy,2));
data.lp.x = (data.lp.x-data.rp.x)*data.lengthFact/distance+mdata.lp.x;
data.lp.y = (data.lp.y-data.rp.y)*data.lengthFact/distance+mdata.lp.y;
data.rp.x = mdata.lp.x;
data.rp.y = mdata.lp.y;
let axix = new THREE.Vector3(1,0,0);
let axixnow = new THREE.Vector3(data.rp.x-data.lp.x,0,data.rp.y-data.lp.y);
let rotenum = axixnow.angleTo(axix);
//不同坐标系方向值不同
if(data.lp.y>data.rp.y){
testmesh2.rotation.z = 0.218;
data.lp.x = data.rp.x - (data.lengthFact)*Math.cos(testmesh2.rotation.z);
data.lp.y = data.rp.y + (data.lengthFact)*Math.sin(testmesh2.rotation.z);
}else if(data.lp.y<data.rp.y){
testmesh2.rotation.z = -0.218;
data.lp.x = data.rp.x - (data.lengthFact)*Math.cos(testmesh2.rotation.z);
data.lp.y = data.rp.y + (data.lengthFact)*Math.sin(testmesh2.rotation.z);
}else{
testmesh2.rotation.z = rotenum;
}
testmesh2.position.x = (data.rp.x + data.lp.x)/2;
testmesh2.position.z = (data.rp.y + data.lp.y)/2;
}
if(direct == "right"){
let dx = Math.abs(data.lp.x - data.rp.x);
    let dy = Math.abs(data.lp.y - data.rp.y);
    let distance = Math.sqrt(Math.pow(dx,2)+Math.pow(dy,2));
data.rp.x = (data.rp.x-data.lp.x)*data.lengthFact/distance+mdata.rp.x;
data.rp.y = (data.rp.y-data.lp.y)*data.lengthFact/distance+mdata.rp.y;
data.lp.x = mdata.rp.x;
data.lp.y = mdata.rp.y;
let axix = new THREE.Vector3(1,0,0);
let axixnow = new THREE.Vector3(data.rp.x-data.lp.x,0,data.rp.y-data.lp.y);
let rotenum = axixnow.angleTo(axix);
//不同坐标系方向值不同
if(data.lp.y>data.rp.y){
testmesh2.rotation.z = 0.218;
data.rp.x = data.lp.x+(data.lengthFact)*Math.cos(testmesh2.rotation.z);
data.rp.y = data.lp.y-(data.lengthFact)*Math.sin(testmesh2.rotation.z);
}else if(data.lp.y<data.rp.y){
testmesh2.rotation.z = -0.218;
data.rp.x = data.lp.x+(data.lengthFact)*Math.cos(testmesh2.rotation.z);
data.rp.y = data.lp.y-(data.lengthFact)*Math.sin(testmesh2.rotation.z);
}
testmesh2.position.x = (data.lp.x + data.rp.x)/2;
testmesh2.position.z = (data.lp.y + data.rp.y)/2;
}
}else{
data.lp.x = data.lp.x;
data.rp.x = data.lp.x + data.lengthFact;
testmesh2.position.x = (data.lp.x + data.rp.x)/2;
testmesh2.position.z = (data.lp.y + data.rp.y)/2;
}
// testmesh2.position.y = 10;
testmesh2.code = data.code;
testmesh2.name = data.name;
testmesh2.meshtype = "link";
testmesh2.lp = data.lp;
testmesh2.rp = data.rp;
testmesh2.rightlist = autorail.rightlist;
testmesh2.leftlist = autorail.leftlist;
testmesh2.lengthfact = data.lengthFact;
scope.linksgroup.add( testmesh2 );
scope.linkdata.push(testmesh2);
}
}
}
}

View File

@ -0,0 +1,149 @@
export function RailList(){
let scope = this;
this.linkrail = [];
this.switchrail = [];
this.setrail = function(){
};
this.init = function(linkdata,switchdata,scene,storemod){
for(let i=0;i<linkdata.length;i++){
scope.linkrail[linkdata[i].code] = {
lp:linkdata[i].rail[0],
rp:linkdata[i].rail[1],
lconnect:null,
rconnect:null,
lengthfact:linkdata[i].lengthfact,
lineleft:null,
lineright:null,
points:[],
type:null
};
if(linkdata[i].rotation._z == 0){
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(scope.linkrail[linkdata[i].code].lp.x+2,0,scope.linkrail[linkdata[i].code].lp.z));
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(scope.linkrail[linkdata[i].code].rp.x-2,0,scope.linkrail[linkdata[i].code].rp.z));
scope.linkrail[linkdata[i].code].type = 0;
}else{
if(linkdata[i].rotation._z>0){
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(scope.linkrail[linkdata[i].code].lp.x+2.1,0,scope.linkrail[linkdata[i].code].lp.z-0.6));
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(scope.linkrail[linkdata[i].code].rp.x-2.1,0,scope.linkrail[linkdata[i].code].rp.z+0.6));
scope.linkrail[linkdata[i].code].type = 1;
}else{
scope.linkrail[linkdata[i].code].type = 2;
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(scope.linkrail[linkdata[i].code].lp.x+2.1,0,scope.linkrail[linkdata[i].code].lp.z+0.6));
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(scope.linkrail[linkdata[i].code].rp.x-2.1,0,scope.linkrail[linkdata[i].code].rp.z-0.6));
}
}
}
for(let i=0;i<switchdata.length;i++){
scope.switchrail[switchdata[i].code] = {
alink:switchdata[i].alink,
blink:switchdata[i].blink,
clink:switchdata[i].clink,
position:switchdata[i].position,
directtype:null,
locateType:0
};
if(scope.linkrail[switchdata[i].blink].lp.x < switchdata[i].position.x){
scope.linkrail[switchdata[i].blink].points.push(new THREE.Vector3(switchdata[i].position.x,switchdata[i].position.y,switchdata[i].position.z));
if(scope.linkrail[switchdata[i].alink].type == 1){
scope.linkrail[switchdata[i].blink].points.push(new THREE.Vector3(scope.linkrail[switchdata[i].alink].lp.x+2.1,0,scope.linkrail[switchdata[i].alink].lp.z-0.6));
}else if(scope.linkrail[switchdata[i].alink].type == 2){
scope.linkrail[switchdata[i].blink].points.push(new THREE.Vector3(scope.linkrail[switchdata[i].alink].lp.x+2.1,0,scope.linkrail[switchdata[i].alink].lp.z+0.6));
}else{
scope.linkrail[switchdata[i].blink].points.push(new THREE.Vector3(scope.linkrail[switchdata[i].alink].lp.x+2,0,scope.linkrail[switchdata[i].alink].lp.z));
}
scope.switchrail[switchdata[i].code].directtype = "1";
}else{
scope.linkrail[switchdata[i].blink].points.splice(0,0,new THREE.Vector3(switchdata[i].position.x,switchdata[i].position.y,switchdata[i].position.z));
if(scope.linkrail[switchdata[i].alink].type == 1){
scope.linkrail[switchdata[i].blink].points.splice(0,0,new THREE.Vector3(scope.linkrail[switchdata[i].alink].rp.x-2.1,0,scope.linkrail[switchdata[i].alink].rp.z+0.6));
}else if(scope.linkrail[switchdata[i].alink].type == 2){
scope.linkrail[switchdata[i].blink].points.splice(0,0,new THREE.Vector3(scope.linkrail[switchdata[i].alink].rp.x-2.1,0,scope.linkrail[switchdata[i].alink].rp.z-0.6));
}else{
scope.linkrail[switchdata[i].blink].points.splice(0,0,new THREE.Vector3(scope.linkrail[switchdata[i].alink].rp.x-2,0,scope.linkrail[switchdata[i].alink].rp.z));
}
scope.switchrail[switchdata[i].code].directtype = "2";
}
//
if(scope.linkrail[switchdata[i].clink].lp.x < switchdata[i].position.x){
scope.linkrail[switchdata[i].clink].points.push(new THREE.Vector3(switchdata[i].position.x,switchdata[i].position.y,switchdata[i].position.z));
if(scope.linkrail[switchdata[i].alink].type == 1){
scope.linkrail[switchdata[i].clink].points.push(new THREE.Vector3(scope.linkrail[switchdata[i].alink].lp.x+2.1,0,scope.linkrail[switchdata[i].alink].lp.z-0.6));
}else if(scope.linkrail[switchdata[i].alink].type == 2){
scope.linkrail[switchdata[i].clink].points.push(new THREE.Vector3(scope.linkrail[switchdata[i].alink].lp.x+2.1,0,scope.linkrail[switchdata[i].alink].lp.z+0.6));
}else{
scope.linkrail[switchdata[i].clink].points.push(new THREE.Vector3(scope.linkrail[switchdata[i].alink].lp.x+2,0,scope.linkrail[switchdata[i].alink].lp.z));
}
scope.switchrail[switchdata[i].code].directtype = "1";
}else{
scope.linkrail[switchdata[i].clink].points.splice(0,0,new THREE.Vector3(switchdata[i].position.x,switchdata[i].position.y,switchdata[i].position.z));
if(scope.linkrail[switchdata[i].alink].type == 1){
scope.linkrail[switchdata[i].clink].points.splice(0,0,new THREE.Vector3(scope.linkrail[switchdata[i].alink].rp.x-2.1,0,scope.linkrail[switchdata[i].alink].rp.z+0.6));
}else if(scope.linkrail[switchdata[i].alink].type == 2){
scope.linkrail[switchdata[i].clink].points.splice(0,0,new THREE.Vector3(scope.linkrail[switchdata[i].alink].rp.x-2.1,0,scope.linkrail[switchdata[i].alink].rp.z-0.6));
}else{
scope.linkrail[switchdata[i].clink].points.splice(0,0,new THREE.Vector3(scope.linkrail[switchdata[i].alink].rp.x-2,0,scope.linkrail[switchdata[i].alink].rp.z));
}
scope.switchrail[switchdata[i].code].directtype = "2";
}
const ddd = storemod.getters['map/getDeviceByCode'](switchdata[i].code);
scope.switchrail[switchdata[i].code].locateType = ddd.locateType;
if(ddd.locateType == "01"){
//1--向左 2--向右
//__\__ __/__
if(scope.switchrail[switchdata[i].code].directtype == "1"){
scope.linkrail[switchdata[i].alink].lconnect = switchdata[i].blink;
scope.linkrail[switchdata[i].blink].rconnect = switchdata[i].alink;
}else if(scope.switchrail[switchdata[i].code].directtype == "2"){
scope.linkrail[switchdata[i].alink].rconnect = switchdata[i].blink;
scope.linkrail[switchdata[i].blink].lconnect = switchdata[i].alink;
}
}else if(ddd.locateType == "02"){
if(switchdata[i].directtype == "1"){
scope.linkrail[switchdata[i].alink].lconnect = switchdata[i].clink;
scope.linkrail[switchdata[i].clink].rconnect = switchdata[i].alink;
}else if(switchdata[i].directtype == "2"){
scope.linkrail[switchdata[i].alink].rconnect = switchdata[i].clink;
scope.linkrail[switchdata[i].clink].lconnect = switchdata[i].alink;
}
}
}
for(let i=0;i<linkdata.length;i++){
scope.linkrail[linkdata[i].code].lineleft = new THREE.CatmullRomCurve3(scope.linkrail[linkdata[i].code].points);
// scope.linkrail[linkdata[i].code].lineleft.curveType = "catmullrom";
// scope.linkrail[linkdata[i].code].lineleft.tension = 0.2;
let rightpoints = [];
scope.linkrail[linkdata[i].code].points.forEach(item=>{
rightpoints.push(item);
}
);
rightpoints.reverse();
scope.linkrail[linkdata[i].code].lineright = new THREE.CatmullRomCurve3(rightpoints);
// scope.linkrail[linkdata[i].code].lineright.curveType = "catmullrom";
// scope.linkrail[linkdata[i].code].lineright.tension = 0.1;
var points = scope.linkrail[linkdata[i].code].lineleft.getPoints( 50 );
var geometry = new THREE.BufferGeometry().setFromPoints( points );
var material = new THREE.LineBasicMaterial( { color : 0xff0000 } );
// Create the final object to add to the scene
var curveObject = new THREE.Line( geometry, material );
// scene.add(curveObject);
}
}
this.getrail = function(){
};
}

View File

@ -6,6 +6,12 @@ export function SectionList() {
this.type = 'sectionlist';
let sectiongroup = new THREE.Group();
sectiongroup.name = "section";
let switchgroup = new THREE.Group();
switchgroup.name = "switch";
this.sections = {
datalist: [],
modellist: []
@ -15,6 +21,7 @@ export function SectionList() {
datalist: [],
modellist: []
};
this.standtrack = [];
this.initpromise = function (sectiondata, switchdata, scene) {
return new Promise(function(resolve, reject) {
@ -97,78 +104,287 @@ export function SectionList() {
});
};
this.loadpromise = function(jlmap3ddata,assetloader,sectiondata,switchdata,scene){
return new Promise(function(resolve, reject){
// scene.add(sectiongroup);
scene.add(switchgroup);
let linkdata = jlmap3ddata.linklist;
for(let i=0;i<sectiondata.length;i++){
if(sectiondata[i].type == "01"){
//初始化区段对象数据
let newsection = new SectionModel(sectiondata);
newsection.name = sectiondata[i].code;
newsection.code = sectiondata[i].code;
newsection.index = i;
newsection.isStandTrack = sectiondata[i].isStandTrack;
newsection.relStandCode = sectiondata[i].relStandCode;
newsection.type = sectiondata[i].type;
newsection.offsetRight = sectiondata[i].offsetRight;
newsection.offsetLeft = sectiondata[i].offsetLeft;
newsection.linkCode = sectiondata[i].linkCode;
scope.sections.datalist.push(newsection);
// scope.sections.modellist.push("");
}
}
let autosuidao;
for(let i=0;i<assetloader.modellist.length;i++){
if(assetloader.modellist[i].deviceType == "autosuidao"){
autosuidao = assetloader.modellist[i].mesh.children[0];
}
}
for(let i = 0;i < sectiondata.length;i++){
let testmesh1 = autosuidao.clone(true);
testmesh1.code = sectiondata[i].code;
testmesh1.name = sectiondata[i].code;
if(sectiondata[i].relStandCode){
testmesh1.relStandCode = sectiondata[i].relStandCode;
}else{
testmesh1.relStandCode = "";
}
testmesh1.rightlist = sectiondata[i].rightlist;
testmesh1.leftlist = sectiondata[i].leftlist;
testmesh1.rightpoint = sectiondata[i].rightpoint;
testmesh1.leftpoint = sectiondata[i].leftpoint;
testmesh1.isStandTrack = sectiondata[i].isStandTrack;
testmesh1.lengthfact = sectiondata[i].lengthfact;
for(let i=0;i<testmesh1.rightlist.length;i++){
testmesh1.geometry.attributes.position.array[testmesh1.rightlist[i]*3] = testmesh1.lengthfact;
testmesh1.geometry.attributes.uv.array[testmesh1.rightlist[i]*2] = (testmesh1.geometry.attributes.position.array[3]-testmesh1.geometry.attributes.position.array[0])/15.3;
}
let newsuidao = new THREE.BufferGeometry();
newsuidao.copy(testmesh1.geometry);
testmesh1.geometry = newsuidao;
testmesh1.geometry.attributes.position.needsUpdate = true;
testmesh1.geometry.attributes.uv.needsUpdate = true;
testmesh1.geometry.computeBoundingSphere();
testmesh1.geometry.center();
testmesh1.position.x = sectiondata[i].position.x;
testmesh1.position.y = sectiondata[i].position.y;
testmesh1.position.z = sectiondata[i].position.z;
testmesh1.rotation.x = -Math.PI/2;
testmesh1.rotation.z = sectiondata[i].rotation._z;
let newsection = new SectionModel(sectiondata);
newsection.name = sectiondata[i].code;
newsection.code = sectiondata[i].code;
newsection.isStandTrack = sectiondata[i].isStandTrack;
newsection.relStandCode = sectiondata[i].relStandCode;
newsection.linkCode = sectiondata[i].linkCode;
scope.sections.datalist.push(newsection);
if(testmesh1.isStandTrack == false){
sectiongroup.add(testmesh1);
}else{
scope.standtrack.push(testmesh1);
var box = new THREE.BoxHelper( testmesh1, 0xff0000 );
sectiongroup.add( box );
}
scope.sections.modellist.push(testmesh1);
}
let switchmesh1;
let switchmesh2;
for(let i=0;i<assetloader.modellist.length;i++){
if(assetloader.modellist[i].deviceType == "autoswitch1"){
switchmesh1 = assetloader.modellist[i].mesh;
}
if(assetloader.modellist[i].deviceType == "autoswitch2"){
switchmesh2 = assetloader.modellist[i].mesh;
}
}
// switchmesh1.rotation.x = Math.PI/2;
// switchmesh2.rotation.z = Math.PI/2;
for(let i=0;i<switchdata.length;i++){
let newswitch = {
code:switchdata[i].code,
pa:switchdata[i].pa,
pb:switchdata[i].pb,
pc:switchdata[i].pc,
paname:switchdata[i].paname,
pbname:switchdata[i].pbname,
pcname:switchdata[i].pcname,
alink:switchdata[i].alink,
blink:switchdata[i].blink,
clink:switchdata[i].clink
};
let sectionA,sectionB,sectionC;
for(let j=0;j<scope.sections.modellist.length;j++){
if(newswitch.paname == scope.sections.modellist[j].code){
sectionA = scope.sections.modellist[j];
}else if(newswitch.pbname == scope.sections.modellist[j].code){
sectionB = scope.sections.modellist[j];
}else if(newswitch.pcname == scope.sections.modellist[j].code){
sectionC = scope.sections.modellist[j];
}
}
let testswitch;
if(switchdata[i].pa[0].x>switchdata[i].pb[0].x){
if(((switchdata[i].pc[0].y+switchdata[i].pc[1].y)/2) < switchdata[i].pa[0].y){
if(((switchdata[i].pc[0].x+switchdata[i].pc[1].x)/2)>switchdata[i].pa[0].x){
testswitch = switchmesh1.clone(true);
}else{
testswitch = switchmesh2.clone(true);
}
}else{
if(((switchdata[i].pc[0].x+switchdata[i].pc[1].x)/2)>switchdata[i].pa[0].x){
testswitch = switchmesh2.clone(true);
}else{
testswitch = switchmesh1.clone(true);
}
testswitch.rotation.z = Math.PI;
}
}else{
if(((switchdata[i].pc[0].y+switchdata[i].pc[1].y)/2) < switchdata[i].pa[1].y){
if(((switchdata[i].pc[0].x+switchdata[i].pc[1].x)/2)>switchdata[i].pa[1].x){
testswitch = switchmesh1.clone(true);
}else{
testswitch = switchmesh2.clone(true);
}
}else{
if(((switchdata[i].pc[0].x+switchdata[i].pc[1].x)/2)>switchdata[i].pa[1].x){
testswitch = switchmesh2.clone(true);
}else{
testswitch = switchmesh1.clone(true);
}
testswitch.rotation.z = Math.PI;
}
}
testswitch.position.x = switchdata[i].position.x;
testswitch.position.y = switchdata[i].position.y;
testswitch.position.z = switchdata[i].position.z;
// testswitch.rotation.x = switchdata[i].rotation._x;
// testswitch.rotation.y = switchdata[i].rotation._y;
// testswitch.rotation.z = switchdata[i].rotation._z;
scope.switchs.datalist.push(newswitch);
scope.switchs.modellist.push(testswitch);
switchgroup.add(testswitch);
}
resolve("loadersection");
});
}
function buildsuidao(linkdata,suidaodata,assetloader,scene){
let autosuidao;
for(let i=0;i<assetloader.modellist.length;i++){
if(assetloader.modellist[i].deviceType == "autosuidao"){
autosuidao = assetloader.modellist[i].mesh.children[0];
}
}
let rightlist = [];
let leftlist = [];
let rightpoint = 0;
let leftpoint = 0;
let count = autosuidao.geometry.attributes.position.count;
for(let i=0;i<count;i++){
if(autosuidao.geometry.attributes.position.array[i*3] >7){
rightlist.push(i);
if(autosuidao.geometry.attributes.position.array[i*3] > rightpoint){
rightpoint = i;
}
}
if(autosuidao.geometry.attributes.position.array[i*3] <-7){
leftlist.push(i);
if(autosuidao.geometry.attributes.position.array[i*3] < rightpoint){
leftpoint = i;
}
}
}
autosuidao.rightlist = rightlist;
autosuidao.leftlist = leftlist;
autosuidao.rightpoint = rightpoint;
autosuidao.leftpoint = leftpoint;
// console.log(autosuidao);
// console.log(linkdata.linksgroup.children);
// console.log(suidaodata.datalist);
for(let i = 0;i < suidaodata.datalist.length;i++){
let link = linkdata.linksgroup.getObjectByProperty("code",suidaodata.datalist[i].linkCode);
let suidao = suidaodata.datalist[i];
let len = suidao.offsetRight-suidao.offsetLeft;
// console.log("-------------------------------------");
// console.log("name:"+link.name);
// console.log(link.lengthfact);
// console.log(len);
// console.log("ofl:"+suidao.offsetLeft+" "+"ofr:"+suidao.offsetRight);
// console.log("-------------------------------------");
let testmesh1 = autosuidao.clone(true);
for(let i=0;i<autosuidao.rightlist.length;i++){
testmesh1.geometry.attributes.position.array[autosuidao.rightlist[i]*3] = len-7.5;
testmesh1.geometry.attributes.uv.array[autosuidao.rightlist[i]*2] = (testmesh1.geometry.attributes.position.array[3]-testmesh1.geometry.attributes.position.array[0])/15.3;
}
let newsuidao = new THREE.BufferGeometry();
newsuidao.copy(testmesh1.geometry);
testmesh1.geometry = newsuidao;
testmesh1.geometry.attributes.position.needsUpdate = true;
testmesh1.geometry.attributes.uv.needsUpdate = true;
testmesh1.geometry.computeBoundingSphere();
testmesh1.geometry.center();
let lenfact = link.lengthfact;
testmesh1.rotation.x = -Math.PI/2;
testmesh1.rotation.z = link.rotation.z;
//
// console.log(link.lp.x);
// console.log(link.rp.x);
// console.log(suidao.offsetLeft*(len/lenfact));
// console.log((link.rp.x-link.lp.x)*(len/lenfact)/2);
// console.log("==============");
//
if(testmesh1.rotation.z != 0){
testmesh1.position.x = link.lp.x+suidao.offsetLeft*(len/lenfact)+ (link.rp.x-link.lp.x)*(len/lenfact)/2;
if(link.lp.y > link.rp.y){
testmesh1.position.z = link.lp.y-suidao.offsetLeft*(len/lenfact) + (link.rp.y-link.lp.y)*(len/lenfact)/2;
}else{
testmesh1.position.z = link.lp.y+suidao.offsetLeft*(len/lenfact) + (link.rp.y-link.lp.y)*(len/lenfact)/2;
}
}else{
testmesh1.position.x = link.lp.x+suidao.offsetLeft+len/2;
testmesh1.position.z = link.position.z;
}
testmesh1.position.y = 3.5;
// testmesh1.rotation.x = Math.PI/4;
testmesh1.code = suidaodata.datalist[i].code;
testmesh1.name = suidaodata.datalist[i].code;
// testmesh1.position.z = link.position.z;
testmesh1.relStandCode = suidaodata.datalist[i].relStandCode;
// testmesh1.stationCode = suidaodata.datalist[i].stationCode;
testmesh1.rightlist = autosuidao.rightlist;
testmesh1.leftlist = autosuidao.leftlist;
testmesh1.rightpoint = autosuidao.rightpoint;
testmesh1.leftpoint = autosuidao.leftpoint;
testmesh1.isStandTrack = suidaodata.datalist[i].isStandTrack;
testmesh1.lengthfact = len;
testmesh1.linkCode = suidao.linkCode;
if(suidaodata.datalist[i].isStandTrack == false){
sectiongroup.add(testmesh1);
}else{
scope.standtrack.push(testmesh1);
var box = new THREE.BoxHelper( testmesh1, 0xff0000 );
sectiongroup.add( box );
}
scope.sections.modellist.push(testmesh1);
}
}
// this.init = function(sectiondata,switchdata,scene){
//
// //遍历区段
// for(let i=0;i<sectiondata.length;i++){
// if(sectiondata[i].type == "01"){
// //初始化区段对象数据
// let newsection = new SectionModel(sectiondata);
//
// newsection.name = sectiondata[i].code;
// newsection.code = sectiondata[i].code;
// newsection.index = i;
// newsection.isStandTrack = sectiondata[i].isStandTrack;
// newsection.type = sectiondata[i].type;
//
// scope.sections.datalist.push(newsection);
// scope.sections.modellist.push("");
// }
//
// }
//
// //定义区分道岔组
// let switchlist = [];
// //遍历道岔数据
// for(let i=0;i<switchdata.length;i++){
// //道岔信息
// let newswitch = {
// code:null,
// pa:null,
// pb:null,
// pc:null,
// paname:null,
// pbname:null,
// pcname:null
// };
// //获取道岔分辨的点 PS:可能修改动态判断
// for(let j=0;j<sectiondata.length;j++){
// if(switchdata[i].sectionACode == sectiondata[j].code){
// newswitch.pa = sectiondata[j].points;
// newswitch.paname = switchdata[i].sectionACode;
// }
// if(switchdata[i].sectionBCode == sectiondata[j].code){
// newswitch.pb = sectiondata[j].points;
// newswitch.pbname = switchdata[i].sectionBCode;
// }
// if(switchdata[i].sectionCCode == sectiondata[j].code){
// newswitch.pc = sectiondata[j].points;
// newswitch.pcname = switchdata[i].sectionCCode;
// }
// if(newswitch.pa != null && newswitch.pb!= null && newswitch.pc != null){
// newswitch.code = switchdata[i].code;
// switchlist.push(newswitch);
// j = sectiondata.length;
// }
// }
// }
//
// //道岔贴图
// //遍历道岔信息组合轨道
// for(let i=0;i<switchlist.length;i++){
// //道岔对象组
// let newswitch = new SwitchModel();
//
// newswitch.name = switchlist[i].code;
// newswitch.code = switchlist[i].code;
//
// newswitch.index = i;
//
// scope.switchs.datalist.push(newswitch);
// scope.switchs.modellist.push("");
// }
//
// }
}

View File

@ -8,8 +8,10 @@ export function SectionModel(data) {
this.index = null;
//轨迹点
this.rail = [];
this.railline = null;
//长度
this.distance = null;
this.distance = [];
this.isStandTrack = null;

View File

@ -50,11 +50,13 @@ export function StationStandList() {
}
}
}
newstationstand.index = i;
newstationstand.num = i;
scope.list[stationdata[i].code] = newstationstand;
}
}
let map = scope.list;
for(let k in map){
@ -65,10 +67,6 @@ export function StationStandList() {
num = j;
}
}
map[k].mesh = assetloader.modellist[num].mesh.clone(true);
map[k].id = assetloader.modellist[num].id;
map[k].mesh.code = map[k].code;
@ -98,25 +96,19 @@ export function StationStandList() {
textmaterial.dispose();
textt.dispose();
}else{
for(let netnum =0;netnum <netstand.length;netnum++){
if(netstand[netnum].code == k ){
for(let netnum =0;netnum <netstand.length;netnum++){
if(netstand[netnum].code == k ){
for(let j=0;j<assetloader.modellist.length;j++){
if(assetloader.modellist[j].id == netstand[netnum].modelid){
num = j;
map[k].index = netnum;
j = assetloader.modellist.length;
}
for(let j=0;j<assetloader.modellist.length;j++){
if(assetloader.modellist[j].id == netstand[netnum].modelid){
num = j;
map[k].index = netnum;
j = assetloader.modellist.length;
}
netnum = netstand.length;
}
}
netnum = netstand.length;
}
}
map[k].mesh = assetloader.modellist[num].mesh.clone(true);
let newclip = assetloader.modellist[num].mesh.animations[ 0 ];
@ -172,16 +164,15 @@ export function StationStandList() {
map[k].mesh.scale.x = netstand[map[k].index].scale.x;
map[k].mesh.scale.y = netstand[map[k].index].scale.y;
map[k].mesh.scale.z = netstand[map[k].index].scale.z;
let textgeometry = new THREE.PlaneBufferGeometry( 271, 374, 1 );
let textt = new THREE.CanvasTexture(getTextCanvas(stationdata[map[k].index]));
let textt = new THREE.CanvasTexture(getTextCanvas(stationdata[map[k].num]));
let textmaterial = new THREE.MeshBasicMaterial( { side: THREE.DoubleSide,map:textt ,transparent: true} );
let textplane = new THREE.Mesh( textgeometry, textmaterial );
textplane.name = stationdata[map[k].index].code;
textplane.name = stationdata[map[k].num].code;
map[k].type = "station";
map[k].rname = stationdata[map[k].index].runPlanName;
map[k].kmmark = stationdata[map[k].index].kmPost;
map[k].rname = stationdata[map[k].num].runPlanName;
map[k].kmmark = stationdata[map[k].num].kmPost;
textplane.position.y = 300;
textplane.rotation.x = Math.PI/2;

View File

@ -10,7 +10,7 @@ export function StationStandModel(opts) {
this.ismodel = false;
this.istexture = false;
this.modelurl = null;
this.index = null;
this.direction1= {
position:null,
name:null,

View File

@ -38,6 +38,7 @@ export function TrainList() {
top:[],
down:[]
};
for(let j=0;j<newmesh.children.length;j++){
if(newmesh.children[j].name == "c1" || newmesh.children[j].name == "c6"){
@ -122,8 +123,9 @@ export function TrainList() {
let textmaterial = new THREE.MeshBasicMaterial( { side: THREE.DoubleSide,map:textt ,transparent: true} );
let textplane = new THREE.Mesh( textgeometry, textmaterial );
textplane.name = data[i].code;
textplane.position.x = -50;
textplane.position.y = 130;
textplane.position.x = 0;
textplane.position.y = 0;
textplane.position.z = 60;
textplane.tcode = data[i].code;
//textplane.rotation.x = Math.PI;
scope.textlist.push(textplane);
@ -139,7 +141,7 @@ export function TrainList() {
newmesh.groupNumber = data[i].groupNumber;
newmesh.position.set(0,-50000,0);
newmesh.children[0].position.y = 0;
// newmesh.children[0].position.y = 0;
//newmesh.rotation.y = Math.PI/2;
newmesh.status = "00";
newmesh.nowcode = null;

View File

@ -12,107 +12,61 @@ export function UpdateTrain(camera,traindata){
if(trainmodel.speeds > 0 && trainmodel.speeds){
let speed = null;
if(traindata.group.children[j].progress<1){
if(traindata.group.children[j].progress >=0&&traindata.group.children[j].progress<=1){
// console.log(trainmodel.rname);
// console.log(trainmodel.speeds);
// console.log(trainmodel.progress);
let movecurve = trainmodel.curve;
if(trainmodel.status == "03"){
if(movecurve.points.length>1){
let point = movecurve.getPointAt(traindata.group.children[j].progress);
if(trainmodel.status == "03"){//向左
let point = movecurve.getPointAt(traindata.group.children[j].progress);
if(Math.abs( point.z -trainmodel.children[0].matrixWorld.elements[14]) >0.1){
trainmodel.children[0].up = new THREE.Vector3(-1,0,0);
let tangent = movecurve.getTangentAt(traindata.group.children[j].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);
let rotas = {
posr:point,
rota:trainmodel.children[0].rotation.y
}
trainmodel.children[1].rotalist.push(rotas);
if(Math.abs( point.z -trainmodel.children[0].matrixWorld.elements[14]) >0.02){
trainmodel.children[0].up = new THREE.Vector3(-1,0,0);
let tangent = movecurve.getTangentAt(traindata.group.children[j].progress).normalize();
trainmodel.children[0].axis.crossVectors(trainmodel.children[0].up, tangent).normalize();
let radians = Math.acos(trainmodel.children[0].up.dot(tangent));
let offsetz = parseFloat(trainmodel.children[0].matrixWorld.elements[14]) - parseFloat(point.z);
trainmodel.children[0].position.z += offsetz;
//trainmodel.position.z = point.z;
}
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;
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]-38)<=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.y = 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.children[0].rotation.x);
// console.log(trainmodel.children[0].rotation.y);
// console.log(trainmodel.children[0].rotation.z);
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.progress += trainmodel.speeds;
}
if(trainmodel.status == "02"){
trainmodel.position.x = point.x;
trainmodel.position.y = 0;
let point = movecurve.getPointAt(trainmodel.progress);
if(Math.abs( point.z -trainmodel.children[0].matrixWorld.elements[14]) >0.1){
trainmodel.children[0].up = new THREE.Vector3(1,0,0);
let tangent = movecurve.getTangentAt(traindata.group.children[j].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);
let rotas = {
posr:point,
rota:trainmodel.children[0].rotation.y
}
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++){
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);
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]+38)>=trainmodel.children[rs].rotalist[0].posr.x){
if((trainmodel.children[rs].matrixWorld.elements[12]-8)<=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.y = trainmodel.children[rs].rotalist[0].rota;
trainmodel.children[rs].rotation.z = trainmodel.children[rs].rotalist[0].rota;
trainmodel.children[rs].rotalist.splice(0,1)
xh--;
}else{
@ -120,17 +74,94 @@ export function UpdateTrain(camera,traindata){
}
}
//console.log(trainmodel.children[rs].rotalist.length);
}
}
}
// console.log(trainmodel.rotalist);
trainmodel.progress += trainmodel.speeds;
}
trainmodel.progress += trainmodel.speeds;
}
if(trainmodel.status == "02"){
if(movecurve.points.length>1){
let point = movecurve.getPointAt(trainmodel.progress);
if(Math.abs( point.z -trainmodel.children[0].matrixWorld.elements[14]) >0.02){
trainmodel.children[0].up = new THREE.Vector3(1,0,0);
let tangent = movecurve.getTangentAt(traindata.group.children[j].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]+8)>=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.status == '02'){
trainmodel.curve = trainmodel.nextcurve;
}else if(trainmodel.status == '03'){
trainmodel.curve = trainmodel.nextcurve;
}
// 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;
}
}

View File

@ -15,12 +15,14 @@ function hasPermission(roles, permissionRoles) {
return roles.some(role => permissionRoles.indexOf(role) >= 0);
}
const whiteList = ['/login', '/design/login', '/login/xty']; // 不重定向白名单
const whiteList = ['/login', '/design/login', '/xty/login']; // 不重定向白名单
const loginPage = whiteList[0];
const loginDesignPage = whiteList[1];
const loginXtyPage = whiteList[2];
// 获取路径数据
function getRouteInfo(to) {
let loginPath = '/';
@ -37,12 +39,16 @@ function getRouteInfo(to) {
getTokenInfo = getDesignToken;
clientId = LoginParams.Design.clientId;
} else {
loginPath = loginPage;
loginPath = getSessionStorage('project')==='xty'?loginXtyPage:loginPage;
getTokenInfo = getToken;
clientId = null;
}
} else if ( /^\/xty/.test(toRoutePath)) {
loginPath = loginXtyPage;
getTokenInfo = getToken;
clientId = null;
} else {
loginPath = loginPage;
loginPath = getSessionStorage('project')==='xty'?loginXtyPage:loginPage;
getTokenInfo = getToken;
clientId = null;
}

View File

@ -214,6 +214,9 @@ StompClient.prototype = {
// 发送消息
send(url, msg) {
if (this.status) {
if(msg) {
msg = JSON.stringify(msg);
}
try {
this.clientIns.send(url, {}, msg);
} catch (err) {

View File

@ -172,7 +172,7 @@ export default {
init: function (skinCode) {
const mapdata = this.$store.getters['map/map'];
const dom = document.getElementById('app');
this.jlmap3d = new JLmapDriving(dom, mapdata, skinCode);
this.jlmap3d = new JLmapDriving(dom, mapdata, skinCode,this.$store);
this.jlmap3d.eventon();
this.cctvshow = false;
@ -285,7 +285,9 @@ export default {
.trainstatus{
left:0;
top:0;
width:350px;
width:fit-content;
width:-webkit-fit-content;
width:-moz-fit-content;
height:30px;
background: #000000;
position:absolute;

View File

@ -6,7 +6,13 @@
<el-button type="transrota" @click="transrota">旋转</el-button>
<el-button type="transscal" @click="transscal">拉伸</el-button>
<el-button type="transscal" @click="transscal">放大缩小</el-button>
<el-button type="vexscal" @click="vexscal">拉伸</el-button>
<el-button type="testrail" @click="testrail">测试轨迹</el-button>
<el-button type="autoss" @click="autoss">自动匹配轨道信号灯</el-button>
<el-button type="expo" @click="expo">导出obj</el-button>
@ -49,6 +55,15 @@ export default {
async transscal(){
this.$emit('transscal');
},
async vexscal(){
this.$emit('vexscal');
},
async testrail(){
this.$emit('testrail');
},
async autoss(){
this.$emit('autoss');
},
async expo(){
this.$emit('expo');
},

View File

@ -14,7 +14,7 @@
<Edit-Assets ref="assets" @smodel="smodel" @stexture="stexture">
</Edit-Assets>
<Edit-Menu ref="menu" @transpos="transpos" @transrota="transrota" @transscal="transscal" @expo="expo" @save="save"
<Edit-Menu ref="menu" @transpos="transpos" @transrota="transrota" @transscal="transscal" @vexscal= "vexscal" @testrail="testrail" @autoss="autoss" @expo="expo" @save="save"
@back="back">
</Edit-Menu>
@ -150,12 +150,27 @@
},
transpos() {
this.jlmap3dedit.transcontrol.setMode('translate');
this.jlmap3dedit.vexscaloff();
},
transrota() {
this.jlmap3dedit.transcontrol.setMode('rotate');
this.jlmap3dedit.vexscaloff();
},
transscal() {
this.jlmap3dedit.transcontrol.setMode('scale');
this.jlmap3dedit.vexscaloff();
},
vexscal(){
this.jlmap3dedit.transcontrol.detach();
this.jlmap3dedit.vexscal();
console.log("vexscal");
},
testrail(){
this.jlmap3dedit.testrail();
},
autoss(){
this.jlmap3dedit.autoss();
},
expo() {
@ -164,9 +179,8 @@
save() {
//console.log("save");
let param = getmodels(this.jlmap3dedit);
console.log(this.jlmap3dedit);
console.log(param);
//console.log(param);
update3dMapData(param).then(data => {
//console.log(data);
if (data.code == "200") {

View File

@ -11,7 +11,7 @@
<el-button type="primary" @click="raysignal">{{$t('jlmap3d.turnoutCheck')}}</el-button>
<el-button type="primary" @click="back">{{$t('global.back')}}</el-button>
</el-button-group>
</div>
@ -117,10 +117,9 @@ export default {
}
},
init: function (skinCode) {
console.log('three');
const mapdata = this.$store.getters['map/map'];
const dom = document.getElementById('app');
this.jlmap3d = new JLmap3d(dom, mapdata, skinCode);
this.jlmap3d = new JLmap3d(dom, mapdata, skinCode,this.$store);
this.jlmap3d.eventon();
},
raystand() {

View File

@ -1,19 +1,19 @@
<template>
<div class="PlanStatusBar">
<ul class="ul-box">
<div class="li_plan" @click="showTrain" v-if="isNotUser">{{$t('planMonitor.serviceAndTripNumber')}}</div>
<div v-if="isNotUser" class="li_plan" @click="showTrain">{{ $t('planMonitor.serviceAndTripNumber') }}</div>
</ul>
<ul class="ul-box">
<div class="li_plan" @click="handleAddPlanningTrain" v-if="isNotUser">{{$t('planMonitor.addPlan')}}</div>
<div class="li_plan" @click="handleDeletePlanningTrain" v-if="isNotUser">{{$t('planMonitor.deletePlan')}}</div>
<div class="li_plan" @click="handleDuplicateTrain" v-if="isNotUser">{{$t('planMonitor.duplicatePlan')}}</div>
<div class="li_plan" @click="handleAddTask" v-if="isNotUser">{{$t('planMonitor.addTask')}}</div>
<div class="li_plan" @click="handleDeleteTask" v-if="isNotUser">{{$t('planMonitor.deleteTask')}}</div>
<div class="li_plan" @click="handleModifyingTask" v-if="isNotUser">{{$t('planMonitor.modifyTask')}}</div>
<div v-if="isNotUser" class="li_plan" @click="handleAddPlanningTrain">{{ $t('planMonitor.addPlan') }}</div>
<div v-if="isNotUser" class="li_plan" @click="handleDeletePlanningTrain">{{ $t('planMonitor.deletePlan') }}</div>
<div v-if="isNotUser" class="li_plan" @click="handleDuplicateTrain">{{ $t('planMonitor.duplicatePlan') }}</div>
<div v-if="isNotUser" class="li_plan" @click="handleAddTask">{{ $t('planMonitor.addTask') }}</div>
<div v-if="isNotUser" class="li_plan" @click="handleDeleteTask">{{ $t('planMonitor.deleteTask') }}</div>
<div v-if="isNotUser" class="li_plan" @click="handleModifyingTask">{{ $t('planMonitor.modifyTask') }}</div>
</ul>
<ul class="ul-box tool">
<div class="li_plan" @click="handlePlanEffectiveCheck" v-if="isNotUser">{{$t('planMonitor.validityCheck')}}</div>
<div class="li_plan" @click="handleTestRunPlan">{{$t('planMonitor.testRunning')}}</div>
<div v-if="isNotUser" class="li_plan" @click="handlePlanEffectiveCheck">{{ $t('planMonitor.validityCheck') }}</div>
<div class="li_plan" @click="handleTestRunPlan">{{ $t('planMonitor.testRunning') }}</div>
</ul>
</div>
</template>
@ -27,19 +27,19 @@ export default {
name: 'PlanStatusBar',
data() {
return {
isNotUser:true
isNotUser: true
};
},
watch: {
},
created(){
if(/^\/plan\/usertool/.test(this.$route.fullPath)){
this.isNotUser=false;
}else{
this.isNotUser=true;
}
},
created() {
if (/^\/plan\/usertool/.test(this.$route.fullPath)) {
this.isNotUser=false;
} else {
this.isNotUser=true;
}
},
methods: {
showTrain() {
this.$emit('showTrain');
@ -131,11 +131,15 @@ export default {
async handleTestRunPlan() {
const data = { planId: this.$route.query.planId };
runPlanNotify(data).then(resp => {
const query = {
skinCode: this.$route.query.skinCode, prdType: '01', group: resp.data, mapId: this.$route.query.mapId, planId: this.$route.query.planId
};
this.$router.push({ path: `${UrlConfig.display}/plan`, query: query });
launchFullscreen();
if (resp.data) {
const query = {
skinCode: this.$route.query.skinCode, prdType: '01', group: resp.data, mapId: this.$route.query.mapId, planId: this.$route.query.planId
};
this.$router.push({ path: `${UrlConfig.display}/plan`, query: query });
launchFullscreen();
} else {
this.$messageBox(this.$t('error.checkTheValidityFirst'));
}
}).catch(error => {
this.$messageBox(this.$t('tip.createSimulationFaild')+this.$t('global.colon')+error.message);
});

View File

@ -1,200 +1,200 @@
<template>
<el-card>
<QueryListPage ref="subSystemListPage" :pager-config="pagerConfig" :query-form="queryForm" :query-list="queryList" />
<once-generate ref="generate" @create="generateMapSystem"></once-generate>
<createMapSystem ref="createMapSystem" :title="$t('systemGenerate.createSubSystem')" @create="handleCreate" operateType="add"></createMapSystem>
<createMapSystem ref="modifyMapSystem" :title="$t('systemGenerate.modifySubSystem')" @create="handleModify" operateType="modify"></createMapSystem>
</el-card>
<el-card>
<QueryListPage ref="subSystemListPage" :pager-config="pagerConfig" :query-form="queryForm" :query-list="queryList" />
<once-generate ref="generate" @create="generateMapSystem" />
<createMapSystem ref="createMapSystem" :title="$t('systemGenerate.createSubSystem')" operate-type="add" @create="handleCreate" />
<createMapSystem ref="modifyMapSystem" :title="$t('systemGenerate.modifySubSystem')" operate-type="modify" @create="handleModify" />
</el-card>
</template>
<script>
import Cookies from 'js-cookie';
import { listPublishMap } from '@/api/jmap/map';
import { generateMapSystem,getMapSystemPageList,createMapSubSystem,getSubSystemInfo,updateSubSystem,deleteSubSystem} from '@/api/trainingPlatform';
import ConstConfig from '@/scripts/ConstConfig';
import OnceGenerate from './generate';
import createMapSystem from './create';
import Cookies from 'js-cookie';
import { listPublishMap } from '@/api/jmap/map';
import { generateMapSystem, getMapSystemPageList, createMapSubSystem, getSubSystemInfo, updateSubSystem, deleteSubSystem} from '@/api/trainingPlatform';
import ConstConfig from '@/scripts/ConstConfig';
import OnceGenerate from './generate';
import createMapSystem from './create';
export default {
name: 'SystemGenerate',
data() {
return{
prdTypeList:[],
mapId: '',
pagerConfig: {
pageSize: 'pageSize',
pageIndex: 'pageNum'
},
queryForm: {
labelWidth: '100px',
reset: true,
queryObject: {
mapId: {
type: 'select',
label: this.$t('systemGenerate.map'),
config: {
data: []
}
},
'name': {
type: 'text',
label: this.$t('systemGenerate.name')
},
'type': {
type: 'select',
label: this.$t('systemGenerate.type'),
config: {
data: []
}
},
}
},
queryList: {
query: this.queryFunction,
selectCheckShow: false,
indexShow: true,
columns: [
{
title: this.$t('systemGenerate.name'),
prop: 'name'
},
{
title: this.$t('systemGenerate.type'),
type: 'tag',
prop: 'type',
columnValue: (row) => { return this.$convertField(row.type , this.prdTypeList, ['value', 'label']); },
tagType: (row) => { return ''; }
},
{
title: this.$t('systemGenerate.mapName'),
type: 'tag',
prop: 'mapName',
columnValue: (row) => { return row.mapName},
tagType: (row) => { return ''; }
},
{
title: this.$t('systemGenerate.prdName'),
prop: 'prdName'
},
{
type: 'button',
title: this.$t('global.operate'),
width: '400',
buttons: [
{
name: this.$t('systemGenerate.updateData'),
handleClick: this.updateData,
type: ''
},
{
name: this.$t('systemGenerate.deleteData'),
handleClick: this.deleteData,
type: 'danger',
showControl:(row) => { return Boolean(row.customized) },
},
],
},
],
actions: [
{ text: this.$t('systemGenerate.commission'), handler: this.handleAdd },
{ text: this.$t('systemGenerate.generate'), handler: this.generate }
]
},
export default {
name: 'SystemGenerate',
components: {
OnceGenerate,
createMapSystem
},
data() {
return {
prdTypeList: [],
mapId: '',
pagerConfig: {
pageSize: 'pageSize',
pageIndex: 'pageNum'
},
queryForm: {
labelWidth: '100px',
reset: true,
queryObject: {
mapId: {
type: 'select',
label: this.$t('systemGenerate.map'),
config: {
data: []
}
},
'name': {
type: 'text',
label: this.$t('systemGenerate.name')
},
'type': {
type: 'select',
label: this.$t('systemGenerate.type'),
config: {
data: []
}
}
}
},
queryList: {
query: this.queryFunction,
selectCheckShow: false,
indexShow: true,
columns: [
{
title: this.$t('systemGenerate.name'),
prop: 'name'
},
{
title: this.$t('systemGenerate.type'),
type: 'tag',
prop: 'type',
columnValue: (row) => { return this.$convertField(row.type, this.prdTypeList, ['value', 'label']); },
tagType: (row) => { return ''; }
},
{
title: this.$t('systemGenerate.mapName'),
type: 'tag',
prop: 'mapName',
columnValue: (row) => { return row.mapName; },
tagType: (row) => { return ''; }
},
{
title: this.$t('systemGenerate.prdName'),
prop: 'prdName'
},
{
type: 'button',
title: this.$t('global.operate'),
width: '400',
buttons: [
{
name: this.$t('systemGenerate.updateData'),
handleClick: this.updateData,
type: ''
},
{
name: this.$t('systemGenerate.deleteData'),
handleClick: this.deleteData,
type: 'danger',
showControl: (row) => { return Boolean(row.customized); }
}
]
}
],
actions: [
{ text: this.$t('systemGenerate.commission'), handler: this.handleAdd },
{ text: this.$t('systemGenerate.generate'), handler: this.generate }
]
}
}
},
components: {
OnceGenerate,
createMapSystem
},
mounted(){
this.loadInitData();
},
computed: {
height() {
return this.$store.state.app.height - 50;
}
},
methods: {
updateData(index,row){
getSubSystemInfo(row.id).then(response => {
this.$refs.modifyMapSystem.doShow(response.data);
}).catch(() => {
this.$messageBox(this.$t('systemGenerate.getSubSystemInfoFail'));
});
},
deleteData(index,row){
this.$confirm(this.$t('systemGenerate.deleteMapSystemTip'), this.$t('global.tips'), {
confirmButtonText: this.$t('global.confirm'),
cancelButtonText: this.$t('global.cancel'),
type: 'warning'
}).then(() => {
deleteSubSystem(row.id).then(response => {
this.$message.success(this.$t('systemGenerate.deleteMapSystemSuccess'));
this.reloadTable();
}).catch(() => {
this.$messageBox(this.$t('systemGenerate.deleteMapSystemFail'));
});
}).catch(() => { });
},
handleCreate(data){
delete data.id;
createMapSubSystem(data).then(response => {
this.$message.success(this.$t('systemGenerate.createMapSystemSuccess'));
};
},
computed: {
height() {
return this.$store.state.app.height - 50;
}
},
mounted() {
this.loadInitData();
},
methods: {
updateData(index, row) {
getSubSystemInfo(row.id).then(response => {
this.$refs.modifyMapSystem.doShow(response.data);
}).catch(() => {
this.$messageBox(this.$t('systemGenerate.getSubSystemInfoFail'));
});
},
deleteData(index, row) {
this.$confirm(this.$t('systemGenerate.deleteMapSystemTip'), this.$t('global.tips'), {
confirmButtonText: this.$t('global.confirm'),
cancelButtonText: this.$t('global.cancel'),
type: 'warning'
}).then(() => {
deleteSubSystem(row.id).then(response => {
this.$message.success(this.$t('systemGenerate.deleteMapSystemSuccess'));
this.reloadTable();
}).catch(() => {
this.$messageBox(this.$t('systemGenerate.createMapSystemFail'));
this.$messageBox(this.$t('systemGenerate.deleteMapSystemFail'));
});
},
handleModify(data){
let datainfo={'name':data.name};
updateSubSystem(data.id,datainfo).then(response => {
this.$message.success(this.$t('systemGenerate.updateMapSystemSuccess'));
this.reloadTable();
}).catch(() => {
this.$messageBox(this.$t('systemGenerate.updateMapSystemFail'));
}).catch(() => { });
},
handleCreate(data) {
delete data.id;
createMapSubSystem(data).then(response => {
this.$message.success(this.$t('systemGenerate.createMapSystemSuccess'));
this.reloadTable();
}).catch(() => {
this.$messageBox(this.$t('systemGenerate.createMapSystemFail'));
});
},
handleModify(data) {
const datainfo={'name': data.name};
updateSubSystem(data.id, datainfo).then(response => {
this.$message.success(this.$t('systemGenerate.updateMapSystemSuccess'));
this.reloadTable();
}).catch(() => {
this.$messageBox(this.$t('systemGenerate.updateMapSystemFail'));
});
},
handleAdd() {
this.$refs.createMapSystem.doShow();
},
reloadTable() {
if (this.queryList && this.queryList.reload) {
this.queryList.reload();
}
},
async loadInitData() {
try {
//
this.mapList = [];
const res = await listPublishMap();
this.allMapList=res.data;
res.data.forEach(elem => {
this.queryForm.queryObject.mapId.config.data.push({ value: elem.id, label: elem.name });
});
},
handleAdd(){
this.$refs.createMapSystem.doShow();
},
reloadTable(){
if (this.queryList && this.queryList.reload) {
this.queryList.reload();
}
},
async loadInitData() {
try {
//
this.mapList = [];
const res = await listPublishMap();
this.allMapList=res.data;
res.data.forEach(elem => {
this.queryForm.queryObject.mapId.config.data.push({ value: elem.id, label: elem.name });
});
let productTypeList=ConstConfig.ConstSelect.productType;
this.prdTypeList=Cookies.get("user_lang")=="en"?
productTypeList.map(elem => { return { value: elem.value, label: elem.enlabel } }):
productTypeList.map(elem => { return { value: elem.value, label: elem.label } });
this.queryForm.queryObject.type.config.data=this.prdTypeList;
} catch (error) {
console.error(error, '获取发布地图');
}
},
generate() {
this.$refs.generate.doShow();
},
generateMapSystem(data) {
generateMapSystem(data.mapId).then(response => {
this.reloadTable();
this.$message.success(this.$t('systemGenerate.generateSuccess'));
}).catch(() => {
this.$messageBox(this.$t('systemGenerate.generateFail'));
});
},
queryFunction(params) {
return getMapSystemPageList(params);
},
}
}
const productTypeList=ConstConfig.ConstSelect.productType;
this.prdTypeList=Cookies.get('user_lang')=='en'
?productTypeList.map(elem => { return { value: elem.value, label: elem.enlabel }; })
:productTypeList.map(elem => { return { value: elem.value, label: elem.label }; });
this.queryForm.queryObject.type.config.data=this.prdTypeList;
} catch (error) {
console.error(error, '获取发布地图');
}
},
generate() {
this.$refs.generate.doShow();
},
generateMapSystem(data) {
generateMapSystem(data.mapId).then(response => {
this.reloadTable();
this.$message.success(this.$t('systemGenerate.generateSuccess'));
}).catch(() => {
this.$messageBox(this.$t('systemGenerate.generateFail'));
});
},
queryFunction(params) {
return getMapSystemPageList(params);
}
}
};
</script>

View File

@ -27,6 +27,7 @@
<span v-if="node.data.id ==='Simulation'">&nbsp;{{ node.data.name+ $t('global.simulationSystem') }}</span>
<span v-else-if="node.data.id ==='Lesson'">&nbsp;{{ node.data.name+ $t('global.lessonSystem') }}</span>
<span v-else-if="node.data.id ==='Exam'">&nbsp;{{ node.data.name+ $t('global.examSystem') }}</span>
<span v-else-if="node.data.id ==='Plan'">&nbsp;{{ node.data.name+ $t('global.runPlanSystem') }}</span>
<span v-else>&nbsp;{{ node.data.name }}</span>
</span>
</el-tree>
@ -138,9 +139,9 @@ export default {
this.setLocalRoute(`${UrlConfig.trainingPlatform.prodDetail}/${obj.id}?mapId=${this.mapId}`);
this.$router.push({ path: `${UrlConfig.trainingPlatform.prodDetail}/${obj.id}`, query: { mapId: this.mapId}});
break;
// case '':
// this.$router.push({ path: `${UrlConfig.trainingPlatform.runPlan}/${this.mapId}`, query: {skinCode: '02'} });
// break;
case 'Plan':
this.$router.push({ path: `${UrlConfig.trainingPlatform.runPlan}/${this.mapId}`, query: {skinCode: '02'} });
break;
}
}).catch((error) => {
if (error.code === '40004') {

Binary file not shown.

After

Width:  |  Height:  |  Size: 161 KiB

BIN
static/model/auto/rail.FBX Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
static/model/signal/d3d.FBX Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 307 KiB

Binary file not shown.