diff --git a/src/jlmap3d/edit/jl3dEditorLoader.js b/src/jlmap3d/edit/jl3dEditorLoader.js index e055cde81..c6542c604 100644 --- a/src/jlmap3d/edit/jl3dEditorLoader.js +++ b/src/jlmap3d/edit/jl3dEditorLoader.js @@ -162,7 +162,7 @@ export function jl3dEditorLoader(mapid,scope){ .then(function(data){ //console.log(data); // return jlmap3ddata.sectionlist.initpromise(jlmap3ddata,assetloader,mapdata.sectionList,mapdata.switchList,scene); - return jlmap3ddata.sectionlist.loadpromise(jlmap3ddata,assetloader,sectiondata.section,scene); + return jlmap3ddata.sectionlist.loadpromise(jlmap3ddata,assetloader,sectiondata.section,mapdata.sectionList,mapdata.switchList,scene); }) .then(function(data){ //console.log(data); diff --git a/src/jlmap3d/edit/jlmap3dedit.js b/src/jlmap3d/edit/jlmap3dedit.js index 86bb47f90..6b8781022 100644 --- a/src/jlmap3d/edit/jlmap3dedit.js +++ b/src/jlmap3d/edit/jlmap3dedit.js @@ -282,11 +282,12 @@ export function JLmap3dEdit(dom, data, mapid) { } - this.vexscal = function(){ + this.vexscal = function(scalMode){ scope.transcontrol.detach() this.scalswitch = true; if(scope.selectmodel.railpoint){ - scalControls.attach(scope.selectmodel,scope.selectmodel.railpoint); + scalControls.updateDatalist(scope.mapdata.sectionlist.sections.datalist); + scalControls.attach(scope.selectmodel,scope.selectmodel.railpoint,scalMode); }else{ scalControls.attach(scope.selectmodel); } @@ -315,6 +316,120 @@ export function JLmap3dEdit(dom, data, mapid) { // scope.mapdata.signallist.resetsignal(scope.mapdata.linklist); }; + //区段跟左右相邻的区段对齐 + this.alignmentSection = function(alignmentCode,direct){ + 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 newRailPoint = []; + if(direct == "left"){ + if(alignmentModel.lsection){ + let connectSectionCode = alignmentModel.lsection; + let offsetX = alignmentModel.mesh.railpoint[0].x - scope.mapdata.sectionlist.sections.datalist[connectSectionCode].mesh.railpoint[2].x; + let offsetY = alignmentModel.mesh.railpoint[0].y - scope.mapdata.sectionlist.sections.datalist[connectSectionCode].mesh.railpoint[2].y; + let offsetZ = alignmentModel.mesh.railpoint[0].z - scope.mapdata.sectionlist.sections.datalist[connectSectionCode].mesh.railpoint[2].z; + + alignmentModel.railpoint[0].x = scope.mapdata.sectionlist.sections.datalist[connectSectionCode].mesh.railpoint[2].x; + alignmentModel.railpoint[0].y = scope.mapdata.sectionlist.sections.datalist[connectSectionCode].mesh.railpoint[2].y; + alignmentModel.railpoint[0].z = scope.mapdata.sectionlist.sections.datalist[connectSectionCode].mesh.railpoint[2].z; + + alignmentModel.railpoint[1].x -= offsetX; + alignmentModel.railpoint[1].y -= offsetY; + alignmentModel.railpoint[1].z -= offsetZ; + + alignmentModel.railpoint[2].x -= offsetX; + alignmentModel.railpoint[2].y -= offsetY; + alignmentModel.railpoint[2].z -= offsetZ; + + } + } + if(direct == "right"){ + if(alignmentModel.rsection){ + let connectSectionCode = alignmentModel.rsection; + let offsetX = alignmentModel.mesh.railpoint[2].x - scope.mapdata.sectionlist.sections.datalist[connectSectionCode].mesh.railpoint[0].x; + let offsetY = alignmentModel.mesh.railpoint[2].y - scope.mapdata.sectionlist.sections.datalist[connectSectionCode].mesh.railpoint[0].y; + let offsetZ = alignmentModel.mesh.railpoint[2].z - scope.mapdata.sectionlist.sections.datalist[connectSectionCode].mesh.railpoint[0].z; + + alignmentModel.railpoint[2].x = scope.mapdata.sectionlist.sections.datalist[connectSectionCode].mesh.railpoint[0].x; + alignmentModel.railpoint[2].y = scope.mapdata.sectionlist.sections.datalist[connectSectionCode].mesh.railpoint[0].y; + alignmentModel.railpoint[2].z = scope.mapdata.sectionlist.sections.datalist[connectSectionCode].mesh.railpoint[0].z; + + alignmentModel.railpoint[1].x -= offsetX; + alignmentModel.railpoint[1].y -= offsetY; + alignmentModel.railpoint[1].z -= offsetZ; + + alignmentModel.railpoint[0].x -= offsetX; + alignmentModel.railpoint[0].y -= offsetY; + alignmentModel.railpoint[0].z -= offsetZ + + } + } + + let newpointlist = []; + for(let i=0;i2){ + newAlignmentSection.lengthFact = newAlignmentSection.lengthFact/5; + } + + let len = newAlignmentSection.lengthFact; + // closedSpline.arcLengthDivisions; + let count = newAlignmentSection.geometry.attributes.position.count/3; + + for(let i=0;i2){ - // console.log(newsection); - console.log("======================="); - if(newsection.code == "T27"){ - console.log(newsection.railpoint[0]); - console.log(newsection.railpoint[1]); - console.log(newsection.railpoint[2]); - } let height = Math.random()/1000; var closedSpline = new THREE.CatmullRomCurve3( [ - new THREE.Vector3(newsection.railpoint[0].x,height,newsection.railpoint[0].z), - new THREE.Vector3(newsection.railpoint[1].x,height,newsection.railpoint[1].z+0.0001), - new THREE.Vector3(newsection.railpoint[2].x,height,newsection.railpoint[2].z) + new THREE.Vector3(newsection.railpoint[0].x,newsection.railpoint[0].y,newsection.railpoint[0].z), + new THREE.Vector3(newsection.railpoint[1].x,newsection.railpoint[1].y,newsection.railpoint[1].z+0.0001), + new THREE.Vector3(newsection.railpoint[2].x,newsection.railpoint[2].y,newsection.railpoint[2].z) ] ); closedSpline.type = 'catmullrom'; closedSpline.closed = false; @@ -864,8 +845,14 @@ export function SectionList() { extrudePath : closedSpline, }; var shape = new THREE.Shape(); - shape.moveTo( 0,-2 ); - shape.lineTo( 0, 2 ); + if(newsection.railpoint[0].y != newsection.railpoint[2].y){ + shape.moveTo( -2, 0 ); + shape.lineTo( 2, 0 ); + }else{ + shape.moveTo( 0,-2 ); + shape.lineTo( 0, 2 ); + } + var geometry = new THREE.ExtrudeBufferGeometry( shape, extrudeSettings ); var randomMaterail = new THREE.MeshLambertMaterial({ @@ -874,15 +861,15 @@ export function SectionList() { }); if(newsection.standTrack == false){ - testmesh2 = new THREE.Mesh( geometry, randomMaterail ); + testmesh2 = new THREE.Mesh( geometry, selectmaterial ); }else{ testmesh2 = new THREE.Mesh( geometry, selectmaterial ); } testmesh2.railpoint = [ - {x:newsection.railpoint[0].x,y:height,z:newsection.railpoint[0].z}, - {x:newsection.railpoint[1].x,y:height,z:newsection.railpoint[1].z}, - {x:newsection.railpoint[2].x,y:height,z:newsection.railpoint[2].z}, + {x:newsection.railpoint[0].x,y:newsection.railpoint[0].y,z:newsection.railpoint[0].z}, + {x:newsection.railpoint[1].x,y:newsection.railpoint[1].y,z:newsection.railpoint[1].z}, + {x:newsection.railpoint[2].x,y:newsection.railpoint[2].y,z:newsection.railpoint[2].z}, ]; testmesh2.lengthFact = newsection.railpoint[2].x-newsection.railpoint[0].x; let len = testmesh2.lengthFact; @@ -999,6 +986,100 @@ export function SectionList() { } + + for(let i=0;i cposx){ + if(aposy < cposy){ + // ——A + // /C + scope.sections.datalist[ccode].ctype = 1; + }else{ + // \C + // ——A + scope.sections.datalist[ccode].ctype = 2; + } + }else{ + if(aposy < cposy){ + // A—— + // \C + scope.sections.datalist[ccode].ctype = 3; + }else{ + // /C + // A—— + scope.sections.datalist[ccode].ctype = 4; + } + } + + scope.sections.datalist[acode].csection = ccode; + + if(scope.sections.datalist[ccode].ctype == 1 || scope.sections.datalist[ccode].ctype == 2){ + if(scope.sections.datalist[acode].lsection == "" || scope.sections.datalist[acode].lsection == undefined){ + scope.sections.datalist[acode].lsection = bcode; + } + + if(scope.sections.datalist[bcode].rsection == "" || scope.sections.datalist[bcode].rsection == undefined){ + scope.sections.datalist[bcode].rsection = acode; + } + + if(scope.sections.datalist[ccode].rsection == "" || scope.sections.datalist[ccode].rsection == undefined){ + scope.sections.datalist[ccode].rsection = acode; + }else if(scope.sections.datalist[ccode].lsection == "" || scope.sections.datalist[ccode].lsection == undefined){ + scope.sections.datalist[ccode].lsection = acode; + } + } + + if(scope.sections.datalist[ccode].ctype == 3 || scope.sections.datalist[ccode].ctype == 4){ + if(scope.sections.datalist[acode].rsection == "" || scope.sections.datalist[acode].rsection == undefined){ + scope.sections.datalist[acode].rsection = bcode; + } + + if(scope.sections.datalist[bcode].lsection == "" ||scope.sections.datalist[bcode].lsection == undefined ){ + scope.sections.datalist[bcode].lsection = acode; + } + + if(scope.sections.datalist[ccode].rsection == "" || scope.sections.datalist[ccode].rsection == undefined){ + scope.sections.datalist[ccode].rsection = acode; + }else if(scope.sections.datalist[ccode].lsection == "" || scope.sections.datalist[ccode].lsection == undefined){ + scope.sections.datalist[ccode].lsection = acode; + } + } + + + } + resolve("loadersection"); }); diff --git a/src/jlmap3d/edit/testEditorModel/StationStandList.js b/src/jlmap3d/edit/testEditorModel/StationStandList.js index eb064ca3b..b1075b2cb 100644 --- a/src/jlmap3d/edit/testEditorModel/StationStandList.js +++ b/src/jlmap3d/edit/testEditorModel/StationStandList.js @@ -126,10 +126,9 @@ export function StationStandList() { let newstationstand = new StationStandModel(standsdata[i]); let newstationmesh; let stands = []; - console.log("--------------------"); for(let j=0;j 0 || trainlisttest.list[code].children[2].rotalist.length > 0 || trainlisttest.list[code].children[3].rotalist.length > 0 || trainlisttest.list[code].children[4].rotalist.length > 0|| trainlisttest.list[code].children[5].rotalist.length > 0){ for(let rs = 1;rs<6;rs++){ //console.log(rs); if(trainlisttest.list[code].children[rs].rotalist[0]){ let offsetz = parseFloat(trainlisttest.list[code].children[rs].rotalist[0].posr.z) - parseFloat(trainlisttest.list[code].children[rs].matrixWorld.elements[14]); - trainlisttest.list[code].children[rs].position.z += offsetz; + // let offsety = parseFloat(trainlisttest.list[code].children[rs].rotalist[0].posr.y) - parseFloat(trainlisttest.list[code].children[rs].matrixWorld.elements[13]); + // trainlisttest.list[code].children[rs].position.y += offsety; for(let xh=0;xh=trainlisttest.list[code].children[rs].rotalist[0].posr.x){ @@ -307,7 +315,8 @@ export function Jlmap3dSubscribeNew(jlmap3d,routegroup,jsonwebwork) { } - trainlisttest.list[code].children[rs].rotation.z = trainlisttest.list[code].children[rs].rotalist[0].rota; + trainlisttest.list[code].children[rs].rotation.z = trainlisttest.list[code].children[rs].rotalist[0].rotz; + // trainlisttest.list[code].children[rs].rotation.y = trainlisttest.list[code].children[rs].rotalist[0].roty; trainlisttest.list[code].children[rs].rotalist.splice(0,1) xh--; }else{ @@ -348,7 +357,7 @@ export function Jlmap3dSubscribeNew(jlmap3d,routegroup,jsonwebwork) { // trainlisttest.list[code].len = rails.sectionrail[data.section].lengthfact; trainlisttest.list[code].status = '0'; - if(-trainlisttest.list[code].children[0].position.z != point.z){ + if(-trainlisttest.list[code].children[0].position.z != point.z || trainlisttest.list[code].children[0].position.y != point.y){ trainlisttest.list[code].children[0].up = new THREE.Vector3(-1,0,0); @@ -357,16 +366,21 @@ export function Jlmap3dSubscribeNew(jlmap3d,routegroup,jsonwebwork) { let radians = Math.acos(trainlisttest.list[code].children[0].up.dot(tangent)); trainlisttest.list[code].children[0].quaternion.setFromAxisAngle(trainlisttest.list[code].children[0].axis, radians); trainlisttest.list[code].children[0].rotation.x = -Math.PI/2; + let newRotationZ = trainlisttest.list[code].children[0].rotation.z; trainlisttest.list[code].children[0].rotation.z = trainlisttest.list[code].children[0].rotation.y; trainlisttest.list[code].children[0].rotation.y = 0; + // trainlisttest.list[code].children[0].rotation.y = -newRotationZ; let rotas = { posr:point, - rota:trainlisttest.list[code].children[0].rotation.z + roty:trainlisttest.list[code].children[0].rotation.y, + rotz:trainlisttest.list[code].children[0].rotation.z } trainlisttest.list[code].children[1].rotalist.push(rotas); let offsetz = point.z + trainlisttest.list[code].children[0].position.z; trainlisttest.list[code].children[0].position.z -= offsetz; + // let offsety = parseFloat(point.y) - parseFloat(trainlisttest.list[code].children[0].position.y); + // trainlisttest.list[code].children[0].position.y += offsety; // trainlisttest.list[code].position.z = point.z; } @@ -378,6 +392,8 @@ export function Jlmap3dSubscribeNew(jlmap3d,routegroup,jsonwebwork) { let offsetz = parseFloat(trainlisttest.list[code].children[rs].rotalist[0].posr.z) + parseFloat(trainlisttest.list[code].children[rs].position.z); trainlisttest.list[code].children[rs].position.z -= offsetz; + // let offsety = parseFloat(trainlisttest.list[code].children[rs].rotalist[0].posr.y) - parseFloat(trainlisttest.list[code].children[rs].matrixWorld.elements[13]); + // trainlisttest.list[code].children[rs].position.y += offsety; for(let xh=0;xh2){ + if(scalMode == "plane"){ + if(_movemesh.railpoint.length>2){ - if(_selected.name == "left"){ - newpointlist[0] = new THREE.Vector3(_selected.position.x,_movemesh.railpoint[0].y,_selected.position.z); + if(_selected.name == "left"){ + newpointlist[0] = new THREE.Vector3(_selected.position.x,_movemesh.railpoint[0].y,_selected.position.z); + } + if(_selected.name == "mid"){ + newpointlist[1] = new THREE.Vector3(_selected.position.x,_movemesh.railpoint[1].y,_selected.position.z); + } + if(_selected.name == "right"){ + newpointlist[2] = new THREE.Vector3(_selected.position.x,_movemesh.railpoint[2].y,_selected.position.z); + } + curvestep = 10; + }else{ + + if(_selected.name == "left"){ + newpointlist[0] = new THREE.Vector3(_selected.position.x,_movemesh.railpoint[0].y,_selected.position.z); + } + if(_selected.name == "right"){ + newpointlist[1] = new THREE.Vector3(_selected.position.x,_movemesh.railpoint[1].y,_selected.position.z); + } + curvestep =1; } - if(_selected.name == "mid"){ - newpointlist[1] = new THREE.Vector3(_selected.position.x,_movemesh.railpoint[0].y,_selected.position.z); - } - if(_selected.name == "right"){ - newpointlist[2] = new THREE.Vector3(_selected.position.x,_movemesh.railpoint[0].y,_selected.position.z); - } - curvestep = 10; }else{ + if(_movemesh.railpoint.length>2){ - if(_selected.name == "left"){ - newpointlist[0] = new THREE.Vector3(_selected.position.x,_movemesh.railpoint[0].y,_selected.position.z); + if(_selected.name == "left"){ + newpointlist[0] = new THREE.Vector3(_movemesh.railpoint[0].x,_selected.position.y,_movemesh.railpoint[0].z); + } + if(_selected.name == "mid"){ + newpointlist[1] = new THREE.Vector3(_movemesh.railpoint[1].x,_selected.position.y,_movemesh.railpoint[1].z); + } + if(_selected.name == "right"){ + newpointlist[2] = new THREE.Vector3(_movemesh.railpoint[2].x,_selected.position.y,_movemesh.railpoint[2].z); + } + curvestep = 10; + }else{ + + if(_selected.name == "left"){ + newpointlist[0] = new THREE.Vector3(_movemesh.railpoint[0].x,_selected.position.y,_movemesh.railpoint[0].z); + } + if(_selected.name == "right"){ + newpointlist[1] = new THREE.Vector3(_movemesh.railpoint[1].x,_selected.position.y,_movemesh.railpoint[1].z); + } + curvestep =1; } - if(_selected.name == "right"){ - newpointlist[1] = new THREE.Vector3(_selected.position.x,_movemesh.railpoint[0].y,_selected.position.z); - } - curvestep =1; } + closedSpline = new THREE.CatmullRomCurve3(newpointlist); closedSpline.type = 'catmullrom'; closedSpline.closed = false; @@ -398,8 +429,16 @@ THREE.ScalControls = function ( scene,_camera, _domElement ) { }; var shape = new THREE.Shape(); - shape.moveTo( 0,-2 ); - shape.lineTo( 0, 2 ); + if(newpointlist[0].y != newpointlist[2].y){ + shape.moveTo( -2, 0 ); + shape.lineTo( 2, 0 ); + }else{ + shape.moveTo( 0,-2 ); + shape.lineTo( 0, 2 ); + } + + + selectmaterial = _movemesh.material; var geometry = new THREE.ExtrudeBufferGeometry( shape, extrudeSettings ); _movemesh = new THREE.Mesh( geometry, selectmaterial ); @@ -440,6 +479,8 @@ THREE.ScalControls = function ( scene,_camera, _domElement ) { } } _movemesh.meshtype = "section"; + sectionList[_movemesh.code].mesh = _movemesh; + sectionList[_movemesh.code].railpoint = _movemesh.railpoint; // _movemesh.geometry.computeBoundingBox(); // _movemesh.geometry.center() // _movemesh.position.set(oldobject.position.x,oldobject.position.y,oldobject.position.z); @@ -458,8 +499,12 @@ THREE.ScalControls = function ( scene,_camera, _domElement ) { this.deactivate = deactivate; this.dispose = dispose; + this.updateDatalist = function(sectionDataList){ + sectionList = sectionDataList; + } // Backward compatibility - this.attach = function(movemesh,points){ + this.attach = function(movemesh,points,mode){ + scalMode = mode; if(!helpmove){ if(points){ diff --git a/src/jlmap3d/main/control/TransformControls.js b/src/jlmap3d/main/control/TransformControls.js index 46d53435e..ffc3bcd2a 100644 --- a/src/jlmap3d/main/control/TransformControls.js +++ b/src/jlmap3d/main/control/TransformControls.js @@ -162,12 +162,12 @@ THREE.TransformControls = function ( camera, domElement ) { let len = object.railpoint.length-1; - cube1.position.set(object.railpoint[0].x-object.position.x,0,object.railpoint[0].z-object.position.z); - cube3.position.set(object.railpoint[len].x-object.position.x,0,object.railpoint[len].z-object.position.z); + cube1.position.set(object.railpoint[0].x-object.position.x,object.railpoint[0].y,object.railpoint[0].z-object.position.z); + cube3.position.set(object.railpoint[len].x-object.position.x,object.railpoint[len].y,object.railpoint[len].z-object.position.z); atobject.add(cube1); atobject.add(cube3); if(object.railpoint.length>2){ - cube2.position.set(object.railpoint[1].x-object.position.x,0,object.railpoint[1].z-object.position.z); + cube2.position.set(object.railpoint[1].x-object.position.x,object.railpoint[1].y,object.railpoint[1].z-object.position.z); atobject.add(cube2); virtualmovebox.position.set(cube2.position.x,cube2.position.y,cube2.position.z); }else{ diff --git a/src/jlmap3d/main/newmodel/RailListN.js b/src/jlmap3d/main/newmodel/RailListN.js index abe2e1a3a..5354d8bbe 100644 --- a/src/jlmap3d/main/newmodel/RailListN.js +++ b/src/jlmap3d/main/newmodel/RailListN.js @@ -231,14 +231,15 @@ export function RailListN(){ } scope.sectionrail[sectioncode].lineleft = new THREE.CatmullRomCurve3(leftpoints); - scope.sectionrail[sectioncode].lineleft.curveType = "centripetal"; + scope.sectionrail[sectioncode].lineleft.type = "catmullrom"; + scope.sectionrail[sectioncode].lineleft.closed = false; scope.sectionrail[sectioncode].lineleft.name = sectioncode; scope.sectionrail[sectioncode].lineright = new THREE.CatmullRomCurve3(rightpoints); - scope.sectionrail[sectioncode].lineright.curveType = "centripetal"; + scope.sectionrail[sectioncode].lineright.type = "catmullrom"; + scope.sectionrail[sectioncode].lineright.closed = false; scope.sectionrail[sectioncode].lineright.name = sectioncode; - // // // for(let n=0,nm=scope.sectionrail[sectioncode].lineleft.points.length;n放大缩小 - 拉伸 + 测试轨迹 @@ -57,9 +57,6 @@ export default { async transscal(){ this.$emit('transscal'); }, - async vexscal(){ - this.$emit('vexscal'); - }, async testrail(){ this.$emit('testrail'); }, diff --git a/src/views/jlmap3d/edit/component/property.vue b/src/views/jlmap3d/edit/component/property.vue index 50b86f8e9..59b03d899 100644 --- a/src/views/jlmap3d/edit/component/property.vue +++ b/src/views/jlmap3d/edit/component/property.vue @@ -45,6 +45,13 @@ + 区段左对齐 + + 区段右对齐 + + 平面拉伸 + + 高度改变