修改大铁三维单体设备通信和显示逻辑

This commit is contained in:
sunzhenyu 2021-06-08 14:55:37 +08:00
parent e0b9861b78
commit 9a2e993b5d
6 changed files with 353 additions and 457 deletions

View File

@ -3,13 +3,19 @@ import { JL3D_LOCAL_STATIC } from '@/api/jlmap3d/assets3d.js';
//信号机贴图
export function Signallightload(lights) {
settexture(lights, "red", JL3D_LOCAL_STATIC+'/device/signal/1.jpg');
settexture(lights,"red",JL3D_LOCAL_STATIC+'/jl3d/railway/texture/1.jpg');
settexture(lights, "yellow", JL3D_LOCAL_STATIC+'/device/signal/2.jpg');
settexture(lights,"yellow",JL3D_LOCAL_STATIC+'/jl3d/railway/texture/2.jpg');
settexture( lights,"green",JL3D_LOCAL_STATIC+'/jl3d/railway/texture/3.jpg');
settexture( lights,"white",JL3D_LOCAL_STATIC+'/jl3d/railway/texture/4.jpg');
settexture( lights,"blue",JL3D_LOCAL_STATIC+'/jl3d/railway/texture/5.jpg');
settexture( lights,"black",JL3D_LOCAL_STATIC+'/jl3d/railway/texture/6.jpg');
settexture(lights, "green", JL3D_LOCAL_STATIC+'/device/signal/3.jpg');
settexture(lights, "black", JL3D_LOCAL_STATIC+'/device/signal/4.jpg');
}
//加载贴图

View File

@ -27,8 +27,6 @@ export function Jl3ddeviceNew(dom,group,token,skinCode) {
var scope = this;
let helpbox,textplane;
let daochamodel;
let psdtexturemap = [];
let psdVoiceStationList = [];
this.dom = dom;
this.nowcode = null;
@ -110,9 +108,6 @@ export function Jl3ddeviceNew(dom,group,token,skinCode) {
for(let i=0,leni=mapnetdata.switchList.length;i<leni;i++){
lableCodeMap[mapnetdata.switchList[i].name] = mapnetdata.switchList[i].code;
}
for(let i=0,leni=mapnetdata.psdList.length;i<leni;i++){
lableCodeMap[mapnetdata.psdList[i].standCode] = mapnetdata.psdList[i].code;
}
for(let i=0,leni=mapnetdata.signalList.length;i<leni;i++){
lableCodeMap[mapnetdata.signalList[i].name] = mapnetdata.signalList[i].code;
}
@ -121,20 +116,7 @@ export function Jl3ddeviceNew(dom,group,token,skinCode) {
}
let stationStandList = mapnetdata.stationStandList;
let psdList = mapnetdata.psdList;
for(let i=0,leni=stationStandList.length;i<leni;i++){
for(let j=0,lenj=psdList.length;j<lenj;j++){
if(stationStandList[i].code == psdList[j].standCode){
psdVoiceStationList[psdList[j].code] = {
stationCode:stationStandList[i].stationCode,
right:stationStandList[i].right,
finlStationName:"",
nowStationName:""
}
j = lenj;
}
}
}
let stationList = [];
for(let i=0,leni=mapnetdata.stationList.length;i<leni;i++){
@ -144,32 +126,22 @@ export function Jl3ddeviceNew(dom,group,token,skinCode) {
}
}
// console.log(mapnetdata.stationList);
for(let k in psdVoiceStationList){
for(let i=0,leni=stationList.length;i<leni;i++){
// console.log("---------------");
// console.log("---------------");
if(psdVoiceStationList[k].stationCode == stationList[i].code){
psdVoiceStationList[k].nowStationName = stationList[i].name;
if(psdVoiceStationList[k].right){
psdVoiceStationList[k].finlStationName = stationList[leni-1].name;
}else{
psdVoiceStationList[k].finlStationName = stationList[0].name;
}
i = leni;
}
}
}
});
document.addEventListener( "mousedown", onselect, false );
let teststomp = new StompClient();
// let topic = '/user/topic/simulation/assistant/'+group;
let topic = "/queue/simulation/"+group+"/srDeviceState";//'/user/queue/simulation/jl3d/'+group
let signalTopic = "/queue/simulation/"+group+"/srSignal/";//'/user/queue/simulation/jl3d/'+group
let switchTopic = "/queue/simulation/"+group+"/srSwitch/";//'/user/queue/simulation/jl3d/'+group
let psdTopic = "/queue/simulation/"+group+"/srPsd/";//'/user/queue/simulation/jl3d/'+group
let nowTopic = "";
let oldTopic = "";
let header = {'X-Token': token};
try {
teststomp.subscribe(topic, callback, header);
// teststomp.subscribe(topic, callback, header);
} catch (error) {
console.error('websocket订阅失败');
}
@ -178,39 +150,24 @@ export function Jl3ddeviceNew(dom,group,token,skinCode) {
let data = JSON.parse(Response.body);
console.log(data);
if(data.srSignal){
if(data.srSignal[0] == scope.nowcode){
scope.updateSignal(data.srSignal[1]);
}
}
if(data.srSwitch){
if(data.srSwitch[0] == scope.nowcode){
scope.updateSwitch(data.srSwitch[1]);
}
}
if(data.type == "DeviceCtrl_3D"){
if(data.body.code == scope.nowcode){
scope.updateaction(data.body);
}
}
if(data.type == "Device_Fault_Set_3D"){
let realDeviceCode = lableCodeMap[data.body.code];
if(realDeviceCode == scope.nowcode){
scope.deviceFaultSet(data.body);
}
}
if(data.type == "Device_Fault_Over_3D"){
let realDeviceCode = lableCodeMap[data.body.code];
if(realDeviceCode == scope.nowcode){
scope.deviceFaultOver(data.body);
}
}
if(data.type == "Simulation_Reset"){
scope.deviceReset();
}
if(data.type == 'Simulation_Over'){
let projectDevice=getSessionStorage('projectDevice');
if(getSessionStorage('project').startsWith('heb')&&projectDevice){
store.dispatch('LogOut').then(() => {
location.reload();
});
}
}
}
let changeelement = document.getElementById('jl3d');
window.addEventListener('resize', () =>
@ -237,23 +194,12 @@ export function Jl3ddeviceNew(dom,group,token,skinCode) {
getPublish3dMapDetail(skinCode).then(netdata => {
let netDataAssets = JSON.parse(netdata.data.assets);
if(netDataAssets.stationTextureList[0].urls.length > 1){
setpsdstationmap(JSON.parse(netdata.data.stands));
Standtextureload(scope,netDataAssets.stationTextureList[0]);
}
scope.modelmanager.loadpromise(netDataAssets.deviceAssetList, scope.mixers).then(function (data) {
//综合演练情况下当模型加载后显示
psdModelShow();
moveanima.initlistnew(scope.modelmanager.switchmodel.mesh);
daochamodel = scope.modelmanager.switchmodel.mesh.getObjectByName("DAOCHA");
if(scope.stationtexture["devicelist"]){
scope.modelmanager.standmodel.mesh.getObjectByName("zhantailiebiao").material.map =scope.stationtexture["devicelist"];
scope.modelmanager.standmodel.mesh.getObjectByName("zhantailiebiao").material.map.needsUpdate = true;
}
if(scope.stationtexture["pingbimen"]){
scope.modelmanager.standmodel.mesh.getObjectByName("pingbimen1").material.map =scope.stationtexture["pingbimen"];
scope.modelmanager.standmodel.mesh.getObjectByName("pingbimen1").material.map.needsUpdate = true;
}
})
let checkobject = setInterval(function(){
@ -267,15 +213,6 @@ export function Jl3ddeviceNew(dom,group,token,skinCode) {
});
//初始化屏蔽门贴图
function setpsdstationmap(stationlist){
for(let i=0,leni=stationlist.length;i<leni;i++){
psdtexturemap[stationlist[i].stands[0].code] = stationlist[i].code;
psdtexturemap[stationlist[i].stands[1].code] = stationlist[i].code;
psdtexturemap[stationlist[i].stands[0].name] = stationlist[i].code;
psdtexturemap[stationlist[i].stands[1].name] = stationlist[i].code;
}
}
let stopTime = 0;
//循环渲染函数
function animate() {
@ -342,20 +279,20 @@ export function Jl3ddeviceNew(dom,group,token,skinCode) {
updatemenulist();
}
if (data._type == "Signal") {
scope.modelmanager.signalmodel.code = data.code;
scope.showmodel = scope.modelmanager.signalmodel.mesh;
if(data.type == "ARRIVAL"){
scope.showmodel = scope.modelmanager.signal5.mesh;
}else if(data.type == "EXIT"){
scope.showmodel = scope.modelmanager.signal32.mesh;
}else if(data.type == "PASSING"){
scope.showmodel = scope.modelmanager.signal3.mesh;
}else if(data.type == "SHUNTING"){
scope.showmodel = scope.modelmanager.signal2.mesh;
}
scope.showmodel.code = data.code;
scope.scene.add(scope.showmodel);
}
if (data._type == "Psd") {
scope.modelmanager.standmodel.code = data.code;
scope.showmodel = scope.modelmanager.standmodel.mesh;
scope.scene.add(scope.showmodel);
if(scope.stationtexture[psdtexturemap[data.standCode]]){
scope.modelmanager.standmodel.mesh.getObjectByName("zhantaiming").material.map =scope.stationtexture[psdtexturemap[data.standCode]];
scope.modelmanager.standmodel.mesh.getObjectByName("zhantaiming").material.map.needsUpdate = true;
}
}
if (data._type == "Section") {
scope.showmodel = scope.modelmanager.sectionmodel.mesh;
@ -401,29 +338,18 @@ export function Jl3ddeviceNew(dom,group,token,skinCode) {
}
if (data._type == "Signal") {
scope.showmodel = scope.modelmanager.signalmodel.mesh;
scope.scene.add(scope.showmodel);
}
if (data._type == "Psd") {
scope.showmodel = scope.modelmanager.standmodel.mesh;
scope.scene.add(scope.showmodel);
if(data.standCode == undefined){
if(psdtexturemap[data.code]){
scope.modelmanager.standmodel.mesh.getObjectByName("zhantaiming").material.map =scope.stationtexture[psdtexturemap[data.code]];
scope.modelmanager.standmodel.mesh.getObjectByName("zhantaiming").material.map.needsUpdate = true;
}else{
scope.modelmanager.standmodel.mesh.getObjectByName("zhantaiming").material.map =scope.stationtexture["Station18398"];
scope.modelmanager.standmodel.mesh.getObjectByName("zhantaiming").material.map.needsUpdate = true;
}
console.log(data);
if(data.type == "ARRIVAL"){
scope.showmodel = scope.modelmanager.signal5.mesh;
}else if(data.type == "EXIT"){
scope.showmodel = scope.modelmanager.signal32.mesh;
}else if(data.type == "PASSING"){
scope.showmodel = scope.modelmanager.signal3.mesh;
}else if(data.type == "SHUNTING"){
scope.showmodel = scope.modelmanager.signal2.mesh;
}
if(scope.stationtexture[psdtexturemap[data.standCode]]){
scope.modelmanager.standmodel.mesh.getObjectByName("zhantaiming").material.map =scope.stationtexture[psdtexturemap[data.standCode]];
scope.modelmanager.standmodel.mesh.getObjectByName("zhantaiming").material.map.needsUpdate = true;
}
scope.scene.add(scope.showmodel);
}
@ -436,6 +362,22 @@ export function Jl3ddeviceNew(dom,group,token,skinCode) {
if (data._type == "Switch") {
nowTopic = switchTopic + data.code;
}
if (data._type == "Signal") {
nowTopic = signalTopic + data.code;
}
if (data._type == "Psd") {
nowTopic = psdTopic + data.code;
}
if(nowTopic != oldTopic){
teststomp.unsubscribe(oldTopic);
oldTopic = nowTopic;
teststomp.subscribe(nowTopic, callback, header);
}
}
this.changeStaticSwitch = function(mode){
@ -632,6 +574,205 @@ export function Jl3ddeviceNew(dom,group,token,skinCode) {
scope.animationmodel = null;
}
//根据数据切换设备样式
this.updateSignal = function(lightType){
if(scope.showmodel.deviceType == "ARRIVAL"){
if(lightType == '0'){
scope.showmodel.getObjectByName("01").material.map = scope.signallights["black"];
scope.showmodel.getObjectByName("01").material.map.needsUpdate = true;
scope.showmodel.getObjectByName("02").material.map = scope.signallights["black"];
scope.showmodel.getObjectByName("02").material.map.needsUpdate = true;
scope.showmodel.getObjectByName("03").material.map = scope.signallights["black"];
scope.showmodel.getObjectByName("03").material.map.needsUpdate = true;
scope.showmodel.getObjectByName("04").material.map = scope.signallights["black"];
scope.showmodel.getObjectByName("04").material.map.needsUpdate = true;
scope.showmodel.getObjectByName("05").material.map = scope.signallights["black"];
scope.showmodel.getObjectByName("05").material.map.needsUpdate = true;
}
if(lightType == '3'){
scope.showmodel.getObjectByName("01").material.map = scope.signallights["yellow"];
scope.showmodel.getObjectByName("01").material.map.needsUpdate = true;
scope.showmodel.getObjectByName("02").material.map = scope.signallights["black"];
scope.showmodel.getObjectByName("02").material.map.needsUpdate = true;
scope.showmodel.getObjectByName("03").material.map = scope.signallights["black"];
scope.showmodel.getObjectByName("03").material.map.needsUpdate = true;
scope.showmodel.getObjectByName("04").material.map = scope.signallights["black"];
scope.showmodel.getObjectByName("04").material.map.needsUpdate = true;
scope.showmodel.getObjectByName("05").material.map = scope.signallights["black"];
scope.showmodel.getObjectByName("05").material.map.needsUpdate = true;
}
if(lightType == '7'){
scope.showmodel.getObjectByName("01").material.map = scope.signallights["yellow"];
scope.showmodel.getObjectByName("01").material.map.needsUpdate = true;
scope.showmodel.getObjectByName("02").material.map = scope.signallights["black"];
scope.showmodel.getObjectByName("02").material.map.needsUpdate = true;
scope.showmodel.getObjectByName("03").material.map = scope.signallights["black"];
scope.showmodel.getObjectByName("03").material.map.needsUpdate = true;
scope.showmodel.getObjectByName("04").material.map = scope.signallights["yellow"];
scope.showmodel.getObjectByName("04").material.map.needsUpdate = true;
scope.showmodel.getObjectByName("05").material.map = scope.signallights["black"];
scope.showmodel.getObjectByName("05").material.map.needsUpdate = true;
}
if(lightType == '1'){
scope.showmodel.getObjectByName("01").material.map = scope.signallights["black"];
scope.showmodel.getObjectByName("01").material.map.needsUpdate = true;
scope.showmodel.getObjectByName("02").material.map = scope.signallights["black"];
scope.showmodel.getObjectByName("02").material.map.needsUpdate = true;
scope.showmodel.getObjectByName("03").material.map = scope.signallights["red"];
scope.showmodel.getObjectByName("03").material.map.needsUpdate = true;
scope.showmodel.getObjectByName("04").material.map = scope.signallights["black"];
scope.showmodel.getObjectByName("04").material.map.needsUpdate = true;
scope.showmodel.getObjectByName("05").material.map = scope.signallights["black"];
scope.showmodel.getObjectByName("05").material.map.needsUpdate = true;
}
if(lightType == '9'){
scope.showmodel.getObjectByName("01").material.map = scope.signallights["black"];
scope.showmodel.getObjectByName("01").material.map.needsUpdate = true;
scope.showmodel.getObjectByName("02").material.map = scope.signallights["black"];
scope.showmodel.getObjectByName("02").material.map.needsUpdate = true;
scope.showmodel.getObjectByName("03").material.map = scope.signallights["red"];
scope.showmodel.getObjectByName("03").material.map.needsUpdate = true;
scope.showmodel.getObjectByName("04").material.map = scope.signallights["black"];
scope.showmodel.getObjectByName("04").material.map.needsUpdate = true;
scope.showmodel.getObjectByName("05").material.map = scope.signallights["white"];
scope.showmodel.getObjectByName("05").material.map.needsUpdate = true;
}
if(lightType == '6'){
scope.showmodel.getObjectByName("01").material.map = scope.signallights["black"];
scope.showmodel.getObjectByName("01").material.map.needsUpdate = true;
scope.showmodel.getObjectByName("02").material.map = scope.signallights["green"];
scope.showmodel.getObjectByName("02").material.map.needsUpdate = true;
scope.showmodel.getObjectByName("03").material.map = scope.signallights["black"];
scope.showmodel.getObjectByName("03").material.map.needsUpdate = true;
scope.showmodel.getObjectByName("04").material.map = scope.signallights["yellow"];
scope.showmodel.getObjectByName("04").material.map.needsUpdate = true;
scope.showmodel.getObjectByName("05").material.map = scope.signallights["black"];
scope.showmodel.getObjectByName("05").material.map.needsUpdate = true;
}
}else if(scope.showmodel.deviceType == "EXIT"){
if(lightType == '0'){
scope.showmodel.getObjectByName("01").material.map = scope.signallights["black"];
scope.showmodel.getObjectByName("01").material.map.needsUpdate = true;
scope.showmodel.getObjectByName("02").material.map = scope.signallights["black"];
scope.showmodel.getObjectByName("02").material.map.needsUpdate = true;
scope.showmodel.getObjectByName("03").material.map = scope.signallights["black"];
scope.showmodel.getObjectByName("03").material.map.needsUpdate = true;
scope.showmodel.getObjectByName("04").material.map = scope.signallights["black"];
scope.showmodel.getObjectByName("04").material.map.needsUpdate = true;
scope.showmodel.getObjectByName("05").material.map = scope.signallights["black"];
scope.showmodel.getObjectByName("05").material.map.needsUpdate = true;
}
if(lightType == '1'){
scope.showmodel.getObjectByName("01").material.map = scope.signallights["black"];
scope.showmodel.getObjectByName("01").material.map.needsUpdate = true;
scope.showmodel.getObjectByName("02").material.map = scope.signallights["black"];
scope.showmodel.getObjectByName("02").material.map.needsUpdate = true;
scope.showmodel.getObjectByName("03").material.map = scope.signallights["black"];
scope.showmodel.getObjectByName("03").material.map.needsUpdate = true;
scope.showmodel.getObjectByName("04").material.map = scope.signallights["black"];
scope.showmodel.getObjectByName("04").material.map.needsUpdate = true;
scope.showmodel.getObjectByName("05").material.map = scope.signallights["red"];
scope.showmodel.getObjectByName("05").material.map.needsUpdate = true;
}
if(lightType == '2'){
scope.showmodel.getObjectByName("01").material.map = scope.signallights["green"];
scope.showmodel.getObjectByName("01").material.map.needsUpdate = true;
scope.showmodel.getObjectByName("02").material.map = scope.signallights["black"];
scope.showmodel.getObjectByName("02").material.map.needsUpdate = true;
scope.showmodel.getObjectByName("03").material.map = scope.signallights["black"];
scope.showmodel.getObjectByName("03").material.map.needsUpdate = true;
scope.showmodel.getObjectByName("04").material.map = scope.signallights["black"];
scope.showmodel.getObjectByName("04").material.map.needsUpdate = true;
scope.showmodel.getObjectByName("05").material.map = scope.signallights["black"];
scope.showmodel.getObjectByName("05").material.map.needsUpdate = true;
}
if(lightType == '3'){
scope.showmodel.getObjectByName("01").material.map = scope.signallights["black"];
scope.showmodel.getObjectByName("01").material.map.needsUpdate = true;
scope.showmodel.getObjectByName("02").material.map = scope.signallights["black"];
scope.showmodel.getObjectByName("02").material.map.needsUpdate = true;
scope.showmodel.getObjectByName("03").material.map = scope.signallights["yellow"];
scope.showmodel.getObjectByName("03").material.map.needsUpdate = true;
scope.showmodel.getObjectByName("04").material.map = scope.signallights["black"];
scope.showmodel.getObjectByName("04").material.map.needsUpdate = true;
scope.showmodel.getObjectByName("05").material.map = scope.signallights["black"];
scope.showmodel.getObjectByName("05").material.map.needsUpdate = true;
}
}else if(scope.showmodel.deviceType == "PASSING"){
if(lightType == '0'){
scope.showmodel.getObjectByName("01").material.map = scope.signallights["black"];
scope.showmodel.getObjectByName("01").material.map.needsUpdate = true;
scope.showmodel.getObjectByName("02").material.map = scope.signallights["black"];
scope.showmodel.getObjectByName("02").material.map.needsUpdate = true;
scope.showmodel.getObjectByName("03").material.map = scope.signallights["black"];
scope.showmodel.getObjectByName("03").material.map.needsUpdate = true;
}
if(lightType == '1'){
scope.showmodel.getObjectByName("01").material.map = scope.signallights["black"];
scope.showmodel.getObjectByName("01").material.map.needsUpdate = true;
scope.showmodel.getObjectByName("02").material.map = scope.signallights["black"];
scope.showmodel.getObjectByName("02").material.map.needsUpdate = true;
scope.showmodel.getObjectByName("03").material.map = scope.signallights["red"];
scope.showmodel.getObjectByName("03").material.map.needsUpdate = true;
}
if(lightType == '2'){
scope.showmodel.getObjectByName("01").material.map = scope.signallights["black"];
scope.showmodel.getObjectByName("01").material.map.needsUpdate = true;
scope.showmodel.getObjectByName("02").material.map = scope.signallights["green"];
scope.showmodel.getObjectByName("02").material.map.needsUpdate = true;
scope.showmodel.getObjectByName("03").material.map = scope.signallights["black"];
scope.showmodel.getObjectByName("03").material.map.needsUpdate = true;
}
if(lightType == '3'){
scope.showmodel.getObjectByName("01").material.map = scope.signallights["yellow"];
scope.showmodel.getObjectByName("01").material.map.needsUpdate = true;
scope.showmodel.getObjectByName("02").material.map = scope.signallights["black"];
scope.showmodel.getObjectByName("02").material.map.needsUpdate = true;
scope.showmodel.getObjectByName("03").material.map = scope.signallights["black"];
scope.showmodel.getObjectByName("03").material.map.needsUpdate = true;
}
}else if(scope.showmodel.deviceType == "SHUNTING"){
if(lightType == '0'){
scope.showmodel.getObjectByName("01").material.map = scope.signallights["black"];
scope.showmodel.getObjectByName("01").material.map.needsUpdate = true;
scope.showmodel.getObjectByName("02").material.map = scope.signallights["black"];
scope.showmodel.getObjectByName("02").material.map.needsUpdate = true;
}
if(lightType == '10'){
scope.showmodel.getObjectByName("01").material.map = scope.signallights["black"];
scope.showmodel.getObjectByName("01").material.map.needsUpdate = true;
scope.showmodel.getObjectByName("02").material.map = scope.signallights["blue"];
scope.showmodel.getObjectByName("02").material.map.needsUpdate = true;
}
if(lightType == '11'){
scope.showmodel.getObjectByName("01").material.map = scope.signallights["white"];
scope.showmodel.getObjectByName("01").material.map.needsUpdate = true;
scope.showmodel.getObjectByName("02").material.map = scope.signallights["black"];
scope.showmodel.getObjectByName("02").material.map.needsUpdate = true;
}
}
};
this.updateSwitch = function(normal){
if (normal == "1") {
scope.modelmanager.switchmodel.normalPosition = "0";
scope.modelmanager.switchmodel.action.reset();
scope.modelmanager.switchmodel.action.time = 0;
scope.modelmanager.switchmodel.action.timeScale = 1;
scope.modelmanager.switchmodel.action.play();
} else if (normal == "2") {
scope.modelmanager.switchmodel.normalPosition = "1";
scope.modelmanager.switchmodel.action.reset();
scope.modelmanager.switchmodel.action.time = scope.modelmanager.switchmodel.action._clip.duration;
scope.modelmanager.switchmodel.action.timeScale = -1;
scope.modelmanager.switchmodel.action.play();
}
};
this.updateaction = function (data) {
if (data.type == "SWITCH") {
if (data.normal == "0") {
@ -675,78 +816,9 @@ export function Jl3ddeviceNew(dom,group,token,skinCode) {
}
}
if (data.type == "PSD" || data.type == "STAND") {
if (data.code == scope.nowcode) {
if (data.open == "1" ) {
scope.modelmanager.standmodel.screenDoorOpenStatus = "0";
scope.modelmanager.standmodel.action.reset();
scope.modelmanager.standmodel.action.time = 0;
scope.modelmanager.standmodel.action.timeScale = 1;
scope.modelmanager.standmodel.action.play();
localVoicePlay("开往"+psdVoiceStationList[data.code].finlStationName+"方向的列车进站了!");
}
if (data.open == "0" ) {
scope.modelmanager.standmodel.screenDoorOpenStatus = "1";
scope.modelmanager.standmodel.action.reset();
scope.modelmanager.standmodel.action.time = scope.modelmanager.standmodel.action._clip.duration;
scope.modelmanager.standmodel.action.timeScale = -1;
scope.modelmanager.standmodel.action.play();
}
}
}
// scope.showmodel.
}
this.deviceFaultSet = function (data) {
if (data.type == "SIGNAL") {//从上往下红绿黄
scope.modelmanager.signalmodel.mesh.getObjectByName("d3d001").material.map = scope.signallights["black"];
scope.modelmanager.signalmodel.mesh.getObjectByName("d3d001").material.map.needsUpdate = true;
scope.modelmanager.signalmodel.mesh.getObjectByName("d3d002").material.map = scope.signallights["black"];
scope.modelmanager.signalmodel.mesh.getObjectByName("d3d002").material.map.needsUpdate = true;
scope.modelmanager.signalmodel.mesh.getObjectByName("d3d003").material.map = scope.signallights["black"];
scope.modelmanager.signalmodel.mesh.getObjectByName("d3d003").material.map.needsUpdate = true;
}
if (data.type == "PSD" || data.type == "STAND") {
scope.modelmanager.standmodel.screenDoorOpenStatus = "0";
scope.modelmanager.standmodel.action.reset();
scope.modelmanager.standmodel.action.time = 0;
scope.modelmanager.standmodel.action.timeScale = 1;
scope.modelmanager.standmodel.action.play();
}
}
this.deviceFaultOver = function (data) {
// if (data.type == "SIGNAL") {//从上往下红绿黄
// scope.modelmanager.signalmodel.mesh.children[0].material.map = scope.signallights["red"];
// scope.modelmanager.signalmodel.mesh.children[0].material.map.needsUpdate = true;
// scope.modelmanager.signalmodel.mesh.children[2].material.map = scope.signallights["yellow"];
// scope.modelmanager.signalmodel.mesh.children[2].material.map.needsUpdate = true;
// scope.modelmanager.signalmodel.mesh.children[1].material.map = scope.signallights["green"];
// scope.modelmanager.signalmodel.mesh.children[1].material.map.needsUpdate = true;
// }
if (data.type == "PSD" || data.type == "STAND") {
scope.modelmanager.standmodel.screenDoorOpenStatus = "1";
scope.modelmanager.standmodel.action.reset();
scope.modelmanager.standmodel.action.time = scope.modelmanager.standmodel.action._clip.duration;
scope.modelmanager.standmodel.action.timeScale = -1;
scope.modelmanager.standmodel.action.play();
}
}
this.deviceReset = function () {
scope.modelmanager.standmodel.screenDoorOpenStatus = "1";
scope.modelmanager.standmodel.action.reset();
scope.modelmanager.standmodel.action.time = scope.modelmanager.standmodel.action._clip.duration;
scope.modelmanager.standmodel.action.timeScale = -1;
scope.modelmanager.standmodel.action.play();
}
this.updateselect = function(updata){
if(helpbox){
@ -796,68 +868,10 @@ export function Jl3ddeviceNew(dom,group,token,skinCode) {
}
if (data._type == "Signal") {
console.log(data);
if(data.logicLight == 0){
if(data.redOpen == 1){
scope.modelmanager.signalmodel.mesh.getObjectByName("d3d001").material.map = scope.signallights["red"];
scope.modelmanager.signalmodel.mesh.getObjectByName("d3d001").material.map.needsUpdate = true;
}else{
scope.modelmanager.signalmodel.mesh.getObjectByName("d3d001").material.map = scope.signallights["black"];
scope.modelmanager.signalmodel.mesh.getObjectByName("d3d001").material.map.needsUpdate = true;
}
if(data.yellowOpen == 1){
scope.modelmanager.signalmodel.mesh.getObjectByName("d3d002").material.map = scope.signallights["yellow"];
scope.modelmanager.signalmodel.mesh.getObjectByName("d3d002").material.map.needsUpdate = true;
}else{
scope.modelmanager.signalmodel.mesh.getObjectByName("d3d002").material.map = scope.signallights["black"];
scope.modelmanager.signalmodel.mesh.getObjectByName("d3d002").material.map.needsUpdate = true;
}
if(data.greenOpen == 1){
scope.modelmanager.signalmodel.mesh.getObjectByName("d3d003").material.map = scope.signallights["green"];
scope.modelmanager.signalmodel.mesh.getObjectByName("d3d003").material.map.needsUpdate = true;
}else{
scope.modelmanager.signalmodel.mesh.getObjectByName("d3d003").material.map = scope.signallights["black"];
scope.modelmanager.signalmodel.mesh.getObjectByName("d3d003").material.map.needsUpdate = true;
}
}else{
scope.modelmanager.signalmodel.mesh.getObjectByName("d3d001").material.map = scope.signallights["black"];
scope.modelmanager.signalmodel.mesh.getObjectByName("d3d001").material.map.needsUpdate = true;
scope.modelmanager.signalmodel.mesh.getObjectByName("d3d002").material.map = scope.signallights["black"];
scope.modelmanager.signalmodel.mesh.getObjectByName("d3d002").material.map.needsUpdate = true;
scope.modelmanager.signalmodel.mesh.getObjectByName("d3d003").material.map = scope.signallights["black"];
scope.modelmanager.signalmodel.mesh.getObjectByName("d3d003").material.map.needsUpdate = true;
}
}
if (data._type == "Psd") {
if (data.screenDoorOpenStatus == "0") {
scope.modelmanager.standmodel.screenDoorOpenStatus = "0";
scope.modelmanager.standmodel.action.reset();
scope.modelmanager.standmodel.action.time = scope.modelmanager.standmodel.action._clip.duration;
scope.modelmanager.standmodel.action.timeScale = 1;
scope.modelmanager.standmodel.action.play();
}
if (data.screenDoorOpenStatus == "1") {
scope.modelmanager.standmodel.screenDoorOpenStatus = "1";
scope.modelmanager.standmodel.action.reset();
scope.modelmanager.standmodel.action.time = 0;
scope.modelmanager.standmodel.action.timeScale = -1;
scope.modelmanager.standmodel.action.play();
}
scope.camera.position.x = 0;
scope.camera.position.y = 8.3;
scope.camera.position.z = 12;
scope.controls.target = new THREE.Vector3(0,8.3,0);
scope.controls.update();
}else{
scope.camera.position.x = 0;
scope.camera.position.y = 20;
scope.camera.position.z = 30;
scope.controls.target = new THREE.Vector3(0,10,0);
scope.controls.update();
}
}

View File

@ -18,18 +18,34 @@ export function ModelManager(){
action:null
};
this.signalmodel = {
code:"signal",
this.signal5 = {
code:"s1",
lightType:"01",
status:"01",
switchLocateType:"01",
mesh:null,
action:null
};
this.standmodel = {
code:"stand",
screenDoorOpenStatus:"01",
this.signal32 = {
code:"s2",
lightType:"01",
status:"01",
mesh:null,
action:null
};
this.signal3 = {
code:"s3",
lightType:"01",
status:"01",
mesh:null,
action:null
};
this.signal2 = {
code:"s4",
lightType:"01",
status:"01",
mesh:null,
action:null
};
@ -41,12 +57,6 @@ export function ModelManager(){
action:null
};
this.roommodel = {
code:"room",
sectionstatus:"01",
mesh:null,
action:null
};
this.loadpromise = function (data,mixers){
let initlist = [];
@ -55,27 +65,61 @@ export function ModelManager(){
deviceType: "staticSwitch",
id: "x11",
packageName: "转辙教学模型",
type: "staticSwitch",
type: "static",
url: "/device/switch/511DHcongxinzuo22222222222222(1).fbx"
};
initlist.push(fbxpromise(staticSwitch,mixers,scope.staticswitchmodel));
let signal5 = {
assetname: "竖5灯",
deviceType: "ARRIVAL",
id: "s1",
packageName: "竖5灯",
type: "static",
url: "/jl3d/railway/model/signal5.FBX"
};
initlist.push(fbxpromise(signal5,mixers,scope.signal5));
let signal32 = {
assetname: "32灯",
deviceType: "EXIT",
id: "s2",
packageName: "32灯",
type: "static",
url: "/jl3d/railway/model/signal32.FBX"
};
initlist.push(fbxpromise(signal32,mixers,scope.signal32));
let signal3 = {
assetname: "3灯",
deviceType: "PASSING",
id: "s3",
packageName: "3灯",
type: "static",
url: "/jl3d/railway/model/signal3.FBX"
};
initlist.push(fbxpromise(signal3,mixers,scope.signal3));
let signal2 = {
assetname: "2灯",
deviceType: "SHUNTING",
id: "s4",
packageName: "2灯",
type: "static",
url: "/jl3d/railway/model/signal2.FBX"
};
initlist.push(fbxpromise(signal2,mixers,scope.signal2));
for(let i=0,leni=data.length;i<leni;i++){
if(data[i].deviceType == "DeviceSignal"){
initlist.push(fbxpromise(data[i],mixers,scope.signalmodel));
}
if(data[i].deviceType == "DeviceSwitch"){
initlist.push(fbxpromise(data[i],mixers,scope.switchmodel));
}
if(data[i].deviceType == "DeviceDoor"){
initlist.push(fbxpromise(data[i],mixers,scope.standmodel));
}
if(data[i].deviceType == "DeviceSection"){
initlist.push(fbxpromise(data[i],mixers,scope.sectionmodel));
}
if(data[i].deviceType == "MaintainerRoom"){
initlist.push(fbxpromise(data[i],mixers,scope.roommodel));
}
}
return new Promise(function(resolve, reject){
@ -95,11 +139,12 @@ function fbxpromise(asset,mixers,model){
return new Promise(function(resolve, reject){
var loader = new THREE.FBXLoader();
let modelurl;
if(asset.type == "staticSwitch"){
if(asset.type == "static"){
modelurl = JL3D_LOCAL_STATIC+asset.url;
}else{
modelurl = BASE_ASSET_API+asset.url;
}
loader.load( modelurl, function ( object ) {
let mixer = new THREE.AnimationMixer( object );
object.traverse( function ( child ) {
@ -109,9 +154,21 @@ function fbxpromise(asset,mixers,model){
}
} );
object.animacode = model.code;
object.deviceType = asset.deviceType;
if(asset.deviceType == "ARRIVAL" || asset.deviceType == "EXIT" || asset.deviceType == "PASSING" || asset.deviceType == "SHUNTING"){
for(let j=0;j<object.children.length;j++){
let newmaterial = new THREE.MeshPhongMaterial();
newmaterial.copy(object.children[j].material);
object.children[j].material = newmaterial;
object.children[j].material.needsUpdate = true;
newmaterial.dispose();
}
}
model.mesh = object;
if(object.animations.length>0){
if(asset.type == "staticSwitch"){
if(asset.deviceType == "staticSwitch"){
// for(let i=0;i<object.animations.length;i++){
// model.action[object.animations[i].name] = mixer.clipAction( object.animations[ i ] );

View File

@ -137,23 +137,6 @@ export function Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup,sta
}
function DeviceDestroy(data){
for(let i=0,leni=data.length;i<leni;i++){
if(data[i].type == "SIGNAL"){
signalupdate(data[i]);
}
if(data[i].type == "SWITCH"){
switchupdate(data[i]);
}
if(data[i].type == "PSD"){
standupdate(data[i]);
}
if(data[i].type == "TRAIN_DOOR"){
traindoorupdate(data[i]);
}
}
}
function tdtUpdate(data){
@ -531,102 +514,6 @@ export function Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup,sta
}
}
function traindoorupdate(data){
// console.log(data);
// console.log("direct:"+trainmodel.right);
// console.log(trainmodel.openleft);
// console.log(trainmodel.openright);
if(trainmodel.code == data.code){
if(trainmodel.right == "0"){
if(data.doorCode == "2"){
if(trainmodel.openleft != data.open && data.open == "0"){
trainmodel.openleft = "0";
for(let an=actions["traindoor"].top.length-1;an>=0;an--){
actions["traindoor"].top[an].reset();
actions["traindoor"].top[an].time = actions["traindoor"].top[an]._clip.duration;
actions["traindoor"].top[an].timeScale = -1;
actions["traindoor"].top[an].play();
}
}else if(trainmodel.openleft != data.open && data.open == "1"){
trainmodel.openleft = "1";
console.log(data);
for(let an=actions["traindoor"].top.length-1;an>=0;an--){
actions["traindoor"].top[an].reset();
actions["traindoor"].top[an].time = 0;
actions["traindoor"].top[an].timeScale = 1;
actions["traindoor"].top[an].play();
}
}
}else{
if (trainmodel.openright != data.open && data.open == '0') {
trainmodel.openright = '0';
for (let an=actions["traindoor"].down.length-1; an>=0; an--) {
actions["traindoor"].down[an].reset();
actions["traindoor"].down[an].time = actions["traindoor"].down[an]._clip.duration;
actions["traindoor"].down[an].timeScale = -1;
actions["traindoor"].down[an].play();
}
} else if (trainmodel.openright != data.open && data.open == '1') {
trainmodel.openright = "1";
for(let an=actions["traindoor"].down.length-1;an>=0;an--){
actions["traindoor"].down[an].reset();
actions["traindoor"].down[an].time = 0;
actions["traindoor"].down[an].timeScale = 1;
actions["traindoor"].down[an].play();
}
}
}
}else{
if(data.doorCode == "1"){
if(trainmodel.openleft != data.open && data.open == "0"){
trainmodel.openleft = "0";
for(let an=actions["traindoor"].top.length-1;an>=0;an--){
actions["traindoor"].top[an].reset();
actions["traindoor"].top[an].time = actions["traindoor"].top[an]._clip.duration;
actions["traindoor"].top[an].timeScale = -1;
actions["traindoor"].top[an].play();
}
}else if(trainmodel.openleft != data.open && data.open == "1"){
trainmodel.openleft = "1";
for(let an=actions["traindoor"].top.length-1;an>=0;an--){
actions["traindoor"].top[an].reset();
actions["traindoor"].top[an].time = 0;
actions["traindoor"].top[an].timeScale = 1;
actions["traindoor"].top[an].play();
}
}
}else{
if (trainmodel.openright != data.open && data.open == '0') {
trainmodel.openright = '0';
for (let an=actions["traindoor"].down.length-1; an>=0; an--) {
actions["traindoor"].down[an].reset();
actions["traindoor"].down[an].time = actions["traindoor"].down[an]._clip.duration;
actions["traindoor"].down[an].timeScale = -1;
actions["traindoor"].down[an].play();
}
} else if (trainmodel.openright != data.open && data.open == '1') {
trainmodel.openright = "1";
for(let an=actions["traindoor"].down.length-1;an>=0;an--){
actions["traindoor"].down[an].reset();
actions["traindoor"].down[an].time = 0;
actions["traindoor"].down[an].timeScale = 1;
actions["traindoor"].down[an].play();
}
}
}
}
}
}
function trainstatus(data){
// 遍历列车对象组
if (trainlisttest) {
@ -701,56 +588,8 @@ export function Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup,sta
}
}
}
function standupdate(data) {
code = data.code;
if ( actions[code]) {
if (data.open == '1') {
actions[code].status = '1';
actions[code].action.reset();
actions[code].action.time = 0;
actions[code].action.timeScale = 1;
actions[code].action.play();
}
if (data.open == '0') {
actions[code].status = '0';
actions[code].action.reset();
actions[code].action.time = actions[code].action._clip.duration;
actions[code].action.timeScale = -1;
actions[code].action.play();
}
}
}
function signalupdate(data) {
code = data.code;
if(data.red == 1){
signallist.list[code].mesh.getObjectByName("red").material.map = materials["red"];
signallist.list[code].mesh.getObjectByName("red").material.map.needsUpdate = true;
}else{
signallist.list[code].mesh.getObjectByName("red").material.map = materials["white"];
signallist.list[code].mesh.getObjectByName("red").material.map.needsUpdate = true;
}
if(data.yellow == 1){
signallist.list[code].mesh.getObjectByName("yellow").material.map = materials["yellow"];
signallist.list[code].mesh.getObjectByName("yellow").material.map.needsUpdate = true;
}else{
signallist.list[code].mesh.getObjectByName("yellow").material.map = materials["white"];
signallist.list[code].mesh.getObjectByName("yellow").material.map.needsUpdate = true;
}
if(data.green == 1){
signallist.list[code].mesh.getObjectByName("green").material.map = materials["green"];
signallist.list[code].mesh.getObjectByName("green").material.map.needsUpdate = true;
}else{
signallist.list[code].mesh.getObjectByName("green").material.map = materials["white"];
signallist.list[code].mesh.getObjectByName("green").material.map.needsUpdate = true;
}
}
function initswitch(data) {
code = data.code;
@ -771,26 +610,6 @@ export function Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup,sta
}
}
function switchupdate(data) {
code = data.code;
if (actions[code].normal != data.normal) {
if (data.normal == '02') {
// sectionlist.switchs.modellist[j].normal = data.normal;
actions[code].action.reset();
actions[code].action.time = 0;
actions[code].action.timeScale = 1;
actions[code].action.play();
actions[code].normal = "02";
} else if (data.normal == '01') {
// sectionlist.switchs.modellist[j].normal = data.normal;
actions[code].action.reset();
actions[code].action.time = actions[code].action._clip.duration;
actions[code].action.timeScale = -1;
actions[code].action.play();
actions[code].normal = "01";
}
}
}
function signalLightUpdate(code,lightType){
signallist.list[code].mesh.lightType = lightType;

View File

@ -2,9 +2,9 @@ export function getBaseUrl() {
let BASE_API;
if (process.env.NODE_ENV === 'development') {
// BASE_API = 'https://joylink.club/jlcloud';
// BASE_API = 'https://test.joylink.club/jlcloud';
BASE_API = 'https://test.joylink.club/jlcloud';
// BASE_API = 'http://192.168.8.107:9000'; // 袁琪
BASE_API = 'http://192.168.3.83:9000'; // 旭强 有线
// BASE_API = 'http://192.168.3.83:9000'; // 旭强 有线
// BASE_API = 'http://192.168.8.114:9000'; // 旭强 无线
// BASE_API = 'http://192.168.3.120:9000'; // 张赛
// BASE_API = 'http://192.168.8.140:9000'; // 杜康

View File

@ -15,7 +15,7 @@
v-show="deviceShow"
ref="Jl3dRailwayDevice"
:panel-show="deviceShow"
@closedevice3dview="jumpjlmap3dmodeFl"
@closedevice3dview="jumpjlmap3dmodel"
/>
<Jl3dRailway-Drive v-show="drivingShow" ref="Jl3dRailwayDrive" :panel-show="drivingShow" @showdriving="showdriving" />
<draw-select ref="drawSelect" />