修改背景自适应,修改三维地图编辑逻辑存读以及三维沙盘加载
This commit is contained in:
parent
c191afd2b7
commit
e19e44835f
@ -1,5 +1,5 @@
|
|||||||
export function SetCamera(dom) {
|
export function SetCamera(dom) {
|
||||||
var camera = new THREE.PerspectiveCamera(60, dom.clientWidth/dom.clientHeight, 1, 5000);
|
var camera = new THREE.PerspectiveCamera(60, dom.clientWidth/dom.clientHeight, 1, 3000);
|
||||||
camera.position.set( 0, 0, 0 );
|
camera.position.set( 0, 0, 0 );
|
||||||
camera.aspect = window.innerWidth / window.innerHeight;
|
camera.aspect = window.innerWidth / window.innerHeight;
|
||||||
camera.updateProjectionMatrix();
|
camera.updateProjectionMatrix();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
export function SetScene() {
|
export function SetScene(project) {
|
||||||
var scene = new THREE.Scene();
|
var scene = new THREE.Scene();
|
||||||
// var cubeTextureLoader = new THREE.CubeTextureLoader();
|
// var cubeTextureLoader = new THREE.CubeTextureLoader();
|
||||||
//
|
//
|
||||||
@ -10,7 +10,13 @@ export function SetScene() {
|
|||||||
// 'pz.png', 'nz.png',
|
// 'pz.png', 'nz.png',
|
||||||
// ] );
|
// ] );
|
||||||
//
|
//
|
||||||
var bgTexture = new THREE.TextureLoader().load("../../static/background/background.jpg");
|
var bgTexture;
|
||||||
|
console.log(project);
|
||||||
|
if(project == ""){
|
||||||
|
bgTexture = new THREE.TextureLoader().load("../../static/background/background.jpg");
|
||||||
|
}else if(project == "hyd"){
|
||||||
|
bgTexture = new THREE.TextureLoader().load("../../static/background/other.jpg");
|
||||||
|
}
|
||||||
scene.background = bgTexture;
|
scene.background = bgTexture;
|
||||||
// cubeTexture.dispose();
|
// cubeTexture.dispose();
|
||||||
return scene;
|
return scene;
|
||||||
|
@ -6,15 +6,9 @@ import {SetObj} from '@/jlmap3d/edit/utils/SetObj.js';
|
|||||||
import {SectionList} from '@/jlmap3d/edit/neweditmodel/SectionList.js';
|
import {SectionList} from '@/jlmap3d/edit/neweditmodel/SectionList.js';
|
||||||
import {SignalList} from '@/jlmap3d/edit/neweditmodel/SignalList.js';
|
import {SignalList} from '@/jlmap3d/edit/neweditmodel/SignalList.js';
|
||||||
import {StationStandList} from '@/jlmap3d/edit/neweditmodel/StationStandList.js';
|
import {StationStandList} from '@/jlmap3d/edit/neweditmodel/StationStandList.js';
|
||||||
import {TrainList} from '@/jlmap3d/edit/neweditmodel/TrainList.js';
|
|
||||||
import {TrainListTest} from '@/jlmap3d/edit/neweditmodel/TrainListTest.js';
|
|
||||||
import {SwitchList} from '@/jlmap3d/edit/neweditmodel/SwitchList.js';
|
import {SwitchList} from '@/jlmap3d/edit/neweditmodel/SwitchList.js';
|
||||||
import {LinkList} from '@/jlmap3d/edit/neweditmodel/LinkList.js';
|
|
||||||
import {RailList} from '@/jlmap3d/edit/neweditmodel/RailList.js';
|
import {RailList} from '@/jlmap3d/edit/neweditmodel/RailList.js';
|
||||||
|
|
||||||
|
|
||||||
import {RealSectionList} from '@/jlmap3d/edit/neweditmodel/RealSectionList.js';
|
|
||||||
|
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import {getmodels} from '@/jlmap3d/edit/connect/getmodels';
|
import {getmodels} from '@/jlmap3d/edit/connect/getmodels';
|
||||||
import { Loading } from 'element-ui';
|
import { Loading } from 'element-ui';
|
||||||
@ -27,12 +21,15 @@ export function Jlmap3ddata(mapid,scope){
|
|||||||
let assetloader = scope.assetloader;
|
let assetloader = scope.assetloader;
|
||||||
let loadingInstance = Loading.service({ fullscreen: true });
|
let loadingInstance = Loading.service({ fullscreen: true });
|
||||||
get3dMapData(editmapid).then(data => {
|
get3dMapData(editmapid).then(data => {
|
||||||
//console.log(data);
|
console.log(data);
|
||||||
initobj(editmapid,data);
|
if(data.data ){
|
||||||
}).catch(error => {
|
if(data.data.assets){
|
||||||
//console.log(error);
|
init3d(editmapid,data.data);
|
||||||
if(error.code == "30001"){
|
}else{
|
||||||
//console.log("没有三维数据");
|
initobj(editmapid,data.data.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
}else{
|
||||||
let params = {mapId:editmapid};
|
let params = {mapId:editmapid};
|
||||||
|
|
||||||
set3dMapData(params).then(data => {
|
set3dMapData(params).then(data => {
|
||||||
@ -43,10 +40,12 @@ export function Jlmap3ddata(mapid,scope){
|
|||||||
|
|
||||||
}
|
}
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
//console.log(error);
|
console.log(error);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}).catch(error => {
|
||||||
|
console.log(error);
|
||||||
});
|
});
|
||||||
|
|
||||||
function initobj(mapid,data3did){
|
function initobj(mapid,data3did){
|
||||||
@ -63,15 +62,12 @@ export function Jlmap3ddata(mapid,scope){
|
|||||||
//初始化轨道和道岔 暂时
|
//初始化轨道和道岔 暂时
|
||||||
jlmap3ddata.sectionlist = new SectionList();
|
jlmap3ddata.sectionlist = new SectionList();
|
||||||
|
|
||||||
// jlmap3ddata.linklist = new LinkList();
|
|
||||||
jlmap3ddata.signallist = new SignalList();
|
jlmap3ddata.signallist = new SignalList();
|
||||||
|
|
||||||
jlmap3ddata.switchlist = new SwitchList();
|
jlmap3ddata.switchlist = new SwitchList();
|
||||||
// jlmap3ddata.trainlisttest = new TrainListTest();
|
|
||||||
//
|
//
|
||||||
// jlmap3ddata.raillist = new RailList();
|
jlmap3ddata.raillist = new RailList();
|
||||||
|
jlmap3ddata.raillist.setrail();
|
||||||
console.log(mapdata);
|
|
||||||
assetloader.assetinit(scene)
|
assetloader.assetinit(scene)
|
||||||
.then(function(data){
|
.then(function(data){
|
||||||
//console.log(data);
|
//console.log(data);
|
||||||
@ -81,11 +77,6 @@ export function Jlmap3ddata(mapid,scope){
|
|||||||
//console.log(data);
|
//console.log(data);
|
||||||
return jlmap3ddata.sectionlist.initpromise(jlmap3ddata,assetloader,mapdata.sectionList,mapdata.switchList,scene);
|
return jlmap3ddata.sectionlist.initpromise(jlmap3ddata,assetloader,mapdata.sectionList,mapdata.switchList,scene);
|
||||||
})
|
})
|
||||||
// .then(function(data){
|
|
||||||
// //console.log(data);
|
|
||||||
// return jlmap3ddata.linklist.initpromise(mapdata.linkList,scene,assetloader);
|
|
||||||
// })
|
|
||||||
|
|
||||||
.then(function(data){
|
.then(function(data){
|
||||||
//console.log(data);
|
//console.log(data);
|
||||||
return jlmap3ddata.signallist.initpromise(jlmap3ddata,mapdata.signalList,scene,assetloader);
|
return jlmap3ddata.signallist.initpromise(jlmap3ddata,mapdata.signalList,scene,assetloader);
|
||||||
@ -94,10 +85,6 @@ export function Jlmap3ddata(mapid,scope){
|
|||||||
return jlmap3ddata.switchlist.initpromise(jlmap3ddata,mapdata.switchList,scene,assetloader);
|
return jlmap3ddata.switchlist.initpromise(jlmap3ddata,mapdata.switchList,scene,assetloader);
|
||||||
})
|
})
|
||||||
|
|
||||||
// .then(function(data){
|
|
||||||
// //console.log(data);
|
|
||||||
// return jlmap3ddata.trainlisttest.initpromise(mapdata.trainList,scene,assetloader);
|
|
||||||
// })
|
|
||||||
.then(function(data){
|
.then(function(data){
|
||||||
//console.log(data);
|
//console.log(data);
|
||||||
loadingInstance.close();
|
loadingInstance.close();
|
||||||
@ -109,24 +96,25 @@ export function Jlmap3ddata(mapid,scope){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function init3d(mapid,netdata){
|
function init3d(mapid,netdata){
|
||||||
|
console.log(netdata);
|
||||||
// console.log(netdata)
|
// console.log(netdata)
|
||||||
getMapDetail(mapid).then(data => {
|
getMapDetail(mapid).then(data => {
|
||||||
jlmap3ddata.id = netdata.id;
|
jlmap3ddata.id = netdata.id;
|
||||||
jlmap3ddata.mapId = mapid;
|
jlmap3ddata.mapId = mapid;
|
||||||
let mapdata = data.data;
|
let mapdata = data.data;
|
||||||
|
|
||||||
jlmap3ddata.linklist = new LinkList();
|
// //初始化站台
|
||||||
|
jlmap3ddata.stationstandlist = new StationStandList();
|
||||||
//初始化轨道和道岔 暂时
|
//初始化轨道和道岔 暂时
|
||||||
jlmap3ddata.sectionlist = new SectionList();
|
jlmap3ddata.sectionlist = new SectionList();
|
||||||
|
|
||||||
jlmap3ddata.signallist = new SignalList();
|
jlmap3ddata.signallist = new SignalList();
|
||||||
//初始化站台
|
|
||||||
jlmap3ddata.stationstandlist = new StationStandList();
|
jlmap3ddata.switchlist = new SwitchList();
|
||||||
//初始化测试列车
|
|
||||||
jlmap3ddata.trainlisttest = new TrainListTest();
|
|
||||||
|
|
||||||
jlmap3ddata.raillist = new RailList();
|
jlmap3ddata.raillist = new RailList();
|
||||||
|
|
||||||
let loaderdata = JSON.parse(netdata.sections);
|
let sectiondata = JSON.parse(netdata.sections);
|
||||||
let switchdata = JSON.parse(netdata.switchs);
|
let switchdata = JSON.parse(netdata.switchs);
|
||||||
let signaldata = JSON.parse(netdata.signals);
|
let signaldata = JSON.parse(netdata.signals);
|
||||||
let standsdata = JSON.parse(netdata.stands);
|
let standsdata = JSON.parse(netdata.stands);
|
||||||
@ -134,32 +122,28 @@ export function Jlmap3ddata(mapid,scope){
|
|||||||
assetloader.setmodellist(netdata.assets,5);
|
assetloader.setmodellist(netdata.assets,5);
|
||||||
assetloader.assetpromise(scene)
|
assetloader.assetpromise(scene)
|
||||||
.then(function(data){
|
.then(function(data){
|
||||||
//console.log(data);
|
|
||||||
return jlmap3ddata.linklist.loadpromise(loaderdata.link,mapdata.linkList,scene,assetloader);
|
return jlmap3ddata.stationstandlist.loadpromise(jlmap3ddata,standsdata,scene,assetloader);
|
||||||
})
|
})
|
||||||
.then(function(data){
|
.then(function(data){
|
||||||
//console.log(data);
|
//console.log(data);
|
||||||
return jlmap3ddata.sectionlist.loadpromise(jlmap3ddata,assetloader,loaderdata.section,switchdata,scene);
|
return jlmap3ddata.sectionlist.loadpromise(jlmap3ddata,assetloader,sectiondata.section,scene);
|
||||||
})
|
})
|
||||||
.then(function(data){
|
.then(function(data){
|
||||||
//console.log(data);
|
//console.log(data);
|
||||||
return jlmap3ddata.signallist.loadpromise(signaldata,scene,assetloader,mapdata.signalList);
|
return jlmap3ddata.signallist.loadpromise(signaldata,scene,assetloader,mapdata.signalList);
|
||||||
})
|
})
|
||||||
.then(function(data){
|
.then(function(data){
|
||||||
//console.log(data);
|
console.log(data);
|
||||||
return jlmap3ddata.stationstandlist.initpromise(jlmap3ddata,mapdata.stationList,mapdata.stationStandList,scene,assetloader,standsdata);
|
return jlmap3ddata.switchlist.loadpromise(jlmap3ddata,switchdata,scene,assetloader);
|
||||||
})
|
|
||||||
.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){
|
// .then(function(data){
|
||||||
// //console.log(data);
|
// //console.log(data);
|
||||||
// return jlmap3ddata.realsectionlist.loadpromise(jlmap3ddata,scene,assetloader);
|
// return jlmap3ddata.sectionlist.loadpromise(jlmap3ddata,assetloader,loaderdata.section,switchdata,scene);
|
||||||
// })
|
// })
|
||||||
|
|
||||||
|
|
||||||
.then(function(data){
|
.then(function(data){
|
||||||
//console.log(data);
|
//console.log(data);
|
||||||
loadingInstance.close();
|
loadingInstance.close();
|
||||||
|
182
src/jlmap3d/edit/connect/newgetmodels.js
Normal file
182
src/jlmap3d/edit/connect/newgetmodels.js
Normal file
@ -0,0 +1,182 @@
|
|||||||
|
//import request from '@/utils/request';
|
||||||
|
|
||||||
|
export function getmodels(data) {
|
||||||
|
let postmap = {
|
||||||
|
id:data.mapdata.id,
|
||||||
|
mapId:data.mapdata.mapId,
|
||||||
|
assets:"null",
|
||||||
|
sections:"null",
|
||||||
|
signals:"null",
|
||||||
|
trains:"null",
|
||||||
|
stands:"null",
|
||||||
|
switchs:"null"
|
||||||
|
};
|
||||||
|
console.log(data.mapdata);
|
||||||
|
if(data.mapdata.sectionlist.sections== undefined){
|
||||||
|
return postmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(data == undefined){
|
||||||
|
|
||||||
|
return postmap;
|
||||||
|
}else{
|
||||||
|
//资源
|
||||||
|
let assets = [];
|
||||||
|
for(let i=0;i<data.assetloader.modellist.length;i++){
|
||||||
|
let asset = {
|
||||||
|
id:data.assetloader.modellist[i].id,
|
||||||
|
name:data.assetloader.modellist[i].name,
|
||||||
|
deviceType:data.assetloader.modellist[i].deviceType,
|
||||||
|
type:data.assetloader.modellist[i].type,
|
||||||
|
assetUrl:data.assetloader.modellist[i].assetUrl
|
||||||
|
}
|
||||||
|
assets.push(asset);
|
||||||
|
}
|
||||||
|
postmap.assets = JSON.stringify(assets);
|
||||||
|
//link轨道
|
||||||
|
// let links = [];
|
||||||
|
// for(let i=0;i<data.mapdata.linklist.linksgroup.children.length;i++){
|
||||||
|
// let link = {
|
||||||
|
// uuid:data.mapdata.linklist.linksgroup.children[i].uuid,
|
||||||
|
// code:data.mapdata.linklist.linksgroup.children[i].code,
|
||||||
|
// name:data.mapdata.linklist.linksgroup.children[i].name,
|
||||||
|
// lengthfact:data.mapdata.linklist.linksgroup.children[i].lengthfact,
|
||||||
|
// position:data.mapdata.linklist.linksgroup.children[i].position,
|
||||||
|
// rotation:data.mapdata.linklist.linksgroup.children[i].rotation,
|
||||||
|
// scale:data.mapdata.linklist.linksgroup.children[i].scale,
|
||||||
|
// rightlist:data.mapdata.linklist.linksgroup.children[i].rightlist,
|
||||||
|
// leftlist:data.mapdata.linklist.linksgroup.children[i].leftlist,
|
||||||
|
// lp:data.mapdata.linklist.linksgroup.children[i].lp,
|
||||||
|
// rp:data.mapdata.linklist.linksgroup.children[i].rp,
|
||||||
|
// rail:data.mapdata.linklist.linksgroup.children[i].rail,
|
||||||
|
// }
|
||||||
|
// links.push(link);
|
||||||
|
// }
|
||||||
|
// postmap.sections.link = JSON.stringify(links);
|
||||||
|
|
||||||
|
//section隧道
|
||||||
|
let sections = [];
|
||||||
|
console.log(data.mapdata.sectionlist.sections.datalist);
|
||||||
|
for(let i in data.mapdata.sectionlist.sections.datalist){
|
||||||
|
|
||||||
|
console.log(data.mapdata.sectionlist.sections.datalist[i]);
|
||||||
|
let section = {
|
||||||
|
// uuid:data.mapdata.sectionlist.sections.modellist[i].uuid,
|
||||||
|
code:data.mapdata.sectionlist.sections.datalist[i].code,
|
||||||
|
name:data.mapdata.sectionlist.sections.datalist[i].name,
|
||||||
|
lengthFact:data.mapdata.sectionlist.sections.datalist[i].lengthFact,
|
||||||
|
standTrack:data.mapdata.sectionlist.sections.datalist[i].standTrack,
|
||||||
|
rightlist:data.mapdata.sectionlist.sections.datalist[i].rightlist,
|
||||||
|
leftlist:data.mapdata.sectionlist.sections.datalist[i].leftlist,
|
||||||
|
rp:data.mapdata.sectionlist.sections.datalist[i].rp,
|
||||||
|
lp:data.mapdata.sectionlist.sections.datalist[i].lp,
|
||||||
|
|
||||||
|
rail:data.mapdata.sectionlist.sections.datalist[i].rail,
|
||||||
|
position:data.mapdata.sectionlist.sections.datalist[i].mesh.position,
|
||||||
|
rotation:data.mapdata.sectionlist.sections.datalist[i].mesh.rotation,
|
||||||
|
scale:data.mapdata.sectionlist.sections.datalist[i].mesh.scale,
|
||||||
|
rsection:null,
|
||||||
|
lsection:null,
|
||||||
|
csection:null
|
||||||
|
}
|
||||||
|
if(data.mapdata.sectionlist.sections.datalist[i].rsection){
|
||||||
|
section.rsection = data.mapdata.sectionlist.sections.datalist[i].rsection;
|
||||||
|
}
|
||||||
|
if(data.mapdata.sectionlist.sections.datalist[i].lsection){
|
||||||
|
section.lsection = data.mapdata.sectionlist.sections.datalist[i].lsection;
|
||||||
|
}
|
||||||
|
if(data.mapdata.sectionlist.sections.datalist[i].csection){
|
||||||
|
section.csection = data.mapdata.sectionlist.sections.datalist[i].csection;
|
||||||
|
}
|
||||||
|
|
||||||
|
// testmesh1.position.z = link.position.z;
|
||||||
|
|
||||||
|
sections.push(section);
|
||||||
|
}
|
||||||
|
let arrray = {
|
||||||
|
section:sections,
|
||||||
|
};
|
||||||
|
postmap.sections = JSON.stringify(arrray);
|
||||||
|
//道岔
|
||||||
|
let switchs = [];
|
||||||
|
|
||||||
|
for(let i=0;i<data.mapdata.switchlist.switchs.datalist.length;i++){
|
||||||
|
let switcha = {
|
||||||
|
// uuid:data.mapdata.switchlist.switchs.modellist[i].uuid,
|
||||||
|
code:data.mapdata.switchlist.switchs.datalist[i].code,
|
||||||
|
name:data.mapdata.switchlist.switchs.datalist[i].name,
|
||||||
|
pa:data.mapdata.switchlist.switchs.datalist[i].pa,
|
||||||
|
pb:data.mapdata.switchlist.switchs.datalist[i].pb,
|
||||||
|
pc:data.mapdata.switchlist.switchs.datalist[i].pc,
|
||||||
|
position:data.mapdata.switchlist.switchs.modellist[i].position,
|
||||||
|
rotation:data.mapdata.switchlist.switchs.modellist[i].rotation,
|
||||||
|
scale:data.mapdata.switchlist.switchs.modellist[i].scale
|
||||||
|
}
|
||||||
|
switchs.push(switcha);
|
||||||
|
}
|
||||||
|
postmap.switchs = JSON.stringify(switchs);
|
||||||
|
//信号
|
||||||
|
let signals = [];
|
||||||
|
for(let i=0;i<data.mapdata.signallist.list.length;i++){
|
||||||
|
|
||||||
|
|
||||||
|
let signal = {
|
||||||
|
// uuid:data.mapdata.signallist.list[i].mesh.uuid,
|
||||||
|
name:data.mapdata.signallist.list[i].mesh.name,
|
||||||
|
modelid:data.mapdata.signallist.list[i].mesh.modelid,
|
||||||
|
code:data.mapdata.signallist.list[i].mesh.code,
|
||||||
|
right:data.mapdata.signallist.list[i].mesh.right,
|
||||||
|
position:data.mapdata.signallist.list[i].mesh.position,
|
||||||
|
rotation:data.mapdata.signallist.list[i].mesh.rotation,
|
||||||
|
scale:data.mapdata.signallist.list[i].mesh.scale
|
||||||
|
}
|
||||||
|
|
||||||
|
signals.push(signal);
|
||||||
|
}
|
||||||
|
postmap.signals = JSON.stringify(signals);
|
||||||
|
//车站
|
||||||
|
let stands = [];
|
||||||
|
|
||||||
|
for(let i=0;i<data.mapdata.stationstandlist.list.length;i++){
|
||||||
|
let station = {
|
||||||
|
// uuid:data.mapdata.stationstandlist.list[i].uuid,
|
||||||
|
code:data.mapdata.stationstandlist.list[i].code,
|
||||||
|
name:data.mapdata.stationstandlist.list[i].name,
|
||||||
|
modelid:data.mapdata.stationstandlist.list[i].modelid,
|
||||||
|
position:data.mapdata.stationstandlist.list[i].mesh.position,
|
||||||
|
rotation:data.mapdata.stationstandlist.list[i].mesh.rotation,
|
||||||
|
scale:data.mapdata.stationstandlist.list[i].mesh.scale,
|
||||||
|
direction1:{
|
||||||
|
name:data.mapdata.stationstandlist.list[i].direction1.name,
|
||||||
|
code:data.mapdata.stationstandlist.list[i].direction1.code
|
||||||
|
},
|
||||||
|
direction2:{
|
||||||
|
name:data.mapdata.stationstandlist.list[i].direction2.name,
|
||||||
|
code:data.mapdata.stationstandlist.list[i].direction2.code
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stands.push(station);
|
||||||
|
}
|
||||||
|
postmap.stands = JSON.stringify(stands);
|
||||||
|
//列车
|
||||||
|
let trains = [];
|
||||||
|
for(let i=0;i<data.assetloader.modellist.length;i++){
|
||||||
|
if(data.assetloader.modellist[i].deviceType == "train"){
|
||||||
|
let train = {
|
||||||
|
id:data.assetloader.modellist[i].id,
|
||||||
|
name:data.assetloader.modellist[i].name,
|
||||||
|
deviceType:data.assetloader.modellist[i].deviceType,
|
||||||
|
type:data.assetloader.modellist[i].type,
|
||||||
|
assetUrl:data.assetloader.modellist[i].assetUrl
|
||||||
|
}
|
||||||
|
|
||||||
|
trains.push(train);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
postmap.trains = JSON.stringify(trains);
|
||||||
|
|
||||||
|
return postmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -93,6 +93,7 @@ export function JLmap3dEdit(dom, data, mapid) {
|
|||||||
stationstandlist:null,
|
stationstandlist:null,
|
||||||
trainlisttest:null,
|
trainlisttest:null,
|
||||||
realsectionlist:null,
|
realsectionlist:null,
|
||||||
|
raillist:null,
|
||||||
path:[]
|
path:[]
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -248,7 +249,7 @@ export function JLmap3dEdit(dom, data, mapid) {
|
|||||||
|
|
||||||
this.testrail = function(){
|
this.testrail = function(){
|
||||||
console.log("testrail");
|
console.log("testrail");
|
||||||
console.log(scope.mapdata.raillist);
|
console.log(scope.mapdata);
|
||||||
scope.mapdata.raillist.resetrail(scope.mapdata,scope.scene);
|
scope.mapdata.raillist.resetrail(scope.mapdata,scope.scene);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -11,54 +11,73 @@ export function RailList(){
|
|||||||
|
|
||||||
|
|
||||||
this.resetrail = function(mapdata,scene){
|
this.resetrail = function(mapdata,scene){
|
||||||
console.log(mapdata);
|
|
||||||
|
|
||||||
let raillink = mapdata.linklist.linksgroup.children;
|
|
||||||
for(let i=0;i<raillink.length;i++){
|
let section = mapdata.sectionlist.sections.datalist;
|
||||||
var geometry = new THREE.PlaneBufferGeometry( raillink[i].lengthfact-25, 0.1, 0.1 );
|
|
||||||
|
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 material = new THREE.MeshBasicMaterial( {color: 0xffff00, side: THREE.DoubleSide} );
|
||||||
var plane = new THREE.Mesh( geometry, material );
|
var plane = new THREE.Mesh( geometry, material );
|
||||||
plane.position.x = raillink[i].position.x;
|
plane.position.x = section[i].mesh.position.x;
|
||||||
plane.position.y = 2;
|
plane.position.y = 2+Math.random()*10;
|
||||||
plane.position.z = raillink[i].position.z;
|
plane.position.z = section[i].mesh.position.z;
|
||||||
plane.rotation.x = -Math.PI/2;
|
plane.rotation.x = -Math.PI/2;
|
||||||
plane.rotation.z = raillink[i].rotation._z;
|
plane.rotation.z = section[i].mesh.rotation._z;
|
||||||
|
|
||||||
|
// if( plane.rotation.z != ){
|
||||||
|
//
|
||||||
|
// }
|
||||||
var geometry1 = new THREE.CircleBufferGeometry( 1, 16 );
|
var geometry1 = new THREE.CircleBufferGeometry( 1, 16 );
|
||||||
var material1 = new THREE.MeshBasicMaterial( { color: 0xffff00 } );
|
var material1 = new THREE.MeshBasicMaterial( { color: 0xffff00 } );
|
||||||
var geometry2 = new THREE.CircleBufferGeometry( 1, 16 );
|
var geometry2 = new THREE.CircleBufferGeometry( 1, 16 );
|
||||||
var material2 = new THREE.MeshBasicMaterial( { color: 0xff2000 } );
|
var material2 = new THREE.MeshBasicMaterial( { color: 0xff2000 } );
|
||||||
var circle1 = new THREE.Mesh( geometry1, material1 );
|
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;
|
circle1.rotation.x = -Math.PI/2;
|
||||||
|
|
||||||
scene.add( circle1 );
|
|
||||||
|
|
||||||
var circle2 = new THREE.Mesh( geometry2, material2 );
|
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;
|
circle2.rotation.x = -Math.PI/2;
|
||||||
mapdata.linklist.linksgroup.children[i].rail = [{
|
|
||||||
|
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,
|
x:circle2.position.x,
|
||||||
z:circle2.position.z
|
z:circle2.position.z
|
||||||
},{
|
},{
|
||||||
x:circle1.position.x,
|
x:circle1.position.x,
|
||||||
z:circle1.position.z
|
z:circle1.position.z
|
||||||
}];
|
}];
|
||||||
scene.add( circle2 );
|
// console.log(i);
|
||||||
scene.add( plane );
|
// console.log(section[i].mesh);
|
||||||
}
|
// console.log(mapdata.sectionlist.sections.datalist[i].rail);
|
||||||
|
// console.log("=======================");
|
||||||
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 );
|
|
||||||
}
|
}
|
||||||
|
// 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 );
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -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(){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -9,8 +9,6 @@ export function SectionList() {
|
|||||||
this.sectiongroup = new THREE.Group();
|
this.sectiongroup = new THREE.Group();
|
||||||
this.sectiongroup.name = "section";
|
this.sectiongroup.name = "section";
|
||||||
|
|
||||||
this.switchgroup = new THREE.Group();
|
|
||||||
this.switchgroup.name = "switch";
|
|
||||||
|
|
||||||
this.sections = {
|
this.sections = {
|
||||||
datalist:[],
|
datalist:[],
|
||||||
@ -51,8 +49,8 @@ export function SectionList() {
|
|||||||
if(sectiondata[i].type == "01" || sectiondata[i].type == "03"){
|
if(sectiondata[i].type == "01" || sectiondata[i].type == "03"){
|
||||||
//初始化区段对象数据
|
//初始化区段对象数据
|
||||||
let newsection = new SectionModel(sectiondata[i]);
|
let newsection = new SectionModel(sectiondata[i]);
|
||||||
|
// console.log(sectiondata[i]);
|
||||||
newsection.name = sectiondata[i].code;
|
newsection.name = sectiondata[i].name;
|
||||||
newsection.code = sectiondata[i].code;
|
newsection.code = sectiondata[i].code;
|
||||||
newsection.index = i;
|
newsection.index = i;
|
||||||
newsection.type = sectiondata[i].type;
|
newsection.type = sectiondata[i].type;
|
||||||
@ -63,6 +61,8 @@ export function SectionList() {
|
|||||||
newsection.lsection = sectiondata[i].leftSectionCode;
|
newsection.lsection = sectiondata[i].leftSectionCode;
|
||||||
newsection.points = sectiondata[i].points;
|
newsection.points = sectiondata[i].points;
|
||||||
newsection.pointslength = sectiondata[i].points.length-1;
|
newsection.pointslength = sectiondata[i].points.length-1;
|
||||||
|
newsection.rightlist = autorail.rightlist;
|
||||||
|
newsection.leftlist = autorail.leftlist;
|
||||||
// console.log(sectiondata[i].points.length);
|
// console.log(sectiondata[i].points.length);
|
||||||
newsection.standTrack = sectiondata[i].standTrack;
|
newsection.standTrack = sectiondata[i].standTrack;
|
||||||
newsection.endbuild = false;
|
newsection.endbuild = false;
|
||||||
@ -95,7 +95,7 @@ export function SectionList() {
|
|||||||
sectiondata[i].startx = sectiondata[i].points[0].x;
|
sectiondata[i].startx = sectiondata[i].points[0].x;
|
||||||
sectiondata[i].starty = sectiondata[i].points[0].y;
|
sectiondata[i].starty = sectiondata[i].points[0].y;
|
||||||
sectiondata[i].lengthFact = 134;
|
sectiondata[i].lengthFact = 134;
|
||||||
console.log(sectiondata[i].lengthFact);
|
// console.log(sectiondata[i].lengthFact);
|
||||||
scope.stopsection.push(sectiondata[i]);
|
scope.stopsection.push(sectiondata[i]);
|
||||||
}
|
}
|
||||||
// sections.modellist.push("");
|
// sections.modellist.push("");
|
||||||
@ -161,7 +161,7 @@ export function SectionList() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
console.log(scope.sections.datalist);
|
// console.log(scope.sections.datalist);
|
||||||
// console.log(scope.stopsection);
|
// console.log(scope.stopsection);
|
||||||
// console.log(jlmap3ddata);
|
// console.log(jlmap3ddata);
|
||||||
let stationlist = jlmap3ddata.stationstandlist.list;
|
let stationlist = jlmap3ddata.stationstandlist.list;
|
||||||
@ -179,7 +179,7 @@ export function SectionList() {
|
|||||||
downcode:null,
|
downcode:null,
|
||||||
posx:null,
|
posx:null,
|
||||||
};
|
};
|
||||||
console.log(stationlist[i]);
|
// console.log(stationlist[i]);
|
||||||
for(let j=0,lenj = scope.stopsection.length;j<lenj;j++){
|
for(let j=0,lenj = scope.stopsection.length;j<lenj;j++){
|
||||||
if(scope.stopsection[j].code == stationlist[i].direction2.section){
|
if(scope.stopsection[j].code == stationlist[i].direction2.section){
|
||||||
realstopsection.topsection = scope.stopsection[j];
|
realstopsection.topsection = scope.stopsection[j];
|
||||||
@ -196,7 +196,7 @@ export function SectionList() {
|
|||||||
stopsections.push(realstopsection);
|
stopsections.push(realstopsection);
|
||||||
}
|
}
|
||||||
stopsections.sort(compare("posx"))
|
stopsections.sort(compare("posx"))
|
||||||
console.log(stopsections);
|
// console.log(stopsections);
|
||||||
|
|
||||||
// if((scope.stopsection.length%2)==0){
|
// if((scope.stopsection.length%2)==0){
|
||||||
//
|
//
|
||||||
@ -299,8 +299,11 @@ export function SectionList() {
|
|||||||
y:0,
|
y:0,
|
||||||
z:scope.sections.datalist[stopsections[i].downsection.code].mesh.position.z
|
z:scope.sections.datalist[stopsections[i].downsection.code].mesh.position.z
|
||||||
};
|
};
|
||||||
createsection(autorail,topnextpoint,stopsections[i].topsection.code,stopsections[i+1].topsection.code,0);
|
let topstart = scope.sections.datalist[stopsections[i].topsection.code].rsection;
|
||||||
createsection(autorail,downnextpoint,stopsections[i].downsection.code,stopsections[i+1].downsection.code,34.8);
|
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 stations = jlmap3ddata.stationstandlist.list;
|
||||||
@ -310,6 +313,7 @@ export function SectionList() {
|
|||||||
num = j;
|
num = j;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(let j=0,lenj=stations.length;j<lenj;j++){
|
for(let j=0,lenj=stations.length;j<lenj;j++){
|
||||||
// console.log(j);
|
// console.log(j);
|
||||||
// console.log(scope.sections.datalist[stations[j].direction1.section]);
|
// console.log(scope.sections.datalist[stations[j].direction1.section]);
|
||||||
@ -317,7 +321,8 @@ export function SectionList() {
|
|||||||
let z = (scope.sections.datalist[stations[j].direction1.section].mesh.position.z+scope.sections.datalist[stations[j].direction2.section].mesh.position.z)/2;
|
let z = (scope.sections.datalist[stations[j].direction1.section].mesh.position.z+scope.sections.datalist[stations[j].direction2.section].mesh.position.z)/2;
|
||||||
|
|
||||||
var mesh = assetloader.modellist[num].mesh.clone(true);
|
var mesh = assetloader.modellist[num].mesh.clone(true);
|
||||||
|
jlmap3ddata.stationstandlist.list[j].modelid = assetloader.modellist[num].modelid;
|
||||||
|
jlmap3ddata.stationstandlist.list[j].mesh = mesh;
|
||||||
// console.log(x);
|
// console.log(x);
|
||||||
mesh.position.set(x,0,z);
|
mesh.position.set(x,0,z);
|
||||||
// mesh.rotation.x = Math.PI/2;
|
// mesh.rotation.x = Math.PI/2;
|
||||||
@ -528,12 +533,7 @@ export function SectionList() {
|
|||||||
}
|
}
|
||||||
testmesh2.position.x = (data.rp.x + data.lp.x)/2;
|
testmesh2.position.x = (data.rp.x + data.lp.x)/2;
|
||||||
testmesh2.position.z = (data.rp.z + data.lp.z)/2;
|
testmesh2.position.z = (data.rp.z + data.lp.z)/2;
|
||||||
if(data.ctype == "1"){
|
|
||||||
buildrailcurve(testmesh2,"right",data.ctype);
|
|
||||||
}
|
|
||||||
if(data.ctype == "2"){
|
|
||||||
buildrailcurve(testmesh2,"right",data.ctype);
|
|
||||||
}
|
|
||||||
// testmesh2.rotation.z = ;
|
// testmesh2.rotation.z = ;
|
||||||
}
|
}
|
||||||
if(data.ctype == "3" || data.ctype == "4"){
|
if(data.ctype == "3" || data.ctype == "4"){
|
||||||
@ -564,20 +564,28 @@ export function SectionList() {
|
|||||||
|
|
||||||
testmesh2.position.x = (data.lp.x + data.rp.x)/2;
|
testmesh2.position.x = (data.lp.x + data.rp.x)/2;
|
||||||
testmesh2.position.z = (data.lp.z + data.rp.z)/2;
|
testmesh2.position.z = (data.lp.z + data.rp.z)/2;
|
||||||
if(data.ctype == "3"){
|
|
||||||
buildrailcurve(testmesh2,"left",data.ctype);
|
|
||||||
}
|
|
||||||
if(data.ctype == "4"){
|
|
||||||
buildrailcurve(testmesh2,"left",data.ctype);
|
|
||||||
}
|
|
||||||
// testmesh2.rotation.z = ;
|
// testmesh2.rotation.z = ;
|
||||||
}
|
}
|
||||||
|
// if(data.ctype == "1"){
|
||||||
|
// buildrailcurve(testmesh2,"right",data.ctype);
|
||||||
|
// }
|
||||||
|
// if(data.ctype == "2"){
|
||||||
|
// buildrailcurve(testmesh2,"right",data.ctype);
|
||||||
|
// }
|
||||||
|
// if(data.ctype == "3"){
|
||||||
|
// buildrailcurve(testmesh2,"left",data.ctype);
|
||||||
|
// }
|
||||||
|
// if(data.ctype == "4"){
|
||||||
|
// buildrailcurve(testmesh2,"left",data.ctype);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
var box = new THREE.BoxHelper( testmesh2, 0xffff00 );
|
// var box = new THREE.BoxHelper( testmesh2, 0xffffff );
|
||||||
scope.sectiongroup.add( box );
|
// scope.sectiongroup.add( box );
|
||||||
|
|
||||||
}
|
}
|
||||||
function buildrailcurve(origin,direct,type){
|
function buildrailcurve(origin,direct,type){
|
||||||
|
console.log(origin.position);
|
||||||
if(direct == "right"){
|
if(direct == "right"){
|
||||||
let testmesh1 = autorail.clone(true);
|
let testmesh1 = autorail.clone(true);
|
||||||
for(let i=0;i<autorail.rightlist.length;i++){
|
for(let i=0;i<autorail.rightlist.length;i++){
|
||||||
@ -592,8 +600,7 @@ export function SectionList() {
|
|||||||
testmesh1.geometry.attributes.uv.needsUpdate = true;
|
testmesh1.geometry.attributes.uv.needsUpdate = true;
|
||||||
testmesh1.geometry.computeBoundingSphere();
|
testmesh1.geometry.computeBoundingSphere();
|
||||||
testmesh1.geometry.center();
|
testmesh1.geometry.center();
|
||||||
|
//
|
||||||
testmesh1.rotation.x = -Math.PI/2;
|
|
||||||
|
|
||||||
let testmesh2 = autorail.clone(true);
|
let testmesh2 = autorail.clone(true);
|
||||||
for(let i=0;i<autorail.rightlist.length;i++){
|
for(let i=0;i<autorail.rightlist.length;i++){
|
||||||
@ -625,25 +632,33 @@ export function SectionList() {
|
|||||||
testmesh3.geometry.center();
|
testmesh3.geometry.center();
|
||||||
|
|
||||||
if(type == "1"){
|
if(type == "1"){
|
||||||
testmesh1.position.x = origin.position.x + (origin.lengthFact)/2 +0.9;
|
testmesh1.rotation.x = 0;
|
||||||
|
testmesh2.rotation.x = 0;
|
||||||
|
testmesh3.rotation.x = 0;
|
||||||
|
|
||||||
|
testmesh1.position.x =(origin.lengthFact)/2 +0.9;
|
||||||
testmesh1.position.z = 0.03;
|
testmesh1.position.z = 0.03;
|
||||||
testmesh1.rotation.z = 0.05;
|
testmesh1.rotation.z = 0.05;
|
||||||
testmesh2.position.x = origin.position.x + (origin.lengthFact)/2 +2.3;
|
|
||||||
|
testmesh2.position.x = (origin.lengthFact)/2 +2.3;
|
||||||
testmesh2.position.z = 0.14;
|
testmesh2.position.z = 0.14;
|
||||||
testmesh2.rotation.z = 0.1;
|
testmesh2.rotation.z = 0.1;
|
||||||
testmesh3.position.x = origin.position.x + (origin.lengthFact)/2 +3.7;
|
testmesh3.position.x = (origin.lengthFact)/2 +3.7;
|
||||||
testmesh3.position.z = 0.32;
|
testmesh3.position.z = 0.32;
|
||||||
testmesh3.rotation.z = 0.15;
|
testmesh3.rotation.z = 0.15;
|
||||||
|
|
||||||
}
|
}
|
||||||
if(type == "2"){
|
if(type == "2"){
|
||||||
testmesh1.position.x = origin.position.x + (origin.lengthFact)/2 +0.9;
|
testmesh1.rotation.y = 0;
|
||||||
|
testmesh2.rotation.y = 0;
|
||||||
|
testmesh3.rotation.y = 0;
|
||||||
|
testmesh1.position.x = (origin.lengthFact)/2 +0.9;
|
||||||
testmesh1.position.z = 0.03;
|
testmesh1.position.z = 0.03;
|
||||||
testmesh1.rotation.z = 0.05;
|
testmesh1.rotation.z = 0.05;
|
||||||
testmesh2.position.x = origin.position.x + (origin.lengthFact)/2 +2.3;
|
testmesh2.position.x = (origin.lengthFact)/2 +2.3;
|
||||||
testmesh2.position.z = 0.14;
|
testmesh2.position.z = 0.14;
|
||||||
testmesh2.rotation.z = 0.1;
|
testmesh2.rotation.z = 0.1;
|
||||||
testmesh3.position.x = origin.position.x + (origin.lengthFact)/2 +3.7;
|
testmesh3.position.x = (origin.lengthFact)/2 +3.7;
|
||||||
testmesh3.position.z = 0.32;
|
testmesh3.position.z = 0.32;
|
||||||
testmesh3.rotation.z = 0.15;
|
testmesh3.rotation.z = 0.15;
|
||||||
|
|
||||||
@ -655,7 +670,7 @@ export function SectionList() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
if(direct == "left"){
|
if(direct == "left"){
|
||||||
let testmesh1 = rail.clone(true);
|
let testmesh1 = autorail.clone(true);
|
||||||
// console.log(testmesh2.geometry.attributes.position.array);
|
// console.log(testmesh2.geometry.attributes.position.array);
|
||||||
for(let i=0;i<autorail.rightlist.length;i++){
|
for(let i=0;i<autorail.rightlist.length;i++){
|
||||||
testmesh1.geometry.attributes.position.array[autorail.rightlist[i]*3] = 1;
|
testmesh1.geometry.attributes.position.array[autorail.rightlist[i]*3] = 1;
|
||||||
@ -670,10 +685,9 @@ export function SectionList() {
|
|||||||
testmesh1.geometry.computeBoundingSphere();
|
testmesh1.geometry.computeBoundingSphere();
|
||||||
testmesh1.geometry.center();
|
testmesh1.geometry.center();
|
||||||
|
|
||||||
testmesh1.rotation.x = -Math.PI/2;
|
|
||||||
origin.add( testmesh1 );
|
origin.add( testmesh1 );
|
||||||
|
|
||||||
let testmesh2 = rail.clone(true);
|
let testmesh2 = autorail.clone(true);
|
||||||
for(let i=0;i<autorail.rightlist.length;i++){
|
for(let i=0;i<autorail.rightlist.length;i++){
|
||||||
testmesh2.geometry.attributes.position.array[autorail.rightlist[i]*3] = 1;
|
testmesh2.geometry.attributes.position.array[autorail.rightlist[i]*3] = 1;
|
||||||
testmesh2.geometry.attributes.uv.array[autorail.rightlist[i]*2] = testmesh2.geometry.attributes.position.array[0]-testmesh2.geometry.attributes.position.array[3];
|
testmesh2.geometry.attributes.uv.array[autorail.rightlist[i]*2] = testmesh2.geometry.attributes.position.array[0]-testmesh2.geometry.attributes.position.array[3];
|
||||||
@ -688,7 +702,7 @@ export function SectionList() {
|
|||||||
testmesh2.geometry.center();
|
testmesh2.geometry.center();
|
||||||
|
|
||||||
|
|
||||||
let testmesh3 = rail.clone(true);
|
let testmesh3 = autorail.clone(true);
|
||||||
for(let i=0;i<autorail.rightlist.length;i++){
|
for(let i=0;i<autorail.rightlist.length;i++){
|
||||||
testmesh3.geometry.attributes.position.array[autorail.rightlist[i]*3] = 1;
|
testmesh3.geometry.attributes.position.array[autorail.rightlist[i]*3] = 1;
|
||||||
testmesh3.geometry.attributes.uv.array[autorail.rightlist[i]*2] = testmesh3.geometry.attributes.position.array[0]-testmesh3.geometry.attributes.position.array[3];
|
testmesh3.geometry.attributes.uv.array[autorail.rightlist[i]*2] = testmesh3.geometry.attributes.position.array[0]-testmesh3.geometry.attributes.position.array[3];
|
||||||
@ -703,25 +717,32 @@ export function SectionList() {
|
|||||||
testmesh3.geometry.center();
|
testmesh3.geometry.center();
|
||||||
|
|
||||||
if(type == "3"){
|
if(type == "3"){
|
||||||
testmesh1.position.x = origin.position.x - (origin.lengthFact)/2 +0.9;
|
|
||||||
|
testmesh1.rotation.x = 0;
|
||||||
|
testmesh2.rotation.x = 0;
|
||||||
|
testmesh3.rotation.x = 0;
|
||||||
|
testmesh1.position.x = - (origin.lengthFact)/2-0.9;
|
||||||
testmesh1.position.z = 0.03;
|
testmesh1.position.z = 0.03;
|
||||||
testmesh1.rotation.z = 0.05;
|
testmesh1.rotation.z = 0.05;
|
||||||
testmesh2.position.x = origin.position.x - (origin.lengthFact)/2 +2.3;
|
testmesh2.position.x = - (origin.lengthFact)/2 -2.3;
|
||||||
testmesh2.position.z = 0.14;
|
testmesh2.position.z = 0.14;
|
||||||
testmesh2.rotation.z = 0.1;
|
testmesh2.rotation.z = 0.1;
|
||||||
testmesh3.position.x = origin.position.x - (origin.lengthFact)/2 +3.7;
|
testmesh3.position.x = - (origin.lengthFact)/2 -3.7;
|
||||||
testmesh3.position.z = 0.32;
|
testmesh3.position.z = 0.32;
|
||||||
testmesh3.rotation.z = 0.15;
|
testmesh3.rotation.z = 0.15;
|
||||||
|
|
||||||
}
|
}
|
||||||
if(type == "4"){
|
if(type == "4"){
|
||||||
testmesh1.position.x = origin.position.x - (origin.lengthFact)/2 +0.9;
|
testmesh1.rotation.z = 0;
|
||||||
|
testmesh2.rotation.z = 0;
|
||||||
|
testmesh3.rotation.z = 0;
|
||||||
|
testmesh1.position.x = - (origin.lengthFact)/2 -0.9;
|
||||||
testmesh1.position.z = 0.03;
|
testmesh1.position.z = 0.03;
|
||||||
testmesh1.rotation.z = 0.05;
|
testmesh1.rotation.z = 0.05;
|
||||||
testmesh2.position.x = origin.position.x - (origin.lengthFact)/2 +2.3;
|
testmesh2.position.x = - (origin.lengthFact)/2 -2.3;
|
||||||
testmesh2.position.z = 0.14;
|
testmesh2.position.z = 0.14;
|
||||||
testmesh2.rotation.z = 0.1;
|
testmesh2.rotation.z = 0.1;
|
||||||
testmesh3.position.x = origin.position.x - (origin.lengthFact)/2 +3.7;
|
testmesh3.position.x = - (origin.lengthFact)/2 -3.7;
|
||||||
testmesh3.position.z = 0.32;
|
testmesh3.position.z = 0.32;
|
||||||
testmesh3.rotation.z = 0.15;
|
testmesh3.rotation.z = 0.15;
|
||||||
|
|
||||||
@ -768,17 +789,17 @@ export function SectionList() {
|
|||||||
y:0,
|
y:0,
|
||||||
z:testmesh2.position.z
|
z:testmesh2.position.z
|
||||||
};
|
};
|
||||||
|
|
||||||
scope.sectiongroup.add( testmesh2 );
|
scope.sectiongroup.add( testmesh2 );
|
||||||
scope.sections.datalist[start].mesh = testmesh2;
|
scope.sections.datalist[start].mesh = testmesh2;
|
||||||
|
scope.sections.datalist[start].lengthFact = scope.sections.datalist[start].lengthFact;
|
||||||
let topstartpoint = {
|
let topstartpoint = {
|
||||||
x:position.x+scope.sections.datalist[start].lengthFact,
|
x:position.x+scope.sections.datalist[start].lengthFact,
|
||||||
y:0,
|
y:0,
|
||||||
z:position.z
|
z:position.z
|
||||||
};
|
};
|
||||||
// console.log(topstartpoint.x);
|
// console.log(topstartpoint.x);
|
||||||
var box = new THREE.BoxHelper( testmesh2, 0xffff00 );
|
// var box = new THREE.BoxHelper( testmesh2, 0xffffff );
|
||||||
scope.sectiongroup.add( box );
|
// scope.sectiongroup.add( box );
|
||||||
if(scope.sections.datalist[start].code == end){
|
if(scope.sections.datalist[start].code == end){
|
||||||
return ;
|
return ;
|
||||||
}else{
|
}else{
|
||||||
@ -812,621 +833,76 @@ export function SectionList() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.sectionpromise = function(linkdata,linklist,sectiondata,switchdata,standsdata,scene){
|
this.loadpromise = function(jlmap3ddata,assetloader,sectiondata,scene){
|
||||||
// console.log(linkdata);
|
|
||||||
// console.log(linklist);
|
|
||||||
// console.log(sectiondata);
|
|
||||||
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.z = 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++){
|
for(let i=0;i<assetloader.modellist.length;i++){
|
||||||
if(assetloader.modellist[i].deviceType == "autosuidao"){
|
if(assetloader.modellist[i].deviceType == "autorail"){
|
||||||
autosuidao = assetloader.modellist[i].mesh.children[0];
|
autorail = assetloader.modellist[i].mesh.children[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// console.log(suidaodata);
|
let count = autorail.geometry.attributes.position.count;
|
||||||
let rightlist = [];
|
let rightlist = [];
|
||||||
let leftlist = [];
|
let leftlist = [];
|
||||||
let rightpoint = 0;
|
|
||||||
let leftpoint = 0;
|
|
||||||
let count = autosuidao.geometry.attributes.position.count;
|
|
||||||
|
|
||||||
for(let i=0;i<count;i++){
|
for(let i=0;i<count;i++){
|
||||||
if(autosuidao.geometry.attributes.position.array[i*3] >7){
|
if(autorail.geometry.attributes.position.array[i*3] >0.49){
|
||||||
rightlist.push(i);
|
rightlist.push(i);
|
||||||
if(autosuidao.geometry.attributes.position.array[i*3] > rightpoint){
|
|
||||||
rightpoint = i;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if(autosuidao.geometry.attributes.position.array[i*3] <-7){
|
if(autorail.geometry.attributes.position.array[i*3] <-0.49){
|
||||||
leftlist.push(i);
|
leftlist.push(i);
|
||||||
if(autosuidao.geometry.attributes.position.array[i*3] < rightpoint){
|
|
||||||
leftpoint = i;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
autosuidao.rightlist = rightlist;
|
autorail.rightlist = rightlist;
|
||||||
autosuidao.leftlist = leftlist;
|
autorail.leftlist = leftlist;
|
||||||
autosuidao.rightpoint = rightpoint;
|
scene.add(scope.sectiongroup);
|
||||||
autosuidao.leftpoint = leftpoint;
|
return new Promise(function(resolve, reject){
|
||||||
// console.log(autosuidao);
|
console.log(sectiondata);
|
||||||
// console.log(linkdata.linksgroup.children);
|
for(let i=0,leni = sectiondata.length;i<leni;i++){
|
||||||
// console.log(suidaodata.datalist);
|
let newsection = {
|
||||||
for(let i = 0;i < suidaodata.datalist.length;i++){
|
code:sectiondata[i].code,
|
||||||
let link = linkdata.linksgroup.getObjectByProperty("code",suidaodata.datalist[i].linkCode);
|
name:sectiondata[i].name,
|
||||||
let suidao = suidaodata.datalist[i];
|
standTrack:sectiondata[i].standTrack,
|
||||||
let len = suidao.offsetRight-suidao.offsetLeft;
|
rail:sectiondata[i].rail,
|
||||||
// console.log("-------------------------------------");
|
rightlist:sectiondata[i].rightlist,
|
||||||
// console.log("name:"+link.name);
|
leftlist:sectiondata[i].leftlist,
|
||||||
// console.log(link.lengthfact);
|
rsection:sectiondata[i].rsection,
|
||||||
// console.log(len);
|
lsection:sectiondata[i].lsection,
|
||||||
// console.log("ofl:"+suidao.offsetLeft+" "+"ofr:"+suidao.offsetRight);
|
csection:sectiondata[i].csection,
|
||||||
// console.log("-------------------------------------");
|
lengthFact:sectiondata[i].lengthFact,
|
||||||
|
rp:sectiondata[i].rp,
|
||||||
|
lp:sectiondata[i].lp,
|
||||||
|
mesh:null
|
||||||
|
};
|
||||||
|
|
||||||
let testmesh1 = autosuidao.clone(true);
|
let len = newsection.lengthFact;
|
||||||
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;
|
let testmesh2 = autorail.clone(true);
|
||||||
testmesh1.rotation.z = link.rotation.z;
|
for(let i=0;i<autorail.rightlist.length;i++){
|
||||||
//
|
testmesh2.geometry.attributes.position.array[autorail.rightlist[i]*3] = len;
|
||||||
// console.log(link.lp.x);
|
testmesh2.geometry.attributes.uv.array[autorail.rightlist[i]*2] = testmesh2.geometry.attributes.position.array[0]-testmesh2.geometry.attributes.position.array[3];
|
||||||
// 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.z > link.rp.z){
|
|
||||||
testmesh1.position.z = link.lp.z-suidao.offsetLeft*(len/lenfact) + (link.rp.z-link.lp.z)*(len/lenfact)/2;
|
|
||||||
}else{
|
|
||||||
testmesh1.position.z = link.lp.z+suidao.offsetLeft*(len/lenfact) + (link.rp.z-link.lp.z)*(len/lenfact)/2;
|
|
||||||
}
|
}
|
||||||
}else{
|
let newrail = new THREE.BufferGeometry();
|
||||||
testmesh1.position.x = link.lp.x+suidao.offsetLeft+len/2;
|
newrail.copy(testmesh2.geometry);
|
||||||
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;
|
// console.log(sectiondata[i]);
|
||||||
testmesh1.leftlist = autosuidao.leftlist;
|
// console.log(testmesh2);
|
||||||
testmesh1.rightpoint = autosuidao.rightpoint;
|
testmesh2.geometry = newrail;
|
||||||
testmesh1.leftpoint = autosuidao.leftpoint;
|
testmesh2.geometry.attributes.position.needsUpdate = true;
|
||||||
testmesh1.isStandTrack = suidaodata.datalist[i].isStandTrack;
|
testmesh2.geometry.attributes.uv.needsUpdate = true;
|
||||||
testmesh1.lengthfact = len;
|
testmesh2.geometry.computeBoundingSphere();
|
||||||
testmesh1.linkCode = suidao.linkCode;
|
testmesh2.geometry.center();
|
||||||
if(suidaodata.datalist[i].isStandTrack == false){
|
testmesh2.code = newsection.code;
|
||||||
scope.sectiongroup.add(testmesh1);
|
testmesh2.rightlist = sectiondata[i].rightlist,
|
||||||
|
testmesh2.leftlist = sectiondata[i].leftlist,
|
||||||
|
testmesh2.position.set(sectiondata[i].position.x,sectiondata[i].position.y,sectiondata[i].position.z);
|
||||||
|
testmesh2.rotation.set(sectiondata[i].rotation._x,sectiondata[i].rotation._y,sectiondata[i].rotation._z);
|
||||||
|
scope.sectiongroup.add(testmesh2);
|
||||||
|
newsection.mesh = testmesh2;
|
||||||
|
scope.sections.datalist[newsection.code] = newsection;
|
||||||
|
|
||||||
}else{
|
|
||||||
scope.standtrack.push(testmesh1);
|
|
||||||
var box = new THREE.BoxHelper( testmesh1, 0xff0000 );
|
|
||||||
scope.sectiongroup.add( box );
|
|
||||||
}
|
}
|
||||||
scope.sections.modellist.push(testmesh1);
|
resolve("loadersection");
|
||||||
}
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.resetsection = function(scene){
|
this.resetsection = function(scene){
|
||||||
|
@ -33,11 +33,14 @@ export function SignalList() {
|
|||||||
let newsignal = new SignalModel(data[i]);
|
let newsignal = new SignalModel(data[i]);
|
||||||
|
|
||||||
if(haddata == false){
|
if(haddata == false){
|
||||||
|
// console.log(data[i])
|
||||||
let newmesh = assetloader.modellist[num].mesh.clone(true);
|
let newmesh = assetloader.modellist[num].mesh.clone(true);
|
||||||
|
|
||||||
newmesh.name = assetloader.modellist[num].name;
|
newmesh.name = data[i].name;
|
||||||
newmesh.modelid = assetloader.modellist[num].id;
|
newmesh.modelid = assetloader.modellist[num].id;
|
||||||
newmesh.code = data[i].code;
|
newmesh.code = data[i].code;
|
||||||
|
newmesh.sectionCode = data[i].sectionCode;
|
||||||
|
newmesh.right = data[i].right;
|
||||||
for(let j=0;j<newmesh.children.length;j++){
|
for(let j=0;j<newmesh.children.length;j++){
|
||||||
newmesh.children[j].code = data[i].code;
|
newmesh.children[j].code = data[i].code;
|
||||||
}
|
}
|
||||||
@ -73,6 +76,11 @@ export function SignalList() {
|
|||||||
newsignal.mesh = newmesh;
|
newsignal.mesh = newmesh;
|
||||||
newsignal.sectionOffset = data[i].sectionOffset;
|
newsignal.sectionOffset = data[i].sectionOffset;
|
||||||
newsignal.mesh.status = "01";
|
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.group.add(newmesh);
|
||||||
scope.list.push(newsignal);
|
scope.list.push(newsignal);
|
||||||
|
|
||||||
@ -123,15 +131,16 @@ export function SignalList() {
|
|||||||
num = j;
|
num = j;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// console.log(signaldata[i]);
|
||||||
let newmesh = assetloader.modellist[num].mesh.clone(true);
|
let newmesh = assetloader.modellist[num].mesh.clone(true);
|
||||||
newmesh.uuid = signaldata[i].id;
|
// 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.name = signaldata[i].name;
|
||||||
newmesh.modelid = assetloader.modellist[num].id;
|
newmesh.modelid = assetloader.modellist[num].id;
|
||||||
newmesh.code = signaldata[i].code;
|
newmesh.code = signaldata[i].code;
|
||||||
newmesh.offset = data[i].offset;
|
newmesh.right = data[i].right;
|
||||||
newmesh.linkCode = data[i].linkCode;
|
|
||||||
newmesh.directionType = data[i].directionType;
|
|
||||||
newmesh.position.x = signaldata[i].position.x;
|
newmesh.position.x = signaldata[i].position.x;
|
||||||
newmesh.position.y = signaldata[i].position.y;
|
newmesh.position.y = signaldata[i].position.y;
|
||||||
newmesh.position.z = signaldata[i].position.z;
|
newmesh.position.z = signaldata[i].position.z;
|
||||||
|
@ -33,6 +33,7 @@ export function StationStandList() {
|
|||||||
|
|
||||||
//遍历车站站台数据
|
//遍历车站站台数据
|
||||||
for(let j=0;j<stationstanddata.length;j++){
|
for(let j=0;j<stationstanddata.length;j++){
|
||||||
|
|
||||||
if(stationstanddata[j].small == false){
|
if(stationstanddata[j].small == false){
|
||||||
//收集有效车站数据
|
//收集有效车站数据
|
||||||
if(stationstanddata[j].stationCode == stationdata[i].code){
|
if(stationstanddata[j].stationCode == stationdata[i].code){
|
||||||
@ -45,16 +46,19 @@ export function StationStandList() {
|
|||||||
//向右上行
|
//向右上行
|
||||||
// console.log(stationstanddata[j]);
|
// console.log(stationstanddata[j]);
|
||||||
if(stationstanddata[j].right == true){
|
if(stationstanddata[j].right == true){
|
||||||
|
// console.log(stationstanddata[j]);
|
||||||
|
newstationstand.direction1.code = stationstanddata[j].code;
|
||||||
newstationstand.direction1.position = stationstanddata[j].position;
|
newstationstand.direction1.position = stationstanddata[j].position;
|
||||||
newstationstand.direction1.name = stationstanddata[j].code;
|
newstationstand.direction1.name = stationstanddata[j].name;
|
||||||
newstationstand.direction1.screenDoorOpenStatus = "01";
|
newstationstand.direction1.screenDoorOpenStatus = "01";
|
||||||
newstationstand.direction1.section = stationstanddata[j].standTrackCode;
|
newstationstand.direction1.section = stationstanddata[j].standTrackCode;
|
||||||
// console.log(stationstanddata[j].standTrackCode);
|
// console.log(stationstanddata[j].standTrackCode);
|
||||||
}
|
}
|
||||||
//向左下行
|
//向左下行
|
||||||
if(stationstanddata[j].right == false){
|
if(stationstanddata[j].right == false){
|
||||||
|
newstationstand.direction2.code = stationstanddata[j].code;
|
||||||
newstationstand.direction2.position = stationstanddata[j].position;
|
newstationstand.direction2.position = stationstanddata[j].position;
|
||||||
newstationstand.direction2.name = stationstanddata[j].code;
|
newstationstand.direction2.name = stationstanddata[j].name;
|
||||||
newstationstand.direction2.screenDoorOpenStatus = "01";
|
newstationstand.direction2.screenDoorOpenStatus = "01";
|
||||||
newstationstand.direction2.section = stationstanddata[j].standTrackCode;
|
newstationstand.direction2.section = stationstanddata[j].standTrackCode;
|
||||||
// console.log(stationstanddata[j].standTrackCode);
|
// console.log(stationstanddata[j].standTrackCode);
|
||||||
@ -158,7 +162,43 @@ export function StationStandList() {
|
|||||||
resolve("loadedstation");
|
resolve("loadedstation");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
this.loadpromise = function(jlmap3ddata,standsdata,scene,assetloader){
|
||||||
|
return new Promise(function(resolve, reject){
|
||||||
|
console.log(standsdata);
|
||||||
|
let stations = jlmap3ddata.stationstandlist.list;
|
||||||
|
let num;
|
||||||
|
for(let j=0;j<assetloader.modellist.length;j++){
|
||||||
|
if(assetloader.modellist[j].deviceType == "stand"){
|
||||||
|
num = j;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(let i=0;i<standsdata.length;i++){
|
||||||
|
let newstationstand = new StationStandModel(standsdata[i]);
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
let newstationmesh = assetloader.modellist[num].mesh.clone(true);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
scene.add(scope.group);
|
||||||
|
resolve("loadedstation");
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
this.update = function(){
|
this.update = function(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,36 +15,86 @@ export function SwitchList() {
|
|||||||
|
|
||||||
this.initpromise = function(jlmap3ddata,data,scene,assetloader,netdata){
|
this.initpromise = function(jlmap3ddata,data,scene,assetloader,netdata){
|
||||||
// console.log(jlmap3ddata);
|
// console.log(jlmap3ddata);
|
||||||
scene.add( scope.switchgroup );
|
return new Promise(function(resolve, reject){
|
||||||
let sectiondata = jlmap3ddata.sectionlist.sections.datalist;
|
scene.add( scope.switchgroup );
|
||||||
// console.log(sectiondata);
|
let sectiondata = jlmap3ddata.sectionlist.sections.datalist;
|
||||||
let num;
|
// console.log(sectiondata);
|
||||||
for(let j=0;j<assetloader.modellist.length;j++){
|
let num;
|
||||||
if(assetloader.modellist[j].deviceType == "autoswitch"){
|
for(let j=0;j<assetloader.modellist.length;j++){
|
||||||
num = 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
|
|
||||||
};
|
};
|
||||||
|
for(let i=0,leni = data.length;i<leni;i++){
|
||||||
|
|
||||||
let autoswitch = assetloader.modellist[num].mesh.clone(true);
|
let newswitch = {
|
||||||
scope.switchgroup.add(autoswitch);
|
code:data[i].code,
|
||||||
if(sectiondata[data[i].sectionACode].mesh.position.x >sectiondata[data[i].sectionBCode].mesh.position.x){
|
name:data[i].name,
|
||||||
autoswitch.position.set(sectiondata[data[i].sectionACode].lp.x,0,sectiondata[data[i].sectionACode].lp.z);
|
pa:data[i].sectionACode,
|
||||||
autoswitch.rotation.z = Math.PI;
|
pb:data[i].sectionBCode,
|
||||||
}else{
|
pc:data[i].sectionCCode
|
||||||
autoswitch.position.set(sectiondata[data[i].sectionACode].rp.x,0,sectiondata[data[i].sectionACode].rp.z);
|
};
|
||||||
|
|
||||||
|
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].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
|
||||||
|
};
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(scope.switchs.modellist);
|
||||||
|
resolve("loadedswitch");
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
this.update = function(){
|
this.update = function(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,107 +0,0 @@
|
|||||||
import {TrainModel} from '@/jlmap3d/edit/editmodel/TrainModel.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( '../../static/model/train/' ).load( 'train.mtl', function ( materials ) {
|
|
||||||
materials.preload();
|
|
||||||
|
|
||||||
new THREE.OBJLoader().setMaterials( materials ).setPath( '../../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;
|
|
||||||
}
|
|
@ -36,7 +36,7 @@ import {MouseControls} from '@/jlmap3d/main/control/FirstControls';
|
|||||||
|
|
||||||
var clock = new THREE.Clock();
|
var clock = new THREE.Clock();
|
||||||
|
|
||||||
export function JLmapDriving(dom,data,mapId,storemod,translation,routegroup) {
|
export function JLmapDriving(dom,data,mapId,storemod,translation,routegroup,project) {
|
||||||
|
|
||||||
let scope = this;
|
let scope = this;
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ export function JLmapDriving(dom,data,mapId,storemod,translation,routegroup) {
|
|||||||
// 定义相机
|
// 定义相机
|
||||||
//let camera = SetCamera(dom);
|
//let camera = SetCamera(dom);
|
||||||
// 定义场景(渲染容器)
|
// 定义场景(渲染容器)
|
||||||
let scene = SetScene();
|
let scene = SetScene(project);
|
||||||
|
|
||||||
let speed = 0;
|
let speed = 0;
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ import {Stats} from '@/jlmap3d/main/lib/stats.min.js';
|
|||||||
|
|
||||||
var clock = new THREE.Clock();
|
var clock = new THREE.Clock();
|
||||||
|
|
||||||
export function JLmap3d(dom, data,skinCode,storemod,routegroup) {
|
export function JLmap3d(dom, data,skinCode,storemod,routegroup,project) {
|
||||||
|
|
||||||
|
|
||||||
let scope = this;
|
let scope = this;
|
||||||
@ -52,7 +52,7 @@ export function JLmap3d(dom, data,skinCode,storemod,routegroup) {
|
|||||||
//定义相机
|
//定义相机
|
||||||
let camera = SetCamera(dom);
|
let camera = SetCamera(dom);
|
||||||
//定义场景(渲染容器)
|
//定义场景(渲染容器)
|
||||||
let scene = SetScene();
|
let scene = SetScene(project);
|
||||||
//定义镜头操作
|
//定义镜头操作
|
||||||
let controls = new THREE.OrbitControls(camera);
|
let controls = new THREE.OrbitControls(camera);
|
||||||
controls.maxPolarAngle = Math.PI/2;
|
controls.maxPolarAngle = Math.PI/2;
|
||||||
@ -166,7 +166,7 @@ export function JLmap3d(dom, data,skinCode,storemod,routegroup) {
|
|||||||
//
|
//
|
||||||
// }
|
// }
|
||||||
//根据相机渲染场景
|
//根据相机渲染场景
|
||||||
renderer.render(scene,camera);
|
renderer.render(scene,camera);
|
||||||
// console.log(scope.animateswitch);
|
// console.log(scope.animateswitch);
|
||||||
//检测动画构造器播放动画
|
//检测动画构造器播放动画
|
||||||
|
|
||||||
|
@ -7,6 +7,12 @@ import {RealSectionList} from '@/jlmap3d/main/model/RealSectionList.js';
|
|||||||
import {LinkList} from '@/jlmap3d/main/model/LinkList.js';
|
import {LinkList} from '@/jlmap3d/main/model/LinkList.js';
|
||||||
import {RailList} from '@/jlmap3d/main/model/RailList.js';
|
import {RailList} from '@/jlmap3d/main/model/RailList.js';
|
||||||
|
|
||||||
|
import {SectionListN} from '@/jlmap3d/main/newmodel/SectionListN';
|
||||||
|
import {SignalListN} from '@/jlmap3d/main/newmodel/SignalListN';
|
||||||
|
import {StationStandListN} from '@/jlmap3d/main/newmodel/StationStandListN';
|
||||||
|
import {SwitchListN} from '@/jlmap3d/main/newmodel/SwitchListN';
|
||||||
|
|
||||||
|
|
||||||
import {Materialload} from '@/jlmap3d/main/loaders/Materialload.js';
|
import {Materialload} from '@/jlmap3d/main/loaders/Materialload.js';
|
||||||
|
|
||||||
import { Loading } from 'element-ui';
|
import { Loading } from 'element-ui';
|
||||||
@ -26,27 +32,128 @@ export function ModelLoad(data,scope,netdata,mapdata,camera,controls,scene,store
|
|||||||
let mixers = scope.mixers;
|
let mixers = scope.mixers;
|
||||||
let actions = scope.actions;
|
let actions = scope.actions;
|
||||||
|
|
||||||
let linklist,sectionlist,signallist,stationstandlist,trainlisttest,realsectionlist,rails;
|
let linklist,sectionlist,signallist,stationstandlist,trainlisttest,switchlist,realsectionlist,rails;
|
||||||
|
|
||||||
let loadingInstance = Loading.service({ fullscreen: true });
|
let loadingInstance = Loading.service({ fullscreen: true });
|
||||||
|
|
||||||
|
|
||||||
let isSection = false;
|
let isSection = false;
|
||||||
|
let isNewdata = false;
|
||||||
if(netdata.assets){
|
if(netdata.assets){
|
||||||
let assetsdata = JSON.parse(netdata.sections);
|
let assetsdata = JSON.parse(netdata.sections);
|
||||||
|
// console.log(assetsdata.link);
|
||||||
if(assetsdata.link){
|
if(assetsdata.link){
|
||||||
isSection = true;
|
isSection = true;
|
||||||
|
}else{
|
||||||
|
isNewdata = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isSection == true){
|
if(isSection == true){
|
||||||
init3d(data,netdata);
|
init3d(data,netdata);
|
||||||
|
}else if(isNewdata == true){
|
||||||
|
initnew3d(data,netdata);
|
||||||
}else{
|
}else{
|
||||||
loadingInstance.close();
|
loadingInstance.close();
|
||||||
alert("没有三维数据");
|
alert("没有三维数据");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function initnew3d(data,netdata){
|
||||||
|
console.log(data);
|
||||||
|
console.log(netdata);
|
||||||
|
let mapdata = data;
|
||||||
|
//初始化轨道和道岔
|
||||||
|
// lengthfact(data);
|
||||||
|
|
||||||
|
// linklist = new LinkList();
|
||||||
|
sectionlist = new SectionListN();
|
||||||
|
signallist = new SignalListN();
|
||||||
|
switchlist = new SwitchListN();
|
||||||
|
//初始化站台
|
||||||
|
stationstandlist = new StationStandListN();
|
||||||
|
//初始化测试列车
|
||||||
|
trainlisttest = new TrainList();
|
||||||
|
// realsectionlist = new RealSectionList();
|
||||||
|
|
||||||
|
rails = 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);
|
||||||
|
|
||||||
|
assetloader.setmodellist(netdata.assets);
|
||||||
|
|
||||||
|
assetloader.assetpromise(sceneload)
|
||||||
|
// .then(function(data){
|
||||||
|
// return linklist.loadpromise(loaderdata.link,sceneload,assetloader);
|
||||||
|
// })
|
||||||
|
.then(function(data){
|
||||||
|
//console.log(data);
|
||||||
|
//,netdata.stands,mixers,actions,"0"
|
||||||
|
return stationstandlist.loadpromise(mapdata.stationList,standsdata,sceneload,assetloader,mixers,actions,"02");
|
||||||
|
})
|
||||||
|
.then(function(data){
|
||||||
|
//console.log(data);
|
||||||
|
return sectionlist.loadpromise(mapdata.sectionList,sectiondata.section,scene,assetloader);
|
||||||
|
})
|
||||||
|
// .then(function(data){
|
||||||
|
// //console.log(data);
|
||||||
|
// //console.log(assetloader);
|
||||||
|
// return trainlisttest.initpromise(mapdata.trainList,sceneload,assetloader,mixers,actions,"0");
|
||||||
|
// })
|
||||||
|
// .then(function(data){
|
||||||
|
// //console.log(data);
|
||||||
|
// return sectionlist.loadpromise(linklist,assetloader,loaderdata.section,switchdata,sceneload);
|
||||||
|
// })
|
||||||
|
// .then(function(data){
|
||||||
|
// //console.log(data);
|
||||||
|
// return jlmap3ddata.realsectionlist.initpromise(jlmap3ddata,sceneload,assetloader,mixers,actions);
|
||||||
|
// })
|
||||||
|
.then(function(data){
|
||||||
|
//console.log(data);
|
||||||
|
return signallist.loadpromise(mapdata.signalList,signaldata,sceneload,assetloader);
|
||||||
|
})
|
||||||
|
.then(function(data){
|
||||||
|
return switchlist.loadpromise(mapdata.switchList,switchdata,sceneload,assetloader);
|
||||||
|
})
|
||||||
|
.then(function(data){
|
||||||
|
//console.log(data);
|
||||||
|
//console.log(assetloader);
|
||||||
|
return trainlisttest.initpromise(mapdata.trainList,sceneload,assetloader,mixers,actions,"02");
|
||||||
|
})
|
||||||
|
// .then(function(data){
|
||||||
|
// return new Promise(function(resolve, reject){
|
||||||
|
// let stopoffset = 64;
|
||||||
|
// rails.init(loaderdata.link,mapdata.linkList,mapdata.sectionList,switchdata,
|
||||||
|
// stationstandlist.list,sceneload,storemod,stopoffset);
|
||||||
|
// resolve("loadrail");
|
||||||
|
//
|
||||||
|
// });
|
||||||
|
// })
|
||||||
|
|
||||||
|
.then(function(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;
|
||||||
|
// // scope.assetloader.modellist[mn].mesh.position.y -=0.1;
|
||||||
|
// // console.log(scope.assetloader.modellist[mn].mesh);
|
||||||
|
// scene.add(scope.assetloader.modellist[mn].mesh);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
scope.animateswitch = true;
|
||||||
|
|
||||||
|
// // mapdata = jlmap3ddata;
|
||||||
|
backdata.loaderdata(sectionlist,linklist,signallist,stationstandlist,trainlisttest,realsectionlist,rails);
|
||||||
|
// scope.Subscribe.updatamap(sectionlist,linklist,signallist,stationstandlist,trainlisttest,realsectionlist,rails,scope.materiallist,scope.actions,scope.sceneload);
|
||||||
|
// scope.webwork.postMessage("on");
|
||||||
|
// console.log(stationstandlist);
|
||||||
|
updatemenulist(stationstandlist.list,trainlisttest.list);
|
||||||
|
loadingInstance.close();
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function init3d(data,netdata){
|
function init3d(data,netdata){
|
||||||
let mapdata = data;
|
let mapdata = data;
|
||||||
|
@ -29,21 +29,109 @@ export function ModelLoad(data,scope,netdata,sectionlist,linklist,signallist,sta
|
|||||||
|
|
||||||
|
|
||||||
let isSection = false;
|
let isSection = false;
|
||||||
|
let isNewdata = false;
|
||||||
if(netdata.assets){
|
if(netdata.assets){
|
||||||
let assetsdata = JSON.parse(netdata.sections);
|
let assetsdata = JSON.parse(netdata.sections);
|
||||||
// console.log(netdata);
|
console.log(assetsdata.link);
|
||||||
if(assetsdata.link){
|
if(assetsdata.link){
|
||||||
isSection = true;
|
isSection = true;
|
||||||
|
}else{
|
||||||
|
isNewdata = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
console.log(isNewdata);
|
||||||
|
// console.log(netdata);
|
||||||
if(isSection == true){
|
if(isSection == true){
|
||||||
init3d(data,netdata);
|
init3d(data,netdata);
|
||||||
|
}else if(isNewdata == true){
|
||||||
|
initnew3d(data,netdata);
|
||||||
}else{
|
}else{
|
||||||
loadingInstance.close();
|
loadingInstance.close();
|
||||||
alert("没有三维数据");
|
alert("没有三维数据");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function initnew3d(data,netdata){
|
||||||
|
console.log(data);
|
||||||
|
console.log(netdata);
|
||||||
|
let mapdata = data;
|
||||||
|
// console.log(data);
|
||||||
|
//初始化轨道和道岔 暂时
|
||||||
|
lengthfact(data);
|
||||||
|
|
||||||
|
linklist = new LinkList();
|
||||||
|
sectionlist = new SectionList();
|
||||||
|
signallist = new SignalList();
|
||||||
|
//初始化站台
|
||||||
|
stationstandlist = new StationStandList();
|
||||||
|
//初始化测试列车
|
||||||
|
trainlisttest = new TrainList();
|
||||||
|
realsectionlist = new RealSectionList();
|
||||||
|
|
||||||
|
rails = 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);
|
||||||
|
|
||||||
|
assetloader.setmodellist(netdata.assets);
|
||||||
|
|
||||||
|
assetloader.assetpromise(sceneload)
|
||||||
|
.then(function(data){
|
||||||
|
return linklist.loadpromise(loaderdata.link,sceneload,assetloader);
|
||||||
|
})
|
||||||
|
.then(function(data){
|
||||||
|
//console.log(data);
|
||||||
|
return stationstandlist.initpromise(mapdata.stationList,mapdata.stationStandList,sceneload,assetloader,netdata.stands,mixers,actions,"0");
|
||||||
|
})
|
||||||
|
.then(function(data){
|
||||||
|
//console.log(data);
|
||||||
|
//console.log(assetloader);
|
||||||
|
return trainlisttest.initpromise(mapdata.trainList,sceneload,assetloader,mixers,actions,"0");
|
||||||
|
})
|
||||||
|
.then(function(data){
|
||||||
|
//console.log(data);
|
||||||
|
return sectionlist.loadpromise(linklist,assetloader,loaderdata.section,switchdata,sceneload);
|
||||||
|
})
|
||||||
|
// .then(function(data){
|
||||||
|
// //console.log(data);
|
||||||
|
// return jlmap3ddata.realsectionlist.initpromise(jlmap3ddata,sceneload,assetloader,mixers,actions);
|
||||||
|
// })
|
||||||
|
.then(function(data){
|
||||||
|
//console.log(data);
|
||||||
|
return signallist.initpromise(mapdata.signalList,sceneload,assetloader,netdata.signals);
|
||||||
|
})
|
||||||
|
.then(function(data){
|
||||||
|
return new Promise(function(resolve, reject){
|
||||||
|
let stopoffset = 64;
|
||||||
|
rails.init(loaderdata.link,mapdata.linkList,mapdata.sectionList,switchdata,
|
||||||
|
stationstandlist.list,sceneload,storemod,stopoffset);
|
||||||
|
resolve("loadrail");
|
||||||
|
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
.then(function(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;
|
||||||
|
// scope.assetloader.modellist[mn].mesh.position.y -=0.1;
|
||||||
|
// console.log(scope.assetloader.modellist[mn].mesh);
|
||||||
|
scene.add(scope.assetloader.modellist[mn].mesh);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
scope.animateswitch = true;
|
||||||
|
|
||||||
|
// mapdata = jlmap3ddata;
|
||||||
|
backdata.loaderdata(sectionlist,linklist,signallist,stationstandlist,trainlisttest,realsectionlist,rails);
|
||||||
|
scope.Subscribe.updatamap(sectionlist,linklist,signallist,stationstandlist,trainlisttest,realsectionlist,rails,scope.materiallist,scope.actions,scope.sceneload);
|
||||||
|
scope.webwork.postMessage("on");
|
||||||
|
loadingInstance.close();
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function init3d(data,netdata){
|
function init3d(data,netdata){
|
||||||
let mapdata = data;
|
let mapdata = data;
|
||||||
|
96
src/jlmap3d/main/newmodel/SectionListN.js
Normal file
96
src/jlmap3d/main/newmodel/SectionListN.js
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
import {SectionModel} from '@/jlmap3d/main/newmodel/SectionModel.js';
|
||||||
|
import {SwitchModel} from '@/jlmap3d/main/newmodel/SwitchModel.js';
|
||||||
|
export function SectionListN() {
|
||||||
|
|
||||||
|
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.loadpromise = function(sectionList,sectiondata,scene,assetloader){
|
||||||
|
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;
|
||||||
|
scene.add(scope.sectiongroup);
|
||||||
|
return new Promise(function(resolve, reject){
|
||||||
|
console.log(sectiondata);
|
||||||
|
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,
|
||||||
|
rightlist:sectiondata[i].rightlist,
|
||||||
|
leftlist:sectiondata[i].leftlist,
|
||||||
|
rsection:sectiondata[i].rsection,
|
||||||
|
lsection:sectiondata[i].lsection,
|
||||||
|
csection:sectiondata[i].csection,
|
||||||
|
lengthFact:sectiondata[i].lengthFact,
|
||||||
|
rp:sectiondata[i].rp,
|
||||||
|
lp:sectiondata[i].lp,
|
||||||
|
mesh:null
|
||||||
|
};
|
||||||
|
|
||||||
|
let len = newsection.lengthFact;
|
||||||
|
console.log(newsection.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);
|
||||||
|
|
||||||
|
// console.log(sectiondata[i]);
|
||||||
|
// console.log(testmesh2);
|
||||||
|
testmesh2.geometry = newrail;
|
||||||
|
testmesh2.geometry.attributes.position.needsUpdate = true;
|
||||||
|
testmesh2.geometry.attributes.uv.needsUpdate = true;
|
||||||
|
testmesh2.geometry.computeBoundingSphere();
|
||||||
|
testmesh2.geometry.center();
|
||||||
|
testmesh2.code = newsection.code;
|
||||||
|
testmesh2.rightlist = sectiondata[i].rightlist,
|
||||||
|
testmesh2.leftlist = sectiondata[i].leftlist,
|
||||||
|
testmesh2.position.set(sectiondata[i].position.x,sectiondata[i].position.y,sectiondata[i].position.z);
|
||||||
|
testmesh2.rotation.set(sectiondata[i].rotation._x,sectiondata[i].rotation._y,sectiondata[i].rotation._z);
|
||||||
|
scope.sectiongroup.add(testmesh2);
|
||||||
|
newsection.mesh = testmesh2;
|
||||||
|
scope.sections.datalist[newsection.code] = newsection;
|
||||||
|
|
||||||
|
}
|
||||||
|
resolve("loadersection");
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
this.resetsection = function(scene){
|
||||||
|
scene.remove(scope.sectiongroup);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
26
src/jlmap3d/main/newmodel/SectionModel.js
Normal file
26
src/jlmap3d/main/newmodel/SectionModel.js
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
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;
|
||||||
|
|
||||||
|
}
|
51
src/jlmap3d/main/newmodel/SignalListN.js
Normal file
51
src/jlmap3d/main/newmodel/SignalListN.js
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
import {SignalModel} from '@/jlmap3d/main/newmodel/SignalModel.js';
|
||||||
|
|
||||||
|
export function SignalListN() {
|
||||||
|
|
||||||
|
let scope = this;
|
||||||
|
|
||||||
|
this.type = "signallist";
|
||||||
|
|
||||||
|
this.list = [];
|
||||||
|
|
||||||
|
this.group = new THREE.Group();
|
||||||
|
|
||||||
|
this.loadpromise = function(data,signaldata,scene,assetloader){
|
||||||
|
|
||||||
|
return new Promise(function(resolve, reject){
|
||||||
|
for(let i=0;i<signaldata.length;i++){
|
||||||
|
let newsignal = new SignalModel(signaldata[i]);
|
||||||
|
let selectmesh = null;
|
||||||
|
for(let j=0;j<assetloader.modellist.length;j++){
|
||||||
|
if(assetloader.modellist[j].deviceType == "signal"){
|
||||||
|
selectmesh = assetloader.modellist[j].mesh;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// console.log(signaldata[i]);
|
||||||
|
let newmesh = selectmesh.clone(true);
|
||||||
|
// 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 = selectmesh.id;
|
||||||
|
newmesh.code = signaldata[i].code;
|
||||||
|
newmesh.right = data[i].right;
|
||||||
|
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[signaldata[i].code] = newsignal;
|
||||||
|
}
|
||||||
|
scene.add(scope.group);
|
||||||
|
resolve("loadedsignal");
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
36
src/jlmap3d/main/newmodel/SignalModel.js
Normal file
36
src/jlmap3d/main/newmodel/SignalModel.js
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
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;
|
||||||
|
}
|
158
src/jlmap3d/main/newmodel/StationStandListN.js
Normal file
158
src/jlmap3d/main/newmodel/StationStandListN.js
Normal file
@ -0,0 +1,158 @@
|
|||||||
|
import {StationStandModel} from '@/jlmap3d/main/newmodel/StationStandModel.js';
|
||||||
|
|
||||||
|
export function StationStandListN() {
|
||||||
|
|
||||||
|
let scope = this;
|
||||||
|
|
||||||
|
this.type = "stationstandlist";
|
||||||
|
|
||||||
|
this.list = [];
|
||||||
|
|
||||||
|
this.group = new THREE.Group();
|
||||||
|
|
||||||
|
this.textlist = [];
|
||||||
|
|
||||||
|
this.loadpromise = function(stationdata,standsdata,scene,assetloader,mixers,actionss,mode){
|
||||||
|
return new Promise(function(resolve, reject){
|
||||||
|
|
||||||
|
let stations = stationdata;
|
||||||
|
let selectmesh;
|
||||||
|
for(let j=0;j<assetloader.modellist.length;j++){
|
||||||
|
if(assetloader.modellist[j].deviceType == "stand"){
|
||||||
|
selectmesh = assetloader.modellist[j].mesh;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(let i=0;i<standsdata.length;i++){
|
||||||
|
let newstationstand = new StationStandModel(standsdata[i]);
|
||||||
|
|
||||||
|
newstationstand.code = standsdata[i].code;
|
||||||
|
newstationstand.name = standsdata[i].name;
|
||||||
|
newstationstand.type = "station";
|
||||||
|
newstationstand.num = i;
|
||||||
|
|
||||||
|
newstationstand.direction1.code = standsdata[i].direction1.code;
|
||||||
|
newstationstand.direction1.name = standsdata[i].direction1.name;
|
||||||
|
newstationstand.direction1.screenDoorOpenStatus = "01";
|
||||||
|
|
||||||
|
newstationstand.direction2.code = standsdata[i].direction2.code;
|
||||||
|
newstationstand.direction2.name = standsdata[i].direction2.name;
|
||||||
|
newstationstand.direction2.screenDoorOpenStatus = "01";
|
||||||
|
|
||||||
|
let newstationmesh = selectmesh.clone(true);
|
||||||
|
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[standsdata[i].code] = newstationstand;
|
||||||
|
|
||||||
|
let newclip = selectmesh.animations[ 0 ];
|
||||||
|
console.log(newstationmesh);
|
||||||
|
for(let j=0;j<newstationmesh.children.length;j++){
|
||||||
|
|
||||||
|
if(newstationmesh.children[j].name == "top"){
|
||||||
|
newstationmesh.children[j].animations = [];
|
||||||
|
newstationmesh.children[j].animations.push(newclip.clone());
|
||||||
|
|
||||||
|
let mixer = new THREE.AnimationMixer( newstationmesh.children[j] );
|
||||||
|
|
||||||
|
let key = newstationstand.direction1.name;
|
||||||
|
actionss[key] = {
|
||||||
|
status:"01",
|
||||||
|
action:mixer.clipAction( newstationmesh.children[j].animations[0])
|
||||||
|
};
|
||||||
|
actionss[key].action.setLoop(THREE.LoopOnce);
|
||||||
|
actionss[key].action.clampWhenFinished = true;
|
||||||
|
//actionss[key].play();
|
||||||
|
mixers.push(mixer);
|
||||||
|
}
|
||||||
|
if(newstationmesh.children[j].name == "down"){
|
||||||
|
newstationmesh.children[j].animations = [];
|
||||||
|
newstationmesh.children[j].animations.push(newclip.clone());
|
||||||
|
|
||||||
|
let mixer = new THREE.AnimationMixer( newstationmesh.children[j] );
|
||||||
|
|
||||||
|
let key = newstationstand.direction2.name;
|
||||||
|
actionss[key] = {
|
||||||
|
status:"01",
|
||||||
|
action:mixer.clipAction( newstationmesh.children[j].animations[0])
|
||||||
|
};
|
||||||
|
actionss[key].action.setLoop(THREE.LoopOnce);
|
||||||
|
actionss[key].action.clampWhenFinished = true;
|
||||||
|
//actionss[key].play();
|
||||||
|
mixers.push(mixer);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
// console.log(newstationmesh);
|
||||||
|
if(mode){
|
||||||
|
if(mode == "02"){
|
||||||
|
let textgeometry = new THREE.PlaneBufferGeometry( 271, 374, 1 );
|
||||||
|
let textt = new THREE.CanvasTexture(getTextCanvas(stationdata[i]));
|
||||||
|
let textmaterial = new THREE.MeshBasicMaterial( { side: THREE.DoubleSide,map:textt ,transparent: true} );
|
||||||
|
let textplane = new THREE.Mesh( textgeometry, textmaterial );
|
||||||
|
textplane.name = stationdata[i].code;
|
||||||
|
textplane.position.y = 300;
|
||||||
|
textplane.rotation.x = Math.PI/2;
|
||||||
|
//textplane.position.x = -30;
|
||||||
|
scope.textlist.push(textplane);
|
||||||
|
newstationmesh.add(textplane);
|
||||||
|
textgeometry.dispose();
|
||||||
|
textmaterial.dispose();
|
||||||
|
textt.dispose();
|
||||||
|
// let newtopstation = topstationmesh.clone(true);
|
||||||
|
// newtopstation.position.x = map[k].mesh.position.x;
|
||||||
|
// newtopstation.position.z = map[k].mesh.position.z;
|
||||||
|
// scene.add(newtopstation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// scene.add(scope.textlist);
|
||||||
|
scene.add(scope.group);
|
||||||
|
resolve("loadedstation");
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//canvas文字贴图方法
|
||||||
|
//PS:待提炼 增强功能
|
||||||
|
var stationcanvas = new Image();
|
||||||
|
stationcanvas.src = "../../static/texture/msgt.png";
|
||||||
|
function getTextCanvas(text){
|
||||||
|
let canvas = document.getElementById('canvastexture');
|
||||||
|
|
||||||
|
canvas.width = 256;
|
||||||
|
canvas.height = 512;
|
||||||
|
// canvas.style.width = width;
|
||||||
|
// canvas.style.height = height;
|
||||||
|
|
||||||
|
let ctx = canvas.getContext('2d');
|
||||||
|
//ctx.fillStyle = '#FFFFFF';
|
||||||
|
ctx.fillRect(0, 0,256,512);
|
||||||
|
|
||||||
|
ctx.fillStyle = '#FFFFFF';
|
||||||
|
// ctx.textAlign = 'center';
|
||||||
|
// ctx.textBaseline = 'middle';
|
||||||
|
ctx.clearRect(0,0,256,512);
|
||||||
|
|
||||||
|
ctx.drawImage(stationcanvas,0,0,256,512);
|
||||||
|
|
||||||
|
ctx.font = "20px Verdana";
|
||||||
|
ctx.fillText("车站名称: "+text.name, 20,58);
|
||||||
|
|
||||||
|
ctx.fillText("漫游", 30,100);
|
||||||
|
ctx.fillText("信息", 114,100);
|
||||||
|
ctx.fillText("备忘", 190,100);
|
||||||
|
|
||||||
|
ctx.fillText("车站序号: "+text.name, 10,155);
|
||||||
|
|
||||||
|
ctx.fillText("公里标记:"+text.kmPost,10 ,256*3/4);
|
||||||
|
|
||||||
|
let data = ctx.getImageData(0, 0,256,512);
|
||||||
|
return data;
|
||||||
|
}
|
35
src/jlmap3d/main/newmodel/StationStandModel.js
Normal file
35
src/jlmap3d/main/newmodel/StationStandModel.js
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
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;
|
||||||
|
}
|
58
src/jlmap3d/main/newmodel/SwitchListN.js
Normal file
58
src/jlmap3d/main/newmodel/SwitchListN.js
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
import {SwitchModel} from '@/jlmap3d/main/newmodel/SwitchModel.js';
|
||||||
|
|
||||||
|
export function SwitchListN() {
|
||||||
|
|
||||||
|
let scope = this;
|
||||||
|
this.type = "switchlist";
|
||||||
|
|
||||||
|
this.switchgroup = new THREE.Group();
|
||||||
|
this.switchgroup.name = "switch";
|
||||||
|
|
||||||
|
this.switchs = {
|
||||||
|
datalist:[],
|
||||||
|
modellist:[]
|
||||||
|
};
|
||||||
|
|
||||||
|
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].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
|
||||||
|
};
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// console.log(scope.switchs.modellist);
|
||||||
|
resolve("loadedswitch");
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
22
src/jlmap3d/main/newmodel/SwitchModel.js
Normal file
22
src/jlmap3d/main/newmodel/SwitchModel.js
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
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 +1,8 @@
|
|||||||
export function RealSectionModel(data) {
|
export function TrainModel(opts) {
|
||||||
|
|
||||||
var scope = this;
|
var scope = this;
|
||||||
|
|
||||||
this.mesh = null;
|
this.mesh = null;
|
||||||
this.meshurl = null;
|
this.meshurl = null;
|
||||||
this.picurl = null;
|
this.picurl = null;
|
||||||
|
|
||||||
}
|
}
|
@ -180,6 +180,15 @@ export default {
|
|||||||
trainAtoOff: this.$t('jlmap3d.trainAtoOff'),
|
trainAtoOff: this.$t('jlmap3d.trainAtoOff'),
|
||||||
stopTime: this.$t('jlmap3d.stopTime')
|
stopTime: this.$t('jlmap3d.stopTime')
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let project = this.$route.query.project;
|
||||||
|
console.log(project);
|
||||||
|
if(project){
|
||||||
|
this.jlmap3d = new JLmapDriving(dom, mapdata, skinCode,this.$store,translation,group,project);
|
||||||
|
}else{
|
||||||
|
this.jlmap3d = new JLmapDriving(dom, mapdata, skinCode,this.$store,translation,group,project);
|
||||||
|
}
|
||||||
|
|
||||||
// console.log(translation);
|
// console.log(translation);
|
||||||
this.jlmap3d = new JLmapDriving(dom, mapdata, skinCode,this.$store,translation,group);
|
this.jlmap3d = new JLmapDriving(dom, mapdata, skinCode,this.$store,translation,group);
|
||||||
this.jlmap3d.eventon();
|
this.jlmap3d.eventon();
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
|
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { update3dMapData } from '@/api/jlmap3d/load3ddata'
|
import { update3dMapData } from '@/api/jlmap3d/load3ddata'
|
||||||
import { getmodels } from '@/jlmap3d/edit/connect/getmodels';
|
import { getmodels } from '@/jlmap3d/edit/connect/newgetmodels';
|
||||||
|
|
||||||
//components
|
//components
|
||||||
import EditProperty from '@/views/jlmap3d/edit/component/property';
|
import EditProperty from '@/views/jlmap3d/edit/component/property';
|
||||||
|
@ -133,7 +133,15 @@ export default {
|
|||||||
init: function (skinCode,group) {
|
init: function (skinCode,group) {
|
||||||
const mapdata = this.$store.getters['map/map'];
|
const mapdata = this.$store.getters['map/map'];
|
||||||
const dom = document.getElementById('app');
|
const dom = document.getElementById('app');
|
||||||
this.jlmap3d = new JLmap3d(dom, mapdata, skinCode,this.$store,group);
|
let project = this.$route.query.project;
|
||||||
|
console.log(project);
|
||||||
|
if(project){
|
||||||
|
|
||||||
|
this.jlmap3d = new JLmap3d(dom, mapdata, skinCode,this.$store,group,project);
|
||||||
|
}else{
|
||||||
|
|
||||||
|
this.jlmap3d = new JLmap3d(dom, mapdata, skinCode,this.$store,group,"");
|
||||||
|
}
|
||||||
this.jlmap3d.eventon();
|
this.jlmap3d.eventon();
|
||||||
},
|
},
|
||||||
raystand() {
|
raystand() {
|
||||||
@ -161,17 +169,17 @@ export default {
|
|||||||
this.jlmap3d.showtrainmsg(showtype);
|
this.jlmap3d.showtrainmsg(showtype);
|
||||||
},
|
},
|
||||||
updatemenulist(stationlist, trainlist) {
|
updatemenulist(stationlist, trainlist) {
|
||||||
const stations = [];
|
let stations = [];
|
||||||
for (const k in stationlist) {
|
for (let k in stationlist) {
|
||||||
stations.push(stationlist[k]);
|
stations.push(stationlist[k]);
|
||||||
}
|
}
|
||||||
const trains = [];
|
let trains = [];
|
||||||
for (const k in trainlist) {
|
for (let k in trainlist) {
|
||||||
trains.push(trainlist[k]);
|
trains.push(trainlist[k]);
|
||||||
}
|
}
|
||||||
this.stationlist = stations;
|
this.stationlist = stations;
|
||||||
this.trainlist = trains;
|
this.trainlist = trains;
|
||||||
|
// console.log(this.stationlist);
|
||||||
},
|
},
|
||||||
|
|
||||||
sstation(changedata) {
|
sstation(changedata) {
|
||||||
|
BIN
static/background/other.jpg
Normal file
BIN
static/background/other.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 208 KiB |
Loading…
Reference in New Issue
Block a user