修改区段坐标,增加道岔,信号机,站台位置
This commit is contained in:
parent
3dfa7d6000
commit
103929b23f
@ -103,7 +103,7 @@ export function Jlmap3ddata(mapid,scope){
|
||||
})
|
||||
.then(function(data){
|
||||
//console.log(data);
|
||||
return jlmap3ddata.stationstandlist.initpromise(mapdata.stationList,mapdata.stationStandList,scene,assetloader);
|
||||
return jlmap3ddata.stationstandlist.initpromise(jlmap3ddata,mapdata.stationList,mapdata.stationStandList,scene,assetloader);
|
||||
})
|
||||
.then(function(data){
|
||||
//console.log(data);
|
||||
|
@ -234,6 +234,8 @@ function linkhelp(data,scene){
|
||||
// testmesh2.position.y = 10;
|
||||
testmesh2.code = data.code;
|
||||
testmesh2.name = data.name;
|
||||
testmesh2.lp = data.lp;
|
||||
testmesh2.rp = data.rp;
|
||||
testmesh2.lengthfact = data.lengthFact;
|
||||
scope.linksgroup.add( testmesh2 );
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ export function SectionList() {
|
||||
datalist:[],
|
||||
modellist:[]
|
||||
};
|
||||
this.standtrack = [];
|
||||
|
||||
this.initpromise = function(jlmap3ddata,assetloader,sectiondata,switchdata,scene){
|
||||
return new Promise(function(resolve, reject){
|
||||
@ -29,6 +30,7 @@ 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;
|
||||
@ -78,11 +80,50 @@ export function SectionList() {
|
||||
//道岔贴图
|
||||
let switchmesh;
|
||||
for(let i=0;i<assetloader.modellist.length;i++){
|
||||
if(assetloader.modellist[i].deviceType == "switch"){
|
||||
if(assetloader.modellist[i].deviceType == "autoswitch"){
|
||||
switchmesh = assetloader.modellist[i].mesh;
|
||||
}
|
||||
}
|
||||
|
||||
//遍历道岔信息组合轨道
|
||||
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 = switchmesh.clone(true);
|
||||
sectionA.matrixAutoUpdate = false;
|
||||
let switchposx = sectionA.matrixWorld.elements[12];
|
||||
let switchposz = sectionA.matrixWorld.elements[14];
|
||||
|
||||
if(sectionA.position.x>sectionB.position.x){
|
||||
testswitch.rotation.y = Math.PI;
|
||||
|
||||
// if(sectionA.position.z>sectionC.position.z){
|
||||
// }else{
|
||||
// }
|
||||
|
||||
}else{
|
||||
testswitch.rotation.y = 0;
|
||||
|
||||
// if(sectionA.position.z>sectionC.position.z){
|
||||
// }else{
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
testswitch.position.x = switchposx;
|
||||
testswitch.position.y = 0;
|
||||
testswitch.position.z = switchposz;
|
||||
scene.add(testswitch);
|
||||
}
|
||||
// for(let i=0;i<switchlist.length;i++){
|
||||
// let sectionA,sectionB,sectionC;
|
||||
// for(let j=0;j<scope.sections.modellist.length;j++){
|
||||
@ -217,19 +258,28 @@ export function SectionList() {
|
||||
|
||||
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);
|
||||
@ -243,6 +293,7 @@ export function SectionList() {
|
||||
// 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;
|
||||
@ -255,26 +306,48 @@ export function SectionList() {
|
||||
testmesh1.geometry.attributes.uv.needsUpdate = true;
|
||||
testmesh1.geometry.computeBoundingSphere();
|
||||
testmesh1.geometry.center();
|
||||
let offset = suidao.offsetLeft + len/2;
|
||||
let lenfact = link.lengthfact;
|
||||
if(offset<=(link.lengthfact/2)){
|
||||
testmesh1.position.x = -(lenfact/2-offset);
|
||||
|
||||
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 = offset -lenfact/2;
|
||||
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;
|
||||
|
||||
|
||||
link.add(testmesh1);
|
||||
testmesh1.code = suidaodata.datalist[i].code;
|
||||
testmesh1.name = suidaodata.datalist[i].code;
|
||||
testmesh1.position.z = 3.5;
|
||||
testmesh1.position.y = 0;
|
||||
testmesh1.rotation.x = 0;
|
||||
// testmesh1.position.z = link.position.z;
|
||||
testmesh1.relStandCode = suidaodata.datalist[i].relStandCode;
|
||||
testmesh1.stationCode = suidaodata.datalist[i].stationCode;
|
||||
testmesh1.rightpoint = autosuidao.rightpoint;
|
||||
testmesh1.leftpoint = autosuidao.leftpoint;
|
||||
if(suidaodata.datalist[i].isStandTrack == false){
|
||||
scene.add(testmesh1);
|
||||
|
||||
}else{
|
||||
scope.standtrack.push(testmesh1);
|
||||
}
|
||||
|
||||
|
||||
scope.sections.modellist.push(testmesh1);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
this.update = function(){
|
||||
|
@ -12,7 +12,7 @@ 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;
|
||||
@ -21,7 +21,6 @@ export function StationStandList() {
|
||||
netstand = JSON.parse(netdata);
|
||||
haddata = true;
|
||||
}
|
||||
|
||||
scope.group.name = "station";
|
||||
scene.add(scope.group);
|
||||
//遍历车站数据
|
||||
@ -69,7 +68,6 @@ export function StationStandList() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
scope.list[i].mesh = assetloader.modellist[num].mesh.clone(true);
|
||||
|
||||
scope.list[i].uuid = assetloader.modellist[num].uuid;
|
||||
@ -80,8 +78,20 @@ 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]);
|
||||
}
|
||||
}
|
||||
console.log(standsection);
|
||||
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} );
|
||||
|
@ -81,7 +81,7 @@ let defaultautosuidao = {
|
||||
let testswitch = {
|
||||
id:"11",
|
||||
name:"道岔",
|
||||
deviceType:"switch",
|
||||
deviceType:"autoswitch",
|
||||
type:"fuzhou",
|
||||
picUrl:"",
|
||||
assetUrl:"../../static/model/auto/testdaocha.FBX"
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user