Merge remote-tracking branch 'origin/master'

This commit is contained in:
walker-sheng 2020-11-02 19:30:07 +08:00
commit e9fddbfe18
864 changed files with 26003 additions and 68094 deletions

1
.gitignore vendored
View File

@ -6,6 +6,7 @@ yarn-debug.log*
yarn-error.log* yarn-error.log*
package-lock.json package-lock.json
tests/**/coverage/ tests/**/coverage/
/src/utils/baseUrl.js
# Editor directories and files # Editor directories and files
.idea .idea

View File

@ -1,300 +1,6 @@
import request from '@/utils/request'; import request from '@/utils/request';
export function postDataBd(data) {
return request({
url: `/api/audio/bd?group=${data.group}&conversationId=${data.conversationId}`,
method: 'post',
data: data.file
});
}
// 创建/获取会话id
export function getConversation(data) {
return request({
url: `/api/audio/conversation`,
method: 'get',
params: {
group: data.group,
userId: data.userId,
code: data.code
}
});
}
export function postDataXf(data) {
return request({
url: `/api/audio/xf`,
method: 'post',
data: data
});
}
// 获取语音历史记录
export function getHistoryVoice(code) {
return request({
url: `/api/audio/${code}/history`,
method: 'get'
});
}
// 文字聊天 发送文字
export function chatWithText(data, group) {
return request({
url: `/api/jointTraining/chatWithText?group=${group}`,
method: 'post',
data: {
message: data
}
});
}
// 文字聊天 发送语音
export function chatWithAudio(file, group) {
return request({
url: `/api/jointTraining/chatWithAudio?group=${group}`,
method: 'post',
data: file
});
}
// 文字聊天 发送语音(新版)
export function chatWithAudioNew(file, group) {
return request({
url: `/api/v1/jointTraining/chatWithAudio?group=${group}`,
method: 'post',
data: file
});
}
// 生成分发二维码
export function getJoinTrainCode(data, group) {
return request({
url: `/api/jointTraining/qrCode?group=${group}`,
method: 'post',
data: data
});
}
// 创建房间
export function postCreateRoom(data) {
return request({
url: `/api/jointTraining/room`,
method: 'post',
data: data
});
}
// 检查房间存在
export function checkRoomExist(params) {
return request({
url: `/api/simulationRoom`,
method: 'get',
params
});
}
// 获取房间详情
export function postRoomDetail(group) {
return request({
url: `/api/jointTraining/room/${group}`,
method: 'get'
});
}
// 销毁房间
export function deljointTrainRoom(group) {
return request({
url: `/api/jointTraining/room`,
method: 'delete',
params: {
group: group
}
});
}
// 查询有权限房间列表
export function getjointTrainList(params) {
return request({
url: `/api/jointTraining/room/list`,
method: 'get',
params: params
});
}
// 加入房间
export function getjointTraining(group) {
return request({
url: `/api/jointTraining/room/join`,
method: 'put',
params: {
group: group
}
});
}
// 设置人员角色
export function putUserRoles(data, group) {
return request({
url: `/api/jointTraining/room/user/role?group=${group}`,
method: 'put',
data: data
});
}
// 获取房间里的用户列表
export function getJointTrainRoomUserList(group) {
return request({
url: `/api/jointTraining/room/${group}/user/list`,
method: 'get'
});
}
// 离开房间接口
export function putJointTrainingExit(group) {
return request({
url: `/api/jointTraining/room/exit`,
method: 'put',
params: {
group: group
}
});
}
// 开始联合演练
export function startJointTraining(group) {
return request({
url: `/api/jointTraining/room/simulation`,
method: 'post',
params: {
group: group
}
});
}
// 获取个人信息
export function getUserRoles(group) {
return request({
url: `/api/jointTraining/room/user/role`,
method: 'get',
params: {
group: group
}
});
}
// 踢出用户
export function putJointTrainingUserkicked(userId, group) {
return request({
url: `/api/jointTraining/room/user`,
method: 'put',
params: {
userId: userId,
group: group
}
});
}
// 管理员结束所有人的仿真
export function putJointTrainingSimulation(group) {
return request({
url: `/api/jointTraining/room/simulation/all`,
method: 'put',
params: {
group: group
}
});
}
// 结束仿真返回房间
export function putJointTrainingSimulationUser(group) {
return request({
url: `/api/jointTraining/room/simulation/user/exit`,
method: 'put',
params: {
group: group
}
});
}
// 进入仿真
export function putJointTrainingSimulationEntrance(group) {
return request({
url: `/api/jointTraining/room/simulation/user/entrance`,
method: 'put',
params: {
group: group
}
});
}
/**
* 权限获取(房间权限)
*/
export function getPermissionJoint(group) {
return request({
url: '/api/jointTraining/qrCode',
method: 'get',
params: {
group: group
}
});
}
// 添加或更新真实设备和仿真对象连接
export function setRealDevice(group, data) {
return request({
url: `/api/jointTraining/room/realDevice?group=${group}`,
method: 'post',
data: data
});
}
// 删除真实设备和仿真对象连接
export function delRealDevice(id, group) {
return request({
url: `/api/jointTraining/room/realDevice/${id}`,
method: 'delete',
params: { group: group }
});
}
// 获取真实设备列表
export function getRealDevices(group) {
return request({
url: `/api/jointTraining/room/${group}/devices`,
method: 'get'
});
}
// 获取房间真实设备连接关系
export function getRealDevicesInRoom(group) {
return request({
url: `/api/jointTraining/room/${group}/realDevice/connect`,
method: 'get'
});
}
// 更新真实设备的连接关系
export function updateRealDevices(group, data) {
return request({
url: `/api/jointTraining/room/${group}/realDevice`,
method: 'put',
data: data
});
}
// 真实设备是否被其他仿真使用
export function realDeviceIsUsed(group, projectCode) {
return request({
url: `/api/jointTraining/room/${group}/realDeviceUsed`,
method: 'get',
params: {
projectCode: projectCode
}
});
}
// 获取仿真成员列表(新版地图) // 获取仿真成员列表(新版地图)
export function getSimulationMembersNew(group) { export function getSimulationMembersNew(group) {
return request({ return request({
@ -302,23 +8,6 @@ export function getSimulationMembersNew(group) {
method: 'get' method: 'get'
}); });
} }
// 获取仿真会话消息列表(新版地图)
export function getSimulationContextListNew(group, conversationId) {
return request({
url: `/simulation/${group}/conversation/${conversationId}`,
method: 'get'
});
}
// 接受其他人的会话邀请 (新版地图)
export function acceptCoversitionInvite(group, conversationId) {
return request({
url: `/simulation/${group}/${conversationId}/accept`,
method: 'put'
});
}
/** 发起会话 */ /** 发起会话 */
export function startConversition(group, data, sign) { export function startConversition(group, data, sign) {
return request({ return request({
@ -327,13 +16,6 @@ export function startConversition(group, data, sign) {
data data
}); });
} }
/** 根据会话id获取仿真会话 */
export function getSimulationConversition(group, conversationId) {
return request({
url: `/api/simulation/${group}/conversation/${conversationId}`,
method: 'get'
});
}
/** 发送会话消息 */ /** 发送会话消息 */
export function sendSimulationConversition(group, conversationId, file) { export function sendSimulationConversition(group, conversationId, file) {
return request({ return request({
@ -363,3 +45,11 @@ export function getAllConversition(group) {
method: 'get' method: 'get'
}); });
} }
/** 语音播完的接口 */
export function overConversationMessage(group, conversationMessageId) {
return request({
url: `/api/v1/competitionPractical/${group}/audio/over/${conversationMessageId}`,
method: 'put'
});
}

View File

@ -22,13 +22,7 @@ export function deleteCompany(id) {
method: 'delete' method: 'delete'
}); });
} }
/** 根据id查询公司信心 */
export function getCompanyById(id) {
return request({
url: `/api/company/${id}`,
method: 'get'
});
}
/** 更新公司信息 */ /** 更新公司信息 */
export function updateCompany(id, data) { export function updateCompany(id, data) {
return request({ return request({

View File

@ -7,20 +7,7 @@ export function refereeExitSimulation(group) {
method: 'delete' method: 'delete'
}); });
} }
/** 裁判进入仿真 */
export function refereeEnterSimulation(group) {
return request({
url: `/api/v1/competition/room/${group}/refree`,
method: 'post'
});
}
/** 裁判查询竞赛人员的房间列表 */
export function refereeGetCompetitionList(id) {
return request({
url: `/api/v1/competition/${id}/room`,
method: 'get'
});
}
/** 参赛者创建演练房间 */ /** 参赛者创建演练房间 */
export function participantCreatTrainingRoom(id, data) { export function participantCreatTrainingRoom(id, data) {
return request({ return request({
@ -30,23 +17,6 @@ export function participantCreatTrainingRoom(id, data) {
}); });
} }
// 加载试卷
export function loadingPaper(competitionId, data) {
return request({
url: `/api/v1/competition/${competitionId}/testPaper`,
method: 'post',
data
});
}
/** 竞赛报名 */
export function postSignUp(id, data) {
return request({
url: `/api/race/${id}/signUp`,
method: 'post',
data
});
}
/** 查询用户是否已经报名该竞赛 */ /** 查询用户是否已经报名该竞赛 */
export function getIsSignUp(raceId, params = {}) { export function getIsSignUp(raceId, params = {}) {
return request({ return request({
@ -56,24 +26,6 @@ export function getIsSignUp(raceId, params = {}) {
}); });
} }
/** 分页查询竞赛报名人员 */
export function getRaceUserList(params) {
return request({
url: `/api/race/${params.raceId}/raceUser/page`,
method: 'get',
params
});
}
/** 裁判打分 */
export function putRefereeScoring(data) {
return request({
url: `/api/v1/competition/referee/scoring`,
method: 'put',
data
});
}
/** 提交试卷 */ /** 提交试卷 */
export function postCompetitionTheory(data) { export function postCompetitionTheory(data) {
return request({ return request({
@ -83,14 +35,6 @@ export function postCompetitionTheory(data) {
}); });
} }
/** 查询本竞赛用的实操列表 */
export function getCompetitionPractical(competitionId) {
return request({
url: `/api/v1/competitionPractical/competition/${competitionId}`,
method: 'get'
});
}
/** 查询竞赛报名人员详情 */ /** 查询竞赛报名人员详情 */
export function getRaceUserById(raceId) { export function getRaceUserById(raceId) {
return request({ return request({
@ -169,68 +113,6 @@ export function getPracticalCompetitionResult(competitionId) {
}); });
} }
/** 回访准备 */
export function playBackReady(params) {
return request({
url: `/api/v1/simulationRecord/playback/ready`,
method: 'get',
params
});
}
/** 设置倍速 */
export function setPlaySpeed(params) {
return request({
url: `/api/v1/simulationRecord/playback/setPlaySpeed`,
method: 'get',
params
});
}
/** 开始播放 */
export function startPlaying(params) {
return request({
url: `/api/v1/simulationRecord/playback/startPlaying`,
method: 'get',
params
});
}
/** 暂停播放 */
export function playingPause(params) {
return request({
url: `/api/v1/simulationRecord/playback/pausePlaying`,
method: 'get',
params
});
}
/** 结束播放 */
export function endPlaying(params) {
return request({
url: `/api/v1/simulationRecord/playback/endPlaying`,
method: 'get',
params
});
}
/** 从暂停中播放 */
export function fromPauseToPlay(params) {
return request({
url: `/api/v1/simulationRecord/playback/playing`,
method: 'get',
params
});
}
/** 裁判查询理论考试结果 */
export function getTheroyCompetitionResult(competitionId, raceUserId) {
return request({
url: `api/v1/competitionTheory/detail/competition/${competitionId}/raceUser/${raceUserId}`,
method: 'get'
});
}
// 以下drts项目使用 // 以下drts项目使用
/** 项目获取试题列表 */ /** 项目获取试题列表 */
@ -360,3 +242,21 @@ export function getEmptyOperationalStatistics(group) {
}); });
} }
/** 草稿场景数据导入*/
export function postSceneImport(scriptId, name, data) {
return request({
url: `/api/v1/competitionPractical/${scriptId}/import?name=${name}`,
method: 'post',
data: data,
time: 60000
});
}
/** 草稿场景数据导出 */
export function getSceneExport(id) {
return request({
url: `/api/v1/competitionPractical/${id}/export`,
method: 'get'
});
}

View File

@ -138,37 +138,10 @@ export function previewRunPlan(planId) {
}); });
} }
/** 加载剧本 */
export function loadDraftScript(scriptId, memberId, group) {
return request({
url: `/api/simulation/${group}/scriptDraft/${scriptId}?memberId=${memberId}`,
method: 'post'
});
}
/** 剧本预览选择角色 */ /** 剧本预览选择角色 */
export function loadDraftScriptNew(memberId, group) { export function loadDraftScriptNew(memberId, group) {
return request({ return request({
// url: `/simulation/${group}/choosePlay?memberId=${memberId}`,
url: `/api/scriptSimulation/${group}/chooseMemberAndStart?memberId=${memberId}`, url: `/api/scriptSimulation/${group}/chooseMemberAndStart?memberId=${memberId}`,
method: 'put' method: 'put'
}); });
} }
/** 剧本预览选择角色 */
export function loadDraftScriptNewMode(memberId, group, mode) {
return request({
// url: `/simulation/${group}/choosePlay?memberId=${memberId}`,
url: `/api/scriptSimulation/${group}/chooseMemberAndStart?memberId=${memberId}&mode=${mode}`,
method: 'put'
});
}
/** 获取已发布的有地图的城市列表*/
export function publisMapCityList(data) {
return request({
url: `/api/map/city?dicCode=${data}`,
method: 'get'
});
}

View File

@ -95,3 +95,10 @@ export function aKeyGeneratingLesson(data) {
data: data data: data
}); });
} }
/** 根据课程ID获取班级 */
export function getExamClassList(lessonId) {
return request({
url: `/api/lesson/${lessonId}/classes`,
method: 'get'
});
}

View File

@ -85,15 +85,6 @@ export function getLessonChapterDetail(data) {
}); });
} }
/** 发布课程*/
export function publishLesson(data) {
return request({
url: `/api/lessonDraft/${data.id}/publish`,
method: 'post',
data: data
});
}
/** 课程章节拖拽排序*/ /** 课程章节拖拽排序*/
export function dragSortLessonChapter(data) { export function dragSortLessonChapter(data) {
return request({ return request({

View File

@ -16,14 +16,6 @@ export function getPublishMapListOnline() {
}); });
} }
/** 根据皮肤获取发布地图列表*/
export function getPublishMapListByLineCode(lineCode) {
return request({
url: `/api/map/${lineCode}/list`,
method: 'get'
});
}
/** 根据地图id获取地图版本信息*/ /** 根据地图id获取地图版本信息*/
export function getPublishMapVersionById(id) { export function getPublishMapVersionById(id) {
return request({ return request({
@ -107,15 +99,6 @@ export function putMapOffLine(mapId) {
}); });
} }
// /** 修改发布地图名称*/
// export function updatePublishMapName(data) {
// return request({
// url: `/api/map/${data.mapId}/updateName`,
// method: 'put',
// data: data
// });
// }
// 检测地图名称唯一性 // 检测地图名称唯一性
export function checkMapName(name) { export function checkMapName(name) {
return request({ return request({
@ -133,23 +116,6 @@ export function getPublishMapDetailList(params, code) {
}); });
} }
/** 获取有屏蔽门的站台列表*/
export function hasDoorStationList(mapId) {
return request({
url: `/api/map/${mapId}/stand/hasDoor`,
method: 'get'
});
}
// /** 修改发布地图城市*/
// export function updatePublishMapCity(data) {
// return request({
// url: `/api/map/${data.mapId}/city`,
// method: 'put',
// data: data
// });
// }
// 修改地图基本信息 // 修改地图基本信息
export function updatePublishMapInfo(data) { export function updatePublishMapInfo(data) {
return request({ return request({
@ -254,3 +220,19 @@ export function getStandListByStationCode(id, stationCode) {
method: 'get' method: 'get'
}); });
} }
/** 获取已发布的有地图的城市列表*/
export function publisMapCityList(data) {
return request({
url: `/api/map/city?dicCode=${data}`,
method: 'get'
});
}
/** 新版地图根据仿真mapId获取仿真地图数据 */
export function getNewMapDataByMapId(mapId) {
return request({
url: `/api/map/${mapId}/mapData`,
method: 'get'
});
}

View File

@ -60,15 +60,6 @@ export function saveMap(data) {
}); });
} }
// 保存新草稿地图
// export function saveNewMap(data) {
// return request({
// url: `/api/mapBuild/${data.mapId}/saveNewElements`,
// method: 'post',
// data: data
// });
// }
/** 草稿地图另存为*/ /** 草稿地图另存为*/
export function saveAsMap(data) { export function saveAsMap(data) {
return request({ return request({
@ -124,78 +115,6 @@ export function getBuildMapExport(mapId) {
}); });
} }
/** 查询进路列表*/
export function listRouteRoute(mapId, params) {
return request({
url: `/api/mapBuild/${mapId}/route`,
method: 'get',
params: params
});
}
/** 查询进路地图列表*/
export function listRouteMapRoute(mapId) {
return request({
url: `/api/mapBuild/${mapId}/route/all`,
method: 'get'
});
}
/** 查询进路明细*/
export function queryRouteRouteDetail(data) {
return request({
url: `/api/mapBuild/route/${data.id}`,
method: 'get'
});
}
/** 创建进路*/
export function createRouteRoute(data) {
return request({
url: `/api/mapBuild/route`,
method: 'post',
data: data
});
}
/** 删除进路*/
export function deleteRouteRoute(id) {
return request({
url: `/api/mapBuild/route/${id}`,
method: 'delete'
});
}
/** 更新进路*/
export function updateRouteRoute(data) {
return request({
url: `/api/mapBuild/route/${data.id}`,
method: 'put',
data: data
});
}
/** 创建联动道岔*/
export function createLinkageSwitch(data) {
return request({
url: `/api/mapBuild/switchCoupled`,
method: 'post',
data: data
});
}
/** 删除联动道岔*/
export function deleteLinkageSwitch(coupleId) {
return request({
url: `/api/mapBuild/switchCoupled/${coupleId}`,
method: 'delete'
});
}
/** get联动道岔列表*/
export function listLinkageSwitch(mapId, params) {
return request({
url: `/api/mapBuild/${mapId}/switchCoupled`,
method: 'get',
params: params
});
}
/** 草稿地图数据校验*/ /** 草稿地图数据校验*/
export function verifyMap(id) { export function verifyMap(id) {
return request({ return request({
@ -204,49 +123,6 @@ export function verifyMap(id) {
}); });
} }
/** 分页查询交路数据*/
export function listRouting(mapId, params) {
return request({
url: `/api/mapBuild/${mapId}/routing`,
method: 'get',
params: params
});
}
/** 创建交路*/
export function addRouting(data) {
return request({
url: `/api/mapBuild/routing`,
method: 'post',
data: data
});
}
/** 删除交路*/
export function deleteRouting(routingId) {
return request({
url: `/api/mapBuild/routing/${routingId}`,
method: 'delete'
});
}
/** 获取交路详情*/
export function getRouting(routingId) {
return request({
url: `/api/mapBuild/routing/${routingId}`,
method: 'get'
});
}
/** 更新交路*/
export function updateRouting(data) {
return request({
url: `/api/mapBuild/routing/${data.id}`,
method: 'put',
data: data
});
}
/** 分页查询交路数据(新版)*/ /** 分页查询交路数据(新版)*/
export function listRoutingData(mapId, params) { export function listRoutingData(mapId, params) {
return request({ return request({
@ -307,49 +183,6 @@ export function generateStationRunData(routingId) {
}); });
} }
// 创建自动信号 old旧数据
export function postAutoSignal(data) {
return request({
url: `/api/mapBuild/autoSignal`,
method: 'post',
data: data
});
}
// 删除自动信号 old旧数据
export function delAutoSignal(autoSignalId) {
return request({
url: `/api/mapBuild/autoSignal/${autoSignalId}`,
method: 'delete'
});
}
// 分页获取自动信号列表 old旧数据
export function getAutoSignalList(mapId, params) {
return request({
url: `/api/mapBuild/${mapId}/autoSignal`,
method: 'get',
params
});
}
// 获取自动信号详情 old旧数据
export function getAutoSignalDetail(autoSignalId) {
return request({
url: `/api/mapBuild/autoSignal/${autoSignalId}`,
method: 'get'
});
}
// 更新自动信号 old旧数据
export function putAutoSignal(data) {
return request({
url: `/api/mapBuild/autoSignal/${data.autoSignalId}`,
method: 'put',
data: data
});
}
// 分页获取自动信号列表 new新数据 // 分页获取自动信号列表 new新数据
export function getAutoSignalListNew(mapId, params) { export function getAutoSignalListNew(mapId, params) {
return request({ return request({
@ -392,14 +225,6 @@ export function putAutoSignalNew(data) {
data: data data: data
}); });
} }
export function getListByCityCode(cityCode) {
return request({
url: `/api/mapBuild/${cityCode}/list`,
method: 'get'
});
}
// 创建信号机接近区段 // 创建信号机接近区段
export function postApproachSection(data) { export function postApproachSection(data) {
return request({ return request({
@ -464,12 +289,6 @@ export function delContinueProtect(id) {
method: 'delete' method: 'delete'
}); });
} }
export function getContinueProtectById(id) {
return request({
url: `/api/mapBuild/overlap/${id}`,
method: 'get'
});
}
export function getContinueProtectList(mapId, params) { export function getContinueProtectList(mapId, params) {
return request({ return request({
url: `/api/mapBuild/${mapId}/overlap/paging`, url: `/api/mapBuild/${mapId}/overlap/paging`,
@ -545,15 +364,6 @@ export function getRouteNewList(mapId, params) {
params params
}); });
} }
// 获取自动折返分组列表
export function getAutoReentryGroupList(mapId, params) {
return request({
url: `/api/mapBuild/${mapId}/autoReentry/group/reentryTrack`,
method: 'get',
params
});
}
// 新建进路侧防 // 新建进路侧防
export function postFlankProtection(data) { export function postFlankProtection(data) {
return request({ return request({

View File

@ -1,44 +1,2 @@
import request from '@/utils/request'; // import request from '@/utils/request';
/** 获取路径单元列表*/
export function getRouteUnitList(id, data) {
return request({
url: `/api/mapBuild/${id}/routeUnit`,
method: 'get',
params: data
});
}
/** 创建路径单元*/
export function addRouteUnit(data) {
return request({
url: `/api/mapBuild/routeUnit`,
method: 'post',
data: data
});
}
/** 删除路径单元*/
export function delRouteUnit(id) {
return request({
url: `/api/mapBuild/routeUnit/${id}`,
method: 'DELETE'
});
}
/** 获取路径单元*/
export function getRouteUnit(id) {
return request({
url: `/api/mapBuild/routeUnit/${id}`,
method: 'get'
});
}
/** 更新路径单元*/
export function setRouteUnit(data) {
return request({
url: `/api/mapBuild/routeUnit/${data.id}`,
method: 'put',
data: data
});
}

View File

@ -1,29 +1,5 @@
import request from '@/utils/request'; import request from '@/utils/request';
/** 开始实训 0*/
export function startTraining(args, group) {
return request({
url: `/api/training/${args.id}/start`,
method: 'get',
params: {
group
}
});
}
/** 实训结束*/
export function endTraining(args, group) {
return request({
url: `/api/training/${args.lessonId}/${args.id}/end`,
method: 'get',
params: {
mode: args.mode,
usedTime: args.usedTime,
group
}
});
}
/** 发送步骤数据*/ /** 发送步骤数据*/
export function sendTrainingNextStep(data, group) { export function sendTrainingNextStep(data, group) {
return request({ return request({
@ -35,32 +11,6 @@ export function sendTrainingNextStep(data, group) {
} }
}); });
} }
/** 获取章节基本信息 0*/
export function getTrainingDetail(trainingId) {
return request({
url: `/api/training/${trainingId}`,
method: 'get'
});
}
/** 添加实训 0*/
export function addTraining(data) {
return request({
url: '/api/training',
method: 'post',
data: data
});
}
/** 获取实训步骤数据 0*/
export function getTrainingStepsDetail(trainingId, params) {
return request({
url: `/api/training/${trainingId}/detail`,
method: 'get',
params: params
});
}
/** 查询实训列表 0*/ /** 查询实训列表 0*/
export function pageQueryTraining(params) { export function pageQueryTraining(params) {
return request({ return request({
@ -69,41 +19,6 @@ export function pageQueryTraining(params) {
params: params params: params
}); });
} }
/** 自动生成实训操作 0*/
export function addAutoTraining(data) {
return request({
url: `/api/training/generate`,
method: 'post',
data: data
});
}
/** 修改自动删除实训操作 0*/
export function updateAutoTraining(data) {
return request({
url: `/api/training/batchUpdateGenerate`,
method: 'put',
data: data
});
}
/** 删除自动生成实训 0*/
export function deleteAutoTraining(params) {
return request({
url: `/api/training/generate`,
method: 'delete',
params: params
});
}
/** 获取用户实训列表 0*/
export function getTrainingList(data) {
return request({
url: `/api/training/list`,
method: 'get',
params: data
});
}
export function sendCommand(group, command) { export function sendCommand(group, command) {
return request({ return request({
url: `/api/training/deviceChange?group=${group}`, url: `/api/training/deviceChange?group=${group}`,
@ -125,29 +40,6 @@ export function sendCommandNew(group, commandDefinitionId, command) {
data: command data: command
}); });
} }
// 添加用户实训数据 0
export function addUserTraining(data) {
return request({
url: `/api/training/userTraining`,
method: 'post',
data: data
});
}
// 更新用户实训数据 0
export function putUserTraining(data) {
return request({
url: `/api/training/userTraining/${data.id}`,
method: 'put',
data: data
});
}
// 清除实训数据 0
export function deleteUserTraining(statsId) {
return request({
url: `/api/training/userTraining/${statsId}`,
method: 'delete'
});
}
/** 开始实训 (新版地图) */ /** 开始实训 (新版地图) */
export function startTrainingNew (args, group) { export function startTrainingNew (args, group) {
@ -184,7 +76,8 @@ export function getTrainingDetailNew(trainingId) {
url: `/api/v1/training/${trainingId}`, url: `/api/v1/training/${trainingId}`,
method: 'get' method: 'get'
}); });
}/** 添加实训(新版地图) */ }
/** 添加实训(新版地图) */
export function addTrainingNew(data) { export function addTrainingNew(data) {
return request({ return request({
url: '/api/v1/training', url: '/api/v1/training',

View File

@ -1,34 +1,5 @@
import request from '@/utils/request'; import request from '@/utils/request';
// 文字聊天 发送文字
export function chatWithTextNew(data, group) {
return request({
url: `/api/v1/jointTraining/chatWithText?group=${group}`,
method: 'post',
data: {
message: data
}
});
}
// 生成分发二维码
export function getJoinTrainCodeNew(data, group) {
return request({
url: `/api/v1/jointTraining/qrCode?group=${group}`,
method: 'post',
data: data
});
}
// 创建房间
export function postCreateRoomNew(data) {
return request({
url: `/api/v1/jointTraining/room`,
method: 'post',
data: data
});
}
// 检查房间存在 // 检查房间存在
export function checkRoomExistNew(params) { export function checkRoomExistNew(params) {
return request({ return request({
@ -38,45 +9,6 @@ export function checkRoomExistNew(params) {
}); });
} }
// 获取房间详情
export function postRoomDetailNew(group) {
return request({
url: `/api/v1/jointTraining/room/${group}`,
method: 'get'
});
}
// 销毁房间
export function deljointTrainRoomNew(group) {
return request({
url: `/api/v1/jointTraining/room`,
method: 'delete',
params: {
group: group
}
});
}
// 查询有权限房间列表
export function getjointTrainListNew(params) {
return request({
url: `/api/v1/jointTraining/room/list`,
method: 'get',
params: params
});
}
// 加入房间
export function getjointTrainingNew(group) {
return request({
url: `/api/v1/jointTraining/room/join`,
method: 'put',
params: {
group: group
}
});
}
// 设置人员角色 // 设置人员角色
export function putUserRolesNew(data, group) { export function putUserRolesNew(data, group) {
return request({ return request({
@ -86,70 +18,6 @@ export function putUserRolesNew(data, group) {
}); });
} }
// 获取房间里的用户列表
export function getJointTrainRoomUserListNew(group) {
return request({
url: `/api/v1/jointTraining/room/${group}/user/list`,
method: 'get'
});
}
// 离开房间接口
export function putJointTrainingExitNew(group) {
return request({
url: `/api/v1/jointTraining/room/exit`,
method: 'put',
params: {
group: group
}
});
}
// 开始联合演练
export function startJointTrainingNew(group) {
return request({
url: `/api/v1/jointTraining/room/simulation`,
method: 'post',
params: {
group: group
}
});
}
// 获取个人信息
export function getUserRolesNew(group) {
return request({
url: `/api/v1/jointTraining/room/user/role`,
method: 'get',
params: {
group: group
}
});
}
// 踢出用户
export function putJointTrainingUserkickedNew(userId, group) {
return request({
url: `/api/v1/jointTraining/room/user`,
method: 'put',
params: {
userId: userId,
group: group
}
});
}
// 管理员结束所有人的仿真
export function putJointTrainingSimulationNew(group) {
return request({
url: `/api/v1/jointTraining/room/simulation/all`,
method: 'put',
params: {
group: group
}
});
}
// 结束仿真返回房间 // 结束仿真返回房间
export function putJointTrainingSimulationUserNew(group) { export function putJointTrainingSimulationUserNew(group) {
return request({ return request({
@ -160,90 +28,3 @@ export function putJointTrainingSimulationUserNew(group) {
} }
}); });
} }
// 进入仿真
export function putJointTrainingSimulationEntranceNew(group) {
return request({
url: `/api/v1/jointTraining/room/simulation/user/entrance`,
method: 'put',
params: {
group: group
}
});
}
/**
* 权限获取(房间权限)
*/
export function getPermissionJointNew(group) {
return request({
url: '/api/v1/jointTraining/qrCode',
method: 'get',
params: {
group: group
}
});
}
// 添加或更新真实设备和仿真对象连接
export function setRealDeviceNew(group, data) {
return request({
url: `/api/v1/jointTraining/room/realDevice?group=${group}`,
method: 'post',
data: data
});
}
// 删除真实设备和仿真对象连接
export function delRealDeviceNew(id, group) {
return request({
url: `/api/v1/jointTraining/room/realDevice/${id}`,
method: 'delete',
params: { group: group }
});
}
// 获取真实设备列表
export function getRealDevicesNew(group) {
return request({
url: `/api/v1/jointTraining/room/${group}/devices`,
method: 'get'
});
}
// 获取房间真实设备连接关系
export function getRealDevicesInRoomNew(group) {
return request({
url: `/api/v1/jointTraining/room/${group}/realDevice/connect`,
method: 'get'
});
}
// 更新真实设备的连接关系
export function updateRealDevicesNew(group, data) {
return request({
url: `/api/v1/jointTraining/room/${group}/realDevice`,
method: 'put',
data: data
});
}
// 真实设备是否被其他仿真使用
export function realDeviceIsUsedNew(group, projectCode) {
return request({
url: `/api/v1/jointTraining/room/${group}/realDeviceUsed`,
method: 'get',
params: {
projectCode: projectCode
}
});
}
// 获取所有需要值班员的车站(新版)
export function getAvailableStaionList(mapId) {
return request({
url: `/api/map/${mapId}/station/needSupervisor`,
method: 'get'
});
}

View File

@ -10,15 +10,6 @@ export function getLessonPermissonPageList(params) {
}); });
} }
/** 创建课程权限*/
export function createLessonPermisson(data) {
return request({
url: '/api/permission',
method: 'post',
data: data
});
}
/** 获取权限详情*/ /** 获取权限详情*/
export function getPermissonDetail(id) { export function getPermissonDetail(id) {
return request({ return request({
@ -44,14 +35,6 @@ export function postPermissonList(mapId) {
}); });
} }
/** 获取用户某课程某段时间内可用的权限数量*/
export function getTotalRemains(params) {
return request({
url: '/api/userPermission/totalRemains',
method: 'get',
params: params
});
}
/** 设置权限失效或有效*/ /** 设置权限失效或有效*/
export function setLessonPermisson(data) { export function setLessonPermisson(data) {
return request({ return request({
@ -61,25 +44,7 @@ export function setLessonPermisson(data) {
}); });
} }
/** 设置权限失效或有效*/ /** 用户权限列表*/
export function getPermissionList(id) {
return request({
url: `/api/permission/${id}`,
method: 'get'
});
}
/** 获取大屏权限列表*/
export function queryPermissionScreen() {
return request({
url: `/api/userPermission/bigScreen`,
method: 'get'
});
}
/**
* 用户权限列表
*/
export function listPermision(params) { export function listPermision(params) {
return request({ return request({
url: `/api/userPermission`, url: `/api/userPermission`,
@ -88,9 +53,7 @@ export function listPermision(params) {
}); });
} }
/** /** 个人权限列表*/
* 个人权限列表
*/
export function listUserPermision(params) { export function listUserPermision(params) {
return request({ return request({
url: `/api/userPermission/my`, url: `/api/userPermission/my`,
@ -99,14 +62,6 @@ export function listUserPermision(params) {
}); });
} }
/** 用户权限列表 */
export function getDistribute(id) {
return request({
url: `/api/distribute/${id}`,
method: 'get'
});
}
/** 设置权限所有者 */ /** 设置权限所有者 */
export function putPermissionOwner(data) { export function putPermissionOwner(data) {
return request({ return request({

View File

@ -48,10 +48,7 @@ export function update(data) {
}); });
} }
/** /** 根据字典code获取明细列表*/
* 根据字典code获取明细列表
* @param {*} code
*/
export function getDetailList(code) { export function getDetailList(code) {
return request({ return request({
url: '/api/dictionary/getDetailListByCode', url: '/api/dictionary/getDetailListByCode',

View File

@ -1,32 +1,5 @@
import request from '@/utils/request'; import request from '@/utils/request';
/** 权限转增*/
export function getLessons(data) {
return request({
url: '/api/distribute/getLessons',
method: 'get',
data: data
});
}
/** 权限分发*/
export function giveLessons(data) {
return request({
url: '/api/distribute/distribute',
method: 'post',
data: data
});
}
/** 权限转增*/
export function permissionTurnAdd(data) {
return request({
url: '/api/distribute/transfer',
method: 'post',
data: data
});
}
/** 权限获取*/ /** 权限获取*/
export function getPermission(state) { export function getPermission(state) {
return request({ return request({
@ -35,24 +8,6 @@ export function getPermission(state) {
}); });
} }
/** 接收课程权限*/
export function receiveLessons(data) {
return request({
url: '/api/distribute/receiveLessons',
method: 'get',
data: data
});
}
/** 考试权限分发*/
export function giveExams(data) {
return request({
url: `/api/distribute/giveExams`,
method: 'post',
data: data
});
}
/** 权限打包分页查询*/ /** 权限打包分页查询*/
export function listPackagePermission(params) { export function listPackagePermission(params) {
return request({ return request({
@ -62,15 +17,6 @@ export function listPackagePermission(params) {
}); });
} }
/** 打包权限*/
export function packagePermissionDistribute(data) {
return request({
url: `/api/distribute/givePermission/package`,
method: 'post',
data: data
});
}
/** 权限回收*/ /** 权限回收*/
export function restorePackagePermission(id) { export function restorePackagePermission(id) {
return request({ return request({
@ -97,32 +43,6 @@ export function getPermissionPackageDetail(id, params) {
}); });
} }
/** 权限分发打包*/
export function permissionDistributePackage(data) {
return request({
url: `/api/distribute/package`,
method: 'post',
data: data
});
}
/** 权限分发解包*/
export function permissionDistributeUnPackage(permissionId) {
return request({
url: `/api/distribute/${permissionId}/unPackage`,
method: 'delete'
});
}
/** 查询可打包的权限分发*/
export function listCanPackagePermission(params) {
return request({
url: `/api/distribute/package`,
method: 'get',
params: params
});
}
// 设置权限分发列表 权限失效 // 设置权限分发列表 权限失效
export function setCommodityStatus(id) { export function setCommodityStatus(id) {
return request({ return request({
@ -148,11 +68,3 @@ export function givePermission(data) {
data: data data: data
}); });
} }
/** 查询权限分发领取用户列表 */
export function distributeUsers(distributeId) {
return request({
url: `/api/distribute/${distributeId}/distributeUsers`,
method: 'get'
});
}

View File

@ -93,19 +93,3 @@ export function updateExamRules(data) {
data: data data: data
}); });
} }
/** 根据课程ID获取试卷 */
export function getExamParperList(lessonId) {
return request({
url: `/api/exam/${lessonId}/list`,
method: 'get'
});
}
/** 根据课程ID获取班级 */
export function getExamClassList(lessonId) {
return request({
url: `/api/lesson/${lessonId}/classes`,
method: 'get'
});
}

View File

@ -9,9 +9,7 @@ export function getCommodityDetailByParams(data) {
}); });
} }
/** /** 获取商品明细列表*/
* 获取商品明细列表
*/
export function getCommodityList(params) { export function getCommodityList(params) {
return request({ return request({
url: '/api/goods', url: '/api/goods',
@ -20,20 +18,7 @@ export function getCommodityList(params) {
}); });
} }
/** /** 删除商品明细*/
* 保存商品明细列表
*/
export function saveCommodityList(params) {
return request({
url: '/api/goods',
method: 'post',
data: params
});
}
/**
* 删除商品明细
*/
export function delCommodity(id) { export function delCommodity(id) {
return request({ return request({
url: `/api/goods/${id}`, url: `/api/goods/${id}`,
@ -41,29 +26,7 @@ export function delCommodity(id) {
}); });
} }
/** /** 获取商品地图,产品,课程列表*/
* 获取商品地图产品课程列表
*/
export function getMapLesson() {
return request({
url: `/api/goods/tree`,
method: 'get'
});
}
/**
* 获取商品地图产品课程列表
*/
export function getCommodityDetailById(id) {
return request({
url: `/api/goods/${id}`,
method: 'get'
});
}
/**
* 获取商品地图产品课程列表
*/
export function updataCommodityList(data) { export function updataCommodityList(data) {
return request({ return request({
url: `/api/goods/${data.id}`, url: `/api/goods/${data.id}`,
@ -72,9 +35,7 @@ export function updataCommodityList(data) {
}); });
} }
/** /** 设置失效或有效切换*/
* 设置失效或有效切换
*/
export function setCommodityStatus(id) { export function setCommodityStatus(id) {
return request({ return request({
url: `/api/goods/${id}/status`, url: `/api/goods/${id}/status`,
@ -110,44 +71,6 @@ export function getGoodsList() {
}); });
} }
// 根据权限id查询商品
export function getGoodsByPermissionId(id) {
return request({
url: `/api/goods/permissionId`,
method: 'get',
params: {
permissionId: id
}
});
}
// 创建商品
export function postsPermissionGoods(data) {
return request({
// url: `/api/goods`,
url: `/api/goods/create/list`,
method: 'post',
data: data
});
}
// 创建万能权限商品
export function postPermissionIdsGoods(data) {
return request({
url: `/api/goods/permissionIds`,
method: 'post',
data: data
});
}
// 创建万能权限商品
export function postCreatePackage(data) {
return request({
url: `/api/goods/create/package`,
method: 'post',
data: data
});
}
// 获取订单对应的商品列表 // 获取订单对应的商品列表
export function getGoodsListByOrderId(id) { export function getGoodsListByOrderId(id) {
return request({ return request({

View File

@ -26,14 +26,6 @@ export function delSkinCode(id) {
}); });
} }
/** 根据id查询真实线路 */
export function querySkinCode(id) {
return request({
url: `/api/realLine/${id}`,
method: 'get'
});
}
/** 修改真实线路*/ /** 修改真实线路*/
export function updateSkinCode(data) { export function updateSkinCode(data) {
return request({ return request({
@ -60,23 +52,6 @@ export function putRealLineConfig(id, data) {
}); });
} }
/** 通过皮肤Code更新地图皮肤*/
export function updateSkinCodeByCode(data) {
return request({
url: `/api/realLine/${data.code}/update`,
method: 'put',
data: data
});
}
/** 检查code是否存在*/
export function querySkinCodeExistByCode(code) {
return request({
url: `/api/realLine/${code}/exist`,
method: 'get'
});
}
/** 获取真实线路列表*/ /** 获取真实线路列表*/
export function getLineCodeList() { export function getLineCodeList() {
return request({ return request({

View File

@ -10,15 +10,6 @@ export function getOrderPageList(params) {
}); });
} }
/** 根据ID获取订单数据*/
export function getOrderDetail(id, params) {
return request({
url: `/api/order/${id}`,
method: 'get',
params: params
});
}
/** 创建一个订单*/ /** 创建一个订单*/
export function createOrder(data) { export function createOrder(data) {
return request({ return request({
@ -37,31 +28,6 @@ export function updateOrder(data) {
}); });
} }
export function deleteOrder(id) {
return request({
url: `/api/order/${id}`,
method: 'delete'
});
}
/** 订单权限领取*/
export function getOrder(params) {
return request({
url: '/api/order/getOrder',
method: 'get',
params: params
});
}
/** 订单权限分发*/
export function giveOrder(data) {
return request({
url: '/api/order/giveOrder',
method: 'post',
data: data
});
}
/** 订单续费*/ /** 订单续费*/
export function getOrderCharge(id) { export function getOrderCharge(id) {
return request({ return request({
@ -104,14 +70,6 @@ export function cancalOrder(orderId) {
}); });
} }
// 万能权限查询权限包商品
export function postFindPermission(ids) {
return request({
url: `/api/goods/permissionIds?ids=${ids}`,
method: 'get'
});
}
// 获取订单的分发二维码 // 获取订单的分发二维码
export function getDistributeFromOrder(orderCode) { export function getDistributeFromOrder(orderCode) {
return request({ return request({

View File

@ -1,29 +1,4 @@
import request from '@/utils/request'; import request from '@/utils/request';
/** 注册用户*/
export function createUserInfo(data) {
return request({
url: '/api/userinfo/create',
method: 'put',
data: data
});
}
/** 根据用户Id获取用户信息*/
export function getUserInfoByOpenId(params) {
return request({
url: '/api/userinfo/getByOpenId',
method: 'get',
params: params
});
}
/** 根据姓名或者手机号查询用户*/
export function getUserInfoByNameOrMobile(params) {
return request({
url: '/api/userinfo/nameOrMobile',
method: 'get',
params: params
});
}
/** 查询用户参数*/ /** 查询用户参数*/
export function getUserConfigInfo() { export function getUserConfigInfo() {
@ -33,15 +8,6 @@ export function getUserConfigInfo() {
}); });
} }
/** 设置用户参数*/
export function setUserConfigInfo(data) {
return request({
url: '/api/user/config',
method: 'post',
data: data
});
}
/** 获取销售列表*/ /** 获取销售列表*/
export function getSellerList() { export function getSellerList() {
return request({ return request({
@ -85,10 +51,10 @@ export function saveUserSubscribe(data) {
}); });
} }
// 修改用户权限 // 修改用户信息
export function putRoles(data) { export function putRoles(data) {
return request({ return request({
url: `/api/user/${data.id}/role`, url: `/api/user/${data.id}/info`,
method: 'put', method: 'put',
data: data data: data
}); });
@ -211,14 +177,6 @@ export function exportStudentResults(projectCode, data) {
data: data data: data
}); });
} }
// 生成绑定微信二维码
export function getWxQrCode(params) {
return request({
url: `/api/user/wmurl`,
method: 'get',
params: params
});
}
// 获取微信小程序绑定二维码 // 获取微信小程序绑定二维码
export function getBindWxQrCodeUrl() { export function getBindWxQrCodeUrl() {

View File

@ -51,22 +51,6 @@ export function delPublishExam(id) {
}); });
} }
/** 删除用户实训*/
export function delTrainingList() {
return request({
url: `/api/userExam/list`,
method: 'delet'
});
}
/** 设置试卷失效 */
export function setExamGive(id) {
return request({
url: `/api/userExam/${id}/abandon`,
method: 'put'
});
}
export function updateExam(data) { export function updateExam(data) {
return request({ return request({
url: `/api/userExam/${data.id}`, url: `/api/userExam/${data.id}`,

View File

@ -23,13 +23,6 @@ export function getProjectDeviceList(params) {
params:params params:params
}); });
} }
// export function getProjectDeviceList(params) {
// return request({
// url: `/api/device/paging`,
// method: 'get',
// params:params
// });
// }
/** 删除项目设备 */ /** 删除项目设备 */
export function deleteProjectDevice(id) { export function deleteProjectDevice(id) {
return request({ return request({
@ -92,14 +85,7 @@ export function setPscConfig(id, data) {
data: data data: data
}); });
} }
/** 查询项目下的所有设备 */
export function getAllDeviceInProject(params) {
return request({
url: `/api/project/device/project`,
method: 'get',
params
});
}
/** 添加/修改ibp设备配置 */ /** 添加/修改ibp设备配置 */
export function setVrIbpConfig(id, data) { export function setVrIbpConfig(id, data) {
return request({ return request({
@ -183,3 +169,11 @@ export function setSandboxConfig(id, data) {
data: data data: data
}); });
} }
/** 添加/修改联锁工作站配置 */
export function setIlwConfig(id, data) {
return request({
url: `/api/device/${id}/config/ilw`,
method: 'put',
data: data
});
}

View File

@ -15,3 +15,43 @@ export function pushSysNotice(data) {
data data
}); });
} }
export function postLicense(data) {
return request({
url: `/api/license`,
method: 'post',
data
});
}
export function postLicenseValidate(data) {
return request({
url: `/api/license/validate`,
method: 'post',
// baseURL: 'https://joylink.club/jlcloud',
data
});
}
export function postLicenseLocal(data) {
return request({
url: `/api/license/local`,
method: 'post',
data
});
}
export function getPagingQueryList(params) {
return request({
url: `/api/license/pagingQuery`,
method: 'get',
params
});
}
export function putLicenseValid(id) {
return request({
url: `/api/license/${id}/invalidating`,
method: 'put'
});
}

View File

@ -1,12 +1,5 @@
import request from '@/utils/request'; import request from '@/utils/request';
/** 获取出题规则列表 */
export function getQuestionRuleList() {
return request({
url: `/api/questionsRule`,
method: 'get'
});
}
/** 添加出题规则 */ /** 添加出题规则 */
export function addQuestionRule(data) { export function addQuestionRule(data) {
return request({ return request({
@ -30,13 +23,7 @@ export function deleteQuestionRule(id) {
method: 'delete' method: 'delete'
}); });
} }
/** 查询单个出题规则 */
export function selectedQuestionRule(id) {
return request({
url: `/api/questionsRule/${id}`,
method: 'get'
});
}
/** 更改出题规则内容 */ /** 更改出题规则内容 */
export function updateQuestionRule(id, data) { export function updateQuestionRule(id, data) {
return request({ return request({

View File

@ -1,43 +1,17 @@
import request from '@/utils/request'; import request from '@/utils/request';
/** 分页查询竞赛 */
export function getRaceList(params) {
return request({
url: `/api/race`,
method: 'get',
params: params
});
}
/** 创建竞赛 */
export function createRace(data) {
return request({
url: `/api/race`,
method: 'post',
data
});
}
/** 修改竞赛信息 */
export function updateRace(id, data) {
return request({
url: `/api/race/${id}`,
method: 'put',
data
});
}
// /** 获取实操试题列表(题库)*/
// export function getPracticeList(params) {
// return request({
// url: `/api/v1/competitionPractical`,
// method: 'get',
// params
// });
// }
/** 导入项目试题库 */ /** 导入项目试题库 */
export function importQuestionBand(data, projectCode) { export function importQuestionBand(data, companyId) {
return request({ return request({
url: `/api/questionBank/project/${projectCode}/questions`, url: `/api/questionBank/questions/import?id=${companyId}`,
method: 'post', method: 'post',
data data
}); });
} }
/** 查询公司下题目类型数量 */
export function selectQuestionTypeNum(companyId) {
return request({
url: `/api/questionBank/type/number?companyId=${companyId}`,
method: 'get'
});
}

View File

@ -1,68 +1,197 @@
import request from '@/utils/request'; import request from '@/utils/request';
/** /**
* 获取运行图数据 * 查询线路列表
*/ */
export function getRpTools() { export function listLines() {
return request({
url: `/api/rpTools/map`,
method: 'get'
})
}
/**
* 查询线路列表
*/
export function listStations(lineId) {
return request({
url: `/api/rpTools/${lineId}/station`,
method: 'get'
})
}
/**
* 更新线路车站
*/
export function updateStation(stationId, data) {
return request({
url: `/api/rpTools/station/${stationId}`,
method: 'put',
data
})
}
/**
* 查询运行图列表
*/
export function listRps() {
return request({ return request({
url: '/api/rpTools', url: `/api/rpTools`,
method: 'get' method: 'get'
}); });
} }
/** /** 创建运行图*/
* 添加车次 export function createRp(data) {
*/ return request({
export function addRpTrip(data) { url: `/api/rpTools`,
return request({ method: 'post',
url: '/api/rpTools/trip', data
method: 'post',
data
}); });
} }
/** /**
* 删除车次 * 删除运行图组
*/ */
export function delRpTrip(tripNo) { export function deleteRp(groupId) {
return request({ return request({
url: `/api/rpTools/${tripNo}/trip`, url: `/api/rpTools/${groupId}`,
method: 'delete' method: 'delete'
}) })
} }
/** /** 获取运行图配置*/
* 修改运行时间 export function getRpConfig(planId) {
*/ return request({
export function justTripNoRunning(tripNo, data) { url: `/api/rpTools/${planId}/config`,
method: 'get'
});
}
/** 修改运行图配置*/
export function modifyRpConfig(planId, data) {
return request({
url: `/api/rpTools/${planId}/config`,
method: 'put',
data
});
}
/** 获取运行图数据*/
export function getRpTools(planId) {
return request({
url: `/api/rpTools/${planId}`,
method: 'get'
});
}
/** 添加车次*/
export function addRpTrip(planId, data) {
return request({
url: `/api/rpTools/${planId}/trip`,
method: 'post',
data
});
}
/** 删除车次*/
export function delRpTrip(planId, tripNo) {
return request({
url: `/api/rpTools/${planId}/${tripNo}/trip`,
method: 'delete'
});
}
/** 平移服务*/
export function translateRpService(planId, serviceNo, data) {
return request({
url: `/api/rpTools/${planId}/${serviceNo}/service`,
method: 'put',
data
});
}
/** 删除服务*/
export function delRpService(planId, serviceNo) {
return request({
url: `/api/rpTools/${planId}/${serviceNo}/service`,
method: 'delete'
});
}
/** 添加区域*/
export function createRpArea(planId, data) {
return request({
url: `/api/rpTools/${planId}/area`,
method: 'post',
data
});
}
/** 修改区域*/
export function modifyRpArea(planId, areaNo, data) {
return request({
url: `/api/rpTools/${planId}/${areaNo}/area`,
method: 'put',
data
});
}
/** 修改区域文字*/
export function modifyAreaNote(planId, areaNo, data) {
return request({
url: `/api/rpTools/${planId}/${areaNo}/text`,
method: 'put',
data
});
}
/** 删除区域*/
export function delRpArea(planId, areaNo) {
return request({
url: `/api/rpTools/${planId}/${areaNo}/area`,
method: 'delete'
});
}
/** 修改运行时间*/
export function justTripNoRunning(planId, tripNo, data) {
return request({
url: `/api/rpTools/${planId}/${tripNo}/running`,
method: 'put',
data
});
}
/** 修改停站时间*/
export function justTripNoStop(planId, tripNo, data) {
return request({
url: `/api/rpTools/${planId}/${tripNo}/stop`,
method: 'put',
data
});
}
/** 修改折返时间*/
export function justTripTurnBack(planId, tripNo, data) {
return request({
url: `/api/rpTools/${planId}/${tripNo}/turnBack`,
method: 'put',
data
});
}
/** 开始编辑*/
export function startRpEdit(planId) {
return request({ return request({
url: `/api/rpTools/${tripNo}/running`, url: `/api/rpTools/${planId}/edit`,
method: 'put', method: 'put'
data
}) })
} }
/** 开始编辑*/
/** export function endRpEdit(planId) {
* 修改停站时间
*/
export function justTripNoStop(tripNo, data) {
return request({ return request({
url: `/api/rpTools/${tripNo}/stop`, url: `/api/rpTools/${planId}/endEdit`,
method: 'put', method: 'put'
data
}) })
} }
/**
* 平移车次
*/
export function translateTripNo(tripNo, data) {
return request({
url: `/api/rpTools/${tripNo}/trip`,
method: 'put',
data
})
}

View File

@ -1,19 +1,6 @@
import request from '@/utils/request'; import request from '@/utils/request';
/** /** 获取运行图的车站列表*/
* 新建地图速度等级列表
*/
export function newSpeedLevels(data) {
return request({
url: '/api/runPlan/draft/speed',
method: 'post',
data: data
});
}
/**
* 获取运行图的车站列表
*/
export function getStationList(mapId) { export function getStationList(mapId) {
return request({ return request({
url: `/api/runPlan/draft/station/${mapId}`, url: `/api/runPlan/draft/station/${mapId}`,
@ -30,20 +17,7 @@ export function populatingGenericData(planId, data) {
}); });
} }
/** /** 查询运行图获取数据*/
* 创建运行图
*/
export function newRunPlan(data) {
return request({
url: '/api/runPlan/draft',
method: 'post',
data: data
});
}
/**
* 查询运行图获取数据
*/
export function queryRunPlan(planId) { export function queryRunPlan(planId) {
return request({ return request({
url: `/api/runPlan/draft/${planId}`, url: `/api/runPlan/draft/${planId}`,
@ -96,9 +70,7 @@ export function publishRunPlan(data) {
}); });
} }
/** /** 导入真实运行图*/
* 导入真实运行图
*/
export function importRunPlan(data) { export function importRunPlan(data) {
return request({ return request({
url: `/api/runPlan/draft/${data.mapId}/prdPlan`, url: `/api/runPlan/draft/${data.mapId}/prdPlan`,
@ -115,13 +87,6 @@ export function getRpListByMapId(mapId) {
}); });
} }
/** 获取站间运行时间*/
export function getStationRunning(mapId) {
return request({
url: `/api/runPlan/draft/${mapId}/stationRunning`,
method: 'get'
});
}
/** 获取地图原始站间运行等级 */ /** 获取地图原始站间运行等级 */
export function getMapStationRun(mapId) { export function getMapStationRun(mapId) {
return request({ return request({
@ -188,6 +153,15 @@ export function addPlanService(data) {
}); });
} }
/** 修改计划*/
export function updatePlanService(planId, serviceNumber, data) {
return request({
url: `/api/runPlan/draft/${planId}/service/${serviceNumber}`,
method: 'put',
data: data
});
}
/** 删除计划*/ /** 删除计划*/
export function deletePlanService(data) { export function deletePlanService(data) {
return request({ return request({
@ -243,6 +217,22 @@ export function getRoutingBySDTNumber(params) {
}); });
} }
/** 修改计划号*/
export function updateServiceNumber(planId, serviceNumber, newServiceNumber) {
return request({
url: `/api/runPlan/draft/${planId}/service/${serviceNumber}/serviceNumber?newServiceNumber=${newServiceNumber}`,
method: 'put'
});
}
/** 修改任务车次号*/
export function updateTripNumber(planId, SDTNumber, tripNumber) {
return request({
url: `/api/runPlan/draft/${planId}/trip/${SDTNumber}/tripNumber?tripNumber=${tripNumber}`,
method: 'put'
});
}
/** 运行图仿真测试*/ /** 运行图仿真测试*/
export function runPlanNotify({ planId }) { export function runPlanNotify({ planId }) {
return request({ return request({

View File

@ -1,58 +1,12 @@
import request from '@/utils/request'; import request from '@/utils/request';
export function querySecheduling(group, params) {
return request({
url: `/api/scheduling/${group}/day`,
method: 'get',
params
});
}
export function generateScheduling(group, params) {
return request({
url: `/api/scheduling/${group}/generate`,
method: 'post',
params
});
}
export function getSchedulingAllTrains(group) {
return request({
url: `/api/scheduling/${group}/train/all`,
method: 'get'
});
}
export function checkScheduling(group, data) {
return request({
url: `/api/scheduling/${group}/check`,
method: 'post',
data
});
}
export function saveScheduling(group, data) {
return request({
url: `/api/scheduling/${group}/save`,
method: 'post',
data
});
}
export function generateSchedulingAgain(group) { export function generateSchedulingAgain(group) {
return request({ return request({
url: `/api/scheduling/${group}/rebuild`, url: `/api/scheduling/${group}/rebuild`,
method: 'delete' method: 'delete'
}); });
} }
/** 生成地图通用派班计划 */
export function generateCommonScheduling (data) {
return request({
url: `/api/v1/scheduling/generate/common`,
method: 'post',
data
});
}
/** 查询某天的派班计划 */ /** 查询某天的派班计划 */
export function querySechedulingNew (group, params) { export function querySechedulingNew (group, params) {
return request({ return request({

View File

@ -1,15 +1,5 @@
import request from '@/utils/request'; import request from '@/utils/request';
/** 分页查找上线的剧本*/
export function getScriptPageListOnline(params) {
return request({
url: `/api/script/paging/online`,
// url: `/api/script/paging/published`,
method: 'get',
params: params
});
}
/** 分页查找上线的剧本(新版)*/ /** 分页查找上线的剧本(新版)*/
export function getScriptPageListOnlineNew(params) { export function getScriptPageListOnlineNew(params) {
return request({ return request({
@ -19,14 +9,6 @@ export function getScriptPageListOnlineNew(params) {
}); });
} }
/** 通过ID查询发布的剧本的详细信息 */
export function getScriptById(id) {
return request({
url: `/api/script/${id}/detail`,
method: 'get'
});
}
/** 通过ID查询发布的剧本的详细信息(新版) */ /** 通过ID查询发布的剧本的详细信息(新版) */
export function getScriptByIdNew(id) { export function getScriptByIdNew(id) {
return request({ return request({
@ -35,14 +17,6 @@ export function getScriptByIdNew(id) {
}); });
} }
/** 通过group查询未发布剧本的详细信息 */
export function getDraftScriptByGroup(group) {
return request({
url: `/api/simulation/${group}/script/loadedScript`,
method: 'get'
});
}
/** 通过group查询未发布剧本的详细信息(新版) */ /** 通过group查询未发布剧本的详细信息(新版) */
export function getDraftScriptByGroupNew(group) { export function getDraftScriptByGroupNew(group) {
return request({ return request({
@ -52,7 +26,7 @@ export function getDraftScriptByGroupNew(group) {
} }
/** 剧本撤销发布 */ /** 剧本撤销发布 */
export function retractScript(id, data) { export function retractScript(id) {
return request({ return request({
url: `/api/script/draft/${id}/retract`, url: `/api/script/draft/${id}/retract`,
method: 'put' method: 'put'
@ -127,19 +101,20 @@ export function getAllSelectedScriptRole(group) {
}); });
} }
/** 加载剧本接口(仿真使用 竞赛) */ /** 草稿剧本数据导入*/
export function loadScript(group, scriptId) { export function postScriptImport(mapId, name, data) {
return request({ return request({
url: `/api/scriptSimulation/${group}/load/script/${scriptId}`, url: `/api/script/draft/${mapId}/import?name=${name}`,
method: 'PUT' method: 'post',
data: data,
time: 60000
}); });
} }
/** 剧本实训结束 接口(仿真使用 竞赛) */ /** 草稿剧本数据导出 */
export function endScriptTraining(group) { export function getScriptExport(id) {
return request({ return request({
url: `/api/scriptSimulation/${group}/finish`, url: `/api/script/draft/${id}/export`,
method: 'get' method: 'get'
}); });
} }

View File

@ -1,23 +1,5 @@
import request from '@/utils/request'; import request from '@/utils/request';
/** 获取故障规则列表*/
export function getFailureGenerateRules(params) {
return request({
url: `/api/simulation/failureGenerateRules`,
method: 'get',
params: params
});
}
/** 设置自动故障*/
export function setFailureMode(data, group) {
return request({
url: `/api/simulation/${group}/failureMode`,
method: 'post',
data: data
});
}
/** 设置自动故障(新版)*/ /** 设置自动故障(新版)*/
export function setFailureModeNew(data, group) { export function setFailureModeNew(data, group) {
return request({ return request({
@ -41,15 +23,6 @@ export function getSimulationFaultRules(group) {
}); });
} }
// 创建故障规则(新版)
export function addFailureRule(data) {
return request({
url: `/api/v1/faultRule`,
method: 'post',
data: data
});
}
/** 根据id删除故障规则 */ /** 根据id删除故障规则 */
export function deleteFailureRule(id) { export function deleteFailureRule(id) {
return request({ return request({
@ -58,56 +31,7 @@ export function deleteFailureRule(id) {
}); });
} }
/** 获取故障规则列表(新版)*/ /** 退出仿真系统*/
export function getFailureRulesNew(params) {
return request({
url: `/api/v1/faultRule/page`,
method: 'get',
params: params
});
}
// 修改故障规则(新版)
export function modifyFailureRule(data) {
return request({
url: `/api/v1/faultRule`,
method: 'put',
data: data
});
}
/** 通过id获取故障规则(新版)*/
export function getFailureRulesByIdNew(id) {
return request({
url: `/api/v1/faultRule/${id}`,
method: 'get'
});
}
/**
* 仿真系统按计划行车
*/
export function runDiagramStart(params, group) {
return request({
url: `/api/simulation/${group}/start`,
method: 'put',
params: params
});
}
/**
* 仿真系统结束计划行车
*/
export function runDiagramOver(group) {
return request({
url: `/api/simulation/${group}/over`,
method: 'put'
});
}
/**
* 退出仿真系统
*/
export function runDiagramQuit(group) { export function runDiagramQuit(group) {
return request({ return request({
url: `/api/simulation/${group}/quit`, url: `/api/simulation/${group}/quit`,
@ -115,43 +39,6 @@ export function runDiagramQuit(group) {
}); });
} }
/** 获取仿真系统时间*/
export function runDiagramGetTime(group) {
return request({
url: `/api/simulation/${group}/systemTime`,
method: 'get'
});
}
// 查看是否开始按计划行车
export function runDiagramIsStart(group) {
return request({
url: `/api/simulation/${group}/isRunPlanStart`,
method: 'get'
});
}
/**
* 仿真系统CBTC
* @param {*} mapId
*/
export function simulationNotify({ mapId, prdType }) {
return request({
url: `/api/simulation/${mapId}/${prdType}`,
method: 'get'
});
}
/**
* 实训系统CBTC
* @param {*} data
*/
export function trainingNotify({ trainingId }) {
return request({
url: `/api/simulation/training/${trainingId}`,
method: 'get'
});
}
/** 实训系统(新版地图) */ /** 实训系统(新版地图) */
export function trainingNotifyNew({ trainingId }) { export function trainingNotifyNew({ trainingId }) {
return request({ return request({
@ -159,16 +46,7 @@ export function trainingNotifyNew({ trainingId }) {
method: 'get' method: 'get'
}); });
} }
/**
* 考试系统CBTC
* @param {*} data
*/
export function examNotify({ examId }) {
return request({
url: `/api/simulation/exam/${examId}`,
method: 'get'
});
}
/** 考试系统(新版地图)*/ /** 考试系统(新版地图)*/
export function examNotifyNew({ examId }) { export function examNotifyNew({ examId }) {
return request({ return request({
@ -211,30 +89,6 @@ export function deleteSimulationStats(statsId) {
}); });
} }
/** 获取用户鼠标左键选中的设备信息*/
export function letfMouseSelectDevice(deviceCode, group) {
return request({
url: `/api/simulation/${group}/device/${deviceCode}`,
method: 'get'
});
}
/** 获取每日运行图*/
export function getEveryDayRunPlanData(group) {
return request({
url: `/api/simulation/${group}/runPlan`,
method: 'get'
});
}
/** 录制脚本仿真*/
export function scriptRecordNotify(scriptId) {
return request({
url: `/api/simulation/scriptWrite/${scriptId}`,
method: 'get'
});
}
/** 录制脚本仿真(新版)*/ /** 录制脚本仿真(新版)*/
export function scriptRecordNotifyNew(scriptId) { export function scriptRecordNotifyNew(scriptId) {
return request({ return request({
@ -243,14 +97,6 @@ export function scriptRecordNotifyNew(scriptId) {
}); });
} }
/** 保存剧本背景*/
export function saveScriptScenes(group) {
return request({
url: `/api/simulation/${group}/scriptWrite/scenes`,
method: 'put'
});
}
/** 保存剧本背景(新版)*/ /** 保存剧本背景(新版)*/
export function saveScriptScenesNew(group) { export function saveScriptScenesNew(group) {
return request({ return request({
@ -267,14 +113,6 @@ export function scriptRePreview(group) {
}); });
} }
/** 保存录制任务数据*/
export function saveScriptData(group) {
return request({
url: `/api/simulation/${group}/scriptWrite/saveData`,
method: 'put'
});
}
/** 保存录制任务数据(新版)*/ /** 保存录制任务数据(新版)*/
export function saveScriptDataNew(group) { export function saveScriptDataNew(group) {
return request({ return request({
@ -283,15 +121,6 @@ export function saveScriptDataNew(group) {
}); });
} }
/** 更新任务地图定位信息*/
export function updateMapLocation(group, data) {
return request({
url: `/api/simulation/${group}/scriptWrite/mapLocation`,
method: 'put',
data
});
}
/** 更新任务地图定位信息(新版)*/ /** 更新任务地图定位信息(新版)*/
export function updateMapLocationNew(group, data) { export function updateMapLocationNew(group, data) {
return request({ return request({
@ -301,82 +130,6 @@ export function updateMapLocationNew(group, data) {
}); });
} }
/** 获取剧本编制的所有成员角色*/
export function getScriptMemberData(group) {
return request({
url: `/api/simulation/${group}/scriptWrite/members`,
method: 'get'
});
}
/** 获取剧本出演成员角色 */
export function getScriptPlayMember(group) {
return request({
url: `/api/simulation/${group}/scriptWrite/players`,
method: 'get'
});
}
/** 获取剧本出演成员角色(新版地图) */
export function getScriptPlayMemberNew(group) {
return request({
url: `/api/scriptSimulation/${group}/allPlayer`,
method: 'get'
});
}
/** 取消剧本演出成员角色 */
export function cancleScriptMembers(group, data) {
return request({
url: `/api/simulation/${group}/scriptWrite/removePlayers`,
method: 'put',
data
});
}
/** 取消剧本演出成员角色 */
export function cancleScriptMembersNew(group, data) {
return request({
url: `/api/scriptSimulation/${group}/removePlayers`,
method: 'put',
data
});
}
/** 选择剧本演出成员角色 */
export function selectScriptMembers(group, data) {
return request({
url: `/api/simulation/${group}/scriptWrite/choosePlayers`,
method: 'put',
data
});
}
/** 选择剧本演出成员角色 (新版地图)*/
export function selectScriptMembersNew(group, data) {
return request({
url: `/api/scriptSimulation/${group}/choosePlayers`,
method: 'put',
data
});
}
/** 修改剧本演出成员性别 */
export function modifyScriptMemberSex(group, playerId, data) {
return request({
url: `/api/simulation/${group}/scriptWrite/player/${playerId}?gender=${data.gender}`,
method: 'put'
});
}
/** 清除仿真剧本数据*/
export function dumpScriptData(group) {
return request({
url: `/api/simulation/${group}/scriptWrite/saveData`,
method: 'delete'
});
}
/** 清除仿真剧本数据(新版)*/ /** 清除仿真剧本数据(新版)*/
export function dumpScriptDataNew(group) { export function dumpScriptDataNew(group) {
return request({ return request({
@ -385,57 +138,6 @@ export function dumpScriptDataNew(group) {
}); });
} }
/** 查询录制剧本步骤*/
export function queryScriptStep(group) {
return request({
url: `/api/simulation/${group}/scriptRecordStage`,
method: 'get'
});
}
/** 获取指定时间里可加载列车的个数*/
export function getDesignatedTimeTrainNum(params, group) {
return request({
url: `/api/simulation/${group}/plan/trainNum`,
method: 'get',
params
});
}
/** 添加剧本动作 */
export function addScriptAction(group, data) {
return request({
url: `/api/simulation/${group}/scriptWrite/action`,
method: 'post',
data
});
}
/** 添加剧本动作(新版) */
export function addScriptActionNew(group, data) {
return request({
url: `/api/scriptSimulation/${group}/addAction`,
method: 'PUT',
data
});
}
/** 删除剧本动作 */
export function deleteScriptAction(group, actionId) {
return request({
url: `/api/simulation/${group}/scriptWrite/action/${actionId}`,
method: 'delete'
});
}
/** 修改剧本动作 */
export function modifyScriptAction(group, actionId, data) {
return request({
url: `/api/simulation/${group}/scriptWrite/action/${actionId}`,
method: 'put',
data
});
}
/** 修改剧本动作(新版) */ /** 修改剧本动作(新版) */
export function modifyScriptActionNew(group, data) { export function modifyScriptActionNew(group, data) {
return request({ return request({
@ -461,22 +163,6 @@ export function deleteExistingSimulation(group) {
method: 'delete' method: 'delete'
}); });
} }
/** 根据设备类型获取设备列表 */
export function getDeviceCodeByDeviceType(group, params) {
return request({
url: `/api/simulation/${group}/deviceType/devices`,
method: 'get',
params
});
}
/** 获取任务录制的数据 */
export function getScriptRecord(group) {
return request({
url: `/api/simulation/${group}/scriptWrite`,
method: 'get'
});
}
/** 获取任务录制的所有动作(新版)*/ /** 获取任务录制的所有动作(新版)*/
export function getScriptAllAction(group) { export function getScriptAllAction(group) {
@ -486,22 +172,6 @@ export function getScriptAllAction(group) {
}); });
} }
/** 加载任务*/
export function loadQuest(questId, memberId, group) {
return request({
url: `/api/simulation/${group}/quest/${questId}?memberId=${memberId}`,
method: 'post'
});
}
/** 加载剧本 */
export function loadScript(scriptId, memberId, group) {
return request({
url: `api/simulation/${group}/script/${scriptId}?memberId=${memberId}`,
method: 'post'
});
}
/** 加载剧本(新版) */ /** 加载剧本(新版) */
export function loadScriptNew(scriptId, memberId, group) { export function loadScriptNew(scriptId, memberId, group) {
return request({ return request({
@ -510,14 +180,6 @@ export function loadScriptNew(scriptId, memberId, group) {
}); });
} }
/** 退出剧本*/
export function quitScript(group) {
return request({
url: `/api/simulation/${group}/script`,
method: 'delete'
});
}
/** 退出剧本(新版)*/ /** 退出剧本(新版)*/
export function quitScriptNew(group) { export function quitScriptNew(group) {
return request({ return request({
@ -526,48 +188,6 @@ export function quitScriptNew(group) {
}); });
} }
/** 退出任务*/
export function quitQuest(group) {
return request({
url: `/api/simulation/${group}/quest`,
method: 'put'
});
}
/** 根据group获取仿真对象*/
export function getSimulationInfo(group) {
return request({
url: `/api/simulation/${group}`,
method: 'get'
});
}
/** 获取可用的设备指令*/
export function getAvailableDeviceCommand(params) {
return request({
url: `/api/simulation/deviceCommand/available`,
method: 'get',
params
});
}
/** 保存/修改任务剧本*/
export function saveTaskScript(group, data) {
return request({
url: `/api/simulation/${group}/questRecord/script`,
method: 'post',
data
});
}
/** 暂停剧本编制的仿真 */
export function scriptPause(group) {
return request({
url: `/api/simulation/${group}/scriptWrite/pause`,
method: 'post'
});
}
/** 暂停仿真 */ /** 暂停仿真 */
export function simulationPause(group) { export function simulationPause(group) {
return request({ return request({
@ -576,57 +196,15 @@ export function simulationPause(group) {
}); });
} }
/** 恢复仿真运行并执行刚编辑的剧本动作 */
export function executeScript(group) {
return request({
url: `/api/simulation/${group}/scriptWrite/execute`,
method: 'post'
});
}
/** 恢复仿真运行并执行刚编辑的剧本动作(新版) */ /** 恢复仿真运行并执行刚编辑的剧本动作(新版) */
export function executeScriptNew(group) { export function executeScriptNew(group) {
return request({ return request({
// url: `/api/scriptSimulation/${group}/recoverAndExecute`,
url: `/simulation/${group}/resume`, url: `/simulation/${group}/resume`,
method: 'PUT' method: 'PUT'
}); });
} }
/** 生成用户自己的当日运行图*/
export function generateDayRunPlan(planId, group) {
return request({
url: `/api/simulation/${group}/loadRunPlan/${planId}`,
method: 'post'
});
}
/** 创建派班计划仿真*/
export function schedulingNotify(params) {
return request({
url: `/api/scheduling/simulation`,
method: 'post',
params
});
}
/** 获取PLC网关 */
export function getPlcGateway(group) {
return request({
url: `/api/simulation/${group}/plcGateway`,
method: 'get'
});
}
/** 处理ibp盘事件 */ /** 处理ibp盘事件 */
// export function handlerIbpEvent(group, data) {
// return request({
// url: `/api/simulation/${group}/ibp/event`,
// method: 'post',
// data: data
// });
// }
export function handlerIbpEvent(group, button, stationCode) { export function handlerIbpEvent(group, button, stationCode) {
return request({ return request({
url: `/simulation/${group}/ibp/${button}?stationCode=${stationCode}`, url: `/simulation/${group}/ibp/${button}?stationCode=${stationCode}`,
@ -673,22 +251,6 @@ export function getNewMapDataByGroup(group) {
}); });
} }
/** 新版地图根据仿真mapId获取仿真地图数据 */
export function getNewMapDataByMapId(mapId) {
return request({
url: `/api/map/${mapId}/mapData`,
method: 'get'
});
}
/** 新版地图指令操作定义 */
export function newMapOperate(group, operationId, data) {
return request({
url: `/simulation/${group}/operate/${operationId}`,
method: 'post',
data: data
});
}
/** 新版地图根据group获取仿真运行图 */ /** 新版地图根据group获取仿真运行图 */
export function getEveryDayRunPlanNew(group) { export function getEveryDayRunPlanNew(group) {
return request({ return request({
@ -713,15 +275,6 @@ export function clearSimulation(group) {
}); });
} }
/** 查询进路信息*/
export function querySignalStatus(group, params) {
return request({
url: `/api/simulation/${group}/status/signal`,
method: 'get',
params
});
}
/** 获取仿真运行图车次号列表 */ /** 获取仿真运行图车次号列表 */
export function getTripNumberList(group) { export function getTripNumberList(group) {
return request({ return request({
@ -827,3 +380,19 @@ export function getIbpInitialState (group, stationCode) {
method: 'get' method: 'get'
}); });
} }
// 获取报警列表
export function getAlarmList(group, params) {
return request({
url: `/simulation/${group}/alarm`,
method: 'get',
params:params
});
}
// 报警确认
export function confirmAlarm(group, data) {
return request({
url: `/simulation/${group}/alarm/confirm`,
method: 'put',
data
});
}

View File

@ -1,89 +1 @@
import request from '@/utils/request'; // import request from '@/utils/request';
// 课程列表
export function getLessonList(code) {
return request({
url: '/api/stats/lesson/list',
method: 'get',
params: {
wmCode: code
}
});
}
// 课程内实训数据统计
export function getLessonTimeChart(data) {
return request({
url: `/api/stats/lesson/${data.id}/stats`,
method: 'get',
params: {
wmCode: data.code
}
});
}
// 查询参与考试的课程列表
export function getExamTree(code) {
return request({
url: '/api/stats/exam/lessonList',
method: 'get',
params: {
wmCode: code
}
});
}
// 查询参与考试的试题列表
export function getstatsExamList(data) {
return request({
url: `/api/stats/exam/${data.lessonId}/list`,
method: 'get',
params: {
wmCode: data.code
}
});
}
// 个人考试数据统计
export function getExamChart(data) {
return request({
url: `/api/stats/exam/${data.examId}/stats`,
method: 'get',
params: {
wmCode: data.code
}
});
}
// 个人关注地图数据统计列表
export function getRelevanceMapList(code) {
return request({
url: `/api/user/subscribe`,
method: 'get',
params: {
wmCode: code
}
});
}
// 仿真地图下产品列表
export function getSimulationPrdList(mapId, code) {
return request({
url: `/api/stats/simulation/${mapId}/prdList`,
method: 'get',
params: {
wmCode: code
}
});
}
// 个人仿真数据统计
export function getSimulationTimeChart(data) {
return request({
url: `/api/stats/simulation/${data.mapId}/stats`,
method: 'get',
params: {
wmCode: data.code
}
});
}

View File

@ -1,75 +1,68 @@
import request from '@/utils/request'; import request from '@/utils/request';
/** 根据cityCode后去对应地图及其子系统 */
export function getTrainingSystemList(cityCode, params) { export function getTrainingSystemList(cityCode, params) {
/** 根据cityCode后去对应地图及其子系统 */
return request({ return request({
url: `/api/mapSystem/city/${cityCode}`, url: `/api/mapSystem/city/${cityCode}`,
method: 'get', method: 'get',
params params
}); });
} }
/** 根据mapId生成地图子系统 */
export function generateMapSystem(mapId) { export function generateMapSystem(mapId) {
/** 根据mapId生成地图子系统 */
return request({ return request({
url: `/api/mapSystem/generate/${mapId}`, url: `/api/mapSystem/generate/${mapId}`,
method: 'post' method: 'post'
}); });
} }
/** 查询子系统信息 */
export function getSubSystemInfo(id) { export function getSubSystemInfo(id) {
/** 查询子系统信息 */
return request({ return request({
url: `/api/mapSystem/${id}`, url: `/api/mapSystem/${id}`,
method: 'get' method: 'get'
}); });
} }
/** 查询子系统详情*/
export function getSubSystemDetail(id) { export function getSubSystemDetail(id) {
/** 查询子系统详情*/
return request({ return request({
url: `/api/mapSystem/${id}/detail`, url: `/api/mapSystem/${id}/detail`,
method: 'get' method: 'get'
}); });
} }
/** 分页查询地图系统 */
export function getMapSystemPageList(params) { export function getMapSystemPageList(params) {
/** 分页查询地图系统 */
return request({ return request({
url: `/api/mapSystem`, url: `/api/mapSystem`,
method: 'get', method: 'get',
params params
}); });
} }
/** 创建地图系统 */
export function createMapSubSystem(data) { export function createMapSubSystem(data) {
/** 创建地图系统 */
return request({ return request({
url: `/api/mapSystem`, url: `/api/mapSystem`,
method: 'post', method: 'post',
data: data data: data
}); });
} }
/** 查询子系统信息 */
export function updateSubSystem(id, data) { export function updateSubSystem(id, data) {
/** 查询子系统信息 */
return request({ return request({
url: `/api/mapSystem/${id}`, url: `/api/mapSystem/${id}`,
method: 'put', method: 'put',
data: data data: data
}); });
} }
/** 删除地图系统 */
export function deleteSubSystem(id) { export function deleteSubSystem(id) {
/** 删除地图系统 */
return request({ return request({
url: `/api/mapSystem/${id}`, url: `/api/mapSystem/${id}`,
method: 'delete' method: 'delete'
}); });
} }
/** 根据项目编号查询地图子系统 */
export function getSubSystemByProjectCode() { export function getSubSystemByProjectCode() {
/** 根据项目编号查询地图子系统 */
return request({ return request({
url: `/api/mapSystem/project`, url: `/api/mapSystem/project`,
method: 'get' method: 'get'

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

BIN
src/assets/teleRing.mp3 Normal file

Binary file not shown.

BIN
src/assets/voiceClose.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

BIN
src/assets/voiceOpen.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

@ -13,53 +13,51 @@
import pathToRegexp from 'path-to-regexp'; import pathToRegexp from 'path-to-regexp';
export default { export default {
data() { data() {
return { return {
levelList: null levelList: null
}; };
}, },
watch: { watch: {
$route() { $route() {
this.getBreadcrumb(); this.getBreadcrumb();
} }
}, },
created() { created() {
this.getBreadcrumb(); this.getBreadcrumb();
}, },
methods: { methods: {
getBreadcrumb() { getBreadcrumb() {
// only show routes with meta.title let matched = this.$route.matched.filter(item => item.meta && item.meta.title);
let matched = this.$route.matched.filter(item => item.meta && item.meta.title); const first = matched[0];
const first = matched[0];
if (!this.isDashboard(first)) { if (!this.isDashboard(first)) {
matched = [{ path: '/dashboard', meta: { title: 'Dashboard' }}].concat(matched); matched = [{ path: '/dashboard', meta: { title: 'Dashboard' }}].concat(matched);
} }
this.levelList = matched.filter(item => item.meta && item.meta.title && item.meta.breadcrumb !== false); this.levelList = matched.filter(item => item.meta && item.meta.title && item.meta.breadcrumb !== false);
}, },
isDashboard(route) { isDashboard(route) {
const name = route && route.name; const name = route && route.name;
if (!name) { if (!name) {
return false; return false;
} }
return name.trim().toLocaleLowerCase() === 'Dashboard'.toLocaleLowerCase(); return name.trim().toLocaleLowerCase() === 'Dashboard'.toLocaleLowerCase();
}, },
pathCompile(path) { pathCompile(path) {
// To solve this problem https://github.com/PanJiaChen/vue-element-admin/issues/561 const { params } = this.$route;
const { params } = this.$route; var toPath = pathToRegexp.compile(path);
var toPath = pathToRegexp.compile(path); return toPath(params);
return toPath(params); },
}, handleLink(item) {
handleLink(item) { const { redirect, path } = item;
const { redirect, path } = item; if (redirect) {
if (redirect) { this.$router.push(redirect);
this.$router.push(redirect); return;
return; }
} this.$router.push(this.pathCompile(path));
this.$router.push(this.pathCompile(path)); }
} }
}
}; };
</script> </script>

View File

@ -15,18 +15,18 @@
<script> <script>
export default { export default {
name: 'Hamburger', name: 'Hamburger',
props: { props: {
isActive: { isActive: {
type: Boolean, type: Boolean,
default: false default: false
} }
}, },
methods: { methods: {
toggleClick() { toggleClick() {
this.$emit('toggleClick'); this.$emit('toggleClick');
} }
} }
}; };
</script> </script>

View File

@ -214,6 +214,7 @@
<el-select <el-select
v-model="formModel[item.prop]" v-model="formModel[item.prop]"
filterable filterable
:clearable="item.clearable"
:placeholder="item.placeholder" :placeholder="item.placeholder"
:disabled="item.disabled" :disabled="item.disabled"
@change="((val)=>{deviceChange(val, item)})" @change="((val)=>{deviceChange(val, item)})"

View File

@ -302,6 +302,7 @@ export default {
// //
initPageData() { initPageData() {
this.modelFields = []; this.modelFields = [];
this.formModel = {};
this.exportFlag = this.queryForm.canExport; this.exportFlag = this.queryForm.canExport;
this.resetShow = this.queryForm.reset; this.resetShow = this.queryForm.reset;
this.buildQueryField(); this.buildQueryField();

View File

@ -17,10 +17,10 @@ export default {
/** 注意在ie中 第一次获取到的值为组件自带50% 移动之后赋值为px*/ /** 注意在ie中 第一次获取到的值为组件自带50% 移动之后赋值为px*/
if (sty.left.includes('%')) { if (sty.left.includes('%')) {
styL = +document.body.clientWidth * (+sty.left.replace(/\%/g, '') / 100); styL = +document.body.clientWidth * (+sty.left.replace(/\%/g, '') / 100);
styT = +document.body.clientHeight * (+sty.top.replace(/\%/g, '') / 100); styT = +document.body.clientHeight * (+sty.bottom.replace(/\%/g, '') / 100);
} else { } else {
styL = +sty.left.replace(/\px/g, ''); styL = +sty.left.replace(/\px/g, '');
styT = +sty.top.replace(/\px/g, ''); styT = +sty.bottom.replace(/\px/g, '');
} }
document.onmousemove = function (e) { document.onmousemove = function (e) {
@ -28,20 +28,23 @@ export default {
const l = e.clientX - disX; const l = e.clientX - disX;
const t = e.clientY - disY; const t = e.clientY - disY;
console.log(l, l + styL, dragDom.style.left);
/** 移动当前元素*/ /** 移动当前元素*/
if (l + styL < 0) { if (l + styL < 0) {
dragDom.style.left = `0px`; dragDom.style.left = `0px`;
} else if (l + styL > document.body.clientWidth - dragDom.clientWidth - 30) { } else if (l + styL > document.body.clientWidth - dragDom.clientWidth - 100) {
dragDom.style.left = `${document.body.clientWidth - dragDom.clientWidth - 30}px`; dragDom.style.left = `${document.body.clientWidth - dragDom.clientWidth - 100}px`;
} else { } else {
dragDom.style.left = `${l + styL}px`; dragDom.style.left = `${l + styL}px`;
} }
if (t + styT < 0) {
dragDom.style.top = `0px`; if (document.body.clientHeight - (styT - t) - dragDom.clientHeight < 0) {
} else if (t + styT > document.body.clientHeight - dragDom.clientHeight - 10) { dragDom.style.bottom = `${document.body.clientHeight - dragDom.clientHeight}px`;
dragDom.style.top = `${document.body.clientHeight - dragDom.clientHeight - 10}px`; } else if (document.body.clientHeight - (styT - t) - dragDom.clientHeight > document.body.clientHeight - dragDom.clientHeight) {
dragDom.style.bottom = `0px`;
} else { } else {
dragDom.style.top = `${t + styT}px`; dragDom.style.bottom = `${styT - t}px`;
} }
/** 将此时的位置传出去*/ /** 将此时的位置传出去*/

View File

@ -82,5 +82,9 @@ export default {
practiceManage:'Practice manage', practiceManage:'Practice manage',
bankManage: 'Bank manage', bankManage: 'Bank manage',
sceneManage:'Scene manage', sceneManage:'Scene manage',
companyManage: 'Company manage' companyManage: 'Company manage',
authorApply: 'Grant application',
AuthorList: 'Authorization code list',
questionsRuleManage: 'Question rule manage',
preTheoryData: 'Pre Theory Data'
}; };

View File

@ -41,7 +41,7 @@ export default {
nickname: 'Nickname', nickname: 'Nickname',
wellDelType: 'This operation will delete the type. Do you want to continue?', wellDelType: 'This operation will delete the type. Do you want to continue?',
permission: 'Permission', permission: 'Permission',
editUserPermission: 'Edit User Rights', editUserPermission: 'Edit User Info',
lessonName: 'Lesson Name', lessonName: 'Lesson Name',
selectTraining: 'Selection Training', selectTraining: 'Selection Training',
createUserTraining: 'Creating User Training', createUserTraining: 'Creating User Training',

View File

@ -87,5 +87,9 @@ export default {
bankManage: '题库列表', bankManage: '题库列表',
practiceManage:'实操列表', practiceManage:'实操列表',
sceneManage:'场景列表', sceneManage:'场景列表',
companyManage: '单位管理' companyManage: '单位管理',
authorApply: '授权申请',
AuthorList: '授权列表',
questionsRuleManage: '出题规则管理',
preTheoryData: '理论导入预处理'
}; };

View File

@ -41,7 +41,7 @@ export default {
nickname: '昵称', nickname: '昵称',
wellDelType: '此操作将删除该类型, 是否继续?', wellDelType: '此操作将删除该类型, 是否继续?',
permission: '权限', permission: '权限',
editUserPermission: '编辑用户权限', editUserPermission: '编辑用户信息',
lessonName: '课程名称', lessonName: '课程名称',
selectTraining: '选择实训', selectTraining: '选择实训',
createUserTraining: '创建用户实训', createUserTraining: '创建用户实训',

View File

@ -67,7 +67,7 @@ export default class text extends Group {
} }
setState(model) { setState(model) {
this.textName.setStyle('text', model.context); this.textName.setStyle('text', model.context);
this.textName.setStyle('textBackgroundColor', model.gbColor); model.gbColor && this.textName.setStyle('textBackgroundColor', model.gbColor);
} }
setSize(width, height) { setSize(width, height) {
this.model.width = width; this.model.width = width;

View File

@ -1,5 +1,5 @@
import elType from './elType'; import elType from './elType';
import iscs from '../iscs'; import Vue from 'vue';
export default { export default {
[elType.A.lab]: { [elType.A.lab]: {
@ -35,7 +35,7 @@ export default {
context: '' context: ''
}, },
stateB: { stateB: {
context: '' context: '0'
} }
} }
} // 数组 } // 数组
@ -46,32 +46,36 @@ const arrNumKV = [45.8, 57.4, 67.1, 25.8, 34.8, 48.1];
const arrNumKW = [113.5, 178.0, 254.6, 157.6, 135.7]; const arrNumKW = [113.5, 178.0, 254.6, 157.6, 135.7];
const arrNumMVar = [0.254, 0.54, 0.971, 1.257]; const arrNumMVar = [0.254, 0.54, 0.971, 1.257];
export function setNum(groupList) { export function setNum(groupList, jubeg) {
const typeC = [];
groupList.forEach(group => { groupList.forEach(group => {
group.elemList.forEach(el => { switch (group.type) {
switch (el.type) { case elType.C.lab:
case elType.C.lab: switch (Vue.prototype.$iscs.iscsDevice[group.code].model.unit) {
switch (iscs.iscsDevice[el.code].unit) { case 'A':
case 'A': group.context = jubeg ? '0A' : `${arrNumA[Math.floor(Math.random() * arrNumA.length + 1) - 1]}A`;
el.context = Math.floor(Math.random() * arrNumA.length + 1) - 1; typeC.push(group);
break; break;
case 'V': case 'V':
el.context = Math.floor(Math.random() * arrNumV.length + 1) - 1; group.context = jubeg ? '0V' : `${arrNumV[Math.floor(Math.random() * arrNumV.length + 1) - 1]}V`;
break; typeC.push(group);
case 'KV': break;
el.context = Math.floor(Math.random() * arrNumKV.length + 1) - 1; case 'KV':
break; group.context = jubeg ? '0KV' : `${arrNumKV[Math.floor(Math.random() * arrNumKV.length + 1) - 1]}KV`;
case 'KW': typeC.push(group);
el.context = Math.floor(Math.random() * arrNumKW.length + 1) - 1; break;
break; case 'KW':
case 'MVar': group.context = jubeg ? '0KW' : `${arrNumKW[Math.floor(Math.random() * arrNumKW.length + 1) - 1]}KW`;
el.context = Math.floor(Math.random() * arrNumMVar.length + 1) - 1; typeC.push(group);
break; break;
} case 'MVar':
group.context = jubeg ? '0MVar' : `${arrNumMVar[Math.floor(Math.random() * arrNumMVar.length + 1) - 1]}MVar`;
typeC.push(group);
break; break;
} }
}); break;
}
}); });
return groupList; return typeC;
} }

View File

@ -32,23 +32,32 @@ export function initDataSave(data) {
let sections = []; let sections = [];
// console.log(data.mapdata.sectionlist.sections.datalist); // console.log(data.mapdata.sectionlist.sections.datalist);
for(let i in data.mapdata.sectionlist.sections.datalist){ for(let i in data.mapdata.sectionlist.sections.datalist){
console.log(data.mapdata.sectionlist.sections.datalist[i].mesh.railpoint);
let section = { let section = {
// uuid:data.mapdata.sectionlist.sections.modellist[i].uuid, // uuid:data.mapdata.sectionlist.sections.modellist[i].uuid,
code:data.mapdata.sectionlist.sections.datalist[i].code, code:data.mapdata.sectionlist.sections.datalist[i].code,
name:data.mapdata.sectionlist.sections.datalist[i].name, name:data.mapdata.sectionlist.sections.datalist[i].name,
lengthFact:data.mapdata.sectionlist.sections.datalist[i].mesh.lengthFact, lengthFact:null,
standTrack:data.mapdata.sectionlist.sections.datalist[i].standTrack, standTrack:data.mapdata.sectionlist.sections.datalist[i].standTrack,
rp:data.mapdata.sectionlist.sections.datalist[i].rp, rp:data.mapdata.sectionlist.sections.datalist[i].rp,
lp:data.mapdata.sectionlist.sections.datalist[i].lp, lp:data.mapdata.sectionlist.sections.datalist[i].lp,
railpoint:data.mapdata.sectionlist.sections.datalist[i].mesh.railpoint, railpoint:null,
rail:data.mapdata.sectionlist.sections.datalist[i].rail, rail:data.mapdata.sectionlist.sections.datalist[i].rail,
position:data.mapdata.sectionlist.sections.datalist[i].mesh.position, position:null,
rotation:data.mapdata.sectionlist.sections.datalist[i].mesh.rotation, rotation:null,
scale:data.mapdata.sectionlist.sections.datalist[i].mesh.scale, scale:null,
} }
let nowmesh = data.mapdata.sectionlist.sectiongroup.getObjectByProperty("code",section.code); if(data.mapdata.sectionlist.sections.datalist[i].mesh){
section.railpoint = nowmesh.railpoint; console.log(data.mapdata.sectionlist.sections.datalist[i].mesh.railpoint);
let nowmesh = data.mapdata.sectionlist.sectiongroup.getObjectByProperty("code",section.code);
section.railpoint = nowmesh.railpoint;
section.lengthFact = data.mapdata.sectionlist.sections.datalist[i].mesh.lengthFact;
section.position = data.mapdata.sectionlist.sections.datalist[i].mesh.position;
section.rotation = data.mapdata.sectionlist.sections.datalist[i].mesh.rotation;
section.scale = data.mapdata.sectionlist.sections.datalist[i].mesh.scale;
sections.push(section);
}
// console.log(nowmesh.railpoint); // console.log(nowmesh.railpoint);
// if(data.mapdata.sectionlist.sections.datalist[i].rsection){ // if(data.mapdata.sectionlist.sections.datalist[i].rsection){
// section.rsection = data.mapdata.sectionlist.sections.datalist[i].rsection; // section.rsection = data.mapdata.sectionlist.sections.datalist[i].rsection;
@ -62,7 +71,7 @@ export function initDataSave(data) {
// testmesh1.position.z = link.position.z; // testmesh1.position.z = link.position.z;
sections.push(section);
} }
let arrray = { let arrray = {
section:sections, section:sections,

View File

@ -423,63 +423,12 @@ export function JLmap3dEdit(dom, data, mapid) {
for(let i=0;i<alignmentModel.railpoint.length;i++){ for(let i=0;i<alignmentModel.railpoint.length;i++){
newpointlist.push(new THREE.Vector3(alignmentModel.railpoint[i].x,alignmentModel.railpoint[i].y,alignmentModel.railpoint[i].z)); newpointlist.push(new THREE.Vector3(alignmentModel.railpoint[i].x,alignmentModel.railpoint[i].y,alignmentModel.railpoint[i].z));
} }
let closedSpline = new THREE.CatmullRomCurve3(newpointlist);
closedSpline.type = 'catmullrom';
closedSpline.closed = false;
let extrudeSettings = {
steps : 5,
curveSegments : 1,
bevelSegments : 1,
bevelEnabled : false,
extrudePath : closedSpline,
};
var shape = new THREE.Shape(); let newSection = reCreatSection(newpointlist,oldobject);
shape.moveTo( 0,-2 ); newSection.meshtype = "section";
shape.lineTo( 0, 2 ); scope.mapdata.sectionlist.sections.datalist[alignmentCode].mesh = newSection;
let selectmaterial = oldobject.material; objectparent.add(newSection);
var geometry = new THREE.ExtrudeBufferGeometry( shape, extrudeSettings );
let newAlignmentSection = new THREE.Mesh( geometry, selectmaterial );
newAlignmentSection.code = oldobject.code;
newAlignmentSection.railpoint = [];
for(let i=0;i<newpointlist.length;i++){
newAlignmentSection.railpoint[i] = {
x:newpointlist[i].x,
y:newpointlist[i].y,
z:newpointlist[i].z
}
}
newAlignmentSection.lengthFact = closedSpline.arcLengthDivisions/4;
if(newpointlist.length>2){
newAlignmentSection.lengthFact = newAlignmentSection.lengthFact/5;
}
let len = newAlignmentSection.lengthFact;
// closedSpline.arcLengthDivisions;
let count = newAlignmentSection.geometry.attributes.position.count/3;
for(let i=0;i<count;i++){
let ui=i*6;
if(i%2 != 0){
newAlignmentSection.geometry.attributes.uv.array[ui] = 0;
newAlignmentSection.geometry.attributes.uv.array[ui+1] = 1;
newAlignmentSection.geometry.attributes.uv.array[ui+2] = len;
newAlignmentSection.geometry.attributes.uv.array[ui+3] = 1;
newAlignmentSection.geometry.attributes.uv.array[ui+4] = len;
newAlignmentSection.geometry.attributes.uv.array[ui+5] = 0;
}else{
newAlignmentSection.geometry.attributes.uv.array[ui] = 0;
newAlignmentSection.geometry.attributes.uv.array[ui+1] = 0;
newAlignmentSection.geometry.attributes.uv.array[ui+2] = 0;
newAlignmentSection.geometry.attributes.uv.array[ui+3] = 1;
newAlignmentSection.geometry.attributes.uv.array[ui+4] = len;
newAlignmentSection.geometry.attributes.uv.array[ui+5] = 0;
}
}
newAlignmentSection.meshtype = "section";
scope.mapdata.sectionlist.sections.datalist[alignmentCode].mesh = newAlignmentSection;
objectparent.add(newAlignmentSection);
}; };
//区段平整 //区段平整
@ -493,6 +442,34 @@ export function JLmap3dEdit(dom, data, mapid) {
for(let i=0;i<alignmentModel.railpoint.length;i++){ for(let i=0;i<alignmentModel.railpoint.length;i++){
newpointlist.push(new THREE.Vector3(alignmentModel.railpoint[i].x,alignmentModel.railpoint[0].y,alignmentModel.railpoint[i].z)); newpointlist.push(new THREE.Vector3(alignmentModel.railpoint[i].x,alignmentModel.railpoint[0].y,alignmentModel.railpoint[i].z));
} }
let newSection = reCreatSection(newpointlist,oldobject);
newSection.meshtype = "section";
scope.mapdata.sectionlist.sections.datalist[alignmentCode].mesh = newSection;
objectparent.add(newSection);
}
//直区段修复
this.straightSection = function(alignmentCode){
let oldobject = scope.mapdata.sectionlist.sections.datalist[alignmentCode].mesh;
let alignmentModel = scope.mapdata.sectionlist.sections.datalist[alignmentCode];
let objectparent = oldobject.parent;
objectparent.remove(oldobject);
let newpointlist = [];
newpointlist.push(new THREE.Vector3(alignmentModel.railpoint[0].x,alignmentModel.railpoint[0].y,alignmentModel.railpoint[0].z));
newpointlist.push(new THREE.Vector3(alignmentModel.railpoint[1].x,alignmentModel.railpoint[0].y,alignmentModel.railpoint[0].z+0.001));
newpointlist.push(new THREE.Vector3(alignmentModel.railpoint[2].x,alignmentModel.railpoint[0].y,alignmentModel.railpoint[0].z));
// console.log(oldobject);
let newSection = reCreatSection(newpointlist,oldobject);
newSection.meshtype = "section";
scope.mapdata.sectionlist.sections.datalist[alignmentCode].mesh = newSection;
objectparent.add(newSection);
}
function reCreatSection(newpointlist,oldobject){
let closedSpline = new THREE.CatmullRomCurve3(newpointlist); let closedSpline = new THREE.CatmullRomCurve3(newpointlist);
closedSpline.type = 'catmullrom'; closedSpline.type = 'catmullrom';
closedSpline.closed = false; closedSpline.closed = false;
@ -524,31 +501,29 @@ export function JLmap3dEdit(dom, data, mapid) {
if(newpointlist.length>2){ if(newpointlist.length>2){
newAlignmentSection.lengthFact = newAlignmentSection.lengthFact/5; newAlignmentSection.lengthFact = newAlignmentSection.lengthFact/5;
} }
let len = newAlignmentSection.lengthFact; let len = newAlignmentSection.lengthFact;
// closedSpline.arcLengthDivisions; // closedSpline.arcLengthDivisions;
let count = newAlignmentSection.geometry.attributes.position.count/3; let count = newAlignmentSection.geometry.attributes.position.count/3;
for(let i=0;i<count;i++){ for(let i=0;i<count;i++){
let ui=i*6; let ui=i*6;
if(i%2 != 0){ if(i%2 != 0){
newAlignmentSection.geometry.attributes.uv.array[ui] = 0; newAlignmentSection.geometry.attributes.uv.array[ui] = 0;
newAlignmentSection.geometry.attributes.uv.array[ui+1] = 1; newAlignmentSection.geometry.attributes.uv.array[ui+1] = 1;
newAlignmentSection.geometry.attributes.uv.array[ui+2] = len; newAlignmentSection.geometry.attributes.uv.array[ui+2] = len;
newAlignmentSection.geometry.attributes.uv.array[ui+3] = 1; newAlignmentSection.geometry.attributes.uv.array[ui+3] = 1;
newAlignmentSection.geometry.attributes.uv.array[ui+4] = len; newAlignmentSection.geometry.attributes.uv.array[ui+4] = len;
newAlignmentSection.geometry.attributes.uv.array[ui+5] = 0; newAlignmentSection.geometry.attributes.uv.array[ui+5] = 0;
}else{ }else{
newAlignmentSection.geometry.attributes.uv.array[ui] = 0; newAlignmentSection.geometry.attributes.uv.array[ui] = 0;
newAlignmentSection.geometry.attributes.uv.array[ui+1] = 0; newAlignmentSection.geometry.attributes.uv.array[ui+1] = 0;
newAlignmentSection.geometry.attributes.uv.array[ui+2] = 0; newAlignmentSection.geometry.attributes.uv.array[ui+2] = 0;
newAlignmentSection.geometry.attributes.uv.array[ui+3] = 1; newAlignmentSection.geometry.attributes.uv.array[ui+3] = 1;
newAlignmentSection.geometry.attributes.uv.array[ui+4] = len; newAlignmentSection.geometry.attributes.uv.array[ui+4] = len;
newAlignmentSection.geometry.attributes.uv.array[ui+5] = 0; newAlignmentSection.geometry.attributes.uv.array[ui+5] = 0;
} }
} }
newAlignmentSection.meshtype = "section"; return newAlignmentSection;
scope.mapdata.sectionlist.sections.datalist[alignmentCode].mesh = newAlignmentSection;
objectparent.add(newAlignmentSection);
} }
//屏幕自适应 //屏幕自适应

View File

@ -335,8 +335,10 @@ export function SectionList() {
for(let j=0,lenj=stopsections[i].reals.length;j<lenj;j++){ for(let j=0,lenj=stopsections[i].reals.length;j<lenj;j++){
let topnextpoint = {}; let topnextpoint = {};
console.log(stopsections[i].reals[j].section.code);
if(scope.sections.datalist[stopsections[i].reals[j].section.code].railpoint == 0){ console.log(scope.sections.datalist[stopsections[i].reals[j].section.code]);
if(scope.sections.datalist[stopsections[i].reals[j].section.code].railpoint.length == 0){
let
topnextpoint = { topnextpoint = {
x:scope.sections.datalist[stopsections[i].reals[0].section.code].railpoint[0].x, x:scope.sections.datalist[stopsections[i].reals[0].section.code].railpoint[0].x,
y:0, y:0,
@ -425,6 +427,9 @@ export function SectionList() {
position.z = py; position.z = py;
let len = scope.sections.datalist[start].lengthFact; let len = scope.sections.datalist[start].lengthFact;
let height = Math.random()/1000; let height = Math.random()/1000;
console.log(origin);
console.log(start);
console.log("++++++++++++++++++");
scope.sections.datalist[start].railpoint = [ scope.sections.datalist[start].railpoint = [
new THREE.Vector3(position.x,height,position.z), new THREE.Vector3(position.x,height,position.z),
new THREE.Vector3(position.x+0.5,height,position.z+0.0001), new THREE.Vector3(position.x+0.5,height,position.z+0.0001),
@ -496,12 +501,13 @@ export function SectionList() {
y:0, y:0,
z:position.z z:position.z
}; };
console.log(origin+"******************************"); // console.log(origin+"******************************");
console.log(start); // console.log(start);
console.log(origin); // console.log(origin);
console.log(scope.sections.datalist[start]);
if(scope.sections.datalist[start].standTrack == true && start != origin){ if(scope.sections.datalist[start].standTrack == true && start != origin){
console.log(start+"到达"); // console.log(start+"到达");
console.log("++++++++++++++++++++++++"); // console.log("++++++++++++++++++++++++");
return ; return ;
}else if(scope.sections.datalist[start].rsection == undefined){ }else if(scope.sections.datalist[start].rsection == undefined){
return ; return ;
@ -1021,7 +1027,7 @@ export function SectionList() {
let ccode = switch2d[i].sectionCCode; let ccode = switch2d[i].sectionCCode;
// console.log(switchdata[i]); // console.log(switchdata[i]);
console.log(scope.sections.datalist[acode]);
let aposx = (scope.sections.datalist[acode].points[0].x + scope.sections.datalist[acode].points[scope.sections.datalist[acode].pointslength].x)/2; let aposx = (scope.sections.datalist[acode].points[0].x + scope.sections.datalist[acode].points[scope.sections.datalist[acode].pointslength].x)/2;
let cposx = (scope.sections.datalist[ccode].points[0].x + scope.sections.datalist[ccode].points[scope.sections.datalist[ccode].pointslength].x)/2; let cposx = (scope.sections.datalist[ccode].points[0].x + scope.sections.datalist[ccode].points[scope.sections.datalist[ccode].pointslength].x)/2;

View File

@ -46,44 +46,55 @@ export function SignalList() {
} }
let section = sectiondata[data[i].sectionCode]; let section = sectiondata[data[i].sectionCode];
let posx = null; let posx = null;
if(section.lsection == undefined){
if(data[i].sectionOffset > section.lengthFact/2){ section = sectiondata[section.rsection];
posx = section.mesh.position.x + data[i].sectionOffset - section.lengthFact/2; data[i].sectionOffset = section.lengthFact;
}else{ data[i].sectionCode = section.rsection;
posx = section.mesh.position.x - (section.lengthFact/2 - data[i].sectionOffset);
} }
//根据线路方向修改信号灯位置 if(section.rsection == undefined){
if(data[i].right == false){ section = sectiondata[section.lsection];
if(section.standTrack == true){ data[i].sectionOffset = 0;
posx = posx - 7; data[i].sectionCode = section.rsection;
}
newmesh.position.set(posx,0,section.mesh.position.z-3);
newmesh.rotation.z = ( Math.PI / 2 );
}else if(data[i].right == true){
if(section.standTrack == true){
posx = posx + 7;
}
newmesh.position.set(posx,0,section.mesh.position.z+3);
newmesh.rotation.z = ( - Math.PI / 2 );
} }
newmesh.scale.x = 0.05;
newmesh.scale.y = 0.05;
newmesh.scale.z = 0.05;
newmesh.sectionOffset = data[i].sectionOffset;
newmesh.sectionCode = data[i].sectionCode;
newmesh.right = data[i].right;
newsignal.mesh = newmesh;
newsignal.sectionOffset = data[i].sectionOffset; if(data[i].sectionOffset > section.lengthFact/2){
newsignal.mesh.status = "01"; posx = section.mesh.position.x + data[i].sectionOffset - section.lengthFact/2;
newsignal.name = data[i].name; }else{
newsignal.modelid = assetloader.modellist[num].id; posx = section.mesh.position.x - (section.lengthFact/2 - data[i].sectionOffset);
newsignal.code = data[i].code; }
newsignal.sectionCode = data[i].sectionCode; //根据线路方向修改信号灯位置
newsignal.right = data[i].right; if(data[i].right == false){
scope.group.add(newmesh); if(section.standTrack == true){
scope.list.push(newsignal); posx = posx - 7;
}
newmesh.position.set(posx,0,section.mesh.position.z-3);
newmesh.rotation.z = ( Math.PI / 2 );
}else if(data[i].right == true){
if(section.standTrack == true){
posx = posx + 7;
}
newmesh.position.set(posx,0,section.mesh.position.z+3);
newmesh.rotation.z = ( - Math.PI / 2 );
}
newmesh.scale.x = 0.05;
newmesh.scale.y = 0.05;
newmesh.scale.z = 0.05;
newmesh.sectionOffset = data[i].sectionOffset;
newmesh.sectionCode = data[i].sectionCode;
newmesh.right = data[i].right;
newsignal.mesh = newmesh;
newsignal.sectionOffset = data[i].sectionOffset;
newsignal.mesh.status = "01";
newsignal.name = data[i].name;
newsignal.modelid = assetloader.modellist[num].id;
newsignal.code = data[i].code;
newsignal.sectionCode = data[i].sectionCode;
newsignal.right = data[i].right;
scope.group.add(newmesh);
scope.list.push(newsignal);
}else{ }else{
for(let j=0;j<assetloader.modellist.length;j++){ for(let j=0;j<assetloader.modellist.length;j++){

View File

@ -1,7 +1,7 @@
//转辙机动画
export function Moveanimate(main){ export function Moveanimate(main){
let scope = this; let scope = this;
//内容信息显示plane
this.helpbox = null; this.helpbox = null;
this.textplane = null; this.textplane = null;
//动画列表 //动画列表
@ -14,9 +14,8 @@ export function Moveanimate(main){
this.status = true; this.status = true;
//当前动画模型 //当前动画模型
this.nowmodelname = undefined; this.nowmodelname = undefined;
//定义转辙机零件动画
this.initlistnew = function(switchmodel){ this.initlistnew = function(switchmodel){
scope.animatelist[switchmodel.animacode+"chaijie"] = []; scope.animatelist[switchmodel.animacode+"chaijie"] = [];
scope.animatelist[switchmodel.animacode+"fuwei"] = []; scope.animatelist[switchmodel.animacode+"fuwei"] = [];
for(let i=0,leni=switchmodel.children.length;i<leni;i++){ for(let i=0,leni=switchmodel.children.length;i<leni;i++){
@ -29,8 +28,6 @@ export function Moveanimate(main){
points2.push(new THREE.Vector3(switchmodel.children[i].position.x-1.5,switchmodel.children[i].position.y,switchmodel.children[i].position.z)); points2.push(new THREE.Vector3(switchmodel.children[i].position.x-1.5,switchmodel.children[i].position.y,switchmodel.children[i].position.z));
points2.push(new THREE.Vector3(switchmodel.children[i].position.x,switchmodel.children[i].position.y,switchmodel.children[i].position.z)); points2.push(new THREE.Vector3(switchmodel.children[i].position.x,switchmodel.children[i].position.y,switchmodel.children[i].position.z));
scope.initanimate(scope.animatelist[switchmodel.animacode+"fuwei"],switchmodel.children[i],switchmodel.name+"dizuooff",points2,0.5,true,0); scope.initanimate(scope.animatelist[switchmodel.animacode+"fuwei"],switchmodel.children[i],switchmodel.name+"dizuooff",points2,0.5,true,0);
} }
if(switchmodel.children[i].name == "DJZ"){ if(switchmodel.children[i].name == "DJZ"){
let points1 = []; let points1 = [];
@ -186,7 +183,6 @@ export function Moveanimate(main){
// scope.initanimate(switchmodel.children[i],switchmodel.name+"select1",points,true); // scope.initanimate(switchmodel.children[i],switchmodel.name+"select1",points,true);
let modelorderlist = []; let modelorderlist = [];
modelorderlist[switchmodel.animacode] = [ modelorderlist[switchmodel.animacode] = [
{name:"SZ",pos:[-1.5,0,-1]}, {name:"SZ",pos:[-1.5,0,-1]},
{name:"DINGK",pos:[0,9,0]}, {name:"DINGK",pos:[0,9,0]},
@ -194,8 +190,6 @@ export function Moveanimate(main){
{name:"DJZ",pos:[-3,0,0]}, {name:"DJZ",pos:[-3,0,0]},
{name:"DDJ",pos:[-1.5,0,0]}, {name:"DDJ",pos:[-1.5,0,0]},
{name:"JSQ",pos:[-3,3,0]}, {name:"JSQ",pos:[-3,3,0]},
{name:"ZDKBQ",pos:[0,3,0]}, {name:"ZDKBQ",pos:[0,3,0]},
@ -210,48 +204,45 @@ export function Moveanimate(main){
{name:"BSG",pos:[1,0,-5]}, {name:"BSG",pos:[1,0,-5]},
{name:"DZG",pos:[-1,0,-5]} {name:"DZG",pos:[-1,0,-5]}
]; ];
scope.animatelist[switchmodel.animacode+"on"] = []; scope.animatelist[switchmodel.animacode+"on"] = [];
scope.animatelist[switchmodel.animacode+"off"] = []; scope.animatelist[switchmodel.animacode+"off"] = [];
for(let i=0,leni=modelorderlist[switchmodel.animacode].length;i<leni;i++){
let orderdata = modelorderlist[switchmodel.animacode]; for(let i=0,leni=modelorderlist[switchmodel.animacode].length;i<leni;i++){
let modelon = switchmodel.getObjectByName(orderdata[i].name);
// modelon.helpbox = undefined;
let pointson = [];
pointson.push(new THREE.Vector3(modelon.position.x,modelon.position.y,modelon.position.z));
pointson.push(new THREE.Vector3(modelon.position.x+orderdata[i].pos[0],modelon.position.y+orderdata[i].pos[1],modelon.position.z+orderdata[i].pos[2]));
let pointsoff = []; let orderdata = modelorderlist[switchmodel.animacode];
pointsoff.push(new THREE.Vector3(modelon.position.x+orderdata[i].pos[0],modelon.position.y+orderdata[i].pos[1],modelon.position.z+orderdata[i].pos[2])); let modelon = switchmodel.getObjectByName(orderdata[i].name);
pointsoff.push(new THREE.Vector3(modelon.position.x,modelon.position.y,modelon.position.z)); // modelon.helpbox = undefined;
let pointson = [];
pointson.push(new THREE.Vector3(modelon.position.x,modelon.position.y,modelon.position.z));
pointson.push(new THREE.Vector3(modelon.position.x+orderdata[i].pos[0],modelon.position.y+orderdata[i].pos[1],modelon.position.z+orderdata[i].pos[2]));
// if(i == 0){ let pointsoff = [];
scope.initanimate(scope.animatelist[switchmodel.animacode+"on"],modelon,switchmodel.animacode+modelon.name+"on",pointson,0.03,true,i); pointsoff.push(new THREE.Vector3(modelon.position.x+orderdata[i].pos[0],modelon.position.y+orderdata[i].pos[1],modelon.position.z+orderdata[i].pos[2]));
scope.initanimate(scope.animatelist[switchmodel.animacode+"off"],modelon,switchmodel.animacode+modelon.name+"off",pointsoff,0.03,true,leni-i-1); pointsoff.push(new THREE.Vector3(modelon.position.x,modelon.position.y,modelon.position.z));
// }else if((i+1)<leni){
// scope.initanimate(modelon,switchmodel.animacode+modelon.name+"on",pointson,0.03,true,switchmodel.animacode+orderdata[i+1].name+"on");
// scope.initanimate(modelon,switchmodel.animacode+modelon.name+"off",pointsoff,0.03,true,switchmodel.animacode+orderdata[i-1].name+"off");
// }else{
// scope.initanimate(modelon,switchmodel.animacode+modelon.name+"on",pointson,0.03,true);
// scope.initanimate(modelon,switchmodel.animacode+modelon.name+"off",pointsoff,0.03,true,switchmodel.animacode+orderdata[i-1].name+"off");
// }
// if(switchmodel.children[i].name == "xinpian"){ // if(i == 0){
// } scope.initanimate(scope.animatelist[switchmodel.animacode+"on"],modelon,switchmodel.animacode+modelon.name+"on",pointson,0.03,true,i);
// if(switchmodel.children[i].name =="cigang"){ scope.initanimate(scope.animatelist[switchmodel.animacode+"off"],modelon,switchmodel.animacode+modelon.name+"off",pointsoff,0.03,true,leni-i-1);
// } // }else if((i+1)<leni){
} // scope.initanimate(modelon,switchmodel.animacode+modelon.name+"on",pointson,0.03,true,switchmodel.animacode+orderdata[i+1].name+"on");
// scope.initanimate(modelon,switchmodel.animacode+modelon.name+"off",pointsoff,0.03,true,switchmodel.animacode+orderdata[i-1].name+"off");
// }else{
// scope.initanimate(modelon,switchmodel.animacode+modelon.name+"on",pointson,0.03,true);
// scope.initanimate(modelon,switchmodel.animacode+modelon.name+"off",pointsoff,0.03,true,switchmodel.animacode+orderdata[i-1].name+"off");
// }
// if(switchmodel.children[i].name == "xinpian"){
// }
// if(switchmodel.children[i].name =="cigang"){
// }
}
} }
//动画对象定义 //动画对象定义
this.initanimate = function(list,modelobject,name,points,speed,type,nextname){ this.initanimate = function(list,modelobject,name,points,speed,type,nextname){
let curve = new THREE.CatmullRomCurve3(points); let curve = new THREE.CatmullRomCurve3(points);
// curve动画轨迹 // curve动画轨迹
// progress动画进度 // progress动画进度
// enable当前动画开关 // enable当前动画开关
@ -273,14 +264,9 @@ export function Moveanimate(main){
} }
list[nextname].push(animate); list[nextname].push(animate);
if(nextname){
// list[nextname] = animate;
// animate.next = nextname;
}else{
// list.push(animate);
}
} }
//设置动画播放列表
this.setplaylist = function(nowlist,enable){ this.setplaylist = function(nowlist,enable){
scope.playlist = nowlist; scope.playlist = nowlist;
@ -290,6 +276,8 @@ export function Moveanimate(main){
scope.playlist[scope.playorder][i].status = "start"; scope.playlist[scope.playorder][i].status = "start";
} }
} }
//更新信息plane内容
this.updatehelpbox = function(nowhelpbox,nowtextplane){ this.updatehelpbox = function(nowhelpbox,nowtextplane){
scope.textplane = nowtextplane; scope.textplane = nowtextplane;
scope.helpbox = nowhelpbox; scope.helpbox = nowhelpbox;
@ -298,15 +286,17 @@ export function Moveanimate(main){
this.startstop = function(){ this.startstop = function(){
} }
this.next = function(){ this.next = function(){
} }
this.before = function(){ this.before = function(){
} }
//动画播放器 //动画播放器
this.animateupdate = function(){ this.animateupdate = function(){
// console.log(scope.animatelist);
if(scope.enable){ if(scope.enable){
if(scope.playlist){ if(scope.playlist){
@ -325,7 +315,6 @@ export function Moveanimate(main){
scope.playlist[scope.playorder][i].status = "end"; scope.playlist[scope.playorder][i].status = "end";
scope.playlist[scope.playorder][i].progress = 0; scope.playlist[scope.playorder][i].progress = 0;
if(i >= scope.playlist[scope.playorder].length-1){ if(i >= scope.playlist[scope.playorder].length-1){
if(scope.playorder >= scope.playlist.length-1 ){ if(scope.playorder >= scope.playlist.length-1 ){
scope.playlist = null; scope.playlist = null;
@ -340,7 +329,6 @@ export function Moveanimate(main){
} }
} }
}else{ }else{
// console.log(scope.animatelist[k].connectmodel); // console.log(scope.animatelist[k].connectmodel);
if(scope.nowmodelname != scope.playlist[scope.playorder][i].connectmodel.name){ if(scope.nowmodelname != scope.playlist[scope.playorder][i].connectmodel.name){
@ -383,5 +371,4 @@ export function Moveanimate(main){
} }
} }
} }

View File

@ -1,8 +1,8 @@
import { JL3D_LOCAL_STATIC } from '@/api/jlmap3d/assets3d.js'; import { JL3D_LOCAL_STATIC } from '@/api/jlmap3d/assets3d.js';
//信号机贴图
export function Signallightload(lights) { export function Signallightload(lights) {
settexture(lights, "red", JL3D_LOCAL_STATIC+'/MODEL/device/signal/1.jpg'); settexture(lights, "red", JL3D_LOCAL_STATIC+'/MODEL/device/signal/1.jpg');
settexture(lights, "yellow", JL3D_LOCAL_STATIC+'/MODEL/device/signal/2.jpg'); settexture(lights, "yellow", JL3D_LOCAL_STATIC+'/MODEL/device/signal/2.jpg');
@ -12,6 +12,7 @@ export function Signallightload(lights) {
settexture(lights, "black", JL3D_LOCAL_STATIC+'/MODEL/device/signal/4.jpg'); settexture(lights, "black", JL3D_LOCAL_STATIC+'/MODEL/device/signal/4.jpg');
} }
//加载贴图
function settexture(lights, name, textureurl) { function settexture(lights, name, textureurl) {
var loader = new THREE.TextureLoader(); var loader = new THREE.TextureLoader();

View File

@ -4,13 +4,6 @@ export function Textconfig(){
this.devicelist = []; this.devicelist = [];
this.jdqinit = function(){
}
this.jdqraycast = function(){
}
//配置继电器文字信息 //配置继电器文字信息
this.initdevicetext = function(selectmodel){ this.initdevicetext = function(selectmodel){

View File

@ -1,729 +0,0 @@
import { Staticmodel } from '@/jlmap3d/jl3ddevice/config.js';
import { JL3D_LOCAL_STATIC } from '@/api/jlmap3d/assets3d.js';
//loader
import { FBXLoader } from '@/jlmap3d/main/loaders/FBXLoader';
import { OrbitControls } from '@/jlmap3d/main/control/OrbitControls';
import { ModelManager } from '@/jlmap3d/jl3ddevice/loader.js';
import { Signallightload } from '@/jlmap3d/jl3ddevice/component/signallight.js';
import { Moveanimate } from '@/jlmap3d/jl3ddevice/component/moveanimate.js';
import { Textconfig } from '@/jlmap3d/jl3ddevice/component/textconfig.js';
import StompClient from '@/utils/sock';
var clock = new THREE.Clock();
export function Jl3ddevice(dom,group,token) {
var scope = this;
this.dom = dom;
this.nowcode = null;
this.animateswitch = false;
this.signallights = [];
Signallightload(this.signallights);
this.mixers = [];
this.showmodel = null;
//新数据交互
let helpbox,textplane;
let daochamodel;
//点击事件状态
this.raycasterstatus = false;
//动画状态
this.animastats = false;
//当前选中模型
this.nowobject = null;
//当前动画播放模型
this.animationmodel = null;
this.devicetext = new Textconfig();
this.windowstatus = '0';
//初始化webgl渲染
this.renderer = new THREE.WebGLRenderer({ antialias: true });
this.renderer.setClearColor(new THREE.Color(0x000000));
this.renderer.setSize(dom.offsetWidth, dom.offsetHeight);
this.renderer.shadowMap.enabled = true;
this.renderer.shadowMap.type = THREE.PCFSoftShadowMap;
this.dom.appendChild(this.renderer.domElement);
//定义相机
this.camera = new THREE.PerspectiveCamera(70, dom.offsetWidth / dom.offsetHeight, 0.01, 120);
this.camera.position.set(0, 20, 30);
this.camera.aspect = dom.offsetWidth / dom.offsetHeight;
this.camera.updateProjectionMatrix();
//定义场景(渲染容器)
this.scene = new THREE.Scene();
this.scene.background = new THREE.Color(0xa0a0a0);
var mesh = new THREE.Mesh(new THREE.PlaneBufferGeometry(200, 200), new THREE.MeshPhongMaterial({ color: 0x999999, depthWrite: false }));
mesh.rotation.x = - Math.PI / 2;
mesh.receiveShadow = true;
this.scene.add(mesh);
var grid = new THREE.GridHelper(200, 20, 0x000000, 0x000000);
grid.material.opacity = 0.2;
grid.material.transparent = true;
this.scene.add(grid);
//定义全局光
let ambientLight = new THREE.AmbientLight(0xffffff, 1.3);
this.scene.add(ambientLight);
var spotLight = new THREE.SpotLight(0xffffff);
spotLight.position.set(-50, 60, 15);
spotLight.castShadow = true;
spotLight.shadow.mapSize.width = 1024;
spotLight.shadow.mapSize.height = 1024;
this.scene.add(spotLight);
this.controls = new THREE.OrbitControls(this.camera, dom);
this.controls.maxPolarAngle = Math.PI / 2;
this.controls.minPolarangle = Math.PI / 5;
this.controls.maxDistance = 80;
this.controls.update();
this.selectmodel = null;
let moveanima = new Moveanimate(scope);
document.addEventListener( "mousedown", onselect, false );
let teststomp = new StompClient();
let topic = '/user/topic/simulation/assistant/'+group;
// let topic = '/user/queue/simulation/jl3d/'+group;
let header = {'X-Token': token};
try {
// console.log("teststomp");
teststomp.subscribe(topic, callback, header);
} catch (error) {
console.error('websocket订阅失败');
}
function callback(Response) {
let data = JSON.parse(Response.body);
if(scope.nowcode != data.body.code){
scope.nowcode = data.body.code;
scope.selectmodel(data);
}else{
scope.updateaction(data);
}
}
window.onresize = function () {
scope.camera.aspect = scope.dom.offsetWidth / scope.dom.offsetHeight;
scope.camera.updateProjectionMatrix();
scope.renderer.setSize(scope.dom.offsetWidth, scope.dom.offsetHeight);
}
this.domresize = function(){
scope.camera.aspect = scope.dom.offsetWidth / scope.dom.offsetHeight;
scope.camera.updateProjectionMatrix();
scope.renderer.setSize(scope.dom.offsetWidth, scope.dom.offsetHeight);
}
this.anime = null;
this.modelmanager = new ModelManager();
this.modelmanager.loadpromise(Staticmodel, scope.mixers).then(function (data) {
moveanima.initlistnew(scope.modelmanager.switchmodel.mesh);
daochamodel = scope.modelmanager.switchmodel.mesh.getObjectByName("DAOCHA");
animate();
})
//循环渲染函数
function animate() {
scope.anime = requestAnimationFrame(animate);
scope.renderer.render(scope.scene, scope.camera);
scope.controls.update();
//scope.camera.lookAt(plane);
//
moveanima.animateupdate();
let delta = clock.getDelta();
if (scope.mixers) {
for (let i = 0; i < scope.mixers.length; i++) {
if (scope.mixers[i]) {
scope.mixers[i].update(delta);
}
}
}
}
this.selectmodel = function (data) {
if (scope.showmodel) {
scope.nowcode = data.body.code;
if (scope.showmodel.code != data.body.code) {
scope.scene.remove(scope.showmodel);
scope.showmodel = null
if (data.body._type == "Switch") {
scope.modelmanager.switchmodel.locateType = data.body.locateType;
scope.modelmanager.switchmodel.code = data.body.code;
scope.showmodel = scope.modelmanager.switchmodel.mesh;
scope.scene.add(scope.showmodel);
scope.devicetext.initdevicetext(scope.modelmanager.switchmodel.mesh);
scope.nowobject = scope.modelmanager.switchmodel.mesh;
updatemenulist(scope.devicetext.devicelist);
scope.raycasterstatus = true;
}else{
scope.raycasterstatus = false;
scope.nowobject = "";
updatemenulist();
}
if (data.body._type == "Signal") {
scope.modelmanager.signalmodel.code = data.body.code;
scope.showmodel = scope.modelmanager.signalmodel.mesh;
scope.scene.add(scope.showmodel);
}
if (data.body._type == "StationStand") {
scope.modelmanager.standmodel.code = data.body.code;
scope.showmodel = scope.modelmanager.standmodel.mesh;
scope.scene.add(scope.showmodel);
}
if(scope.showmodel){
scope.resetmodel();
scope.showmodel.code = data.code;
initstatus(data);
}
}
} else {
if (data.body._type == "Switch") {
scope.modelmanager.switchmodel.locateType = data.body.locateType;
scope.modelmanager.switchmodel.code = data.body.code;
scope.showmodel = scope.modelmanager.switchmodel.mesh;
scope.scene.add(scope.showmodel);
scope.devicetext.initdevicetext(scope.modelmanager.switchmodel.mesh);
scope.nowobject = scope.modelmanager.switchmodel.mesh;
updatemenulist(scope.devicetext.devicelist);
scope.raycasterstatus = true;
if (data.body.locateType == "01") {
scope.modelmanager.switchmodel.locateType = "01";
scope.modelmanager.switchmodel.action.reset();
scope.modelmanager.switchmodel.action.time = 0;
scope.modelmanager.switchmodel.action.timeScale = -1;
scope.modelmanager.switchmodel.action.play();
} else if (data.body.locateType == "02") {
scope.modelmanager.switchmodel.locateType = "02";
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();
}
}else{
scope.raycasterstatus = false;
scope.nowobject = "";
updatemenulist();
}
if (data.body._type == "Signal") {
scope.modelmanager.signalmodel.code = data.body.code;
scope.showmodel = scope.modelmanager.signalmodel.mesh;
scope.scene.add(scope.showmodel);
}
if (data.body._type == "StationStand") {
scope.modelmanager.standmodel.code = data.body.code;
scope.showmodel = scope.modelmanager.standmodel.mesh;
scope.scene.add(scope.showmodel);
}
initstatus(data);
}
}
this.updateaction = function (data) {
if (data.body._type == "Switch") {
if (data.body.code == scope.modelmanager.switchmodel.code) {
if (scope.modelmanager.switchmodel.locateType != data.body.locateType) {
if (data.body.locateType == "03" && scope.modelmanager.switchmodel.locateType == "01") {
scope.modelmanager.switchmodel.locateType = "02";
scope.modelmanager.switchmodel.action.reset();
scope.modelmanager.switchmodel.action.time = 0;
scope.modelmanager.switchmodel.action.timeScale = 1;
scope.modelmanager.switchmodel.action.play();
} else if (data.body.locateType == "03" && scope.modelmanager.switchmodel.locateType == "02") {
scope.modelmanager.switchmodel.locateType = "01";
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();
}
}
}
}
if (data.body._type == "Signal") {//从上往下红绿黄
if (data.body.code == scope.modelmanager.signalmodel.code) {
scope.modelmanager.signalmodel.status = data.body.status;
if (data.body.lightType == "01") {
if (data.body.status == "01") {
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[1].material.map = scope.signallights["black"];
scope.modelmanager.signalmodel.mesh.children[1].material.map.needsUpdate = true;
scope.modelmanager.signalmodel.mesh.children[2].material.map = scope.signallights["black"];
scope.modelmanager.signalmodel.mesh.children[2].material.map.needsUpdate = true;
}
//开放
if (data.body.status == "02") {
scope.modelmanager.signalmodel.mesh.children[0].material.map = scope.signallights["black"];
scope.modelmanager.signalmodel.mesh.children[0].material.map.needsUpdate = true;
scope.modelmanager.signalmodel.mesh.children[1].material.map = scope.signallights["black"];
scope.modelmanager.signalmodel.mesh.children[1].material.map.needsUpdate = true;
scope.modelmanager.signalmodel.mesh.children[2].material.map = scope.signallights["green"];
scope.modelmanager.signalmodel.mesh.children[2].material.map.needsUpdate = true;
}
//开放侧向
if (data.body.status == "03") {
scope.modelmanager.signalmodel.mesh.children[0].material.map = scope.signallights["black"];
scope.modelmanager.signalmodel.mesh.children[0].material.map.needsUpdate = true;
scope.modelmanager.signalmodel.mesh.children[1].material.map = scope.signallights["yellow"];
scope.modelmanager.signalmodel.mesh.children[1].material.map.needsUpdate = true;
scope.modelmanager.signalmodel.mesh.children[2].material.map = scope.signallights["black"];
scope.modelmanager.signalmodel.mesh.children[2].material.map.needsUpdate = true;
}
//引导
if (data.body.status == "04") {
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[1].material.map = scope.signallights["yellow"];
scope.modelmanager.signalmodel.mesh.children[1].material.map.needsUpdate = true;
scope.modelmanager.signalmodel.mesh.children[2].material.map = scope.signallights["black"];
scope.modelmanager.signalmodel.mesh.children[2].material.map.needsUpdate = true;
}
//封锁
if (data.body.status == "05") {
scope.modelmanager.signalmodel.mesh.children[0].material.map = scope.signallights["black"];
scope.modelmanager.signalmodel.mesh.children[0].material.map.needsUpdate = true;
scope.modelmanager.signalmodel.mesh.children[1].material.map = scope.signallights["black"];
scope.modelmanager.signalmodel.mesh.children[1].material.map.needsUpdate = true;
scope.modelmanager.signalmodel.mesh.children[2].material.map = scope.signallights["black"];
scope.modelmanager.signalmodel.mesh.children[2].material.map.needsUpdate = true;
}
//故障
if (data.body.status == "06") {
scope.modelmanager.signalmodel.mesh.children[0].material.map = scope.signallights["black"];
scope.modelmanager.signalmodel.mesh.children[0].material.map.needsUpdate = true;
scope.modelmanager.signalmodel.mesh.children[1].material.map = scope.signallights["black"];
scope.modelmanager.signalmodel.mesh.children[1].material.map.needsUpdate = true;
scope.modelmanager.signalmodel.mesh.children[2].material.map = scope.signallights["black"];
scope.modelmanager.signalmodel.mesh.children[2].material.map.needsUpdate = true;
}
} else if (data.body.lightType == "02") {
scope.modelmanager.signalmodel.mesh.children[0].material.map = scope.signallights["black"];
scope.modelmanager.signalmodel.mesh.children[0].material.map.needsUpdate = true;
scope.modelmanager.signalmodel.mesh.children[1].material.map = scope.signallights["black"];
scope.modelmanager.signalmodel.mesh.children[1].material.map.needsUpdate = true;
scope.modelmanager.signalmodel.mesh.children[2].material.map = scope.signallights["black"];
scope.modelmanager.signalmodel.mesh.children[2].material.map.needsUpdate = true;
}
}
}
if (data.body._type == "StationStand") {
if (data.body.code == scope.modelmanager.standmodel.code) {
if (data.body.screenDoorOpenStatus == "02" && scope.modelmanager.standmodel.screenDoorOpenStatus == "01") {
scope.modelmanager.standmodel.screenDoorOpenStatus = "00";
}
if (data.body.screenDoorOpenStatus == "02" && scope.modelmanager.standmodel.screenDoorOpenStatus == "00") {
scope.modelmanager.standmodel.screenDoorOpenStatus = "02";
scope.modelmanager.standmodel.action.reset();
scope.modelmanager.standmodel.action.time = 0;
scope.modelmanager.standmodel.action.timeScale = 1;
scope.modelmanager.standmodel.action.play();
}
if (data.body.screenDoorOpenStatus == "01" && scope.modelmanager.standmodel.screenDoorOpenStatus == "02") {
scope.modelmanager.standmodel.screenDoorOpenStatus = "00";
}
if (data.body.screenDoorOpenStatus == "01" && scope.modelmanager.standmodel.screenDoorOpenStatus == "00") {
scope.modelmanager.standmodel.screenDoorOpenStatus = "01";
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.
}
function initstatus(data) {
if (data.body._type == "Switch") {
if (data.body.locateType == "01") {
scope.modelmanager.switchmodel.locateType = "01";
scope.modelmanager.switchmodel.action.reset();
scope.modelmanager.switchmodel.action.time = 0;
scope.modelmanager.switchmodel.action.timeScale = -1;
scope.modelmanager.switchmodel.action.play();
} else if (data.body.locateType == "02") {
scope.modelmanager.switchmodel.locateType = "02";
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();
}
}
if (data.body._type == "Signal") {
if (data.body.lightType == "01") {
if (data.body.status == "01") {
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[1].material.map = scope.signallights["black"];
scope.modelmanager.signalmodel.mesh.children[1].material.map.needsUpdate = true;
scope.modelmanager.signalmodel.mesh.children[2].material.map = scope.signallights["black"];
scope.modelmanager.signalmodel.mesh.children[2].material.map.needsUpdate = true;
}
//开放
if (data.body.status == "02") {
scope.modelmanager.signalmodel.mesh.children[0].material.map = scope.signallights["black"];
scope.modelmanager.signalmodel.mesh.children[0].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;
scope.modelmanager.signalmodel.mesh.children[2].material.map = scope.signallights["black"];
scope.modelmanager.signalmodel.mesh.children[2].material.map.needsUpdate = true;
}
if (data.body.switchLocateType == "03") {
scope.modelmanager.signalmodel.mesh.children[0].material.map = scope.signallights["black"];
scope.modelmanager.signalmodel.mesh.children[0].material.map.needsUpdate = true;
scope.modelmanager.signalmodel.mesh.children[1].material.map = scope.signallights["black"];
scope.modelmanager.signalmodel.mesh.children[1].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;
}
//引导
if (data.body.status == "03") {
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[1].material.map = scope.signallights["black"];
scope.modelmanager.signalmodel.mesh.children[1].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;
}
//封锁
if (data.body.status == "04") {
scope.modelmanager.signalmodel.mesh.children[0].material.map = scope.signallights["black"];
scope.modelmanager.signalmodel.mesh.children[0].material.map.needsUpdate = true;
scope.modelmanager.signalmodel.mesh.children[1].material.map = scope.signallights["black"];
scope.modelmanager.signalmodel.mesh.children[1].material.map.needsUpdate = true;
scope.modelmanager.signalmodel.mesh.children[2].material.map = scope.signallights["black"];
scope.modelmanager.signalmodel.mesh.children[2].material.map.needsUpdate = true;
}
//故障
if (data.body.status == "05") {
scope.modelmanager.signalmodel.mesh.children[0].material.map = scope.signallights["black"];
scope.modelmanager.signalmodel.mesh.children[0].material.map.needsUpdate = true;
scope.modelmanager.signalmodel.mesh.children[1].material.map = scope.signallights["black"];
scope.modelmanager.signalmodel.mesh.children[1].material.map.needsUpdate = true;
scope.modelmanager.signalmodel.mesh.children[2].material.map = scope.signallights["black"];
scope.modelmanager.signalmodel.mesh.children[2].material.map.needsUpdate = true;
}
} else if (data.body.lightType == "02") {
scope.modelmanager.signalmodel.mesh.children[0].material.map = scope.signallights["black"];
scope.modelmanager.signalmodel.mesh.children[0].material.map.needsUpdate = true;
scope.modelmanager.signalmodel.mesh.children[1].material.map = scope.signallights["black"];
scope.modelmanager.signalmodel.mesh.children[1].material.map.needsUpdate = true;
scope.modelmanager.signalmodel.mesh.children[2].material.map = scope.signallights["black"];
scope.modelmanager.signalmodel.mesh.children[2].material.map.needsUpdate = true;
}
}
if (data.body._type == "StationStand") {
if (data.body.code == scope.modelmanager.standmodel.code) {
if (data.body.screenDoorOpenStatus == "02") {
scope.modelmanager.standmodel.screenDoorOpenStatus = "02";
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.body.screenDoorOpenStatus == "01") {
scope.modelmanager.standmodel.screenDoorOpenStatus = "01";
scope.modelmanager.standmodel.action.reset();
scope.modelmanager.standmodel.action.time = 0;
scope.modelmanager.standmodel.action.timeScale = -1;
scope.modelmanager.standmodel.action.play();
}
}
}
}
//设备分解、归位动画按钮
this.disperdevice1 = function(){
if(scope.nowobject.animacode){
if(moveanima.status == true){
if(scope.animastats == false){
scope.animastats = true;
moveanima.setplaylist(moveanima.animatelist[scope.nowobject.animacode+"on"],true)
} else if(scope.animastats == true){
scope.animastats = false;
moveanima.setplaylist(moveanima.animatelist[scope.nowobject.animacode+"off"],true);
}
}
}
};
this.disperdevice2 = function(){
if(scope.nowobject.animacode){
if(moveanima.status == true){
if(scope.animastats == false){
scope.animastats = true;
moveanima.setplaylist(moveanima.animatelist[scope.nowobject.animacode+"chaijie"],true);
} else if(scope.animastats == true){
scope.animastats = false;
moveanima.setplaylist(moveanima.animatelist[scope.nowobject.animacode+"fuwei"],true);
}
}
}
};
this.resetmodel = function(){
if(scope.nowobject.animacode){
scope.animastats = false;
moveanima.setplaylist(moveanima.animatelist[scope.nowobject.animacode+"fuwei"],true);
}
};
this.animationmsgshowon = function(nowobject){
scope.animationmodel = nowobject;
if(helpbox){
scope.animationmodel.helpbox = null;
scope.scene.remove( helpbox );
helpbox = undefined;
}
settext(scope.animationmodel,scope.animationmodel.position);
// console.log(scope.animationmodel);
helpbox = new THREE.BoxHelper( scope.animationmodel, 0xff0000 );
moveanima.updatehelpbox(helpbox,textplane);
// settext(intersects[0].object,intersects[0].point);
// getdevicemsg(intersects[0].object.name);
scope.scene.add( helpbox );
getdevicemsg(nowobject.name);
}
this.animationmsgshowoff = function(nowobject){
if(helpbox){
scope.animationmodel.helpbox = null;
scope.scene.remove( helpbox );
helpbox = undefined;
}
if(textplane){
scope.scene.remove(textplane);
textplane.geometry.dispose();
textplane.material.dispose();
}
scope.animationmodel = null;
}
this.updateselect = function(updata){
// console.log(updata);
if(helpbox){
scope.scene.remove( helpbox );
helpbox = null;
}
helpbox = new THREE.BoxHelper( updata.mesh, 0xff0000 );
// console.log(updata.mesh);
let point = {
x:updata.mesh.matrixWorld.elements[12],
y:updata.mesh.matrixWorld.elements[13],
z:updata.mesh.matrixWorld.elements[14]
};
settext(updata.mesh,point)
getdevicemsg(updata.mesh.name);
scope.scene.add( helpbox );
}
function getdevicemsg(selectname){
// console.log(selectname);
for(let i=0,leni=scope.devicetext.devicelist.length;i<leni;i++){
if(selectname == scope.devicetext.devicelist[i].name){
updatemsg(scope.devicetext.devicelist[i].text,scope.devicetext.devicelist[i].msg);
i=leni;
}
}
}
this.updatewindowstatus = function(nowwindowstatus){
scope.windowstatus == nowwindowstatus;
}
function onselect(event){
if(event.button == '0'){
if(scope.raycasterstatus){
//定义光线
let raycaster = new THREE.Raycaster();
//定义平面鼠标点击坐标
let mouse = new THREE.Vector2();
let getBoundingClientRect = scope.dom.getBoundingClientRect()
if(scope.windowstatus == '0'){
mouse.x = ( (event.clientX - getBoundingClientRect .left) /scope.dom.offsetWidth) * 2-1;
mouse.y = -( (event.clientY - getBoundingClientRect .top) / scope.dom.offsetHeight) * 2 + 1;
}else{
mouse.x = (event.clientX / scope.dom.offsetWidth) * 2 - 1;
mouse.y = -(event.clientY / scope.dom.offsetHeight) * 2 + 1;
}
raycaster.setFromCamera( mouse, scope.camera );
let intersects = raycaster.intersectObjects( scope.modelmanager.switchmodel.mesh.children,true);
if(helpbox){
scope.scene.remove( helpbox );
helpbox = null;
}
if(textplane){
scope.scene.remove(textplane);
textplane.geometry.dispose();
textplane.material.dispose();
}
if(intersects[0]){
if(intersects[0].object.raycastoff){
helpbox = new THREE.BoxHelper( intersects[0].object.parent, 0xff0000 );
settext(intersects[0].object.parent,intersects[0].point);
getdevicemsg(intersects[0].object.parent.name);
}else{
helpbox = new THREE.BoxHelper( intersects[0].object, 0xff0000 );
settext(intersects[0].object,intersects[0].point);
getdevicemsg(intersects[0].object.name);
}
scope.scene.add( helpbox );
}
}
}
}
function settext(intersects,point){
if(intersects.text){
let textgeometry = new THREE.PlaneBufferGeometry( 18, 12, 1 );
let textt = new THREE.CanvasTexture(getTextCanvas(intersects.text));
let textmaterial = new THREE.MeshBasicMaterial( {
side: THREE.DoubleSide,
map:textt ,transparent: true,
alphaTest:0.1
} );
if(textplane){
scope.scene.remove(textplane);
textplane.geometry.dispose();
textplane.material.dispose();
}
textplane= new THREE.Mesh( textgeometry, textmaterial );
// textplane.name = data[i].code;
textplane.position.x = point.x;
textplane.position.y = point.y+6;
textplane.position.z = point.z;
// console.log(textplane.position);
// textplane.tcode = data[i].code;
textplane.rotation.y = -Math.PI/2;
textplane.lookAt(scope.camera.position);
// scope.textlist.push(textplane);
// newmesh.children[0].add(textplane);
scope.scene.add(textplane);
textgeometry.dispose();
textmaterial.dispose();
textt.dispose();
}
}
var beauty = new Image();
beauty.src = JL3D_LOCAL_STATIC+"/texture/guide.png";
//canvas文字贴图方法
//PS:待提炼 增强功能
function getTextCanvas(text){
var canvas = document.getElementById('canvastexture');
canvas.width = 256;
canvas.height = 128;
var ctx = canvas.getContext('2d');
//var bg = canvas.createPattern(img, "no-repeat");
//ctx.fillStyle = bg;
ctx.fillRect(0, 0,256,128);
ctx.font = "20px Verdana";
ctx.fillStyle = '#FFFFFF';
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.clearRect(0,0,256,128);
//console.log(text.groupNumber);
ctx.drawImage(beauty,0,0,256, 128);
ctx.fillText("设备部件:"+text, 90,30);
// ctx.fillText("车组人员:XXX", 40,20);
// ctx.fillText("速度:XXX.XXX", 40,30);
//ctx.fillText(text.trainModel.name, width/2,height*3/4);
let data = ctx.getImageData(0, 0,256, 128);
return data;
}
this.hideswitch = function (nowswitchstatus){
if(nowswitchstatus){
scope.modelmanager.switchmodel.mesh.add(daochamodel);
}else{
scope.modelmanager.switchmodel.mesh.remove(daochamodel);
}
}
}

View File

@ -62,7 +62,6 @@ export function Jl3ddeviceNew(dom,group,token,skinCode) {
this.dom.appendChild(this.renderer.domElement); this.dom.appendChild(this.renderer.domElement);
//定义相机 //定义相机
this.camera = new THREE.PerspectiveCamera(70, dom.offsetWidth / dom.offsetHeight, 0.01, 200); this.camera = new THREE.PerspectiveCamera(70, dom.offsetWidth / dom.offsetHeight, 0.01, 200);
this.camera.position.set(0, 20, 30); this.camera.position.set(0, 20, 30);
this.camera.aspect = dom.offsetWidth / dom.offsetHeight; this.camera.aspect = dom.offsetWidth / dom.offsetHeight;
@ -87,7 +86,7 @@ export function Jl3ddeviceNew(dom,group,token,skinCode) {
let ambientLight = new THREE.AmbientLight(0xffffff, 1.3); let ambientLight = new THREE.AmbientLight(0xffffff, 1.3);
this.scene.add(ambientLight); this.scene.add(ambientLight);
//区域聚光灯
var spotLight = new THREE.SpotLight(0xececff); var spotLight = new THREE.SpotLight(0xececff);
spotLight.position.set(-50, 80, 0); spotLight.position.set(-50, 80, 0);
spotLight.castShadow = true; spotLight.castShadow = true;
@ -95,8 +94,7 @@ export function Jl3ddeviceNew(dom,group,token,skinCode) {
spotLight.shadow.mapSize.height = 2048; spotLight.shadow.mapSize.height = 2048;
this.scene.add(spotLight); this.scene.add(spotLight);
//定义轨道视角控制器
this.controls = new THREE.OrbitControls(this.camera, dom); this.controls = new THREE.OrbitControls(this.camera, dom);
this.controls.maxPolarAngle = Math.PI / 2; this.controls.maxPolarAngle = Math.PI / 2;
this.controls.minPolarangle = Math.PI / 5; this.controls.minPolarangle = Math.PI / 5;
@ -161,8 +159,8 @@ export function Jl3ddeviceNew(dom,group,token,skinCode) {
} }
} }
} }
console.log(psdVoiceStationList);
}); });
document.addEventListener( "mousedown", onselect, false ); document.addEventListener( "mousedown", onselect, false );
let teststomp = new StompClient(); let teststomp = new StompClient();
@ -176,8 +174,8 @@ export function Jl3ddeviceNew(dom,group,token,skinCode) {
} }
function callback(Response) { function callback(Response) {
let data = JSON.parse(Response.body); let data = JSON.parse(Response.body);
// }else{
if(data.type == "DeviceCtrl_3D"){ if(data.type == "DeviceCtrl_3D"){
if(data.body.code == scope.nowcode){ if(data.body.code == scope.nowcode){
scope.updateaction(data.body); scope.updateaction(data.body);
@ -207,12 +205,9 @@ export function Jl3ddeviceNew(dom,group,token,skinCode) {
location.reload(); location.reload();
}); });
} }
// }
} }
window.onresize = function () {
window.onresize = function () {
// if(scope.windowstatus){ // if(scope.windowstatus){
// changeelement.style.width = '50%'; // changeelement.style.width = '50%';
@ -225,7 +220,6 @@ export function Jl3ddeviceNew(dom,group,token,skinCode) {
scope.camera.updateProjectionMatrix(); scope.camera.updateProjectionMatrix();
scope.renderer.setSize(scope.dom.offsetWidth, scope.dom.offsetHeight); scope.renderer.setSize(scope.dom.offsetWidth, scope.dom.offsetHeight);
console.log(scope.windowstatus);
if(scope.windowstatus == "0"){ if(scope.windowstatus == "0"){
let changeelement = document.getElementById('jl3d'); let changeelement = document.getElementById('jl3d');
changeelement.style.width = '100%'; changeelement.style.width = '100%';
@ -236,22 +230,18 @@ export function Jl3ddeviceNew(dom,group,token,skinCode) {
scope.renderer.setSize(window.innerWidth, scope.dom.offsetHeight); scope.renderer.setSize(window.innerWidth, scope.dom.offsetHeight);
} }
// }
} }
this.domresize = function(){ this.domresize = function(){
scope.camera.aspect = scope.dom.offsetWidth / scope.dom.offsetHeight; scope.camera.aspect = scope.dom.offsetWidth / scope.dom.offsetHeight;
scope.camera.updateProjectionMatrix(); scope.camera.updateProjectionMatrix();
scope.renderer.setSize(scope.dom.offsetWidth, scope.dom.offsetHeight); scope.renderer.setSize(scope.dom.offsetWidth, scope.dom.offsetHeight);
} }
this.anime = null; this.anime = null;
this.modelmanager = new ModelManager(); this.modelmanager = new ModelManager();
getPublish3dMapDetail(skinCode).then(netdata => { getPublish3dMapDetail(skinCode).then(netdata => {
let netDataAssets = JSON.parse(netdata.data.assets); let netDataAssets = JSON.parse(netdata.data.assets);
@ -274,9 +264,18 @@ export function Jl3ddeviceNew(dom,group,token,skinCode) {
} }
}) })
animate(); let checkobject = setInterval(function(){
if(scope.modelmanager.switchmodel.mesh){
clearInterval(checkobject);
animate();
}
},1000);
}); });
//初始化屏蔽门贴图
function setpsdstationmap(stationlist){ function setpsdstationmap(stationlist){
for(let i=0,leni=stationlist.length;i<leni;i++){ for(let i=0,leni=stationlist.length;i<leni;i++){
psdtexturemap[stationlist[i].stands[0].code] = stationlist[i].code; psdtexturemap[stationlist[i].stands[0].code] = stationlist[i].code;
@ -293,7 +292,6 @@ export function Jl3ddeviceNew(dom,group,token,skinCode) {
scope.renderer.render(scope.scene, scope.camera); scope.renderer.render(scope.scene, scope.camera);
scope.controls.update(); scope.controls.update();
//scope.camera.lookAt(plane); //scope.camera.lookAt(plane);
//
moveanima.animateupdate(); moveanima.animateupdate();
let delta = clock.getDelta(); let delta = clock.getDelta();
if (scope.mixers) { if (scope.mixers) {
@ -303,22 +301,18 @@ export function Jl3ddeviceNew(dom,group,token,skinCode) {
} }
} }
} }
} }
//隐藏道岔
this.hideswitch = function (nowswitchstatus){ this.hideswitch = function (nowswitchstatus){
if(nowswitchstatus){ if(nowswitchstatus){
scope.modelmanager.switchmodel.mesh.add(daochamodel); scope.modelmanager.switchmodel.mesh.add(daochamodel);
}else{ }else{
scope.modelmanager.switchmodel.mesh.remove(daochamodel); scope.modelmanager.switchmodel.mesh.remove(daochamodel);
} }
} }
//选择模型
this.selectmodel = function (data) { this.selectmodel = function (data) {
scope.modelmanager // scope.modelmanager
if (scope.showmodel) { if (scope.showmodel) {
if (scope.showmodel.code != data.code) { if (scope.showmodel.code != data.code) {
@ -347,7 +341,6 @@ export function Jl3ddeviceNew(dom,group,token,skinCode) {
scope.modelmanager.signalmodel.code = data.code; scope.modelmanager.signalmodel.code = data.code;
scope.showmodel = scope.modelmanager.signalmodel.mesh; scope.showmodel = scope.modelmanager.signalmodel.mesh;
scope.scene.add(scope.showmodel); scope.scene.add(scope.showmodel);
} }
if (data._type == "Psd") { if (data._type == "Psd") {
@ -374,10 +367,15 @@ export function Jl3ddeviceNew(dom,group,token,skinCode) {
} }
} else { } else {
scope.nowcode = data.code; scope.nowcode = data.code;
if (data._type == "Switch") { if (data._type == "Switch") {
scope.modelmanager.switchmodel.normalPosition = "0"; scope.modelmanager.switchmodel.normalPosition = "0";
scope.showmodel = scope.modelmanager.switchmodel.mesh; scope.showmodel = scope.modelmanager.switchmodel.mesh;
scope.scene.add(scope.showmodel);
scope.devicetext.initdevicetext(scope.modelmanager.switchmodel.mesh);
scope.nowobject = scope.modelmanager.switchmodel.mesh;
updatemenulist(scope.devicetext.devicelist);
scope.raycasterstatus = true;
// scope.scene.add(scope.showmodel); // scope.scene.add(scope.showmodel);
if (data.normalPosition == "0") { if (data.normalPosition == "0") {
scope.modelmanager.switchmodel.normalPosition = "0"; scope.modelmanager.switchmodel.normalPosition = "0";
@ -506,7 +504,7 @@ export function Jl3ddeviceNew(dom,group,token,skinCode) {
} }
scope.animationmodel = null; scope.animationmodel = null;
} }
//根据数据切换设备样式
this.updateaction = function (data) { this.updateaction = function (data) {
if (data.type == "SWITCH") { if (data.type == "SWITCH") {
if (data.normal == "0") { if (data.normal == "0") {
@ -548,7 +546,6 @@ export function Jl3ddeviceNew(dom,group,token,skinCode) {
} }
} }
if (data.type == "PSD" || data.type == "STAND") { if (data.type == "PSD" || data.type == "STAND") {
if (data.code == scope.nowcode) { if (data.code == scope.nowcode) {
if (data.open == "1" ) { if (data.open == "1" ) {
@ -559,8 +556,6 @@ export function Jl3ddeviceNew(dom,group,token,skinCode) {
scope.modelmanager.standmodel.action.timeScale = 1; scope.modelmanager.standmodel.action.timeScale = 1;
scope.modelmanager.standmodel.action.play(); scope.modelmanager.standmodel.action.play();
console.log(data); console.log(data);
console.log();
localVoicePlay("开往"+psdVoiceStationList[data.code].finlStationName+"方向的列车进站了!"); localVoicePlay("开往"+psdVoiceStationList[data.code].finlStationName+"方向的列车进站了!");
} }
@ -596,7 +591,6 @@ export function Jl3ddeviceNew(dom,group,token,skinCode) {
scope.modelmanager.standmodel.action.play(); scope.modelmanager.standmodel.action.play();
} }
} }
this.deviceFaultOver = function (data) { this.deviceFaultOver = function (data) {
@ -669,7 +663,6 @@ export function Jl3ddeviceNew(dom,group,token,skinCode) {
scope.modelmanager.switchmodel.action.timeScale = -1; scope.modelmanager.switchmodel.action.timeScale = -1;
scope.modelmanager.switchmodel.action.play(); scope.modelmanager.switchmodel.action.play();
} }
} }
} }
@ -704,13 +697,11 @@ export function Jl3ddeviceNew(dom,group,token,skinCode) {
scope.modelmanager.signalmodel.mesh.children[2].material.map = scope.signallights["black"]; scope.modelmanager.signalmodel.mesh.children[2].material.map = scope.signallights["black"];
scope.modelmanager.signalmodel.mesh.children[2].material.map.needsUpdate = true; scope.modelmanager.signalmodel.mesh.children[2].material.map.needsUpdate = true;
} }
} }
if (data._type == "Psd") { if (data._type == "Psd") {
if (data.screenDoorOpenStatus == "0") { if (data.screenDoorOpenStatus == "0") {
scope.modelmanager.standmodel.screenDoorOpenStatus = "0"; scope.modelmanager.standmodel.screenDoorOpenStatus = "0";
scope.modelmanager.standmodel.action.reset(); scope.modelmanager.standmodel.action.reset();
scope.modelmanager.standmodel.action.time = scope.modelmanager.standmodel.action._clip.duration; scope.modelmanager.standmodel.action.time = scope.modelmanager.standmodel.action._clip.duration;
scope.modelmanager.standmodel.action.timeScale = 1; scope.modelmanager.standmodel.action.timeScale = 1;
@ -719,7 +710,6 @@ export function Jl3ddeviceNew(dom,group,token,skinCode) {
if (data.screenDoorOpenStatus == "1") { if (data.screenDoorOpenStatus == "1") {
scope.modelmanager.standmodel.screenDoorOpenStatus = "1"; scope.modelmanager.standmodel.screenDoorOpenStatus = "1";
scope.modelmanager.standmodel.action.reset(); scope.modelmanager.standmodel.action.reset();
scope.modelmanager.standmodel.action.time = 0; scope.modelmanager.standmodel.action.time = 0;
scope.modelmanager.standmodel.action.timeScale = -1; scope.modelmanager.standmodel.action.timeScale = -1;
@ -739,11 +729,12 @@ export function Jl3ddeviceNew(dom,group,token,skinCode) {
} }
} }
this.updatewindowstatus = function(nowwindowstatus){ this.updatewindowstatus = function(nowwindowstatus){
scope.windowstatus == nowwindowstatus; scope.windowstatus == nowwindowstatus;
} }
//
function onselect(event){ function onselect(event){
if(event.button == '0'){ if(event.button == '0'){
@ -764,7 +755,6 @@ export function Jl3ddeviceNew(dom,group,token,skinCode) {
raycaster.setFromCamera( mouse, scope.camera ); raycaster.setFromCamera( mouse, scope.camera );
let intersects = raycaster.intersectObjects( scope.modelmanager.switchmodel.mesh.children,true); let intersects = raycaster.intersectObjects( scope.modelmanager.switchmodel.mesh.children,true);
if(helpbox){ if(helpbox){
scope.scene.remove( helpbox ); scope.scene.remove( helpbox );
@ -776,8 +766,6 @@ export function Jl3ddeviceNew(dom,group,token,skinCode) {
textplane.material.dispose(); textplane.material.dispose();
} }
if(intersects[0]){ if(intersects[0]){
if(intersects[0].object.raycastoff){ if(intersects[0].object.raycastoff){
helpbox = new THREE.BoxHelper( intersects[0].object.parent, 0xff0000 ); helpbox = new THREE.BoxHelper( intersects[0].object.parent, 0xff0000 );
settext(intersects[0].object.parent,intersects[0].point); settext(intersects[0].object.parent,intersects[0].point);
@ -787,9 +775,7 @@ export function Jl3ddeviceNew(dom,group,token,skinCode) {
helpbox = new THREE.BoxHelper( intersects[0].object, 0xff0000 ); helpbox = new THREE.BoxHelper( intersects[0].object, 0xff0000 );
settext(intersects[0].object,intersects[0].point); settext(intersects[0].object,intersects[0].point);
getdevicemsg(intersects[0].object.name); getdevicemsg(intersects[0].object.name);
} }
scope.scene.add( helpbox ); scope.scene.add( helpbox );
} }
} }
@ -821,7 +807,6 @@ export function Jl3ddeviceNew(dom,group,token,skinCode) {
textplane.lookAt(scope.camera.position); textplane.lookAt(scope.camera.position);
// scope.textlist.push(textplane); // scope.textlist.push(textplane);
// newmesh.children[0].add(textplane); // newmesh.children[0].add(textplane);
scope.scene.add(textplane); scope.scene.add(textplane);
textgeometry.dispose(); textgeometry.dispose();
@ -834,28 +819,28 @@ export function Jl3ddeviceNew(dom,group,token,skinCode) {
//canvas文字贴图方法 //canvas文字贴图方法
//PS:待提炼 增强功能 //PS:待提炼 增强功能
function getTextCanvas(text){ function getTextCanvas(text){
var canvas = document.getElementById('canvastexture'); var canvas = document.getElementById('canvastexture');
canvas.width = 256; canvas.width = 256;
canvas.height = 128; canvas.height = 128;
var ctx = canvas.getContext('2d'); var ctx = canvas.getContext('2d');
//var bg = canvas.createPattern(img, "no-repeat"); //var bg = canvas.createPattern(img, "no-repeat");
//ctx.fillStyle = bg; //ctx.fillStyle = bg;
ctx.fillRect(0, 0,256,128); ctx.fillRect(0, 0,256,128);
ctx.font = "20px Verdana"; ctx.font = "20px Verdana";
ctx.fillStyle = '#FFFFFF'; ctx.fillStyle = '#FFFFFF';
ctx.textAlign = 'center'; ctx.textAlign = 'center';
ctx.textBaseline = 'middle'; ctx.textBaseline = 'middle';
ctx.clearRect(0,0,256,128); ctx.clearRect(0,0,256,128);
ctx.drawImage(beauty,0,0,256, 128); ctx.drawImage(beauty,0,0,256, 128);
ctx.fillText("设备部件:"+text, 90,30); ctx.fillText("设备部件:"+text, 90,30);
// ctx.fillText("车组人员:XXX", 40,20); // ctx.fillText("车组人员:XXX", 40,20);
// ctx.fillText("速度:XXX.XXX", 40,30); // ctx.fillText("速度:XXX.XXX", 40,30);
//ctx.fillText(text.trainModel.name, width/2,height*3/4); //ctx.fillText(text.trainModel.name, width/2,height*3/4);
let data = ctx.getImageData(0, 0,256, 128); let data = ctx.getImageData(0, 0,256, 128);
return data; return data;
} }
let voiceSelect; let voiceSelect;
@ -871,18 +856,16 @@ export function Jl3ddeviceNew(dom,group,token,skinCode) {
} }
function localVoicePlay(playText) { function localVoicePlay(playText) {
localVoiceCancel(); localVoiceCancel();
let toSpeak = new SpeechSynthesisUtterance(playText); let toSpeak = new SpeechSynthesisUtterance(playText);
toSpeak.rate = 0.7; toSpeak.rate = 0.7;
toSpeak.voice = voiceSelect; toSpeak.voice = voiceSelect;
window.speechSynthesis.speak(toSpeak);
}
window.speechSynthesis.speak(toSpeak);
}
function localVoiceCancel() { function localVoiceCancel() {
window.speechSynthesis.cancel(); window.speechSynthesis.cancel();
} }
} }

View File

@ -4,7 +4,6 @@ export function Standtextureload(jlmap3dedit,standTextureData){
for(let i=0,leni=standTextureData.urls.length;i<leni;i++){ for(let i=0,leni=standTextureData.urls.length;i<leni;i++){
setstationtexture(jlmap3dedit.stationtexture,standTextureData.urls[i].name,BASE_ASSET_API + standTextureData.urls[i].url); setstationtexture(jlmap3dedit.stationtexture,standTextureData.urls[i].name,BASE_ASSET_API + standTextureData.urls[i].url);
} }
} }
function settexture(materiallist,name,textureurl){ function settexture(materiallist,name,textureurl){

View File

@ -1,85 +0,0 @@
import Stomp from 'stompjs';
import { getBaseUrl } from '@/utils/baseUrl';
const BASE_API = getBaseUrl();
let baseUrl = 'http://192.168.3.6:9600';// 本地旭强
if (BASE_API == 'https://joylink.club/jlcloud') {
baseUrl = 'https://joylink.club/relay';
} else if (BASE_API == 'https://test.joylink.club/jlcloud') {
baseUrl = 'https://test.joylink.club/relay';
}
class StompClient {
constructor() {
const ws = new WebSocket(`${baseUrl}/ws-relay`.replace(/https/, 'wss').replace(/http/, 'ws'));
this.client = Stomp.over(ws);
this.client.debug = function (message) {
console.debug(message);
};
this.subscribeMap = new Map(); // 已订阅,对象{dest:'', handler:function, sub: Object}
this.connected = false;
this.onUsed = false;
}
connect() {
return new Promise((resolve, reject) => {
this.onUsed = true;
const that = this;
const header = {
login: 'relay',
passcode: 'relay'
};
this.client.connect(header,
()=>{
that.connected = true;
// 重连时需要重新订阅
that.subscribeMap.forEach((subscribe, dest) => {
that.subscribe(subscribe.dest, subscribe.handler);
});
resolve();
},
(error)=>{
console.error(error);
this.connected = false;
reject(error);
});
});
}
disconnect() {
this.onUsed = false;
this.client.disconnect();
}
subscribe(destination, handler) {
if (!this.connected) {
const that = this;
this.connect().then(() => {
that.subscribe(destination, handler);
});
} else {
const sub = this.client.subscribe(destination, handler);
this.subscribeMap.set(destination, {dest: destination, handler: handler, sub: sub});
}
}
unsubscribe(destination) {
const subscribe = this.subscribeMap.get(destination);
if (subscribe && subscribe.sub) {
subscribe.sub.unsubscribe();
} else if (subscribe) {
this.subscribeMap.delete(destination);
}
}
send(destination, body) {
if (body) {
body = JSON.stringify(body);
this.client.send(destination, {}, body);
} else {
console.error('stomp send body required');
}
}
}
export default StompClient;

View File

@ -1,43 +0,0 @@
import StompClient from '@/utils/sock';
// import { getTrainingCbtcDemon, runDiagramStart, runDiagramOver, setTrainingCbtcInitTime } from '@/api/simulation';
// import { creatSubscribe, clearSubscribe, displayTopic, screenTopic } from '@/utils/stomp';
import { getBaseUrl } from '@/utils/baseUrl'
import { getToken } from '@/utils/auth';
// 定于仿真socket接口
export function DeviceSubscribe(jlmap3d,routegroup,jsonwebwork) {
const scope = this;
this.map = null;
this.teststomp = new StompClient();
this.topic = '/user/queue/simulation/jl3d/'+routegroup;
let header = {'X-Token': getToken() };
this.updatamap = function() {
};
this.socketon = function(topic) {
try {
// console.log("teststomp");
scope.teststomp.subscribe(topic, callback, header);
} catch (error) {
console.error('websocket订阅失败');
}
};
this.socketoff = function(topic) {
scope.teststomp.unsubscribe(topic);
};
// 仿真socket接口回调函数
function callback(Response) {
}
}

View File

@ -1,147 +0,0 @@
export function Jdqcontrol(){
let scope = this;
this.devicelist = [];
this.jdqinit = function(){
}
this.jdqraycast = function(){
}
//配置继电器文字信息
this.jdqdevicelist = function(selectmodel){
if(scope.devicelist.length>0){
scope.devicelist = [];
}
for(let i=0,leni=selectmodel.children.length;i<leni;i++){
let part= {
name:selectmodel.children[i].name,
text:null,
mesh:selectmodel.children[i],
index:i,
show:true,
msg:null,
};
if(selectmodel.children[i].name == "dizuo"){
part.text = "底座";
part.msg = "安防继电器部件。";
selectmodel.children[i].text = "底座";
}
if(selectmodel.children[i].name == "cigang"){
part.text = "磁钢";
part.msg = "使继电器由于线圈中电流极性不同而具有定位和范围两种稳定状态,这两种稳定状态在线圈中电流小时候,仍能继续保持。";
selectmodel.children[i].text = "磁钢";
}
if(selectmodel.children[i].name == "Lxing"){
part.text = "L型轭铁";
part.msg = "扼铁呈L洲形,由电工纯铁板冲压成型,外表镀多层铬防护。";
selectmodel.children[i].text = "L型轭铁";
}
if(selectmodel.children[i].name == "jiaoxingxiantie"){
part.text = "角型衔铁";
part.msg = "衔铁为角型,靠蝶形钢丝卡固定在轭铁的刀刃上,动作灵活。衔铁由电工纯铁冲压成型,衔铁上铆有重锤片,以保证衔铁靠重力返回";
selectmodel.children[i].text = "角型衔铁";
}
if(selectmodel.children[i].name == "xianquan"){
part.text = "线圈";
part.msg = "线圈水平安装在铁芯上,分为前圈和后圈,之所以采用双线圈,主要是为了增强控制电路的适应性和灵活性,可根据电路需要单线圈控"+
"制、双线圈串联控制或双线圈并联控制。";
selectmodel.children[i].text = "线圈";
}
if(selectmodel.children[i].name == "zhongchuipian"){
part.text = "重锤片";
part.msg = "重锤片由薄钢板制成,其片数由接点组的多少决定,使衔铁的重量基本上满足后接点压力的需要。";
selectmodel.children[i].text = "重锤片";
}
if(selectmodel.children[i].name == "lagan"){
part.text = "拉杆";
part.msg = "拉杆有铁制的和塑料制的,衔铁通过拉杆带动接点组。";
selectmodel.children[i].text = "拉杆";
}
if(selectmodel.children[i].name == "dongjiedianzhou"){
part.text = "动接点轴";
part.msg = "动接点轴由锡磷青铜线制成。";
selectmodel.children[i].text = "动接点轴";
}
// if(selectmodel.children[i].name == "neibu"){
// part.text = "内部";
// part.msg = "";
// selectmodel.children[i].text = "内部";
// }
if(selectmodel.children[i].name == "jiedian"){
part.text = "接点";
part.msg = "具有开端功率娇小的接点能力。";
selectmodel.children[i].text = "接点";
}
if(selectmodel.children[i].name == "yapian"){
part.text = "压片";
part.msg = "压片由弹簧钢板冲压成弓形,分上、下两篇,其作用是保证接点组的稳固性。";
selectmodel.children[i].text = "压片";
}
if(selectmodel.children[i].name == "fanghuozhao"){
part.text = "防火罩";
part.msg = "保护继电器内设备运行。";
selectmodel.children[i].text = "防火罩";
}
if(selectmodel.children[i].name == "dianyuanpian"){
part.text = "电源片";
part.msg = "电源片单元由黄铜制成的电源片压在胶木内。";
selectmodel.children[i].text = "电源片";
}
if(selectmodel.children[i].name == "xinpian"){
part.text = "电路板";
part.msg = "故在电路中起着自动调节、安全保护、转换电路等作用。";
selectmodel.children[i].text = "电路板";
}
if(selectmodel.children[i].name =="jueyuanzhou"){
part.text = "绝缘轴";
part.msg = "绝缘轴用冻石瓷料制成,抗冲击强度足够。";
selectmodel.children[i].text = "绝缘轴";
}
if(selectmodel.children[i].name =="cichuihuqi"){
part.text = "磁吹弧器";
part.msg = "通过在接点开关相对位置处设置永久磁铁的技术手段,以永久磁铁的磁场作用力影响接点开关产生的电弧,使得电弧受磁场作用力加速拉长至消灭,从而成为一种遮断电弧的继电器。";
selectmodel.children[i].text = "磁吹弧器";
}
if(selectmodel.children[i].name =="jiaqiangdongjiediandanyuan"){
part.text = "加强接点单元";
part.msg = "具有开端功率较大的接点能力。";
selectmodel.children[i].text = "加强接点单元";
}
if(selectmodel.children[i].name =="yunmugehupian"){
part.text = "云母隔弧片";
part.msg = "云母隔弧片。";
selectmodel.children[i].text = "云母隔弧片";
}
if(selectmodel.children[i].name =="yapian1"){
part.text = "压片";
part.msg = "压片。";
selectmodel.children[i].text = "压片";
}
if(selectmodel.children[i].name =="jiedian1"){
part.text = "接点";
part.msg = "具有开端功率娇小的接点能力。";
selectmodel.children[i].text = "接点";
}
if(selectmodel.children[i].name =="ccichuihuqi"){
part.text = "磁吹弧器";
part.msg = "提高了继电器的可靠性。";
selectmodel.children[i].text = "磁吹弧器";
}
// if(part.text == null){
// console.log(selectmodel.children[i].name);
// }
if(part.text){
scope.devicelist.push(part);
}
}
}
}

View File

@ -1,672 +0,0 @@
export function Moveanimate(main){
let scope = this;
this.helpbox = null;
this.textplane = null;
//动画列表
this.animatelist = [];
this.playlist = null;
this.playorder = 0;
//动画播放器开关
this.enable = true;
//动画开关状态
this.status = true;
//当前动画模型
this.nowmodelname = undefined;
//定义所有继电器部件动画
// this.initlist = function(modellist){
//
// for(let j=0,lenj=modellist.length;j<lenj;j++){
//
// for(let i=0,leni=modellist[j].children.length;i<leni;i++){
//
// if(modellist[j].children[i].name == "dizuo"){
// let points1 = [];
// points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
// points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z-150));
// scope.initanimate(modellist[j].children[i],modellist[j].name+"dizuoon",points1,0.5,true,0);
// let points2 = [];
// points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z-150));
// points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
// scope.initanimate(modellist[j].children[i],modellist[j].name+"dizuooff",points2,0.5,true,0);
//
//
// }
// if(modellist[j].children[i].name == "Lxing"){
// let points1 = [];
// points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
// points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y-50,modellist[j].children[i].position.z));
// scope.initanimate(modellist[j].children[i],modellist[j].name+"Lxingon",points1,0.5,true,0);
// let points2 = [];
// points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y-50,modellist[j].children[i].position.z));
// points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
// scope.initanimate(modellist[j].children[i],modellist[j].name+"Lxingoff",points2,0.5,true,0);
// }
// if(modellist[j].children[i].name == "jiaoxingxiantie"){
// let points1 = [];
// points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
// points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z+25));
// scope.initanimate(modellist[j].children[i],modellist[j].name+"jiaoxingxiantieon",points1,0.5,true,0);
// let points2 = [];
// points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z+25));
// points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
// scope.initanimate(modellist[j].children[i],modellist[j].name+"jiaoxingxiantieoff",points2,0.5,true,0);
// }
// if(modellist[j].children[i].name == "xianquan"){
// let points1 = [];
// points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
// points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y-100,modellist[j].children[i].position.z));
// scope.initanimate(modellist[j].children[i],modellist[j].name+"xianquanon",points1,0.5,true,0);
// let points2 = [];
// points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y-100,modellist[j].children[i].position.z));
// points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
// scope.initanimate(modellist[j].children[i],modellist[j].name+"xianquanoff",points2,0.5,true,0);
// }
// if(modellist[j].children[i].name == "zhongchuipian"){
// let points1 = [];
// points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
// points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y-25,modellist[j].children[i].position.z));
// scope.initanimate(modellist[j].children[i],modellist[j].name+"zhongchuipianon",points1,0.5,true,0);
// let points2 = [];
// points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y+25,modellist[j].children[i].position.z));
// points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
// scope.initanimate(modellist[j].children[i],modellist[j].name+"zhongchuipianoff",points2,0.5,true,0);
// }
// if(modellist[j].children[i].name == "lagan"){
// let points1 = [];
// points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
// points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y+100,modellist[j].children[i].position.z+50));
// scope.initanimate(modellist[j].children[i],modellist[j].name+"laganon",points1,0.5,true,0);
// let points2 = [];
// points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y+100,modellist[j].children[i].position.z+50));
// points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
// scope.initanimate(modellist[j].children[i],modellist[j].name+"laganoff",points2,0.5,true,0);
// }
// if(modellist[j].children[i].name == "dongjiedianzhou"){
// let points1 = [];
// points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
// points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y+100,modellist[j].children[i].position.z+25));
// scope.initanimate(modellist[j].children[i],modellist[j].name+"dongjiedianzhouon",points1,0.5,true,0);
// let points2 = [];
// points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y+100,modellist[j].children[i].position.z+25));
// points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
// scope.initanimate(modellist[j].children[i],modellist[j].name+"dongjiedianzhouoff",points2,0.5,true,0);
// }
// if(modellist[j].children[i].name == "neibu"){
// let points1 = [];
// points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
// points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z-50));
// scope.initanimate(modellist[j].children[i],modellist[j].name+"neibuon",points1,0.5,true,0);
// let points2 = [];
// points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z-50));
// points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
// scope.initanimate(modellist[j].children[i],modellist[j].name+"neibuoff",points2,0.5,true,0);
// }
// if(modellist[j].children[i].name == "jiedian"){
// let points1 = [];
// points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
// points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y+100,modellist[j].children[i].position.z-15));
// scope.initanimate(modellist[j].children[i],modellist[j].name+"jiedianon",points1,0.5,true,0);
// let points2 = [];
// points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y+100,modellist[j].children[i].position.z-15));
// points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
// scope.initanimate(modellist[j].children[i],modellist[j].name+"jiedianoff",points2,0.5,true,0);
//
// }
// if(modellist[j].children[i].name == "yapian"){
// let points1 = [];
// points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
// points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y+100,modellist[j].children[i].position.z-25));
// scope.initanimate(modellist[j].children[i],modellist[j].name+"yapianon",points1,0.5,true,0);
// let points2 = [];
// points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y+100,modellist[j].children[i].position.z-25));
// points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
// scope.initanimate(modellist[j].children[i],modellist[j].name+"yapianoff",points2,0.5,true,0);
// }
// if(modellist[j].children[i].name == "fanghuozhao"){
// let points1 = [];
//
// points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
// points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z+200));
// scope.initanimate(modellist[j].children[i],modellist[j].name+"fanghuozhaoon",points1,0.5,true,0);
//
// let points2 = [];
// points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z+200));
// points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
// scope.initanimate(modellist[j].children[i],modellist[j].name+"fanghuozhaooff",points2,0.5,true,0);
// }
// if(modellist[j].children[i].name == "dianyuanpian"){
// let points1 = [];
// points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
// points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z-50));
// scope.initanimate(modellist[j].children[i],modellist[j].name+"dianyuanpianon",points1,0.5,true,0);
// let points2 = [];
// points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z-50));
// points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
// scope.initanimate(modellist[j].children[i],modellist[j].name+"dianyuanpianoff",points2,0.5,true,0);
// }
// if(modellist[j].children[i].name == "xinpian"){
// let points1 = [];
// points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
// points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y+150,modellist[j].children[i].position.z));
// scope.initanimate(modellist[j].children[i],modellist[j].name+"xinpianon",points1,0.5,true,0);
// let points2 = [];
// points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y+150,modellist[j].children[i].position.z));
// points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
// scope.initanimate(modellist[j].children[i],modellist[j].name+"xinpianoff",points2,0.5,true,0);
// }
// if(modellist[j].children[i].name =="jueyuanzhou"){
// let points1 = [];
// points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
// points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y+100,modellist[j].children[i].position.z));
// scope.initanimate(modellist[j].children[i],modellist[j].name+"jueyuanzhouon",points1,0.5,true,0);
// let points2 = [];
// points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y+100,modellist[j].children[i].position.z));
// points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
// scope.initanimate(modellist[j].children[i],modellist[j].name+"jueyuanzhouoff",points2,0.5,true,0);
// }
// if(modellist[j].children[i].name =="cigang"){
// let points1 = [];
// points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
// points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y-100,modellist[j].children[i].position.z+100));
// scope.initanimate(modellist[j].children[i],modellist[j].name+"cigangon",points1,0.5,true,0);
// let points2 = [];
// points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y-100,modellist[j].children[i].position.z+100));
// points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
// scope.initanimate(modellist[j].children[i],modellist[j].name+"cigangoff",points2,0.5,true,0);
// }
// }
//
// }
// //
//
//
//
// }
this.initlistnew = function(modellist){
for(let j=0,lenj=modellist.length;j<lenj;j++){
scope.animatelist[modellist[j].code+"chaijie"] = [];
scope.animatelist[modellist[j].code+"fuwei"] = [];
for(let i=0,leni=modellist[j].children.length;i<leni;i++){
if(modellist[j].children[i].name == "dizuo"){
let points1 = [];
points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z-150));
scope.initanimate(scope.animatelist[modellist[j].code+"chaijie"],modellist[j].children[i],modellist[j].name+"dizuoon",points1,0.5,true,0);
let points2 = [];
points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z-150));
points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
scope.initanimate(scope.animatelist[modellist[j].code+"fuwei"],modellist[j].children[i],modellist[j].name+"dizuooff",points2,0.5,true,0);
}
if(modellist[j].children[i].name == "Lxing"){
let points1 = [];
points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y-50,modellist[j].children[i].position.z));
scope.initanimate(scope.animatelist[modellist[j].code+"chaijie"],modellist[j].children[i],modellist[j].name+"Lxingon",points1,0.5,true,0);
let points2 = [];
points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y-50,modellist[j].children[i].position.z));
points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
scope.initanimate(scope.animatelist[modellist[j].code+"fuwei"],modellist[j].children[i],modellist[j].name+"Lxingoff",points2,0.5,true,0);
}
if(modellist[j].children[i].name == "jiaoxingxiantie"){
let points1 = [];
points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z+25));
scope.initanimate(scope.animatelist[modellist[j].code+"chaijie"],modellist[j].children[i],modellist[j].name+"jiaoxingxiantieon",points1,0.5,true,0);
let points2 = [];
points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z+25));
points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
scope.initanimate(scope.animatelist[modellist[j].code+"fuwei"],modellist[j].children[i],modellist[j].name+"jiaoxingxiantieoff",points2,0.5,true,0);
}
if(modellist[j].children[i].name == "xianquan"){
let points1 = [];
points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y-100,modellist[j].children[i].position.z));
scope.initanimate(scope.animatelist[modellist[j].code+"chaijie"],modellist[j].children[i],modellist[j].name+"xianquanon",points1,0.5,true,0);
let points2 = [];
points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y-100,modellist[j].children[i].position.z));
points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
scope.initanimate(scope.animatelist[modellist[j].code+"fuwei"],modellist[j].children[i],modellist[j].name+"xianquanoff",points2,0.5,true,0);
}
if(modellist[j].children[i].name == "zhongchuipian"){
let points1 = [];
points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y-25,modellist[j].children[i].position.z));
scope.initanimate(scope.animatelist[modellist[j].code+"chaijie"],modellist[j].children[i],modellist[j].name+"zhongchuipianon",points1,0.5,true,0);
let points2 = [];
points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y+25,modellist[j].children[i].position.z));
points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
scope.initanimate(scope.animatelist[modellist[j].code+"fuwei"],modellist[j].children[i],modellist[j].name+"zhongchuipianoff",points2,0.5,true,0);
}
if(modellist[j].children[i].name == "lagan"){
let points1 = [];
points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y+100,modellist[j].children[i].position.z+50));
scope.initanimate(scope.animatelist[modellist[j].code+"chaijie"],modellist[j].children[i],modellist[j].name+"laganon",points1,0.5,true,0);
let points2 = [];
points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y+100,modellist[j].children[i].position.z+50));
points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
scope.initanimate(scope.animatelist[modellist[j].code+"fuwei"],modellist[j].children[i],modellist[j].name+"laganoff",points2,0.5,true,0);
}
if(modellist[j].children[i].name == "dongjiedianzhou"){
let points1 = [];
points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y+100,modellist[j].children[i].position.z+25));
scope.initanimate(scope.animatelist[modellist[j].code+"chaijie"],modellist[j].children[i],modellist[j].name+"dongjiedianzhouon",points1,0.5,true,0);
let points2 = [];
points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y+100,modellist[j].children[i].position.z+25));
points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
scope.initanimate(scope.animatelist[modellist[j].code+"fuwei"],modellist[j].children[i],modellist[j].name+"dongjiedianzhouoff",points2,0.5,true,0);
}
if(modellist[j].children[i].name == "neibu"){
let points1 = [];
points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z-50));
scope.initanimate(scope.animatelist[modellist[j].code+"chaijie"],modellist[j].children[i],modellist[j].name+"neibuon",points1,0.5,true,0);
let points2 = [];
points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z-50));
points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
scope.initanimate(scope.animatelist[modellist[j].code+"fuwei"],modellist[j].children[i],modellist[j].name+"neibuoff",points2,0.5,true,0);
}
if(modellist[j].children[i].name == "jiedian"){
let points1 = [];
points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y+100,modellist[j].children[i].position.z-15));
scope.initanimate(scope.animatelist[modellist[j].code+"chaijie"],modellist[j].children[i],modellist[j].name+"jiedianon",points1,0.5,true,0);
let points2 = [];
points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y+100,modellist[j].children[i].position.z-15));
points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
scope.initanimate(scope.animatelist[modellist[j].code+"fuwei"],modellist[j].children[i],modellist[j].name+"jiedianoff",points2,0.5,true,0);
}
if(modellist[j].children[i].name == "yapian"){
let points1 = [];
points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y+100,modellist[j].children[i].position.z-25));
scope.initanimate(scope.animatelist[modellist[j].code+"chaijie"],modellist[j].children[i],modellist[j].name+"yapianon",points1,0.5,true,0);
let points2 = [];
points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y+100,modellist[j].children[i].position.z-25));
points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
scope.initanimate(scope.animatelist[modellist[j].code+"fuwei"],modellist[j].children[i],modellist[j].name+"yapianoff",points2,0.5,true,0);
}
if(modellist[j].children[i].name == "fanghuozhao"){
let points1 = [];
points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z+200));
scope.initanimate(scope.animatelist[modellist[j].code+"chaijie"],modellist[j].children[i],modellist[j].name+"fanghuozhaoon",points1,0.5,true,0);
let points2 = [];
points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z+200));
points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
scope.initanimate(scope.animatelist[modellist[j].code+"fuwei"],modellist[j].children[i],modellist[j].name+"fanghuozhaooff",points2,0.5,true,0);
}
if(modellist[j].children[i].name == "dianyuanpian"){
let points1 = [];
points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z-50));
scope.initanimate(scope.animatelist[modellist[j].code+"chaijie"],modellist[j].children[i],modellist[j].name+"dianyuanpianon",points1,0.5,true,0);
let points2 = [];
points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z-50));
points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
scope.initanimate(scope.animatelist[modellist[j].code+"fuwei"],modellist[j].children[i],modellist[j].name+"dianyuanpianoff",points2,0.5,true,0);
}
if(modellist[j].children[i].name == "xinpian"){
let points1 = [];
points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y+150,modellist[j].children[i].position.z));
scope.initanimate(scope.animatelist[modellist[j].code+"chaijie"],modellist[j].children[i],modellist[j].name+"xinpianon",points1,0.5,true,0);
let points2 = [];
points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y+150,modellist[j].children[i].position.z));
points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
scope.initanimate(scope.animatelist[modellist[j].code+"fuwei"],modellist[j].children[i],modellist[j].name+"xinpianoff",points2,0.5,true,0);
}
if(modellist[j].children[i].name =="jueyuanzhou"){
let points1 = [];
points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y+100,modellist[j].children[i].position.z));
scope.initanimate(scope.animatelist[modellist[j].code+"chaijie"],modellist[j].children[i],modellist[j].name+"jueyuanzhouon",points1,0.5,true,0);
let points2 = [];
points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y+100,modellist[j].children[i].position.z));
points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
scope.initanimate(scope.animatelist[modellist[j].code+"fuwei"],modellist[j].children[i],modellist[j].name+"jueyuanzhouoff",points2,0.5,true,0);
}
if(modellist[j].children[i].name =="cigang"){
let points1 = [];
points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y-100,modellist[j].children[i].position.z+100));
scope.initanimate(scope.animatelist[modellist[j].code+"chaijie"],modellist[j].children[i],modellist[j].name+"cigangon",points1,0.5,true,0);
let points2 = [];
points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y-100,modellist[j].children[i].position.z+100));
points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
scope.initanimate(scope.animatelist[modellist[j].code+"fuwei"],modellist[j].children[i],modellist[j].name+"cigangoff",points2,0.5,true,0);
}
if(modellist[j].children[i].name =="ccichuihuqi"){
let points1 = [];
points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y-50,modellist[j].children[i].position.z+100));
scope.initanimate(scope.animatelist[modellist[j].code+"chaijie"],modellist[j].children[i],modellist[j].name+"ccichuihuqion",points1,0.5,true,0);
let points2 = [];
points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y-50,modellist[j].children[i].position.z+100));
points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
scope.initanimate(scope.animatelist[modellist[j].code+"fuwei"],modellist[j].children[i],modellist[j].name+"ccichuihuqioff",points2,0.5,true,0);
}
if(modellist[j].children[i].name =="cichuihuqi"){
let points1 = [];
points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y-50,modellist[j].children[i].position.z+100));
scope.initanimate(scope.animatelist[modellist[j].code+"chaijie"],modellist[j].children[i],modellist[j].name+"cichuihuqion",points1,0.5,true,0);
let points2 = [];
points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y-50,modellist[j].children[i].position.z+100));
points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
scope.initanimate(scope.animatelist[modellist[j].code+"fuwei"],modellist[j].children[i],modellist[j].name+"cichuihuqioff",points2,0.5,true,0);
}
if(modellist[j].children[i].name =="jiaqiangdongjiediandanyuan"){
let points1 = [];
points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y+25,modellist[j].children[i].position.z+100));
scope.initanimate(scope.animatelist[modellist[j].code+"chaijie"],modellist[j].children[i],modellist[j].name+"jiaqiangdongjiediandanyuanon",points1,0.5,true,0);
let points2 = [];
points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y+25,modellist[j].children[i].position.z+100));
points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
scope.initanimate(scope.animatelist[modellist[j].code+"fuwei"],modellist[j].children[i],modellist[j].name+"jiaqiangdongjiediandanyuanoff",points2,0.5,true,0);
}
if(modellist[j].children[i].name =="yunmugehupian"){
let points1 = [];
points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
points1.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y+100,modellist[j].children[i].position.z+100));
scope.initanimate(scope.animatelist[modellist[j].code+"chaijie"],modellist[j].children[i],modellist[j].name+"yunmugehupianon",points1,0.5,true,0);
let points2 = [];
points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y+100,modellist[j].children[i].position.z+100));
points2.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
scope.initanimate(scope.animatelist[modellist[j].code+"fuwei"],modellist[j].children[i],modellist[j].name+"yunmugehupianoff",points2,0.5,true,0);
}
}
}
// let points = [];
// points.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
// points.push(new THREE.Vector3(modellist[j].children[i].position.x,modellist[j].children[i].position.y,modellist[j].children[i].position.z));
// scope.initanimate(modellist[j].children[i],modellist[j].name+"select1",points,true);
let modelorderlist = [];
modelorderlist[modellist[0].code] = [
{name:"fanghuozhao",pos:[0,0,200]},
{name:"dizuo",pos:[0,0,-150]},
{name:"dianyuanpian",pos:[0,0,-50]},
{name:"neibu",pos:[0,0,-25]},
{name:"xianquan",pos:[0,-200,0]},
{name:"Lxing",pos:[0,-150,0]},
{name:"jiaoxingxiantie",pos:[0,-100,50]},
{name:"zhongchuipian",pos:[0,-100,-50]},
{name:"jiedian",pos:[0,0,100]},
{name:"dongjiedianzhou",pos:[0,100,100]},
{name:"jueyuanzhou",pos:[0,150,50]},
{name:"lagan",pos:[0,150,0]},
{name:"yapian",pos:[0,0,25]}
];
modelorderlist[modellist[1].code] = [
{name:"fanghuozhao",pos:[0,0,200]},
{name:"dizuo",pos:[0,0,-150]},
{name:"dianyuanpian",pos:[0,0,-50]},
{name:"neibu",pos:[0,0,-25]},
{name:"xianquan",pos:[0,-200,0]},
{name:"Lxing",pos:[0,-150,0]},
{name:"jiaoxingxiantie",pos:[0,-100,50]},
{name:"zhongchuipian",pos:[0,-100,-50]},
{name:"jiedian",pos:[0,0,100]},
{name:"dongjiedianzhou",pos:[0,100,100]},
{name:"jueyuanzhou",pos:[0,150,50]},
{name:"lagan",pos:[0,150,0]},
{name:"yapian",pos:[0,0,25]}
];
modelorderlist[modellist[2].code] = [
{name:"fanghuozhao",pos:[0,0,200]},
{name:"dizuo",pos:[0,0,-150]},
{name:"dianyuanpian",pos:[0,0,-50]},
{name:"neibu",pos:[0,0,-25]},
{name:"xianquan",pos:[0,-200,0]},
{name:"Lxing",pos:[0,-150,0]},
{name:"jiaoxingxiantie",pos:[0,-100,50]},
{name:"zhongchuipian",pos:[0,-100,-50]},
{name:"jiedian",pos:[0,0,100]},
{name:"dongjiedianzhou",pos:[0,100,100]},
{name:"jueyuanzhou",pos:[0,150,50]},
{name:"lagan",pos:[0,150,0]},
{name:"yapian",pos:[0,0,25]}
];
modelorderlist[modellist[3].code] = [
{name:"fanghuozhao",pos:[0,0,200]},
{name:"dizuo",pos:[0,0,-150]},
{name:"dianyuanpian",pos:[0,0,-50]},
{name:"neibu",pos:[0,0,-25]},
{name:"xianquan",pos:[0,-200,0]},
{name:"Lxing",pos:[0,-150,0]},
{name:"jiaoxingxiantie",pos:[0,-100,50]},
{name:"zhongchuipian",pos:[0,-100,-50]},
{name:"jiedian",pos:[0,0,100]},
{name:"dongjiedianzhou",pos:[0,100,100]},
{name:"jueyuanzhou",pos:[0,150,50]},
{name:"lagan",pos:[0,150,0]},
{name:"yapian",pos:[0,0,25]}
];
modelorderlist[modellist[4].code] = [
{name:"fanghuozhao",pos:[0,0,200]},
{name:"dizuo",pos:[0,0,-150]},
{name:"dianyuanpian",pos:[0,0,-50]},
{name:"neibu",pos:[0,0,-25]},
{name:"xianquan",pos:[0,-200,0]},
{name:"Lxing",pos:[0,-150,0]},
{name:"zhongchuipian",pos:[0,-100,-50]},
{name:"jiaoxingxiantie",pos:[0,-100,50]},
{name:"jiedian",pos:[0,150,100]},
{name:"dongjiedianzhou",pos:[0,150,75]},
{name:"jueyuanzhou",pos:[0,150,50]},
{name:"yunmugehupian",pos:[0,100,100]},
{name:"jiaqiangdongjiediandanyuan",pos:[0,75,75]},
{name:"cichuihuqi",pos:[0,75,25]},
{name:"lagan",pos:[0,150,0]},
{name:"yapian1",pos:[0,0,100]},
{name:"yapian",pos:[0,0,10]}
];
modelorderlist[modellist[5].code] = [
{name:"fanghuozhao",pos:[0,0,200]},
{name:"dizuo",pos:[0,0,-150]},
{name:"dianyuanpian",pos:[0,0,-50]},
{name:"neibu",pos:[0,0,-25]},
{name:"xianquan",pos:[0,-200,0]},
{name:"cigang",pos:[0,-200,50]},
{name:"Lxing",pos:[0,-150,0]},
{name:"jiaoxingxiantie",pos:[0,-100,50]},
{name:"zhongchuipian",pos:[0,-100,-50]},
{name:"jiedian",pos:[0,0,100]},
{name:"dongjiedianzhou",pos:[0,100,100]},
{name:"jueyuanzhou",pos:[0,150,50]},
{name:"ccichuihuqi",pos:[0,-50,75]},
{name:"lagan",pos:[0,150,0]},
{name:"yapian",pos:[0,0,25]}
];
for(let j=0,lenj=modellist.length;j<lenj;j++){
scope.animatelist[modellist[j].code+"on"] = [];
scope.animatelist[modellist[j].code+"off"] = [];
for(let i=0,leni=modelorderlist[modellist[j].code].length;i<leni;i++){
let orderdata = modelorderlist[modellist[j].code];
let modelon = modellist[j].getObjectByName(orderdata[i].name);
// modelon.helpbox = undefined;
let pointson = [];
pointson.push(new THREE.Vector3(modelon.position.x,modelon.position.y,modelon.position.z));
pointson.push(new THREE.Vector3(modelon.position.x+orderdata[i].pos[0],modelon.position.y+orderdata[i].pos[1],modelon.position.z+orderdata[i].pos[2]));
let pointsoff = [];
pointsoff.push(new THREE.Vector3(modelon.position.x+orderdata[i].pos[0],modelon.position.y+orderdata[i].pos[1],modelon.position.z+orderdata[i].pos[2]));
pointsoff.push(new THREE.Vector3(modelon.position.x,modelon.position.y,modelon.position.z));
// if(i == 0){
scope.initanimate(scope.animatelist[modellist[j].code+"on"],modelon,modellist[j].code+modelon.name+"on",pointson,0.01,true,i);
scope.initanimate(scope.animatelist[modellist[j].code+"off"],modelon,modellist[j].code+modelon.name+"off",pointsoff,0.01,true,leni-i-1);
// }else if((i+1)<leni){
// scope.initanimate(modelon,modellist[j].code+modelon.name+"on",pointson,0.01,true,modellist[j].code+orderdata[i+1].name+"on");
// scope.initanimate(modelon,modellist[j].code+modelon.name+"off",pointsoff,0.01,true,modellist[j].code+orderdata[i-1].name+"off");
// }else{
// scope.initanimate(modelon,modellist[j].code+modelon.name+"on",pointson,0.01,true);
// scope.initanimate(modelon,modellist[j].code+modelon.name+"off",pointsoff,0.01,true,modellist[j].code+orderdata[i-1].name+"off");
// }
// if(modellist[j].children[i].name == "xinpian"){
// }
// if(modellist[j].children[i].name =="cigang"){
// }
}
}
}
//动画对象定义
this.initanimate = function(list,modelobject,name,points,speed,type,nextname){
let curve = new THREE.CatmullRomCurve3(points);
// curve动画轨迹
// progress动画进度
// enable当前动画开关
// speed动画速度
let animate = {
name:name,
curve:curve,
progress:0,
directchange:false,
connectmodel:modelobject,
enable:false,
status:"start",
speed:speed,
next:null
};
// list[nextname] = [];
if(list[nextname] == undefined){
list[nextname] = [];
}
list[nextname].push(animate);
if(nextname){
// list[nextname] = animate;
// animate.next = nextname;
}else{
// list.push(animate);
}
}
this.setplaylist = function(nowlist,enable){
scope.playlist = nowlist;
scope.enable = enable;
scope.playorder = 0;
for(let i=0;i<scope.playlist[scope.playorder].length;i++){
scope.playlist[scope.playorder][i].status = "start";
}
}
this.updatehelpbox = function(nowhelpbox,nowtextplane){
scope.textplane = nowtextplane;
scope.helpbox = nowhelpbox;
}
this.startstop = function(){
}
this.next = function(){
}
this.before = function(){
}
//动画播放器
this.animateupdate = function(){
// console.log(scope.animatelist);
if(scope.enable){
if(scope.playlist){
for(let i=0;i<scope.playlist[scope.playorder].length;i++){
if(scope.playlist[scope.playorder][i].status == "start"){
}
if(scope.playlist[scope.playorder][i].progress>=1){
let point = scope.playlist[scope.playorder][i].curve.getPointAt(1);
//更新模型坐标
scope.playlist[scope.playorder][i].connectmodel.position.x = point.x;
scope.playlist[scope.playorder][i].connectmodel.position.y = point.y;
scope.playlist[scope.playorder][i].connectmodel.position.z = point.z;
scope.playlist[scope.playorder][i].enable = false;
scope.playlist[scope.playorder][i].status = "end";
scope.playlist[scope.playorder][i].progress = 0;
if(i >= scope.playlist[scope.playorder].length-1){
if(scope.playorder >= scope.playlist.length-1 ){
scope.playlist = null;
scope.status = true;
scope.enable = false;
main.animationmsgshowoff();
scope.nowmodelname = undefined;
scope.playorder = null;
break;
}else{
scope.playorder += 1;
}
}
}else{
// console.log(scope.animatelist[k].connectmodel);
if(scope.nowmodelname != scope.playlist[scope.playorder][i].connectmodel.name){
scope.nowmodelname = scope.playlist[scope.playorder][i].connectmodel.name;
main.animationmsgshowon(scope.playlist[scope.playorder][i].connectmodel);
}
//根据动画进度获取动画轨迹上点
scope.status = false;
let point = scope.playlist[scope.playorder][i].curve.getPointAt(scope.playlist[scope.playorder][i].progress);
//更新模型坐标
scope.playlist[scope.playorder][i].connectmodel.position.x = point.x;
scope.playlist[scope.playorder][i].connectmodel.position.y = point.y;
scope.playlist[scope.playorder][i].connectmodel.position.z = point.z;
if(scope.helpbox){
scope.helpbox.update();
}
if(scope.textplane){
scope.textplane.position.x = scope.playlist[scope.playorder][i].connectmodel.matrixWorld.elements[12];
scope.textplane.position.y = scope.playlist[scope.playorder][i].connectmodel.matrixWorld.elements[13]+100;
scope.textplane.position.z = scope.playlist[scope.playorder][i].connectmodel.matrixWorld.elements[14];
}
//判断模型转向
if(scope.playlist[scope.playorder][i].directchange){
let tangent = scope.playlist[scope.playorder][i].curve.getPointAt(scope.playlist[scope.playorder][i].progress+0.001);
// scope.animatelist[k]
tangent = null;
}
//增加动画进度,释放点变量
scope.playlist[scope.playorder][i].progress += scope.playlist[scope.playorder][i].speed;
point = null;
}
}
}
}
}
}

View File

@ -1,73 +0,0 @@
import { getBaseUrl } from '@/utils/baseUrl';
import { JL3D_LOCAL_STATIC } from '@/api/jlmap3d/assets3d.js';
const BASE_API = getBaseUrl();
let modelurl = JL3D_LOCAL_STATIC+"/MODEL/jdq/";
// if(BASE_API == 'https://joylink.club/jlcloud'){
// modelurl = "https://joylink.club/oss/jdq/";
// }else if(BASE_API == 'https://test.joylink.club/jlcloud'){
// modelurl = "https://test.joylink.club/oss/jdq/";
// }
var Staticmodel = {
Jdq1: {
id: "1",
name: "继电器a1700",
deviceType: "jdq1700",
type: "training",
picUrl: "",
assetUrl: modelurl + "jdq1700.FBX"
},
Jdq2: {
id: "1",
name: "继电器b1700",
deviceType: "jdq1700",
type: "training",
picUrl: "",
assetUrl: modelurl + "jdq1700.FBX"
},
Jdq3: {
id: "1",
name: "继电器c1700",
deviceType: "jdq1700",
type: "training",
picUrl: "",
assetUrl: modelurl + "jdq1700.FBX"
},
Jdq4: {
id: "1",
name: "继电器h18",
deviceType: "jdq",
type: "training",
picUrl: "",
assetUrl: modelurl + "jdqh18.FBX"
},
Jdq5: {
id: "1",
name: "继电器H125",
deviceType: "jdq",
type: "training",
picUrl: "",
assetUrl: modelurl + "jdqH125.FBX"
},
Jdq6: {
id: "1",
name: "继电器135",
deviceType: "jdq",
type: "training",
picUrl: "",
assetUrl: modelurl + "jdq135.FBX"
},
Jdqg:{
id: "0",
name: "继电器柜",
deviceType: "jdqg",
type: "training",
picUrl: "",
assetUrl: modelurl + "jdqg.FBX"
}
}
export { Staticmodel }

View File

@ -1,576 +0,0 @@
import { Staticmodel } from '@/jlmap3d/jl3ddevicetrain/config.js';
import { JL3D_LOCAL_STATIC } from '@/api/jlmap3d/assets3d.js';
//loader
import { FBXLoader } from '@/jlmap3d/main/loaders/FBXLoader';
import { OrbitControls } from '@/jlmap3d/main/control/OrbitControls';
import { ModelManager } from '@/jlmap3d/jl3ddevicetrain/loader.js';
import { Moveanimate } from '@/jlmap3d/jl3ddevicetrain/component/moveanimate.js';
import { Jdqcontrol } from '@/jlmap3d/jl3ddevicetrain/component/jdqcontrol.js';
import { DragControls } from '@/jlmap3d/main/control/DragControls.js';
import StompClient from '@/jlmap3d/jl3ddevicetrain/component/StompClient.js';
// import { Signallightload } from '@/jlmap3d/jl3ddevice/component/signallight.js';
// import StompClient from '@/utils/sock';
import {Stats} from '@/jlmap3d/main/lib/stats.min.js';
var clock = new THREE.Clock();
export function Jl3ddevice(dom,serviceid) {
let scope = this;
//helpbox选中包围框
//textplane三维介绍标牌
let helpbox,textplane;
let connect = null;
this.dom = dom;
this.nowcode = null;
this.animateswitch = false;
this.mixers = [];
this.showmodel = null;
//场景状态
this.status = 0;
//动画状态
this.animastats = false;
//当前选中模型
this.selectmodel = null;
//当前动画播放模型
this.animationmodel = null;
//初始化webgl渲染
let renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize(dom.offsetWidth, dom.offsetHeight);
// renderer.shadowMap.enabled = true;
// renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.setClearColor( 0x000000, 0 );
this.dom.appendChild(renderer.domElement);
//定义相机
let camera = new THREE.PerspectiveCamera(70, dom.offsetWidth / dom.offsetHeight, 0.01, 4000);
camera.position.set(-1000, 1500, 0);
camera.aspect = dom.offsetWidth / dom.offsetHeight;
camera.updateProjectionMatrix();
//视角轨迹控制器
this.controls = new THREE.OrbitControls(camera, dom);
this.controls.enabled = true;
this.controls.target = new THREE.Vector3(500,1000,0);
this.controls.screenSpacePanning = true;
this.controls.update();
this.controls.maxDistance = 3000;
//定义场景(渲染容器)
let scene = new THREE.Scene();
var bgTexture = new THREE.TextureLoader().load(JL3D_LOCAL_STATIC+"/background/other.jpg");
scene.background = bgTexture;
//定义全局光
let ambientLight = new THREE.AmbientLight(0xffffff, 1.3);
scene.add(ambientLight);
var light = new THREE.HemisphereLight( 0xffffff, 0x444444 );
light.position.set( 0, 200, 0 );
scene.add( light );
//网格地面
// var grid = new THREE.GridHelper( 1000, 20, 0x000000, 0x000000 );
// grid.material.opacity = 0.2;
// grid.material.transparent = true;
// grid.position.x = 10000;
// scene.add( grid );
let objects = [];
let dragcontrol = new THREE.DragControls( objects, camera, scope.dom );
dragcontrol.enabled = false;
//菜单选中设备更新设备较少
this.updateselect = function(updata){
// console.log(updata);
if(helpbox){
scene.remove( helpbox );
helpbox = null;
}
helpbox = new THREE.BoxHelper( updata.mesh, 0xff0000 );
// console.log(updata.mesh);
let point = {
x:updata.mesh.matrixWorld.elements[12],
y:updata.mesh.matrixWorld.elements[13],
z:updata.mesh.matrixWorld.elements[14]
};
settext(updata.mesh,point)
getdevicemsg(updata.mesh.name);
scene.add( helpbox );
}
//返回设备选择
this.backselect = function(){
move3();
updatemenulist(scope.jdqcontrol.devicelist,"all");
scope.modelmanager.controllist[0].position.set(19,1270,-275);
scope.modelmanager.controllist[0].rotation.y = -Math.PI/2;
scope.modelmanager.controllist[0].rotation.z = -Math.PI/2;
scope.modelmanager.controllist[1].position.set(19,1270,-165);
scope.modelmanager.controllist[1].rotation.y = -Math.PI/2;
scope.modelmanager.controllist[1].rotation.z = -Math.PI/2;
scope.modelmanager.controllist[2].position.set(19,1270,-55);
scope.modelmanager.controllist[2].rotation.y = -Math.PI/2;
scope.modelmanager.controllist[2].rotation.z = -Math.PI/2;
scope.modelmanager.controllist[3].position.set(19,1270,65);
scope.modelmanager.controllist[3].rotation.y = -Math.PI/2;
scope.modelmanager.controllist[3].rotation.z = -Math.PI/2;
scope.modelmanager.controllist[4].position.set(19,1270,170);
scope.modelmanager.controllist[4].rotation.y = -Math.PI/2;
scope.modelmanager.controllist[4].rotation.z = -Math.PI/2;
scope.modelmanager.controllist[5].position.set(19,1270,280);
scope.modelmanager.controllist[5].rotation.y = -Math.PI/2;
scope.modelmanager.controllist[5].rotation.z = -Math.PI/2;
camera.position.set(-1000, 1500, 0);
scope.controls.target = new THREE.Vector3(500,1000,0);
scope.controls.update();
scope.status = '0';
if(textplane){
scene.remove(textplane);
textplane.geometry.dispose();
textplane.material.dispose();
}
scope.selectmodel = null;
scope.jdqcontrol.devicelist = [];
scope.animastats = false;
updatemsg();
};
//设备分解、归位动画按钮
this.disperdevice1 = function(){
if(scope.status == '1'){
if(moveanima.status == true){
if(scope.animastats == false){
scope.animastats = true;
move1();
} else if(scope.animastats == true){
scope.animastats = false;
move2();
}
}
}
};
this.disperdevice2 = function(){
if(scope.status == '1'){
if(moveanima.status == true){
if(scope.animastats == false){
scope.animastats = true;
moveanima.setplaylist(moveanima.animatelist[scope.selectmodel.code+"chaijie"],true);
} else if(scope.animastats == true){
scope.animastats = false;
moveanima.setplaylist(moveanima.animatelist[scope.selectmodel.code+"fuwei"],true);
}
}
}
};
// let stats = new Stats();
// dom.appendChild( stats.dom );
document.addEventListener( "mousedown", onselect, false );
document.addEventListener( "mouseup", onmouseup, false );
document.addEventListener( "touchstart", ontouch, false );
window.onresize = function () {
camera.aspect = scope.dom.offsetWidth / scope.dom.offsetHeight;
camera.updateProjectionMatrix();
renderer.setSize(scope.dom.offsetWidth, scope.dom.offsetHeight);
}
this.jdqcontrol = new Jdqcontrol();
let moveanima = new Moveanimate(scope);
this.anime = null;
this.modelmanager = new ModelManager();
this.modelmanager.loadpromise(Staticmodel, scope.mixers,scene).then(function (data) {
moveanima.initlistnew( scope.modelmanager.controllist);
connect = new StompClient();
// debugger
connect.subscribe("/queue/simulation/"+serviceid,callback);
animate();
});
this.sendmsg = function (type,index){
// console.log(index);
let msg = {
// deskId:serviceid,
id:index+1,
on:null
};
if(type == "0"){
msg.on = true;
}
if(type == "1"){
msg.on = false;
}
//"/app/topic/relay/"+msg.id+"/control/"+msg.on
connect.send("/app/topic/simulation/"+serviceid+"/relay/"+msg.id+"/control/"+msg.on,{});
}
this.upmodelaction = function(type,index){
if(type == "0"){
scope.modelmanager.actionlist[index].reset();
scope.modelmanager.actionlist[index].time = 0;
scope.modelmanager.actionlist[index].timeScale = 1;
scope.modelmanager.actionlist[index].play();
}
if(type == "1"){
scope.modelmanager.actionlist[index].reset();
scope.modelmanager.actionlist[index].time = scope.modelmanager.actionlist[index]._clip.duration;
scope.modelmanager.actionlist[index].timeScale = -1;
scope.modelmanager.actionlist[index].play();
}
};
this.buttoncontrol = function(action){
if("startstop"){
moveanima.startstop();
}
if("next"){
moveanima.next();
}
if("before"){
moveanima.before();
}
};
this.resetmodel = function(){
moveanima.setplaylist(moveanima.animatelist[scope.selectmodel.code+"fuwei"],true);
};
//循环渲染函数
let delta;
let data;
function callback(Response){
// console.log(Response);
data = JSON.parse(Response.body);
// console.log(data);
upjdqstats(data);
}
function animate() {
scope.anime = requestAnimationFrame(animate);
renderer.render(scene, camera);
moveanima.animateupdate();
// scope.controls.update();
// stats.update();
delta = clock.getDelta();
if(textplane){
textplane.lookAt(camera.position);
}
if (scope.mixers) {
for (let i = 0; i < scope.mixers.length; i++) {
if (scope.mixers[i]._actions[0].isRunning()) {
scope.mixers[i].update(delta);
}
}
}
}
function move1(){
moveanima.setplaylist(moveanima.animatelist[scope.selectmodel.code+"on"],true);
}
function move2(){
if(scope.selectmodel){
moveanima.setplaylist(moveanima.animatelist[scope.selectmodel.code+"off"],true);
}
}
function move3(){
if(scope.selectmodel){
moveanima.setplaylist(moveanima.animatelist[scope.selectmodel.code+"fuwei"],true);
}
}
function ontouch(event){
if(scope.status == '0'){
let raycaster = new THREE.Raycaster();
//定义平面鼠标点击坐标
let mouse = new THREE.Vector2();
mouse.x = (event.touches[0].pageX / dom.offsetWidth) * 2 - 1;
mouse.y = -(event.touches[0].pageY / dom.offsetHeight) * 2 + 1;
raycaster.setFromCamera( mouse, camera );
for(let i=0,leni=scope.modelmanager.controllist.length;i<leni;i++){
let intersects = raycaster.intersectObjects( scope.modelmanager.controllist[i].children,true);
if(intersects[0]){
scope.modelmanager.controllist[i].position.set(10000,0,0);
scope.modelmanager.controllist[i].rotation.y = 0;
scope.modelmanager.controllist[i].rotation.z = 0;
camera.position.set(10800, 500, 0);
scope.controls.target = new THREE.Vector3(10000,0,0);
scope.jdqcontrol.jdqdevicelist(scope.modelmanager.controllist[i]);
updatemenulist(scope.jdqcontrol.devicelist,scope.modelmanager.controllist[i].code);
scope.controls.update();
scope.selectmodel = scope.modelmanager.controllist[i];
scope.status = '1';
}
}
}
if(scope.status == '1'){
//定义光线
let raycaster = new THREE.Raycaster();
//定义平面鼠标点击坐标
let mouse = new THREE.Vector2();
mouse.x = (event.touches[0].pageX / dom.offsetWidth) * 2 - 1;
mouse.y = -(event.touches[0].pageY / dom.offsetHeight) * 2 + 1;
raycaster.setFromCamera( mouse, camera );
let intersects = raycaster.intersectObjects( scope.modelmanager.controllist,true);
if(helpbox){
scene.remove( helpbox );
helpbox = null;
}
if(textplane){
scene.remove(textplane);
textplane.geometry.dispose();
textplane.material.dispose();
}
if(intersects[0]){
if(intersects[0].object.raycastoff){
helpbox = new THREE.BoxHelper( intersects[0].object.parent, 0xff0000 );
settext(intersects[0].object.parent,intersects[0].point);
getdevicemsg(intersects[0].object.parent.name);
}else{
helpbox = new THREE.BoxHelper( intersects[0].object, 0xff0000 );
settext(intersects[0].object,intersects[0].point);
getdevicemsg(intersects[0].object.name);
}
scene.add( helpbox );
}
}
}
function onselect(event){
if(event.button == '0'){
if(scope.status == '0'){
let raycaster = new THREE.Raycaster();
//定义平面鼠标点击坐标
let mouse = new THREE.Vector2();
mouse.x = (event.clientX / dom.offsetWidth) * 2 - 1;
mouse.y = -(event.clientY / dom.offsetHeight) * 2 + 1;
raycaster.setFromCamera( mouse, camera );
for(let i=0,leni=scope.modelmanager.controllist.length;i<leni;i++){
let intersects = raycaster.intersectObjects( scope.modelmanager.controllist[i].children,true);
if(intersects[0]){
scope.modelmanager.controllist[i].position.set(10000,0,0);
scope.modelmanager.controllist[i].rotation.y = 0;
scope.modelmanager.controllist[i].rotation.z = 0;
camera.position.set(10800, 500, 0);
scope.controls.target = new THREE.Vector3(10000,0,0);
scope.jdqcontrol.jdqdevicelist(scope.modelmanager.controllist[i]);
updatemenulist(scope.jdqcontrol.devicelist,scope.modelmanager.controllist[i].code);
scope.controls.update();
scope.selectmodel = scope.modelmanager.controllist[i];
scope.status = '1';
i = scope.modelmanager.controllist.length;
}
}
}
if(scope.status == '1'){
//定义光线
let raycaster = new THREE.Raycaster();
//定义平面鼠标点击坐标
let mouse = new THREE.Vector2();
mouse.x = (event.clientX / dom.offsetWidth) * 2 - 1;
mouse.y = -(event.clientY / dom.offsetHeight) * 2 + 1;
raycaster.setFromCamera( mouse, camera );
let intersects = raycaster.intersectObjects( scope.modelmanager.controllist,true);
if(helpbox){
scene.remove( helpbox );
helpbox = null;
}
if(textplane){
scene.remove(textplane);
textplane.geometry.dispose();
textplane.material.dispose();
}
if(intersects[0]){
dragcontrol.setObjects(intersects[0].object);
if(intersects[0].object.raycastoff){
helpbox = new THREE.BoxHelper( intersects[0].object.parent, 0xff0000 );
settext(intersects[0].object.parent,intersects[0].point);
getdevicemsg(intersects[0].object.parent.name);
}else{
helpbox = new THREE.BoxHelper( intersects[0].object, 0xff0000 );
settext(intersects[0].object,intersects[0].point);
getdevicemsg(intersects[0].object.name);
}
scope.controls.enabled = false;
dragcontrol.enabled = true;
scene.add( helpbox );
}
}
}
}
function onmouseup(event){
// event.preventDefault();
scope.controls.enabled = true;
dragcontrol.enabled = false;
//
// dragcontrol.setObjects(null);
// document.removeEventListener("mouseup", onmouseup, false );
}
this.animationmsgshowon = function(nowobject){
scope.animationmodel = nowobject;
if(helpbox){
scope.animationmodel.helpbox = null;
scene.remove( helpbox );
helpbox = undefined;
}
settext(scope.animationmodel,scope.animationmodel.position);
// console.log(scope.animationmodel);
helpbox = new THREE.BoxHelper( scope.animationmodel, 0xff0000 );
moveanima.updatehelpbox(helpbox,textplane);
// settext(intersects[0].object,intersects[0].point);
// getdevicemsg(intersects[0].object.name);
scene.add( helpbox );
getdevicemsg(nowobject.name);
}
this.animationmsgshowoff = function(nowobject){
if(helpbox){
scope.animationmodel.helpbox = null;
scene.remove( helpbox );
helpbox = undefined;
}
if(textplane){
scene.remove(textplane);
textplane.geometry.dispose();
textplane.material.dispose();
}
scope.animationmodel = null;
}
function getdevicemsg(selectname){
// console.log(selectname);
for(let i=0,leni=scope.jdqcontrol.devicelist.length;i<leni;i++){
if(selectname == scope.jdqcontrol.devicelist[i].name){
updatemsg(scope.jdqcontrol.devicelist[i].text,scope.jdqcontrol.devicelist[i].msg);
i=leni;
}
}
}
function settext(intersects,point){
if(scope.status == '1'){
if(intersects.text){
let textgeometry = new THREE.PlaneBufferGeometry( 300, 200, 1 );
let textt = new THREE.CanvasTexture(getTextCanvas(intersects.text));
let textmaterial = new THREE.MeshBasicMaterial( {
side: THREE.DoubleSide,
map:textt ,transparent: true,
alphaTest:0.1
} );
if(textplane){
scene.remove(textplane);
textplane.geometry.dispose();
textplane.material.dispose();
}
textplane= new THREE.Mesh( textgeometry, textmaterial );
// textplane.name = data[i].code;
textplane.position.x = point.x;
textplane.position.y = point.y+100;
textplane.position.z = point.z;
// console.log(textplane.position);
// textplane.tcode = data[i].code;
textplane.rotation.y = -Math.PI/2;
textplane.lookAt(camera.position);
// scope.textlist.push(textplane);
// newmesh.children[0].add(textplane);
scene.add(textplane);
textgeometry.dispose();
textmaterial.dispose();
textt.dispose();
}
}
}
var beauty = new Image();
beauty.src = JL3D_LOCAL_STATIC+"/texture/guide.png";
//canvas文字贴图方法
//PS:待提炼 增强功能
function getTextCanvas(text){
if(scope.status == '1'){
var canvas = document.getElementById('canvastexture');
canvas.width = 256;
canvas.height = 128;
var ctx = canvas.getContext('2d');
//var bg = canvas.createPattern(img, "no-repeat");
//ctx.fillStyle = bg;
ctx.fillRect(0, 0,256,128);
ctx.font = "20px Verdana";
ctx.fillStyle = '#FFFFFF';
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.clearRect(0,0,256,128);
//console.log(text.groupNumber);
ctx.drawImage(beauty,0,0,256, 128);
ctx.fillText("设备部件:"+text, 90,30);
// ctx.fillText("车组人员:XXX", 40,20);
// ctx.fillText("速度:XXX.XXX", 40,30);
//ctx.fillText(text.trainModel.name, width/2,height*3/4);
let data = ctx.getImageData(0, 0,256, 128);
return data;
}
}
}

View File

@ -1,571 +0,0 @@
import { Staticmodel } from '@/jlmap3d/jl3ddevicetrain/config.js';
import { JL3D_LOCAL_STATIC } from '@/api/jlmap3d/assets3d.js';
//loader
import { FBXLoader } from '@/jlmap3d/main/loaders/FBXLoader';
import { OrbitControls } from '@/jlmap3d/main/control/OrbitControls';
import { ModelManager } from '@/jlmap3d/jl3ddevicetrain/loader.js';
import { Moveanimate } from '@/jlmap3d/jl3ddevicetrain/component/moveanimate.js';
import { Jdqcontrol } from '@/jlmap3d/jl3ddevicetrain/component/jdqcontrol.js';
import StompClient from '@/jlmap3d/jl3ddevicetrain/component/StompClient.js';
// import { Signallightload } from '@/jlmap3d/jl3ddevice/component/signallight.js';
// import StompClient from '@/utils/sock';
import {Stats} from '@/jlmap3d/main/lib/stats.min.js';
var clock = new THREE.Clock();
export function Jl3ddevice(dom,serviceid) {
let scope = this;
//helpbox选中包围框
//textplane三维介绍标牌
let helpbox,textplane;
let connect = null;
this.dom = dom;
this.nowcode = null;
this.animateswitch = false;
this.mixers = [];
this.showmodel = null;
//场景状态
this.status = 0;
//动画状态
this.animastats = false;
//当前选中模型
this.selectmodel = null;
//初始化webgl渲染
let renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize(dom.offsetWidth, dom.offsetHeight);
// renderer.shadowMap.enabled = true;
// renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.setClearColor( 0x000000, 0 );
this.dom.appendChild(renderer.domElement);
//定义相机
let camera = new THREE.PerspectiveCamera(70, dom.offsetWidth / dom.offsetHeight, 0.01, 5000);
camera.position.set(-1000, 1500, 0);
camera.aspect = dom.offsetWidth / dom.offsetHeight;
camera.updateProjectionMatrix();
//视角轨迹控制器
this.controls = new THREE.OrbitControls(camera, dom);
this.controls.target = new THREE.Vector3(500,1000,0);
this.controls.screenSpacePanning = true;
this.controls.update();
//定义场景(渲染容器)
let scene = new THREE.Scene();
var bgTexture = new THREE.TextureLoader().load(JL3D_LOCAL_STATIC+"/background/other.jpg");
scene.background = bgTexture;
//定义全局光
let ambientLight = new THREE.AmbientLight(0xffffff, 1.3);
scene.add(ambientLight);
var light = new THREE.HemisphereLight( 0xffffff, 0x444444 );
light.position.set( 0, 200, 0 );
scene.add( light );
//网格地面
// var grid = new THREE.GridHelper( 1000, 20, 0x000000, 0x000000 );
// grid.material.opacity = 0.2;
// grid.material.transparent = true;
// grid.position.x = 10000;
// scene.add( grid );
//菜单选中设备更新设备较少
this.updateselect = function(updata){
// console.log(updata);
if(helpbox){
scene.remove( helpbox );
helpbox = null;
}
helpbox = new THREE.BoxHelper( updata.mesh, 0xff0000 );
// console.log(updata.mesh);
let point = {
x:updata.mesh.matrixWorld.elements[12],
y:updata.mesh.matrixWorld.elements[13],
z:updata.mesh.matrixWorld.elements[14]
};
settext(updata.mesh,point)
getdevicemsg(updata.mesh.name);
// moveanima.animatelist[scope.selectmodel.name+"select1"].enable = true;
// console.log(intersects[0].object);
scene.add( helpbox );
}
//返回设备选择
this.backselect = function(){
move2();
updatemenulist(scope.jdqcontrol.devicelist);
scope.modelmanager.controllist[0].position.set(19,1270,-275);
scope.modelmanager.controllist[0].rotation.y = -Math.PI/2;
scope.modelmanager.controllist[0].rotation.z = -Math.PI/2;
scope.modelmanager.controllist[1].position.set(19,1270,-165);
scope.modelmanager.controllist[1].rotation.y = -Math.PI/2;
scope.modelmanager.controllist[1].rotation.z = -Math.PI/2;
scope.modelmanager.controllist[2].position.set(19,1270,-55);
scope.modelmanager.controllist[2].rotation.y = -Math.PI/2;
scope.modelmanager.controllist[2].rotation.z = -Math.PI/2;
scope.modelmanager.controllist[3].position.set(19,1270,65);
scope.modelmanager.controllist[3].rotation.y = -Math.PI/2;
scope.modelmanager.controllist[3].rotation.z = -Math.PI/2;
scope.modelmanager.controllist[4].position.set(19,1270,170);
scope.modelmanager.controllist[4].rotation.y = -Math.PI/2;
scope.modelmanager.controllist[4].rotation.z = -Math.PI/2;
scope.modelmanager.controllist[5].position.set(19,1270,280);
scope.modelmanager.controllist[5].rotation.y = -Math.PI/2;
scope.modelmanager.controllist[5].rotation.z = -Math.PI/2;
camera.position.set(-1000, 1500, 0);
scope.controls.target = new THREE.Vector3(500,1000,0);
scope.controls.update();
scope.status = '0';
if(textplane){
scene.remove(textplane);
textplane.geometry.dispose();
textplane.material.dispose();
}
scope.selectmodel = null;
scope.jdqcontrol.devicelist = [];
scope.animastats = false;
updatemsg();
};
//设备分解、归位动画按钮
this.disperdevice = function(){
if(scope.status == '1'){
if(moveanima.status == true){
if(scope.animastats == false){
scope.animastats = true;
move1();
} else if(scope.animastats == true){
scope.animastats = false;
move2();
}
}
}
};
// let stats = new Stats();
// dom.appendChild( stats.dom );
document.addEventListener( "mousedown", onselect, false );
document.addEventListener( "touchstart", ontouch, false );
window.onresize = function () {
camera.aspect = scope.dom.offsetWidth / scope.dom.offsetHeight;
camera.updateProjectionMatrix();
renderer.setSize(scope.dom.offsetWidth, scope.dom.offsetHeight);
}
this.jdqcontrol = new Jdqcontrol();
let moveanima = new Moveanimate(scope);
this.anime = null;
this.modelmanager = new ModelManager();
this.modelmanager.loadpromise(Staticmodel, scope.mixers,scene).then(function (data) {
moveanima.initlistnew( scope.modelmanager.controllist);
connect = new StompClient();
// debugger
connect.subscribe("/queue/simulation/"+serviceid,callback);
animate();
});
this.sendmsg = function (type,index){
// console.log(index);
let msg = {
// deskId:serviceid,
id:index+1,
on:null
};
if(type == "0"){
msg.on = true;
}
if(type == "1"){
msg.on = false;
}
//"/app/topic/relay/"+msg.id+"/control/"+msg.on
connect.send("/app/topic/simulation/"+serviceid+"/relay/"+msg.id+"/control/"+msg.on,{});
}
this.upmodelaction = function(type,index){
if(type == "0"){
scope.modelmanager.actionlist[index].reset();
scope.modelmanager.actionlist[index].time = 0;
scope.modelmanager.actionlist[index].timeScale = 1;
scope.modelmanager.actionlist[index].play();
}
if(type == "1"){
scope.modelmanager.actionlist[index].reset();
scope.modelmanager.actionlist[index].time = scope.modelmanager.actionlist[index]._clip.duration;
scope.modelmanager.actionlist[index].timeScale = -1;
scope.modelmanager.actionlist[index].play();
}
};
//循环渲染函数
let delta;
let data;
function callback(Response){
// console.log(Response);
data = JSON.parse(Response.body);
// console.log(data);
upjdqstats(data);
}
function animate() {
scope.anime = requestAnimationFrame(animate);
renderer.render(scene, camera);
moveanima.animateupdate();
// scope.controls.update();
// stats.update();
delta = clock.getDelta();
if (scope.mixers) {
for (let i = 0; i < scope.mixers.length; i++) {
if (scope.mixers[i]._actions[0].isRunning()) {
scope.mixers[i].update(delta);
}
}
}
}
function move1(){
console.log(scope.selectmodel);
moveanima.animatelist[scope.selectmodel.code+"fanghuozhao"+"on"].enable = true;
// for(let i=0,leni=scope.selectmodel.children.length;i<leni;i++){
//
// if(scope.selectmodel.children[i].name == "dizuo"){
// moveanima.animatelist[scope.selectmodel.name+"dizuoon"].enable = true;
// }
// if(scope.selectmodel.children[i].name == "Lxing"){
// moveanima.animatelist[scope.selectmodel.name+"Lxingon"].enable = true;
// }
// if(scope.selectmodel.children[i].name == "jiaoxingxiantie"){
// moveanima.animatelist[scope.selectmodel.name+"jiaoxingxiantieon"].enable = true;
// }
// if(scope.selectmodel.children[i].name == "xianquan"){
// moveanima.animatelist[scope.selectmodel.name+"xianquanon"].enable = true;
// }
// if(scope.selectmodel.children[i].name == "zhongchuipian"){
// moveanima.animatelist[scope.selectmodel.name+"zhongchuipianon"].enable = true;
// }
// if(scope.selectmodel.children[i].name == "lagan"){
// moveanima.animatelist[scope.selectmodel.name+"laganon"].enable = true;
// }
// if(scope.selectmodel.children[i].name == "dongjiedianzhou"){
// moveanima.animatelist[scope.selectmodel.name+"dongjiedianzhouon"].enable = true;
// }
// if(scope.selectmodel.children[i].name == "neibu"){
// moveanima.animatelist[scope.selectmodel.name+"neibuon"].enable = true;
// }
// if(scope.selectmodel.children[i].name == "jiedian"){
// moveanima.animatelist[scope.selectmodel.name+"jiedianon"].enable = true;
// }
// if(scope.selectmodel.children[i].name == "yapian"){
// moveanima.animatelist[scope.selectmodel.name+"yapianon"].enable = true;
// }
// if(scope.selectmodel.children[i].name == "fanghuozhao"){
// moveanima.animatelist[scope.selectmodel.name+"fanghuozhaoon"].enable = true;
// }
// if(scope.selectmodel.children[i].name == "dianyuanpian"){
// moveanima.animatelist[scope.selectmodel.name+"dianyuanpianon"].enable = true;
// }
// if(scope.selectmodel.children[i].name == "xinpian"){
// moveanima.animatelist[scope.selectmodel.name+"xinpianon"].enable = true;
// }
// if(scope.selectmodel.children[i].name =="jueyuanzhou"){
// moveanima.animatelist[scope.selectmodel.name+"jueyuanzhouon"].enable = true;
// }
// if(scope.selectmodel.children[i].name =="cigang"){
// moveanima.animatelist[scope.selectmodel.name+"cigangon"].enable = true;
// }
// }
}
function move2(){
if(scope.selectmodel){
moveanima.animatelist[scope.selectmodel.code+"yapian"+"off"].enable = true;
// for(let i=0,leni=scope.selectmodel.children.length;i<leni;i++){
//
// if(scope.selectmodel.children[i].name == "dizuo"){
// moveanima.animatelist[scope.selectmodel.name+"dizuooff"].enable = true;
// }
// if(scope.selectmodel.children[i].name == "Lxing"){
// moveanima.animatelist[scope.selectmodel.name+"Lxingoff"].enable = true;
// }
// if(scope.selectmodel.children[i].name == "jiaoxingxiantie"){
// moveanima.animatelist[scope.selectmodel.name+"jiaoxingxiantieoff"].enable = true;
// }
// if(scope.selectmodel.children[i].name == "xianquan"){
// moveanima.animatelist[scope.selectmodel.name+"xianquanoff"].enable = true;
// }
// if(scope.selectmodel.children[i].name == "zhongchuipian"){
// moveanima.animatelist[scope.selectmodel.name+"zhongchuipianoff"].enable = true;
// }
// if(scope.selectmodel.children[i].name == "lagan"){
// moveanima.animatelist[scope.selectmodel.name+"laganoff"].enable = true;
// }
// if(scope.selectmodel.children[i].name == "dongjiedianzhou"){
// moveanima.animatelist[scope.selectmodel.name+"dongjiedianzhouoff"].enable = true;
// }
// if(scope.selectmodel.children[i].name == "neibu"){
// moveanima.animatelist[scope.selectmodel.name+"neibuoff"].enable = true;
// }
// if(scope.selectmodel.children[i].name == "jiedian"){
// moveanima.animatelist[scope.selectmodel.name+"jiedianoff"].enable = true;
// }
// if(scope.selectmodel.children[i].name == "yapian"){
// moveanima.animatelist[scope.selectmodel.name+"yapianoff"].enable = true;
// }
// if(scope.selectmodel.children[i].name == "fanghuozhao"){
// moveanima.animatelist[scope.selectmodel.name+"fanghuozhaooff"].enable = true;
// }
// if(scope.selectmodel.children[i].name == "dianyuanpian"){
// moveanima.animatelist[scope.selectmodel.name+"dianyuanpianoff"].enable = true;
// }
// if(scope.selectmodel.children[i].name == "xinpian"){
// moveanima.animatelist[scope.selectmodel.name+"xinpianoff"].enable = true;
// }
// if(scope.selectmodel.children[i].name =="jueyuanzhou"){
// moveanima.animatelist[scope.selectmodel.name+"jueyuanzhouoff"].enable = true;
// }
// if(scope.selectmodel.children[i].name =="cigang"){
// moveanima.animatelist[scope.selectmodel.name+"cigangoff"].enable = true;
// }
// }
}
}
function ontouch(event){
if(scope.status == '0'){
let raycaster = new THREE.Raycaster();
//定义平面鼠标点击坐标
let mouse = new THREE.Vector2();
mouse.x = (event.touches[0].pageX / dom.offsetWidth) * 2 - 1;
mouse.y = -(event.touches[0].pageY / dom.offsetHeight) * 2 + 1;
raycaster.setFromCamera( mouse, camera );
for(let i=0,leni=scope.modelmanager.controllist.length;i<leni;i++){
let intersects = raycaster.intersectObjects( scope.modelmanager.controllist[i].children,true);
if(intersects[0]){
scope.modelmanager.controllist[i].position.set(10000,0,0);
scope.modelmanager.controllist[i].rotation.y = 0;
scope.modelmanager.controllist[i].rotation.z = 0;
camera.position.set(10800, 500, 0);
scope.controls.target = new THREE.Vector3(10000,0,0);
scope.jdqcontrol.jdqdevicelist(scope.modelmanager.controllist[i]);
updatemenulist(scope.jdqcontrol.devicelist);
scope.controls.update();
scope.selectmodel = scope.modelmanager.controllist[i];
scope.status = '1';
}
}
}
if(scope.status == '1'){
//定义光线
let raycaster = new THREE.Raycaster();
//定义平面鼠标点击坐标
let mouse = new THREE.Vector2();
mouse.x = (event.touches[0].pageX / dom.offsetWidth) * 2 - 1;
mouse.y = -(event.touches[0].pageY / dom.offsetHeight) * 2 + 1;
raycaster.setFromCamera( mouse, camera );
let intersects = raycaster.intersectObjects( scope.modelmanager.controllist,true);
if(helpbox){
scene.remove( helpbox );
helpbox = null;
}
if(textplane){
scene.remove(textplane);
textplane.geometry.dispose();
textplane.material.dispose();
}
if(intersects[0]){
if(intersects[0].object.raycastoff){
helpbox = new THREE.BoxHelper( intersects[0].object.parent, 0xff0000 );
settext(intersects[0].object.parent,intersects[0].point);
getdevicemsg(intersects[0].object.parent.name);
}else{
helpbox = new THREE.BoxHelper( intersects[0].object, 0xff0000 );
settext(intersects[0].object,intersects[0].point);
getdevicemsg(intersects[0].object.name);
}
scene.add( helpbox );
}
}
}
function onselect(event){
if(event.button == '0'){
if(scope.status == '0'){
let raycaster = new THREE.Raycaster();
//定义平面鼠标点击坐标
let mouse = new THREE.Vector2();
mouse.x = (event.clientX / dom.offsetWidth) * 2 - 1;
mouse.y = -(event.clientY / dom.offsetHeight) * 2 + 1;
raycaster.setFromCamera( mouse, camera );
for(let i=0,leni=scope.modelmanager.controllist.length;i<leni;i++){
let intersects = raycaster.intersectObjects( scope.modelmanager.controllist[i].children,true);
if(intersects[0]){
scope.modelmanager.controllist[i].position.set(10000,0,0);
scope.modelmanager.controllist[i].rotation.y = 0;
scope.modelmanager.controllist[i].rotation.z = 0;
camera.position.set(10800, 500, 0);
scope.controls.target = new THREE.Vector3(10000,0,0);
scope.jdqcontrol.jdqdevicelist(scope.modelmanager.controllist[i]);
updatemenulist(scope.jdqcontrol.devicelist);
scope.controls.update();
scope.selectmodel = scope.modelmanager.controllist[i];
scope.status = '1';
i = scope.modelmanager.controllist.length;
}
}
}
if(scope.status == '1'){
//定义光线
let raycaster = new THREE.Raycaster();
//定义平面鼠标点击坐标
let mouse = new THREE.Vector2();
mouse.x = (event.clientX / dom.offsetWidth) * 2 - 1;
mouse.y = -(event.clientY / dom.offsetHeight) * 2 + 1;
raycaster.setFromCamera( mouse, camera );
let intersects = raycaster.intersectObjects( scope.modelmanager.controllist,true);
if(helpbox){
scene.remove( helpbox );
helpbox = null;
}
if(textplane){
scene.remove(textplane);
textplane.geometry.dispose();
textplane.material.dispose();
}
if(intersects[0]){
if(intersects[0].object.raycastoff){
helpbox = new THREE.BoxHelper( intersects[0].object.parent, 0xff0000 );
settext(intersects[0].object.parent,intersects[0].point);
getdevicemsg(intersects[0].object.parent.name);
}else{
helpbox = new THREE.BoxHelper( intersects[0].object, 0xff0000 );
settext(intersects[0].object,intersects[0].point);
getdevicemsg(intersects[0].object.name);
}
scene.add( helpbox );
}
}
}
}
this.animationmsgshow = function(nowobject){
getdevicemsg(nowobject.name);
}
function getdevicemsg(selectname){
// console.log(selectname);
for(let i=0,leni=scope.jdqcontrol.devicelist.length;i<leni;i++){
if(selectname == scope.jdqcontrol.devicelist[i].name){
updatemsg(scope.jdqcontrol.devicelist[i].text,scope.jdqcontrol.devicelist[i].msg);
i=leni;
}
}
}
function settext(intersects,point){
if(intersects.text){
let textgeometry = new THREE.PlaneBufferGeometry( 300, 200, 1 );
let textt = new THREE.CanvasTexture(getTextCanvas(intersects.text));
let textmaterial = new THREE.MeshBasicMaterial( {
side: THREE.DoubleSide,
map:textt ,transparent: true,
alphaTest:0.1
} );
if(textplane){
scene.remove(textplane);
textplane.geometry.dispose();
textplane.material.dispose();
}
textplane= new THREE.Mesh( textgeometry, textmaterial );
// textplane.name = data[i].code;
textplane.position.x = point.x;
textplane.position.y = point.y+100;
textplane.position.z = point.z;
// console.log(textplane.position);
// textplane.tcode = data[i].code;
textplane.rotation.y = -Math.PI/2;
textplane.lookAt(camera.position);
// scope.textlist.push(textplane);
// newmesh.children[0].add(textplane);
scene.add(textplane);
textgeometry.dispose();
textmaterial.dispose();
textt.dispose();
}
}
var beauty = new Image();
beauty.src = JL3D_LOCAL_STATIC+"/texture/guide.png";
//canvas文字贴图方法
//PS:待提炼 增强功能
function getTextCanvas(text){
var canvas = document.getElementById('canvastexture');
canvas.width = 256;
canvas.height = 128;
var ctx = canvas.getContext('2d');
//var bg = canvas.createPattern(img, "no-repeat");
//ctx.fillStyle = bg;
ctx.fillRect(0, 0,256,128);
ctx.font = "20px Verdana";
ctx.fillStyle = '#FFFFFF';
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.clearRect(0,0,256,128);
//console.log(text.groupNumber);
ctx.drawImage(beauty,0,0,256, 128);
ctx.fillText("设备部件:"+text, 90,30);
// ctx.fillText("车组人员:XXX", 40,20);
// ctx.fillText("速度:XXX.XXX", 40,30);
//ctx.fillText(text.trainModel.name, width/2,height*3/4);
let data = ctx.getImageData(0, 0,256, 128);
return data;
}
}

View File

@ -1,184 +0,0 @@
export function ModelManager(){
let scope = this;
this.controllist = [];
this.actionlist = [];
let jdq1 = {
code:"jdq1",
locateType:"01",
mesh:null,
action:null
};
let jdq2 = {
code:"jdq2",
locateType:"01",
mesh:null,
action:null
};
let jdq3 = {
code:"jdq3",
locateType:"01",
mesh:null,
action:null
};
let jdq4 = {
code:"jdq4",
locateType:"01",
mesh:null,
action:null
};
let jdq5 = {
code:"jdq5",
locateType:"01",
mesh:null,
action:null
};
let jdq6 = {
code:"jdq6",
locateType:"01",
mesh:null,
action:null
};
this.jdqg = {
code:null,
locateType:"00",
mesh:null,
action:null
};
this.loadpromise = function (data,mixers,scene){
let initlist = [];
initlist.push(fbxpromise(data.Jdq1,mixers,jdq1));
initlist.push(fbxpromise(data.Jdq2,mixers,jdq2));
initlist.push(fbxpromise(data.Jdq3,mixers,jdq3));
initlist.push(fbxpromise(data.Jdq4,mixers,jdq4));
initlist.push(fbxpromise(data.Jdq5,mixers,jdq5));
initlist.push(fbxpromise(data.Jdq6,mixers,jdq6));
initlist.push(fbxpromise(data.Jdqg,mixers,scope.jdqg));
return new Promise(function(resolve, reject){
Promise.all(initlist).then((result) => {
jdq1.mesh.stats = "0";
jdq1.mesh.position.x = 19;
jdq1.mesh.position.z = -275;
jdq1.mesh.position.y = 1270;
jdq1.mesh.rotation.y = -Math.PI/2;
jdq1.mesh.rotation.z = -Math.PI/2;
jdq2.mesh.stats = "0";
jdq2.mesh.position.x = 19;
jdq2.mesh.position.z = -165;
jdq2.mesh.position.y = 1270;
jdq2.mesh.rotation.y = -Math.PI/2;
jdq2.mesh.rotation.z = -Math.PI/2;
jdq3.mesh.stats = "0";
jdq3.mesh.position.x = 19;
jdq3.mesh.position.z = -55;
jdq3.mesh.position.y = 1270;
jdq3.mesh.rotation.y = -Math.PI/2;
jdq3.mesh.rotation.z = -Math.PI/2;
jdq4.mesh.stats = "0";
jdq4.mesh.position.x = 19;
jdq4.mesh.position.z = 65;
jdq4.mesh.position.y = 1270;
jdq4.mesh.rotation.y = -Math.PI/2;
jdq4.mesh.rotation.z = -Math.PI/2;
jdq5.mesh.stats = "0";
jdq5.mesh.position.x = 19;
jdq5.mesh.position.z = 170;
jdq5.mesh.position.y = 1270;
jdq5.mesh.rotation.y = -Math.PI/2;
jdq5.mesh.rotation.z = -Math.PI/2;
jdq6.mesh.stats = "0";
jdq6.mesh.position.x = 19;
jdq6.mesh.position.z = 280;
jdq6.mesh.position.y = 1270;
jdq6.mesh.rotation.y = -Math.PI/2;
jdq6.mesh.rotation.z = -Math.PI/2;
scope.controllist.push(jdq1.mesh);
scope.controllist.push(jdq2.mesh);
scope.controllist.push(jdq3.mesh);
scope.controllist.push(jdq4.mesh);
scope.controllist.push(jdq5.mesh);
scope.controllist.push(jdq6.mesh);
// console.log(jdq1);
scope.actionlist.push(jdq1.action);
scope.actionlist.push(jdq2.action);
scope.actionlist.push(jdq3.action);
scope.actionlist.push(jdq4.action);
scope.actionlist.push(jdq5.action);
scope.actionlist.push(jdq6.action);
scene.add(jdq1.mesh);
scene.add(jdq2.mesh);
scene.add(jdq3.mesh);
scene.add(jdq4.mesh);
scene.add(jdq5.mesh);
scene.add(jdq6.mesh);
scene.add(scope.jdqg.mesh);
resolve("success"); //['成功了', 'success']
}).catch((error) => {
//console.log(error);
});
});
}
}
function fbxpromise(asset,mixers,model){
return new Promise(function(resolve, reject){
var loader = new THREE.FBXLoader();
loader.load( asset.assetUrl, function ( object ) {
let mixer = new THREE.AnimationMixer( object );
// object.traverse( function ( child ) {
// if ( child.isMesh ) {
// child.castShadow = true;
// child.receiveShadow = true;
// }
// } );
//设置透明贴图的材质属性
for(let i=0,leni=object.children.length;i<leni;i++){
if(object.children[i].name == "fanghuozhao"){
for(let j=0,lenj=object.children[i].children.length;j<lenj;j++){
object.children[i].children[j].raycastoff = true;
if(object.children[i].children[j].name == "waizhao"){
object.children[i].children[j].material.depthTest = false;
}
}
}
}
object.name = asset.name;
object.code = model.code;
model.mesh = object;
if(object.animations.length>0){
model.action = mixer.clipAction( object.animations[ 0 ] );
model.action.setLoop(THREE.LoopOnce);
model.action.clampWhenFinished = true;
// model.action.play();
// scope.actionlist.push("1");
mixers.push(mixer);
}
resolve(asset.deviceType);
} );
});
}

View File

@ -8,7 +8,7 @@ import {MTLLoader} from '@/jlmap3d/main/loaders/MTLLoader.js';
import { FBXLoader } from '@/jlmap3d/main/loaders/FBXLoader.js'; import { FBXLoader } from '@/jlmap3d/main/loaders/FBXLoader.js';
// data // data
import { Jl3ddata } from '@/jlmap3d/main/model/jl3ddata'; import { Jl3ddata } from '@/jlmap3d/main/newmodel/jl3ddata';
// setconfig // setconfig
import { SetCamera } from '@/jlmap3d/config/SetCamera'; import { SetCamera } from '@/jlmap3d/config/SetCamera';
@ -21,10 +21,8 @@ import {OrbitControls} from '@/jlmap3d/main/control/OrbitControls.js';
import { DragControls } from '@/jlmap3d/main/control/DragControls.js'; import { DragControls } from '@/jlmap3d/main/control/DragControls.js';
// 加载器 // 加载器
import { DriverLoad } from '@/jlmap3d/main/loaders/DriverLoad';
import { DriverLoadNew } from '@/jlmap3d/main/loaders/DriverLoadNew'; import { DriverLoadNew } from '@/jlmap3d/main/loaders/DriverLoadNew';
// connect // connect
import {Jl3dDriving} from '@/jlmap3d/jl3ddrive/moveupdate/DrivingConnect';
import {Jl3dDrivingNew} from '@/jlmap3d/jl3ddrive/moveupdate/DrivingConnectNew'; import {Jl3dDrivingNew} from '@/jlmap3d/jl3ddrive/moveupdate/DrivingConnectNew';
import { getPublishMapVersion, getPublishMapDetail, getPublish3dMapDetail} from '@/api/jlmap3d/load3ddata'; import { getPublishMapVersion, getPublishMapDetail, getPublish3dMapDetail} from '@/api/jlmap3d/load3ddata';
@ -158,57 +156,7 @@ export function JLmapDriving(dom,data,mapId,storemod,translation,routegroup,proj
getPublish3dMapDetail(mapId).then(netdata => { getPublish3dMapDetail(mapId).then(netdata => {
// console.log(netdata); // console.log(netdata);
let assetsdata = JSON.parse(netdata.data.sections); let assetsdata = JSON.parse(netdata.data.sections);
if(assetsdata.link){
scope.datatype = "old";
// datanew();
// scope.jsonwebwork = new Worker(JL3D_LOCAL_STATIC+"/workertest/jsonworker.js");
// scope.Subscribe = new Jlmap3dSubscribe(scope,routegroup,scope.jsonwebwork);
// scope.Subscribe.socketon(scope.Subscribe.topic);
scope.Subscribe = new Jl3dDriving(mixers,updatemmi,sound,translation,routegroup);
scope.Subscribe.socketon(scope.Subscribe.topic);
DriverLoad(data,scope,netdata.data,sectionlist,linklist,signallist,stationstandlist,trainlisttest,realsectionlist,rails, camera, controls3, scene,mixers,storemod);
var timer = setInterval(function() {
if(trainlisttest){
if(trainlisttest.group){
if(trainlisttest.group.children[0]){
// console.log(trainlisttest.group.children[0].name);
updatemmi.updatedrivingcode(trainlisttest.group.children[0].name);
scope.Subscribe.initdrivercode(trainlisttest.group.children[0].name);
for(let k in rails.switchrail){
const ddd = storemod.getters['map/getDeviceByCode'](k);
let switchdata = rails.switchrail[k];
rails.switchrail[k].locateType = ddd.locateType;
if(ddd.locateType == "01"){
//1--向左 2--向右
//__\__ __/__
if(rails.switchrail[k].directtype == "1"){
rails.linkrail[switchdata.alink].lconnect = switchdata.blink;
rails.linkrail[switchdata.blink].rconnect = switchdata.alink;
}else if(rails.switchrail[k].directtype == "2"){
rails.linkrail[switchdata.alink].rconnect = switchdata.blink;
rails.linkrail[switchdata.blink].lconnect = switchdata.alink;
}
}else if(ddd.locateType == "02"){
if(rails.switchrail[k].directtype == "1"){
rails.linkrail[switchdata.alink].lconnect = switchdata.clink;
rails.linkrail[switchdata.clink].rconnect = switchdata.alink;
}else if(rails.switchrail[k].directtype == "2"){
rails.linkrail[switchdata.alink].rconnect = switchdata.clink;
rails.linkrail[switchdata.clink].lconnect = switchdata.alink;
}
}
}
clearInterval(timer);
}
}
}
}, 2000);
}else{
scope.datatype = "new"; scope.datatype = "new";
driverWebWorker = new Worker(JL3D_LOCAL_STATIC+"/workertest/driverWebWorker.js"); driverWebWorker = new Worker(JL3D_LOCAL_STATIC+"/workertest/driverWebWorker.js");
scope.Subscribe = new Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup,driverWebWorker,stats); scope.Subscribe = new Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup,driverWebWorker,stats);
@ -230,7 +178,7 @@ export function JLmapDriving(dom,data,mapId,storemod,translation,routegroup,proj
}, 2000); }, 2000);
}
}); });
}); });

View File

@ -1,886 +0,0 @@
import StompClient from '@/utils/sock';
import { getTrainingCbtcDemon, runDiagramStart, runDiagramOver, setTrainingCbtcInitTime } from '@/api/simulation';
import { creatSubscribe, clearSubscribe, displayTopic, screenTopic } from '@/utils/stomp';
import { getToken } from '@/utils/auth';
import router from '@/router/index_APP_TARGET';
// 定于仿真socket接口
export function Jl3dDriving(mixers, updatemmi, sound, translation, routegroup) {
const scope = this;
this.map = null;
const toppic = '/app/topic/simulation/client/' + routegroup + '/drive';
var trainlisttest = null;
var sectionlist = null;
var signallist = null;
var stationstandlist = null;
var sectionlist = null;
var materials = null;
var actions = null;
var rails = null;
var links = null;
var scenes = null;
var code = null;
var drivingcode = null;
var drivingspeed = null;
var drivingaptspeed = null;
let driverswitch = false;
const stoptimer = null;
const num = 30;
const pointstand = null;
// run as plane = 01;
// reset = 02;
var datatype = '00';
this.teststomp = new StompClient();
this.topic = '/user/queue/simulation/jl3d/' + routegroup;
const header = {'X-Token': getToken() };
this.updatamap = function(newsectionlist, newlinklist, newsignallist, newstationstandlist, newtrainlisttest, newrealsectionlist, newrails, materiallist, nowaction, scene) {
// console.log(mapdata);
// console.log(newtrainlisttest);
trainlisttest = newtrainlisttest;
sectionlist = newsectionlist;
signallist = newsignallist;
stationstandlist = newstationstandlist;
materials = materiallist;
scenes = scene;
actions = nowaction;
links = newlinklist;
rails = newrails;
};
this.initdrivercode = function(code) {
drivingcode = code;
};
this.socketon = function(topic) {
try {
// console.log("teststomp");
scope.teststomp.subscribe(topic, callback, header);
} catch (error) {
console.error('websocket订阅失败');
}
};
this.socketoff = function(topic) {
scope.teststomp.unsubscribe(topic);
for (let i = 0; i < trainlisttest.group.children.length; i++) {
if (trainlisttest.group.children[i].dispose == false) {
code = trainlisttest.group.children[i].name;
trainlisttest.list[code].rotation.y = 0;
trainlisttest.list[code].doorStatus = '01';
trainlisttest.list[code].speed = 0;
trainlisttest.group.children[i].dispose = true;
trainlisttest.group.children[i].position.x = -50000;
trainlisttest.group.children[i].position.y = -50000;
trainlisttest.group.remove(trainlisttest.group.children[i]);
i--;
}
}
};
// 仿真socket接口回调函数
function callback(Response) {
// console.log(Response);
// 对象化数据
const data = JSON.parse(Response.body);
// 遍历后台数据
// 判断消息类型
// if(data.type == "Simulation_TrainPosition"){
//
//
// }
// console.log(data);
// console.log(data);
switch (data.type) {
case 'Simulation_Driver_Change':
trainlisttest.group.remove(trainlisttest.list[drivingcode]);
trainlisttest.list[data.body.code].dispose = true;
trainlisttest.list[drivingcode].dispose = true;
drivingcode = data.body.code;
trainlisttest.group.add(trainlisttest.list[drivingcode]);
// sound.volswitch = true;
updatemmi.updatedrivingcode( data.body.code);
break;
case 'Simulation_TrainSpeed':
trainspeed(data);
break;
case 'SJL3D_TrainStatus':
trainstatus(data);
break;
case 'Simulation_DeviceStatus':
devicestatus(data);
break;
case 'Simulation_Drive_Data_Routing':
updatemmi.updatedrivedata(data.body);
break;
case 'Simulation_Reset':
simulationreset(data);
default :
// TODO
}
// if(data.type == 'Simulation_Drive_Data_Routing'){
// updatemmi.updatedrivedata(data.body);
// }
//
// if (data.type == 'Simulation_Driver_Change') {
// drivingcode = data.body.code;
// updatemmi.updatedrivingcode( data.body.code);
// }
//
// if (data.type == 'Simulation_TrainSpeed') {
// trainspeed(data);
// }
//
// if (data.type == 'SJL3D_TrainStatus') {
// trainstatus(data);
// }
//
// if (data.type == 'Simulation_DeviceStatus') {
// devicestatus(data);
// }
}
function trainspeed(data) {
// console.log(data);
if (trainlisttest) {
for (let tl = 0; tl < data.body.length; tl++) {
code = data.body[tl].id;
if (trainlisttest.list[code].speed != data.body[tl].v) {
trainlisttest.list[code].speed = data.body[tl].v;
if (trainlisttest.list[code].runMode == '02') {
if (trainlisttest.list[code].isStandTrack == true) {
trainlisttest.list[code].speeds = parseFloat(data.body[tl].v * 10 / 36 / 25 / trainlisttest.list[code].len);
} else {
trainlisttest.list[code].speeds = parseFloat(data.body[tl].v * 10 / 36 / 25 / trainlisttest.list[code].len);
}
} else {
trainlisttest.list[code].speeds = parseFloat(data.body[tl].v * 10 / 36 / 25 / trainlisttest.list[code].len);
}
if (code == drivingcode) {
// if (data.body[tl].v >0) {
// updatemmi.updatenowspeed(data.body[tl].v);
// } else {
updatemmi.updatenowspeed(Math.abs(data.body[tl].v));
// console.log(data.body[i]);
// }
}
}
if (code == drivingcode) {
// if(sound.volswitch == true){
// sound.setVolume( data.body[tl].v/100 );
// }
if (data.body[tl].atpv) {
updatemmi.updateatpspeed(data.body[tl].atpv);
} else {
updatemmi.updateatpspeed(-1);
}
if (data.body[tl].atov) {
updatemmi.updateatospeed(data.body[tl].atov);
} else {
updatemmi.updateatospeed(-1);
}
if (trainlisttest.list[code].progress < 1) {
const syncdata = {
type: 'Train',
code: code,
linkCode: trainlisttest.list[code].nowcode,
percent: 0
};
if (trainlisttest.list[code].status == '02') {
if (trainlisttest.list[code].targetLink == trainlisttest.list[code].nowcode) {
if ((trainlisttest.list[code].linkOffsetPercent / trainlisttest.list[code].pc) >= trainlisttest.list[code].targetpercent) {
syncdata.percent = trainlisttest.list[code].progress;
} else {
syncdata.percent = trainlisttest.list[code].progress * trainlisttest.list[code].pc;
}
} else {
syncdata.percent = trainlisttest.list[code].progress;
}
} else {
if (trainlisttest.list[code].targetLink == trainlisttest.list[code].nowcode) {
if ((trainlisttest.list[code].linkOffsetPercent / trainlisttest.list[code].pc) <= trainlisttest.list[code].targetpercent) {
syncdata.percent = (1 - trainlisttest.list[code].progress);
} else {
syncdata.percent = (1 - trainlisttest.list[code].progress) * trainlisttest.list[code].pc;
}
} else {
syncdata.percent = (1 - trainlisttest.list[code].progress);
}
}
// console.log("send");
// console.log(trainlisttest.list[code]);
//
// console.log(syncdata);
// console.log("=============");
scope.teststomp.send(toppic, syncdata);
}
}
}
}
}
function trainstatus(data) {
// console.log(data.body);
for (let i = data.body.length - 1; i >= 0; i--) {
// 遍历列车对象组
// console.log(trainlisttest);
if (trainlisttest) {
code = data.body[i].code;
// 剔除不显示的车
// 找到对应列车
if (code == drivingcode) {
driverswitch = data.body[i].runMode;
// 更新车组号
updatemmi.updatetrainnum(data.body[i].groupNumber);
// 更新列车
if (data.body[i].parkRemainTime > 0) {
updatemmi.updatestoptime(translation.stopTime + parseInt(data.body[i].parkRemainTime));
} else {
if (data.body[i].runMode == '02') {
updatemmi.updatestoptime(translation.trainAtoOn);
} else {
if (trainlisttest.list[code].isStandTrack == true && trainlisttest.list[code].progress > 0.95 && trainlisttest.list[code].speed <= 0) {
// if(stoptimer){
//
// }else{
// stoptimer = setInterval(function(){
// if(num >=0){
// updatemmi.updatestoptime("停站时间:"+num);
// num --;
// }
// },1000);
// }
} else {
updatemmi.updatestoptime(translation.trainAtoOff);
}
}
}
}
trainlisttest.list[code].runMode = data.body[i].runMode;
// 车门开关验证
if (trainlisttest.list[code].doorStatus != data.body[i].doorStatus && data.body[i].doorStatus == '01') {
// console.log("close");
trainlisttest.list[code].doorStatus = '01';
for (let an = actions[code].top.length - 1; an >= 0; an--) {
actions[code].top[an].reset();
actions[code].top[an].time = actions[code].top[an]._clip.duration;
actions[code].top[an].timeScale = -1;
actions[code].top[an].play();
}
} else if (trainlisttest.list[code].doorStatus != data.body[i].doorStatus && data.body[i].doorStatus == '02') {
// console.log("open");
trainlisttest.list[code].doorStatus = '02';
for (let an = actions[code].top.length - 1; an >= 0; an--) {
actions[code].top[an].reset();
actions[code].top[an].time = 0;
actions[code].top[an].timeScale = 1;
actions[code].top[an].play();
}
}
// if (data.body[i].directionType == '02') {
//
// } else {
// if (trainlisttest.list[code].doorStatus != data.body[i].doorStatus && data.body[i].doorStatus == '01') {
// // console.log("close");
// trainlisttest.list[code].doorStatus = '01';
// for (let an=actions[code].down.length-1; an>=0; an--) {
// actions[code].down[an].reset();
// actions[code].down[an].time = actions[code].top[an]._clip.duration;
// actions[code].down[an].timeScale = -1;
// actions[code].down[an].play();
// }
// } else if (trainlisttest.list[code].doorStatus != data.body[i].doorStatus && data.body[i].doorStatus == '02') {
// // console.log("open");
// trainlisttest.list[code].doorStatus = '02';
// for (let an=actions[code].down.length-1; an>=0; an--) {
// actions[code].down[an].reset();
// actions[code].down[an].time = 0;
// actions[code].down[an].timeScale = 1;
// actions[code].down[an].play();
// }
// }
// }
// 遍历获取所在轨道
if (trainlisttest.list[code].dispose != data.body[i].dispose && data.body[i].dispose == false) {
if (rails.linkrail[data.body[i].linkCode]) {
// console.log(trainlisttest.group);
if (trainlisttest.group.children.length < 1) {
trainlisttest.group.add(trainlisttest.list[code]);
drivingcode = code;
updatemmi.updatedrivingcode(drivingcode);
}
if (trainlisttest.list[code].mixerpush == false) {
for (let mi = 0, lenmi = trainlisttest.list[code].mixer.length; mi < lenmi; mi++) {
mixers.push(trainlisttest.list[code].mixer[mi]);
}
trainlisttest.list[code].mixerpush = true;
}
// trainlisttest.group.add(trainlisttest.list[code]);
trainlisttest.list[code].position.y = 0;
trainlisttest.list[code].progress = 0;
// trainlisttest.list[code].oldoffset = data.body[i].sectionOffsetPercent;
trainlisttest.list[code].dispose = false;
trainlisttest.list[code].nowcode = data.body[i].linkCode;
trainlisttest.list[code].pc = 1;
// console.log(data.body[i]);
if (data.body[i].directionType == '02') { // 向右
if (data.body[i].targetStation) {
trainlisttest.list[code].stopstation = data.body[i].targetStation;
// console.log(rails.stops[data.body[i].targetStation].direct2.percent);
trainlisttest.list[code].pc = data.body[i].targetLinkPercent / rails.stops[data.body[i].targetStation].direct2.percent;
trainlisttest.list[code].targetpercent = rails.stops[data.body[i].targetStation].direct2.percent;
trainlisttest.list[code].progress = data.body[i].linkOffsetPercent / trainlisttest.list[code].pc;
trainlisttest.list[code].linkOffsetPercent = data.body[i].linkOffsetPercent;
trainlisttest.list[code].targetLink = data.body[i].targetLink;
} else {
trainlisttest.list[code].progress = data.body[i].linkOffsetPercent;
trainlisttest.list[code].linkOffsetPercent = data.body[i].linkOffsetPercent;
}
trainlisttest.list[code].status = '02';
trainlisttest.list[code].curve = rails.linkrail[data.body[i].linkCode].lineleft;
const point = rails.linkrail[data.body[i].linkCode].lineleft.getPointAt(trainlisttest.list[code].progress);
trainlisttest.list[code].rotation.y = 0;
trainlisttest.list[code].position.x = point.x;
trainlisttest.list[code].position.y = 0;
for (let tl = 0; tl < 6; tl++) {
trainlisttest.list[code].children[tl].position.z = point.z;
}
} else if (data.body[i].directionType == '03') { // 向左
// if(trainlisttest.list[code].rname == "006"){
// console.log("0000000000000000");
// console.log(data.body[i].linkOffsetPercent);
// }
if (data.body[i].targetStation) {
trainlisttest.list[code].stopstation = data.body[i].targetStation;
trainlisttest.list[code].pc = data.body[i].targetLinkPercent / rails.stops[data.body[i].targetStation].direct1.percent;
// console.log(data.body[i].targetLinkPercent);
// console.log(rails.stops[data.body[i].targetStation].direct1.percent);
// console.log(trainlisttest.list[code].pc);
trainlisttest.list[code].targetpercent = rails.stops[data.body[i].targetStation].direct1.percent;
trainlisttest.list[code].progress = 1 - data.body[i].linkOffsetPercent / trainlisttest.list[code].pc;
trainlisttest.list[code].linkOffsetPercent = data.body[i].linkOffsetPercent;
trainlisttest.list[code].targetLink = data.body[i].targetLink;
} else {
trainlisttest.list[code].progress = 1 - data.body[i].linkOffsetPercent;
trainlisttest.list[code].linkOffsetPercent = data.body[i].linkOffsetPercent;
}
// console.log("progress:"+trainlisttest.list[code].progress);
// console.log("linkOffsetPercent:"+trainlisttest.list[code].linkOffsetPercent);
// console.log("datatarget:"+ data.body[i].targetLinkPercent);
// console.log("directpercent:"+trainlisttest.list[code].targetpercent);
// console.log("====================");
trainlisttest.list[code].status = '03';
trainlisttest.list[code].curve = rails.linkrail[data.body[i].linkCode].lineright;
const point = rails.linkrail[data.body[i].linkCode].lineright.getPointAt(trainlisttest.list[code].progress);
trainlisttest.list[code].rotation.y = Math.PI;
trainlisttest.list[code].position.x = point.x;
trainlisttest.list[code].position.y = 0;
for (let tl = 0; tl < 6; tl++) {
trainlisttest.list[code].children[tl].position.z = -point.z;
}
}
trainlisttest.list[code].len = rails.linkrail[data.body[i].linkCode].lengthfact;
// trainlisttest.list[code].isStandTrack = sectionlist.sections.datalist[data.body[i].sectionCode].isStandTrack;
// trainlisttest.list[code].len = sectionlist.sections.datalist[data.body[i].sectionCode].distance;
if (data.body[i].speed == 0) {
trainlisttest.list[code].speeds = data.body[i].speed;
trainlisttest.list[code].speeds = 0;
// trainlisttest.list[code].startmark = 1;
} else {
trainlisttest.list[code].speeds = data.body[i].speed;
trainlisttest.list[code].speeds = parseFloat(data.body[i].speed * 10 / 36 / 25 / trainlisttest.list[code].len);
}
}
} else if (trainlisttest.list[code].dispose != data.body[i].dispose && data.body[i].dispose == true) {
trainlisttest.group.remove(trainlisttest.list[code]);
trainlisttest.list[code].progress = null;
trainlisttest.list[code].dispose = true;
code = trainlisttest.group.children[i].name;
trainlisttest.list[code].rotation.y = 0;
trainlisttest.list[code].doorStatus = '01';
trainlisttest.list[code].speed = 0;
trainlisttest.list[code].position.x = -50000;
trainlisttest.list[code].position.y = -50000;
trainlisttest.list[code].pc = 1;
} else if (trainlisttest.list[code].dispose == data.body[i].dispose && data.body[i].dispose == false) {
if (rails.linkrail[data.body[i].linkCode]) {
if (driverswitch == '02' && code == drivingcode) {
updatemmi.updatenowspeed(data.body[i].speed);
if (data.body[i].atpSpeed) {
updatemmi.updateatpspeed(data.body[i].atpSpeed);
} else {
updatemmi.updateatpspeed(-1);
}
if (data.body[i].targetSpeed) {
updatemmi.updateatospeed(data.body[i].targetSpeed);
} else {
updatemmi.updateatospeed(-1);
}
if (data.body[i].maLen) {
updatemmi.updatenowlen(data.body[i].maLen);
} else {
updatemmi.updatenowlen(0);
}
// if(trainlisttest.list[code].isStandTrack == true){
// pointstand = null;
// if(data.body[i].directionType == "02"){
// pointstand = trainlisttest.list[code].curve.getPointAt(data.body[i].sectionOffsetPercent);
// }else{
// pointstand = trainlisttest.list[code].curve.getPointAt(1-data.body[i].sectionOffsetPercent);
// }
// console.log(data.body[i].sectionOffsetPercent)
// console.log(pointstand.x);
//
// trainlisttest.list[code].position.x = pointstand.x;
// }
}
if (driverswitch == '05' && code == drivingcode) {
if (data.body[i].maLen) {
updatemmi.updatenowlen(data.body[i].maLen);
} else {
updatemmi.updatenowlen(0);
}
}
if (trainlisttest.list[code].status != data.body[i].directionType) {
if (data.body[i].directionType == '02') { // 向右
trainlisttest.list[code].progress = 0;
const rotaposx = trainlisttest.list[code].children[5].matrixWorld.elements[12];
const rotaposz = trainlisttest.list[code].children[0].matrixWorld.elements[14];
trainlisttest.list[code].rotation.y = 0;
trainlisttest.list[code].position.x = rotaposx;
for (let tl = 0; tl < 6; tl++) {
trainlisttest.list[code].children[tl].position.z = rotaposz;
}
trainlisttest.list[code].progress = (rotaposx - rails.linkrail[data.body[i].linkCode].lp.x) / rails.linkrail[data.body[i].linkCode].lengthfact;
trainlisttest.list[code].status = '02';
trainlisttest.list[code].curve = rails.linkrail[data.body[i].linkCode].lineleft;
trainlisttest.list[code].nextcurve = null;
trainlisttest.list[code].len = rails.linkrail[data.body[i].linkCode].lengthfact;
} else if (data.body[i].directionType == '03') { // 向左
trainlisttest.list[code].progress = 0;
const rotaposx = trainlisttest.list[code].children[5].matrixWorld.elements[12];
const rotaposz = Math.abs(trainlisttest.list[code].children[0].matrixWorld.elements[14]);
trainlisttest.list[code].rotation.y = Math.PI;
trainlisttest.list[code].position.x = rotaposx;
for (let tl = 0; tl < 6; tl++) {
trainlisttest.list[code].children[tl].position.z = -rotaposz;
}
trainlisttest.list[code].progress = 1 - (rotaposx - rails.linkrail[data.body[i].linkCode].lp.x) / rails.linkrail[data.body[i].linkCode].lengthfact;
trainlisttest.list[code].status = '03';
trainlisttest.list[code].curve = rails.linkrail[data.body[i].linkCode].lineright;
trainlisttest.list[code].nextcurve = null;
trainlisttest.list[code].len = rails.linkrail[data.body[i].linkCode].lengthfact;
}
}
let nextcode;
if (code == drivingcode) {
// console.log(data.body[i].targetStation);
// console.log("netpercent");
// console.log(data.body[i].targetLinkPercent);
// console.log(data.body[i].linkOffsetPercent);
// console.log("3dpercent");
// if(rails.stops[data.body[i].targetStation]){
// console.log(rails.stops[data.body[i].targetStation].direct2.percent);
// }
//
// console.log(trainlisttest.list[code].progress);
// console.log(trainlisttest.list[code].pc);
// console.log("===============");
// console.log(data.body[i]);
if (data.body[i].directionType == '02') {
if (trainlisttest.list[code].stopstation != data.body[i].targetStation) {
trainlisttest.list[code].stopstation = data.body[i].targetStation;
if (data.body[i].targetStation) {
trainlisttest.list[code].pc = data.body[i].targetLinkPercent / rails.stops[data.body[i].targetStation].direct2.percent;
trainlisttest.list[code].targetpercent = rails.stops[data.body[i].targetStation].direct2.percent;
trainlisttest.list[code].linkOffsetPercent = data.body[i].linkOffsetPercent;
trainlisttest.list[code].targetLink = data.body[i].targetLink;
// trainlisttest.list[code].progress = trainlisttest.list[code].linkOffsetPercent*trainlisttest.list[code].pc;
}
}
trainlisttest.list[code].status = '02';
nextcode = rails.linkrail[data.body[i].linkCode].rconnect;
if (nextcode) {
// console.log(rails.linkrail[nextcode].lineleft.points);
trainlisttest.list[code].nextcurve = rails.linkrail[nextcode].lineleft;
trainlisttest.list[code].nextlen = rails.linkrail[nextcode].lengthfact;
} else {
trainlisttest.list[code].nextlen = 0;
}
} else if (data.body[i].directionType == '03') {
if (trainlisttest.list[code].stopstation != data.body[i].targetStation) {
trainlisttest.list[code].stopstation = data.body[i].targetStation;
if (data.body[i].targetStation) {
trainlisttest.list[code].pc = data.body[i].targetLinkPercent / rails.stops[data.body[i].targetStation].direct1.percent;
trainlisttest.list[code].targetpercent = rails.stops[data.body[i].targetStation].direct1.percent;
trainlisttest.list[code].linkOffsetPercent = data.body[i].linkOffsetPercent;
trainlisttest.list[code].targetLink = data.body[i].targetLink;
// trainlisttest.list[code].progress = (1-trainlisttest.list[code].linkOffsetPercent)*trainlisttest.list[code].pc;
}
}
trainlisttest.list[code].status = '03';
nextcode = rails.linkrail[data.body[i].linkCode].lconnect;
if (nextcode) {
trainlisttest.list[code].nextcurve = rails.linkrail[nextcode].lineright;
trainlisttest.list[code].nextlen = rails.linkrail[nextcode].lengthfact;
} else {
trainlisttest.list[code].nextlen = 0;
}
}
trainlisttest.list[code].nextcode = nextcode;
// console.log(trainlisttest.list[code].nowcode);
// console.log(trainlisttest.list[code].nextcode);
// console.log(trainlisttest.list[code].curve.points);
// console.log(trainlisttest.list[code].nextcurve.points);
// console.log("=========================");
} else {
// trainlisttest.list[code].stopstation = data.body[i].targetStation;
// // console.log(rails.stops[data.body[i].targetStation].direct2.percent);
// trainlisttest.list[code].pc = data.body[i].targetLinkPercent/rails.stops[data.body[i].targetStation].direct2.percent;
// trainlisttest.list[code].targetpercent = rails.stops[data.body[i].targetStation].direct2.percent;
// trainlisttest.list[code].progress = data.body[i].linkOffsetPercent*trainlisttest.list[code].pc;
// trainlisttest.list[code].linkOffsetPercent = data.body[i].linkOffsetPercent;
// trainlisttest.list[code].targetLink = data.body[i].targetLink;
let nextcode;
if (data.body[i].directionType == '02') {
if (rails.linkrail[data.body[i].linkCode].lineleft) {
nextcode = rails.linkrail[data.body[i].linkCode].rconnect;
trainlisttest.list[code].status = '02';
if (nextcode) {
trainlisttest.list[code].nextcurve = rails.linkrail[nextcode].lineleft;
trainlisttest.list[code].nextlen = rails.linkrail[nextcode].lengthfact;
}
trainlisttest.list[code].nowcode = data.body[i].linkCode;
trainlisttest.list[code].curve = rails.linkrail[data.body[i].linkCode].lineleft;
trainlisttest.list[code].len = rails.linkrail[data.body[i].linkCode].lengthfact;
trainlisttest.list[code].progress = data.body[i].linkOffsetPercent;
trainlisttest.list[code].linkOffsetPercent = data.body[i].linkOffsetPercent;
if (data.body[i].targetStation) {
trainlisttest.list[code].pc = data.body[i].targetLinkPercent / rails.stops[data.body[i].targetStation].direct2.percent;
trainlisttest.list[code].targetpercent = rails.stops[data.body[i].targetStation].direct2.percent;
trainlisttest.list[code].targetLink = data.body[i].targetLink;
trainlisttest.list[code].progress = data.body[i].linkOffsetPercent / trainlisttest.list[code].pc;
}
trainlisttest.list[code].speeds = parseFloat(trainlisttest.list[code].speed * 10 / 36 / 25 / trainlisttest.list[code].len);
}
} else if (data.body[i].directionType == '03') {
if (rails.linkrail[data.body[i].linkCode].lineright) {
nextcode = rails.linkrail[data.body[i].linkCode].lconnect;
trainlisttest.list[code].status = '03';
if (nextcode) {
trainlisttest.list[code].nextcurve = rails.linkrail[nextcode].lineright;
trainlisttest.list[code].nextlen = rails.linkrail[nextcode].lengthfact;
}
trainlisttest.list[code].nowcode = data.body[i].linkCode;
trainlisttest.list[code].curve = rails.linkrail[data.body[i].linkCode].lineright;
trainlisttest.list[code].len = rails.linkrail[data.body[i].linkCode].lengthfact;
trainlisttest.list[code].progress = 1 - data.body[i].linkOffsetPercent;
trainlisttest.list[code].linkOffsetPercent = data.body[i].linkOffsetPercent;
if (data.body[i].targetStation) {
trainlisttest.list[code].pc = data.body[i].targetLinkPercent / rails.stops[data.body[i].targetStation].direct1.percent;
trainlisttest.list[code].targetpercent = rails.stops[data.body[i].targetStation].direct1.percent;
trainlisttest.list[code].targetLink = data.body[i].targetLink;
trainlisttest.list[code].progress = (1 - data.body[i].linkOffsetPercent) / trainlisttest.list[code].pc;
}
trainlisttest.list[code].speeds = parseFloat(trainlisttest.list[code].speed * 10 / 36 / 25 / trainlisttest.list[code].len);
}
}
trainlisttest.list[code].nextcode = nextcode;
}
// console.log(data.body[i].linkOffsetPercent);
// console.log(trainlisttest.list[code].progress);
// console.log(trainlisttest.list[code].curve.points);
// console.log(trainlisttest.list[code].nextcurve.points);
// console.log(trainlisttest.list[code].len);
// console.log(trainlisttest.list[code].nextlen);
// console.log("==========================================");
}
}
}
}
}
function simulationreset(data) {
// console.log(data);
for (const k in trainlisttest.list) {
trainlisttest.list[k].dispose = true;
trainlisttest.group.remove(trainlisttest.list[k]);
trainlisttest.list[k].stopstation = null;
trainlisttest.list[k].pc = null;
trainlisttest.list[k].targetpercent = null;
trainlisttest.list[k].progress = null;
trainlisttest.list[k].linkOffsetPercent = null;
trainlisttest.list[k].targetLink = null;
drivingcode = null;
}
}
function devicestatus(data) {
for (let i = data.body.length - 1; i >= 0; i--) {
// 0xFFFFFF
// 0xCD0000 红
// 0xEEEE00 黄
// 0x32CD32 绿
if (data.body[i]._type == 'Signal') {
if (signallist) {
signalupdate(data.body[i]);
}
}
if (data.body[i]._type == 'StationStand' ) {
if (actions) {
standupdate(data.body[i]);
}
}
if (data.body[i]._type == 'Switch') {
if (sectionlist) {
switchupdate(data.body[i]);
}
}
}
}
function standupdate(data) {
code = data.code;
if ( actions[code]) {
if (data.screenDoorOpenStatus == '02' && actions[code].status == '01') {
actions[code].status = '00';
}
if (data.screenDoorOpenStatus == '02' && actions[code].status == '00') {
actions[code].status = '02';
actions[code].action.reset();
actions[code].action.time = 0;
actions[code].action.timeScale = 1;
actions[code].action.play();
}
if (data.screenDoorOpenStatus == '01' && actions[code].status == '02') {
actions[code].status = '00';
}
if (data.screenDoorOpenStatus == '01' && actions[code].status == '00') {
actions[code].status = '01';
actions[code].action.reset();
actions[code].action.time = actions[code].action._clip.duration;
actions[code].action.timeScale = -1;
actions[code].action.play();
}
}
}
function signalupdate(data) {
code = data.code;
if (data.lightType == '01') {
if (signallist.list[code].mesh.code) {
signallist.list[code].mesh.status = data.status;
// 55
// 33
// 77
// 关闭
if (data.status == '01') {
signallist.list[code].mesh.getObjectByName('red').material.map = materials[0];
signallist.list[code].mesh.getObjectByName('red').material.map.needsUpdate = true;
signallist.list[code].mesh.getObjectByName('yellow').material.map = materials[3];
signallist.list[code].mesh.getObjectByName('yellow').material.map.needsUpdate = true;
signallist.list[code].mesh.getObjectByName('green').material.map = materials[3];
signallist.list[code].mesh.getObjectByName('green').material.map.needsUpdate = true;
}
// 开放
if (data.status == '02') {
signallist.list[code].mesh.getObjectByName('red').material.map = materials[3];
signallist.list[code].mesh.getObjectByName('red').material.map.needsUpdate = true;
signallist.list[code].mesh.getObjectByName('yellow').material.map = materials[3];
signallist.list[code].mesh.getObjectByName('yellow').material.map.needsUpdate = true;
signallist.list[code].mesh.getObjectByName('green').material.map = materials[2];
signallist.list[code].mesh.getObjectByName('green').material.map.needsUpdate = true;
}
if (data.status == '03') {
signallist.list[code].mesh.getObjectByName('red').material.map = materials[3];
signallist.list[code].mesh.getObjectByName('red').material.map.needsUpdate = true;
signallist.list[code].mesh.getObjectByName('yellow').material.map = materials[1];
signallist.list[code].mesh.getObjectByName('yellow').material.map.needsUpdate = true;
signallist.list[code].mesh.getObjectByName('green').material.map = materials[3];
signallist.list[code].mesh.getObjectByName('green').material.map.needsUpdate = true;
}
// 引导
if (data.status == '03') {
signallist.list[code].mesh.getObjectByName('red').material.map = materials[0];
signallist.list[code].mesh.getObjectByName('red').material.map.needsUpdate = true;
signallist.list[code].mesh.getObjectByName('yellow').material.map = materials[1];
signallist.list[code].mesh.getObjectByName('yellow').material.map.needsUpdate = true;
signallist.list[code].mesh.getObjectByName('green').material.map = materials[3];
signallist.list[code].mesh.getObjectByName('green').material.map.needsUpdate = true;
}
// 封锁
if (data.status == '04') {
signallist.list[code].mesh.getObjectByName('red').material.map = materials[3];
signallist.list[code].mesh.getObjectByName('red').material.map.needsUpdate = true;
signallist.list[code].mesh.getObjectByName('yellow').material.map = materials[3];
signallist.list[code].mesh.getObjectByName('yellow').material.map.needsUpdate = true;
signallist.list[code].mesh.getObjectByName('green').material.map = materials[3];
signallist.list[code].mesh.getObjectByName('green').material.map.needsUpdate = true;
}
// 故障
if (data.status == '05') {
signallist.list[code].mesh.getObjectByName('red').material.map = materials[3];
signallist.list[code].mesh.getObjectByName('red').material.map.needsUpdate = true;
signallist.list[code].mesh.getObjectByName('yellow').material.map = materials[3];
signallist.list[code].mesh.getObjectByName('yellow').material.map.needsUpdate = true;
signallist.list[code].mesh.getObjectByName('green').material.map = materials[3];
signallist.list[code].mesh.getObjectByName('green').material.map.needsUpdate = true;
}
}
} else if (data.lightType == '02') {
if (signallist.list[code].mesh.code) {
signallist.list[code].mesh.getObjectByName('red').material.map = materials[3];
signallist.list[code].mesh.getObjectByName('red').material.map.needsUpdate = true;
signallist.list[code].mesh.getObjectByName('yellow').material.map = materials[3];
signallist.list[code].mesh.getObjectByName('yellow').material.map.needsUpdate = true;
signallist.list[code].mesh.getObjectByName('green').material.map = materials[3];
signallist.list[code].mesh.getObjectByName('green').material.map.needsUpdate = true;
}
}
}
function switchupdate(data) {
code = data.code;
for (let j = sectionlist.switchs.modellist.length - 1; j >= 0; j--) {
if (rails.switchrail[code]) {
if (rails.switchrail[code].locateType != data.locateType) {
// console.log("道岔变化:"+code);
if (data.locateType == '02') {
// console.log("02 反位");
if (actions[sectionlist.switchs.modellist[j].code]) {
sectionlist.switchs.modellist[j].locateType = data.locateType;
actions[sectionlist.switchs.modellist[j].code].reset();
actions[sectionlist.switchs.modellist[j].code].time = 0;
actions[sectionlist.switchs.modellist[j].code].timeScale = 1;
actions[sectionlist.switchs.modellist[j].code].play();
}
rails.switchrail[code].locateType = '02';
const testswitch = rails.switchrail[code];
if (rails.switchrail[code].directtype == '1') {
// console.log("道岔朝向1向左");
// console.log("aleft:"+testswitch.clink);
// console.log("cright:"+testswitch.alink);
rails.linkrail[testswitch.alink].lconnect = testswitch.clink;
rails.linkrail[testswitch.clink].rconnect = testswitch.alink;
} else if (rails.switchrail[code].directtype == '2') {
// console.log("道岔朝向2向右");
// console.log("aright:"+testswitch.clink);
// console.log("cleft:"+testswitch.alink);
rails.linkrail[testswitch.alink].rconnect = testswitch.clink;
rails.linkrail[testswitch.clink].lconnect = testswitch.alink;
}
} else if (data.locateType == '01') {
// console.log("01 定位");
if (actions[sectionlist.switchs.modellist[j].code]) {
sectionlist.switchs.modellist[j].locateType = data.locateType;
actions[sectionlist.switchs.modellist[j].code].reset();
actions[sectionlist.switchs.modellist[j].code].time = actions[sectionlist.switchs.modellist[j].code]._clip.duration;
actions[sectionlist.switchs.modellist[j].code].timeScale = -1;
actions[sectionlist.switchs.modellist[j].code].play();
}
rails.switchrail[code].locateType = '01';
const testswitch = rails.switchrail[code];
if (rails.switchrail[code].directtype == '1') {
// console.log("道岔朝向1向左");
// console.log("aleft"+testswitch.blink);
// console.log("cright:"+testswitch.alink);
rails.linkrail[testswitch.alink].lconnect = testswitch.blink;
rails.linkrail[testswitch.blink].rconnect = testswitch.alink;
} else if (rails.switchrail[code].directtype == '2') {
// console.log("道岔朝向2向右");
// console.log("aright:"+testswitch.blink);
// console.log("cleft:"+testswitch.alink);
rails.linkrail[testswitch.alink].rconnect = testswitch.blink;
rails.linkrail[testswitch.blink].lconnect = testswitch.alink;
}
}
}
j = 0;
}
}
}
}

View File

@ -7,7 +7,7 @@ import { FBXLoader } from '@/jlmap3d/main/loaders/FBXLoader';
import { JL3D_LOCAL_STATIC } from '@/api/jlmap3d/assets3d.js'; import { JL3D_LOCAL_STATIC } from '@/api/jlmap3d/assets3d.js';
//data //data
import { Jl3ddata } from '@/jlmap3d/main/model/jl3ddata'; import { Jl3ddata } from '@/jlmap3d/main/newmodel/jl3ddata';
//setconfig //setconfig
import { SetCamera } from '@/jlmap3d/config/SetCamera'; import { SetCamera } from '@/jlmap3d/config/SetCamera';
@ -30,7 +30,6 @@ import { getPublishMapVersion, getPublishMapDetail,getPublish3dMapDetail} from '
//utils //utils
// import { UpdateTrain } from '@/jlmap3d/main/utils/UpdateTrain'; // import { UpdateTrain } from '@/jlmap3d/main/utils/UpdateTrain';
import { UpdateTrain } from '@/jlmap3d/jl3dsimulation/connect/UpdateTrainTest'; import { UpdateTrain } from '@/jlmap3d/jl3dsimulation/connect/UpdateTrainTest';
import { UpdateTrainNew } from '@/jlmap3d/jl3dsimulation/connect/UpdateTrainNew';
// import { ReStart } from '@/jlmap3d/main/utils/ReStart'; // import { ReStart } from '@/jlmap3d/main/utils/ReStart';
import {Stats} from '@/jlmap3d/main/lib/stats.min.js'; import {Stats} from '@/jlmap3d/main/lib/stats.min.js';
@ -198,12 +197,7 @@ export function JLmap3dMaintainer(dom, data,skinCode,storemod,routegroup,project
scope.webwork.onmessage = function (event) { scope.webwork.onmessage = function (event) {
//更新列车位置 //更新列车位置
// if(scope.datatype == "new"){
//
// UpdateTrainNew(camera,trainlisttest);
// }else{
// UpdateTrain(camera,trainlisttest);
// }
if(camerarail.moveswitch == true){ if(camerarail.moveswitch == true){
// console.log(camerarail.progress); // console.log(camerarail.progress);

View File

@ -1,11 +1,4 @@
//componnent //componnent
import {SectionList} from '@/jlmap3d/main/model/SectionList.js';
import {SignalList} from '@/jlmap3d/main/model/SignalList.js';
import {StationStandList} from '@/jlmap3d/main/model/StationStandList.js';
import {TrainList} from '@/jlmap3d/main/model/TrainList.js';
import {RealSectionList} from '@/jlmap3d/main/model/RealSectionList.js';
import {LinkList} from '@/jlmap3d/main/model/LinkList.js';
import {RailList} from '@/jlmap3d/main/model/RailList.js';
import {TrainListN} from '@/jlmap3d/main/newmodel/TrainListN.js'; import {TrainListN} from '@/jlmap3d/main/newmodel/TrainListN.js';
import {SectionListN} from '@/jlmap3d/main/newmodel/SectionListN'; import {SectionListN} from '@/jlmap3d/main/newmodel/SectionListN';
@ -52,8 +45,6 @@ export function MaintainerLoad(data,scope,netdata,mapdata,camera,controls,scene)
let mapdata = data; let mapdata = data;
//初始化轨道和道岔 //初始化轨道和道岔
// lengthfact(data);
// linklist = new LinkList(); // linklist = new LinkList();
sectionlist = new SectionListN(); sectionlist = new SectionListN();
signallist = new SignalListN(); signallist = new SignalListN();
@ -177,39 +168,3 @@ export function MaintainerLoad(data,scope,netdata,mapdata,camera,controls,scene)
} }
function lengthfact(data){
let linklist = [];
//console.log(data);
for(let i=0;i<data.linkList.length;i++){
let dx = Math.abs(data.linkList[i].lp.x - data.linkList[i].rp.x);
    let dy = Math.abs(data.linkList[i].lp.y - data.linkList[i].rp.y);
    let distance = Math.sqrt(Math.pow(dx,2)+Math.pow(dy,2));
let link = {
code:data.linkList[i].code,
lengthfact:data.linkList[i].lengthFact,
distance:distance
};
linklist.push(link);
}
let sectionlist = [];
for(let i=0;i<data.sectionList.length;i++){
for(let j=0;j<linklist.length;j++){
if(linklist[j].code == data.sectionList[i].linkCode){
let sectionoffset = data.sectionList[i].offsetRight - data.sectionList[i].offsetLeft;
let sectionlengthfact = sectionoffset/linklist[j].distance*linklist[j].lengthfact
let section = {
code:data.sectionList[i].code,
lengthfact:sectionoffset
};
sectionlist.push(section);
j = linklist.length;
}
}
}
//console.log(sectionlist);
}

View File

@ -4,7 +4,7 @@ import { getToken } from '@/utils/auth';
import store from '@/store/index_APP_TARGET'; import store from '@/store/index_APP_TARGET';
// 定于仿真socket接口 // 定于仿真socket接口
export function PassflowConnect(jl3dpass,deviceaction,toptrain,downtrain,routegroup) { export function PassflowConnect(deviceaction,toptrain,downtrain,routegroup,passerStation,passerAi) {
const scope = this; const scope = this;
this.teststomp = new StompClient(); this.teststomp = new StompClient();
@ -32,7 +32,7 @@ export function PassflowConnect(jl3dpass,deviceaction,toptrain,downtrain,routegr
if(data.type == "DeviceCtrl_3D"){ if(data.type == "DeviceCtrl_3D"){
if(data.body.type == "PSD"){ if(data.body.type == "PSD"){
if(data.body.code == jl3dpass.nowstation.toppsd){ if(data.body.code == passerStation.nowStation.toppsd){
if(data.body.open == 0){ if(data.body.open == 0){
deviceaction.top.action.reset(); deviceaction.top.action.reset();
@ -40,21 +40,21 @@ export function PassflowConnect(jl3dpass,deviceaction,toptrain,downtrain,routegr
deviceaction.top.action.timeScale = -1; deviceaction.top.action.timeScale = -1;
deviceaction.top.action.play(); deviceaction.top.action.play();
}else{ }else{
jl3dpass.passerout("top") passerAi.passerout("top")
deviceaction.top.action.reset(); deviceaction.top.action.reset();
deviceaction.top.action.time = 0; deviceaction.top.action.time = 0;
deviceaction.top.action.timeScale = 1; deviceaction.top.action.timeScale = 1;
deviceaction.top.action.play(); deviceaction.top.action.play();
} }
} }
if(data.body.code == jl3dpass.nowstation.downpsd){ if(data.body.code == passerStation.nowStation.downpsd){
if(data.body.open == 0){ if(data.body.open == 0){
deviceaction.down.action.reset(); deviceaction.down.action.reset();
deviceaction.down.action.time = deviceaction.down.action._clip.duration; deviceaction.down.action.time = deviceaction.down.action._clip.duration;
deviceaction.down.action.timeScale = -1; deviceaction.down.action.timeScale = -1;
deviceaction.down.action.play(); deviceaction.down.action.play();
}else{ }else{
jl3dpass.passerout("down"); passerAi.passerout("down");
deviceaction.down.action.reset(); deviceaction.down.action.reset();
deviceaction.down.action.time = 0; deviceaction.down.action.time = 0;
deviceaction.down.action.timeScale = 1; deviceaction.down.action.timeScale = 1;
@ -92,7 +92,7 @@ export function PassflowConnect(jl3dpass,deviceaction,toptrain,downtrain,routegr
if(data.type == "TrainRun_3D"){ if(data.type == "TrainRun_3D"){
for(let i=0,leni = data.body.length;i<leni;i++){ for(let i=0,leni = data.body.length;i<leni;i++){
if(data.body[i].section == jl3dpass.nowstation.topsection){ if(data.body[i].section == passerStation.nowStation.topsection){
if(toptrain.nowcode != data.body[i].code){ if(toptrain.nowcode != data.body[i].code){
toptrain.nowcode = data.body[i].code; toptrain.nowcode = data.body[i].code;
} }
@ -104,7 +104,7 @@ export function PassflowConnect(jl3dpass,deviceaction,toptrain,downtrain,routegr
} }
} }
if(data.body[i].section == jl3dpass.nowstation.downsection){ if(data.body[i].section == passerStation.nowStation.downsection){
if(downtrain.nowcode != data.body[i].code){ if(downtrain.nowcode != data.body[i].code){
downtrain.nowcode = data.body[i].code; downtrain.nowcode = data.body[i].code;
} }

View File

@ -1,854 +0,0 @@
import { Staticmodel } from '@/jlmap3d/jl3dpassflow/config.js';
//loader
import { FBXLoader } from '@/jlmap3d/main/loaders/FBXLoader';
import { OrbitControls } from '@/jlmap3d/main/control/OrbitControls';
import { ModelManager } from '@/jlmap3d/jl3dpassflow/loader.js';
import { SkeletonUtils } from '@/jlmap3d/main/utils/SkeletonUtils.js';
import StompClient from '@/utils/sock';
import { Loading } from 'element-ui';
var clock = new THREE.Clock();
let scene,camerass,renderer;
let rendermode = 0;
var mixers = [];
var testmesh1,testmesh2;
var humans = [];
var checkdoor1 = [];
var checkdoor2 = [];
var station;
var zhajiinmodel;
var zhajioutmodel;
var monitor;
let ids = 0;
var rungroup = new THREE.Group();
let originhuman1 = null;
let originhuman2 = null;
let originanima1 = null;
let originanima2 = null;
let lefttrain = null;
let righttrain = null;
let moveanimatelist = [];
let zhajiin = [];
let zhajiout = [];
let deviceaction = [];
for(let i=0;i<5;i++){
checkdoor1[i]={
id:"c1"+i,
status:0,
pos:[],
max:10
};
}
for(let i=0;i<5;i++){
let zhaji = {
id:"in0"+(i+1),
status:0,
waiting:0
}
zhajiin.push(zhaji);
}
for(let i=0;i<5;i++){
let zhaji = {
id:"out0"+(i+1),
status:0,
waiting:0
}
zhajiout.push(zhaji);
}
let stationleft = [];
let stationright = [];
for(let i=0;i<22;i++){
let sl = {
id:"left"+i,
status:0,
waiting:0
}
stationleft.push(sl);
}
for(let i=0;i<22;i++){
let sr = {
id:"right"+i,
status:0,
waiting:0
}
stationright.push(sr);
}
var windowWidth = window.innerWidth ;
var windowHeight = window.innerHeight;
var views = [
{
left: 0,
bottom: 0,
width: 0.5,
height: 0.5,
background: new THREE.Color( 0.5, 0.5, 0.7 ),
eye: [ 3.7, 16, 26 ],
up: [3.7, 10 ,16 ],
fov: 30
},
{
left: 0,
bottom: 0.5,
width: 0.5,
height: 0.5,
background: new THREE.Color( 0.5, 0.5, 0.7 ),
eye: [ 3.7,17,-4 ],
up: [ 3.7, 10 ,16],
fov: 30
},
{
left: 0.5,
bottom: 0,
width: 0.5,
height: 0.5,
background: new THREE.Color( 0.7, 0.5, 0.5 ),
eye: [ -60, 6,11],
up: [ -59, 5.9,11 ],
fov: 45
},
{
left: 0.5,
bottom: 0.5,
width: 0.5,
height: 0.5,
background: new THREE.Color( 0.5, 0.7, 0.7 ),
eye: [ -7,17,2],
up: [-7, 10, 8],
fov: 60
}
];
export function Jl3dpassflow(dom) {
var scope = this;
this.dom = dom;
this.nowcode = null;
this.animateswitch = false;
this.signallights = [];
this.mixers = [];
this.showmodel = null;
//初始化webgl渲染
renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setClearColor(new THREE.Color(0x000000));
renderer.setSize(dom.offsetWidth, dom.offsetHeight);
this.dom.appendChild(renderer.domElement);
//定义相机
camerass = new THREE.PerspectiveCamera(70, dom.offsetWidth / dom.offsetHeight, 0.01, 1000);
camerass.position.set(0, 80, 40);
camerass.aspect = dom.offsetWidth / dom.offsetHeight;
camerass.updateProjectionMatrix();
for ( var ii = 0; ii < views.length; ++ ii ) {
var view = views[ ii ];
var camera = new THREE.PerspectiveCamera( view.fov, window.innerWidth / window.innerHeight, 1, 200 );
camera.position.fromArray( view.eye );
camera.lookAt( view.up[0],view.up[1],view.up[2] );
view.camera = camera;
}
//定义场景(渲染容器)
scene = new THREE.Scene();
scene.background = new THREE.Color(0xa0a0a0);
var mesh = new THREE.Mesh(new THREE.PlaneBufferGeometry(200, 200), new THREE.MeshPhongMaterial({ color: 0x999999, depthWrite: false }));
mesh.rotation.x = - Math.PI / 2;
mesh.receiveShadow = true;
scene.add(mesh);
var grid = new THREE.GridHelper(200, 20, 0x000000, 0x000000);
grid.material.opacity = 0.2;
grid.material.transparent = true;
scene.add(grid);
//定义全局光
let ambientLight = new THREE.AmbientLight(0xffffff, 1.3);
scene.add(ambientLight);
//
// var spotLight = new THREE.SpotLight(0xffffff);
// spotLight.position.set(-50, 60, 15);
// spotLight.castShadow = true;
// spotLight.shadow.mapSize.width = 1024;
// spotLight.shadow.mapSize.height = 1024;
// scene.add(spotLight);
this.controls = new THREE.OrbitControls(camerass, dom);
this.controls.maxPolarAngle = Math.PI / 2;
this.controls.minPolarangle = Math.PI / 5;
this.controls.maxDistance = 800;
this.controls.screenSpacePanning = true;
this.controls.update();
this.selectmodel = null;
window.onresize = function () {
renderer.setSize(scope.dom.offsetWidth, scope.dom.offsetHeight);
windowWidth = scope.dom.offsetWidth ;
windowHeight = scope.dom.offsetHeight;
camerass.aspect = scope.dom.offsetWidth / scope.dom.offsetHeight;
camerass.updateProjectionMatrix();
}
this.anime = null;
this.modelmanager = new ModelManager();
let loadingInstance = Loading.service({ fullscreen: true });
this.modelmanager.loadpromise(Staticmodel, scope.mixers).then(function (data) {
// console.log(scope.modelmanager);
initstationanimation(scope.modelmanager.station.mesh);
initzhajiinaimation(scope.modelmanager.zhajiin.mesh);
initzhajioutanimation(scope.modelmanager.zhajiout.mesh);
monitor = scope.modelmanager.monitor.mesh;
scene.add(monitor);
originhuman1 = scope.modelmanager.man1.mesh;
originhuman2 = scope.modelmanager.man2.mesh;
let mixer1 = new THREE.AnimationMixer( originhuman1 );
let mixer2 = new THREE.AnimationMixer( originhuman2 );
originanima1 = originhuman1.animations[ 0 ];
originanima2 = originhuman2.animations[ 0 ];
originhuman1.remove(originhuman1.children[2]);
scene.add(rungroup);
loadingInstance.close();
scope.switchrender(false);
animate();
})
let checkobject = setInterval(function(){
// console.log(originhuman1);
if(originhuman1){
console.log("start");
clearInterval(checkobject);
//进站控制
setInterval(function(){
// console.log("ww");
// console.log(humans.length);
if(humans){
// console.log(humans.length);
if(humans.length<500){
newhumancreate();
}
// console.log(humans.length);
for(let i=0;i<humans.length;i++){
// console.log(humans[i]);
if(humans[i].status == 0){
if(humans[i].stage == 1){
let points = [];
points.push(new THREE.Vector3(humans[i].mesh.position.x,humans[i].mesh.position.y,humans[i].mesh.position.z));
points.push(new THREE.Vector3(humans[i].mesh.position.x,humans[i].mesh.position.y,humans[i].mesh.position.z-5));
zhajicontrol("in",humans[i].doors);
moveanimateinit(humans[i],i,points,i,0.02);
}
if(humans[i].stage == 2){
let points = [];
points.push(new THREE.Vector3(humans[i].mesh.position.x,humans[i].mesh.position.y,humans[i].mesh.position.z));
points.push(new THREE.Vector3(12,10,12.9));
points.push(new THREE.Vector3(28,1.7,12.9));
points.push(new THREE.Vector3(34,1.7,12.9));
//1--left
//2-- right
if(humans[i].direct == 1){
points.push(new THREE.Vector3(34,1.7,16));
for(let j =0;j<22;j++){
if(stationleft[j].waiting == 0){
points.push(new THREE.Vector3(51-j*5,1.7,22));
points.push(new THREE.Vector3(51-j*5,1.7,23));
humans[i].doors = j;
stationright[j].waiting = 1;
moveanimateinit(humans[i],i,points,i,0.002);
j =22;
}
}
}else{
points.push(new THREE.Vector3(34,1.7,16));
points.push(new THREE.Vector3(14,1.7,17));
points.push(new THREE.Vector3(14,1.7,3));
for(let j =0;j<22;j++){
if(stationright[j].waiting == 0){
points.push(new THREE.Vector3(51-j*5,1.7,3));
points.push(new THREE.Vector3(51-j*5,1.7,2));
humans[i].doors = j;
stationright[j].waiting = 1;
moveanimateinit(humans[i],i,points,i,0.002);
j =22;
}
}
}
moveanimateinit(humans[i],i,points,i,0.002);
}
//出站
if(humans[i].stage == 3){
let points = [];
points.push(new THREE.Vector3(humans[i].mesh.position.x,humans[i].mesh.position.y,humans[i].mesh.position.z));
if(humans[i].doors<11){
if(humans[i].direct == 1){
points.push(new THREE.Vector3(10,1.7,17));
}else{
points.push(new THREE.Vector3(8,1.7,5));
}
points.push(new THREE.Vector3(8,1.7,13));
points.push(new THREE.Vector3(5,1.7,13));
points.push(new THREE.Vector3(-4,6,13));
}else{
if(humans[i].direct == 1){
points.push(new THREE.Vector3(-19,1.7,17));
}else{
points.push(new THREE.Vector3(-18,1.7,6.4));
}
points.push(new THREE.Vector3(-18,1.7,13));
points.push(new THREE.Vector3(-12,1.7,13));
points.push(new THREE.Vector3(-7,6.8,12));
}
points.push(new THREE.Vector3(-5,10,4));
points.push(new THREE.Vector3(14,10,3));
var j = Math.floor(Math.random()*(4-1+1))+1;
points.push(new THREE.Vector3(19,10,-2+j*1.4));
humans[i].doors = j;
moveanimateinit(humans[i],i,points,i,0.002);
}
if(humans[i].stage == 4){
let points = [];
points.push(new THREE.Vector3(humans[i].mesh.position.x,humans[i].mesh.position.y,humans[i].mesh.position.z));
points.push(new THREE.Vector3(humans[i].mesh.position.x+4,humans[i].mesh.position.y,humans[i].mesh.position.z));
if(humans[i].direct == 1){
points.push(new THREE.Vector3(33,10,25));
}else{
points.push(new THREE.Vector3(33.5,10,-5));
}
zhajicontrol("out",humans[i].doors);
moveanimateinit(humans[i],i,points,i,0.002);
}
}
}
}
},1000);
};
},1000);
this.switchrender = function(mode){
if(mode){
rendermode = 0;
renderer.setViewport( 0, 0, scope.dom.offsetWidth, scope.dom.offsetHeight );
renderer.setScissor( 0, 0, scope.dom.offsetWidth, scope.dom.offsetHeight );
renderer.setScissorTest( false );
renderer.setSize(scope.dom.offsetWidth, scope.dom.offsetHeight);
camerass.aspect = dom.offsetWidth / dom.offsetHeight;
camerass.updateProjectionMatrix();
}else{
rendermode = 1;
}
}
//循环渲染函数
function animate() {
// console.log(rendermode);
if(rendermode == 0){
renderer.render(scene, camerass);
scope.controls.update();
}else{
monitorrender();
}
let delta = clock.getDelta();
for(let i=mixers.length-1;i>=0;i--){
if ( mixers[i] && mixers[i].runplay == true){
mixers[i].update( delta );
}
}
moveanimateupdate();
requestAnimationFrame(animate);
}
function moveanimateinit(model,name,points,index,speed){
let curve = new THREE.CatmullRomCurve3(points);
curve.curvrtype = "chordal";
// curve动画轨迹
// progress动画进度
// enable当前动画开关
// speed动画速度
let animate = {
name:index,
index:index,
curve:curve,
progress:0,
directchange:false,
enable:true,
status:"start",
speed:speed,
};
humans[index].runrail = animate;
humans[index].status = 1;
humans[index].action.play();
humans[index].mixer.runplay = true;
moveanimatelist.push(animate);
}
function moveanimateupdate(){
if(humans.length>0){
for(let i=0;i<humans.length;i++){
if(humans[i].runrail.enable){
// 动画播放结束
if(humans[i].runrail.progress>=1){
// let point = humans[i].runrail.curve.getPointAt(1);
//更新模型坐标
// console.log(moveanimatelist);
if(humans[i].status == 1){
humans[i].runrail.enable = false;
humans[i].runrail.progress = 1;
humans[i].mixer.runplay = false;
humans[i].action.stop();
humans[i].status = 0;
if(humans[i].stage == 4){
rungroup.remove(humans[i].mesh);
// humans.splice(i,1);
}
if(humans[i].stage == 3){
if(humans[i].direct == 1){
stationleft[humans[i].doors].waiting = 0;
}else{
stationright[humans[i].doors].waiting = 0;
}
humans[i].stage = 4;
}
if(humans[i].stage == 2){
humans[i].stage = 3;
}
if(humans[i].stage == 1){
humans[i].stage = 2;
}
if(humans[i].stage == 0){
// console.log(humans[i].doors);
zhajiin[humans[i].doors].waiting = 0;
humans[i].stage = 1;
}
moveanimatelist.splice(i,1);
}
}else{
//根据动画进度获取动画轨迹上点
let point = humans[i].runrail.curve.getPointAt(humans[i].runrail.progress);
//更新模型坐标
humans[i].mesh.position.x = point.x;
humans[i].mesh.position.y = point.y;
humans[i].mesh.position.z = point.z;
if((humans[i].runrail.progress+0.001)<1){
let tangent = humans[i].runrail.curve.getPointAt(humans[i].runrail.progress+0.001);
humans[i].mesh.lookAt(new THREE.Vector3(tangent.x,humans[i].mesh.position.y,tangent.z));
}
humans[i].runrail.progress += humans[i].runrail.speed;
point = null;
}
}
}
}
}
function newhumancreate(){
var direct = Math.floor(Math.random()*(3-1+1))+1;
var mantype = Math.floor(Math.random()*(3-1+1))+1;
// console.log(direct);
let points = [];
let newhuman;
if(mantype == 1){
newhuman = THREE.SkeletonUtils.clone( originhuman1 );
newhuman.animations = [];
newhuman.animations.push(originanima1.clone());
}else{
newhuman = THREE.SkeletonUtils.clone( originhuman2 );
newhuman.animations = [];
newhuman.animations.push(originanima2.clone());
}
if(direct == 1|| direct == 2){
newhuman.position.set(32,10,25);
points.push(new THREE.Vector3(32,10,25));
points.push(new THREE.Vector3(26,10,21));
points.push(new THREE.Vector3(18,10,18));
}else{
newhuman.position.set(32,10,-5);
points.push(new THREE.Vector3(32,10,-5));
points.push(new THREE.Vector3(26,10,12));
points.push(new THREE.Vector3(24,10,17));
points.push(new THREE.Vector3(18,10,18));
}
let j = Math.floor(Math.random()*(4-1+1))+1;
points.push(new THREE.Vector3(-0.5+j*1.4,10,18.5));
// zhajiin[j].waiting = 1;
let mixer = new THREE.AnimationMixer( newhuman );
mixer.runplay = false;
let action = mixer.clipAction( newhuman.animations[ 0 ] );
var stationdirection = Math.floor(Math.random()*(2-1+1))+1;
let newone = {
id:humans.length,
mesh:newhuman,
status:1,
stage:0,
direct:stationdirection,
doorstatus:null,
doors:j,
action:action,
mixer:mixer,
runrail:null
};
humans.push(newone);
mixers.push(mixer);
rungroup.add(newhuman);
moveanimateinit(newone,humans.length,points,newone.id,0.002);
// return newone;
}
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"){
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();
mixer.runplay = true;
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;
mixer.runplay = true;
mixers.push(mixer);
let device = {
action:action,
mixer:mixer,
};
deviceaction[object.children[j].name] = device;
}
}
station = object;
scene.add(object);
}
function initzhajiinaimation(object){
let mixer = new THREE.AnimationMixer( object );
let newclip = object.animations[ 0 ];
let newzhaji = object;
for(let i=0;i<newzhaji.children.length;i++){
if(newzhaji.children[i].name == "in01"){
newzhaji.children[i].animations = [];
newzhaji.children[i].animations.push(newclip.clone());
let mixer = new THREE.AnimationMixer( newzhaji.children[i] );
let action =mixer.clipAction( newzhaji.children[i].animations[0]);
action.setLoop(THREE.LoopOnce);
action.clampWhenFinished = true;
mixer.runplay = true;
mixers.push(mixer);
let device = {
action:action,
mixer:mixer,
};
deviceaction[object.children[i].name] = device;
}
if(newzhaji.children[i].name == "in02"){
newzhaji.children[i].animations = [];
newzhaji.children[i].animations.push(newclip.clone());
let mixer = new THREE.AnimationMixer( newzhaji.children[i] );
let action =mixer.clipAction( newzhaji.children[i].animations[0]);
action.setLoop(THREE.LoopOnce);
action.clampWhenFinished = true;
mixer.runplay = true;
mixers.push(mixer);
let device = {
action:action,
mixer:mixer,
};
deviceaction[object.children[i].name] = device;
}
if(newzhaji.children[i].name == "in03"){
newzhaji.children[i].animations = [];
newzhaji.children[i].animations.push(newclip.clone());
let mixer = new THREE.AnimationMixer( newzhaji.children[i] );
let action =mixer.clipAction( newzhaji.children[i].animations[0]);
action.setLoop(THREE.LoopOnce);
action.clampWhenFinished = true;
mixer.runplay = true;
mixers.push(mixer);
let device = {
action:action,
mixer:mixer,
};
deviceaction[object.children[i].name] = device;
}
if(newzhaji.children[i].name == "in04"){
newzhaji.children[i].animations = [];
newzhaji.children[i].animations.push(newclip.clone());
let mixer = new THREE.AnimationMixer( newzhaji.children[i] );
let action =mixer.clipAction( newzhaji.children[i].animations[0]);
action.setLoop(THREE.LoopOnce);
action.clampWhenFinished = true;
mixer.runplay = true;
mixers.push(mixer);
let device = {
action:action,
mixer:mixer,
};
deviceaction[object.children[i].name] = device;
}
if(newzhaji.children[i].name == "in05"){
newzhaji.children[i].animations = [];
newzhaji.children[i].animations.push(newclip.clone());
let mixer = new THREE.AnimationMixer( newzhaji.children[i] );
let action =mixer.clipAction( newzhaji.children[i].animations[0]);
action.setLoop(THREE.LoopOnce);
action.clampWhenFinished = true;
mixer.runplay = true;
mixers.push(mixer);
let device = {
action:action,
mixer:mixer,
};
deviceaction[object.children[i].name] = device;
}
}
zhajiinmodel = newzhaji;
scene.add(newzhaji);
}
function initzhajioutanimation(object){
let mixer = new THREE.AnimationMixer( object );
let newclip = object.animations[ 0 ];
let newzhaji = object;
for(let i=0;i<newzhaji.children.length;i++){
if(newzhaji.children[i].name == "out01"){
newzhaji.children[i].animations = [];
newzhaji.children[i].animations.push(newclip.clone());
let mixer = new THREE.AnimationMixer( newzhaji.children[i] );
let action =mixer.clipAction( newzhaji.children[i].animations[0]);
action.setLoop(THREE.LoopOnce);
action.clampWhenFinished = true;
mixer.runplay = true;
mixers.push(mixer);
let device = {
action:action,
mixer:mixer,
};
deviceaction[object.children[i].name] = device;
}
if(newzhaji.children[i].name == "out02"){
newzhaji.children[i].animations = [];
newzhaji.children[i].animations.push(newclip.clone());
let mixer = new THREE.AnimationMixer( newzhaji.children[i] );
let action =mixer.clipAction( newzhaji.children[i].animations[0]);
action.setLoop(THREE.LoopOnce);
action.clampWhenFinished = true;
mixer.runplay = true;
mixers.push(mixer);
let device = {
action:action,
mixer:mixer,
};
deviceaction[object.children[i].name] = device;
}
if(newzhaji.children[i].name == "out03"){
newzhaji.children[i].animations = [];
newzhaji.children[i].animations.push(newclip.clone());
let mixer = new THREE.AnimationMixer( newzhaji.children[i] );
let action =mixer.clipAction( newzhaji.children[i].animations[0]);
action.setLoop(THREE.LoopOnce);
action.clampWhenFinished = true;
mixer.runplay = true;
mixers.push(mixer);
let device = {
action:action,
mixer:mixer,
};
deviceaction[object.children[i].name] = device;
}
if(newzhaji.children[i].name == "out04"){
newzhaji.children[i].animations = [];
newzhaji.children[i].animations.push(newclip.clone());
let mixer = new THREE.AnimationMixer( newzhaji.children[i] );
let action =mixer.clipAction( newzhaji.children[i].animations[0]);
action.setLoop(THREE.LoopOnce);
action.clampWhenFinished = true;
mixer.runplay = true;
mixers.push(mixer);
let device = {
action:action,
mixer:mixer,
};
deviceaction[object.children[i].name] = device;
}
if(newzhaji.children[i].name == "out05"){
newzhaji.children[i].animations = [];
newzhaji.children[i].animations.push(newclip.clone());
let mixer = new THREE.AnimationMixer( newzhaji.children[i] );
let action =mixer.clipAction( newzhaji.children[i].animations[0]);
action.setLoop(THREE.LoopOnce);
action.clampWhenFinished = true;
mixer.runplay = true;
mixers.push(mixer);
let device = {
action:action,
mixer:mixer,
};
deviceaction[object.children[i].name] = device;
}
}
zhajioutmodel = newzhaji
scene.add(newzhaji);
}
function zhajicontrol(type,door){
let devicenum = door-1;
if(type == "in"){
deviceaction[zhajiin[devicenum].id].action.reset();
deviceaction[zhajiin[devicenum].id].action.time = 0;
deviceaction[zhajiin[devicenum].id].action.timeScale = 1;
deviceaction[zhajiin[devicenum].id].action.play();
}else if(type == "out"){
deviceaction[zhajiout[devicenum].id].action.reset();
deviceaction[zhajiout[devicenum].id].action.time = 0;
deviceaction[zhajiout[devicenum].id].action.timeScale = 1;
deviceaction[zhajiout[devicenum].id].action.play();
}
}
function monitorrender() {
// updateSize();
for ( var ii = 0; ii < views.length; ++ ii ) {
var view = views[ ii ];
var camera = view.camera;
// view.updateCamera( camera, scene, mouseX, mouseY );
var left = Math.floor( windowWidth * view.left );
var bottom = Math.floor( windowHeight * view.bottom );
var width = Math.floor( windowWidth * view.width );
var height = Math.floor( windowHeight * view.height );
renderer.setViewport( left, bottom, width, height );
renderer.setScissor( left, bottom, width, height );
renderer.setScissorTest( true );
camera.aspect = width / height;
camera.updateProjectionMatrix();
renderer.render( scene, camera );
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
import { BASE_ASSET_API } from '@/api/jlmap3d/assets3d.js'; import { BASE_ASSET_API } from '@/api/jlmap3d/assets3d.js';
//模型管理器
export function ModelManager(){ export function ModelManager(){
let scope = this; let scope = this;
@ -65,7 +65,7 @@ export function ModelManager(){
action:null action:null
}; };
//读取模型
this.loadpromise = function (data,mixers){ this.loadpromise = function (data,mixers){
let initlist = []; let initlist = [];
for(let i=0,leni=data.length;i<leni;i++){ for(let i=0,leni=data.length;i<leni;i++){
@ -95,7 +95,7 @@ export function ModelManager(){
initlist.push(fbxpromise(data[i],mixers,scope.section)); initlist.push(fbxpromise(data[i],mixers,scope.section));
} }
} }
//promise按顺序加载
return new Promise(function(resolve, reject){ return new Promise(function(resolve, reject){
Promise.all(initlist).then((result) => { Promise.all(initlist).then((result) => {
@ -108,18 +108,13 @@ export function ModelManager(){
} }
} }
//fbx模型加载
function fbxpromise(asset,mixers,model){ function fbxpromise(asset,mixers,model){
return new Promise(function(resolve, reject){ return new Promise(function(resolve, reject){
var loader = new THREE.FBXLoader(); var loader = new THREE.FBXLoader();
loader.load( BASE_ASSET_API+asset.url, function ( object ) { loader.load( BASE_ASSET_API+asset.url, function ( object ) {
// let mixer = new THREE.AnimationMixer( object );
// object.traverse( function ( child ) { //列车模型子物体重新排序
// if ( child.isMesh ) {
// child.castShadow = true;
// child.receiveShadow = true;
// }
// } );
if(asset.type == "cctvTrain"){ if(asset.type == "cctvTrain"){
// let mixer = new THREE.AnimationMixer( object ); // let mixer = new THREE.AnimationMixer( object );
let realtrain = new THREE.Group(); let realtrain = new THREE.Group();

View File

@ -0,0 +1,230 @@
export function PasserCheckDoor(data) {
var scope = this;
//入口闸机组
this.zhajiin = [];
//出口闸机组
this.zhajiout = [];
//定义闸机状态
for(let i=0;i<5;i++){
let zhaji = {
id:"in0"+(i+1),
status:0,
waiting:0
}
scope.zhajiin.push(zhaji);
}
for(let i=0;i<5;i++){
let zhaji = {
id:"out0"+(i+1),
status:0,
waiting:0
}
scope.zhajiout.push(zhaji);
}
//初始化闸机动画
this.initCheckDoorInAnimation = function(object,mixers ,deviceaction ,scene){
let mixer = new THREE.AnimationMixer( object );
let newclip = object.animations[ 0 ];
let newzhaji = object;
for(let i=0;i<newzhaji.children.length;i++){
if(newzhaji.children[i].name == "in01"){
newzhaji.children[i].animations = [];
newzhaji.children[i].animations.push(newclip.clone());
let mixer = new THREE.AnimationMixer( newzhaji.children[i] );
let action =mixer.clipAction( newzhaji.children[i].animations[0]);
action.setLoop(THREE.LoopOnce);
action.clampWhenFinished = true;
mixers.push(mixer);
let device = {
action:action,
mixer:mixer,
};
deviceaction[object.children[i].name] = device;
}
if(newzhaji.children[i].name == "in02"){
newzhaji.children[i].animations = [];
newzhaji.children[i].animations.push(newclip.clone());
let mixer = new THREE.AnimationMixer( newzhaji.children[i] );
let action =mixer.clipAction( newzhaji.children[i].animations[0]);
action.setLoop(THREE.LoopOnce);
action.clampWhenFinished = true;
mixers.push(mixer);
let device = {
action:action,
mixer:mixer,
};
deviceaction[object.children[i].name] = device;
}
if(newzhaji.children[i].name == "in03"){
newzhaji.children[i].animations = [];
newzhaji.children[i].animations.push(newclip.clone());
let mixer = new THREE.AnimationMixer( newzhaji.children[i] );
let action =mixer.clipAction( newzhaji.children[i].animations[0]);
action.setLoop(THREE.LoopOnce);
action.clampWhenFinished = true;
mixers.push(mixer);
let device = {
action:action,
mixer:mixer,
};
deviceaction[object.children[i].name] = device;
}
if(newzhaji.children[i].name == "in04"){
newzhaji.children[i].animations = [];
newzhaji.children[i].animations.push(newclip.clone());
let mixer = new THREE.AnimationMixer( newzhaji.children[i] );
let action =mixer.clipAction( newzhaji.children[i].animations[0]);
action.setLoop(THREE.LoopOnce);
action.clampWhenFinished = true;
mixers.push(mixer);
let device = {
action:action,
mixer:mixer,
};
deviceaction[object.children[i].name] = device;
}
if(newzhaji.children[i].name == "in05"){
newzhaji.children[i].animations = [];
newzhaji.children[i].animations.push(newclip.clone());
let mixer = new THREE.AnimationMixer( newzhaji.children[i] );
let action =mixer.clipAction( newzhaji.children[i].animations[0]);
action.setLoop(THREE.LoopOnce);
action.clampWhenFinished = true;
mixers.push(mixer);
let device = {
action:action,
mixer:mixer,
};
deviceaction[object.children[i].name] = device;
}
}
scene.add(newzhaji);
}
//初始化闸机动画
this.initCheckDoorOutAnimation = function(object,mixers ,deviceaction ,scene){
let mixer = new THREE.AnimationMixer( object );
let newclip = object.animations[ 0 ];
let newzhaji = object;
for(let i=0;i<newzhaji.children.length;i++){
if(newzhaji.children[i].name == "out01"){
newzhaji.children[i].animations = [];
newzhaji.children[i].animations.push(newclip.clone());
let mixer = new THREE.AnimationMixer( newzhaji.children[i] );
let action =mixer.clipAction( newzhaji.children[i].animations[0]);
action.setLoop(THREE.LoopOnce);
action.clampWhenFinished = true;
mixers.push(mixer);
let device = {
action:action,
mixer:mixer,
};
deviceaction[object.children[i].name] = device;
}
if(newzhaji.children[i].name == "out02"){
newzhaji.children[i].animations = [];
newzhaji.children[i].animations.push(newclip.clone());
let mixer = new THREE.AnimationMixer( newzhaji.children[i] );
let action =mixer.clipAction( newzhaji.children[i].animations[0]);
action.setLoop(THREE.LoopOnce);
action.clampWhenFinished = true;
mixers.push(mixer);
let device = {
action:action,
mixer:mixer,
};
deviceaction[object.children[i].name] = device;
}
if(newzhaji.children[i].name == "out03"){
newzhaji.children[i].animations = [];
newzhaji.children[i].animations.push(newclip.clone());
let mixer = new THREE.AnimationMixer( newzhaji.children[i] );
let action =mixer.clipAction( newzhaji.children[i].animations[0]);
action.setLoop(THREE.LoopOnce);
action.clampWhenFinished = true;
mixers.push(mixer);
let device = {
action:action,
mixer:mixer,
};
deviceaction[object.children[i].name] = device;
}
if(newzhaji.children[i].name == "out04"){
newzhaji.children[i].animations = [];
newzhaji.children[i].animations.push(newclip.clone());
let mixer = new THREE.AnimationMixer( newzhaji.children[i] );
let action =mixer.clipAction( newzhaji.children[i].animations[0]);
action.setLoop(THREE.LoopOnce);
action.clampWhenFinished = true;
mixers.push(mixer);
let device = {
action:action,
mixer:mixer,
};
deviceaction[object.children[i].name] = device;
}
if(newzhaji.children[i].name == "out05"){
newzhaji.children[i].animations = [];
newzhaji.children[i].animations.push(newclip.clone());
let mixer = new THREE.AnimationMixer( newzhaji.children[i] );
let action =mixer.clipAction( newzhaji.children[i].animations[0]);
action.setLoop(THREE.LoopOnce);
action.clampWhenFinished = true;
mixers.push(mixer);
let device = {
action:action,
mixer:mixer,
};
deviceaction[object.children[i].name] = device;
}
}
scene.add(newzhaji);
}
//闸机动画控制
this.checkDoorControl = function(type,door,deviceaction){
let devicenum = door;
if(type == "in"){
let checkDoorId = scope.zhajiin[devicenum].id;
deviceaction[checkDoorId].action.reset();
deviceaction[checkDoorId].action.time = 0;
deviceaction[checkDoorId].action.timeScale = 1;
deviceaction[checkDoorId].action.play();
}else if(type == "out"){
let checkDoorId = scope.zhajiout[devicenum].id;
deviceaction[checkDoorId].action.reset();
deviceaction[checkDoorId].action.time = 0;
deviceaction[checkDoorId].action.timeScale = 1;
deviceaction[checkDoorId].action.play();
}
}
}

View File

@ -0,0 +1,174 @@
export function PasserHuman() {
let scope = this;
//初始人物模型和动画
let originhuman1 = null;
let originhuman2 = null;
let originanima1 = null;
let originanima2 = null;
//初始化人物模型动画
this.initHumans = function(object1,object2,mixers,deviceaction,scene){
originhuman1 = object1;
originhuman1.progress = 1;
// scene.add(originhuman1);
originhuman2 = object2;
let mixer1 = new THREE.AnimationMixer( originhuman1 );
let mixer2 = new THREE.AnimationMixer( originhuman2 );
originanima1 = originhuman1.animations[ 0 ];
originanima2 = originhuman2.animations[ 0 ];
originhuman1.remove(originhuman1.children[2]);
}
//创建新的乘客
this.newHumanCreate = function(humanlist,position,stage,direct,door){
let mantype = Math.floor(Math.random()*(3-1+1))+1;
let newhuman;
if(mantype == 1){
newhuman = THREE.SkeletonUtils.clone( originhuman1 );
newhuman.animations = [];
newhuman.animations.push(originanima1.clone());
}else{
newhuman = THREE.SkeletonUtils.clone( originhuman2 );
newhuman.animations = [];
newhuman.animations.push(originanima2.clone());
}
let mixer = new THREE.AnimationMixer( newhuman );
newhuman.position.copy(position);
newhuman.status = 0;
newhuman.stage = stage;
if(direct){
if(direct == "top"){
newhuman.rotation.y = Math.PI;
}
newhuman.direct = direct;
}else{
newhuman.direct = null;
}
newhuman.doorstatus = null;
if(door){
newhuman.door = door;
}else{
newhuman.door = null;
}
newhuman.action = mixer.clipAction( newhuman.animations[ 0 ] );
newhuman.mixer = mixer;
newhuman.runrail = null;
newhuman.speed = 0;
newhuman.mixer = mixer;
humanlist.add(newhuman);
// console.log(humanlist.children.length);
}
//定义新模型走路动画
this.initMoveAnimate = function(model,name,points,index){
model.status = 1;
let curve = new THREE.CatmullRomCurve3(points);
curve.curvrtype = "catmullrom";
// curve.getLength();
// curve动画轨迹
// progress动画进度
// enable当前动画开关
// speed动画速度
// console.log(curve);
model.action.play();
model.progress = 0;
model.runrail = curve;
model.speed = 0.2/curve.getLength();
}
//更新人物列表中人物的动画
this.moveAnimateUpdate = function(humanlist,olddataai,passerHuman){
for(let i=0;i<humanlist.children.length;i++){
if(humanlist.children[i].status == 1){
if(humanlist.children[i].progress>=1){
//更新模型坐标
if(humanlist.children[i].status == 1){
humanlist.children[i].progress = 1;
humanlist.children[i].action.stop();
humanlist.children[i].status = 0;
if(humanlist.children[i].stage == 8){
passerHuman.uncache(humanlist.children[i]);
humanlist.remove(humanlist.children[i]);
i--;
}else if(humanlist.children[i].stage == 7){
humanlist.children[i].stage = 8;
}
// else if(humanlist.children[i].stage == 6){
//
// humanlist.children[i].stage = 7;
//
// }
else if(humanlist.children[i].stage == 5){
humanlist.children[i].stage = 7;
}else if(humanlist.children[i].stage == 4){
passerHuman.uncache(humanlist.children[i]);
humanlist.remove(humanlist.children[i]);
i--;
}else if(humanlist.children[i].stage == 3){
humanlist.children[i].stage = 4;
if(olddataai){
humanlist.children[i].stage = 5;
}
}else if(humanlist.children[i].stage == 2){
humanlist.children[i].stage = 3;
}else if(humanlist.children[i].stage == 1){
humanlist.children[i].stage = 2;
}else if(humanlist.children[i].stage == 0){
// // console.log(humans[i].doors);
// zhajiin[humanlist.children[i].doors].waiting = 0;
humanlist.children[i].stage = 1;
}
}
}else{
//根据动画进度获取动画轨迹上点
// console.log(i);
// console.log(humanlist.children[i].runrail);
// console.log(humanlist.children[i].progress);
let point = humanlist.children[i].runrail.getPointAt(humanlist.children[i].progress);
//更新模型坐标
humanlist.children[i].position.x = point.x;
humanlist.children[i].position.y = point.y;
humanlist.children[i].position.z = point.z;
if((humanlist.children[i].progress+0.001)<1){
let tangent = humanlist.children[i].runrail.getPointAt(humanlist.children[i].progress+0.001);
humanlist.children[i].lookAt(new THREE.Vector3(tangent.x,humanlist.children[i].position.y,tangent.z));
}
humanlist.children[i].progress += humanlist.children[i].speed;
point = null;
}
}
}
}
//离开车站释放缓存
this.uncache = function(uncachemodel){
if(uncachemodel){
uncachemodel.mixer.uncacheAction();
uncachemodel.traverse( function ( child ) {
if ( child.isMesh ) {
child.geometry.dispose();
child.material.dispose();
}
} );
}
}
}

View File

@ -0,0 +1,176 @@
import {Materialload} from '@/jlmap3d/main/loaders/Materialload.js';
export function PasserStation() {
var scope = this;
this.stationMesh = null;
this.stationleft = [];
this.stationright = [];
//替换材质组(站台的)
this.stationtexture = [];
this.stationlist = [];
this.nowStation = null;
for(let i=0;i<22;i++){
let sl = {
id:"left"+i,
status:0,
waiting:0
}
scope.stationleft.push(sl);
}
for(let i=0;i<22;i++){
let sr = {
id:"right"+i,
status:0,
waiting:0
}
scope.stationright.push(sr);
}
//初始化车站模型动画
this.initStationAnimation = function( object,mixers ,deviceaction ,scene){
let mixer = new THREE.AnimationMixer( object ,mixers ,deviceaction ,scene);
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;
}
}
object.traverse( function ( child ) {
if ( child.isMesh ) {
child.renderOrder = 9;
}
} );
scope.stationMesh = object;
// console.log(deviceaction);
scene.add(object);
}
//初始化车站名称数据
this.initStationList = function(stationdata,standdata,psddata){
let list = [];
if(psddata){
for(let i=0,leni = standdata.length;i<leni;i++){
for(let j=0,lenj = psddata.length;j<lenj;j++){
if(standdata[i].code == psddata[j].standCode){
standdata[i].name = psddata[j].code;
}
}
}
for(let i=0,leni = stationdata.length;i<leni;i++){
if(stationdata[i].depot == false){
list[stationdata[i].name] = [];
for(let j=0,lenj = standdata.length;j<lenj;j++){
if(standdata[j].stationCode == stationdata[i].code){
list[stationdata[i].name].push(standdata[j]);
}
}
}
}
for(let k in list){
if(list[k].length>0){
let stationobject = {
code : list[k][0].stationCode,
name : k,
toppsd:null,
downpsd:null,
topsection:null,
downsection:null,
};
if(list[k][0].position.y<list[k][1].position.y){
stationobject.toppsd = list[k][0].name;
stationobject.downpsd = list[k][1].name;
stationobject.topsection = list[k][0].standTrackCode;
stationobject.downsection = list[k][1].standTrackCode;
}else{
stationobject.toppsd = list[k][1].name;
stationobject.downpsd = list[k][0].name;
stationobject.topsection = list[k][1].standTrackCode;
stationobject.downsection = list[k][0].standTrackCode;
}
scope.stationlist.push(stationobject);
}
}
scope.nowStation = scope.stationlist[0];
if(scope.stationtexture["stationlist"]){
scope.stationMesh.getObjectByName("zhantailiebiao").material.map =scope.stationtexture["stationlist"];
scope.stationMesh.getObjectByName("zhantailiebiao").material.map.needsUpdate = true;
if(scope.stationMesh.getObjectByName("menkuangyanse")){
scope.stationMesh.getObjectByName("menkuangyanse").material.map =scope.stationtexture["pingbimen"];
scope.stationMesh.getObjectByName("menkuangyanse").material.map.needsUpdate = true;
}
scope.stationMesh.getObjectByName("zhantaiming").material.map = scope.stationtexture[scope.nowStation.code];
scope.stationMesh.getObjectByName("zhantaiming").material.map.needsUpdate = true;
}
updatestationlist(scope.stationlist);
}else{
olddataai = true;
}
}
//加载线路车站名贴图
this.loadMaterial = function(netdata3d){
Materialload(scope,JSON.parse(netdata3d.data.assets).stationTextureList[0]);
}
//更换场景车站
this.changestation = function(stationname){
for(let i=0,leni=scope.stationlist.length;i<leni;i++){
if(scope.stationlist[i].name == stationname){
scope.nowStation = scope.stationlist[i];
if(scope.stationtexture["stationlist"]){
scope.stationMesh.getObjectByName("zhantaiming").material.map = scope.stationtexture[scope.nowStation.code];
scope.stationMesh.getObjectByName("zhantaiming").material.map.needsUpdate = true;
}
i=leni;
}
}
}
}

View File

@ -0,0 +1,121 @@
export function PasserTrain() {
let scope = this;
this.toptrain = null;
this.downtrain = null;
//初始化列车模型动画
this.initTrain = function(object,mixers,deviceaction,scene){
let ntracks1,ntracks2,tclip,fclip;
ntracks1 = object.animations.slice(16,27);
tclip = new THREE.AnimationClip("three",2,ntracks1);
ntracks2 = object.animations.slice(0,15);
fclip = new THREE.AnimationClip("four",2,ntracks2);
object.traverse( function ( child ) {
if ( child.isMesh ) {
child.renderOrder = 8;
}
} );
scope.toptrain = object.clone(true);
scope.toptrain.nowcode = null;
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));
scope.toptrain.curve = new THREE.CatmullRomCurve3(points1);
scope.downtrain = object.clone(true);
scope.downtrain.nowcode = null;
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));
scope.downtrain.curve = new THREE.CatmullRomCurve3(points2);
inittrainanimation(scope.toptrain,tclip,fclip,mixers);
inittrainanimation(scope.downtrain,tclip,fclip,mixers);
scope.toptrain.position.z = -20;
scope.toptrain.position.y = -20000;
scope.toptrain.rotation.y = Math.PI;
scope.downtrain.position.z = 40;
scope.downtrain.position.y = -20000;
scene.add(scope.toptrain);
scene.add(scope.downtrain);
}
//初始化车门动画
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].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);
}
}
}
}
}
}

View File

@ -1,5 +1,5 @@
import { ZoneModel } from '@/jlmap3d/jl3dpassflow/model/zonemodel.js'; import { ZoneModel } from '@/jlmap3d/jl3dpassflow/model/zonemodel.js';
//进站区域1
let enter1 = { let enter1 = {
code : '001', code : '001',
name : "enter1", name : "enter1",
@ -11,7 +11,7 @@ let enter1 = {
new THREE.Vector3(32,9.8,-6) new THREE.Vector3(32,9.8,-6)
] ]
}; };
//进站区域2
let enter2 = { let enter2 = {
code : '002', code : '002',
name : "enter2", name : "enter2",
@ -23,7 +23,7 @@ let enter2 = {
new THREE.Vector3(32,9.8,31.5) new THREE.Vector3(32,9.8,31.5)
] ]
}; };
//安检区域
let security = { let security = {
code : '003', code : '003',
name : "security", name : "security",
@ -35,7 +35,7 @@ let security = {
new THREE.Vector3(21,9.8,21) new THREE.Vector3(21,9.8,21)
] ]
}; };
//进方向闸机区域
let entergate = { let entergate = {
code : '004', code : '004',
name : "entergate", name : "entergate",
@ -50,7 +50,7 @@ let entergate = {
new THREE.Vector3(0.7,9.8,18.1) new THREE.Vector3(0.7,9.8,18.1)
] ]
}; };
//站台上车区域
let standtop = { let standtop = {
code : '005', code : '005',
name : "standtop", name : "standtop",
@ -86,7 +86,7 @@ let standtop = {
new THREE.Vector3(-63.5,1.77,-1.8) new THREE.Vector3(-63.5,1.77,-1.8)
] ]
}; };
//站台下车区域
let standdown = { let standdown = {
code : '006', code : '006',
name : "standdown", name : "standdown",
@ -123,6 +123,7 @@ let standdown = {
] ]
}; };
//4是刚下车状态 //4是刚下车状态
//出方向闸机区域
let exitgate = { let exitgate = {
code : '007', code : '007',
name : "exitgate", name : "exitgate",
@ -137,7 +138,7 @@ let exitgate = {
new THREE.Vector3(18,9.8,5.4) new THREE.Vector3(18,9.8,5.4)
] ]
}; };
//出站台区域1
let exit1 = { let exit1 = {
code : '008', code : '008',
name : "exit1", name : "exit1",
@ -149,7 +150,7 @@ let exit1 = {
new THREE.Vector3(30.5,9.8,-7.4) new THREE.Vector3(30.5,9.8,-7.4)
] ]
}; };
//出站台区域2
let exit2 = { let exit2 = {
code : '009', code : '009',
name : "exit2", name : "exit2",
@ -163,6 +164,7 @@ let exit2 = {
}; };
let enternum = 0; let enternum = 0;
let exitnum = 0; let exitnum = 0;
//区域管理器
export function ZoneManager() { export function ZoneManager() {
var scope = this; var scope = this;
@ -172,7 +174,7 @@ export function ZoneManager() {
this.list = []; this.list = [];
initzone(); initzone();
//初始化区域对象
function initzone(){ function initzone(){
scope.list[enter1.name] = new ZoneModel(enter1); scope.list[enter1.name] = new ZoneModel(enter1);
scope.list[enter2.name] = new ZoneModel(enter2); scope.list[enter2.name] = new ZoneModel(enter2);
@ -184,7 +186,7 @@ export function ZoneManager() {
scope.list[exit1.name] = new ZoneModel(exit1); scope.list[exit1.name] = new ZoneModel(exit1);
scope.list[exit2.name] = new ZoneModel(exit2); scope.list[exit2.name] = new ZoneModel(exit2);
} }
//获取区域范围内点
this.getinitposition = function(name){ this.getinitposition = function(name){
// console.log(scope.list[name]); // console.log(scope.list[name]);
let randompoint = new THREE.Vector3(0,scope.list[name].randompoint.y,0); let randompoint = new THREE.Vector3(0,scope.list[name].randompoint.y,0);
@ -246,6 +248,7 @@ export function ZoneManager() {
}; };
return standdata; return standdata;
} }
this.getgateposition = function(name){ this.getgateposition = function(name){
let randompoint = new THREE.Vector3(0,0,0); let randompoint = new THREE.Vector3(0,0,0);

View File

@ -0,0 +1,256 @@
export function PasserAi(zone,finder) {
let scope = this;
//下车控制开关
this.toppasseron = false;
this.downpasseron = false;
//上车控制开关
this.toppasserin = false;
this.downpasserin = false;
let passerZone = zone;
let pathFinder = finder;
let path;
let playerPosition = new THREE.Vector3( -3.5, 0.5, 5.5 );
let targetPosition = new THREE.Vector3();
//生成下车出站人物
this.passerout = function(direct){
// console.log(direct);
if(direct == "top"){
// console.log("toppasser");
scope.toppasseron = true;
setTimeout(function(){
scope.toppasseron = false
scope.toppasserin = true;
setTimeout(function(){
scope.toppasserin = false;
}, 20000);
}, 5000);
}
if(direct == "down"){
// console.log("downpasser");
scope.downpasseron = true;
setTimeout(function(){
scope.downpasseron = false;
scope.downpasserin = true;
setTimeout(function(){
scope.downpasserin = false;
}, 20000);
}, 5000);
}
}
//初始化加载人物
this.initPasser = function(humanlist,passerHuman){
for(let i=0;i<3;i++){
passerHuman.newHumanCreate(humanlist,passerZone.getinitposition("enter1"),0);
}
for(let i=0;i<3;i++){
passerHuman.newHumanCreate(humanlist,passerZone.getinitposition("enter2"),0);
}
for(let i=0;i<3;i++){
passerHuman.newHumanCreate(humanlist,passerZone.getinitposition("security"),1);
}
// for(let i=0;i<2;i++){
// // passerHuman.newHumanCreate(humanlist,passerZone.getinitposition("entergate"),3);
// }
for(let i=0;i<6;i++){
let standdata = passerZone.getstandposition("standtop");
passerHuman.newHumanCreate(humanlist,standdata.point,4,"top",standdata.door);
}
for(let i=0;i<6;i++){
let standdata = passerZone.getstandposition("standdown");
passerHuman.newHumanCreate(humanlist,standdata.point,4,"down",standdata.door);
}
}
//人物站台阶段更新
this.aiUpdate = function(humanlist,passerHuman,passerCheckDoor,deviceaction){
for(let i=0;i<humanlist.children.length;i++){
// console.log(humans[i]);
if(humanlist.children[i].status == 0){
//stage = 0 进入车站
if(humanlist.children[i].stage == 0){
let points = [];
points.push(new THREE.Vector3(humanlist.children[i].position.x,humanlist.children[i].position.y,humanlist.children[i].position.z));
targetPosition = passerZone.getzoneposition("security");
path = pathFinder.find(points[0],targetPosition);
for(let i=0;i<path.length;i++){
points.push(new THREE.Vector3(path[i].x,path[i].y,path[i].z));
}
passerHuman.initMoveAnimate(humanlist.children[i],i,points,i);
// console.log(path);
}
//stage = 1 前往进站闸机
if(humanlist.children[i].stage == 1){
let points = [];
points.push(new THREE.Vector3(humanlist.children[i].position.x,humanlist.children[i].position.y,humanlist.children[i].position.z));
targetPosition = passerZone.getgateposition("entergate");
path = pathFinder.find(points[0],targetPosition.point);
humanlist.children[i].door = targetPosition.door;
for(let i=0;i<path.length;i++){
points.push(new THREE.Vector3(path[i].x,path[i].y,path[i].z));
}
passerHuman.initMoveAnimate(humanlist.children[i],i,points,i);
}
//stage = 2 过闸机
if(humanlist.children[i].stage == 2){
let points = [];
points.push(new THREE.Vector3(humanlist.children[i].position.x,humanlist.children[i].position.y,humanlist.children[i].position.z));
points.push(new THREE.Vector3(humanlist.children[i].position.x,humanlist.children[i].position.y,humanlist.children[i].position.z-5));
passerCheckDoor.checkDoorControl("in",humanlist.children[i].door,deviceaction)
passerHuman.initMoveAnimate(humanlist.children[i],i,points,i);
}
//stage = 3 前往站台
if(humanlist.children[i].stage == 3){
let direct = Math.floor(Math.random()*(2))+1;
// console.log(direct);
let points = [];
points.push(new THREE.Vector3(humanlist.children[i].position.x,humanlist.children[i].position.y,humanlist.children[i].position.z));
// points.push(new THREE.Vector3(11.81,9.8,13.11));
//1--top
//2-- down
if(direct == 1){
targetPosition = passerZone.getstandposition("standtop");
path = pathFinder.find(points[0],targetPosition.point);
humanlist.children[i].direct = "top";
}else{
targetPosition = passerZone.getstandposition("standdown");
path = pathFinder.find(points[0],targetPosition.point);
humanlist.children[i].direct = "down";
}
if(path[0].y<9.84){
points.push(new THREE.Vector3(11.81,9.8,13.11));
points.push(new THREE.Vector3(29.5,1.77,13.16));
}
for(let i=0;i<path.length;i++){
points.push(new THREE.Vector3(path[i].x,path[i].y,path[i].z));
}
humanlist.children[i].door = targetPosition.door;
passerHuman.initMoveAnimate(humanlist.children[i],i,points,i);
}
//stage = 4 上车
if(humanlist.children[i].stage == 4){
if(scope.toppasserin && humanlist.children[i].direct == "top"){
let points = [];
points.push(new THREE.Vector3(humanlist.children[i].position.x,humanlist.children[i].position.y,humanlist.children[i].position.z));
points.push(passerZone.list["standtop"].doorpoints[humanlist.children[i].door]);
if(points[1] == undefined){
}else{
passerHuman.initMoveAnimate(humanlist.children[i],i,points,i);
}
}
if(scope.downpasserin && humanlist.children[i].direct == "down"){
let points = [];
points.push(new THREE.Vector3(humanlist.children[i].position.x,humanlist.children[i].position.y,humanlist.children[i].position.z));
points.push(passerZone.list["standdown"].doorpoints[humanlist.children[i].door]);
if(points[1] == undefined){
}else{
passerHuman.initMoveAnimate(humanlist.children[i],i,points,i);
}
// console.log(points);
}
}
//stage = 5 下车
if(humanlist.children[i].stage == 5){
let points = [];
points.push(new THREE.Vector3(humanlist.children[i].position.x,humanlist.children[i].position.y,humanlist.children[i].position.z));
if(humanlist.children[i].direct == "top"){
points.push(new THREE.Vector3(humanlist.children[i].position.x,humanlist.children[i].position.y,humanlist.children[i].position.z+5));
}
if(humanlist.children[i].direct == "down"){
points.push(new THREE.Vector3(humanlist.children[i].position.x,humanlist.children[i].position.y,humanlist.children[i].position.z-5));
}
targetPosition = passerZone.getgateposition("exitgate");
path = pathFinder.find(points[1],targetPosition.point);
humanlist.children[i].door = targetPosition.door;
for(let i=0;i<path.length;i++){
points.push(new THREE.Vector3(path[i].x,path[i].y,path[i].z));
}
passerHuman.initMoveAnimate(humanlist.children[i],i,points,i);
}
//stage = 6 前往出站闸机
// if(humanlist.children[i].stage == 6){
// let points = [];
// points.push(new THREE.Vector3(humanlist.children[i].position.x,humanlist.children[i].position.y,humanlist.children[i].position.z));
//
// groupID = pathfinder.getGroup( ZONE, points[0] );
// targetPosition = passerZone.getgateposition("exitgate");
// path = pathfinder.findPath( points[0], targetPosition, ZONE, groupID );
//
// for(let i=0;i<path.length;i++){
// points.push(new THREE.Vector3(path[i].x,path[i].y,path[i].z));
// }
// passerHuman.initMoveAnimate(humanlist.children[i],i,points,i);
// }
//stage = 7 出闸机
if(humanlist.children[i].stage == 7){
let points = [];
points.push(new THREE.Vector3(humanlist.children[i].position.x,humanlist.children[i].position.y,humanlist.children[i].position.z));
points.push(new THREE.Vector3(humanlist.children[i].position.x+5,humanlist.children[i].position.y,humanlist.children[i].position.z));
passerCheckDoor.checkDoorControl("out",humanlist.children[i].door,deviceaction)
passerHuman.initMoveAnimate(humanlist.children[i],i,points,i);
}
//stage = 8 出站
if(humanlist.children[i].stage == 8){
let direct = Math.floor(Math.random()*(3-1+1))+1;
let points = [];
points.push(new THREE.Vector3(humanlist.children[i].position.x,humanlist.children[i].position.y,humanlist.children[i].position.z));
//1--top
//2-- down
if(direct == 1){
targetPosition = passerZone.getzoneposition("exit1");
path = pathFinder.find(points[0],targetPosition);
}else{
targetPosition = passerZone.getzoneposition("exit2");
path = pathFinder.find(points[0],targetPosition);
}
for(let i=0;i<path.length;i++){
points.push(new THREE.Vector3(path[i].x,path[i].y,path[i].z));
}
passerHuman.initMoveAnimate(humanlist.children[i],i,points,i);
}
}
}
}
}

View File

@ -0,0 +1,69 @@
import { JL3D_LOCAL_STATIC } from '@/api/jlmap3d/assets3d.js';
import { Pathfinding } from '@/jlmap3d/utils/pathfinder/Pathfinding.js';
import { OBJLoader } from '@/jlmap3d/main/loaders/OBJLoader';
export function PathFinder(){
let scope = this;
this.navmesh = null;
const ZONE = 'level';
const SPEED = 10;
const OFFSET = 0.2;
THREE.Pathfinding = Pathfinding;
let groupID,path,level;
let playerPosition = new THREE.Vector3( -3.5, 0.5, 5.5 );
let pathFinder = new THREE.Pathfinding();
let loaderObj = new THREE.OBJLoader();
// load a resource
loaderObj.load(
// resource URL
JL3D_LOCAL_STATIC+'/jl3d/path/path.obj',
// called when resource is loaded
function ( object ) {
// console.time('createZone()');
const zone = THREE.Pathfinding.createZone(object.children[0].geometry);
// console.timeEnd('createZone()');
pathFinder.setZoneData( ZONE, zone );
const navWireframe = new THREE.Mesh(object.children[0].geometry, new THREE.MeshBasicMaterial({
color: 0x808080,
wireframe: true
}));
navWireframe.position.y = OFFSET / 2;
// scene.add(navWireframe);
scope.navmesh = object;
groupID = pathFinder.getGroup( ZONE, playerPosition );
},
// called when loading is in progresses
function ( xhr ) {
console.log( ( xhr.loaded / xhr.total * 100 ) + '% loaded' );
},
// called when loading has errors
function ( error ) {
console.log( 'An error happened' );
}
);
this.find = function(startPoint,targetPosition){
groupID = pathFinder.getGroup( ZONE, startPoint );
let resultPath = pathFinder.findPath( startPoint, targetPosition, ZONE, groupID );
return resultPath;
}
}

View File

@ -0,0 +1,66 @@
import { FourViewRender } from '@/jlmap3d/jl3dpassflow/passerrender/renderstate/fourviewrender.js';
import { TwoViewRender } from '@/jlmap3d/jl3dpassflow/passerrender/renderstate/twoviewrender.js';
import { FreeViewRender } from '@/jlmap3d/jl3dpassflow/passerrender/renderstate/freeviewrender.js';
export function PasserRender(mapmode) {
let scope = this;
this.state = null;
this.nowrender = null;
this.windowWidth = null;
this.windowHeight = null;
let fourViewRender = new FourViewRender();
let twoViewRender = new TwoViewRender();
let freeViewRender = new FreeViewRender();
let renderer = null;
this.initView = function(dom,scene,camerass){
scope.windowWidth = dom.offsetWidth ;
scope.windowHeight = dom.offsetHeight;
renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setClearColor(new THREE.Color(0x000000));
renderer.setViewport( 0, 0, scope.windowWidth, scope.windowHeight);
renderer.setScissor( 0, 0, scope.windowWidth, scope.windowHeight);
renderer.setScissorTest( false );
renderer.setSize(scope.windowWidth, scope.windowHeight);
renderer.sortObjects = true;
dom.appendChild(renderer.domElement);
fourViewRender.initRender(renderer,dom,scene);
twoViewRender.initRender(renderer,dom,scene);
freeViewRender.initRender(renderer,dom,scene,camerass);
//
scope.state = "4views";
scope.nowrender = fourViewRender;
}
this.changeRenderMode = function(mode){
if(mode == "4views"){
scope.nowrender = fourViewRender;
}
if(mode == "2views"){
scope.nowrender = twoViewRender;
}
if(mode == "freeview"){
scope.nowrender = freeViewRender;
}
scope.nowrender.changeRender();
}
this.reSize = function(offsetWidth,offsetHeight){
scope.nowrender.reSize(offsetWidth,offsetHeight);
}
this.update = function(){
scope.nowrender.update();
}
}

View File

@ -0,0 +1,115 @@
export function FourViewRender() {
let scope = this;
let renderer = null;
let windowWidth = null;
let windowHeight = null;
let renderScene = null;
let specilView,
specilCamera,
specilLeft,
specilBottom,
specilWidth,
specilHeight;
let views4 = [
{
left: 0,
bottom: 0,
width: 0.5,
height: 0.5,
background: new THREE.Color( 0.5, 0.5, 0.7 ),
eye: [ 3.7, 16, 26 ],
up: [3.7, 10 ,16 ],
fov: 30
},
{
left: 0,
bottom: 0.5,
width: 0.5,
height: 0.5,
background: new THREE.Color( 0.5, 0.5, 0.7 ),
eye: [ 3.7,17,-4 ],
up: [ 3.7, 10 ,16],
fov: 30
},
{
left: 0.5,
bottom: 0,
width: 0.5,
height: 0.5,
background: new THREE.Color( 0.7, 0.5, 0.5 ),
eye: [ -60, 6,11],
up: [ -59, 5.9,11 ],
fov: 45
},
{
left: 0.5,
bottom: 0.5,
width: 0.5,
height: 0.5,
background: new THREE.Color( 0.5, 0.7, 0.7 ),
eye: [ -7,17,2],
up: [-7, 10, 8],
fov: 60
}
];
for ( let ii = 0; ii < views4.length; ++ ii ) {
let view = views4[ ii ];
let camera = new THREE.PerspectiveCamera( view.fov, window.innerWidth / window.innerHeight, 1, 200 );
camera.position.fromArray( view.eye );
camera.lookAt( view.up[0],view.up[1],view.up[2] );
view.camera = camera;
}
this.initRender = function(render,dom,scene){
windowWidth = dom.offsetWidth ;
windowHeight = dom.offsetHeight;
renderScene = scene;
renderer = render;
}
this.changeRender = function(){
renderer.setClearColor(new THREE.Color(0x000000));
renderer.setSize(windowWidth, windowHeight);
renderer.sortObjects = true;
}
this.reSize = function(offsetWidth,offsetHeight){
windowWidth = window.innerWidth;
windowHeight = window.innerHeight;
}
this.update = function(){
for ( let ii = 0; ii < 4; ii ++ ) {
specilView = views4[ ii ];
specilCamera = specilView.camera;
// view.updateCamera( camera, scene, mouseX, mouseY );
specilLeft = Math.floor( windowWidth * specilView.left );
specilBottom = Math.floor( windowHeight * specilView.bottom );
specilWidth = Math.floor( windowWidth * specilView.width );
specilHeight = Math.floor( windowHeight * specilView.height );
renderer.setViewport( specilLeft,specilBottom,specilWidth,specilHeight );
renderer.setScissor( specilLeft,specilBottom,specilWidth,specilHeight );
renderer.setScissorTest( true );
specilCamera.aspect = specilWidth / specilHeight;
specilCamera.updateProjectionMatrix();
renderer.render( renderScene, specilCamera );
}
}
}

View File

@ -0,0 +1,51 @@
export function FreeViewRender() {
let scope = this;
let renderer = null;
let camera = null;
let windowWidth = null;
let windowHeight = null;
let renderScene = null;
let specilView,
specilCamera,
specilLeft,
specilBottom,
specilWidth,
specilHeight;
this.initRender = function(render,dom,scene,camerass){
camera = camerass;
camera.aspect = windowWidth / windowHeight;
camera.updateProjectionMatrix();
windowWidth = dom.offsetWidth ;
windowHeight = dom.offsetHeight;
renderScene = scene;
renderer = render;
}
this.changeRender = function(){
camera.aspect = windowWidth / windowHeight;
camera.updateProjectionMatrix();
renderer.setClearColor(new THREE.Color(0x000000));
renderer.setViewport( 0, 0, windowWidth, windowHeight);
renderer.setScissor( 0, 0, windowWidth, windowHeight);
renderer.setSize(windowWidth, windowHeight);
renderer.sortObjects = true;
}
this.reSize = function(offsetWidth,offsetHeight){
windowWidth = window.innerWidth;
windowHeight = window.innerHeight;
camera.aspect = windowWidth / windowHeight;
camera.updateProjectionMatrix();
renderer.setSize(windowWidth, windowHeight);
}
this.update = function(){
renderer.render(renderScene, camera);
}
}

View File

@ -0,0 +1,93 @@
export function TwoViewRender(render) {
let scope = this;
let renderer = null;
let windowWidth = null;
let windowHeight = null;
let renderScene = null;
let specilView,
specilCamera,
specilLeft,
specilBottom,
specilWidth,
specilHeight;
let views2 = [
{
left: 0,
bottom: 0,
width: 0.5,
height: 1,
background: new THREE.Color( 0.5, 0.5, 0.7 ),
eye: [ 3.7, 16, 26 ],
up: [3.7, 10 ,16 ],
fov: 60
},
{
left: 0.5,
bottom: 0,
width: 0.5,
height: 1,
background: new THREE.Color( 0.7, 0.5, 0.5 ),
eye: [ -60, 6,11],
up: [ -59, 5.9,11 ],
fov: 60
},
];
for ( let ii = 0; ii < views2.length; ++ ii ) {
let view = views2[ ii ];
let camera = new THREE.PerspectiveCamera( view.fov, window.innerWidth / window.innerHeight, 1, 200 );
camera.position.fromArray( view.eye );
camera.lookAt( view.up[0],view.up[1],view.up[2] );
view.camera = camera;
}
this.initRender = function(render,dom,scene){
windowWidth = dom.offsetWidth ;
windowHeight = dom.offsetHeight;
renderScene = scene;
renderer = render;
}
this.changeRender = function(){
renderer.setClearColor(new THREE.Color(0x000000));
renderer.setSize(windowWidth, windowHeight);
renderer.sortObjects = true;
}
this.reSize = function(offsetWidth,offsetHeight){
windowWidth = window.innerWidth;
windowHeight = window.innerHeight;
}
this.update = function(){
for ( let ii = 0; ii < 2; ii ++ ) {
specilView = views2[ ii ];
specilCamera = specilView.camera;
// view.updateCamera( camera, scene, mouseX, mouseY );
specilLeft = Math.floor( windowWidth * specilView.left );
specilBottom = Math.floor( windowHeight * specilView.bottom );
specilWidth = Math.floor( windowWidth * specilView.width );
specilHeight = Math.floor( windowHeight * specilView.height );
renderer.setViewport( specilLeft,specilBottom,specilWidth,specilHeight );
renderer.setScissor( specilLeft,specilBottom,specilWidth,specilHeight );
renderer.setScissorTest( true );
specilCamera.aspect = specilWidth / specilHeight;
specilCamera.updateProjectionMatrix();
renderer.render( renderScene, specilCamera );
}
}
}

View File

@ -1,744 +0,0 @@
import StompClient from '@/utils/sock';
// import { getTrainingCbtcDemon, runDiagramStart, runDiagramOver, setTrainingCbtcInitTime } from '@/api/simulation';
// import { creatSubscribe, clearSubscribe, displayTopic, screenTopic } from '@/utils/stomp';
import { getBaseUrl } from '@/utils/baseUrl'
import { getToken } from '@/utils/auth';
// 定于仿真socket接口
export function Jlmap3dSubscribe(jlmap3d,routegroup,jsonwebwork) {
const scope = this;
this.map = null;
var trainlisttest = null;
var sectionlist = null;
var signallist = null;
var stationstandlist = null;
var sectionlist = null;
var materials = null;
var actions = null;
var rails = null;
var links = null;
var scenes = null;
var code = null;
var drivingcode = null;
var drivingspeed = null;
var drivingaptspeed = null;
let driverswitch = false;
let stoptimer = null;
let num = 30;
let pointstand = null;
let data = null;
// run as plane = 01;
// reset = 02;
var datatype = '00';
this.teststomp = new StompClient();
this.topic = '/user/queue/simulation/jl3d/'+routegroup;
let header = {'X-Token': getToken() };
let connectmsg = {
type:'init',
baseurl:getBaseUrl(),
topic:this.topic,
token:getToken(),
};
jsonwebwork.postMessage(connectmsg);
jsonwebwork.onmessage = function (event) {
// console.log(event.data);
// if(event.data.type == 'Simulation_Driver_Change'){
// drivingcode = event.data.body.code;
// jlmap3d.updatedrivingcode( event.data.body.code);
// }
// if(data.type == 'Simulation_TrainSpeed'){
// trainspeed(data);
// }
// console.log(event);
// if(event.data.type == 'SJL3D_TrainStatus'){
// trainstatus(event.data);
// }
// if(event.data.type == 'Simulation_DeviceStatus'){
// devicestatus(event.data);
// }
// console.log(data);
if(event.data._type == 'Simulation_Driver_Change'){
drivingcode = event.data.body.code;
jlmap3d.updatedrivingcode( event.data.body.code);
}
if(event.data._type == 'Train'){
trainstatus(event.data);
}
if (event.data._type== 'Signal' && signallist) {
// console.log(event.data);
signalupdate(event.data);
}
if (event.data._type== 'StationStand' && actions) {
// console.log(event.data);
standupdate(event.data);
}
if (event.data._type == 'Switch' && sectionlist) {
// console.log(event.data);
switchupdate(event.data);
}
// if(event.data._type = ''){
// trainstatus(event.data);
// }
// if(event.data.type == 'Simulation_DeviceStatus'){
// devicestatus(event.data);
// }
if(event.data.type == 'Simulation_Reset'){
simulationreset(event.data);
}
};
// jsonwebwork.onmessage = function (event) {
// console.log(event.data);
// if(event.data.type == 'Simulation_Driver_Change'){
// drivingcode = event.data.body.code;
// jlmap3d.updatedrivingcode( event.data.body.code);
// }
// // if(event.data.type == 'Simulation_TrainSpeed'){
// // trainspeed(event.data);
// // }
// if(event.data.type == 'SJL3D_TrainStatus'){
// trainstatus(event.data);
// }
// if(event.data.type == 'Simulation_DeviceStatus'){
// devicestatus(event.data);
// }
// if(event.data.type == 'Simulation_Reset'){
// simulationreset(event.data);
// }
// };
this.updatamap = function(newsectionlist,newlinklist,newsignallist,newstationstandlist,newtrainlisttest,newrealsectionlist,newrails, materiallist, nowaction, scene) {
// console.log(mapdata);
trainlisttest = newtrainlisttest;
sectionlist = newsectionlist;
signallist = newsignallist;
stationstandlist = newstationstandlist;
materials = materiallist;
scenes = scene;
actions = nowaction;
links = newlinklist;
rails = newrails;
};
this.socketon = function(topic) {
try {
// console.log("teststomp");
// scope.teststomp.subscribe(topic, callback, header);
} catch (error) {
console.error('websocket订阅失败');
}
};
this.socketoff = function(topic) {
scope.teststomp.unsubscribe(topic);
for (let i=0; i<trainlisttest.group.children.length; i++) {
if (trainlisttest.group.children[i].dispose == false) {
code = trainlisttest.group.children[i].name;
trainlisttest.list[code].rotation.y = 0;
trainlisttest.list[code].doorStatus = '01';
trainlisttest.list[code].speed = 0;
trainlisttest.group.children[i].dispose = true;
trainlisttest.group.children[i].position.x = -50000;
trainlisttest.group.children[i].position.y = -50000;
trainlisttest.group.remove(trainlisttest.group.children[i]);
i--;
}
}
};
// 仿真socket接口回调函数
function callback(Response) {
}
function trainspeed(data){
if (trainlisttest) {
for (let tl = 0; tl<data.body.length; tl++) {
code = data.body[tl].id;
if(trainlisttest.list[code].speed != data.body[tl].v){
trainlisttest.list[code].speed = data.body[tl].v;
trainlisttest.list[code].speeds = parseFloat(data.body[tl].v*10/36/18/trainlisttest.list[code].len);
}
}
}
}
function trainstatus(data){
// for (let i=data.body.length-1; i>=0; i--) {
// console.log(data.body[i]);
// console.log(data);
// 遍历列车对象组
if (trainlisttest) {
code = data.code;
// 剔除不显示的车
// 找到对应列车
if ( trainlisttest.list[code]) {
trainlisttest.list[code].runMode = data.runMode;
// 车门开关验证
// if(data.directionType == "02"){
if (trainlisttest.list[code].doorStatus != data.doorStatus && data.doorStatus == '01') {
// console.log("close");
trainlisttest.list[code].doorStatus = '01';
for (let an=actions[code].top.length-1; an>=0; an--) {
actions[code].top[an].reset();
actions[code].top[an].time = actions[code].top[an]._clip.duration;
actions[code].top[an].timeScale = -1;
actions[code].top[an].play();
}
} else if (trainlisttest.list[code].doorStatus != data.doorStatus && data.doorStatus == '02') {
// console.log("open");
trainlisttest.list[code].doorStatus = '02';
for (let an=actions[code].top.length-1; an>=0; an--) {
actions[code].top[an].reset();
actions[code].top[an].time = 0;
actions[code].top[an].timeScale = 1;
actions[code].top[an].play();
}
}
// if(trainlisttest.list[code].doorStatus != data.doorStatus && data.doorStatus == "01"){
// //console.log("close");
// trainlisttest.list[code].doorStatus = "01";
// for(let an=actions[code].down.length-1;an>=0;an--){
// actions[code].down[an].reset();
// actions[code].down[an].time = actions[code].top[an]._clip.duration;
// actions[code].down[an].timeScale = -1;
// actions[code].down[an].play();
// }
// }else if(trainlisttest.list[code].doorStatus != data.doorStatus && data.doorStatus == "02"){
// //console.log("open");
// trainlisttest.list[code].doorStatus = "02";
// for(let an=actions[code].down.length-1;an>=0;an--){
// actions[code].down[an].reset();
// actions[code].down[an].time = 0;
// actions[code].down[an].timeScale = 1;
// actions[code].down[an].play();
// }
// }
// }
// 遍历获取所在轨道
if (trainlisttest.list[code].dispose != data.dispose && data.dispose == false) {
if (rails.linkrail[data.linkCode]) {
trainlisttest.group.add(trainlisttest.list[code]);
trainlisttest.list[code].position.y = 0;
// trainlisttest.list[code].progress = 0;
trainlisttest.list[code].dispose = false;
trainlisttest.list[code].nowcode = data.linkCode;
trainlisttest.list[code].nextcode = null;
trainlisttest.list[code].pc = 1;
if(trainlisttest.list[code].mixerpush == false){
for(let mi=0,lenmi=trainlisttest.list[code].mixer.length;mi<lenmi;mi++){
jlmap3d.mixers.push(trainlisttest.list[code].mixer[mi]);
}
trainlisttest.list[code].mixerpush = true;
// console.log(trainlisttest.list[code].mixerpush);
}
if (data.directionType == '02') { // 向右
if(data.targetStation){
trainlisttest.list[code].stopstation = data.targetStation;
// console.log(rails.stops[data.targetStation].direct2.percent);
trainlisttest.list[code].pc = data.targetLinkPercent/rails.stops[data.targetStation].direct2.percent;
trainlisttest.list[code].targetpercent = rails.stops[data.targetStation].direct2.percent;
trainlisttest.list[code].progress = data.linkOffsetPercent/trainlisttest.list[code].pc;
trainlisttest.list[code].linkOffsetPercent = data.linkOffsetPercent;
trainlisttest.list[code].targetLink = data.targetLink;
// console.log(data.targetLinkPercent);
// console.log(rails.stops[data.targetStation].direct2.percent);
// console.log(trainlisttest.list[code].progress);
// console.log("===================");
let point = rails.linkrail[data.linkCode].lineleft.getPointAt(trainlisttest.list[code].progress);
trainlisttest.list[code].rotation.y = 0;
trainlisttest.list[code].position.x = point.x;
trainlisttest.list[code].position.y = 0;
for (let tl=0; tl<6; tl++) {
trainlisttest.list[code].children[tl].position.z = point.z;
}
}else{
trainlisttest.list[code].progress = data.linkOffsetPercent/trainlisttest.list[code].pc;
trainlisttest.list[code].linkOffsetPercent = data.linkOffsetPercent;
let point = rails.linkrail[data.linkCode].lineleft.getPointAt(trainlisttest.list[code].progress);
trainlisttest.list[code].rotation.y = 0;
trainlisttest.list[code].position.x = point.x;
trainlisttest.list[code].position.y = 0;
for (let tl=0; tl<6; tl++) {
trainlisttest.list[code].children[tl].position.z = point.z;
}
}
trainlisttest.list[code].curve = rails.linkrail[data.linkCode].lineleft;
trainlisttest.list[code].len = rails.linkrail[data.linkCode].lengthfact;
trainlisttest.list[code].status = '02';
} else if (data.directionType == '03') { // 向左
// if(trainlisttest.list[code].rname == "006"){
// console.log("0000000000000000");
// console.log(data.linkOffsetPercent);
// }
if(data.targetStation){
trainlisttest.list[code].stopstation = data.targetStation;
trainlisttest.list[code].pc = data.targetLinkPercent/rails.stops[data.targetStation].direct1.percent;
trainlisttest.list[code].targetpercent = rails.stops[data.targetStation].direct1.percent;
trainlisttest.list[code].progress = 1-(data.linkOffsetPercent/trainlisttest.list[code].pc);
trainlisttest.list[code].linkOffsetPercent = data.linkOffsetPercent;
trainlisttest.list[code].targetLink = data.targetLink;
// console.log(data.targetLinkPercent);
// console.log(rails.stops[data.targetStation].direct1.percent);
// console.log(trainlisttest.list[code].progress);
// console.log("===================");
let point = rails.linkrail[data.linkCode].lineright.getPointAt(trainlisttest.list[code].progress);
trainlisttest.list[code].rotation.y = Math.PI;
trainlisttest.list[code].position.x = point.x;
trainlisttest.list[code].position.y = 0;
for (let tl=0; tl<6; tl++) {
trainlisttest.list[code].children[tl].position.z = -point.z;
}
}else{
trainlisttest.list[code].progress = data.linkOffsetPercent/trainlisttest.list[code].pc;
trainlisttest.list[code].linkOffsetPercent = data.linkOffsetPercent;
let point = rails.linkrail[data.linkCode].lineleft.getPointAt(trainlisttest.list[code].progress);
trainlisttest.list[code].rotation.y = 0;
trainlisttest.list[code].position.x = point.x;
trainlisttest.list[code].position.y = 0;
for (let tl=0; tl<6; tl++) {
trainlisttest.list[code].children[tl].position.z = point.z;
}
}
trainlisttest.list[code].curve = rails.linkrail[data.linkCode].lineright;
trainlisttest.list[code].len = rails.linkrail[data.linkCode].lengthfact;
trainlisttest.list[code].status = '03';
// trainlisttest.list[code].curve = rails.linkrail[data.linkCode].lineright;
}
trainlisttest.list[code].len = rails.linkrail[data.linkCode].lengthfact;
// trainlisttest.list[code].isStandTrack = sectionlist.sections.datalist[data.sectionCode].isStandTrack;
// trainlisttest.list[code].len = sectionlist.sections.datalist[data.sectionCode].distance;
if(trainlisttest.list[code].targetLink == trainlisttest.list[code].nowcode){
trainlisttest.list[code].statsstop = 0;
}else{
trainlisttest.list[code].statsstop = 1;
}
if(data.speed == 0){
trainlisttest.list[code].speeds = data.speed;
trainlisttest.list[code].speeds = 0;
// trainlisttest.list[code].startmark = 1;
}else{
trainlisttest.list[code].speeds = data.speed;
trainlisttest.list[code].speeds = parseFloat(data.speed*10/36/18/trainlisttest.list[code].len);
}
}
} else if (trainlisttest.list[code].dispose != data.dispose && data.dispose == true) {
trainlisttest.group.remove(trainlisttest.list[code]);
trainlisttest.list[code].progress = null;
trainlisttest.list[code].dispose = true;
code = trainlisttest.group.children[i].name;
trainlisttest.list[code].rotation.y = 0;
trainlisttest.list[code].doorStatus = '01';
trainlisttest.list[code].speed = 0;
trainlisttest.list[code].position.x = -50000;
trainlisttest.list[code].position.y = -50000;
trainlisttest.list[code].pc = 1;
} else if (trainlisttest.list[code].dispose == data.dispose && data.dispose == false) {
// if(data.){
//
// }
if (data.directionType == '02' && trainlisttest.list[code].status != data.directionType) { // 向右
let rotaposx = trainlisttest.list[code].children[5].matrixWorld.elements[12];
let rotaposz = trainlisttest.list[code].children[0].matrixWorld.elements[14];
trainlisttest.list[code].rotation.y = 0;
trainlisttest.list[code].position.x = rotaposx;
for (let tl=0; tl<6; tl++) {
trainlisttest.list[code].children[tl].position.z = rotaposz;
}
trainlisttest.list[code].progress = (rotaposx-rails.linkrail[data.linkCode].lp.x)/rails.linkrail[data.linkCode].lengthfact;
trainlisttest.list[code].status = '02';
trainlisttest.list[code].curve = rails.linkrail[data.linkCode].lineleft;
trainlisttest.list[code].nextcurve = null;
trainlisttest.list[code].len = rails.linkrail[data.linkCode].lengthfact;
} else if (data.directionType == '03'&& trainlisttest.list[code].status != data.directionType) { // 向左
let rotaposx = trainlisttest.list[code].children[5].matrixWorld.elements[12];
let rotaposz = Math.abs(trainlisttest.list[code].children[0].matrixWorld.elements[14]);
trainlisttest.list[code].rotation.y = Math.PI;
trainlisttest.list[code].position.x = rotaposx;
for (let tl=0; tl<6; tl++) {
trainlisttest.list[code].children[tl].position.z = -rotaposz;
}
trainlisttest.list[code].progress = 1-(rotaposx-rails.linkrail[data.linkCode].lp.x)/rails.linkrail[data.linkCode].lengthfact;
trainlisttest.list[code].status = '03';
trainlisttest.list[code].curve = rails.linkrail[data.linkCode].lineright;
trainlisttest.list[code].nextcurve = null;
trainlisttest.list[code].len = rails.linkrail[data.linkCode].lengthfact;
}
if(trainlisttest.list[code].nextcode == null ){//&& trainlisttest.list[code].stopstation == data.targetStation
// if(data.groupNumber == "016"){
// console.log(trainlisttest.list[code].nextcode);
// console.log(trainlisttest.list[code].stopstation);
// console.log(data.targetStation);
// console.log(data.body[i]);
// console.log(trainlisttest.list[code]);
// }
// if(trainlisttest.list[code].targetLink != trainlisttest.list[code].nowcode){
let nextcode;
if(data.directionType == '02'){
trainlisttest.list[code].status = '02';
// console.log(rails.linkrail[trainlisttest.list[code].nowcode]);
if(rails.linkrail[trainlisttest.list[code].nowcode]){
nextcode = rails.linkrail[trainlisttest.list[code].nowcode].rconnect;
}
if(nextcode){
trainlisttest.list[code].nextcurve = rails.linkrail[nextcode].lineleft;
trainlisttest.list[code].nextlen = rails.linkrail[nextcode].lengthfact;
}else{
trainlisttest.list[code].nextlen = 0;
}
}else if(data.directionType == '03'){
trainlisttest.list[code].status = '03';
if(rails.linkrail[trainlisttest.list[code].nowcode]){
nextcode = rails.linkrail[trainlisttest.list[code].nowcode].lconnect;
}
if(nextcode){
trainlisttest.list[code].nextcurve = rails.linkrail[nextcode].lineright;
trainlisttest.list[code].nextlen = rails.linkrail[nextcode].lengthfact;
}else{
trainlisttest.list[code].nextlen = 0;
}
}
trainlisttest.list[code].nextcode = nextcode;
// }
if(trainlisttest.list[code].curve == null){
trainlisttest.list[code].len = trainlisttest.list[code].nextlen;
trainlisttest.list[code].nowcode = trainlisttest.list[code].nextcode;
trainlisttest.list[code].curve = trainlisttest.list[code].nextcurve;
trainlisttest.list[code].nextcurve = null;
trainlisttest.list[code].nextlen = null;
trainlisttest.list[code].nextcode = null;
}
}
if(data.groupNumber == "016"){
// console.log(data.targetLink);
// console.log(trainlisttest.list[code].nowcode);
//
// console.log(trainlisttest.list[code].progress);
// console.log("==============");
}
trainlisttest.list[code].targetLink = data.targetLink;
if(trainlisttest.list[code].stopstation != data.targetStation){
if(data.directionType == '02'){
if(data.targetStation){
trainlisttest.list[code].pc = data.targetLinkPercent/rails.stops[data.targetStation].direct2.percent;
trainlisttest.list[code].targetpercent = rails.stops[data.targetStation].direct2.percent;
// trainlisttest.list[code].linkOffsetPercent = data.linkOffsetPercent;
// trainlisttest.list[code].targetLink = data.targetLink;
}
trainlisttest.list[code].status = '02';
}else if(data.directionType == '03'){
if(data.targetStation){
trainlisttest.list[code].pc = data.targetLinkPercent/rails.stops[data.targetStation].direct1.percent;
trainlisttest.list[code].targetpercent = rails.stops[data.targetStation].direct1.percent;
// trainlisttest.list[code].linkOffsetPercent = data.linkOffsetPercent;
// trainlisttest.list[code].targetLink = data.targetLink;
}
trainlisttest.list[code].status = '03';
}
trainlisttest.list[code].stopstation = data.targetStation;
}
}
}
if(trainlisttest.list[code].targetLink == trainlisttest.list[code].nowcode){
trainlisttest.list[code].statsstop = 0;
}else{
trainlisttest.list[code].statsstop = 1;
}
// console.log(data.body[i]);
if(trainlisttest.list[code].speed != data.speed){
trainlisttest.list[code].speed = data.speed;
trainlisttest.list[code].speeds = parseFloat(data.speed*10/36/18/trainlisttest.list[code].len);
}
}
// }
}
function standupdate(data) {
code = data.code;
if ( actions[code]) {
if (data.screenDoorOpenStatus == '02' && actions[code].status == '01') {
actions[code].status = '00';
}
if (data.screenDoorOpenStatus == '02' && actions[code].status == '00') {
actions[code].status = '02';
actions[code].action.reset();
actions[code].action.time = 0;
actions[code].action.timeScale = 1;
actions[code].action.play();
}
if (data.screenDoorOpenStatus == '01' && actions[code].status == '02') {
actions[code].status = '00';
}
if (data.screenDoorOpenStatus == '01' && actions[code].status == '00') {
actions[code].status = '01';
actions[code].action.reset();
actions[code].action.time = actions[code].action._clip.duration;
actions[code].action.timeScale = -1;
actions[code].action.play();
}
}
}
function devicestatus(data){
for (let i= 0,leni = data.body.length; i<leni; i++) {
// 0xFFFFFF
// 0xCD0000 红
// 0xEEEE00 黄
// 0x32CD32 绿
if (data._type == 'Signal' && signallist) {
if (signallist) {
// console.log(data.body[i]);
signalupdate(data.body[i]);
}
}
if (data._type == 'StationStand' && actions) {
if (actions) {
standupdate(data.body[i]);
}
}
if (data._type == 'Switch' && sectionlist) {
if (sectionlist) {
switchupdate(data.body[i]);
}
}
}
}
function signalupdate(data) {
code = data.code;
// console.log(data);
if (data.lightType == '01') {
if (signallist.list[code].mesh.code) {
signallist.list[code].mesh.status = data.status;
// 55
// 33
// 77
// 关闭
if (data.status == '01') {
signallist.list[code].mesh.getObjectByName("red").material.map = materials[0];
signallist.list[code].mesh.getObjectByName("red").material.map.needsUpdate = true;
signallist.list[code].mesh.getObjectByName("yellow").material.map = materials[3];
signallist.list[code].mesh.getObjectByName("yellow").material.map.needsUpdate = true;
signallist.list[code].mesh.getObjectByName("green").material.map = materials[3];
signallist.list[code].mesh.getObjectByName("green").material.map.needsUpdate = true;
}
// 开放
if (data.status == '02') {
signallist.list[code].mesh.getObjectByName("red").material.map = materials[3];
signallist.list[code].mesh.getObjectByName("red").material.map.needsUpdate = true;
signallist.list[code].mesh.getObjectByName("yellow").material.map = materials[3];
signallist.list[code].mesh.getObjectByName("yellow").material.map.needsUpdate = true;
signallist.list[code].mesh.getObjectByName("green").material.map = materials[2];
signallist.list[code].mesh.getObjectByName("green").material.map.needsUpdate = true;
}
if (data.status == '03') {
signallist.list[code].mesh.getObjectByName("red").material.map = materials[3];
signallist.list[code].mesh.getObjectByName("red").material.map.needsUpdate = true;
signallist.list[code].mesh.getObjectByName("yellow").material.map = materials[1];
signallist.list[code].mesh.getObjectByName("yellow").material.map.needsUpdate = true;
signallist.list[code].mesh.getObjectByName("green").material.map = materials[3];
signallist.list[code].mesh.getObjectByName("green").material.map.needsUpdate = true;
}
// 引导
if (data.status == '03') {
signallist.list[code].mesh.getObjectByName("red").material.map = materials[0];
signallist.list[code].mesh.getObjectByName("red").material.map.needsUpdate = true;
signallist.list[code].mesh.getObjectByName("yellow").material.map = materials[1];
signallist.list[code].mesh.getObjectByName("yellow").material.map.needsUpdate = true;
signallist.list[code].mesh.getObjectByName("green").material.map = materials[3];
signallist.list[code].mesh.getObjectByName("green").material.map.needsUpdate = true;
}
// 封锁
if (data.status == '04') {
signallist.list[code].mesh.getObjectByName("red").material.map = materials[3];
signallist.list[code].mesh.getObjectByName("red").material.map.needsUpdate = true;
signallist.list[code].mesh.getObjectByName("yellow").material.map = materials[3];
signallist.list[code].mesh.getObjectByName("yellow").material.map.needsUpdate = true;
signallist.list[code].mesh.getObjectByName("green").material.map = materials[3];
signallist.list[code].mesh.getObjectByName("green").material.map.needsUpdate = true;
}
// 故障
if (data.status == '05') {
signallist.list[code].mesh.getObjectByName("red").material.map = materials[3];
signallist.list[code].mesh.getObjectByName("red").material.map.needsUpdate = true;
signallist.list[code].mesh.getObjectByName("yellow").material.map = materials[3];
signallist.list[code].mesh.getObjectByName("yellow").material.map.needsUpdate = true;
signallist.list[code].mesh.getObjectByName("green").material.map = materials[3];
signallist.list[code].mesh.getObjectByName("green").material.map.needsUpdate = true;
}
if (data.status == '06') {
signallist.list[code].mesh.getObjectByName("red").material.map = materials[3];
signallist.list[code].mesh.getObjectByName("red").material.map.needsUpdate = true;
signallist.list[code].mesh.getObjectByName("yellow").material.map = materials[3];
signallist.list[code].mesh.getObjectByName("yellow").material.map.needsUpdate = true;
signallist.list[code].mesh.getObjectByName("green").material.map = materials[3];
signallist.list[code].mesh.getObjectByName("green").material.map.needsUpdate = true;
}
}
} else if (data.lightType == '01') {
if (signallist.list[code].mesh.code) {
signallist.list[code].mesh.getObjectByName("red").material.map = materials[3];
signallist.list[code].mesh.getObjectByName("red").material.map.needsUpdate = true;
signallist.list[code].mesh.getObjectByName("yellow").material.map = materials[3];
signallist.list[code].mesh.getObjectByName("yellow").material.map.needsUpdate = true;
signallist.list[code].mesh.getObjectByName("green").material.map = materials[3];
signallist.list[code].mesh.getObjectByName("green").material.map.needsUpdate = true;
}
}
}
function switchupdate(data) {
code = data.code;
for (let j=sectionlist.switchs.modellist.length-1; j>=0; j--) {
if (rails.switchrail[code]) {
if (rails.switchrail[code].locateType != data.locateType) {
if (data.locateType == '02') {
if (actions[sectionlist.switchs.modellist[j].code]) {
sectionlist.switchs.modellist[j].locateType = data.locateType;
actions[sectionlist.switchs.modellist[j].code].reset();
actions[sectionlist.switchs.modellist[j].code].time = 0;
actions[sectionlist.switchs.modellist[j].code].timeScale = 1;
actions[sectionlist.switchs.modellist[j].code].play();
}
rails.switchrail[code].locateType = "02";
let testswitch = rails.switchrail[code];
// console.log(testswitch);
// console.log(rails.linkrail[testswitch.alink]);
// console.log(rails.linkrail[testswitch.clink]);
if(rails.switchrail[code].directtype == "1"){
rails.linkrail[testswitch.alink].lconnect = testswitch.clink;
rails.linkrail[testswitch.clink].rconnect = testswitch.alink;
}else if(rails.switchrail[code].directtype == "2"){
rails.linkrail[testswitch.alink].rconnect = testswitch.clink;
rails.linkrail[testswitch.clink].lconnect = testswitch.alink;
}
} else if (data.locateType == '01') {
if (actions[sectionlist.switchs.modellist[j].code]) {
sectionlist.switchs.modellist[j].locateType = data.locateType;
actions[sectionlist.switchs.modellist[j].code].reset();
actions[sectionlist.switchs.modellist[j].code].time = actions[sectionlist.switchs.modellist[j].code]._clip.duration;
actions[sectionlist.switchs.modellist[j].code].timeScale = -1;
actions[sectionlist.switchs.modellist[j].code].play();
}
rails.switchrail[code].locateType = "01";
let testswitch = rails.switchrail[code];
// console.log(testswitch);
// console.log(rails.linkrail[testswitch.alink]);
// console.log(rails.linkrail[testswitch.clink]);
if(rails.switchrail[code].directtype == "1"){
rails.linkrail[testswitch.alink].lconnect = testswitch.blink;
rails.linkrail[testswitch.blink].rconnect = testswitch.alink;
}else if(rails.switchrail[code].directtype == "2"){
rails.linkrail[testswitch.alink].rconnect = testswitch.blink;
rails.linkrail[testswitch.blink].lconnect = testswitch.alink;
}
}
}
j = 0;
}
}
}
function simulationreset(data){
for(let i=0;i<trainlisttest.group.children.length;i++){
trainlisttest.group.children[i].dispose = true;
trainlisttest.group.children[i].stopstation = null;
trainlisttest.group.children[i].pc = null;
trainlisttest.group.children[i].targetpercent = null;
trainlisttest.group.children[i].progress = null;
trainlisttest.group.children[i].linkOffsetPercent = null;
trainlisttest.group.children[i].targetLink = null;
trainlisttest.group.remove(trainlisttest.group.children[i]);
i--;
}
}
}

View File

@ -530,68 +530,71 @@ export function Jlmap3dSubscribeNew(jlmap3d,routegroup,jsonwebwork) {
}else if(data[i].deviceType == "PSD"){ }else if(data[i].deviceType == "PSD"){
initstand(data[i]); initstand(data[i]);
}else{ }else{
console.log(data[i]);
} }
} }
} }
function DeviceDestroy(data){ function DeviceDestroy(data){
for(let i=0,leni=data.body.deviceList.length;i<leni;i++){ if(data.body.deviceList.length){
for(let i=0,leni=data.body.deviceList.length;i<leni;i++){
if(data.body.deviceList[i].type == "TRAIN"){ if(data.body.deviceList[i].type == "TRAIN"){
code =data.body.deviceList[i].code; code =data.body.deviceList[i].code;
if (trainlisttest.list[code].dispose != data.body.deviceList[i].dispose && data.body.deviceList[i].dispose == "0") { if (trainlisttest.list[code].dispose != data.body.deviceList[i].dispose && data.body.deviceList[i].dispose == "0") {
if (rails.sectionrail[data.body.deviceList[i].section]) { if (rails.sectionrail[data.body.deviceList[i].section]) {
trainlisttest.group.add(trainlisttest.list[code]); trainlisttest.group.add(trainlisttest.list[code]);
trainlisttest.list[code].position.y = 0; trainlisttest.list[code].position.y = 0;
// trainlisttest.list[code].progress = 0; // trainlisttest.list[code].progress = 0;
trainlisttest.list[code].dispose = "0"; trainlisttest.list[code].dispose = "0";
trainlisttest.list[code].nowcode = data.body.deviceList[i].section; trainlisttest.list[code].nowcode = data.body.deviceList[i].section;
trainlisttest.list[code].nextcode = null; trainlisttest.list[code].nextcode = null;
trainlisttest.list[code].curve = null;
trainlisttest.list[code].nextcurve = null;
trainlisttest.list[code].pc = 1;
if(trainlisttest.list[code].mixerpush == false){
for(let mi=0,lenmi=trainlisttest.list[code].mixer.length;mi<lenmi;mi++){
jlmap3d.mixers.push(trainlisttest.list[code].mixer[mi]);
}
trainlisttest.list[code].mixerpush = true;
}
}
} else if (trainlisttest.list[code].dispose != data.body.deviceList[i].dispose && data.body.deviceList[i].dispose == "1") {
trainlisttest.list[code].status = 1;
trainlisttest.group.remove(trainlisttest.list[code]);
trainlisttest.list[code].progress = null;
trainlisttest.list[code].dispose = "1";
code = trainlisttest.group.children[i].name;
trainlisttest.list[code].rotation.y = 0;
trainlisttest.list[code].open = '1';
trainlisttest.list[code].curve = null; trainlisttest.list[code].curve = null;
trainlisttest.list[code].nextcurve = null; trainlisttest.list[code].nextcurve = null;
trainlisttest.list[code].speed = 0;
trainlisttest.list[code].position.x = -50000;
trainlisttest.list[code].position.y = -50000;
trainlisttest.list[code].pc = 1; trainlisttest.list[code].pc = 1;
if(trainlisttest.list[code].mixerpush == false){
for(let mi=0,lenmi=trainlisttest.list[code].mixer.length;mi<lenmi;mi++){
jlmap3d.mixers.push(trainlisttest.list[code].mixer[mi]);
}
trainlisttest.list[code].mixerpush = true;
}
} }
} else if (trainlisttest.list[code].dispose != data.body.deviceList[i].dispose && data.body.deviceList[i].dispose == "1") { }
trainlisttest.list[code].status = 1; if(data.body.deviceList[i].type == "SIGNAL"){
trainlisttest.group.remove(trainlisttest.list[code]); signalupdate(data.body.deviceList[i]);
trainlisttest.list[code].progress = null; }
trainlisttest.list[code].dispose = "1"; if(data.body.deviceList[i].type == "SWITCH"){
code = trainlisttest.group.children[i].name; switchupdate(data.body.deviceList[i]);
trainlisttest.list[code].rotation.y = 0; }
trainlisttest.list[code].open = '1'; if(data.body.deviceList[i].type == "PSD"){
trainlisttest.list[code].curve = null; standupdate(data.body.deviceList[i]);
trainlisttest.list[code].nextcurve = null; }
trainlisttest.list[code].speed = 0; if(data.body.deviceList[i].type == "TRAIN_DOOR"){
trainlisttest.list[code].position.x = -50000; traindoorupdate(data.body.deviceList[i]);
trainlisttest.list[code].position.y = -50000;
trainlisttest.list[code].pc = 1;
} }
} }
if(data.body.deviceList[i].type == "SIGNAL"){
signalupdate(data.body.deviceList[i]);
}
if(data.body.deviceList[i].type == "SWITCH"){
switchupdate(data.body.deviceList[i]);
}
if(data.body.deviceList[i].type == "PSD"){
standupdate(data.body.deviceList[i]);
}
if(data.body.deviceList[i].type == "TRAIN_DOOR"){
traindoorupdate(data.body.deviceList[i]);
}
} }
} }
function traindoorupdate(data){ function traindoorupdate(data){

View File

@ -1,744 +0,0 @@
import StompClient from '@/utils/sock';
// import { getTrainingCbtcDemon, runDiagramStart, runDiagramOver, setTrainingCbtcInitTime } from '@/api/simulation';
// import { creatSubscribe, clearSubscribe, displayTopic, screenTopic } from '@/utils/stomp';
import { getBaseUrl } from '@/utils/baseUrl'
import { getToken } from '@/utils/auth';
// 定于仿真socket接口
export function Jlmap3dSubscribe(jlmap3d,routegroup,jsonwebwork) {
const scope = this;
this.map = null;
var trainlisttest = null;
var sectionlist = null;
var signallist = null;
var stationstandlist = null;
var sectionlist = null;
var materials = null;
var actions = null;
var rails = null;
var links = null;
var scenes = null;
var code = null;
var drivingcode = null;
var drivingspeed = null;
var drivingaptspeed = null;
let driverswitch = false;
let stoptimer = null;
let num = 30;
let pointstand = null;
let data = null;
// run as plane = 01;
// reset = 02;
var datatype = '00';
this.teststomp = new StompClient();
this.topic = '/user/queue/simulation/jl3d/'+routegroup;
let header = {'X-Token': getToken() };
let connectmsg = {
type:'init',
baseurl:getBaseUrl(),
topic:this.topic,
token:getToken(),
};
jsonwebwork.postMessage(connectmsg);
jsonwebwork.onmessage = function (event) {
// if(event.data.type == 'Simulation_Driver_Change'){
// drivingcode = event.data.body.code;
// jlmap3d.updatedrivingcode( event.data.body.code);
// }
// if(data.type == 'Simulation_TrainSpeed'){
// trainspeed(data);
// }
// console.log(event);
// if(event.data.type == 'SJL3D_TrainStatus'){
// trainstatus(event.data);
// }
// if(event.data.type == 'Simulation_DeviceStatus'){
// devicestatus(event.data);
// }
if(event.data._type == 'Simulation_Driver_Change'){
drivingcode = event.data.body.code;
jlmap3d.updatedrivingcode( event.data.body.code);
}
if(event.data._type == 'Train'){
// console.log(event.data);
trainstatus(event.data);
}
if (event.data._type== 'Signal' && signallist) {
// console.log(event.data);
signalupdate(event.data);
}
if (event.data._type== 'StationStand' && actions) {
// console.log(event.data);
standupdate(event.data);
}
if (event.data._type == 'Switch' && sectionlist) {
// console.log(event.data);
switchupdate(event.data);
}
// if(event.data._type = ''){
// trainstatus(event.data);
// }
// if(event.data.type == 'Simulation_DeviceStatus'){
// devicestatus(event.data);
// }
if(event.data.type == 'Simulation_Reset'){
simulationreset(event.data);
}
};
// jsonwebwork.onmessage = function (event) {
// console.log(event.data);
// if(event.data.type == 'Simulation_Driver_Change'){
// drivingcode = event.data.body.code;
// jlmap3d.updatedrivingcode( event.data.body.code);
// }
// // if(event.data.type == 'Simulation_TrainSpeed'){
// // trainspeed(event.data);
// // }
// if(event.data.type == 'SJL3D_TrainStatus'){
// trainstatus(event.data);
// }
// if(event.data.type == 'Simulation_DeviceStatus'){
// devicestatus(event.data);
// }
// if(event.data.type == 'Simulation_Reset'){
// simulationreset(event.data);
// }
// };
this.updatamap = function(newsectionlist,newlinklist,newsignallist,newstationstandlist,newtrainlisttest,newrealsectionlist,newrails, materiallist, nowaction, scene) {
// console.log(mapdata);
trainlisttest = newtrainlisttest;
sectionlist = newsectionlist;
signallist = newsignallist;
stationstandlist = newstationstandlist;
materials = materiallist;
scenes = scene;
actions = nowaction;
links = newlinklist;
rails = newrails;
};
this.socketon = function(topic) {
try {
// console.log("teststomp");
// scope.teststomp.subscribe(topic, callback, header);
} catch (error) {
console.error('websocket订阅失败');
}
};
this.socketoff = function(topic) {
scope.teststomp.unsubscribe(topic);
for (let i=0; i<trainlisttest.group.children.length; i++) {
if (trainlisttest.group.children[i].dispose == false) {
code = trainlisttest.group.children[i].name;
trainlisttest.list[code].rotation.y = 0;
trainlisttest.list[code].doorStatus = '01';
trainlisttest.list[code].speed = 0;
trainlisttest.group.children[i].dispose = true;
trainlisttest.group.children[i].position.x = -50000;
trainlisttest.group.children[i].position.y = -50000;
trainlisttest.group.remove(trainlisttest.group.children[i]);
i--;
}
}
};
// 仿真socket接口回调函数
function callback(Response) {
}
function trainspeed(data){
if (trainlisttest) {
for (let tl = 0; tl<data.body.length; tl++) {
code = data.body[tl].id;
if(trainlisttest.list[code].speed != data.body[tl].v){
trainlisttest.list[code].speed = data.body[tl].v;
trainlisttest.list[code].speeds = parseFloat(data.body[tl].v*10/36/18/trainlisttest.list[code].len);
}
}
}
}
function trainstatus(data){
// for (let i=data.body.length-1; i>=0; i--) {
// console.log(data.body[i]);
// console.log(data);
// 遍历列车对象组
if (trainlisttest) {
code = data.code;
// 剔除不显示的车
// 找到对应列车
if ( trainlisttest.list[code]) {
trainlisttest.list[code].runMode = data.runMode;
// 车门开关验证
// if(data.directionType == "02"){
if (trainlisttest.list[code].doorStatus != data.doorStatus && data.doorStatus == '01') {
// console.log("close");
trainlisttest.list[code].doorStatus = '01';
for (let an=actions[code].top.length-1; an>=0; an--) {
actions[code].top[an].reset();
actions[code].top[an].time = actions[code].top[an]._clip.duration;
actions[code].top[an].timeScale = -1;
actions[code].top[an].play();
}
} else if (trainlisttest.list[code].doorStatus != data.doorStatus && data.doorStatus == '02') {
// console.log("open");
trainlisttest.list[code].doorStatus = '02';
for (let an=actions[code].top.length-1; an>=0; an--) {
actions[code].top[an].reset();
actions[code].top[an].time = 0;
actions[code].top[an].timeScale = 1;
actions[code].top[an].play();
}
}
// if(trainlisttest.list[code].doorStatus != data.doorStatus && data.doorStatus == "01"){
// //console.log("close");
// trainlisttest.list[code].doorStatus = "01";
// for(let an=actions[code].down.length-1;an>=0;an--){
// actions[code].down[an].reset();
// actions[code].down[an].time = actions[code].top[an]._clip.duration;
// actions[code].down[an].timeScale = -1;
// actions[code].down[an].play();
// }
// }else if(trainlisttest.list[code].doorStatus != data.doorStatus && data.doorStatus == "02"){
// //console.log("open");
// trainlisttest.list[code].doorStatus = "02";
// for(let an=actions[code].down.length-1;an>=0;an--){
// actions[code].down[an].reset();
// actions[code].down[an].time = 0;
// actions[code].down[an].timeScale = 1;
// actions[code].down[an].play();
// }
// }
// }
// 遍历获取所在轨道
if (trainlisttest.list[code].dispose != data.dispose && data.dispose == false) {
if (rails.linkrail[data.linkCode]) {
trainlisttest.group.add(trainlisttest.list[code]);
trainlisttest.list[code].position.y = 0;
// trainlisttest.list[code].progress = 0;
trainlisttest.list[code].dispose = false;
trainlisttest.list[code].nowcode = data.linkCode;
trainlisttest.list[code].nextcode = null;
trainlisttest.list[code].pc = 1;
if(trainlisttest.list[code].mixerpush == false){
for(let mi=0,lenmi=trainlisttest.list[code].mixer.length;mi<lenmi;mi++){
jlmap3d.mixers.push(trainlisttest.list[code].mixer[mi]);
}
trainlisttest.list[code].mixerpush = true;
// console.log(trainlisttest.list[code].mixerpush);
}
if (data.directionType == '02') { // 向右
if(data.targetStation){
trainlisttest.list[code].stopstation = data.targetStation;
// console.log(rails.stops[data.targetStation].direct2.percent);
trainlisttest.list[code].pc = data.targetLinkPercent/rails.stops[data.targetStation].direct2.percent;
trainlisttest.list[code].targetpercent = rails.stops[data.targetStation].direct2.percent;
trainlisttest.list[code].progress = data.linkOffsetPercent/trainlisttest.list[code].pc;
trainlisttest.list[code].linkOffsetPercent = data.linkOffsetPercent;
trainlisttest.list[code].targetLink = data.targetLink;
// console.log(data.targetLinkPercent);
// console.log(rails.stops[data.targetStation].direct2.percent);
// console.log(trainlisttest.list[code].progress);
// console.log("===================");
let point = rails.linkrail[data.linkCode].lineleft.getPointAt(trainlisttest.list[code].progress);
trainlisttest.list[code].rotation.y = 0;
trainlisttest.list[code].position.x = point.x;
trainlisttest.list[code].position.y = 0;
for (let tl=0; tl<6; tl++) {
trainlisttest.list[code].children[tl].position.z = point.z;
}
}else{
trainlisttest.list[code].progress = data.linkOffsetPercent/trainlisttest.list[code].pc;
trainlisttest.list[code].linkOffsetPercent = data.linkOffsetPercent;
let point = rails.linkrail[data.linkCode].lineleft.getPointAt(trainlisttest.list[code].progress);
trainlisttest.list[code].rotation.y = 0;
trainlisttest.list[code].position.x = point.x;
trainlisttest.list[code].position.y = 0;
for (let tl=0; tl<6; tl++) {
trainlisttest.list[code].children[tl].position.z = point.z;
}
}
trainlisttest.list[code].curve = rails.linkrail[data.linkCode].lineleft;
trainlisttest.list[code].len = rails.linkrail[data.linkCode].lengthfact;
trainlisttest.list[code].status = '02';
} else if (data.directionType == '03') { // 向左
// if(trainlisttest.list[code].rname == "006"){
// console.log("0000000000000000");
// console.log(data.linkOffsetPercent);
// }
if(data.targetStation){
trainlisttest.list[code].stopstation = data.targetStation;
trainlisttest.list[code].pc = data.targetLinkPercent/rails.stops[data.targetStation].direct1.percent;
trainlisttest.list[code].targetpercent = rails.stops[data.targetStation].direct1.percent;
trainlisttest.list[code].progress = 1-(data.linkOffsetPercent/trainlisttest.list[code].pc);
trainlisttest.list[code].linkOffsetPercent = data.linkOffsetPercent;
trainlisttest.list[code].targetLink = data.targetLink;
// console.log(data.targetLinkPercent);
// console.log(rails.stops[data.targetStation].direct1.percent);
// console.log(trainlisttest.list[code].progress);
// console.log("===================");
let point = rails.linkrail[data.linkCode].lineright.getPointAt(trainlisttest.list[code].progress);
trainlisttest.list[code].rotation.y = Math.PI;
trainlisttest.list[code].position.x = point.x;
trainlisttest.list[code].position.y = 0;
for (let tl=0; tl<6; tl++) {
trainlisttest.list[code].children[tl].position.z = -point.z;
}
}else{
trainlisttest.list[code].progress = data.linkOffsetPercent/trainlisttest.list[code].pc;
trainlisttest.list[code].linkOffsetPercent = data.linkOffsetPercent;
let point = rails.linkrail[data.linkCode].lineleft.getPointAt(trainlisttest.list[code].progress);
trainlisttest.list[code].rotation.y = 0;
trainlisttest.list[code].position.x = point.x;
trainlisttest.list[code].position.y = 0;
for (let tl=0; tl<6; tl++) {
trainlisttest.list[code].children[tl].position.z = point.z;
}
}
trainlisttest.list[code].curve = rails.linkrail[data.linkCode].lineright;
trainlisttest.list[code].len = rails.linkrail[data.linkCode].lengthfact;
trainlisttest.list[code].status = '03';
// trainlisttest.list[code].curve = rails.linkrail[data.linkCode].lineright;
}
trainlisttest.list[code].len = rails.linkrail[data.linkCode].lengthfact;
// trainlisttest.list[code].isStandTrack = sectionlist.sections.datalist[data.sectionCode].isStandTrack;
// trainlisttest.list[code].len = sectionlist.sections.datalist[data.sectionCode].distance;
if(trainlisttest.list[code].targetLink == trainlisttest.list[code].nowcode){
trainlisttest.list[code].statsstop = 0;
}else{
trainlisttest.list[code].statsstop = 1;
}
if(data.speed == 0){
trainlisttest.list[code].speeds = data.speed;
trainlisttest.list[code].speeds = 0;
// trainlisttest.list[code].startmark = 1;
}else{
trainlisttest.list[code].speeds = data.speed;
trainlisttest.list[code].speeds = parseFloat(data.speed*10/36/18/trainlisttest.list[code].len);
}
}
} else if (trainlisttest.list[code].dispose != data.dispose && data.dispose == true) {
trainlisttest.group.remove(trainlisttest.list[code]);
trainlisttest.list[code].progress = null;
trainlisttest.list[code].dispose = true;
code = trainlisttest.group.children[i].name;
trainlisttest.list[code].rotation.y = 0;
trainlisttest.list[code].doorStatus = '01';
trainlisttest.list[code].speed = 0;
trainlisttest.list[code].position.x = -50000;
trainlisttest.list[code].position.y = -50000;
trainlisttest.list[code].pc = 1;
} else if (trainlisttest.list[code].dispose == data.dispose && data.dispose == false) {
// if(data.){
//
// }
if (data.directionType == '02' && trainlisttest.list[code].status != data.directionType) { // 向右
let rotaposx = trainlisttest.list[code].children[5].matrixWorld.elements[12];
let rotaposz = trainlisttest.list[code].children[0].matrixWorld.elements[14];
trainlisttest.list[code].rotation.y = 0;
trainlisttest.list[code].position.x = rotaposx;
for (let tl=0; tl<6; tl++) {
trainlisttest.list[code].children[tl].position.z = rotaposz;
}
trainlisttest.list[code].progress = (rotaposx-rails.linkrail[data.linkCode].lp.x)/rails.linkrail[data.linkCode].lengthfact;
trainlisttest.list[code].status = '02';
trainlisttest.list[code].curve = rails.linkrail[data.linkCode].lineleft;
trainlisttest.list[code].nextcurve = null;
trainlisttest.list[code].len = rails.linkrail[data.linkCode].lengthfact;
} else if (data.directionType == '03'&& trainlisttest.list[code].status != data.directionType) { // 向左
let rotaposx = trainlisttest.list[code].children[5].matrixWorld.elements[12];
let rotaposz = Math.abs(trainlisttest.list[code].children[0].matrixWorld.elements[14]);
trainlisttest.list[code].rotation.y = Math.PI;
trainlisttest.list[code].position.x = rotaposx;
for (let tl=0; tl<6; tl++) {
trainlisttest.list[code].children[tl].position.z = -rotaposz;
}
trainlisttest.list[code].progress = 1-(rotaposx-rails.linkrail[data.linkCode].lp.x)/rails.linkrail[data.linkCode].lengthfact;
trainlisttest.list[code].status = '03';
trainlisttest.list[code].curve = rails.linkrail[data.linkCode].lineright;
trainlisttest.list[code].nextcurve = null;
trainlisttest.list[code].len = rails.linkrail[data.linkCode].lengthfact;
}
if(trainlisttest.list[code].nextcode == null ){//&& trainlisttest.list[code].stopstation == data.targetStation
// if(data.groupNumber == "016"){
// console.log(trainlisttest.list[code].nextcode);
// console.log(trainlisttest.list[code].stopstation);
// console.log(data.targetStation);
// console.log(data.body[i]);
// console.log(trainlisttest.list[code]);
// }
// if(trainlisttest.list[code].targetLink != trainlisttest.list[code].nowcode){
let nextcode;
if(data.directionType == '02'){
trainlisttest.list[code].status = '02';
// console.log(rails.linkrail[trainlisttest.list[code].nowcode]);
if(rails.linkrail[trainlisttest.list[code].nowcode]){
nextcode = rails.linkrail[trainlisttest.list[code].nowcode].rconnect;
}
if(nextcode){
trainlisttest.list[code].nextcurve = rails.linkrail[nextcode].lineleft;
trainlisttest.list[code].nextlen = rails.linkrail[nextcode].lengthfact;
}else{
trainlisttest.list[code].nextlen = 0;
}
}else if(data.directionType == '03'){
trainlisttest.list[code].status = '03';
if(rails.linkrail[trainlisttest.list[code].nowcode]){
nextcode = rails.linkrail[trainlisttest.list[code].nowcode].lconnect;
}
if(nextcode){
trainlisttest.list[code].nextcurve = rails.linkrail[nextcode].lineright;
trainlisttest.list[code].nextlen = rails.linkrail[nextcode].lengthfact;
}else{
trainlisttest.list[code].nextlen = 0;
}
}
trainlisttest.list[code].nextcode = nextcode;
// }
if(trainlisttest.list[code].curve == null){
trainlisttest.list[code].len = trainlisttest.list[code].nextlen;
trainlisttest.list[code].nowcode = trainlisttest.list[code].nextcode;
trainlisttest.list[code].curve = trainlisttest.list[code].nextcurve;
trainlisttest.list[code].nextcurve = null;
trainlisttest.list[code].nextlen = null;
trainlisttest.list[code].nextcode = null;
}
}
if(data.groupNumber == "016"){
// console.log(data.targetLink);
// console.log(trainlisttest.list[code].nowcode);
//
// console.log(trainlisttest.list[code].progress);
// console.log("==============");
}
trainlisttest.list[code].targetLink = data.targetLink;
if(trainlisttest.list[code].stopstation != data.targetStation){
if(data.directionType == '02'){
if(data.targetStation){
trainlisttest.list[code].pc = data.targetLinkPercent/rails.stops[data.targetStation].direct2.percent;
trainlisttest.list[code].targetpercent = rails.stops[data.targetStation].direct2.percent;
// trainlisttest.list[code].linkOffsetPercent = data.linkOffsetPercent;
// trainlisttest.list[code].targetLink = data.targetLink;
}
trainlisttest.list[code].status = '02';
}else if(data.directionType == '03'){
if(data.targetStation){
trainlisttest.list[code].pc = data.targetLinkPercent/rails.stops[data.targetStation].direct1.percent;
trainlisttest.list[code].targetpercent = rails.stops[data.targetStation].direct1.percent;
// trainlisttest.list[code].linkOffsetPercent = data.linkOffsetPercent;
// trainlisttest.list[code].targetLink = data.targetLink;
}
trainlisttest.list[code].status = '03';
}
trainlisttest.list[code].stopstation = data.targetStation;
}
}
}
if(trainlisttest.list[code].targetLink == trainlisttest.list[code].nowcode){
trainlisttest.list[code].statsstop = 0;
}else{
trainlisttest.list[code].statsstop = 1;
}
// console.log(data.body[i]);
if(trainlisttest.list[code].speed != data.speed){
trainlisttest.list[code].speed = data.speed;
trainlisttest.list[code].speeds = parseFloat(data.speed*10/36/18/trainlisttest.list[code].len);
}
}
// }
}
function standupdate(data) {
code = data.code;
if ( actions[code]) {
if (data.screenDoorOpenStatus == '02' && actions[code].status == '01') {
actions[code].status = '00';
}
if (data.screenDoorOpenStatus == '02' && actions[code].status == '00') {
actions[code].status = '02';
actions[code].action.reset();
actions[code].action.time = 0;
actions[code].action.timeScale = 1;
actions[code].action.play();
}
if (data.screenDoorOpenStatus == '01' && actions[code].status == '02') {
actions[code].status = '00';
}
if (data.screenDoorOpenStatus == '01' && actions[code].status == '00') {
actions[code].status = '01';
actions[code].action.reset();
actions[code].action.time = actions[code].action._clip.duration;
actions[code].action.timeScale = -1;
actions[code].action.play();
}
}
}
function devicestatus(data){
for (let i= 0,leni = data.body.length; i<leni; i++) {
// 0xFFFFFF
// 0xCD0000 红
// 0xEEEE00 黄
// 0x32CD32 绿
if (data._type == 'Signal' && signallist) {
if (signallist) {
// console.log(data.body[i]);
signalupdate(data.body[i]);
}
}
if (data._type == 'StationStand' && actions) {
if (actions) {
standupdate(data.body[i]);
}
}
if (data._type == 'Switch' && sectionlist) {
if (sectionlist) {
switchupdate(data.body[i]);
}
}
}
}
function signalupdate(data) {
code = data.code;
// console.log(data);
if (data.lightType == '01') {
if (signallist.list[code].mesh.code) {
signallist.list[code].mesh.status = data.status;
// 55
// 33
// 77
// 关闭
if (data.status == '01') {
signallist.list[code].mesh.getObjectByName("red").material.map = materials[0];
signallist.list[code].mesh.getObjectByName("red").material.map.needsUpdate = true;
signallist.list[code].mesh.getObjectByName("yellow").material.map = materials[3];
signallist.list[code].mesh.getObjectByName("yellow").material.map.needsUpdate = true;
signallist.list[code].mesh.getObjectByName("green").material.map = materials[3];
signallist.list[code].mesh.getObjectByName("green").material.map.needsUpdate = true;
}
// 开放
if (data.status == '02') {
signallist.list[code].mesh.getObjectByName("red").material.map = materials[3];
signallist.list[code].mesh.getObjectByName("red").material.map.needsUpdate = true;
signallist.list[code].mesh.getObjectByName("yellow").material.map = materials[3];
signallist.list[code].mesh.getObjectByName("yellow").material.map.needsUpdate = true;
signallist.list[code].mesh.getObjectByName("green").material.map = materials[2];
signallist.list[code].mesh.getObjectByName("green").material.map.needsUpdate = true;
}
if (data.status == '03') {
signallist.list[code].mesh.getObjectByName("red").material.map = materials[3];
signallist.list[code].mesh.getObjectByName("red").material.map.needsUpdate = true;
signallist.list[code].mesh.getObjectByName("yellow").material.map = materials[1];
signallist.list[code].mesh.getObjectByName("yellow").material.map.needsUpdate = true;
signallist.list[code].mesh.getObjectByName("green").material.map = materials[3];
signallist.list[code].mesh.getObjectByName("green").material.map.needsUpdate = true;
}
// 引导
if (data.status == '03') {
signallist.list[code].mesh.getObjectByName("red").material.map = materials[0];
signallist.list[code].mesh.getObjectByName("red").material.map.needsUpdate = true;
signallist.list[code].mesh.getObjectByName("yellow").material.map = materials[1];
signallist.list[code].mesh.getObjectByName("yellow").material.map.needsUpdate = true;
signallist.list[code].mesh.getObjectByName("green").material.map = materials[3];
signallist.list[code].mesh.getObjectByName("green").material.map.needsUpdate = true;
}
// 封锁
if (data.status == '04') {
signallist.list[code].mesh.getObjectByName("red").material.map = materials[3];
signallist.list[code].mesh.getObjectByName("red").material.map.needsUpdate = true;
signallist.list[code].mesh.getObjectByName("yellow").material.map = materials[3];
signallist.list[code].mesh.getObjectByName("yellow").material.map.needsUpdate = true;
signallist.list[code].mesh.getObjectByName("green").material.map = materials[3];
signallist.list[code].mesh.getObjectByName("green").material.map.needsUpdate = true;
}
// 故障
if (data.status == '05') {
signallist.list[code].mesh.getObjectByName("red").material.map = materials[3];
signallist.list[code].mesh.getObjectByName("red").material.map.needsUpdate = true;
signallist.list[code].mesh.getObjectByName("yellow").material.map = materials[3];
signallist.list[code].mesh.getObjectByName("yellow").material.map.needsUpdate = true;
signallist.list[code].mesh.getObjectByName("green").material.map = materials[3];
signallist.list[code].mesh.getObjectByName("green").material.map.needsUpdate = true;
}
if (data.status == '06') {
signallist.list[code].mesh.getObjectByName("red").material.map = materials[3];
signallist.list[code].mesh.getObjectByName("red").material.map.needsUpdate = true;
signallist.list[code].mesh.getObjectByName("yellow").material.map = materials[3];
signallist.list[code].mesh.getObjectByName("yellow").material.map.needsUpdate = true;
signallist.list[code].mesh.getObjectByName("green").material.map = materials[3];
signallist.list[code].mesh.getObjectByName("green").material.map.needsUpdate = true;
}
}
} else if (data.lightType == '01') {
if (signallist.list[code].mesh.code) {
signallist.list[code].mesh.getObjectByName("red").material.map = materials[3];
signallist.list[code].mesh.getObjectByName("red").material.map.needsUpdate = true;
signallist.list[code].mesh.getObjectByName("yellow").material.map = materials[3];
signallist.list[code].mesh.getObjectByName("yellow").material.map.needsUpdate = true;
signallist.list[code].mesh.getObjectByName("green").material.map = materials[3];
signallist.list[code].mesh.getObjectByName("green").material.map.needsUpdate = true;
}
}
}
function switchupdate(data) {
code = data.code;
for (let j=sectionlist.switchs.modellist.length-1; j>=0; j--) {
if (rails.switchrail[code]) {
if (rails.switchrail[code].locateType != data.locateType) {
if (data.locateType == '02') {
if (actions[sectionlist.switchs.modellist[j].code]) {
sectionlist.switchs.modellist[j].locateType = data.locateType;
actions[sectionlist.switchs.modellist[j].code].reset();
actions[sectionlist.switchs.modellist[j].code].time = 0;
actions[sectionlist.switchs.modellist[j].code].timeScale = 1;
actions[sectionlist.switchs.modellist[j].code].play();
}
rails.switchrail[code].locateType = "02";
let testswitch = rails.switchrail[code];
// console.log(testswitch);
// console.log(rails.linkrail[testswitch.alink]);
// console.log(rails.linkrail[testswitch.clink]);
if(rails.switchrail[code].directtype == "1"){
rails.linkrail[testswitch.alink].lconnect = testswitch.clink;
rails.linkrail[testswitch.clink].rconnect = testswitch.alink;
}else if(rails.switchrail[code].directtype == "2"){
rails.linkrail[testswitch.alink].rconnect = testswitch.clink;
rails.linkrail[testswitch.clink].lconnect = testswitch.alink;
}
} else if (data.locateType == '01') {
if (actions[sectionlist.switchs.modellist[j].code]) {
sectionlist.switchs.modellist[j].locateType = data.locateType;
actions[sectionlist.switchs.modellist[j].code].reset();
actions[sectionlist.switchs.modellist[j].code].time = actions[sectionlist.switchs.modellist[j].code]._clip.duration;
actions[sectionlist.switchs.modellist[j].code].timeScale = -1;
actions[sectionlist.switchs.modellist[j].code].play();
}
rails.switchrail[code].locateType = "01";
let testswitch = rails.switchrail[code];
// console.log(testswitch);
// console.log(rails.linkrail[testswitch.alink]);
// console.log(rails.linkrail[testswitch.clink]);
if(rails.switchrail[code].directtype == "1"){
rails.linkrail[testswitch.alink].lconnect = testswitch.blink;
rails.linkrail[testswitch.blink].rconnect = testswitch.alink;
}else if(rails.switchrail[code].directtype == "2"){
rails.linkrail[testswitch.alink].rconnect = testswitch.blink;
rails.linkrail[testswitch.blink].lconnect = testswitch.alink;
}
}
}
j = 0;
}
}
}
function simulationreset(data){
for(let i=0;i<trainlisttest.group.children.length;i++){
trainlisttest.group.children[i].dispose = true;
trainlisttest.group.children[i].stopstation = null;
trainlisttest.group.children[i].pc = null;
trainlisttest.group.children[i].targetpercent = null;
trainlisttest.group.children[i].progress = null;
trainlisttest.group.children[i].linkOffsetPercent = null;
trainlisttest.group.children[i].targetLink = null;
trainlisttest.group.remove(trainlisttest.group.children[i]);
i--;
}
}
}

View File

@ -1,445 +0,0 @@
import StompClient from '@/utils/sock';
import { displayTopic } from '@/utils/stomp';
import { getToken } from '@/utils/auth';
import router from '@/router/index_APP_TARGET';
// 定于仿真socket接口
export function Jlmap3dSubscribe(worker,routegroup) {
const scope = this;
this.map = null;
const webworker = worker;
var trainlisttest = null;
var sectionlist = null;
var signallist = null;
var stationstandlist = null;
var sectionlist = null;
var materials = null;
var actions = null;
var scenes = null;
var code = null;
this.teststomp = new StompClient();
this.topic = displayTopic;
const header = { group: router.currentRoute.query.group, 'X-Token': getToken() };
console.log( router.currentRoute.query.group);
this.updatamap = function (mapdata, materiallist, nowaction, scene) {
// console.log(mapdata);
scope.map = mapdata;
trainlisttest = this.map.trainlisttest;
sectionlist = this.map.sectionlist;
signallist = this.map.signallist;
stationstandlist = this.map.stationstandlist;
sectionlist = this.map.sectionlist;
materials = materiallist;
scenes = scene;
actions = nowaction;
};
this.socketon = function (topic) {
try {
// console.log("teststomp");
scope.teststomp.subscribe(topic, callback, header);
} catch (error) {
console.error('websocket订阅失败');
}
};
this.socketoff = function (topic) {
scope.teststomp.unsubscribe(topic);
};
// 仿真socket接口回调函数
function callback(Response) {
// 对象化数据
const data = JSON.parse(Response.body);
// 遍历后台数据
// 判断消息类型
// if(data.type == "Simulation_TrainPosition"){
//
//
// }
if (data.type == 'Simulation_DeviceStatus') {
if (data.body.length < 200) {
for (let i = data.body.length - 1; i >= 0; i--) {
if (data.body[i]._type == 'Train') {
// console.log(data.body[i]);
// 遍历列车对象组
// console.log(data.body[i]);
if (trainlisttest) {
code = data.body[i].code;
// 剔除不显示的车
// 找到对应列车
if (trainlisttest.list[code]) {
// 车门开关验证
// if(data.body[i].directionType == "02"){
if (trainlisttest.list[code].doorStatus != data.body[i].doorStatus && data.body[i].doorStatus == '01') {
// console.log("close");
trainlisttest.list[code].doorStatus = '01';
for (let an = actions[code].top.length - 1; an >= 0; an--) {
actions[code].top[an].reset();
actions[code].top[an].time = actions[code].top[an]._clip.duration;
actions[code].top[an].timeScale = -1;
actions[code].top[an].play();
}
} else if (trainlisttest.list[code].doorStatus != data.body[i].doorStatus && data.body[i].doorStatus == '02') {
// console.log("open");
trainlisttest.list[code].doorStatus = '02';
for (let an = actions[code].top.length - 1; an >= 0; an--) {
actions[code].top[an].reset();
actions[code].top[an].time = 0;
actions[code].top[an].timeScale = 1;
actions[code].top[an].play();
}
}
// }else{
// if(trainlisttest.list[code].doorStatus != data.body[i].doorStatus && data.body[i].doorStatus == "01"){
// //console.log("close");
// trainlisttest.list[code].doorStatus = "01";
// for(let an=actions[code].down.length-1;an>=0;an--){
// actions[code].down[an].reset();
// actions[code].down[an].time = actions[code].top[an]._clip.duration;
// actions[code].down[an].timeScale = -1;
// actions[code].down[an].play();
// }
// }else if(trainlisttest.list[code].doorStatus != data.body[i].doorStatus && data.body[i].doorStatus == "02"){
// //console.log("open");
// trainlisttest.list[code].doorStatus = "02";
// for(let an=actions[code].down.length-1;an>=0;an--){
// actions[code].down[an].reset();
// actions[code].down[an].time = 0;
// actions[code].down[an].timeScale = 1;
// actions[code].down[an].play();
// }
// }
// }
// 遍历获取所在轨道
if (trainlisttest.list[code].dispose != data.body[i].dispose && data.body[i].dispose == false) {
trainlisttest.group.add(trainlisttest.list[code]);
if (sectionlist.sections.datalist[data.body[i].sectionCode].code) {
trainlisttest.list[code].position.y = 0;
trainlisttest.list[code].progress = 0;
trainlisttest.list[code].oldoffset = data.body[i].sectionOffsetPercent;
trainlisttest.list[code].dispose = false;
if (data.body[i].directionType == '02') {
trainlisttest.list[code].status = '02';
trainlisttest.list[code].rotation.y = 0;
} else if (data.body[i].directionType == '03') {
trainlisttest.list[code].status = '03';
trainlisttest.list[code].rotation.y = Math.PI;
}
}
} else if (trainlisttest.list[code].dispose != data.body[i].dispose && data.body[i].dispose == true) {
trainlisttest.group.remove(trainlisttest.list[code]);
trainlisttest.list[code].progress = null;
trainlisttest.list[code].dispose = true;
} else if (trainlisttest.list[code].dispose == data.body[i].dispose && data.body[i].dispose == false) {
if (sectionlist.sections.datalist[data.body[i].sectionCode].code) {
if (trainlisttest.list[code].nowcode != data.body[i].sectionCode || trainlisttest.list[code].nextcode != data.body[i].nextSectionCode) {
trainlisttest.list[code].nowcode = data.body[i].sectionCode;
trainlisttest.list[code].nextcode = data.body[i].nextSectionCode;
const vexlist = [];
const endrotation = null;
if (data.body[i].directionType == '02') { // 向右
if (trainlisttest.list[code].status != data.body[i].directionType) {
console.log(trainlisttest.list[code].position);
console.log(trainlisttest.list[code].children[5].matrixWorld);
trainlisttest.list[code].position.x = trainlisttest.list[code].children[5].matrixWorld.elements[12];
trainlisttest.list[code].children[0].position.z = trainlisttest.list[code].children[0].matrixWorld.elements[14];
trainlisttest.list[code].children[1].position.z = trainlisttest.list[code].children[1].matrixWorld.elements[14];
trainlisttest.list[code].children[2].position.z = trainlisttest.list[code].children[2].matrixWorld.elements[14];
trainlisttest.list[code].children[3].position.z = trainlisttest.list[code].children[3].matrixWorld.elements[14];
trainlisttest.list[code].children[4].position.z = trainlisttest.list[code].children[4].matrixWorld.elements[14];
trainlisttest.list[code].children[5].position.z = trainlisttest.list[code].children[5].matrixWorld.elements[14];
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x > sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) {
vexlist.push(new THREE.Vector3(trainlisttest.list[code].position.x, 0, trainlisttest.list[code].children[0].matrixWorld.elements[14]));
for (let m = sectionlist.sections.datalist[data.body[i].sectionCode].rail.length - 1; m >= 0; m--) {
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[m].x > trainlisttest.list[code].position.x) {
vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
}
}
} else {
vexlist.push(new THREE.Vector3(trainlisttest.list[code].position.x, 0, trainlisttest.list[code].children[0].matrixWorld.elements[14]));
for (let m = 0; m < sectionlist.sections.datalist[data.body[i].sectionCode].rail.length; m++) {
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[m].x > trainlisttest.list[code].position.x) {
vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
}
}
}
} else {
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x > sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) {
for (let m = sectionlist.sections.datalist[data.body[i].sectionCode].rail.length - 1; m >= 0; m--) {
vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
}
} else {
for (let m = 0; m < sectionlist.sections.datalist[data.body[i].sectionCode].rail.length; m++) {
vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
}
}
}
trainlisttest.list[code].status = '02';
trainlisttest.list[code].rotation.y = 0;
} else if (data.body[i].directionType == '03') { // 向左
if (trainlisttest.list[code].status != data.body[i].directionType) {
trainlisttest.list[code].position.x = trainlisttest.list[code].children[5].matrixWorld.elements[12];
trainlisttest.list[code].children[0].position.z = trainlisttest.list[code].children[0].matrixWorld.elements[14];
trainlisttest.list[code].children[1].position.z = trainlisttest.list[code].children[1].matrixWorld.elements[14];
trainlisttest.list[code].children[2].position.z = trainlisttest.list[code].children[2].matrixWorld.elements[14];
trainlisttest.list[code].children[3].position.z = trainlisttest.list[code].children[3].matrixWorld.elements[14];
trainlisttest.list[code].children[4].position.z = trainlisttest.list[code].children[4].matrixWorld.elements[14];
trainlisttest.list[code].children[5].position.z = trainlisttest.list[code].children[5].matrixWorld.elements[14];
//
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x < sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) {
vexlist.push(new THREE.Vector3(trainlisttest.list[code].position.x, 0, trainlisttest.list[code].children[0].matrixWorld.elements[14]));
for (let m = sectionlist.sections.datalist[data.body[i].sectionCode].rail.length - 1; m >= 0; m--) {
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[m].x < trainlisttest.list[code].position.x) {
vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
}
}
} else {
vexlist.push(new THREE.Vector3(trainlisttest.list[code].position.x, 0, trainlisttest.list[code].children[0].matrixWorld.elements[14]));
for (let m = 0; m < sectionlist.sections.datalist[data.body[i].sectionCode].rail.length; m++) {
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[m].x < trainlisttest.list[code].position.x) {
vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
}
}
}
} else {
//
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x < sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) {
for (let m = sectionlist.sections.datalist[data.body[i].sectionCode].rail.length - 1; m >= 0; m--) {
vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
}
} else {
for (let m = 0; m < sectionlist.sections.datalist[data.body[i].sectionCode].rail.length; m++) {
vexlist.push(sectionlist.sections.datalist[data.body[i].sectionCode].rail[m]);
}
}
}
trainlisttest.list[code].status = '03';
trainlisttest.list[code].rotation.y = Math.PI;
}
trainlisttest.list[code].curve = new THREE.CatmullRomCurve3(vexlist);
// console.log(trainlisttest.list[code].curve.points);
// console.log(data.body[i].speed)
// console.log(sectionlist.sections.datalist[data.body[i].sectionCode].distance);
trainlisttest.list[code].speeds = data.body[i].speed * 10 / 36 / 11 / sectionlist.sections.datalist[data.body[i].sectionCode].distance;
trainlisttest.list[code].progress = 0;
}
// console.log("speed");
// console.log(data.body[i].speed);
// console.log(trainlisttest.list[code].speed);
if (data.body[i].speed != trainlisttest.list[code].speed) {
trainlisttest.list[code].speed = data.body[i].speed;
trainlisttest.list[code].speeds = data.body[i].speed * 10 / 36 / 11 / sectionlist.sections.datalist[data.body[i].sectionCode].distance;
// if(trainlisttest.list[code].speeds > 0.1){
// console.log(data.body[i]);
// console.log(data.body[i].speed)
// console.log(sectionlist.sections.datalist[data.body[i].sectionCode].distance);
// console.log(trainlisttest.list[code].speeds);
// }
}
}
}
}
}
}
// 0xFFFFFF
// 0xCD0000 红
// 0xEEEE00 黄
// 0x32CD32 绿
if (data.body[i]._type == 'Signal') {
if (signallist) {
code = data.body[i].code;
if (data.body[i].lightType == '01') {
if (signallist.list[code].mesh.code) {
signallist.list[code].mesh.status = data.body[i].status;
// 55
// 33
// 77
// 关闭
if (data.body[i].status == '01') {
signallist.list[code].mesh.children[0].material.map = materials[3];
signallist.list[code].mesh.children[0].material.map.needsUpdate = true;
signallist.list[code].mesh.children[1].material.map = materials[0];
signallist.list[code].mesh.children[1].material.map.needsUpdate = true;
signallist.list[code].mesh.children[2].material.map = materials[3];
signallist.list[code].mesh.children[2].material.map.needsUpdate = true;
}
// 开放
if (data.body[i].status == '02') {
if (data.body[i].switchLocateType == '01') {
signallist.list[code].mesh.children[0].material.map = materials[2];
signallist.list[code].mesh.children[0].material.map.needsUpdate = true;
signallist.list[code].mesh.children[1].material.map = materials[3];
signallist.list[code].mesh.children[1].material.map.needsUpdate = true;
signallist.list[code].mesh.children[2].material.map = materials[3];
signallist.list[code].mesh.children[2].material.map.needsUpdate = true;
}
if (data.body[i].switchLocateType == '02') {
signallist.list[code].mesh.children[0].material.map = materials[3];
signallist.list[code].mesh.children[0].material.map.needsUpdate = true;
signallist.list[code].mesh.children[1].material.map = materials[3];
signallist.list[code].mesh.children[1].material.map.needsUpdate = true;
signallist.list[code].mesh.children[2].material.map = materials[1];
signallist.list[code].mesh.children[2].material.map.needsUpdate = true;
}
}
// 引导
if (data.body[i].status == '03') {
signallist.list[code].mesh.children[0].material.map = materials[3];
signallist.list[code].mesh.children[0].material.map.needsUpdate = true;
signallist.list[code].mesh.children[1].material.map = materials[0];
signallist.list[code].mesh.children[1].material.map.needsUpdate = true;
signallist.list[code].mesh.children[2].material.map = materials[1];
signallist.list[code].mesh.children[2].material.map.needsUpdate = true;
}
// 封锁
if (data.body[i].status == '04') {
signallist.list[code].mesh.children[0].material.map = materials[3];
signallist.list[code].mesh.children[0].material.map.needsUpdate = true;
signallist.list[code].mesh.children[1].material.map = materials[3];
signallist.list[code].mesh.children[1].material.map.needsUpdate = true;
signallist.list[code].mesh.children[2].material.map = materials[3];
signallist.list[code].mesh.children[2].material.map.needsUpdate = true;
}
// 故障
if (data.body[i].status == '05') {
signallist.list[code].mesh.children[0].material.map = materials[3];
signallist.list[code].mesh.children[0].material.map.needsUpdate = true;
signallist.list[code].mesh.children[1].material.map = materials[3];
signallist.list[code].mesh.children[1].material.map.needsUpdate = true;
signallist.list[code].mesh.children[2].material.map = materials[3];
signallist.list[code].mesh.children[2].material.map.needsUpdate = true;
}
}
} else if (data.body[i].lightType == '01') {
if (signallist.list[code].mesh.code) {
signallist.list[code].mesh.children[0].material.map = materials[3];
signallist.list[code].mesh.children[0].material.map.needsUpdate = true;
signallist.list[code].mesh.children[1].material.map = materials[3];
signallist.list[code].mesh.children[1].material.map.needsUpdate = true;
signallist.list[code].mesh.children[2].material.map = materials[3];
signallist.list[code].mesh.children[2].material.map.needsUpdate = true;
}
}
}
}
if (data.body[i]._type == 'StationStand') {
if (actions) {
code = data.body[i].code;
if (data.body[i].screenDoorOpenStatus == '02' && actions[code].status == '01') {
actions[code].status = '00';
}
if (data.body[i].screenDoorOpenStatus == '02' && actions[code].status == '00') {
actions[code].status = '02';
actions[code].action.reset();
actions[code].action.time = 0;
actions[code].action.timeScale = 1;
actions[code].action.play();
}
if (data.body[i].screenDoorOpenStatus == '01' && actions[code].status == '02') {
actions[code].status = '00';
}
if (data.body[i].screenDoorOpenStatus == '01' && actions[code].status == '00') {
actions[code].status = '01';
actions[code].action.reset();
actions[code].action.time = actions[code].action._clip.duration;
actions[code].action.timeScale = -1;
actions[code].action.play();
}
}
}
if (data.body[i]._type == 'Switch') {
if (sectionlist) {
code = data.body[i].code;
for (let j = sectionlist.switchs.modellist.length - 1; j >= 0; j--) {
if (sectionlist.switchs.modellist[j].code == code) {
if (sectionlist.switchs.modellist[j].locateType != data.body[i].locateType) {
if (data.body[i].locateType == '02') {
sectionlist.switchs.modellist[j].locateType = data.body[i].locateType;
actions[sectionlist.switchs.modellist[j].code].reset();
actions[sectionlist.switchs.modellist[j].code].time = 0;
actions[sectionlist.switchs.modellist[j].code].timeScale = 1;
actions[sectionlist.switchs.modellist[j].code].play();
} else if (data.body[i].locateType == '01') {
sectionlist.switchs.modellist[j].locateType = data.body[i].locateType;
actions[sectionlist.switchs.modellist[j].code].reset();
actions[sectionlist.switchs.modellist[j].code].time = actions[sectionlist.switchs.modellist[j].code]._clip.duration;
actions[sectionlist.switchs.modellist[j].code].timeScale = -1;
actions[sectionlist.switchs.modellist[j].code].play();
}
}
// console.log(sectionlist.group[j].name);
j = 0;
}
}
}
}
}
} else if (data.body.length > 200) {
}
}
}
}

View File

@ -1,174 +0,0 @@
export function UpdateTrainNew(camera,traindata){
if(traindata != undefined ){
for(let j=traindata.group.children.length-1;j>=0;j--){
//判断是否有移动事件
let trainmodel = traindata.group.children[j];
if(trainmodel.speeds > 0 && trainmodel.speeds){
let speed = null;
if(traindata.group.children[j].progress >=0&&traindata.group.children[j].progress<=1){
let movecurve = trainmodel.curve;
if(trainmodel.status == "1"){
let point = movecurve.getPointAt(trainmodel.progress);
let worldpositionz = trainmodel.children[0].position.z;
trainmodel.position.x = point.x;
trainmodel.position.y = 0;
let offset = Math.abs( point.z -parseFloat(worldpositionz));
if(Math.abs( point.z -trainmodel.children[0].matrixWorld.elements[14]) >0.02){
trainmodel.children[0].up = new THREE.Vector3(1,0,0);
let tangent = movecurve.getTangentAt(traindata.group.children[j].progress).normalize();
trainmodel.children[0].axis.crossVectors(trainmodel.children[0].up, tangent).normalize();
let radians = Math.acos(trainmodel.children[0].up.dot(tangent));
trainmodel.children[0].quaternion.setFromAxisAngle(trainmodel.children[0].axis, radians);
trainmodel.children[0].rotation.x = -Math.PI/2;
trainmodel.children[0].rotation.z = trainmodel.children[0].rotation.y;
trainmodel.children[0].rotation.y = 0;
let rotas = {
posr:point,
rota:trainmodel.children[0].rotation.z
}
trainmodel.children[1].rotalist.push(rotas);
let offsetz = parseFloat(point.z) - parseFloat(trainmodel.children[0].matrixWorld.elements[14]);
trainmodel.children[0].position.z += offsetz;
}
if(trainmodel.children[1].rotalist.length > 0 || trainmodel.children[2].rotalist.length > 0 || trainmodel.children[3].rotalist.length > 0 || trainmodel.children[4].rotalist.length > 0|| trainmodel.children[5].rotalist.length > 0){
for(let rs = 1;rs<6;rs++){
if(trainmodel.children[rs].rotalist[0]){
let offsetz = parseFloat(trainmodel.children[rs].rotalist[0].posr.z) - parseFloat(trainmodel.children[rs].matrixWorld.elements[14]);
trainmodel.children[rs].position.z += offsetz;
for(let xh=0;xh<trainmodel.children[rs].rotalist.length;xh++){
if((trainmodel.children[rs].matrixWorld.elements[12]+8)>=trainmodel.children[rs].rotalist[0].posr.x){
if(rs != 5){
let asd = trainmodel.children[rs].rotalist[0];
trainmodel.children[rs+1].rotalist.push(asd);
}
trainmodel.children[rs].rotation.z = trainmodel.children[rs].rotalist[0].rota;
trainmodel.children[rs].rotalist.splice(0,1)
xh--;
}else{
xh = trainmodel.children[rs].rotalist.length;
}
}
}
}
}
trainmodel.progress += trainmodel.speeds;
// if(trainmodel.statsstop == 0){
// if((1-trainmodel.progress) > 0.95){
//
// trainmodel.progress += trainmodel.speeds;
// }
//
// }else{
// trainmodel.progress += trainmodel.speeds;
// }
}
if(trainmodel.status == "0"){
let point = movecurve.getPointAt(trainmodel.progress);
let worldpositionz = trainmodel.children[0].position.z;
trainmodel.position.x = point.x;
trainmodel.position.y = 0;
if(Math.abs( point.z -trainmodel.children[0].matrixWorld.elements[14]) >0.02){
trainmodel.children[0].up = new THREE.Vector3(-1,0,0);
let tangent = movecurve.getTangentAt(traindata.group.children[j].progress).normalize();
trainmodel.children[0].axis.crossVectors(trainmodel.children[0].up, tangent).normalize();
let radians = Math.acos(trainmodel.children[0].up.dot(tangent));
trainmodel.children[0].quaternion.setFromAxisAngle(trainmodel.children[0].axis, radians);
trainmodel.children[0].rotation.x = -Math.PI/2;
trainmodel.children[0].rotation.z = trainmodel.children[0].rotation.y;
trainmodel.children[0].rotation.y = 0;
let rotas = {
posr:point,
rota:trainmodel.children[0].rotation.z
}
trainmodel.children[1].rotalist.push(rotas);
let offsetz = parseFloat(trainmodel.children[0].matrixWorld.elements[14]) - parseFloat(point.z);
trainmodel.children[0].position.z += offsetz;
}
if(trainmodel.children[1].rotalist.length > 0 || trainmodel.children[2].rotalist.length > 0 || trainmodel.children[3].rotalist.length > 0 || trainmodel.children[4].rotalist.length > 0|| trainmodel.children[5].rotalist.length > 0){
for(let rs = 1;rs<6;rs++){
if(trainmodel.children[rs].rotalist[0]){
let offsetz = parseFloat(trainmodel.children[rs].matrixWorld.elements[14]) - parseFloat(trainmodel.children[rs].rotalist[0].posr.z);
trainmodel.children[rs].position.z += offsetz;
for(let xh=0;xh<trainmodel.children[rs].rotalist.length;xh++){
if((trainmodel.children[rs].matrixWorld.elements[12]-8)<=trainmodel.children[rs].rotalist[0].posr.x){
if(rs != 5){
let asd = trainmodel.children[rs].rotalist[0];
trainmodel.children[rs+1].rotalist.push(asd);
}
trainmodel.children[rs].rotation.z = trainmodel.children[rs].rotalist[0].rota;
trainmodel.children[rs].rotalist.splice(0,1)
xh--;
}else{
xh = trainmodel.children[rs].rotalist.length;
}
}
}
}
}
trainmodel.progress += trainmodel.speeds;
// if(trainmodel.statsstop == 0){
// if(trainmodel.progress < 0.95){
// trainmodel.progress += trainmodel.speeds;
// }
// }else{
// trainmodel.progress += trainmodel.speeds;
// }
}
}else{
if(trainmodel.nextcurve){
trainmodel.progress = 0;
trainmodel.len = trainmodel.nextlen;
if(trainmodel.nextcode){
trainmodel.nowcode = trainmodel.nextcode;
trainmodel.isstandsection = trainmodel.nextissection;
if(trainmodel.isstandsection){
trainmodel.statsstop = 0;
}else{
trainmodel.statsstop = 1;
}
}
trainmodel.speeds = parseFloat(trainmodel.speed*10/36/25/trainmodel.len);
trainmodel.curve = trainmodel.nextcurve;
trainmodel.nextcurve = null;
trainmodel.nextlen = null;
trainmodel.nextcode = null;
}
}
}
}
}
}

View File

@ -1,4 +1,4 @@
//行车逻辑
export function UpdateTrain(camera,traindata){ export function UpdateTrain(camera,traindata){
if(traindata != undefined ){ if(traindata != undefined ){
for(let j=traindata.group.children.length-1;j>=0;j--){ for(let j=traindata.group.children.length-1;j>=0;j--){

View File

@ -6,7 +6,7 @@ import { AssetLoader } from '@/jlmap3d/main/loaders/AssetLoader';
import { FBXLoader } from '@/jlmap3d/main/loaders/FBXLoader'; import { FBXLoader } from '@/jlmap3d/main/loaders/FBXLoader';
import { JL3D_LOCAL_STATIC } from '@/api/jlmap3d/assets3d.js'; import { JL3D_LOCAL_STATIC } from '@/api/jlmap3d/assets3d.js';
//data //data
import { Jl3ddata } from '@/jlmap3d/main/model/jl3ddata'; import { Jl3ddata } from '@/jlmap3d/main/newmodel/jl3ddata';
//setconfig //setconfig
import { SetCamera } from '@/jlmap3d/config/SetCamera'; import { SetCamera } from '@/jlmap3d/config/SetCamera';
@ -19,11 +19,9 @@ import { OrbitControls } from '@/jlmap3d/main/control/OrbitControls';
// import { DragControls } from '@/jlmap3d/main/control/DragControls'; // import { DragControls } from '@/jlmap3d/main/control/DragControls';
//加载器 //加载器
import { SimulationLoad } from '@/jlmap3d/main/loaders/SimulationLoad';
import { SimulationLoadNew } from '@/jlmap3d/main/loaders/SimulationLoadNew'; import { SimulationLoadNew } from '@/jlmap3d/main/loaders/SimulationLoadNew';
//connect //connect
import {Jlmap3dSubscribe } from '@/jlmap3d/jl3dsimulation/connect/Jlmap3dSubscribe';
import {Jlmap3dSubscribeNew } from '@/jlmap3d/jl3dsimulation/connect/Jlmap3dSubscribeNew'; import {Jlmap3dSubscribeNew } from '@/jlmap3d/jl3dsimulation/connect/Jlmap3dSubscribeNew';
import { getPublishMapVersion, getPublishMapDetail,getPublish3dMapDetail} from '@/api/jlmap3d/load3ddata'; import { getPublishMapVersion, getPublishMapDetail,getPublish3dMapDetail} from '@/api/jlmap3d/load3ddata';
@ -31,7 +29,6 @@ import { getPublishMapVersion, getPublishMapDetail,getPublish3dMapDetail} from '
//utils //utils
// import { UpdateTrain } from '@/jlmap3d/main/utils/UpdateTrain'; // import { UpdateTrain } from '@/jlmap3d/main/utils/UpdateTrain';
import { UpdateTrain } from '@/jlmap3d/jl3dsimulation/connect/UpdateTrainTest'; import { UpdateTrain } from '@/jlmap3d/jl3dsimulation/connect/UpdateTrainTest';
import { UpdateTrainNew } from '@/jlmap3d/jl3dsimulation/connect/UpdateTrainNew';
// import { ReStart } from '@/jlmap3d/main/utils/ReStart'; // import { ReStart } from '@/jlmap3d/main/utils/ReStart';
import {Stats} from '@/jlmap3d/main/lib/stats.min.js'; import {Stats} from '@/jlmap3d/main/lib/stats.min.js';
@ -40,7 +37,6 @@ var clock = new THREE.Clock();
export function JLmap3d(dom, data,skinCode,storemod,routegroup,project) { export function JLmap3d(dom, data,skinCode,storemod,routegroup,project) {
let scope = this; let scope = this;
this.dom = dom; this.dom = dom;
@ -49,8 +45,10 @@ export function JLmap3d(dom, data,skinCode,storemod,routegroup,project) {
renderer.domElement.style.position = "absolute"; renderer.domElement.style.position = "absolute";
renderer.domElement.style.top = "0"; renderer.domElement.style.top = "0";
document.getElementById('testjlmap3d').appendChild(renderer.domElement); document.getElementById('testjlmap3d').appendChild(renderer.domElement);
//定义相机 //定义相机
let camera = SetCamera(dom); let camera = SetCamera(dom);
//定义场景(渲染容器) //定义场景(渲染容器)
let scene = SetScene(project); let scene = SetScene(project);
let scenesimulation = new THREE.Group(); let scenesimulation = new THREE.Group();
@ -82,6 +80,7 @@ export function JLmap3d(dom, data,skinCode,storemod,routegroup,project) {
//模型操作命令组 //模型操作命令组
this.actions = {}; this.actions = {};
//设备数据
let sectionlist = null; let sectionlist = null;
let linklist = null; let linklist = null;
let signallist = null; let signallist = null;
@ -90,82 +89,31 @@ export function JLmap3d(dom, data,skinCode,storemod,routegroup,project) {
let realsectionlist = null; let realsectionlist = null;
let rails = null; let rails = null;
//轨道相机
let camerarail = { let camerarail = {
curve:null, curve:null,
progress:0, progress:0,
moveswitch:false moveswitch:false
}; };
//地图模型数据 //地图模型数据
let mapdata = new Jl3ddata(); let mapdata = new Jl3ddata();
//订阅仿真socket
// console.log(routegroup);
// this.Subscribe = new Jlmap3dSubscribe(scope,routegroup,scope.jsonwebwork);
//连接到通信
//console.log(this.Subscribe.config);
//订阅仿真socket
this.webwork = new Worker(JL3D_LOCAL_STATIC+"/workertest/trainworker.js"); this.webwork = new Worker(JL3D_LOCAL_STATIC+"/workertest/trainworker.js");
//初始化加载数据和模型getPublishMapDetail //初始化加载数据和模型getPublishMapDetail
getPublishMapDetail(skinCode).then(data => { getPublishMapDetail(skinCode).then(data => {
let mapnetdata = data.data; let mapnetdata = data.data;
getPublish3dMapDetail(skinCode).then(netdata => { getPublish3dMapDetail(skinCode).then(netdata => {
let assetsdata = JSON.parse(netdata.data.sections); let assetsdata = JSON.parse(netdata.data.sections);
if(assetsdata.link){ scope.datatype = "new";
scope.datatype = "old"; scope.jsonwebworknew = new Worker(JL3D_LOCAL_STATIC+"/workertest/jsonworkernew.js");
scope.jsonwebwork = new Worker(JL3D_LOCAL_STATIC+"/workertest/jsonworker.js"); scope.Subscribe = new Jlmap3dSubscribeNew(scope,routegroup,scope.jsonwebworknew);
scope.Subscribe = new Jlmap3dSubscribe(scope,routegroup,scope.jsonwebwork); scope.Subscribe.socketon(scope.Subscribe.topic);
scope.Subscribe.socketon(scope.Subscribe.topic); SimulationLoadNew(mapnetdata,scope,netdata.data,mapdata,camera,controls,scenesimulation,storemod);
SimulationLoad(mapnetdata,scope,netdata.data,mapdata,camera,controls,scenesimulation,storemod);
}else{
scope.datatype = "new";
scope.jsonwebworknew = new Worker(JL3D_LOCAL_STATIC+"/workertest/jsonworkernew.js");
scope.Subscribe = new Jlmap3dSubscribeNew(scope,routegroup,scope.jsonwebworknew);
scope.Subscribe.socketon(scope.Subscribe.topic);
SimulationLoadNew(mapnetdata,scope,netdata.data,mapdata,camera,controls,scenesimulation,storemod);
}
}); });
}); });
//
// let stats = new Stats();
// dom.appendChild( stats.dom );
// var timer = setInterval(function() {
// if(trainlisttest){
// if(trainlisttest.group){
// if(trainlisttest.group.children[0]){
// for(let k in rails.switchrail){
// const ddd = storemod.getters['map/getDeviceByCode'](k);
// let switchdata = rails.switchrail[k];
// rails.switchrail[k].locateType = ddd.locateType;
//
// if(ddd.locateType == "01"){
// //1--向左 2--向右
// //__\__ __/__
// if(rails.switchrail[k].directtype == "1"){
// rails.linkrail[switchdata.alink].lconnect = switchdata.blink;
// rails.linkrail[switchdata.blink].rconnect = switchdata.alink;
// }else if(rails.switchrail[k].directtype == "2"){
// rails.linkrail[switchdata.alink].rconnect = switchdata.blink;
// rails.linkrail[switchdata.blink].lconnect = switchdata.alink;
// }
//
// }else if(ddd.locateType == "02"){
// if(rails.switchrail[k].directtype == "1"){
// rails.linkrail[switchdata.alink].lconnect = switchdata.clink;
// rails.linkrail[switchdata.clink].rconnect = switchdata.alink;
// }else if(rails.switchrail[k].directtype == "2"){
// rails.linkrail[switchdata.alink].rconnect = switchdata.clink;
// rails.linkrail[switchdata.clink].lconnect = switchdata.alink;
// }
// }
// }
// clearInterval(timer);
// }
// }
// }
//
// }, 2000);
//开启渲染 //开启渲染
animate(); animate();
startWorker(scope.webwork); startWorker(scope.webwork);
@ -174,18 +122,13 @@ export function JLmap3d(dom, data,skinCode,storemod,routegroup,project) {
//循环渲染函数 //循环渲染函数
function animate() { function animate() {
//循环渲染 //循环渲染
//requestAnimationFrame(animate);
//renderer.setAnimationLoop(animate);
requestAnimationFrame(animate); requestAnimationFrame(animate);
//判断渲染是否开启 //根据相机渲染场景
//根据相机渲染场景
renderer.render(scene,camera); renderer.render(scene,camera);
//检测动画构造器播放动画
// }
// stats.update(); // stats.update();
} }
//利用webworker当做定时器驱动设备动画更新列车状态车站漫游动画
function startWorker(webwork){ function startWorker(webwork){
if(typeof(Worker)!=="undefined"){ if(typeof(Worker)!=="undefined"){
@ -193,11 +136,19 @@ export function JLmap3d(dom, data,skinCode,storemod,routegroup,project) {
//更新列车位置 //更新列车位置
if(scope.datatype == "new"){ if(scope.datatype == "new"){
// UpdateTrainNew(camera,trainlisttest);
}else{ }else{
UpdateTrain(camera,trainlisttest); UpdateTrain(camera,trainlisttest);
} }
delta = clock.getDelta();
for(let i=scope.mixers.length-1;i>=0;i--){
if(scope.mixers[i]._actions[0].isRunning()){
// console.log(scope.mixers[i]._actions[0].isRunning());
scope.mixers[i].update( delta );
}
}
//开启车站漫游
if(camerarail.moveswitch == true){ if(camerarail.moveswitch == true){
// console.log(camerarail.progress); // console.log(camerarail.progress);
if(camerarail.progress>=0.99){ if(camerarail.progress>=0.99){
@ -218,18 +169,12 @@ export function JLmap3d(dom, data,skinCode,storemod,routegroup,project) {
} }
delta = clock.getDelta();
for(let i=scope.mixers.length-1;i>=0;i--){
if(scope.mixers[i]._actions[0].isRunning()){
// console.log(scope.mixers[i]._actions[0].isRunning());
scope.mixers[i].update( delta );
}
}
}; };
} }
} }
//释放场景缓存关闭渲染循环
this.dispose = function(){ this.dispose = function(){
renderer.setAnimationLoop(null); renderer.setAnimationLoop(null);
renderer.dispose(); renderer.dispose();
@ -259,6 +204,7 @@ export function JLmap3d(dom, data,skinCode,storemod,routegroup,project) {
} }
}; };
//切换显示车站信息
this.showstationmsg = function(showtype){ this.showstationmsg = function(showtype){
if(showtype == "show"){ if(showtype == "show"){
for(let st=0;st<stationstandlist.group.children.length;st++){ for(let st=0;st<stationstandlist.group.children.length;st++){
@ -271,6 +217,7 @@ export function JLmap3d(dom, data,skinCode,storemod,routegroup,project) {
} }
}; };
//切换显示列车信息
this.showtrainmsg = function(showtype){ this.showtrainmsg = function(showtype){
console.log(trainlisttest); console.log(trainlisttest);
if(showtype == "show"){ if(showtype == "show"){
@ -284,24 +231,23 @@ export function JLmap3d(dom, data,skinCode,storemod,routegroup,project) {
} }
}; };
// this.restart = function(){ //开启轨道镜头交互
// ReStart(mapdata);
// };
this.animateon = function(){ this.animateon = function(){
controls.enabled = true; controls.enabled = true;
}; };
//关闭轨道镜头交互
this.animateoff = function(){ this.animateoff = function(){
controls.enabled = false; controls.enabled = false;
}; };
//更新加载后数据
this.loaderdata = function(loadsectionlist,loadlinklist,loadsignallist,loadstationstandlist,loadtrainlisttest,loadrealsectionlist,loadrails){ this.loaderdata = function(loadsectionlist,loadlinklist,loadsignallist,loadstationstandlist,loadtrainlisttest,loadrealsectionlist,loadrails){
sectionlist = loadsectionlist; sectionlist = loadsectionlist;
linklist = loadlinklist; linklist = loadlinklist;
signallist = loadsignallist; signallist = loadsignallist;
stationstandlist = loadstationstandlist; stationstandlist = loadstationstandlist;
trainlisttest = loadtrainlisttest; trainlisttest = loadtrainlisttest;
realsectionlist = loadrealsectionlist; realsectionlist = loadrealsectionlist;
rails = loadrails; rails = loadrails;
@ -324,8 +270,8 @@ export function JLmap3d(dom, data,skinCode,storemod,routegroup,project) {
window.removeEventListener( 'resize', onWindowResize, false ); window.removeEventListener( 'resize', onWindowResize, false );
}; };
//根据菜单选项切换相机位置
this.updatecamera = function(mesh,type){ this.updatecamera = function(mesh,type){
//console.log(mesh);
if(type == "station"){ if(type == "station"){
camera.position.x = mesh.position.x; camera.position.x = mesh.position.x;
camera.position.y = mesh.position.y+800; camera.position.y = mesh.position.y+800;
@ -347,8 +293,8 @@ export function JLmap3d(dom, data,skinCode,storemod,routegroup,project) {
controls.update(); controls.update();
} }
//窗口自适应
function onWindowResize() { function onWindowResize() {
//窗口自适应
camera.aspect = window.innerWidth / window.innerHeight; camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix(); camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight ); renderer.setSize( window.innerWidth, window.innerHeight );
@ -357,7 +303,6 @@ export function JLmap3d(dom, data,skinCode,storemod,routegroup,project) {
//三维交互点击事件函数 //三维交互点击事件函数
function onselect(event) { function onselect(event) {
if(event.button == "0"){ if(event.button == "0"){
//定义光线 //定义光线
let raycaster = new THREE.Raycaster(); let raycaster = new THREE.Raycaster();
//定义平面鼠标点击坐标 //定义平面鼠标点击坐标

View File

@ -1,187 +0,0 @@
//componnent
import {SectionList} from '@/jlmap3d/main/model/SectionList.js';
import {SignalList} from '@/jlmap3d/main/model/SignalList.js';
import {StationStandList} from '@/jlmap3d/main/model/StationStandList.js';
import {TrainList} from '@/jlmap3d/main/model/TrainList.js';
import {RealSectionList} from '@/jlmap3d/main/model/RealSectionList.js';
import {LinkList} from '@/jlmap3d/main/model/LinkList.js';
import {RailList} from '@/jlmap3d/main/model/RailList.js';
import {Materialload} from '@/jlmap3d/main/loaders/Materialload.js';
import {SectionListN} from '@/jlmap3d/main/newmodel/SectionListN';
import {SignalListN} from '@/jlmap3d/main/newmodel/SignalListN';
import {StationStandListN} from '@/jlmap3d/main/newmodel/StationStandListN';
import {SwitchListN} from '@/jlmap3d/main/newmodel/SwitchListN';
import {RailListN} from '@/jlmap3d/main/newmodel/RailListN.js';
import { Loading } from 'element-ui';
// import {SwitchModel} from '@/jlmap3d/model/SwitchModel.js';
export function DriverLoad(data,scope,netdata,sectionlist,linklist,signallist,stationstandlist,trainlisttest,realsectionlist,rails,camera,controls,scene,mixerss,storemod){
//console.log(mapdata);
Materialload(scope);
//console.log(data);
//console.log(scope);
let sceneload = scene;
let backdata = scope;
let assetloader = scope.assetloader;
let animateswitch = scope.animateswitch;
let mixers = mixerss;
let actions = scope.actions;
let loadingInstance = Loading.service({ fullscreen: true });
let switchlist;
let isSection = false;
let isNewdata = false;
if(netdata.assets){
let assetsdata = JSON.parse(netdata.sections);
// console.log(assetsdata.link);
if(assetsdata.link){
isSection = true;
}else{
isNewdata = true;
}
}
// console.log(isNewdata);
// console.log(netdata);
if(isSection == true){
init3d(data,netdata);
}else{
loadingInstance.close();
alert("没有三维数据");
}
function init3d(data,netdata){
let mapdata = data.data;
// console.log(data);
//初始化轨道和道岔 暂时
lengthfact(data.data);
linklist = new LinkList();
sectionlist = new SectionList();
signallist = new SignalList();
//初始化站台
stationstandlist = new StationStandList();
//初始化测试列车
trainlisttest = new TrainList();
realsectionlist = new RealSectionList();
rails = new RailList();
let loaderdata = JSON.parse(netdata.sections);
let switchdata = JSON.parse(netdata.switchs);
let signaldata = JSON.parse(netdata.signals);
let standsdata = JSON.parse(netdata.stands);
assetloader.setmodellist(netdata.assets);
assetloader.assetpromise(sceneload)
.then(function(data){
return linklist.loadpromise(loaderdata.link,sceneload,assetloader);
})
.then(function(data){
//console.log(data);
return stationstandlist.initpromise(mapdata.stationList,mapdata.stationStandList,sceneload,assetloader,netdata.stands,mixers,actions,"0");
})
.then(function(data){
//console.log(data);
//console.log(assetloader);
return trainlisttest.initpromise(mapdata.trainList,sceneload,assetloader,mixers,actions,"0");
})
.then(function(data){
//console.log(data);
return sectionlist.loadpromise(linklist,assetloader,loaderdata.section,switchdata,sceneload);
})
// .then(function(data){
// //console.log(data);
// return jlmap3ddata.realsectionlist.initpromise(jlmap3ddata,sceneload,assetloader,mixers,actions);
// })
.then(function(data){
//console.log(data);
return signallist.initpromise(mapdata.signalList,sceneload,assetloader,netdata.signals);
})
.then(function(data){
return new Promise(function(resolve, reject){
let stopoffset = 64;
rails.init(loaderdata.link,mapdata.linkList,mapdata.sectionList,switchdata,
stationstandlist.list,sceneload,storemod,stopoffset);
resolve("loadrail");
});
})
.then(function(data){
for(let mn=0;mn<scope.assetloader.modellist.length;mn++){
if(scope.assetloader.modellist[mn].name && scope.assetloader.modellist[mn].name == "suidao"){
// scope.assetloader.modellist[mn].mesh.rotation.x = Math.PI/2;
// scope.assetloader.modellist[mn].mesh.position.y -=0.1;
// console.log(scope.assetloader.modellist[mn].mesh);
scene.add(scope.assetloader.modellist[mn].mesh);
}
}
scope.animateswitch = true;
// mapdata = jlmap3ddata;
backdata.loaderdata(sectionlist,linklist,signallist,stationstandlist,trainlisttest,realsectionlist,rails);
scope.Subscribe.updatamap(sectionlist,linklist,signallist,stationstandlist,trainlisttest,realsectionlist,rails,scope.materiallist,scope.actions,scope.sceneload);
scope.webwork.postMessage("on");
loadingInstance.close();
});
}
function onProgress( xhr ) {
if ( xhr.lengthComputable ) {
let percentComplete = xhr.loaded / xhr.total * 100;
//console.log( 'model ' + Math.round( percentComplete, 2 ) + '% downloaded' );
}
}
function onError() {}
}
function lengthfact(data){
let linklist = [];
for(let i=0;i<data.linkList.length;i++){
let dx = Math.abs(data.linkList[i].lp.x - data.linkList[i].rp.x);
    let dy = Math.abs(data.linkList[i].lp.y - data.linkList[i].rp.y);
    let distance = Math.sqrt(Math.pow(dx,2)+Math.pow(dy,2));
let link = {
code:data.linkList[i].code,
lengthfact:data.linkList[i].lengthFact,
distance:distance
};
linklist.push(link);
}
let sectionlist = [];
for(let i=0;i<data.sectionList.length;i++){
for(let j=0;j<linklist.length;j++){
if(linklist[j].code == data.sectionList[i].linkCode){
let sectionoffset = data.sectionList[i].offsetRight - data.sectionList[i].offsetLeft;
let sectionlengthfact = sectionoffset/linklist[j].distance*linklist[j].lengthfact
let section = {
code:data.sectionList[i].code,
lengthfact:sectionoffset
};
sectionlist.push(section);
j = linklist.length;
}
}
}
//console.log(sectionlist);
}

View File

@ -52,7 +52,6 @@ export function DriverLoadNew(data,scope,netdata,mapdata,sectionlist,signallist,
Materialload(scope,JSON.parse(netdata.assets).stationTextureList[0]); Materialload(scope,JSON.parse(netdata.assets).stationTextureList[0]);
let mapdata = data; let mapdata = data;
//初始化轨道和道岔 //初始化轨道和道岔
// linklist = new LinkList();
sectionlist = new SectionListN(); sectionlist = new SectionListN();
signallist = new SignalListN(); signallist = new SignalListN();
switchlist = new SwitchListN(); switchlist = new SwitchListN();
@ -154,37 +153,3 @@ export function DriverLoadNew(data,scope,netdata,mapdata,sectionlist,signallist,
} }
//旧link相关停操作待删除
function lengthfact(data){
let linklist = [];
for(let i=0;i<data.linkList.length;i++){
let dx = Math.abs(data.linkList[i].lp.x - data.linkList[i].rp.x);
    let dy = Math.abs(data.linkList[i].lp.y - data.linkList[i].rp.y);
    let distance = Math.sqrt(Math.pow(dx,2)+Math.pow(dy,2));
let link = {
code:data.linkList[i].code,
lengthfact:data.linkList[i].lengthFact,
distance:distance
};
linklist.push(link);
}
let sectionlist = [];
for(let i=0;i<data.sectionList.length;i++){
for(let j=0;j<linklist.length;j++){
if(linklist[j].code == data.sectionList[i].linkCode){
let sectionoffset = data.sectionList[i].offsetRight - data.sectionList[i].offsetLeft;
let sectionlengthfact = sectionoffset/linklist[j].distance*linklist[j].lengthfact
let section = {
code:data.sectionList[i].code,
lengthfact:sectionoffset
};
sectionlist.push(section);
j = linklist.length;
}
}
}
}

View File

@ -17,107 +17,7 @@ export function Materialload(jlmap3dedit,standTextureData){
setstationtexture(jlmap3dedit.stationtexture,standTextureData.urls[i].name,BASE_ASSET_API + standTextureData.urls[i].url); setstationtexture(jlmap3dedit.stationtexture,standTextureData.urls[i].name,BASE_ASSET_API + standTextureData.urls[i].url);
} }
} }
//
// if(assettype){
// if(assettype.stationtexture == "xian3"){
// if(jlmap3dedit.stationtexture){
// setstationtexture(jlmap3dedit.stationtexture,"stationlist",JL3D_LOCAL_STATIC+'/texture/xian3/xian3list.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"pingbimen",JL3D_LOCAL_STATIC+'/texture/xian3/pingbimen.png');
// setstationtexture(jlmap3dedit.stationtexture,"Station18000",JL3D_LOCAL_STATIC+'/texture/xian3/Station18000.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station61238",JL3D_LOCAL_STATIC+'/texture/xian3/Station61238.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station41790",JL3D_LOCAL_STATIC+'/texture/xian3/Station41790.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station67945",JL3D_LOCAL_STATIC+'/texture/xian3/Station67945.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station85598",JL3D_LOCAL_STATIC+'/texture/xian3/Station85598.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station4324",JL3D_LOCAL_STATIC+'/texture/xian3/Station4324.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station55755",JL3D_LOCAL_STATIC+'/texture/xian3/Station55755.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station53597",JL3D_LOCAL_STATIC+'/texture/xian3/Station53597.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station68029",JL3D_LOCAL_STATIC+'/texture/xian3/Station68029.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station17596",JL3D_LOCAL_STATIC+'/texture/xian3/Station17596.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station66742",JL3D_LOCAL_STATIC+'/texture/xian3/Station66742.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station90701",JL3D_LOCAL_STATIC+'/texture/xian3/Station90701.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station90652",JL3D_LOCAL_STATIC+'/texture/xian3/Station90652.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station54200",JL3D_LOCAL_STATIC+'/texture/xian3/Station54200.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station19253",JL3D_LOCAL_STATIC+'/texture/xian3/Station19253.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station37821",JL3D_LOCAL_STATIC+'/texture/xian3/Station37821.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station47557",JL3D_LOCAL_STATIC+'/texture/xian3/Station47557.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station78551",JL3D_LOCAL_STATIC+'/texture/xian3/Station78551.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station64474",JL3D_LOCAL_STATIC+'/texture/xian3/Station64474.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station21203",JL3D_LOCAL_STATIC+'/texture/xian3/Station21203.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station34499",JL3D_LOCAL_STATIC+'/texture/xian3/Station34499.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station571",JL3D_LOCAL_STATIC+'/texture/xian3/Station571.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station99903",JL3D_LOCAL_STATIC+'/texture/xian3/Station99903.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station43447",JL3D_LOCAL_STATIC+'/texture/xian3/Station43447.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station67917",JL3D_LOCAL_STATIC+'/texture/xian3/Station67917.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station60649",JL3D_LOCAL_STATIC+'/texture/xian3/Station60649.jpg');
// }
// }
// if(assettype.stationtexture == "haerbin1"){
// if(jlmap3dedit.stationtexture){
// setstationtexture(jlmap3dedit.stationtexture,"stationlist",JL3D_LOCAL_STATIC+'/texture/heb/haerbinlist.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"pingbimen",JL3D_LOCAL_STATIC+'/texture/heb/pingbimen.png');
// setstationtexture(jlmap3dedit.stationtexture,"Station5361",JL3D_LOCAL_STATIC+'/texture/heb/Station5361.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station11094",JL3D_LOCAL_STATIC+'/texture/heb/Station11094.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station11136",JL3D_LOCAL_STATIC+'/texture/heb/Station11136.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station17293",JL3D_LOCAL_STATIC+'/texture/heb/Station17293.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station18398",JL3D_LOCAL_STATIC+'/texture/heb/Station18398.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station22163",JL3D_LOCAL_STATIC+'/texture/heb/Station22163.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station25464",JL3D_LOCAL_STATIC+'/texture/heb/Station25464.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station28090",JL3D_LOCAL_STATIC+'/texture/heb/Station28090.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station41999",JL3D_LOCAL_STATIC+'/texture/heb/Station41999.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station44338",JL3D_LOCAL_STATIC+'/texture/heb/Station44338.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station46464",JL3D_LOCAL_STATIC+'/texture/heb/Station46464.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station50565",JL3D_LOCAL_STATIC+'/texture/heb/Station50565.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station60068",JL3D_LOCAL_STATIC+'/texture/heb/Station60068.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station62429",JL3D_LOCAL_STATIC+'/texture/heb/Station62429.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station64444",JL3D_LOCAL_STATIC+'/texture/heb/Station64444.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station71700",JL3D_LOCAL_STATIC+'/texture/heb/Station71700.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station72132",JL3D_LOCAL_STATIC+'/texture/heb/Station72132.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station78164",JL3D_LOCAL_STATIC+'/texture/heb/Station78164.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station79537",JL3D_LOCAL_STATIC+'/texture/heb/Station79537.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station82618",JL3D_LOCAL_STATIC+'/texture/heb/Station82618.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station85520",JL3D_LOCAL_STATIC+'/texture/heb/Station85520.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station89483",JL3D_LOCAL_STATIC+'/texture/heb/Station89483.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station96090",JL3D_LOCAL_STATIC+'/texture/heb/Station96090.jpg');
// }
// }
// if(assettype.stationtexture == "nb1"){
// if(jlmap3dedit.stationtexture){
// setstationtexture(jlmap3dedit.stationtexture,"stationlist",JL3D_LOCAL_STATIC+'/texture/nb1/nb1list.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"pingbimen",JL3D_LOCAL_STATIC+'/texture/nb1/pingbimen.png');
// setstationtexture(jlmap3dedit.stationtexture,"Station1533",JL3D_LOCAL_STATIC+'/texture/nb1/Station1533.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station11231",JL3D_LOCAL_STATIC+'/texture/nb1/Station11231.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station12421",JL3D_LOCAL_STATIC+'/texture/nb1/Station12421.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station16356",JL3D_LOCAL_STATIC+'/texture/nb1/Station16356.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station18678",JL3D_LOCAL_STATIC+'/texture/nb1/Station18678.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station19817",JL3D_LOCAL_STATIC+'/texture/nb1/Station19817.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station23567",JL3D_LOCAL_STATIC+'/texture/nb1/Station23567.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station24903",JL3D_LOCAL_STATIC+'/texture/nb1/Station24903.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station26416",JL3D_LOCAL_STATIC+'/texture/nb1/Station26416.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station27207",JL3D_LOCAL_STATIC+'/texture/nb1/Station27207.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station28032",JL3D_LOCAL_STATIC+'/texture/nb1/Station28032.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station28958",JL3D_LOCAL_STATIC+'/texture/nb1/Station28958.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station30520",JL3D_LOCAL_STATIC+'/texture/nb1/Station30520.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station32955",JL3D_LOCAL_STATIC+'/texture/nb1/Station32955.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station38286",JL3D_LOCAL_STATIC+'/texture/nb1/Station38286.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station38674",JL3D_LOCAL_STATIC+'/texture/nb1/Station38674.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station44173",JL3D_LOCAL_STATIC+'/texture/nb1/Station44173.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station63100",JL3D_LOCAL_STATIC+'/texture/nb1/Station63100.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station69378",JL3D_LOCAL_STATIC+'/texture/nb1/Station69378.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station72310",JL3D_LOCAL_STATIC+'/texture/nb1/Station72310.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station72764",JL3D_LOCAL_STATIC+'/texture/nb1/Station72764.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station75414",JL3D_LOCAL_STATIC+'/texture/nb1/Station75414.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station75494",JL3D_LOCAL_STATIC+'/texture/nb1/Station75494.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station75703",JL3D_LOCAL_STATIC+'/texture/nb1/Station75703.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station78392",JL3D_LOCAL_STATIC+'/texture/nb1/Station78392.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station81700",JL3D_LOCAL_STATIC+'/texture/nb1/Station81700.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station84098",JL3D_LOCAL_STATIC+'/texture/nb1/Station84098.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station86112",JL3D_LOCAL_STATIC+'/texture/nb1/Station86112.jpg');
// setstationtexture(jlmap3dedit.stationtexture,"Station99584",JL3D_LOCAL_STATIC+'/texture/nb1/Station99584.jpg');
// }
// }
// }
//console.log(jlmap3dedit.materiallist);
} }
function settexture(materiallist,name,textureurl){ function settexture(materiallist,name,textureurl){

View File

@ -1,211 +0,0 @@
//componnent
import {SectionList} from '@/jlmap3d/main/model/SectionList.js';
import {SignalList} from '@/jlmap3d/main/model/SignalList.js';
import {StationStandList} from '@/jlmap3d/main/model/StationStandList.js';
import {TrainList} from '@/jlmap3d/main/model/TrainList.js';
import {RealSectionList} from '@/jlmap3d/main/model/RealSectionList.js';
import {LinkList} from '@/jlmap3d/main/model/LinkList.js';
import {RailList} from '@/jlmap3d/main/model/RailList.js';
import {SectionListN} from '@/jlmap3d/main/newmodel/SectionListN';
import {SignalListN} from '@/jlmap3d/main/newmodel/SignalListN';
import {StationStandListN} from '@/jlmap3d/main/newmodel/StationStandListN';
import {SwitchListN} from '@/jlmap3d/main/newmodel/SwitchListN';
import {RailListN} from '@/jlmap3d/main/newmodel/RailListN.js';
import {Materialload} from '@/jlmap3d/main/loaders/Materialload.js';
import { Loading } from 'element-ui';
// import {SwitchModel} from '@/jlmap3d/model/SwitchModel.js';
export function SimulationLoad(data,scope,netdata,mapdata,camera,controls,scene,storemod){
//console.log(mapdata);
Materialload(scope);
//console.log(data);
//console.log(scope);
let sceneload = scene;
let backdata = scope;
let jlmap3ddata = mapdata;
let assetloader = scope.assetloader;
let animateswitch = scope.animateswitch;
let mixers = scope.mixers;
let actions = scope.actions;
let linklist,sectionlist,signallist,stationstandlist,trainlisttest,switchlist,realsectionlist,rails;
let loadingInstance = Loading.service({ fullscreen: true });
let isSection = false;
let isNewdata = false;
if(netdata.assets){
init3d(data,netdata);
}else{
loadingInstance.close();
alert("没有三维数据");
}
function init3d(data,netdata){
let mapdata = data;
// console.log(data);
//初始化轨道和道岔 暂时
lengthfact(data);
linklist = new LinkList();
sectionlist = new SectionList();
//初始化信号机
signallist = new SignalList();
//初始化站台
stationstandlist = new StationStandList();
//初始化测试列车
trainlisttest = new TrainList();
realsectionlist = new RealSectionList();
rails = new RailList();
let loaderdata = JSON.parse(netdata.sections);
let switchdata = JSON.parse(netdata.switchs);
let signaldata = JSON.parse(netdata.signals);
let standsdata = JSON.parse(netdata.stands);
// console.log(netdata.assets);
assetloader.setmodellist(netdata.assets,1);
assetloader.assetpromise(sceneload)
.then(function(data){
//console.log(data);
return linklist.loadpromise(loaderdata.link,scene,assetloader);
})
.then(function(data){
//console.log(data);
return stationstandlist.initpromise(mapdata.stationList,mapdata.stationStandList,sceneload,assetloader,netdata.stands,mixers,actions,"02");
})
.then(function(data){
//console.log(data);
//console.log(assetloader);
return trainlisttest.initpromise(mapdata.trainList,sceneload,assetloader,mixers,actions,"02");
})
.then(function(data){
//console.log(data);
return sectionlist.loadpromise(linklist,assetloader,loaderdata.section,switchdata,sceneload);
})
// // .then(function(data){
// // //console.log(data);
// // return realsectionlist.initpromise(jlmap3ddata,sceneload,assetloader,mixers,actions);
// // })
.then(function(data){
//console.log(data);
return signallist.initpromise(mapdata.signalList,sceneload,assetloader,netdata.signals);
})
.then(function(data){
return new Promise(function(resolve, reject){
let stopoffset = 61.92;
rails.init(loaderdata.link,mapdata.linkList,mapdata.sectionList,switchdata, stationstandlist.list,sceneload,storemod,stopoffset);
resolve("loadrail");
});
})
.then(function(data){
return new Promise(function(resolve, reject){
let mergegeometry
let mergeindex = 0;
let materialarr = [];
for(let mn=0;mn<scope.assetloader.modellist.length;mn++){
if(scope.assetloader.modellist[mn].name && scope.assetloader.modellist[mn].name == "suidao"){
// scope.assetloader.modellist[mn].mesh.rotation.x = Math.PI/2;
// console.log(scope.assetloader.modellist[mn].mesh.position);
scope.assetloader.modellist[mn].mesh.name = "suidao";
// console.log(scope.assetloader.modellist[mn].mesh);
scene.add(scope.assetloader.modellist[mn].mesh);
}
if(scope.assetloader.modellist[mn].name && scope.assetloader.modellist[mn].name == "background"){
// scope.assetloader.modellist[mn].mesh.rotation.x = Math.PI/2;
// console.log(scope.assetloader.modellist[mn].mesh.position);
scope.assetloader.modellist[mn].mesh.name = "background";
// console.log(scope.assetloader.modellist[mn].mesh);
scene.add(scope.assetloader.modellist[mn].mesh);
}
}
let mergemesh = new THREE.Mesh( mergegeometry, materialarr );
scene.add(mergemesh);
resolve("mergemodel");
});
})
.then(function(data){
// scope.animateswitch = true;
//console.log(scope);
//更新相机方向
backdata.loaderdata(sectionlist,linklist,signallist,stationstandlist,trainlisttest,realsectionlist,rails);
scope.updatecamera(stationstandlist.group.children[0],"station");
//
scope.Subscribe.updatamap(sectionlist,linklist,signallist,stationstandlist,trainlisttest,realsectionlist,rails,scope.materiallist,scope.actions,scope.sceneload);
//
updatemenulist(stationstandlist.list,trainlisttest.list);
scope.webwork.postMessage("on");
scope.jsonwebwork.postMessage("connect");
// console.log(sceneload);
loadingInstance.close();
});
}
function onProgress( xhr ) {
if ( xhr.lengthComputable ) {
let percentComplete = xhr.loaded / xhr.total * 100;
//console.log( 'model ' + Math.round( percentComplete, 2 ) + '% downloaded' );
}
}
function onError() {}
}
function lengthfact(data){
let linklist = [];
//console.log(data);
for(let i=0;i<data.linkList.length;i++){
let dx = Math.abs(data.linkList[i].lp.x - data.linkList[i].rp.x);
    let dy = Math.abs(data.linkList[i].lp.y - data.linkList[i].rp.y);
    let distance = Math.sqrt(Math.pow(dx,2)+Math.pow(dy,2));
let link = {
code:data.linkList[i].code,
lengthfact:data.linkList[i].lengthFact,
distance:distance
};
linklist.push(link);
}
let sectionlist = [];
for(let i=0;i<data.sectionList.length;i++){
for(let j=0;j<linklist.length;j++){
if(linklist[j].code == data.sectionList[i].linkCode){
let sectionoffset = data.sectionList[i].offsetRight - data.sectionList[i].offsetLeft;
let sectionlengthfact = sectionoffset/linklist[j].distance*linklist[j].lengthfact
let section = {
code:data.sectionList[i].code,
lengthfact:sectionoffset
};
sectionlist.push(section);
j = linklist.length;
}
}
}
//console.log(sectionlist);
}

View File

@ -1,11 +1,4 @@
//componnent //componnent
import {SectionList} from '@/jlmap3d/main/model/SectionList.js';
import {SignalList} from '@/jlmap3d/main/model/SignalList.js';
import {StationStandList} from '@/jlmap3d/main/model/StationStandList.js';
import {TrainList} from '@/jlmap3d/main/model/TrainList.js';
import {RealSectionList} from '@/jlmap3d/main/model/RealSectionList.js';
import {LinkList} from '@/jlmap3d/main/model/LinkList.js';
import {RailList} from '@/jlmap3d/main/model/RailList.js';
import {TrainListN} from '@/jlmap3d/main/newmodel/TrainListN.js'; import {TrainListN} from '@/jlmap3d/main/newmodel/TrainListN.js';
import {SectionListN} from '@/jlmap3d/main/newmodel/SectionListN'; import {SectionListN} from '@/jlmap3d/main/newmodel/SectionListN';
@ -55,7 +48,6 @@ export function SimulationLoadNew(data,scope,netdata,mapdata,camera,controls,sce
//初始化轨道和道岔 //初始化轨道和道岔
// lengthfact(data); // lengthfact(data);
// linklist = new LinkList();
sectionlist = new SectionListN(); sectionlist = new SectionListN();
signallist = new SignalListN(); signallist = new SignalListN();
switchlist = new SwitchListN(); switchlist = new SwitchListN();
@ -63,7 +55,6 @@ export function SimulationLoadNew(data,scope,netdata,mapdata,camera,controls,sce
stationstandlist = new StationStandListN(); stationstandlist = new StationStandListN();
//初始化测试列车 //初始化测试列车
trainlisttest = new TrainListN(); trainlisttest = new TrainListN();
// realsectionlist = new RealSectionList();
rails = new RailListN(); rails = new RailListN();
@ -177,7 +168,7 @@ export function SimulationLoadNew(data,scope,netdata,mapdata,camera,controls,sce
scope.jsonwebworknew.postMessage("connect"); scope.jsonwebworknew.postMessage("connect");
updatemenulist(stationstandlist.list,trainlisttest.list); updatemenulist(stationstandlist.list,trainlisttest.list);
// loadingInstance.close(); // loadingInstance.close();
store.dispatch('app/animationsClose'); store.dispatch('app/animationsClose');
}); });
} }

View File

@ -1,327 +0,0 @@
export function LinkList(data){
let scope = this;
this.type = "linklist";
this.linkdata = [];
this.linksgroup = new THREE.Group();
this.linksgroup.name = "link";
this.initpromise = function(linkdata,scene,assetloader){
// console.log("init");
return new Promise(function(resolve, reject){
linkhelp(linkdata,scene);
scene.add(scope.linksgroup);
linktest(linkdata,scene,assetloader);
resolve("loadedrealsection");
});
};
this.loadpromise = function(linkdata,scene,assetloader){
// console.log(linkdata);
console.log("load");
return new Promise(function(resolve, reject){
scene.add(scope.linksgroup);
loadlink(linkdata,scene,assetloader);
resolve("loadedrealsection");
});
};
function linkhelp(data,scene){
let groups = new THREE.Group();
for(let i=0;i<data.length;i++){
let lineGeometry = new THREE.Geometry();//生成几何体
lineGeometry.vertices.push(new THREE.Vector3(data[i].lp.x, 1, data[i].lp.y));//线段的两个顶点
lineGeometry.vertices.push(new THREE.Vector3(data[i].rp.x, 1, data[i].rp.y));
let line = new THREE.Line(lineGeometry, new THREE.LineDashedMaterial({
color: 0xffffff,//线段的颜色
dashSize: 1,//短划线的大小
gapSize: 3//短划线之间的距离
}));
line.name = data[i].code;
line.lengthFact = data[i].lengthFact;
line.lp = data[i].lp;
line.rp = data[i].rp;
line.distancex = data[i].rp.x-data[i].lp.x;
line.distancey = data[i].rp.y-data[i].lp.y;
line.computeLineDistances();//不可或缺的,若无,则线段不能显示为虚线
groups.add(line);
}
groups.position.z = 2000;
scene.add(groups);
}
let mergegeometry = new THREE.Geometry();
function loadlink(data,scene,assetloader){
let autorail;
for(let i=0;i<assetloader.modellist.length;i++){
if(assetloader.modellist[i].deviceType == "autorail"){
autorail = assetloader.modellist[i].mesh.children[0];
}
}
let count = autorail.geometry.attributes.position.count;
let rightlist = [];
let leftlist = [];
for(let i=0;i<count;i++){
if(autorail.geometry.attributes.position.array[i*3] >0.49){
rightlist.push(i);
}
if(autorail.geometry.attributes.position.array[i*3] <-0.49){
leftlist.push(i);
}
}
for(let i=0;i<data.length;i++){
// console.log("link");
// console.log(data[i]);
let testmesh2 = autorail.clone(true);
testmesh2.code = data[i].code;
testmesh2.name = data[i].name;
testmesh2.rightlist = rightlist;
testmesh2.leftlist = leftlist;
testmesh2.rp = data[i].rp;
testmesh2.lp = data[i].lp;
testmesh2.lengthfact = data[i].lengthfact;
for(let i=0;i<testmesh2.rightlist.length;i++){
testmesh2.geometry.attributes.position.array[testmesh2.rightlist[i]*3] = testmesh2.lengthfact-25;
testmesh2.geometry.attributes.uv.array[testmesh2.rightlist[i]*2] = testmesh2.geometry.attributes.position.array[0]-testmesh2.geometry.attributes.position.array[3];
}
let newrail = new THREE.BufferGeometry();
newrail.copy(testmesh2.geometry);
testmesh2.geometry = newrail;
testmesh2.geometry.attributes.position.needsUpdate = true;
testmesh2.geometry.attributes.uv.needsUpdate = true;
testmesh2.geometry.computeBoundingSphere();
testmesh2.geometry.center();
testmesh2.position.x = data[i].position.x;
testmesh2.position.y = data[i].position.y;
testmesh2.position.z = data[i].position.z;
// testmesh2.rotation.x = data[i].rotation._x;
// testmesh2.rotation.y = data[i].rotation._y;
testmesh2.rotation.z = data[i].rotation._z;
testmesh2.updateMatrix();
mergegeometry.merge(new THREE.Geometry().fromBufferGeometry(testmesh2.geometry),testmesh2.matrix);
// console.log(testmesh2);
testmesh2.geometry.dispose();
for(let j in testmesh2.material){
testmesh2.material[j].map.dispose();
testmesh2.material[j].dispose();
}
// scope.linkdata.push(testmesh2);
// scope.linksgroup.add(testmesh2);
}
let mergemesh = new THREE.Mesh( mergegeometry, autorail.material );
scope.linksgroup.add( mergemesh );
}
// return linklist;
function linktest(data,scene,assetloader){
let autorail = null;
let autosuidao = null;
for(let i=0;i<assetloader.modellist.length;i++){
if(assetloader.modellist[i].deviceType == "autorail"){
autorail = assetloader.modellist[i].mesh.children[0];
}
}
let rightlist = [];
let leftlist = [];
let count = autorail.geometry.attributes.position.count;
for(let i=0;i<count;i++){
if(autorail.geometry.attributes.position.array[i*3] >0.49){
rightlist.push(i);
}
if(autorail.geometry.attributes.position.array[i*3] <-0.49){
leftlist.push(i);
}
}
autorail.rightlist = rightlist;
autorail.leftlist = leftlist;
let reallinks = [];
let testlink;
testlink = data;
if(data){
let index,startdata;
for(let n=0;n<data.length;n++){
if(data[n].leftFdCode == undefined && data[n].leftSdCode == undefined && data[n].rightFdCode ){
if(startdata){
if(data[n].lp.x<startdata.lp.x){
startdata = data[n];
index = n;
}
}else{
startdata = data[n];
index = n;
}
}
}
buildmodel(startdata);
reallinks.push(startdata);
data.splice(index,1);
for(let i=0;i<reallinks.length;i++){
for(let j=0;j<data.length;j++){
if(reallinks[i].leftFdCode && j>=0){
if(reallinks[i].leftFdCode == data[j].code){
buildmodel(data[j],reallinks[i],j,"left");
reallinks.push(data[j]);
data.splice(j,1);
j--;
}
}
if(reallinks[i].leftSdCode && j>=0){
if(reallinks[i].leftSdCode == data[j].code){
buildmodel(data[j],reallinks[i],j,"left");
reallinks.push(data[j]);
data.splice(j,1);
j--;
}
}
if(reallinks[i].rightFdCode && j>=0){
if(reallinks[i].rightFdCode == data[j].code){
buildmodel(data[j],reallinks[i],j,"right");
reallinks.push(data[j]);
data.splice(j,1);
j--;
}
}
if(reallinks[i].rightSdCode && j>=0){
if(reallinks[i].rightSdCode == data[j].code){
buildmodel(data[j],reallinks[i],j,"right");
reallinks.push(data[j]);
data.splice(j,1);
j--;
}
}
}
}
function buildmodel(data,mdata,sx,direct){
let len = data.lengthFact;
let testmesh2 = autorail.clone(true);
for(let i=0;i<autorail.rightlist.length;i++){
testmesh2.geometry.attributes.position.array[autorail.rightlist[i]*3] = len-25;
testmesh2.geometry.attributes.uv.array[autorail.rightlist[i]*2] = testmesh2.geometry.attributes.position.array[0]-testmesh2.geometry.attributes.position.array[3];
}
let newrail = new THREE.BufferGeometry();
newrail.copy(testmesh2.geometry);
testmesh2.geometry = newrail;
testmesh2.geometry.attributes.position.needsUpdate = true;
testmesh2.geometry.attributes.uv.needsUpdate = true;
testmesh2.geometry.computeBoundingSphere();
testmesh2.geometry.center();
// data.lp.y *= 10;
// data.rp.y *= 10;
if(mdata){
if(direct == "left"){
let dx = Math.abs(data.lp.x - data.rp.x);
    let dy = Math.abs(data.lp.y - data.rp.y);
    let distance = Math.sqrt(Math.pow(dx,2)+Math.pow(dy,2));
data.lp.x = (data.lp.x-data.rp.x)*data.lengthFact/distance+mdata.lp.x;
data.lp.y = (data.lp.y-data.rp.y)*data.lengthFact/distance+mdata.lp.y;
data.rp.x = mdata.lp.x;
data.rp.y = mdata.lp.y;
let axix = new THREE.Vector3(1,0,0);
let axixnow = new THREE.Vector3(data.rp.x-data.lp.x,0,data.rp.y-data.lp.y);
let rotenum = axixnow.angleTo(axix);
//不同坐标系方向值不同
if(data.lp.y>data.rp.y){
testmesh2.rotation.z = 0.218;
data.lp.x = data.rp.x - (data.lengthFact)*Math.cos(testmesh2.rotation.z);
data.lp.y = data.rp.y + (data.lengthFact)*Math.sin(testmesh2.rotation.z);
}else if(data.lp.y<data.rp.y){
testmesh2.rotation.z = -0.218;
data.lp.x = data.rp.x - (data.lengthFact)*Math.cos(testmesh2.rotation.z);
data.lp.y = data.rp.y + (data.lengthFact)*Math.sin(testmesh2.rotation.z);
}else{
testmesh2.rotation.z = rotenum;
}
testmesh2.position.x = (data.rp.x + data.lp.x)/2;
testmesh2.position.z = (data.rp.y + data.lp.y)/2;
}
if(direct == "right"){
let dx = Math.abs(data.lp.x - data.rp.x);
    let dy = Math.abs(data.lp.y - data.rp.y);
    let distance = Math.sqrt(Math.pow(dx,2)+Math.pow(dy,2));
data.rp.x = (data.rp.x-data.lp.x)*data.lengthFact/distance+mdata.rp.x;
data.rp.y = (data.rp.y-data.lp.y)*data.lengthFact/distance+mdata.rp.y;
data.lp.x = mdata.rp.x;
data.lp.y = mdata.rp.y;
let axix = new THREE.Vector3(1,0,0);
let axixnow = new THREE.Vector3(data.rp.x-data.lp.x,0,data.rp.y-data.lp.y);
let rotenum = axixnow.angleTo(axix);
//不同坐标系方向值不同
if(data.lp.y>data.rp.y){
testmesh2.rotation.z = 0.218;
data.rp.x = data.lp.x+(data.lengthFact)*Math.cos(testmesh2.rotation.z);
data.rp.y = data.lp.y-(data.lengthFact)*Math.sin(testmesh2.rotation.z);
}else if(data.lp.y<data.rp.y){
testmesh2.rotation.z = -0.218;
data.rp.x = data.lp.x+(data.lengthFact)*Math.cos(testmesh2.rotation.z);
data.rp.y = data.lp.y-(data.lengthFact)*Math.sin(testmesh2.rotation.z);
}
testmesh2.position.x = (data.lp.x + data.rp.x)/2;
testmesh2.position.z = (data.lp.y + data.rp.y)/2;
}
}else{
data.lp.x = data.lp.x;
data.rp.x = data.lp.x + data.lengthFact;
testmesh2.position.x = (data.lp.x + data.rp.x)/2;
testmesh2.position.z = (data.lp.y + data.rp.y)/2;
}
// testmesh2.position.y = 10;
testmesh2.code = data.code;
testmesh2.name = data.name;
testmesh2.meshtype = "link";
testmesh2.lp = data.lp;
testmesh2.rp = data.rp;
testmesh2.rightlist = autorail.rightlist;
testmesh2.leftlist = autorail.leftlist;
testmesh2.lengthfact = data.lengthFact;
scope.linksgroup.add( testmesh2 );
scope.linkdata.push(testmesh2);
}
}
}
}

View File

@ -1,331 +0,0 @@
export function RailList(){
let scope = this;
this.linkrail = [];
this.switchrail = [];
this.stops = [];
this.setrail = function(){
};
this.init = function(linkdata,linklist,sectiondata,switchdata,standsdata,scene,storemod,stopoffset){
for(let i=0;i<linkdata.length;i++){
scope.linkrail[linkdata[i].code] = {
lp:linkdata[i].rail[0],
rp:linkdata[i].rail[1],
lconnect:null,
rconnect:null,
lengthfact:linkdata[i].lengthfact,
lineleft:null,
lineright:null,
points:[],
type:null
};
}
for(let i=0;i<switchdata.length;i++){
scope.switchrail[switchdata[i].code] = {
alink:switchdata[i].alink,
blink:switchdata[i].blink,
clink:switchdata[i].clink,
position:switchdata[i].position,
directtype:null,
locateType:0
};
if(scope.linkrail[switchdata[i].blink].lp.x < switchdata[i].position.x){
scope.linkrail[switchdata[i].alink].lswitch = switchdata[i].code;
scope.linkrail[switchdata[i].blink].rswitch = switchdata[i].code;
}else{
scope.linkrail[switchdata[i].alink].rswitch = switchdata[i].code;
scope.linkrail[switchdata[i].blink].lswitch = switchdata[i].code;
}
//
if(scope.linkrail[switchdata[i].clink].lp.x < switchdata[i].position.x){
scope.linkrail[switchdata[i].alink].lswitch = switchdata[i].code;
scope.linkrail[switchdata[i].clink].rswitch = switchdata[i].code;
}else{
scope.linkrail[switchdata[i].alink].rswitch = switchdata[i].code;
scope.linkrail[switchdata[i].clink].lswitch = switchdata[i].code;
}
}
for(let i=0;i<linkdata.length;i++){
if(linkdata[i].rotation._z == 0){
scope.linkrail[linkdata[i].code].type = 0;
if(scope.linkrail[linkdata[i].code].lswitch){
let switchpoint = scope.switchrail[scope.linkrail[linkdata[i].code].lswitch].position;
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x,0,switchpoint.z));
}
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(scope.linkrail[linkdata[i].code].lp.x,0,scope.linkrail[linkdata[i].code].lp.z));
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(scope.linkrail[linkdata[i].code].rp.x,0,scope.linkrail[linkdata[i].code].rp.z));
if(scope.linkrail[linkdata[i].code].rswitch){
let switchpoint = scope.switchrail[scope.linkrail[linkdata[i].code].rswitch].position;
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x,0,switchpoint.z));
}
}else{
if(linkdata[i].rotation._z>0){
let testline = new THREE.CatmullRomCurve3([
new THREE.Vector3(scope.linkrail[linkdata[i].code].lp.x,0,scope.linkrail[linkdata[i].code].lp.z),
new THREE.Vector3(scope.linkrail[linkdata[i].code].rp.x,0,scope.linkrail[linkdata[i].code].rp.z)
]);
scope.linkrail[linkdata[i].code].type = 1;
if(scope.linkrail[linkdata[i].code].lswitch){
let switchpoint = scope.switchrail[scope.linkrail[linkdata[i].code].lswitch].position;
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x,0,switchpoint.z));
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x+1.5,0,switchpoint.z));
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x+2,0,switchpoint.z));
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x+4.5,0,switchpoint.z-0.05));
}
scope.linkrail[linkdata[i].code].points.push(testline.getPointAt(0.12));
scope.linkrail[linkdata[i].code].points.push(testline.getPointAt(0.22));
scope.linkrail[linkdata[i].code].points.push(testline.getPointAt(0.82));
scope.linkrail[linkdata[i].code].points.push(testline.getPointAt(0.92));
if(scope.linkrail[linkdata[i].code].rswitch){
let switchpoint = scope.switchrail[scope.linkrail[linkdata[i].code].rswitch].position;
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x-4.5,0,switchpoint.z+0.05));
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x-2,0,switchpoint.z));
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x-1.5,0,switchpoint.z));
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x,0,switchpoint.z));
}
}else{
let testline = new THREE.CatmullRomCurve3([
new THREE.Vector3(scope.linkrail[linkdata[i].code].lp.x,0,scope.linkrail[linkdata[i].code].lp.z),
new THREE.Vector3(scope.linkrail[linkdata[i].code].rp.x,0,scope.linkrail[linkdata[i].code].rp.z)
]);
scope.linkrail[linkdata[i].code].type = 2;
if(scope.linkrail[linkdata[i].code].lswitch){
let switchpoint = scope.switchrail[scope.linkrail[linkdata[i].code].lswitch].position;
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x,0,switchpoint.z));
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x+1.5,0,switchpoint.z));
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x+2,0,switchpoint.z));
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x+4.5,0,switchpoint.z+0.05));
}
scope.linkrail[linkdata[i].code].points.push(testline.getPointAt(0.12));
scope.linkrail[linkdata[i].code].points.push(testline.getPointAt(0.22));
scope.linkrail[linkdata[i].code].points.push(testline.getPointAt(0.82));
scope.linkrail[linkdata[i].code].points.push(testline.getPointAt(0.92));
if(scope.linkrail[linkdata[i].code].rswitch){
let switchpoint = scope.switchrail[scope.linkrail[linkdata[i].code].rswitch].position;
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x-4.5,0,switchpoint.z-0.05));
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x-2,0,switchpoint.z));
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x-1.5,0,switchpoint.z));
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x,0,switchpoint.z));
}
}
}
}
for(let i=0;i<switchdata.length;i++){
// const ddd = storemod.getters['map/getDeviceByCode'](switchdata[i].code);
// scope.switchrail[switchdata[i].code].locateType = ddd.locateType;
// if(ddd.locateType == "01"){
// //1--向左 2--向右
// //__\__ __/__
// if(scope.switchrail[switchdata[i].code].directtype == "1"){
// scope.linkrail[switchdata[i].alink].lconnect = switchdata[i].blink;
// scope.linkrail[switchdata[i].blink].rconnect = switchdata[i].alink;
// }else if(scope.switchrail[switchdata[i].code].directtype == "2"){
// scope.linkrail[switchdata[i].alink].rconnect = switchdata[i].blink;
// scope.linkrail[switchdata[i].blink].lconnect = switchdata[i].alink;
// }
// }else if(ddd.locateType == "02"){
// if(switchdata[i].directtype == "1"){
// scope.linkrail[switchdata[i].alink].lconnect = switchdata[i].clink;
// scope.linkrail[switchdata[i].clink].rconnect = switchdata[i].alink;
// }else if(switchdata[i].directtype == "2"){
// scope.linkrail[switchdata[i].alink].rconnect = switchdata[i].clink;
// scope.linkrail[switchdata[i].clink].lconnect = switchdata[i].alink;
// }
// }
if(scope.linkrail[switchdata[i].blink].lp.x < switchdata[i].position.x){
scope.switchrail[switchdata[i].code].directtype = "1";
}else{
scope.switchrail[switchdata[i].code].directtype = "2";
}
if(scope.linkrail[switchdata[i].clink].lp.x < switchdata[i].position.x){
scope.switchrail[switchdata[i].code].directtype = "1";
}else{
scope.switchrail[switchdata[i].code].directtype = "2";
}
}
for(let i=0;i<linkdata.length;i++){
scope.linkrail[linkdata[i].code].lineleft = new THREE.CatmullRomCurve3(scope.linkrail[linkdata[i].code].points);
scope.linkrail[linkdata[i].code].lineleft.curveType = "centripetal";
// scope.linkrail[linkdata[i].code].lineleft.tension = 0.2;
let rightpoints = [];
scope.linkrail[linkdata[i].code].points.forEach(item=>{
rightpoints.push(item);
}
);
rightpoints.reverse();
scope.linkrail[linkdata[i].code].lineright = new THREE.CatmullRomCurve3(rightpoints);
scope.linkrail[linkdata[i].code].lineright.curveType = "centripetal";
//
// for(let n=0,nm=scope.linkrail[linkdata[i].code].lineleft.points.length;n<nm;n++){
// var geometry = new THREE.CircleGeometry( 0.05, 16 );
// var material = new THREE.MeshBasicMaterial( { color: 0xffff00 } );
// var circle = new THREE.Mesh( geometry, material );
// console.log(n);
// console.log(scope.linkrail[linkdata[i].code].lineleft.points[n]);
// circle.position.x = scope.linkrail[linkdata[i].code].lineleft.points[n].x;
// circle.position.y = scope.linkrail[linkdata[i].code].lineleft.points[n].y;
// circle.position.z = scope.linkrail[linkdata[i].code].lineleft.points[n].z;
// circle.rotation.x = -Math.PI/2;
// scene.add( circle );
// }
// // scope.linkrail[linkdata[i].code].lineright.tension = 0.11;
// var points = scope.linkrail[linkdata[i].code].lineleft.getPoints( 50 );
// var geometry = new THREE.BufferGeometry().setFromPoints( points );
// var material;
// if(scope.linkrail[linkdata[i].code].type == 0){
// material = new THREE.LineBasicMaterial( { color : 0xff0000 } );
// }
// if(scope.linkrail[linkdata[i].code].type == 1){
// material = new THREE.LineBasicMaterial( { color : 0x00ff00 } );
// }
// if(scope.linkrail[linkdata[i].code].type == 2){
// material = new THREE.LineBasicMaterial( { color : 0x0000ff } );
// }
//
//
// // Create the final object to add to the scene
// var curveObject = new THREE.Line( geometry, material );
//
// curveObject.position.y = Math.random();
// scene.add(curveObject);
}
let standsections = [];
for(let i=0,len=sectiondata.length;i<len;i++){
if(sectiondata[i].isStandTrack == true){
standsections.push(sectiondata[i]);
}
}
for(let k in standsdata){
let stop = {
code:null,
direct1:{
percent:null,
},
direct2:{
percent:null,
}
};
for(let i=0,leni=standsections.length;i<leni;i++){
for(let j=0,lenj=linklist.length;j<lenj;j++){
if(standsections[i].linkCode == linklist[j].code){
// let geometry = new THREE.CircleGeometry( 2, 16 );
// let material = new THREE.MeshBasicMaterial( { color: 0x00ffff } );
if(standsdata[k].direction1.code == standsections[i].relStandCode){
stop.code = standsdata[k].code;
// let circle1 = new THREE.Mesh( geometry, material );
// let circle2 = new THREE.Mesh( geometry, material );
let num = scope.linkrail[linklist[j].code].lineleft.points.length-1;
let lengthfacts = scope.linkrail[linklist[j].code].lineleft.points[num].x - scope.linkrail[linklist[j].code].lineleft.points[0].x;
let directoffset1 = standsdata[k].position.x-stopoffset-scope.linkrail[linklist[j].code].lineleft.points[0].x;
stop.direct1.percent = directoffset1/lengthfacts;
// circle1.position.x = standsdata[k].position.x+stopoffset;
// circle1.position.y = 5;
// circle1.position.z = scope.linkrail[linklist[j].code].points[0].z;
// circle1.rotation.x = -Math.PI/2;
//
// circle2.position.x = standsdata[k].position.x-stopoffset;
// circle2.position.y = 5;
// circle2.position.z = scope.linkrail[linklist[j].code].points[0].z;
// circle2.rotation.x = -Math.PI/2;
// scene.add( circle1 );
// scene.add( circle2 );
// console.log(stop);
}
if(standsdata[k].direction2.code == standsections[i].relStandCode){
stop.code = standsdata[k].code;
// let circle1 = new THREE.Mesh( geometry, material );
// let circle2 = new THREE.Mesh( geometry, material );
let num = scope.linkrail[linklist[j].code].lineleft.points.length-1;
let lengthfacts = scope.linkrail[linklist[j].code].lineleft.points[num].x - scope.linkrail[linklist[j].code].lineleft.points[0].x;
let directoffset2 = parseInt(standsdata[k].position.x+stopoffset-scope.linkrail[linklist[j].code].lineleft.points[0].x);
// console.log(directoffset2);
stop.direct2.percent = directoffset2/lengthfacts;
// console.log("test");
// console.log(directoffset1);
// console.log(directoffset2);
// console.log("sectoffsetleft");
// console.log(stop.direct1.percent);
// console.log(scope.linkrail[linklist[j].code].lengthfact);
// console.log(lengthfacts);
// console.log("........................");
// console.log(standsections[i].leftStopPointOffset);
// console.log(standsdata[n].position.x-stopoffset-scope.linkrail[linklist[j].code].lineleft.points[0].x);
// console.log("........................");
// console.log(standsdata[n].position.x+stopoffset);
// console.log(scope.linkrail[linklist[j].code].lineleft.getPointAt(stop.direct1.percent).x);
// console.log("sectoffsetright");
// console.log(scope.linkrail[linklist[j].code]);
// console.log(stop.direct2.percent);
// console.log(scope.linkrail[linklist[j].code].lengthfact);
// console.log(lengthfacts);
// console.log("........................");
// console.log(standsections[i].rightStopPointOffset);
// console.log(standsdata[k].position.x+stopoffset-scope.linkrail[linklist[j].code].lineleft.points[0].x);
// console.log("........................");
// console.log(standsdata[k].position.x+stopoffset);
// console.log(scope.linkrail[linklist[j].code].lineleft.getPointAt(stop.direct2.percent).x);
// circle1.position.x = standsdata[k].position.x+stopoffset;
// circle1.position.y = 5;
// circle1.position.z = scope.linkrail[linklist[j].code].points[0].z;
// circle1.rotation.x = -Math.PI/2;
// //
// circle2.position.x = standsdata[k].position.x-stopoffset;
// circle2.position.y = 5;
// circle2.position.z = scope.linkrail[linklist[j].code].points[0].z;
// circle2.rotation.x = -Math.PI/2;
//
// scene.add( circle1 );
// scene.add( circle2 );
// console.log(stop);
}
if(stop.direct1.percent != null && stop.direct2.percent != null){
// console.log(stop)
scope.stops[standsdata[k].code] = stop;
}
j = lenj;
}
}
}
}
// console.log(scope.stops);
}
this.getrail = function(){
};
}

View File

@ -1,118 +0,0 @@
import {RealSectionModel} from '@/jlmap3d/edit/editmodel/RealSectionModel.js';
export function RealSectionList(data) {
let scope = this;
this.type = "sectionlist";
this.list = [];
this.group = [];
this.switch = [];
this.initpromise = function(jlmap3ddata,scene,assetloader,mixers,actions){
return new Promise(function(resolve, reject){
let modelnum = null;
for(let i=0;i<assetloader.modellist.length;i++){
if(assetloader.modellist[i].deviceType == "mapSection"){
modelnum = i;
}
}
let newmesh = assetloader.modellist[modelnum].mesh;
let mixer = new THREE.AnimationMixer( newmesh );
for(let i=0;i<newmesh.children.length;i++){
let name = newmesh.children[i].name.split("_");
let newmeshname = name[0]+"_"+name[1]+"_"+name[2]+"."+name[3];
//console.log(newmeshname);
if(name[0] == "Switch"){
for(let j=0;j<jlmap3ddata.sectionlist.switchs.datalist.length;j++){
if(jlmap3ddata.sectionlist.switchs.datalist[j].name == newmeshname){
//绿色道岔
let nowname = jlmap3ddata.sectionlist.switchs.datalist[j].name;
let nowcode = jlmap3ddata.sectionlist.switchs.datalist[j].code;
newmesh.children[i].name = nowname;
newmesh.children[i].code = nowcode;
for(let n=0;n<newmesh.children[i].children.length;n++){
newmesh.children[i].children[n].code = nowcode;
}
jlmap3ddata.sectionlist.switchs.modellist[j] = newmesh.children[i];
for(let m=0;m<newmesh.animations[0].tracks.length;m++){
let animatename = newmesh.animations[0].tracks[m].name.split(".");
for(let nm=0;nm<jlmap3ddata.sectionlist.switchs.modellist[j].children.length;nm++){
if(animatename[0] == jlmap3ddata.sectionlist.switchs.modellist[j].children[nm].name && animatename[1] == "position"){
let newtracks = newmesh.animations[0].tracks.slice(m,m+6);
let newclip = new THREE.AnimationClip(jlmap3ddata.sectionlist.switchs.modellist[j].name,2,newtracks);
jlmap3ddata.sectionlist.switchs.modellist[j].locateType = null;
jlmap3ddata.sectionlist.switchs.modellist[j].animations = [];
jlmap3ddata.sectionlist.switchs.modellist[j].animations.push(newclip);
let mixer = new THREE.AnimationMixer( jlmap3ddata.sectionlist.switchs.modellist[j] );
actions[jlmap3ddata.sectionlist.switchs.modellist[j].name] = mixer.clipAction( jlmap3ddata.sectionlist.switchs.modellist[j].animations[ 0 ] );
actions[jlmap3ddata.sectionlist.switchs.modellist[j].name].setLoop(THREE.LoopOnce);
actions[jlmap3ddata.sectionlist.switchs.modellist[j].name].clampWhenFinished = true;
actions[jlmap3ddata.sectionlist.switchs.modellist[j].name].play();
mixers.push(mixer);
m = newmesh.animations[0].tracks.length;
}
}
}
j = jlmap3ddata.sectionlist.switchs.datalist.length;
}
}
}
if(name[0] == "Section"){
//物理区段
if(jlmap3ddata.sectionlist.sections.datalist[newmeshname]){
if(jlmap3ddata.sectionlist.sections.datalist[newmeshname].isStandTrack == true){
//红色站台区段
}else{
//蓝色其他区段
}
let nowname = jlmap3ddata.sectionlist.sections.datalist[newmeshname].name;
let nowcode = jlmap3ddata.sectionlist.sections.datalist[newmeshname].code;
newmesh.children[i].name = nowname;
newmesh.children[i].code = nowcode;
let j = jlmap3ddata.sectionlist.sections.datalist[newmeshname].index;
jlmap3ddata.sectionlist.sections.modellist.push(newmesh.children[i]);
}
}
if(name[0] == "Singal"){
console.log();
newmesh.remove(newmesh.children[i]);
i = i-1;
}
if(name[0] == "Station"){
newmesh.remove(newmesh.children[i]);
i = i-1;
}
}
scene.add(newmesh);
resolve("loadedrealsection");
});
}
}

View File

@ -1,8 +0,0 @@
export function RealSectionModel(data) {
var scope = this;
this.mesh = null;
this.meshurl = null;
this.picurl = null;
}

Some files were not shown because too many files have changed in this diff Show More