修改三维vr乘车报站,修改哈尔滨静态贴图
This commit is contained in:
parent
d5278b3127
commit
9290dc6b47
@ -6,16 +6,18 @@ const BASE_API = getBaseUrl();
|
|||||||
let uploadurl = null;
|
let uploadurl = null;
|
||||||
let asseturl = null;
|
let asseturl = null;
|
||||||
if(BASE_API == "https://test.joylink.club/jlcloud"){
|
if(BASE_API == "https://test.joylink.club/jlcloud"){
|
||||||
uploadurl = "https://test.joylink.club/jlfile";
|
uploadurl = "https://joylink.club/jlfile";
|
||||||
asseturl = "https://test.joylink.club/oss/joylink"
|
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"){
|
}else if(BASE_API == "https://joylink.club/jlcloud"){
|
||||||
uploadurl = "https://joylink.club/jlfile";
|
uploadurl = "https://joylink.club/jlfile";
|
||||||
asseturl = "https://joylink.club/oss/joylink"
|
asseturl = "https://joylink.club/oss/joylink";
|
||||||
}else{
|
}else{
|
||||||
// uploadurl = "https://test.joylink.club/jlfile";
|
// uploadurl = "https://test.joylink.club/jlfile";
|
||||||
// asseturl = "https://test.joylink.club/oss/joylink"
|
// asseturl = "https://test.joylink.club/oss/joylink"
|
||||||
uploadurl = "../static";
|
uploadurl = "../static";
|
||||||
asseturl = "../static"
|
asseturl = "../static";
|
||||||
}
|
}
|
||||||
const BASE_UPLOAD_API = uploadurl;
|
const BASE_UPLOAD_API = uploadurl;
|
||||||
export const BASE_ASSET_API = asseturl;
|
export const BASE_ASSET_API = asseturl;
|
||||||
|
@ -23,24 +23,43 @@ import { getToken } from '@/utils/auth';
|
|||||||
import { sendCommandNew } from '@/api/jmap/training';
|
import { sendCommandNew } from '@/api/jmap/training';
|
||||||
|
|
||||||
var clock = new THREE.Clock();
|
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 = {
|
let lableCodeMap = {
|
||||||
switch:[],
|
switch:[],
|
||||||
psd:[],
|
psd:[],
|
||||||
signal:[],
|
signal:[],
|
||||||
section:[]
|
section:[]
|
||||||
};
|
};
|
||||||
|
//故障列表
|
||||||
let faultList = [];
|
let faultList = [];
|
||||||
|
//车站信息列表
|
||||||
let stationList = [];
|
let stationList = [];
|
||||||
|
//列车对象
|
||||||
let trainControl = new TrainControl();
|
let trainControl = new TrainControl();
|
||||||
|
//人物所处地面状态
|
||||||
|
let positionStatus = "dm";
|
||||||
|
//列车地板
|
||||||
|
let floors = [];
|
||||||
|
//声音
|
||||||
|
window.speechSynthesis.getVoices()
|
||||||
|
let voices = speechSynthesis.getVoices();
|
||||||
|
|
||||||
export function Jl3dfaultdeviceVR(dom,group,token,skinCode) {
|
export function Jl3dfaultdeviceVR(dom,group,token,skinCode) {
|
||||||
|
|
||||||
var scope = this;
|
var scope = this;
|
||||||
@ -106,7 +125,7 @@ export function Jl3dfaultdeviceVR(dom,group,token,skinCode) {
|
|||||||
this.renderer.gammaOutput = true;
|
this.renderer.gammaOutput = true;
|
||||||
this.renderer.vr.enabled = true;
|
this.renderer.vr.enabled = true;
|
||||||
this.dom.appendChild(this.renderer.domElement);
|
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);
|
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();
|
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();
|
let loaderObj = new THREE.OBJLoader();
|
||||||
|
|
||||||
// load a resource
|
// load a resource
|
||||||
@ -155,7 +201,7 @@ export function Jl3dfaultdeviceVR(dom,group,token,skinCode) {
|
|||||||
|
|
||||||
|
|
||||||
// console.time('createZone()');
|
// console.time('createZone()');
|
||||||
console.log(object);
|
|
||||||
const zone = THREE.Pathfinding.createZone(object.children[0].geometry);
|
const zone = THREE.Pathfinding.createZone(object.children[0].geometry);
|
||||||
// console.timeEnd('createZone()');
|
// console.timeEnd('createZone()');
|
||||||
|
|
||||||
@ -169,6 +215,7 @@ export function Jl3dfaultdeviceVR(dom,group,token,skinCode) {
|
|||||||
// scene.add(navWireframe);
|
// scene.add(navWireframe);
|
||||||
|
|
||||||
navmesh = object;
|
navmesh = object;
|
||||||
|
|
||||||
// scene.add(navmesh);
|
// scene.add(navmesh);
|
||||||
// movegroup.add(navmesh);
|
// movegroup.add(navmesh);
|
||||||
// Set the player's navigation mesh group
|
// Set the player's navigation mesh group
|
||||||
@ -281,6 +328,131 @@ export function Jl3dfaultdeviceVR(dom,group,token,skinCode) {
|
|||||||
|
|
||||||
return;
|
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"){
|
if(event.data.type == "SWITCH"){
|
||||||
scope.updateaction(event.data);
|
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]);
|
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,6 +579,14 @@ export function Jl3dfaultdeviceVR(dom,group,token,skinCode) {
|
|||||||
scope.nowStationModel = scope.modelmanager.stationIn.mesh;
|
scope.nowStationModel = scope.modelmanager.stationIn.mesh;
|
||||||
scope.scene.add(scope.nowStationModel);
|
scope.scene.add(scope.nowStationModel);
|
||||||
}
|
}
|
||||||
|
trainControl.inittrain(scope.scene,scope.modelmanager.train.mesh,scope.modelmanager.train.animations,mixers);
|
||||||
|
floors.push(trainControl.toptrain.floor);
|
||||||
|
floors.push(trainControl.downtrain.floor);
|
||||||
|
floors.push(navmesh.children[0]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
let timer=setInterval(function(){
|
||||||
|
|
||||||
if(scope.stationtexture["stationlist"]){
|
if(scope.stationtexture["stationlist"]){
|
||||||
vrPlane.setStationPlane(stationList,scope.stationtexture);
|
vrPlane.setStationPlane(stationList,scope.stationtexture);
|
||||||
@ -416,13 +598,15 @@ export function Jl3dfaultdeviceVR(dom,group,token,skinCode) {
|
|||||||
}
|
}
|
||||||
scope.nowStationModel.getObjectByName("zhantaiming").material.map = scope.stationtexture[scope.nowstation.code];
|
scope.nowStationModel.getObjectByName("zhantaiming").material.map = scope.stationtexture[scope.nowstation.code];
|
||||||
scope.nowStationModel.getObjectByName("zhantaiming").material.map.needsUpdate = true;
|
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(scope.modelmanager.otherDevice.mesh);
|
||||||
scope.scene.add( vrPlane.group );
|
scope.scene.add( vrPlane.group );
|
||||||
vrwebworker.postMessage("connect");
|
vrwebworker.postMessage("connect");
|
||||||
animate();
|
animate();
|
||||||
|
clearInterval(timer);
|
||||||
|
}
|
||||||
|
},1000);
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -475,9 +659,15 @@ export function Jl3dfaultdeviceVR(dom,group,token,skinCode) {
|
|||||||
scope.nowStationModel = scope.modelmanager.stationIn.mesh;
|
scope.nowStationModel = scope.modelmanager.stationIn.mesh;
|
||||||
scope.scene.add(scope.nowStationModel);
|
scope.scene.add(scope.nowStationModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
scope.nowstation = stationList[i];
|
scope.nowstation = stationList[i];
|
||||||
|
let stationworket = {
|
||||||
|
type:'station',
|
||||||
|
station:scope.nowstation
|
||||||
|
};
|
||||||
|
vrwebworker.postMessage(stationworket);
|
||||||
vrPlane.updataStationMsg(scope.nowstation);
|
vrPlane.updataStationMsg(scope.nowstation);
|
||||||
scope.nowStationModel.getObjectByName("zhantaiming").material.map = scope.stationtexture[scope.nowstation.code];
|
scope.nowStationModel.getObjectByName("zhantaiming").material.map = scope.stationtexture[scope.nowstation.code];
|
||||||
scope.nowStationModel.getObjectByName("zhantaiming").material.map.needsUpdate = true;
|
scope.nowStationModel.getObjectByName("zhantaiming").material.map.needsUpdate = true;
|
||||||
@ -498,19 +688,16 @@ export function Jl3dfaultdeviceVR(dom,group,token,skinCode) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(object.name == "shebeijian"){
|
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"){
|
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"){
|
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"){
|
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"){
|
if(object.name == "anime"){
|
||||||
@ -630,10 +817,18 @@ export function Jl3dfaultdeviceVR(dom,group,token,skinCode) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
scope.nowstation = stationList[i];
|
scope.nowstation = stationList[i];
|
||||||
|
let stationworket = {
|
||||||
|
type:'station',
|
||||||
|
station:scope.nowstation
|
||||||
|
};
|
||||||
|
vrwebworker.postMessage(stationworket);
|
||||||
vrPlane.updataStationMsg(scope.nowstation);
|
vrPlane.updataStationMsg(scope.nowstation);
|
||||||
scope.nowStationModel.getObjectByName("zhantaiming").material.map = scope.stationtexture[scope.nowstation.code];
|
scope.nowStationModel.getObjectByName("zhantaiming").material.map = scope.stationtexture[scope.nowstation.code];
|
||||||
scope.nowStationModel.getObjectByName("zhantaiming").material.map.needsUpdate = true;
|
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;
|
i = leni;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -651,19 +846,16 @@ export function Jl3dfaultdeviceVR(dom,group,token,skinCode) {
|
|||||||
|
|
||||||
|
|
||||||
if(object.name == "shebeijian"){
|
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"){
|
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"){
|
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"){
|
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"){
|
if(object.name == "anime"){
|
||||||
@ -740,20 +932,59 @@ export function Jl3dfaultdeviceVR(dom,group,token,skinCode) {
|
|||||||
}else{
|
}else{
|
||||||
var intersections = getIntersections( controller );
|
var intersections = getIntersections( controller );
|
||||||
// console.log(intersections);
|
// console.log(intersections);
|
||||||
if ( intersections.length > 0 ) {
|
if ( intersections) {
|
||||||
// console.log(intersections);
|
// console.log(intersections);
|
||||||
var intersection = intersections[ 0 ];
|
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;
|
var object = intersection.object;
|
||||||
// object.matrix.premultiply( tempMatrix );
|
console.log(intersection.point);
|
||||||
// object.matrix.decompose( object.position, object.quaternion, object.scale );
|
|
||||||
// object.material.emissive.b = 1;
|
|
||||||
// controller.add( object );
|
|
||||||
|
|
||||||
// controller.userData.selected = object;
|
if(positionStatus == "dm"){
|
||||||
// console.log(object.matrixWorld.elements);
|
|
||||||
human.position.set( intersection.point.x, intersection.point.y+0.6, intersection.point.z );
|
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 ) {
|
function onControlModelStart( event ) {
|
||||||
var controller = event.target;
|
// var controller = event.target;
|
||||||
var intersections = getIntersections( controller );
|
// var intersections = getIntersections( controller );
|
||||||
if ( intersections.length > 0 ) {
|
// if ( intersections.length > 0 ) {
|
||||||
|
|
||||||
// for(){}
|
|
||||||
// console.log(intersections);
|
|
||||||
var intersection = intersections[ 0 ];
|
|
||||||
// console.log(intersection);
|
|
||||||
// tempMatrix.getInverse( controller.matrixWorld );
|
|
||||||
//
|
//
|
||||||
// var object = intersection.object;
|
// // for(){}
|
||||||
// object.matrix.premultiply( tempMatrix );
|
// // console.log(intersections);
|
||||||
// object.matrix.decompose( object.position, object.quaternion, object.scale );
|
// var intersection = intersections[ 0 ];
|
||||||
// object.material.emissive.b = 1;
|
// // console.log(intersection);
|
||||||
// controller.add( object );
|
// // 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 );
|
tempMatrix.identity().extractRotation( controller.matrixWorld );
|
||||||
raycastervr.ray.origin.setFromMatrixPosition( controller.matrixWorld );
|
raycastervr.ray.origin.setFromMatrixPosition( controller.matrixWorld );
|
||||||
raycastervr.ray.direction.set( 0, 0, - 1 ).applyMatrix4( tempMatrix );
|
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 loader = new THREE.TextureLoader();
|
||||||
var circle;
|
var circle;
|
||||||
@ -900,10 +1147,12 @@ export function Jl3dfaultdeviceVR(dom,group,token,skinCode) {
|
|||||||
|
|
||||||
var intersections = getIntersections( controller );
|
var intersections = getIntersections( controller );
|
||||||
|
|
||||||
if ( intersections.length > 0 ) {
|
if ( intersections) {
|
||||||
|
|
||||||
var intersection = intersections[ 0 ];
|
var intersection = intersections[ 0 ];
|
||||||
|
// console.log(intersection);
|
||||||
var object = intersection.object;
|
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) {
|
this.updateaction = function (data) {
|
||||||
if (data.type == "SWITCH") {
|
if (data.type == "SWITCH") {
|
||||||
console.log("pay");
|
|
||||||
if (data.normal == "0") {
|
if (data.normal == "0") {
|
||||||
console.log("play1");
|
|
||||||
scope.modelmanager.otherDevice.normalPosition = "0";
|
scope.modelmanager.otherDevice.normalPosition = "0";
|
||||||
scope.modelmanager.otherDevice.action.reset();
|
scope.modelmanager.otherDevice.action.reset();
|
||||||
scope.modelmanager.otherDevice.action.time = 0;
|
scope.modelmanager.otherDevice.action.time = 0;
|
||||||
scope.modelmanager.otherDevice.action.timeScale = 1;
|
scope.modelmanager.otherDevice.action.timeScale = 1;
|
||||||
scope.modelmanager.otherDevice.action.play();
|
scope.modelmanager.otherDevice.action.play();
|
||||||
} else if (data.normal == "1") {
|
} else if (data.normal == "1") {
|
||||||
console.log("play2");
|
|
||||||
scope.modelmanager.otherDevice.normalPosition = "1";
|
scope.modelmanager.otherDevice.normalPosition = "1";
|
||||||
scope.modelmanager.otherDevice.action.reset();
|
scope.modelmanager.otherDevice.action.reset();
|
||||||
scope.modelmanager.otherDevice.action.time = scope.modelmanager.otherDevice.action._clip.duration;
|
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] = [];
|
list[stationdata[i].name] = [];
|
||||||
for(let j=0,lenj = standdata.length;j<lenj;j++){
|
for(let j=0,lenj = standdata.length;j<lenj;j++){
|
||||||
if(standdata[j].stationCode == stationdata[i].code){
|
if(standdata[j].stationCode == stationdata[i].code){
|
||||||
|
standdata[j].index = i;
|
||||||
list[stationdata[i].name].push(standdata[j]);
|
list[stationdata[i].name].push(standdata[j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1005,6 +1252,7 @@ export function Jl3dfaultdeviceVR(dom,group,token,skinCode) {
|
|||||||
topsection:null,
|
topsection:null,
|
||||||
downsection:null,
|
downsection:null,
|
||||||
inside:null,
|
inside:null,
|
||||||
|
index:list[k][0].index,
|
||||||
};
|
};
|
||||||
if(list[k][0].position.y<list[k][1].position.y){
|
if(list[k][0].position.y<list[k][1].position.y){
|
||||||
stationobject.toppsd = list[k][0].name;
|
stationobject.toppsd = list[k][0].name;
|
||||||
@ -1016,16 +1264,20 @@ export function Jl3dfaultdeviceVR(dom,group,token,skinCode) {
|
|||||||
stationobject.toppsd = list[k][1].name;
|
stationobject.toppsd = list[k][1].name;
|
||||||
stationobject.downpsd = list[k][0].name;
|
stationobject.downpsd = list[k][0].name;
|
||||||
stationobject.topsection = list[k][1].standTrackCode;
|
stationobject.topsection = list[k][1].standTrackCode;
|
||||||
stationobject.downsection = list[k][0].standTrackCode;
|
stationobject.downsection = list[k][0].sstandTrackCode;
|
||||||
stationobject.inside = list[k][0].inside;
|
stationobject.inside = list[k][0].inside;
|
||||||
}
|
}
|
||||||
stationList.push(stationobject);
|
stationList.push(stationobject);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
console.log(stationList);
|
||||||
scope.nowstation = stationList[0];
|
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(){
|
function updateFaultList(){
|
||||||
vrPlane.updataFaultList(faultList);
|
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){
|
function setTextVr(intersects,plane){
|
||||||
console.log(intersects);
|
console.log(intersects);
|
||||||
console.log(plane);
|
console.log(plane);
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
var VRButton = {
|
var VRButton = {
|
||||||
|
|
||||||
createButton: function ( renderer, options ) {
|
createButton: function ( originPos,renderer, options ) {
|
||||||
|
|
||||||
if ( options && options.referenceSpaceType ) {
|
if ( options && options.referenceSpaceType ) {
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ var VRButton = {
|
|||||||
button.onclick = function () {
|
button.onclick = function () {
|
||||||
|
|
||||||
device.isPresenting ? device.exitPresent() : device.requestPresent( [ { source: renderer.domElement } ] );
|
device.isPresenting ? device.exitPresent() : device.requestPresent( [ { source: renderer.domElement } ] );
|
||||||
|
originPos.position.set( -12.21, 1.38+0.6, 3.49);
|
||||||
};
|
};
|
||||||
|
|
||||||
renderer.vr.setDevice( device );
|
renderer.vr.setDevice( device );
|
||||||
|
@ -3,63 +3,167 @@ export function TrainControl(){
|
|||||||
this.toptrain = null;
|
this.toptrain = null;
|
||||||
this.downtrain = null;
|
this.downtrain = null;
|
||||||
|
|
||||||
|
|
||||||
this.inittrain = function(scene,object,animations,mixers){
|
this.inittrain = function(scene,object,animations,mixers){
|
||||||
let ntracks1,ntracks2,tclip,fclip;
|
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);
|
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 = object.clone(true);
|
||||||
scope.toptrain.nowcode = null;
|
scope.toptrain.nowcode = null;
|
||||||
|
scope.toptrain.floor = scope.toptrain.getObjectByName("xunlu6");
|
||||||
|
scope.toptrain.floor.name = "topfloor";
|
||||||
|
scope.toptrain.status = 0;
|
||||||
scope.toptrain.action = {
|
scope.toptrain.action = {
|
||||||
top:[],
|
top:[],
|
||||||
down:[]
|
down:[]
|
||||||
};
|
};
|
||||||
let points1 = [];
|
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.toptrain.curve = new THREE.CatmullRomCurve3(points1);
|
||||||
|
|
||||||
scope.downtrain = object.clone(true);
|
scope.downtrain = object.clone(true);
|
||||||
scope.downtrain.nowcode = null;
|
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 = {
|
scope.downtrain.action = {
|
||||||
top:[],
|
top:[],
|
||||||
down:[]
|
down:[]
|
||||||
};
|
};
|
||||||
let points2 = [];
|
let points2 = [];
|
||||||
points2.push(new THREE.Vector3(-71,0.06,28.68));
|
points2.push(new THREE.Vector3(-38.73,0.06,8.8));
|
||||||
points2.push(new THREE.Vector3(60.73,0.06,28.68));
|
points2.push(new THREE.Vector3(41.33,0.06,8.8));
|
||||||
scope.downtrain.curve = new THREE.CatmullRomCurve3(points2);
|
scope.downtrain.curve = new THREE.CatmullRomCurve3(points2);
|
||||||
|
|
||||||
|
|
||||||
inittrainanimation(scope.toptrain,tclip,fclip,mixers);
|
inittrainanimation(scope.toptrain,tclip,fclip,mixers);
|
||||||
inittrainanimation(scope.downtrain,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.toptrain);
|
||||||
scene.add(scope.downtrain);
|
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){
|
function inittrainanimation(train,tclip,fclip,mixers){
|
||||||
|
|
||||||
for(let j=0;j<train.children.length;j++){
|
for(let j=0;j<train.children.length;j++){
|
||||||
|
if(train.children[j].name != "xunlu6"){
|
||||||
if(train.children[j].name == "c1" || train.children[j].name == "c6"){
|
if(train.children[j].name == "c1" || train.children[j].name == "c6"){
|
||||||
|
|
||||||
for(let n=0,lenn = train.children[j].children.length;n<lenn;n++){
|
for(let n=0,lenn = train.children[j].children.length;n<lenn;n++){
|
||||||
if(train.children[j].children[n].name == "top"){
|
if(train.children[j].children[n].name == "top"){
|
||||||
|
|
||||||
train.children[j].children[n].animations = [];
|
train.children[j].children[n].animations = [];
|
||||||
train.children[j].children[n].animations.push(tclip.clone());
|
train.children[j].children[n].animations.push(tclip.clone());
|
||||||
let mixer = new THREE.AnimationMixer( train.children[j].children[n] );
|
let mixer = new THREE.AnimationMixer( train.children[j].children[n] );
|
||||||
@ -110,5 +214,7 @@ export function TrainControl(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,8 @@ function fbxpromise(mixers,model){
|
|||||||
var loader = new THREE.FBXLoader();
|
var loader = new THREE.FBXLoader();
|
||||||
loader.load( model.url, function ( object ) {
|
loader.load( model.url, function ( object ) {
|
||||||
let mixer = new THREE.AnimationMixer( object );
|
let mixer = new THREE.AnimationMixer( object );
|
||||||
|
// console.log(model.code);
|
||||||
|
// console.log(object.animations[0]);
|
||||||
object.animacode = model.code;
|
object.animacode = model.code;
|
||||||
// model.mesh = object;
|
// model.mesh = object;
|
||||||
|
|
||||||
@ -87,7 +88,10 @@ function fbxpromise(mixers,model){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
realtrain.add(object.getObjectByName("xunlu6"));
|
||||||
model.mesh = realtrain;
|
model.mesh = realtrain;
|
||||||
|
|
||||||
|
// console.log(realtrain);
|
||||||
model.animations = object.animations[0].tracks;
|
model.animations = object.animations[0].tracks;
|
||||||
}else{
|
}else{
|
||||||
model.mesh = object;
|
model.mesh = object;
|
||||||
|
@ -71,7 +71,7 @@ export function PassflowConnect(jl3dpass,deviceaction,toptrain,downtrain,routegr
|
|||||||
|
|
||||||
}else{
|
}else{
|
||||||
opentraindoor(toptrain,data.body.doorCode,"top");
|
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.copy(toptrain.curve.getPointAt(data.body[i].offset));
|
||||||
|
|
||||||
// toptrain.position
|
|
||||||
// if(){
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
}else{
|
}else{
|
||||||
if(downtrain.nowcode == data.body[i].code){
|
if(downtrain.nowcode == data.body[i].code){
|
||||||
toptrain.position.x -= 1;
|
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 topic = null;
|
||||||
let header = null;
|
let header = null;
|
||||||
|
let station = null;
|
||||||
|
let nowTopTrain = null;
|
||||||
|
let nowDownTrain = null;
|
||||||
|
let nowTakeTrain = {
|
||||||
|
code:null,
|
||||||
|
type:"",
|
||||||
|
status:"trainStop"
|
||||||
|
};
|
||||||
function timedCount(){
|
function timedCount(){
|
||||||
|
|
||||||
onmessage = (e) => {
|
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"){
|
if(e.data == "connect"){
|
||||||
let teststomp = new StompClient(header,token);
|
let teststomp = new StompClient(header,token);
|
||||||
teststomp.subscribe(topic, callback, header);
|
teststomp.subscribe(topic, callback, header);
|
||||||
@ -712,37 +751,105 @@ function timedCount(){
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// if(data.type == 'TrainRun_3D'){
|
// let nowTopTrain = null;
|
||||||
// postMessage(data);
|
// let nowDownTrain = null;
|
||||||
// return;
|
if(data.type == 'TrainRun_3D'){
|
||||||
// }
|
|
||||||
//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'){
|
|
||||||
// console.log(data);
|
// console.log(data);
|
||||||
|
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);
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(data.type == 'Simulation_Reset'){
|
if(data.type == 'Simulation_Reset'){
|
||||||
postMessage(data);
|
postMessage(data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// if( data.body.length>300){
|
|
||||||
// // console.log(data);
|
|
||||||
// postMessage(data);
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user