diff --git a/src/jlmap3d/edit/Jlmap3ddata.js b/src/jlmap3d/edit/Jlmap3ddata.js index ef0be8a51..15e326824 100644 --- a/src/jlmap3d/edit/Jlmap3ddata.js +++ b/src/jlmap3d/edit/Jlmap3ddata.js @@ -42,7 +42,8 @@ export function Jlmap3ddata(mapid,scope){ console.log(isSection); if(isSection == true){ - init3d(editmapid,data.data); + initobj(editmapid,data.data.id); + //init3d(editmapid,data.data); }else{ // console.log(editmapid); // console.log(data.data.id); @@ -74,6 +75,7 @@ export function Jlmap3ddata(mapid,scope){ console.log(mapid); getMapDetail(mapid).then(data => { let mapdata = data.data; + console.log(mapdata); //console.log(data3did); jlmap3ddata.id = data3did; jlmap3ddata.mapId = mapid; @@ -84,7 +86,7 @@ export function Jlmap3ddata(mapid,scope){ //初始化站台 jlmap3ddata.stationstandlist = new StationStandList(); jlmap3ddata.trainlisttest = new TrainListTest(); - + LinkList(mapdata.linkList,scene); assetloader.assetinit(scene) .then(function(data){ //console.log(data); @@ -107,7 +109,7 @@ export function Jlmap3ddata(mapid,scope){ loadingInstance.close(); }); //初始化信号 - SetObj(mapdata,scope); + //SetObj(mapdata,scope); }); } diff --git a/src/jlmap3d/edit/action/sectionaction.js b/src/jlmap3d/edit/action/sectionaction.js index 3bda18c4e..a421c2254 100644 --- a/src/jlmap3d/edit/action/sectionaction.js +++ b/src/jlmap3d/edit/action/sectionaction.js @@ -36,34 +36,60 @@ export function Sectionaction(){ } } //点击事件 - this.raycaster = function(data){ - console.log(); - if(scope.on == true){ + this.raycaster = function(data,type){ + console.log("sa"); + 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; - //定义光线 - 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;i=0){ + if(reallinks[i].leftFdCode == data[j].code){ + buildmodel(data[j],reallinks[i],j,"left"); + reallinks.push(data[j]); + data.splice(j,1); + j--; + } + } + if(reallinks[i].leftSdCode && j>=0){ + + if(reallinks[i].leftSdCode == data[j].code){ + buildmodel(data[j],reallinks[i],j,"left"); + reallinks.push(data[j]); + data.splice(j,1); + j--; + } + } + + if(reallinks[i].rightFdCode && j>=0){ + if(reallinks[i].rightFdCode == data[j].code){ + + buildmodel(data[j],reallinks[i],j,"right"); + reallinks.push(data[j]); + data.splice(j,1); + j--; + } + } + + if(reallinks[i].rightSdCode && j>=0){ + if(reallinks[i].rightSdCode == data[j].code){ + buildmodel(data[j],reallinks[i],j,"right"); + reallinks.push(data[j]); + data.splice(j,1); + j--; + } + } + + } + } + + function checklink(code,data){ + if(code == data.leftFdCode){ + + } + if(code == data.leftSdCode){ + + } + if(code == data.rightFdCode){ + + } + if(code == data.rightSdCode){ + + } + } + + function buildmodel(data,mdata,sx,direct){ + console.log("sa"); + let len = data.lengthFact; + let testmesh2 = testmesh1.clone(true); + let newgeometry = new THREE.PlaneBufferGeometry( 1, 4 ); + for(let j=0;jdata.rp.y){ + testmesh2.rotation.z = rotenum; + }else { + testmesh2.rotation.z = -rotenum; + } + } + + if(direct == "right"){ + + let dx = Math.abs(data.lp.x - data.rp.x); +     let dy = Math.abs(data.lp.y - data.rp.y); +     let distance = Math.sqrt(Math.pow(dx,2)+Math.pow(dy,2)); + data.rp.x = (data.rp.x-data.lp.x)*data.lengthFact/distance+mdata.rp.x; + data.rp.y = (data.rp.y-data.lp.y)*data.lengthFact/distance+mdata.rp.y; + + data.lp.x = mdata.rp.x; + data.lp.y = mdata.rp.y; + testmesh2.position.x = (data.lp.x + data.rp.x)/2; + testmesh2.position.z = (data.lp.y + data.rp.y)/2; + + let axix = new THREE.Vector3(1,0,0); + let axixnow = new THREE.Vector3(data.rp.x-data.lp.x,0,data.rp.y-data.lp.y); + let rotenum = axixnow.angleTo(axix); + //不同坐标系方向值不同 + if(data.lp.y>data.rp.y){ + testmesh2.rotation.z = rotenum; + }else { + testmesh2.rotation.z = -rotenum; + } + + } + + }else{ + data.lp.x = data.lp.x; + data.rp.x = data.lp.x + data.lengthFact; + + testmesh2.position.x = (data.lp.x + data.rp.x)/2; + testmesh2.position.z = (data.lp.y + data.rp.y)/2; + + } + testmesh2.position.y = 10; + testmesh2.code = data.code; + var box = new THREE.BoxHelper( testmesh2, 0xff0000 ); + scene.add( box ); + linksgroup.add( testmesh2 ); + } + } + } } diff --git a/src/jlmap3d/edit/jlmap3dedit.js b/src/jlmap3d/edit/jlmap3dedit.js index 6b546948d..14c8ff96a 100644 --- a/src/jlmap3d/edit/jlmap3dedit.js +++ b/src/jlmap3d/edit/jlmap3dedit.js @@ -152,14 +152,21 @@ export function JLmap3dEdit(dom, data, mapid) { } this.actiommode = function(changedata){ + console.log(changedata); console.log(scope.editmode); // console.log(scope.actionmode); // console.log(changedata); - if(scope.editmode == "trackedit"){ - scope.selectmodel = scope.action.sectionaction.changemodel(scope,changedata); + if(changedata == "trackreplace"){ + scope.editmode == "trackedit"; + scope.eventon(); } + // if(scope.editmode == "trackedit"){ + // scope.selectmodel = scope.action.sectionaction.changemodel(scope,changedata); + // } + + if(scope.actionmode == "signaledit"){ scope.selectmodel = scope.action.signalaction.changemodel(scope,changedata); } @@ -208,7 +215,7 @@ export function JLmap3dEdit(dom, data, mapid) { //从站台对象组获取点击目标 if(scope.editmode == "trackedit"){ - scope.selectmodel = scope.action.sectionaction.raycaster(scope); + scope.selectmodel = scope.action.sectionaction.raycaster(scope,"test"); } if(scope.editmode == "signaledit"){ diff --git a/static/material/guidao/z025111.png b/static/material/guidao/z025111.png new file mode 100644 index 000000000..77747e3e1 Binary files /dev/null and b/static/material/guidao/z025111.png differ