修改三维客流pis

This commit is contained in:
sunzhenyu 2020-12-08 11:28:34 +08:00
parent ce7a3de96f
commit 7a607d308d
7 changed files with 157 additions and 4 deletions

View File

@ -75,8 +75,13 @@ export function TrainConnect(trafficTrain,deviceaction,toptrain,routegroup,passe
}
if(data.type == "TRAIN_PIS"){
console.log(data);
for(let i=0;i<data.body.length;i++){
trafficTrain.trainList[data.body[i].code].endStation = data.body[i].endStation;
trafficTrain.trainList[data.body[i].code].nextStation = data.body[i].nextStation;
}
console.log(trafficTrain.trainList);
}
if(data.type == "TRAIN_PFI_NUM"){
trafficTrain.trainList = [];

View File

@ -18,6 +18,10 @@ import { PasserTrain } from '@/jlmap3d/jl3dtrafficplan/model/passertrain.js';
import { PasserHuman } from '@/jlmap3d/jl3dtrafficplan/model/traintrunk/passertrunkhuman.js';
//cctv渲染器
import { PasserRender } from '@/jlmap3d/jl3dpassflow/passerrender/passerrender.js';
//pis
import { PisTexture } from '@/jlmap3d/jl3dtrafficplan/utils/trainpiscanvas.js';
//cctv行人ai
import { PasserAi } from '@/jlmap3d/jl3dpassflow/passerai/passerai.js';
//行人寻路相关工具
@ -133,7 +137,7 @@ export function Jl3dTrafficTrain(dom,skinCode,routegroup,viewMap,initCode) {
let stationlist = [];
let socktest = null;
let passerTrain = new PasserTrain();
let pisControl = new PisTexture();
this.modelmanager.loadpromise(Staticmodel, scope.mixers,"2").then(function (data) {
// console.log(data);
passerTrain.initTrain(scope.modelmanager.train.mesh,mixers,deviceaction,scene);
@ -148,7 +152,8 @@ export function Jl3dTrafficTrain(dom,skinCode,routegroup,viewMap,initCode) {
scene.add(humanlist);
socktest = new TrainConnect(scope,deviceaction,passerTrain.toptrain,routegroup,passerAi);
console.log(passerTrain.toptrain);
pisControl.getMaterial(passerTrain.toptrain);
let checkobject = setInterval(function(){

View File

@ -19,7 +19,7 @@ var Staticmodel = [
name: "列车",
deviceType: "train",
type: "cctvTrain",
url: BASE_ASSET_API + "/MODEL/2020-11-16/48-14909.FBX"
url: BASE_ASSET_API + "/MODEL/2020-12-08/493-62073.FBX"
},
{
id: "8",

View File

@ -0,0 +1,128 @@
//静态资源文件路劲
import { JL3D_LOCAL_STATIC } from '@/api/jlmap3d/assets3d.js';
export function PisTexture(zone,finder) {
let scope = this;
this.stationNum = 0;
this.materialPis = null;
this.direct = 0;
this.index = null;
let lightConfig = [
{x:46,y:100},
{x:67,y:100},
{x:88,y:100},
{x:109,y:100},
{x:130,y:100},
{x:151,y:100},
{x:172,y:100},
{x:193,y:100},
{x:214,y:100},
{x:235,y:100},
{x:256,y:100},
{x:277,y:100},
{x:298,y:100},
{x:319,y:100},
{x:340,y:100},
{x:361,y:100},
{x:382,y:100},
{x:403,y:100},
{x:424,y:100},
{x:445,y:100},
{x:466,y:100},
];
var textureTop = new Image();
textureTop.src = JL3D_LOCAL_STATIC+"/trafficplan/directtop.jpg";
var textureDown = new Image();
textureDown.src = JL3D_LOCAL_STATIC+"/trafficplan/directdown.jpg";
let canvas = document.getElementById('canvastexture');
canvas.width = 512;
canvas.height = 128;
var ctx = canvas.getContext('2d');
this.getMaterial = function(trainModel){
scope.materialPis = trainModel.children[0].getObjectByName("PIS").material;
}
this.startRender = function(){
setInterval(function(){
// var texture = getTextCanvasLight("xxx");
if(scope.index){
scope.updateTexture();
}
}, 1000);
}
this.updateParam = function(direct,index){
scope.direct = direct;
scope.index = index;
}
this.updateTexture = function(){
// var texture = getTextCanvasLight(direct);
scope.materialPis.map.image = getTextCanvasLight(scope.direct,scope.index);
scope.materialPis.map.needsUpdate = true;
}
}
let lightNum = false;
function getLightTextCanvas(direct,index){
ctx.fillRect(0, 0,512,128);
ctx.font = "10px Verdana";
// ctx.fillStyle = '#ffffff';
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.clearRect(0,0,512,128);
if(direct == true){
ctx.drawImage(textureTop,0,0,512, 128);
}else{
ctx.drawImage(textureDown,0,0,512, 128);
}
if(lightNum == false){
for(let i=0;i<lightConfig.length;i++){
ctx.beginPath();
ctx.arc(lightConfig[i].x,lightConfig[i].y,3,0,Math.PI*2,false);
ctx.fillStyle="rgba(192,80,77,0.7)";
//半透明的红色rgba(192,80,77,0.7)
//rgba(39,246,205,0.7)
ctx.fill();
ctx.strokeStyle="rgba(192,80,77,1)";
//红色rgba(192,80,77,1)
//rgba(39,246,205,1)
ctx.stroke();
}
lightNum = true;
}else{
for(let i=0;i<lightConfig.length;i++){
ctx.beginPath();
ctx.arc(lightConfig[i].x,lightConfig[i].y,3,0,Math.PI*2,false);
ctx.fillStyle="rgba(39,246,205,0.7)";
//半透明的红色rgba(192,80,77,0.7)
//rgba(39,246,205,0.7)
ctx.fill();
ctx.strokeStyle="rgba(39,246,205,1)";
//红色rgba(192,80,77,1)
//rgba(39,246,205,1)
ctx.stroke();
}
lightNum = false;
}
let data = ctx.getImageData(0, 0,512,128);
return data;
}

View File

@ -1,6 +1,11 @@
<template>
<div class="jl3dtrafficplan">
<div id="jl3d" :class="lineCode=='07'?'jl3ddraw':'jl3ddraw1'" />
<div id="testjlmap3d" class="jlmap3ddraw">
<canvas id="canvastexture" />
</div>
<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="updateTrainCode">
@ -373,4 +378,14 @@ export default {
width:250px;
}
.jlmap3ddraw {
float: left;
left: 0;
//left:20%;
width: 100%;
height: 100%;
position:absolute;
z-index: -1;
}
</style>

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB