修改编辑器轨道匹配逻辑

This commit is contained in:
sunzhenyu 2020-01-03 16:56:36 +08:00
parent 33966b5a33
commit 71cadb56e8
12 changed files with 331 additions and 186 deletions

View File

@ -8,6 +8,7 @@ import {SignalList} from '@/jlmap3d/edit/neweditmodel/SignalList.js';
import {StationStandList} from '@/jlmap3d/edit/neweditmodel/StationStandList.js'; import {StationStandList} from '@/jlmap3d/edit/neweditmodel/StationStandList.js';
import {TrainList} from '@/jlmap3d/edit/neweditmodel/TrainList.js'; import {TrainList} from '@/jlmap3d/edit/neweditmodel/TrainList.js';
import {TrainListTest} from '@/jlmap3d/edit/neweditmodel/TrainListTest.js'; import {TrainListTest} from '@/jlmap3d/edit/neweditmodel/TrainListTest.js';
import {SwitchList} from '@/jlmap3d/edit/neweditmodel/SwitchList.js';
import {LinkList} from '@/jlmap3d/edit/neweditmodel/LinkList.js'; import {LinkList} from '@/jlmap3d/edit/neweditmodel/LinkList.js';
import {RailList} from '@/jlmap3d/edit/neweditmodel/RailList.js'; import {RailList} from '@/jlmap3d/edit/neweditmodel/RailList.js';
@ -49,8 +50,8 @@ export function Jlmap3ddata(mapid,scope){
}); });
function initobj(mapid,data3did){ function initobj(mapid,data3did){
console.log(mapid); // console.log(mapid);
console.log(data3did); // console.log(data3did);
getMapDetail(mapid).then(data => { getMapDetail(mapid).then(data => {
let mapdata = data.data; let mapdata = data.data;
//console.log(data3did); //console.log(data3did);
@ -63,8 +64,9 @@ export function Jlmap3ddata(mapid,scope){
jlmap3ddata.sectionlist = new SectionList(); jlmap3ddata.sectionlist = new SectionList();
// jlmap3ddata.linklist = new LinkList(); // jlmap3ddata.linklist = new LinkList();
// jlmap3ddata.signallist = new SignalList(); jlmap3ddata.signallist = new SignalList();
jlmap3ddata.switchlist = new SwitchList();
// jlmap3ddata.trainlisttest = new TrainListTest(); // jlmap3ddata.trainlisttest = new TrainListTest();
// //
// jlmap3ddata.raillist = new RailList(); // jlmap3ddata.raillist = new RailList();
@ -84,10 +86,13 @@ export function Jlmap3ddata(mapid,scope){
// return jlmap3ddata.linklist.initpromise(mapdata.linkList,scene,assetloader); // return jlmap3ddata.linklist.initpromise(mapdata.linkList,scene,assetloader);
// }) // })
// .then(function(data){ .then(function(data){
// //console.log(data); //console.log(data);
// return jlmap3ddata.signallist.initpromise(jlmap3ddata,mapdata.signalList,scene,assetloader); return jlmap3ddata.signallist.initpromise(jlmap3ddata,mapdata.signalList,scene,assetloader);
// }) })
.then(function(data){
return jlmap3ddata.switchlist.initpromise(jlmap3ddata,mapdata.switchList,scene,assetloader);
})
// .then(function(data){ // .then(function(data){
// //console.log(data); // //console.log(data);

View File

@ -24,7 +24,7 @@ import { SetLights } from '@/jlmap3d/config/SetLights';
//加载器 //加载器
// import { Jlmap3ddata } from '@/jlmap3d/edit/Jlmap3ddata'; // import { Jlmap3ddata } from '@/jlmap3d/edit/Jlmap3ddata';
import { Jlmap3ddata } from '@/jlmap3d/edit/Jlmap3ddata'; import { Jlmap3ddata } from '@/jlmap3d/edit/Jlmap3dnewdata';
//操作管理器 //操作管理器
import { Actionmanage } from '@/jlmap3d/edit/actionmanage'; import { Actionmanage } from '@/jlmap3d/edit/actionmanage';

View File

@ -42,7 +42,7 @@ export function SectionList() {
autorail.leftlist = leftlist; autorail.leftlist = leftlist;
return new Promise(function(resolve, reject){ return new Promise(function(resolve, reject){
scene.add(scope.sectiondata); // scene.add(scope.sectiondata);
scene.add(scope.sectiongroup); scene.add(scope.sectiongroup);
@ -63,7 +63,18 @@ export function SectionList() {
newsection.lsection = sectiondata[i].leftSectionCode; newsection.lsection = sectiondata[i].leftSectionCode;
newsection.points = sectiondata[i].points; newsection.points = sectiondata[i].points;
newsection.pointslength = sectiondata[i].points.length-1; newsection.pointslength = sectiondata[i].points.length-1;
newsection.standTrack = sectiondata[i].standTrack;
newsection.endbuild = false; newsection.endbuild = false;
newsection.rp = {
x:0,
y:0,
z:0
};
newsection.lp = {
x:0,
y:0,
z:0
};
scope.sections.datalist[sectiondata[i].code] = newsection; scope.sections.datalist[sectiondata[i].code] = newsection;
// console.log("-----------------------"); // console.log("-----------------------");
@ -71,13 +82,13 @@ export function SectionList() {
// if(sectiondata[i].code == "T285"){ // if(sectiondata[i].code == "T285"){
// console.log(sectiondata[i]); // console.log(sectiondata[i]);
// } // }
if(sectiondata[i].points[0].y > sectiondata[i].points[sectiondata[i].points.length-1].y){ // if(sectiondata[i].points[0].y > sectiondata[i].points[sectiondata[i].points.length-1].y){
newsection.iscur = "1"; // newsection.iscur = "1";
}else if(sectiondata[i].points[0].y < sectiondata[i].points[sectiondata[i].points.length-1].y){ // }else if(sectiondata[i].points[0].y < sectiondata[i].points[sectiondata[i].points.length-1].y){
newsection.iscur = "2"; // newsection.iscur = "2";
}else{ // }else{
newsection.iscur = "3"; // newsection.iscur = "3";
} // }
if(sectiondata[i].standTrack == true){ if(sectiondata[i].standTrack == true){
// console.log(sectiondata[i].code); // console.log(sectiondata[i].code);
sectiondata[i].startx = sectiondata[i].points[0].x; sectiondata[i].startx = sectiondata[i].points[0].x;
@ -87,6 +98,7 @@ export function SectionList() {
// sections.modellist.push(""); // sections.modellist.push("");
} }
} }
//连接区段 //连接区段
for(let i=0;i<switchdata.length;i++){ for(let i=0;i<switchdata.length;i++){
let acode = switchdata[i].sectionACode; let acode = switchdata[i].sectionACode;
@ -103,7 +115,7 @@ export function SectionList() {
// console.log(cposx); // console.log(cposx);
// console.log("----------------"); // console.log("----------------");
if(aposx > cposx){ if(aposx > cposx){
if(aposy > cposy){ if(aposy < cposy){
// ——A // ——A
// /C // /C
scope.sections.datalist[ccode].ctype = 1; scope.sections.datalist[ccode].ctype = 1;
@ -113,7 +125,7 @@ export function SectionList() {
scope.sections.datalist[ccode].ctype = 2; scope.sections.datalist[ccode].ctype = 2;
} }
}else{ }else{
if(aposy > cposy){ if(aposy < cposy){
// A—— // A——
// \C // \C
scope.sections.datalist[ccode].ctype = 3; scope.sections.datalist[ccode].ctype = 3;
@ -147,38 +159,67 @@ export function SectionList() {
console.log(scope.sections.datalist); console.log(scope.sections.datalist);
console.log(scope.stopsection); // console.log(scope.stopsection);
console.log(jlmap3ddata); // console.log(jlmap3ddata);
let stationlist = jlmap3ddata.stationstandlist.list; let stationlist = jlmap3ddata.stationstandlist.list;
scope.stopsection.sort(compare("startx"))
let stopsections = []; let stopsections = [];
if((scope.stopsection.length%2)==0){
for(let i=0,leni =scope.stopsection.length;i<leni;i){
// stationsections.push(scope.stopsection[i]); for(let i=0,leni = stationlist.length;i<leni;i++){
// console.log(stationlist[i]);
let realstopsection ={ let realstopsection ={
//上行 //上行
topsection:null, topsection:null,
//下行 //下行
downsection:null, downsection:null,
topcode:null,
downcode:null,
posx:null,
}; };
if(scope.stopsection[i].starty > scope.stopsection[i+1].starty){ console.log(stationlist[i]);
realstopsection.topsection = scope.stopsection[i+1]; for(let j=0,lenj = scope.stopsection.length;j<lenj;j++){
realstopsection.downsection = scope.stopsection[i]; if(scope.stopsection[j].code == stationlist[i].direction2.section){
}else{ realstopsection.topsection = scope.stopsection[j];
realstopsection.topsection = scope.stopsection[i]; realstopsection.topcode = stationlist[i].direction2.section;
realstopsection.downsection = scope.stopsection[i+1];
} }
if(scope.stopsection[j].code == stationlist[i].direction1.section){
realstopsection.downsection = scope.stopsection[j];
realstopsection.downcode = stationlist[i].direction1.section;
}
}
realstopsection.posx =(realstopsection.topsection.startx + realstopsection.downsection.startx)/2;
stopsections.push(realstopsection); stopsections.push(realstopsection);
i=i+2;
} }
stopsections.sort(compare("posx"))
}else{
alert("erro stopsection length");
}
console.log(stopsections); console.log(stopsections);
// if((scope.stopsection.length%2)==0){
//
// for(let i=0,leni =scope.stopsection.length;i<leni;i){
// // stationsections.push(scope.stopsection[i]);
// let realstopsection ={
// //上行
// topsection:null,
// //下行
// downsection:null,
// };
// if(scope.stopsection[i].starty > scope.stopsection[i+1].starty){
// realstopsection.topsection = scope.stopsection[i+1];
// realstopsection.downsection = scope.stopsection[i];
// }else{
// realstopsection.topsection = scope.stopsection[i];
// realstopsection.downsection = scope.stopsection[i+1];
// }
// stopsections.push(realstopsection);
// i=i+2;
// }
//
// }else{
// alert("erro stopsection length");
// }
let leng1 = 0; let leng1 = 0;
let leng2 = 0; let leng2 = 0;
for(let i=0,leni=stopsections.length;i<leni;i++){ for(let i=0,leni=stopsections.length;i<leni;i++){
@ -195,6 +236,7 @@ export function SectionList() {
// console.log(stopsections[i].topsection.code); // console.log(stopsections[i].topsection.code);
// console.log(stopsections[i+1].topsection.code); // console.log(stopsections[i+1].topsection.code);
// console.log("---------------------------"); // console.log("---------------------------");
console.log(stopsections[i]);
let topresults = findnextsection(findarray1,scope.sections.datalist[stopsections[i].topsection.code].rsection,stopsections[i+1].topsection.code); let topresults = findnextsection(findarray1,scope.sections.datalist[stopsections[i].topsection.code].rsection,stopsections[i+1].topsection.code);
let downresults = findnextsection(findarray2,scope.sections.datalist[stopsections[i].downsection.code].rsection,stopsections[i+1].downsection.code); let downresults = findnextsection(findarray2,scope.sections.datalist[stopsections[i].downsection.code].rsection,stopsections[i+1].downsection.code);
let maxlengthfact = 0; let maxlengthfact = 0;
@ -239,8 +281,8 @@ export function SectionList() {
y:0, y:0,
z:stopsections[0].downsection.points[0].y z:stopsections[0].downsection.points[0].y
}; };
createsection(autorail,topstartpoint,stopsections[0].topsection.code,stopsections[1].topsection.code,45); createsection(autorail,topstartpoint,stopsections[0].topsection.code,stopsections[1].topsection.code,0);
createsection(autorail,downstartpoint,stopsections[0].downsection.code,stopsections[1].downsection.code,80); createsection(autorail,downstartpoint,stopsections[0].downsection.code,stopsections[1].downsection.code,34.8);
for(let i=1,leni=stopsections.length;i<leni;i++){ for(let i=1,leni=stopsections.length;i<leni;i++){
if(stopsections[i+1]){ if(stopsections[i+1]){
let topnextpoint = { let topnextpoint = {
@ -254,8 +296,8 @@ export function SectionList() {
y:0, y:0,
z:scope.sections.datalist[stopsections[i].downsection.code].mesh.position.z z:scope.sections.datalist[stopsections[i].downsection.code].mesh.position.z
}; };
createsection(autorail,topnextpoint,stopsections[i].topsection.code,stopsections[i+1].topsection.code,45); createsection(autorail,topnextpoint,stopsections[i].topsection.code,stopsections[i+1].topsection.code,0);
createsection(autorail,downnextpoint,stopsections[i].downsection.code,stopsections[i+1].downsection.code,80); createsection(autorail,downnextpoint,stopsections[i].downsection.code,stopsections[i+1].downsection.code,34.8);
} }
} }
let stations = jlmap3ddata.stationstandlist.list; let stations = jlmap3ddata.stationstandlist.list;
@ -336,10 +378,10 @@ export function SectionList() {
// console.log(data); // console.log(data);
// console.log(origin); // console.log(origin);
// console.log(data); // console.log(data);
console.log("============="); // console.log("=============");
console.log(type); // console.log(type);
console.log(origin); // console.log(origin);
console.log(data); // console.log(data);
let len = data.lengthFact; let len = data.lengthFact;
let testmesh2 = autorail.clone(true); let testmesh2 = autorail.clone(true);
@ -357,129 +399,158 @@ export function SectionList() {
scope.sectiongroup.add( testmesh2 ); scope.sectiongroup.add( testmesh2 );
data.mesh = testmesh2; data.mesh = testmesh2;
if(type == "right"){ if(type == "right"){
testmesh2.position.x = origin.rp.x + data.lengthFact/2; let dx = Math.abs(data.points[0].x - data.points[data.pointslength].x);
data.lp = {     let dy = Math.abs(data.points[0].y - data.points[data.pointslength].y);
x:origin.rp.x ,     let distance = Math.sqrt(Math.pow(dx,2)+Math.pow(dy,2));
y:0,
z:origin.rp.z
};
data.rp = {
x: origin.rp.x + data.lengthFact,
y:0,
z: origin.rp.z
};
if(data.iscur == "3"){ data.rp.x = (data.points[data.pointslength].x-data.points[0].x)*data.lengthFact/distance+origin.rp.x;
testmesh2.position.z = origin.mesh.position.z; data.rp.z = (data.points[data.pointslength].y-data.points[0].y)*data.lengthFact/distance+origin.rp.z;
}
if(data.iscur == "1"){ data.lp.x = origin.rp.x;
testmesh2.position.z = origin.rp.z - data.lengthFact/2; data.lp.z = origin.rp.z;
data.rp.z = origin.rp.z - data.lengthFact; let axix = new THREE.Vector3(1,0,0);
testmesh2.rotation.z = 0.218; let axixnow = new THREE.Vector3(data.rp.x-data.lp.x,0,data.rp.z-data.lp.z);
} let rotenum = axixnow.angleTo(axix);
if(data.iscur == "2"){ //不同坐标系方向值不同
testmesh2.position.z = origin.rp.z + data.lengthFact/2; if(data.points[0].y>data.points[data.pointslength].y){
data.rp.z = origin.rp.z + data.lengthFact; testmesh2.rotation.z = 0.2193;
testmesh2.rotation.z = -0.218; data.rp.x = data.lp.x+(data.lengthFact)*Math.cos(testmesh2.rotation.z);
data.rp.z = data.lp.z-(data.lengthFact)*Math.sin(testmesh2.rotation.z);
}else if(data.points[0].y<data.points[data.pointslength].y){
testmesh2.rotation.z = -0.2193;
data.rp.x = data.lp.x+(data.lengthFact)*Math.cos(testmesh2.rotation.z);
data.rp.z = data.lp.z-(data.lengthFact)*Math.sin(testmesh2.rotation.z);
}else{
data.rp.z = data.lp.z;
// testmesh2.rotation.z = rotenum;
} }
testmesh2.position.x = (data.lp.x + data.rp.x)/2;
testmesh2.position.z = (data.lp.z + data.rp.z)/2;
// if(data.iscur == "3"){
// testmesh2.position.z = origin.mesh.position.z;
// }
// if(data.iscur == "1"){
// testmesh2.position.z = origin.rp.z - data.lengthFact/2;
// data.rp.z = origin.rp.z - data.lengthFact;
// testmesh2.rotation.z = 0.2193;
// }
// if(data.iscur == "2"){
// testmesh2.position.z = origin.rp.z + data.lengthFact/2;
// data.rp.z = origin.rp.z + data.lengthFact;
// testmesh2.rotation.z = -0.2193;
// }
} }
if(type == "left"){ if(type == "left"){
testmesh2.position.x = origin.lp.x - data.lengthFact/2; let dx = Math.abs(data.points[0].x - data.points[data.pointslength].x);
data.lp = {     let dy = Math.abs(data.points[0].y - data.points[data.pointslength].y);
x:origin.lp.x - data.lengthFact,     let distance = Math.sqrt(Math.pow(dx,2)+Math.pow(dy,2));
y:0,
z:origin.lp.z data.lp.x = (data.points[0].x-data.points[data.pointslength].x)*data.lengthFact/distance+origin.lp.x;
}; data.lp.z = (data.points[0].y-data.points[data.pointslength].y)*data.lengthFact/distance+origin.lp.z;
data.rp = {
x: origin.lp.x, data.rp.x = origin.lp.x;
y:0, data.rp.z = origin.lp.z;
z: origin.lp.z
};
if(data.iscur == "3"){ let axix = new THREE.Vector3(1,0,0);
testmesh2.position.z = origin.mesh.position.z; let axixnow = new THREE.Vector3(data.rp.x-data.lp.x,0,data.rp.z-data.lp.z);
} let rotenum = axixnow.angleTo(axix);
if(data.iscur == "1"){ //不同坐标系方向值不同
testmesh2.position.z = origin.lp.z + data.lengthFact/2; if(data.points[0].y>data.points[data.pointslength].y){
data.lp.z = origin.lp.z + data.lengthFact; testmesh2.rotation.z = 0.2193;
testmesh2.rotation.z = 0.218; data.lp.x = data.rp.x - (data.lengthFact)*Math.cos(testmesh2.rotation.z);
} data.lp.z = data.rp.z + (data.lengthFact)*Math.sin(testmesh2.rotation.z);
if(data.iscur == "2"){ }else if(data.points[0].y<data.points[data.pointslength].y){
testmesh2.position.z = origin.lp.z - data.lengthFact/2; testmesh2.rotation.z = -0.2193;
data.lp.z = origin.lp.z + data.lengthFact; data.lp.x = data.rp.x - (data.lengthFact)*Math.cos(testmesh2.rotation.z);
testmesh2.rotation.z = -0.218; data.lp.z = data.rp.z + (data.lengthFact)*Math.sin(testmesh2.rotation.z);
}else{
data.lp.z = data.rp.z;
// testmesh2.rotation.z = rotenum;
} }
testmesh2.position.x = (data.rp.x + data.lp.x)/2;
testmesh2.position.z = (data.rp.z + data.lp.z)/2;
// if(data.iscur == "3"){
// testmesh2.position.z = origin.mesh.position.z;
// }
// if(data.iscur == "1"){
// testmesh2.position.z = origin.lp.z + data.lengthFact/2;
// data.lp.z = origin.lp.z + data.lengthFact;
// testmesh2.rotation.z = 0.2193;
// }
// if(data.iscur == "2"){
// testmesh2.position.z = origin.lp.z - data.lengthFact/2;
// data.lp.z = origin.lp.z + data.lengthFact;
// testmesh2.rotation.z = -0.2193;
// }
} }
// console.log(data.ctype); // console.log(data.ctype);
if(type == "cross"){ if(type == "cross"){
// console.log(data.ctype); // console.log(data.ctype);
if(data.ctype == "1"){ if(data.ctype == "1"||data.ctype == "2" ){
testmesh2.position.x = origin.lp.x - data.lengthFact/2; let dx = Math.abs(data.points[0].x - data.points[data.pointslength].x);
testmesh2.position.z = origin.lp.z - data.lengthFact/2;     let dy = Math.abs(data.points[0].y - data.points[data.pointslength].y);
testmesh2.rotation.z = -0.218;     let distance = Math.sqrt(Math.pow(dx,2)+Math.pow(dy,2));
data.lp = {
x:origin.lp.x - data.lengthFact, data.lp.x = (data.points[0].x-data.points[data.pointslength].x)*data.lengthFact/distance+origin.lp.x;
y:0, data.lp.z = (data.points[0].y-data.points[data.pointslength].y)*data.lengthFact/distance+origin.lp.z;
z:origin.lp.z - data.lengthFact/2,
}; data.rp.x = origin.lp.x;
data.rp = { data.rp.z = origin.lp.z;
x: origin.lp.x,
y:0,
z: origin.lp.z let axix = new THREE.Vector3(1,0,0);
}; let axixnow = new THREE.Vector3(data.rp.x-data.lp.x,0,data.rp.z-data.lp.z);
let rotenum = axixnow.angleTo(axix);
//不同坐标系方向值不同
if(data.points[0].y>data.points[data.pointslength].y){
testmesh2.rotation.z = 0.2193;
data.lp.x = data.rp.x - (data.lengthFact)*Math.cos(testmesh2.rotation.z);
data.lp.z = data.rp.z + (data.lengthFact)*Math.sin(testmesh2.rotation.z);
}else if(data.points[0].y<data.points[data.pointslength].y){
testmesh2.rotation.z = -0.2193;
data.lp.x = data.rp.x - (data.lengthFact)*Math.cos(testmesh2.rotation.z);
data.lp.z = data.rp.z + (data.lengthFact)*Math.sin(testmesh2.rotation.z);
}else{
data.lp.z = data.rp.z;
}
testmesh2.position.x = (data.rp.x + data.lp.x)/2;
testmesh2.position.z = (data.rp.z + data.lp.z)/2;
// testmesh2.rotation.z = ; // testmesh2.rotation.z = ;
} }
if(data.ctype == "2"){ if(data.ctype == "3" || data.ctype == "4"){
testmesh2.position.x = origin.lp.x - data.lengthFact/2; let dx = Math.abs(data.points[0].x - data.points[data.pointslength].x);
testmesh2.position.z = origin.lp.z + data.lengthFact/2;     let dy = Math.abs(data.points[0].y - data.points[data.pointslength].y);
testmesh2.rotation.z = 0.218;     let distance = Math.sqrt(Math.pow(dx,2)+Math.pow(dy,2));
data.lp = {
x:origin.lp.x - data.lengthFact, data.rp.x = (data.points[data.pointslength].x-data.points[0].x)*data.lengthFact/distance+origin.rp.x;
y:0, data.rp.z = (data.points[data.pointslength].y-data.points[0].y)*data.lengthFact/distance+origin.rp.z;
z:origin.lp.z + data.lengthFact/2,
}; data.lp.x = origin.rp.x;
data.rp = { data.lp.z = origin.rp.z;
x: origin.lp.x, let axix = new THREE.Vector3(1,0,0);
y:0, let axixnow = new THREE.Vector3(data.rp.x-data.lp.x,0,data.rp.z-data.lp.z);
z: origin.lp.z let rotenum = axixnow.angleTo(axix);
}; //不同坐标系方向值不同
// testmesh2.rotation.z = ; if(data.points[0].y>data.points[data.pointslength].y){
} testmesh2.rotation.z = 0.2193;
if(data.ctype == "3"){ data.rp.x = data.lp.x+(data.lengthFact)*Math.cos(testmesh2.rotation.z);
testmesh2.position.x = origin.rp.x + data.lengthFact/2; data.rp.z = data.lp.z-(data.lengthFact)*Math.sin(testmesh2.rotation.z);
testmesh2.position.z = origin.rp.z - data.lengthFact/2; }else if(data.points[0].y<data.points[data.pointslength].y){
testmesh2.rotation.z = 0.218; testmesh2.rotation.z = -0.2193;
data.lp = { data.rp.x = data.lp.x+(data.lengthFact)*Math.cos(testmesh2.rotation.z);
x:origin.rp.x, data.rp.z = data.lp.z-(data.lengthFact)*Math.sin(testmesh2.rotation.z);
y:0, }else{
z:origin.rp.z data.lp.z = data.rp.z;
};
data.rp = {
x: origin.rp.x + data.lengthFact,
y:0,
z: origin.rp.z - data.lengthFact/2
};
// testmesh2.rotation.z = ;
}
if(data.ctype == "4"){
testmesh2.position.x = origin.rp.x + data.lengthFact/2;
testmesh2.position.z = origin.rp.z + data.lengthFact/2;
testmesh2.rotation.z = -0.218;
data.lp = {
x:origin.rp.x,
y:0,
z:origin.rp.z
};
data.rp = {
x: origin.rp.x + data.lengthFact,
y:0,
z: origin.rp.z + data.lengthFact/2
};
// testmesh2.rotation.z = ;
} }
testmesh2.position.x = (data.lp.x + data.rp.x)/2;
testmesh2.position.z = (data.lp.z + data.rp.z)/2;
// testmesh2.rotation.z = ;
}
} }
} }
@ -534,6 +605,10 @@ export function SectionList() {
} }
function findnextsection(findarray,start,end){ function findnextsection(findarray,start,end){
// console.log("====================");
// console.log(start);
// console.log(end);
// console.log("====================");
if(scope.sections.datalist[start].code == end){ if(scope.sections.datalist[start].code == end){
return findarray; return findarray;
}else{ }else{
@ -541,7 +616,10 @@ export function SectionList() {
findarray.distance = findarray.distance + scope.sections.datalist[start].lengthFact; findarray.distance = findarray.distance + scope.sections.datalist[start].lengthFact;
// console.log(scope.sections.datalist[start]); // console.log(scope.sections.datalist[start]);
// console.log(scope.sections.datalist[start].code); // console.log(scope.sections.datalist[start].code);
// console.log(scope.sections.datalist[start]);
// return function(){
return findnextsection(findarray,scope.sections.datalist[start].rsection,end); return findnextsection(findarray,scope.sections.datalist[start].rsection,end);
// }
} }
} }
function compare(property){ function compare(property){
@ -1134,10 +1212,10 @@ export function SectionList() {
if(testmesh1.rotation.z != 0){ if(testmesh1.rotation.z != 0){
testmesh1.position.x = link.lp.x+suidao.offsetLeft*(len/lenfact)+ (link.rp.x-link.lp.x)*(len/lenfact)/2; 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){ if(link.lp.z > link.rp.z){
testmesh1.position.z = link.lp.y-suidao.offsetLeft*(len/lenfact) + (link.rp.y-link.lp.y)*(len/lenfact)/2; testmesh1.position.z = link.lp.z-suidao.offsetLeft*(len/lenfact) + (link.rp.z-link.lp.z)*(len/lenfact)/2;
}else{ }else{
testmesh1.position.z = link.lp.y+suidao.offsetLeft*(len/lenfact) + (link.rp.y-link.lp.y)*(len/lenfact)/2; testmesh1.position.z = link.lp.z+suidao.offsetLeft*(len/lenfact) + (link.rp.z-link.lp.z)*(len/lenfact)/2;
} }
}else{ }else{
testmesh1.position.x = link.lp.x+suidao.offsetLeft+len/2; testmesh1.position.x = link.lp.x+suidao.offsetLeft+len/2;

View File

@ -13,6 +13,7 @@ export function SignalList() {
this.initpromise = function(jlmap3ddata,data,scene,assetloader,netdata){ this.initpromise = function(jlmap3ddata,data,scene,assetloader,netdata){
return new Promise(function(resolve, reject){ return new Promise(function(resolve, reject){
scope.group.name = "signal"; scope.group.name = "signal";
// console.log(data);
//遍历信号数据 //遍历信号数据
let netsignal = null; let netsignal = null;
let haddata = false; let haddata = false;
@ -20,18 +21,18 @@ export function SignalList() {
netsignal = JSON.parse(netdata); netsignal = JSON.parse(netdata);
haddata = true; haddata = true;
} }
let linkdata = jlmap3ddata.linklist; let sectiondata = jlmap3ddata.sectionlist.sections.datalist;
for(let i=0;i<data.length;i++){
let newsignal = new SignalModel(data[i]);
let num; let num;
if(haddata == false){
for(let j=0;j<assetloader.modellist.length;j++){ for(let j=0;j<assetloader.modellist.length;j++){
if(assetloader.modellist[j].deviceType == "signal"){ if(assetloader.modellist[j].deviceType == "signal"){
num = j; num = j;
} }
} }
for(let i=0;i<data.length;i++){
let newsignal = new SignalModel(data[i]);
if(haddata == false){
let newmesh = assetloader.modellist[num].mesh.clone(true); let newmesh = assetloader.modellist[num].mesh.clone(true);
newmesh.name = assetloader.modellist[num].name; newmesh.name = assetloader.modellist[num].name;
@ -40,29 +41,36 @@ export function SignalList() {
for(let j=0;j<newmesh.children.length;j++){ for(let j=0;j<newmesh.children.length;j++){
newmesh.children[j].code = data[i].code; newmesh.children[j].code = data[i].code;
} }
let link = linkdata.linksgroup.getObjectByProperty("code",data[i].linkCode); let section = sectiondata[data[i].sectionCode];
let posx = null; let posx = null;
if(data[i].offset > link.lengthfact/2){ if(data[i].sectionOffset > section.lengthFact/2){
posx = link.position.x + data[i].offset - link.lengthfact/2-10; posx = section.mesh.position.x + data[i].sectionOffset - section.lengthFact/2;
}else{ }else{
posx = link.position.x - (link.lengthfact/2 - data[i].offset)+10; posx = section.mesh.position.x - (section.lengthFact/2 - data[i].sectionOffset);
} }
//根据线路方向修改信号灯位置 //根据线路方向修改信号灯位置
if(data[i].directionType == "01"){ if(data[i].right == false){
newmesh.position.set(posx,0,link.position.z-3); if(section.standTrack == true){
posx = posx - 7;
}
newmesh.position.set(posx,0,section.mesh.position.z-3);
newmesh.rotation.z = ( Math.PI / 2 ); newmesh.rotation.z = ( Math.PI / 2 );
}else if(data[i].directionType == "02"){ }else if(data[i].right == true){
newmesh.position.set(posx,0,link.position.z+3); if(section.standTrack == true){
posx = posx + 7;
}
newmesh.position.set(posx,0,section.mesh.position.z+3);
newmesh.rotation.z = ( - Math.PI / 2 ); newmesh.rotation.z = ( - Math.PI / 2 );
} }
newmesh.scale.x = 0.05; newmesh.scale.x = 0.05;
newmesh.scale.y = 0.05; newmesh.scale.y = 0.05;
newmesh.scale.z = 0.05; newmesh.scale.z = 0.05;
newmesh.offset = data[i].offset; newmesh.sectionOffset = data[i].sectionOffset;
newmest.linkCode = data[i].linkCode; newmesh.sectionCode = data[i].sectionCode;
newsignal.mesh = newmesh; newsignal.mesh = newmesh;
newsignal.offset = data[i].offset; newsignal.sectionOffset = data[i].sectionOffset;
newsignal.mesh.status = "01"; newsignal.mesh.status = "01";
scope.group.add(newsignal.mesh); scope.group.add(newsignal.mesh);
scope.list.push(newsignal); scope.list.push(newsignal);

View File

@ -43,6 +43,7 @@ export function StationStandList() {
// console.log(newstationstand.name); // console.log(newstationstand.name);
//向右上行 //向右上行
console.log(stationstanddata[j]);
if(stationstanddata[j].right == true){ if(stationstanddata[j].right == true){
newstationstand.direction1.position = stationstanddata[j].position; newstationstand.direction1.position = stationstanddata[j].position;
newstationstand.direction1.name = stationstanddata[j].code; newstationstand.direction1.name = stationstanddata[j].code;

View File

@ -1,13 +1,48 @@
import {SwitchModel} from '@/jlmap3d/model/SwitchModel.js'; import {SwitchModel} from '@/jlmap3d/edit/neweditmodel/SwitchModel.js';
export function SwitchList() { export function SwitchList() {
let scope = this;
this.type = "switchlist"; this.type = "switchlist";
this.list = null; this.switchgroup = new THREE.Group();
this.switchgroup.name = "switch";
this.init = function(){ this.switchs = {
datalist:[],
modellist:[]
};
this.initpromise = function(jlmap3ddata,data,scene,assetloader,netdata){
// console.log(jlmap3ddata);
scene.add( scope.switchgroup );
let sectiondata = jlmap3ddata.sectionlist.sections.datalist;
// console.log(sectiondata);
let num;
for(let j=0;j<assetloader.modellist.length;j++){
if(assetloader.modellist[j].deviceType == "autoswitch"){
num = j;
}
}
for(let i=0,leni = data.length;i<leni;i++){
let newswitch = {
code:data[i].code,
name:data[i].name,
pa:data[i].sectionACode,
pb:data[i].sectionBCode,
pc:data[i].sectionCCode
};
let autoswitch = assetloader.modellist[num].mesh.clone(true);
scope.switchgroup.add(autoswitch);
if(sectiondata[data[i].sectionACode].mesh.position.x >sectiondata[data[i].sectionBCode].mesh.position.x){
autoswitch.position.set(sectiondata[data[i].sectionACode].lp.x,0,sectiondata[data[i].sectionACode].lp.z);
autoswitch.rotation.z = Math.PI;
}else{
autoswitch.position.set(sectiondata[data[i].sectionACode].rp.x,0,sectiondata[data[i].sectionACode].rp.z);
}
}
} }
this.update = function(){ this.update = function(){

View File

@ -110,6 +110,15 @@ let defaultautosuidao = {
assetUrl:"../../static/model/auto/suidao.FBX" assetUrl:"../../static/model/auto/suidao.FBX"
} }
let autoswitch = {
id:"104",
name:"道岔",
deviceType:"autoswitch",
type:"fuzhou",
picUrl:"",
assetUrl:"../../static/model/auto/autoswitch.FBX"
}
let autoswitch1 = { let autoswitch1 = {
id:"102", id:"102",
name:"道岔1", name:"道岔1",
@ -243,6 +252,11 @@ export function AssetLoader(){
let defaultswitch2 = new AssetModel(autoswitch2); let defaultswitch2 = new AssetModel(autoswitch2);
scope.modellist.push(defaultswitch2); scope.modellist.push(defaultswitch2);
let autoswitchs = new AssetModel(autoswitch);
scope.modellist.push(autoswitchs);
fbxpromise(signal) fbxpromise(signal)
.then(function(data){ .then(function(data){
////console.log(data); ////console.log(data);
@ -268,6 +282,10 @@ export function AssetLoader(){
////console.log(data); ////console.log(data);
return fbxpromise(defaultswitch2); return fbxpromise(defaultswitch2);
}) })
.then(function(data){
////console.log(data);
return fbxpromise(autoswitchs);
})
.then(function(data){ .then(function(data){
////console.log(scope.modellist); ////console.log(scope.modellist);
resolve("loaderassets"); resolve("loaderassets");

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.