diff --git a/src/jlmap3d/edit/Jlmap3ddata.js b/src/jlmap3d/edit/Jlmap3ddata.js index 0df8701d5..2c2a96a1c 100644 --- a/src/jlmap3d/edit/Jlmap3ddata.js +++ b/src/jlmap3d/edit/Jlmap3ddata.js @@ -26,9 +26,7 @@ export function Jlmap3ddata(mapid,scope){ get3dMapData(editmapid).then(data => { //console.log(data); if(data.code == "200"){ - //console.log("数据存在"); - let isSection = false; //console.log(data.data); if(data.data.assets){ @@ -40,14 +38,14 @@ export function Jlmap3ddata(mapid,scope){ } } - console.log(isSection); if(isSection == true){ initobj(editmapid,data.data.id); //init3d(editmapid,data.data); }else{ // console.log(editmapid); // console.log(data.data.id); - initobj(editmapid,data.data.id); + init3d(editmapid,data.data); + // initobj(editmapid,data.data.id); } } @@ -60,7 +58,7 @@ export function Jlmap3ddata(mapid,scope){ set3dMapData(params).then(data => { if(data.code == "200"){ //console.log("创建三维数据成功"); - //console.log(data); + // console.log(data); initobj(editmapid,data.data.id); } @@ -72,14 +70,11 @@ export function Jlmap3ddata(mapid,scope){ }); function initobj(mapid,data3did){ - console.log(mapid); getMapDetail(mapid).then(data => { let mapdata = data.data; - console.log(mapdata); //console.log(data3did); jlmap3ddata.id = data3did; jlmap3ddata.mapId = mapid; - console.log(jlmap3ddata.mapId); //初始化轨道和道岔 暂时 jlmap3ddata.linklist = new LinkList(); jlmap3ddata.sectionlist = new SectionList(); @@ -120,50 +115,60 @@ export function Jlmap3ddata(mapid,scope){ } function init3d(mapid,netdata){ + console.log(netdata) getMapDetail(mapid).then(data => { jlmap3ddata.id = netdata.id; jlmap3ddata.mapId = mapid; let mapdata = data.data; - //初始化轨道和道岔 暂时 - jlmap3ddata.sectionlist = new SectionList(); - jlmap3ddata.signallist = new SignalList(); - //初始化站台 - jlmap3ddata.stationstandlist = new StationStandList(); - //初始化测试列车 - jlmap3ddata.trainlisttest = new TrainListTest(); + jlmap3ddata.linklist = new LinkList(); + //初始化轨道和道岔 暂时 + jlmap3ddata.sectionlist = new SectionList(); + jlmap3ddata.signallist = new SignalList(); + //初始化站台 + jlmap3ddata.stationstandlist = new StationStandList(); + //初始化测试列车 + jlmap3ddata.trainlisttest = new TrainListTest(); - jlmap3ddata.realsectionlist = new RealSectionList(); + jlmap3ddata.realsectionlist = new RealSectionList(); - assetloader.setmodellist(netdata.assets); + assetloader.setmodellist(netdata.assets); + let loaderdata = JSON.parse(netdata.sections); + let switchdata = JSON.parse(netdata.switchs); + let signaldata = JSON.parse(netdata.signals); + let standsdata = JSON.parse(netdata.stands); + console.log(loaderdata); + assetloader.assetpromise(scene) + .then(function(data){ + //console.log(data); + return jlmap3ddata.linklist.loadpromise(loaderdata.link,scene,assetloader); + }) + .then(function(data){ + //console.log(data); + return jlmap3ddata.sectionlist.loadpromise(jlmap3ddata,assetloader,loaderdata.section,switchdata,scene); + }) + .then(function(data){ + //console.log(data); + return jlmap3ddata.signallist.loadpromise(signaldata,scene,assetloader); + }) + .then(function(data){ + //console.log(data); + return jlmap3ddata.stationstandlist.initpromise(jlmap3ddata,mapdata.stationList,mapdata.stationStandList,scene,assetloader,standsdata); + }) + .then(function(data){ + //console.log(data); + return jlmap3ddata.trainlisttest.initpromise(mapdata.trainList,scene,assetloader); + }) + // .then(function(data){ + // //console.log(data); + // return jlmap3ddata.realsectionlist.loadpromise(jlmap3ddata,scene,assetloader); + // }) + .then(function(data){ + //console.log(data); + loadingInstance.close(); + }); - assetloader.assetpromise(scene) - .then(function(data){ - //console.log(data); - return jlmap3ddata.sectionlist.initpromise(mapdata.sectionList,mapdata.switchList,scene); - }) - .then(function(data){ - //console.log(data); - return jlmap3ddata.signallist.initpromise(mapdata.signalList,scene,assetloader,netdata.signals); - }) - .then(function(data){ - //console.log(data); - return jlmap3ddata.stationstandlist.initpromise(mapdata.stationList,mapdata.stationStandList,scene,assetloader,netdata.stands); - }) - .then(function(data){ - //console.log(data); - return jlmap3ddata.trainlisttest.initpromise(mapdata.trainList,scene,assetloader); - }) - .then(function(data){ - //console.log(data); - return jlmap3ddata.realsectionlist.initpromise(jlmap3ddata,scene,assetloader); - }) - .then(function(data){ - //console.log(data); - loadingInstance.close(); - }); - - }); + }); } diff --git a/src/jlmap3d/edit/action/sectionaction.js b/src/jlmap3d/edit/action/sectionaction.js index a421c2254..8876f16f4 100644 --- a/src/jlmap3d/edit/action/sectionaction.js +++ b/src/jlmap3d/edit/action/sectionaction.js @@ -37,48 +37,30 @@ export function Sectionaction(){ } //点击事件 this.raycaster = function(data,type){ - console.log("sa"); + console.log(type); + let modellist; if(type == "test"){ - let modellist = data.scene.getObjectByName("link").children; - //定义光线 - let raycaster = new THREE.Raycaster(); - //定义平面鼠标点击坐标 - let mouse = new THREE.Vector2(); - mouse.x = (event.clientX / window.innerWidth) * 2 - 1; - mouse.y = -(event.clientY / window.innerHeight) * 2 + 1; - - raycaster.setFromCamera( mouse, data.camera ); - let intersects1; - for(let i=0;i0.49){ + rightlist.push(i); + } + if(autorail.geometry.attributes.position.array[i*3] <-0.49){ + leftlist.push(i); + } + } + + + + for(let i=0;isectionB.position.x){ + testswitch.rotation.y = Math.PI; + + // if(sectionA.position.z>sectionC.position.z){ + // }else{ + // } + + }else{ + testswitch.rotation.y = 0; + + // if(sectionA.position.z>sectionC.position.z){ + // }else{ + // } + + } + + testswitch.position.x = switchposx; + testswitch.position.y = 0; + testswitch.position.z = switchposz; + scope.switchs.modellist.push(testswitch); + switchgroup.add(testswitch); + } + + resolve("loadersection"); + }); + + } + // + // this.init = function(sectiondata,switchdata,scene){ + // + // //遍历区段 + // for(let i=0;isectionB.position.x){ - testswitch.rotation.y = Math.PI; - - // if(sectionA.position.z>sectionC.position.z){ - // }else{ - // } - - }else{ - testswitch.rotation.y = 0; - - // if(sectionA.position.z>sectionC.position.z){ - // }else{ - // } - - } - - testswitch.position.x = switchposx; - testswitch.position.y = 0; - testswitch.position.z = switchposz; - scene.add(testswitch); + scope.switchs.datalist.push(newswitch); + scope.switchs.modellist.push(testswitch); + switchgroup.add(testswitch); } - // for(let i=0;isectionB.position.x){ - // if(sectionA.position.z>sectionC.position.z){ - // testswitch.rotation.y = 0; - // }else{ - // testswitch.rotation.y = Math.PI; - // } - // }else{ - // if(sectionA.position.z>sectionC.position.z){ - // testswitch.rotation.y = 0; - // }else{ - // testswitch.rotation.y = Math.PI; - // } - // } - // testswitch.position.x = (sectionA.position.x+sectionB.position.x)/2; - // testswitch.position.y = 0; - // testswitch.position.z = sectionA.position.z; - // console.log("----------"); - // console.log(testswitch.position); - // console.log(sectionA.position); - // console.log(sectionB.position); - // console.log(sectionC.position); - // console.log("---------"); - // scene.add(testswitch); - // //道岔对象组 - // let newswitch = new SwitchModel(); - // newswitch.name = switchlist[i].code; - // newswitch.code = switchlist[i].code; - // newswitch.index = i; - // scope.switchs.datalist.push(newswitch); - // scope.switchs.modellist.push(""); - // } - - resolve("loadersection"); + resolve("loadersection"); }); } - this.init = function(sectiondata,switchdata,scene){ - - //遍历区段 - for(let i=0;i 0 ) { + + var object = intersects[ 0 ].object; + + _plane.setFromNormalAndCoplanarPoint( _camera.getWorldDirection( _plane.normal ), _worldPosition.setFromMatrixPosition( object.matrixWorld ) ); + + if ( _hovered !== object ) { + + scope.dispatchEvent( { type: 'hoveron', object: object } ); + + _domElement.style.cursor = 'pointer'; + _hovered = object; + + } + + } else { + + if ( _hovered !== null ) { + + scope.dispatchEvent( { type: 'hoveroff', object: _hovered } ); + + _domElement.style.cursor = 'auto'; + _hovered = null; + + } + + } + + } + + function onDocumentMouseDown( event ) { + + event.preventDefault(); + + _raycaster.setFromCamera( _mouse, _camera ); + + var intersects = _raycaster.intersectObjects( _objects ); + + if ( intersects.length > 0 ) { + + _selected = intersects[ 0 ].object; + + if ( _raycaster.ray.intersectPlane( _plane, _intersection ) ) { + + _inverseMatrix.getInverse( _selected.parent.matrixWorld ); + _offset.copy( _intersection ).sub( _worldPosition.setFromMatrixPosition( _selected.matrixWorld ) ); + + } + + _domElement.style.cursor = 'move'; + + scope.dispatchEvent( { type: 'dragstart', object: _selected } ); + + } + + + } + + function onDocumentMouseCancel( event ) { + + event.preventDefault(); + + if ( _selected ) { + + scope.dispatchEvent( { type: 'dragend', object: _selected } ); + + _selected = null; + + } + + _domElement.style.cursor = _hovered ? 'pointer' : 'auto'; + + } + + function onDocumentTouchMove( event ) { + + event.preventDefault(); + event = event.changedTouches[ 0 ]; + + var rect = _domElement.getBoundingClientRect(); + + _mouse.x = ( ( event.clientX - rect.left ) / rect.width ) * 2 - 1; + _mouse.y = - ( ( event.clientY - rect.top ) / rect.height ) * 2 + 1; + + _raycaster.setFromCamera( _mouse, _camera ); + + if ( _selected && scope.enabled ) { + + if ( _raycaster.ray.intersectPlane( _plane, _intersection ) ) { + + _selected.position.copy( _intersection.sub( _offset ).applyMatrix4( _inverseMatrix ) ); + + } + + scope.dispatchEvent( { type: 'drag', object: _selected } ); + + return; + + } + + } + + function onDocumentTouchStart( event ) { + + event.preventDefault(); + event = event.changedTouches[ 0 ]; + + var rect = _domElement.getBoundingClientRect(); + + _mouse.x = ( ( event.clientX - rect.left ) / rect.width ) * 2 - 1; + _mouse.y = - ( ( event.clientY - rect.top ) / rect.height ) * 2 + 1; + + _raycaster.setFromCamera( _mouse, _camera ); + + var intersects = _raycaster.intersectObjects( _objects ); + + if ( intersects.length > 0 ) { + + _selected = intersects[ 0 ].object; + + _plane.setFromNormalAndCoplanarPoint( _camera.getWorldDirection( _plane.normal ), _worldPosition.setFromMatrixPosition( _selected.matrixWorld ) ); + + if ( _raycaster.ray.intersectPlane( _plane, _intersection ) ) { + + _inverseMatrix.getInverse( _selected.parent.matrixWorld ); + _offset.copy( _intersection ).sub( _worldPosition.setFromMatrixPosition( _selected.matrixWorld ) ); + + } + + _domElement.style.cursor = 'move'; + + scope.dispatchEvent( { type: 'dragstart', object: _selected } ); + + } + + + } + + function onDocumentTouchEnd( event ) { + + event.preventDefault(); + + if ( _selected ) { + + scope.dispatchEvent( { type: 'dragend', object: _selected } ); + + _selected = null; + + } + + _domElement.style.cursor = 'auto'; + + } + + activate(); + + // API + + this.enabled = true; + + this.activate = activate; + this.deactivate = deactivate; + this.dispose = dispose; + + // Backward compatibility + this.attach = function(movemesh){ + console.log(movemesh); + _movemesh = movemesh; + originposition = movemesh.position.x; + let offset = (_movemesh.geometry.attributes.position.array[movemesh.rightlist[0]*3] - _movemesh.geometry.attributes.position.array[movemesh.leftlist[0]*3])/2; + cubegroup.children[0].position.x = movemesh.position.x + offset; + cubegroup.children[0].position.y = movemesh.position.y; + cubegroup.children[0].position.z = movemesh.position.z; + cubegroup.children[1].position.x = movemesh.position.x - offset; + cubegroup.children[1].position.y = movemesh.position.y; + cubegroup.children[1].position.z = movemesh.position.z; + + _scene.add(cubegroup); + } + + this.detach = function(){ + // _movemesh = ""; + _scene.remove(cubegroup); + } + + this.setObjects = function () { + + console.error( 'THREE.ScalControls: setObjects() has been removed.' ); + + }; + + this.on = function ( type, listener ) { + + console.warn( 'THREE.ScalControls: on() has been deprecated. Use addEventListener() instead.' ); + scope.addEventListener( type, listener ); + + }; + + this.off = function ( type, listener ) { + + console.warn( 'THREE.ScalControls: off() has been deprecated. Use removeEventListener() instead.' ); + scope.removeEventListener( type, listener ); + + }; + + this.notify = function ( type ) { + + console.error( 'THREE.ScalControls: notify() has been deprecated. Use dispatchEvent() instead.' ); + scope.dispatchEvent( { type: type } ); + + }; + +}; + +THREE.ScalControls.prototype = Object.create( THREE.EventDispatcher.prototype ); +THREE.ScalControls.prototype.constructor = THREE.ScalControls; diff --git a/src/jlmap3d/main/loaders/AssetLoader.js b/src/jlmap3d/main/loaders/AssetLoader.js index ba698ff44..ef70f88bc 100644 --- a/src/jlmap3d/main/loaders/AssetLoader.js +++ b/src/jlmap3d/main/loaders/AssetLoader.js @@ -28,7 +28,7 @@ let defaultstation = { deviceType:"stand", type:"num4", picUrl:"", - assetUrl:"https://joylink.club/oss/models/station/fuzhou/fuzhou.FBX" + assetUrl:"../../static/model/station/fuzhou.FBX" }//https://joylink.club/oss/models/station/fuzhou/fuzhou.FBX //../../static/model/station/zhantai715(2).FBX @@ -105,11 +105,8 @@ export function AssetLoader(){ let defaultmodel2 = new AssetModel(defaulttrain); scope.modellist.push(defaultmodel2); - let defaultmodel3 = new AssetModel(defaultstation); - scope.modellist.push(defaultmodel3); - - let defaultmodel4 = new AssetModel(defaultswitch); - scope.modellist.push(defaultmodel4); + let station = new AssetModel(defaultstation); + scope.modellist.push(station); let driver = new AssetModel(defaultdriver); scope.modellist.push(driver); @@ -117,7 +114,8 @@ export function AssetLoader(){ let suidao = new AssetModel(defaultsuidao); scope.modellist.push(suidao); - + let defaultswitch = new AssetModel(testswitch); + scope.modellist.push(defaultswitch); diff --git a/src/jlmap3d/main/loaders/model/Assetmodel.js b/src/jlmap3d/main/loaders/model/Assetmodel.js index bb5c5ad2c..b88dcc794 100644 --- a/src/jlmap3d/main/loaders/model/Assetmodel.js +++ b/src/jlmap3d/main/loaders/model/Assetmodel.js @@ -1,7 +1,7 @@ export function AssetModel(data){ let scope = this; - + this.id = data.id; this.name = data.name; diff --git a/src/views/jlmap3d/edit/component/menu.vue b/src/views/jlmap3d/edit/component/menu.vue index 544cacbd9..e8ca4c151 100644 --- a/src/views/jlmap3d/edit/component/menu.vue +++ b/src/views/jlmap3d/edit/component/menu.vue @@ -6,7 +6,13 @@ 旋转 - 拉伸 + 放大缩小 + + 拉伸 + + 测试轨迹 + + 自动匹配轨道信号灯 导出obj @@ -49,6 +55,15 @@ export default { async transscal(){ this.$emit('transscal'); }, + async vexscal(){ + this.$emit('vexscal'); + }, + async testrail(){ + this.$emit('testrail'); + }, + async autoss(){ + this.$emit('autoss'); + }, async expo(){ this.$emit('expo'); }, diff --git a/src/views/jlmap3d/edit/jlmap3dedit.vue b/src/views/jlmap3d/edit/jlmap3dedit.vue index e8cac8e33..297f8a70b 100644 --- a/src/views/jlmap3d/edit/jlmap3dedit.vue +++ b/src/views/jlmap3d/edit/jlmap3dedit.vue @@ -14,7 +14,7 @@ - @@ -150,12 +150,27 @@ }, transpos() { this.jlmap3dedit.transcontrol.setMode('translate'); + this.jlmap3dedit.vexscaloff(); }, transrota() { this.jlmap3dedit.transcontrol.setMode('rotate'); + this.jlmap3dedit.vexscaloff(); }, transscal() { this.jlmap3dedit.transcontrol.setMode('scale'); + this.jlmap3dedit.vexscaloff(); + }, + vexscal(){ + + this.jlmap3dedit.transcontrol.detach(); + this.jlmap3dedit.vexscal(); + console.log("vexscal"); + }, + testrail(){ + this.jlmap3dedit.testrail(); + }, + autoss(){ + this.jlmap3dedit.autoss(); }, expo() { @@ -164,9 +179,8 @@ save() { //console.log("save"); let param = getmodels(this.jlmap3dedit); - console.log(this.jlmap3dedit); console.log(param); - //console.log(param); + update3dMapData(param).then(data => { //console.log(data); if (data.code == "200") { diff --git a/static/model/auto/rail.FBX b/static/model/auto/rail.FBX index df02dc320..58c2aa49e 100644 Binary files a/static/model/auto/rail.FBX and b/static/model/auto/rail.FBX differ diff --git a/static/model/auto/railold.FBX b/static/model/auto/railold.FBX new file mode 100644 index 000000000..df02dc320 Binary files /dev/null and b/static/model/auto/railold.FBX differ diff --git a/static/model/auto/suidao.FBX b/static/model/auto/suidao.FBX index f386a1fe3..0ea58d08d 100644 Binary files a/static/model/auto/suidao.FBX and b/static/model/auto/suidao.FBX differ diff --git a/static/model/auto/suidaoold.FBX b/static/model/auto/suidaoold.FBX new file mode 100644 index 000000000..f386a1fe3 Binary files /dev/null and b/static/model/auto/suidaoold.FBX differ diff --git a/static/model/auto/testdaocha.FBX b/static/model/auto/testdaocha.FBX index a13713c2d..2b8070636 100644 Binary files a/static/model/auto/testdaocha.FBX and b/static/model/auto/testdaocha.FBX differ diff --git a/static/model/auto/testdaocha1.FBX b/static/model/auto/testdaocha1.FBX new file mode 100644 index 000000000..a13713c2d Binary files /dev/null and b/static/model/auto/testdaocha1.FBX differ diff --git a/static/model/station/fuzhou.FBX b/static/model/station/fuzhou.FBX index d8ae91271..c578639d3 100644 Binary files a/static/model/station/fuzhou.FBX and b/static/model/station/fuzhou.FBX differ diff --git a/static/model/station/zhantai715(1).FBX b/static/model/station/zhantai715(1).FBX deleted file mode 100644 index be229f4c1..000000000 Binary files a/static/model/station/zhantai715(1).FBX and /dev/null differ diff --git a/static/model/station/zhantai715.FBX b/static/model/station/zhantai715.FBX deleted file mode 100644 index cf24a65b9..000000000 Binary files a/static/model/station/zhantai715.FBX and /dev/null differ