修改路劲判断函数,区分仿真和沙盘加载显示内容,测试站台模型

This commit is contained in:
sunzhenyu 2019-11-04 18:57:35 +08:00
parent 2a39905de3
commit 4532446048
14 changed files with 269 additions and 160 deletions

View File

@ -159,13 +159,13 @@ export function Jl3dDriving(updatemmi,sound,translation) {
if (trainlisttest.list[code].runMode == '02') {
if (trainlisttest.list[code].isStandTrack == true) {
trainlisttest.list[code].speeds = parseFloat(data.body[tl].v*10/36/24/trainlisttest.list[code].len);
trainlisttest.list[code].speeds = parseFloat(data.body[tl].v*10/36/25/trainlisttest.list[code].len);
} else {
trainlisttest.list[code].speeds = parseFloat(data.body[tl].v*10/36/24/trainlisttest.list[code].len);
trainlisttest.list[code].speeds = parseFloat(data.body[tl].v*10/36/25/trainlisttest.list[code].len);
}
} else {
trainlisttest.list[code].speeds = parseFloat(data.body[tl].v*10/36/24/trainlisttest.list[code].len);
trainlisttest.list[code].speeds = parseFloat(data.body[tl].v*10/36/25/trainlisttest.list[code].len);
}
if (code == drivingcode) {
@ -309,7 +309,7 @@ export function Jl3dDriving(updatemmi,sound,translation) {
if (trainlisttest.list[code].dispose != data.body[i].dispose && data.body[i].dispose == false) {
if (rails.linkrail[data.body[i].linkCode]) {
console.log(trainlisttest.group);
// console.log(trainlisttest.group);
if(trainlisttest.group.children.length<1){
trainlisttest.group.add(trainlisttest.list[code]);
}
@ -363,7 +363,7 @@ export function Jl3dDriving(updatemmi,sound,translation) {
// 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/24/trainlisttest.list[code].len);
trainlisttest.list[code].speeds = parseFloat(data.body[i].speed*10/36/25/trainlisttest.list[code].len);
}
@ -421,7 +421,41 @@ export function Jl3dDriving(updatemmi,sound,translation) {
}
}
if (trainlisttest.list[code].status != data.body[i].directionType) {
if (data.body[i].directionType == '02') { // 向右
trainlisttest.list[code].progress = 0;
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;
trainlisttest.list[code].nextcurve = null;
trainlisttest.list[code].len = rails.linkrail[data.body[i].linkCode].lengthfact;
} else if (data.body[i].directionType == '03') { // 向左
trainlisttest.list[code].progress = 0;
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;
trainlisttest.list[code].nextcurve = null;
trainlisttest.list[code].len = rails.linkrail[data.body[i].linkCode].lengthfact;
}
}
@ -485,7 +519,7 @@ export function Jl3dDriving(updatemmi,sound,translation) {
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/24/trainlisttest.list[code].len);
trainlisttest.list[code].speeds = parseFloat(trainlisttest.list[code].speed*10/36/25/trainlisttest.list[code].len);
}
}else if(data.body[i].directionType == '03'){
if(rails.linkrail[data.body[i].linkCode].lineright){
@ -499,7 +533,7 @@ export function Jl3dDriving(updatemmi,sound,translation) {
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/24/trainlisttest.list[code].len);
trainlisttest.list[code].speeds = parseFloat(trainlisttest.list[code].speed*10/36/25/trainlisttest.list[code].len);
}
}
trainlisttest.list[code].nextcode = nextcode;

View File

@ -19,8 +19,9 @@ export function UpdateTrain(camera,traindata,control){
if(trainmodel.status == "03"){
if(movecurve.points.length>1){
let point = movecurve.getPointAt(traindata.group.children[0].progress);
if(Math.abs( point.z -trainmodel.children[0].matrixWorld.elements[14]) >0.001){
trainmodel.position.x = point.x;
trainmodel.position.y = 0;
if(Math.abs( point.z -trainmodel.children[0].matrixWorld.elements[14]) >0.005){
trainmodel.children[0].up = new THREE.Vector3(-1,0,0);
let tangent = movecurve.getTangentAt(traindata.group.children[0].progress).normalize();
trainmodel.children[0].axis.crossVectors(trainmodel.children[0].up, tangent).normalize();
@ -37,7 +38,8 @@ export function UpdateTrain(camera,traindata,control){
let offsetz = parseFloat(trainmodel.children[0].matrixWorld.elements[14]) - parseFloat(point.z);
trainmodel.children[0].position.z += offsetz;
//trainmodel.position.z = point.z;
// trainmodel.position.z = point.z;
}
trainmodel.position.x = point.x;
@ -52,7 +54,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]-6)<=trainmodel.children[rs].rotalist[0].posr.x){
if((trainmodel.children[rs].matrixWorld.elements[12]-10)<=trainmodel.children[rs].rotalist[0].posr.x){
if(rs != 5){
let asd = trainmodel.children[rs].rotalist[0];
@ -78,8 +80,9 @@ 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.001){
trainmodel.position.x = point.x;
trainmodel.position.y = 0;
if(Math.abs( point.z -trainmodel.children[0].matrixWorld.elements[14]) >0.005){
trainmodel.children[0].up = new THREE.Vector3(1,0,0);
let tangent = movecurve.getTangentAt(traindata.group.children[0].progress).normalize();
trainmodel.children[0].axis.crossVectors(trainmodel.children[0].up, tangent).normalize();
@ -94,12 +97,13 @@ export function UpdateTrain(camera,traindata,control){
}
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.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++){
@ -110,7 +114,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]+6)>=trainmodel.children[rs].rotalist[0].posr.x){
if((trainmodel.children[rs].matrixWorld.elements[12]+10)>=trainmodel.children[rs].rotalist[0].posr.x){
if(rs != 5){
let asd = trainmodel.children[rs].rotalist[0];
@ -146,7 +150,7 @@ export function UpdateTrain(camera,traindata,control){
trainmodel.progress = 0;
trainmodel.len = trainmodel.nextlen;
trainmodel.nowcode = trainmodel.nextcode;
trainmodel.speeds = parseFloat(trainmodel.speed*10/36/24/trainmodel.len);
trainmodel.speeds = parseFloat(trainmodel.speed*10/36/25/trainmodel.len);
trainmodel.curve = trainmodel.nextcurve;
trainmodel.nextcurve = null;
@ -178,7 +182,7 @@ export function UpdateTrain(camera,traindata,control){
if(trainmodel.status == "03" && trainmodel.progress>0){
if(movecurve.points.length>1){
let point = movecurve.getPointAt(traindata.group.children[0].progress);
if(Math.abs( point.z -trainmodel.children[0].matrixWorld.elements[14]) >0.01){
if(Math.abs( point.z -trainmodel.children[0].matrixWorld.elements[14]) >0.005){
trainmodel.children[0].up = new THREE.Vector3(-1,0,0);
let tangent = movecurve.getTangentAt(traindata.group.children[0].progress).normalize();
trainmodel.children[0].axis.crossVectors(trainmodel.children[0].up, tangent).normalize();
@ -210,7 +214,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]-6)<=trainmodel.children[rs].rotalist[0].posr.x){
if((trainmodel.children[rs].matrixWorld.elements[12]-9)<=trainmodel.children[rs].rotalist[0].posr.x){
if(rs != 5){
let asd = trainmodel.children[rs].rotalist[0];
@ -240,7 +244,7 @@ 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.01){
if(Math.abs( point.z -trainmodel.children[0].matrixWorld.elements[14]) >0.005){
trainmodel.children[0].up = new THREE.Vector3(1,0,0);
let tangent = movecurve.getTangentAt(traindata.group.children[0].progress).normalize();
trainmodel.children[0].axis.crossVectors(trainmodel.children[0].up, tangent).normalize();

View File

@ -114,13 +114,13 @@ export function Jlmap3dSubscribe(jlmap3d) {
trainlisttest.list[code].speed = data.body[tl].v;
if (trainlisttest.list[code].runMode == '02') {
if (trainlisttest.list[code].isStandTrack == true) {
trainlisttest.list[code].speeds = parseFloat(data.body[tl].v*10/36/17/trainlisttest.list[code].len);
trainlisttest.list[code].speeds = parseFloat(data.body[tl].v*10/36/20/trainlisttest.list[code].len);
} else {
trainlisttest.list[code].speeds = parseFloat(data.body[tl].v*10/36/21/trainlisttest.list[code].len);
trainlisttest.list[code].speeds = parseFloat(data.body[tl].v*10/36/20/trainlisttest.list[code].len);
}
} else {
trainlisttest.list[code].speeds = parseFloat(data.body[tl].v*10/36/21/trainlisttest.list[code].len);
trainlisttest.list[code].speeds = parseFloat(data.body[tl].v*10/36/20/trainlisttest.list[code].len);
}
if (code == drivingcode) {
@ -313,7 +313,7 @@ export function Jlmap3dSubscribe(jlmap3d) {
// 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);
trainlisttest.list[code].speeds = parseFloat(data.body[i].speed*10/36/20/trainlisttest.list[code].len);
}
}
@ -622,9 +622,9 @@ export function Jlmap3dSubscribe(jlmap3d) {
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]);
// 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;

View File

@ -34,8 +34,9 @@ let defaultstation = {
deviceType:"stand",
type:"num4",
picUrl:"",
assetUrl:modelurl+"/models/station/fuzhou/fuzhou.FBX"
assetUrl:"../../static/model/station/fuzhou.FBX"
}
//modelurl+"/models/station/fuzhou/fuzhou.FBX"
//https://test.joylink.club/oss/models/station/fuzhou/fuzhou.FBX
//https://joylink.club/oss/models/station/fuzhou/fuzhou.FBX
//../../static/model/station/zhantai715(2).FBX
@ -112,11 +113,16 @@ export function AssetLoader(){
this.name = null;
this.trainoffset = 0;
this.modellist = [];
this.materiallist = [];
//初始化资源加载器
this.setmodellist = function (data){
this.setmodellist = function (data,trainoffset){
if(trainoffset){
scope.trainoffset = trainoffset;
}
// console.log("setmodellist");
let defaultmodel1 = new AssetModel(defaultsignal);
scope.modellist.push(defaultmodel1);
@ -464,7 +470,8 @@ 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;
object.children[i].position.x = object.children[i].position.x+scope.trainoffset;
//object.children[i].position.y = j*10;
realtrain.add(object.children[i]);
i--;

View File

@ -554,7 +554,7 @@ THREE.FBXLoader = ( function () {
if(materialNode.Opacity.value<1 && materialNode.Opacity.value>0.9){
parameters.side = THREE.DoubleSide;
parameters.transparent = true;
parameters.alphaTest = 0.7;
// parameters.alphaTest = 0.7;
parameters.opacity = 1;
}else{
@ -567,7 +567,7 @@ THREE.FBXLoader = ( function () {
if(materialNode.Opacity.value<1 && materialNode.Opacity.value>0.9){
parameters.side = THREE.DoubleSide;
parameters.transparent = true;
parameters.alphaTest = 0.7;
// parameters.alphaTest = 0.7;
parameters.opacity = 1;
}else{
parameters.opacity = parseFloat( materialNode.Opacity.value );
@ -577,7 +577,7 @@ THREE.FBXLoader = ( function () {
if ( parameters.opacity < 1.0 ) {
parameters.transparent = true;
parameters.alphaTest = 0.1;
// parameters.alphaTest = 0.1;
}
if ( materialNode.ReflectionFactor ) {

View File

@ -66,7 +66,7 @@ export function ModelLoad(data,scope,netdata,mapdata,camera,controls,scene,store
let signaldata = JSON.parse(netdata.signals);
let standsdata = JSON.parse(netdata.stands);
// console.log(netdata.assets);
assetloader.setmodellist(netdata.assets);
assetloader.setmodellist(netdata.assets,5);
assetloader.assetpromise(sceneload)
.then(function(data){
@ -75,12 +75,12 @@ export function ModelLoad(data,scope,netdata,mapdata,camera,controls,scene,store
})
.then(function(data){
//console.log(data);
return jlmap3ddata.stationstandlist.initpromise(mapdata.stationList,mapdata.stationStandList,sceneload,assetloader,netdata.stands,mixers,actions);
return jlmap3ddata.stationstandlist.initpromise(mapdata.stationList,mapdata.stationStandList,sceneload,assetloader,netdata.stands,mixers,actions,"02");
})
.then(function(data){
//console.log(data);
//console.log(assetloader);
return jlmap3ddata.trainlisttest.initpromise(mapdata.trainList,sceneload,assetloader,mixers,actions);
return jlmap3ddata.trainlisttest.initpromise(mapdata.trainList,sceneload,assetloader,mixers,actions,"02");
})
.then(function(data){
//console.log(data);

View File

@ -73,12 +73,12 @@ export function ModelLoad(data,scope,netdata,mapdata,camera,controls,scene,mixer
})
.then(function(data){
//console.log(data);
return jlmap3ddata.stationstandlist.initpromise(mapdata.stationList,mapdata.stationStandList,sceneload,assetloader,netdata.stands,mixers,actions);
return jlmap3ddata.stationstandlist.initpromise(mapdata.stationList,mapdata.stationStandList,sceneload,assetloader,netdata.stands,mixers,actions,"0");
})
.then(function(data){
//console.log(data);
//console.log(assetloader);
return jlmap3ddata.trainlisttest.initpromise(mapdata.trainList,sceneload,assetloader,mixers,actions);
return jlmap3ddata.trainlisttest.initpromise(mapdata.trainList,sceneload,assetloader,mixers,actions,"0");
})
.then(function(data){
//console.log(data);

View File

@ -23,24 +23,8 @@ export function RailList(){
points:[],
type:null
};
if(linkdata[i].rotation._z == 0){
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(scope.linkrail[linkdata[i].code].lp.x+2,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-2,0,scope.linkrail[linkdata[i].code].rp.z));
scope.linkrail[linkdata[i].code].type = 0;
}else{
if(linkdata[i].rotation._z>0){
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(scope.linkrail[linkdata[i].code].lp.x+2.2,0,scope.linkrail[linkdata[i].code].lp.z-0.2));
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(scope.linkrail[linkdata[i].code].rp.x-2.2,0,scope.linkrail[linkdata[i].code].rp.z+0.2));
scope.linkrail[linkdata[i].code].type = 1;
}else{
scope.linkrail[linkdata[i].code].type = 2;
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(scope.linkrail[linkdata[i].code].lp.x+2.2,0,scope.linkrail[linkdata[i].code].lp.z+0.2));
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(scope.linkrail[linkdata[i].code].rp.x-2.2,0,scope.linkrail[linkdata[i].code].rp.z-0.2));
}
}
}
for(let i=0;i<switchdata.length;i++){
scope.switchrail[switchdata[i].code] = {
alink:switchdata[i].alink,
@ -52,64 +36,86 @@ export function RailList(){
};
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-1,switchdata[i].position.y,switchdata[i].position.z));
scope.linkrail[switchdata[i].blink].points.push(new THREE.Vector3(switchdata[i].position.x,switchdata[i].position.y,switchdata[i].position.z));
if(scope.linkrail[switchdata[i].alink].type == 1){
scope.linkrail[switchdata[i].blink].points.push(new THREE.Vector3(scope.linkrail[switchdata[i].alink].lp.x+1.1,0,scope.linkrail[switchdata[i].alink].lp.z-0.1));
scope.linkrail[switchdata[i].blink].points.push(new THREE.Vector3(scope.linkrail[switchdata[i].alink].lp.x+2.2,0,scope.linkrail[switchdata[i].alink].lp.z-0.2));
}else if(scope.linkrail[switchdata[i].alink].type == 2){
scope.linkrail[switchdata[i].blink].points.push(new THREE.Vector3(scope.linkrail[switchdata[i].alink].lp.x+1.1,0,scope.linkrail[switchdata[i].alink].lp.z+0.1));
scope.linkrail[switchdata[i].blink].points.push(new THREE.Vector3(scope.linkrail[switchdata[i].alink].lp.x+2.2,0,scope.linkrail[switchdata[i].alink].lp.z+0.2));
}else{
scope.linkrail[switchdata[i].blink].points.push(new THREE.Vector3(scope.linkrail[switchdata[i].alink].lp.x+2,0,scope.linkrail[switchdata[i].alink].lp.z));
}
scope.switchrail[switchdata[i].code].directtype = "1";
scope.linkrail[switchdata[i].alink].lswitch = switchdata[i].code;
scope.linkrail[switchdata[i].blink].rswitch = switchdata[i].code;
}else{
scope.linkrail[switchdata[i].blink].points.splice(0,0,new THREE.Vector3(switchdata[i].position.x+1,switchdata[i].position.y,switchdata[i].position.z));
scope.linkrail[switchdata[i].blink].points.splice(0,0,new THREE.Vector3(switchdata[i].position.x,switchdata[i].position.y,switchdata[i].position.z));
if(scope.linkrail[switchdata[i].alink].type == 1){
scope.linkrail[switchdata[i].blink].points.splice(0,0,new THREE.Vector3(scope.linkrail[switchdata[i].alink].rp.x-1.1,0,scope.linkrail[switchdata[i].alink].rp.z+0.1));
scope.linkrail[switchdata[i].blink].points.splice(0,0,new THREE.Vector3(scope.linkrail[switchdata[i].alink].rp.x-2.2,0,scope.linkrail[switchdata[i].alink].rp.z+0.2));
}else if(scope.linkrail[switchdata[i].alink].type == 2){
scope.linkrail[switchdata[i].blink].points.splice(0,0,new THREE.Vector3(scope.linkrail[switchdata[i].alink].rp.x-1.1,0,scope.linkrail[switchdata[i].alink].rp.z-0.1));
scope.linkrail[switchdata[i].blink].points.splice(0,0,new THREE.Vector3(scope.linkrail[switchdata[i].alink].rp.x-2.2,0,scope.linkrail[switchdata[i].alink].rp.z-0.2));
}else{
scope.linkrail[switchdata[i].blink].points.splice(0,0,new THREE.Vector3(scope.linkrail[switchdata[i].alink].rp.x-2,0,scope.linkrail[switchdata[i].alink].rp.z));
}
scope.switchrail[switchdata[i].code].directtype = "2";
scope.linkrail[switchdata[i].alink].rswitch = switchdata[i].code;
scope.linkrail[switchdata[i].blink].lswitch = switchdata[i].code;
}
//
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-1,switchdata[i].position.y,switchdata[i].position.z));
scope.linkrail[switchdata[i].clink].points.push(new THREE.Vector3(switchdata[i].position.x,switchdata[i].position.y,switchdata[i].position.z));
if(scope.linkrail[switchdata[i].alink].type == 1){
scope.linkrail[switchdata[i].clink].points.push(new THREE.Vector3(switchdata[i].position.x+1,switchdata[i].position.y,switchdata[i].position.z-0.11));
scope.linkrail[switchdata[i].clink].points.push(new THREE.Vector3(scope.linkrail[switchdata[i].alink].lp.x+1.1,0,scope.linkrail[switchdata[i].alink].lp.z-0.1));
scope.linkrail[switchdata[i].clink].points.push(new THREE.Vector3(scope.linkrail[switchdata[i].alink].lp.x+2.2,0,scope.linkrail[switchdata[i].alink].lp.z-0.2));
}else if(scope.linkrail[switchdata[i].alink].type == 2){
scope.linkrail[switchdata[i].clink].points.push(new THREE.Vector3(switchdata[i].position.x+1,switchdata[i].position.y,switchdata[i].position.z+0.11));
scope.linkrail[switchdata[i].clink].points.push(new THREE.Vector3(scope.linkrail[switchdata[i].alink].lp.x+1.1,0,scope.linkrail[switchdata[i].alink].lp.z+0.1));
scope.linkrail[switchdata[i].clink].points.push(new THREE.Vector3(scope.linkrail[switchdata[i].alink].lp.x+2.2,0,scope.linkrail[switchdata[i].alink].lp.z+0.2));
}else{
scope.linkrail[switchdata[i].clink].points.push(new THREE.Vector3(scope.linkrail[switchdata[i].alink].lp.x+2,0,scope.linkrail[switchdata[i].alink].lp.z));
}
scope.switchrail[switchdata[i].code].directtype = "1";
scope.linkrail[switchdata[i].alink].lswitch = switchdata[i].code;
scope.linkrail[switchdata[i].clink].rswitch = switchdata[i].code;
}else{
scope.linkrail[switchdata[i].clink].points.splice(0,0,new THREE.Vector3(switchdata[i].position.x+1,switchdata[i].position.y,switchdata[i].position.z));
scope.linkrail[switchdata[i].clink].points.splice(0,0,new THREE.Vector3(switchdata[i].position.x,switchdata[i].position.y,switchdata[i].position.z));
if(scope.linkrail[switchdata[i].alink].type == 1){
scope.linkrail[switchdata[i].clink].points.splice(0,0,new THREE.Vector3(switchdata[i].position.x-1,switchdata[i].position.y,switchdata[i].position.z+0.11));
scope.linkrail[switchdata[i].clink].points.splice(0,0,new THREE.Vector3(scope.linkrail[switchdata[i].alink].rp.x-1.1,0,scope.linkrail[switchdata[i].alink].rp.z+0.1));
scope.linkrail[switchdata[i].clink].points.splice(0,0,new THREE.Vector3(scope.linkrail[switchdata[i].alink].rp.x-2.2,0,scope.linkrail[switchdata[i].alink].rp.z+0.2));
}else if(scope.linkrail[switchdata[i].alink].type == 2){
scope.linkrail[switchdata[i].clink].points.splice(0,0,new THREE.Vector3(switchdata[i].position.x-1,switchdata[i].position.y,switchdata[i].position.z-0.11));
scope.linkrail[switchdata[i].clink].points.splice(0,0,new THREE.Vector3(scope.linkrail[switchdata[i].alink].rp.x-1.1,0,scope.linkrail[switchdata[i].alink].rp.z-0.1));
scope.linkrail[switchdata[i].clink].points.splice(0,0,new THREE.Vector3(scope.linkrail[switchdata[i].alink].rp.x-2.2,0,scope.linkrail[switchdata[i].alink].rp.z-0.2));
}else{
scope.linkrail[switchdata[i].clink].points.splice(0,0,new THREE.Vector3(scope.linkrail[switchdata[i].alink].rp.x-2,0,scope.linkrail[switchdata[i].alink].rp.z));
}
scope.switchrail[switchdata[i].code].directtype = "2";
scope.linkrail[switchdata[i].alink].rswitch = switchdata[i].code;
scope.linkrail[switchdata[i].clink].lswitch = switchdata[i].code;
}
}
for(let i=0;i<linkdata.length;i++){
if(linkdata[i].rotation._z == 0){
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(scope.linkrail[linkdata[i].code].lp.x+1.5,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-1.5,0,scope.linkrail[linkdata[i].code].rp.z));
scope.linkrail[linkdata[i].code].type = 0;
}else{
if(linkdata[i].rotation._z>0){
let testline = new THREE.CatmullRomCurve3([
new THREE.Vector3(scope.linkrail[linkdata[i].code].lp.x,0,scope.linkrail[linkdata[i].code].lp.z),
new THREE.Vector3(scope.linkrail[linkdata[i].code].rp.x,0,scope.linkrail[linkdata[i].code].rp.z)
]);
scope.linkrail[linkdata[i].code].type = 1;
if(scope.linkrail[linkdata[i].code].lswitch){
let switchpoint = scope.switchrail[scope.linkrail[linkdata[i].code].lswitch].position;
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x+1.5,0,switchpoint.z));
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x+2,0,switchpoint.z));
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x+5,0,switchpoint.z-0.05));
}
scope.linkrail[linkdata[i].code].points.push(testline.getPointAt(0.12));
scope.linkrail[linkdata[i].code].points.push(testline.getPointAt(0.22));
scope.linkrail[linkdata[i].code].points.push(testline.getPointAt(0.82));
scope.linkrail[linkdata[i].code].points.push(testline.getPointAt(0.92));
if(scope.linkrail[linkdata[i].code].rswitch){
let switchpoint = scope.switchrail[scope.linkrail[linkdata[i].code].rswitch].position;
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x-5,0,switchpoint.z+0.05));
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x-2,0,switchpoint.z));
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x-1.5,0,switchpoint.z));
}
}else{
let testline = new THREE.CatmullRomCurve3([
new THREE.Vector3(scope.linkrail[linkdata[i].code].lp.x,0,scope.linkrail[linkdata[i].code].lp.z),
new THREE.Vector3(scope.linkrail[linkdata[i].code].rp.x,0,scope.linkrail[linkdata[i].code].rp.z)
]);
scope.linkrail[linkdata[i].code].type = 2;
if(scope.linkrail[linkdata[i].code].lswitch){
let switchpoint = scope.switchrail[scope.linkrail[linkdata[i].code].lswitch].position;
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x+1.5,0,switchpoint.z));
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x+2,0,switchpoint.z));
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x+5,0,switchpoint.z+0.05));
}
scope.linkrail[linkdata[i].code].points.push(testline.getPointAt(0.12));
scope.linkrail[linkdata[i].code].points.push(testline.getPointAt(0.22));
scope.linkrail[linkdata[i].code].points.push(testline.getPointAt(0.82));
scope.linkrail[linkdata[i].code].points.push(testline.getPointAt(0.92));
if(scope.linkrail[linkdata[i].code].rswitch){
let switchpoint = scope.switchrail[scope.linkrail[linkdata[i].code].rswitch].position;
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x-5,0,switchpoint.z-0.05));
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x-2,0,switchpoint.z));
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x-1.5,0,switchpoint.z));
}
}
}
}
for(let i=0;i<switchdata.length;i++){
const ddd = storemod.getters['map/getDeviceByCode'](switchdata[i].code);
scope.switchrail[switchdata[i].code].locateType = ddd.locateType;
@ -123,7 +129,6 @@ export function RailList(){
scope.linkrail[switchdata[i].alink].rconnect = switchdata[i].blink;
scope.linkrail[switchdata[i].blink].lconnect = switchdata[i].alink;
}
}else if(ddd.locateType == "02"){
if(switchdata[i].directtype == "1"){
scope.linkrail[switchdata[i].alink].lconnect = switchdata[i].clink;
@ -133,10 +138,54 @@ export function RailList(){
scope.linkrail[switchdata[i].clink].lconnect = 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-2,switchdata[i].position.y,switchdata[i].position.z));
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(switchdata[i].position.x+1.5,switchdata[i].position.y,switchdata[i].position.z));
if(scope.linkrail[switchdata[i].alink].type == 1){
}else if(scope.linkrail[switchdata[i].alink].type == 2){
}else{
scope.linkrail[switchdata[i].blink].points.push(new THREE.Vector3(scope.linkrail[switchdata[i].alink].lp.x+1.5,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+2,switchdata[i].position.y,switchdata[i].position.z));
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(switchdata[i].position.x-1.5,switchdata[i].position.y,switchdata[i].position.z));
if(scope.linkrail[switchdata[i].alink].type == 1){
}else if(scope.linkrail[switchdata[i].alink].type == 2){
}else{
scope.linkrail[switchdata[i].blink].points.splice(0,0,new THREE.Vector3(scope.linkrail[switchdata[i].alink].rp.x-1.5,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-3.5,switchdata[i].position.y,switchdata[i].position.z+0.02));
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(switchdata[i].position.x+1.5,switchdata[i].position.y,switchdata[i].position.z));
if(scope.linkrail[switchdata[i].alink].type == 1){
}else if(scope.linkrail[switchdata[i].alink].type == 2){
}else{
scope.linkrail[switchdata[i].clink].points.push(new THREE.Vector3(scope.linkrail[switchdata[i].alink].lp.x+1.5,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+3.5,switchdata[i].position.y,switchdata[i].position.z-0.02));
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(switchdata[i].position.x-1.5,switchdata[i].position.y,switchdata[i].position.z));
if(scope.linkrail[switchdata[i].alink].type == 1){
}else if(scope.linkrail[switchdata[i].alink].type == 2){
}else{
scope.linkrail[switchdata[i].clink].points.splice(0,0,new THREE.Vector3(scope.linkrail[switchdata[i].alink].rp.x-1.5,0,scope.linkrail[switchdata[i].alink].rp.z));
}
scope.switchrail[switchdata[i].code].directtype = "2";
}
}
for(let i=0;i<linkdata.length;i++){
scope.linkrail[linkdata[i].code].lineleft = new THREE.CatmullRomCurve3(scope.linkrail[linkdata[i].code].points);
// scope.linkrail[linkdata[i].code].lineleft.curveType = "catmullrom";
scope.linkrail[linkdata[i].code].lineleft.curveType = "centripetal";
// scope.linkrail[linkdata[i].code].lineleft.tension = 0.2;
let rightpoints = [];
scope.linkrail[linkdata[i].code].points.forEach(item=>{
@ -145,10 +194,10 @@ export function RailList(){
);
rightpoints.reverse();
scope.linkrail[linkdata[i].code].lineright = new THREE.CatmullRomCurve3(rightpoints);
scope.linkrail[linkdata[i].code].lineright.curveType = "chordal";
//
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.5, 16 );
// 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);
@ -177,7 +226,7 @@ export function RailList(){
// // Create the final object to add to the scene
// var curveObject = new THREE.Line( geometry, material );
//
// curveObject.position.y = Math.random()/10;
// curveObject.position.y = Math.random();
// scene.add(curveObject);
}

View File

@ -12,7 +12,7 @@ export function StationStandList() {
this.textlist = [];
this.initpromise = function(stationdata,stationstanddata,scene,assetloader,netdata,mixers,actionss){
this.initpromise = function(stationdata,stationstanddata,scene,assetloader,netdata,mixers,actionss,mode){
return new Promise(function(resolve, reject){
let netstand = null;
@ -164,25 +164,33 @@ 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].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].num].code;
if(mode){
if(mode == "02"){
let textgeometry = new THREE.PlaneBufferGeometry( 271, 374, 1 );
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].num].code;
textplane.position.y = 300;
textplane.rotation.x = Math.PI/2;
//textplane.position.x = -30;
scope.textlist.push(textplane);
map[k].mesh.add(textplane);
textgeometry.dispose();
textmaterial.dispose();
textt.dispose();
}
}
map[k].type = "station";
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;
//textplane.position.x = -30;
scope.textlist.push(textplane);
map[k].mesh.add(textplane);
textgeometry.dispose();
textmaterial.dispose();
textt.dispose();
scope.group.add(map[k].mesh);
}
@ -354,9 +362,9 @@ function getTextCanvas(text){
ctx.fillText("信息", 114,100);
ctx.fillText("备忘", 190,100);
ctx.fillText("车站序号: "+text.name, 40,155);
ctx.fillText("车站序号: "+text.name, 10,155);
ctx.fillText("公里标记:"+text.kmPost,40 ,256*3/4);
ctx.fillText("公里标记:"+text.kmPost,10 ,256*3/4);
let data = ctx.getImageData(0, 0,256,512);
return data;

View File

@ -12,7 +12,7 @@ export function TrainList() {
this.textlist = [];
this.initpromise = function(data,scene,assetloader,mixers,actionss){
this.initpromise = function(data,scene,assetloader,mixers,actionss,mode){
return new Promise(function(resolve, reject){
//遍历列车数据
for(let i=0;i<data.length;i++){
@ -118,22 +118,28 @@ export function TrainList() {
// newmesh.children[n-1].add(newmesh.children[n]);
// }
//创建列车字牌
let textgeometry = new THREE.PlaneBufferGeometry( 150, 100, 1 );
let textt = new THREE.CanvasTexture(getTextCanvas(data[i]));
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 = 0;
textplane.position.y = 0;
textplane.position.z = 60;
textplane.tcode = data[i].code;
//textplane.rotation.x = Math.PI;
scope.textlist.push(textplane);
newmesh.children[0].add(textplane);
if(mode){
if(mode == "02"){
let textgeometry = new THREE.PlaneBufferGeometry( 150, 100, 1 );
let textt = new THREE.CanvasTexture(getTextCanvas(data[i]));
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 = 0;
textplane.position.y = 0;
textplane.position.z = 60;
textplane.tcode = data[i].code;
//textplane.rotation.x = Math.PI;
scope.textlist.push(textplane);
newmesh.children[0].add(textplane);
textgeometry.dispose();
textmaterial.dispose();
textt.dispose();
}
}
textgeometry.dispose();
textmaterial.dispose();
textt.dispose();
//group.add(textplane);
newmesh.first = false;
newmesh.name = data[i].code;
@ -187,24 +193,24 @@ function getTextCanvas(text){
var canvas = document.getElementById('canvastexture');
canvas.width = 128;
canvas.height = 96;
canvas.height = 64;
var ctx = canvas.getContext('2d');
//var bg = canvas.createPattern(img, "no-repeat");
//ctx.fillStyle = bg;
ctx.fillRect(0, 0,128,96);
ctx.font = "10px Verdana";
ctx.fillRect(0, 0,128,64);
ctx.font = "8px Verdana";
ctx.fillStyle = '#000000';
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.clearRect(0,0,128,96);
ctx.clearRect(0,0,128,64);
//console.log(text.groupNumber);
ctx.drawImage(beauty,0,0,128, 96);
ctx.fillText("车组号:"+text.groupNumber, 60,15);
ctx.fillText("车组人员:XXX", 60,31);
ctx.fillText("速度:XXX.XXX", 60,43);
ctx.drawImage(beauty,0,0,128, 64);
ctx.fillText("车组号:"+text.groupNumber, 40,10);
ctx.fillText("车组人员:XXX", 40,20);
// ctx.fillText("速度:XXX.XXX", 40,30);
//ctx.fillText(text.trainModel.name, width/2,height*3/4);
let data = ctx.getImageData(0, 0,128,96);
let data = ctx.getImageData(0, 0,128,64);
return data;
}

View File

@ -20,7 +20,8 @@ export function UpdateTrain(camera,traindata){
if(trainmodel.status == "03"){
if(movecurve.points.length>1){
let point = movecurve.getPointAt(traindata.group.children[j].progress);
trainmodel.position.x = point.x;
trainmodel.position.y = 0;
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();
@ -46,8 +47,7 @@ export function UpdateTrain(camera,traindata){
//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++){
@ -84,6 +84,8 @@ export function UpdateTrain(camera,traindata){
if(trainmodel.status == "02"){
if(movecurve.points.length>1){
let point = movecurve.getPointAt(trainmodel.progress);
trainmodel.position.x = point.x;
trainmodel.position.y = 0;
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();
@ -103,8 +105,7 @@ export function UpdateTrain(camera,traindata){
//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++){

Binary file not shown.

Binary file not shown.