diff --git a/src/jlmap3d/edit/Jlmap3ddata.js b/src/jlmap3d/edit/Jlmap3ddata.js index 15e326824..5a065ce20 100644 --- a/src/jlmap3d/edit/Jlmap3ddata.js +++ b/src/jlmap3d/edit/Jlmap3ddata.js @@ -86,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); @@ -106,6 +106,7 @@ export function Jlmap3ddata(mapid,scope){ }) .then(function(data){ //console.log(data); + LinkList(mapdata.linkList,scene,assetloader); loadingInstance.close(); }); //初始化信号 diff --git a/src/jlmap3d/edit/editmodel/LinkList.js b/src/jlmap3d/edit/editmodel/LinkList.js index b469dc513..837896adf 100644 --- a/src/jlmap3d/edit/editmodel/LinkList.js +++ b/src/jlmap3d/edit/editmodel/LinkList.js @@ -1,5 +1,5 @@ -export function LinkList(data,scene){ +export function LinkList(data,scene,assetloader){ let groups = new THREE.Group(); let linklist = []; @@ -29,215 +29,270 @@ export function LinkList(data,scene){ let linksgroup = new THREE.Group(); linksgroup.name = "link"; scene.add(linksgroup); - console.log(linksgroup); + + let suidaogroup = new THREE.Group(); + suidaogroup.name = "suidao"; + scene.add(suidaogroup); + linktest(data,scene); // return linklist; - function linktest(data,scene){ - let texture = new THREE.TextureLoader().load( '../../static/material/guidao/z025111.png' ); - texture.repeat.set(1,1); - texture.wrapS = texture.wrapT = THREE.RepeatWrapping; - // texture.repeat.x = 2000; - let testmaterial = new THREE.MeshPhongMaterial( { map: texture } ); + function linktest(data,scene){ + console.log(assetloader.modellist); + let autorail = null; + let autosuidao = null; + for(let i=0;i0.49){ + rightlist.push(i); + } + if(autorail.geometry.attributes.position.array[i*3] <-0.49){ + leftlist.push(i); + } + } - let testmesh1 = new THREE.Mesh( new THREE.PlaneBufferGeometry( 1, 4 ), testmaterial ); - testmesh1.rotation.x = - Math.PI / 2; + autorail.rightlist = rightlist; + autorail.leftlist = leftlist; - let reallinks = []; - let testlink; - testlink = data; - if(data){ - let index,startdata; - for(let n=0;n0.49){ + rightlist.push(i); + } + if(autosuidao.geometry.attributes.position.array[i*3] <-0.49){ + leftlist.push(i); + } + } + autosuidao.rightlist = rightlist; + autosuidao.leftlist = leftlist; + + console.log(autorail); + console.log(autosuidao); + + let reallinks = []; + let testlink; + testlink = data; + if(data){ + let index,startdata; + for(let n=0;n=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; + startdata = data[n]; + index = n; + } + } + } + buildmodel(startdata); + reallinks.push(startdata); + data.splice(index,1); + + + 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(data); + let len = data.lengthFact; + // console.log(autorail); + // console.log(autosuidao); + + let testmesh2 = autorail.clone(true); + + for(let i=0;idata.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; + } + } - testmesh2.position.y = 10; - testmesh2.code = data.code; - var box = new THREE.BoxHelper( testmesh2, 0xff0000 ); - scene.add( box ); - linksgroup.add( testmesh2 ); + + }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; + testmesh1.position.x = testmesh2.position.x; + testmesh1.position.z = testmesh2.position.z; + testmesh1.rotation.x = -Math.PI/2; + testmesh1.rotation.z = testmesh2.rotation.z; + var box = new THREE.BoxHelper( testmesh2, 0xff0000 ); + scene.add( box ); + suidaogroup.add( testmesh1 ); + linksgroup.add( testmesh2 ); } } } +} diff --git a/src/jlmap3d/main/loaders/AssetLoader.js b/src/jlmap3d/main/loaders/AssetLoader.js index d952e6d79..d0c2eb2e2 100644 --- a/src/jlmap3d/main/loaders/AssetLoader.js +++ b/src/jlmap3d/main/loaders/AssetLoader.js @@ -60,9 +60,23 @@ let defaultsuidao = { }//https://joylink.club/oss/models/suidao/suidao.FBX //../../static/model/ +let defaultautorail = { + id:"100", + name:"autorail", + deviceType:"autorail", + type:"autorail", + picUrl:"", + assetUrl:"../../static/model/auto/rail.FBX" +} - - +let defaultautosuidao = { + id:"101", + name:"autosuidao", + deviceType:"autosuidao", + type:"autosuidao", + picUrl:"", + assetUrl:"../../static/model/auto/suidao.FBX" +} export function AssetLoader(){ @@ -95,6 +109,9 @@ export function AssetLoader(){ scope.modellist.push(suidao); + + + let modeldata = JSON.parse(data); for(let j=0;j