修复路径判断

This commit is contained in:
sunzhenyu 2019-10-18 15:29:17 +08:00
parent 4a8e5a9cb2
commit a7e7988754
5 changed files with 84 additions and 66 deletions

View File

@ -431,6 +431,7 @@ export function Jl3dDriving(updatemmi,sound) {
trainlisttest.list[code].curve = rails.linkrail[data.body[i].linkCode].lineleft;
trainlisttest.list[code].nextcurve = null;
}
trainlisttest.list[code].len = rails.linkrail[data.body[i].linkCode].lengthfact;
} else if (data.body[i].directionType == '03') { // 向左
@ -449,54 +450,10 @@ export function Jl3dDriving(updatemmi,sound) {
trainlisttest.list[code].nextcurve = null;
}
trainlisttest.list[code].len = rails.linkrail[data.body[i].linkCode].lengthfact;
}
trainlisttest.list[code].len = rails.linkrail[data.body[i].linkCode].lengthfact;
if(trainlisttest.list[code].nextcurve == null){
if(code != drivingcode){
let nextcode;
if(data.body[i].directionType == '02'){
if(rails.linkrail[data.body[i].linkCode].lineleft){
trainlisttest.list[code].status = '02';
trainlisttest.list[code].curve = rails.linkrail[data.body[i].linkCode].lineleft;
trainlisttest.list[code].len = rails.linkrail[data.body[i].linkCode].lengthfact;
trainlisttest.list[code].progress = data.body[i].linkOffsetPercent;
trainlisttest.list[code].speeds = parseFloat(trainlisttest.list[code].speed*10/36/21/trainlisttest.list[code].len);
}
}else if(data.body[i].directionType == '03'){
if(rails.linkrail[data.body[i].linkCode].lineright){
trainlisttest.list[code].status = '03';
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].progress = 1-data.body[i].linkOffsetPercent;
trainlisttest.list[code].speeds = parseFloat(trainlisttest.list[code].speed*10/36/21/trainlisttest.list[code].len);
}
}
trainlisttest.list[code].nextcode = nextcode;
}else{
let nextcode;
if(data.body[i].directionType == '02'){
trainlisttest.list[code].status = '02';
nextcode = rails.linkrail[data.body[i].linkCode].rconnect;
if(nextcode){
trainlisttest.list[code].nextcurve = rails.linkrail[nextcode].lineleft;
trainlisttest.list[code].nextlen = rails.linkrail[nextcode].lengthfact;
}
}else if(data.body[i].directionType == '03'){
trainlisttest.list[code].status = '03';
nextcode = rails.linkrail[data.body[i].linkCode].lconnect;
if(nextcode){
trainlisttest.list[code].nextcurve = rails.linkrail[nextcode].lineright;
trainlisttest.list[code].nextlen = rails.linkrail[nextcode].lengthfact;
}
}
trainlisttest.list[code].nextcode = nextcode;
}
// console.log(data.body[i].directionType);
// console.log(data.body[i].linkCode);
@ -512,7 +469,54 @@ export function Jl3dDriving(updatemmi,sound) {
// console.log("***********************");
// console.log(rails.linkrail[nextcode].lineleft.points);
if(code == drivingcode){
let nextcode;
if(data.body[i].directionType == '02'){
trainlisttest.list[code].status = '02';
nextcode = rails.linkrail[data.body[i].linkCode].rconnect;
if(nextcode){
trainlisttest.list[code].nextcurve = rails.linkrail[nextcode].lineleft;
trainlisttest.list[code].nextlen = rails.linkrail[nextcode].lengthfact;
}
}else if(data.body[i].directionType == '03'){
trainlisttest.list[code].status = '03';
nextcode = rails.linkrail[data.body[i].linkCode].lconnect;
if(nextcode){
trainlisttest.list[code].nextcurve = rails.linkrail[nextcode].lineright;
trainlisttest.list[code].nextlen = rails.linkrail[nextcode].lengthfact;
}
}
trainlisttest.list[code].nextcode = nextcode;
// console.log(trainlisttest.list[code].nowcode);
// console.log(trainlisttest.list[code].nextcode);
// console.log(trainlisttest.list[code].curve.points);
// console.log(trainlisttest.list[code].nextcurve.points);
// console.log("=========================");
}else{
let nextcode;
if(data.body[i].directionType == '02'){
if(rails.linkrail[data.body[i].linkCode].lineleft){
trainlisttest.list[code].status = '02';
trainlisttest.list[code].curve = rails.linkrail[data.body[i].linkCode].lineleft;
trainlisttest.list[code].len = rails.linkrail[data.body[i].linkCode].lengthfact;
trainlisttest.list[code].progress = data.body[i].linkOffsetPercent;
trainlisttest.list[code].speeds = parseFloat(trainlisttest.list[code].speed*10/36/21/trainlisttest.list[code].len);
}
}else if(data.body[i].directionType == '03'){
if(rails.linkrail[data.body[i].linkCode].lineright){
trainlisttest.list[code].status = '03';
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].progress = 1-data.body[i].linkOffsetPercent;
trainlisttest.list[code].speeds = parseFloat(trainlisttest.list[code].speed*10/36/21/trainlisttest.list[code].len);
}
}
trainlisttest.list[code].nextcode = nextcode;
}
@ -683,7 +687,9 @@ export function Jl3dDriving(updatemmi,sound) {
for (let j=sectionlist.switchs.modellist.length-1; j>=0; j--) {
if (rails.switchrail[code]) {
if (rails.switchrail[code].locateType != data.locateType) {
console.log("道岔变化:"+code);
if (data.locateType == '02') {
console.log("02 反位");
if (actions[sectionlist.switchs.modellist[j].code]) {
sectionlist.switchs.modellist[j].locateType = data.locateType;
actions[sectionlist.switchs.modellist[j].code].reset();
@ -696,14 +702,21 @@ export function Jl3dDriving(updatemmi,sound) {
let testswitch = rails.switchrail[code];
if(rails.switchrail[code].directtype == "1"){
console.log("道岔朝向1向左");
console.log("aleft:"+testswitch.clink);
console.log("cright:"+testswitch.alink);
rails.linkrail[testswitch.alink].lconnect = testswitch.clink;
rails.linkrail[testswitch.clink].rconnect = testswitch.alink;
}else if(rails.switchrail[code].directtype == "2"){
console.log("道岔朝向2向右");
console.log("aright:"+testswitch.clink);
console.log("cleft:"+testswitch.alink);
rails.linkrail[testswitch.alink].rconnect = testswitch.clink;
rails.linkrail[testswitch.clink].lconnect = testswitch.alink;
}
} else if (data.locateType == '01') {
console.log("01 定位");
if (actions[sectionlist.switchs.modellist[j].code]) {
sectionlist.switchs.modellist[j].locateType = data.locateType;
actions[sectionlist.switchs.modellist[j].code].reset();
@ -715,9 +728,15 @@ export function Jl3dDriving(updatemmi,sound) {
rails.switchrail[code].locateType = "01";
let testswitch = rails.switchrail[code];
if(rails.switchrail[code].directtype == "1"){
console.log("道岔朝向1向左");
console.log("aleft"+testswitch.blink);
console.log("cright:"+testswitch.alink);
rails.linkrail[testswitch.alink].lconnect = testswitch.blink;
rails.linkrail[testswitch.blink].rconnect = testswitch.alink;
}else if(rails.switchrail[code].directtype == "2"){
console.log("道岔朝向2向右");
console.log("aright:"+testswitch.blink);
console.log("cleft:"+testswitch.alink);
rails.linkrail[testswitch.alink].rconnect = testswitch.blink;
rails.linkrail[testswitch.blink].lconnect = testswitch.alink;
}

View File

@ -44,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;
@ -290,10 +290,10 @@ export function Jlmap3dSubscribe(jlmap3d) {
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);
}
// 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;
@ -600,9 +600,9 @@ export function Jlmap3dSubscribe(jlmap3d) {
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]);
// 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;

View File

@ -65,7 +65,7 @@ export function ModelLoad(data,scope,netdata,mapdata,camera,controls,scene,store
let switchdata = JSON.parse(netdata.switchs);
let signaldata = JSON.parse(netdata.signals);
let standsdata = JSON.parse(netdata.stands);
console.log(netdata.assets);
// console.log(netdata.assets);
assetloader.setmodellist(netdata.assets);
assetloader.assetpromise(sceneload)
@ -102,13 +102,13 @@ export function ModelLoad(data,scope,netdata,mapdata,camera,controls,scene,store
});
})
.then(function(data){
for(let mn=0;mn<scope.assetloader.modellist.length;mn++){
if(scope.assetloader.modellist[mn].name && scope.assetloader.modellist[mn].name == "suidao"){
// scope.assetloader.modellist[mn].mesh.rotation.x = Math.PI/2;
console.log(scope.assetloader.modellist[mn].mesh.position);
scene.add(scope.assetloader.modellist[mn].mesh);
}
}
// for(let mn=0;mn<scope.assetloader.modellist.length;mn++){
// if(scope.assetloader.modellist[mn].name && scope.assetloader.modellist[mn].name == "suidao"){
// // scope.assetloader.modellist[mn].mesh.rotation.x = Math.PI/2;
// console.log(scope.assetloader.modellist[mn].mesh.position);
// scene.add(scope.assetloader.modellist[mn].mesh);
// }
// }
scope.animateswitch = true;

View File

@ -32,9 +32,9 @@ export function UpdateTrain(camera,traindata){
trainmodel.children[0].rotation.z = trainmodel.children[0].rotation.y;
trainmodel.children[0].rotation.y = 0;
console.log(trainmodel.children[0].rotation.x);
console.log(trainmodel.children[0].rotation.y);
console.log(trainmodel.children[0].rotation.z);
// 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
@ -147,7 +147,7 @@ export function UpdateTrain(camera,traindata){
}
else{
if(trainmodel.status == '02'){
trainmodel.curve = trainmodel.nextcurve;
}else if(trainmodel.status == '03'){

View File

@ -117,7 +117,6 @@ export default {
}
},
init: function (skinCode) {
console.log('three');
const mapdata = this.$store.getters['map/map'];
const dom = document.getElementById('app');
this.jlmap3d = new JLmap3d(dom, mapdata, skinCode,this.$store);