隧道,信号机自动部署测试

This commit is contained in:
sunzhenyu 2019-09-19 18:55:18 +08:00
parent c4e8bee27a
commit 3dfa7d6000
8 changed files with 236 additions and 151 deletions

View File

@ -81,6 +81,7 @@ export function Jlmap3ddata(mapid,scope){
jlmap3ddata.mapId = mapid; jlmap3ddata.mapId = mapid;
console.log(jlmap3ddata.mapId); console.log(jlmap3ddata.mapId);
//初始化轨道和道岔 暂时 //初始化轨道和道岔 暂时
jlmap3ddata.linklist = new LinkList();
jlmap3ddata.sectionlist = new SectionList(); jlmap3ddata.sectionlist = new SectionList();
jlmap3ddata.signallist = new SignalList(); jlmap3ddata.signallist = new SignalList();
//初始化站台 //初始化站台
@ -90,11 +91,15 @@ export function Jlmap3ddata(mapid,scope){
assetloader.assetinit(scene) assetloader.assetinit(scene)
.then(function(data){ .then(function(data){
//console.log(data); //console.log(data);
return jlmap3ddata.sectionlist.initpromise(mapdata.sectionList,mapdata.switchList,scene); return jlmap3ddata.linklist.initpromise(mapdata.linkList,scene,assetloader);
}) })
.then(function(data){ .then(function(data){
//console.log(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.signallist.initpromise(jlmap3ddata,mapdata.signalList,scene,assetloader);
}) })
.then(function(data){ .then(function(data){
//console.log(data); //console.log(data);
@ -106,7 +111,6 @@ export function Jlmap3ddata(mapid,scope){
}) })
.then(function(data){ .then(function(data){
//console.log(data); //console.log(data);
LinkList(mapdata.linkList,scene,assetloader);
loadingInstance.close(); loadingInstance.close();
}); });
//初始化信号 //初始化信号

View File

@ -1,8 +1,25 @@
export function LinkList(data,scene,assetloader){ export function LinkList(data){
let scope = this;
this.type = "linklist";
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");
});
}
function linkhelp(data,scene){
let groups = new THREE.Group(); let groups = new THREE.Group();
let linklist = [];
for(let i=0;i<data.length;i++){ for(let i=0;i<data.length;i++){
let lineGeometry = new THREE.Geometry();//生成几何体 let lineGeometry = new THREE.Geometry();//生成几何体
@ -22,36 +39,27 @@ export function LinkList(data,scene,assetloader){
line.distancey = data[i].rp.y-data[i].lp.y; line.distancey = data[i].rp.y-data[i].lp.y;
line.computeLineDistances();//不可或缺的,若无,则线段不能显示为虚线 line.computeLineDistances();//不可或缺的,若无,则线段不能显示为虚线
groups.add(line); groups.add(line);
groups.position.z = 2000;
linklist.push(line);
} }
groups.position.z = 2000;
scene.add(groups); scene.add(groups);
let linksgroup = new THREE.Group(); }
linksgroup.name = "link";
scene.add(linksgroup);
let suidaogroup = new THREE.Group();
suidaogroup.name = "suidao";
scene.add(suidaogroup);
linktest(data,scene);
// return linklist; // return linklist;
function linktest(data,scene){ function linktest(data,scene,assetloader){
console.log(assetloader.modellist);
let autorail = null; let autorail = null;
let autosuidao = null; let autosuidao = null;
for(let i=0;i<assetloader.modellist.length;i++){ for(let i=0;i<assetloader.modellist.length;i++){
if(assetloader.modellist[i].deviceType == "autorail"){ if(assetloader.modellist[i].deviceType == "autorail"){
autorail = assetloader.modellist[i].mesh.children[0]; autorail = assetloader.modellist[i].mesh.children[0];
} }
if(assetloader.modellist[i].deviceType == "autosuidao"){
autosuidao = assetloader.modellist[i].mesh.children[0];
} }
}
autosuidao.rotation.x = 0;
let rightlist = []; let rightlist = [];
let leftlist = []; let leftlist = [];
let count = autorail.geometry.attributes.position.count; let count = autorail.geometry.attributes.position.count;
@ -67,22 +75,6 @@ export function LinkList(data,scene,assetloader){
autorail.rightlist = rightlist; autorail.rightlist = rightlist;
autorail.leftlist = leftlist; autorail.leftlist = leftlist;
rightlist = [];
leftlist = [];
count = autosuidao.geometry.attributes.position.count;
for(let i=0;i<count;i++){
if(autosuidao.geometry.attributes.position.array[i*3] >0.49){
rightlist.push(i);
}
if(autosuidao.geometry.attributes.position.array[i*3] <-0.49){
leftlist.push(i);
}
}
autosuidao.rightlist = rightlist;
autosuidao.leftlist = leftlist;
console.log(autorail);
console.log(autosuidao);
let reallinks = []; let reallinks = [];
let testlink; let testlink;
@ -102,12 +94,9 @@ export function LinkList(data,scene,assetloader){
} }
} }
} }
buildmodel(startdata); buildmodel(startdata);
reallinks.push(startdata); reallinks.push(startdata);
data.splice(index,1); data.splice(index,1);
for(let i=0;i<reallinks.length;i++){ for(let i=0;i<reallinks.length;i++){
for(let j=0;j<data.length;j++){ for(let j=0;j<data.length;j++){
if(reallinks[i].leftFdCode && j>=0){ if(reallinks[i].leftFdCode && j>=0){
@ -150,31 +139,12 @@ export function LinkList(data,scene,assetloader){
} }
} }
function checklink(code,data){
if(code == data.leftFdCode){
}
if(code == data.leftSdCode){
}
if(code == data.rightFdCode){
}
if(code == data.rightSdCode){
}
}
function buildmodel(data,mdata,sx,direct){ function buildmodel(data,mdata,sx,direct){
console.log(data);
let len = data.lengthFact; let len = data.lengthFact;
// console.log(autorail);
// console.log(autosuidao);
let testmesh2 = autorail.clone(true); let testmesh2 = autorail.clone(true);
for(let i=0;i<autorail.rightlist.length;i++){ for(let i=0;i<autorail.rightlist.length;i++){
testmesh2.geometry.attributes.position.array[autorail.rightlist[i]*3] = len-20; testmesh2.geometry.attributes.position.array[autorail.rightlist[i]*3] = len-20.5;
testmesh2.geometry.attributes.uv.array[autorail.rightlist[i]*2] = testmesh2.geometry.attributes.position.array[0]-testmesh2.geometry.attributes.position.array[3]; 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(); let newrail = new THREE.BufferGeometry();
@ -184,22 +154,6 @@ export function LinkList(data,scene,assetloader){
testmesh2.geometry.attributes.uv.needsUpdate = true; testmesh2.geometry.attributes.uv.needsUpdate = true;
testmesh2.geometry.computeBoundingSphere(); testmesh2.geometry.computeBoundingSphere();
testmesh2.geometry.center(); testmesh2.geometry.center();
let testmesh1 = autosuidao.clone(true);
for(let i=0;i<autosuidao.rightlist.length;i++){
testmesh1.geometry.attributes.position.array[autosuidao.rightlist[i]*3] = len-20;
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();
// testmesh2.add(testmesh1);
// data.lp.y *= 10; // data.lp.y *= 10;
// data.rp.y *= 10; // data.rp.y *= 10;
@ -270,28 +224,18 @@ export function LinkList(data,scene,assetloader){
}else { }else {
testmesh2.rotation.z = -rotenum; testmesh2.rotation.z = -rotenum;
} }
} }
}else{ }else{
data.lp.x = data.lp.x; data.lp.x = data.lp.x;
data.rp.x = data.lp.x + data.lengthFact; data.rp.x = data.lp.x + data.lengthFact;
testmesh2.position.x = (data.lp.x + data.rp.x)/2; testmesh2.position.x = (data.lp.x + data.rp.x)/2;
testmesh2.position.z = (data.lp.y + data.rp.y)/2; testmesh2.position.z = (data.lp.y + data.rp.y)/2;
} }
// testmesh2.position.y = 10; // testmesh2.position.y = 10;
testmesh2.code = data.code; testmesh2.code = data.code;
testmesh1.position.x = testmesh2.position.x; testmesh2.name = data.name;
testmesh1.position.z = testmesh2.position.z; testmesh2.lengthfact = data.lengthFact;
testmesh1.rotation.x = -Math.PI/2; scope.linksgroup.add( testmesh2 );
testmesh1.rotation.z = testmesh2.rotation.z;
var box = new THREE.BoxHelper( testmesh2, 0xff0000 );
scene.add( box );
suidaogroup.add( testmesh1 );
linksgroup.add( testmesh2 );
} }
} }
} }

View File

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

View File

@ -16,9 +16,9 @@ export function SectionList() {
modellist:[] modellist:[]
}; };
this.initpromise = function(jlmap3ddata,assetloader,sectiondata,switchdata,scene){
this.initpromise = function (sectiondata,switchdata,scene){
return new Promise(function(resolve, reject){ return new Promise(function(resolve, reject){
let linkdata = jlmap3ddata.linklist;
//遍历区段 //遍历区段
for(let i=0;i<sectiondata.length;i++){ for(let i=0;i<sectiondata.length;i++){
if(sectiondata[i].type == "01"){ if(sectiondata[i].type == "01"){
@ -30,12 +30,15 @@ export function SectionList() {
newsection.index = i; newsection.index = i;
newsection.isStandTrack = sectiondata[i].isStandTrack; newsection.isStandTrack = sectiondata[i].isStandTrack;
newsection.type = sectiondata[i].type; 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.datalist.push(newsection);
scope.sections.modellist.push(""); // scope.sections.modellist.push("");
} }
} }
buildsuidao(linkdata,scope.sections,assetloader,scene);
//定义区分道岔组 //定义区分道岔组
let switchlist = []; let switchlist = [];
@ -72,21 +75,59 @@ export function SectionList() {
} }
} }
} }
//道岔贴图 //道岔贴图
//遍历道岔信息组合轨道 let switchmesh;
for(let i=0;i<switchlist.length;i++){ for(let i=0;i<assetloader.modellist.length;i++){
//道岔对象组 if(assetloader.modellist[i].deviceType == "switch"){
let newswitch = new SwitchModel(); switchmesh = assetloader.modellist[i].mesh;
newswitch.name = switchlist[i].code;
newswitch.code = switchlist[i].code;
newswitch.index = i;
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 = switchmesh.clone(true);
// if(sectionA.position.x>sectionB.position.x){
// if(sectionA.position.z>sectionC.position.z){
// testswitch.rotation.y = 0;
// }else{
// testswitch.rotation.y = Math.PI;
// }
// }else{
// if(sectionA.position.z>sectionC.position.z){
// testswitch.rotation.y = 0;
// }else{
// testswitch.rotation.y = Math.PI;
// }
// }
// testswitch.position.x = (sectionA.position.x+sectionB.position.x)/2;
// testswitch.position.y = 0;
// testswitch.position.z = sectionA.position.z;
// console.log("----------");
// console.log(testswitch.position);
// console.log(sectionA.position);
// console.log(sectionB.position);
// console.log(sectionC.position);
// console.log("---------");
// scene.add(testswitch);
// //道岔对象组
// 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("");
// }
resolve("loadersection"); resolve("loadersection");
}); });
@ -108,7 +149,7 @@ export function SectionList() {
newsection.type = sectiondata[i].type; newsection.type = sectiondata[i].type;
scope.sections.datalist.push(newsection); scope.sections.datalist.push(newsection);
scope.sections.modellist.push(""); // scope.sections.modellist.push("");
} }
} }
@ -150,6 +191,7 @@ export function SectionList() {
} }
//道岔贴图 //道岔贴图
//遍历道岔信息组合轨道 //遍历道岔信息组合轨道
for(let i=0;i<switchlist.length;i++){ for(let i=0;i<switchlist.length;i++){
//道岔对象组 //道岔对象组
@ -163,9 +205,78 @@ export function SectionList() {
scope.switchs.datalist.push(newswitch); scope.switchs.datalist.push(newswitch);
scope.switchs.modellist.push(""); scope.switchs.modellist.push("");
} }
} }
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 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] <-7){
leftlist.push(i);
}
}
autosuidao.rightlist = rightlist;
autosuidao.leftlist = leftlist;
// 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 offset = suidao.offsetLeft + len/2;
let lenfact = link.lengthfact;
if(offset<=(link.lengthfact/2)){
testmesh1.position.x = -(lenfact/2-offset);
}else{
testmesh1.position.x = offset -lenfact/2;
}
// 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;
scope.sections.modellist.push(testmesh1);
}
}
this.update = function(){ this.update = function(){
} }

View File

@ -10,7 +10,7 @@ export function SignalList() {
this.group = new THREE.Group(); 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){ return new Promise(function(resolve, reject){
scope.group.name = "signal"; scope.group.name = "signal";
//遍历信号数据 //遍历信号数据
@ -20,7 +20,7 @@ export function SignalList() {
netsignal = JSON.parse(netdata); netsignal = JSON.parse(netdata);
haddata = true; haddata = true;
} }
let linkdata = jlmap3ddata.linklist;
for(let i=0;i<data.length;i++){ for(let i=0;i<data.length;i++){
let newsignal = new SignalModel(data[i]); let newsignal = new SignalModel(data[i]);
@ -40,16 +40,25 @@ 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 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"){ 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 ); newmesh.rotation.z = ( Math.PI / 2 );
}else if(data[i].directionType == "02"){ }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.rotation.z = ( - Math.PI / 2 );
} }
newmesh.scale.x = 0.05;
newmesh.scale.y = 0.05;
newmesh.scale.z = 0.05;
newsignal.mesh = newmesh; newsignal.mesh = newmesh;
newsignal.mesh.status = "01"; newsignal.mesh.status = "01";
scope.group.add(newsignal.mesh); scope.group.add(newsignal.mesh);

View File

@ -78,6 +78,15 @@ let defaultautosuidao = {
assetUrl:"../../static/model/auto/suidao.FBX" assetUrl:"../../static/model/auto/suidao.FBX"
} }
let testswitch = {
id:"11",
name:"道岔",
deviceType:"switch",
type:"fuzhou",
picUrl:"",
assetUrl:"../../static/model/auto/testdaocha.FBX"
}
export function AssetLoader(){ export function AssetLoader(){
let scope = this; let scope = this;
@ -174,6 +183,9 @@ export function AssetLoader(){
let autosuidao = new AssetModel(defaultautosuidao); let autosuidao = new AssetModel(defaultautosuidao);
scope.modellist.push(autosuidao); scope.modellist.push(autosuidao);
let defaultmodel4 = new AssetModel(testswitch);
scope.modellist.push(defaultmodel4);
fbxpromise(signal) fbxpromise(signal)
.then(function(data){ .then(function(data){
////console.log(data); ////console.log(data);
@ -191,6 +203,10 @@ export function AssetLoader(){
////console.log(data); ////console.log(data);
return fbxpromise(autosuidao); return fbxpromise(autosuidao);
}) })
.then(function(data){
////console.log(data);
return fbxpromise(defaultmodel4);
})
.then(function(data){ .then(function(data){
////console.log(scope.modellist); ////console.log(scope.modellist);
resolve("loaderassets"); resolve("loaderassets");

View File

@ -2,8 +2,8 @@
export function getBaseUrl() { export function getBaseUrl() {
let BASE_API; let BASE_API;
if (process.env.NODE_ENV === 'development') { if (process.env.NODE_ENV === 'development') {
BASE_API = 'https://joylink.club/jlcloud'; // BASE_API = 'https://joylink.club/jlcloud';
// BASE_API = 'https://test.joylink.club/jlcloud'; BASE_API = 'https://test.joylink.club/jlcloud';
// BASE_API = 'http://192.168.3.5:9000'; // 袁琪 // BASE_API = 'http://192.168.3.5:9000'; // 袁琪
// BASE_API = 'http://192.168.3.6:9000'; // 旭强 // BASE_API = 'http://192.168.3.6:9000'; // 旭强
// BASE_API = 'http://192.168.3.41:9000'; // 王兴杰 // BASE_API = 'http://192.168.3.41:9000'; // 王兴杰

Binary file not shown.