This commit is contained in:
joylink_cuiweidong 2020-06-01 17:38:44 +08:00
commit 8eefd599b5
20 changed files with 1690 additions and 1473 deletions

View File

@ -154,6 +154,7 @@ export function JLmapDriving(dom,data,mapId,storemod,translation,routegroup,proj
let assetsdata = JSON.parse(netdata.data.sections);
if(assetsdata.link){
scope.datatype = "old";
// datanew();
// scope.jsonwebwork = new Worker("../../static/workertest/jsonworker.js");
// scope.Subscribe = new Jlmap3dSubscribe(scope,routegroup,scope.jsonwebwork);
// scope.Subscribe.socketon(scope.Subscribe.topic);
@ -165,7 +166,7 @@ export function JLmapDriving(dom,data,mapId,storemod,translation,routegroup,proj
if(trainlisttest){
if(trainlisttest.group){
if(trainlisttest.group.children[0]){
console.log(trainlisttest.group.children[0].name);
// console.log(trainlisttest.group.children[0].name);
updatemmi.updatedrivingcode(trainlisttest.group.children[0].name);
scope.Subscribe.initdrivercode(trainlisttest.group.children[0].name);
for(let k in rails.switchrail){

View File

@ -100,6 +100,7 @@ export function Jl3dDriving(mixers, updatemmi, sound, translation, routegroup) {
//
// }
// console.log(data);
// console.log(data);
switch (data.type) {
case 'Simulation_Driver_Change':
@ -113,6 +114,7 @@ export function Jl3dDriving(mixers, updatemmi, sound, translation, routegroup) {
updatemmi.updatedrivingcode( data.body.code);
break;
case 'Simulation_TrainSpeed':
trainspeed(data);
break;
case 'SJL3D_TrainStatus':

View File

@ -98,6 +98,7 @@ export function Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup,sta
// console.log(data);
if(data.type == "Train_Position"){
// stats.update();
trainrun(data.body);
return;
}

View File

@ -48,6 +48,22 @@ var Staticmodel = {
picUrl: "",
assetUrl: "../../static/model/passflow/monitor.FBX"
},
train: {
id: "7",
name: "列车",
deviceType: "train",
type: "hrb",
picUrl: "",
assetUrl: "../../static/model/train/train.FBX"
},
section: {
id: "8",
name: "区段",
deviceType: "section",
type: "hrb",
picUrl: "",
assetUrl: "../../static/model/passflow/section.FBX"
},
}

View File

@ -12,6 +12,8 @@ import { Pathfinding } from '@/jlmap3d/jl3dpassflow/utils/Pathfinding.js';
// const Pathfinding = window.threePathfinding.Pathfinding;
import { ZoneManager } from '@/jlmap3d/jl3dpassflow/model/zonemanager.js';
import { getPublishMapVersion, getPublishMapDetail,getPublish3dMapDetail} from '@/api/jlmap3d/load3ddata';
import StompClient from '@/utils/sock';
import { Loading } from 'element-ui';
@ -38,7 +40,6 @@ let originhuman1 = null;
let originhuman2 = null;
let originanima1 = null;
let originanima2 = null;
let moveanimatelist = [];
let zhajiin = [];
let zhajiout = [];
@ -144,7 +145,7 @@ var views = [
];
export function Jl3dpassflow(dom) {
export function Jl3dpassflow(dom,skinCode) {
var scope = this;
this.dom = dom;
@ -218,10 +219,6 @@ export function Jl3dpassflow(dom) {
this.selectmodel = null;
const Color = {
GROUND: new THREE.Color( 0x606060 ).convertGammaToLinear( 2.2 ).getHex(),
NAVMESH: new THREE.Color( 0xFFFFFF ).convertGammaToLinear( 2.2 ).getHex(),
};
const ZONE = 'level';
const SPEED = 10;
@ -233,12 +230,35 @@ export function Jl3dpassflow(dom) {
let groupID, path;
const playerPosition = new THREE.Vector3( -3.5, 0.5, 5.5 );
const targetPosition = new THREE.Vector3();
let playerPosition = new THREE.Vector3( -3.5, 0.5, 5.5 );
let targetPosition = new THREE.Vector3();
let pathfinder = new THREE.Pathfinding();
let mouse = new THREE.Vector2();
let raycaster = new THREE.Raycaster();
getPublishMapDetail(skinCode).then(netdata => {
// let assetsdata = JSON.parse(netdata.data.sections);
console.log(netdata);
// if(assetsdata.link){
// scope.datatype = "old";
// scope.jsonwebwork = new Worker("../../static/workertest/jsonworker.js");
// scope.Subscribe = new Jlmap3dSubscribe(scope,routegroup,scope.jsonwebwork);
// scope.Subscribe.socketon(scope.Subscribe.topic);
// SimulationLoad(mapnetdata,scope,netdata.data,mapdata,camera,controls,scenesimulation,storemod);
//
// }else{
// scope.datatype = "new";
// scope.jsonwebworknew = new Worker("../../static/workertest/jsonworkernew.js");
// scope.Subscribe = new Jlmap3dSubscribeNew(scope,routegroup,scope.jsonwebworknew);
// scope.Subscribe.socketon(scope.Subscribe.topic);
// SimulationLoadNew(mapnetdata,scope,netdata.data,mapdata,camera,controls,scenesimulation,storemod);
// }
});
const pathfinder = new THREE.Pathfinding();
const mouse = new THREE.Vector2();
const raycaster = new THREE.Raycaster();
var loader = new THREE.OBJLoader();
@ -250,9 +270,9 @@ export function Jl3dpassflow(dom) {
function ( object ) {
console.time('createZone()');
// console.time('createZone()');
const zone = THREE.Pathfinding.createZone(object.children[0].geometry);
console.timeEnd('createZone()');
// console.timeEnd('createZone()');
pathfinder.setZoneData( ZONE, zone );
@ -301,7 +321,6 @@ export function Jl3dpassflow(dom) {
console.log(intersects[0].point);
targetPosition.copy( intersects[0].point );
originhuman1.position.copy( playerPosition );
// Teleport on ctrl/cmd click or RMB.
if (event.metaKey || event.ctrlKey || event.button === 2) {
@ -320,28 +339,14 @@ export function Jl3dpassflow(dom) {
points.push(path[i]);
}
originhuman1.curve = new THREE.CatmullRomCurve3(points);
originhuman1.curve.curvrtype = "chordal";
originhuman1.curve.curvrtype = "centripetal";
originhuman1.progress = 0;
console.log(path);
}
function tick ( dt ) {
// if ( !level || !(path||[]).length ) return
//
// let targetPosition = path[ 0 ];
// const velocity = targetPosition.clone().sub( playerPosition );
//
// if (velocity.lengthSq() > 0.05 * 0.05) {
// velocity.normalize();
// // Move player to target
// playerPosition.add( velocity.multiplyScalar( dt * SPEED ) );
// // originhuman1.lookAt();
// originhuman1.position.copy( playerPosition );
// } else {
// // Remove node from the path we calculated
// path.shift();
// }
if(originhuman1.curve){
if(originhuman1.progress<1){
let point = originhuman1.curve.getPointAt(originhuman1.progress);
@ -383,7 +388,8 @@ export function Jl3dpassflow(dom) {
initstationanimation(scope.modelmanager.station.mesh);
initzhajiinaimation(scope.modelmanager.zhajiin.mesh);
initzhajioutanimation(scope.modelmanager.zhajiout.mesh);
scene.add(scope.modelmanager.section.mesh);
// scene.add(scope.modelmanager.train.mesh);
level = scope.modelmanager.station.mesh;
monitor = scope.modelmanager.monitor.mesh;
@ -415,45 +421,6 @@ export function Jl3dpassflow(dom) {
scene.add(humanlist);
scene.add(scope.modelmanager.man1.mesh);
for(let i=0;i<200;i++){
var mantype = Math.floor(Math.random()*(3-1+1))+1;
let newhuman;
if(mantype == 1){
newhuman = THREE.SkeletonUtils.clone( originhuman1 );
newhuman.animations = [];
newhuman.animations.push(originanima1.clone());
}else{
newhuman = THREE.SkeletonUtils.clone( originhuman2 );
newhuman.animations = [];
newhuman.animations.push(originanima2.clone());
}
// zhajiin[j].waiting = 1;
let mixer = new THREE.AnimationMixer( newhuman );
mixer.runplay = false;
let action = mixer.clipAction( newhuman.animations[ 0 ] );
newhuman.status = 1;
newhuman.stage = 0;
let newone = {
id:i,
mesh:newhuman,
direct:null,
doorstatus:null,
doors:null,
action:action,
mixer:mixer,
runrail:null
};
humans.push(newone);
mixers.push(mixer);
humanlist.add(newhuman);
}
}
@ -466,8 +433,8 @@ export function Jl3dpassflow(dom) {
clearInterval(checkobject);
//进站控制
startWorker();
// stationwebwork.postMessage("on");
// passerwebwork.postMessage("on");
stationwebwork.postMessage("on");
passerwebwork.postMessage("on");
};
},1000);
@ -488,123 +455,40 @@ export function Jl3dpassflow(dom) {
}
}
function initpasser(){
for(let i=0;i<3;i++){
newhumancreate(stationzon.getinitposition("enter1"),0);
}
for(let i=0;i<3;i++){
newhumancreate(stationzon.getinitposition("enter2"),0);
}
for(let i=0;i<3;i++){
newhumancreate(stationzon.getinitposition("security"),1);
}
for(let i=0;i<2;i++){
newhumancreate(stationzon.getinitposition("entergate"),2);
}
for(let i=0;i<6;i++){
newhumancreate(stationzon.getinitposition("standtop"),3);
}
for(let i=0;i<6;i++){
newhumancreate(stationzon.getinitposition("standdown"),3);
}
for(let i=0;i<5;i++){
newhumancreate(stationzon.getinitposition("exitgate"),4);
}
console.log(humanlist);
}
function startWorker(){
initpasser();
passerwebwork.onmessage = function (event) {
if(humans){
// console.log(humans.length);
// console.log(humans.length);
for(let i=0;i<humans.length;i++){
// console.log(humans[i]);
if(humans[i].status == 0){
if(humans[i].stage == 1){
let points = [];
points.push(new THREE.Vector3(humans[i].mesh.position.x,humans[i].mesh.position.y,humans[i].mesh.position.z));
points.push(new THREE.Vector3(humans[i].mesh.position.x,humans[i].mesh.position.y,humans[i].mesh.position.z-5));
zhajicontrol("in",humans[i].doors);
moveanimateinit(humans[i],i,points,i,0.02);
}
if(humans[i].stage == 2){
let points = [];
points.push(new THREE.Vector3(humans[i].mesh.position.x,humans[i].mesh.position.y,humans[i].mesh.position.z));
points.push(new THREE.Vector3(12,10,12.9));
points.push(new THREE.Vector3(28,1.7,12.9));
points.push(new THREE.Vector3(34,1.7,12.9));
//1--left
//2-- right
if(humans[i].direct == 1){
points.push(new THREE.Vector3(34,1.7,16));
for(let j =0;j<22;j++){
if(stationleft[j].waiting == 0){
points.push(new THREE.Vector3(51-j*5,1.7,22));
points.push(new THREE.Vector3(51-j*5,1.7,23));
humans[i].doors = j;
stationright[j].waiting = 1;
moveanimateinit(humans[i],i,points,i,0.002);
j =22;
}
}
}else{
points.push(new THREE.Vector3(34,1.7,16));
points.push(new THREE.Vector3(14,1.7,17));
points.push(new THREE.Vector3(14,1.7,3));
for(let j =0;j<22;j++){
if(stationright[j].waiting == 0){
points.push(new THREE.Vector3(51-j*5,1.7,3));
points.push(new THREE.Vector3(51-j*5,1.7,2));
humans[i].doors = j;
stationright[j].waiting = 1;
moveanimateinit(humans[i],i,points,i,0.002);
j =22;
}
}
}
moveanimateinit(humans[i],i,points,i,0.002);
}
//出站
if(humans[i].stage == 3){
let points = [];
points.push(new THREE.Vector3(humans[i].mesh.position.x,humans[i].mesh.position.y,humans[i].mesh.position.z));
if(humans[i].doors<11){
if(humans[i].direct == 1){
points.push(new THREE.Vector3(10,1.7,17));
}else{
points.push(new THREE.Vector3(8,1.7,5));
}
points.push(new THREE.Vector3(8,1.7,13));
points.push(new THREE.Vector3(5,1.7,13));
points.push(new THREE.Vector3(-4,6,13));
}else{
if(humans[i].direct == 1){
points.push(new THREE.Vector3(-19,1.7,17));
}else{
points.push(new THREE.Vector3(-18,1.7,6.4));
}
points.push(new THREE.Vector3(-18,1.7,13));
points.push(new THREE.Vector3(-12,1.7,13));
points.push(new THREE.Vector3(-7,6.8,12));
}
points.push(new THREE.Vector3(-5,10,4));
points.push(new THREE.Vector3(14,10,3));
var j = Math.floor(Math.random()*(4-1+1))+1;
points.push(new THREE.Vector3(19,10,-2+j*1.4));
humans[i].doors = j;
moveanimateinit(humans[i],i,points,i,0.002);
}
if(humans[i].stage == 4){
let points = [];
points.push(new THREE.Vector3(humans[i].mesh.position.x,humans[i].mesh.position.y,humans[i].mesh.position.z));
points.push(new THREE.Vector3(humans[i].mesh.position.x+4,humans[i].mesh.position.y,humans[i].mesh.position.z));
if(humans[i].direct == 1){
points.push(new THREE.Vector3(33,10,25));
}else{
points.push(new THREE.Vector3(33.5,10,-5));
}
zhajicontrol("out",humans[i].doors);
moveanimateinit(humans[i],i,points,i,0.002);
}
}
}
}
moveanimateupdate();
// delta = clock.getDelta();
// tick(delta);
passerai();
if(mixers[i]._actions[0].isRunning()){
mixers[i].update( delta );
}
delta = clock.getDelta();
// tick(delta);
for(let i=mixers.length-1;i>=0;i--){
if(mixers[i]._actions[0].isRunning()){
@ -615,9 +499,17 @@ export function Jl3dpassflow(dom) {
};
stationwebwork.onmessage = function (event) {
// console.log("stationwebwork");
if(humans.length<200){
newhumancreate();
// if(humans.length<200){
var direct = Math.floor(Math.random()*(3-1+1))+1;
//1--top
//2-- down
if(direct == 1){
newhumancreate(stationzon.getzoneposition("enter1"),0);
}else{
newhumancreate(stationzon.getzoneposition("enter2"),0);
}
// }
};
}
@ -632,125 +524,272 @@ export function Jl3dpassflow(dom) {
monitorrender();
}
delta = clock.getDelta();
tick(delta);
// delta = clock.getDelta();
// tick(delta);
requestAnimationFrame(animate);
}
function moveanimateinit(model,name,points,index,speed){
function passerai(){
for(let i=0;i<humanlist.children.length;i++){
// console.log(humans[i]);
if(humanlist.children[i].status == 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));
groupID = pathfinder.getGroup( ZONE, points[0] );
targetPosition = stationzon.getzoneposition("security");
path = pathfinder.findPath( points[0], targetPosition, ZONE, groupID );
for(let i=0;i<path.length;i++){
points.push(new THREE.Vector3(path[i].x,path[i].y,path[i].z));
}
moveanimateinit(humanlist.children[i],i,points,i);
// console.log(path);
}
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));
groupID = pathfinder.getGroup( ZONE, points[0] );
targetPosition = stationzon.getzoneposition("entergate");
path = pathfinder.findPath( points[0], targetPosition, ZONE, groupID );
for(let i=0;i<path.length;i++){
points.push(new THREE.Vector3(path[i].x,path[i].y,path[i].z));
}
moveanimateinit(humanlist.children[i],i,points,i);
}
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));
// zhajicontrol("in",humans[i].doors);
moveanimateinit(humanlist.children[i],i,points,i);
}
if(humanlist.children[i].stage == 3){
var direct = Math.floor(Math.random()*(3-1+1))+1;
let points = [];
points.push(new THREE.Vector3(humanlist.children[i].position.x,humanlist.children[i].position.y,humanlist.children[i].position.z));
//1--top
//2-- down
if(direct == 1){
groupID = pathfinder.getGroup( ZONE, points[0] );
targetPosition = stationzon.getzoneposition("standtop");
path = pathfinder.findPath( points[0], targetPosition, ZONE, groupID );
}else{
groupID = pathfinder.getGroup( ZONE, points[0] );
targetPosition = stationzon.getzoneposition("standdown");
path = pathfinder.findPath( points[0], targetPosition, ZONE, groupID );
}
if(path == null){
console.log(points);
console.log(path);
}
for(let i=0;i<path.length;i++){
points.push(new THREE.Vector3(path[i].x,path[i].y,path[i].z));
}
moveanimateinit(humanlist.children[i],i,points,i);
}
// //出站
// if(humanlist.children[i].stage == 3){
// // let points = [];
// // points.push(new THREE.Vector3(humans[i].mesh.position.x,humans[i].mesh.position.y,humans[i].mesh.position.z));
// // if(humans[i].doors<11){
// // if(humans[i].direct == 1){
// // points.push(new THREE.Vector3(10,1.7,17));
// // }else{
// // points.push(new THREE.Vector3(8,1.7,5));
// // }
// // points.push(new THREE.Vector3(8,1.7,13));
// // points.push(new THREE.Vector3(5,1.7,13));
// // points.push(new THREE.Vector3(-4,6,13));
// // }else{
// // if(humans[i].direct == 1){
// // points.push(new THREE.Vector3(-19,1.7,17));
// // }else{
// // points.push(new THREE.Vector3(-18,1.7,6.4));
// // }
// // points.push(new THREE.Vector3(-18,1.7,13));
// // points.push(new THREE.Vector3(-12,1.7,13));
// // points.push(new THREE.Vector3(-7,6.8,12));
// // }
// // points.push(new THREE.Vector3(-5,10,4));
// // points.push(new THREE.Vector3(14,10,3));
// // var j = Math.floor(Math.random()*(4-1+1))+1;
// // points.push(new THREE.Vector3(19,10,-2+j*1.4));
// //
// // humans[i].doors = j;
// // moveanimateinit(humans[i],i,points,i,0.002);
// }
if(humanlist.children[i].stage == 4){
let points = [];
points.push(new THREE.Vector3(humanlist.children[i].position.x,humanlist.children[i].position.y,humanlist.children[i].position.z));
groupID = pathfinder.getGroup( ZONE, points[0] );
targetPosition = stationzon.getzoneposition("exitgate");
path = pathfinder.findPath( points[0], targetPosition, ZONE, groupID );
if(path == null){
console.log(points[0]);
console.log(targetPosition);
}
for(let i=0;i<path.length;i++){
points.push(new THREE.Vector3(path[i].x,path[i].y,path[i].z));
}
moveanimateinit(humanlist.children[i],i,points,i);
}
if(humanlist.children[i].stage == 5){
let points = [];
points.push(new THREE.Vector3(humanlist.children[i].position.x,humanlist.children[i].position.y,humanlist.children[i].position.z));
points.push(new THREE.Vector3(humanlist.children[i].position.x+5,humanlist.children[i].position.y,humanlist.children[i].position.z));
// zhajicontrol("in",humans[i].doors);
moveanimateinit(humanlist.children[i],i,points,i);
}
if(humanlist.children[i].stage == 6){
var direct = Math.floor(Math.random()*(3-1+1))+1;
let points = [];
points.push(new THREE.Vector3(humanlist.children[i].position.x,humanlist.children[i].position.y,humanlist.children[i].position.z));
//1--top
//2-- down
if(direct == 1){
groupID = pathfinder.getGroup( ZONE, points[0] );
targetPosition = stationzon.getzoneposition("exit1");
path = pathfinder.findPath( points[0], targetPosition, ZONE, groupID );
}else{
groupID = pathfinder.getGroup( ZONE, points[0] );
targetPosition = stationzon.getzoneposition("exit2");
path = pathfinder.findPath( points[0], targetPosition, ZONE, groupID );
}
if(path == null){
console.log(points[0]);
console.log(targetPosition);
}
for(let i=0;i<path.length;i++){
points.push(new THREE.Vector3(path[i].x,path[i].y,path[i].z));
}
moveanimateinit(humanlist.children[i],i,points,i);
}
}
}
}
function moveanimateinit(model,name,points,index){
model.status = 1;
let curve = new THREE.CatmullRomCurve3(points);
curve.curvrtype = "chordal";
curve.curvrtype = "centripetal";
// curve.getLength();
// curve动画轨迹
// progress动画进度
// enable当前动画开关
// speed动画速度
// console.log(curve);
let animate = {
name:index,
index:index,
curve:curve,
progress:0,
directchange:false,
enable:true,
status:"start",
speed:speed,
};
humans[index].runrail = animate;
humans[index].status = 1;
humans[index].action.play();
humans[index].mixer.runplay = true;
moveanimatelist.push(animate);
model.action.play();
model.progress = 0;
model.runrail = curve;
model.speed = 0.1/curve.getLength();
}
function moveanimateupdate(){
if(humans.length>0){
for(let i=0;i<humans.length;i++){
if(humans[i].runrail.enable){
// 动画播放结束
if(humans[i].runrail.progress>=1){
for(let i=0;i<humanlist.children.length;i++){
if(humanlist.children[i].status == 1){
if(humanlist.children[i].progress>=1){
// let point = humans[i].runrail.curve.getPointAt(1);
//更新模型坐标
// console.log(moveanimatelist);
if(humans[i].status == 1){
humans[i].runrail.enable = false;
humans[i].runrail.progress = 1;
humans[i].mixer.runplay = false;
humans[i].action.stop();
humans[i].status = 0;
if(humanlist.children[i].status == 1){
// humanlist.children[i].runrail.enable = false;
if(humans[i].stage == 4){
humanlist.remove(humans[i].mesh);
// humans.splice(i,1);
}
// if(humanlist.children[i].stage == 4){
//
// humanlist.remove(humanlist.children[i].mesh);
// // humans.splice(i,1);
// }
//
if(humans[i].stage == 3){
humanlist.children[i].progress = 1;
// humanlist.children[i].mixer.runplay = false;
humanlist.children[i].action.stop();
humanlist.children[i].status = 0;
if(humans[i].direct == 1){
stationleft[humans[i].doors].waiting = 0;
}else{
stationright[humans[i].doors].waiting = 0;
}
humans[i].stage = 4;
if(humanlist.children[i].stage == 6){
humanlist.remove(humanlist.children[i]);
// humanlist.children[i].stage = 7;
}
if(humans[i].stage == 2){
humans[i].stage = 3;
if(humanlist.children[i].stage == 5){
humanlist.children[i].stage = 6;
}
if(humanlist.children[i].stage == 4){
humanlist.children[i].stage = 5;
}
if(humanlist.children[i].stage == 3){
humanlist.children[i].stage = 4;
}
//
if(humanlist.children[i].stage == 2){
humanlist.children[i].stage = 3;
}
if(humans[i].stage == 1){
if(humanlist.children[i].stage == 1){
humans[i].stage = 2;
humanlist.children[i].stage = 2;
}
if(humans[i].stage == 0){
// console.log(humans[i].doors);
zhajiin[humans[i].doors].waiting = 0;
humans[i].stage = 1;
if(humanlist.children[i].stage == 0){
// // console.log(humans[i].doors);
// zhajiin[humanlist.children[i].doors].waiting = 0;
humanlist.children[i].stage = 1;
}
moveanimatelist.splice(i,1);
}
}else{
//根据动画进度获取动画轨迹上点
let point = humans[i].runrail.curve.getPointAt(humans[i].runrail.progress);
// 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);
//更新模型坐标
humans[i].mesh.position.x = point.x;
humans[i].mesh.position.y = point.y;
humans[i].mesh.position.z = point.z;
if((humans[i].runrail.progress+0.001)<1){
let tangent = humans[i].runrail.curve.getPointAt(humans[i].runrail.progress+0.001);
humans[i].mesh.lookAt(new THREE.Vector3(tangent.x,humans[i].mesh.position.y,tangent.z));
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));
}
humans[i].runrail.progress += humans[i].runrail.speed;
humanlist.children[i].progress += humanlist.children[i].speed;
point = null;
}
}
}
}
}
function newhumancreate(){
var direct = Math.floor(Math.random()*(3-1+1))+1;
function newhumancreate(position,stage,){
var mantype = Math.floor(Math.random()*(3-1+1))+1;
// console.log(direct);
let points = [];
let newhuman;
if(mantype == 1){
newhuman = THREE.SkeletonUtils.clone( originhuman1 );
@ -762,51 +801,21 @@ export function Jl3dpassflow(dom) {
newhuman.animations.push(originanima2.clone());
}
if(direct == 1|| direct == 2){
let testposition = stationzon.getzoneposition("enter1");
newhuman.position.set(32,10,25);
points.push(testposition);
points.push(new THREE.Vector3(26,10,21));
points.push(new THREE.Vector3(18,10,18));
}else{
let testposition = stationzon.getzoneposition("enter2");
newhuman.position.set(32,10,-5);
points.push(testposition);
points.push(new THREE.Vector3(26,10,12));
points.push(new THREE.Vector3(24,10,17));
points.push(new THREE.Vector3(18,10,18));
}
let j = Math.floor(Math.random()*(4-1+1))+1;
points.push(new THREE.Vector3(-0.5+j*1.4,10,18.5));
// zhajiin[j].waiting = 1;
let mixer = new THREE.AnimationMixer( newhuman );
mixer.runplay = false;
let action = mixer.clipAction( newhuman.animations[ 0 ] );
newhuman.position.copy(position);
newhuman.status = 0;
var stationdirection = Math.floor(Math.random()*(2-1+1))+1;
let newone = {
id:humans.length,
mesh:newhuman,
status:1,
stage:0,
direct:stationdirection,
doorstatus:null,
doors:j,
action:action,
mixer:mixer,
runrail:null
};
humans.push(newone);
newhuman.stage = stage;
newhuman.direct = null;
newhuman.doorstatus = null;
newhuman.doors = null;
newhuman.action = mixer.clipAction( newhuman.animations[ 0 ] );
newhuman.mixer = mixer;
newhuman.runrail = null;
newhuman.speed = 0;
mixers.push(mixer);
humanlist.add(newhuman);
moveanimateinit(newone,humans.length,points,newone.id,0.002);
// return newone;
}
function initstationanimation(object){

View File

@ -44,6 +44,22 @@ export function ModelManager(){
action:null
};
this.train = {
code:null,
screenDoorOpenStatus:"01",
mesh:null,
action:null
};
this.section = {
code:null,
screenDoorOpenStatus:"01",
mesh:null,
action:null
};
this.loadpromise = function (data,mixers){
let initlist = [];
initlist.push(fbxpromise(data.man1,mixers,scope.man1));
@ -52,6 +68,8 @@ export function ModelManager(){
initlist.push(fbxpromise(data.zhajiin,mixers,scope.zhajiin));
initlist.push(fbxpromise(data.zhajiout,mixers,scope.zhajiout));
initlist.push(fbxpromise(data.monitor,mixers,scope.monitor));
initlist.push(fbxpromise(data.train,mixers,scope.train));
initlist.push(fbxpromise(data.section,mixers,scope.section));
return new Promise(function(resolve, reject){

View File

@ -5,6 +5,7 @@ let enter1 = {
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)
@ -16,9 +17,10 @@ let enter2 = {
name : "enter2",
type : "normal",
stage : "0",
randompoint : new THREE.Vector3(27,9.8,16),
railpoints : [
new THREE.Vector3(35,9.8,31.5),
new THREE.Vector3(31,9.8,31.5)
new THREE.Vector3(34,9.8,31.5),
new THREE.Vector3(32,9.8,31.5)
]
};
@ -27,6 +29,7 @@ let security = {
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)
@ -38,12 +41,13 @@ let entergate = {
name : "entergate",
type : "device",
stage : "2",
randompoint : new THREE.Vector3(2.3,9.8,13),
railpoints : [
new THREE.Vector3(6.3,9.8,17.4),
new THREE.Vector3(4.8,9.8,17.4),
new THREE.Vector3(3.4,9.8,17.4),
new THREE.Vector3(2.1,9.8,17.4),
new THREE.Vector3(0.7,9.8,17.4)
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)
]
};
@ -52,6 +56,7 @@ let standtop = {
name : "standtop",
type : "stand",
stage : "3",
randompoint : new THREE.Vector3(-64,1.77,0.38),
railpoints : [
new THREE.Vector3(52.1,1.77,-1.8),
new THREE.Vector3(-63.5,1.77,-1.8)
@ -63,6 +68,7 @@ let standdown = {
name : "standdown",
type : "stand",
stage : "3",
randompoint : new THREE.Vector3(-64,1.77,21),
railpoints : [
new THREE.Vector3(52.1,1.77,24),
new THREE.Vector3(-64,1.77,24)
@ -74,12 +80,13 @@ let exitgate = {
name : "exitgate",
type : "device",
stage : "5",
randompoint : new THREE.Vector3(-16,9.8,-0.4),
railpoints : [
new THREE.Vector3(18.8,9.8,-0.27),
new THREE.Vector3(18.8,9.8,1.18),
new THREE.Vector3(18.8,9.8,2.64),
new THREE.Vector3(18.8,9.8,4.1),
new THREE.Vector3(18.8,9.8,5.4)
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)
]
};
@ -88,6 +95,7 @@ let exit1 = {
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)
@ -99,9 +107,10 @@ let exit2 = {
name : "exit2",
type : "normal",
stage : "6",
randompoint : new THREE.Vector3(),
railpoints : [
new THREE.Vector3(28.3,9.8,28.8),
new THREE.Vector3(31.2,9.8,28.8)
new THREE.Vector3(28.3,9.8,28),
new THREE.Vector3(30.2,9.8,28)
]
};
@ -127,6 +136,44 @@ export function ZoneManager() {
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.getzoneposition = function(name){
// let random = Math.random();
let position = scope.list[name].railline.getPointAt(Math.random());

View File

@ -7,6 +7,7 @@ export function ZoneModel(data) {
this.type = data.type;
this.stage = data.stage;
this.status = 0;
this.randompoint = data.randompoint;
//轨迹点
this.railpoints = data.railpoints;

View File

@ -66,12 +66,12 @@ export function Jlmap3dSubscribe(jlmap3d,routegroup,jsonwebwork) {
// if(event.data.type == 'Simulation_DeviceStatus'){
// devicestatus(event.data);
// }
// console.log(data);
if(event.data._type == 'Simulation_Driver_Change'){
drivingcode = event.data.body.code;
jlmap3d.updatedrivingcode( event.data.body.code);
}
if(event.data._type == 'Train'){
// console.log(event.data);
trainstatus(event.data);
}
if (event.data._type== 'Signal' && signallist) {

View File

@ -191,12 +191,12 @@ export function JLmap3d(dom, data,skinCode,storemod,routegroup,project) {
scope.webwork.onmessage = function (event) {
//更新列车位置
// if(scope.datatype == "new"){
//
if(scope.datatype == "new"){
// UpdateTrainNew(camera,trainlisttest);
// }else{
// UpdateTrain(camera,trainlisttest);
// }
}else{
UpdateTrain(camera,trainlisttest);
}
if(camerarail.moveswitch == true){
// console.log(camerarail.progress);

View File

@ -8,6 +8,7 @@ export function Materialload(jlmap3dedit,assettype){
settexture( jlmap3dedit.materiallist,"black",'../../static/material/signal/5.jpg');
if(assettype){
if(assettype.stationtexture == "xian3"){
if(jlmap3dedit.stationtexture){
setstationtexture(jlmap3dedit.stationtexture,"stationlist",'../../static/texture/xian3/xian3list.jpg');
@ -69,6 +70,8 @@ export function Materialload(jlmap3dedit,assettype){
}
}
}
//console.log(jlmap3dedit.materiallist);
}

View File

@ -138,6 +138,7 @@ import axios from 'axios';
}
},
updatetrainlist(){
console.log(this.group);
getSimulationTrainlistNew(this.group).then(netdata => {
this.options = [];
this.trainlist = netdata.data;

View File

@ -3,11 +3,11 @@
<div id="jl3d" class="jl3ddraw">
</div>
<!-- <div class="menutop">
<div class="menutop">
<el-button-group>
<el-button type="primary" @click="switchrender">{{rendermode}}</el-button>
</el-button-group>
</div> -->
</div>
<div class="menudown">
<el-button-group>
<el-button type="primary" @click="back">退出</el-button>
@ -18,7 +18,7 @@
</template>
<script>
import Vue from 'vue';
import { Jl3dpassflow } from '@/jlmap3d/jl3dpassflow/jl3dpassflow.js';
import { Jl3dpassflow } from '@/jlmap3d/jl3dpassflow/jl3dpassflownew.js';
import { ProjectIcon } from '@/scripts/ProjectConfig';
export default {
@ -54,7 +54,7 @@ export default {
init: function () {
// let mapdata = this.$store.state.socket.device;
const dom = document.getElementById('jl3d');
this.jl3d = new Jl3dpassflow(dom);
this.jl3d = new Jl3dpassflow(dom,this.$route.query.mapid);
},
switchrender() {
if (this.renderswitch == true) {

View File

@ -152,7 +152,9 @@ export default {
}
},
'$store.state.map.showCentralizedStationNum': function (val) {
if (this.$store.state.map.showCentralizedStationCode) {
this.setShowStation(this.$store.state.map.showCentralizedStationCode);
}
},
'$store.state.training.offsetStationCode': function(code) {
if (code && this.localStationShow && this.$store.state.training.prdType === '01') {

View File

@ -45,7 +45,7 @@ export default {
},
maxWidth: {
type: Number,
require: true
default: 0
},
maxHeight: {
type: Number,
@ -205,6 +205,11 @@ export default {
indexKmRangeMap: {}
};
},
computed: {
...mapGetters('runPlan', [
'stations'
])
},
watch: {
maxWidth() {
this.setPosition();
@ -232,11 +237,6 @@ export default {
this.$refs.tripTable.setCurrentRow(this.tripNumberConfig.data[index]);
}
},
computed: {
...mapGetters('runPlan', [
'stations'
])
},
mounted() {
this.PlanConvert = this.$theme.loadPlanConvert(this.lineCode);
},
@ -247,6 +247,7 @@ export default {
serviceNumberChange(row) {
if (row) {
this.$store.dispatch('runPlan/setSelected', { serviceNumber: row.serviceNumber, tripNumber: null });
this.renderTripNumber({ serviceNumber: row.serviceNumber, tripNumber: null });
const serviceObj = this.$store.state.runPlan.editData[row.serviceNumber];
if (serviceObj) {
this.analyticalTripNumber(serviceObj.trainMap);
@ -256,6 +257,7 @@ export default {
tripNumberChange(row) {
if (row) {
this.$store.dispatch('runPlan/setSelected', { serviceNumber: this.$store.state.runPlan.selected.serviceNumber, tripNumber: row.tripNumber });
this.renderTripNumber({ serviceNumber: this.$store.state.runPlan.selected.serviceNumber, tripNumber: row.tripNumber });
}
},
async analyticalServiceNumber(data) {
@ -426,6 +428,39 @@ export default {
`到站时间: ${timeFormat(param.data[0] + this.PlanConvert.TranslationTime)} (${param.data[0]})<br>`
].join('');
},
renderTripNumber(params) {
const tripNumber = params.tripNumber; //
const serviceNumber = params.serviceNumber; //
let data;
const op = this.myChart.getOption();
op.series.forEach((item, index) => {
if (item.name == serviceNumber && item.data) {
const temp = item.data.filter(elem => elem[3] == tripNumber);
if (temp.length) {
data = temp;
}
}
if (item.name == 'trainLabel') {
op.series.pop();
this.myChart && this.myChart.setOption(op, true);
}
});
op.series.push({
name: 'trainLabel',
lineStyle: {
color: '#000',
width: 2,
type: 'solid'
},
z: 10,
type: 'line',
data: data
});
setTimeout(() => {
this.myChart && this.myChart.setOption(op, true);
}, 50);
},
mouseClick(params) {
const model = {
serviceNumber: params.seriesName

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -675,7 +675,7 @@ function timedCount(){
// postMessage(data);
// }
//
console.log(e.data);
// console.log(e.data);
if(e.data.type == "init"){
topic = e.data.topic;
@ -695,7 +695,7 @@ function timedCount(){
function callback(Response) {
// console.log(Response);
data = JSON.parse(Response.body);
console.log(data);
// console.log(data);
if(data.type == 'SJL3D_TrainStatus'){
for (let i=0,leni = data.body.length; i<leni; i++) {
postMessage(data.body[i]);