修改编辑器轨道匹配逻辑

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

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/Jlmap3dnewdata';
//操作管理器
import { Actionmanage } from '@/jlmap3d/edit/actionmanage';

View File

@ -42,7 +42,7 @@ export function SectionList() {
autorail.leftlist = leftlist;
return new Promise(function(resolve, reject){
scene.add(scope.sectiondata);
// scene.add(scope.sectiondata);
scene.add(scope.sectiongroup);
@ -63,7 +63,18 @@ export function SectionList() {
newsection.lsection = sectiondata[i].leftSectionCode;
newsection.points = sectiondata[i].points;
newsection.pointslength = sectiondata[i].points.length-1;
newsection.standTrack = sectiondata[i].standTrack;
newsection.endbuild = false;
newsection.rp = {
x:0,
y:0,
z:0
};
newsection.lp = {
x:0,
y:0,
z:0
};
scope.sections.datalist[sectiondata[i].code] = newsection;
// console.log("-----------------------");
@ -71,13 +82,13 @@ export function SectionList() {
// if(sectiondata[i].code == "T285"){
// console.log(sectiondata[i]);
// }
if(sectiondata[i].points[0].y > sectiondata[i].points[sectiondata[i].points.length-1].y){
newsection.iscur = "1";
}else if(sectiondata[i].points[0].y < sectiondata[i].points[sectiondata[i].points.length-1].y){
newsection.iscur = "2";
}else{
newsection.iscur = "3";
}
// if(sectiondata[i].points[0].y > sectiondata[i].points[sectiondata[i].points.length-1].y){
// newsection.iscur = "1";
// }else if(sectiondata[i].points[0].y < sectiondata[i].points[sectiondata[i].points.length-1].y){
// newsection.iscur = "2";
// }else{
// newsection.iscur = "3";
// }
if(sectiondata[i].standTrack == true){
// console.log(sectiondata[i].code);
sectiondata[i].startx = sectiondata[i].points[0].x;
@ -87,6 +98,7 @@ export function SectionList() {
// sections.modellist.push("");
}
}
//连接区段
for(let i=0;i<switchdata.length;i++){
let acode = switchdata[i].sectionACode;
@ -103,7 +115,7 @@ export function SectionList() {
// console.log(cposx);
// console.log("----------------");
if(aposx > cposx){
if(aposy > cposy){
if(aposy < cposy){
// ——A
// /C
scope.sections.datalist[ccode].ctype = 1;
@ -113,7 +125,7 @@ export function SectionList() {
scope.sections.datalist[ccode].ctype = 2;
}
}else{
if(aposy > cposy){
if(aposy < cposy){
// A——
// \C
scope.sections.datalist[ccode].ctype = 3;
@ -147,38 +159,67 @@ export function SectionList() {
console.log(scope.sections.datalist);
console.log(scope.stopsection);
console.log(jlmap3ddata);
// console.log(scope.stopsection);
// console.log(jlmap3ddata);
let stationlist = jlmap3ddata.stationstandlist.list;
scope.stopsection.sort(compare("startx"))
let 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];
for(let i=0,leni = stationlist.length;i<leni;i++){
// console.log(stationlist[i]);
let realstopsection ={
//上行
topsection:null,
//下行
downsection:null,
topcode:null,
downcode:null,
posx:null,
};
console.log(stationlist[i]);
for(let j=0,lenj = scope.stopsection.length;j<lenj;j++){
if(scope.stopsection[j].code == stationlist[i].direction2.section){
realstopsection.topsection = scope.stopsection[j];
realstopsection.topcode = stationlist[i].direction2.section;
}
if(scope.stopsection[j].code == stationlist[i].direction1.section){
realstopsection.downsection = scope.stopsection[j];
realstopsection.downcode = stationlist[i].direction1.section;
}
stopsections.push(realstopsection);
i=i+2;
}
realstopsection.posx =(realstopsection.topsection.startx + realstopsection.downsection.startx)/2;
}else{
alert("erro stopsection length");
stopsections.push(realstopsection);
}
stopsections.sort(compare("posx"))
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 leng2 = 0;
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+1].topsection.code);
// console.log("---------------------------");
console.log(stopsections[i]);
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 maxlengthfact = 0;
@ -239,8 +281,8 @@ export function SectionList() {
y:0,
z:stopsections[0].downsection.points[0].y
};
createsection(autorail,topstartpoint,stopsections[0].topsection.code,stopsections[1].topsection.code,45);
createsection(autorail,downstartpoint,stopsections[0].downsection.code,stopsections[1].downsection.code,80);
createsection(autorail,topstartpoint,stopsections[0].topsection.code,stopsections[1].topsection.code,0);
createsection(autorail,downstartpoint,stopsections[0].downsection.code,stopsections[1].downsection.code,34.8);
for(let i=1,leni=stopsections.length;i<leni;i++){
if(stopsections[i+1]){
let topnextpoint = {
@ -254,8 +296,8 @@ export function SectionList() {
y:0,
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,downnextpoint,stopsections[i].downsection.code,stopsections[i+1].downsection.code,80);
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,34.8);
}
}
let stations = jlmap3ddata.stationstandlist.list;
@ -336,10 +378,10 @@ export function SectionList() {
// console.log(data);
// console.log(origin);
// console.log(data);
console.log("=============");
console.log(type);
console.log(origin);
console.log(data);
// console.log("=============");
// console.log(type);
// console.log(origin);
// console.log(data);
let len = data.lengthFact;
let testmesh2 = autorail.clone(true);
@ -357,129 +399,158 @@ export function SectionList() {
scope.sectiongroup.add( testmesh2 );
data.mesh = testmesh2;
if(type == "right"){
testmesh2.position.x = origin.rp.x + data.lengthFact/2;
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
};
let dx = Math.abs(data.points[0].x - data.points[data.pointslength].x);
    let dy = Math.abs(data.points[0].y - data.points[data.pointslength].y);
    let distance = Math.sqrt(Math.pow(dx,2)+Math.pow(dy,2));
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.218;
}
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.218;
data.rp.x = (data.points[data.pointslength].x-data.points[0].x)*data.lengthFact/distance+origin.rp.x;
data.rp.z = (data.points[data.pointslength].y-data.points[0].y)*data.lengthFact/distance+origin.rp.z;
data.lp.x = origin.rp.x;
data.lp.z = origin.rp.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.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"){
testmesh2.position.x = origin.lp.x - data.lengthFact/2;
data.lp = {
x:origin.lp.x - data.lengthFact,
y:0,
z:origin.lp.z
};
data.rp = {
x: origin.lp.x,
y:0,
z: origin.lp.z
};
let dx = Math.abs(data.points[0].x - data.points[data.pointslength].x);
    let dy = Math.abs(data.points[0].y - data.points[data.pointslength].y);
    let distance = Math.sqrt(Math.pow(dx,2)+Math.pow(dy,2));
data.lp.x = (data.points[0].x-data.points[data.pointslength].x)*data.lengthFact/distance+origin.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.z = origin.lp.z;
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.218;
}
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.218;
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.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);
if(type == "cross"){
// console.log(data.ctype);
if(data.ctype == "1"){
testmesh2.position.x = origin.lp.x - data.lengthFact/2;
testmesh2.position.z = origin.lp.z - data.lengthFact/2;
testmesh2.rotation.z = -0.218;
data.lp = {
x:origin.lp.x - data.lengthFact,
y:0,
z:origin.lp.z - data.lengthFact/2,
};
data.rp = {
x: origin.lp.x,
y:0,
z: origin.lp.z
};
// testmesh2.rotation.z = ;
}
if(data.ctype == "2"){
testmesh2.position.x = origin.lp.x - data.lengthFact/2;
testmesh2.position.z = origin.lp.z + data.lengthFact/2;
testmesh2.rotation.z = 0.218;
data.lp = {
x:origin.lp.x - data.lengthFact,
y:0,
z:origin.lp.z + data.lengthFact/2,
};
data.rp = {
x: origin.lp.x,
y:0,
z: origin.lp.z
};
// testmesh2.rotation.z = ;
}
if(data.ctype == "3"){
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 = ;
}
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 = ;
}
if(data.ctype == "1"||data.ctype == "2" ){
let dx = Math.abs(data.points[0].x - data.points[data.pointslength].x);
    let dy = Math.abs(data.points[0].y - data.points[data.pointslength].y);
    let distance = Math.sqrt(Math.pow(dx,2)+Math.pow(dy,2));
data.lp.x = (data.points[0].x-data.points[data.pointslength].x)*data.lengthFact/distance+origin.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.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 = ;
}
if(data.ctype == "3" || data.ctype == "4"){
let dx = Math.abs(data.points[0].x - data.points[data.pointslength].x);
    let dy = Math.abs(data.points[0].y - data.points[data.pointslength].y);
    let distance = Math.sqrt(Math.pow(dx,2)+Math.pow(dy,2));
data.rp.x = (data.points[data.pointslength].x-data.points[0].x)*data.lengthFact/distance+origin.rp.x;
data.rp.z = (data.points[data.pointslength].y-data.points[0].y)*data.lengthFact/distance+origin.rp.z;
data.lp.x = origin.rp.x;
data.lp.z = origin.rp.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.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.lp.z = data.rp.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){
// console.log("====================");
// console.log(start);
// console.log(end);
// console.log("====================");
if(scope.sections.datalist[start].code == end){
return findarray;
}else{
@ -541,7 +616,10 @@ export function SectionList() {
findarray.distance = findarray.distance + scope.sections.datalist[start].lengthFact;
// console.log(scope.sections.datalist[start]);
// console.log(scope.sections.datalist[start].code);
return findnextsection(findarray,scope.sections.datalist[start].rsection,end);
// console.log(scope.sections.datalist[start]);
// return function(){
return findnextsection(findarray,scope.sections.datalist[start].rsection,end);
// }
}
}
function compare(property){
@ -1134,10 +1212,10 @@ export function SectionList() {
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;
if(link.lp.z > link.rp.z){
testmesh1.position.z = link.lp.z-suidao.offsetLeft*(len/lenfact) + (link.rp.z-link.lp.z)*(len/lenfact)/2;
}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{
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){
return new Promise(function(resolve, reject){
scope.group.name = "signal";
// console.log(data);
//遍历信号数据
let netsignal = null;
let haddata = false;
@ -20,18 +21,18 @@ export function SignalList() {
netsignal = JSON.parse(netdata);
haddata = true;
}
let linkdata = jlmap3ddata.linklist;
let sectiondata = jlmap3ddata.sectionlist.sections.datalist;
let num;
for(let j=0;j<assetloader.modellist.length;j++){
if(assetloader.modellist[j].deviceType == "signal"){
num = j;
}
}
for(let i=0;i<data.length;i++){
let newsignal = new SignalModel(data[i]);
let num;
if(haddata == false){
for(let j=0;j<assetloader.modellist.length;j++){
if(assetloader.modellist[j].deviceType == "signal"){
num = j;
}
}
if(haddata == false){
let newmesh = assetloader.modellist[num].mesh.clone(true);
newmesh.name = assetloader.modellist[num].name;
@ -40,29 +41,36 @@ 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 section = sectiondata[data[i].sectionCode];
let posx = null;
if(data[i].offset > link.lengthfact/2){
posx = link.position.x + data[i].offset - link.lengthfact/2-10;
if(data[i].sectionOffset > section.lengthFact/2){
posx = section.mesh.position.x + data[i].sectionOffset - section.lengthFact/2;
}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"){
newmesh.position.set(posx,0,link.position.z-3);
if(data[i].right == false){
if(section.standTrack == true){
posx = posx - 7;
}
newmesh.position.set(posx,0,section.mesh.position.z-3);
newmesh.rotation.z = ( Math.PI / 2 );
}else if(data[i].directionType == "02"){
newmesh.position.set(posx,0,link.position.z+3);
}else if(data[i].right == true){
if(section.standTrack == true){
posx = posx + 7;
}
newmesh.position.set(posx,0,section.mesh.position.z+3);
newmesh.rotation.z = ( - Math.PI / 2 );
}
newmesh.scale.x = 0.05;
newmesh.scale.y = 0.05;
newmesh.scale.z = 0.05;
newmesh.offset = data[i].offset;
newmest.linkCode = data[i].linkCode;
newmesh.sectionOffset = data[i].sectionOffset;
newmesh.sectionCode = data[i].sectionCode;
newsignal.mesh = newmesh;
newsignal.offset = data[i].offset;
newsignal.sectionOffset = data[i].sectionOffset;
newsignal.mesh.status = "01";
scope.group.add(newsignal.mesh);
scope.list.push(newsignal);

View File

@ -43,6 +43,7 @@ export function StationStandList() {
// console.log(newstationstand.name);
//向右上行
console.log(stationstanddata[j]);
if(stationstanddata[j].right == true){
newstationstand.direction1.position = stationstanddata[j].position;
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() {
let scope = this;
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(){

View File

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

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.