修改三维沙盘和三维驾驶行车逻辑,设备动画逻辑,通信逻辑
This commit is contained in:
parent
d55ca741dc
commit
9de8b430ee
@ -141,27 +141,24 @@ export function JLmapDriving(dom,data,mapId,storemod,translation,routegroup,proj
|
|||||||
let cameracctv = new THREE.PerspectiveCamera(70, dom.clientWidth/dom.clientHeight, 1, 50);
|
let cameracctv = new THREE.PerspectiveCamera(70, dom.clientWidth/dom.clientHeight, 1, 50);
|
||||||
cameracctv.position.set( 2, -1,27 );
|
cameracctv.position.set( 2, -1,27 );
|
||||||
|
|
||||||
cameracctv.rotation.y = Math.PI/5*3;
|
cameracctv.rotation.y = Math.PI/2;
|
||||||
camera.add(cameracctv);
|
camera.add(cameracctv);
|
||||||
|
|
||||||
// let spotLight = new THREE.SpotLight( 0xffffff, 1 );
|
|
||||||
// // spotLight.position.set( 15, 40, 35 );
|
|
||||||
// spotLight.angle = Math.PI / 5;
|
|
||||||
// spotLight.penumbra = 0.05;
|
|
||||||
// spotLight.decay = 1;
|
|
||||||
// spotLight.distance = 30;
|
|
||||||
//
|
|
||||||
// spotLight.castShadow = true;
|
|
||||||
// spotLight.shadow.mapSize.width = 1024;
|
|
||||||
// spotLight.shadow.mapSize.height = 1024;
|
|
||||||
// spotLight.shadow.camera.near = 10;
|
|
||||||
// spotLight.shadow.camera.far = 50;
|
|
||||||
// spotLight.rotation.y = Math.PI;
|
|
||||||
// spotLight.position.y = -1;
|
|
||||||
// console.log(spotLight);
|
|
||||||
// controls3.getObject().add( spotLight );
|
|
||||||
// 订阅仿真socket
|
|
||||||
|
|
||||||
|
// 初始化加载数据和模型
|
||||||
|
getPublishMapDetail(mapId).then(data => {
|
||||||
|
let mapnetdata = data.data;
|
||||||
|
getPublish3dMapDetail(mapId).then(netdata => {
|
||||||
|
let assetsdata = JSON.parse(netdata.data.sections);
|
||||||
|
if(assetsdata.link){
|
||||||
|
scope.datatype = "old";
|
||||||
|
// scope.jsonwebwork = new Worker("../../static/workertest/jsonworker.js");
|
||||||
|
// scope.Subscribe = new Jlmap3dSubscribe(scope,routegroup,scope.jsonwebwork);
|
||||||
|
// scope.Subscribe.socketon(scope.Subscribe.topic);
|
||||||
|
scope.Subscribe = new Jl3dDriving(mixers,updatemmi,sound,translation,routegroup);
|
||||||
|
|
||||||
|
scope.Subscribe.socketon(scope.Subscribe.topic);
|
||||||
|
DriverLoad(data,scope,netdata.data,sectionlist,linklist,signallist,stationstandlist,trainlisttest,realsectionlist,rails, camera, controls3, scene,mixers,storemod);
|
||||||
var timer = setInterval(function() {
|
var timer = setInterval(function() {
|
||||||
if(trainlisttest){
|
if(trainlisttest){
|
||||||
if(trainlisttest.group){
|
if(trainlisttest.group){
|
||||||
@ -201,30 +198,28 @@ export function JLmapDriving(dom,data,mapId,storemod,translation,routegroup,proj
|
|||||||
}
|
}
|
||||||
|
|
||||||
}, 2000);
|
}, 2000);
|
||||||
// 初始化加载数据和模型
|
|
||||||
getPublishMapDetail(mapId).then(data => {
|
|
||||||
let mapnetdata = data.data;
|
|
||||||
getPublish3dMapDetail(mapId).then(netdata => {
|
|
||||||
let assetsdata = JSON.parse(netdata.data.sections);
|
|
||||||
if(assetsdata.link){
|
|
||||||
scope.datatype = "old";
|
|
||||||
// scope.jsonwebwork = new Worker("../../static/workertest/jsonworker.js");
|
|
||||||
// scope.Subscribe = new Jlmap3dSubscribe(scope,routegroup,scope.jsonwebwork);
|
|
||||||
// scope.Subscribe.socketon(scope.Subscribe.topic);
|
|
||||||
scope.Subscribe = new Jl3dDriving(mixers,updatemmi,sound,translation,routegroup);
|
|
||||||
|
|
||||||
scope.Subscribe.socketon(scope.Subscribe.topic);
|
|
||||||
DriverLoad(data,scope,netdata.data,sectionlist,linklist,signallist,stationstandlist,trainlisttest,realsectionlist,rails, camera, controls3, scene,mixers,storemod);
|
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
scope.datatype = "new";
|
scope.datatype = "new";
|
||||||
scope.Subscribe = new Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup);
|
scope.Subscribe = new Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup,stats);
|
||||||
|
|
||||||
|
|
||||||
scope.Subscribe.socketon(scope.Subscribe.topic);
|
|
||||||
// scope.jsonwebworknew = new Worker("../../static/workertest/jsonworkernew.js");
|
// scope.jsonwebworknew = new Worker("../../static/workertest/jsonworkernew.js");
|
||||||
// scope.Subscribe = new Jlmap3dSubscribeNew(scope,routegroup,scope.jsonwebworknew);
|
// scope.Subscribe = new Jlmap3dSubscribeNew(scope,routegroup,scope.jsonwebworknew);
|
||||||
// scope.Subscribe.socketon(scope.Subscribe.topic);
|
// scope.Subscribe.socketon(scope.Subscribe.topic);
|
||||||
DriverLoadNew(mapnetdata,scope,netdata.data,mapdata,sectionlist,signallist,switchlist,stationstandlist,trainlisttest,rails,camera,controls3,scene,mixers);
|
DriverLoadNew(mapnetdata,scope,netdata.data,mapdata,sectionlist,signallist,switchlist,stationstandlist,trainlisttest,rails,camera,controls3,scene,mixers);
|
||||||
|
var timer = setInterval(function() {
|
||||||
|
if(trainlisttest){
|
||||||
|
if(trainlisttest.group){
|
||||||
|
if(trainlisttest.group.children[0]){
|
||||||
|
updatemmi.updatedrivingcodenew(trainlisttest.group.children[0].code);
|
||||||
|
scope.Subscribe.initdrivercode(trainlisttest.group.children[0].code);
|
||||||
|
scope.Subscribe.socketon(scope.Subscribe.topic);
|
||||||
|
clearInterval(timer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}, 2000);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,8 +229,8 @@ export function JLmapDriving(dom,data,mapId,storemod,translation,routegroup,proj
|
|||||||
// getPublish3dMapDetail(mapId).then(netdata => {
|
// getPublish3dMapDetail(mapId).then(netdata => {
|
||||||
// DriverLoad(data, scope, netdata.data, sectionlist,linklist,signallist,stationstandlist,trainlisttest,realsectionlist,rails, camera, controls3, scene,mixers,storemod);
|
// DriverLoad(data, scope, netdata.data, sectionlist,linklist,signallist,stationstandlist,trainlisttest,realsectionlist,rails, camera, controls3, scene,mixers,storemod);
|
||||||
// });
|
// });
|
||||||
// let stats = new Stats();
|
let stats = new Stats();
|
||||||
// dom.appendChild( stats.dom );
|
dom.appendChild( stats.dom );
|
||||||
// 开启渲染
|
// 开启渲染
|
||||||
animate();
|
animate();
|
||||||
startWorker();
|
startWorker();
|
||||||
@ -280,7 +275,10 @@ export function JLmapDriving(dom,data,mapId,storemod,translation,routegroup,proj
|
|||||||
|
|
||||||
scope.webwork.onmessage = function (event) {
|
scope.webwork.onmessage = function (event) {
|
||||||
// 更新列车位置
|
// 更新列车位置
|
||||||
|
if(scope.datatype == "old"){
|
||||||
UpdateTrain(camera, trainlisttest);
|
UpdateTrain(camera, trainlisttest);
|
||||||
|
}
|
||||||
|
//
|
||||||
delta = clock.getDelta();
|
delta = clock.getDelta();
|
||||||
for (let i=mixers.length-1; i>=0; i--) {
|
for (let i=mixers.length-1; i>=0; i--) {
|
||||||
mixers[i].update( delta );
|
mixers[i].update( delta );
|
||||||
@ -316,9 +314,19 @@ export function JLmapDriving(dom,data,mapId,storemod,translation,routegroup,proj
|
|||||||
};
|
};
|
||||||
|
|
||||||
updatemmi.updatedrivingcode = function(code) {
|
updatemmi.updatedrivingcode = function(code) {
|
||||||
// console.log(trainlisttest);
|
console.log(trainlisttest);
|
||||||
drivingcode = code;
|
drivingcode = code;
|
||||||
trainlisttest.list[drivingcode].children[0].add(controls3.getObject());
|
trainlisttest.group.children[0].children[0].add(controls3.getObject());
|
||||||
|
controls3.getObject().position.x = 10;
|
||||||
|
controls3.getObject().position.y = 0;
|
||||||
|
controls3.getObject().position.z = 1.5;
|
||||||
|
controls3.getObject().rotation.x = Math.PI/2;
|
||||||
|
controls3.getObject().rotation.y = -Math.PI/2;
|
||||||
|
};
|
||||||
|
|
||||||
|
updatemmi.updatedrivingcodenew = function(code) {
|
||||||
|
drivingcode = code;
|
||||||
|
trainlisttest.group.children[0].children[0].add(controls3.getObject());
|
||||||
controls3.getObject().position.x = 10;
|
controls3.getObject().position.x = 10;
|
||||||
controls3.getObject().position.y = 0;
|
controls3.getObject().position.y = 0;
|
||||||
controls3.getObject().position.z = 1.5;
|
controls3.getObject().position.z = 1.5;
|
||||||
|
@ -92,7 +92,6 @@ export function Jl3dDriving(mixers,updatemmi,sound,translation,routegroup) {
|
|||||||
// console.log(Response);
|
// console.log(Response);
|
||||||
// 对象化数据
|
// 对象化数据
|
||||||
let data = JSON.parse(Response.body);
|
let data = JSON.parse(Response.body);
|
||||||
console.log(data);
|
|
||||||
// 遍历后台数据
|
// 遍历后台数据
|
||||||
|
|
||||||
// 判断消息类型
|
// 判断消息类型
|
||||||
|
@ -7,7 +7,7 @@ import { getToken } from '@/utils/auth';
|
|||||||
import router from '@/router';
|
import router from '@/router';
|
||||||
|
|
||||||
// 定于仿真socket接口
|
// 定于仿真socket接口
|
||||||
export function Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup) {
|
export function Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup,stats) {
|
||||||
|
|
||||||
let scope = this;
|
let scope = this;
|
||||||
this.map = null;
|
this.map = null;
|
||||||
@ -22,6 +22,7 @@ export function Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup) {
|
|||||||
var rails = null;
|
var rails = null;
|
||||||
var links = null;
|
var links = null;
|
||||||
|
|
||||||
|
let trainmodel = null;
|
||||||
var scenes = null;
|
var scenes = null;
|
||||||
|
|
||||||
var code = null;
|
var code = null;
|
||||||
@ -39,12 +40,13 @@ export function Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup) {
|
|||||||
// reset = 02;
|
// reset = 02;
|
||||||
var datatype = '00';
|
var datatype = '00';
|
||||||
this.teststomp = new StompClient();
|
this.teststomp = new StompClient();
|
||||||
this.topic = '/user/queue/simulation/jl3d/'+routegroup;
|
this.topic = '/user/queue/simulation/drive/'+routegroup;
|
||||||
let header = {'X-Token': getToken() };
|
let header = {'X-Token': getToken() };
|
||||||
|
|
||||||
this.updatamap = function(newsectionlist,newlinklist,newsignallist,newstationstandlist,newtrainlisttest,newrealsectionlist,newrails, materiallist, nowaction, scene) {
|
this.updatamap = function(newsectionlist,newlinklist,newsignallist,newstationstandlist,newtrainlisttest,newrealsectionlist,newrails, materiallist, nowaction, scene) {
|
||||||
// console.log(mapdata);
|
// console.log(mapdata);
|
||||||
// console.log(newtrainlisttest);
|
// console.log(newtrainlisttest);
|
||||||
|
trainmodel = newtrainlisttest.group.children[0];
|
||||||
trainlisttest = newtrainlisttest;
|
trainlisttest = newtrainlisttest;
|
||||||
sectionlist = newsectionlist;
|
sectionlist = newsectionlist;
|
||||||
signallist = newsignallist;
|
signallist = newsignallist;
|
||||||
@ -75,9 +77,9 @@ export function Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup) {
|
|||||||
for (let i=0; i<trainlisttest.group.children.length; i++) {
|
for (let i=0; i<trainlisttest.group.children.length; i++) {
|
||||||
if (trainlisttest.group.children[i].dispose == false) {
|
if (trainlisttest.group.children[i].dispose == false) {
|
||||||
code = trainlisttest.group.children[i].name;
|
code = trainlisttest.group.children[i].name;
|
||||||
trainlisttest.list[code].rotation.y = 0;
|
trainmodel.rotation.y = 0;
|
||||||
trainlisttest.list[code].doorStatus = '01';
|
trainmodel.doorStatus = '01';
|
||||||
trainlisttest.list[code].speed = 0;
|
trainmodel.speed = 0;
|
||||||
trainlisttest.group.children[i].dispose = true;
|
trainlisttest.group.children[i].dispose = true;
|
||||||
trainlisttest.group.children[i].position.x = -50000;
|
trainlisttest.group.children[i].position.x = -50000;
|
||||||
trainlisttest.group.children[i].position.y = -50000;
|
trainlisttest.group.children[i].position.y = -50000;
|
||||||
@ -91,134 +93,240 @@ export function Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup) {
|
|||||||
function callback(Response) {
|
function callback(Response) {
|
||||||
// console.log(Response);
|
// console.log(Response);
|
||||||
// 对象化数据
|
// 对象化数据
|
||||||
|
|
||||||
let data = JSON.parse(Response.body);
|
let data = JSON.parse(Response.body);
|
||||||
console.log(data);
|
|
||||||
// 遍历后台数据
|
// 遍历后台数据
|
||||||
if(event.data.type == "Train_Hmi_3D"){
|
// console.log(data);
|
||||||
trainhmi(event.data);
|
if(data.type == "Train_Position"){
|
||||||
|
stats.update();
|
||||||
|
trainrun(data.body);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (event.data.type== 'SIGNAL' && signallist) {
|
if(data.type == "Train_Hmi_3D"){
|
||||||
signalupdate(event.data);
|
trainhmi(data.body);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// if (event.data.type== 'SIGNAL' && signallist) {
|
||||||
|
// signalupdate(event.data);
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
|
||||||
|
if(data.type == "DeviceCtrl_3D"){
|
||||||
|
if (data.body.type== 'SIGNAL' && signallist) {
|
||||||
|
signalupdate(data.body);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.data.type== "PSD" && actions) {
|
if (data.body.type== "PSD" && actions) {
|
||||||
standupdate(event.data);
|
standupdate(data.body);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (event.data.type == "SWITCH") {
|
if (data.body.type == "SWITCH") {
|
||||||
switchupdate(event.data);
|
switchupdate(data.body);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (event.data.type == 'TRAIN_DOOR') {
|
if (data.body.type == 'TRAIN_DOOR') {
|
||||||
traindoorupdate(event.data);
|
traindoorupdate(data.body);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(event.data.type == 'Simulation_Reset'){
|
|
||||||
simulationreset(event.data);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(event.data.type == 'Simulation_DeviceStatus'){
|
|
||||||
initall(event.data.body);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(data.type == "Device_Load_Destroy_3D"){
|
||||||
|
DeviceDestroy(data.body);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// if (event.data.type== "PSD" && actions) {
|
||||||
|
// standupdate(event.data);
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// if (event.data.type == "SWITCH") {
|
||||||
|
// switchupdate(event.data);
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// if (event.data.type == 'TRAIN_DOOR') {
|
||||||
|
// traindoorupdate(event.data);
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if(event.data.type == 'Simulation_Reset'){
|
||||||
|
// simulationreset(event.data);
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// if(event.data.type == 'Simulation_DeviceStatus'){
|
||||||
|
// initall(event.data.body);
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
function DeviceDestroy(data){
|
||||||
|
// console.log(data);
|
||||||
|
for(let i=0,leni=data.length;i<leni;i++){
|
||||||
|
|
||||||
|
if(data[i].type == "SIGNAL"){
|
||||||
|
signalupdate(data[i]);
|
||||||
|
}
|
||||||
|
if(data[i].type == "SWITCH"){
|
||||||
|
switchupdate(data[i]);
|
||||||
|
}
|
||||||
|
if(data[i].type == "PSD"){
|
||||||
|
standupdate(data[i]);
|
||||||
|
}
|
||||||
|
if(data[i].type == "TRAIN_DOOR"){
|
||||||
|
traindoorupdate(data[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function trainrun(data){
|
function trainrun(data){
|
||||||
let code = data.code;
|
// console.log(data);
|
||||||
if(trainlisttest.list[code].dispose == "0"){
|
if(data.code != trainmodel.code){
|
||||||
if(trainlisttest.list[code].curve == null){
|
trainmodel.code = data.code;
|
||||||
if (data.right == '1') { // 向右
|
trainmodel.nowcode = data.code;
|
||||||
|
|
||||||
trainlisttest.list[code].progress = data.offset;
|
|
||||||
trainlisttest.list[code].isstandsection = rails.sectionrail[data.section].standTrack;
|
|
||||||
if(rails.sectionrail[data.section].standTrack){
|
|
||||||
trainlisttest.list[code].statsstop = 0;
|
|
||||||
}
|
}
|
||||||
let point = rails.sectionrail[data.section].lineleft.getPointAt(trainlisttest.list[code].progress);
|
|
||||||
trainlisttest.list[code].rotation.y = 0;
|
if(data.section != trainmodel.nowsection){
|
||||||
trainlisttest.list[code].position.x = point.x;
|
trainmodel.nowsection = data.section;
|
||||||
trainlisttest.list[code].position.y = 0;
|
trainmodel.curve = rails.sectionrail[data.section].lineleft;
|
||||||
|
}
|
||||||
|
// console.log(trainmodel.right);
|
||||||
|
if(trainmodel.right != data.right){
|
||||||
|
|
||||||
|
if(data.right == "0"){
|
||||||
|
trainmodel.right = "0";
|
||||||
|
trainmodel.rotation.y = Math.PI;
|
||||||
|
let point = trainmodel.curve.getPointAt(data.offset);
|
||||||
|
trainmodel.position.x = point.x;
|
||||||
for (let tl=0; tl<6; tl++) {
|
for (let tl=0; tl<6; tl++) {
|
||||||
trainlisttest.list[code].children[tl].position.z = parseFloat(point.z);
|
trainmodel.children[tl].position.z = point.z;
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
trainlisttest.list[code].curve = rails.sectionrail[data.section].lineleft;
|
trainmodel.right = "1";
|
||||||
|
trainmodel.rotation.y = 0;
|
||||||
if(data.next){
|
let point = trainmodel.curve.getPointAt(data.offset);
|
||||||
trainlisttest.list[code].nextcode = data.next;
|
trainmodel.position.x = point.x;
|
||||||
trainlisttest.list[code].nextcurve = rails.sectionrail[data.next].lineleft;
|
|
||||||
trainlisttest.list[code].nextlen = rails.sectionrail[data.next].lengthfact;
|
|
||||||
}
|
|
||||||
trainlisttest.list[code].len = rails.sectionrail[data.section].lengthfact;
|
|
||||||
trainlisttest.list[code].status = '1';
|
|
||||||
|
|
||||||
} else if (data.right == '0') { // 向左
|
|
||||||
trainlisttest.list[code].progress = 1-data.offset;
|
|
||||||
trainlisttest.list[code].isstandsection = rails.sectionrail[data.section].standTrack;
|
|
||||||
if(rails.sectionrail[data.section].standTrack){
|
|
||||||
trainlisttest.list[code].statsstop = 0;
|
|
||||||
}
|
|
||||||
let point = rails.sectionrail[data.section].lineright.getPointAt(trainlisttest.list[code].progress);
|
|
||||||
|
|
||||||
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++) {
|
for (let tl=0; tl<6; tl++) {
|
||||||
trainlisttest.list[code].children[tl].position.z = parseFloat(-point.z);
|
trainmodel.children[tl].position.z = point.z;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
trainlisttest.list[code].curve = rails.sectionrail[data.section].lineright;
|
if(trainmodel.curve && trainmodel.offset != data.offset){
|
||||||
if(data.next){
|
trainmodel.offset = data.offset;
|
||||||
trainlisttest.list[code].nextcode = data.next;
|
let pos = trainmodel.curve.getPointAt(data.offset);
|
||||||
trainlisttest.list[code].nextcurve = rails.sectionrail[data.next].lineright;
|
trainmodel.position.x = pos.x;
|
||||||
trainlisttest.list[code].nextlen = rails.sectionrail[data.next].lengthfact;
|
// trainmodel.children[0].position.z = pos.z;
|
||||||
|
if(data.right == "0"){
|
||||||
|
if(-trainmodel.children[0].position.z != pos.z){
|
||||||
|
trainmodel.children[0].up = new THREE.Vector3(1,0,0);
|
||||||
|
let tangent = trainmodel.curve.getTangentAt(data.offset).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:pos,
|
||||||
|
rota:trainmodel.children[0].rotation.z
|
||||||
}
|
}
|
||||||
trainlisttest.list[code].len = rails.sectionrail[data.section].lengthfact;
|
trainmodel.children[1].rotalist.push(rotas);
|
||||||
trainlisttest.list[code].status = '0';
|
let offsetz = pos.z + trainmodel.children[0].position.z;
|
||||||
|
trainmodel.children[0].position.z -= offsetz;
|
||||||
|
// trainmodel.position.z = point.z;
|
||||||
|
|
||||||
|
}
|
||||||
|
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].position.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]+10)>=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);
|
||||||
|
}
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
//后端数据驱动车的位置更新与代码驱动车的移动相结合
|
if(trainmodel.children[0].position.z != pos.z){
|
||||||
if(data.code != trainlisttest.list[code].code){
|
trainmodel.children[0].up = new THREE.Vector3(-1,0,0);
|
||||||
if (data.right == '1') { // 向右
|
let tangent = trainmodel.curve.getTangentAt(data.offset).normalize();
|
||||||
trainlisttest.list[code].nowcode = data.code;
|
trainmodel.children[0].axis.crossVectors(trainmodel.children[0].up, tangent).normalize();
|
||||||
trainlisttest.list[code].curve = rails.sectionrail[data.section].lineleft;
|
let radians = Math.acos(trainmodel.children[0].up.dot(tangent));
|
||||||
trainlisttest.list[code].progress = data.offset;
|
trainmodel.children[0].quaternion.setFromAxisAngle(trainmodel.children[0].axis, radians);
|
||||||
trainlisttest.list[code].nextcode = data.next;
|
trainmodel.children[0].rotation.x = -Math.PI/2;
|
||||||
trainlisttest.list[code].nextcurve = rails.sectionrail[data.next].lineleft;
|
trainmodel.children[0].rotation.z = trainmodel.children[0].rotation.y;
|
||||||
trainlisttest.list[code].nextlen = rails.sectionrail[data.next].lengthfact;
|
trainmodel.children[0].rotation.y = 0;
|
||||||
trainlisttest.list[code].nextissection = rails.sectionrail[data.next].standTrack;
|
let rotas = {
|
||||||
} else if (data.right == '0') { // 向左
|
posr:pos,
|
||||||
trainlisttest.list[code].nowcode = data.code;
|
rota:trainmodel.children[0].rotation.z
|
||||||
trainlisttest.list[code].curve = rails.sectionrail[data.section].lineright;
|
|
||||||
trainlisttest.list[code].progress = 1-data.offset;
|
|
||||||
trainlisttest.list[code].nextcode = data.next;
|
|
||||||
trainlisttest.list[code].nextcurve = rails.sectionrail[data.next].lineright;
|
|
||||||
trainlisttest.list[code].nextlen = rails.sectionrail[data.next].lengthfact;
|
|
||||||
trainlisttest.list[code].nextissection = rails.sectionrail[data.next].standTrack;
|
|
||||||
}
|
}
|
||||||
}
|
trainmodel.children[1].rotalist.push(rotas);
|
||||||
}
|
|
||||||
if(data.speed == 0){
|
|
||||||
trainlisttest.list[code].speeds = 0;
|
|
||||||
trainlisttest.list[code].statsstop = 0;
|
|
||||||
}else{
|
|
||||||
trainlisttest.list[code].speeds = parseFloat(data.speed*10/36/18/trainlisttest.list[code].len);
|
|
||||||
}
|
|
||||||
if(data.right != trainlisttest.list[code].status){
|
|
||||||
|
|
||||||
trainlisttest.list[code].status = data.right;
|
|
||||||
trainlisttest.list[code].curve = null;
|
let offsetz = parseFloat(pos.z) - parseFloat(trainmodel.children[0].position.z);
|
||||||
trainlisttest.list[code].nextcurve = null;
|
trainmodel.children[0].position.z += offsetz;
|
||||||
trainlisttest.list[code].nextlen = null;
|
}
|
||||||
|
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]-10)<=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.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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// let pos = ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function initall(data){
|
function initall(data){
|
||||||
@ -233,86 +341,68 @@ export function Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function trainhmi(data){
|
function trainhmi(data){
|
||||||
// console.log(data);
|
for(let i=0,leni=data.length;i<leni;i++){
|
||||||
for(let i=0,leni=data.body.length;i<leni;i++){
|
if(trainmodel.code == data[i].code){
|
||||||
code =data.body[i].code;
|
// console.log(data[i]);
|
||||||
if (trainlisttest.list[code].dispose != data.body[i].dispose && data.body[i].dispose == "0") {
|
//更新车组号
|
||||||
|
updatemmi.updatetrainnum(data[i].code);
|
||||||
|
|
||||||
if (rails.sectionrail[data.body[i].section]) {
|
updatemmi.updatestoptime(data[i].atoOn);
|
||||||
|
|
||||||
trainlisttest.group.add(trainlisttest.list[code]);
|
updatemmi.updatenowspeed(data[i].v);
|
||||||
trainlisttest.list[code].position.y = 0;
|
|
||||||
// trainlisttest.list[code].progress = 0;
|
|
||||||
trainlisttest.list[code].dispose = "0";
|
|
||||||
trainlisttest.list[code].nowcode = data.body[i].section;
|
|
||||||
trainlisttest.list[code].nextcode = null;
|
|
||||||
trainlisttest.list[code].curve = null;
|
|
||||||
trainlisttest.list[code].nextcurve = null;
|
|
||||||
trainlisttest.list[code].pc = 1;
|
|
||||||
|
|
||||||
if(trainlisttest.list[code].mixerpush == false){
|
updatemmi.updateatpspeed(data[i].pv);
|
||||||
for(let mi=0,lenmi=trainlisttest.list[code].mixer.length;mi<lenmi;mi++){
|
|
||||||
jlmap3d.mixers.push(trainlisttest.list[code].mixer[mi]);
|
|
||||||
}
|
|
||||||
trainlisttest.list[code].mixerpush = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (trainlisttest.list[code].dispose != data.body[i].dispose && data.body[i].dispose == "1") {
|
|
||||||
trainlisttest.list[code].status = 1;
|
|
||||||
trainlisttest.group.remove(trainlisttest.list[code]);
|
|
||||||
trainlisttest.list[code].progress = null;
|
|
||||||
trainlisttest.list[code].dispose = "1";
|
|
||||||
code = trainlisttest.group.children[i].name;
|
|
||||||
trainlisttest.list[code].rotation.y = 0;
|
|
||||||
trainlisttest.list[code].open = '1';
|
|
||||||
trainlisttest.list[code].curve = null;
|
|
||||||
trainlisttest.list[code].nextcurve = null;
|
|
||||||
trainlisttest.list[code].speed = 0;
|
|
||||||
trainlisttest.list[code].position.x = -50000;
|
|
||||||
trainlisttest.list[code].position.y = -50000;
|
|
||||||
trainlisttest.list[code].pc = 1;
|
|
||||||
|
|
||||||
|
updatemmi.updateatospeed(data[i].tv);
|
||||||
|
|
||||||
|
updatemmi.updatenowlen(data[i].destinationCode);
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function traindoorupdate(data){
|
function traindoorupdate(data){
|
||||||
let code = data.code;
|
|
||||||
|
if(trainmodel.code == data.code){
|
||||||
|
|
||||||
if(data.doorCode == "0"){
|
if(data.doorCode == "0"){
|
||||||
|
|
||||||
if(trainlisttest.list[code].open != data.open && data.open == "0"){
|
if(trainmodel.open != data.open && data.open == "0"){
|
||||||
trainlisttest.list[code].open = "0";
|
trainmodel.open = "0";
|
||||||
for(let an=actions[code].down.length-1;an>=0;an--){
|
for(let an=actions["traindoor"].down.length-1;an>=0;an--){
|
||||||
actions[code].down[an].reset();
|
actions["traindoor"].down[an].reset();
|
||||||
actions[code].down[an].time = actions[code].top[an]._clip.duration;
|
actions["traindoor"].down[an].time = actions["traindoor"].top[an]._clip.duration;
|
||||||
actions[code].down[an].timeScale = -1;
|
actions["traindoor"].down[an].timeScale = -1;
|
||||||
actions[code].down[an].play();
|
actions["traindoor"].down[an].play();
|
||||||
}
|
}
|
||||||
}else if(trainlisttest.list[code].open != data.open && data.open == "1"){
|
}else if(trainmodel.open != data.open && data.open == "1"){
|
||||||
trainlisttest.list[code].open = "1";
|
trainmodel.open = "1";
|
||||||
for(let an=actions[code].down.length-1;an>=0;an--){
|
for(let an=actions["traindoor"].down.length-1;an>=0;an--){
|
||||||
actions[code].down[an].reset();
|
actions["traindoor"].down[an].reset();
|
||||||
actions[code].down[an].time = 0;
|
actions["traindoor"].down[an].time = 0;
|
||||||
actions[code].down[an].timeScale = 1;
|
actions["traindoor"].down[an].timeScale = 1;
|
||||||
actions[code].down[an].play();
|
actions["traindoor"].down[an].play();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
if (trainlisttest.list[code].open != data.open && data.open == '0') {
|
|
||||||
trainlisttest.list[code].open = '0';
|
|
||||||
for (let an=actions[code].top.length-1; an>=0; an--) {
|
if (trainmodel.open != data.open && data.open == '0') {
|
||||||
actions[code].top[an].reset();
|
trainmodel.open = '0';
|
||||||
actions[code].top[an].time = actions[code].top[an]._clip.duration;
|
for (let an=actions["traindoor"].top.length-1; an>=0; an--) {
|
||||||
actions[code].top[an].timeScale = -1;
|
actions["traindoor"].top[an].reset();
|
||||||
actions[code].top[an].play();
|
actions["traindoor"].top[an].time = actions["traindoor"].top[an]._clip.duration;
|
||||||
|
actions["traindoor"].top[an].timeScale = -1;
|
||||||
|
actions["traindoor"].top[an].play();
|
||||||
}
|
}
|
||||||
} else if (trainlisttest.list[code].open != data.open && data.open == '1') {
|
} else if (trainmodel.open != data.open && data.open == '1') {
|
||||||
trainlisttest.list[code].open = "1";
|
trainmodel.open = "1";
|
||||||
for(let an=actions[code].top.length-1;an>=0;an--){
|
for(let an=actions["traindoor"].top.length-1;an>=0;an--){
|
||||||
actions[code].top[an].reset();
|
actions["traindoor"].top[an].reset();
|
||||||
actions[code].top[an].time = 0;
|
actions["traindoor"].top[an].time = 0;
|
||||||
actions[code].top[an].timeScale = 1;
|
actions["traindoor"].top[an].timeScale = 1;
|
||||||
actions[code].top[an].play();
|
actions["traindoor"].top[an].play();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -320,6 +410,8 @@ export function Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function trainstatus(data){
|
function trainstatus(data){
|
||||||
// 遍历列车对象组
|
// 遍历列车对象组
|
||||||
if (trainlisttest) {
|
if (trainlisttest) {
|
||||||
@ -327,48 +419,48 @@ export function Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup) {
|
|||||||
code = data.code;
|
code = data.code;
|
||||||
// 剔除不显示的车
|
// 剔除不显示的车
|
||||||
// 找到对应列车
|
// 找到对应列车
|
||||||
if ( trainlisttest.list[code]) {
|
if ( trainmodel) {
|
||||||
|
|
||||||
trainlisttest.list[code].driveMode = data.driveMode;
|
trainmodel.driveMode = data.driveMode;
|
||||||
trainlisttest.list[code].status = data.right;
|
trainmodel.status = data.right;
|
||||||
// 车门开关验证
|
// 车门开关验证
|
||||||
|
|
||||||
|
|
||||||
// 遍历获取所在轨道
|
// 遍历获取所在轨道
|
||||||
if (trainlisttest.list[code].dispose != data.dispose && data.dispose == "0") {
|
if (trainmodel.dispose != data.dispose && data.dispose == "0") {
|
||||||
if (rails.sectionrail[data.sectionCode]) {
|
if (rails.sectionrail[data.sectionCode]) {
|
||||||
|
|
||||||
trainlisttest.group.add(trainlisttest.list[code]);
|
trainlisttest.group.add(trainmodel);
|
||||||
trainlisttest.list[code].position.y = 0;
|
trainmodel.position.y = 0;
|
||||||
// trainlisttest.list[code].progress = 0;
|
// trainmodel.progress = 0;
|
||||||
trainlisttest.list[code].dispose = "0";
|
trainmodel.dispose = "0";
|
||||||
trainlisttest.list[code].nowcode = data.sectionCode;
|
trainmodel.nowcode = data.sectionCode;
|
||||||
trainlisttest.list[code].nextcode = null;
|
trainmodel.nextcode = null;
|
||||||
trainlisttest.list[code].curve = null;
|
trainmodel.curve = null;
|
||||||
trainlisttest.list[code].nextcurve = null;
|
trainmodel.nextcurve = null;
|
||||||
trainlisttest.list[code].pc = 1;
|
trainmodel.pc = 1;
|
||||||
|
|
||||||
if(trainlisttest.list[code].mixerpush == false){
|
if(trainmodel.mixerpush == false){
|
||||||
for(let mi=0,lenmi=trainlisttest.list[code].mixer.length;mi<lenmi;mi++){
|
for(let mi=0,lenmi=trainmodel.mixer.length;mi<lenmi;mi++){
|
||||||
jlmap3d.mixers.push(trainlisttest.list[code].mixer[mi]);
|
jlmap3d.mixers.push(trainmodel.mixer[mi]);
|
||||||
}
|
}
|
||||||
trainlisttest.list[code].mixerpush = true;
|
trainmodel.mixerpush = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (trainlisttest.list[code].dispose != data.dispose && data.dispose == "1") {
|
} else if (trainmodel.dispose != data.dispose && data.dispose == "1") {
|
||||||
trainlisttest.list[code].status = 1;
|
trainmodel.status = 1;
|
||||||
trainlisttest.group.remove(trainlisttest.list[code]);
|
trainlisttest.group.remove(trainmodel);
|
||||||
trainlisttest.list[code].progress = null;
|
trainmodel.progress = null;
|
||||||
trainlisttest.list[code].dispose = "1";
|
trainmodel.dispose = "1";
|
||||||
code = trainlisttest.group.children[i].name;
|
code = trainlisttest.group.children[i].name;
|
||||||
trainlisttest.list[code].rotation.y = 0;
|
trainmodel.rotation.y = 0;
|
||||||
trainlisttest.list[code].open = '1';
|
trainmodel.open = '1';
|
||||||
trainlisttest.list[code].curve = null;
|
trainmodel.curve = null;
|
||||||
trainlisttest.list[code].nextcurve = null;
|
trainmodel.nextcurve = null;
|
||||||
trainlisttest.list[code].speed = 0;
|
trainmodel.speed = 0;
|
||||||
trainlisttest.list[code].position.x = -50000;
|
trainmodel.position.x = -50000;
|
||||||
trainlisttest.list[code].position.y = -50000;
|
trainmodel.position.y = -50000;
|
||||||
trainlisttest.list[code].pc = 1;
|
trainmodel.pc = 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -414,7 +506,7 @@ export function Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup) {
|
|||||||
}
|
}
|
||||||
function signalupdate(data) {
|
function signalupdate(data) {
|
||||||
code = data.code;
|
code = data.code;
|
||||||
if(data.redOpen == 1){
|
if(data.red == 1){
|
||||||
signallist.list[code].mesh.getObjectByName("red").material.map = materials[0];
|
signallist.list[code].mesh.getObjectByName("red").material.map = materials[0];
|
||||||
signallist.list[code].mesh.getObjectByName("red").material.map.needsUpdate = true;
|
signallist.list[code].mesh.getObjectByName("red").material.map.needsUpdate = true;
|
||||||
}else{
|
}else{
|
||||||
@ -422,7 +514,7 @@ export function Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup) {
|
|||||||
signallist.list[code].mesh.getObjectByName("green").material.map.needsUpdate = true;
|
signallist.list[code].mesh.getObjectByName("green").material.map.needsUpdate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(data.yellowOpen == 1){
|
if(data.yellow == 1){
|
||||||
signallist.list[code].mesh.getObjectByName("yellow").material.map = materials[1];
|
signallist.list[code].mesh.getObjectByName("yellow").material.map = materials[1];
|
||||||
signallist.list[code].mesh.getObjectByName("yellow").material.map.needsUpdate = true;
|
signallist.list[code].mesh.getObjectByName("yellow").material.map.needsUpdate = true;
|
||||||
|
|
||||||
@ -432,7 +524,7 @@ export function Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(data.greenOpen == 1){
|
if(data.green == 1){
|
||||||
signallist.list[code].mesh.getObjectByName("green").material.map = materials[2];
|
signallist.list[code].mesh.getObjectByName("green").material.map = materials[2];
|
||||||
signallist.list[code].mesh.getObjectByName("green").material.map.needsUpdate = true;
|
signallist.list[code].mesh.getObjectByName("green").material.map.needsUpdate = true;
|
||||||
|
|
||||||
|
@ -51,15 +51,15 @@ export function Jlmap3dSubscribeNew(jlmap3d,routegroup,jsonwebwork) {
|
|||||||
};
|
};
|
||||||
jsonwebwork.postMessage(connectmsg);
|
jsonwebwork.postMessage(connectmsg);
|
||||||
jsonwebwork.onmessage = function (event) {
|
jsonwebwork.onmessage = function (event) {
|
||||||
// console.log(event.data);
|
|
||||||
|
|
||||||
|
|
||||||
// if(event.data.deviceType == "TRAIN"){
|
// if(event.data.deviceType == "TRAIN"){
|
||||||
// // console.log(event.data);
|
// // console.log(event.data);
|
||||||
//
|
//
|
||||||
// }
|
// }
|
||||||
if(event.data.type == "Train_Hmi_3D"){
|
if(event.data.type == "Device_Load_Destroy_3D"){
|
||||||
trainhmi(event.data);
|
DeviceDestroy(event.data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,6 +77,7 @@ export function Jlmap3dSubscribeNew(jlmap3d,routegroup,jsonwebwork) {
|
|||||||
// }
|
// }
|
||||||
if (event.data.type== 'SIGNAL' && signallist) {
|
if (event.data.type== 'SIGNAL' && signallist) {
|
||||||
signalupdate(event.data);
|
signalupdate(event.data);
|
||||||
|
console.log(event.data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,9 +250,11 @@ export function Jlmap3dSubscribeNew(jlmap3d,routegroup,jsonwebwork) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function trainhmi(data){
|
function DeviceDestroy(data){
|
||||||
// console.log(data);
|
console.log(data);
|
||||||
for(let i=0,leni=data.body.length;i<leni;i++){
|
for(let i=0,leni=data.body.length;i<leni;i++){
|
||||||
|
|
||||||
|
if(data.body[i].type == "TRAIN"){
|
||||||
code =data.body[i].code;
|
code =data.body[i].code;
|
||||||
if (trainlisttest.list[code].dispose != data.body[i].dispose && data.body[i].dispose == "0") {
|
if (trainlisttest.list[code].dispose != data.body[i].dispose && data.body[i].dispose == "0") {
|
||||||
|
|
||||||
@ -291,6 +294,19 @@ export function Jlmap3dSubscribeNew(jlmap3d,routegroup,jsonwebwork) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(data.body[i].type == "SIGNAL"){
|
||||||
|
signalupdate(data.body[i]);
|
||||||
|
}
|
||||||
|
if(data.body[i].type == "SWITCH"){
|
||||||
|
switchupdate(data.body[i]);
|
||||||
|
}
|
||||||
|
if(data.body[i].type == "PSD"){
|
||||||
|
standupdate(data.body[i]);
|
||||||
|
}
|
||||||
|
if(data.body[i].type == "TRAIN_DOOR"){
|
||||||
|
traindoorupdate(data.body[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function traindoorupdate(data){
|
function traindoorupdate(data){
|
||||||
@ -431,7 +447,7 @@ export function Jlmap3dSubscribeNew(jlmap3d,routegroup,jsonwebwork) {
|
|||||||
}
|
}
|
||||||
function signalupdate(data) {
|
function signalupdate(data) {
|
||||||
code = data.code;
|
code = data.code;
|
||||||
if(data.redOpen == 1){
|
if(data.red == 1){
|
||||||
signallist.list[code].mesh.getObjectByName("red").material.map = materials[0];
|
signallist.list[code].mesh.getObjectByName("red").material.map = materials[0];
|
||||||
signallist.list[code].mesh.getObjectByName("red").material.map.needsUpdate = true;
|
signallist.list[code].mesh.getObjectByName("red").material.map.needsUpdate = true;
|
||||||
}else{
|
}else{
|
||||||
@ -439,7 +455,7 @@ export function Jlmap3dSubscribeNew(jlmap3d,routegroup,jsonwebwork) {
|
|||||||
signallist.list[code].mesh.getObjectByName("green").material.map.needsUpdate = true;
|
signallist.list[code].mesh.getObjectByName("green").material.map.needsUpdate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(data.yellowOpen == 1){
|
if(data.yellow == 1){
|
||||||
signallist.list[code].mesh.getObjectByName("yellow").material.map = materials[1];
|
signallist.list[code].mesh.getObjectByName("yellow").material.map = materials[1];
|
||||||
signallist.list[code].mesh.getObjectByName("yellow").material.map.needsUpdate = true;
|
signallist.list[code].mesh.getObjectByName("yellow").material.map.needsUpdate = true;
|
||||||
|
|
||||||
@ -449,7 +465,7 @@ export function Jlmap3dSubscribeNew(jlmap3d,routegroup,jsonwebwork) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(data.greenOpen == 1){
|
if(data.green == 1){
|
||||||
signallist.list[code].mesh.getObjectByName("green").material.map = materials[2];
|
signallist.list[code].mesh.getObjectByName("green").material.map = materials[2];
|
||||||
signallist.list[code].mesh.getObjectByName("green").material.map.needsUpdate = true;
|
signallist.list[code].mesh.getObjectByName("green").material.map.needsUpdate = true;
|
||||||
|
|
||||||
|
@ -58,7 +58,6 @@ export function DriverLoad(data,scope,netdata,sectionlist,linklist,signallist,st
|
|||||||
let mapdata = data.data;
|
let mapdata = data.data;
|
||||||
// console.log(data);
|
// console.log(data);
|
||||||
//初始化轨道和道岔 暂时
|
//初始化轨道和道岔 暂时
|
||||||
console.log(data);
|
|
||||||
lengthfact(data.data);
|
lengthfact(data.data);
|
||||||
|
|
||||||
linklist = new LinkList();
|
linklist = new LinkList();
|
||||||
@ -154,7 +153,6 @@ export function DriverLoad(data,scope,netdata,sectionlist,linklist,signallist,st
|
|||||||
|
|
||||||
function lengthfact(data){
|
function lengthfact(data){
|
||||||
let linklist = [];
|
let linklist = [];
|
||||||
console.log(data.linkList);
|
|
||||||
for(let i=0;i<data.linkList.length;i++){
|
for(let i=0;i<data.linkList.length;i++){
|
||||||
|
|
||||||
let dx = Math.abs(data.linkList[i].lp.x - data.linkList[i].rp.x);
|
let dx = Math.abs(data.linkList[i].lp.x - data.linkList[i].rp.x);
|
||||||
|
@ -97,7 +97,7 @@ export function DriverLoadNew(data,scope,netdata,mapdata,sectionlist,signallist,
|
|||||||
.then(function(data){
|
.then(function(data){
|
||||||
//console.log(data);
|
//console.log(data);
|
||||||
//console.log(assetloader);
|
//console.log(assetloader);
|
||||||
return trainlisttest.initpromise(mapdata.trainList,sceneload,assetloader,mixers,actions,"01");
|
return trainlisttest.drivertrain(mapdata.trainList,sceneload,assetloader,mixers,actions,"01");
|
||||||
})
|
})
|
||||||
.then(function(data){
|
.then(function(data){
|
||||||
return new Promise(function(resolve, reject){
|
return new Promise(function(resolve, reject){
|
||||||
@ -124,7 +124,7 @@ export function DriverLoadNew(data,scope,netdata,mapdata,sectionlist,signallist,
|
|||||||
// // mapdata = jlmap3ddata;
|
// // mapdata = jlmap3ddata;
|
||||||
backdata.loaderdata(sectionlist,linklist,signallist,stationstandlist,trainlisttest,realsectionlist,rails);
|
backdata.loaderdata(sectionlist,linklist,signallist,stationstandlist,trainlisttest,realsectionlist,rails);
|
||||||
scope.Subscribe.updatamap(sectionlist,linklist,signallist,stationstandlist,trainlisttest,realsectionlist,rails,scope.materiallist,scope.actions,scope.sceneload);
|
scope.Subscribe.updatamap(sectionlist,linklist,signallist,stationstandlist,trainlisttest,realsectionlist,rails,scope.materiallist,scope.actions,scope.sceneload);
|
||||||
// scope.webwork.postMessage("on");
|
scope.webwork.postMessage("on");
|
||||||
// console.log(stationstandlist);
|
// console.log(stationstandlist);
|
||||||
// updatemenulist(stationstandlist.list,trainlisttest.list);
|
// updatemenulist(stationstandlist.list,trainlisttest.list);
|
||||||
loadingInstance.close();
|
loadingInstance.close();
|
||||||
|
@ -12,6 +12,141 @@ export function TrainListN() {
|
|||||||
this.group.name = "train";
|
this.group.name = "train";
|
||||||
this.textlist = [];
|
this.textlist = [];
|
||||||
|
|
||||||
|
this.drivertrain = function(data,scene,assetloader,mixers,actionss,mode){
|
||||||
|
|
||||||
|
return new Promise(function(resolve, reject){
|
||||||
|
|
||||||
|
|
||||||
|
let selectmesh,ntracks1,ntracks2,tclip,fclip;
|
||||||
|
for(let n=assetloader.modellist.length-1;n>=0;n--){
|
||||||
|
if(assetloader.modellist[n].deviceType == "train"){
|
||||||
|
|
||||||
|
selectmesh = assetloader.modellist[n].mesh
|
||||||
|
|
||||||
|
ntracks1 = assetloader.modellist[n].animations.slice(16,27);
|
||||||
|
|
||||||
|
tclip = new THREE.AnimationClip("three",2,ntracks1);
|
||||||
|
|
||||||
|
ntracks2 = assetloader.modellist[n].animations.slice(0,15);
|
||||||
|
|
||||||
|
fclip = new THREE.AnimationClip("four",2,ntracks2);
|
||||||
|
|
||||||
|
n = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
actionss["traindoor"] = {
|
||||||
|
top:[],
|
||||||
|
down:[]
|
||||||
|
};
|
||||||
|
let newmesh = selectmesh.clone(true);
|
||||||
|
newmesh.mixer = [];
|
||||||
|
|
||||||
|
for(let j=0;j<newmesh.children.length;j++){
|
||||||
|
|
||||||
|
if(newmesh.children[j].name == "c1" || newmesh.children[j].name == "c6"){
|
||||||
|
// console.log("===================");
|
||||||
|
for(let n=0,lenn = newmesh.children[j].children.length;n<lenn;n++){
|
||||||
|
|
||||||
|
if(newmesh.children[j].children[n].name == "top"){
|
||||||
|
newmesh.children[j].children[n].animations = [];
|
||||||
|
newmesh.children[j].children[n].animations.push(tclip.clone());
|
||||||
|
let mixer = new THREE.AnimationMixer( newmesh.children[j].children[n] );
|
||||||
|
// console.log(n);
|
||||||
|
// console.log(newmesh.children[j].children[n]);
|
||||||
|
newmesh.mixer.push(mixer);
|
||||||
|
newmesh.mixerpush = false;
|
||||||
|
|
||||||
|
let action = mixer.clipAction( newmesh.children[j].children[n].animations[ 0 ] );
|
||||||
|
//action.play();
|
||||||
|
action.setLoop(THREE.LoopOnce);
|
||||||
|
action.clampWhenFinished = true;
|
||||||
|
actionss["traindoor"].top.push(action);
|
||||||
|
mixers.push(mixer);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(newmesh.children[j].children[n].name == "down"){
|
||||||
|
newmesh.children[j].children[n].animations = [];
|
||||||
|
newmesh.children[j].children[n].animations.push(tclip.clone());
|
||||||
|
let mixer = new THREE.AnimationMixer( newmesh.children[j].children[n] );
|
||||||
|
|
||||||
|
newmesh.mixer.push(mixer);
|
||||||
|
newmesh.mixerpush = false;
|
||||||
|
|
||||||
|
let action = mixer.clipAction( newmesh.children[j].children[n].animations[ 0 ] );
|
||||||
|
//action.play();
|
||||||
|
action.setLoop(THREE.LoopOnce);
|
||||||
|
action.clampWhenFinished = true;
|
||||||
|
actionss["traindoor"].down.push(action);
|
||||||
|
mixers.push(mixer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
for(let n=0,lenn = newmesh.children[j].children.length;n<lenn;n++){
|
||||||
|
if(newmesh.children[j].children[n].name == "top"){
|
||||||
|
newmesh.children[j].children[n].animations = [];
|
||||||
|
newmesh.children[j].children[n].animations.push(fclip.clone());
|
||||||
|
let mixer = new THREE.AnimationMixer( newmesh.children[j].children[n] );
|
||||||
|
newmesh.mixer.push(mixer);
|
||||||
|
newmesh.mixerpush = false;
|
||||||
|
let action = mixer.clipAction( newmesh.children[j].children[n].animations[ 0 ] );
|
||||||
|
//action.play();
|
||||||
|
action.setLoop(THREE.LoopOnce);
|
||||||
|
action.clampWhenFinished = true;
|
||||||
|
actionss["traindoor"].top.push(action);
|
||||||
|
mixers.push(mixer);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(newmesh.children[j].children[n].name == "down"){
|
||||||
|
newmesh.children[j].children[n].animations = [];
|
||||||
|
newmesh.children[j].children[n].animations.push(fclip.clone());
|
||||||
|
let mixer = new THREE.AnimationMixer( newmesh.children[j].children[n] );
|
||||||
|
newmesh.mixer.push(mixer);
|
||||||
|
newmesh.mixerpush = false;
|
||||||
|
let action = mixer.clipAction( newmesh.children[j].children[n].animations[ 0 ] );
|
||||||
|
//action.play();
|
||||||
|
action.setLoop(THREE.LoopOnce);
|
||||||
|
action.clampWhenFinished = true;
|
||||||
|
actionss["traindoor"].down.push(action);
|
||||||
|
mixers.push(mixer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
newmesh.children[j].axis = new THREE.Vector3();
|
||||||
|
newmesh.children[j].up = new THREE.Vector3(1, 0, 0);
|
||||||
|
// newmesh.axis = new THREE.Vector3();
|
||||||
|
// newmesh.up = new THREE.Vector3(1, 0, 0);
|
||||||
|
// var pos = new THREE.Mesh( geometryp, materialp);
|
||||||
|
// pos.position.x = -73.5;
|
||||||
|
// newmesh.children[j].add( pos );
|
||||||
|
newmesh.children[j].rotalist = [];
|
||||||
|
// console.log(newmesh);
|
||||||
|
}
|
||||||
|
|
||||||
|
newmesh.first = false;
|
||||||
|
newmesh.name = "drivetrain";
|
||||||
|
newmesh.code = "";
|
||||||
|
newmesh.groupNumber = "";
|
||||||
|
newmesh.right = "3";
|
||||||
|
newmesh.position.set(0,0,0);
|
||||||
|
newmesh.status = "00";
|
||||||
|
newmesh.nowcode = null;
|
||||||
|
newmesh.nowsection = null;
|
||||||
|
newmesh.curve = null;
|
||||||
|
newmesh.doorStatus = "01";
|
||||||
|
newmesh.speed = 0;
|
||||||
|
newmesh.speeds = 0;
|
||||||
|
newmesh.offset = null;
|
||||||
|
newmesh.open = '3';
|
||||||
|
|
||||||
|
|
||||||
|
scope.group.add(newmesh);
|
||||||
|
scope.list[0] = newmesh;
|
||||||
|
scene.add(scope.group);
|
||||||
|
resolve("loadedtrain");
|
||||||
|
});
|
||||||
|
}
|
||||||
this.initpromise = function(data,scene,assetloader,mixers,actionss,mode){
|
this.initpromise = function(data,scene,assetloader,mixers,actionss,mode){
|
||||||
return new Promise(function(resolve, reject){
|
return new Promise(function(resolve, reject){
|
||||||
let selectmesh,ntracks1,ntracks2,tclip,fclip;
|
let selectmesh,ntracks1,ntracks2,tclip,fclip;
|
||||||
@ -186,7 +321,6 @@ export function TrainListN() {
|
|||||||
newmesh.open = null;
|
newmesh.open = null;
|
||||||
newmesh.statsstop = 0;
|
newmesh.statsstop = 0;
|
||||||
|
|
||||||
|
|
||||||
scope.list[data[i].code] = newmesh;
|
scope.list[data[i].code] = newmesh;
|
||||||
//scene.add(newmesh);
|
//scene.add(newmesh);
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,9 @@ export function getBaseUrl() {
|
|||||||
let BASE_API;
|
let BASE_API;
|
||||||
if (process.env.NODE_ENV === 'development') {
|
if (process.env.NODE_ENV === 'development') {
|
||||||
// BASE_API = 'https://joylink.club/jlcloud';
|
// BASE_API = 'https://joylink.club/jlcloud';
|
||||||
BASE_API = 'https://test.joylink.club/jlcloud';
|
// BASE_API = 'https://test.joylink.club/jlcloud';
|
||||||
// BASE_API = 'http://192.168.3.5:9000'; // 袁琪
|
// BASE_API = 'http://192.168.3.5:9000'; // 袁琪
|
||||||
// BASE_API = 'http://192.168.3.6:9000'; // 旭强
|
BASE_API = 'http://192.168.3.6:9000'; // 旭强
|
||||||
// BASE_API = 'http://192.168.3.41:9000'; // 张赛
|
// BASE_API = 'http://192.168.3.41:9000'; // 张赛
|
||||||
// BASE_API = 'http://192.168.3.82:9000'; // 杜康
|
// BASE_API = 'http://192.168.3.82:9000'; // 杜康
|
||||||
// BASE_API = 'http://b29z135112.zicp.vip';
|
// BASE_API = 'http://b29z135112.zicp.vip';
|
||||||
|
@ -691,6 +691,12 @@ function timedCount(){
|
|||||||
// postMessage(data.body[i]);
|
// postMessage(data.body[i]);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
if(data.type == "Device_Load_Destroy_3D"){
|
||||||
|
postMessage(data);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(data.type == 'TrainRun_3D'){
|
if(data.type == 'TrainRun_3D'){
|
||||||
postMessage(data);
|
postMessage(data);
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user