修改三维vr乘车报站,修改哈尔滨静态贴图
This commit is contained in:
parent
d5278b3127
commit
9290dc6b47
@ -6,16 +6,18 @@ const BASE_API = getBaseUrl();
|
||||
let uploadurl = null;
|
||||
let asseturl = null;
|
||||
if(BASE_API == "https://test.joylink.club/jlcloud"){
|
||||
uploadurl = "https://test.joylink.club/jlfile";
|
||||
asseturl = "https://test.joylink.club/oss/joylink"
|
||||
uploadurl = "https://joylink.club/jlfile";
|
||||
asseturl = "https://joylink.club/oss/joylink";
|
||||
// uploadurl = "https://test.joylink.club/jlfile";
|
||||
// asseturl = "https://test.joylink.club/oss/joylink";
|
||||
}else if(BASE_API == "https://joylink.club/jlcloud"){
|
||||
uploadurl = "https://joylink.club/jlfile";
|
||||
asseturl = "https://joylink.club/oss/joylink"
|
||||
asseturl = "https://joylink.club/oss/joylink";
|
||||
}else{
|
||||
// uploadurl = "https://test.joylink.club/jlfile";
|
||||
// asseturl = "https://test.joylink.club/oss/joylink"
|
||||
uploadurl = "../static";
|
||||
asseturl = "../static"
|
||||
asseturl = "../static";
|
||||
}
|
||||
const BASE_UPLOAD_API = uploadurl;
|
||||
export const BASE_ASSET_API = asseturl;
|
||||
|
@ -23,24 +23,43 @@ import { getToken } from '@/utils/auth';
|
||||
import { sendCommandNew } from '@/api/jmap/training';
|
||||
|
||||
var clock = new THREE.Clock();
|
||||
let movegroup = new THREE.Group();
|
||||
let human = new THREE.Object3D();
|
||||
let controller1, controller2,raycastervr;
|
||||
let vrPlane;
|
||||
let vrPlaneStatus = false;
|
||||
let tempMatrix = new THREE.Matrix4();
|
||||
let nowdevice = null;
|
||||
|
||||
let movegroup = new THREE.Group();
|
||||
//人物组(包裹vr头盔对象)
|
||||
let human = new THREE.Object3D();
|
||||
|
||||
let controller1, controller2,raycastervr;
|
||||
//vrUI面板
|
||||
let vrPlane;
|
||||
//vrUI面板控制状态
|
||||
let vrPlaneStatus = false;
|
||||
|
||||
let tempMatrix = new THREE.Matrix4();
|
||||
|
||||
let nowdevice = null;
|
||||
//设备动画
|
||||
let deviceaction = [];
|
||||
//设备lable<==>code转换
|
||||
let lableCodeMap = {
|
||||
switch:[],
|
||||
psd:[],
|
||||
signal:[],
|
||||
section:[]
|
||||
};
|
||||
//故障列表
|
||||
let faultList = [];
|
||||
//车站信息列表
|
||||
let stationList = [];
|
||||
|
||||
//列车对象
|
||||
let trainControl = new TrainControl();
|
||||
//人物所处地面状态
|
||||
let positionStatus = "dm";
|
||||
//列车地板
|
||||
let floors = [];
|
||||
//声音
|
||||
window.speechSynthesis.getVoices()
|
||||
let voices = speechSynthesis.getVoices();
|
||||
|
||||
export function Jl3dfaultdeviceVR(dom,group,token,skinCode) {
|
||||
|
||||
var scope = this;
|
||||
@ -106,7 +125,7 @@ export function Jl3dfaultdeviceVR(dom,group,token,skinCode) {
|
||||
this.renderer.gammaOutput = true;
|
||||
this.renderer.vr.enabled = true;
|
||||
this.dom.appendChild(this.renderer.domElement);
|
||||
document.body.appendChild( VRButton.createButton( this.renderer ) );
|
||||
document.body.appendChild( VRButton.createButton( human,this.renderer ) );
|
||||
//定义相机
|
||||
|
||||
this.camera = new THREE.PerspectiveCamera(50, window.innerWidth / window.innerHeight, 0.01, 300);
|
||||
@ -144,6 +163,33 @@ export function Jl3dfaultdeviceVR(dom,group,token,skinCode) {
|
||||
|
||||
raycastervr = new THREE.Raycaster();
|
||||
|
||||
//设定声音
|
||||
let voiceSelect;
|
||||
localVoiceInit();
|
||||
function localVoiceInit(){
|
||||
let voices = speechSynthesis.getVoices();
|
||||
for(let i = 0; i < voices.length; i++) {
|
||||
if(voices[i].name == "Microsoft Huihui Desktop - Chinese (Simplified)"){
|
||||
voiceSelect = voices[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
function localVoicePlay(playText) {
|
||||
localVoiceCancel();
|
||||
let toSpeak = new SpeechSynthesisUtterance(playText);
|
||||
toSpeak.rate = 0.7;
|
||||
toSpeak.voice = voiceSelect;
|
||||
|
||||
window.speechSynthesis.speak(toSpeak);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function localVoiceCancel() {
|
||||
window.speechSynthesis.cancel();
|
||||
}
|
||||
|
||||
let loaderObj = new THREE.OBJLoader();
|
||||
|
||||
// load a resource
|
||||
@ -155,7 +201,7 @@ export function Jl3dfaultdeviceVR(dom,group,token,skinCode) {
|
||||
|
||||
|
||||
// console.time('createZone()');
|
||||
console.log(object);
|
||||
|
||||
const zone = THREE.Pathfinding.createZone(object.children[0].geometry);
|
||||
// console.timeEnd('createZone()');
|
||||
|
||||
@ -169,6 +215,7 @@ export function Jl3dfaultdeviceVR(dom,group,token,skinCode) {
|
||||
// scene.add(navWireframe);
|
||||
|
||||
navmesh = object;
|
||||
|
||||
// scene.add(navmesh);
|
||||
// movegroup.add(navmesh);
|
||||
// Set the player's navigation mesh group
|
||||
@ -281,6 +328,131 @@ export function Jl3dfaultdeviceVR(dom,group,token,skinCode) {
|
||||
|
||||
return;
|
||||
}
|
||||
if(event.data.type == "takeTopTrain"){
|
||||
|
||||
for(let i=0,leni=stationList.length;i<leni;i++){
|
||||
|
||||
if(stationList[i].code == event.data.stationcode){
|
||||
scope.nowstation = stationList[i];
|
||||
let stationworket = {
|
||||
type:'station',
|
||||
station:scope.nowstation
|
||||
};
|
||||
|
||||
let voicetext = scope.nowstation.name.split("(");
|
||||
localVoicePlay("列车即将进站"+voicetext[0]);
|
||||
|
||||
vrwebworker.postMessage(stationworket);
|
||||
vrPlane.updataStationMsg(scope.nowstation);
|
||||
trainControl.toptrain.position.x = 20000;
|
||||
trainControl.downtrain.position.x = 20000;
|
||||
trainControl.toptrain.status = "0";
|
||||
trainControl.downtrain.status = "0";
|
||||
scope.nowStationModel.getObjectByName("zhantaiming").material.map = scope.stationtexture[scope.nowstation.code];
|
||||
scope.nowStationModel.getObjectByName("zhantaiming").material.map.needsUpdate = true;
|
||||
i = leni;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if(event.data.type == "takeDownTrain"){
|
||||
console.log(event.data);
|
||||
console.log(stationList);
|
||||
for(let i=0,leni=stationList.length;i<leni;i++){
|
||||
if(stationList[i].code == event.data.stationcode){
|
||||
scope.nowstation = stationList[i];
|
||||
let stationworket = {
|
||||
type:'station',
|
||||
station:scope.nowstation
|
||||
};
|
||||
|
||||
let voicetext = scope.nowstation.name.split("(");
|
||||
localVoicePlay("列车即将进站"+voicetext[0]);
|
||||
|
||||
vrwebworker.postMessage(stationworket);
|
||||
vrPlane.updataStationMsg(scope.nowstation);
|
||||
trainControl.toptrain.position.x = 20000;
|
||||
trainControl.downtrain.position.x = 20000;
|
||||
trainControl.toptrain.status = "0";
|
||||
trainControl.downtrain.status = "0";
|
||||
scope.nowStationModel.getObjectByName("zhantaiming").material.map = scope.stationtexture[scope.nowstation.code];
|
||||
scope.nowStationModel.getObjectByName("zhantaiming").material.map.needsUpdate = true;
|
||||
i = leni;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(event.data.type == "topTrain"){
|
||||
console.log(event.data);
|
||||
console.log(trainControl.toptrain.status);
|
||||
if(trainControl.toptrain.status != 1){
|
||||
trainControl.toptrain.position.copy(trainControl.toptrain.curve.getPointAt(event.data.offset));
|
||||
}
|
||||
|
||||
}
|
||||
if(event.data.type == "downTrain"){
|
||||
if(trainControl.downtrain.status != 1){
|
||||
trainControl.downtrain.position.copy(trainControl.downtrain.curve.getPointAt(event.data.offset));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(event.data.type == "topTrainDoor"){
|
||||
|
||||
console.log(event.data);
|
||||
|
||||
if(event.data.open == "0"){
|
||||
trainControl.closetraindoor(trainControl.toptrain,event.data.doorCode,"top");
|
||||
// trainLeaveStation("top");
|
||||
}else{
|
||||
trainControl.opentraindoor(trainControl.toptrain,event.data.doorCode,"top");
|
||||
trainControl.toptrain.status = 1;
|
||||
}
|
||||
|
||||
}
|
||||
if(event.data.type == "downTrainDoor"){
|
||||
if(event.data.open == "0"){
|
||||
trainControl.closetraindoor(trainControl.downtrain,event.data.doorCode,"down");
|
||||
// trainLeaveStation("down");
|
||||
}else{
|
||||
trainControl.opentraindoor(trainControl.downtrain,event.data.doorCode,"down");
|
||||
trainControl.downtrain.status = 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(event.data.type == "topPsd"){
|
||||
|
||||
if(event.data.open == 0){
|
||||
|
||||
deviceaction.top.action.reset();
|
||||
deviceaction.top.action.time =deviceaction.top.action._clip.duration;
|
||||
deviceaction.top.action.timeScale = -1;
|
||||
deviceaction.top.action.play();
|
||||
}else{
|
||||
deviceaction.top.action.reset();
|
||||
deviceaction.top.action.time = 0;
|
||||
deviceaction.top.action.timeScale = 1;
|
||||
deviceaction.top.action.play();
|
||||
}
|
||||
}
|
||||
if(event.data.type == "downPsd"){
|
||||
if(event.data.open == 0){
|
||||
deviceaction.down.action.reset();
|
||||
deviceaction.down.action.time = deviceaction.down.action._clip.duration;
|
||||
deviceaction.down.action.timeScale = -1;
|
||||
deviceaction.down.action.play();
|
||||
}else{
|
||||
deviceaction.down.action.reset();
|
||||
deviceaction.down.action.time = 0;
|
||||
deviceaction.down.action.timeScale = 1;
|
||||
deviceaction.down.action.play();
|
||||
}
|
||||
}
|
||||
|
||||
if(event.data.type == "SWITCH"){
|
||||
scope.updateaction(event.data);
|
||||
}
|
||||
@ -393,6 +565,8 @@ export function Jl3dfaultdeviceVR(dom,group,token,skinCode) {
|
||||
human.position.set(switchModel.matrixWorld.elements[12],switchModel.matrixWorld.elements[13],switchModel.matrixWorld.elements[14]);
|
||||
|
||||
|
||||
initstationanimation(scope.modelmanager.stationIn.mesh);
|
||||
initstationanimation(scope.modelmanager.stationOut.mesh);
|
||||
|
||||
|
||||
|
||||
@ -405,24 +579,34 @@ export function Jl3dfaultdeviceVR(dom,group,token,skinCode) {
|
||||
scope.nowStationModel = scope.modelmanager.stationIn.mesh;
|
||||
scope.scene.add(scope.nowStationModel);
|
||||
}
|
||||
|
||||
if(scope.stationtexture["stationlist"]){
|
||||
vrPlane.setStationPlane(stationList,scope.stationtexture);
|
||||
scope.nowStationModel.getObjectByName("zhantailiebiao").material.map =scope.stationtexture["stationlist"];
|
||||
scope.nowStationModel.getObjectByName("zhantailiebiao").material.map.needsUpdate = true;
|
||||
if(scope.nowStationModel.getObjectByName("menkuangyanse")){
|
||||
scope.nowStationModel.getObjectByName("menkuangyanse").material.map =scope.stationtexture["pingbimen"];
|
||||
scope.nowStationModel.getObjectByName("menkuangyanse").material.map.needsUpdate = true;
|
||||
}
|
||||
scope.nowStationModel.getObjectByName("zhantaiming").material.map = scope.stationtexture[scope.nowstation.code];
|
||||
scope.nowStationModel.getObjectByName("zhantaiming").material.map.needsUpdate = true;
|
||||
|
||||
}
|
||||
trainControl.inittrain(scope.scene,scope.modelmanager.train.mesh,scope.modelmanager.train.animations,mixers);
|
||||
scope.scene.add(scope.modelmanager.otherDevice.mesh);
|
||||
scope.scene.add( vrPlane.group );
|
||||
vrwebworker.postMessage("connect");
|
||||
animate();
|
||||
floors.push(trainControl.toptrain.floor);
|
||||
floors.push(trainControl.downtrain.floor);
|
||||
floors.push(navmesh.children[0]);
|
||||
|
||||
|
||||
|
||||
let timer=setInterval(function(){
|
||||
|
||||
if(scope.stationtexture["stationlist"]){
|
||||
vrPlane.setStationPlane(stationList,scope.stationtexture);
|
||||
scope.nowStationModel.getObjectByName("zhantailiebiao").material.map =scope.stationtexture["stationlist"];
|
||||
scope.nowStationModel.getObjectByName("zhantailiebiao").material.map.needsUpdate = true;
|
||||
if(scope.nowStationModel.getObjectByName("menkuangyanse")){
|
||||
scope.nowStationModel.getObjectByName("menkuangyanse").material.map =scope.stationtexture["pingbimen"];
|
||||
scope.nowStationModel.getObjectByName("menkuangyanse").material.map.needsUpdate = true;
|
||||
}
|
||||
scope.nowStationModel.getObjectByName("zhantaiming").material.map = scope.stationtexture[scope.nowstation.code];
|
||||
scope.nowStationModel.getObjectByName("zhantaiming").material.map.needsUpdate = true;
|
||||
scope.scene.add(scope.modelmanager.otherDevice.mesh);
|
||||
scope.scene.add( vrPlane.group );
|
||||
vrwebworker.postMessage("connect");
|
||||
animate();
|
||||
clearInterval(timer);
|
||||
}
|
||||
},1000);
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@ -475,9 +659,15 @@ export function Jl3dfaultdeviceVR(dom,group,token,skinCode) {
|
||||
scope.nowStationModel = scope.modelmanager.stationIn.mesh;
|
||||
scope.scene.add(scope.nowStationModel);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
scope.nowstation = stationList[i];
|
||||
let stationworket = {
|
||||
type:'station',
|
||||
station:scope.nowstation
|
||||
};
|
||||
vrwebworker.postMessage(stationworket);
|
||||
vrPlane.updataStationMsg(scope.nowstation);
|
||||
scope.nowStationModel.getObjectByName("zhantaiming").material.map = scope.stationtexture[scope.nowstation.code];
|
||||
scope.nowStationModel.getObjectByName("zhantaiming").material.map.needsUpdate = true;
|
||||
@ -498,19 +688,16 @@ export function Jl3dfaultdeviceVR(dom,group,token,skinCode) {
|
||||
}
|
||||
|
||||
if(object.name == "shebeijian"){
|
||||
human.position.set( -199.90, 0.20+0.6, -5.76 );
|
||||
human.position.set( 41.30, 6.05+0.6, -5.55);
|
||||
}
|
||||
|
||||
if(object.name == "jiankongshi"){
|
||||
human.position.set( -213.610, 0.20+0.6,5.38);
|
||||
human.position.set( 28.30, 6.05+0.6,5.65);
|
||||
}
|
||||
|
||||
if(object.name == "station1"){
|
||||
human.position.set( -242.37, -4.46+0.6, 4.13);
|
||||
human.position.set( -12.21, 1.38+0.6, 3.49);
|
||||
}
|
||||
|
||||
if(object.name == "station2"){
|
||||
human.position.set( -242.621, 0.20+0.6, 4.90 );
|
||||
human.position.set( -0.63, 6.05+0.6, 4.40 );
|
||||
}
|
||||
|
||||
if(object.name == "anime"){
|
||||
@ -630,10 +817,18 @@ export function Jl3dfaultdeviceVR(dom,group,token,skinCode) {
|
||||
}
|
||||
|
||||
scope.nowstation = stationList[i];
|
||||
let stationworket = {
|
||||
type:'station',
|
||||
station:scope.nowstation
|
||||
};
|
||||
vrwebworker.postMessage(stationworket);
|
||||
vrPlane.updataStationMsg(scope.nowstation);
|
||||
scope.nowStationModel.getObjectByName("zhantaiming").material.map = scope.stationtexture[scope.nowstation.code];
|
||||
scope.nowStationModel.getObjectByName("zhantaiming").material.map.needsUpdate = true;
|
||||
|
||||
trainControl.toptrain.position.x = 20000;
|
||||
trainControl.downtrain.position.x = 20000;
|
||||
trainControl.toptrain.status = "0";
|
||||
trainControl.downtrain.status = "0";
|
||||
i = leni;
|
||||
}
|
||||
}
|
||||
@ -651,19 +846,16 @@ export function Jl3dfaultdeviceVR(dom,group,token,skinCode) {
|
||||
|
||||
|
||||
if(object.name == "shebeijian"){
|
||||
human.position.set( -199.90, 0.20+0.6, -5.76 );
|
||||
human.position.set( 41.30, 6.05+0.6, -5.55);
|
||||
}
|
||||
|
||||
if(object.name == "jiankongshi"){
|
||||
human.position.set( -213.610, 0.20+0.6,5.38);
|
||||
human.position.set( 28.30, 6.05+0.6,5.65);
|
||||
}
|
||||
|
||||
if(object.name == "station1"){
|
||||
human.position.set( -242.37, -4.46+0.6, 4.13);
|
||||
human.position.set( -12.21, 1.38+0.6, 3.49);
|
||||
}
|
||||
|
||||
if(object.name == "station2"){
|
||||
human.position.set( -242.621, 0.20+0.6, 4.90 );
|
||||
human.position.set( -0.63, 6.05+0.6, 4.40 );
|
||||
}
|
||||
|
||||
if(object.name == "anime"){
|
||||
@ -740,20 +932,59 @@ export function Jl3dfaultdeviceVR(dom,group,token,skinCode) {
|
||||
}else{
|
||||
var intersections = getIntersections( controller );
|
||||
// console.log(intersections);
|
||||
if ( intersections.length > 0 ) {
|
||||
if ( intersections) {
|
||||
// console.log(intersections);
|
||||
var intersection = intersections[ 0 ];
|
||||
// console.log(intersection);
|
||||
console.log("=======================");
|
||||
console.log(positionStatus);
|
||||
console.log(intersection.object.name);
|
||||
if(positionStatus != intersection.object.name){
|
||||
positionStatus = intersection.object.name;
|
||||
|
||||
if(intersection.object.name == "dm"){
|
||||
scope.scene.add(human);
|
||||
vrwebworker.postMessage("takeStation");
|
||||
}
|
||||
if(intersection.object.name == "topfloor"){
|
||||
trainControl.toptrain.add(human);
|
||||
vrwebworker.postMessage("takeTopTrain");
|
||||
}
|
||||
if(intersection.object.name == "downfloor"){
|
||||
trainControl.downtrain.add(human);
|
||||
vrwebworker.postMessage("takeDownTrain");
|
||||
}
|
||||
|
||||
}
|
||||
var object = intersection.object;
|
||||
// object.matrix.premultiply( tempMatrix );
|
||||
// object.matrix.decompose( object.position, object.quaternion, object.scale );
|
||||
// object.material.emissive.b = 1;
|
||||
// controller.add( object );
|
||||
console.log(intersection.point);
|
||||
|
||||
// controller.userData.selected = object;
|
||||
// console.log(object.matrixWorld.elements);
|
||||
human.position.set( intersection.point.x, intersection.point.y+0.6, intersection.point.z );
|
||||
if(positionStatus == "dm"){
|
||||
human.position.set( intersection.point.x, intersection.point.y+0.6, intersection.point.z );
|
||||
}
|
||||
if(positionStatus == "topfloor"){
|
||||
let posx = intersection.point.x - trainControl.toptrain.position.x;
|
||||
let posz = intersection.point.z - trainControl.toptrain.position.z;
|
||||
human.position.set( posx, intersection.point.y+0.6, posz);
|
||||
// console.log(human.position);
|
||||
}
|
||||
if(positionStatus == "downfloor"){
|
||||
let posx = trainControl.downtrain.position.x - intersection.point.x;
|
||||
let posz = trainControl.downtrain.position.z - intersection.point.z;
|
||||
|
||||
human.position.set( posx, intersection.point.y+0.6, posz);
|
||||
// console.log(human.position);
|
||||
}
|
||||
|
||||
|
||||
// var object = intersection.object;
|
||||
// // object.matrix.premultiply( tempMatrix );
|
||||
// // object.matrix.decompose( object.position, object.quaternion, object.scale );
|
||||
// // object.material.emissive.b = 1;
|
||||
// // controller.add( object );
|
||||
//
|
||||
// // controller.userData.selected = object;
|
||||
// // console.log(object.matrixWorld.elements);
|
||||
// human.position.set( intersection.point.x, intersection.point.y+0.6, intersection.point.z );
|
||||
|
||||
}
|
||||
}
|
||||
@ -772,23 +1003,23 @@ export function Jl3dfaultdeviceVR(dom,group,token,skinCode) {
|
||||
}
|
||||
|
||||
function onControlModelStart( event ) {
|
||||
var controller = event.target;
|
||||
var intersections = getIntersections( controller );
|
||||
if ( intersections.length > 0 ) {
|
||||
|
||||
// for(){}
|
||||
// console.log(intersections);
|
||||
var intersection = intersections[ 0 ];
|
||||
// console.log(intersection);
|
||||
// tempMatrix.getInverse( controller.matrixWorld );
|
||||
//
|
||||
// var object = intersection.object;
|
||||
// object.matrix.premultiply( tempMatrix );
|
||||
// object.matrix.decompose( object.position, object.quaternion, object.scale );
|
||||
// object.material.emissive.b = 1;
|
||||
// controller.add( object );
|
||||
|
||||
}
|
||||
// var controller = event.target;
|
||||
// var intersections = getIntersections( controller );
|
||||
// if ( intersections.length > 0 ) {
|
||||
//
|
||||
// // for(){}
|
||||
// // console.log(intersections);
|
||||
// var intersection = intersections[ 0 ];
|
||||
// // console.log(intersection);
|
||||
// // tempMatrix.getInverse( controller.matrixWorld );
|
||||
// //
|
||||
// // var object = intersection.object;
|
||||
// // object.matrix.premultiply( tempMatrix );
|
||||
// // object.matrix.decompose( object.position, object.quaternion, object.scale );
|
||||
// // object.material.emissive.b = 1;
|
||||
// // controller.add( object );
|
||||
//
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@ -865,7 +1096,23 @@ export function Jl3dfaultdeviceVR(dom,group,token,skinCode) {
|
||||
tempMatrix.identity().extractRotation( controller.matrixWorld );
|
||||
raycastervr.ray.origin.setFromMatrixPosition( controller.matrixWorld );
|
||||
raycastervr.ray.direction.set( 0, 0, - 1 ).applyMatrix4( tempMatrix );
|
||||
return raycastervr.intersectObjects( navmesh.children,true );
|
||||
for(let i=0;i<3;i++){
|
||||
let rayObject = raycastervr.intersectObject( floors[i]);
|
||||
// console.log(rayObject);
|
||||
if(rayObject.length>0){
|
||||
return rayObject;
|
||||
}
|
||||
}
|
||||
// if(positionStatus == "station"){
|
||||
// return raycastervr.intersectObjects( navmesh.children,true );
|
||||
// }
|
||||
// if(positionStatus == "toptrain"){
|
||||
// return raycastervr.intersectObjects( trainControl.topTrain.floor,true );
|
||||
// }
|
||||
// if(positionStatus == "downtrain"){
|
||||
// return raycastervr.intersectObjects( trainControl.downTrain.floor,true );
|
||||
// }
|
||||
|
||||
}
|
||||
var loader = new THREE.TextureLoader();
|
||||
var circle;
|
||||
@ -900,10 +1147,12 @@ export function Jl3dfaultdeviceVR(dom,group,token,skinCode) {
|
||||
|
||||
var intersections = getIntersections( controller );
|
||||
|
||||
if ( intersections.length > 0 ) {
|
||||
if ( intersections) {
|
||||
|
||||
var intersection = intersections[ 0 ];
|
||||
// console.log(intersection);
|
||||
var object = intersection.object;
|
||||
circle.position.set( intersection.point.x, intersection.point.y+0.01, intersection.point.z );
|
||||
circle.position.set( intersection.point.x, intersection.point.y+0.05, intersection.point.z );
|
||||
}
|
||||
}
|
||||
|
||||
@ -938,16 +1187,13 @@ export function Jl3dfaultdeviceVR(dom,group,token,skinCode) {
|
||||
|
||||
this.updateaction = function (data) {
|
||||
if (data.type == "SWITCH") {
|
||||
console.log("pay");
|
||||
if (data.normal == "0") {
|
||||
console.log("play1");
|
||||
scope.modelmanager.otherDevice.normalPosition = "0";
|
||||
scope.modelmanager.otherDevice.action.reset();
|
||||
scope.modelmanager.otherDevice.action.time = 0;
|
||||
scope.modelmanager.otherDevice.action.timeScale = 1;
|
||||
scope.modelmanager.otherDevice.action.play();
|
||||
} else if (data.normal == "1") {
|
||||
console.log("play2");
|
||||
scope.modelmanager.otherDevice.normalPosition = "1";
|
||||
scope.modelmanager.otherDevice.action.reset();
|
||||
scope.modelmanager.otherDevice.action.time = scope.modelmanager.otherDevice.action._clip.duration;
|
||||
@ -990,6 +1236,7 @@ export function Jl3dfaultdeviceVR(dom,group,token,skinCode) {
|
||||
list[stationdata[i].name] = [];
|
||||
for(let j=0,lenj = standdata.length;j<lenj;j++){
|
||||
if(standdata[j].stationCode == stationdata[i].code){
|
||||
standdata[j].index = i;
|
||||
list[stationdata[i].name].push(standdata[j]);
|
||||
}
|
||||
}
|
||||
@ -1005,6 +1252,7 @@ export function Jl3dfaultdeviceVR(dom,group,token,skinCode) {
|
||||
topsection:null,
|
||||
downsection:null,
|
||||
inside:null,
|
||||
index:list[k][0].index,
|
||||
};
|
||||
if(list[k][0].position.y<list[k][1].position.y){
|
||||
stationobject.toppsd = list[k][0].name;
|
||||
@ -1016,16 +1264,20 @@ export function Jl3dfaultdeviceVR(dom,group,token,skinCode) {
|
||||
stationobject.toppsd = list[k][1].name;
|
||||
stationobject.downpsd = list[k][0].name;
|
||||
stationobject.topsection = list[k][1].standTrackCode;
|
||||
stationobject.downsection = list[k][0].standTrackCode;
|
||||
stationobject.downsection = list[k][0].sstandTrackCode;
|
||||
stationobject.inside = list[k][0].inside;
|
||||
}
|
||||
stationList.push(stationobject);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
console.log(stationList);
|
||||
scope.nowstation = stationList[0];
|
||||
|
||||
let stationworket = {
|
||||
type:'station',
|
||||
station:scope.nowstation
|
||||
};
|
||||
vrwebworker.postMessage(stationworket);
|
||||
|
||||
|
||||
}
|
||||
@ -1035,6 +1287,61 @@ export function Jl3dfaultdeviceVR(dom,group,token,skinCode) {
|
||||
function updateFaultList(){
|
||||
vrPlane.updataFaultList(faultList);
|
||||
}
|
||||
|
||||
function initstationanimation(object){
|
||||
let mixer = new THREE.AnimationMixer( object );
|
||||
|
||||
let newclip = object.animations[ 0 ];
|
||||
for(let j=0;j<object.children.length;j++){
|
||||
|
||||
if(object.children[j].name == "top"){
|
||||
// let geometry = new THREE.BoxBufferGeometry( 50, 50, 50 );
|
||||
// let material = new THREE.MeshBasicMaterial( {color: 0x00ff00} );
|
||||
// let cube = new THREE.Mesh( geometry, material );
|
||||
// cube.position.copy(object.children[j].position);
|
||||
// scene.add( cube );
|
||||
object.children[j].animations = [];
|
||||
object.children[j].animations.push(newclip.clone());
|
||||
|
||||
let mixer = new THREE.AnimationMixer( object.children[j] );
|
||||
|
||||
let action =mixer.clipAction( object.children[j].animations[0])
|
||||
action.setLoop(THREE.LoopOnce);
|
||||
action.clampWhenFinished = true;
|
||||
// action.play();
|
||||
|
||||
mixers.push(mixer);
|
||||
let device = {
|
||||
action:action,
|
||||
mixer:mixer,
|
||||
};
|
||||
deviceaction[object.children[j].name] = device;
|
||||
}
|
||||
if(object.children[j].name == "down"){
|
||||
object.children[j].animations = [];
|
||||
object.children[j].animations.push(newclip.clone());
|
||||
|
||||
let mixer = new THREE.AnimationMixer( object.children[j] );
|
||||
|
||||
|
||||
let action =mixer.clipAction( object.children[j].animations[0])
|
||||
// action.play();
|
||||
action.setLoop(THREE.LoopOnce);
|
||||
action.clampWhenFinished = true;
|
||||
|
||||
mixers.push(mixer);
|
||||
let device = {
|
||||
action:action,
|
||||
mixer:mixer,
|
||||
};
|
||||
deviceaction[object.children[j].name] = device;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
function setTextVr(intersects,plane){
|
||||
console.log(intersects);
|
||||
console.log(plane);
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
var VRButton = {
|
||||
|
||||
createButton: function ( renderer, options ) {
|
||||
createButton: function ( originPos,renderer, options ) {
|
||||
|
||||
if ( options && options.referenceSpaceType ) {
|
||||
|
||||
@ -38,7 +38,7 @@ var VRButton = {
|
||||
button.onclick = function () {
|
||||
|
||||
device.isPresenting ? device.exitPresent() : device.requestPresent( [ { source: renderer.domElement } ] );
|
||||
|
||||
originPos.position.set( -12.21, 1.38+0.6, 3.49);
|
||||
};
|
||||
|
||||
renderer.vr.setDevice( device );
|
||||
@ -166,7 +166,7 @@ var VRButton = {
|
||||
element.style.zIndex = '999';
|
||||
|
||||
}
|
||||
|
||||
|
||||
if ( 'xr' in navigator ) {
|
||||
console.log("xr");
|
||||
var button = document.createElement( 'button' );
|
||||
|
@ -3,90 +3,169 @@ export function TrainControl(){
|
||||
this.toptrain = null;
|
||||
this.downtrain = null;
|
||||
|
||||
|
||||
this.inittrain = function(scene,object,animations,mixers){
|
||||
let ntracks1,ntracks2,tclip,fclip;
|
||||
|
||||
ntracks1 = animations.slice(16,27);
|
||||
ntracks2 = animations.slice(6,13);
|
||||
|
||||
fclip = new THREE.AnimationClip("four",2,ntracks2);
|
||||
|
||||
|
||||
ntracks1 = animations.slice(0,5);
|
||||
|
||||
tclip = new THREE.AnimationClip("three",2,ntracks1);
|
||||
|
||||
ntracks2 = animations.slice(0,15);
|
||||
|
||||
fclip = new THREE.AnimationClip("four",2,ntracks2);
|
||||
|
||||
|
||||
|
||||
scope.toptrain = object.clone(true);
|
||||
scope.toptrain.nowcode = null;
|
||||
scope.toptrain.floor = scope.toptrain.getObjectByName("xunlu6");
|
||||
scope.toptrain.floor.name = "topfloor";
|
||||
scope.toptrain.status = 0;
|
||||
scope.toptrain.action = {
|
||||
top:[],
|
||||
down:[]
|
||||
};
|
||||
let points1 = [];
|
||||
points1.push(new THREE.Vector3(-71,0.06,-6.3));
|
||||
points1.push(new THREE.Vector3(60.73,0.06,-6.3));
|
||||
|
||||
points1.push(new THREE.Vector3(-38.73,0.06,-8.3));
|
||||
points1.push(new THREE.Vector3(38.33,0.06,-8.3));
|
||||
|
||||
scope.toptrain.curve = new THREE.CatmullRomCurve3(points1);
|
||||
|
||||
scope.downtrain = object.clone(true);
|
||||
scope.downtrain.nowcode = null;
|
||||
scope.downtrain.floor = scope.downtrain.getObjectByName("xunlu6");
|
||||
// console.log();
|
||||
scope.downtrain.floor.name = "downfloor";
|
||||
scope.downtrain.status = 0;
|
||||
scope.downtrain.action = {
|
||||
top:[],
|
||||
down:[]
|
||||
};
|
||||
let points2 = [];
|
||||
points2.push(new THREE.Vector3(-71,0.06,28.68));
|
||||
points2.push(new THREE.Vector3(60.73,0.06,28.68));
|
||||
points2.push(new THREE.Vector3(-38.73,0.06,8.8));
|
||||
points2.push(new THREE.Vector3(41.33,0.06,8.8));
|
||||
scope.downtrain.curve = new THREE.CatmullRomCurve3(points2);
|
||||
|
||||
|
||||
inittrainanimation(scope.toptrain,tclip,fclip,mixers);
|
||||
inittrainanimation(scope.downtrain,tclip,fclip,mixers);
|
||||
|
||||
// console.log("train");
|
||||
// console.log(scope.toptrain);
|
||||
// console.log(scope.downtrain);
|
||||
scope.toptrain.position.z = -8.3;
|
||||
scope.toptrain.position.y = -20000;
|
||||
scope.downtrain.rotation.y = Math.PI;
|
||||
scope.downtrain.position.z = 8.8;
|
||||
scope.downtrain.position.y = -20000;
|
||||
|
||||
scope.toptrain.position.z = 8.8;
|
||||
// scope.toptrain.position.y = -20000;
|
||||
scope.toptrain.rotation.y = Math.PI;
|
||||
scope.downtrain.position.z = -8.3;
|
||||
// scope.downtrain.position.y = -20000;
|
||||
scene.add(scope.toptrain);
|
||||
scene.add(scope.downtrain);
|
||||
}
|
||||
this.opentraindoor = function(train,doorcode,direct){
|
||||
|
||||
let actions = null;
|
||||
if(direct == "top"){
|
||||
// if(doorcode == "1"){
|
||||
// actions = train.action.down;
|
||||
// }
|
||||
//
|
||||
// if(doorcode == "2"){
|
||||
// actions = train.action.top;
|
||||
// }
|
||||
actions = train.action.down;
|
||||
}else{
|
||||
// if(doorcode == "1"){
|
||||
// actions = train.action.top;
|
||||
// }
|
||||
//
|
||||
// if(doorcode == "2"){
|
||||
// actions = train.action.down;
|
||||
// }
|
||||
actions = train.action.down;
|
||||
}
|
||||
|
||||
for(let an=actions.length-1;an>=0;an--){
|
||||
actions[an].reset();
|
||||
actions[an].time = 0;
|
||||
actions[an].timeScale = 1;
|
||||
actions[an].play();
|
||||
}
|
||||
}
|
||||
|
||||
this.closetraindoor = function(train,doorcode,direct){
|
||||
let actions = null;
|
||||
if(direct == "top"){
|
||||
// if(doorcode == "1"){
|
||||
// actions = train.action.down;
|
||||
// }
|
||||
// if(doorcode == "2"){
|
||||
// actions = train.action.top;
|
||||
// }
|
||||
actions = train.action.down;
|
||||
}else{
|
||||
// if(doorcode == "1"){
|
||||
// actions = train.action.top;
|
||||
// }
|
||||
// if(doorcode == "2"){
|
||||
// actions = train.action.down;
|
||||
// }
|
||||
actions = train.action.down;
|
||||
}
|
||||
|
||||
for(let an=actions.length-1;an>=0;an--){
|
||||
actions[an].reset();
|
||||
actions[an].time = actions[an]._clip.duration;
|
||||
actions[an].timeScale = -1;
|
||||
actions[an].play();
|
||||
}
|
||||
scope.trainLeaveStation(direct);
|
||||
}
|
||||
this.trainLeaveStation = function(direction){
|
||||
if(direction == "top"){
|
||||
setTimeout(function(){
|
||||
let timer=setInterval(function(){
|
||||
scope.toptrain.position.x -= 0.5;
|
||||
},50);
|
||||
setTimeout(
|
||||
function(){
|
||||
scope.toptrain.status = 0;
|
||||
clearInterval(timer);
|
||||
},20000);
|
||||
},2000);
|
||||
|
||||
}
|
||||
if(direction == "down"){
|
||||
setTimeout(function(){
|
||||
let timer=setInterval(function(){
|
||||
scope.downtrain.position.x += 0.5;
|
||||
},50);
|
||||
setTimeout(
|
||||
function(){
|
||||
scope.downtrain.status = 0;
|
||||
clearInterval(timer);
|
||||
},20000);
|
||||
},2000);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function inittrainanimation(train,tclip,fclip,mixers){
|
||||
|
||||
for(let j=0;j<train.children.length;j++){
|
||||
if(train.children[j].name == "c1" || train.children[j].name == "c6"){
|
||||
for(let n=0,lenn = train.children[j].children.length;n<lenn;n++){
|
||||
if(train.children[j].children[n].name == "top"){
|
||||
train.children[j].children[n].animations = [];
|
||||
train.children[j].children[n].animations.push(tclip.clone());
|
||||
let mixer = new THREE.AnimationMixer( train.children[j].children[n] );
|
||||
mixers.push(mixer);
|
||||
let action = mixer.clipAction( train.children[j].children[n].animations[ 0 ] );
|
||||
action.setLoop(THREE.LoopOnce);
|
||||
action.clampWhenFinished = true;
|
||||
train.action.top.push(action);
|
||||
mixers.push(mixer);
|
||||
}
|
||||
if(train.children[j].children[n].name == "down"){
|
||||
train.children[j].children[n].animations = [];
|
||||
train.children[j].children[n].animations.push(tclip.clone());
|
||||
let mixer = new THREE.AnimationMixer( train.children[j].children[n] );
|
||||
mixers.push(mixer);
|
||||
let action = mixer.clipAction( train.children[j].children[n].animations[ 0 ] );
|
||||
action.setLoop(THREE.LoopOnce);
|
||||
action.clampWhenFinished = true;
|
||||
train.action.down.push(action);
|
||||
mixers.push(mixer);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
for(let n=0,lenn = train.children[j].children.length;n<lenn;n++){
|
||||
if(train.children[j].name != "xunlu6"){
|
||||
if(train.children[j].name == "c1" || train.children[j].name == "c6"){
|
||||
|
||||
for(let n=0,lenn = train.children[j].children.length;n<lenn;n++){
|
||||
if(train.children[j].children[n].name == "top"){
|
||||
|
||||
train.children[j].children[n].animations = [];
|
||||
train.children[j].children[n].animations.push(fclip.clone());
|
||||
train.children[j].children[n].animations.push(tclip.clone());
|
||||
let mixer = new THREE.AnimationMixer( train.children[j].children[n] );
|
||||
mixers.push(mixer);
|
||||
let action = mixer.clipAction( train.children[j].children[n].animations[ 0 ] );
|
||||
@ -97,8 +176,7 @@ export function TrainControl(){
|
||||
}
|
||||
if(train.children[j].children[n].name == "down"){
|
||||
train.children[j].children[n].animations = [];
|
||||
train.children[j].children[n].animations.push(fclip.clone());
|
||||
|
||||
train.children[j].children[n].animations.push(tclip.clone());
|
||||
let mixer = new THREE.AnimationMixer( train.children[j].children[n] );
|
||||
mixers.push(mixer);
|
||||
let action = mixer.clipAction( train.children[j].children[n].animations[ 0 ] );
|
||||
@ -107,8 +185,36 @@ export function TrainControl(){
|
||||
train.action.down.push(action);
|
||||
mixers.push(mixer);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
for(let n=0,lenn = train.children[j].children.length;n<lenn;n++){
|
||||
if(train.children[j].children[n].name == "top"){
|
||||
train.children[j].children[n].animations = [];
|
||||
train.children[j].children[n].animations.push(fclip.clone());
|
||||
let mixer = new THREE.AnimationMixer( train.children[j].children[n] );
|
||||
mixers.push(mixer);
|
||||
let action = mixer.clipAction( train.children[j].children[n].animations[ 0 ] );
|
||||
action.setLoop(THREE.LoopOnce);
|
||||
action.clampWhenFinished = true;
|
||||
train.action.top.push(action);
|
||||
mixers.push(mixer);
|
||||
}
|
||||
if(train.children[j].children[n].name == "down"){
|
||||
train.children[j].children[n].animations = [];
|
||||
train.children[j].children[n].animations.push(fclip.clone());
|
||||
|
||||
let mixer = new THREE.AnimationMixer( train.children[j].children[n] );
|
||||
mixers.push(mixer);
|
||||
let action = mixer.clipAction( train.children[j].children[n].animations[ 0 ] );
|
||||
action.setLoop(THREE.LoopOnce);
|
||||
action.clampWhenFinished = true;
|
||||
train.action.down.push(action);
|
||||
mixers.push(mixer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -69,7 +69,8 @@ function fbxpromise(mixers,model){
|
||||
var loader = new THREE.FBXLoader();
|
||||
loader.load( model.url, function ( object ) {
|
||||
let mixer = new THREE.AnimationMixer( object );
|
||||
|
||||
// console.log(model.code);
|
||||
// console.log(object.animations[0]);
|
||||
object.animacode = model.code;
|
||||
// model.mesh = object;
|
||||
|
||||
@ -87,7 +88,10 @@ function fbxpromise(mixers,model){
|
||||
}
|
||||
}
|
||||
}
|
||||
realtrain.add(object.getObjectByName("xunlu6"));
|
||||
model.mesh = realtrain;
|
||||
|
||||
// console.log(realtrain);
|
||||
model.animations = object.animations[0].tracks;
|
||||
}else{
|
||||
model.mesh = object;
|
||||
|
@ -71,7 +71,7 @@ export function PassflowConnect(jl3dpass,deviceaction,toptrain,downtrain,routegr
|
||||
|
||||
}else{
|
||||
opentraindoor(toptrain,data.body.doorCode,"top");
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -98,10 +98,6 @@ export function PassflowConnect(jl3dpass,deviceaction,toptrain,downtrain,routegr
|
||||
}
|
||||
toptrain.position.copy(toptrain.curve.getPointAt(data.body[i].offset));
|
||||
|
||||
// toptrain.position
|
||||
// if(){
|
||||
//
|
||||
// }
|
||||
}else{
|
||||
if(downtrain.nowcode == data.body[i].code){
|
||||
toptrain.position.x -= 1;
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 446 KiB After Width: | Height: | Size: 219 KiB |
4872
static/vrtest/WAICE_ZOULU.obj
Normal file
4872
static/vrtest/WAICE_ZOULU.obj
Normal file
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
BIN
static/vrtest/vrHuman.FBX
Normal file
BIN
static/vrtest/vrHuman.FBX
Normal file
Binary file not shown.
BIN
static/vrtest/vrTrain.2FBX
Normal file
BIN
static/vrtest/vrTrain.2FBX
Normal file
Binary file not shown.
Binary file not shown.
@ -669,6 +669,14 @@ let data = null;
|
||||
|
||||
let topic = null;
|
||||
let header = null;
|
||||
let station = null;
|
||||
let nowTopTrain = null;
|
||||
let nowDownTrain = null;
|
||||
let nowTakeTrain = {
|
||||
code:null,
|
||||
type:"",
|
||||
status:"trainStop"
|
||||
};
|
||||
function timedCount(){
|
||||
|
||||
onmessage = (e) => {
|
||||
@ -681,6 +689,37 @@ function timedCount(){
|
||||
|
||||
}
|
||||
|
||||
if(e.data.type == "station"){
|
||||
// console.log(e.data.station);
|
||||
station = e.data.station;
|
||||
|
||||
}
|
||||
|
||||
if(e.data.type == "takeStation"){
|
||||
nowTakeTrain = {
|
||||
code:null,
|
||||
type:"",
|
||||
status:"trainStop"
|
||||
};
|
||||
}
|
||||
console.log(e.data);
|
||||
if(e.data == "takeTopTrain"){
|
||||
console.log(nowTopTrain);
|
||||
nowTakeTrain = {
|
||||
code:nowTopTrain,
|
||||
type:"takeTopTrain",
|
||||
status:"trainStop"
|
||||
};
|
||||
}
|
||||
if(e.data == "takeDownTrain"){
|
||||
// console.log(nowDownTrain);
|
||||
nowTakeTrain = {
|
||||
code:nowDownTrain,
|
||||
type:"takeDownTrain",
|
||||
status:"trainStop"
|
||||
};
|
||||
}
|
||||
|
||||
if(e.data == "connect"){
|
||||
let teststomp = new StompClient(header,token);
|
||||
teststomp.subscribe(topic, callback, header);
|
||||
@ -712,37 +751,105 @@ function timedCount(){
|
||||
return;
|
||||
}
|
||||
//
|
||||
// if(data.type == 'TrainRun_3D'){
|
||||
// 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"){
|
||||
// postMessage(data.body[i]);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if(data.type == "Train_Hmi_3D"){
|
||||
// postMessage(data);
|
||||
// return;
|
||||
// }
|
||||
if(data.type == 'DeviceCtrl_3D'){
|
||||
// let nowTopTrain = null;
|
||||
// let nowDownTrain = null;
|
||||
if(data.type == 'TrainRun_3D'){
|
||||
// console.log(data);
|
||||
postMessage(data.body);
|
||||
if(nowTakeTrain.status == "trainStop"){
|
||||
|
||||
for(let i=0,leni = data.body.length;i<leni;i++){
|
||||
if(data.body[i].section == station.topsection){
|
||||
if(nowTopTrain != data.body[i].code){
|
||||
nowTopTrain = data.body[i].code;
|
||||
}
|
||||
data.body[i].type = "topTrain";
|
||||
postMessage(data.body[i]);
|
||||
}
|
||||
if(data.body[i].section == station.downsection){
|
||||
if(nowDownTrain != data.body[i].code){
|
||||
nowDownTrain = data.body[i].code;
|
||||
}
|
||||
data.body[i].type = "downTrain";
|
||||
postMessage(data.body[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if(data.type == 'BeAbout2Arrive_3D'){
|
||||
|
||||
if(data.body.groupNumber == nowTakeTrain.code){
|
||||
// nowTakeTrain.code = null;
|
||||
|
||||
let arriveStation = {
|
||||
stationcode:data.body.stationCode,
|
||||
type:nowTakeTrain.type,
|
||||
};
|
||||
postMessage(arriveStation);
|
||||
}
|
||||
}
|
||||
if(data.type == 'DeviceCtrl_3D'){
|
||||
|
||||
if(data.body.type == "TRAIN_DOOR"){
|
||||
|
||||
if(data.body.code == nowTopTrain){
|
||||
data.body.type = "topTrainDoor";
|
||||
|
||||
|
||||
|
||||
postMessage(data.body);
|
||||
}
|
||||
if(data.body.code == nowDownTrain){
|
||||
data.body.type = "downTrainDoor";
|
||||
postMessage(data.body);
|
||||
}
|
||||
if(nowTakeTrain.type === "takeTopTrain"){
|
||||
if(data.body.open == "0"){
|
||||
nowTakeTrain.status = "trainRun";
|
||||
}else{
|
||||
nowTakeTrain.status = "trainStop";
|
||||
}
|
||||
}
|
||||
if(nowTakeTrain.type === "takeDownTrain"){
|
||||
if(data.body.open == "0"){
|
||||
nowTakeTrain.status = "trainRun";
|
||||
}else{
|
||||
nowTakeTrain.status = "trainStop";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(data.body.type == "PSD"){
|
||||
if(data.body.code == station.toppsd){
|
||||
let psdData = {
|
||||
type:"topPsd",
|
||||
code:data.body.code,
|
||||
open:data.body.open
|
||||
}
|
||||
postMessage(psdData);
|
||||
}
|
||||
if(data.body.code == station.downpsd){
|
||||
let psdData = {
|
||||
type:"downPsd",
|
||||
code:data.body.code,
|
||||
open:data.body.open
|
||||
}
|
||||
postMessage(psdData);
|
||||
}
|
||||
}
|
||||
if(data.body.type == "SWITCH"){
|
||||
postMessage(data.body);
|
||||
}// console.log(data);
|
||||
|
||||
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