diff --git a/src/jlmap3d/jl3dtrafficplan/jl3dsandboxtest.js b/src/jlmap3d/jl3dtrafficplan/jl3dsandboxtest.js index 8a53a5463..3e9c81c38 100644 --- a/src/jlmap3d/jl3dtrafficplan/jl3dsandboxtest.js +++ b/src/jlmap3d/jl3dtrafficplan/jl3dsandboxtest.js @@ -9,13 +9,14 @@ import { OrbitControls } from '@/jlmap3d/main/control/OrbitControls'; import { dataManager } from '@/jlmap3d/jl3dtrafficplan/sandbox/datamanager'; -import StompClient from '@/utils/sock'; + import store from '@/store/index'; // import { Loading } from 'element-ui'; import {Stats} from '@/jlmap3d/main/lib/stats.min.js'; -export function Jl3dSandBoxTest(dom,skinCode,routegroup,token) { +export function Jl3dSandBoxTest(dom,textUi,skinCode,routegroup,token) { let scope = this; + textUi.updataData("sss"); var camera, scene, renderer,controls, light; camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 0.001, 50000 ); @@ -43,9 +44,10 @@ export function Jl3dSandBoxTest(dom,skinCode,routegroup,token) { - let manager = new dataManager(scene); + let manager = new dataManager(scene,camera,routegroup); manager.init(skinCode); + animate(); //循环渲染函数 function animate() { diff --git a/src/jlmap3d/jl3dtrafficplan/sandbox/datamanager.js b/src/jlmap3d/jl3dtrafficplan/sandbox/datamanager.js index 8234c3fc8..e0af98dc1 100644 --- a/src/jlmap3d/jl3dtrafficplan/sandbox/datamanager.js +++ b/src/jlmap3d/jl3dtrafficplan/sandbox/datamanager.js @@ -7,23 +7,102 @@ import { sectionModel } from '@/jlmap3d/jl3dtrafficplan/sandbox/sectionmodel'; import { signalModel } from '@/jlmap3d/jl3dtrafficplan/sandbox/signalmodel'; import { stationModel } from '@/jlmap3d/jl3dtrafficplan/sandbox/stationmodel'; import { trainModel } from '@/jlmap3d/jl3dtrafficplan/sandbox/trainmodel'; +import { ModelManager } from '@/jlmap3d/jl3dtrafficplan/sandbox/loader'; -export function dataManager(scene) { +import {Materialload} from '@/jlmap3d/main/loaders/Materialload.js'; +//数据整合 +import { sandBoxConnect } from '@/jlmap3d/jl3dtrafficplan/sandbox/sandboxconnect'; + +import { textUi } from '@/jlmap3d/jl3dtrafficplan/sandbox/textUi'; + + +export function dataManager(scene,camera,routegroup) { let scope = this; - let section = new sectionModel(); - let signal = new signalModel(); - let station = new stationModel(); - let train = new trainModel(); + let section = new sectionModel(scene); + let signal = new signalModel(scene); + let station = new THREE.Group(); + scene.add( station ); + let train = new trainModel(scene); + this.topCurve = ""; + this.downCurve = ""; + console.log(routegroup); + this.nowConnect = ''; + + var detaildiv = document.createElement("div"); + detaildiv.style.width = "128px"; + detaildiv.id = "detail"; + detaildiv.style.backgroundColor = "#ccc" + detaildiv.style.height = "256px"; + detaildiv.style.border = "1px solid #f00"; + detaildiv.style.position = "absolute"; + detaildiv.style.top = "0px"; + detaildiv.style.zIndex = 10; + detaildiv.style.display = "none"; + document.body.appendChild(detaildiv); + let text = new textUi(scene); + text.init(); + + let modelmanager = new ModelManager(); + Materialload(scope); this.init = function(skinCode){ - loadGeoJson().then(function(data){ - //console.log(data); + modelmanager.loadpromise().then(function (data) { + console.log(data); + return loadGeoJson(); + }).then(function(data){ + console.log(data); return loadMapData(skinCode); + }).then(function(data){ + scope.nowConnect = new sandBoxConnect(scope,routegroup,section,signal,station,train); + document.addEventListener( 'mousemove', onDocumentMouseMove, false ); + raycasterList.push(station); + raycasterList.push(train.trainGroup); }); + } + + let raycaster = new THREE.Raycaster(); + let mouse = new THREE.Vector2(); + let line,intersects,intersect; + let raycasterList = []; + + function onDocumentMouseMove( event ) { + + event.preventDefault(); + + mouse.x = ( event.clientX / window.innerWidth ) * 2 - 1; + mouse.y = - ( event.clientY / window.innerHeight ) * 2 + 1; + + raycaster.setFromCamera( mouse, camera ); + + for(let i=0;i0){ + i = raycasterList.length; + } + } + // console.log(intersects); + if ( intersects.length > 0 ) { + + intersect = intersects[ 0 ]; + console.log(intersect.object.position); + console.log(text.textplane.position); + console.log(intersect.object.name); + console.log(intersect.object.groupNumber); + detaildiv.style.display = ""; + detaildiv.style.left = event.clientX-64 + "px"; + detaildiv.style.top = event.clientY-270 + "px"; + } else { + detaildiv.style.display = "none"; + + } + + + } + function loadMapData(skinCode){ return new Promise(function(resolve, reject){ @@ -35,7 +114,9 @@ export function dataManager(scene) { getPublishMapDetail(skinCode).then(netdata => { console.log(netdata); - section.init(netdata.sectionList,netdata.switchList); + section.init(netdata.data.sectionList,netdata.data.switchList,stationData); + signal.init(netdata.data.signalList,section.topData,section.downData,scope.topCurve,scope.downCurve,modelmanager.signal); + train.init(netdata.data.trainList); resolve("loadMap"); }); }); @@ -61,36 +142,41 @@ export function dataManager(scene) { let stationListData = null; let originX = 0; let originY = 0; - let double = 1000; + let double = 10000; //['成功了', 'success'] readTextFile(JL3D_LOCAL_STATIC+"/trafficplan/fuzhou1.json", function(text){ var data = JSON.parse(text); - console.log(data.data.busline_list[0]); + // console.log(data.data.busline_list[0]); stationListData = data.data.busline_list[0]; let posx = stationListData.xs.split(","); let posz = stationListData.ys.split(","); - + posx.reverse(); + posz.reverse(); originX = posx[0]; originY = posz[0]; let pointsTop = []; let pointsDown = []; for(let i=0;i { + // store.dispatch('app/animationsClose'); + resolve("success"); //['成功了', 'success'] + }).catch((error) => { + //console.log(error); + }); + + }); + } + +} +//fbx模型加载 +function fbxpromise(asset){ + return new Promise(function(resolve, reject){ + var loader = new THREE.FBXLoader(); + + loader.load( BASE_ASSET_API+asset.url, function ( object ) { + asset.mesh = object; + resolve(asset.deviceType); + } ); + + }); +} diff --git a/src/jlmap3d/jl3dtrafficplan/sandbox/sandboxconnect.js b/src/jlmap3d/jl3dtrafficplan/sandbox/sandboxconnect.js index 8fcacab77..764f53d7f 100644 --- a/src/jlmap3d/jl3dtrafficplan/sandbox/sandboxconnect.js +++ b/src/jlmap3d/jl3dtrafficplan/sandbox/sandboxconnect.js @@ -1,3 +1,179 @@ -export function sandBoxConnect() { - let scope = this; + +import StompClient from '@/utils/sock'; +import { getBaseUrl } from '@/utils/baseUrl' +import { getToken } from '@/utils/auth'; +import store from '@/store/index'; + +// 定于仿真socket接口 +export function sandBoxConnect(manager,routegroup,section,signal,station,train ) { + let scope = this; + this.teststomp = new StompClient(); + let start = true; + let topic = '/user/queue/simulation/jl3d/'+routegroup; + let header = {'X-Token': getToken() }; + let topswitch = false; + let downswitch = false; + socketon(topic); + + function socketon(topic) { + try { + scope.teststomp.subscribe(topic, callback, header); + } catch (error) { + console.error('websocket订阅失败'); + } + + }; + + this.socketoff = function(topic) { + scope.teststomp.unsubscribe(topic); + }; + + // 仿真socket接口回调函数 + function callback(Response) { + let data = JSON.parse(Response.body); + + /** 站台客流当前人数信息 */ + if(data.type == "STAND_PFI"){ + + let newStandData = data.body; + let count = 0; + for(let j=0;j { + location.reload(); + }); + } + + } + } diff --git a/src/jlmap3d/jl3dtrafficplan/sandbox/sectionmodel.js b/src/jlmap3d/jl3dtrafficplan/sandbox/sectionmodel.js index 9a42c2257..891e682fd 100644 --- a/src/jlmap3d/jl3dtrafficplan/sandbox/sectionmodel.js +++ b/src/jlmap3d/jl3dtrafficplan/sandbox/sectionmodel.js @@ -1,18 +1,27 @@ export function sectionModel() { let scope = this; + this.sections={ + datalist:[] + }; + + this.stopsection = []; + + this.topData = []; + this.downData = []; + this.topSectionList = []; + this.downSectionList = []; + this.init = function(sectiondata,switchdata,stationdata){ - this.init = function(sectiondata,switchdata){ for(let i=0;i 1){ - for(let i=0,leni=standTextureData.urls.length;i 1){ + for(let i=0,leni=standTextureData.urls.length;i
+ style="left:40%" @mouseenter="onMouseOverNormal">
+ style="left:40%;" v-show="normalShow"@mouseleave="onMouseOutNormal" @click="initNormal"> -
@@ -24,7 +24,7 @@
+ style="left:70%;" v-show="trainRescueShow" @mouseleave="onMouseOutRescue" @click="initTrainRescueVr"> --> diff --git a/src/views/jlmap3d/trafficplan/component/textui.vue b/src/views/jlmap3d/trafficplan/component/textui.vue new file mode 100644 index 000000000..3c0ad56cb --- /dev/null +++ b/src/views/jlmap3d/trafficplan/component/textui.vue @@ -0,0 +1,54 @@ + + + + + + diff --git a/src/views/jlmap3d/trafficplan/jl3dtestview.vue b/src/views/jlmap3d/trafficplan/jl3dtestview.vue index 7a47d9c58..83a7a9435 100644 --- a/src/views/jlmap3d/trafficplan/jl3dtestview.vue +++ b/src/views/jlmap3d/trafficplan/jl3dtestview.vue @@ -1,6 +1,6 @@