Merge branch 'test' of https://git.code.tencent.com/lian-cbtc/jl-client into test
This commit is contained in:
commit
fa7eefbeba
@ -1,196 +0,0 @@
|
||||
import { getPublishMapDetail,getMapDetail,set3dMapData,get3dMapData } from '@/api/jlmap3d/load3ddata';
|
||||
|
||||
//原始信息obj化提供给三维建模
|
||||
import {SetObj} from '@/jlmap3d/edit/utils/SetObj.js';
|
||||
//componnent
|
||||
import {SectionList} from '@/jlmap3d/edit/editmodel/SectionList.js';
|
||||
import {SignalList} from '@/jlmap3d/edit/editmodel/SignalList.js';
|
||||
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';
|
||||
|
||||
import axios from 'axios';
|
||||
import {getmodels} from '@/jlmap3d/edit/connect/getmodels';
|
||||
import { Loading } from 'element-ui';
|
||||
// import {SwitchModel} from '@/jlmap3d/model/SwitchModel.js';
|
||||
|
||||
export function Jlmap3ddata(mapid,scope){
|
||||
let editmapid = mapid;
|
||||
let scene = scope.scene;
|
||||
let jlmap3ddata = scope.mapdata;
|
||||
let assetloader = scope.assetloader;
|
||||
let loadingInstance = Loading.service({ fullscreen: true });
|
||||
get3dMapData(editmapid).then(data => {
|
||||
//console.log(data);
|
||||
if(data.code == "200"){
|
||||
//console.log("数据存在");
|
||||
let isSection = false;
|
||||
//console.log(data.data);
|
||||
if(data.data.assets){
|
||||
let assets = JSON.parse(data.data.assets);
|
||||
for(let i=0;i<assets.length;i++){
|
||||
if(assets[i].deviceType == "mapSection"){
|
||||
isSection = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(isSection == true){
|
||||
initobj(editmapid,data.data.id);
|
||||
//init3d(editmapid,data.data);
|
||||
}else{
|
||||
// console.log(editmapid);
|
||||
// console.log(data.data.id);
|
||||
init3d(editmapid,data.data);
|
||||
// initobj(editmapid,data.data.id);
|
||||
}
|
||||
|
||||
}
|
||||
}).catch(error => {
|
||||
//console.log(error);
|
||||
if(error.code == "30001"){
|
||||
//console.log("没有三维数据");
|
||||
let params = {mapId:editmapid};
|
||||
|
||||
set3dMapData(params).then(data => {
|
||||
if(data.code == "200"){
|
||||
//console.log("创建三维数据成功");
|
||||
// console.log(data);
|
||||
initobj(editmapid,data.data.id);
|
||||
|
||||
}
|
||||
}).catch(error => {
|
||||
//console.log(error);
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
function initobj(mapid,data3did){
|
||||
getMapDetail(mapid).then(data => {
|
||||
let mapdata = data.data;
|
||||
//console.log(data3did);
|
||||
jlmap3ddata.id = data3did;
|
||||
jlmap3ddata.mapId = 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.linklist.initpromise(mapdata.linkList,scene,assetloader);
|
||||
})
|
||||
.then(function(data){
|
||||
//console.log(data);
|
||||
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){
|
||||
//console.log(data);
|
||||
return jlmap3ddata.stationstandlist.initpromise(jlmap3ddata,mapdata.stationList,mapdata.stationStandList,scene,assetloader);
|
||||
})
|
||||
.then(function(data){
|
||||
//console.log(data);
|
||||
return jlmap3ddata.trainlisttest.initpromise(mapdata.trainList,scene,assetloader);
|
||||
})
|
||||
.then(function(data){
|
||||
//console.log(data);
|
||||
loadingInstance.close();
|
||||
});
|
||||
//初始化信号
|
||||
//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.linklist = new LinkList();
|
||||
//初始化轨道和道岔 暂时
|
||||
jlmap3ddata.sectionlist = new SectionList();
|
||||
jlmap3ddata.signallist = new SignalList();
|
||||
//初始化站台
|
||||
jlmap3ddata.stationstandlist = new StationStandList();
|
||||
//初始化测试列车
|
||||
jlmap3ddata.trainlisttest = new TrainListTest();
|
||||
|
||||
jlmap3ddata.raillist = 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(mapdata);
|
||||
assetloader.setmodellist(netdata.assets,5);
|
||||
assetloader.assetpromise(scene)
|
||||
.then(function(data){
|
||||
//console.log(data);
|
||||
return jlmap3ddata.linklist.loadpromise(loaderdata.link,mapdata.linkList,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){
|
||||
return jlmap3ddata.sectionlist.sectionpromise(loaderdata.link,mapdata.linkList,mapdata.sectionList,switchdata,standsdata,scene);
|
||||
})
|
||||
.then(function(data){
|
||||
//console.log(data);
|
||||
return jlmap3ddata.trainlisttest.initpromise(mapdata.trainList,scene,assetloader,"0");
|
||||
})
|
||||
// .then(function(data){
|
||||
// //console.log(data);
|
||||
// return jlmap3ddata.realsectionlist.loadpromise(jlmap3ddata,scene,assetloader);
|
||||
// })
|
||||
.then(function(data){
|
||||
//console.log(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);
|
||||
scope.assetloader.modellist[mn].mesh.name = "suidao";
|
||||
console.log(scope.assetloader.modellist[mn].mesh);
|
||||
scene.add(scope.assetloader.modellist[mn].mesh);
|
||||
}
|
||||
|
||||
}
|
||||
loadingInstance.close();
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,190 +0,0 @@
|
||||
import { getPublishMapDetail,getMapDetail,set3dMapData,get3dMapData } from '@/api/jlmap3d/load3ddata';
|
||||
|
||||
//原始信息obj化提供给三维建模
|
||||
import {SetObj} from '@/jlmap3d/edit/utils/SetObj.js';
|
||||
//componnent
|
||||
import {SectionList} from '@/jlmap3d/edit/neweditmodel/SectionList.js';
|
||||
import {SignalList} from '@/jlmap3d/edit/neweditmodel/SignalList.js';
|
||||
import {StationStandList} from '@/jlmap3d/edit/neweditmodel/StationStandList.js';
|
||||
import {SwitchList} from '@/jlmap3d/edit/neweditmodel/SwitchList.js';
|
||||
import {RailList} from '@/jlmap3d/edit/neweditmodel/RailList.js';
|
||||
|
||||
import axios from 'axios';
|
||||
import {getmodels} from '@/jlmap3d/edit/connect/getmodels';
|
||||
import { Loading } from 'element-ui';
|
||||
// import {SwitchModel} from '@/jlmap3d/model/SwitchModel.js';
|
||||
|
||||
export function Jlmap3ddata(mapid,scope){
|
||||
let editmapid = mapid;
|
||||
let scene = scope.scene;
|
||||
let jlmap3ddata = scope.mapdata;
|
||||
let jlmap3dasset = scope.assetManager;
|
||||
let assetloader = scope.assetloader;
|
||||
let loadingInstance = Loading.service({ fullscreen: true });
|
||||
get3dMapData(editmapid).then(data => {
|
||||
console.log("3dmapdata:");
|
||||
console.log(data);
|
||||
if(data.data ){
|
||||
if(data.data.assets){
|
||||
// initobj(editmapid,data.data.id);
|
||||
init3d(editmapid,data.data);
|
||||
}else{
|
||||
initobj(editmapid,data.data.id);
|
||||
}
|
||||
|
||||
}else{
|
||||
let params = {mapId:editmapid};
|
||||
|
||||
set3dMapData(params).then(data => {
|
||||
if(data.code == "200"){
|
||||
//console.log("创建三维数据成功");
|
||||
// console.log(data);
|
||||
initobj(editmapid,data.data.id);
|
||||
|
||||
}
|
||||
}).catch(error => {
|
||||
console.log(error);
|
||||
});
|
||||
}
|
||||
|
||||
}).catch(error => {
|
||||
console.log(error);
|
||||
});
|
||||
|
||||
function initobj(mapid,data3did){
|
||||
// console.log(mapid);
|
||||
// console.log(data3did);
|
||||
getMapDetail(mapid).then(data => {
|
||||
console.log(data);
|
||||
let mapdata = data.data;
|
||||
//console.log(data3did);
|
||||
jlmap3ddata.id = data3did;
|
||||
jlmap3ddata.mapId = mapid;
|
||||
|
||||
// //初始化站台
|
||||
jlmap3ddata.stationstandlist = new StationStandList();
|
||||
//初始化轨道和道岔 暂时
|
||||
jlmap3ddata.sectionlist = new SectionList();
|
||||
|
||||
jlmap3ddata.signallist = new SignalList();
|
||||
|
||||
jlmap3ddata.switchlist = new SwitchList();
|
||||
//
|
||||
jlmap3ddata.raillist = new RailList();
|
||||
jlmap3ddata.raillist.setrail();
|
||||
|
||||
assetloader.assetinit(scene)
|
||||
.then(function(data){
|
||||
//console.log(data);
|
||||
return jlmap3ddata.stationstandlist.initpromise(jlmap3ddata,mapdata.stationList,mapdata.stationStandList,scene,assetloader);
|
||||
})
|
||||
.then(function(data){
|
||||
//console.log(data);
|
||||
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){
|
||||
return jlmap3ddata.switchlist.initpromise(jlmap3ddata,mapdata.switchList,scene,assetloader);
|
||||
})
|
||||
|
||||
.then(function(data){
|
||||
//console.log(data);
|
||||
loadingInstance.close();
|
||||
});
|
||||
//初始化信号
|
||||
//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;
|
||||
// console.log(netdata);
|
||||
// //初始化站台
|
||||
jlmap3ddata.stationstandlist = new StationStandList();
|
||||
//初始化轨道和道岔 暂时
|
||||
jlmap3ddata.sectionlist = new SectionList();
|
||||
|
||||
jlmap3ddata.signallist = new SignalList();
|
||||
|
||||
jlmap3ddata.switchlist = new SwitchList();
|
||||
|
||||
jlmap3ddata.raillist = new RailList();
|
||||
|
||||
let sectiondata = JSON.parse(netdata.sections);
|
||||
let switchdata = JSON.parse(netdata.switchs);
|
||||
let signaldata = JSON.parse(netdata.signals);
|
||||
let standsdata = JSON.parse(netdata.stands);
|
||||
jlmap3dasset = JSON.parse(netdata.assets);
|
||||
console.log(netdata);
|
||||
if(jlmap3dasset.sceneAssetList == undefined){
|
||||
|
||||
// loadEditAllAsset(jlmap3dasset);
|
||||
assetloader.setmodellistnew(netdata.assets,5);
|
||||
assetloader.assetpromise(scene)
|
||||
.then(function(data){
|
||||
// return jlmap3ddata.stationstandlist.initpromise(jlmap3ddata,mapdata.stationList,mapdata.stationStandList,scene,assetloader);
|
||||
return jlmap3ddata.stationstandlist.loadpromise(jlmap3ddata,standsdata,mapdata.stationStandList,scene,assetloader);
|
||||
})
|
||||
.then(function(data){
|
||||
//console.log(data);
|
||||
// return jlmap3ddata.sectionlist.initpromise(jlmap3ddata,assetloader,mapdata.sectionList,mapdata.switchList,scene);
|
||||
return jlmap3ddata.sectionlist.loadpromise(jlmap3ddata,assetloader,sectiondata.section,scene);
|
||||
})
|
||||
.then(function(data){
|
||||
//console.log(data);
|
||||
// return jlmap3ddata.signallist.initpromise(jlmap3ddata,mapdata.signalList,scene,assetloader);
|
||||
return jlmap3ddata.signallist.loadpromise(signaldata,scene,assetloader,mapdata.signalList);
|
||||
})
|
||||
.then(function(data){
|
||||
// return jlmap3ddata.switchlist.initpromise(jlmap3ddata,mapdata.switchList,scene,assetloader);
|
||||
return jlmap3ddata.switchlist.loadpromise(jlmap3ddata,switchdata,scene,assetloader);
|
||||
})
|
||||
.then(function(data){
|
||||
//console.log(data);
|
||||
loadingInstance.close();
|
||||
});
|
||||
}else{
|
||||
loadEditAllAsset(jlmap3dasset);
|
||||
assetloader.setModelListOver(jlmap3dasset.sceneAssetList,5);
|
||||
assetloader.assetPromiseOver(scene)
|
||||
.then(function(data){
|
||||
console.log(assetloader.modellist);
|
||||
// return jlmap3ddata.stationstandlist.initpromise(jlmap3ddata,mapdata.stationList,mapdata.stationStandList,scene,assetloader);
|
||||
return jlmap3ddata.stationstandlist.loadpromise(jlmap3ddata,standsdata,mapdata.stationStandList,scene,assetloader);
|
||||
})
|
||||
.then(function(data){
|
||||
//console.log(data);
|
||||
// return jlmap3ddata.sectionlist.initpromise(jlmap3ddata,assetloader,mapdata.sectionList,mapdata.switchList,scene);
|
||||
return jlmap3ddata.sectionlist.loadpromise(jlmap3ddata,assetloader,sectiondata.section,scene);
|
||||
})
|
||||
.then(function(data){
|
||||
//console.log(data);
|
||||
// return jlmap3ddata.signallist.initpromise(jlmap3ddata,mapdata.signalList,scene,assetloader);
|
||||
return jlmap3ddata.signallist.loadpromise(signaldata,scene,assetloader,mapdata.signalList);
|
||||
})
|
||||
.then(function(data){
|
||||
// return jlmap3ddata.switchlist.initpromise(jlmap3ddata,mapdata.switchList,scene,assetloader);
|
||||
return jlmap3ddata.switchlist.loadpromise(jlmap3ddata,switchdata,scene,assetloader);
|
||||
})
|
||||
.then(function(data){
|
||||
//console.log(data);
|
||||
loadingInstance.close();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,315 +0,0 @@
|
||||
|
||||
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,netlink,scene,assetloader){
|
||||
return new Promise(function(resolve, reject){
|
||||
scene.add(scope.linksgroup);
|
||||
loadlink(linkdata,netlink,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,netlink,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 num=0,lennum=netlink.length;num<lennum;num++){
|
||||
if(netlink[num].code == data[i].code){
|
||||
testmesh2.oldlength = netlink[num].lengthFact;
|
||||
num = lennum;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
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(){
|
||||
|
||||
};
|
||||
}
|
@ -1,185 +0,0 @@
|
||||
import {RealSectionModel} from '@/jlmap3d/edit/editmodel/RealSectionModel.js';
|
||||
|
||||
export function RealSectionList(data) {
|
||||
|
||||
let scope = this;
|
||||
|
||||
this.type = "sectionlist";
|
||||
|
||||
this.list = [];
|
||||
|
||||
this.group = [];
|
||||
|
||||
this.switch = [];
|
||||
|
||||
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"){
|
||||
modelnum = i;
|
||||
}
|
||||
}
|
||||
let newmesh = assetloader.modellist[modelnum].mesh;
|
||||
//let mixer = new THREE.AnimationMixer( newmesh );
|
||||
////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<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 = 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;
|
||||
}
|
||||
|
||||
sectiondata.sectionlist.switchs.modellist[j] = newmesh.children[i];
|
||||
j = sectiondata.sectionlist.switchs.datalist.length;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(name[0] == "Section"){
|
||||
//console.log(newmesh.children[i]);
|
||||
//物理区段
|
||||
for(let j=0;j<sectiondata.sectionlist.sections.datalist.length;j++){
|
||||
|
||||
if(sectiondata.sectionlist.sections.datalist[j].name == newmeshname){
|
||||
|
||||
if(sectiondata.sectionlist.sections.datalist[j].isStandTrack == true){
|
||||
//红色站台区段
|
||||
var box = new THREE.BoxHelper( newmesh.children[i], 0xff0000 );
|
||||
}else{
|
||||
//蓝色其他区段
|
||||
var box = new THREE.BoxHelper( newmesh.children[i], 0x0000ff );
|
||||
}
|
||||
scene.add( box );
|
||||
|
||||
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;
|
||||
sectiondata.sectionlist.sections.modellist[j] = newmesh.children[i];
|
||||
j = sectiondata.sectionlist.sections.datalist.length;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
scene.add(newmesh);
|
||||
|
||||
resolve("loadedrealsection");
|
||||
});
|
||||
}
|
||||
|
||||
this.init = function(sectiondata,scene,assetloader){
|
||||
|
||||
let newmesh = assetloader.modellist[2].mesh;
|
||||
//let mixer = new THREE.AnimationMixer( newmesh );
|
||||
////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<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 = 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;
|
||||
}
|
||||
|
||||
sectiondata.sectionlist.switchs.modellist[j] = newmesh.children[i];
|
||||
j = sectiondata.sectionlist.switchs.datalist.length;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(name[0] == "Section"){
|
||||
|
||||
//物理区段
|
||||
for(let j=0;j<sectiondata.sectionlist.sections.datalist.length;j++){
|
||||
|
||||
if(sectiondata.sectionlist.sections.datalist[j].name == newmeshname){
|
||||
|
||||
if(sectiondata.sectionlist.sections.datalist[j].isStandTrack == true){
|
||||
//红色站台区段
|
||||
var box = new THREE.BoxHelper( newmesh.children[i], 0xff0000 );
|
||||
}else{
|
||||
//蓝色其他区段
|
||||
var box = new THREE.BoxHelper( newmesh.children[i], 0x0000ff );
|
||||
}
|
||||
scene.add( box );
|
||||
|
||||
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;
|
||||
sectiondata.sectionlist.sections.modellist[j] = newmesh.children[i];
|
||||
j = sectiondata.sectionlist.sections.datalist.length;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(name[0] == "Singal"){
|
||||
|
||||
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 = sectiondata.signallist.list.length;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
scene.add(newmesh);
|
||||
}
|
||||
|
||||
|
||||
this.update = function(){
|
||||
|
||||
}
|
||||
|
||||
this.renderon = function(){
|
||||
|
||||
}
|
||||
|
||||
this.renderoff = function(){
|
||||
|
||||
}
|
||||
|
||||
this.dispose = function(){
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
export function RealSectionModel(data) {
|
||||
var scope = this;
|
||||
|
||||
this.mesh = null;
|
||||
this.meshurl = null;
|
||||
this.picurl = null;
|
||||
|
||||
}
|
@ -1,842 +0,0 @@
|
||||
import {SectionModel} from '@/jlmap3d/edit/editmodel/SectionModel.js';
|
||||
import {SwitchModel} from '@/jlmap3d/edit/editmodel/SwitchModel.js';
|
||||
export function SectionList() {
|
||||
|
||||
let scope = this;
|
||||
|
||||
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(jlmap3ddata,assetloader,sectiondata,switchdata,scene){
|
||||
// console.log(sectiondata);
|
||||
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"){
|
||||
//初始化区段对象数据
|
||||
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);
|
||||
// sections.modellist.push("");
|
||||
}
|
||||
}
|
||||
// buildsuidao(linkdata,sections,assetloader,scene);
|
||||
// console.log(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 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 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;
|
||||
}
|
||||
}
|
||||
|
||||
//遍历道岔信息组合轨道
|
||||
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.sectionpromise = function(linkdata,linklist,sectiondata,switchdata,standsdata,scene){
|
||||
// console.log(linkdata);
|
||||
// console.log(linklist);
|
||||
// console.log(sectiondata);
|
||||
console.log(standsdata);
|
||||
return new Promise(function(resolve, reject){
|
||||
let linkrail = [];
|
||||
let switchrail = [];
|
||||
for(let i=0;i<linkdata.length;i++){
|
||||
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
|
||||
};
|
||||
}
|
||||
|
||||
for(let i=0;i<switchdata.length;i++){
|
||||
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(linkrail[switchdata[i].blink].lp.x < switchdata[i].position.x){
|
||||
linkrail[switchdata[i].alink].lswitch = switchdata[i].code;
|
||||
linkrail[switchdata[i].blink].rswitch = switchdata[i].code;
|
||||
|
||||
}else{
|
||||
linkrail[switchdata[i].alink].rswitch = switchdata[i].code;
|
||||
linkrail[switchdata[i].blink].lswitch = switchdata[i].code;
|
||||
}
|
||||
//
|
||||
if(linkrail[switchdata[i].clink].lp.x < switchdata[i].position.x){
|
||||
linkrail[switchdata[i].alink].lswitch = switchdata[i].code;
|
||||
linkrail[switchdata[i].clink].rswitch = switchdata[i].code;
|
||||
}else{
|
||||
linkrail[switchdata[i].alink].rswitch = switchdata[i].code;
|
||||
linkrail[switchdata[i].clink].lswitch = switchdata[i].code;
|
||||
}
|
||||
}
|
||||
|
||||
for(let i=0;i<linkdata.length;i++){
|
||||
if(linkdata[i].rotation._z == 0){
|
||||
linkrail[linkdata[i].code].type = 0;
|
||||
if(linkrail[linkdata[i].code].lswitch){
|
||||
let switchpoint = switchrail[linkrail[linkdata[i].code].lswitch].position;
|
||||
linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x,0,switchpoint.z));
|
||||
}
|
||||
|
||||
linkrail[linkdata[i].code].points.push(new THREE.Vector3(linkrail[linkdata[i].code].lp.x,0,linkrail[linkdata[i].code].lp.z));
|
||||
linkrail[linkdata[i].code].points.push(new THREE.Vector3(linkrail[linkdata[i].code].rp.x,0,linkrail[linkdata[i].code].rp.z));
|
||||
|
||||
if(linkrail[linkdata[i].code].rswitch){
|
||||
let switchpoint = switchrail[linkrail[linkdata[i].code].rswitch].position;
|
||||
linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x,0,switchpoint.z));
|
||||
}
|
||||
|
||||
}else{
|
||||
|
||||
if(linkdata[i].rotation._z>0){
|
||||
let testline = new THREE.CatmullRomCurve3([
|
||||
new THREE.Vector3(linkrail[linkdata[i].code].lp.x,0,linkrail[linkdata[i].code].lp.z),
|
||||
new THREE.Vector3(linkrail[linkdata[i].code].rp.x,0,linkrail[linkdata[i].code].rp.z)
|
||||
]);
|
||||
|
||||
linkrail[linkdata[i].code].type = 1;
|
||||
if(linkrail[linkdata[i].code].lswitch){
|
||||
let switchpoint = switchrail[linkrail[linkdata[i].code].lswitch].position;
|
||||
linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x,0,switchpoint.z));
|
||||
linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x+1.5,0,switchpoint.z));
|
||||
linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x+2,0,switchpoint.z-0.01));
|
||||
linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x+3.5,0,switchpoint.z-0.05));
|
||||
}
|
||||
|
||||
linkrail[linkdata[i].code].points.push(testline.getPointAt(0.12));
|
||||
linkrail[linkdata[i].code].points.push(testline.getPointAt(0.22));
|
||||
linkrail[linkdata[i].code].points.push(testline.getPointAt(0.82));
|
||||
linkrail[linkdata[i].code].points.push(testline.getPointAt(0.92));
|
||||
|
||||
if(linkrail[linkdata[i].code].rswitch){
|
||||
let switchpoint = switchrail[linkrail[linkdata[i].code].rswitch].position;
|
||||
linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x-3.5,0,switchpoint.z+0.05));
|
||||
linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x-2,0,switchpoint.z+0.01));
|
||||
linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x-1.5,0,switchpoint.z));
|
||||
linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x,0,switchpoint.z));
|
||||
}
|
||||
|
||||
}else{
|
||||
let testline = new THREE.CatmullRomCurve3([
|
||||
new THREE.Vector3(linkrail[linkdata[i].code].lp.x,0,linkrail[linkdata[i].code].lp.z),
|
||||
new THREE.Vector3(linkrail[linkdata[i].code].rp.x,0,linkrail[linkdata[i].code].rp.z)
|
||||
]);
|
||||
linkrail[linkdata[i].code].type = 2;
|
||||
if(linkrail[linkdata[i].code].lswitch){
|
||||
let switchpoint = switchrail[linkrail[linkdata[i].code].lswitch].position;
|
||||
linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x,0,switchpoint.z));
|
||||
linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x+1.5,0,switchpoint.z));
|
||||
linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x+2,0,switchpoint.z+0.01));
|
||||
linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x+3.5,0,switchpoint.z+0.05));
|
||||
}
|
||||
|
||||
linkrail[linkdata[i].code].points.push(testline.getPointAt(0.12));
|
||||
linkrail[linkdata[i].code].points.push(testline.getPointAt(0.22));
|
||||
linkrail[linkdata[i].code].points.push(testline.getPointAt(0.82));
|
||||
linkrail[linkdata[i].code].points.push(testline.getPointAt(0.92));
|
||||
|
||||
if(linkrail[linkdata[i].code].rswitch){
|
||||
let switchpoint = switchrail[linkrail[linkdata[i].code].rswitch].position;
|
||||
linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x-3.5,0,switchpoint.z-0.05));
|
||||
linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x-2,0,switchpoint.z-0.01));
|
||||
linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x-1.5,0,switchpoint.z));
|
||||
linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x,0,switchpoint.z));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for(let i=0;i<linkdata.length;i++){
|
||||
linkrail[linkdata[i].code].lineleft = new THREE.CatmullRomCurve3(linkrail[linkdata[i].code].points);
|
||||
linkrail[linkdata[i].code].lineleft.curveType = "centripetal";
|
||||
// linkrail[linkdata[i].code].lineleft.tension = 0.2;
|
||||
let rightpoints = [];
|
||||
linkrail[linkdata[i].code].points.forEach(item=>{
|
||||
rightpoints.push(item);
|
||||
}
|
||||
);
|
||||
rightpoints.reverse();
|
||||
linkrail[linkdata[i].code].lineright = new THREE.CatmullRomCurve3(rightpoints);
|
||||
linkrail[linkdata[i].code].lineright.curveType = "centripetal";
|
||||
|
||||
// scope.linkrail[linkdata[i].code].lineright.tension = 0.11;
|
||||
var points = linkrail[linkdata[i].code].lineleft.getPoints( 50 );
|
||||
var geometry = new THREE.BufferGeometry().setFromPoints( points );
|
||||
var material;
|
||||
if(linkrail[linkdata[i].code].type == 0){
|
||||
material = new THREE.LineBasicMaterial( { color : 0xff0000 } );
|
||||
}
|
||||
if(linkrail[linkdata[i].code].type == 1){
|
||||
material = new THREE.LineBasicMaterial( { color : 0x00ff00 } );
|
||||
}
|
||||
if(linkrail[linkdata[i].code].type == 2){
|
||||
material = new THREE.LineBasicMaterial( { color : 0x0000ff } );
|
||||
}
|
||||
|
||||
|
||||
// Create the final object to add to the scene
|
||||
var curveObject = new THREE.Line( geometry, material );
|
||||
|
||||
curveObject.position.y = Math.random();
|
||||
scene.add(curveObject);
|
||||
}
|
||||
|
||||
let standsections = [];
|
||||
for(let i=0,len=sectiondata.length;i<len;i++){
|
||||
if(sectiondata[i].isStandTrack == true){
|
||||
standsections.push(sectiondata[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// console.log(standsections);
|
||||
for(let i=0,leni=standsections.length;i<leni;i++){
|
||||
for(let j=0,lenj=linklist.length;j<lenj;j++){
|
||||
if(standsections[i].linkCode == linklist[j].code){
|
||||
for(let n=0,lenn=standsdata.length;n<lenn;n++){
|
||||
if(standsections[i].relStandCode == standsdata[n].direction1.name){
|
||||
let geometry = new THREE.CircleGeometry( 2, 16 );
|
||||
let material = new THREE.MeshBasicMaterial( { color: 0x00ffff } );
|
||||
// console.log(standsections[i].stationCode);
|
||||
// console.log(standsdata[n].code);
|
||||
// console.log(standsdata[n].position.x);
|
||||
// console.log("position.z");
|
||||
// console.log(linkrail[linklist[j].code].points[0].z);
|
||||
// console.log(standsdata[n].position.z);
|
||||
// console.log("........................................");
|
||||
let circle1 = new THREE.Mesh( geometry, material );
|
||||
let circle2 = new THREE.Mesh( geometry, material );
|
||||
if(linkrail[linklist[j].code].points[0].z>standsdata[n].position.z){
|
||||
circle1.position.x = standsdata[n].position.x-64;
|
||||
circle1.position.y = 5;
|
||||
circle1.position.z = linkrail[linklist[j].code].points[0].z;
|
||||
circle1.rotation.x = -Math.PI/2;
|
||||
|
||||
circle2.position.x = standsdata[n].position.x+64;
|
||||
circle2.position.y = 5;
|
||||
circle2.position.z = linkrail[linklist[j].code].points[0].z-(linkrail[linklist[j].code].points[0].z-standsdata[n].position.z)*2;
|
||||
circle2.rotation.x = -Math.PI/2;
|
||||
}else{
|
||||
circle1.position.x = standsdata[n].position.x+64;
|
||||
circle1.position.y = 5;
|
||||
circle1.position.z = linkrail[linklist[j].code].points[0].z+(standsdata[n].position.z-linkrail[linklist[j].code].points[0].z)*2;
|
||||
circle1.rotation.x = -Math.PI/2;
|
||||
|
||||
circle2.position.x = standsdata[n].position.x-64;
|
||||
circle2.position.y = 5;
|
||||
circle2.position.z = linkrail[linklist[j].code].points[0].z;
|
||||
circle2.rotation.x = -Math.PI/2;
|
||||
}
|
||||
|
||||
|
||||
scene.add( circle1 );
|
||||
scene.add( circle2 );
|
||||
n = lenn;
|
||||
}
|
||||
}
|
||||
// console.log(standsections[i]);
|
||||
// console.log(linklist[j]);
|
||||
// console.log("====================================");
|
||||
|
||||
let progress1 = standsections[i].leftStopPointOffset/linklist[j].lengthFact;
|
||||
let progress2 = standsections[i].rightStopPointOffset/linklist[j].lengthFact;
|
||||
|
||||
let point1 = linkrail[linklist[j].code].lineleft.getPointAt(progress1);
|
||||
|
||||
var geometry = new THREE.CircleGeometry( 2, 16 );
|
||||
var material = new THREE.MeshBasicMaterial( { color: 0xffff00 } );
|
||||
let circle1 = new THREE.Mesh( geometry, material );
|
||||
circle1.position.x = point1.x;
|
||||
circle1.position.y = point1.y;
|
||||
circle1.position.z = point1.z;
|
||||
circle1.rotation.x = -Math.PI/2;
|
||||
scene.add( circle1 );
|
||||
|
||||
let point2 = linkrail[linklist[j].code].lineleft.getPointAt(progress2);
|
||||
let circle2 = new THREE.Mesh( geometry, material );
|
||||
circle2.position.x = point2.x;
|
||||
circle2.position.y = point2.y;
|
||||
circle2.position.z = point2.z;
|
||||
circle2.rotation.x = -Math.PI/2;
|
||||
scene.add( circle2 );
|
||||
// console.log(progress1);
|
||||
// console.log(progress2);
|
||||
// console.log(standsections[i].leftStopPointOffset);
|
||||
// console.log(standsections[i].rightStopPointOffset);
|
||||
// console.log(linklist[j].lengthFact);
|
||||
// console.log(linkrail[linklist[j].code].lineleft.points);
|
||||
// console.log(point1);
|
||||
// console.log(point2);
|
||||
// console.log("====================================");
|
||||
|
||||
j = lenj;
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
//
|
||||
// sections.datalist.push(newsection);
|
||||
// // 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;
|
||||
//
|
||||
// switchs.datalist.push(newswitch);
|
||||
// switchs.modellist.push("");
|
||||
// }
|
||||
// }
|
||||
|
||||
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);
|
||||
// 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){
|
||||
// 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 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);
|
||||
scope.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];
|
||||
}
|
||||
}
|
||||
// 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(){
|
||||
|
||||
}
|
||||
|
||||
this.renderon = function(){
|
||||
|
||||
}
|
||||
|
||||
this.renderoff = function(){
|
||||
|
||||
}
|
||||
|
||||
this.dispose = function(){
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
export function SectionModel(data) {
|
||||
var scope = this;
|
||||
//命名
|
||||
this.name = null;
|
||||
//code
|
||||
this.code = null;
|
||||
//索引位置
|
||||
this.index = null;
|
||||
//轨迹点
|
||||
this.rail = [];
|
||||
|
||||
this.railline = null;
|
||||
//长度
|
||||
this.distance = [];
|
||||
|
||||
this.isStandTrack = null;
|
||||
|
||||
this.type = null;
|
||||
//指向模型
|
||||
this.mesh = null;
|
||||
// //模型地址
|
||||
// this.meshurl = null;
|
||||
// //贴图地址
|
||||
// this.picurl = null;
|
||||
|
||||
}
|
@ -1,222 +0,0 @@
|
||||
import {SignalModel} from '@/jlmap3d/edit/editmodel/SignalModel.js';
|
||||
|
||||
export function SignalList() {
|
||||
|
||||
let scope = this;
|
||||
|
||||
this.type = "signallist";
|
||||
|
||||
this.list = [];
|
||||
|
||||
this.group = new THREE.Group();
|
||||
|
||||
this.initpromise = function(jlmap3ddata,data,scene,assetloader,netdata){
|
||||
return new Promise(function(resolve, reject){
|
||||
scope.group.name = "signal";
|
||||
//遍历信号数据
|
||||
let netsignal = null;
|
||||
let haddata = false;
|
||||
if(netdata){
|
||||
netsignal = JSON.parse(netdata);
|
||||
haddata = true;
|
||||
}
|
||||
let linkdata = jlmap3ddata.linklist;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
let newmesh = assetloader.modellist[num].mesh.clone(true);
|
||||
|
||||
newmesh.name = assetloader.modellist[num].name;
|
||||
newmesh.modelid = assetloader.modellist[num].id;
|
||||
newmesh.code = data[i].code;
|
||||
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(posx,0,link.position.z-3);
|
||||
newmesh.rotation.z = ( Math.PI / 2 );
|
||||
}else if(data[i].directionType == "02"){
|
||||
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);
|
||||
|
||||
}else{
|
||||
for(let j=0;j<assetloader.modellist.length;j++){
|
||||
if(assetloader.modellist[j].id == netsignal[i].modelid){
|
||||
num = j;
|
||||
}
|
||||
}
|
||||
let newmesh = assetloader.modellist[num].mesh.clone(true);
|
||||
|
||||
newmesh.uuid = netsignal[i].id;
|
||||
newmesh.name = netsignal[i].name;
|
||||
newmesh.modelid = assetloader.modellist[num].id;
|
||||
newmesh.code = netsignal[i].code;
|
||||
for(let j=0;j<newmesh.children.length;j++){
|
||||
newmesh.children[j].code = netsignal[i].code;
|
||||
}
|
||||
newmesh.position.x = netsignal[i].position.x;
|
||||
newmesh.position.y = netsignal[i].position.y;
|
||||
newmesh.position.z = netsignal[i].position.z;
|
||||
newmesh.rotation.x = netsignal[i].rotation._x;
|
||||
newmesh.rotation.y = netsignal[i].rotation._y;
|
||||
newmesh.rotation.z = netsignal[i].rotation._z;
|
||||
newmesh.scale.x = netsignal[i].scale.x;
|
||||
newmesh.scale.y = netsignal[i].scale.y;
|
||||
newmesh.scale.z = netsignal[i].scale.z;
|
||||
newsignal.mesh = newmesh;
|
||||
newsignal.mesh.status = "01";
|
||||
scope.group.add(newsignal.mesh);
|
||||
scope.list.push(newsignal);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
scene.add(scope.group);
|
||||
resolve("loadedsignal");
|
||||
});
|
||||
}
|
||||
|
||||
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(jlmap3ddata);
|
||||
let linkdata = jlmap3ddata.linkdata;
|
||||
for(let i=0;i<scope.group.children.length;i++){
|
||||
let signaldata = scope.group.children[i];
|
||||
for(let j=0,lenj=linkdata.length;j<lenj;j++){
|
||||
if(linkdata[j].code == signaldata.linkCode){
|
||||
let posx = linkdata[j].lp.x + (signaldata.offset/linkdata[j].oldlength)*linkdata[j].lengthfact;
|
||||
|
||||
//根据线路方向修改信号灯位置
|
||||
// console.log(posx);
|
||||
if(signaldata.directionType == "01"){
|
||||
signaldata.position.set(posx,0,linkdata[j].position.z-2.4);
|
||||
signaldata.rotation.z = ( Math.PI / 2 );
|
||||
// signaldata.scale.set(1,1,1);
|
||||
}else if(signaldata.directionType == "02"){
|
||||
signaldata.position.set(posx,0,linkdata[j].position.z+2.4);
|
||||
signaldata.rotation.z = ( - Math.PI / 2 );
|
||||
// signaldata.scale.set(1,1,1);
|
||||
}
|
||||
j = lenj;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
this.init = function(data,realsectionlist,scene,assetloader){
|
||||
|
||||
|
||||
scope.group.name = "signal";
|
||||
//遍历信号数据
|
||||
for(let i=0;i<data.length;i++){
|
||||
let newsignal = new SignalModel(data);
|
||||
|
||||
let newmesh = assetloader.modellist[0].mesh.clone(true);
|
||||
|
||||
newmesh.name = assetloader.modellist[0].id;
|
||||
newmesh.code = data[i].code;
|
||||
for(let j=0;j<newmesh.children.length;j++){
|
||||
newmesh.children[j].code = data[i].code;
|
||||
}
|
||||
|
||||
//根据线路方向修改信号灯位置
|
||||
if(data[i].directionType == "01"){
|
||||
newmesh.position.set(data[i].position.x,1,data[i].position.y-10);
|
||||
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.rotation.z = ( - Math.PI / 2 );
|
||||
}
|
||||
//newmesh.scale.set(0.1,0.1,0.1);
|
||||
newsignal.mesh = newmesh;
|
||||
newsignal.mesh.status = "01";
|
||||
scope.group.add(newsignal.mesh);
|
||||
scope.list.push(newsignal);
|
||||
|
||||
}
|
||||
scene.add(scope.group);
|
||||
}
|
||||
|
||||
this.reposition = function(){
|
||||
|
||||
}
|
||||
|
||||
this.update = function(){
|
||||
|
||||
}
|
||||
|
||||
this.renderon = function(){
|
||||
|
||||
}
|
||||
|
||||
this.renderoff = function(){
|
||||
|
||||
}
|
||||
|
||||
this.dispose = function(){
|
||||
|
||||
}
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
export function SignalModel(data) {
|
||||
|
||||
this.uuid = null;
|
||||
this.code = null;
|
||||
this.name = null;
|
||||
this.modelid = null;
|
||||
this.type = null;
|
||||
this.direction = null;
|
||||
this.ismodel = false;
|
||||
this.istexture = false;
|
||||
this.modelurl = null;
|
||||
// this.textures = {
|
||||
// red:null,
|
||||
// yellor:null,
|
||||
// green:null
|
||||
// }
|
||||
// this.position = {
|
||||
// x:0,
|
||||
// y:0,
|
||||
// z:0
|
||||
// };
|
||||
// this.rotation = {
|
||||
// x:0,
|
||||
// y:0,
|
||||
// z:0
|
||||
// };
|
||||
// this.scale = {
|
||||
// x:0,
|
||||
// y:0,
|
||||
// z:0
|
||||
// }
|
||||
|
||||
this.mesh = null;
|
||||
this.meshurl = null;
|
||||
this.picurl = null;
|
||||
}
|
@ -1,190 +0,0 @@
|
||||
import {StationStandModel} from '@/jlmap3d/edit/editmodel/StationStandModel.js';
|
||||
|
||||
export function StationStandList() {
|
||||
|
||||
let scope = this;
|
||||
|
||||
this.type = "stationstandlist";
|
||||
|
||||
this.list = [];
|
||||
|
||||
this.group = new THREE.Group();
|
||||
|
||||
this.textlist = [];
|
||||
|
||||
this.initpromise = function(jlmap3ddata,stationdata,stationstanddata,scene,assetloader,netdata){
|
||||
return new Promise(function(resolve, reject){
|
||||
|
||||
let netstand = null;
|
||||
let haddata = false;
|
||||
if(netdata){
|
||||
haddata = true;
|
||||
}
|
||||
scope.group.name = "station";
|
||||
scene.add(scope.group);
|
||||
//遍历车站数据
|
||||
for(let i=0;i<stationdata.length;i++){
|
||||
|
||||
let newstationstand = new StationStandModel(stationdata);
|
||||
//判断站台是否显示
|
||||
if(stationdata[i].visible == true){
|
||||
//遍历车站站台数据
|
||||
for(let j=0;j<stationstanddata.length;j++){
|
||||
//收集有效车站数据
|
||||
if(stationstanddata[j].stationCode == stationdata[i].code){
|
||||
|
||||
newstationstand.name = stationdata[i].name;
|
||||
newstationstand.code = stationdata[i].code;
|
||||
|
||||
if(stationstanddata[j].direction == "01"){
|
||||
newstationstand.direction1.position = stationstanddata[j].position;
|
||||
newstationstand.direction1.name = stationstanddata[j].code;
|
||||
newstationstand.direction1.screenDoorOpenStatus = "01";
|
||||
newstationstand.width = stationstanddata[j].width*2;
|
||||
newstationstand.height = stationstanddata[j].height;
|
||||
}
|
||||
if(stationstanddata[j].direction == "02"){
|
||||
newstationstand.direction2.position = stationstanddata[j].position;
|
||||
newstationstand.direction2.name = stationstanddata[j].code;
|
||||
newstationstand.direction2.screenDoorOpenStatus = "01";
|
||||
}
|
||||
}
|
||||
}
|
||||
scope.list.push(newstationstand);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//建立需要显示车的车站模型对象
|
||||
for(let i=0;i<scope.list.length;i++){
|
||||
|
||||
let num;
|
||||
if(haddata == false){
|
||||
for(let j=0;j<assetloader.modellist.length;j++){
|
||||
if(assetloader.modellist[j].deviceType == "stand"){
|
||||
num = j;
|
||||
}
|
||||
}
|
||||
|
||||
scope.list[i].mesh = assetloader.modellist[num].mesh.clone(true);
|
||||
|
||||
scope.list[i].uuid = assetloader.modellist[num].uuid;
|
||||
scope.list[i].id = assetloader.modellist[num].id;
|
||||
scope.list[i].modelid = assetloader.modellist[num].id;
|
||||
scope.list[i].mesh.code = scope.list[i].code;
|
||||
|
||||
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);
|
||||
|
||||
|
||||
// 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].deviceType == "stand"){
|
||||
num = j;
|
||||
}
|
||||
}
|
||||
scope.list[i].mesh = assetloader.modellist[num].mesh.clone(true);
|
||||
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 = netdata[i].code;
|
||||
}
|
||||
|
||||
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 = 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} );
|
||||
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);
|
||||
}
|
||||
|
||||
// scene.add(plane);
|
||||
}
|
||||
|
||||
resolve("loadedstation");
|
||||
});
|
||||
}
|
||||
|
||||
this.update = function(){
|
||||
|
||||
}
|
||||
|
||||
this.renderon = function(){
|
||||
|
||||
}
|
||||
|
||||
this.renderoff = function(){
|
||||
|
||||
}
|
||||
|
||||
this.dispose = function(){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
//canvas文字贴图方法
|
||||
//PS:待提炼 增强功能
|
||||
function getTextCanvas(text){
|
||||
var canvas = document.getElementById('canvastexture');
|
||||
// let width = 128;
|
||||
// let height = 64;
|
||||
// canvas.style.width = width + "px";
|
||||
// canvas.style.height = height + "px";
|
||||
|
||||
var ctx = canvas.getContext('2d');
|
||||
ctx.fillStyle = '#FFFFFF';
|
||||
ctx.fillRect(0, 0,128,64);
|
||||
ctx.font = "500px";
|
||||
ctx.fillStyle = '#000000';
|
||||
ctx.textAlign = 'center';
|
||||
ctx.textBaseline = 'middle';
|
||||
ctx.clearRect(0,0,128,64);
|
||||
|
||||
ctx.fillText(text.name, 128/2,64/4);
|
||||
ctx.fillText(text.runPlanName, 128/2,64*2/4);
|
||||
ctx.fillText(text.kmPost, 128/2,64*3/4);
|
||||
|
||||
let data = ctx.getImageData(0, 0,128,64);
|
||||
return data;
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
export function StationStandModel(opts) {
|
||||
|
||||
var scope = this;
|
||||
|
||||
this.uuid = null;
|
||||
this.code = null;
|
||||
this.name = null;
|
||||
this.modelid = null;
|
||||
this.type = null;
|
||||
|
||||
this.ismodel = false;
|
||||
this.istexture = false;
|
||||
this.modelurl = null;
|
||||
|
||||
this.direction1= {
|
||||
position:null,
|
||||
name:null,
|
||||
screenDoorOpenStatus:null,
|
||||
mesh:null,
|
||||
openpos:[],
|
||||
closepos:[]
|
||||
}
|
||||
this.direction2= {
|
||||
position:null,
|
||||
name:null,
|
||||
screenDoorOpenStatus:null,
|
||||
mesh:null,
|
||||
openpos:[],
|
||||
closepos:[]
|
||||
}
|
||||
|
||||
this.mesh = null;
|
||||
this.meshurl = null;
|
||||
this.picurl = null;
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
import {SwitchModel} from '@/jlmap3d/model/SwitchModel.js';
|
||||
|
||||
export function SwitchList() {
|
||||
|
||||
this.type = "switchlist";
|
||||
|
||||
this.list = null;
|
||||
|
||||
this.init = function(){
|
||||
|
||||
}
|
||||
|
||||
this.update = function(){
|
||||
|
||||
}
|
||||
|
||||
this.renderon = function(){
|
||||
|
||||
}
|
||||
|
||||
this.renderoff = function(){
|
||||
|
||||
}
|
||||
|
||||
this.dispose = function(){
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
export function SwitchModel() {
|
||||
|
||||
var scope = this;
|
||||
//命名
|
||||
this.name = null;
|
||||
//code
|
||||
this.code = null;
|
||||
//索引位置
|
||||
this.index = null;
|
||||
//轨迹点
|
||||
this.rail = [];
|
||||
//长度
|
||||
this.distance = null;
|
||||
|
||||
this.action = null;
|
||||
//指向模型
|
||||
this.mesh = null;
|
||||
// //模型地址
|
||||
// this.meshurl = null;
|
||||
// //贴图地址
|
||||
// this.picurl = null;
|
||||
}
|
@ -1,108 +0,0 @@
|
||||
import {TrainModel} from '@/jlmap3d/edit/editmodel/TrainModel.js';
|
||||
import { JL3D_LOCAL_STATIC } from '@/api/jlmap3d/assets3d.js';
|
||||
|
||||
export function TrainList() {
|
||||
|
||||
let scope = this;
|
||||
|
||||
this.type = "trainlist";
|
||||
|
||||
this.list = [];
|
||||
|
||||
this.group = [];
|
||||
|
||||
this.textlist = [];
|
||||
|
||||
this.init = function(data,scene){
|
||||
scope.group = new THREE.Group();
|
||||
scope.group.name = "train";
|
||||
scene.add(scope.group);
|
||||
// model
|
||||
THREE.Loader.Handlers.add( /\.dds$/i, new THREE.DDSLoader() ) ;
|
||||
for(let i=0;i<data.length;i++){
|
||||
new THREE.MTLLoader().setPath( JL3D_LOCAL_STATIC+'/MODEL/train/' ).load( 'train.mtl', function ( materials ) {
|
||||
materials.preload();
|
||||
|
||||
new THREE.OBJLoader().setMaterials( materials ).setPath( JL3D_LOCAL_STATIC+'/MODEL/train/' ).load( 'train.obj', function ( object ) {
|
||||
|
||||
object.name = data[i].code;
|
||||
|
||||
object.position.z = 30000;
|
||||
object.position.y = 2;
|
||||
|
||||
let textgeometry = new THREE.PlaneBufferGeometry( 64, 32, 1 );
|
||||
let textmaterial = new THREE.MeshBasicMaterial( { side: THREE.DoubleSide,map: new THREE.CanvasTexture(getTextCanvas(data[i])),transparent: true} );
|
||||
let textplane = new THREE.Mesh( textgeometry, textmaterial );
|
||||
textplane.name = data[i].code;
|
||||
textplane.position.y = 30;
|
||||
//textplane.rotation.x = Math.PI/2;
|
||||
scope.textlist.push(textplane);
|
||||
object.add(textplane);
|
||||
|
||||
let newtrain = {};
|
||||
newtrain.mesh = object;
|
||||
newtrain.mesh.scale.set(0.5,0.5,0.5);
|
||||
newtrain.mesh.first = false;
|
||||
|
||||
scope.list.push(newtrain);
|
||||
scope.group.add(newtrain.mesh);
|
||||
}, onProgress, onError );
|
||||
|
||||
} );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
this.update = function(){
|
||||
|
||||
}
|
||||
|
||||
this.renderon = function(){
|
||||
|
||||
}
|
||||
|
||||
this.renderoff = function(){
|
||||
|
||||
}
|
||||
|
||||
this.dispose = function(){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
let onProgress = function ( xhr ) {
|
||||
|
||||
if ( xhr.lengthComputable ) {
|
||||
|
||||
let percentComplete = xhr.loaded / xhr.total * 100;
|
||||
//console.log( Math.round( percentComplete, 2 ) + '% downloaded' );
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
let onError = function () { };
|
||||
|
||||
|
||||
function getTextCanvas(text){
|
||||
var width=128, height=64;
|
||||
var canvas = document.createElement('canvas');
|
||||
canvas.width = width;
|
||||
canvas.height = height;
|
||||
canvas.style.width = width + "px";
|
||||
canvas.style.height = height + "px";
|
||||
|
||||
var ctx = canvas.getContext('2d');
|
||||
ctx.fillStyle = '#FFFFFF';
|
||||
ctx.fillRect(0, 0, width, height);
|
||||
ctx.font = 1+'px';
|
||||
ctx.fillStyle = '#000000';
|
||||
ctx.textAlign = 'center';
|
||||
ctx.textBaseline = 'middle';
|
||||
ctx.clearRect(0,0,width,height);
|
||||
//ctx.fillText(text.trainNumber, width/2,height/4);
|
||||
ctx.fillText("车组号:"+text.trainNumber, width/2,height*2/4);
|
||||
//ctx.fillText(text.trainModel.name, width/2,height*3/4);
|
||||
return canvas;
|
||||
}
|
@ -1,175 +0,0 @@
|
||||
import {TrainModel} from '@/jlmap3d/edit/editmodel/TrainModel.js';
|
||||
|
||||
export function TrainListTest() {
|
||||
|
||||
let scope = this;
|
||||
|
||||
this.type = "trainlist";
|
||||
|
||||
this.list = [];
|
||||
|
||||
this.group = [];
|
||||
|
||||
this.textlist = [];
|
||||
|
||||
this.initpromise = function(data,scene,assetloader){
|
||||
return new Promise(function(resolve, reject){
|
||||
//列车节数
|
||||
let trainnum = 4;
|
||||
//遍历列车数据
|
||||
for(let i=0;i<data.length;i++){
|
||||
|
||||
// let group = new THREE.Group();
|
||||
// //创建列车模型
|
||||
// for(let j=0;j<trainnum;j++){
|
||||
// let geometry = new THREE.BoxBufferGeometry( 10, 4, 5 );
|
||||
// let material = new THREE.MeshBasicMaterial( {color: 0x3A5FCD} );
|
||||
// let train = new THREE.Mesh( geometry, material );
|
||||
// train.name = data[i].code;
|
||||
// train.position.set(j*11,2,0);
|
||||
// group.add(train);
|
||||
// }
|
||||
let newmesh;
|
||||
for(let n=0;n<assetloader.modellist.length;n++){
|
||||
if(assetloader.modellist[n].deviceType == "train"){
|
||||
newmesh = assetloader.modellist[n].mesh.clone(true);
|
||||
n = assetloader.modellist.length;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
for(let j=0;j<newmesh.children.length;j++){
|
||||
newmesh.children[j].name = data[i].code;
|
||||
//newmesh.children[j].rotation.y = 0.05*j;
|
||||
}
|
||||
//创建列车字牌
|
||||
let textgeometry = new THREE.PlaneBufferGeometry( 128, 64, 1 );
|
||||
let textmaterial = new THREE.MeshBasicMaterial( { side: THREE.DoubleSide,map: new THREE.CanvasTexture(getTextCanvas(data[i])),transparent: true} );
|
||||
let textplane = new THREE.Mesh( textgeometry, textmaterial );
|
||||
textplane.name = data[i].code;
|
||||
textplane.position.y = 30;
|
||||
textplane.position.x = -30;
|
||||
//textplane.rotation.x = Math.PI;
|
||||
scope.textlist.push(textplane);
|
||||
newmesh.add(textplane);
|
||||
//group.add(textplane);
|
||||
newmesh.first = false;
|
||||
newmesh.name = data[i].code;
|
||||
newmesh.groupNumber = data[i].groupNumber;
|
||||
newmesh.position.set(20,2,-20*i);
|
||||
//newmesh.rotation.y = Math.PI/2;
|
||||
newmesh.movelist = [];
|
||||
newmesh.rotelist = [];
|
||||
newmesh.endpoint = null;
|
||||
|
||||
scope.list.push(newmesh);
|
||||
//scene.add(newmesh);
|
||||
}
|
||||
resolve("loadedtrain");
|
||||
});
|
||||
}
|
||||
|
||||
this.init = function(data,scene,assetloader){
|
||||
//列车节数
|
||||
let trainnum = 4;
|
||||
//遍历列车数据
|
||||
for(let i=0;i<data.length;i++){
|
||||
|
||||
// let group = new THREE.Group();
|
||||
// //创建列车模型
|
||||
// for(let j=0;j<trainnum;j++){
|
||||
// let geometry = new THREE.BoxBufferGeometry( 10, 4, 5 );
|
||||
// let material = new THREE.MeshBasicMaterial( {color: 0x3A5FCD} );
|
||||
// let train = new THREE.Mesh( geometry, material );
|
||||
// train.name = data[i].code;
|
||||
// train.position.set(j*11,2,0);
|
||||
// group.add(train);
|
||||
// }
|
||||
|
||||
let newmesh = assetloader.modellist[1].mesh.clone(true);
|
||||
|
||||
for(let j=0;j<newmesh.children.length;j++){
|
||||
newmesh.children[j].name = data[i].code;
|
||||
//newmesh.children[j].rotation.y = 0.05*j;
|
||||
}
|
||||
//创建列车字牌
|
||||
let textgeometry = new THREE.PlaneBufferGeometry( 128, 64, 1 );
|
||||
let textmaterial = new THREE.MeshBasicMaterial( { side: THREE.DoubleSide,map: new THREE.CanvasTexture(getTextCanvas(data[i])),transparent: true} );
|
||||
let textplane = new THREE.Mesh( textgeometry, textmaterial );
|
||||
textplane.name = data[i].code;
|
||||
textplane.position.y = 30;
|
||||
textplane.position.x = -30;
|
||||
//textplane.rotation.x = Math.PI;
|
||||
scope.textlist.push(textplane);
|
||||
newmesh.add(textplane);
|
||||
//group.add(textplane);
|
||||
newmesh.first = false;
|
||||
newmesh.name = data[i].code;
|
||||
newmesh.groupNumber = data[i].groupNumber;
|
||||
newmesh.position.set(20,2,-20*i);
|
||||
//newmesh.rotation.y = Math.PI/2;
|
||||
newmesh.movelist = [];
|
||||
newmesh.rotelist = [];
|
||||
newmesh.endpoint = null;
|
||||
|
||||
scope.list.push(newmesh);
|
||||
scene.add(newmesh);
|
||||
}
|
||||
}
|
||||
|
||||
this.update = function(){
|
||||
|
||||
}
|
||||
|
||||
this.renderon = function(){
|
||||
|
||||
}
|
||||
|
||||
this.renderoff = function(){
|
||||
|
||||
}
|
||||
|
||||
this.dispose = function(){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
let onProgress = function ( xhr ) {
|
||||
|
||||
if ( xhr.lengthComputable ) {
|
||||
|
||||
let percentComplete = xhr.loaded / xhr.total * 100;
|
||||
//console.log( Math.round( percentComplete, 2 ) + '% downloaded' );
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
let onError = function () { };
|
||||
|
||||
//canvas文字贴图方法
|
||||
//PS:待提炼 增强功能
|
||||
function getTextCanvas(text){
|
||||
var canvas = document.getElementById('canvastexture');
|
||||
// let width = 128;
|
||||
// let height = 64;
|
||||
// canvas.style.width = width + "px";
|
||||
// canvas.style.height = height + "px";
|
||||
|
||||
var ctx = canvas.getContext('2d');
|
||||
ctx.fillStyle = '#FFFFFF';
|
||||
ctx.fillRect(0, 0,128,64);
|
||||
ctx.font = "500px";
|
||||
ctx.fillStyle = '#000000';
|
||||
ctx.textAlign = 'center';
|
||||
ctx.textBaseline = 'middle';
|
||||
ctx.clearRect(0,0,128,64);
|
||||
////console.log(text.groupNumber);
|
||||
//ctx.fillText(text.trainNumber, width/2,height/4);
|
||||
ctx.fillText("车组号:"+text.groupNumber, 128/2,64*2/4);
|
||||
//ctx.fillText(text.trainModel.name, width/2,height*3/4);
|
||||
let data = ctx.getImageData(0, 0,128,64);
|
||||
return data;
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
export function TrainModel(opts) {
|
||||
|
||||
var scope = this;
|
||||
|
||||
this.mesh = null;
|
||||
this.meshurl = null;
|
||||
this.picurl = null;
|
||||
}
|
@ -1,84 +0,0 @@
|
||||
export function RailList(){
|
||||
let scope = this;
|
||||
|
||||
this.linkrail = [];
|
||||
|
||||
this.switchrail = [];
|
||||
|
||||
this.setrail = function(){
|
||||
|
||||
};
|
||||
|
||||
|
||||
this.resetrail = function(mapdata,scene){
|
||||
|
||||
|
||||
let section = mapdata.sectionlist.sections.datalist;
|
||||
|
||||
let n =0;
|
||||
for(let i in section){
|
||||
|
||||
n = n+1;
|
||||
var geometry = new THREE.PlaneBufferGeometry( section[i].lengthFact, 1, 1 );
|
||||
var material = new THREE.MeshBasicMaterial( {color: 0xffff00, side: THREE.DoubleSide} );
|
||||
var plane = new THREE.Mesh( geometry, material );
|
||||
plane.position.x = section[i].mesh.position.x;
|
||||
plane.position.y = 2+Math.random()*10;
|
||||
plane.position.z = section[i].mesh.position.z;
|
||||
plane.rotation.x = -Math.PI/2;
|
||||
plane.rotation.z = section[i].mesh.rotation._z;
|
||||
|
||||
// if( plane.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.rotation.x = -Math.PI/2;
|
||||
|
||||
|
||||
var circle2 = new THREE.Mesh( geometry2, material2 );
|
||||
|
||||
circle2.rotation.x = -Math.PI/2;
|
||||
|
||||
circle1.position.x = plane.position.x + (section[i].lengthFact)/2*Math.cos(plane.rotation.z);
|
||||
circle1.position.y = 1;
|
||||
circle1.position.z = plane.position.z - (section[i].lengthFact)/2*Math.sin(plane.rotation.z);
|
||||
circle2.position.x = plane.position.x - (section[i].lengthFact)/2*Math.cos(plane.rotation.z);
|
||||
circle2.position.y = 0.5;
|
||||
circle2.position.z = plane.position.z + (section[i].lengthFact)/2*Math.sin(plane.rotation.z);
|
||||
// }
|
||||
scene.add( circle1 );
|
||||
scene.add( circle2 );
|
||||
scene.add( plane );
|
||||
mapdata.sectionlist.sections.datalist[i].rail = [{
|
||||
x:circle2.position.x,
|
||||
z:circle2.position.z
|
||||
},{
|
||||
x:circle1.position.x,
|
||||
z:circle1.position.z
|
||||
}];
|
||||
// console.log(i);
|
||||
// console.log(section[i].mesh);
|
||||
// console.log(mapdata.sectionlist.sections.datalist[i].rail);
|
||||
// console.log("=======================");
|
||||
}
|
||||
// console.log(n);
|
||||
// for(let i=0;i<mapdata.switchlist.switchgroup.children.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.switchlist.switchgroup.children[i].position.x;
|
||||
// circle1.position.z = mapdata.switchlist.switchgroup.children[i].position.z;
|
||||
// circle1.rotation.x = -Math.PI/2;
|
||||
// scene.add( circle1 );
|
||||
// }
|
||||
};
|
||||
|
||||
this.getrail = function(){
|
||||
|
||||
};
|
||||
}
|
@ -1,911 +0,0 @@
|
||||
import {SectionModel} from '@/jlmap3d/edit/editmodel/SectionModel.js';
|
||||
import {SwitchModel} from '@/jlmap3d/edit/editmodel/SwitchModel.js';
|
||||
import { JL3D_LOCAL_STATIC } from '@/api/jlmap3d/assets3d.js';
|
||||
|
||||
export function SectionList() {
|
||||
|
||||
let scope = this;
|
||||
|
||||
this.type = "sectionlist";
|
||||
|
||||
this.sectiongroup = new THREE.Group();
|
||||
this.sectiongroup.name = "section";
|
||||
|
||||
|
||||
this.sections = {
|
||||
datalist:[],
|
||||
modellist:[]
|
||||
};
|
||||
this.stopsection = [];
|
||||
this.standtrack = [];
|
||||
var autorail;
|
||||
this.initpromise = function(jlmap3ddata,assetloader,sectiondata,switchdata,scene){
|
||||
console.log(sectiondata);
|
||||
console.log(sectiondata);
|
||||
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);
|
||||
}
|
||||
}
|
||||
autorail.rightlist = rightlist;
|
||||
autorail.leftlist = leftlist;
|
||||
|
||||
return new Promise(function(resolve, reject){
|
||||
// scene.add(scope.sectiondata);
|
||||
scene.add(scope.sectiongroup);
|
||||
|
||||
|
||||
//收集需要显示区段
|
||||
for(let i=0;i<sectiondata.length;i++){
|
||||
if(sectiondata[i].type == "01" || sectiondata[i].type == "03"){
|
||||
//初始化区段对象数据
|
||||
let newsection = new SectionModel(sectiondata[i]);
|
||||
// console.log(sectiondata[i]);
|
||||
newsection.name = sectiondata[i].name;
|
||||
newsection.code = sectiondata[i].code;
|
||||
newsection.index = i;
|
||||
newsection.type = sectiondata[i].type;
|
||||
newsection.lengthFact = sectiondata[i].lengthFact;
|
||||
|
||||
newsection.stationcode = sectiondata[i].stationCode;
|
||||
newsection.rsection = sectiondata[i].rightSectionCode;
|
||||
newsection.lsection = sectiondata[i].leftSectionCode;
|
||||
newsection.points = sectiondata[i].points;
|
||||
newsection.pointslength = sectiondata[i].points.length-1;
|
||||
newsection.rightlist = autorail.rightlist;
|
||||
newsection.leftlist = autorail.leftlist;
|
||||
// console.log(sectiondata[i].points.length);
|
||||
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("-----------------------");
|
||||
// console.log(sectiondata[i].code);
|
||||
// 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";
|
||||
// }
|
||||
// console.log(scope.sections.datalist[sectiondata[i].code]);
|
||||
if(sectiondata[i].standTrack == true){
|
||||
sectiondata[i].startx = sectiondata[i].points[0].x;
|
||||
sectiondata[i].starty = sectiondata[i].points[0].y;
|
||||
scope.sections.datalist[sectiondata[i].code].lengthFact = 134;
|
||||
sectiondata[i].lengthFact = 134;
|
||||
// console.log(sectiondata[i].lengthFact);
|
||||
scope.stopsection.push(sectiondata[i]);
|
||||
}
|
||||
// sections.modellist.push("");
|
||||
}
|
||||
}
|
||||
|
||||
//连接区段
|
||||
for(let i=0;i<switchdata.length;i++){
|
||||
let acode = switchdata[i].sectionACode;
|
||||
let bcode = switchdata[i].sectionBCode;
|
||||
let ccode = switchdata[i].sectionCCode;
|
||||
// console.log(switchdata[i]);
|
||||
|
||||
|
||||
let aposx = (scope.sections.datalist[acode].points[0].x + scope.sections.datalist[acode].points[scope.sections.datalist[acode].pointslength].x)/2;
|
||||
let cposx = (scope.sections.datalist[ccode].points[0].x + scope.sections.datalist[ccode].points[scope.sections.datalist[ccode].pointslength].x)/2;
|
||||
|
||||
let aposy = (scope.sections.datalist[acode].points[0].y + scope.sections.datalist[acode].points[scope.sections.datalist[acode].pointslength].y)/2;
|
||||
let cposy = (scope.sections.datalist[ccode].points[0].y + scope.sections.datalist[ccode].points[scope.sections.datalist[ccode].pointslength].y)/2;
|
||||
|
||||
// console.log("----------------");
|
||||
if(aposx > cposx){
|
||||
if(aposy < cposy){
|
||||
// ——A
|
||||
// /C
|
||||
scope.sections.datalist[ccode].ctype = 1;
|
||||
}else{
|
||||
// \C
|
||||
// ——A
|
||||
scope.sections.datalist[ccode].ctype = 2;
|
||||
}
|
||||
}else{
|
||||
if(aposy < cposy){
|
||||
// A——
|
||||
// \C
|
||||
scope.sections.datalist[ccode].ctype = 3;
|
||||
}else{
|
||||
// /C
|
||||
// A——
|
||||
scope.sections.datalist[ccode].ctype = 4;
|
||||
}
|
||||
}
|
||||
|
||||
if(scope.sections.datalist[acode].rsection == "" || scope.sections.datalist[acode].rsection == undefined){
|
||||
scope.sections.datalist[acode].rsection = bcode;
|
||||
scope.sections.datalist[acode].csection = ccode;
|
||||
}else if(scope.sections.datalist[acode].lsection == "" || scope.sections.datalist[acode].lsection == undefined){
|
||||
scope.sections.datalist[acode].lsection = bcode;
|
||||
scope.sections.datalist[acode].csection = ccode;
|
||||
}
|
||||
|
||||
if(scope.sections.datalist[bcode].rsection == "" || scope.sections.datalist[bcode].rsection == undefined){
|
||||
scope.sections.datalist[bcode].rsection = acode;
|
||||
}else if(scope.sections.datalist[bcode].lsection == "" ||scope.sections.datalist[bcode].lsection == undefined ){
|
||||
scope.sections.datalist[bcode].lsection = acode;
|
||||
}
|
||||
|
||||
if(scope.sections.datalist[ccode].rsection == "" || scope.sections.datalist[ccode].rsection == undefined){
|
||||
scope.sections.datalist[ccode].rsection = acode;
|
||||
}else if(scope.sections.datalist[ccode].lsection == "" || scope.sections.datalist[ccode].lsection == undefined){
|
||||
scope.sections.datalist[ccode].lsection = acode;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// console.log(scope.sections.datalist);
|
||||
// console.log(scope.stopsection);
|
||||
let stationlist = jlmap3ddata.stationstandlist.list;
|
||||
console.log(jlmap3ddata.stationstandlist.list);
|
||||
let stopsections = [];
|
||||
|
||||
|
||||
for(let i=0,leni = stationlist.length;i<leni;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;
|
||||
}
|
||||
}
|
||||
console.log(realstopsection);
|
||||
realstopsection.posx =(realstopsection.topsection.startx + realstopsection.downsection.startx)/2;
|
||||
|
||||
|
||||
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++){
|
||||
if(stopsections[i+1]){
|
||||
let findarray1 = {
|
||||
distance:0,
|
||||
findarray:[],
|
||||
};
|
||||
let findarray2 = {
|
||||
distance:0,
|
||||
findarray:[],
|
||||
};
|
||||
// console.log("===========================");
|
||||
// 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);
|
||||
console.log("==================");
|
||||
console.log(stopsections);
|
||||
// console.log(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 maxsection = null;
|
||||
// leng1 =leng1 + topresults.distance;
|
||||
// leng2 =leng2 + downresults.distance;
|
||||
// console.log(topresults);
|
||||
// console.log(topresults.distance);
|
||||
// console.log(downresults.distance);
|
||||
// console.log("------------------");
|
||||
|
||||
if(topresults.distance > downresults.distance){
|
||||
let offset = topresults.distance - downresults.distance;
|
||||
console.log(downresults.findarray);
|
||||
for(let n=0,lenn= downresults.findarray.length;n<lenn;n++){
|
||||
if(downresults.findarray[n].lengthFact>maxsection){
|
||||
maxlengthfact = downresults.findarray[n].lengthFact;
|
||||
console.log(n);
|
||||
|
||||
|
||||
maxsection = downresults.findarray[n];
|
||||
}
|
||||
}
|
||||
console.log(maxsection);
|
||||
scope.sections.datalist[maxsection.code].lengthFact += offset;
|
||||
}else if(topresults.distance < downresults.distance){
|
||||
let offset = downresults.distance - topresults.distance;
|
||||
for(let n=0,lenn= topresults.findarray.length;n<lenn;n++){
|
||||
if(topresults.findarray[n].lengthFact>maxsection){
|
||||
maxlengthfact = topresults.findarray[n].lengthFact;
|
||||
maxsection = topresults.findarray[n];
|
||||
}
|
||||
}
|
||||
scope.sections.datalist[maxsection.code].lengthFact += offset;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
let topstartpoint = {
|
||||
x:stopsections[0].topsection.points[0].x,
|
||||
y:0,
|
||||
z:stopsections[0].topsection.points[0].y
|
||||
};
|
||||
|
||||
let downstartpoint = {
|
||||
x:stopsections[0].downsection.points[0].x,
|
||||
y:0,
|
||||
z:stopsections[0].downsection.points[0].y
|
||||
};
|
||||
console.log(stopsections[1].topsection.lengthFact);
|
||||
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 = {
|
||||
x:scope.sections.datalist[stopsections[i].topsection.code].mesh.position.x+66.5,
|
||||
y:0,
|
||||
z:scope.sections.datalist[stopsections[i].topsection.code].mesh.position.z
|
||||
};
|
||||
|
||||
let downnextpoint = {
|
||||
x:scope.sections.datalist[stopsections[i].downsection.code].mesh.position.x+66.5,
|
||||
y:0,
|
||||
z:scope.sections.datalist[stopsections[i].downsection.code].mesh.position.z
|
||||
};
|
||||
let topstart = scope.sections.datalist[stopsections[i].topsection.code].rsection;
|
||||
let downstart = scope.sections.datalist[stopsections[i].downsection.code].rsection;
|
||||
|
||||
createsection(autorail,topnextpoint,topstart,stopsections[i+1].topsection.code,0);
|
||||
createsection(autorail,downnextpoint,downstart,stopsections[i+1].downsection.code,34.8);
|
||||
}
|
||||
}
|
||||
let stations = jlmap3ddata.stationstandlist.list;
|
||||
let num;
|
||||
let num2;
|
||||
for(let j=0;j<assetloader.modellist.length;j++){
|
||||
if(assetloader.modellist[j].deviceType == "stand"){
|
||||
num = j;
|
||||
}
|
||||
if(assetloader.modellist[j].deviceType == "standwaice"){
|
||||
num2 = j;
|
||||
console.log(assetloader.modellist[num2]);
|
||||
console.log(assetloader.modellist[num2].mesh);
|
||||
assetloader.modellist[num2].mesh.rotation.x = 0;
|
||||
}
|
||||
}
|
||||
|
||||
for(let j=0,lenj=stations.length;j<lenj;j++){
|
||||
// console.log(j);
|
||||
// console.log(scope.sections.datalist[stations[j].direction1.section]);
|
||||
let x = scope.sections.datalist[stations[j].direction1.section].mesh.position.x;
|
||||
let z = (scope.sections.datalist[stations[j].direction1.section].mesh.position.z+scope.sections.datalist[stations[j].direction2.section].mesh.position.z)/2;
|
||||
let mesh;
|
||||
if(stations[j].direction1.inside == true){
|
||||
mesh = assetloader.modellist[num].mesh.clone(true);
|
||||
}else{
|
||||
mesh = assetloader.modellist[num2].mesh.clone(true);
|
||||
}
|
||||
|
||||
jlmap3ddata.stationstandlist.list[j].modelid = assetloader.modellist[num].modelid;
|
||||
jlmap3ddata.stationstandlist.list[j].mesh = mesh;
|
||||
// console.log(x);
|
||||
mesh.position.set(x,0,z);
|
||||
// mesh.rotation.x = Math.PI/2;
|
||||
scene.add( mesh );
|
||||
}
|
||||
|
||||
// console.log(scope.sections.datalist[stations[0].direction1.section]);
|
||||
|
||||
scope.sections.datalist[stations[0].direction1.section].endbuild = true;
|
||||
buildsectionall(scope.sections.datalist[stations[0].direction1.section]);
|
||||
|
||||
// if(sectiondata[i].standTrack == true){
|
||||
// scope.stopsection.push(sectiondata[i]);
|
||||
// }
|
||||
|
||||
resolve("loadersection");
|
||||
});
|
||||
|
||||
};
|
||||
function buildsectionall(origin){
|
||||
if(origin.rsection){
|
||||
if(scope.sections.datalist[origin.rsection].endbuild == false){
|
||||
scope.sections.datalist[origin.rsection].endbuild = true;
|
||||
if(scope.sections.datalist[origin.rsection].mesh == null){
|
||||
buildsection(origin,scope.sections.datalist[origin.rsection],"right");
|
||||
buildsectionall(scope.sections.datalist[origin.rsection]);
|
||||
}else{
|
||||
buildsectionall(scope.sections.datalist[origin.rsection]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if(origin.lsection){
|
||||
if(scope.sections.datalist[origin.lsection].endbuild == false){
|
||||
scope.sections.datalist[origin.lsection].endbuild = true;
|
||||
if(scope.sections.datalist[origin.lsection].mesh == null){
|
||||
buildsection(origin,scope.sections.datalist[origin.lsection],"left");
|
||||
buildsectionall(scope.sections.datalist[origin.lsection]);
|
||||
}else{
|
||||
buildsectionall(scope.sections.datalist[origin.lsection]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(origin.csection){
|
||||
if(scope.sections.datalist[origin.csection].endbuild == false){
|
||||
scope.sections.datalist[origin.csection].endbuild = true;
|
||||
if(scope.sections.datalist[origin.csection].mesh == null){
|
||||
buildsection(origin,scope.sections.datalist[origin.csection],"cross");
|
||||
buildsectionall(scope.sections.datalist[origin.csection]);
|
||||
}else{
|
||||
buildsectionall(scope.sections.datalist[origin.csection]);
|
||||
}
|
||||
}
|
||||
}
|
||||
// return ;
|
||||
}
|
||||
|
||||
function buildsection(origin,data,type){
|
||||
// console.log(data);
|
||||
// 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);
|
||||
for(let i=0;i<autorail.rightlist.length;i++){
|
||||
testmesh2.geometry.attributes.position.array[autorail.rightlist[i]*3] = len;
|
||||
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();
|
||||
testmesh2.code = data.code;
|
||||
testmesh2.lengthFact = data.lengthFact;
|
||||
scope.sectiongroup.add( testmesh2 );
|
||||
|
||||
|
||||
data.mesh = testmesh2;
|
||||
if(data.points[0].x == data.points[data.pointslength].x && data.points[0].y == data.points[data.pointslength].y){
|
||||
|
||||
}else{
|
||||
if(type == "right"){
|
||||
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.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.rp.z != data.lp.z){
|
||||
testmesh2.railpoint = [
|
||||
{x:data.lp.x,y:0,z:data.lp.z},
|
||||
{x:testmesh2.position.x,y:0,z:testmesh2.position.z},
|
||||
{x:data.rp.x,y:0,z:data.rp.z}
|
||||
];
|
||||
}else{
|
||||
testmesh2.railpoint = [
|
||||
{x:data.lp.x,y:0,z:data.lp.z},
|
||||
{x:data.rp.x,y:0,z:data.rp.z}
|
||||
];
|
||||
}
|
||||
// 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"){
|
||||
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.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.rp.z != data.lp.z){
|
||||
testmesh2.railpoint = [
|
||||
{x:data.lp.x,y:0,z:data.lp.z},
|
||||
{x:testmesh2.position.x,y:0,z:testmesh2.position.z},
|
||||
{x:data.rp.x,y:0,z:data.rp.z}
|
||||
];
|
||||
}else{
|
||||
testmesh2.railpoint = [
|
||||
{x:data.lp.x,y:0,z:data.lp.z},
|
||||
{x:data.rp.x,y:0,z:data.rp.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.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);
|
||||
// console.log(scope.sections.datalist[data.code].points.length);
|
||||
// console.log(scope.sections.datalist[data.code]);
|
||||
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 = ;
|
||||
}
|
||||
testmesh2.railpoint = [
|
||||
{x:data.lp.x,y:0,z:data.lp.z},
|
||||
{x:testmesh2.position.x,y:0,z:testmesh2.position.z},
|
||||
{x:data.rp.x,y:0,z:data.rp.z}
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// var box = new THREE.BoxHelper( testmesh2, 0xffffff );
|
||||
// scope.sectiongroup.add( box );
|
||||
|
||||
}
|
||||
function createsection(autorail,position,start,end,py){
|
||||
position.z = py;
|
||||
if(scope.sections.datalist[start].code == end){
|
||||
console.log(scope.sections.datalist[start]);
|
||||
}
|
||||
let len = scope.sections.datalist[start].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;
|
||||
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();
|
||||
testmesh2.code = start;
|
||||
|
||||
// var geometry = new THREE.BoxBufferGeometry( scope.sections.datalist[start].lengthFact, 1, 3 );
|
||||
// var material = new THREE.MeshBasicMaterial( {color: 0xFFFFFF*Math.random()} );
|
||||
// var testmesh2 = new THREE.Mesh( geometry, material );
|
||||
|
||||
testmesh2.position.set(position.x+(scope.sections.datalist[start].lengthFact/2),position.y,position.z);
|
||||
|
||||
scope.sections.datalist[start].lp = {
|
||||
x:testmesh2.position.x-scope.sections.datalist[start].lengthFact/2,
|
||||
y:0,
|
||||
z:testmesh2.position.z
|
||||
};
|
||||
scope.sections.datalist[start].rp = {
|
||||
x:testmesh2.position.x+scope.sections.datalist[start].lengthFact/2,
|
||||
y:0,
|
||||
z:testmesh2.position.z
|
||||
};
|
||||
testmesh2.railpoint = [
|
||||
{x:scope.sections.datalist[start].lp.x,y:0,z:scope.sections.datalist[start].lp.z},
|
||||
{x:scope.sections.datalist[start].rp.x,y:0,z:scope.sections.datalist[start].rp.z}
|
||||
];
|
||||
|
||||
scope.sectiongroup.add( testmesh2 );
|
||||
scope.sections.datalist[start].mesh = testmesh2;
|
||||
scope.sections.datalist[start].mesh.lengthFact = scope.sections.datalist[start].lengthFact;
|
||||
let topstartpoint = {
|
||||
x:position.x+scope.sections.datalist[start].lengthFact,
|
||||
y:0,
|
||||
z:position.z
|
||||
};
|
||||
// console.log(topstartpoint.x);
|
||||
// var box = new THREE.BoxHelper( testmesh2, 0xffffff );
|
||||
// scope.sectiongroup.add( box );
|
||||
if(scope.sections.datalist[start].code == end){
|
||||
// console.log(scope.sections.datalist[start]);
|
||||
return ;
|
||||
}else{
|
||||
return createsection(autorail,topstartpoint,scope.sections.datalist[start].rsection,end,py);
|
||||
}
|
||||
}
|
||||
|
||||
function findnextsection(findarray,start,end){
|
||||
// console.log("====================");
|
||||
// console.log(start);
|
||||
// console.log(end);
|
||||
// console.log("====================");
|
||||
console.log(scope.sections.datalist[start]);
|
||||
console.log(end);
|
||||
if(scope.sections.datalist[start].code == end){
|
||||
return findarray;
|
||||
}else{
|
||||
findarray.findarray.push(scope.sections.datalist[start]);
|
||||
findarray.distance = findarray.distance + scope.sections.datalist[start].lengthFact;
|
||||
// console.log(scope.sections.datalist[start]);
|
||||
// console.log(scope.sections.datalist[start].code);
|
||||
// console.log(scope.sections.datalist[start]);
|
||||
// return function(){
|
||||
return findnextsection(findarray,scope.sections.datalist[start].rsection,end);
|
||||
// }
|
||||
}
|
||||
}
|
||||
function compare(property){
|
||||
return function(a,b){
|
||||
var value1 = a[property];
|
||||
var value2 = b[property];
|
||||
return value1 - value2;
|
||||
}
|
||||
}
|
||||
|
||||
this.loadpromise = function(jlmap3ddata,assetloader,sectiondata,scene){
|
||||
// console.log("-------------------");
|
||||
// console.log(jlmap3ddata.sectionlist.sections.datalist);
|
||||
// console.log(sectiondata);
|
||||
var texture = new THREE.TextureLoader().load( JL3D_LOCAL_STATIC+'/test/z0251.png' );
|
||||
texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
|
||||
texture.repeat.set( 1,1);
|
||||
|
||||
var selectmaterial = new THREE.MeshPhongMaterial( { map: texture,transparent:true,alphaTest:0.1 } );
|
||||
|
||||
|
||||
scene.add(scope.sectiongroup);
|
||||
return new Promise(function(resolve, reject){
|
||||
for(let i=0,leni = sectiondata.length;i<leni;i++){
|
||||
let newsection = {
|
||||
code:sectiondata[i].code,
|
||||
name:sectiondata[i].name,
|
||||
standTrack:sectiondata[i].standTrack,
|
||||
rail:sectiondata[i].rail,
|
||||
lengthFact:sectiondata[i].lengthFact,
|
||||
rp:sectiondata[i].rp,
|
||||
lp:sectiondata[i].lp,
|
||||
railpoint:sectiondata[i].railpoint,
|
||||
mesh:null
|
||||
};
|
||||
|
||||
let len = newsection.lengthFact;
|
||||
let testmesh2 = null;
|
||||
if(newsection.railpoint){
|
||||
if(newsection.railpoint.length>2){
|
||||
// console.log(newsection);
|
||||
let height = Math.random()/1000;
|
||||
var closedSpline = new THREE.CatmullRomCurve3( [
|
||||
new THREE.Vector3(newsection.railpoint[0].x,height,newsection.railpoint[0].z),
|
||||
new THREE.Vector3(newsection.railpoint[1].x,height,newsection.railpoint[1].z),
|
||||
new THREE.Vector3(newsection.railpoint[2].x,height,newsection.railpoint[2].z)
|
||||
] );
|
||||
closedSpline.type = 'catmullrom';
|
||||
closedSpline.closed = false;
|
||||
var extrudeSettings = {
|
||||
steps : 5,
|
||||
curveSegments : 1,
|
||||
bevelSegments : 1,
|
||||
bevelEnabled : false,
|
||||
extrudePath : closedSpline,
|
||||
};
|
||||
var shape = new THREE.Shape();
|
||||
shape.moveTo( 0,-2 );
|
||||
shape.lineTo( 0, 2 );
|
||||
var geometry = new THREE.ExtrudeBufferGeometry( shape, extrudeSettings );
|
||||
testmesh2 = new THREE.Mesh( geometry, selectmaterial );
|
||||
|
||||
testmesh2.railpoint = [
|
||||
{x:newsection.railpoint[0].x,y:height,z:newsection.railpoint[0].z},
|
||||
{x:newsection.railpoint[1].x,y:height,z:newsection.railpoint[1].z},
|
||||
{x:newsection.railpoint[2].x,y:height,z:newsection.railpoint[2].z},
|
||||
];
|
||||
testmesh2.lengthFact = newsection.railpoint[2].x - newsection.railpoint[0].x;
|
||||
// closedSpline.arcLengthDivisions;
|
||||
let count = testmesh2.geometry.attributes.position.count/3;
|
||||
|
||||
for(let i=0;i<count;i++){
|
||||
let ui=i*6;
|
||||
if(i%2 != 0){
|
||||
testmesh2.geometry.attributes.uv.array[ui] = 0;
|
||||
testmesh2.geometry.attributes.uv.array[ui+1] = 1;
|
||||
testmesh2.geometry.attributes.uv.array[ui+2] = len/5;
|
||||
testmesh2.geometry.attributes.uv.array[ui+3] = 1;
|
||||
testmesh2.geometry.attributes.uv.array[ui+4] = len/5;
|
||||
testmesh2.geometry.attributes.uv.array[ui+5] = 0;
|
||||
}else{
|
||||
testmesh2.geometry.attributes.uv.array[ui] = 0;
|
||||
testmesh2.geometry.attributes.uv.array[ui+1] = 0;
|
||||
testmesh2.geometry.attributes.uv.array[ui+2] = 0;
|
||||
testmesh2.geometry.attributes.uv.array[ui+3] = 1;
|
||||
testmesh2.geometry.attributes.uv.array[ui+4] = len/5;
|
||||
testmesh2.geometry.attributes.uv.array[ui+5] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
let height = Math.random()/1000;
|
||||
|
||||
var closedSpline = new THREE.CatmullRomCurve3( [
|
||||
new THREE.Vector3(newsection.railpoint[0].x,height,newsection.railpoint[0].z),
|
||||
new THREE.Vector3(newsection.railpoint[1].x,height,newsection.railpoint[0].z),
|
||||
] );
|
||||
|
||||
closedSpline.type = 'catmullrom';
|
||||
closedSpline.closed = false;
|
||||
// Set up settings for later extrusion
|
||||
var extrudeSettings = {
|
||||
steps : 1,
|
||||
curveSegments : 1,
|
||||
bevelSegments : 1,
|
||||
bevelEnabled : false,
|
||||
extrudePath : closedSpline,
|
||||
};
|
||||
var shape = new THREE.Shape();
|
||||
shape.moveTo( -2,0 );
|
||||
shape.lineTo( 2,0 );
|
||||
// Extrude the triangle along the CatmullRom curve
|
||||
var geometry = new THREE.ExtrudeBufferGeometry( shape, extrudeSettings );
|
||||
testmesh2 = new THREE.Mesh( geometry, selectmaterial );
|
||||
testmesh2.railpoint = [
|
||||
{x:newsection.railpoint[0].x,y:height,z:newsection.railpoint[0].z},
|
||||
{x:newsection.railpoint[1].x,y:height,z:newsection.railpoint[0].z},
|
||||
];
|
||||
testmesh2.lengthFact = newsection.railpoint[1].x - newsection.railpoint[0].x;
|
||||
// closedSpline.arcLengthDivisions;
|
||||
let count = testmesh2.geometry.attributes.position.count/3;
|
||||
|
||||
for(let i=0;i<count;i++){
|
||||
let ui=i*6;
|
||||
if(i%2 != 0){
|
||||
testmesh2.geometry.attributes.uv.array[ui] = 0;
|
||||
testmesh2.geometry.attributes.uv.array[ui+1] = 1;
|
||||
testmesh2.geometry.attributes.uv.array[ui+2] = len;
|
||||
testmesh2.geometry.attributes.uv.array[ui+3] = 1;
|
||||
testmesh2.geometry.attributes.uv.array[ui+4] = len;
|
||||
testmesh2.geometry.attributes.uv.array[ui+5] = 0;
|
||||
}else{
|
||||
testmesh2.geometry.attributes.uv.array[ui] = 0;
|
||||
testmesh2.geometry.attributes.uv.array[ui+1] = 0;
|
||||
testmesh2.geometry.attributes.uv.array[ui+2] = 0;
|
||||
testmesh2.geometry.attributes.uv.array[ui+3] = 1;
|
||||
testmesh2.geometry.attributes.uv.array[ui+4] = len;
|
||||
testmesh2.geometry.attributes.uv.array[ui+5] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
testmesh2.code = newsection.code;
|
||||
testmesh2.standTrack = newsection.standTrack;
|
||||
testmesh2.meshtype = "section";
|
||||
|
||||
// testmesh2.geometry.computeBoundingBox();
|
||||
// testmesh2.geometry.center()
|
||||
// testmesh2.position.set(sectiondata[i].position.x,sectiondata[i].position.y,sectiondata[i].position.z);
|
||||
scope.sectiongroup.add(testmesh2);
|
||||
newsection.mesh = testmesh2;
|
||||
scope.sections.datalist[newsection.code] = newsection;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
resolve("loadersection");
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
this.resetsection = function(scene){
|
||||
scene.remove(scope.sectiongroup);
|
||||
};
|
||||
|
||||
this.reposition = function(){
|
||||
|
||||
}
|
||||
|
||||
|
||||
this.update = function(){
|
||||
|
||||
}
|
||||
|
||||
this.renderon = function(){
|
||||
|
||||
}
|
||||
|
||||
this.renderoff = function(){
|
||||
|
||||
}
|
||||
|
||||
this.dispose = function(){
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
export function SectionModel(data) {
|
||||
var scope = this;
|
||||
//命名
|
||||
this.name = null;
|
||||
//code
|
||||
this.code = null;
|
||||
//索引位置
|
||||
this.index = null;
|
||||
//轨迹点
|
||||
this.rail = [];
|
||||
|
||||
this.railline = null;
|
||||
//长度
|
||||
this.distance = [];
|
||||
|
||||
this.isStandTrack = null;
|
||||
|
||||
this.type = null;
|
||||
//指向模型
|
||||
this.mesh = null;
|
||||
// //模型地址
|
||||
// this.meshurl = null;
|
||||
// //贴图地址
|
||||
// this.picurl = null;
|
||||
|
||||
}
|
@ -1,270 +0,0 @@
|
||||
import {SignalModel} from '@/jlmap3d/edit/editmodel/SignalModel.js';
|
||||
|
||||
export function SignalList() {
|
||||
|
||||
let scope = this;
|
||||
|
||||
this.type = "signallist";
|
||||
|
||||
this.list = [];
|
||||
|
||||
this.group = new THREE.Group();
|
||||
|
||||
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;
|
||||
if(netdata){
|
||||
netsignal = JSON.parse(netdata);
|
||||
haddata = true;
|
||||
}
|
||||
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++){
|
||||
if(data[i].virtual == false){
|
||||
let newsignal = new SignalModel(data[i]);
|
||||
if(haddata == false){
|
||||
// console.log(data[i])
|
||||
let newmesh = assetloader.modellist[num].mesh.clone(true);
|
||||
|
||||
newmesh.name = data[i].name;
|
||||
newmesh.modelid = assetloader.modellist[num].id;
|
||||
newmesh.code = data[i].code;
|
||||
newmesh.sectionCode = data[i].sectionCode;
|
||||
newmesh.right = data[i].right;
|
||||
newmesh.virtual = data[i].virtual;
|
||||
for(let j=0;j<newmesh.children.length;j++){
|
||||
newmesh.children[j].code = data[i].code;
|
||||
}
|
||||
let section = sectiondata[data[i].sectionCode];
|
||||
let posx = null;
|
||||
|
||||
if(data[i].sectionOffset > section.lengthFact/2){
|
||||
posx = section.mesh.position.x + data[i].sectionOffset - section.lengthFact/2;
|
||||
}else{
|
||||
posx = section.mesh.position.x - (section.lengthFact/2 - data[i].sectionOffset);
|
||||
}
|
||||
//根据线路方向修改信号灯位置
|
||||
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].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.sectionOffset = data[i].sectionOffset;
|
||||
newmesh.sectionCode = data[i].sectionCode;
|
||||
newmesh.right = data[i].right;
|
||||
newsignal.mesh = newmesh;
|
||||
|
||||
newsignal.sectionOffset = data[i].sectionOffset;
|
||||
newsignal.mesh.status = "01";
|
||||
newsignal.name = data[i].name;
|
||||
newsignal.modelid = assetloader.modellist[num].id;
|
||||
newsignal.code = data[i].code;
|
||||
newsignal.sectionCode = data[i].sectionCode;
|
||||
newsignal.right = data[i].right;
|
||||
scope.group.add(newmesh);
|
||||
scope.list.push(newsignal);
|
||||
|
||||
}else{
|
||||
for(let j=0;j<assetloader.modellist.length;j++){
|
||||
if(assetloader.modellist[j].id == netsignal[i].modelid){
|
||||
num = j;
|
||||
}
|
||||
}
|
||||
let newmesh = assetloader.modellist[num].mesh.clone(true);
|
||||
|
||||
newmesh.uuid = netsignal[i].id;
|
||||
newmesh.name = netsignal[i].name;
|
||||
newmesh.modelid = assetloader.modellist[num].id;
|
||||
newmesh.code = netsignal[i].code;
|
||||
newmesh.virtual = data[i].virtual;
|
||||
for(let j=0;j<newmesh.children.length;j++){
|
||||
newmesh.children[j].code = netsignal[i].code;
|
||||
}
|
||||
newmesh.position.x = netsignal[i].position.x;
|
||||
newmesh.position.y = netsignal[i].position.y;
|
||||
newmesh.position.z = netsignal[i].position.z;
|
||||
newmesh.rotation.x = netsignal[i].rotation._x;
|
||||
newmesh.rotation.y = netsignal[i].rotation._y;
|
||||
newmesh.rotation.z = netsignal[i].rotation._z;
|
||||
newmesh.scale.x = netsignal[i].scale.x;
|
||||
newmesh.scale.y = netsignal[i].scale.y;
|
||||
newmesh.scale.z = netsignal[i].scale.z;
|
||||
|
||||
|
||||
// newsignal.mesh = newmesh;
|
||||
newsignal.mesh.status = "01";
|
||||
scope.group.add(newmesh);
|
||||
scope.list.push(newsignal);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
scene.add(scope.group);
|
||||
resolve("loadedsignal");
|
||||
});
|
||||
}
|
||||
|
||||
this.loadpromise = function(signaldata,scene,assetloader,data){
|
||||
return new Promise(function(resolve, reject){
|
||||
let num;
|
||||
for(let j=0;j<assetloader.modellist.length;j++){
|
||||
if(assetloader.modellist[j].type == "signal"){
|
||||
num = j;
|
||||
}
|
||||
}
|
||||
for(let i=0;i<signaldata.length;i++){
|
||||
//signaldata[i].virtual == "false"
|
||||
for(let n=0;n<data.length;n++){
|
||||
if(signaldata[i].code == data[n].code){
|
||||
if(data[n].virtual == false){
|
||||
let newsignal = new SignalModel(signaldata[i]);
|
||||
|
||||
// console.log(signaldata[i]);
|
||||
let newmesh = assetloader.modellist[num].mesh.clone(true);
|
||||
newmesh.sectionCode = data[n].sectionCode;
|
||||
newmesh.sectionOffset = data[n].sectionOffset;
|
||||
// newmesh.uuid = signaldata[i].id;
|
||||
for(let j=0;j<newmesh.children.length;j++){
|
||||
newmesh.children[j].code = signaldata[i].code;
|
||||
}
|
||||
newmesh.name = signaldata[i].name;
|
||||
newmesh.modelid = assetloader.modellist[num].id;
|
||||
newmesh.code = signaldata[i].code;
|
||||
newmesh.right = data[n].right;
|
||||
newmesh.virtual = data[n].virtual;
|
||||
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);
|
||||
n = data.length;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
scene.add(scope.group);
|
||||
resolve("loadedsignal");
|
||||
});
|
||||
};
|
||||
this.resetsignal = function(jlmap3ddata){
|
||||
// console.log(jlmap3ddata.linksgroup);
|
||||
let sectiondata = jlmap3ddata.sectionlist.sectiongroup.children;
|
||||
for(let i=0;i<scope.group.children.length;i++){
|
||||
let signaldata = scope.group.children[i];
|
||||
|
||||
for(let j=0;j<sectiondata.length;j++){
|
||||
if(sectiondata[j].code == signaldata.sectionCode){
|
||||
let section = sectiondata[j];
|
||||
let posx = null;
|
||||
// console.log(section);
|
||||
|
||||
posx = section.railpoint[0].x + signaldata.sectionOffset;
|
||||
|
||||
//根据线路方向修改信号灯位置
|
||||
if(signaldata.right == false){
|
||||
if(section.standTrack == true){
|
||||
posx = posx - 7;
|
||||
}
|
||||
|
||||
signaldata.position.set(posx,0,section.railpoint[0].z-3);
|
||||
signaldata.rotation.z = ( Math.PI / 2 );
|
||||
}else if(signaldata.right == true){
|
||||
if(section.standTrack == true){
|
||||
posx = posx + 7;
|
||||
}
|
||||
signaldata.position.set(posx,0,section.railpoint[0].z+3);
|
||||
signaldata.rotation.z = ( - Math.PI / 2 );
|
||||
}
|
||||
j = sectiondata.length;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
this.init = function(data,realsectionlist,scene,assetloader){
|
||||
|
||||
|
||||
scope.group.name = "signal";
|
||||
//遍历信号数据
|
||||
for(let i=0;i<data.length;i++){
|
||||
let newsignal = new SignalModel(data);
|
||||
|
||||
let newmesh = assetloader.modellist[0].mesh.clone(true);
|
||||
|
||||
newmesh.name = assetloader.modellist[0].id;
|
||||
newmesh.code = data[i].code;
|
||||
for(let j=0;j<newmesh.children.length;j++){
|
||||
newmesh.children[j].code = data[i].code;
|
||||
}
|
||||
|
||||
//根据线路方向修改信号灯位置
|
||||
if(data[i].directionType == "01"){
|
||||
newmesh.position.set(data[i].position.x,1,data[i].position.y-10);
|
||||
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.rotation.z = ( - Math.PI / 2 );
|
||||
}
|
||||
//newmesh.scale.set(0.1,0.1,0.1);
|
||||
newsignal.mesh = newmesh;
|
||||
newsignal.mesh.status = "01";
|
||||
scope.group.add(newsignal.mesh);
|
||||
scope.list.push(newsignal);
|
||||
|
||||
}
|
||||
scene.add(scope.group);
|
||||
}
|
||||
|
||||
this.reposition = function(){
|
||||
|
||||
}
|
||||
|
||||
this.update = function(){
|
||||
|
||||
}
|
||||
|
||||
this.renderon = function(){
|
||||
|
||||
}
|
||||
|
||||
this.renderoff = function(){
|
||||
|
||||
}
|
||||
|
||||
this.dispose = function(){
|
||||
|
||||
}
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
export function SignalModel(data) {
|
||||
|
||||
this.uuid = null;
|
||||
this.code = null;
|
||||
this.name = null;
|
||||
this.modelid = null;
|
||||
this.type = null;
|
||||
this.direction = null;
|
||||
this.ismodel = false;
|
||||
this.istexture = false;
|
||||
this.modelurl = null;
|
||||
// this.textures = {
|
||||
// red:null,
|
||||
// yellor:null,
|
||||
// green:null
|
||||
// }
|
||||
// this.position = {
|
||||
// x:0,
|
||||
// y:0,
|
||||
// z:0
|
||||
// };
|
||||
// this.rotation = {
|
||||
// x:0,
|
||||
// y:0,
|
||||
// z:0
|
||||
// };
|
||||
// this.scale = {
|
||||
// x:0,
|
||||
// y:0,
|
||||
// z:0
|
||||
// }
|
||||
|
||||
this.mesh = null;
|
||||
this.meshurl = null;
|
||||
this.picurl = null;
|
||||
}
|
@ -1,301 +0,0 @@
|
||||
import {StationStandModel} from '@/jlmap3d/edit/editmodel/StationStandModel.js';
|
||||
|
||||
export function StationStandList() {
|
||||
|
||||
let scope = this;
|
||||
|
||||
this.type = "stationstandlist";
|
||||
|
||||
this.list = [];
|
||||
|
||||
this.group = new THREE.Group();
|
||||
|
||||
this.textlist = [];
|
||||
|
||||
this.initpromise = function(jlmap3ddata,stationdata,stationstanddata,scene,assetloader,netdata){
|
||||
|
||||
return new Promise(function(resolve, reject){
|
||||
|
||||
let netstand = null;
|
||||
let haddata = false;
|
||||
if(netdata){
|
||||
haddata = true;
|
||||
}
|
||||
scope.group.name = "station";
|
||||
scene.add(scope.group);
|
||||
//遍历车站数据
|
||||
for(let i=0;i<stationdata.length;i++){
|
||||
|
||||
let newstationstand = new StationStandModel(stationdata[i]);
|
||||
//判断站台是否显示
|
||||
|
||||
if(stationdata[i].visible == true){
|
||||
|
||||
//遍历车站站台数据
|
||||
for(let j=0;j<stationstanddata.length;j++){
|
||||
|
||||
if(stationstanddata[j].small == false){
|
||||
//收集有效车站数据
|
||||
if(stationstanddata[j].stationCode == stationdata[i].code){
|
||||
newstationstand.name = stationdata[i].name;
|
||||
|
||||
newstationstand.code = stationdata[i].code;
|
||||
//向右上行
|
||||
if(stationstanddata[j].right == true){
|
||||
newstationstand.direction1.code = stationstanddata[j].code;
|
||||
newstationstand.direction1.position = stationstanddata[j].position;
|
||||
newstationstand.direction1.name = stationstanddata[j].name;
|
||||
newstationstand.direction1.screenDoorOpenStatus = "01";
|
||||
newstationstand.direction1.section = stationstanddata[j].standTrackCode;
|
||||
newstationstand.direction1.inside = stationstanddata[j].inside;
|
||||
}
|
||||
//向左下行
|
||||
if(stationstanddata[j].right == false){
|
||||
newstationstand.direction2.code = stationstanddata[j].code;
|
||||
newstationstand.direction2.position = stationstanddata[j].position;
|
||||
newstationstand.direction2.name = stationstanddata[j].name;
|
||||
newstationstand.direction2.screenDoorOpenStatus = "01";
|
||||
newstationstand.direction2.section = stationstanddata[j].standTrackCode;
|
||||
newstationstand.direction2.inside = stationstanddata[j].inside;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if(newstationstand.code != null){
|
||||
scope.list.push(newstationstand);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
console.log(scope.list);
|
||||
//建立需要显示车的车站模型对象
|
||||
// for(let i=0;i<scope.list.length;i++){
|
||||
//
|
||||
// let num;
|
||||
// if(haddata == false){
|
||||
// for(let j=0;j<assetloader.modellist.length;j++){
|
||||
// if(assetloader.modellist[j].deviceType == "stand"){
|
||||
// num = j;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// scope.list[i].mesh = assetloader.modellist[num].mesh.clone(true);
|
||||
//
|
||||
// scope.list[i].uuid = assetloader.modellist[num].uuid;
|
||||
// scope.list[i].id = assetloader.modellist[num].id;
|
||||
// scope.list[i].modelid = assetloader.modellist[num].id;
|
||||
// scope.list[i].mesh.code = scope.list[i].code;
|
||||
//
|
||||
// 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);
|
||||
//
|
||||
//
|
||||
// // 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].deviceType == "stand"){
|
||||
// num = j;
|
||||
// }
|
||||
// }
|
||||
// scope.list[i].mesh = assetloader.modellist[num].mesh.clone(true);
|
||||
// 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 = netdata[i].code;
|
||||
// }
|
||||
//
|
||||
// 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 = 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} );
|
||||
// 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);
|
||||
// }
|
||||
//
|
||||
// // scene.add(plane);
|
||||
// }
|
||||
|
||||
resolve("loadedstation");
|
||||
});
|
||||
}
|
||||
this.loadpromise = function(jlmap3ddata,standsdata,jlmapstanddata,scene,assetloader){
|
||||
return new Promise(function(resolve, reject){
|
||||
// console.log(jlmap3ddata);
|
||||
// console.log(standsdata);
|
||||
// console.log(jlmapstanddata);
|
||||
let stations = jlmap3ddata.stationstandlist.list;
|
||||
let num;
|
||||
let num2;
|
||||
let num3;
|
||||
for(let j=0;j<assetloader.modellist.length;j++){
|
||||
if(assetloader.modellist[j].type == "stationInside"){
|
||||
num = j;
|
||||
}
|
||||
if(assetloader.modellist[j].type == "stationOutside"){
|
||||
num2 = j;
|
||||
}
|
||||
if(assetloader.modellist[j].type == "stationThree"){
|
||||
num3 = j;
|
||||
}
|
||||
|
||||
|
||||
if(assetloader.modellist[j].deviceType == "stand"){
|
||||
num = j;
|
||||
}
|
||||
if(assetloader.modellist[j].deviceType == "standwaice"){
|
||||
num2 = j;
|
||||
// assetloader.modellist[num2].mesh.rotation.y = Math.PI/2;
|
||||
}
|
||||
if(assetloader.modellist[j].deviceType == "station3"){
|
||||
num3 = j;
|
||||
}
|
||||
}
|
||||
// console.log("+++++++++++++");
|
||||
// console.log(jlmapstanddata);
|
||||
// console.log(standsdata);
|
||||
for(let i=0;i<standsdata.length;i++){
|
||||
let newstationstand = new StationStandModel(standsdata[i]);
|
||||
let newstationmesh;
|
||||
for(let j=0;j<jlmapstanddata.length;j++){
|
||||
if(jlmapstanddata[j].code == standsdata[i].direction1.code){
|
||||
if(standsdata[i].code != "Station96090"){
|
||||
if(standsdata[i].inside == true){
|
||||
newstationmesh = assetloader.modellist[num].mesh.clone(true);
|
||||
}else{
|
||||
newstationmesh = assetloader.modellist[num2].mesh.clone(true);
|
||||
}
|
||||
// console.log(jlmapstanddata[j]);
|
||||
newstationstand.code = standsdata[i].code;
|
||||
newstationstand.name = standsdata[i].name;
|
||||
newstationstand.direction1.code = standsdata[i].direction1.code;
|
||||
newstationstand.direction1.name = standsdata[i].direction1.name;
|
||||
newstationstand.direction2.code = standsdata[i].direction2.code;
|
||||
newstationstand.direction2.name = standsdata[i].direction2.name;
|
||||
newstationstand.inside = standsdata[i].inside;
|
||||
// console.log(standsdata[i]);
|
||||
newstationmesh.position.x = standsdata[i].position.x;
|
||||
newstationmesh.position.y = standsdata[i].position.y;
|
||||
newstationmesh.position.z = standsdata[i].position.z;
|
||||
// newstationmesh.rotation.x = standsdata[i].rotation._x;
|
||||
// newstationmesh.rotation.y = standsdata[i].rotation._y;
|
||||
// newstationmesh.rotation.z = standsdata[i].rotation._z;
|
||||
newstationstand.mesh = newstationmesh;
|
||||
scope.group.add(newstationmesh);
|
||||
scope.list.push(newstationstand);
|
||||
j = jlmapstanddata.length;
|
||||
}else{
|
||||
if(jlmapstanddata[j].code == standsdata[i].direction1.code){
|
||||
|
||||
newstationmesh = assetloader.modellist[num3].mesh.clone(true);
|
||||
// console.log(jlmapstanddata[j]);
|
||||
newstationstand.code = standsdata[i].code;
|
||||
newstationstand.name = standsdata[i].name;
|
||||
newstationstand.direction1.code = standsdata[i].direction1.code;
|
||||
newstationstand.direction1.name = standsdata[i].direction1.name;
|
||||
newstationstand.direction2.code = standsdata[i].direction2.code;
|
||||
newstationstand.direction2.name = standsdata[i].direction2.name;
|
||||
newstationstand.inside = jlmapstanddata[j].inside;
|
||||
// console.log(standsdata[i]);
|
||||
newstationmesh.position.x = standsdata[i].position.x;
|
||||
newstationmesh.position.y = standsdata[i].position.y;
|
||||
newstationmesh.position.z = standsdata[i].position.z;
|
||||
// newstationmesh.rotation.x = standsdata[i].rotation._x;
|
||||
// newstationmesh.rotation.y = standsdata[i].rotation._y;
|
||||
// newstationmesh.rotation.z = standsdata[i].rotation._z;
|
||||
newstationstand.mesh = newstationmesh;
|
||||
scope.group.add(newstationmesh);
|
||||
scope.list.push(newstationstand);
|
||||
j = jlmapstanddata.length;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
scene.add(scope.group);
|
||||
resolve("loadedstation");
|
||||
});
|
||||
|
||||
}
|
||||
this.update = function(){
|
||||
|
||||
}
|
||||
|
||||
this.renderon = function(){
|
||||
|
||||
}
|
||||
|
||||
this.renderoff = function(){
|
||||
|
||||
}
|
||||
|
||||
this.dispose = function(){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
//canvas文字贴图方法
|
||||
//PS:待提炼 增强功能
|
||||
function getTextCanvas(text){
|
||||
var canvas = document.getElementById('canvastexture');
|
||||
// let width = 128;
|
||||
// let height = 64;
|
||||
// canvas.style.width = width + "px";
|
||||
// canvas.style.height = height + "px";
|
||||
|
||||
var ctx = canvas.getContext('2d');
|
||||
ctx.fillStyle = '#FFFFFF';
|
||||
ctx.fillRect(0, 0,128,64);
|
||||
ctx.font = "500px";
|
||||
ctx.fillStyle = '#000000';
|
||||
ctx.textAlign = 'center';
|
||||
ctx.textBaseline = 'middle';
|
||||
ctx.clearRect(0,0,128,64);
|
||||
|
||||
ctx.fillText(text.name, 128/2,64/4);
|
||||
ctx.fillText(text.runPlanName, 128/2,64*2/4);
|
||||
ctx.fillText(text.kmPost, 128/2,64*3/4);
|
||||
|
||||
let data = ctx.getImageData(0, 0,128,64);
|
||||
return data;
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
export function StationStandModel(opts) {
|
||||
|
||||
var scope = this;
|
||||
|
||||
this.uuid = null;
|
||||
this.code = null;
|
||||
this.name = null;
|
||||
this.modelid = null;
|
||||
this.type = null;
|
||||
|
||||
this.ismodel = false;
|
||||
this.istexture = false;
|
||||
this.modelurl = null;
|
||||
|
||||
this.direction1= {
|
||||
position:null,
|
||||
name:null,
|
||||
screenDoorOpenStatus:null,
|
||||
mesh:null,
|
||||
openpos:[],
|
||||
closepos:[]
|
||||
}
|
||||
this.direction2= {
|
||||
position:null,
|
||||
name:null,
|
||||
screenDoorOpenStatus:null,
|
||||
mesh:null,
|
||||
openpos:[],
|
||||
closepos:[]
|
||||
}
|
||||
|
||||
this.mesh = null;
|
||||
this.meshurl = null;
|
||||
this.picurl = null;
|
||||
}
|
@ -1,135 +0,0 @@
|
||||
import {SwitchModel} from '@/jlmap3d/edit/neweditmodel/SwitchModel.js';
|
||||
|
||||
export function SwitchList() {
|
||||
|
||||
let scope = this;
|
||||
this.type = "switchlist";
|
||||
|
||||
this.switchgroup = new THREE.Group();
|
||||
this.switchgroup.name = "switch";
|
||||
|
||||
this.switchs = {
|
||||
datalist:[],
|
||||
modellist:[]
|
||||
};
|
||||
|
||||
this.initpromise = function(jlmap3ddata,data,scene,assetloader,netdata){
|
||||
// console.log(jlmap3ddata);
|
||||
return new Promise(function(resolve, reject){
|
||||
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);
|
||||
autoswitch.code = data[i].code;
|
||||
scope.switchs.datalist.push(newswitch);
|
||||
scope.switchs.modellist.push(autoswitch);
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
resolve("loadedswitch");
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
this.loadpromise = function(jlmap3ddata,switchdata,scene,assetloader){
|
||||
return new Promise(function(resolve, reject){
|
||||
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].type == "switch"){
|
||||
num = j;
|
||||
}
|
||||
|
||||
if(assetloader.modellist[j].deviceType == "autoswitch"){
|
||||
num = j;
|
||||
}
|
||||
};
|
||||
for(let i=0,leni = switchdata.length;i<leni;i++){
|
||||
// console.log(switchdata[i]);
|
||||
let newswitch = {
|
||||
code:switchdata[i].code,
|
||||
name:switchdata[i].name,
|
||||
pa:switchdata[i].pa,
|
||||
pb:switchdata[i].pb,
|
||||
pc:switchdata[i].pc
|
||||
};
|
||||
|
||||
// console.log(newswitch.pa);
|
||||
let autoswitch = assetloader.modellist[num].mesh.clone(true);
|
||||
autoswitch.code = switchdata[i].code;
|
||||
for(let j=0;j<autoswitch.children.length;j++){
|
||||
autoswitch.children[j].code = switchdata[i].code;
|
||||
}
|
||||
scope.switchs.datalist.push(newswitch);
|
||||
scope.switchs.modellist.push(autoswitch);
|
||||
scope.switchgroup.add(autoswitch);
|
||||
autoswitch.position.set(switchdata[i].position.x,switchdata[i].position.y,switchdata[i].position.z);
|
||||
autoswitch.rotation.x = switchdata[i].rotation._x;
|
||||
autoswitch.rotation.y = switchdata[i].rotation._y;
|
||||
autoswitch.rotation.z = switchdata[i].rotation._z;
|
||||
|
||||
}
|
||||
|
||||
resolve("loadedswitch");
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
this.resetswitch = function(data){
|
||||
// console.log("reset");
|
||||
let sectiondata = data.sectionlist.sectiongroup;
|
||||
for(let i=0;i<scope.switchs.datalist.length;i++){
|
||||
|
||||
let sectionA = sectiondata.getObjectByProperty("code",scope.switchs.datalist[i].pa);
|
||||
let sectionB = sectiondata.getObjectByProperty("code",scope.switchs.datalist[i].pb);
|
||||
|
||||
if(sectionA.railpoint[0].x > sectionB.railpoint[0].x){
|
||||
scope.switchs.modellist[i].position.set(sectionA.railpoint[0].x,0,sectionA.railpoint[0].z);
|
||||
}else{
|
||||
scope.switchs.modellist[i].position.set(sectionA.railpoint[1].x,0,sectionA.railpoint[1].z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.update = function(){
|
||||
|
||||
}
|
||||
|
||||
this.renderon = function(){
|
||||
|
||||
}
|
||||
|
||||
this.renderoff = function(){
|
||||
|
||||
}
|
||||
|
||||
this.dispose = function(){
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
export function SwitchModel() {
|
||||
|
||||
var scope = this;
|
||||
//命名
|
||||
this.name = null;
|
||||
//code
|
||||
this.code = null;
|
||||
//索引位置
|
||||
this.index = null;
|
||||
//轨迹点
|
||||
this.rail = [];
|
||||
//长度
|
||||
this.distance = null;
|
||||
|
||||
this.action = null;
|
||||
//指向模型
|
||||
this.mesh = null;
|
||||
// //模型地址
|
||||
// this.meshurl = null;
|
||||
// //贴图地址
|
||||
// this.picurl = null;
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
export function TrainModel(opts) {
|
||||
|
||||
var scope = this;
|
||||
|
||||
this.mesh = null;
|
||||
this.meshurl = null;
|
||||
this.picurl = null;
|
||||
}
|
@ -1027,7 +1027,7 @@ export function SectionList() {
|
||||
let ccode = switch2d[i].sectionCCode;
|
||||
// console.log(switchdata[i]);
|
||||
|
||||
console.log(scope.sections.datalist[acode]);
|
||||
// console.log(scope.sections.datalist[acode]);
|
||||
let aposx = (scope.sections.datalist[acode].points[0].x + scope.sections.datalist[acode].points[scope.sections.datalist[acode].pointslength].x)/2;
|
||||
let cposx = (scope.sections.datalist[ccode].points[0].x + scope.sections.datalist[ccode].points[scope.sections.datalist[ccode].pointslength].x)/2;
|
||||
|
||||
|
@ -90,7 +90,7 @@ export function StationStandList() {
|
||||
this.loadpromise = function(jlmap3ddata,standsdata,jlmapstanddata,scene,assetloader){
|
||||
return new Promise(function(resolve, reject){
|
||||
// console.log(jlmap3ddata);
|
||||
// console.log(standsdata);
|
||||
console.log(standsdata);
|
||||
// console.log(jlmapstanddata);
|
||||
let stations = jlmap3ddata.stationstandlist.list;
|
||||
let num;
|
||||
|
Loading…
Reference in New Issue
Block a user