行车逻辑测试

This commit is contained in:
sunzhenyu 2019-11-08 18:42:37 +08:00
parent 0a77a56196
commit 957f13fd2f
6 changed files with 253 additions and 55 deletions

View File

@ -364,13 +364,52 @@ export function SectionList() {
standsections.push(sectiondata[i]);
}
}
console.log(standsections);
console.log(linklist);
for(let i=0,leni=standsections.length;i<leni;i++){
for(let j=0,lenj=linklist.length;j<lenj;j++){
if(standsections[i].linkCode == linklist[j].code){
for(let n=0,lenn=standsdata.length;n<lenn;n++){
if(standsections[i].relStandCode == standsdata[n].direction1.name){
let geometry = new THREE.CircleGeometry( 2, 16 );
let material = new THREE.MeshBasicMaterial( { color: 0x00ffff } );
console.log(standsections[i].stationCode);
console.log(standsdata[n].code);
console.log(standsdata[n].position.x);
console.log("position.z");
console.log(linkrail[linklist[j].code].points[0].z);
console.log(standsdata[n].position.z);
console.log("........................................");
let circle1 = new THREE.Mesh( geometry, material );
let circle2 = new THREE.Mesh( geometry, material );
if(linkrail[linklist[j].code].points[0].z>standsdata[n].position.z){
circle1.position.x = standsdata[n].position.x-64;
circle1.position.y = 5;
circle1.position.z = linkrail[linklist[j].code].points[0].z;
circle1.rotation.x = -Math.PI/2;
console.log(standsections[i].linkCode);
circle2.position.x = standsdata[n].position.x+64;
circle2.position.y = 5;
circle2.position.z = linkrail[linklist[j].code].points[0].z-(linkrail[linklist[j].code].points[0].z-standsdata[n].position.z)*2;
circle2.rotation.x = -Math.PI/2;
}else{
circle1.position.x = standsdata[n].position.x+64;
circle1.position.y = 5;
circle1.position.z = linkrail[linklist[j].code].points[0].z+(standsdata[n].position.z-linkrail[linklist[j].code].points[0].z)*2;
circle1.rotation.x = -Math.PI/2;
circle2.position.x = standsdata[n].position.x-64;
circle2.position.y = 5;
circle2.position.z = linkrail[linklist[j].code].points[0].z;
circle2.rotation.x = -Math.PI/2;
}
scene.add( circle1 );
scene.add( circle2 );
n = lenn;
}
}
// console.log(standsections[i]);
// console.log(linklist[j]);
// console.log("====================================");
@ -380,7 +419,7 @@ export function SectionList() {
let point1 = linkrail[linklist[j].code].lineleft.getPointAt(progress1);
var geometry = new THREE.CircleGeometry( 3, 16 );
var geometry = new THREE.CircleGeometry( 2, 16 );
var material = new THREE.MeshBasicMaterial( { color: 0xffff00 } );
let circle1 = new THREE.Mesh( geometry, material );
circle1.position.x = point1.x;
@ -396,15 +435,15 @@ export function SectionList() {
circle2.position.z = point2.z;
circle2.rotation.x = -Math.PI/2;
scene.add( circle2 );
console.log(progress1);
console.log(progress2);
console.log(standsections[i].leftStopPointOffset);
console.log(standsections[i].rightStopPointOffset);
console.log(linklist[j].lengthFact);
console.log(linkrail[linklist[j].code].lineleft.points);
console.log(point1);
console.log(point2);
console.log("====================================");
// console.log(progress1);
// console.log(progress2);
// console.log(standsections[i].leftStopPointOffset);
// console.log(standsections[i].rightStopPointOffset);
// console.log(linklist[j].lengthFact);
// console.log(linkrail[linklist[j].code].lineleft.points);
// console.log(point1);
// console.log(point2);
// console.log("====================================");
j = lenj;

View File

@ -217,7 +217,7 @@ export function JLmapDriving(dom,data,mapId,storemod,translation) {
renderercctv.render(scene,cameracctv);
}
//相机按键位移
// controls3.update();
controls3.update();
delta = clock.getDelta();
for (let i=mixers.length-1; i>=0; i--) {
mixers[i].update( delta );

View File

@ -206,10 +206,11 @@ export function Jl3dDriving(updatemmi,sound,translation) {
};
if (trainlisttest.list[code].status == '02') {
syncdata.percent = trainlisttest.list[code].progress;
syncdata.percent = trainlisttest.list[code].progress*trainlisttest.list[code].pc;
} else {
syncdata.percent = 1 - trainlisttest.list[code].progress;
syncdata.percent = (1 - trainlisttest.list[code].progress)*trainlisttest.list[code].pc;
}
// console.log(syncdata);
// console.log(trainlisttest.list[code].nextcurve);
// console.log("=============");
@ -225,12 +226,13 @@ export function Jl3dDriving(updatemmi,sound,translation) {
for (let i=data.body.length-1; i>=0; i--) {
// 遍历列车对象组
if (trainlisttest) {
console.log(data.body[i]);
code = data.body[i].code;
// 剔除不显示的车
// 找到对应列车
if (code == drivingcode) {
driverswitch = data.body[i].runMode;
//更新车组号
updatemmi.updatetrainnum(data.body[i].groupNumber);
@ -321,6 +323,7 @@ export function Jl3dDriving(updatemmi,sound,translation) {
trainlisttest.list[code].nowcode = data.body[i].linkCode;
let vexlist = [];
let endrotation = null;
trainlisttest.list[code].pc = 1;
if (data.body[i].directionType == '02') { // 向右
let point = rails.linkrail[data.body[i].linkCode].lineleft.getPointAt(data.body[i].linkOffsetPercent);
@ -330,7 +333,8 @@ export function Jl3dDriving(updatemmi,sound,translation) {
for (let tl=0; tl<6; tl++) {
trainlisttest.list[code].children[tl].position.z = point.z;
}
trainlisttest.list[code].stopstation = data.body[i].targetStation;
trainlisttest.list[code].pc = data.body[i].targetLinkPercent/rails.stops[data.body[i].targetStation].direct2.percent;
trainlisttest.list[code].status = '02';
trainlisttest.list[code].progress = data.body[i].linkOffsetPercent;
trainlisttest.list[code].curve = rails.linkrail[data.body[i].linkCode].lineleft;
@ -346,7 +350,8 @@ export function Jl3dDriving(updatemmi,sound,translation) {
// console.log("0000000000000000");
// console.log(data.body[i].linkOffsetPercent);
// }
trainlisttest.list[code].stopstation = data.body[i].targetStation;
trainlisttest.list[code].pc = data.body[i].targetLinkPercent/rails.stops[data.body[i].targetStation].direct1.percent;
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;
@ -379,7 +384,7 @@ export function Jl3dDriving(updatemmi,sound,translation) {
trainlisttest.list[code].speed = 0;
trainlisttest.list[code].position.x = -50000;
trainlisttest.list[code].position.y = -50000;
trainlisttest.list[code].pc = 1;
} else if (trainlisttest.list[code].dispose == data.body[i].dispose && data.body[i].dispose == false) {
if (rails.linkrail[data.body[i].linkCode]) {
@ -475,7 +480,21 @@ export function Jl3dDriving(updatemmi,sound,translation) {
// console.log(rails.linkrail[nextcode].lineleft.points);
let nextcode;
if(code == drivingcode){
console.log(data.body[i].targetStation);
console.log("netpercent");
console.log(data.body[i].targetLinkPercent);
console.log(data.body[i].linkOffsetPercent);
console.log("3dpercent");
console.log(rails.stops[data.body[i].targetStation].direct2.percent);
console.log(trainlisttest.list[code].progress);
console.log(trainlisttest.list[code].pc);
console.log("===============");
if(data.body[i].directionType == '02'){
if(trainlisttest.list[code].stopstation != data.body[i].targetStation){
trainlisttest.list[code].stopstation = data.body[i].targetStation;
trainlisttest.list[code].pc = data.body[i].targetLinkPercent/rails.stops[data.body[i].targetStation].direct2.percent;
}
trainlisttest.list[code].status = '02';
nextcode = rails.linkrail[data.body[i].linkCode].rconnect;
if(nextcode){
@ -488,6 +507,11 @@ export function Jl3dDriving(updatemmi,sound,translation) {
trainlisttest.list[code].nextlen = 0;
}
}else if(data.body[i].directionType == '03'){
if(trainlisttest.list[code].stopstation != data.body[i].targetStation){
trainlisttest.list[code].stopstation = data.body[i].targetStation;
trainlisttest.list[code].pc = data.body[i].targetLinkPercent/rails.stops[data.body[i].targetStation].direct1.percent;
}
trainlisttest.list[code].status = '03';
nextcode = rails.linkrail[data.body[i].linkCode].lconnect;
if(nextcode){

View File

@ -96,7 +96,7 @@ export function ModelLoad(data,scope,netdata,mapdata,camera,controls,scene,store
})
.then(function(data){
return new Promise(function(resolve, reject){
jlmap3ddata.rails.init(loaderdata.link,switchdata,sceneload,storemod);
jlmap3ddata.rails.init(loaderdata.link,mapdata.linkList,mapdata.sectionList,switchdata,standsdata,sceneload,storemod);
resolve("loadrail");
});

View File

@ -94,7 +94,7 @@ export function ModelLoad(data,scope,netdata,mapdata,camera,controls,scene,mixer
})
.then(function(data){
return new Promise(function(resolve, reject){
jlmap3ddata.rails.init(loaderdata.link,switchdata,sceneload,storemod);
jlmap3ddata.rails.init(loaderdata.link,mapdata.linkList,mapdata.sectionList,switchdata,standsdata,sceneload,storemod);
resolve("loadrail");
});

View File

@ -5,11 +5,12 @@ export function RailList(){
this.switchrail = [];
this.stops = [];
this.setrail = function(){
};
this.init = function(linkdata,switchdata,scene,storemod){
this.init = function(linkdata,linklist,sectiondata,switchdata,standsdata,scene,storemod){
console.log(linkdata);
for(let i=0;i<linkdata.length;i++){
scope.linkrail[linkdata[i].code] = {
@ -194,41 +195,175 @@ export function RailList(){
rightpoints.reverse();
scope.linkrail[linkdata[i].code].lineright = new THREE.CatmullRomCurve3(rightpoints);
scope.linkrail[linkdata[i].code].lineright.curveType = "centripetal";
for(let n=0,nm=scope.linkrail[linkdata[i].code].lineleft.points.length;n<nm;n++){
var geometry = new THREE.CircleGeometry( 0.05, 16 );
var material = new THREE.MeshBasicMaterial( { color: 0xffff00 } );
var circle = new THREE.Mesh( geometry, material );
console.log(n);
console.log(scope.linkrail[linkdata[i].code].lineleft.points[n]);
circle.position.x = scope.linkrail[linkdata[i].code].lineleft.points[n].x;
circle.position.y = scope.linkrail[linkdata[i].code].lineleft.points[n].y;
circle.position.z = scope.linkrail[linkdata[i].code].lineleft.points[n].z;
circle.rotation.x = -Math.PI/2;
scene.add( circle );
//
// for(let n=0,nm=scope.linkrail[linkdata[i].code].lineleft.points.length;n<nm;n++){
// var geometry = new THREE.CircleGeometry( 0.05, 16 );
// var material = new THREE.MeshBasicMaterial( { color: 0xffff00 } );
// var circle = new THREE.Mesh( geometry, material );
// console.log(n);
// console.log(scope.linkrail[linkdata[i].code].lineleft.points[n]);
// circle.position.x = scope.linkrail[linkdata[i].code].lineleft.points[n].x;
// circle.position.y = scope.linkrail[linkdata[i].code].lineleft.points[n].y;
// circle.position.z = scope.linkrail[linkdata[i].code].lineleft.points[n].z;
// circle.rotation.x = -Math.PI/2;
// scene.add( circle );
// }
// // scope.linkrail[linkdata[i].code].lineright.tension = 0.11;
// var points = scope.linkrail[linkdata[i].code].lineleft.getPoints( 50 );
// var geometry = new THREE.BufferGeometry().setFromPoints( points );
// var material;
// if(scope.linkrail[linkdata[i].code].type == 0){
// material = new THREE.LineBasicMaterial( { color : 0xff0000 } );
// }
// if(scope.linkrail[linkdata[i].code].type == 1){
// material = new THREE.LineBasicMaterial( { color : 0x00ff00 } );
// }
// if(scope.linkrail[linkdata[i].code].type == 2){
// material = new THREE.LineBasicMaterial( { color : 0x0000ff } );
// }
//
//
// // Create the final object to add to the scene
// var curveObject = new THREE.Line( geometry, material );
//
// curveObject.position.y = Math.random();
// scene.add(curveObject);
}
let standsections = [];
for(let i=0,len=sectiondata.length;i<len;i++){
if(sectiondata[i].isStandTrack == true){
standsections.push(sectiondata[i]);
}
// scope.linkrail[linkdata[i].code].lineright.tension = 0.11;
var points = scope.linkrail[linkdata[i].code].lineleft.getPoints( 50 );
var geometry = new THREE.BufferGeometry().setFromPoints( points );
var material;
if(scope.linkrail[linkdata[i].code].type == 0){
material = new THREE.LineBasicMaterial( { color : 0xff0000 } );
}
if(scope.linkrail[linkdata[i].code].type == 1){
material = new THREE.LineBasicMaterial( { color : 0x00ff00 } );
}
if(scope.linkrail[linkdata[i].code].type == 2){
material = new THREE.LineBasicMaterial( { color : 0x0000ff } );
}
// Create the final object to add to the scene
var curveObject = new THREE.Line( geometry, material );
curveObject.position.y = Math.random();
scene.add(curveObject);
}
console.log(standsections);
for(let i=0,leni=standsections.length;i<leni;i++){
for(let j=0,lenj=linklist.length;j<lenj;j++){
if(standsections[i].linkCode == linklist[j].code){
for(let n=0,lenn=standsdata.length;n<lenn;n++){
if(standsections[i].relStandCode == standsdata[n].direction1.name){
let stop = {
code:standsdata[n].code,
direct1:{
percent:null,
},
direct2:{
percent:null,
}
};
let geometry = new THREE.CircleGeometry( 2, 16 );
let material = new THREE.MeshBasicMaterial( { color: 0x00ffff } );
// console.log(standsections[i].stationCode);
// console.log(standsdata[n].code);
// console.log(standsdata[n].position.x);
// console.log("position.z");
// console.log(scope.linkrail[linklist[j].code].points[0].z);
// console.log(standsdata[n].position.z);
// console.log("........................................");
let circle1 = new THREE.Mesh( geometry, material );
let circle2 = new THREE.Mesh( geometry, material );
if(scope.linkrail[linklist[j].code].points[0].z>standsdata[n].position.z){
let num = scope.linkrail[linklist[j].code].lineleft.points.length-1;
let lengthfacts = scope.linkrail[linklist[j].code].lineleft.points[num].x - scope.linkrail[linklist[j].code].lineleft.points[0].x;
stop.direct1.percent = (standsdata[n].position.x-64-scope.linkrail[linklist[j].code].lineleft.points[0].x)/lengthfacts;
stop.direct2.percent = (standsdata[n].position.x+64-scope.linkrail[linklist[j].code].lineleft.points[0].x)/lengthfacts;
console.log(scope.linkrail[linklist[j].code]);
console.log("sectoffsetleft");
console.log(standsections[i].leftStopPointOffset);
console.log(standsdata[n].position.x-64-scope.linkrail[linklist[j].code].lp.x);
console.log(standsdata[n].position.x+64);
console.log(scope.linkrail[linklist[j].code].lineleft.getPointAt(stop.direct2.percent).x);
console.log("sectoffsetright");
console.log(standsections[i].rightStopPointOffset);
console.log(standsdata[n].position.x+64-scope.linkrail[linklist[j].code].lp.x);
console.log(standsdata[n].position.x-64);
console.log(scope.linkrail[linklist[j].code].lineleft.getPointAt(stop.direct1.percent).x);
circle1.position.x = standsdata[n].position.x-64;
circle1.position.y = 5;
circle1.position.z = scope.linkrail[linklist[j].code].points[0].z;
circle1.rotation.x = 0;
circle2.position.x = standsdata[n].position.x+64;
circle2.position.y = 5;
circle2.position.z = scope.linkrail[linklist[j].code].points[0].z-(scope.linkrail[linklist[j].code].points[0].z-standsdata[n].position.z)*2;
circle2.rotation.x = Math.PI/2;
}else{
let num = scope.linkrail[linklist[j].code].lineleft.points.length-1;
let lengthfacts = scope.linkrail[linklist[j].code].lineleft.points[num].x - scope.linkrail[linklist[j].code].lineleft.points[0].x;
stop.direct1.percent = (standsdata[n].position.x-64-scope.linkrail[linklist[j].code].lineleft.points[0].x)/lengthfacts;
stop.direct2.percent = (standsdata[n].position.x+64-scope.linkrail[linklist[j].code].lineleft.points[0].x)/lengthfacts;
console.log(scope.linkrail[linklist[j].code]);
console.log("sectoffsetleft");
console.log(standsections[i].leftStopPointOffset);
console.log(standsdata[n].position.x-64-scope.linkrail[linklist[j].code].lp.x);
console.log(standsdata[n].position.x+64);
console.log(scope.linkrail[linklist[j].code].lineleft.getPointAt(stop.direct2.percent).x);
console.log("sectoffsetright");
console.log(standsections[i].rightStopPointOffset);
console.log(standsdata[n].position.x+64-scope.linkrail[linklist[j].code].lp.x);
console.log(standsdata[n].position.x-64);
console.log(scope.linkrail[linklist[j].code].lineleft.getPointAt(stop.direct1.percent).x);
circle1.position.x = standsdata[n].position.x+64;
circle1.position.y = 5;
circle1.position.z = scope.linkrail[linklist[j].code].points[0].z+(standsdata[n].position.z-scope.linkrail[linklist[j].code].points[0].z)*2;
circle1.rotation.x = 0;
circle2.position.x = standsdata[n].position.x-64;
circle2.position.y = 5;
circle2.position.z = scope.linkrail[linklist[j].code].points[0].z;
circle2.rotation.x = Math.PI;
}
scene.add( circle1 );
scene.add( circle2 );
scope.stops[standsdata[n].code] = stop;
n = lenn;
}
}
// console.log(standsections[i]);
// console.log(linklist[j]);
// console.log("====================================");
let progress1 = standsections[i].leftStopPointOffset/linklist[j].lengthFact;
let progress2 = standsections[i].rightStopPointOffset/linklist[j].lengthFact;
let point1 = scope.linkrail[linklist[j].code].lineleft.getPointAt(progress1);
var geometry = new THREE.CircleGeometry( 2, 16 );
var material = new THREE.MeshBasicMaterial( { color: 0xffff00 } );
let circle1 = new THREE.Mesh( geometry, material );
circle1.position.x = point1.x;
circle1.position.y = point1.y;
circle1.position.z = point1.z;
circle1.rotation.x = -Math.PI/2;
scene.add( circle1 );
let point2 = scope.linkrail[linklist[j].code].lineleft.getPointAt(progress2);
let circle2 = new THREE.Mesh( geometry, material );
circle2.position.x = point2.x;
circle2.position.y = point2.y;
circle2.position.z = point2.z;
circle2.rotation.x = -Math.PI/2;
scene.add( circle2 );
// console.log(progress1);
// console.log(progress2);
// console.log(standsections[i].leftStopPointOffset);
// console.log(standsections[i].rightStopPointOffset);
// console.log(linklist[j].lengthFact);
// console.log(linkrail[linklist[j].code].lineleft.points);
// console.log(point1);
// console.log(point2);
// console.log("====================================");
j = lenj;
}
}
}
}
this.getrail = function(){