新数据三维仿真优化
This commit is contained in:
parent
a87d551751
commit
d3d1909a82
@ -1,5 +1,5 @@
|
||||
export function SetCamera(dom) {
|
||||
var camera = new THREE.PerspectiveCamera(60, dom.clientWidth/dom.clientHeight, 1, 3000);
|
||||
var camera = new THREE.PerspectiveCamera(60, dom.clientWidth/dom.clientHeight, 1, 2000);
|
||||
camera.position.set( 0, 0, 0 );
|
||||
camera.aspect = window.innerWidth / window.innerHeight;
|
||||
camera.updateProjectionMatrix();
|
||||
|
@ -1,9 +1,5 @@
|
||||
export function SetRender(dom) {
|
||||
var renderer = new THREE.WebGLRenderer({antialias: true});
|
||||
var renderer = new THREE.WebGLRenderer();//{antialias: true}
|
||||
renderer.setSize(dom.offsetWidth, dom.offsetHeight);
|
||||
// renderer.gammaInput = true;
|
||||
// renderer.gammaOutput = true;
|
||||
// renderer.setPixelRatio( window.devicePixelRatio );
|
||||
//renderer.setSize( window.innerWidth, window.innerHeight );
|
||||
return renderer;
|
||||
}
|
||||
|
@ -13,11 +13,11 @@ export function SetScene(project) {
|
||||
var bgTexture;
|
||||
// console.log(project);
|
||||
if(project == "login" || project == undefined){
|
||||
bgTexture = new THREE.TextureLoader().load("../../static/background/background.jpg");
|
||||
bgTexture = new THREE.TextureLoader().load("../../static/background/other.jpg");
|
||||
}else if(project == "hyd"){
|
||||
bgTexture = new THREE.TextureLoader().load("../../static/background/other.jpg");
|
||||
}
|
||||
scene.background = bgTexture;
|
||||
// cubeTexture.dispose();
|
||||
// cubeTexture.dispos e();
|
||||
return scene;
|
||||
}
|
||||
|
@ -56,7 +56,6 @@ export function getmodels(data) {
|
||||
// postmap.sections.link = JSON.stringify(links);
|
||||
|
||||
//section隧道
|
||||
console.log(data.mapdata.sectionlist.sections);
|
||||
let sections = [];
|
||||
|
||||
for(let i=0;i<data.mapdata.sectionlist.sections.datalist.length;i++){
|
||||
|
@ -57,15 +57,14 @@ export function getmodels(data) {
|
||||
|
||||
//section隧道
|
||||
let sections = [];
|
||||
console.log(data.mapdata.sectionlist.sections.datalist);
|
||||
// console.log(data.mapdata.sectionlist.sections.datalist);
|
||||
for(let i in data.mapdata.sectionlist.sections.datalist){
|
||||
|
||||
console.log(data.mapdata.sectionlist.sections.datalist[i]);
|
||||
let section = {
|
||||
// uuid:data.mapdata.sectionlist.sections.modellist[i].uuid,
|
||||
code:data.mapdata.sectionlist.sections.datalist[i].code,
|
||||
name:data.mapdata.sectionlist.sections.datalist[i].name,
|
||||
lengthFact:data.mapdata.sectionlist.sections.datalist[i].lengthFact,
|
||||
lengthFact:data.mapdata.sectionlist.sections.datalist[i].mesh.lengthFact,
|
||||
standTrack:data.mapdata.sectionlist.sections.datalist[i].standTrack,
|
||||
rightlist:data.mapdata.sectionlist.sections.datalist[i].rightlist,
|
||||
leftlist:data.mapdata.sectionlist.sections.datalist[i].leftlist,
|
||||
|
@ -877,8 +877,8 @@ export function SectionList() {
|
||||
name:sectiondata[i].name,
|
||||
standTrack:sectiondata[i].standTrack,
|
||||
rail:sectiondata[i].rail,
|
||||
rightlist:sectiondata[i].rightlist,
|
||||
leftlist:sectiondata[i].leftlist,
|
||||
rightlist:rightlist,
|
||||
leftlist:leftlist,
|
||||
rsection:sectiondata[i].rsection,
|
||||
lsection:sectiondata[i].lsection,
|
||||
csection:sectiondata[i].csection,
|
||||
@ -889,7 +889,9 @@ export function SectionList() {
|
||||
};
|
||||
|
||||
let len = newsection.lengthFact;
|
||||
|
||||
if(sectiondata[i].code == "T208"){
|
||||
console.log(newsection.lengthFact);
|
||||
}
|
||||
let testmesh2 = autorail.clone(true);
|
||||
for(let i=0;i<autorail.rightlist.length;i++){
|
||||
testmesh2.geometry.attributes.position.array[autorail.rightlist[i]*3] = len;
|
||||
@ -906,8 +908,9 @@ export function SectionList() {
|
||||
testmesh2.geometry.computeBoundingSphere();
|
||||
testmesh2.geometry.center();
|
||||
testmesh2.code = newsection.code;
|
||||
testmesh2.rightlist = sectiondata[i].rightlist,
|
||||
testmesh2.leftlist = sectiondata[i].leftlist,
|
||||
testmesh2.rightlist = sectiondata[i].rightlist;
|
||||
testmesh2.leftlist = sectiondata[i].leftlist;
|
||||
testmesh2.lengthFact = newsection.lengthFact;
|
||||
testmesh2.position.set(sectiondata[i].position.x,sectiondata[i].position.y,sectiondata[i].position.z);
|
||||
testmesh2.rotation.set(sectiondata[i].rotation._x,sectiondata[i].rotation._y,sectiondata[i].rotation._z);
|
||||
scope.sectiongroup.add(testmesh2);
|
||||
|
@ -43,48 +43,68 @@ export function Jlmap3dSubscribeNew(jlmap3d,routegroup,jsonwebwork) {
|
||||
this.teststomp = new StompClient();
|
||||
this.topic = '/user/queue/simulation/jl3d/'+routegroup;
|
||||
let header = {'X-Token': getToken() };
|
||||
let connectmsg = {
|
||||
type:'init',
|
||||
baseurl:getBaseUrl(),
|
||||
topic:this.topic,
|
||||
token:getToken(),
|
||||
};
|
||||
jsonwebwork.postMessage(connectmsg);
|
||||
let connectmsg = {
|
||||
type:'init',
|
||||
baseurl:getBaseUrl(),
|
||||
topic:this.topic,
|
||||
token:getToken(),
|
||||
};
|
||||
jsonwebwork.postMessage(connectmsg);
|
||||
jsonwebwork.onmessage = function (event) {
|
||||
// console.log(event.data);
|
||||
|
||||
if(event.data.type == 'Simulation_DeviceStatus'){
|
||||
// console.log(event.data);
|
||||
initall(event.data.body);
|
||||
}
|
||||
|
||||
// if(event.data.deviceType == "TRAIN"){
|
||||
// // console.log(event.data);
|
||||
//
|
||||
// }
|
||||
if(event.data.type == "Train_Hmi_3D"){
|
||||
trainhmi(event.data);
|
||||
return;
|
||||
}
|
||||
if(event.data.type == 'TRAIN'){
|
||||
// console.log(event.data);
|
||||
trainrun(event.data);
|
||||
}
|
||||
|
||||
if(event.data.type == 'TrainRun_3D'){
|
||||
for(let i=0,leni=event.data.body.length;i<leni;i++){
|
||||
// console.log(event.data.body[i]);
|
||||
trainrun(event.data.body[i]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// if(event.data.type == 'TRAIN'){
|
||||
// // console.log(event.data);
|
||||
// trainrun(event.data);
|
||||
// }
|
||||
if (event.data.type== 'SIGNAL' && signallist) {
|
||||
// console.log(event.data);
|
||||
signalupdate(event.data);
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.data.type== "PSD" && actions) {
|
||||
// console.log(event.data);
|
||||
// console.log(actions);
|
||||
standupdate(event.data);
|
||||
return;
|
||||
}
|
||||
if(event.data.type == "SWITCH"){
|
||||
if (event.data.type == "SWITCH") {
|
||||
switchupdate(event.data);
|
||||
return;
|
||||
}
|
||||
if (event.data.type == 'TRAIN_DOOR') {
|
||||
// console.log(event.data);
|
||||
traindoorupdate(event.data);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(event.data.type == 'Simulation_Reset'){
|
||||
simulationreset(event.data);
|
||||
return;
|
||||
}
|
||||
if(event.data.type == 'Simulation_DeviceStatus'){
|
||||
// console.log(event.data);
|
||||
initall(event.data.body);
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
@ -116,7 +136,7 @@ export function Jlmap3dSubscribeNew(jlmap3d,routegroup,jsonwebwork) {
|
||||
if (trainlisttest.group.children[i].dispose == false) {
|
||||
code = trainlisttest.group.children[i].name;
|
||||
trainlisttest.list[code].rotation.y = 0;
|
||||
trainlisttest.list[code].doorCloseLock = '1';
|
||||
trainlisttest.list[code].open = '1';
|
||||
trainlisttest.list[code].speed = 0;
|
||||
trainlisttest.group.children[i].dispose = true;
|
||||
trainlisttest.group.children[i].position.x = -50000;
|
||||
@ -133,7 +153,12 @@ export function Jlmap3dSubscribeNew(jlmap3d,routegroup,jsonwebwork) {
|
||||
let code = data.code;
|
||||
if(trainlisttest.list[code].dispose == "0"){
|
||||
if(trainlisttest.list[code].curve == null){
|
||||
|
||||
if(trainlisttest.list[code].groupNumber == "020"){
|
||||
console.log("===============================");
|
||||
console.log(trainlisttest.list[code].children[0]);
|
||||
console.log(trainlisttest.list[code].children[0].matrixWorld.elements[14]);
|
||||
console.log(trainlisttest.list[code].children[0].position.z);
|
||||
}
|
||||
if (data.right == '1') { // 向右
|
||||
|
||||
trainlisttest.list[code].progress = data.offset;
|
||||
@ -146,7 +171,7 @@ export function Jlmap3dSubscribeNew(jlmap3d,routegroup,jsonwebwork) {
|
||||
trainlisttest.list[code].position.x = point.x;
|
||||
trainlisttest.list[code].position.y = 0;
|
||||
for (let tl=0; tl<6; tl++) {
|
||||
trainlisttest.list[code].children[tl].position.z = point.z;
|
||||
trainlisttest.list[code].children[tl].position.z = parseFloat(point.z);
|
||||
}
|
||||
|
||||
trainlisttest.list[code].curve = rails.sectionrail[data.section].lineleft;
|
||||
@ -172,7 +197,7 @@ export function Jlmap3dSubscribeNew(jlmap3d,routegroup,jsonwebwork) {
|
||||
trainlisttest.list[code].position.y = 0;
|
||||
|
||||
for (let tl=0; tl<6; tl++) {
|
||||
trainlisttest.list[code].children[tl].position.z = -point.z;
|
||||
trainlisttest.list[code].children[tl].position.z = parseFloat(-point.z);
|
||||
}
|
||||
|
||||
trainlisttest.list[code].curve = rails.sectionrail[data.section].lineright;
|
||||
@ -187,7 +212,6 @@ export function Jlmap3dSubscribeNew(jlmap3d,routegroup,jsonwebwork) {
|
||||
|
||||
|
||||
}else{
|
||||
|
||||
if(data.next != trainlisttest.list[code].nextcode){
|
||||
// console.log(rails.sectionrail[data.next]);
|
||||
if (data.right == '1') { // 向右
|
||||
@ -201,17 +225,17 @@ export function Jlmap3dSubscribeNew(jlmap3d,routegroup,jsonwebwork) {
|
||||
trainlisttest.list[code].nextlen = rails.sectionrail[data.next].lengthfact;
|
||||
trainlisttest.list[code].nextissection = rails.sectionrail[data.next].standTrack;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if(data.speed == 0){
|
||||
trainlisttest.list[code].speeds = data.speed;
|
||||
// console.log(data);
|
||||
// trainlisttest.list[code].speeds = data.speed;
|
||||
trainlisttest.list[code].speeds = 0;
|
||||
trainlisttest.list[code].statsstop = 0;
|
||||
}else{
|
||||
// console.log(data.speed);
|
||||
// console.log(trainlisttest.list[code]);
|
||||
trainlisttest.list[code].speeds = data.speed;
|
||||
// trainlisttest.list[code].speeds = data.speed;
|
||||
trainlisttest.list[code].speeds = parseFloat(data.speed*10/36/18/trainlisttest.list[code].len);
|
||||
}
|
||||
if(data.right != trainlisttest.list[code].status){
|
||||
@ -271,7 +295,7 @@ export function Jlmap3dSubscribeNew(jlmap3d,routegroup,jsonwebwork) {
|
||||
trainlisttest.list[code].dispose = "1";
|
||||
code = trainlisttest.group.children[i].name;
|
||||
trainlisttest.list[code].rotation.y = 0;
|
||||
trainlisttest.list[code].doorCloseLock = '1';
|
||||
trainlisttest.list[code].open = '1';
|
||||
trainlisttest.list[code].curve = null;
|
||||
trainlisttest.list[code].nextcurve = null;
|
||||
trainlisttest.list[code].speed = 0;
|
||||
@ -283,6 +307,52 @@ export function Jlmap3dSubscribeNew(jlmap3d,routegroup,jsonwebwork) {
|
||||
}
|
||||
}
|
||||
|
||||
function traindoorupdate(data){
|
||||
let code = data.code;
|
||||
if(data.doorCode == "0"){
|
||||
|
||||
if(trainlisttest.list[code].open != data.open && data.open == "0"){
|
||||
//console.log("close");
|
||||
trainlisttest.list[code].open = "0";
|
||||
for(let an=actions[code].down.length-1;an>=0;an--){
|
||||
actions[code].down[an].reset();
|
||||
actions[code].down[an].time = actions[code].top[an]._clip.duration;
|
||||
actions[code].down[an].timeScale = -1;
|
||||
actions[code].down[an].play();
|
||||
}
|
||||
}else if(trainlisttest.list[code].open != data.open && data.open == "1"){
|
||||
//console.log("open");
|
||||
trainlisttest.list[code].open = "1";
|
||||
for(let an=actions[code].down.length-1;an>=0;an--){
|
||||
actions[code].down[an].reset();
|
||||
actions[code].down[an].time = 0;
|
||||
actions[code].down[an].timeScale = 1;
|
||||
actions[code].down[an].play();
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if (trainlisttest.list[code].open != data.open && data.open == '0') {
|
||||
// console.log("close");
|
||||
trainlisttest.list[code].open = '0';
|
||||
for (let an=actions[code].top.length-1; an>=0; an--) {
|
||||
actions[code].top[an].reset();
|
||||
actions[code].top[an].time = actions[code].top[an]._clip.duration;
|
||||
actions[code].top[an].timeScale = -1;
|
||||
actions[code].top[an].play();
|
||||
}
|
||||
} else if (trainlisttest.list[code].open != data.open && data.open == '1') {
|
||||
trainlisttest.list[code].open = "1";
|
||||
for(let an=actions[code].top.length-1;an>=0;an--){
|
||||
actions[code].top[an].reset();
|
||||
actions[code].top[an].time = 0;
|
||||
actions[code].top[an].timeScale = 1;
|
||||
actions[code].top[an].play();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function trainstatus(data){
|
||||
// 遍历列车对象组
|
||||
@ -296,47 +366,6 @@ export function Jlmap3dSubscribeNew(jlmap3d,routegroup,jsonwebwork) {
|
||||
trainlisttest.list[code].driveMode = data.driveMode;
|
||||
trainlisttest.list[code].status = data.right;
|
||||
// 车门开关验证
|
||||
if(data.right == "1"){
|
||||
// console.log(data);
|
||||
if (trainlisttest.list[code].doorCloseLock != data.doorCloseLock && data.doorCloseLock == '1') {
|
||||
// console.log("close");
|
||||
trainlisttest.list[code].doorCloseLock = '1';
|
||||
for (let an=actions[code].top.length-1; an>=0; an--) {
|
||||
actions[code].top[an].reset();
|
||||
actions[code].top[an].time = actions[code].top[an]._clip.duration;
|
||||
actions[code].top[an].timeScale = -1;
|
||||
actions[code].top[an].play();
|
||||
}
|
||||
} else if (trainlisttest.list[code].doorCloseLock != data.doorCloseLock && data.doorCloseLock == '0') {
|
||||
trainlisttest.list[code].doorCloseLock = "0";
|
||||
for(let an=actions[code].down.length-1;an>=0;an--){
|
||||
actions[code].down[an].reset();
|
||||
actions[code].down[an].time = 0;
|
||||
actions[code].down[an].timeScale = 1;
|
||||
actions[code].down[an].play();
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if(trainlisttest.list[code].doorCloseLock != data.doorCloseLock && data.doorCloseLock == "1"){
|
||||
//console.log("close");
|
||||
trainlisttest.list[code].doorCloseLock = "1";
|
||||
for(let an=actions[code].down.length-1;an>=0;an--){
|
||||
actions[code].down[an].reset();
|
||||
actions[code].down[an].time = actions[code].top[an]._clip.duration;
|
||||
actions[code].down[an].timeScale = -1;
|
||||
actions[code].down[an].play();
|
||||
}
|
||||
}else if(trainlisttest.list[code].doorCloseLock != data.doorCloseLock && data.doorCloseLock == "0"){
|
||||
//console.log("open");
|
||||
trainlisttest.list[code].doorCloseLock = "0";
|
||||
for(let an=actions[code].down.length-1;an>=0;an--){
|
||||
actions[code].down[an].reset();
|
||||
actions[code].down[an].time = 0;
|
||||
actions[code].down[an].timeScale = 1;
|
||||
actions[code].down[an].play();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 遍历获取所在轨道
|
||||
@ -370,7 +399,7 @@ export function Jlmap3dSubscribeNew(jlmap3d,routegroup,jsonwebwork) {
|
||||
trainlisttest.list[code].dispose = "1";
|
||||
code = trainlisttest.group.children[i].name;
|
||||
trainlisttest.list[code].rotation.y = 0;
|
||||
trainlisttest.list[code].doorCloseLock = '1';
|
||||
trainlisttest.list[code].open = '1';
|
||||
trainlisttest.list[code].curve = null;
|
||||
trainlisttest.list[code].nextcurve = null;
|
||||
trainlisttest.list[code].speed = 0;
|
||||
|
744
src/jlmap3d/jl3dsimulation/connect/TrainingConnect.js
Normal file
744
src/jlmap3d/jl3dsimulation/connect/TrainingConnect.js
Normal file
@ -0,0 +1,744 @@
|
||||
import StompClient from '@/utils/sock';
|
||||
|
||||
// import { getTrainingCbtcDemon, runDiagramStart, runDiagramOver, setTrainingCbtcInitTime } from '@/api/simulation';
|
||||
// import { creatSubscribe, clearSubscribe, displayTopic, screenTopic } from '@/utils/stomp';
|
||||
import { getBaseUrl } from '@/utils/baseUrl'
|
||||
import { getToken } from '@/utils/auth';
|
||||
|
||||
// 定于仿真socket接口
|
||||
export function Jlmap3dSubscribe(jlmap3d,routegroup,jsonwebwork) {
|
||||
|
||||
const scope = this;
|
||||
this.map = null;
|
||||
|
||||
var trainlisttest = null;
|
||||
var sectionlist = null;
|
||||
var signallist = null;
|
||||
var stationstandlist = null;
|
||||
var sectionlist = null;
|
||||
var materials = null;
|
||||
var actions = null;
|
||||
var rails = null;
|
||||
var links = null;
|
||||
|
||||
var scenes = null;
|
||||
|
||||
var code = null;
|
||||
|
||||
var drivingcode = null;
|
||||
var drivingspeed = null;
|
||||
var drivingaptspeed = null;
|
||||
|
||||
let driverswitch = false;
|
||||
|
||||
let stoptimer = null;
|
||||
let num = 30;
|
||||
let pointstand = null;
|
||||
|
||||
let data = null;
|
||||
// run as plane = 01;
|
||||
// reset = 02;
|
||||
|
||||
var datatype = '00';
|
||||
this.teststomp = new StompClient();
|
||||
this.topic = '/user/queue/simulation/jl3d/'+routegroup;
|
||||
let header = {'X-Token': getToken() };
|
||||
let connectmsg = {
|
||||
type:'init',
|
||||
baseurl:getBaseUrl(),
|
||||
topic:this.topic,
|
||||
token:getToken(),
|
||||
};
|
||||
jsonwebwork.postMessage(connectmsg);
|
||||
jsonwebwork.onmessage = function (event) {
|
||||
|
||||
// if(event.data.type == 'Simulation_Driver_Change'){
|
||||
// drivingcode = event.data.body.code;
|
||||
// jlmap3d.updatedrivingcode( event.data.body.code);
|
||||
// }
|
||||
// if(data.type == 'Simulation_TrainSpeed'){
|
||||
// trainspeed(data);
|
||||
// }
|
||||
// console.log(event);
|
||||
// if(event.data.type == 'SJL3D_TrainStatus'){
|
||||
// trainstatus(event.data);
|
||||
// }
|
||||
// if(event.data.type == 'Simulation_DeviceStatus'){
|
||||
// devicestatus(event.data);
|
||||
// }
|
||||
if(event.data._type == 'Simulation_Driver_Change'){
|
||||
drivingcode = event.data.body.code;
|
||||
jlmap3d.updatedrivingcode( event.data.body.code);
|
||||
}
|
||||
if(event.data._type == 'Train'){
|
||||
// console.log(event.data);
|
||||
trainstatus(event.data);
|
||||
}
|
||||
if (event.data._type== 'Signal' && signallist) {
|
||||
// console.log(event.data);
|
||||
signalupdate(event.data);
|
||||
}
|
||||
|
||||
if (event.data._type== 'StationStand' && actions) {
|
||||
// console.log(event.data);
|
||||
standupdate(event.data);
|
||||
}
|
||||
|
||||
if (event.data._type == 'Switch' && sectionlist) {
|
||||
// console.log(event.data);
|
||||
switchupdate(event.data);
|
||||
}
|
||||
// if(event.data._type = ''){
|
||||
// trainstatus(event.data);
|
||||
// }
|
||||
// if(event.data.type == 'Simulation_DeviceStatus'){
|
||||
// devicestatus(event.data);
|
||||
// }
|
||||
if(event.data.type == 'Simulation_Reset'){
|
||||
simulationreset(event.data);
|
||||
}
|
||||
};
|
||||
|
||||
// jsonwebwork.onmessage = function (event) {
|
||||
// console.log(event.data);
|
||||
// if(event.data.type == 'Simulation_Driver_Change'){
|
||||
// drivingcode = event.data.body.code;
|
||||
// jlmap3d.updatedrivingcode( event.data.body.code);
|
||||
// }
|
||||
// // if(event.data.type == 'Simulation_TrainSpeed'){
|
||||
// // trainspeed(event.data);
|
||||
// // }
|
||||
// if(event.data.type == 'SJL3D_TrainStatus'){
|
||||
// trainstatus(event.data);
|
||||
// }
|
||||
// if(event.data.type == 'Simulation_DeviceStatus'){
|
||||
// devicestatus(event.data);
|
||||
// }
|
||||
// if(event.data.type == 'Simulation_Reset'){
|
||||
// simulationreset(event.data);
|
||||
// }
|
||||
// };
|
||||
|
||||
this.updatamap = function(newsectionlist,newlinklist,newsignallist,newstationstandlist,newtrainlisttest,newrealsectionlist,newrails, materiallist, nowaction, scene) {
|
||||
// console.log(mapdata);
|
||||
|
||||
trainlisttest = newtrainlisttest;
|
||||
sectionlist = newsectionlist;
|
||||
signallist = newsignallist;
|
||||
stationstandlist = newstationstandlist;
|
||||
materials = materiallist;
|
||||
scenes = scene;
|
||||
actions = nowaction;
|
||||
links = newlinklist;
|
||||
rails = newrails;
|
||||
|
||||
};
|
||||
|
||||
this.socketon = function(topic) {
|
||||
try {
|
||||
// console.log("teststomp");
|
||||
// scope.teststomp.subscribe(topic, callback, header);
|
||||
} catch (error) {
|
||||
console.error('websocket订阅失败');
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
this.socketoff = function(topic) {
|
||||
scope.teststomp.unsubscribe(topic);
|
||||
for (let i=0; i<trainlisttest.group.children.length; i++) {
|
||||
if (trainlisttest.group.children[i].dispose == false) {
|
||||
code = trainlisttest.group.children[i].name;
|
||||
trainlisttest.list[code].rotation.y = 0;
|
||||
trainlisttest.list[code].doorStatus = '01';
|
||||
trainlisttest.list[code].speed = 0;
|
||||
trainlisttest.group.children[i].dispose = true;
|
||||
trainlisttest.group.children[i].position.x = -50000;
|
||||
trainlisttest.group.children[i].position.y = -50000;
|
||||
|
||||
trainlisttest.group.remove(trainlisttest.group.children[i]);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 仿真socket接口回调函数
|
||||
function callback(Response) {
|
||||
|
||||
}
|
||||
|
||||
function trainspeed(data){
|
||||
if (trainlisttest) {
|
||||
|
||||
for (let tl = 0; tl<data.body.length; tl++) {
|
||||
code = data.body[tl].id;
|
||||
if(trainlisttest.list[code].speed != data.body[tl].v){
|
||||
trainlisttest.list[code].speed = data.body[tl].v;
|
||||
trainlisttest.list[code].speeds = parseFloat(data.body[tl].v*10/36/18/trainlisttest.list[code].len);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function trainstatus(data){
|
||||
// for (let i=data.body.length-1; i>=0; i--) {
|
||||
// console.log(data.body[i]);
|
||||
|
||||
// console.log(data);
|
||||
// 遍历列车对象组
|
||||
if (trainlisttest) {
|
||||
code = data.code;
|
||||
// 剔除不显示的车
|
||||
// 找到对应列车
|
||||
|
||||
|
||||
if ( trainlisttest.list[code]) {
|
||||
|
||||
trainlisttest.list[code].runMode = data.runMode;
|
||||
// 车门开关验证
|
||||
// if(data.directionType == "02"){
|
||||
if (trainlisttest.list[code].doorStatus != data.doorStatus && data.doorStatus == '01') {
|
||||
// console.log("close");
|
||||
trainlisttest.list[code].doorStatus = '01';
|
||||
for (let an=actions[code].top.length-1; an>=0; an--) {
|
||||
actions[code].top[an].reset();
|
||||
actions[code].top[an].time = actions[code].top[an]._clip.duration;
|
||||
actions[code].top[an].timeScale = -1;
|
||||
actions[code].top[an].play();
|
||||
}
|
||||
} else if (trainlisttest.list[code].doorStatus != data.doorStatus && data.doorStatus == '02') {
|
||||
// console.log("open");
|
||||
trainlisttest.list[code].doorStatus = '02';
|
||||
for (let an=actions[code].top.length-1; an>=0; an--) {
|
||||
actions[code].top[an].reset();
|
||||
actions[code].top[an].time = 0;
|
||||
actions[code].top[an].timeScale = 1;
|
||||
actions[code].top[an].play();
|
||||
}
|
||||
}
|
||||
// if(trainlisttest.list[code].doorStatus != data.doorStatus && data.doorStatus == "01"){
|
||||
// //console.log("close");
|
||||
// trainlisttest.list[code].doorStatus = "01";
|
||||
// for(let an=actions[code].down.length-1;an>=0;an--){
|
||||
// actions[code].down[an].reset();
|
||||
// actions[code].down[an].time = actions[code].top[an]._clip.duration;
|
||||
// actions[code].down[an].timeScale = -1;
|
||||
// actions[code].down[an].play();
|
||||
// }
|
||||
// }else if(trainlisttest.list[code].doorStatus != data.doorStatus && data.doorStatus == "02"){
|
||||
// //console.log("open");
|
||||
// trainlisttest.list[code].doorStatus = "02";
|
||||
// for(let an=actions[code].down.length-1;an>=0;an--){
|
||||
// actions[code].down[an].reset();
|
||||
// actions[code].down[an].time = 0;
|
||||
// actions[code].down[an].timeScale = 1;
|
||||
// actions[code].down[an].play();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// 遍历获取所在轨道
|
||||
if (trainlisttest.list[code].dispose != data.dispose && data.dispose == false) {
|
||||
|
||||
if (rails.linkrail[data.linkCode]) {
|
||||
trainlisttest.group.add(trainlisttest.list[code]);
|
||||
trainlisttest.list[code].position.y = 0;
|
||||
// trainlisttest.list[code].progress = 0;
|
||||
trainlisttest.list[code].dispose = false;
|
||||
trainlisttest.list[code].nowcode = data.linkCode;
|
||||
trainlisttest.list[code].nextcode = null;
|
||||
trainlisttest.list[code].pc = 1;
|
||||
|
||||
if(trainlisttest.list[code].mixerpush == false){
|
||||
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;
|
||||
// console.log(trainlisttest.list[code].mixerpush);
|
||||
}
|
||||
|
||||
if (data.directionType == '02') { // 向右
|
||||
|
||||
|
||||
if(data.targetStation){
|
||||
trainlisttest.list[code].stopstation = data.targetStation;
|
||||
// console.log(rails.stops[data.targetStation].direct2.percent);
|
||||
trainlisttest.list[code].pc = data.targetLinkPercent/rails.stops[data.targetStation].direct2.percent;
|
||||
trainlisttest.list[code].targetpercent = rails.stops[data.targetStation].direct2.percent;
|
||||
trainlisttest.list[code].progress = data.linkOffsetPercent/trainlisttest.list[code].pc;
|
||||
trainlisttest.list[code].linkOffsetPercent = data.linkOffsetPercent;
|
||||
trainlisttest.list[code].targetLink = data.targetLink;
|
||||
// console.log(data.targetLinkPercent);
|
||||
// console.log(rails.stops[data.targetStation].direct2.percent);
|
||||
// console.log(trainlisttest.list[code].progress);
|
||||
// console.log("===================");
|
||||
let point = rails.linkrail[data.linkCode].lineleft.getPointAt(trainlisttest.list[code].progress);
|
||||
trainlisttest.list[code].rotation.y = 0;
|
||||
trainlisttest.list[code].position.x = point.x;
|
||||
trainlisttest.list[code].position.y = 0;
|
||||
for (let tl=0; tl<6; tl++) {
|
||||
trainlisttest.list[code].children[tl].position.z = point.z;
|
||||
}
|
||||
|
||||
}else{
|
||||
trainlisttest.list[code].progress = data.linkOffsetPercent/trainlisttest.list[code].pc;
|
||||
trainlisttest.list[code].linkOffsetPercent = data.linkOffsetPercent;
|
||||
let point = rails.linkrail[data.linkCode].lineleft.getPointAt(trainlisttest.list[code].progress);
|
||||
trainlisttest.list[code].rotation.y = 0;
|
||||
trainlisttest.list[code].position.x = point.x;
|
||||
trainlisttest.list[code].position.y = 0;
|
||||
for (let tl=0; tl<6; tl++) {
|
||||
trainlisttest.list[code].children[tl].position.z = point.z;
|
||||
}
|
||||
}
|
||||
|
||||
trainlisttest.list[code].curve = rails.linkrail[data.linkCode].lineleft;
|
||||
trainlisttest.list[code].len = rails.linkrail[data.linkCode].lengthfact;
|
||||
trainlisttest.list[code].status = '02';
|
||||
} else if (data.directionType == '03') { // 向左
|
||||
|
||||
// if(trainlisttest.list[code].rname == "006"){
|
||||
// console.log("0000000000000000");
|
||||
// console.log(data.linkOffsetPercent);
|
||||
// }
|
||||
if(data.targetStation){
|
||||
|
||||
trainlisttest.list[code].stopstation = data.targetStation;
|
||||
trainlisttest.list[code].pc = data.targetLinkPercent/rails.stops[data.targetStation].direct1.percent;
|
||||
trainlisttest.list[code].targetpercent = rails.stops[data.targetStation].direct1.percent;
|
||||
trainlisttest.list[code].progress = 1-(data.linkOffsetPercent/trainlisttest.list[code].pc);
|
||||
trainlisttest.list[code].linkOffsetPercent = data.linkOffsetPercent;
|
||||
trainlisttest.list[code].targetLink = data.targetLink;
|
||||
// console.log(data.targetLinkPercent);
|
||||
// console.log(rails.stops[data.targetStation].direct1.percent);
|
||||
// console.log(trainlisttest.list[code].progress);
|
||||
// console.log("===================");
|
||||
let point = rails.linkrail[data.linkCode].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++) {
|
||||
trainlisttest.list[code].children[tl].position.z = -point.z;
|
||||
}
|
||||
}else{
|
||||
trainlisttest.list[code].progress = data.linkOffsetPercent/trainlisttest.list[code].pc;
|
||||
trainlisttest.list[code].linkOffsetPercent = data.linkOffsetPercent;
|
||||
let point = rails.linkrail[data.linkCode].lineleft.getPointAt(trainlisttest.list[code].progress);
|
||||
trainlisttest.list[code].rotation.y = 0;
|
||||
trainlisttest.list[code].position.x = point.x;
|
||||
trainlisttest.list[code].position.y = 0;
|
||||
for (let tl=0; tl<6; tl++) {
|
||||
trainlisttest.list[code].children[tl].position.z = point.z;
|
||||
}
|
||||
}
|
||||
|
||||
trainlisttest.list[code].curve = rails.linkrail[data.linkCode].lineright;
|
||||
trainlisttest.list[code].len = rails.linkrail[data.linkCode].lengthfact;
|
||||
trainlisttest.list[code].status = '03';
|
||||
|
||||
// trainlisttest.list[code].curve = rails.linkrail[data.linkCode].lineright;
|
||||
}
|
||||
|
||||
|
||||
trainlisttest.list[code].len = rails.linkrail[data.linkCode].lengthfact;
|
||||
// trainlisttest.list[code].isStandTrack = sectionlist.sections.datalist[data.sectionCode].isStandTrack;
|
||||
|
||||
// trainlisttest.list[code].len = sectionlist.sections.datalist[data.sectionCode].distance;
|
||||
|
||||
if(trainlisttest.list[code].targetLink == trainlisttest.list[code].nowcode){
|
||||
trainlisttest.list[code].statsstop = 0;
|
||||
}else{
|
||||
trainlisttest.list[code].statsstop = 1;
|
||||
}
|
||||
if(data.speed == 0){
|
||||
trainlisttest.list[code].speeds = data.speed;
|
||||
trainlisttest.list[code].speeds = 0;
|
||||
// trainlisttest.list[code].startmark = 1;
|
||||
}else{
|
||||
trainlisttest.list[code].speeds = data.speed;
|
||||
trainlisttest.list[code].speeds = parseFloat(data.speed*10/36/18/trainlisttest.list[code].len);
|
||||
}
|
||||
|
||||
}
|
||||
} else if (trainlisttest.list[code].dispose != data.dispose && data.dispose == true) {
|
||||
trainlisttest.group.remove(trainlisttest.list[code]);
|
||||
trainlisttest.list[code].progress = null;
|
||||
trainlisttest.list[code].dispose = true;
|
||||
code = trainlisttest.group.children[i].name;
|
||||
trainlisttest.list[code].rotation.y = 0;
|
||||
trainlisttest.list[code].doorStatus = '01';
|
||||
trainlisttest.list[code].speed = 0;
|
||||
trainlisttest.list[code].position.x = -50000;
|
||||
trainlisttest.list[code].position.y = -50000;
|
||||
trainlisttest.list[code].pc = 1;
|
||||
|
||||
} else if (trainlisttest.list[code].dispose == data.dispose && data.dispose == false) {
|
||||
|
||||
// if(data.){
|
||||
//
|
||||
// }
|
||||
if (data.directionType == '02' && trainlisttest.list[code].status != data.directionType) { // 向右
|
||||
|
||||
|
||||
let rotaposx = trainlisttest.list[code].children[5].matrixWorld.elements[12];
|
||||
let 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.linkCode].lp.x)/rails.linkrail[data.linkCode].lengthfact;
|
||||
trainlisttest.list[code].status = '02';
|
||||
trainlisttest.list[code].curve = rails.linkrail[data.linkCode].lineleft;
|
||||
trainlisttest.list[code].nextcurve = null;
|
||||
|
||||
trainlisttest.list[code].len = rails.linkrail[data.linkCode].lengthfact;
|
||||
|
||||
} else if (data.directionType == '03'&& trainlisttest.list[code].status != data.directionType) { // 向左
|
||||
|
||||
let rotaposx = trainlisttest.list[code].children[5].matrixWorld.elements[12];
|
||||
let 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.linkCode].lp.x)/rails.linkrail[data.linkCode].lengthfact;
|
||||
trainlisttest.list[code].status = '03';
|
||||
trainlisttest.list[code].curve = rails.linkrail[data.linkCode].lineright;
|
||||
trainlisttest.list[code].nextcurve = null;
|
||||
|
||||
trainlisttest.list[code].len = rails.linkrail[data.linkCode].lengthfact;
|
||||
|
||||
}
|
||||
|
||||
|
||||
if(trainlisttest.list[code].nextcode == null ){//&& trainlisttest.list[code].stopstation == data.targetStation
|
||||
// if(data.groupNumber == "016"){
|
||||
// console.log(trainlisttest.list[code].nextcode);
|
||||
// console.log(trainlisttest.list[code].stopstation);
|
||||
// console.log(data.targetStation);
|
||||
// console.log(data.body[i]);
|
||||
// console.log(trainlisttest.list[code]);
|
||||
// }
|
||||
// if(trainlisttest.list[code].targetLink != trainlisttest.list[code].nowcode){
|
||||
let nextcode;
|
||||
if(data.directionType == '02'){
|
||||
|
||||
trainlisttest.list[code].status = '02';
|
||||
// console.log(rails.linkrail[trainlisttest.list[code].nowcode]);
|
||||
|
||||
if(rails.linkrail[trainlisttest.list[code].nowcode]){
|
||||
nextcode = rails.linkrail[trainlisttest.list[code].nowcode].rconnect;
|
||||
}
|
||||
|
||||
if(nextcode){
|
||||
trainlisttest.list[code].nextcurve = rails.linkrail[nextcode].lineleft;
|
||||
trainlisttest.list[code].nextlen = rails.linkrail[nextcode].lengthfact;
|
||||
}else{
|
||||
|
||||
trainlisttest.list[code].nextlen = 0;
|
||||
}
|
||||
}else if(data.directionType == '03'){
|
||||
|
||||
trainlisttest.list[code].status = '03';
|
||||
if(rails.linkrail[trainlisttest.list[code].nowcode]){
|
||||
nextcode = rails.linkrail[trainlisttest.list[code].nowcode].lconnect;
|
||||
}
|
||||
if(nextcode){
|
||||
trainlisttest.list[code].nextcurve = rails.linkrail[nextcode].lineright;
|
||||
trainlisttest.list[code].nextlen = rails.linkrail[nextcode].lengthfact;
|
||||
}else{
|
||||
|
||||
trainlisttest.list[code].nextlen = 0;
|
||||
}
|
||||
}
|
||||
trainlisttest.list[code].nextcode = nextcode;
|
||||
|
||||
// }
|
||||
|
||||
if(trainlisttest.list[code].curve == null){
|
||||
trainlisttest.list[code].len = trainlisttest.list[code].nextlen;
|
||||
trainlisttest.list[code].nowcode = trainlisttest.list[code].nextcode;
|
||||
trainlisttest.list[code].curve = trainlisttest.list[code].nextcurve;
|
||||
trainlisttest.list[code].nextcurve = null;
|
||||
trainlisttest.list[code].nextlen = null;
|
||||
trainlisttest.list[code].nextcode = null;
|
||||
}
|
||||
}
|
||||
if(data.groupNumber == "016"){
|
||||
// console.log(data.targetLink);
|
||||
// console.log(trainlisttest.list[code].nowcode);
|
||||
//
|
||||
// console.log(trainlisttest.list[code].progress);
|
||||
// console.log("==============");
|
||||
}
|
||||
trainlisttest.list[code].targetLink = data.targetLink;
|
||||
if(trainlisttest.list[code].stopstation != data.targetStation){
|
||||
|
||||
if(data.directionType == '02'){
|
||||
if(data.targetStation){
|
||||
trainlisttest.list[code].pc = data.targetLinkPercent/rails.stops[data.targetStation].direct2.percent;
|
||||
trainlisttest.list[code].targetpercent = rails.stops[data.targetStation].direct2.percent;
|
||||
// trainlisttest.list[code].linkOffsetPercent = data.linkOffsetPercent;
|
||||
// trainlisttest.list[code].targetLink = data.targetLink;
|
||||
}
|
||||
|
||||
|
||||
trainlisttest.list[code].status = '02';
|
||||
}else if(data.directionType == '03'){
|
||||
if(data.targetStation){
|
||||
trainlisttest.list[code].pc = data.targetLinkPercent/rails.stops[data.targetStation].direct1.percent;
|
||||
trainlisttest.list[code].targetpercent = rails.stops[data.targetStation].direct1.percent;
|
||||
// trainlisttest.list[code].linkOffsetPercent = data.linkOffsetPercent;
|
||||
// trainlisttest.list[code].targetLink = data.targetLink;
|
||||
}
|
||||
|
||||
trainlisttest.list[code].status = '03';
|
||||
|
||||
}
|
||||
trainlisttest.list[code].stopstation = data.targetStation;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(trainlisttest.list[code].targetLink == trainlisttest.list[code].nowcode){
|
||||
trainlisttest.list[code].statsstop = 0;
|
||||
}else{
|
||||
trainlisttest.list[code].statsstop = 1;
|
||||
}
|
||||
// console.log(data.body[i]);
|
||||
|
||||
if(trainlisttest.list[code].speed != data.speed){
|
||||
trainlisttest.list[code].speed = data.speed;
|
||||
trainlisttest.list[code].speeds = parseFloat(data.speed*10/36/18/trainlisttest.list[code].len);
|
||||
}
|
||||
}
|
||||
// }
|
||||
}
|
||||
function standupdate(data) {
|
||||
code = data.code;
|
||||
if ( actions[code]) {
|
||||
if (data.screenDoorOpenStatus == '02' && actions[code].status == '01') {
|
||||
actions[code].status = '00';
|
||||
}
|
||||
if (data.screenDoorOpenStatus == '02' && actions[code].status == '00') {
|
||||
actions[code].status = '02';
|
||||
actions[code].action.reset();
|
||||
actions[code].action.time = 0;
|
||||
actions[code].action.timeScale = 1;
|
||||
actions[code].action.play();
|
||||
}
|
||||
|
||||
if (data.screenDoorOpenStatus == '01' && actions[code].status == '02') {
|
||||
actions[code].status = '00';
|
||||
}
|
||||
if (data.screenDoorOpenStatus == '01' && actions[code].status == '00') {
|
||||
actions[code].status = '01';
|
||||
actions[code].action.reset();
|
||||
actions[code].action.time = actions[code].action._clip.duration;
|
||||
actions[code].action.timeScale = -1;
|
||||
actions[code].action.play();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
function devicestatus(data){
|
||||
for (let i= 0,leni = data.body.length; i<leni; i++) {
|
||||
// 0xFFFFFF
|
||||
// 0xCD0000 红
|
||||
// 0xEEEE00 黄
|
||||
// 0x32CD32 绿
|
||||
|
||||
if (data._type == 'Signal' && signallist) {
|
||||
if (signallist) {
|
||||
// console.log(data.body[i]);
|
||||
signalupdate(data.body[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (data._type == 'StationStand' && actions) {
|
||||
if (actions) {
|
||||
standupdate(data.body[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (data._type == 'Switch' && sectionlist) {
|
||||
if (sectionlist) {
|
||||
switchupdate(data.body[i]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
function signalupdate(data) {
|
||||
code = data.code;
|
||||
// console.log(data);
|
||||
if (data.lightType == '01') {
|
||||
if (signallist.list[code].mesh.code) {
|
||||
signallist.list[code].mesh.status = data.status;
|
||||
|
||||
// 55
|
||||
// 33
|
||||
// 77
|
||||
// 关闭
|
||||
if (data.status == '01') {
|
||||
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("yellow").material.map = materials[3];
|
||||
signallist.list[code].mesh.getObjectByName("yellow").material.map.needsUpdate = true;
|
||||
signallist.list[code].mesh.getObjectByName("green").material.map = materials[3];
|
||||
signallist.list[code].mesh.getObjectByName("green").material.map.needsUpdate = true;
|
||||
|
||||
}
|
||||
// 开放
|
||||
if (data.status == '02') {
|
||||
signallist.list[code].mesh.getObjectByName("red").material.map = materials[3];
|
||||
signallist.list[code].mesh.getObjectByName("red").material.map.needsUpdate = true;
|
||||
signallist.list[code].mesh.getObjectByName("yellow").material.map = materials[3];
|
||||
signallist.list[code].mesh.getObjectByName("yellow").material.map.needsUpdate = true;
|
||||
signallist.list[code].mesh.getObjectByName("green").material.map = materials[2];
|
||||
signallist.list[code].mesh.getObjectByName("green").material.map.needsUpdate = true;
|
||||
}
|
||||
|
||||
if (data.status == '03') {
|
||||
signallist.list[code].mesh.getObjectByName("red").material.map = materials[3];
|
||||
signallist.list[code].mesh.getObjectByName("red").material.map.needsUpdate = true;
|
||||
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("green").material.map = materials[3];
|
||||
signallist.list[code].mesh.getObjectByName("green").material.map.needsUpdate = true;
|
||||
}
|
||||
|
||||
// 引导
|
||||
if (data.status == '03') {
|
||||
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("yellow").material.map = materials[1];
|
||||
signallist.list[code].mesh.getObjectByName("yellow").material.map.needsUpdate = true;
|
||||
signallist.list[code].mesh.getObjectByName("green").material.map = materials[3];
|
||||
signallist.list[code].mesh.getObjectByName("green").material.map.needsUpdate = true;
|
||||
|
||||
}
|
||||
// 封锁
|
||||
if (data.status == '04') {
|
||||
signallist.list[code].mesh.getObjectByName("red").material.map = materials[3];
|
||||
signallist.list[code].mesh.getObjectByName("red").material.map.needsUpdate = true;
|
||||
signallist.list[code].mesh.getObjectByName("yellow").material.map = materials[3];
|
||||
signallist.list[code].mesh.getObjectByName("yellow").material.map.needsUpdate = true;
|
||||
signallist.list[code].mesh.getObjectByName("green").material.map = materials[3];
|
||||
signallist.list[code].mesh.getObjectByName("green").material.map.needsUpdate = true;
|
||||
|
||||
}
|
||||
// 故障
|
||||
if (data.status == '05') {
|
||||
signallist.list[code].mesh.getObjectByName("red").material.map = materials[3];
|
||||
signallist.list[code].mesh.getObjectByName("red").material.map.needsUpdate = true;
|
||||
signallist.list[code].mesh.getObjectByName("yellow").material.map = materials[3];
|
||||
signallist.list[code].mesh.getObjectByName("yellow").material.map.needsUpdate = true;
|
||||
signallist.list[code].mesh.getObjectByName("green").material.map = materials[3];
|
||||
signallist.list[code].mesh.getObjectByName("green").material.map.needsUpdate = true;
|
||||
|
||||
}
|
||||
if (data.status == '06') {
|
||||
signallist.list[code].mesh.getObjectByName("red").material.map = materials[3];
|
||||
signallist.list[code].mesh.getObjectByName("red").material.map.needsUpdate = true;
|
||||
signallist.list[code].mesh.getObjectByName("yellow").material.map = materials[3];
|
||||
signallist.list[code].mesh.getObjectByName("yellow").material.map.needsUpdate = true;
|
||||
signallist.list[code].mesh.getObjectByName("green").material.map = materials[3];
|
||||
signallist.list[code].mesh.getObjectByName("green").material.map.needsUpdate = true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else if (data.lightType == '01') {
|
||||
if (signallist.list[code].mesh.code) {
|
||||
signallist.list[code].mesh.getObjectByName("red").material.map = materials[3];
|
||||
signallist.list[code].mesh.getObjectByName("red").material.map.needsUpdate = true;
|
||||
signallist.list[code].mesh.getObjectByName("yellow").material.map = materials[3];
|
||||
signallist.list[code].mesh.getObjectByName("yellow").material.map.needsUpdate = true;
|
||||
signallist.list[code].mesh.getObjectByName("green").material.map = materials[3];
|
||||
signallist.list[code].mesh.getObjectByName("green").material.map.needsUpdate = true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function switchupdate(data) {
|
||||
code = data.code;
|
||||
for (let j=sectionlist.switchs.modellist.length-1; j>=0; j--) {
|
||||
if (rails.switchrail[code]) {
|
||||
if (rails.switchrail[code].locateType != data.locateType) {
|
||||
if (data.locateType == '02') {
|
||||
if (actions[sectionlist.switchs.modellist[j].code]) {
|
||||
sectionlist.switchs.modellist[j].locateType = data.locateType;
|
||||
actions[sectionlist.switchs.modellist[j].code].reset();
|
||||
actions[sectionlist.switchs.modellist[j].code].time = 0;
|
||||
actions[sectionlist.switchs.modellist[j].code].timeScale = 1;
|
||||
actions[sectionlist.switchs.modellist[j].code].play();
|
||||
}
|
||||
|
||||
rails.switchrail[code].locateType = "02";
|
||||
|
||||
let testswitch = rails.switchrail[code];
|
||||
// console.log(testswitch);
|
||||
// console.log(rails.linkrail[testswitch.alink]);
|
||||
// console.log(rails.linkrail[testswitch.clink]);
|
||||
if(rails.switchrail[code].directtype == "1"){
|
||||
rails.linkrail[testswitch.alink].lconnect = testswitch.clink;
|
||||
rails.linkrail[testswitch.clink].rconnect = testswitch.alink;
|
||||
}else if(rails.switchrail[code].directtype == "2"){
|
||||
rails.linkrail[testswitch.alink].rconnect = testswitch.clink;
|
||||
rails.linkrail[testswitch.clink].lconnect = testswitch.alink;
|
||||
}
|
||||
|
||||
} else if (data.locateType == '01') {
|
||||
if (actions[sectionlist.switchs.modellist[j].code]) {
|
||||
sectionlist.switchs.modellist[j].locateType = data.locateType;
|
||||
actions[sectionlist.switchs.modellist[j].code].reset();
|
||||
actions[sectionlist.switchs.modellist[j].code].time = actions[sectionlist.switchs.modellist[j].code]._clip.duration;
|
||||
actions[sectionlist.switchs.modellist[j].code].timeScale = -1;
|
||||
actions[sectionlist.switchs.modellist[j].code].play();
|
||||
}
|
||||
|
||||
rails.switchrail[code].locateType = "01";
|
||||
let testswitch = rails.switchrail[code];
|
||||
// console.log(testswitch);
|
||||
// console.log(rails.linkrail[testswitch.alink]);
|
||||
// console.log(rails.linkrail[testswitch.clink]);
|
||||
if(rails.switchrail[code].directtype == "1"){
|
||||
rails.linkrail[testswitch.alink].lconnect = testswitch.blink;
|
||||
rails.linkrail[testswitch.blink].rconnect = testswitch.alink;
|
||||
}else if(rails.switchrail[code].directtype == "2"){
|
||||
rails.linkrail[testswitch.alink].rconnect = testswitch.blink;
|
||||
rails.linkrail[testswitch.blink].lconnect = testswitch.alink;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
j = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
function simulationreset(data){
|
||||
for(let i=0;i<trainlisttest.group.children.length;i++){
|
||||
trainlisttest.group.children[i].dispose = true;
|
||||
trainlisttest.group.children[i].stopstation = null;
|
||||
trainlisttest.group.children[i].pc = null;
|
||||
trainlisttest.group.children[i].targetpercent = null;
|
||||
trainlisttest.group.children[i].progress = null;
|
||||
trainlisttest.group.children[i].linkOffsetPercent = null;
|
||||
trainlisttest.group.children[i].targetLink = null;
|
||||
trainlisttest.group.remove(trainlisttest.group.children[i]);
|
||||
i--;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -16,10 +16,22 @@ export function UpdateTrainNew(camera,traindata){
|
||||
|
||||
let movecurve = trainmodel.curve;
|
||||
if(trainmodel.status == "1"){
|
||||
let point = movecurve.getPointAt(traindata.group.children[j].progress);
|
||||
|
||||
let point = movecurve.getPointAt(trainmodel.progress);
|
||||
trainmodel.children[0].updateMatrixWorld(true);
|
||||
let worldpositionz = parseFloat(trainmodel.children[0].matrixWorld.elements[14]);
|
||||
if(trainmodel.groupNumber == "020"){
|
||||
console.log("===============================");
|
||||
console.log(trainmodel.children[0]);
|
||||
console.log(worldpositionz);
|
||||
console.log(trainmodel.children[0].position.z);
|
||||
console.log(point.z);
|
||||
}
|
||||
|
||||
trainmodel.position.x = point.x;
|
||||
trainmodel.position.y = 0;
|
||||
if(Math.abs( point.z -trainmodel.children[0].matrixWorld.elements[14]) >0.02){
|
||||
let offset = Math.abs( point.z -parseFloat(worldpositionz));
|
||||
if(offset >0.02){
|
||||
trainmodel.children[0].up = new THREE.Vector3(-1,0,0);
|
||||
let tangent = movecurve.getTangentAt(traindata.group.children[j].progress).normalize();
|
||||
trainmodel.children[0].axis.crossVectors(trainmodel.children[0].up, tangent).normalize();
|
||||
@ -35,55 +47,70 @@ export function UpdateTrainNew(camera,traindata){
|
||||
rota:trainmodel.children[0].rotation.z
|
||||
}
|
||||
trainmodel.children[1].rotalist.push(rotas);
|
||||
let offsetz = worldpositionz - parseFloat(point.z);
|
||||
|
||||
let offsetz = parseFloat(trainmodel.children[0].matrixWorld.elements[14]) - parseFloat(point.z);
|
||||
trainmodel.children[0].position.z += offsetz;
|
||||
|
||||
}
|
||||
|
||||
if(trainmodel.children[1].rotalist.length > 0 || trainmodel.children[2].rotalist.length > 0 || trainmodel.children[3].rotalist.length > 0 || trainmodel.children[4].rotalist.length > 0|| trainmodel.children[5].rotalist.length > 0){
|
||||
for(let rs = 1;rs<6;rs++){
|
||||
if(trainmodel.children[rs].rotalist[0]){
|
||||
let offsetz = parseFloat(trainmodel.children[rs].matrixWorld.elements[14]) - parseFloat(trainmodel.children[rs].rotalist[0].posr.z);
|
||||
|
||||
trainmodel.children[rs].position.z += offsetz;
|
||||
|
||||
for(let xh=0;xh<trainmodel.children[rs].rotalist.length;xh++){
|
||||
if((trainmodel.children[rs].matrixWorld.elements[12]-8)<=trainmodel.children[rs].rotalist[0].posr.x){
|
||||
|
||||
if(rs != 5){
|
||||
let asd = trainmodel.children[rs].rotalist[0];
|
||||
trainmodel.children[rs+1].rotalist.push(asd);
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(trainmodel.groupNumber == "020"){
|
||||
console.log(offsetz);
|
||||
console.log(trainmodel.children[0].position.z);
|
||||
}
|
||||
}
|
||||
if(trainmodel.statsstop == 0){
|
||||
if((1-trainmodel.progress) > 0.95){
|
||||
|
||||
trainmodel.progress += trainmodel.speeds;
|
||||
}
|
||||
|
||||
}else{
|
||||
trainmodel.progress += trainmodel.speeds;
|
||||
}
|
||||
// if(trainmodel.children[1].rotalist.length > 0 || trainmodel.children[2].rotalist.length > 0 || trainmodel.children[3].rotalist.length > 0 || trainmodel.children[4].rotalist.length > 0|| trainmodel.children[5].rotalist.length > 0){
|
||||
// for(let rs = 1;rs<6;rs++){
|
||||
// if(trainmodel.children[rs].rotalist[0]){
|
||||
// let offsetz = parseFloat(trainmodel.children[rs].matrixWorld.elements[14]) - parseFloat(trainmodel.children[rs].rotalist[0].posr.z);
|
||||
//
|
||||
// trainmodel.children[rs].position.z += offsetz;
|
||||
//
|
||||
// for(let xh=0;xh<trainmodel.children[rs].rotalist.length;xh++){
|
||||
// if((trainmodel.children[rs].matrixWorld.elements[12]-8)<=trainmodel.children[rs].rotalist[0].posr.x){
|
||||
//
|
||||
// if(rs != 5){
|
||||
// let asd = trainmodel.children[rs].rotalist[0];
|
||||
// trainmodel.children[rs+1].rotalist.push(asd);
|
||||
//
|
||||
// }
|
||||
//
|
||||
// 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;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
trainmodel.progress += trainmodel.speeds;
|
||||
// if(trainmodel.statsstop == 0){
|
||||
// if((1-trainmodel.progress) > 0.95){
|
||||
//
|
||||
// trainmodel.progress += trainmodel.speeds;
|
||||
// }
|
||||
//
|
||||
// }else{
|
||||
// trainmodel.progress += trainmodel.speeds;
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
if(trainmodel.status == "0"){
|
||||
let point = movecurve.getPointAt(trainmodel.progress);
|
||||
trainmodel.children[0].updateMatrixWorld(true);
|
||||
let worldpositionz = parseFloat(trainmodel.children[0].matrixWorld.elements[14]);
|
||||
|
||||
trainmodel.position.x = point.x;
|
||||
trainmodel.position.y = 0;
|
||||
if(Math.abs( point.z -trainmodel.children[0].matrixWorld.elements[14]) >0.02){
|
||||
if(trainmodel.groupNumber == "020"){
|
||||
console.log("===============================");
|
||||
console.log(trainmodel.children[0]);
|
||||
console.log(worldpositionz);
|
||||
console.log(trainmodel.children[0].position.z);
|
||||
console.log(point.z);
|
||||
}
|
||||
|
||||
if(Math.abs( point.z -parseFloat(worldpositionz)) >0.02){
|
||||
trainmodel.children[0].up = new THREE.Vector3(1,0,0);
|
||||
let tangent = movecurve.getTangentAt(traindata.group.children[j].progress).normalize();
|
||||
trainmodel.children[0].axis.crossVectors(trainmodel.children[0].up, tangent).normalize();
|
||||
@ -97,43 +124,48 @@ export function UpdateTrainNew(camera,traindata){
|
||||
rota:trainmodel.children[0].rotation.z
|
||||
}
|
||||
trainmodel.children[1].rotalist.push(rotas);
|
||||
let offsetz = parseFloat(point.z) - parseFloat(trainmodel.children[0].matrixWorld.elements[14]);
|
||||
let offsetz = parseFloat(point.z) - parseFloat(worldpositionz);
|
||||
trainmodel.children[0].position.z += offsetz;
|
||||
}
|
||||
|
||||
if(trainmodel.children[1].rotalist.length > 0 || trainmodel.children[2].rotalist.length > 0 || trainmodel.children[3].rotalist.length > 0 || trainmodel.children[4].rotalist.length > 0|| trainmodel.children[5].rotalist.length > 0){
|
||||
|
||||
for(let rs = 1;rs<6;rs++){
|
||||
if(trainmodel.children[rs].rotalist[0]){
|
||||
|
||||
let offsetz = parseFloat(trainmodel.children[rs].rotalist[0].posr.z) - parseFloat(trainmodel.children[rs].matrixWorld.elements[14]);
|
||||
trainmodel.children[rs].position.z += offsetz;
|
||||
|
||||
for(let xh=0;xh<trainmodel.children[rs].rotalist.length;xh++){
|
||||
if((trainmodel.children[rs].matrixWorld.elements[12]+8)>=trainmodel.children[rs].rotalist[0].posr.x){
|
||||
|
||||
if(rs != 5){
|
||||
let asd = trainmodel.children[rs].rotalist[0];
|
||||
trainmodel.children[rs+1].rotalist.push(asd);
|
||||
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(trainmodel.groupNumber == "020"){
|
||||
console.log(offsetz);
|
||||
console.log(trainmodel.children[0].position.z);
|
||||
}
|
||||
}
|
||||
if(trainmodel.statsstop == 0){
|
||||
if(trainmodel.progress < 0.95){
|
||||
trainmodel.progress += trainmodel.speeds;
|
||||
}
|
||||
}else{
|
||||
trainmodel.progress += trainmodel.speeds;
|
||||
}
|
||||
|
||||
// if(trainmodel.children[1].rotalist.length > 0 || trainmodel.children[2].rotalist.length > 0 || trainmodel.children[3].rotalist.length > 0 || trainmodel.children[4].rotalist.length > 0|| trainmodel.children[5].rotalist.length > 0){
|
||||
//
|
||||
// for(let rs = 1;rs<6;rs++){
|
||||
// if(trainmodel.children[rs].rotalist[0]){
|
||||
//
|
||||
// let offsetz = parseFloat(trainmodel.children[rs].rotalist[0].posr.z) - parseFloat(trainmodel.children[rs].matrixWorld.elements[14]);
|
||||
// trainmodel.children[rs].position.z += offsetz;
|
||||
//
|
||||
// for(let xh=0;xh<trainmodel.children[rs].rotalist.length;xh++){
|
||||
// if((trainmodel.children[rs].matrixWorld.elements[12]+8)>=trainmodel.children[rs].rotalist[0].posr.x){
|
||||
//
|
||||
// if(rs != 5){
|
||||
// let asd = trainmodel.children[rs].rotalist[0];
|
||||
// trainmodel.children[rs+1].rotalist.push(asd);
|
||||
//
|
||||
// }
|
||||
// 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;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
trainmodel.progress += trainmodel.speeds;
|
||||
// if(trainmodel.statsstop == 0){
|
||||
// if(trainmodel.progress < 0.95){
|
||||
// trainmodel.progress += trainmodel.speeds;
|
||||
// }
|
||||
// }else{
|
||||
// trainmodel.progress += trainmodel.speeds;
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
@ -44,8 +44,6 @@ export function JLmap3d(dom, data,skinCode,storemod,routegroup,project) {
|
||||
let scope = this;
|
||||
|
||||
this.dom = dom;
|
||||
//渲染循环开关
|
||||
this.animateswitch = false;
|
||||
//初始化webgl渲染
|
||||
let renderer = SetRender(dom);
|
||||
renderer.domElement.style.position = "absolute";
|
||||
@ -59,7 +57,7 @@ export function JLmap3d(dom, data,skinCode,storemod,routegroup,project) {
|
||||
let controls = new THREE.OrbitControls(camera);
|
||||
controls.maxPolarAngle = Math.PI/2;
|
||||
//controls.minPolarAngle = Math.PI/8;
|
||||
controls.maxDistance = 4800;
|
||||
controls.maxDistance = 2000;
|
||||
//模型加载器
|
||||
this.assetloader = new AssetLoader();
|
||||
//替换材质组,例:信号机不同灯光
|
||||
@ -122,8 +120,8 @@ export function JLmap3d(dom, data,skinCode,storemod,routegroup,project) {
|
||||
});
|
||||
});
|
||||
//
|
||||
// let stats = new Stats();
|
||||
// dom.appendChild( stats.dom );
|
||||
let stats = new Stats();
|
||||
dom.appendChild( stats.dom );
|
||||
|
||||
// var timer = setInterval(function() {
|
||||
// if(trainlisttest){
|
||||
@ -161,7 +159,6 @@ export function JLmap3d(dom, data,skinCode,storemod,routegroup,project) {
|
||||
// }
|
||||
//
|
||||
// }, 2000);
|
||||
controls.upscene(scope.animateswitch);
|
||||
//开启渲染
|
||||
animate();
|
||||
startWorker(scope.webwork);
|
||||
@ -174,17 +171,12 @@ export function JLmap3d(dom, data,skinCode,storemod,routegroup,project) {
|
||||
//renderer.setAnimationLoop(animate);
|
||||
requestAnimationFrame(animate);
|
||||
//判断渲染是否开启
|
||||
// if(scope.animateswitch == true){
|
||||
// if(camera.position.y<4000){
|
||||
//
|
||||
// }
|
||||
//根据相机渲染场景
|
||||
renderer.render(scene,camera);
|
||||
// console.log(scope.animateswitch);
|
||||
//检测动画构造器播放动画
|
||||
|
||||
// }
|
||||
// stats.update();
|
||||
stats.update();
|
||||
}
|
||||
|
||||
function startWorker(webwork){
|
||||
@ -293,12 +285,10 @@ export function JLmap3d(dom, data,skinCode,storemod,routegroup,project) {
|
||||
|
||||
this.animateon = function(){
|
||||
controls.enabled = true;
|
||||
// scope.animateswitch = true;
|
||||
};
|
||||
|
||||
this.animateoff = function(){
|
||||
controls.enabled = false;
|
||||
// scope.animateswitch = false;
|
||||
};
|
||||
|
||||
this.loaderdata = function(loadsectionlist,loadlinklist,loadsignallist,loadstationstandlist,loadtrainlisttest,loadrealsectionlist,loadrails){
|
||||
|
@ -133,10 +133,6 @@ THREE.OrbitControls = function ( object, domElement ) {
|
||||
scope.data.trainlisttest = newtrainlisttest;
|
||||
}
|
||||
|
||||
this.upscene = function(animateswitch){
|
||||
// scope.animateswitch = animateswitch;
|
||||
}
|
||||
|
||||
// this method is exposed, but perhaps it would be better if we can make it private...
|
||||
this.update = function () {
|
||||
|
||||
|
@ -142,7 +142,9 @@ THREE.ScalControls = function ( scene,_camera, _domElement ) {
|
||||
// _movemesh.geometry.computeBoundingBox();
|
||||
_movemesh.geometry.computeBoundingSphere();
|
||||
_movemesh.geometry.center();
|
||||
_movemesh.lengthfact = (_movemesh.geometry.attributes.position.array[_movemesh.rightlist[0]] - _movemesh.geometry.attributes.position.array[_movemesh.leftlist[0]])*2+28;
|
||||
// _movemesh.lengthfact = (_movemesh.geometry.attributes.position.array[_movemesh.rightlist[0]] - _movemesh.geometry.attributes.position.array[_movemesh.leftlist[0]])*2+28;
|
||||
_movemesh.lengthFact = (_movemesh.geometry.attributes.position.array[_movemesh.rightlist[0]*3] - _movemesh.geometry.attributes.position.array[_movemesh.leftlist[0]*3]);
|
||||
|
||||
// testmesh2.position.z = 50;
|
||||
|
||||
// testmesh2.geometry.center();
|
||||
|
@ -29,7 +29,6 @@ export function SimulationLoadNew(data,scope,netdata,mapdata,camera,controls,sce
|
||||
let backdata = scope;
|
||||
let jlmap3ddata = mapdata;
|
||||
let assetloader = scope.assetloader;
|
||||
let animateswitch = scope.animateswitch;
|
||||
|
||||
let mixers = scope.mixers;
|
||||
let actions = scope.actions;
|
||||
@ -48,8 +47,7 @@ export function SimulationLoadNew(data,scope,netdata,mapdata,camera,controls,sce
|
||||
}
|
||||
|
||||
function initnew3d(data,netdata){
|
||||
console.log(data);
|
||||
console.log(netdata);
|
||||
|
||||
let mapdata = data;
|
||||
//初始化轨道和道岔
|
||||
// lengthfact(data);
|
||||
@ -118,14 +116,13 @@ export function SimulationLoadNew(data,scope,netdata,mapdata,camera,controls,sce
|
||||
// }
|
||||
//
|
||||
//
|
||||
scope.animateswitch = true;
|
||||
|
||||
console.log("scene+++++++++++++++++++++++++++++++++");
|
||||
console.log(sceneload);
|
||||
// // mapdata = jlmap3ddata;
|
||||
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.webwork.postMessage("on");
|
||||
// console.log(stationstandlist);
|
||||
scope.jsonwebworknew.postMessage("connect");
|
||||
scope.jsonwebworknew.postMessage("connect");
|
||||
updatemenulist(stationstandlist.list,trainlisttest.list);
|
||||
loadingInstance.close();
|
||||
});
|
||||
|
@ -40,6 +40,7 @@ this.loadpromise = function(sectionList,sectiondata,scene,assetloader){
|
||||
scene.add(scope.sectiongroup);
|
||||
return new Promise(function(resolve, reject){
|
||||
// console.log(sectiondata);
|
||||
let mergegeometry = new THREE.Geometry();
|
||||
for(let i=0,leni = sectiondata.length;i<leni;i++){
|
||||
let newsection = {
|
||||
code:sectiondata[i].code,
|
||||
@ -81,16 +82,26 @@ this.loadpromise = function(sectionList,sectiondata,scene,assetloader){
|
||||
testmesh2.geometry.attributes.uv.needsUpdate = true;
|
||||
testmesh2.geometry.computeBoundingSphere();
|
||||
testmesh2.geometry.center();
|
||||
testmesh2.code = newsection.code;
|
||||
testmesh2.rightlist = sectiondata[i].rightlist,
|
||||
testmesh2.leftlist = sectiondata[i].leftlist,
|
||||
testmesh2.position.set(sectiondata[i].position.x,sectiondata[i].position.y,sectiondata[i].position.z);
|
||||
testmesh2.rotation.set(sectiondata[i].rotation._x,sectiondata[i].rotation._y,sectiondata[i].rotation._z);
|
||||
scope.sectiongroup.add(testmesh2);
|
||||
newsection.mesh = testmesh2;
|
||||
testmesh2.matrixAutoUpdate = false;
|
||||
// scope.sectiongroup.add(testmesh2);
|
||||
// newsection.mesh = testmesh2;
|
||||
scope.sections.datalist[newsection.code] = newsection;
|
||||
// console.log(newsection);
|
||||
testmesh2.updateMatrix();
|
||||
mergegeometry.merge(new THREE.Geometry().fromBufferGeometry(testmesh2.geometry),testmesh2.matrix);
|
||||
// console.log(testmesh2);
|
||||
testmesh2.geometry.dispose();
|
||||
for(let j in testmesh2.material){
|
||||
testmesh2.material[j].map.dispose();
|
||||
testmesh2.material[j].dispose();
|
||||
}
|
||||
testmesh2 = null;
|
||||
}
|
||||
let mergemesh = new THREE.Mesh( mergegeometry, autorail.material );
|
||||
mergemesh.matrixAutoUpdate = false;
|
||||
scope.sectiongroup.add(mergemesh);
|
||||
resolve("loadersection");
|
||||
});
|
||||
|
||||
|
@ -9,41 +9,51 @@ export function SignalListN() {
|
||||
this.list = [];
|
||||
|
||||
this.group = new THREE.Group();
|
||||
|
||||
this.group.name = "signallist";
|
||||
this.loadpromise = function(data,signaldata,scene,assetloader){
|
||||
|
||||
return new Promise(function(resolve, reject){
|
||||
// console.log(signaldata);
|
||||
|
||||
for(let i=0;i<signaldata.length;i++){
|
||||
let newsignal = new SignalModel(signaldata[i]);
|
||||
let selectmesh = null;
|
||||
for(let j=0;j<assetloader.modellist.length;j++){
|
||||
if(assetloader.modellist[j].deviceType == "signal"){
|
||||
selectmesh = assetloader.modellist[j].mesh;
|
||||
for(let j=0,lenj = data.length;j<lenj;j++){
|
||||
if(data[j].code == signaldata[i].code){
|
||||
if(data[j].virtual == false){
|
||||
// console.log(signaldata[i]);
|
||||
let newsignal = new SignalModel(signaldata[i]);
|
||||
let selectmesh = null;
|
||||
for(let j=0;j<assetloader.modellist.length;j++){
|
||||
if(assetloader.modellist[j].deviceType == "signal"){
|
||||
selectmesh = assetloader.modellist[j].mesh;
|
||||
}
|
||||
}
|
||||
// console.log(signaldata[i]);
|
||||
let newmesh = selectmesh.clone(true);
|
||||
// newmesh.uuid = signaldata[i].id;
|
||||
for(let j=0;j<newmesh.children.length;j++){
|
||||
newmesh.children[j].code = signaldata[i].code;
|
||||
}
|
||||
newmesh.name = signaldata[i].name;
|
||||
newmesh.code = signaldata[i].code;
|
||||
newmesh.position.x = signaldata[i].position.x;
|
||||
newmesh.position.y = signaldata[i].position.y;
|
||||
newmesh.position.z = signaldata[i].position.z;
|
||||
newmesh.rotation.x = signaldata[i].rotation._x;
|
||||
newmesh.rotation.y = signaldata[i].rotation._y;
|
||||
newmesh.rotation.z = signaldata[i].rotation._z;
|
||||
|
||||
newmesh.matrixAutoUpdate = false;
|
||||
newsignal.mesh = newmesh;
|
||||
newsignal.mesh.status = "01";
|
||||
scope.group.add(newsignal.mesh);
|
||||
scope.list[signaldata[i].code] = newsignal;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// console.log(signaldata[i]);
|
||||
let newmesh = selectmesh.clone(true);
|
||||
// newmesh.uuid = signaldata[i].id;
|
||||
for(let j=0;j<newmesh.children.length;j++){
|
||||
newmesh.children[j].code = signaldata[i].code;
|
||||
}
|
||||
newmesh.name = signaldata[i].name;
|
||||
newmesh.modelid = selectmesh.id;
|
||||
newmesh.code = signaldata[i].code;
|
||||
newmesh.right = data[i].right;
|
||||
newmesh.position.x = signaldata[i].position.x;
|
||||
newmesh.position.y = signaldata[i].position.y;
|
||||
newmesh.position.z = signaldata[i].position.z;
|
||||
newmesh.rotation.x = signaldata[i].rotation._x;
|
||||
newmesh.rotation.y = signaldata[i].rotation._y;
|
||||
newmesh.rotation.z = signaldata[i].rotation._z;
|
||||
newsignal.mesh = newmesh;
|
||||
newsignal.mesh.status = "01";
|
||||
|
||||
scope.group.add(newsignal.mesh);
|
||||
scope.list[signaldata[i].code] = newsignal;
|
||||
}
|
||||
data = null;
|
||||
signaldata = null;
|
||||
scene.add(scope.group);
|
||||
resolve("loadedsignal");
|
||||
});
|
||||
|
@ -1,36 +1,5 @@
|
||||
export function SignalModel(data) {
|
||||
|
||||
this.uuid = null;
|
||||
this.code = null;
|
||||
this.name = null;
|
||||
this.modelid = null;
|
||||
this.type = null;
|
||||
this.direction = null;
|
||||
this.ismodel = false;
|
||||
this.istexture = false;
|
||||
this.modelurl = null;
|
||||
// this.textures = {
|
||||
// red:null,
|
||||
// yellor:null,
|
||||
// green:null
|
||||
// }
|
||||
// this.position = {
|
||||
// x:0,
|
||||
// y:0,
|
||||
// z:0
|
||||
// };
|
||||
// this.rotation = {
|
||||
// x:0,
|
||||
// y:0,
|
||||
// z:0
|
||||
// };
|
||||
// this.scale = {
|
||||
// x:0,
|
||||
// y:0,
|
||||
// z:0
|
||||
// }
|
||||
|
||||
this.mesh = null;
|
||||
this.meshurl = null;
|
||||
this.picurl = null;
|
||||
}
|
||||
|
@ -9,13 +9,12 @@ export function StationStandListN() {
|
||||
this.list = [];
|
||||
|
||||
this.group = new THREE.Group();
|
||||
|
||||
this.group.name = "station";
|
||||
this.textlist = [];
|
||||
|
||||
this.loadpromise = function(stationdata,standsdata,psddata,scene,assetloader,mixers,actionss,mode){
|
||||
return new Promise(function(resolve, reject){
|
||||
console.log(stationdata);
|
||||
console.log(psddata);
|
||||
|
||||
let stations = stationdata;
|
||||
let selectmesh;
|
||||
for(let j=0;j<assetloader.modellist.length;j++){
|
||||
@ -85,7 +84,7 @@ export function StationStandListN() {
|
||||
let mixer = new THREE.AnimationMixer( newstationmesh.children[j] );
|
||||
for(let n=0;n<psddata.length;n++){
|
||||
if(psddata[n].standCode == newstationstand.direction1.code){
|
||||
|
||||
|
||||
let key = psddata[n].code;
|
||||
actionss[key] = {
|
||||
status:"01",
|
||||
@ -104,12 +103,12 @@ export function StationStandListN() {
|
||||
// console.log(newstationmesh);
|
||||
if(mode){
|
||||
if(mode == "02"){
|
||||
let textgeometry = new THREE.PlaneBufferGeometry( 271, 374, 1 );
|
||||
let textgeometry = new THREE.PlaneBufferGeometry( 65, 90, 1 );
|
||||
let textt = new THREE.CanvasTexture(getTextCanvas(stationdata[i]));
|
||||
let textmaterial = new THREE.MeshBasicMaterial( { side: THREE.DoubleSide,map:textt ,transparent: true} );
|
||||
let textplane = new THREE.Mesh( textgeometry, textmaterial );
|
||||
textplane.name = stationdata[i].code;
|
||||
textplane.position.y = 300;
|
||||
textplane.position.y = 70;
|
||||
textplane.rotation.x = Math.PI/2;
|
||||
//textplane.position.x = -30;
|
||||
scope.textlist.push(textplane);
|
||||
@ -125,6 +124,8 @@ export function StationStandListN() {
|
||||
}
|
||||
}
|
||||
// scene.add(scope.textlist);
|
||||
stationdata = null;
|
||||
psddata = null;
|
||||
scene.add(scope.group);
|
||||
resolve("loadedstation");
|
||||
});
|
||||
@ -134,37 +135,38 @@ export function StationStandListN() {
|
||||
//canvas文字贴图方法
|
||||
//PS:待提炼 增强功能
|
||||
var stationcanvas = new Image();
|
||||
stationcanvas.src = "../../static/texture/msgt.png";
|
||||
stationcanvas.src = "../../static/texture/msgtnew.png";
|
||||
function getTextCanvas(text){
|
||||
let canvas = document.getElementById('canvastexture');
|
||||
|
||||
canvas.width = 256;
|
||||
canvas.height = 512;
|
||||
canvas.width = 128;
|
||||
canvas.height = 256;
|
||||
// canvas.style.width = width;
|
||||
// canvas.style.height = height;
|
||||
|
||||
let ctx = canvas.getContext('2d');
|
||||
//ctx.fillStyle = '#FFFFFF';
|
||||
ctx.fillRect(0, 0,256,512);
|
||||
ctx.fillRect(0, 0,128,256);
|
||||
|
||||
ctx.fillStyle = '#FFFFFF';
|
||||
// ctx.textAlign = 'center';
|
||||
// ctx.textBaseline = 'middle';
|
||||
ctx.clearRect(0,0,256,512);
|
||||
ctx.clearRect(0,0,128,256);
|
||||
|
||||
ctx.drawImage(stationcanvas,0,0,256,512);
|
||||
ctx.drawImage(stationcanvas,0,0,128,256);
|
||||
|
||||
ctx.font = "20px Verdana";
|
||||
ctx.fillText("车站名称: "+text.name, 20,58);
|
||||
ctx.font = "10px";
|
||||
ctx.fillText("车站: "+text.name, 15,25);
|
||||
|
||||
ctx.fillText("漫游", 30,100);
|
||||
ctx.fillText("信息", 114,100);
|
||||
ctx.fillText("备忘", 190,100);
|
||||
ctx.fillText("漫游", 18,48);
|
||||
ctx.fillText("信息", 54,48);
|
||||
ctx.fillText("备忘", 93,48);
|
||||
|
||||
ctx.fillText("车站序号: "+text.name, 10,155);
|
||||
ctx.fillText("车站序号: "+text.name, 10,115);
|
||||
|
||||
ctx.fillText("公里标记:"+text.kmPost,10 ,256*3/4);
|
||||
ctx.fillText("公里标记:",10 ,135);
|
||||
ctx.fillText(text.kmPost,10 ,155);
|
||||
|
||||
let data = ctx.getImageData(0, 0,256,512);
|
||||
let data = ctx.getImageData(0, 0,128,256);
|
||||
return data;
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ export function SwitchListN() {
|
||||
autoswitch.rotation.x = switchdata[i].rotation._x;
|
||||
autoswitch.rotation.y = switchdata[i].rotation._y;
|
||||
autoswitch.rotation.z = switchdata[i].rotation._z;
|
||||
|
||||
autoswitch.matrixAutoUpdate = false;
|
||||
autoswitch.animations = assetloader.modellist[num].mesh.animations;
|
||||
|
||||
let mixer = new THREE.AnimationMixer( autoswitch );
|
||||
@ -59,7 +59,6 @@ export function SwitchListN() {
|
||||
actions[autoswitch.code].action.clampWhenFinished = true;
|
||||
mixers.push(mixer);
|
||||
}
|
||||
|
||||
// console.log(scope.switchs.modellist);
|
||||
resolve("loadedswitch");
|
||||
});
|
||||
|
@ -138,7 +138,7 @@ export function TrainListN() {
|
||||
//创建列车字牌
|
||||
if(mode){
|
||||
if(mode == "02"){
|
||||
let textgeometry = new THREE.PlaneBufferGeometry( 150, 100, 1 );
|
||||
let textgeometry = new THREE.PlaneBufferGeometry( 64, 32, 1 );
|
||||
let textt = new THREE.CanvasTexture(getTextCanvas(data[i]));
|
||||
let textmaterial = new THREE.MeshBasicMaterial( {
|
||||
side: THREE.DoubleSide,
|
||||
@ -149,7 +149,8 @@ export function TrainListN() {
|
||||
textplane.name = data[i].code;
|
||||
textplane.position.x = 0;
|
||||
textplane.position.y = 0;
|
||||
textplane.position.z = 60;
|
||||
textplane.position.z = 20;
|
||||
textplane.rotation.x = Math.PI/2;
|
||||
textplane.tcode = data[i].code;
|
||||
//textplane.rotation.x = Math.PI;
|
||||
scope.textlist.push(textplane);
|
||||
@ -182,6 +183,7 @@ export function TrainListN() {
|
||||
newmesh.speeds = 0;
|
||||
newmesh.progress = null;
|
||||
newmesh.startmark = 0;
|
||||
newmesh.open = null;
|
||||
newmesh.statsstop = 0;
|
||||
|
||||
|
||||
@ -193,6 +195,7 @@ export function TrainListN() {
|
||||
// selectmesh.children[i].geometry.dispose();
|
||||
// selectmesh.children[i].material.dispose();
|
||||
// }
|
||||
data = null;
|
||||
scene.add(scope.group);
|
||||
resolve("loadedtrain");
|
||||
});
|
||||
@ -214,7 +217,7 @@ let onProgress = function ( xhr ) {
|
||||
let onError = function () { };
|
||||
|
||||
var beauty = new Image();
|
||||
beauty.src = "../../static/texture/guide.png";
|
||||
beauty.src = "../../static/texture/guidenew.png";
|
||||
//canvas文字贴图方法
|
||||
//PS:待提炼 增强功能
|
||||
function getTextCanvas(text){
|
||||
|
@ -1,8 +1,5 @@
|
||||
export function TrainModel(opts) {
|
||||
|
||||
var scope = this;
|
||||
|
||||
this.mesh = null;
|
||||
this.meshurl = null;
|
||||
this.picurl = null;
|
||||
}
|
||||
|
@ -33,15 +33,15 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Vue from 'vue';
|
||||
import localStore from 'storejs';
|
||||
import { mapGetters } from 'vuex';
|
||||
|
||||
// import ShowProperty from '@/views/jlmap3d/show/property';
|
||||
|
||||
import { simulationNotify, setTrainingCbtcInitTime } from '@/api/simulation';
|
||||
|
||||
import { UrlConfig } from '@/router/index';
|
||||
// import Vue from 'vue';
|
||||
// import localStore from 'storejs';
|
||||
// import { mapGetters } from 'vuex';
|
||||
//
|
||||
// // import ShowProperty from '@/views/jlmap3d/show/property';
|
||||
//
|
||||
// import { simulationNotify, setTrainingCbtcInitTime } from '@/api/simulation';
|
||||
//
|
||||
// import { UrlConfig } from '@/router/index';
|
||||
|
||||
import { JLmap3d } from '@/jlmap3d/jl3dsimulation/jlmap3d.js';
|
||||
|
||||
@ -81,19 +81,6 @@ export default {
|
||||
token:null
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
'jlmap3d.selectmodel.code': {
|
||||
deep: true,
|
||||
handler: function (newVal, oldVal) {
|
||||
if (newVal != oldVal) {
|
||||
// this.selectmodel = this.jlmap3dedit.selectmodel;
|
||||
// this.$refs.property.switchproperty();
|
||||
// console.log(this.jlmap3dedit.selectmodel);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
},
|
||||
beforeDestroy() {
|
||||
// console.log("destroy");
|
||||
if (this.jlmap3d) {
|
||||
@ -136,7 +123,7 @@ export default {
|
||||
let project = this.$route.query.project;
|
||||
// console.log(project);
|
||||
|
||||
|
||||
|
||||
if(project){
|
||||
|
||||
this.jlmap3d = new JLmap3d(dom, mapdata, skinCode,this.$store,group,project);
|
||||
|
@ -27,9 +27,6 @@ export default {
|
||||
|
||||
|
||||
},
|
||||
watch: {
|
||||
|
||||
},
|
||||
methods: {
|
||||
|
||||
init: function() {
|
||||
|
@ -59,16 +59,6 @@ export default {
|
||||
filterText(val) {
|
||||
this.$refs.tree2.filter(val);
|
||||
},
|
||||
modellist: function() {
|
||||
this.$nextTick(function(){
|
||||
////console.log("nextTick");
|
||||
})
|
||||
},
|
||||
texturelist: function() {
|
||||
this.$nextTick(function(){
|
||||
////console.log("nextTick");
|
||||
})
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
modelselect(index){
|
||||
|
Binary file not shown.
Binary file not shown.
BIN
static/model/station/fuzhoufuzhou.FBX
Normal file
BIN
static/model/station/fuzhoufuzhou.FBX
Normal file
Binary file not shown.
BIN
static/texture/guidenew.png
Normal file
BIN
static/texture/guidenew.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
BIN
static/texture/msgtnew.png
Normal file
BIN
static/texture/msgtnew.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.0 KiB |
@ -670,16 +670,6 @@ function timedCount(){
|
||||
|
||||
onmessage = (e) => {
|
||||
|
||||
// data = JSON.parse(e.data);
|
||||
// // console.log(data);
|
||||
// if(data.type == 'Simulation_TrainSpeed'){
|
||||
//
|
||||
// }else{
|
||||
// postMessage(data);
|
||||
// }
|
||||
//
|
||||
console.log(e.data);
|
||||
|
||||
if(e.data.type == "init"){
|
||||
topic = e.data.topic;
|
||||
header = {'X-Token': e.data.token };
|
||||
@ -699,16 +689,18 @@ function timedCount(){
|
||||
|
||||
data = JSON.parse(Response.body);
|
||||
// console.log(data);
|
||||
// if(data.type == 'TrainRun_3D'){
|
||||
// for (let i=0,leni = data.body.length; i<leni; i++) {
|
||||
// data.body[i].type = "TRAIN";
|
||||
// postMessage(data.body[i]);
|
||||
// }
|
||||
// }
|
||||
if(data.type == 'TrainRun_3D'){
|
||||
for (let i=0,leni = data.body.length; i<leni; i++) {
|
||||
data.body[i].type = "TRAIN";
|
||||
postMessage(data.body[i]);
|
||||
}
|
||||
}
|
||||
if(data.type == 'Simulation_DeviceStatus' && data.body.length>300){
|
||||
// console.log(data);
|
||||
postMessage(data);
|
||||
postMessage(data);
|
||||
return;
|
||||
}
|
||||
//data.type == 'Simulation_DeviceStatus' &&
|
||||
|
||||
// if(data.type == 'Simulation_DeviceStatus'){
|
||||
// for (let i= 0,leni = data.body.length; i<leni; i++) {
|
||||
// if(data.body[i].deviceType == "TRAIN"){
|
||||
@ -718,13 +710,21 @@ function timedCount(){
|
||||
// }
|
||||
if(data.type == "Train_Hmi_3D"){
|
||||
postMessage(data);
|
||||
return;
|
||||
}
|
||||
if(data.type == 'DeviceCtrl_3D'){
|
||||
// console.log(data);
|
||||
postMessage(data.body);
|
||||
return;
|
||||
}
|
||||
if(data.type == 'Simulation_Reset'){
|
||||
postMessage(data);
|
||||
return;
|
||||
}
|
||||
if( data.body.length>300){
|
||||
// console.log(data);
|
||||
postMessage(data);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user