修改link为主轨迹运行

This commit is contained in:
sunzhenyu 2019-10-12 16:36:51 +08:00
parent 0e251fc8cb
commit b32b03bc81
26 changed files with 793 additions and 851 deletions

View File

@ -6,11 +6,11 @@ export function SectionList() {
this.type = "sectionlist";
let sectiongroup = new THREE.Group();
sectiongroup.name = "section";
this.sectiongroup = new THREE.Group();
this.sectiongroup.name = "section";
let switchgroup = new THREE.Group();
switchgroup.name = "switch";
this.switchgroup = new THREE.Group();
this.switchgroup.name = "switch";
this.sections = {
datalist:[],
@ -24,8 +24,8 @@ export function SectionList() {
this.initpromise = function(jlmap3ddata,assetloader,sectiondata,switchdata,scene){
return new Promise(function(resolve, reject){
scene.add(sectiongroup);
scene.add(switchgroup);
scene.add(scope.sectiongroup);
scene.add(scope.switchgroup);
let linkdata = jlmap3ddata.linklist;
//遍历区段
for(let i=0;i<sectiondata.length;i++){
@ -187,7 +187,7 @@ export function SectionList() {
testswitch.position.z = switchposz;
scope.switchs.modellist.push(testswitch);
switchgroup.add(testswitch);
scope.switchgroup.add(testswitch);
}
resolve("loadersection");
@ -272,7 +272,7 @@ export function SectionList() {
return new Promise(function(resolve, reject){
console.log(sectiondata);
// scene.add(sectiongroup);
scene.add(switchgroup);
scene.add(scope.switchgroup);
let linkdata = jlmap3ddata.linklist;
for(let i=0;i<sectiondata.length;i++){
@ -347,12 +347,12 @@ export function SectionList() {
if(testmesh1.isStandTrack == false){
sectiongroup.add(testmesh1);
scope.sectiongroup.add(testmesh1);
}else{
scope.standtrack.push(testmesh1);
var box = new THREE.BoxHelper( testmesh1, 0xff0000 );
sectiongroup.add( box );
scope.sectiongroup.add( box );
}
scope.sections.modellist.push(testmesh1);
}
@ -435,7 +435,7 @@ export function SectionList() {
scope.switchs.datalist.push(newswitch);
scope.switchs.modellist.push(testswitch);
switchgroup.add(testswitch);
scope.switchgroup.add(testswitch);
}
resolve("loadersection");
@ -541,19 +541,19 @@ export function SectionList() {
testmesh1.lengthfact = len;
testmesh1.linkCode = suidao.linkCode;
if(suidaodata.datalist[i].isStandTrack == false){
sectiongroup.add(testmesh1);
scope.sectiongroup.add(testmesh1);
}else{
scope.standtrack.push(testmesh1);
var box = new THREE.BoxHelper( testmesh1, 0xff0000 );
sectiongroup.add( box );
scope.sectiongroup.add( box );
}
scope.sections.modellist.push(testmesh1);
}
}
this.resetsection = function(scene){
scene.remove(sectiongroup);
scene.remove(scope.sectiongroup);
};
this.reposition = function(){

View File

@ -160,7 +160,8 @@ export function JLmap3dEdit(dom, data, mapid) {
this.export = function(){
let exporter = new THREE.OBJExporter();
console.log(scope.mapdata);
let exportmodels = scope.mapdata.linklist.linksgroup;
// let exportmodels = scope.mapdata.linklist.linksgroup;
let exportmodels = scope.mapdata.sectionlist.switchgroup;
let result = exporter.parse( exportmodels );
console.log(result);

View File

@ -38,7 +38,7 @@ import {MouseControls} from '@/jlmap3d/main/control/FirstControls';
var clock = new THREE.Clock();
export function JLmapDriving(dom, data, skinCode) {
export function JLmapDriving(dom, data, skinCode,storemod) {
const scope = this;
@ -102,7 +102,7 @@ export function JLmapDriving(dom, data, skinCode) {
camera.position.set( 0, 0, 0 );
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
camera.rotation.x = 0;
let listener = new THREE.AudioListener();
listener.position.y = -2;
camera.add( listener );
@ -133,18 +133,20 @@ export function JLmapDriving(dom, data, skinCode) {
this.Subscribe.socketon(scope.Subscribe.topic);
var timer = setInterval(function() {
if(mapdata.trainlisttest.group){
if(mapdata.trainlisttest.group.children[0]){
updatemmi.updatedrivingcode(mapdata.trainlisttest.group.children[0].name);
scope.Subscribe.initdrivercode(mapdata.trainlisttest.group.children[0].name);
clearInterval(timer);
if(mapdata.trainlisttest){
if(mapdata.trainlisttest.group){
if(mapdata.trainlisttest.group.children[0]){
updatemmi.updatedrivingcode(mapdata.trainlisttest.group.children[0].name);
scope.Subscribe.initdrivercode(mapdata.trainlisttest.group.children[0].name);
clearInterval(timer);
}
}
}
}, 1000);
}, 2000);
// 初始化加载数据和模型
getPublish3dMapDetail(skinCode).then(netdata => {
ModelLoad(data, scope, netdata.data, mapdata, camera, controls3, scene,mixers);
ModelLoad(data, scope, netdata.data, mapdata, camera, controls3, scene,mixers,storemod);
});
// let stats = new Stats();
// dom.appendChild( stats.dom );
@ -170,7 +172,7 @@ export function JLmapDriving(dom, data, skinCode) {
renderercctv.render(scene,cameracctv);
}
//相机按键位移
//controls3.update();
controls3.update();
delta = clock.getDelta();
for (let i=mixers.length-1; i>=0; i--) {
mixers[i].update( delta );
@ -185,6 +187,8 @@ export function JLmapDriving(dom, data, skinCode) {
controls3.getObject().position.x = mapdata.trainlisttest.list[drivingcode].matrixWorld.elements[12]-27;
controls3.getObject().position.y=10;
controls3.getObject().position.z = mapdata.trainlisttest.list[drivingcode].children[0].matrixWorld.elements[14];
controls3.getObject().rotation.x = Math.PI/2;
console.log(controls3);
}
}
@ -228,8 +232,10 @@ export function JLmapDriving(dom, data, skinCode) {
drivingcode = code;
mapdata.trainlisttest.list[drivingcode].children[0].add(controls3.getObject());
mapdata.trainlisttest.list[drivingcode].children[0].add(scope.assetloader.modellist[4].mesh);
controls3.getObject().position.x = 40;
controls3.getObject().position.y= 12.5;
controls3.getObject().position.x = 20;
controls3.getObject().position.y = 0;
controls3.getObject().position.z = 5;
controls3.getObject().rotation.x = Math.PI/2;
controls3.getObject().rotation.y = -Math.PI/2;
scope.assetloader.modellist[4].mesh.position.x = 34;
scope.assetloader.modellist[4].mesh.position.y = 0;

View File

@ -19,6 +19,9 @@ export function Jl3dDriving(updatemmi,sound) {
var sectionlist = null;
var materials = null;
var actions = null;
var rails = null;
var links = null;
var scenes = null;
var code = null;
@ -52,7 +55,8 @@ export function Jl3dDriving(updatemmi,sound) {
materials = materiallist;
scenes = scene;
actions = nowaction;
links = this.map.linklist;
rails = this.map.rails;
};
this.initdrivercode = function(code) {
@ -208,28 +212,21 @@ export function Jl3dDriving(updatemmi,sound) {
//更新车组号
updatemmi.updatetrainnum(data.body[i].groupNumber);
//更新列车
console.log(data.body[i]);
let syncdata = {
type: 'Train',
code: code,
sectionCode: data.body[i].sectionCode,
linkCode: data.body[i].linkCode,
percent: 0
};
if (trainlisttest.list[code].isStandTrack == true && trainlisttest.list[code].progress>0.95 && trainlisttest.list[code].speed<=0) {
if (data.body[i].directionType == '02') {
syncdata.percent = 1-(sectionlist.sections.datalist[data.body[i].sectionCode].rstop/trainlisttest.list[code].len);
} else {
syncdata.percent = sectionlist.sections.datalist[data.body[i].sectionCode].lstop/trainlisttest.list[code].len;
}
//scope.teststomp.send('/app/topic/simulation/client/drive', syncdata);
} else {
if (data.body[i].directionType == '02') {
syncdata.percent = trainlisttest.list[code].progress;
} else {
syncdata.percent = 1 - trainlisttest.list[code].progress;
}
//scope.teststomp.send('/app/topic/simulation/client/drive', syncdata);
}
console.log(syncdata);
scope.teststomp.send('/app/topic/simulation/client/drive', syncdata);
if (data.body[i].parkRemainTime>0) {
updatemmi.updatestoptime('停站时间:'+parseInt(data.body[i].parkRemainTime));
@ -304,91 +301,50 @@ export function Jl3dDriving(updatemmi,sound) {
if (trainlisttest.list[code].dispose != data.body[i].dispose && data.body[i].dispose == false) {
if (sectionlist.sections.datalist[data.body[i].sectionCode].code) {
if (rails.linkrail[data.body[i].linkCode]) {
trainlisttest.group.add(trainlisttest.list[code]);
trainlisttest.list[code].position.y = 0;
trainlisttest.list[code].progress = 0;
trainlisttest.list[code].oldoffset = data.body[i].sectionOffsetPercent;
trainlisttest.list[code].dispose = false;
trainlisttest.list[code].nowcode = data.body[i].sectionCode;
trainlisttest.list[code].nextcode = data.body[i].nextSectionCode;
trainlisttest.list[code].nowcode = data.body[i].linkCode;
trainlisttest.list[code].nextcode = rails.linkrail[data.body[i].linkCode].next;
let vexlist = [];
let endrotation = null;
if (data.body[i].directionType == '02') { // 向右
let offset = null;
let rotaposx = null;
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x>sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) {
offset = sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x-sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x;
rotaposx = sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x+offset*data.body[i].sectionOffsetPercent;
} else {
offset = sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x-sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x;
rotaposx = sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x+offset*data.body[i].sectionOffsetPercent;
}
let rotaposz = sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].z;
let point = rails.linkrail[data.body[i].linkCode].lineleft.getPointAt(data.body[i].linkOffsetPercent);
trainlisttest.list[code].rotation.y = 0;
trainlisttest.list[code].position.x = rotaposx;
trainlisttest.list[code].position.x = point.x;
trainlisttest.list[code].position.y = 0;
for (let tl=0; tl<6; tl++) {
trainlisttest.list[code].children[tl].position.z = rotaposz;
trainlisttest.list[code].children[tl].position.z = point.z;
}
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x>sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) {
for (let m=sectionlist.sections.datalist[data.body[i].sectionCode].rail.length-1; m>=0; m--) {
vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
}
} else {
for (let m=0; m<sectionlist.sections.datalist[data.body[i].sectionCode].rail.length; m++) {
vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
}
}
trainlisttest.list[code].status = '02';
trainlisttest.list[code].progress = data.body[i].sectionOffsetPercent;
trainlisttest.list[code].progress = data.body[i].linkOffsetPercent;
trainlisttest.list[code].curve = rails.linkrail[data.body[i].linkCode].lineleft;
} else if (data.body[i].directionType == '03') { // 向左
trainlisttest.list[code].dispose = false;
trainlisttest.group.add(trainlisttest.list[code]);
let offset = null;
let rotaposx = null;
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x>sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) {
offset = sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x-sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x;
rotaposx = sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x+offset*data.body[i].sectionOffsetPercent;
} else {
offset = sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x-sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x;
rotaposx = sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x+offset*data.body[i].sectionOffsetPercent;
}
let rotaposz = sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].z;
let point = rails.linkrail[data.body[i].linkCode].lineright.getPointAt((1-data.body[i].linkOffsetPercent));
trainlisttest.list[code].rotation.y = Math.PI;
trainlisttest.list[code].position.x = rotaposx;
trainlisttest.list[code].position.x = point.x;
trainlisttest.list[code].position.y = 0;
for (let tl=0; tl<6; tl++) {
trainlisttest.list[code].children[tl].position.z = -rotaposz;
}
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x<sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) {
for (let m=sectionlist.sections.datalist[data.body[i].sectionCode].rail.length-1; m>=0; m--) {
vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
}
} else {
for (let m=0; m<sectionlist.sections.datalist[data.body[i].sectionCode].rail.length; m++) {
vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
}
trainlisttest.list[code].children[tl].position.z = -point.z;
}
// if(trainlisttest.list[code].rname == "006"){
// console.log("0000000000000000");
// console.log(data.body[i].linkOffsetPercent);
// }
trainlisttest.list[code].status = '03';
trainlisttest.list[code].progress = 1-data.body[i].sectionOffsetPercent;
trainlisttest.list[code].progress = 1-data.body[i].linkOffsetPercent;
trainlisttest.list[code].curve = rails.linkrail[data.body[i].linkCode].lineright;
}
trainlisttest.list[code].len = rails.linkrail[data.body[i].linkCode].lengthfact;
// trainlisttest.list[code].isStandTrack = sectionlist.sections.datalist[data.body[i].sectionCode].isStandTrack;
trainlisttest.list[code].curve = new THREE.CatmullRomCurve3(vexlist);
trainlisttest.list[code].isStandTrack = sectionlist.sections.datalist[data.body[i].sectionCode].isStandTrack;
trainlisttest.list[code].len = sectionlist.sections.datalist[data.body[i].sectionCode].distance;
// trainlisttest.list[code].len = sectionlist.sections.datalist[data.body[i].sectionCode].distance;
if(data.body[i].speed == 0){
@ -397,9 +353,10 @@ export function Jl3dDriving(updatemmi,sound) {
// trainlisttest.list[code].startmark = 1;
}else{
trainlisttest.list[code].speeds = data.body[i].speed;
trainlisttest.list[code].speeds = parseFloat(data.body[i].speed*10/36/20/trainlisttest.list[code].len);
trainlisttest.list[code].speeds = parseFloat(data.body[i].speed*10/36/21/trainlisttest.list[code].len);
}
}
} else if (trainlisttest.list[code].dispose != data.body[i].dispose && data.body[i].dispose == true) {
@ -415,7 +372,7 @@ export function Jl3dDriving(updatemmi,sound) {
} else if (trainlisttest.list[code].dispose == data.body[i].dispose && data.body[i].dispose == false) {
if (sectionlist.sections.datalist[data.body[i].sectionCode].code) {
if (rails.linkrail[data.body[i].linkCode]) {
if (driverswitch == '02' && code == drivingcode) {
updatemmi.updatenowspeed(data.body[i].speed);
if (data.body[i].atpSpeed) {
@ -433,8 +390,19 @@ export function Jl3dDriving(updatemmi,sound) {
} else {
updatemmi.updatenowlen(0);
}
// if(trainlisttest.list[code].isStandTrack == true){
// pointstand = null;
// if(data.body[i].directionType == "02"){
// pointstand = trainlisttest.list[code].curve.getPointAt(data.body[i].sectionOffsetPercent);
// }else{
// pointstand = trainlisttest.list[code].curve.getPointAt(1-data.body[i].sectionOffsetPercent);
// }
// console.log(data.body[i].sectionOffsetPercent)
// console.log(pointstand.x);
//
// trainlisttest.list[code].position.x = pointstand.x;
// }
}
if (driverswitch == '05' && code == drivingcode) {
if (data.body[i].maLen) {
updatemmi.updatenowlen(data.body[i].maLen);
@ -442,14 +410,11 @@ export function Jl3dDriving(updatemmi,sound) {
updatemmi.updatenowlen(0);
}
}
if (trainlisttest.list[code].nowcode != data.body[i].sectionCode) {
trainlisttest.list[code].nowcode = data.body[i].sectionCode;
trainlisttest.list[code].nextcode = data.body[i].nextSectionCode;
const vexlist = [];
const endrotation = null;
if(trainlisttest.list[code].nowcode != data.body[i].linkCode){
trainlisttest.list[code].nowcode = data.body[i].linkCode;
trainlisttest.list[code].nextcode = rails.linkrail[data.body[i].linkCode].next;
if (data.body[i].directionType == '02') { // 向右
trainlisttest.list[code].progress = 0;
if (trainlisttest.list[code].status != data.body[i].directionType) {
const rotaposx = trainlisttest.list[code].children[5].matrixWorld.elements[12];
const rotaposz = trainlisttest.list[code].children[0].matrixWorld.elements[14];
@ -458,124 +423,50 @@ export function Jl3dDriving(updatemmi,sound) {
for (let tl=0; tl<6; tl++) {
trainlisttest.list[code].children[tl].position.z = rotaposz;
}
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x>sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) {
vexlist.push(new THREE.Vector3(trainlisttest.list[code].position.x, 0, trainlisttest.list[code].children[0].matrixWorld.elements[14]));
for (let m=sectionlist.sections.datalist[data.body[i].sectionCode].rail.length-1; m>=0; m--) {
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[m].x>trainlisttest.list[code].position.x) {
vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
}
}
} else {
vexlist.push(new THREE.Vector3(trainlisttest.list[code].position.x, 0, trainlisttest.list[code].children[0].matrixWorld.elements[14]));
for (let m=0; m<sectionlist.sections.datalist[data.body[i].sectionCode].rail.length; m++) {
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[m].x>trainlisttest.list[code].position.x) {
vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
}
}
}
} else {
if(data.body[i].speed > 0){
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x>sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) {
for (let m=sectionlist.sections.datalist[data.body[i].sectionCode].rail.length-1; m>=0; m--) {
vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
}
} else {
for (let m=0; m<sectionlist.sections.datalist[data.body[i].sectionCode].rail.length; m++) {
vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
}
}
}else if(data.body[i].speed < 0){
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x<sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) {
for (let m=0; m<sectionlist.sections.datalist[data.body[i].sectionCode].rail.length; m++) {
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[m].x<trainlisttest.list[code].position.x) {
vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
}
}
vexlist.push(new THREE.Vector3(trainlisttest.list[code].position.x, 0, trainlisttest.list[code].children[0].matrixWorld.elements[14]));
} else {
for (let m=sectionlist.sections.datalist[data.body[i].sectionCode].rail.length-1; m>=0; m--) {
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[m].x<trainlisttest.list[code].position.x) {
vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
}
}
vexlist.push(new THREE.Vector3(trainlisttest.list[code].position.x, 0, trainlisttest.list[code].children[0].matrixWorld.elements[14]));
}
}
trainlisttest.list[code].rotation.y = 0;
trainlisttest.list[code].progress = (rotaposx-rails.linkrail[data.body[i].linkCode].lp.x)/rails.linkrail[data.body[i].linkCode].lengthfact;
}
trainlisttest.list[code].status = '02';
trainlisttest.list[code].curve = rails.linkrail[data.body[i].linkCode].lineleft;
} else if (data.body[i].directionType == '03') { // 向左
trainlisttest.list[code].progress = 1;
if (trainlisttest.list[code].status != data.body[i].directionType) {
const rotaposx = trainlisttest.list[code].children[5].matrixWorld.elements[12];
const rotaposz = Math.abs(trainlisttest.list[code].children[0].matrixWorld.elements[14]);
trainlisttest.list[code].rotation.y = Math.PI;
trainlisttest.list[code].position.x = rotaposx;
for (let tl=0; tl<6; tl++) {
trainlisttest.list[code].children[tl].position.z = rotaposz;
trainlisttest.list[code].children[tl].position.z = -rotaposz;
}
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x<sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) {
vexlist.push(new THREE.Vector3(trainlisttest.list[code].position.x, 0, trainlisttest.list[code].children[0].matrixWorld.elements[14]));
for (let m=sectionlist.sections.datalist[data.body[i].sectionCode].rail.length-1; m>=0; m--) {
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[m].x<trainlisttest.list[code].position.x) {
vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
}
}
} else {
vexlist.push(new THREE.Vector3(trainlisttest.list[code].position.x, 0, trainlisttest.list[code].children[0].matrixWorld.elements[14]));
for (let m=0; m<sectionlist.sections.datalist[data.body[i].sectionCode].rail.length; m++) {
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[m].x<trainlisttest.list[code].position.x) {
vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
}
}
}
} else {
if(data.body[i].speed > 0){
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x<sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) {
for (let m=sectionlist.sections.datalist[data.body[i].sectionCode].rail.length-1; m>=0; m--) {
vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
}
} else {
for (let m=0; m<sectionlist.sections.datalist[data.body[i].sectionCode].rail.length; m++) {
vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
}
}
}else if(data.body[i].speed < 0){
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x<sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) {
for (let m=sectionlist.sections.datalist[data.body[i].sectionCode].rail.length-1; m>=0; m--) {
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[m].x>trainlisttest.list[code].position.x) {
vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
}
}
vexlist.push(new THREE.Vector3(trainlisttest.list[code].position.x, 0, trainlisttest.list[code].children[0].matrixWorld.elements[14]));
} else {
for (let m=0; m<sectionlist.sections.datalist[data.body[i].sectionCode].rail.length; m++) {
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[m].x>trainlisttest.list[code].position.x) {
vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
}
}
vexlist.push(new THREE.Vector3(trainlisttest.list[code].position.x, 0, trainlisttest.list[code].children[0].matrixWorld.elements[14]));
}
}
trainlisttest.list[code].rotation.y = Math.PI;
trainlisttest.list[code].progress = 1-(rotaposx-rails.linkrail[data.body[i].linkCode].lp.x)/rails.linkrail[data.body[i].linkCode].lengthfact;
}
trainlisttest.list[code].status = '03';
}
trainlisttest.list[code].curve = new THREE.CatmullRomCurve3(vexlist);
trainlisttest.list[code].isStandTrack = sectionlist.sections.datalist[data.body[i].sectionCode].isStandTrack;
trainlisttest.list[code].len = sectionlist.sections.datalist[data.body[i].sectionCode].distance;
trainlisttest.list[code].speed = data.body[i].speed;
if(data.body[i].speed>0){
trainlisttest.list[code].progress = 0;
}else if(data.body[i].speed<0){
trainlisttest.list[code].progress = 0.999;
trainlisttest.list[code].status = '03';
trainlisttest.list[code].curve = rails.linkrail[data.body[i].linkCode].lineright;
}
// console.log(rails.linkrail[data.body[i].linkCode]);
// console.log(data.body[i].linkCode)
// console.log(nextcode);
trainlisttest.list[code].len = rails.linkrail[data.body[i].linkCode].lengthfact;
}
if(data.body[i].directionType == '02'){
let nextcode = rails.linkrail[data.body[i].linkCode].rconnect;
if(nextcode){
trainlisttest.list[code].nextcurve = rails.linkrail[nextcode].lineleft;
}
}else if(data.body[i].directionType == '03'){
let nextcode = rails.linkrail[data.body[i].linkCode].lconnect;
if(nextcode){
trainlisttest.list[code].nextcurve = rails.linkrail[nextcode].lineright;
}
trainlisttest.list[code].speeds = parseFloat(data.body[i].speed*10/36/20/trainlisttest.list[code].len);
}
}
@ -734,8 +625,8 @@ export function Jl3dDriving(updatemmi,sound) {
function switchupdate(data) {
code = data.code;
for (let j=sectionlist.switchs.modellist.length-1; j>=0; j--) {
if (sectionlist.switchs.modellist[j].code == code) {
if (sectionlist.switchs.modellist[j].locateType != data.locateType) {
if (rails.switchrail[code]) {
if (rails.switchrail[code].locateType != data.locateType) {
if (data.locateType == '02') {
if (actions[sectionlist.switchs.modellist[j].code]) {
sectionlist.switchs.modellist[j].locateType = data.locateType;
@ -744,6 +635,18 @@ export function Jl3dDriving(updatemmi,sound) {
actions[sectionlist.switchs.modellist[j].code].timeScale = 1;
actions[sectionlist.switchs.modellist[j].code].play();
}
rails.switchrail[code].locateType = "02";
let testswitch = rails.switchrail[code];
if(rails.switchrail[code].directtype == "1"){
rails.linkrail[testswitch.alink].lconnect = testswitch.clink;
rails.linkrail[testswitch.clink].rconnect = testswitch.alink;
}else if(rails.switchrail[code].directtype == "2"){
rails.linkrail[testswitch.alink].rconnect = testswitch.clink;
rails.linkrail[testswitch.clink].lconnect = testswitch.alink;
}
} else if (data.locateType == '01') {
if (actions[sectionlist.switchs.modellist[j].code]) {
sectionlist.switchs.modellist[j].locateType = data.locateType;
@ -752,6 +655,17 @@ export function Jl3dDriving(updatemmi,sound) {
actions[sectionlist.switchs.modellist[j].code].timeScale = -1;
actions[sectionlist.switchs.modellist[j].code].play();
}
rails.switchrail[code].locateType = "01";
let testswitch = rails.switchrail[code];
if(rails.switchrail[code].directtype == "1"){
rails.linkrail[testswitch.alink].lconnect = testswitch.blink;
rails.linkrail[testswitch.blink].rconnect = testswitch.alink;
}else if(rails.switchrail[code].directtype == "2"){
rails.linkrail[testswitch.alink].rconnect = testswitch.blink;
rails.linkrail[testswitch.blink].lconnect = testswitch.alink;
}
}
}
j = 0;

View File

@ -12,22 +12,25 @@ export function UpdateTrain(camera,traindata,control){
if(trainmodel.speeds > 0 && trainmodel.speeds){
let speed = null;
if(traindata.group.children[j].progress<1){
if(traindata.group.children[j].progress >=0&&traindata.group.children[j].progress<=1){
let movecurve = trainmodel.curve;
if(trainmodel.status == "03"){
if(movecurve.points.length>1){
let point = movecurve.getPointAt(traindata.group.children[j].progress);
if(Math.abs( point.z -trainmodel.children[0].matrixWorld.elements[14]) >0.1){
if(Math.abs( point.z -trainmodel.children[0].matrixWorld.elements[14]) >0.01){
trainmodel.children[0].up = new THREE.Vector3(-1,0,0);
let tangent = movecurve.getTangentAt(traindata.group.children[j].progress).normalize();
trainmodel.children[0].axis.crossVectors(trainmodel.children[0].up, tangent).normalize();
let radians = Math.acos(trainmodel.children[0].up.dot(tangent));
trainmodel.children[0].quaternion.setFromAxisAngle(trainmodel.children[0].axis, radians);
trainmodel.children[0].rotation.x = -Math.PI/2;
trainmodel.children[0].rotation.z = trainmodel.children[0].rotation.y;
trainmodel.children[0].rotation.y = 0;
let rotas = {
posr:point,
rota:trainmodel.children[0].rotation.y
rota:trainmodel.children[0].rotation.z
}
trainmodel.children[1].rotalist.push(rotas);
@ -48,7 +51,7 @@ export function UpdateTrain(camera,traindata,control){
trainmodel.children[rs].position.z += offsetz;
for(let xh=0;xh<trainmodel.children[rs].rotalist.length;xh++){
if((trainmodel.children[rs].matrixWorld.elements[12]-38)<=trainmodel.children[rs].rotalist[0].posr.x){
if((trainmodel.children[rs].matrixWorld.elements[12]-8)<=trainmodel.children[rs].rotalist[0].posr.x){
if(rs != 5){
let asd = trainmodel.children[rs].rotalist[0];
@ -56,7 +59,7 @@ export function UpdateTrain(camera,traindata,control){
}
trainmodel.children[rs].rotation.y = trainmodel.children[rs].rotalist[0].rota;
trainmodel.children[rs].rotation.z = trainmodel.children[rs].rotalist[0].rota;
trainmodel.children[rs].rotalist.splice(0,1)
xh--;
}else{
@ -74,16 +77,18 @@ export function UpdateTrain(camera,traindata,control){
if(trainmodel.status == "02"){
if(movecurve.points.length>1){
let point = movecurve.getPointAt(trainmodel.progress);
if(Math.abs( point.z -trainmodel.children[0].matrixWorld.elements[14]) >0.1){
if(Math.abs( point.z -trainmodel.children[0].matrixWorld.elements[14]) >0.01){
trainmodel.children[0].up = new THREE.Vector3(1,0,0);
let tangent = movecurve.getTangentAt(traindata.group.children[j].progress).normalize();
trainmodel.children[0].axis.crossVectors(trainmodel.children[0].up, tangent).normalize();
let radians = Math.acos(trainmodel.children[0].up.dot(tangent));
trainmodel.children[0].quaternion.setFromAxisAngle(trainmodel.children[0].axis, radians);
trainmodel.children[0].rotation.x = -Math.PI/2;
trainmodel.children[0].rotation.z = trainmodel.children[0].rotation.y;
trainmodel.children[0].rotation.y = 0;
let rotas = {
posr:point,
rota:trainmodel.children[0].rotation.y
rota:trainmodel.children[0].rotation.z
}
trainmodel.children[1].rotalist.push(rotas);
let offsetz = parseFloat(point.z) - parseFloat(trainmodel.children[0].matrixWorld.elements[14]);
@ -103,7 +108,7 @@ export function UpdateTrain(camera,traindata,control){
trainmodel.children[rs].position.z += offsetz;
for(let xh=0;xh<trainmodel.children[rs].rotalist.length;xh++){
if((trainmodel.children[rs].matrixWorld.elements[12]+38)>=trainmodel.children[rs].rotalist[0].posr.x){
if((trainmodel.children[rs].matrixWorld.elements[12]+8)>=trainmodel.children[rs].rotalist[0].posr.x){
if(rs != 5){
let asd = trainmodel.children[rs].rotalist[0];
@ -112,7 +117,7 @@ export function UpdateTrain(camera,traindata,control){
}
//let offsetx = trainmodel.children[1].matrixWorld.elements[12]-trainmodel.children[0].children[3].matrixWorld.elements[12];
trainmodel.children[rs].rotation.y = trainmodel.children[rs].rotalist[0].rota;
trainmodel.children[rs].rotation.z = trainmodel.children[rs].rotalist[0].rota;
trainmodel.children[rs].rotalist.splice(0,1)
xh--;
}else{
@ -133,26 +138,45 @@ export function UpdateTrain(camera,traindata,control){
}
}
}else{
if(trainmodel.status == '02'){
trainmodel.curve = trainmodel.nextcurve;
}else if(trainmodel.status == '03'){
trainmodel.curve = trainmodel.nextcurve;
}
// console.log(trainmodel.name);
// console.log(trainmodel.progress);
// console.log(trainmodel.nextcurve);
// if(trainmodel.status == "02"){
// trainmodel.progress = 0;
// }else if(trainmodel.status == "03"){
// trainmodel.progress = 1;
// }
// trainmodel.curve = trainmodel.nextcurve;
}
}else if(trainmodel.speeds < 0 && trainmodel.speeds){
let speed = null;
if(traindata.group.children[j].progress<1){
if(traindata.group.children[j].progress >=0&&traindata.group.children[j].progress<=1){
let movecurve = trainmodel.curve;
if(trainmodel.status == "03" && trainmodel.progress>0){
if(movecurve.points.length>1){
let point = movecurve.getPointAt(traindata.group.children[j].progress);
if(Math.abs( point.z -trainmodel.children[0].matrixWorld.elements[14]) >0.1){
if(Math.abs( point.z -trainmodel.children[0].matrixWorld.elements[14]) >0.01){
trainmodel.children[0].up = new THREE.Vector3(-1,0,0);
let tangent = movecurve.getTangentAt(traindata.group.children[j].progress).normalize();
trainmodel.children[0].axis.crossVectors(trainmodel.children[0].up, tangent).normalize();
let radians = Math.acos(trainmodel.children[0].up.dot(tangent));
trainmodel.children[0].quaternion.setFromAxisAngle(trainmodel.children[0].axis, radians);
trainmodel.children[0].rotation.x = -Math.PI/2;
trainmodel.children[0].rotation.z = trainmodel.children[0].rotation.y;
trainmodel.children[0].rotation.y = 0;
let rotas = {
posr:point,
rota:trainmodel.children[0].rotation.y
rota:trainmodel.children[0].rotation.z
}
trainmodel.children[1].rotalist.push(rotas);
@ -173,7 +197,7 @@ export function UpdateTrain(camera,traindata,control){
trainmodel.children[rs].position.z += offsetz;
for(let xh=0;xh<trainmodel.children[rs].rotalist.length;xh++){
if((trainmodel.children[rs].matrixWorld.elements[12]-38)<=trainmodel.children[rs].rotalist[0].posr.x){
if((trainmodel.children[rs].matrixWorld.elements[12]-8)<=trainmodel.children[rs].rotalist[0].posr.x){
if(rs != 5){
let asd = trainmodel.children[rs].rotalist[0];
@ -181,7 +205,7 @@ export function UpdateTrain(camera,traindata,control){
}
trainmodel.children[rs].rotation.y = trainmodel.children[rs].rotalist[0].rota;
trainmodel.children[rs].rotation.z = trainmodel.children[rs].rotalist[0].rota;
trainmodel.children[rs].rotalist.splice(0,1)
xh--;
}else{
@ -203,16 +227,18 @@ export function UpdateTrain(camera,traindata,control){
if(movecurve.points.length>1 && trainmodel.progress>0){
let point = movecurve.getPointAt(trainmodel.progress);
if(Math.abs( point.z -trainmodel.children[0].matrixWorld.elements[14]) >0.1){
if(Math.abs( point.z -trainmodel.children[0].matrixWorld.elements[14]) >0.01){
trainmodel.children[0].up = new THREE.Vector3(1,0,0);
let tangent = movecurve.getTangentAt(traindata.group.children[j].progress).normalize();
trainmodel.children[0].axis.crossVectors(trainmodel.children[0].up, tangent).normalize();
let radians = Math.acos(trainmodel.children[0].up.dot(tangent));
trainmodel.children[0].quaternion.setFromAxisAngle(trainmodel.children[0].axis, radians);
trainmodel.children[0].rotation.x = -Math.PI/2;
trainmodel.children[0].rotation.z = trainmodel.children[0].rotation.y;
trainmodel.children[0].rotation.y = 0;
let rotas = {
posr:point,
rota:trainmodel.children[0].rotation.y
rota:trainmodel.children[0].rotation.z
}
trainmodel.children[1].rotalist.push(rotas);
let offsetz = parseFloat(point.z) - parseFloat(trainmodel.children[0].matrixWorld.elements[14]);
@ -232,7 +258,7 @@ export function UpdateTrain(camera,traindata,control){
trainmodel.children[rs].position.z += offsetz;
for(let xh=0;xh<trainmodel.children[rs].rotalist.length;xh++){
if((trainmodel.children[rs].matrixWorld.elements[12]+38)>=trainmodel.children[rs].rotalist[0].posr.x){
if((trainmodel.children[rs].matrixWorld.elements[12]+8)>=trainmodel.children[rs].rotalist[0].posr.x){
if(rs != 5){
let asd = trainmodel.children[rs].rotalist[0];
@ -241,7 +267,7 @@ export function UpdateTrain(camera,traindata,control){
}
//let offsetx = trainmodel.children[1].matrixWorld.elements[12]-trainmodel.children[0].children[3].matrixWorld.elements[12];
trainmodel.children[rs].rotation.y = trainmodel.children[rs].rotalist[0].rota;
trainmodel.children[rs].rotation.z = trainmodel.children[rs].rotalist[0].rota;
trainmodel.children[rs].rotalist.splice(0,1)
xh--;
}else{

View File

@ -20,6 +20,8 @@ export function Jlmap3dSubscribe(jlmap3d) {
var materials = null;
var actions = null;
var rails = null;
var links = null;
var scenes = null;
var code = null;
@ -42,7 +44,7 @@ export function Jlmap3dSubscribe(jlmap3d) {
const header = {'X-Token': handleToken() };
this.updatamap = function(mapdata, materiallist, nowaction, scene) {
// console.log(mapdata);
console.log(mapdata);
scope.map = mapdata;
trainlisttest = this.map.trainlisttest;
@ -53,6 +55,7 @@ export function Jlmap3dSubscribe(jlmap3d) {
materials = materiallist;
scenes = scene;
actions = nowaction;
links = this.map.linklist;
rails = this.map.rails;
};
@ -113,11 +116,11 @@ export function Jlmap3dSubscribe(jlmap3d) {
if (trainlisttest.list[code].isStandTrack == true) {
trainlisttest.list[code].speeds = parseFloat(data.body[tl].v*10/36/17/trainlisttest.list[code].len);
} else {
trainlisttest.list[code].speeds = parseFloat(data.body[tl].v*10/36/20/trainlisttest.list[code].len);
trainlisttest.list[code].speeds = parseFloat(data.body[tl].v*10/36/21/trainlisttest.list[code].len);
}
} else {
trainlisttest.list[code].speeds = parseFloat(data.body[tl].v*10/36/20/trainlisttest.list[code].len);
trainlisttest.list[code].speeds = parseFloat(data.body[tl].v*10/36/21/trainlisttest.list[code].len);
}
if (code == drivingcode) {
@ -138,382 +141,298 @@ export function Jlmap3dSubscribe(jlmap3d) {
}
}
// if (data.type == 'SJL3D_TrainStatus') {
// for (let i=data.body.length-1; i>=0; i--) {
// if (data.body[i]._type == 'Train') {
//
// // console.log(data.body[i]);
// // 遍历列车对象组
// if (trainlisttest) {
// code = data.body[i].code;
// // 剔除不显示的车
// // 找到对应列车
//
// if ( trainlisttest.list[code]) {
// if (code == drivingcode) {
// driverswitch = data.body[i].runMode;
// jlmap3d.updatetrainnum(data.body[i].groupNumber);
// // console.log(trainlisttest.list[code].progress);
// const syncdata = {
// type: 'Train',
// code: code,
// sectionCode: data.body[i].sectionCode,
// percent: 0
// };
//
// if (trainlisttest.list[code].isStandTrack == true && trainlisttest.list[code].progress>0.95 && trainlisttest.list[code].speed<=0) {
// if (data.body[i].directionType == '02') {
// syncdata.percent = 1-(sectionlist.sections.datalist[data.body[i].sectionCode].rstop/trainlisttest.list[code].len);
// } else {
// syncdata.percent = sectionlist.sections.datalist[data.body[i].sectionCode].lstop/trainlisttest.list[code].len;
// }
// scope.teststomp.send('/app/topic/simulation/client/drive', syncdata);
// } else {
// if (data.body[i].directionType == '02') {
// syncdata.percent = trainlisttest.list[code].progress;
// } else {
// syncdata.percent = 1 - trainlisttest.list[code].progress;
// }
// scope.teststomp.send('/app/topic/simulation/client/drive', syncdata);
// }
//
// if (data.body[i].parkRemainTime>0) {
// jlmap3d.updatestoptime('停站时间:'+parseInt(data.body[i].parkRemainTime));
// } else {
// if (data.body[i].runMode == '02') {
// jlmap3d.updatestoptime('列车自动驾驶中');
// } else {
// if (trainlisttest.list[code].isStandTrack == true && trainlisttest.list[code].progress>0.95 && trainlisttest.list[code].speed<=0) {
// // if(stoptimer){
// //
// // }else{
// // stoptimer = setInterval(function(){
// // if(num >=0){
// // jlmap3d.updatestoptime("停站时间:"+num);
// // num --;
// // }
// // },1000);
// // }
//
// } else {
// jlmap3d.updatestoptime('列车人工驾驶中');
// }
//
// }
// }
// // if(trainlisttest.list[code].speed > 0){
// // if(stoptimer){
// // clearInterval( stoptimer );
// // stoptimer = null;
// // num = 30;
// // }
// // }
//
// }
// trainlisttest.list[code].runMode = data.body[i].runMode;
// // 车门开关验证
// // if(data.body[i].directionType == "02"){
// if (trainlisttest.list[code].doorStatus != data.body[i].doorStatus && data.body[i].doorStatus == '01') {
// // console.log("close");
// trainlisttest.list[code].doorStatus = '01';
// for (let an=actions[code].top.length-1; an>=0; an--) {
// actions[code].top[an].reset();
// actions[code].top[an].time = actions[code].top[an]._clip.duration;
// actions[code].top[an].timeScale = -1;
// actions[code].top[an].play();
// }
// } else if (trainlisttest.list[code].doorStatus != data.body[i].doorStatus && data.body[i].doorStatus == '02') {
// // console.log("open");
// trainlisttest.list[code].doorStatus = '02';
// for (let an=actions[code].top.length-1; an>=0; an--) {
// actions[code].top[an].reset();
// actions[code].top[an].time = 0;
// actions[code].top[an].timeScale = 1;
// actions[code].top[an].play();
// }
// }
// // }else{
// // if(trainlisttest.list[code].doorStatus != data.body[i].doorStatus && data.body[i].doorStatus == "01"){
// // //console.log("close");
// // trainlisttest.list[code].doorStatus = "01";
// // for(let an=actions[code].down.length-1;an>=0;an--){
// // actions[code].down[an].reset();
// // actions[code].down[an].time = actions[code].top[an]._clip.duration;
// // actions[code].down[an].timeScale = -1;
// // actions[code].down[an].play();
// // }
// // }else if(trainlisttest.list[code].doorStatus != data.body[i].doorStatus && data.body[i].doorStatus == "02"){
// // //console.log("open");
// // trainlisttest.list[code].doorStatus = "02";
// // for(let an=actions[code].down.length-1;an>=0;an--){
// // actions[code].down[an].reset();
// // actions[code].down[an].time = 0;
// // actions[code].down[an].timeScale = 1;
// // actions[code].down[an].play();
// // }
// // }
// // }
// // 遍历获取所在轨道
//
// if (trainlisttest.list[code].dispose != data.body[i].dispose && data.body[i].dispose == false) {
//
// if (sectionlist.sections.datalist[data.body[i].sectionCode].code) {
// trainlisttest.group.add(trainlisttest.list[code]);
// trainlisttest.list[code].position.y = 0;
// trainlisttest.list[code].progress = 0;
// trainlisttest.list[code].oldoffset = data.body[i].sectionOffsetPercent;
// trainlisttest.list[code].dispose = false;
// trainlisttest.list[code].nowcode = data.body[i].sectionCode;
// trainlisttest.list[code].nextcode = data.body[i].nextSectionCode;
// let vexlist = [];
// let endrotation = null;
//
// if (data.body[i].directionType == '02') { // 向右
// let offset = null;
// let rotaposx = null;
//
// if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x>sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) {
// offset = sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x-sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x;
// rotaposx = sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x+offset*data.body[i].sectionOffsetPercent;
// } else {
// offset = sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x-sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x;
// rotaposx = sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x+offset*data.body[i].sectionOffsetPercent;
// }
//
// let rotaposz = sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].z;
//
// trainlisttest.list[code].rotation.y = 0;
// trainlisttest.list[code].position.x = rotaposx;
// trainlisttest.list[code].position.y = 0;
// for (let tl=0; tl<6; tl++) {
// trainlisttest.list[code].children[tl].position.z = rotaposz;
// }
//
// if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x>sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) {
// vexlist.push(new THREE.Vector3(rotaposx, 0, rotaposz));
// for (let m=sectionlist.sections.datalist[data.body[i].sectionCode].rail.length-1; m>=0; m--) {
// if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[m].x>rotaposx) {
// vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
// }
//
// }
// } else {
// vexlist.push(new THREE.Vector3(rotaposx, 0, rotaposz));
// for (let m=0; m<sectionlist.sections.datalist[data.body[i].sectionCode].rail.length; m++) {
// if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[m].x>rotaposx) {
// vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
// }
// }
// }
// trainlisttest.list[code].status = '02';
//
// } else if (data.body[i].directionType == '03') { // 向左
//
// trainlisttest.list[code].dispose = false;
// trainlisttest.group.add(trainlisttest.list[code]);
// let offset = null;
// let rotaposx = null;
//
// if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x>sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) {
//
// offset = sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x-sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x;
// rotaposx = sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x+offset*data.body[i].sectionOffsetPercent;
// } else {
//
// offset = sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x-sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x;
// rotaposx = sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x+offset*data.body[i].sectionOffsetPercent;
// }
// let rotaposz = sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].z;
//
// trainlisttest.list[code].rotation.y = Math.PI;
// trainlisttest.list[code].position.x = rotaposx;
// trainlisttest.list[code].position.y = 0;
//
// for (let tl=0; tl<6; tl++) {
// trainlisttest.list[code].children[tl].position.z = -rotaposz;
// }
// if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x<sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) {
// vexlist.push(new THREE.Vector3(rotaposx, 0, rotaposz));
// for (let m=sectionlist.sections.datalist[data.body[i].sectionCode].rail.length-1; m>=0; m--) {
// if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[m].x<rotaposx) {
// vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
// }
// }
// } else {
// vexlist.push(new THREE.Vector3(rotaposx, 0, rotaposz));
// for (let m=0; m<sectionlist.sections.datalist[data.body[i].sectionCode].rail.length; m++) {
// if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[m].x<rotaposx) {
// vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
// }
// }
// }
// trainlisttest.list[code].status = '03';
// }
//
// trainlisttest.list[code].curve = new THREE.CatmullRomCurve3(vexlist);
// trainlisttest.list[code].isStandTrack = sectionlist.sections.datalist[data.body[i].sectionCode].isStandTrack;
// trainlisttest.list[code].progress = 0;
// trainlisttest.list[code].len = sectionlist.sections.datalist[data.body[i].sectionCode].distance;
//
//
// if(data.body[i].speed == 0){
// trainlisttest.list[code].speeds = data.body[i].speed;
// trainlisttest.list[code].speeds = 0;
// // trainlisttest.list[code].startmark = 1;
// }else{
// trainlisttest.list[code].speeds = data.body[i].speed;
// trainlisttest.list[code].speeds = parseFloat(data.body[i].speed*10/36/20/trainlisttest.list[code].len);
// }
//
// }
// } else if (trainlisttest.list[code].dispose != data.body[i].dispose && data.body[i].dispose == true) {
// trainlisttest.group.remove(trainlisttest.list[code]);
// trainlisttest.list[code].progress = null;
// trainlisttest.list[code].dispose = true;
// code = trainlisttest.group.children[i].name;
// trainlisttest.list[code].rotation.y = 0;
// trainlisttest.list[code].doorStatus = '01';
// trainlisttest.list[code].speed = 0;
// trainlisttest.list[code].position.x = -50000;
// trainlisttest.list[code].position.y = -50000;
//
// } else if (trainlisttest.list[code].dispose == data.body[i].dispose && data.body[i].dispose == false) {
//
// if (sectionlist.sections.datalist[data.body[i].sectionCode].code) {
// if (driverswitch == '02' && code == drivingcode) {
// jlmap3d.updatenowspeed(data.body[i].speed);
// if (data.body[i].atpSpeed) {
// jlmap3d.updateatpspeed(data.body[i].atpSpeed);
// } else {
// jlmap3d.updateatpspeed(-1);
// }
// if (data.body[i].targetSpeed) {
// jlmap3d.updateatospeed(data.body[i].targetSpeed);
// } else {
// jlmap3d.updateatospeed(-1);
// }
// if (data.body[i].maLen) {
// jlmap3d.updatenowlen(data.body[i].maLen);
// } else {
// jlmap3d.updatenowlen(0);
// }
// // if(trainlisttest.list[code].isStandTrack == true){
// // pointstand = null;
// // if(data.body[i].directionType == "02"){
// // pointstand = trainlisttest.list[code].curve.getPointAt(data.body[i].sectionOffsetPercent);
// // }else{
// // pointstand = trainlisttest.list[code].curve.getPointAt(1-data.body[i].sectionOffsetPercent);
// // }
// // console.log(data.body[i].sectionOffsetPercent)
// // console.log(pointstand.x);
// //
// // trainlisttest.list[code].position.x = pointstand.x;
// // }
// }
// if (driverswitch == '05' && code == drivingcode) {
// if (data.body[i].maLen) {
// jlmap3d.updatenowlen(data.body[i].maLen);
// } else {
// jlmap3d.updatenowlen(0);
// }
// }
//
// if (trainlisttest.list[code].nowcode != data.body[i].sectionCode || trainlisttest.list[code].nextcode != data.body[i].nextSectionCode) {
// trainlisttest.list[code].nowcode = data.body[i].sectionCode;
// trainlisttest.list[code].nextcode = data.body[i].nextSectionCode;
// const vexlist = [];
// const endrotation = null;
// if (data.body[i].directionType == '02') { // 向右
// if (trainlisttest.list[code].status != data.body[i].directionType) {
// const rotaposx = trainlisttest.list[code].children[5].matrixWorld.elements[12];
// const rotaposz = trainlisttest.list[code].children[0].matrixWorld.elements[14];
// trainlisttest.list[code].rotation.y = 0;
// trainlisttest.list[code].position.x = rotaposx;
// for (let tl=0; tl<6; tl++) {
// trainlisttest.list[code].children[tl].position.z = rotaposz;
// }
// if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x>sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) {
// vexlist.push(new THREE.Vector3(trainlisttest.list[code].position.x, 0, trainlisttest.list[code].children[0].matrixWorld.elements[14]));
// for (let m=sectionlist.sections.datalist[data.body[i].sectionCode].rail.length-1; m>=0; m--) {
// if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[m].x>trainlisttest.list[code].position.x) {
// vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
// }
// }
// } else {
// vexlist.push(new THREE.Vector3(trainlisttest.list[code].position.x, 0, trainlisttest.list[code].children[0].matrixWorld.elements[14]));
// for (let m=0; m<sectionlist.sections.datalist[data.body[i].sectionCode].rail.length; m++) {
// if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[m].x>trainlisttest.list[code].position.x) {
// vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
// }
// }
// }
// } else {
// if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x>sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) {
// for (let m=sectionlist.sections.datalist[data.body[i].sectionCode].rail.length-1; m>=0; m--) {
// vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
// }
// } else {
// for (let m=0; m<sectionlist.sections.datalist[data.body[i].sectionCode].rail.length; m++) {
// vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
// }
// }
// trainlisttest.list[code].rotation.y = 0;
// }
// trainlisttest.list[code].status = '02';
// } else if (data.body[i].directionType == '03') { // 向左
// if (trainlisttest.list[code].status != data.body[i].directionType) {
// const rotaposx = trainlisttest.list[code].children[5].matrixWorld.elements[12];
// const rotaposz = Math.abs(trainlisttest.list[code].children[0].matrixWorld.elements[14]);
// trainlisttest.list[code].rotation.y = Math.PI;
// trainlisttest.list[code].position.x = rotaposx;
// for (let tl=0; tl<6; tl++) {
// trainlisttest.list[code].children[tl].position.z = rotaposz;
// }
// if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x<sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) {
// vexlist.push(new THREE.Vector3(trainlisttest.list[code].position.x, 0, trainlisttest.list[code].children[0].matrixWorld.elements[14]));
// for (let m=sectionlist.sections.datalist[data.body[i].sectionCode].rail.length-1; m>=0; m--) {
// if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[m].x<trainlisttest.list[code].position.x) {
// vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
// }
// }
// } else {
// vexlist.push(new THREE.Vector3(trainlisttest.list[code].position.x, 0, trainlisttest.list[code].children[0].matrixWorld.elements[14]));
// for (let m=0; m<sectionlist.sections.datalist[data.body[i].sectionCode].rail.length; m++) {
// if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[m].x<trainlisttest.list[code].position.x) {
// vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
// }
// }
// }
// } else {
// if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x<sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) {
// for (let m=sectionlist.sections.datalist[data.body[i].sectionCode].rail.length-1; m>=0; m--) {
// vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
// }
//
// } else {
// for (let m=0; m<sectionlist.sections.datalist[data.body[i].sectionCode].rail.length; m++) {
// vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
// }
// }
// trainlisttest.list[code].rotation.y = Math.PI;
// }
// trainlisttest.list[code].status = '03';
// }
// trainlisttest.list[code].curve = new THREE.CatmullRomCurve3(vexlist);
// trainlisttest.list[code].isStandTrack = sectionlist.sections.datalist[data.body[i].sectionCode].isStandTrack;
// trainlisttest.list[code].len = sectionlist.sections.datalist[data.body[i].sectionCode].distance;
// trainlisttest.list[code].progress = 0;
// trainlisttest.list[code].speed = data.body[i].speed;
// trainlisttest.list[code].speeds = parseFloat(data.body[i].speed*10/36/20/trainlisttest.list[code].len);
//
// }
// }
// }
// }
// }
// }
// }
// }
if (data.type == 'SJL3D_TrainStatus') {
for (let i=data.body.length-1; i>=0; i--) {
if (data.body[i]._type == 'Train') {
// console.log(data.body[i]);
// 遍历列车对象组
if (trainlisttest) {
code = data.body[i].code;
// 剔除不显示的车
// 找到对应列车
if ( trainlisttest.list[code]) {
if (code == drivingcode) {
driverswitch = data.body[i].runMode;
jlmap3d.updatetrainnum(data.body[i].groupNumber);
//更新列车
let syncdata = {
type: 'Train',
code: code,
sectionCode: data.body[i].sectionCode,
percent: 0
};
// if (trainlisttest.list[code].isStandTrack == true && trainlisttest.list[code].progress>0.95 && trainlisttest.list[code].speed<=0) {
// if (data.body[i].directionType == '02') {
// syncdata.percent = 1-(sectionlist.sections.datalist[data.body[i].sectionCode].rstop/trainlisttest.list[code].len);
// } else {
// syncdata.percent = sectionlist.sections.datalist[data.body[i].sectionCode].lstop/trainlisttest.list[code].len;
// }
// scope.teststomp.send('/app/topic/simulation/client/drive', syncdata);
// } else {
// if (data.body[i].directionType == '02') {
// syncdata.percent = trainlisttest.list[code].progress;
// } else {
// syncdata.percent = 1 - trainlisttest.list[code].progress;
// }
// scope.teststomp.send('/app/topic/simulation/client/drive', syncdata);
// }
if (data.body[i].parkRemainTime>0) {
jlmap3d.updatestoptime('停站时间:'+parseInt(data.body[i].parkRemainTime));
} else {
if (data.body[i].runMode == '02') {
jlmap3d.updatestoptime('列车自动驾驶中');
} else {
// if (trainlisttest.list[code].isStandTrack == true && trainlisttest.list[code].progress>0.95 && trainlisttest.list[code].speed<=0) {
// // if(stoptimer){
// //
// // }else{
// // stoptimer = setInterval(function(){
// // if(num >=0){
// // jlmap3d.updatestoptime("停站时间:"+num);
// // num --;
// // }
// // },1000);
// // }
//
// } else {
// jlmap3d.updatestoptime('列车人工驾驶中');
// }
}
}
// if(trainlisttest.list[code].speed > 0){
// if(stoptimer){
// clearInterval( stoptimer );
// stoptimer = null;
// num = 30;
// }
// }
}
trainlisttest.list[code].runMode = data.body[i].runMode;
// 车门开关验证
// if(data.body[i].directionType == "02"){
if (trainlisttest.list[code].doorStatus != data.body[i].doorStatus && data.body[i].doorStatus == '01') {
// console.log("close");
trainlisttest.list[code].doorStatus = '01';
for (let an=actions[code].top.length-1; an>=0; an--) {
actions[code].top[an].reset();
actions[code].top[an].time = actions[code].top[an]._clip.duration;
actions[code].top[an].timeScale = -1;
actions[code].top[an].play();
}
} else if (trainlisttest.list[code].doorStatus != data.body[i].doorStatus && data.body[i].doorStatus == '02') {
// console.log("open");
trainlisttest.list[code].doorStatus = '02';
for (let an=actions[code].top.length-1; an>=0; an--) {
actions[code].top[an].reset();
actions[code].top[an].time = 0;
actions[code].top[an].timeScale = 1;
actions[code].top[an].play();
}
}
// }else{
// if(trainlisttest.list[code].doorStatus != data.body[i].doorStatus && data.body[i].doorStatus == "01"){
// //console.log("close");
// trainlisttest.list[code].doorStatus = "01";
// for(let an=actions[code].down.length-1;an>=0;an--){
// actions[code].down[an].reset();
// actions[code].down[an].time = actions[code].top[an]._clip.duration;
// actions[code].down[an].timeScale = -1;
// actions[code].down[an].play();
// }
// }else if(trainlisttest.list[code].doorStatus != data.body[i].doorStatus && data.body[i].doorStatus == "02"){
// //console.log("open");
// trainlisttest.list[code].doorStatus = "02";
// for(let an=actions[code].down.length-1;an>=0;an--){
// actions[code].down[an].reset();
// actions[code].down[an].time = 0;
// actions[code].down[an].timeScale = 1;
// actions[code].down[an].play();
// }
// }
// }
// 遍历获取所在轨道
if (trainlisttest.list[code].dispose != data.body[i].dispose && data.body[i].dispose == false) {
if (rails.linkrail[data.body[i].linkCode]) {
trainlisttest.group.add(trainlisttest.list[code]);
trainlisttest.list[code].position.y = 0;
trainlisttest.list[code].progress = 0;
trainlisttest.list[code].oldoffset = data.body[i].linkOffsetPercent;
trainlisttest.list[code].dispose = false;
trainlisttest.list[code].nowcode = data.body[i].linkCode;
trainlisttest.list[code].nextcode = rails.linkrail[data.body[i].linkCode].next;
let vexlist = [];
if (data.body[i].directionType == '02') { // 向右
let point = rails.linkrail[data.body[i].linkCode].lineleft.getPointAt(data.body[i].linkOffsetPercent);
trainlisttest.list[code].rotation.y = 0;
trainlisttest.list[code].position.x = point.x;
trainlisttest.list[code].position.y = 0;
for (let tl=0; tl<6; tl++) {
trainlisttest.list[code].children[tl].position.z = point.z;
}
trainlisttest.list[code].status = '02';
trainlisttest.list[code].progress = data.body[i].linkOffsetPercent;
trainlisttest.list[code].curve = rails.linkrail[data.body[i].linkCode].lineleft;
} else if (data.body[i].directionType == '03') { // 向左
let point = rails.linkrail[data.body[i].linkCode].lineright.getPointAt((1-data.body[i].linkOffsetPercent));
trainlisttest.list[code].rotation.y = Math.PI;
trainlisttest.list[code].position.x = point.x;
trainlisttest.list[code].position.y = 0;
for (let tl=0; tl<6; tl++) {
trainlisttest.list[code].children[tl].position.z = -point.z;
}
if(trainlisttest.list[code].rname == "006"){
console.log("0000000000000000");
console.log(data.body[i].linkOffsetPercent);
}
trainlisttest.list[code].status = '03';
trainlisttest.list[code].progress = 1-data.body[i].linkOffsetPercent;
trainlisttest.list[code].curve = rails.linkrail[data.body[i].linkCode].lineright;
}
trainlisttest.list[code].len = rails.linkrail[data.body[i].linkCode].lengthfact;
// trainlisttest.list[code].isStandTrack = sectionlist.sections.datalist[data.body[i].sectionCode].isStandTrack;
// trainlisttest.list[code].len = sectionlist.sections.datalist[data.body[i].sectionCode].distance;
if(data.body[i].speed == 0){
trainlisttest.list[code].speeds = data.body[i].speed;
trainlisttest.list[code].speeds = 0;
// trainlisttest.list[code].startmark = 1;
}else{
trainlisttest.list[code].speeds = data.body[i].speed;
trainlisttest.list[code].speeds = parseFloat(data.body[i].speed*10/36/21/trainlisttest.list[code].len);
}
}
} else if (trainlisttest.list[code].dispose != data.body[i].dispose && data.body[i].dispose == true) {
trainlisttest.group.remove(trainlisttest.list[code]);
trainlisttest.list[code].progress = null;
trainlisttest.list[code].dispose = true;
code = trainlisttest.group.children[i].name;
trainlisttest.list[code].rotation.y = 0;
trainlisttest.list[code].doorStatus = '01';
trainlisttest.list[code].speed = 0;
trainlisttest.list[code].position.x = -50000;
trainlisttest.list[code].position.y = -50000;
} else if (trainlisttest.list[code].dispose == data.body[i].dispose && data.body[i].dispose == false) {
if (rails.linkrail[data.body[i].linkCode]) {
if (driverswitch == '02' && code == drivingcode) {
jlmap3d.updatenowspeed(data.body[i].speed);
if (data.body[i].atpSpeed) {
jlmap3d.updateatpspeed(data.body[i].atpSpeed);
} else {
jlmap3d.updateatpspeed(-1);
}
if (data.body[i].targetSpeed) {
jlmap3d.updateatospeed(data.body[i].targetSpeed);
} else {
jlmap3d.updateatospeed(-1);
}
if (data.body[i].maLen) {
jlmap3d.updatenowlen(data.body[i].maLen);
} else {
jlmap3d.updatenowlen(0);
}
// if(trainlisttest.list[code].isStandTrack == true){
// pointstand = null;
// if(data.body[i].directionType == "02"){
// pointstand = trainlisttest.list[code].curve.getPointAt(data.body[i].sectionOffsetPercent);
// }else{
// pointstand = trainlisttest.list[code].curve.getPointAt(1-data.body[i].sectionOffsetPercent);
// }
// console.log(data.body[i].sectionOffsetPercent)
// console.log(pointstand.x);
//
// trainlisttest.list[code].position.x = pointstand.x;
// }
}
if (driverswitch == '05' && code == drivingcode) {
if (data.body[i].maLen) {
jlmap3d.updatenowlen(data.body[i].maLen);
} else {
jlmap3d.updatenowlen(0);
}
}
if(trainlisttest.list[code].nowcode != data.body[i].linkCode){
trainlisttest.list[code].nowcode = data.body[i].linkCode;
trainlisttest.list[code].nextcode = rails.linkrail[data.body[i].linkCode].next;
if (data.body[i].directionType == '02') { // 向右
trainlisttest.list[code].progress = 0;
if (trainlisttest.list[code].status != data.body[i].directionType) {
const rotaposx = trainlisttest.list[code].children[5].matrixWorld.elements[12];
const rotaposz = trainlisttest.list[code].children[0].matrixWorld.elements[14];
trainlisttest.list[code].rotation.y = 0;
trainlisttest.list[code].position.x = rotaposx;
for (let tl=0; tl<6; tl++) {
trainlisttest.list[code].children[tl].position.z = rotaposz;
}
trainlisttest.list[code].progress = (rotaposx-rails.linkrail[data.body[i].linkCode].lp.x)/rails.linkrail[data.body[i].linkCode].lengthfact;
}
trainlisttest.list[code].status = '02';
trainlisttest.list[code].curve = rails.linkrail[data.body[i].linkCode].lineleft;
} else if (data.body[i].directionType == '03') { // 向左
trainlisttest.list[code].progress = 0;
if (trainlisttest.list[code].status != data.body[i].directionType) {
const rotaposx = trainlisttest.list[code].children[5].matrixWorld.elements[12];
const rotaposz = Math.abs(trainlisttest.list[code].children[0].matrixWorld.elements[14]);
trainlisttest.list[code].rotation.y = Math.PI;
trainlisttest.list[code].position.x = rotaposx;
for (let tl=0; tl<6; tl++) {
trainlisttest.list[code].children[tl].position.z = -rotaposz;
}
trainlisttest.list[code].progress = 1-(rotaposx-rails.linkrail[data.body[i].linkCode].lp.x)/rails.linkrail[data.body[i].linkCode].lengthfact;
}
trainlisttest.list[code].status = '03';
trainlisttest.list[code].curve = rails.linkrail[data.body[i].linkCode].lineright;
}
// console.log(rails.linkrail[data.body[i].linkCode]);
// console.log(data.body[i].linkCode)
// console.log(nextcode);
trainlisttest.list[code].len = rails.linkrail[data.body[i].linkCode].lengthfact;
}
if(data.body[i].directionType == '02'){
let nextcode = rails.linkrail[data.body[i].linkCode].rconnect;
if(nextcode){
trainlisttest.list[code].nextcurve = rails.linkrail[nextcode].lineleft;
}
}else if(data.body[i].directionType == '03'){
let nextcode = rails.linkrail[data.body[i].linkCode].lconnect;
if(nextcode){
trainlisttest.list[code].nextcurve = rails.linkrail[nextcode].lineright;
}
}
}
}
}
}
}
}
}
if (data.type == 'Simulation_DeviceStatus') {
@ -535,7 +454,6 @@ export function Jlmap3dSubscribe(jlmap3d) {
}
if (data.body[i]._type == 'Switch') {
console.log(data.body[i]);
if (sectionlist) {
switchupdate(data.body[i]);
}
@ -667,8 +585,8 @@ export function Jlmap3dSubscribe(jlmap3d) {
function switchupdate(data) {
code = data.code;
for (let j=sectionlist.switchs.modellist.length-1; j>=0; j--) {
if (sectionlist.switchs.modellist[j].code == code) {
if (sectionlist.switchs.modellist[j].locateType != data.locateType) {
if (rails.switchrail[code]) {
if (rails.switchrail[code].locateType != data.locateType) {
if (data.locateType == '02') {
if (actions[sectionlist.switchs.modellist[j].code]) {
sectionlist.switchs.modellist[j].locateType = data.locateType;
@ -677,6 +595,21 @@ export function Jlmap3dSubscribe(jlmap3d) {
actions[sectionlist.switchs.modellist[j].code].timeScale = 1;
actions[sectionlist.switchs.modellist[j].code].play();
}
rails.switchrail[code].locateType = "02";
let testswitch = rails.switchrail[code];
console.log(testswitch);
console.log(rails.linkrail[testswitch.alink]);
console.log(rails.linkrail[testswitch.clink]);
if(rails.switchrail[code].directtype == "1"){
rails.linkrail[testswitch.alink].lconnect = testswitch.clink;
rails.linkrail[testswitch.clink].rconnect = testswitch.alink;
}else if(rails.switchrail[code].directtype == "2"){
rails.linkrail[testswitch.alink].rconnect = testswitch.clink;
rails.linkrail[testswitch.clink].lconnect = testswitch.alink;
}
} else if (data.locateType == '01') {
if (actions[sectionlist.switchs.modellist[j].code]) {
sectionlist.switchs.modellist[j].locateType = data.locateType;
@ -685,6 +618,20 @@ export function Jlmap3dSubscribe(jlmap3d) {
actions[sectionlist.switchs.modellist[j].code].timeScale = -1;
actions[sectionlist.switchs.modellist[j].code].play();
}
rails.switchrail[code].locateType = "01";
let testswitch = rails.switchrail[code];
console.log(testswitch);
console.log(rails.linkrail[testswitch.alink]);
console.log(rails.linkrail[testswitch.clink]);
if(rails.switchrail[code].directtype == "1"){
rails.linkrail[testswitch.alink].lconnect = testswitch.blink;
rails.linkrail[testswitch.blink].rconnect = testswitch.alink;
}else if(rails.switchrail[code].directtype == "2"){
rails.linkrail[testswitch.alink].rconnect = testswitch.blink;
rails.linkrail[testswitch.blink].lconnect = testswitch.alink;
}
}
}
j = 0;

View File

@ -29,15 +29,15 @@ import {Jlmap3dSubscribe } from '@/jlmap3d/jl3dsimulation/connect/TrainingConnec
import { getPublishMapVersion, getPublishMapDetail,getPublish3dMapDetail} from '@/api/jlmap3d/load3ddata';
//utils
import { UpdateTrain } from '@/jlmap3d/main/utils/UpdateTrain';
//import { UpdateTrain } from '@/jlmap3d/main/utils/UpdateTrainTest';
// import { UpdateTrain } from '@/jlmap3d/main/utils/UpdateTrain';
import { UpdateTrain } from '@/jlmap3d/main/utils/UpdateTrainTest';
// import { ReStart } from '@/jlmap3d/main/utils/ReStart';
import {Stats} from '@/jlmap3d/main/lib/stats.min.js';
var clock = new THREE.Clock();
export function JLmap3d(dom, data,skinCode) {
export function JLmap3d(dom, data,skinCode,storemod) {
let scope = this;
@ -82,14 +82,13 @@ export function JLmap3d(dom, data,skinCode) {
this.Subscribe = new Jlmap3dSubscribe(this.webwork);
//连接到通信
//console.log(this.Subscribe.config);
//this.webwork.postMessage(this.Subscribe.teststomp);
this.Subscribe.socketon(scope.Subscribe.topic);
//初始化加载数据和模型
getPublish3dMapDetail(skinCode).then(netdata => {
ModelLoad(data,scope,netdata.data,mapdata,camera,controls,scene);
ModelLoad(data,scope,netdata.data,mapdata,camera,controls,scene,storemod);
});
//
// let stats = new Stats();

View File

@ -18,7 +18,7 @@ let defaulttrain = {
deviceType:"train",
type:"num4",
picUrl:"",
assetUrl:"https://joylink.club/oss/models/train/train.FBX"
assetUrl:"../../static/model/train/train.FBX"
}
@ -56,7 +56,7 @@ let defaultsuidao = {
deviceType:"suidao",
type:"suidao",
picUrl:"",
assetUrl:"https://joylink.club/oss/models/suidao/suidao.FBX"
assetUrl:"../../static/model/suidao/suidao.FBX"
}//https://joylink.club/oss/models/suidao/suidao.FBX
//../../static/model/
@ -129,7 +129,6 @@ export function AssetLoader(){
let defaultswitch2 = new AssetModel(autoswitch2);
scope.modellist.push(defaultswitch2);
let modeldata = JSON.parse(data);
for(let j=0;j<modeldata.length;j++){
@ -456,7 +455,7 @@ export function AssetLoader(){
let name = "c"+j;
for(let i=0;i<object.children.length;i++){
if(object.children[i].name == name){
object.children[i].position.x = object.children[i].position.x+38.1;
object.children[i].position.x = object.children[i].position.x+10;
//object.children[i].position.y = j*10;
realtrain.add(object.children[i]);
i--;

View File

@ -12,7 +12,7 @@ import {Materialload} from '@/jlmap3d/main/loaders/Materialload.js';
import { Loading } from 'element-ui';
// import {SwitchModel} from '@/jlmap3d/model/SwitchModel.js';
export function ModelLoad(data,scope,netdata,mapdata,camera,controls,scene){
export function ModelLoad(data,scope,netdata,mapdata,camera,controls,scene,storemod){
//console.log(mapdata);
Materialload(scope);
//console.log(data);
@ -95,7 +95,7 @@ export function ModelLoad(data,scope,netdata,mapdata,camera,controls,scene){
})
.then(function(data){
return new Promise(function(resolve, reject){
jlmap3ddata.rails.init(loaderdata.link,switchdata);
jlmap3ddata.rails.init(loaderdata.link,switchdata,sceneload,storemod);
resolve("loadrail");
});

View File

@ -4,13 +4,15 @@ import {SignalList} from '@/jlmap3d/main/model/SignalList.js';
import {StationStandList} from '@/jlmap3d/main/model/StationStandList.js';
import {TrainList} from '@/jlmap3d/main/model/TrainList.js';
import {RealSectionList} from '@/jlmap3d/main/model/RealSectionList.js';
import {LinkList} from '@/jlmap3d/main/model/LinkList.js';
import {RailList} from '@/jlmap3d/main/model/RailList.js';
import {Materialload} from '@/jlmap3d/main/loaders/Materialload.js';
import { Loading } from 'element-ui';
// import {SwitchModel} from '@/jlmap3d/model/SwitchModel.js';
export function ModelLoad(data,scope,netdata,mapdata,camera,controls,scene,mixerss){
export function ModelLoad(data,scope,netdata,mapdata,camera,controls,scene,mixerss,storemod){
//console.log(mapdata);
Materialload(scope);
//console.log(data);
@ -27,15 +29,14 @@ export function ModelLoad(data,scope,netdata,mapdata,camera,controls,scene,mixer
let isSection = false;
if(netdata.assets){
let assetsdata = JSON.parse(netdata.assets);
for(let i=0;i<assetsdata.length;i++){
if(assetsdata[i].deviceType == "mapSection"){
isSection = true;
}
let assetsdata = JSON.parse(netdata.sections);
console.log(netdata);
if(assetsdata.link){
isSection = true;
}
}
console.log(netdata);
if(isSection == true){
init3d(data,netdata);
}else{
@ -49,18 +50,27 @@ export function ModelLoad(data,scope,netdata,mapdata,camera,controls,scene,mixer
// console.log(data);
//初始化轨道和道岔 暂时
lengthfact(data);
jlmap3ddata.linklist = new LinkList();
jlmap3ddata.sectionlist = new SectionList();
jlmap3ddata.signallist = new SignalList();
//初始化站台
jlmap3ddata.stationstandlist = new StationStandList();
//初始化测试列车
jlmap3ddata.trainlisttest = new TrainList();
jlmap3ddata.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);
jlmap3ddata.realsectionlist = new RealSectionList();
assetloader.setmodellist(netdata.assets);
assetloader.assetpromise(sceneload)
.then(function(data){
//console.log(data);
return jlmap3ddata.linklist.loadpromise(loaderdata.link,scene,assetloader);
})
.then(function(data){
//console.log(data);
return jlmap3ddata.stationstandlist.initpromise(mapdata.stationList,mapdata.stationStandList,sceneload,assetloader,netdata.stands,mixers,actions);
@ -72,52 +82,59 @@ export function ModelLoad(data,scope,netdata,mapdata,camera,controls,scene,mixer
})
.then(function(data){
//console.log(data);
return jlmap3ddata.sectionlist.initpromise(mapdata.sectionList,mapdata.switchList,sceneload);
})
.then(function(data){
//console.log(data);
return jlmap3ddata.realsectionlist.initpromise(jlmap3ddata,sceneload,assetloader,mixers,actions);
return jlmap3ddata.sectionlist.loadpromise(jlmap3ddata,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 jlmap3ddata.signallist.initpromise(mapdata.signalList,sceneload,assetloader,netdata.signals);
})
.then(function(data){
return new Promise(function(resolve, reject){
let loader = new THREE.OBJLoader( );
loader.load( '../../static/rail/fuzhoupath.obj', function ( obj ) {
let object = obj;
//console.log(object.children.length);
let rail = [];
for(let i=0;i<object.children.length;i++){
let name = object.children[i].name.split("_");
let newmeshname = name[0]+"_"+name[1]+"_"+name[2]+"."+name[3];
let vexlist = [];
//console.log( object.children[i].geometry.attributes.position.array);
for(let j=0;j<object.children[i].geometry.attributes.position.array.length;j){
//console.log(object.children[i].geometry.attributes.position.array[j]);
let ved = new THREE.Vector3( object.children[i].geometry.attributes.position.array[j], object.children[i].geometry.attributes.position.array[j+1], object.children[i].geometry.attributes.position.array[j+2] );
j=j+3;
vexlist.push(ved);
}
if(jlmap3ddata.sectionlist.sections.datalist[newmeshname].code){
jlmap3ddata.sectionlist.sections.datalist[newmeshname].rail = vexlist;
//console.log(jlmap3ddata.sectionlist.sections.datalist[n].rail.length);
}
}
resolve("loadedrealsection");
}, onProgress, onError );
jlmap3ddata.rails.init(loaderdata.link,switchdata,sceneload,storemod);
resolve("loadrail");
});
})
// .then(function(data){
// return new Promise(function(resolve, reject){
//
// let loader = new THREE.OBJLoader( );
//
// loader.load( '../../static/rail/fuzhoupath.obj', function ( obj ) {
//
// let object = obj;
// //console.log(object.children.length);
//
// let rail = [];
// for(let i=0;i<object.children.length;i++){
// let name = object.children[i].name.split("_");
// let newmeshname = name[0]+"_"+name[1]+"_"+name[2]+"."+name[3];
//
// let vexlist = [];
// //console.log( object.children[i].geometry.attributes.position.array);
// for(let j=0;j<object.children[i].geometry.attributes.position.array.length;j){
// //console.log(object.children[i].geometry.attributes.position.array[j]);
// let ved = new THREE.Vector3( object.children[i].geometry.attributes.position.array[j], object.children[i].geometry.attributes.position.array[j+1], object.children[i].geometry.attributes.position.array[j+2] );
// j=j+3;
//
// vexlist.push(ved);
// }
//
// if(jlmap3ddata.sectionlist.sections.datalist[newmeshname].code){
// jlmap3ddata.sectionlist.sections.datalist[newmeshname].rail = vexlist;
// //console.log(jlmap3ddata.sectionlist.sections.datalist[n].rail.length);
// }
// }
//
// resolve("loadedrealsection");
// }, onProgress, onError );
//
// });
// })
.then(function(data){
for(let mn=0;mn<scope.assetloader.modellist.length;mn++){
@ -126,6 +143,7 @@ export function ModelLoad(data,scope,netdata,mapdata,camera,controls,scene,mixer
scene.add(scope.assetloader.modellist[mn].mesh);
}
if(scope.assetloader.modellist[mn].name && scope.assetloader.modellist[mn].name == "suidao"){
scope.assetloader.modellist[mn].mesh.rotation.x = -Math.PI/2;
scene.add(scope.assetloader.modellist[mn].mesh);
}
}

View File

@ -9,16 +9,21 @@ export function RailList(){
};
this.init = function(linkdata,switchdata){
this.init = function(linkdata,switchdata,scene,storemod){
for(let i=0;i<linkdata.length;i++){
scope.linkrail[linkdata[i].code] = {
lp:linkdata[i].rail[0],
rp:linkdata[i].rail[1],
lconnect:null,
rconnect:null,
lengthfact:linkdata[i].lengthfact,
prior:null,
next:null,
plist:[]
lineleft:null,
lineright:null,
points:[]
};
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(scope.linkrail[linkdata[i].code].lp.x,0,scope.linkrail[linkdata[i].code].lp.z));
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(scope.linkrail[linkdata[i].code].rp.x,0,scope.linkrail[linkdata[i].code].rp.z));
}
for(let i=0;i<switchdata.length;i++){
scope.switchrail[switchdata[i].code] = {
@ -26,71 +31,76 @@ export function RailList(){
blink:switchdata[i].blink,
clink:switchdata[i].clink,
position:switchdata[i].position,
status:0
directtype:null,
locateType:0
};
scope.linkrail[switchdata[i].alink].next = switchdata[i].blink;
scope.linkrail[switchdata[i].blink].prior = switchdata[i].alink;
if(scope.linkrail[switchdata[i].blink].lp.x < switchdata[i].position.x){
scope.linkrail[switchdata[i].blink].points.push(new THREE.Vector3(switchdata[i].position.x,switchdata[i].position.y,switchdata[i].position.z));
scope.linkrail[switchdata[i].blink].points.push(new THREE.Vector3(scope.linkrail[switchdata[i].alink].lp.x,0,scope.linkrail[switchdata[i].alink].lp.z));
scope.switchrail[switchdata[i].code].directtype = "1";
}else{
scope.linkrail[switchdata[i].blink].points.splice(0,0,new THREE.Vector3(switchdata[i].position.x,switchdata[i].position.y,switchdata[i].position.z));
scope.linkrail[switchdata[i].blink].points.splice(0,0,new THREE.Vector3(scope.linkrail[switchdata[i].alink].rp.x,0,scope.linkrail[switchdata[i].alink].rp.z));
scope.switchrail[switchdata[i].code].directtype = "2";
}
if(scope.linkrail[switchdata[i].clink].lp.x < switchdata[i].position.x){
scope.linkrail[switchdata[i].clink].points.push(new THREE.Vector3(switchdata[i].position.x,switchdata[i].position.y,switchdata[i].position.z));
scope.linkrail[switchdata[i].clink].points.push(new THREE.Vector3(scope.linkrail[switchdata[i].alink].lp.x,0,scope.linkrail[switchdata[i].alink].lp.z));
scope.switchrail[switchdata[i].code].directtype = "1";
}else{
scope.linkrail[switchdata[i].clink].points.splice(0,0,new THREE.Vector3(switchdata[i].position.x,switchdata[i].position.y,switchdata[i].position.z));
scope.linkrail[switchdata[i].clink].points.splice(0,0,new THREE.Vector3(scope.linkrail[switchdata[i].alink].rp.x,0,scope.linkrail[switchdata[i].alink].rp.z));
scope.switchrail[switchdata[i].code].directtype = "2";
}
const ddd = storemod.getters['map/getDeviceByCode'](switchdata[i].code);
scope.switchrail[switchdata[i].code].locateType = ddd.locateType;
if(ddd.locateType == "01"){
//1--向右 2--向左
if(scope.switchrail[switchdata[i].code].directtype == "1"){
scope.linkrail[switchdata[i].alink].rconnect = switchdata[i].blink;
scope.linkrail[switchdata[i].blink].lconnect = switchdata[i].alink;
}else if(scope.switchrail[switchdata[i].code].directtype == "2"){
scope.linkrail[switchdata[i].alink].lconnect = switchdata[i].blink;
scope.linkrail[switchdata[i].blink].rconnect = switchdata[i].alink;
}
}else if(ddd.locateType == "02"){
if(switchdata[i].directtype == "1"){
scope.linkrail[switchdata[i].alink].rconnect = switchdata[i].clink;
scope.linkrail[switchdata[i].clink].lconnect = switchdata[i].alink;
}else if(switchdata[i].directtype == "2"){
scope.linkrail[switchdata[i].alink].lconnect = switchdata[i].clink;
scope.linkrail[switchdata[i].clink].rconnect = switchdata[i].alink;
}
}
}
for(let i=0;i<linkdata.length;i++){
scope.linkrail[linkdata[i].code].lineleft = new THREE.CatmullRomCurve3(scope.linkrail[linkdata[i].code].points);
let rightpoints = [];
scope.linkrail[linkdata[i].code].points.forEach(item=>{
rightpoints.push(item);
}
);
rightpoints.reverse();
scope.linkrail[linkdata[i].code].lineright = new THREE.CatmullRomCurve3(rightpoints);
var points = scope.linkrail[linkdata[i].code].lineleft.getPoints( 50 );
var geometry = new THREE.BufferGeometry().setFromPoints( points );
var material = new THREE.LineBasicMaterial( { color : 0xff0000 } );
// Create the final object to add to the scene
var curveObject = new THREE.Line( geometry, material );
scene.add(curveObject);
}
// console.log(linkdata);
console.log(switchdata);
console.log(scope.linkrail);
console.log(scope.switchrail);
}
this.resetrail = function(mapdata,scene){
console.log(mapdata);
let raillink = mapdata.linklist.linksgroup.children;
for(let i=0;i<raillink.length;i++){
var geometry = new THREE.PlaneBufferGeometry( raillink[i].lengthfact-25, 0.1, 0.1 );
var material = new THREE.MeshBasicMaterial( {color: 0xffff00, side: THREE.DoubleSide} );
var plane = new THREE.Mesh( geometry, material );
plane.position.x = raillink[i].position.x;
plane.position.y = 2;
plane.position.z = raillink[i].position.z;
plane.rotation.x = -Math.PI/2;
plane.rotation.z = raillink[i].rotation._z;
var geometry1 = new THREE.CircleBufferGeometry( 1, 16 );
var material1 = new THREE.MeshBasicMaterial( { color: 0xffff00 } );
var geometry2 = new THREE.CircleBufferGeometry( 1, 16 );
var material2 = new THREE.MeshBasicMaterial( { color: 0xff2000 } );
var circle1 = new THREE.Mesh( geometry1, material1 );
circle1.position.x = plane.position.x + (raillink[i].lengthfact-25)/2*Math.cos(plane.rotation.z);
circle1.position.z = plane.position.z - (raillink[i].lengthfact-25)/2*Math.sin(plane.rotation.z);
circle1.rotation.x = -Math.PI/2;
scene.add( circle1 );
var circle2 = new THREE.Mesh( geometry2, material2 );
circle2.position.x = plane.position.x - (raillink[i].lengthfact-25)/2*Math.cos(plane.rotation.z);
circle2.position.z = plane.position.z + (raillink[i].lengthfact-25)/2*Math.sin(plane.rotation.z);
circle2.rotation.x = -Math.PI/2;
mapdata.linklist.linksgroup.children[i].rail = [{
x:circle1.position.x,
z:circle1.position.z
},{
x:circle2.position.x,
z:circle2.position.z
}];
scene.add( circle2 );
scene.add( plane );
}
for(let i=0;i<mapdata.sectionlist.switchs.modellist.length;i++){
var geometry = new THREE.CircleBufferGeometry( 1, 16 );
var material = new THREE.MeshBasicMaterial( { color: 0xff00ff } );
var circle1 = new THREE.Mesh( geometry, material );
circle1.position.x = mapdata.sectionlist.switchs.modellist[i].position.x;
circle1.position.z = mapdata.sectionlist.switchs.modellist[i].position.z;
circle1.rotation.x = -Math.PI/2;
scene.add( circle1 );
}
};
this.getrail = function(){
};

View File

@ -50,11 +50,13 @@ export function StationStandList() {
}
}
}
newstationstand.index = i;
newstationstand.num = i;
scope.list[stationdata[i].code] = newstationstand;
}
}
let map = scope.list;
for(let k in map){
@ -65,10 +67,6 @@ export function StationStandList() {
num = j;
}
}
map[k].mesh = assetloader.modellist[num].mesh.clone(true);
map[k].id = assetloader.modellist[num].id;
map[k].mesh.code = map[k].code;
@ -98,25 +96,19 @@ export function StationStandList() {
textmaterial.dispose();
textt.dispose();
}else{
for(let netnum =0;netnum <netstand.length;netnum++){
if(netstand[netnum].code == k ){
for(let netnum =0;netnum <netstand.length;netnum++){
if(netstand[netnum].code == k ){
for(let j=0;j<assetloader.modellist.length;j++){
if(assetloader.modellist[j].id == netstand[netnum].modelid){
num = j;
map[k].index = netnum;
j = assetloader.modellist.length;
}
for(let j=0;j<assetloader.modellist.length;j++){
if(assetloader.modellist[j].id == netstand[netnum].modelid){
num = j;
map[k].index = netnum;
j = assetloader.modellist.length;
}
netnum = netstand.length;
}
}
netnum = netstand.length;
}
}
map[k].mesh = assetloader.modellist[num].mesh.clone(true);
let newclip = assetloader.modellist[num].mesh.animations[ 0 ];
@ -172,16 +164,15 @@ export function StationStandList() {
map[k].mesh.scale.x = netstand[map[k].index].scale.x;
map[k].mesh.scale.y = netstand[map[k].index].scale.y;
map[k].mesh.scale.z = netstand[map[k].index].scale.z;
let textgeometry = new THREE.PlaneBufferGeometry( 271, 374, 1 );
let textt = new THREE.CanvasTexture(getTextCanvas(stationdata[map[k].index]));
let textt = new THREE.CanvasTexture(getTextCanvas(stationdata[map[k].num]));
let textmaterial = new THREE.MeshBasicMaterial( { side: THREE.DoubleSide,map:textt ,transparent: true} );
let textplane = new THREE.Mesh( textgeometry, textmaterial );
textplane.name = stationdata[map[k].index].code;
textplane.name = stationdata[map[k].num].code;
map[k].type = "station";
map[k].rname = stationdata[map[k].index].runPlanName;
map[k].kmmark = stationdata[map[k].index].kmPost;
map[k].rname = stationdata[map[k].num].runPlanName;
map[k].kmmark = stationdata[map[k].num].kmPost;
textplane.position.y = 300;
textplane.rotation.x = Math.PI/2;

View File

@ -10,7 +10,7 @@ export function StationStandModel(opts) {
this.ismodel = false;
this.istexture = false;
this.modelurl = null;
this.index = null;
this.direction1= {
position:null,
name:null,

View File

@ -38,6 +38,7 @@ export function TrainList() {
top:[],
down:[]
};
for(let j=0;j<newmesh.children.length;j++){
if(newmesh.children[j].name == "c1" || newmesh.children[j].name == "c6"){
@ -122,7 +123,7 @@ export function TrainList() {
let textmaterial = new THREE.MeshBasicMaterial( { side: THREE.DoubleSide,map:textt ,transparent: true} );
let textplane = new THREE.Mesh( textgeometry, textmaterial );
textplane.name = data[i].code;
textplane.position.x = -50;
textplane.position.x = 0;
textplane.position.y = 130;
textplane.tcode = data[i].code;
//textplane.rotation.x = Math.PI;
@ -139,7 +140,7 @@ export function TrainList() {
newmesh.groupNumber = data[i].groupNumber;
newmesh.position.set(0,-50000,0);
newmesh.children[0].position.y = 0;
// newmesh.children[0].position.y = 0;
//newmesh.rotation.y = Math.PI/2;
newmesh.status = "00";
newmesh.nowcode = null;

View File

@ -12,107 +12,61 @@ export function UpdateTrain(camera,traindata){
if(trainmodel.speeds > 0 && trainmodel.speeds){
let speed = null;
if(traindata.group.children[j].progress<1){
if(traindata.group.children[j].progress >=0&&traindata.group.children[j].progress<=1){
// console.log(trainmodel.rname);
// console.log(trainmodel.speeds);
// console.log(trainmodel.progress);
let movecurve = trainmodel.curve;
if(trainmodel.status == "03"){
if(movecurve.points.length>1){
let point = movecurve.getPointAt(traindata.group.children[j].progress);
if(trainmodel.status == "03"){//向左
let point = movecurve.getPointAt(traindata.group.children[j].progress);
if(Math.abs( point.z -trainmodel.children[0].matrixWorld.elements[14]) >0.1){
trainmodel.children[0].up = new THREE.Vector3(-1,0,0);
let tangent = movecurve.getTangentAt(traindata.group.children[j].progress).normalize();
trainmodel.children[0].axis.crossVectors(trainmodel.children[0].up, tangent).normalize();
let radians = Math.acos(trainmodel.children[0].up.dot(tangent));
trainmodel.children[0].quaternion.setFromAxisAngle(trainmodel.children[0].axis, radians);
let rotas = {
posr:point,
rota:trainmodel.children[0].rotation.y
}
trainmodel.children[1].rotalist.push(rotas);
if(Math.abs( point.z -trainmodel.children[0].matrixWorld.elements[14]) >0.02){
trainmodel.children[0].up = new THREE.Vector3(-1,0,0);
let tangent = movecurve.getTangentAt(traindata.group.children[j].progress).normalize();
trainmodel.children[0].axis.crossVectors(trainmodel.children[0].up, tangent).normalize();
let radians = Math.acos(trainmodel.children[0].up.dot(tangent));
let offsetz = parseFloat(trainmodel.children[0].matrixWorld.elements[14]) - parseFloat(point.z);
trainmodel.children[0].position.z += offsetz;
//trainmodel.position.z = point.z;
}
trainmodel.children[0].quaternion.setFromAxisAngle(trainmodel.children[0].axis, radians);
trainmodel.children[0].rotation.x = -Math.PI/2;
trainmodel.children[0].rotation.z = trainmodel.children[0].rotation.y;
trainmodel.children[0].rotation.y = 0;
trainmodel.position.x = point.x;
trainmodel.position.y = 0;
if(trainmodel.children[1].rotalist.length > 0 || trainmodel.children[2].rotalist.length > 0 || trainmodel.children[3].rotalist.length > 0 || trainmodel.children[4].rotalist.length > 0|| trainmodel.children[5].rotalist.length > 0){
for(let rs = 1;rs<6;rs++){
//console.log(rs);
if(trainmodel.children[rs].rotalist[0]){
let offsetz = parseFloat(trainmodel.children[rs].matrixWorld.elements[14]) - parseFloat(trainmodel.children[rs].rotalist[0].posr.z);
trainmodel.children[rs].position.z += offsetz;
for(let xh=0;xh<trainmodel.children[rs].rotalist.length;xh++){
if((trainmodel.children[rs].matrixWorld.elements[12]-38)<=trainmodel.children[rs].rotalist[0].posr.x){
if(rs != 5){
let asd = trainmodel.children[rs].rotalist[0];
trainmodel.children[rs+1].rotalist.push(asd);
}
trainmodel.children[rs].rotation.y = trainmodel.children[rs].rotalist[0].rota;
trainmodel.children[rs].rotalist.splice(0,1)
xh--;
}else{
xh = trainmodel.children[rs].rotalist.length;
}
}
//console.log(trainmodel.children[rs].rotalist.length);
console.log(trainmodel.children[0].rotation.x);
console.log(trainmodel.children[0].rotation.y);
console.log(trainmodel.children[0].rotation.z);
let rotas = {
posr:point,
rota:trainmodel.children[0].rotation.z
}
trainmodel.children[1].rotalist.push(rotas);
let offsetz = parseFloat(trainmodel.children[0].matrixWorld.elements[14]) - parseFloat(point.z);
trainmodel.children[0].position.z += offsetz;
//trainmodel.position.z = point.z;
}
}
trainmodel.progress += trainmodel.speeds;
}
if(trainmodel.status == "02"){
trainmodel.position.x = point.x;
trainmodel.position.y = 0;
let point = movecurve.getPointAt(trainmodel.progress);
if(Math.abs( point.z -trainmodel.children[0].matrixWorld.elements[14]) >0.1){
trainmodel.children[0].up = new THREE.Vector3(1,0,0);
let tangent = movecurve.getTangentAt(traindata.group.children[j].progress).normalize();
trainmodel.children[0].axis.crossVectors(trainmodel.children[0].up, tangent).normalize();
let radians = Math.acos(trainmodel.children[0].up.dot(tangent));
trainmodel.children[0].quaternion.setFromAxisAngle(trainmodel.children[0].axis, radians);
let rotas = {
posr:point,
rota:trainmodel.children[0].rotation.y
}
trainmodel.children[1].rotalist.push(rotas);
let offsetz = parseFloat(point.z) - parseFloat(trainmodel.children[0].matrixWorld.elements[14]);
trainmodel.children[0].position.z += offsetz;
//trainmodel.position.z = point.z;
}
trainmodel.position.x = point.x;
trainmodel.position.y = 0;
if(trainmodel.children[1].rotalist.length > 0 || trainmodel.children[2].rotalist.length > 0 || trainmodel.children[3].rotalist.length > 0 || trainmodel.children[4].rotalist.length > 0|| trainmodel.children[5].rotalist.length > 0){
for(let rs = 1;rs<6;rs++){
if(trainmodel.children[1].rotalist.length > 0 || trainmodel.children[2].rotalist.length > 0 || trainmodel.children[3].rotalist.length > 0 || trainmodel.children[4].rotalist.length > 0|| trainmodel.children[5].rotalist.length > 0){
for(let rs = 1;rs<6;rs++){
//console.log(rs);
if(trainmodel.children[rs].rotalist[0]){
let offsetz = parseFloat(trainmodel.children[rs].matrixWorld.elements[14]) - parseFloat(trainmodel.children[rs].rotalist[0].posr.z);
let offsetz = parseFloat(trainmodel.children[rs].rotalist[0].posr.z) - parseFloat(trainmodel.children[rs].matrixWorld.elements[14]);
trainmodel.children[rs].position.z += offsetz;
for(let xh=0;xh<trainmodel.children[rs].rotalist.length;xh++){
if((trainmodel.children[rs].matrixWorld.elements[12]+38)>=trainmodel.children[rs].rotalist[0].posr.x){
if((trainmodel.children[rs].matrixWorld.elements[12]-8)<=trainmodel.children[rs].rotalist[0].posr.x){
if(rs != 5){
let asd = trainmodel.children[rs].rotalist[0];
trainmodel.children[rs+1].rotalist.push(asd);
}
//let offsetx = trainmodel.children[1].matrixWorld.elements[12]-trainmodel.children[0].children[3].matrixWorld.elements[12];
trainmodel.children[rs].rotation.y = trainmodel.children[rs].rotalist[0].rota;
trainmodel.children[rs].rotation.z = trainmodel.children[rs].rotalist[0].rota;
trainmodel.children[rs].rotalist.splice(0,1)
xh--;
}else{
@ -120,17 +74,93 @@ export function UpdateTrain(camera,traindata){
}
}
//console.log(trainmodel.children[rs].rotalist.length);
}
}
}
// console.log(trainmodel.rotalist);
trainmodel.progress += trainmodel.speeds;
}
trainmodel.progress += trainmodel.speeds;
}
if(trainmodel.status == "02"){
if(movecurve.points.length>1){
let point = movecurve.getPointAt(trainmodel.progress);
if(Math.abs( point.z -trainmodel.children[0].matrixWorld.elements[14]) >0.02){
trainmodel.children[0].up = new THREE.Vector3(1,0,0);
let tangent = movecurve.getTangentAt(traindata.group.children[j].progress).normalize();
trainmodel.children[0].axis.crossVectors(trainmodel.children[0].up, tangent).normalize();
let radians = Math.acos(trainmodel.children[0].up.dot(tangent));
trainmodel.children[0].quaternion.setFromAxisAngle(trainmodel.children[0].axis, radians);
trainmodel.children[0].rotation.x = -Math.PI/2;
trainmodel.children[0].rotation.z = trainmodel.children[0].rotation.y;
trainmodel.children[0].rotation.y = 0;
let rotas = {
posr:point,
rota:trainmodel.children[0].rotation.z
}
trainmodel.children[1].rotalist.push(rotas);
let offsetz = parseFloat(point.z) - parseFloat(trainmodel.children[0].matrixWorld.elements[14]);
trainmodel.children[0].position.z += offsetz;
//trainmodel.position.z = point.z;
}
trainmodel.position.x = point.x;
trainmodel.position.y = 0;
if(trainmodel.children[1].rotalist.length > 0 || trainmodel.children[2].rotalist.length > 0 || trainmodel.children[3].rotalist.length > 0 || trainmodel.children[4].rotalist.length > 0|| trainmodel.children[5].rotalist.length > 0){
for(let rs = 1;rs<6;rs++){
//console.log(rs);
if(trainmodel.children[rs].rotalist[0]){
let offsetz = parseFloat(trainmodel.children[rs].rotalist[0].posr.z) - parseFloat(trainmodel.children[rs].matrixWorld.elements[14]);
trainmodel.children[rs].position.z += offsetz;
for(let xh=0;xh<trainmodel.children[rs].rotalist.length;xh++){
if((trainmodel.children[rs].matrixWorld.elements[12]+8)>=trainmodel.children[rs].rotalist[0].posr.x){
if(rs != 5){
let asd = trainmodel.children[rs].rotalist[0];
trainmodel.children[rs+1].rotalist.push(asd);
}
//let offsetx = trainmodel.children[1].matrixWorld.elements[12]-trainmodel.children[0].children[3].matrixWorld.elements[12];
trainmodel.children[rs].rotation.z = trainmodel.children[rs].rotalist[0].rota;
trainmodel.children[rs].rotalist.splice(0,1)
xh--;
}else{
xh = trainmodel.children[rs].rotalist.length;
}
}
//console.log(trainmodel.children[rs].rotalist.length);
}
}
// console.log(trainmodel.rotalist);
}
trainmodel.progress += trainmodel.speeds;
}
}
}
else{
if(trainmodel.status == '02'){
trainmodel.curve = trainmodel.nextcurve;
}else if(trainmodel.status == '03'){
trainmodel.curve = trainmodel.nextcurve;
}
// console.log(trainmodel.name);
// console.log(trainmodel.progress);
// console.log(trainmodel.nextcurve);
// if(trainmodel.status == "02"){
// trainmodel.progress = 0;
// }else if(trainmodel.status == "03"){
// trainmodel.progress = 1;
// }
// trainmodel.curve = trainmodel.nextcurve;
}
}

View File

@ -172,7 +172,7 @@ export default {
init: function (skinCode) {
const mapdata = this.$store.getters['map/map'];
const dom = document.getElementById('app');
this.jlmap3d = new JLmapDriving(dom, mapdata, skinCode);
this.jlmap3d = new JLmapDriving(dom, mapdata, skinCode,this.$store);
this.jlmap3d.eventon();
this.cctvshow = false;

View File

@ -11,7 +11,7 @@
<el-button type="primary" @click="raysignal">{{$t('jlmap3d.turnoutCheck')}}</el-button>
<el-button type="primary" @click="back">{{$t('global.back')}}</el-button>
</el-button-group>
</div>
@ -120,7 +120,7 @@ export default {
console.log('three');
const mapdata = this.$store.getters['map/map'];
const dom = document.getElementById('app');
this.jlmap3d = new JLmap3d(dom, mapdata, skinCode);
this.jlmap3d = new JLmap3d(dom, mapdata, skinCode,this.$store);
this.jlmap3d.eventon();
},
raystand() {

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 307 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.