增加三维客流规划模块
This commit is contained in:
parent
2c1b9fcc45
commit
3ad0ccffc1
@ -55,7 +55,7 @@ export default {
|
||||
threeDimensionalView: 'Three-Dimensional View',
|
||||
threeDimensionalStation: 'Three-Dimensional Station',
|
||||
passengerflow: 'CCTV View',
|
||||
trafficplan:'Passer Planing',
|
||||
trafficplantext:'Passer Planing',
|
||||
maintainer: 'Maintainer View',
|
||||
deviceView: 'DeviceView',
|
||||
taskOperateSuccess: 'Task Operate success',
|
||||
|
@ -55,7 +55,8 @@ export default {
|
||||
threeDimensionalView: '数字沙盘',
|
||||
threeDimensionalStation: '三维车站',
|
||||
passengerflow: 'cctv视图',
|
||||
trafficplan:'客流规划',
|
||||
trafficplantext:'客流规划',
|
||||
traffictraintext:'列车客乘',
|
||||
maintainer: '设备故障视图',
|
||||
deviceView: '设备视图',
|
||||
taskOperateSuccess: '任务操作成功',
|
||||
|
185
src/jlmap3d/jl3dtrafficplan/connect/stationconnect.js
Normal file
185
src/jlmap3d/jl3dtrafficplan/connect/stationconnect.js
Normal file
@ -0,0 +1,185 @@
|
||||
import StompClient from '@/utils/sock';
|
||||
import { getBaseUrl } from '@/utils/baseUrl'
|
||||
import { getToken } from '@/utils/auth';
|
||||
import store from '@/store/index_APP_TARGET';
|
||||
|
||||
// 定于仿真socket接口
|
||||
export function PassflowConnect(deviceaction,toptrain,downtrain,routegroup,passerStation,passerAi,passerHuman) {
|
||||
const scope = this;
|
||||
this.teststomp = new StompClient();
|
||||
|
||||
let topic = '/user/queue/simulation/jl3d/'+routegroup;
|
||||
let header = {'X-Token': getToken() };
|
||||
|
||||
socketon(topic);
|
||||
|
||||
function socketon(topic) {
|
||||
try {
|
||||
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 == "DeviceCtrl_3D"){
|
||||
if(data.body.type == "PSD"){
|
||||
if(data.body.code == passerStation.nowStation.toppsd){
|
||||
if(data.body.open == 0){
|
||||
passerAi.passerout("top","end");
|
||||
deviceaction.top.action.reset();
|
||||
deviceaction.top.action.time =deviceaction.top.action._clip.duration;
|
||||
deviceaction.top.action.timeScale = -1;
|
||||
deviceaction.top.action.play();
|
||||
|
||||
}else{
|
||||
passerAi.passerout("top","start")
|
||||
deviceaction.top.action.reset();
|
||||
deviceaction.top.action.time = 0;
|
||||
deviceaction.top.action.timeScale = 1;
|
||||
deviceaction.top.action.play();
|
||||
}
|
||||
}
|
||||
if(data.body.code == passerStation.nowStation.downpsd){
|
||||
if(data.body.open == 0){
|
||||
passerAi.passerout("down","end");
|
||||
deviceaction.down.action.reset();
|
||||
deviceaction.down.action.time = deviceaction.down.action._clip.duration;
|
||||
deviceaction.down.action.timeScale = -1;
|
||||
deviceaction.down.action.play();
|
||||
|
||||
}else{
|
||||
passerAi.passerout("down","start");
|
||||
deviceaction.down.action.reset();
|
||||
deviceaction.down.action.time = 0;
|
||||
deviceaction.down.action.timeScale = 1;
|
||||
deviceaction.down.action.play();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if(data.body.type == "TRAIN_DOOR"){
|
||||
if(toptrain.nowcode == data.body.code){
|
||||
|
||||
if(data.body.open == "0"){
|
||||
closetraindoor(toptrain,data.body.doorCode,"top");
|
||||
|
||||
}else{
|
||||
opentraindoor(toptrain,data.body.doorCode,"top");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
if(downtrain.nowcode == data.body.code){
|
||||
// console.log(data.body);
|
||||
if(data.body.open == "0"){
|
||||
closetraindoor(downtrain,data.body.doorCode,"down");
|
||||
|
||||
}else{
|
||||
opentraindoor(downtrain,data.body.doorCode,"down");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(data.type == "TrainRun_3D"){
|
||||
|
||||
for(let i=0,leni = data.body.length;i<leni;i++){
|
||||
if(data.body[i].section == passerStation.nowStation.topsection){
|
||||
if(toptrain.nowcode != data.body[i].code){
|
||||
toptrain.nowcode = data.body[i].code;
|
||||
}
|
||||
toptrain.position.copy(toptrain.curve.getPointAt(data.body[i].offset));
|
||||
|
||||
}else{
|
||||
if(downtrain.nowcode == data.body[i].code){
|
||||
toptrain.position.x -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
if(data.body[i].section == passerStation.nowStation.downsection){
|
||||
if(downtrain.nowcode != data.body[i].code){
|
||||
downtrain.nowcode = data.body[i].code;
|
||||
}
|
||||
downtrain.position.copy(downtrain.curve.getPointAt(data.body[i].offset));
|
||||
|
||||
}else{
|
||||
if(downtrain.nowcode == data.body[i].code){
|
||||
downtrain.position.x += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(data.type == 'Simulation_Over') {
|
||||
store.dispatch('LogOut').then(() => {
|
||||
location.reload();
|
||||
});
|
||||
}
|
||||
}
|
||||
let actions;
|
||||
|
||||
function opentraindoor(train,doorcode,direct){
|
||||
if(direct == "top"){
|
||||
if(doorcode == "1"){
|
||||
actions = train.action.down;
|
||||
}
|
||||
|
||||
if(doorcode == "2"){
|
||||
actions = train.action.top;
|
||||
}
|
||||
}else{
|
||||
if(doorcode == "1"){
|
||||
actions = train.action.top;
|
||||
}
|
||||
|
||||
if(doorcode == "2"){
|
||||
actions = train.action.down;
|
||||
}
|
||||
}
|
||||
|
||||
for(let an=actions.length-1;an>=0;an--){
|
||||
actions[an].reset();
|
||||
actions[an].time = 0;
|
||||
actions[an].timeScale = 1;
|
||||
actions[an].play();
|
||||
}
|
||||
}
|
||||
function closetraindoor(train,doorcode,direct){
|
||||
|
||||
if(direct == "top"){
|
||||
if(doorcode == "1"){
|
||||
actions = train.action.down;
|
||||
}
|
||||
if(doorcode == "2"){
|
||||
actions = train.action.top;
|
||||
}
|
||||
toptrain.nowcode = null;
|
||||
}else{
|
||||
if(doorcode == "1"){
|
||||
actions = train.action.top;
|
||||
}
|
||||
if(doorcode == "2"){
|
||||
actions = train.action.down;
|
||||
}
|
||||
downtrain.nowcode = null;
|
||||
}
|
||||
|
||||
for(let an=actions.length-1;an>=0;an--){
|
||||
actions[an].reset();
|
||||
actions[an].time = actions[an]._clip.duration;
|
||||
actions[an].timeScale = -1;
|
||||
actions[an].play();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
117
src/jlmap3d/jl3dtrafficplan/connect/trainconnect.js
Normal file
117
src/jlmap3d/jl3dtrafficplan/connect/trainconnect.js
Normal file
@ -0,0 +1,117 @@
|
||||
import StompClient from '@/utils/sock';
|
||||
import { getBaseUrl } from '@/utils/baseUrl'
|
||||
import { getToken } from '@/utils/auth';
|
||||
import store from '@/store/index_APP_TARGET';
|
||||
|
||||
// 定于仿真socket接口
|
||||
export function TrainConnect(trafficTrain,deviceaction,toptrain,routegroup,passerAi) {
|
||||
const scope = this;
|
||||
this.teststomp = new StompClient();
|
||||
|
||||
let topic = '/user/queue/simulation/jl3d/'+routegroup;
|
||||
let header = {'X-Token': getToken() };
|
||||
|
||||
socketon(topic);
|
||||
|
||||
function socketon(topic) {
|
||||
try {
|
||||
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 == "TrainRun_3D"){
|
||||
trafficTrain.trainList = data.body;
|
||||
// console.log(trafficTrain.nowTrainCode);
|
||||
}
|
||||
|
||||
if(data.type == "DeviceCtrl_3D"){
|
||||
|
||||
if(data.body.type == "TRAIN_DOOR"){
|
||||
if(toptrain.nowcode == data.body.code){
|
||||
|
||||
if(data.body.open == "0"){
|
||||
closetraindoor(toptrain,data.body.doorCode,"top");
|
||||
|
||||
}else{
|
||||
opentraindoor(toptrain,data.body.doorCode,"top");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(data.type == 'Simulation_Over') {
|
||||
store.dispatch('LogOut').then(() => {
|
||||
location.reload();
|
||||
});
|
||||
}
|
||||
}
|
||||
let actions;
|
||||
|
||||
function opentraindoor(train,doorcode,direct){
|
||||
if(direct == "top"){
|
||||
if(doorcode == "1"){
|
||||
actions = train.action.down;
|
||||
}
|
||||
|
||||
if(doorcode == "2"){
|
||||
actions = train.action.top;
|
||||
}
|
||||
}else{
|
||||
if(doorcode == "1"){
|
||||
actions = train.action.top;
|
||||
}
|
||||
|
||||
if(doorcode == "2"){
|
||||
actions = train.action.down;
|
||||
}
|
||||
}
|
||||
|
||||
for(let an=actions.length-1;an>=0;an--){
|
||||
actions[an].reset();
|
||||
actions[an].time = 0;
|
||||
actions[an].timeScale = 1;
|
||||
actions[an].play();
|
||||
}
|
||||
}
|
||||
function closetraindoor(train,doorcode,direct){
|
||||
|
||||
if(direct == "top"){
|
||||
if(doorcode == "1"){
|
||||
actions = train.action.down;
|
||||
}
|
||||
if(doorcode == "2"){
|
||||
actions = train.action.top;
|
||||
}
|
||||
toptrain.nowcode = null;
|
||||
}else{
|
||||
if(doorcode == "1"){
|
||||
actions = train.action.top;
|
||||
}
|
||||
if(doorcode == "2"){
|
||||
actions = train.action.down;
|
||||
}
|
||||
}
|
||||
|
||||
for(let an=actions.length-1;an>=0;an--){
|
||||
actions[an].reset();
|
||||
actions[an].time = actions[an]._clip.duration;
|
||||
actions[an].timeScale = -1;
|
||||
actions[an].play();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
import { Staticmodel } from '@/jlmap3d/jl3dpassflow/config.js';
|
||||
import { Staticmodel } from '@/jlmap3d/jl3dtrafficplan/loader/stationconfig.js';
|
||||
//静态资源文件路劲
|
||||
import { JL3D_LOCAL_STATIC } from '@/api/jlmap3d/assets3d.js';
|
||||
//loader
|
||||
@ -6,28 +6,28 @@ import { FBXLoader } from '@/jlmap3d/main/loaders/FBXLoader';
|
||||
//轨道视角控制
|
||||
import { OrbitControls } from '@/jlmap3d/main/control/OrbitControls';
|
||||
//模型管理器
|
||||
import { ModelManager } from '@/jlmap3d/jl3dpassflow/loader.js';
|
||||
import { ModelManager } from '@/jlmap3d/jl3dtrafficplan/loader/loader.js';
|
||||
//骨骼动画模型辅助工具
|
||||
import { SkeletonUtils } from '@/jlmap3d/main/utils/SkeletonUtils.js';
|
||||
//获取信息接口
|
||||
import { getPublishMapVersion, getPublishMapDetail,getPublish3dMapDetail} from '@/api/jlmap3d/load3ddata';
|
||||
//cctv站台对象
|
||||
import { PasserStation } from '@/jlmap3d/jl3dpassflow/model/passerstation.js';
|
||||
import { PasserStation } from '@/jlmap3d/jl3dtrafficplan/model/passerstation.js';
|
||||
//cctv检票机对象
|
||||
import { PasserCheckDoor } from '@/jlmap3d/jl3dpassflow/model/passercheckdoor.js';
|
||||
import { PasserCheckDoor } from '@/jlmap3d/jl3dtrafficplan/model/passercheckdoor.js';
|
||||
//cctv列车对象
|
||||
import { PasserTrain } from '@/jlmap3d/jl3dpassflow/model/passertrain.js';
|
||||
import { PasserTrain } from '@/jlmap3d/jl3dtrafficplan/model/passertrain.js';
|
||||
//cctv行人对象
|
||||
import { PasserHuman } from '@/jlmap3d/jl3dpassflow/model/passerhuman.js';
|
||||
import { PasserHuman } from '@/jlmap3d/jl3dtrafficplan/model/passerhuman.js';
|
||||
//cctv渲染器
|
||||
import { PasserRender } from '@/jlmap3d/jl3dpassflow/passerrender/passerrender.js';
|
||||
//cctv行人ai
|
||||
import { PasserAi } from '@/jlmap3d/jl3dpassflow/passerai/passerai.js';
|
||||
import { PasserAi } from '@/jlmap3d/jl3dtrafficplan/passerai/passerai.js';
|
||||
//行人寻路相关工具
|
||||
import { ZoneManager } from '@/jlmap3d/jl3dpassflow/model/zonemanager.js';
|
||||
import { PathFinder } from '@/jlmap3d/jl3dpassflow/passerai/pathfinder.js';
|
||||
import { ZoneManager } from '@/jlmap3d/jl3dtrafficplan/model/zonemanager.js';
|
||||
import { PathFinder } from '@/jlmap3d/jl3dtrafficplan/passerai/pathfinder.js';
|
||||
//cctv通信工具
|
||||
import { PassflowConnect } from '@/jlmap3d/jl3dpassflow/connect/passflowconnect.js';
|
||||
import { PassflowConnect } from '@/jlmap3d/jl3dtrafficplan/connect/stationconnect.js';
|
||||
|
||||
import StompClient from '@/utils/sock';
|
||||
import store from '@/store/index_APP_TARGET';
|
||||
@ -101,7 +101,15 @@ export function Jl3dTrafficPlan(dom,skinCode,routegroup,viewMap) {
|
||||
// let mouse = new THREE.Vector2();
|
||||
let raycaster = new THREE.Raycaster();
|
||||
|
||||
//进站运动中乘客
|
||||
let humanlist = new THREE.Group();
|
||||
//上行等待上车乘客
|
||||
let topWaitPassers = new THREE.Group();
|
||||
//下行等待上车乘客
|
||||
let downWaitPassers = new THREE.Group();
|
||||
//出站乘客
|
||||
let outStationPassers = new THREE.Group();
|
||||
|
||||
let passerHuman = new PasserHuman();
|
||||
|
||||
let passerAi = new PasserAi(passerZone,pathFinder);
|
||||
@ -134,14 +142,15 @@ export function Jl3dTrafficPlan(dom,skinCode,routegroup,viewMap) {
|
||||
monitor = scope.modelmanager.monitor.mesh;
|
||||
scene.add(monitor);
|
||||
|
||||
|
||||
|
||||
getPublishMapDetail(skinCode).then(netdata => {
|
||||
scope.switchviews('freeview');
|
||||
passerHuman.initHumans(scope.modelmanager.man1.mesh,scope.modelmanager.man2.mesh);
|
||||
scene.add(humanlist);
|
||||
scene.add(topWaitPassers);
|
||||
scene.add(downWaitPassers);
|
||||
scene.add(outStationPassers);
|
||||
passerStation.initStationList(netdata.data.stationList,netdata.data.stationStandList,netdata.data.psdList);
|
||||
socktest = new PassflowConnect(deviceaction,passerTrain.toptrain,passerTrain.downtrain,routegroup,passerStation,passerAi);
|
||||
socktest = new PassflowConnect(deviceaction,passerTrain.toptrain,passerTrain.downtrain,routegroup,passerStation,passerAi,passerHuman);
|
||||
|
||||
store.dispatch('app/animationsClose');
|
||||
|
||||
@ -181,6 +190,28 @@ export function Jl3dTrafficPlan(dom,skinCode,routegroup,viewMap) {
|
||||
j--;
|
||||
// j--;
|
||||
}
|
||||
|
||||
for(let j=0; j<topWaitPassers.children.length;j++){
|
||||
|
||||
topWaitPassers.remove(topWaitPassers.children[j]);
|
||||
j--;
|
||||
// j--;
|
||||
}
|
||||
for(let j=0; j<downWaitPassers.children.length;j++){
|
||||
|
||||
downWaitPassers.remove(downWaitPassers.children[j]);
|
||||
j--;
|
||||
// j--;
|
||||
}
|
||||
for(let j=0; j<outStationPassers.children.length;j++){
|
||||
|
||||
outStationPassers.remove(outStationPassers.children[j]);
|
||||
j--;
|
||||
// j--;
|
||||
}
|
||||
|
||||
|
||||
|
||||
passerTrain.toptrain.position.y = -20000;
|
||||
passerTrain.downtrain.position.y = -20000;
|
||||
|
||||
@ -212,21 +243,21 @@ export function Jl3dTrafficPlan(dom,skinCode,routegroup,viewMap) {
|
||||
// actions[an].play();
|
||||
// }
|
||||
setTimeout(function(){
|
||||
passerAi.initPasser(humanlist,passerHuman);
|
||||
passerAi.initPasser(humanlist,topWaitPassers,downWaitPassers,passerHuman);
|
||||
aiswitch = 0;
|
||||
}, 2000);
|
||||
|
||||
}
|
||||
|
||||
function startWorker(){
|
||||
passerAi.initPasser(humanlist,passerHuman);
|
||||
passerAi.initPasser(humanlist,topWaitPassers,downWaitPassers,passerHuman);
|
||||
let updateaianimate = setInterval(
|
||||
function(){
|
||||
// console.log("?");
|
||||
if(aiswitch == 0){
|
||||
passerHuman.moveAnimateUpdate(humanlist,olddataai,passerHuman);
|
||||
passerAi.aiUpdate(humanlist,passerHuman,passerCheckDoor,deviceaction);
|
||||
|
||||
passerHuman.moveAnimateUpdate(humanlist,topWaitPassers,downWaitPassers,outStationPassers,passerHuman);
|
||||
passerAi.aiUpdate(humanlist,topWaitPassers,downWaitPassers,outStationPassers,passerHuman,passerCheckDoor,deviceaction);
|
||||
// passerZone.zoneActionCheck(humanlist,passerHuman,passerCheckDoor,deviceaction);
|
||||
delta = clock.getDelta();
|
||||
|
||||
for(let i=mixers.length-1;i>=0;i--){
|
||||
@ -234,6 +265,21 @@ export function Jl3dTrafficPlan(dom,skinCode,routegroup,viewMap) {
|
||||
mixers[i].update( delta );
|
||||
}
|
||||
}
|
||||
for(let i=topWaitPassers.children.length-1;i>=0;i--){
|
||||
if(topWaitPassers.children[i].mixer._actions[0].isRunning()){
|
||||
topWaitPassers.children[i].mixer.update( delta );
|
||||
}
|
||||
}
|
||||
for(let i=downWaitPassers.children.length-1;i>=0;i--){
|
||||
if(downWaitPassers.children[i].mixer._actions[0].isRunning()){
|
||||
downWaitPassers.children[i].mixer.update( delta );
|
||||
}
|
||||
}
|
||||
for(let i=outStationPassers.children.length-1;i>=0;i--){
|
||||
if(outStationPassers.children[i].mixer._actions[0].isRunning()){
|
||||
outStationPassers.children[i].mixer.update( delta );
|
||||
}
|
||||
}
|
||||
for(let i=humanlist.children.length-1;i>=0;i--){
|
||||
if(humanlist.children[i].mixer._actions[0].isRunning()){
|
||||
humanlist.children[i].mixer.update( delta );
|
||||
@ -246,32 +292,37 @@ export function Jl3dTrafficPlan(dom,skinCode,routegroup,viewMap) {
|
||||
passerWebWork.onmessage = function (event) {
|
||||
if(aiswitch == 0){
|
||||
// console.log(humanlist.children.length);
|
||||
if(humanlist.children.length < 80){
|
||||
if(humanlist.children.length < 100){
|
||||
let direct = Math.floor(Math.random()*(3-1+1))+1;
|
||||
//1--top
|
||||
//2-- down
|
||||
updatePasserData(humanlist.children.length,topWaitPassers.children.length,downWaitPassers.children.length,outStationPassers.children.length);
|
||||
if(direct == 1){
|
||||
passerHuman.newHumanCreate(humanlist,passerZone.getzoneposition("enter1"),0);
|
||||
}else{
|
||||
passerHuman.newHumanCreate(humanlist,passerZone.getzoneposition("enter2"),0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(outStationPassers.children.length < 100){
|
||||
if(passerAi.toppasseron){
|
||||
for(let i=0,leni=passerZone.list["standtop"].doorpoints.length;i<leni;i++ ){
|
||||
setTimeout(function(){
|
||||
passerHuman.newHumanCreate(humanlist,passerZone.list["standtop"].doorpoints[i],5,"top",i);
|
||||
passerHuman.newHumanCreate(outStationPassers,passerZone.list["standtop"].doorpoints[i],5,"top",i);
|
||||
}, Math.random()*1000);
|
||||
|
||||
}
|
||||
}
|
||||
if(passerAi.downpasseron){
|
||||
|
||||
for(let i=0,leni=passerZone.list["standdown"].doorpoints.length;i<leni;i++ ){
|
||||
setTimeout(function(){
|
||||
passerHuman.newHumanCreate(humanlist,passerZone.list["standdown"].doorpoints[i],5,"down",i);
|
||||
}, Math.random()*1000);
|
||||
passerHuman.newHumanCreate(outStationPassers,passerZone.list["standdown"].doorpoints[i],5,"down",i);
|
||||
}, Math.random()*1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -281,9 +332,9 @@ export function Jl3dTrafficPlan(dom,skinCode,routegroup,viewMap) {
|
||||
function animate() {
|
||||
passerRender.update();
|
||||
|
||||
if(passerRender.state == "freeview"){
|
||||
// if(passerRender.state == "freeview"){
|
||||
controls.update();
|
||||
}
|
||||
// }
|
||||
// delta = clock.getDelta();
|
||||
requestAnimationFrame(animate);
|
||||
|
||||
|
347
src/jlmap3d/jl3dtrafficplan/jl3dtraffictrain.js
Normal file
347
src/jlmap3d/jl3dtrafficplan/jl3dtraffictrain.js
Normal file
@ -0,0 +1,347 @@
|
||||
import { Staticmodel } from '@/jlmap3d/jl3dtrafficplan/loader/trainconfig.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/jl3dtrafficplan/loader/loader.js';
|
||||
//骨骼动画模型辅助工具
|
||||
import { SkeletonUtils } from '@/jlmap3d/main/utils/SkeletonUtils.js';
|
||||
//获取信息接口
|
||||
import { getPublishMapVersion, getPublishMapDetail,getPublish3dMapDetail} from '@/api/jlmap3d/load3ddata';
|
||||
|
||||
//cctv列车对象
|
||||
import { PasserTrain } from '@/jlmap3d/jl3dtrafficplan/model/passertrain.js';
|
||||
//cctv行人对象
|
||||
import { PasserHuman } from '@/jlmap3d/jl3dpassflow/model/passerhuman.js';
|
||||
//cctv渲染器
|
||||
import { PasserRender } from '@/jlmap3d/jl3dpassflow/passerrender/passerrender.js';
|
||||
//cctv行人ai
|
||||
import { PasserAi } from '@/jlmap3d/jl3dpassflow/passerai/passerai.js';
|
||||
//行人寻路相关工具
|
||||
import { ZoneManager } from '@/jlmap3d/jl3dtrafficplan/model/zonemanager.js';
|
||||
import { PathFinder } from '@/jlmap3d/jl3dpassflow/passerai/pathfinder.js';
|
||||
//cctv通信工具
|
||||
import { TrainConnect } from '@/jlmap3d/jl3dtrafficplan/connect/trainconnect.js';
|
||||
|
||||
import StompClient from '@/utils/sock';
|
||||
import store from '@/store/index_APP_TARGET';
|
||||
// import { Loading } from 'element-ui';
|
||||
import {Stats} from '@/jlmap3d/main/lib/stats.min.js';
|
||||
|
||||
//动画播放相关
|
||||
let clock = new THREE.Clock();
|
||||
let delta;
|
||||
|
||||
let scene,camerass,renderer;
|
||||
|
||||
let aiswitch = 0;
|
||||
//动画组
|
||||
let mixers = [];
|
||||
|
||||
//寻路相关对象
|
||||
let passerZone = new ZoneManager();
|
||||
let pathFinder = new PathFinder();
|
||||
let path;
|
||||
|
||||
//设备动画action组
|
||||
let deviceaction = [];
|
||||
//控制帧率的webworker线程
|
||||
let passerWebWork = new Worker(JL3D_LOCAL_STATIC+"/workertest/passsimulation/station.js");
|
||||
|
||||
//老版本临时ai控制
|
||||
let olddataai = false;
|
||||
|
||||
export function Jl3dTrafficTrain(dom,skinCode,routegroup,viewMap) {
|
||||
|
||||
// let stats = new Stats();
|
||||
// dom.appendChild( stats.dom );
|
||||
|
||||
let scope = this;
|
||||
|
||||
this.dom = dom;
|
||||
this.nowcode = null;
|
||||
this.animateswitch = false;
|
||||
this.signallights = [];
|
||||
this.mixers = [];
|
||||
this.showmodel = null;
|
||||
|
||||
this.nowTrainCode = "";
|
||||
|
||||
this.trainList = [];
|
||||
|
||||
//定义相机
|
||||
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();
|
||||
|
||||
//定义场景(渲染容器)
|
||||
scene = new THREE.Scene();
|
||||
scene.background = new THREE.Color(0xa0a0a0);
|
||||
|
||||
let passerRender = new PasserRender(viewMap);
|
||||
passerRender.initView(dom,scene,camerass);
|
||||
|
||||
//定义全局光
|
||||
let ambientLight = new THREE.AmbientLight(0xffffff, 1.3);
|
||||
scene.add(ambientLight);
|
||||
|
||||
let controls = new THREE.OrbitControls(camerass, dom);
|
||||
controls.maxPolarAngle = Math.PI / 2;
|
||||
controls.minPolarangle = Math.PI / 5;
|
||||
controls.maxDistance = 800;
|
||||
controls.screenSpacePanning = true;
|
||||
|
||||
camerass.position.x = 21.83;
|
||||
camerass.position.y = 5.29;
|
||||
camerass.position.z = 17.36;
|
||||
controls.target = new THREE.Vector3(camerass.position.x-0.1,camerass.position.y-0.1,camerass.position.z);
|
||||
controls.update();
|
||||
controls.enabled = false;
|
||||
|
||||
this.selectmodel = null;
|
||||
// let mouse = new THREE.Vector2();
|
||||
let raycaster = new THREE.Raycaster();
|
||||
|
||||
let humanlist = new THREE.Group();
|
||||
let passerHuman = new PasserHuman();
|
||||
|
||||
let passerAi = new PasserAi(passerZone,pathFinder);
|
||||
|
||||
this.anime = null;
|
||||
|
||||
this.modelmanager = new ModelManager();
|
||||
// let loadingInstance = Loading.service({ fullscreen: true });
|
||||
|
||||
this.nowstation = null;
|
||||
|
||||
let stationlist = [];
|
||||
let socktest = null;
|
||||
let passerTrain = new PasserTrain();
|
||||
|
||||
this.modelmanager.loadpromise(Staticmodel, scope.mixers,"2").then(function (data) {
|
||||
console.log(data);
|
||||
passerTrain.initTrain(scope.modelmanager.train.mesh,mixers,deviceaction,scene);
|
||||
passerTrain.toptrain.position.x = 0;
|
||||
passerTrain.toptrain.position.y = 0;
|
||||
passerTrain.toptrain.position.z = 0;
|
||||
// passerTrain.downtrain.position.z = 40;
|
||||
getPublishMapDetail(skinCode).then(netdata => {
|
||||
scope.switchviews('freeview');
|
||||
passerHuman.initHumans(scope.modelmanager.man1.mesh,scope.modelmanager.man2.mesh);
|
||||
scene.add(humanlist);
|
||||
|
||||
socktest = new TrainConnect(scope,deviceaction,passerTrain.toptrain,routegroup,passerAi);
|
||||
|
||||
store.dispatch('app/animationsClose');
|
||||
|
||||
let checkobject = setInterval(function(){
|
||||
|
||||
clearInterval(checkobject);
|
||||
//进站控制
|
||||
startWorker();
|
||||
passerWebWork.postMessage("on");
|
||||
animate();
|
||||
},1000);
|
||||
});
|
||||
|
||||
|
||||
})
|
||||
|
||||
this.changeTrain = function(trainCode){
|
||||
// scope.resetscene();
|
||||
scope.nowTrainCode = trainCode;
|
||||
}
|
||||
|
||||
this.resetscene = function(){
|
||||
aiswitch = 1;
|
||||
passerAi.toppasserin = false;
|
||||
passerAi.downpasserin = false;
|
||||
//下车控制开关
|
||||
passerAi.toppasseron = false;
|
||||
passerAi.downpasseron = false;
|
||||
|
||||
passerTrain.toptrain.nowcode = null;
|
||||
passerTrain.downtrain.nowcode = null;
|
||||
// humanlist = new THREE.Group();
|
||||
for(let j=0; j<humanlist.children.length;j++){
|
||||
|
||||
humanlist.remove(humanlist.children[j]);
|
||||
j--;
|
||||
// j--;
|
||||
}
|
||||
passerTrain.toptrain.position.y = -20000;
|
||||
passerTrain.downtrain.position.y = -20000;
|
||||
|
||||
deviceaction.down.action.reset();
|
||||
deviceaction.down.action.time = deviceaction.down.action._clip.duration;
|
||||
deviceaction.down.action.timeScale = -1;
|
||||
deviceaction.down.action.play();
|
||||
|
||||
deviceaction.top.action.reset();
|
||||
deviceaction.top.action.time = deviceaction.down.action._clip.duration;
|
||||
deviceaction.top.action.timeScale = -1;
|
||||
deviceaction.top.action.play();
|
||||
for(let an=passerTrain.toptrain.action.top.length-1;an>=0;an--){
|
||||
passerTrain.toptrain.action.top[an].reset();
|
||||
passerTrain.toptrain.action.top[an].time = passerTrain.toptrain.action.top[an]._clip.duration;
|
||||
passerTrain.toptrain.action.top[an].timeScale = -1;
|
||||
passerTrain.toptrain.action.top[an].play();
|
||||
}
|
||||
for(let an=passerTrain.toptrain.action.down.length-1;an>=0;an--){
|
||||
passerTrain.toptrain.action.down[an].reset();
|
||||
passerTrain.toptrain.action.down[an].time = passerTrain.toptrain.action.down[an]._clip.duration;
|
||||
passerTrain.toptrain.action.down[an].timeScale = -1;
|
||||
passerTrain.toptrain.action.down[an].play();
|
||||
}
|
||||
// for(let an=actions.length-1;an>=0;an--){
|
||||
// actions[an].reset();
|
||||
// actions[an].time = actions[an]._clip.duration;
|
||||
// actions[an].timeScale = -1;
|
||||
// actions[an].play();
|
||||
// }
|
||||
setTimeout(function(){
|
||||
passerAi.initPasser(humanlist,passerHuman);
|
||||
aiswitch = 0;
|
||||
}, 2000);
|
||||
|
||||
}
|
||||
|
||||
function startWorker(){
|
||||
passerAi.initPasser(humanlist,passerHuman);
|
||||
let updateaianimate = setInterval(
|
||||
function(){
|
||||
// console.log("?");
|
||||
if(aiswitch == 0){
|
||||
passerHuman.moveAnimateUpdate(humanlist,olddataai,passerHuman);
|
||||
// passerAi.aiUpdate(humanlist,passerHuman,passerCheckDoor,deviceaction);
|
||||
|
||||
delta = clock.getDelta();
|
||||
|
||||
for(let i=mixers.length-1;i>=0;i--){
|
||||
if(mixers[i]._actions[0].isRunning()){
|
||||
mixers[i].update( delta );
|
||||
}
|
||||
}
|
||||
for(let i=humanlist.children.length-1;i>=0;i--){
|
||||
if(humanlist.children[i].mixer._actions[0].isRunning()){
|
||||
humanlist.children[i].mixer.update( delta );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
, 100);
|
||||
|
||||
passerWebWork.onmessage = function (event) {
|
||||
if(aiswitch == 0){
|
||||
// console.log(humanlist.children.length);
|
||||
if(humanlist.children.length < 80){
|
||||
let direct = Math.floor(Math.random()*(3-1+1))+1;
|
||||
//1--top
|
||||
//2-- down
|
||||
if(direct == 1){
|
||||
passerHuman.newHumanCreate(humanlist,passerZone.getzoneposition("enter1"),0);
|
||||
}else{
|
||||
passerHuman.newHumanCreate(humanlist,passerZone.getzoneposition("enter2"),0);
|
||||
}
|
||||
if(passerAi.toppasseron){
|
||||
for(let i=0,leni=passerZone.list["standtop"].doorpoints.length;i<leni;i++ ){
|
||||
setTimeout(function(){
|
||||
passerHuman.newHumanCreate(humanlist,passerZone.list["standtop"].doorpoints[i],5,"top",i);
|
||||
}, Math.random()*1000);
|
||||
|
||||
}
|
||||
}
|
||||
if(passerAi.downpasseron){
|
||||
|
||||
for(let i=0,leni=passerZone.list["standdown"].doorpoints.length;i<leni;i++ ){
|
||||
setTimeout(function(){
|
||||
passerHuman.newHumanCreate(humanlist,passerZone.list["standdown"].doorpoints[i],5,"down",i);
|
||||
}, Math.random()*1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
//循环渲染函数
|
||||
function animate() {
|
||||
passerRender.update();
|
||||
|
||||
if(passerRender.state == "freeview"){
|
||||
controls.update();
|
||||
}
|
||||
// delta = clock.getDelta();
|
||||
requestAnimationFrame(animate);
|
||||
|
||||
}
|
||||
|
||||
window.onresize = function () {
|
||||
passerRender.reSize(scope.dom.offsetWidth,scope.dom.offsetHeight);
|
||||
}
|
||||
|
||||
this.switchcamera = function(trunkNum){
|
||||
console.log(passerTrain.toptrain);
|
||||
console.log(camerass.position);
|
||||
console.log(trunkNum);
|
||||
switch (trunkNum) {
|
||||
case '0':
|
||||
camerass.position.x = 21.83;
|
||||
camerass.position.y = 5.29;
|
||||
camerass.position.z = 17.36;
|
||||
controls.target = new THREE.Vector3(camerass.position.x-0.1,camerass.position.y-0.1,camerass.position.z);
|
||||
controls.update();
|
||||
break;
|
||||
case '1':
|
||||
camerass.position.x = 39.83;
|
||||
camerass.position.y = 5.29;
|
||||
camerass.position.z = 17.36;
|
||||
controls.target = new THREE.Vector3(camerass.position.x-0.1,camerass.position.y-0.1,camerass.position.z);
|
||||
controls.update();
|
||||
break;
|
||||
case '2':
|
||||
camerass.position.x = 60.71;
|
||||
camerass.position.y = 5.29;
|
||||
camerass.position.z = 17.36;
|
||||
controls.target = new THREE.Vector3(camerass.position.x-0.1,camerass.position.y-0.1,camerass.position.z);
|
||||
controls.update();
|
||||
break;
|
||||
case '3':
|
||||
camerass.position.x = 82.01;
|
||||
camerass.position.y = 5.29;
|
||||
camerass.position.z = 17.36;
|
||||
controls.target = new THREE.Vector3(camerass.position.x-0.1,camerass.position.y-0.1,camerass.position.z);
|
||||
controls.update();
|
||||
break;
|
||||
case '4':
|
||||
camerass.position.x = 104.06;
|
||||
camerass.position.y = 5.29;
|
||||
camerass.position.z = 17.36;
|
||||
controls.target = new THREE.Vector3(camerass.position.x-0.1,camerass.position.y-0.1,camerass.position.z);
|
||||
controls.update();
|
||||
break;
|
||||
case '5':
|
||||
camerass.position.x = 120.30;
|
||||
camerass.position.y = 5.29;
|
||||
camerass.position.z = 17.36;
|
||||
controls.target = new THREE.Vector3(camerass.position.x-0.1,camerass.position.y-0.1,camerass.position.z);
|
||||
controls.update();
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
this.getTrainList = function(){
|
||||
return scope.trainList;
|
||||
}
|
||||
|
||||
this.switchviews = function(viewmode){
|
||||
passerRender.changeRenderMode(viewmode);
|
||||
}
|
||||
|
||||
}
|
158
src/jlmap3d/jl3dtrafficplan/loader/loader.js
Normal file
158
src/jlmap3d/jl3dtrafficplan/loader/loader.js
Normal file
@ -0,0 +1,158 @@
|
||||
import { BASE_ASSET_API } from '@/api/jlmap3d/assets3d.js';
|
||||
//模型管理器
|
||||
let mode = "0";
|
||||
export function ModelManager(){
|
||||
let scope = this;
|
||||
this.man1 = {
|
||||
code:null,
|
||||
locateType:"01",
|
||||
mesh:null,
|
||||
action:null
|
||||
};
|
||||
this.man2 = {
|
||||
code:null,
|
||||
locateType:"01",
|
||||
mesh:null,
|
||||
action:null
|
||||
};
|
||||
|
||||
|
||||
this.station = {
|
||||
code:null,
|
||||
screenDoorOpenStatus:"01",
|
||||
animations:null,
|
||||
mesh:null,
|
||||
action:null
|
||||
};
|
||||
|
||||
this.zhajiin = {
|
||||
code:null,
|
||||
screenDoorOpenStatus:"01",
|
||||
animations:null,
|
||||
mesh:null,
|
||||
action:null
|
||||
};
|
||||
this.zhajiout = {
|
||||
code:null,
|
||||
screenDoorOpenStatus:"01",
|
||||
animations:null,
|
||||
mesh:null,
|
||||
action:null
|
||||
};
|
||||
|
||||
this.monitor = {
|
||||
code:null,
|
||||
screenDoorOpenStatus:"01",
|
||||
animations:null,
|
||||
mesh:null,
|
||||
action:null
|
||||
};
|
||||
|
||||
this.train = {
|
||||
code:null,
|
||||
screenDoorOpenStatus:"01",
|
||||
animations:null,
|
||||
mesh:null,
|
||||
action:null
|
||||
};
|
||||
|
||||
|
||||
this.section = {
|
||||
code:null,
|
||||
screenDoorOpenStatus:"01",
|
||||
animations:null,
|
||||
mesh:null,
|
||||
action:null
|
||||
};
|
||||
|
||||
//读取模型
|
||||
this.loadpromise = function (data,mixers,loadmode){
|
||||
mode = loadmode;
|
||||
let initlist = [];
|
||||
for(let i=0,leni=data.length;i<leni;i++){
|
||||
if(data[i].type == "man1" || data[i].type == "cctvMan1"){
|
||||
initlist.push(fbxpromise(data[i],mixers,scope.man1));
|
||||
}
|
||||
if(data[i].type == "man2" || data[i].type == "cctvMan2"){
|
||||
initlist.push(fbxpromise(data[i],mixers,scope.man2));
|
||||
}
|
||||
if(data[i].type == "cctvStation"){
|
||||
initlist.push(fbxpromise(data[i],mixers,scope.station));
|
||||
}
|
||||
if(data[i].type == "cctvGateIn"){
|
||||
initlist.push(fbxpromise(data[i],mixers,scope.zhajiin));
|
||||
}
|
||||
if(data[i].type == "cctvGateOut"){
|
||||
initlist.push(fbxpromise(data[i],mixers,scope.zhajiout));
|
||||
}
|
||||
if(data[i].type == "cctvMonitor"){
|
||||
initlist.push(fbxpromise(data[i],mixers,scope.monitor));
|
||||
}
|
||||
if(data[i].type == "cctvTrain"){
|
||||
initlist.push(fbxpromise(data[i],mixers,scope.train));
|
||||
}
|
||||
if(data[i].type == "cctvSection"){
|
||||
initlist.push(fbxpromise(data[i],mixers,scope.section));
|
||||
}
|
||||
}
|
||||
//promise按顺序加载
|
||||
return new Promise(function(resolve, reject){
|
||||
|
||||
Promise.all(initlist).then((result) => {
|
||||
console.log("success");
|
||||
resolve("success"); //['成功了', 'success']
|
||||
}).catch((error) => {
|
||||
//console.log(error);
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
//fbx模型加载
|
||||
function fbxpromise(asset,mixers,model){
|
||||
return new Promise(function(resolve, reject){
|
||||
var loader = new THREE.FBXLoader();
|
||||
if( mode == "2"){
|
||||
|
||||
loader.load( asset.url, function ( object ) {
|
||||
|
||||
model.mesh = object;
|
||||
|
||||
resolve(asset.deviceType);
|
||||
} );
|
||||
|
||||
}else{
|
||||
loader.load( BASE_ASSET_API+asset.url, function ( object ) {
|
||||
|
||||
//列车模型子物体重新排序
|
||||
if(asset.type == "cctvTrain"){
|
||||
// let mixer = new THREE.AnimationMixer( object );
|
||||
let realtrain = new THREE.Group();
|
||||
for(let j=6;j>0;j--){
|
||||
let name = "c"+j;
|
||||
for(let i=0;i<object.children.length;i++){
|
||||
if(object.children[i].name == name){
|
||||
|
||||
object.children[i].position.x = object.children[i].position.x;
|
||||
//object.children[i].position.y = j*10;
|
||||
realtrain.add(object.children[i]);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
model.mesh = realtrain;
|
||||
model.mesh.animations = object.animations[0].tracks;
|
||||
//
|
||||
}else{
|
||||
model.mesh = object;
|
||||
|
||||
}
|
||||
|
||||
resolve(asset.deviceType);
|
||||
} );
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
}
|
71
src/jlmap3d/jl3dtrafficplan/loader/stationconfig.js
Normal file
71
src/jlmap3d/jl3dtrafficplan/loader/stationconfig.js
Normal file
@ -0,0 +1,71 @@
|
||||
import { JL3D_LOCAL_STATIC } from '@/api/jlmap3d/assets3d.js';
|
||||
var Staticmodel = {
|
||||
man1: {
|
||||
id: "1",
|
||||
name: "人物1",
|
||||
deviceType: "man",
|
||||
type: "man",
|
||||
picUrl: "",
|
||||
assetUrl: JL3D_LOCAL_STATIC+"/MODEL/passflow/man1.FBX"
|
||||
},//"https://joylink.club/oss/wx/switch/switch.FBX"
|
||||
man2: {
|
||||
id: "2",
|
||||
name: "人物2",
|
||||
deviceType: "man",
|
||||
type: "man",
|
||||
picUrl: "",
|
||||
assetUrl: JL3D_LOCAL_STATIC+"/MODEL/passflow/man2.FBX"
|
||||
},
|
||||
station: {
|
||||
id: "3",
|
||||
name: "车站",
|
||||
deviceType: "station",
|
||||
type: "hrb",
|
||||
picUrl: "",
|
||||
assetUrl: JL3D_LOCAL_STATIC+"/MODEL/passflow/station.FBX"
|
||||
},
|
||||
zhajiin: {
|
||||
id: "4",
|
||||
name: "闸机",
|
||||
deviceType: "zhajiin",
|
||||
type: "hrb",
|
||||
picUrl: "",
|
||||
assetUrl: JL3D_LOCAL_STATIC+"/MODEL/passflow/zhajiin.FBX"
|
||||
},
|
||||
zhajiout: {
|
||||
id: "5",
|
||||
name: "闸机",
|
||||
deviceType: "zhajiout",
|
||||
type: "hrb",
|
||||
picUrl: "",
|
||||
assetUrl: JL3D_LOCAL_STATIC+"/MODEL/passflow/zhajiout.FBX"
|
||||
},
|
||||
monitor: {
|
||||
id: "6",
|
||||
name: "摄像机",
|
||||
deviceType: "monitor",
|
||||
type: "hrb",
|
||||
picUrl: "",
|
||||
assetUrl: JL3D_LOCAL_STATIC+"/MODEL/passflow/monitor.FBX"
|
||||
},
|
||||
train: {
|
||||
id: "7",
|
||||
name: "列车",
|
||||
deviceType: "train",
|
||||
type: "hrb",
|
||||
picUrl: "",
|
||||
assetUrl: JL3D_LOCAL_STATIC+"/MODEL/train/train.FBX"
|
||||
},
|
||||
section: {
|
||||
id: "8",
|
||||
name: "区段",
|
||||
deviceType: "section",
|
||||
type: "hrb",
|
||||
picUrl: "",
|
||||
assetUrl: JL3D_LOCAL_STATIC+"/MODEL/passflow/section.FBX"
|
||||
},
|
||||
|
||||
|
||||
}
|
||||
|
||||
export { Staticmodel }
|
27
src/jlmap3d/jl3dtrafficplan/loader/trainconfig.js
Normal file
27
src/jlmap3d/jl3dtrafficplan/loader/trainconfig.js
Normal file
@ -0,0 +1,27 @@
|
||||
import { JL3D_LOCAL_STATIC } from '@/api/jlmap3d/assets3d.js';
|
||||
var Staticmodel = [
|
||||
{
|
||||
id: "1",
|
||||
name: "人物1",
|
||||
deviceType: "man1",
|
||||
type: "man1",
|
||||
url: "/cbtc/static/trafficplan/man1.FBX"
|
||||
},
|
||||
{
|
||||
id: "2",
|
||||
name: "人物2",
|
||||
deviceType: "man2",
|
||||
type: "man2",
|
||||
url: "/cbtc/static/trafficplan/man2.FBX"
|
||||
},
|
||||
{
|
||||
id: "7",
|
||||
name: "列车",
|
||||
deviceType: "train",
|
||||
type: "cctvTrain",
|
||||
url: "/cbtc/static/trafficplan/train.FBX"
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
export { Staticmodel }
|
230
src/jlmap3d/jl3dtrafficplan/model/passercheckdoor.js
Normal file
230
src/jlmap3d/jl3dtrafficplan/model/passercheckdoor.js
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
297
src/jlmap3d/jl3dtrafficplan/model/passerhuman.js
Normal file
297
src/jlmap3d/jl3dtrafficplan/model/passerhuman.js
Normal file
@ -0,0 +1,297 @@
|
||||
export function PasserHuman() {
|
||||
let scope = this;
|
||||
|
||||
this.humanWaitIn = [];
|
||||
this.humanWaitOut = [];
|
||||
this.humanInSpeed = 0;
|
||||
this.humanOutSpeed = 0;
|
||||
|
||||
//初始人物模型和动画
|
||||
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.newInHuman= function(humanlist,position){
|
||||
if(scope.humanWaitIn.length != 0){
|
||||
let newhuman;
|
||||
createHumanModel(newhuman,humanlist,position,scope.humanWaitIn[0].stage,scope.humanWaitIn[0].direct,scope.humanWaitIn[0].door);
|
||||
scope.humanWaitIn.shift();
|
||||
}
|
||||
}
|
||||
//创建新的出站乘客
|
||||
this.newOutHuman = function(humanlist,position){
|
||||
if(scope.humanWaitOut.length != 0){
|
||||
let newhuman;
|
||||
createHumanModel(newhuman,humanlist,position,scope.humanWaitOut[0].stage,scope.humanWaitOut[0].direct,scope.humanWaitOut[0].door);
|
||||
scope.humanWaitOut.shift();
|
||||
}
|
||||
|
||||
}
|
||||
//创建新的乘客
|
||||
this.newHumanCreate = function(humanlist,position,stage,direct,door){
|
||||
let newhuman;
|
||||
createHumanModel(newhuman,humanlist,position,stage,direct,door);
|
||||
}
|
||||
|
||||
function createHumanModel(newhuman,humanlist,position,stage,direct,door){
|
||||
let mantype = Math.floor(Math.random()*(3-1+1))+1;
|
||||
|
||||
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);
|
||||
|
||||
if(newhuman.direct == "top"){
|
||||
newhuman.rotation.y = Math.PI;
|
||||
}
|
||||
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);
|
||||
}
|
||||
//定义新模型走路动画
|
||||
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,topWaitPassers,downWaitPassers,outStationPassers,passerHuman){
|
||||
for(let i=0;i<outStationPassers.children.length;i++){
|
||||
if(outStationPassers.children[i].status == 1){
|
||||
if(outStationPassers.children[i].progress>=1){
|
||||
outStationPassers.children[i].progress = 1;
|
||||
outStationPassers.children[i].action.stop();
|
||||
outStationPassers.children[i].status = 0;
|
||||
|
||||
if(outStationPassers.children[i].stage == 8){
|
||||
passerHuman.uncache(outStationPassers.children[i]);
|
||||
outStationPassers.remove(outStationPassers.children[i]);
|
||||
i--;
|
||||
}else if(outStationPassers.children[i].stage == 7){
|
||||
outStationPassers.children[i].stage = 8;
|
||||
}
|
||||
else if(outStationPassers.children[i].stage == 5){
|
||||
|
||||
outStationPassers.children[i].stage = 7;
|
||||
|
||||
}
|
||||
}else{
|
||||
//根据动画进度获取动画轨迹上点
|
||||
// console.log(i);
|
||||
// console.log(humanlist.children[i].runrail);
|
||||
// console.log(humanlist.children[i].progress);
|
||||
let point = outStationPassers.children[i].runrail.getPointAt(outStationPassers.children[i].progress);
|
||||
|
||||
//更新模型坐标
|
||||
outStationPassers.children[i].position.x = point.x;
|
||||
outStationPassers.children[i].position.y = point.y;
|
||||
outStationPassers.children[i].position.z = point.z;
|
||||
if((outStationPassers.children[i].progress+0.001)<1){
|
||||
let tangent = outStationPassers.children[i].runrail.getPointAt(outStationPassers.children[i].progress+0.001);
|
||||
outStationPassers.children[i].lookAt(new THREE.Vector3(tangent.x,outStationPassers.children[i].position.y,tangent.z));
|
||||
}
|
||||
|
||||
outStationPassers.children[i].progress += outStationPassers.children[i].speed;
|
||||
point = null;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(let i=0;i<topWaitPassers.children.length;i++){
|
||||
if(topWaitPassers.children[i].status == 1){
|
||||
if(topWaitPassers.children[i].progress>=1){
|
||||
topWaitPassers.children[i].progress = 1;
|
||||
topWaitPassers.children[i].action.stop();
|
||||
topWaitPassers.children[i].status = 0;
|
||||
|
||||
if(topWaitPassers.children[i].stage == 4){
|
||||
passerHuman.uncache(topWaitPassers.children[i]);
|
||||
topWaitPassers.remove(topWaitPassers.children[i]);
|
||||
i--;
|
||||
}
|
||||
}else{
|
||||
//根据动画进度获取动画轨迹上点
|
||||
// console.log(i);
|
||||
// console.log(humanlist.children[i].runrail);
|
||||
// console.log(humanlist.children[i].progress);
|
||||
let point = topWaitPassers.children[i].runrail.getPointAt(topWaitPassers.children[i].progress);
|
||||
|
||||
//更新模型坐标
|
||||
topWaitPassers.children[i].position.x = point.x;
|
||||
topWaitPassers.children[i].position.y = point.y;
|
||||
topWaitPassers.children[i].position.z = point.z;
|
||||
if((topWaitPassers.children[i].progress+0.001)<1){
|
||||
let tangent = topWaitPassers.children[i].runrail.getPointAt(topWaitPassers.children[i].progress+0.001);
|
||||
topWaitPassers.children[i].lookAt(new THREE.Vector3(tangent.x,topWaitPassers.children[i].position.y,tangent.z));
|
||||
}
|
||||
|
||||
topWaitPassers.children[i].progress += topWaitPassers.children[i].speed;
|
||||
point = null;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(let i=0;i<downWaitPassers.children.length;i++){
|
||||
if(downWaitPassers.children[i].status == 1){
|
||||
if(downWaitPassers.children[i].progress>=1){
|
||||
downWaitPassers.children[i].progress = 1;
|
||||
downWaitPassers.children[i].action.stop();
|
||||
downWaitPassers.children[i].status = 0;
|
||||
if(downWaitPassers.children[i].stage == 4){
|
||||
passerHuman.uncache(downWaitPassers.children[i]);
|
||||
downWaitPassers.remove(downWaitPassers.children[i]);
|
||||
i--;
|
||||
}
|
||||
}else{
|
||||
//根据动画进度获取动画轨迹上点
|
||||
// console.log(i);
|
||||
// console.log(humanlist.children[i].runrail);
|
||||
// console.log(humanlist.children[i].progress);
|
||||
let point = downWaitPassers.children[i].runrail.getPointAt(downWaitPassers.children[i].progress);
|
||||
|
||||
//更新模型坐标
|
||||
downWaitPassers.children[i].position.x = point.x;
|
||||
downWaitPassers.children[i].position.y = point.y;
|
||||
downWaitPassers.children[i].position.z = point.z;
|
||||
if((downWaitPassers.children[i].progress+0.001)<1){
|
||||
let tangent = downWaitPassers.children[i].runrail.getPointAt(downWaitPassers.children[i].progress+0.001);
|
||||
downWaitPassers.children[i].lookAt(new THREE.Vector3(tangent.x,downWaitPassers.children[i].position.y,tangent.z));
|
||||
}
|
||||
|
||||
downWaitPassers.children[i].progress += downWaitPassers.children[i].speed;
|
||||
point = null;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 == 3){
|
||||
|
||||
humanlist.children[i].stage = 4;
|
||||
if(humanlist.children[i].direct == "top"){
|
||||
topWaitPassers.add(humanlist.children[i]);
|
||||
i--;
|
||||
}else if(humanlist.children[i].direct == "down"){
|
||||
downWaitPassers.add(humanlist.children[i]);
|
||||
i--;
|
||||
}
|
||||
|
||||
}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();
|
||||
}
|
||||
} );
|
||||
}
|
||||
}
|
||||
}
|
176
src/jlmap3d/jl3dtrafficplan/model/passerstation.js
Normal file
176
src/jlmap3d/jl3dtrafficplan/model/passerstation.js
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
121
src/jlmap3d/jl3dtrafficplan/model/passertrain.js
Normal file
121
src/jlmap3d/jl3dtrafficplan/model/passertrain.js
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
295
src/jlmap3d/jl3dtrafficplan/model/zonemanager.js
Normal file
295
src/jlmap3d/jl3dtrafficplan/model/zonemanager.js
Normal file
@ -0,0 +1,295 @@
|
||||
import { ZoneModel } from '@/jlmap3d/jl3dpassflow/model/zonemodel.js';
|
||||
//进站区域1
|
||||
let enter1 = {
|
||||
code : '001',
|
||||
name : "enter1",
|
||||
type : "normal",
|
||||
stage : "0",
|
||||
randompoint : new THREE.Vector3(26.6,9.8,-2.7),
|
||||
railpoints : [
|
||||
new THREE.Vector3(34,9.8,-6),
|
||||
new THREE.Vector3(32,9.8,-6)
|
||||
]
|
||||
};
|
||||
//进站区域2
|
||||
let enter2 = {
|
||||
code : '002',
|
||||
name : "enter2",
|
||||
type : "normal",
|
||||
stage : "0",
|
||||
randompoint : new THREE.Vector3(27,9.8,16),
|
||||
railpoints : [
|
||||
new THREE.Vector3(34,9.8,31.5),
|
||||
new THREE.Vector3(32,9.8,31.5)
|
||||
]
|
||||
};
|
||||
//安检区域
|
||||
let security = {
|
||||
code : '003',
|
||||
name : "security",
|
||||
type : "device",
|
||||
stage : "1",
|
||||
randompoint : new THREE.Vector3(8.8,9.8,18),
|
||||
railpoints : [
|
||||
new THREE.Vector3(20.5,9.8,18),
|
||||
new THREE.Vector3(21,9.8,21)
|
||||
]
|
||||
};
|
||||
//进方向闸机区域
|
||||
let entergate = {
|
||||
code : '004',
|
||||
name : "entergate",
|
||||
type : "device",
|
||||
stage : "2",
|
||||
randompoint : new THREE.Vector3(2.3,9.8,13),
|
||||
railpoints : [
|
||||
new THREE.Vector3(6.3,9.8,18.1),
|
||||
new THREE.Vector3(4.8,9.8,18.1),
|
||||
new THREE.Vector3(3.4,9.8,18.1),
|
||||
new THREE.Vector3(2.1,9.8,18.1),
|
||||
new THREE.Vector3(0.7,9.8,18.1)
|
||||
]
|
||||
};
|
||||
//站台上车区域
|
||||
let standtop = {
|
||||
code : '005',
|
||||
name : "standtop",
|
||||
type : "stand",
|
||||
stage : "3",
|
||||
randompoint : new THREE.Vector3(-64,1.77,0.38),
|
||||
doorpoints:[
|
||||
new THREE.Vector3(-62.84,1.77,-4.38),
|
||||
new THREE.Vector3(-58.11,1.77,-4.38),
|
||||
new THREE.Vector3(-53.47,1.77,-4.38),
|
||||
new THREE.Vector3(-45.45,1.77,-4.38),
|
||||
new THREE.Vector3(-41.1,1.77,-4.38),
|
||||
new THREE.Vector3(-36.33,1.77,-4.38),
|
||||
new THREE.Vector3(-31.5,1.77,-4.38),
|
||||
new THREE.Vector3(-23.65,1.77,-4.38),
|
||||
new THREE.Vector3(-18.98,1.77,-4.38),
|
||||
new THREE.Vector3(-14.46,1.77,-4.38),
|
||||
new THREE.Vector3(-10,1.77,-4.38),
|
||||
new THREE.Vector3(-2.2,1.77,-4.38),
|
||||
new THREE.Vector3(2.49,1.77,-4.38),
|
||||
new THREE.Vector3(7.17,1.77,-4.38),
|
||||
new THREE.Vector3(11.8,1.77,-4.38),
|
||||
new THREE.Vector3(19.41,1.77,-4.38),
|
||||
new THREE.Vector3(24.09,1.77,-4.38),
|
||||
new THREE.Vector3(28.72,1.77,-4.38),
|
||||
new THREE.Vector3(33.46,1.77,-4.38),
|
||||
new THREE.Vector3(41.24,1.77,-4.38),
|
||||
new THREE.Vector3(45.82,1.77,-4.38),
|
||||
new THREE.Vector3(50.69,1.77,-4.38)
|
||||
],
|
||||
railpoints : [
|
||||
new THREE.Vector3(52.1,1.77,-1.8),
|
||||
new THREE.Vector3(-63.5,1.77,-1.8)
|
||||
]
|
||||
};
|
||||
//站台下车区域
|
||||
let standdown = {
|
||||
code : '006',
|
||||
name : "standdown",
|
||||
type : "stand",
|
||||
stage : "3",
|
||||
randompoint : new THREE.Vector3(-64,1.77,21),
|
||||
doorpoints:[
|
||||
new THREE.Vector3(-62.84,1.77,27),
|
||||
new THREE.Vector3(-58.11,1.77,27),
|
||||
new THREE.Vector3(-53.47,1.77,27),
|
||||
new THREE.Vector3(-45.45,1.77,27),
|
||||
new THREE.Vector3(-41.1,1.77,27),
|
||||
new THREE.Vector3(-36.33,1.77,27),
|
||||
new THREE.Vector3(-31.5,1.77,27),
|
||||
new THREE.Vector3(-23.65,1.77,27),
|
||||
new THREE.Vector3(-18.98,1.77,27),
|
||||
new THREE.Vector3(-14.46,1.77,27),
|
||||
new THREE.Vector3(-10,1.77,27),
|
||||
new THREE.Vector3(-2.2,1.77,27),
|
||||
new THREE.Vector3(2.49,1.77,27),
|
||||
new THREE.Vector3(7.17,1.77,27),
|
||||
new THREE.Vector3(11.8,1.77,27),
|
||||
new THREE.Vector3(19.41,1.77,27),
|
||||
new THREE.Vector3(24.09,1.77,27),
|
||||
new THREE.Vector3(28.72,1.77,27),
|
||||
new THREE.Vector3(33.46,1.77,27),
|
||||
new THREE.Vector3(41.24,1.77,27),
|
||||
new THREE.Vector3(45.82,1.77,27),
|
||||
new THREE.Vector3(50.69,1.77,27)
|
||||
],
|
||||
railpoints : [
|
||||
new THREE.Vector3(52.1,1.77,24),
|
||||
new THREE.Vector3(-64,1.77,24)
|
||||
]
|
||||
};
|
||||
//4是刚下车状态
|
||||
//出方向闸机区域
|
||||
let exitgate = {
|
||||
code : '007',
|
||||
name : "exitgate",
|
||||
type : "device",
|
||||
stage : "5",
|
||||
randompoint : new THREE.Vector3(-16,9.8,-0.4),
|
||||
railpoints : [
|
||||
new THREE.Vector3(18,9.8,-0.27),
|
||||
new THREE.Vector3(18,9.8,1.18),
|
||||
new THREE.Vector3(18,9.8,2.64),
|
||||
new THREE.Vector3(18,9.8,4.1),
|
||||
new THREE.Vector3(18,9.8,5.4)
|
||||
]
|
||||
};
|
||||
//出站台区域1
|
||||
let exit1 = {
|
||||
code : '008',
|
||||
name : "exit1",
|
||||
type : "normal",
|
||||
stage : "6",
|
||||
randompoint : new THREE.Vector3(),
|
||||
railpoints : [
|
||||
new THREE.Vector3(28.2,9.8,-7),
|
||||
new THREE.Vector3(30.5,9.8,-7.4)
|
||||
]
|
||||
};
|
||||
//出站台区域2
|
||||
let exit2 = {
|
||||
code : '009',
|
||||
name : "exit2",
|
||||
type : "normal",
|
||||
stage : "6",
|
||||
randompoint : new THREE.Vector3(),
|
||||
railpoints : [
|
||||
new THREE.Vector3(28.3,9.8,28),
|
||||
new THREE.Vector3(30.2,9.8,28)
|
||||
]
|
||||
};
|
||||
let enternum = 0;
|
||||
let exitnum = 0;
|
||||
//区域管理器
|
||||
export function ZoneManager() {
|
||||
|
||||
var scope = this;
|
||||
|
||||
this.name = "test";
|
||||
|
||||
this.list = [];
|
||||
|
||||
initzone();
|
||||
//初始化区域对象
|
||||
function initzone(){
|
||||
scope.list[enter1.name] = new ZoneModel(enter1);
|
||||
scope.list[enter2.name] = new ZoneModel(enter2);
|
||||
scope.list[security.name] = new ZoneModel(security);
|
||||
scope.list[entergate.name] = new ZoneModel(entergate);
|
||||
scope.list[standtop.name] = new ZoneModel(standtop);
|
||||
scope.list[standdown.name] = new ZoneModel(standdown);
|
||||
scope.list[exitgate.name] = new ZoneModel(exitgate);
|
||||
scope.list[exit1.name] = new ZoneModel(exit1);
|
||||
scope.list[exit2.name] = new ZoneModel(exit2);
|
||||
}
|
||||
//获取区域范围内点
|
||||
this.getinitposition = function(name){
|
||||
// console.log(scope.list[name]);
|
||||
let randompoint = new THREE.Vector3(0,scope.list[name].randompoint.y,0);
|
||||
|
||||
// console.log(randompoint);
|
||||
if(name == "enter1"){
|
||||
randompoint.x = scope.list[name].randompoint.x + Math.random()*8;
|
||||
randompoint.z = scope.list[name].randompoint.z + Math.random()*8;
|
||||
}
|
||||
if(name == "enter2"){
|
||||
randompoint.x = scope.list[name].randompoint.x + Math.random()*8;
|
||||
randompoint.z = scope.list[name].randompoint.z + Math.random()*8;
|
||||
}
|
||||
if(name == "security"){
|
||||
randompoint.x = scope.list[name].randompoint.x + Math.random()*10;
|
||||
randompoint.z = scope.list[name].randompoint.z + Math.random()*2;
|
||||
}
|
||||
if(name == "entergate"){
|
||||
randompoint.x = scope.list[name].randompoint.x + Math.random()*5;
|
||||
randompoint.z = scope.list[name].randompoint.z - Math.random()*2;
|
||||
}
|
||||
if(name == "standtop"){
|
||||
randompoint.x = scope.list[name].randompoint.x + Math.random()*100;
|
||||
randompoint.z = scope.list[name].randompoint.z + Math.random();
|
||||
}
|
||||
if(name == "standdown"){
|
||||
randompoint.x = scope.list[name].randompoint.x + Math.random()*100;
|
||||
randompoint.z = scope.list[name].randompoint.z ;
|
||||
}
|
||||
if(name == "exitgate"){
|
||||
randompoint.x = scope.list[name].randompoint.x + Math.random()*30;
|
||||
randompoint.z = scope.list[name].randompoint.z + Math.random()*5;
|
||||
}
|
||||
// let random = Math.random();
|
||||
return randompoint;
|
||||
}
|
||||
|
||||
this.getstandposition = function(name){
|
||||
let n = Math.round(Math.random()*20);
|
||||
if(n>=1){
|
||||
n=n;
|
||||
}else{
|
||||
n=0;
|
||||
}
|
||||
|
||||
let randompoint = new THREE.Vector3(0,scope.list[name].doorpoints[n].y,0);
|
||||
|
||||
if(name == "standtop"){
|
||||
randompoint.x = scope.list[name].doorpoints[n].x + Math.random()*3;
|
||||
randompoint.z = scope.list[name].doorpoints[n].z +5;
|
||||
}
|
||||
if(name == "standdown"){
|
||||
randompoint.x = scope.list[name].doorpoints[n].x + Math.random()*3;
|
||||
randompoint.z = scope.list[name].doorpoints[n].z -5;
|
||||
}
|
||||
let standdata = {
|
||||
door:n,
|
||||
point:randompoint
|
||||
};
|
||||
return standdata;
|
||||
}
|
||||
|
||||
this.getgateposition = function(name){
|
||||
let randompoint = new THREE.Vector3(0,0,0);
|
||||
|
||||
let standdata = {
|
||||
door:null,
|
||||
point:null
|
||||
};
|
||||
if(name == "entergate"){
|
||||
randompoint.x = scope.list[name].railpoints[enternum].x ;
|
||||
randompoint.y = scope.list[name].railpoints[enternum].y ;
|
||||
randompoint.z = scope.list[name].railpoints[enternum].z ;
|
||||
standdata.door = 4-enternum;
|
||||
enternum += 1;
|
||||
if(enternum>4){
|
||||
enternum = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(name == "exitgate"){
|
||||
randompoint.x = scope.list[name].railpoints[exitnum].x ;
|
||||
randompoint.y = scope.list[name].railpoints[exitnum].y ;
|
||||
randompoint.z = scope.list[name].railpoints[exitnum].z ;
|
||||
standdata.door = 4-exitnum;
|
||||
exitnum += 1;
|
||||
if(exitnum>4){
|
||||
exitnum = 0;
|
||||
}
|
||||
}
|
||||
standdata.point = randompoint;
|
||||
|
||||
return standdata;
|
||||
}
|
||||
|
||||
this.getzoneposition = function(name){
|
||||
// let random = Math.random();
|
||||
let position = scope.list[name].railline.getPointAt(Math.random());
|
||||
return position;
|
||||
}
|
||||
|
||||
this.zoneActionCheck = function(){
|
||||
|
||||
}
|
||||
|
||||
}
|
20
src/jlmap3d/jl3dtrafficplan/model/zonemodel.js
Normal file
20
src/jlmap3d/jl3dtrafficplan/model/zonemodel.js
Normal file
@ -0,0 +1,20 @@
|
||||
export function ZoneModel(data) {
|
||||
var scope = this;
|
||||
//code
|
||||
this.code = data.code;
|
||||
//命名
|
||||
this.name = data.name;
|
||||
this.type = data.type;
|
||||
this.stage = data.stage;
|
||||
this.status = 0;
|
||||
this.randompoint = data.randompoint;
|
||||
//轨迹点
|
||||
this.railpoints = data.railpoints;
|
||||
|
||||
this.railline = new THREE.CatmullRomCurve3(data.railpoints);
|
||||
if(data.doorpoints){
|
||||
this.doorpoints = data.doorpoints;
|
||||
}else{
|
||||
this.doorpoints = null;
|
||||
}
|
||||
}
|
273
src/jlmap3d/jl3dtrafficplan/passerai/passerai.js
Normal file
273
src/jlmap3d/jl3dtrafficplan/passerai/passerai.js
Normal file
@ -0,0 +1,273 @@
|
||||
|
||||
|
||||
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,mode){
|
||||
// console.log(direct);
|
||||
if(direct == "top"){
|
||||
// console.log("toppasser");
|
||||
if(mode == "start"){
|
||||
scope.toppasseron = true;
|
||||
scope.toppasserin = true;
|
||||
}
|
||||
if(mode == "end"){
|
||||
scope.toppasseron = false
|
||||
scope.toppasserin = false;
|
||||
}
|
||||
// scope.toppasseron = true;
|
||||
// setTimeout(function(){
|
||||
// scope.toppasseron = false
|
||||
// scope.toppasserin = true;
|
||||
//
|
||||
// setTimeout(function(){
|
||||
// scope.toppasserin = false;
|
||||
// }, 20000);
|
||||
// }, 5000);
|
||||
}
|
||||
if(direct == "down"){
|
||||
if(mode == "start"){
|
||||
scope.downpasseron = true;
|
||||
scope.downpasserin = true;
|
||||
}
|
||||
if(mode == "end"){
|
||||
scope.downpasseron = false;
|
||||
scope.downpasserin = false;
|
||||
}
|
||||
// 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,topWaitPassers,downWaitPassers,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(topWaitPassers,standdata.point,4,"top",standdata.door);
|
||||
}
|
||||
for(let i=0;i<6;i++){
|
||||
let standdata = passerZone.getstandposition("standdown");
|
||||
passerHuman.newHumanCreate(downWaitPassers,standdata.point,4,"down",standdata.door);
|
||||
}
|
||||
}
|
||||
|
||||
//人物站台阶段更新
|
||||
this.aiUpdate = function(humanlist,topWaitPassers,downWaitPassers,outStationPassers,passerHuman,passerCheckDoor,deviceaction){
|
||||
|
||||
for(let i=0;i<outStationPassers.children.length;i++){
|
||||
if(outStationPassers.children[i].status == 0){
|
||||
//stage = 5 下车
|
||||
if(outStationPassers.children[i].stage == 5){
|
||||
let points = [];
|
||||
points.push(new THREE.Vector3(outStationPassers.children[i].position.x,outStationPassers.children[i].position.y,outStationPassers.children[i].position.z));
|
||||
if(outStationPassers.children[i].direct == "top"){
|
||||
points.push(new THREE.Vector3(outStationPassers.children[i].position.x,outStationPassers.children[i].position.y,outStationPassers.children[i].position.z+5));
|
||||
}
|
||||
if(outStationPassers.children[i].direct == "down"){
|
||||
points.push(new THREE.Vector3(outStationPassers.children[i].position.x,outStationPassers.children[i].position.y,outStationPassers.children[i].position.z-5));
|
||||
}
|
||||
targetPosition = passerZone.getgateposition("exitgate");
|
||||
path = pathFinder.find(points[1],targetPosition.point);
|
||||
outStationPassers.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(outStationPassers.children[i],i,points,i);
|
||||
}
|
||||
|
||||
//stage = 7 出闸机
|
||||
if(outStationPassers.children[i].stage == 7){
|
||||
let points = [];
|
||||
points.push(new THREE.Vector3(outStationPassers.children[i].position.x,outStationPassers.children[i].position.y,outStationPassers.children[i].position.z));
|
||||
points.push(new THREE.Vector3(outStationPassers.children[i].position.x+5,outStationPassers.children[i].position.y,outStationPassers.children[i].position.z));
|
||||
|
||||
passerCheckDoor.checkDoorControl("out",outStationPassers.children[i].door,deviceaction)
|
||||
passerHuman.initMoveAnimate(outStationPassers.children[i],i,points,i);
|
||||
}
|
||||
|
||||
//stage = 8 出站
|
||||
if(outStationPassers.children[i].stage == 8){
|
||||
let direct = Math.floor(Math.random()*(3-1+1))+1;
|
||||
let points = [];
|
||||
points.push(new THREE.Vector3(outStationPassers.children[i].position.x,outStationPassers.children[i].position.y,outStationPassers.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(outStationPassers.children[i],i,points,i);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(let i=0;i<topWaitPassers.children.length;i++){
|
||||
if(topWaitPassers.children[i].status == 0){
|
||||
//stage = 4 上车
|
||||
if(topWaitPassers.children[i].stage == 4){
|
||||
if(scope.toppasserin && topWaitPassers.children[i].direct == "top"){
|
||||
|
||||
|
||||
let points = [];
|
||||
points.push(new THREE.Vector3(topWaitPassers.children[i].position.x,topWaitPassers.children[i].position.y,topWaitPassers.children[i].position.z));
|
||||
|
||||
points.push(passerZone.list["standtop"].doorpoints[topWaitPassers.children[i].door]);
|
||||
|
||||
if(points[1] == undefined){
|
||||
|
||||
}else{
|
||||
passerHuman.initMoveAnimate(topWaitPassers.children[i],i,points,i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(let i=0;i<downWaitPassers.children.length;i++){
|
||||
if(downWaitPassers.children[i].status == 0){
|
||||
//stage = 4 上车
|
||||
if(downWaitPassers.children[i].stage == 4){
|
||||
|
||||
if(scope.downpasserin && downWaitPassers.children[i].direct == "down"){
|
||||
let points = [];
|
||||
points.push(new THREE.Vector3(downWaitPassers.children[i].position.x,downWaitPassers.children[i].position.y,downWaitPassers.children[i].position.z));
|
||||
|
||||
points.push(passerZone.list["standdown"].doorpoints[downWaitPassers.children[i].door]);
|
||||
|
||||
if(points[1] == undefined){
|
||||
|
||||
}else{
|
||||
passerHuman.initMoveAnimate(downWaitPassers.children[i],i,points,i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
69
src/jlmap3d/jl3dtrafficplan/passerai/pathfinder.js
Normal file
69
src/jlmap3d/jl3dtrafficplan/passerai/pathfinder.js
Normal 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;
|
||||
}
|
||||
}
|
@ -17,6 +17,7 @@ const Jlmap3d = () => import('@/views/jlmap3d/drive/jl3ddrive');
|
||||
const Jlmap3dSandbox = () => import('@/views/jlmap3d/simulation/jl3dsimulation');
|
||||
const Jlmap3dPassFlow = () => import('@/views/jlmap3d/passflow/jl3dpassflow');
|
||||
const Jlmap3dTrafficPlan = () => import('@/views/jlmap3d/trafficplan/jl3dtrafficplan');
|
||||
const Jlmap3dTrafficTrain = () => import('@/views/jlmap3d/trafficplan/jl3dtraffictrain');
|
||||
const Jlmap3dModel = () => import('@/views/jlmap3d/device/jl3ddevice');
|
||||
const Jlmap3dMaintainer = () => import('@/views/jlmap3d/maintainer/jl3dmaintainer');
|
||||
const Jlmap3dMaintainerVr = () => import('@/views/jlmap3d/maintainer/jl3dmaintainervr');
|
||||
@ -232,6 +233,12 @@ export const constantRoutes = [
|
||||
component: Jlmap3dTrafficPlan,
|
||||
hidden: true
|
||||
},
|
||||
{
|
||||
path: '/jlmap3d/traffictrain',
|
||||
component: Jlmap3dTrafficTrain,
|
||||
hidden: true
|
||||
},
|
||||
|
||||
{
|
||||
path: '/jlmap3d/devicemodel',
|
||||
component: Jlmap3dModel,
|
||||
|
123
src/views/jlmap3d/trafficplan/component/stationdata.vue
Normal file
123
src/views/jlmap3d/trafficplan/component/stationdata.vue
Normal file
@ -0,0 +1,123 @@
|
||||
<template>
|
||||
<div class="stationdata">
|
||||
<el-row class="tac">
|
||||
<el-col :span="12">
|
||||
<el-menu
|
||||
default-active="2"
|
||||
class="el-menu-vertical-demo datatab"
|
||||
@open="handleOpen"
|
||||
@close="handleClose"
|
||||
background-color="#545c64"
|
||||
text-color="#fff"
|
||||
active-text-color="#ffd04b">
|
||||
|
||||
<el-submenu index="1">
|
||||
<template slot="title">
|
||||
<span>当前车站总人数:</span>
|
||||
<span>{{allPassers}}</span>
|
||||
</template>
|
||||
</el-submenu>
|
||||
|
||||
<el-submenu index="2">
|
||||
<template slot="title">
|
||||
<span>当前进站流量:</span>
|
||||
<span>{{nowInStationPassers}}</span>
|
||||
</template>
|
||||
</el-submenu>
|
||||
|
||||
<!-- <el-submenu index="3">
|
||||
<template slot="title">
|
||||
<span>当前出站客流:</span>
|
||||
<span>{{nowOutStationPassers}}</span>
|
||||
</template>
|
||||
</el-submenu> -->
|
||||
|
||||
<el-submenu index="4">
|
||||
<template slot="title">
|
||||
<span>上行站台等待旅客:</span>
|
||||
<span>{{topWaitPassers}}</span>
|
||||
</template>
|
||||
</el-submenu>
|
||||
|
||||
<el-submenu index="5">
|
||||
<template slot="title">
|
||||
<span>下行站台等待旅客:</span>
|
||||
<span>{{downWaitPassers}}</span>
|
||||
</template>
|
||||
</el-submenu>
|
||||
|
||||
<el-submenu index="6">
|
||||
<template slot="title">
|
||||
<span>其他数据</span>
|
||||
</template>
|
||||
</el-submenu>
|
||||
</el-menu>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
</div>
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
export default {
|
||||
name: 'StationData',
|
||||
components: {
|
||||
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
allPassers:"30人",
|
||||
topWaitPassers:"12人",
|
||||
downWaitPassers:"13人",
|
||||
nowInStationPassers:"15 人/30s",
|
||||
nowOutStationPassers:"0 人",
|
||||
}
|
||||
},
|
||||
beforeDestroy() {
|
||||
|
||||
|
||||
},
|
||||
watch: {
|
||||
|
||||
},
|
||||
methods: {
|
||||
handleOpen(key, keyPath) {
|
||||
console.log(key, keyPath);
|
||||
},
|
||||
handleClose(key, keyPath) {
|
||||
console.log(key, keyPath);
|
||||
},
|
||||
updatePasserData(humanlistdata,topWaitPassersdata,downWaitPassersdata,outStationPassersdata){
|
||||
this.topWaitPassers = topWaitPassersdata+"人";
|
||||
this.downWaitPassers = downWaitPassersdata+"人";
|
||||
// this.nowOutStationPassers = outStationPassersdata+"人";
|
||||
this.allPassers = humanlistdata+topWaitPassersdata+downWaitPassersdata+outStationPassersdata+"人";
|
||||
},
|
||||
updatePasserSpeed(data){
|
||||
this.nowInStationPassers = data.nowInStationPassers+"人/30s";
|
||||
},
|
||||
updatePasserOut(data){
|
||||
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
//this.init();
|
||||
window.updatePasserData = this.updatePasserData;
|
||||
window.updatePasserSpeed = this.updatePasserSpeed;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<style rel="stylesheet/scss" lang="scss" scoped>
|
||||
.stationdata{
|
||||
top:100px;
|
||||
left:0;
|
||||
position: absolute;
|
||||
}
|
||||
.datatab{
|
||||
width:250px;
|
||||
}
|
||||
</style>
|
@ -13,13 +13,15 @@
|
||||
/>
|
||||
</el-select>
|
||||
</div>
|
||||
<Station-Data>
|
||||
</Station-Data>
|
||||
|
||||
<div class="menutop">
|
||||
<!-- <div class="menutop">
|
||||
<el-button-group>
|
||||
<el-button type="primary" @click="switchauto">自由视角</el-button>
|
||||
<!-- <el-button type="primary" @click="switchrender">{{rendermode}}</el-button> -->
|
||||
<el-button type="primary" @click="switchauto">列车车厢视角</el-button>
|
||||
</el-button-group>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<div class="menudown">
|
||||
<el-button-group>
|
||||
<el-button v-show="isCctv" type="primary" @click="back">退出</el-button>
|
||||
@ -32,10 +34,16 @@
|
||||
import Vue from 'vue';
|
||||
import { Jl3dTrafficPlan } from '@/jlmap3d/jl3dtrafficplan/jl3dtrafficplan.js';
|
||||
import { ProjectIcon, loginInfo } from '@/scripts/ProjectConfig';
|
||||
|
||||
import { getSessionStorage } from '@/utils/auth';
|
||||
import { JL3D_LOCAL_STATIC } from '@/api/jlmap3d/assets3d.js';
|
||||
|
||||
import StationData from '@/views/jlmap3d/trafficplan/component/stationdata';
|
||||
|
||||
export default {
|
||||
name: 'TrafficPlan',
|
||||
components: {
|
||||
StationData,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@ -46,6 +54,9 @@ export default {
|
||||
stationlist:[],
|
||||
value:'',
|
||||
isCctv:true,
|
||||
group:'',
|
||||
mapId:'',
|
||||
lineCode:'',
|
||||
loadingProjectList: ['login', 'design', 'xty', 'designxty', 'gzb', 'designxty', 'xadt', 'designxadt', 'drts', 'designdrts']
|
||||
};
|
||||
},
|
||||
@ -53,9 +64,9 @@ export default {
|
||||
code() {
|
||||
return this.$route.query.code;
|
||||
},
|
||||
lineCode() {
|
||||
return this.$route.query.lineCode;
|
||||
}
|
||||
project() {
|
||||
return getSessionStorage('project');
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
|
||||
@ -67,12 +78,14 @@ export default {
|
||||
document.querySelector("link[rel*='icon']").href = loginInfo[this.$route.query.project].linkIcon || ProjectIcon[this.$route.query.project];
|
||||
},
|
||||
mounted() {
|
||||
|
||||
this.init();
|
||||
window.updatestationlist = this.updatestationlist;
|
||||
if (this.$route.query.type == 'CCTV') {
|
||||
this.isCctv = false;
|
||||
}
|
||||
this.group = this.$route.query.group;
|
||||
this.mapId = this.$route.query.mapId;
|
||||
this.lineCode = this.$route.query.lineCode;
|
||||
this.init();
|
||||
window.updatestationlist = this.updatestationlist;
|
||||
if (this.$route.query.type == 'CCTV') {
|
||||
this.isCctv = false;
|
||||
}
|
||||
},
|
||||
|
||||
beforeDestroy() {
|
||||
@ -97,7 +110,17 @@ export default {
|
||||
|
||||
|
||||
switchauto() {
|
||||
this.jl3d.switchviews('freeview');
|
||||
const routeData = this.$router.resolve({
|
||||
path:'/jlmap3d/traffictrain',
|
||||
query:{
|
||||
mapid:this.$route.query.mapid,
|
||||
group:this.group,
|
||||
project: this.project,
|
||||
noPreLogout: true,
|
||||
lineCode:this.lineCode
|
||||
}
|
||||
});
|
||||
window.open(routeData.href, '_blank', 'noopener noreferrer');
|
||||
},
|
||||
updatestationlist(list) {
|
||||
// console.log(list);
|
||||
|
321
src/views/jlmap3d/trafficplan/jl3dtraffictrain.vue
Normal file
321
src/views/jlmap3d/trafficplan/jl3dtraffictrain.vue
Normal file
@ -0,0 +1,321 @@
|
||||
<template>
|
||||
<div class="jl3dtrafficplan">
|
||||
<div id="jl3d" :class="lineCode=='07'?'jl3ddraw':'jl3ddraw1'" />
|
||||
<div class="station" :style="{'background-image': 'url('+localStatic+'/texture/scene.png)'}">
|
||||
<div style="margin-top:5%;font-size: 30px;">当前列车:</div>
|
||||
<el-select v-model="value" class="listmenu" placeholder="请选择列车" @visible-change="updateTrainList" @change="currentsel">
|
||||
<el-option
|
||||
v-for="item in trainlist"
|
||||
:key="item.code"
|
||||
:label="item.code"
|
||||
:value="item.code"
|
||||
|
||||
/>
|
||||
</el-select>
|
||||
</div>
|
||||
<div class="trunklist">
|
||||
<div class="trunk" :class="{active:index==isActive}"
|
||||
:style="{'background-image': 'url('+localStatic+trunkAsse+')'}"
|
||||
v-for="(trunkAsse,index) in trunkAssetList" @click="assetSelect(index)" >
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="traindata">
|
||||
<el-row class="tac">
|
||||
<el-col :span="12">
|
||||
<el-menu
|
||||
default-active="2"
|
||||
class="el-menu-vertical-demo datatab"
|
||||
@open="handleOpen"
|
||||
@close="handleClose"
|
||||
background-color="#545c64"
|
||||
text-color="#fff"
|
||||
active-text-color="#ffd04b">
|
||||
|
||||
<el-submenu index="1">
|
||||
<template slot="title">
|
||||
<span>当前列车乘客总数:</span>
|
||||
<span>{{allPassers}}</span>
|
||||
</template>
|
||||
</el-submenu>
|
||||
|
||||
<el-submenu index="2">
|
||||
<template slot="title">
|
||||
<span>车厢一</span>
|
||||
</template>
|
||||
</el-submenu>
|
||||
|
||||
<el-submenu index="3">
|
||||
<template slot="title">
|
||||
<span>车厢二</span>
|
||||
</template>
|
||||
</el-submenu>
|
||||
|
||||
<el-submenu index="4">
|
||||
<template slot="title">
|
||||
<span>车厢三</span>
|
||||
</template>
|
||||
</el-submenu>
|
||||
|
||||
<el-submenu index="5">
|
||||
<template slot="title">
|
||||
<span>车厢四</span>
|
||||
</template>
|
||||
</el-submenu>
|
||||
|
||||
<el-submenu index="6">
|
||||
<template slot="title">
|
||||
<span>车厢五</span>
|
||||
</template>
|
||||
</el-submenu>
|
||||
|
||||
<el-submenu index="7">
|
||||
<template slot="title">
|
||||
<span>车厢六</span>
|
||||
</template>
|
||||
</el-submenu>
|
||||
|
||||
</el-menu>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="menudown">
|
||||
<el-button-group>
|
||||
<el-button v-show="isCctv" type="primary" @click="back">退出</el-button>
|
||||
</el-button-group>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
<script>
|
||||
import Vue from 'vue';
|
||||
import { Jl3dTrafficTrain } from '@/jlmap3d/jl3dtrafficplan/jl3dtraffictrain.js';
|
||||
import { ProjectIcon, loginInfo } from '@/scripts/ProjectConfig';
|
||||
import { JL3D_LOCAL_STATIC } from '@/api/jlmap3d/assets3d.js';
|
||||
export default {
|
||||
name: 'TrafficTrain',
|
||||
components: {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
||||
isActive:-1,
|
||||
localStatic:JL3D_LOCAL_STATIC,
|
||||
trunkAssetList:[
|
||||
'/trafficplan/trunkhead.png',
|
||||
'/trafficplan/trunkbody.png',
|
||||
'/trafficplan/trunkbody.png',
|
||||
'/trafficplan/trunkbody.png',
|
||||
'/trafficplan/trunkbody.png',
|
||||
'/trafficplan/trunkback.png'
|
||||
],
|
||||
jl3d: null,
|
||||
rendermode:'监控视角',
|
||||
renderswitch:false,
|
||||
trainlist:[],
|
||||
value:'',
|
||||
isCctv:true,
|
||||
allPassers:0+'人',
|
||||
loadingProjectList: ['login', 'design', 'xty', 'designxty', 'gzb', 'designxty', 'xadt', 'designxadt', 'drts', 'designdrts']
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
code() {
|
||||
return this.$route.query.code;
|
||||
},
|
||||
lineCode() {
|
||||
return this.$route.query.lineCode;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
||||
},
|
||||
|
||||
created() {
|
||||
if (this.loadingProjectList.includes(this.$route.query.project)) {
|
||||
this.$store.dispatch('app/transitionAnimations');
|
||||
}
|
||||
document.querySelector("link[rel*='icon']").href = loginInfo[this.$route.query.project].linkIcon || ProjectIcon[this.$route.query.project];
|
||||
},
|
||||
mounted() {
|
||||
|
||||
this.init();
|
||||
if (this.$route.query.type == 'CCTV') {
|
||||
this.isCctv = false;
|
||||
}
|
||||
},
|
||||
|
||||
beforeDestroy() {
|
||||
},
|
||||
methods: {
|
||||
init: function () {
|
||||
// let mapdata = this.$store.state.socket.device;
|
||||
const dom = document.getElementById('jl3d');
|
||||
this.jl3d = new Jl3dTrafficTrain(dom, this.$route.query.mapid, this.$route.query.group, 'normal');
|
||||
},
|
||||
assetSelect(index){
|
||||
// console.log(index);
|
||||
this.isActive=index;
|
||||
this.jl3d.switchcamera(index+'');
|
||||
},
|
||||
|
||||
switchrender() {
|
||||
if (this.renderswitch == true) {
|
||||
this.rendermode = '退出监控';
|
||||
this.renderswitch = false;
|
||||
this.jl3d.switchviews('freeview');
|
||||
} else {
|
||||
this.rendermode = '监控视角';
|
||||
this.renderswitch = true;
|
||||
this.jl3d.switchviews('4views');
|
||||
}
|
||||
},
|
||||
updateTrainList(){
|
||||
this.trainlist = this.jl3d.getTrainList();
|
||||
// console.log(this.trainlist);
|
||||
},
|
||||
currentsel(selVal) {
|
||||
this.jl3d.changeTrain(selVal);
|
||||
this.isActive=0;
|
||||
this.jl3d.switchcamera(0+'');
|
||||
// let oldgroupnum = this.groupnum;
|
||||
// this.value = selVal;
|
||||
},
|
||||
back() {
|
||||
window.close();
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style scoped>
|
||||
/* #jl3d {
|
||||
width: 937px;
|
||||
height: 937px;
|
||||
} */
|
||||
.jl3dtrafficplan{
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
.jl3ddraw1{
|
||||
position: absolute;
|
||||
float: right;
|
||||
top:0%;
|
||||
/* left: 0; */
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: 0;
|
||||
}
|
||||
.jl3ddraw {
|
||||
position: absolute;
|
||||
float: right;
|
||||
top:0%;
|
||||
/* left: 0; */
|
||||
width: 50%;
|
||||
height: 100%;
|
||||
z-index: 0;
|
||||
}
|
||||
.jlReal3d{
|
||||
position: absolute;
|
||||
top:0%;
|
||||
left: 50%;
|
||||
width: 50%;
|
||||
height: 100%;
|
||||
z-index: 0;
|
||||
font-size:0;
|
||||
}
|
||||
.realCctv1{
|
||||
position: absolute;
|
||||
width:50%;
|
||||
height:50%;
|
||||
left:0;
|
||||
top:0;
|
||||
}
|
||||
.realCctv2{
|
||||
position: absolute;
|
||||
width:50%;
|
||||
height:50%;
|
||||
left:50%;
|
||||
top:0;
|
||||
}
|
||||
.realCctv3{
|
||||
position: absolute;
|
||||
width:50%;
|
||||
height:50%;
|
||||
left:0;
|
||||
top:50%;
|
||||
}
|
||||
.realCctv4{
|
||||
position: absolute;
|
||||
width:50%;
|
||||
height:50%;
|
||||
left:50%;
|
||||
top:50%;
|
||||
}
|
||||
.station{
|
||||
width:250px;
|
||||
height:100px;
|
||||
top:0;
|
||||
left:0;
|
||||
text-align: center;
|
||||
/* right:500px; */
|
||||
/* bottom:0; */
|
||||
position: absolute;
|
||||
background-size: 100% 100%;
|
||||
border-radius:10px;
|
||||
}
|
||||
|
||||
.trunklist{
|
||||
width:3%;
|
||||
height:70%;
|
||||
top:150px;
|
||||
left:1%;
|
||||
position: absolute;
|
||||
background-color: #ffffff;
|
||||
border-radius:10px;
|
||||
|
||||
}
|
||||
.trunk{
|
||||
width:95%;
|
||||
height:16.6%;
|
||||
top:0.2%;
|
||||
left:2.5%;
|
||||
position:relative;
|
||||
background-size: 100% 100%;
|
||||
}
|
||||
.active{
|
||||
border-style:solid;
|
||||
border-color: blue;
|
||||
}
|
||||
|
||||
.listmenu{
|
||||
/* top:50%; */
|
||||
}
|
||||
.menutop{
|
||||
top:0;
|
||||
right:0;
|
||||
position:absolute;
|
||||
}
|
||||
.menudown{
|
||||
bottom:0;
|
||||
right:0;
|
||||
position:absolute;
|
||||
}
|
||||
.traindata{
|
||||
top:0;
|
||||
right:0;
|
||||
position: absolute;
|
||||
}
|
||||
.datatab{
|
||||
width:250px;
|
||||
}
|
||||
#canvastexture {
|
||||
position: absolute;
|
||||
float: left;
|
||||
left: 0;
|
||||
z-index: -12;
|
||||
}
|
||||
</style>
|
@ -78,6 +78,10 @@ export default {
|
||||
type:Boolean,
|
||||
require:true
|
||||
},
|
||||
traffictrainShow:{
|
||||
type:Boolean,
|
||||
require:true
|
||||
},
|
||||
scheduleLoadShow:{
|
||||
type:Boolean,
|
||||
require:true
|
||||
@ -111,7 +115,8 @@ export default {
|
||||
practiceDisabled:false,
|
||||
deviceShow: false,
|
||||
drivingShow: false,
|
||||
jl3dtrafficplan:this.$t('display.demon.trafficplan'),
|
||||
jl3dtrafficplan:this.$t('display.demon.trafficplantext'),
|
||||
jl3dtraffictrain:this.$t('display.demon.traffictraintext'),
|
||||
jl3dpassflow:this.$t('display.demon.passengerflow'),
|
||||
jl3dname: this.$t('display.demon.threeDimensionalView'),
|
||||
jl3dmodel: this.$t('display.demon.deviceView')
|
||||
|
BIN
static/trafficplan/man1.FBX
Normal file
BIN
static/trafficplan/man1.FBX
Normal file
Binary file not shown.
BIN
static/trafficplan/man2.FBX
Normal file
BIN
static/trafficplan/man2.FBX
Normal file
Binary file not shown.
BIN
static/trafficplan/train.FBX
Normal file
BIN
static/trafficplan/train.FBX
Normal file
Binary file not shown.
BIN
static/trafficplan/trunkback.png
Normal file
BIN
static/trafficplan/trunkback.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.3 MiB |
BIN
static/trafficplan/trunkbody.png
Normal file
BIN
static/trafficplan/trunkbody.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.7 MiB |
BIN
static/trafficplan/trunkhead.png
Normal file
BIN
static/trafficplan/trunkhead.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.1 MiB |
Loading…
Reference in New Issue
Block a user