This commit is contained in:
zyy 2020-10-30 18:17:12 +08:00
commit eddaf7635a
20 changed files with 416 additions and 1120 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -37,7 +37,6 @@ var clock = new THREE.Clock();
export function JLmap3d(dom, data,skinCode,storemod,routegroup,project) {
let scope = this;
this.dom = dom;
@ -46,8 +45,10 @@ export function JLmap3d(dom, data,skinCode,storemod,routegroup,project) {
renderer.domElement.style.position = "absolute";
renderer.domElement.style.top = "0";
document.getElementById('testjlmap3d').appendChild(renderer.domElement);
//定义相机
let camera = SetCamera(dom);
//定义场景(渲染容器)
let scene = SetScene(project);
let scenesimulation = new THREE.Group();
@ -79,6 +80,7 @@ export function JLmap3d(dom, data,skinCode,storemod,routegroup,project) {
//模型操作命令组
this.actions = {};
//设备数据
let sectionlist = null;
let linklist = null;
let signallist = null;
@ -87,16 +89,17 @@ export function JLmap3d(dom, data,skinCode,storemod,routegroup,project) {
let realsectionlist = null;
let rails = null;
//轨道相机
let camerarail = {
curve:null,
progress:0,
moveswitch:false
};
//地图模型数据
let mapdata = new Jl3ddata();
//订阅仿真socket
this.webwork = new Worker(JL3D_LOCAL_STATIC+"/workertest/trainworker.js");
//初始化加载数据和模型getPublishMapDetail
getPublishMapDetail(skinCode).then(data => {
@ -110,46 +113,7 @@ export function JLmap3d(dom, data,skinCode,storemod,routegroup,project) {
SimulationLoadNew(mapnetdata,scope,netdata.data,mapdata,camera,controls,scenesimulation,storemod);
});
});
//
// let stats = new Stats();
// dom.appendChild( stats.dom );
// var timer = setInterval(function() {
// if(trainlisttest){
// if(trainlisttest.group){
// if(trainlisttest.group.children[0]){
// for(let k in rails.switchrail){
// const ddd = storemod.getters['map/getDeviceByCode'](k);
// let switchdata = rails.switchrail[k];
// rails.switchrail[k].locateType = ddd.locateType;
//
// if(ddd.locateType == "01"){
// //1--向左 2--向右
// //__\__ __/__
// if(rails.switchrail[k].directtype == "1"){
// rails.linkrail[switchdata.alink].lconnect = switchdata.blink;
// rails.linkrail[switchdata.blink].rconnect = switchdata.alink;
// }else if(rails.switchrail[k].directtype == "2"){
// rails.linkrail[switchdata.alink].rconnect = switchdata.blink;
// rails.linkrail[switchdata.blink].lconnect = switchdata.alink;
// }
//
// }else if(ddd.locateType == "02"){
// if(rails.switchrail[k].directtype == "1"){
// rails.linkrail[switchdata.alink].lconnect = switchdata.clink;
// rails.linkrail[switchdata.clink].rconnect = switchdata.alink;
// }else if(rails.switchrail[k].directtype == "2"){
// rails.linkrail[switchdata.alink].rconnect = switchdata.clink;
// rails.linkrail[switchdata.clink].lconnect = switchdata.alink;
// }
// }
// }
// clearInterval(timer);
// }
// }
// }
//
// }, 2000);
//开启渲染
animate();
startWorker(scope.webwork);
@ -158,18 +122,13 @@ export function JLmap3d(dom, data,skinCode,storemod,routegroup,project) {
//循环渲染函数
function animate() {
//循环渲染
//requestAnimationFrame(animate);
//renderer.setAnimationLoop(animate);
requestAnimationFrame(animate);
//判断渲染是否开启
//根据相机渲染场景
//根据相机渲染场景
renderer.render(scene,camera);
//检测动画构造器播放动画
// }
// stats.update();
}
//利用webworker当做定时器驱动设备动画更新列车状态车站漫游动画
function startWorker(webwork){
if(typeof(Worker)!=="undefined"){
@ -181,6 +140,15 @@ export function JLmap3d(dom, data,skinCode,storemod,routegroup,project) {
UpdateTrain(camera,trainlisttest);
}
delta = clock.getDelta();
for(let i=scope.mixers.length-1;i>=0;i--){
if(scope.mixers[i]._actions[0].isRunning()){
// console.log(scope.mixers[i]._actions[0].isRunning());
scope.mixers[i].update( delta );
}
}
//开启车站漫游
if(camerarail.moveswitch == true){
// console.log(camerarail.progress);
if(camerarail.progress>=0.99){
@ -201,18 +169,12 @@ export function JLmap3d(dom, data,skinCode,storemod,routegroup,project) {
}
delta = clock.getDelta();
for(let i=scope.mixers.length-1;i>=0;i--){
if(scope.mixers[i]._actions[0].isRunning()){
// console.log(scope.mixers[i]._actions[0].isRunning());
scope.mixers[i].update( delta );
}
}
};
}
}
//释放场景缓存关闭渲染循环
this.dispose = function(){
renderer.setAnimationLoop(null);
renderer.dispose();
@ -242,6 +204,7 @@ export function JLmap3d(dom, data,skinCode,storemod,routegroup,project) {
}
};
//切换显示车站信息
this.showstationmsg = function(showtype){
if(showtype == "show"){
for(let st=0;st<stationstandlist.group.children.length;st++){
@ -254,6 +217,7 @@ export function JLmap3d(dom, data,skinCode,storemod,routegroup,project) {
}
};
//切换显示列车信息
this.showtrainmsg = function(showtype){
console.log(trainlisttest);
if(showtype == "show"){
@ -267,24 +231,23 @@ export function JLmap3d(dom, data,skinCode,storemod,routegroup,project) {
}
};
// this.restart = function(){
// ReStart(mapdata);
// };
//开启轨道镜头交互
this.animateon = function(){
controls.enabled = true;
};
//关闭轨道镜头交互
this.animateoff = function(){
controls.enabled = false;
};
//更新加载后数据
this.loaderdata = function(loadsectionlist,loadlinklist,loadsignallist,loadstationstandlist,loadtrainlisttest,loadrealsectionlist,loadrails){
sectionlist = loadsectionlist;
linklist = loadlinklist;
signallist = loadsignallist;
stationstandlist = loadstationstandlist;
trainlisttest = loadtrainlisttest;
realsectionlist = loadrealsectionlist;
rails = loadrails;
@ -307,8 +270,8 @@ export function JLmap3d(dom, data,skinCode,storemod,routegroup,project) {
window.removeEventListener( 'resize', onWindowResize, false );
};
//根据菜单选项切换相机位置
this.updatecamera = function(mesh,type){
//console.log(mesh);
if(type == "station"){
camera.position.x = mesh.position.x;
camera.position.y = mesh.position.y+800;
@ -330,8 +293,8 @@ export function JLmap3d(dom, data,skinCode,storemod,routegroup,project) {
controls.update();
}
//窗口自适应
function onWindowResize() {
//窗口自适应
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
@ -340,7 +303,6 @@ export function JLmap3d(dom, data,skinCode,storemod,routegroup,project) {
//三维交互点击事件函数
function onselect(event) {
if(event.button == "0"){
//定义光线
let raycaster = new THREE.Raycaster();
//定义平面鼠标点击坐标

View File

@ -110,6 +110,7 @@ export function StationStandListN() {
if(mode == "02"){
let textgeometry = new THREE.PlaneBufferGeometry( 65, 90, 1 );
let textt = new THREE.CanvasTexture(getTextCanvas(stationdata[i]));
let textmaterial = new THREE.MeshBasicMaterial( { side: THREE.DoubleSide,map:textt ,transparent: true} );
let textplane = new THREE.Mesh( textgeometry, textmaterial );
textplane.name = stationdata[i].code;
@ -289,6 +290,7 @@ export function StationStandListN() {
if(mode == "02"){
let textgeometry = new THREE.PlaneBufferGeometry( 65, 90, 1 );
let textt = new THREE.CanvasTexture(getTextCanvas(standsdata[i]));
let textmaterial = new THREE.MeshBasicMaterial( { side: THREE.DoubleSide,map:textt ,transparent: true} );
let textplane = new THREE.Mesh( textgeometry, textmaterial );
textplane.name = standsdata[i].code;
@ -414,7 +416,9 @@ export function StationStandListN() {
}
}
}
}
// scene.add(scope.textlist);
stationdata = null;
psddata = null;

View File

@ -26,7 +26,6 @@
<script>
import Vue from 'vue';
import { JL3D_LOCAL_STATIC } from '@/api/jlmap3d/assets3d.js';
import { Jl3ddevice } from '@/jlmap3d/jl3ddevice/jl3ddevice.js';
import { Jl3ddeviceNew } from '@/jlmap3d/jl3ddevice/jl3ddeviceNew.js';
import Jl3ddeviceMsg from '@/views/jlmap3d/device/component/devicemsg';
@ -135,13 +134,10 @@
this.windowstatus = true;
// this.jl3d.updatewindowstatus('1');
}
if(this.$store.state.map.map.linkList){
this.datastatus = "old";
this.initolddata(group,header);
}else{
this.datastatus = "new";
this.initnewdata(group,header);
}
//
this.datastatus = "new";
this.initnewdata(group,header);
if(this.$route.query.type == "VR_PSD"){
this.jl3d.updatewindowstatus('1');
this.psdCode = this.$route.query.psdCode;
@ -156,11 +152,6 @@
beforeDestroy() {
},
methods: {
initolddata: function (group,header) {
// let mapdata = this.$store.state.socket.device;
let dom = document.getElementById('jl3d');
this.jl3d = new Jl3ddevice(dom,group,header,this.mapId);
},
initnewdata: function (group,header){
let dom = document.getElementById('jl3d');
this.jl3d = new Jl3ddeviceNew(dom,group,header,this.mapId);

View File

@ -17,7 +17,7 @@
<div id="bmcbtc" class="panebutton" style="top:8%;left:17%;" @click="bmcbtcclick">
<img class="buttonimg" :src="cbtcbuttonimg" />
<div class="buttontext">BM/CBTC</div>
</div> -->
</div>
<!-- RM -->
<div id="rm" class="panebutton" style="top:8%;left:31%;" @click="rmclick">
<img class="buttonimg" :src="rmbuttonimg" />
@ -83,20 +83,20 @@
</div> -->
<!-- 受电弓升 -->
<!-- <div id="sg" class="panebutton" style="bottom:6%;left:3%;" @click="sgclink">
<div id="sg" class="panebutton" style="bottom:6%;left:3%;" @click="sgclink">
<img class="buttonimg" :src="sgimg" />
<div class="buttontext">{{ $t('jlmap3d.electricGongSheng') }}</div>
</div> -->
</div>
<!-- 受电弓降 -->
<!-- <div id="jg" class="panebutton" style="bottom:6%;left:17%;" @click="jgclick">
<div id="jg" class="panebutton" style="bottom:6%;left:17%;" @click="jgclick">
<img class="buttonimg" :src="jgimg" />
<div class="buttontext">{{ $t('jlmap3d.pantographFall') }}</div>
</div> -->
</div>
<!-- 试灯按钮 -->
<!-- <div id="sl" class="panebutton" style="bottom:6%;left:40%;" @click="slclick">
<img class="buttonimg" :src="slimg" />
<div class="buttontext">{{ $t('jlmap3d.lampButton') }}</div>
</div> -->
</div>
<!-- ATP切除 -->
<div id="atp" class="panebutton" style="bottom:6%;left:31%;" @click="atpclick">
<img class="buttonimg" :src="atpimg" />
@ -193,6 +193,11 @@
doorleftimg:JL3D_LOCAL_STATIC+"/jl3d/control/green.png",
doorrightimg:JL3D_LOCAL_STATIC+"/jl3d/control/green.png",
//lightdark
sgl:JL3D_LOCAL_STATIC+"/jl3d/control/greenz.png",
jgl:JL3D_LOCAL_STATIC+"/jl3d/control/redz.png",
sgd:JL3D_LOCAL_STATIC+"/jl3d/control/greenz.png",
jgd:JL3D_LOCAL_STATIC+"/jl3d/control/redz.png",
}
},
watch: {

View File

@ -0,0 +1,95 @@
<template>
<div class = "tmsfault" >
<div class = "tmsvoltage">{{voltage}}</div>
<div class = "tmscurrent">{{current}}</div>
<div class = "tmslevel">{{level}}</div>
<div class = "tmsspeed">{{speed}}</div>
</div>
</template>
<script>
import axios from 'axios';
export default {
name: 'TmsFault',
components: {
},
data() {
return {
voltage:"750V",
current:"0A",
level:"",
speed:"km/h",
}
},
mounted() {
},
beforeDestroy() {
},
watch: {
},
methods: {
init(){
},
},
beforeDestroy() {
}
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.tmsfault{
position: absolute;
// border-style:solid;
// border-color: #ffffff;
top:7%;
width:100%;
height:84%;
color:white;
}
.tmsvoltage{
top:7%;
left:3%;
width: 15%;
position: absolute;
text-align: center;
// border-style:solid;
// border-color: #ffffff;
}
.tmscurrent{
top:7%;
left:19%;
width: 15%;
position: absolute;
text-align: center;
// border-style:solid;
// border-color: #ffffff;
}
.tmslevel{
top:7%;
left:60%;
width: 20%;
position: absolute;
text-align: center;
// border-style:solid;
// border-color: #ffffff;
}
.tmsspeed{
top:7%;
left:82%;
width: 15%;
position: absolute;
text-align: center;
// border-style:solid;
// border-color: #ffffff;
}
</style>

View File

@ -1,6 +1,7 @@
<template>
<div class = "tms" :style="{'background-image': 'url('+localStatic+'/jl3d/tms.png)'}" >
<Tms-Fault>
</Tms-Fault>
</div>
@ -10,10 +11,13 @@
import axios from 'axios';
import { JL3D_LOCAL_STATIC } from '@/api/jlmap3d/assets3d.js';
export default {
name: 'SimulationTms',
components: {
import TmsFault from '@/views/jlmap3d/drive/sceneview/tmscomponent/tmsfault';
export default {
name: 'DriveTms',
components: {
TmsFault,
},
data() {
return {

View File

@ -55,6 +55,8 @@
<el-button v-if="selectmodel.meshtype == 'section'" type="vexscal" @click="sectionFlat">区段平整</el-button>
<el-button v-if="selectmodel.meshtype == 'section'" type="vexscal" @click="sectionStraight">直区段修复</el-button>
<el-button v-if="selectmodel.meshtype == 'station'" @click="changeStationPos">自动对齐停车点</el-button>
<!-- <el-button v-if="selectmodel.meshtype == 'station'" type="vexscal" @click="vexScalVertical">高度改变</el-button> -->
@ -191,7 +193,9 @@ export default {
sectionFlat(){
this.$emit('flat',this.selectmodel.code);
},
sectionStraight(){
this.$emit('straight',this.selectmodel.code);
},
changeStationPos(){
this.$emit('changeStationPos',this.selectmodel);
},

View File

@ -8,7 +8,7 @@
<Edit-Action ref="action" @saction="saction" @actionevent="actionevent">
</Edit-Action>
<Edit-Property ref="property" :selectmodel='selectmodel' @alignment="alignment" @vexscal= "vexscal" @changeStationPos="changeStationPos" @flat="flat">
<Edit-Property ref="property" :selectmodel='selectmodel' @alignment="alignment" @vexscal= "vexscal" @changeStationPos="changeStationPos" @flat="flat" @straight="straight">
</Edit-Property>
<Edit-Assets ref="assets" @smodel="smodel" @stexture="stexture">
@ -198,6 +198,10 @@
this.jlmap3dedit.vexscaloff();
this.jlmap3dedit.flatSection(alignmentCode);
},
straight(alignmentCode){
this.jlmap3dedit.vexscaloff();
this.jlmap3dedit.straightSection(alignmentCode);
},
save() {
//console.log("save");
console.log(this.jlmap3dedit.assetManager);