增加信号机位置重置
This commit is contained in:
parent
2551a4d595
commit
2c5284b6c4
@ -46,8 +46,8 @@ export function Jlmap3ddata(mapid,scope){
|
|||||||
}else{
|
}else{
|
||||||
// console.log(editmapid);
|
// console.log(editmapid);
|
||||||
// console.log(data.data.id);
|
// console.log(data.data.id);
|
||||||
// init3d(editmapid,data.data);
|
init3d(editmapid,data.data);
|
||||||
initobj(editmapid,data.data.id);
|
// initobj(editmapid,data.data.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -154,7 +154,7 @@ export function Jlmap3ddata(mapid,scope){
|
|||||||
})
|
})
|
||||||
.then(function(data){
|
.then(function(data){
|
||||||
//console.log(data);
|
//console.log(data);
|
||||||
return jlmap3ddata.signallist.loadpromise(signaldata,scene,assetloader);
|
return jlmap3ddata.signallist.loadpromise(signaldata,scene,assetloader,mapdata.signalList);
|
||||||
})
|
})
|
||||||
.then(function(data){
|
.then(function(data){
|
||||||
//console.log(data);
|
//console.log(data);
|
||||||
|
@ -89,7 +89,7 @@ function linkhelp(data,scene){
|
|||||||
testmesh2.lengthfact = data[i].lengthfact;
|
testmesh2.lengthfact = data[i].lengthfact;
|
||||||
|
|
||||||
for(let i=0;i<testmesh2.rightlist.length;i++){
|
for(let i=0;i<testmesh2.rightlist.length;i++){
|
||||||
testmesh2.geometry.attributes.position.array[testmesh2.rightlist[i]*3] = testmesh2.lengthfact-29;
|
testmesh2.geometry.attributes.position.array[testmesh2.rightlist[i]*3] = testmesh2.lengthfact-25;
|
||||||
testmesh2.geometry.attributes.uv.array[testmesh2.rightlist[i]*2] = testmesh2.geometry.attributes.position.array[0]-testmesh2.geometry.attributes.position.array[3];
|
testmesh2.geometry.attributes.uv.array[testmesh2.rightlist[i]*2] = testmesh2.geometry.attributes.position.array[0]-testmesh2.geometry.attributes.position.array[3];
|
||||||
}
|
}
|
||||||
let newrail = new THREE.BufferGeometry();
|
let newrail = new THREE.BufferGeometry();
|
||||||
@ -208,7 +208,7 @@ function linkhelp(data,scene){
|
|||||||
|
|
||||||
let testmesh2 = autorail.clone(true);
|
let testmesh2 = autorail.clone(true);
|
||||||
for(let i=0;i<autorail.rightlist.length;i++){
|
for(let i=0;i<autorail.rightlist.length;i++){
|
||||||
testmesh2.geometry.attributes.position.array[autorail.rightlist[i]*3] = len-26;
|
testmesh2.geometry.attributes.position.array[autorail.rightlist[i]*3] = len-25;
|
||||||
testmesh2.geometry.attributes.uv.array[autorail.rightlist[i]*2] = testmesh2.geometry.attributes.position.array[0]-testmesh2.geometry.attributes.position.array[3];
|
testmesh2.geometry.attributes.uv.array[autorail.rightlist[i]*2] = testmesh2.geometry.attributes.position.array[0]-testmesh2.geometry.attributes.position.array[3];
|
||||||
}
|
}
|
||||||
let newrail = new THREE.BufferGeometry();
|
let newrail = new THREE.BufferGeometry();
|
||||||
|
@ -15,7 +15,7 @@ export function RailList(){
|
|||||||
|
|
||||||
let raillink = mapdata.linklist.linksgroup.children;
|
let raillink = mapdata.linklist.linksgroup.children;
|
||||||
for(let i=0;i<raillink.length;i++){
|
for(let i=0;i<raillink.length;i++){
|
||||||
var geometry = new THREE.PlaneBufferGeometry( raillink[i].lengthfact-20.5, 0.1, 0.1 );
|
var geometry = new THREE.PlaneBufferGeometry( raillink[i].lengthfact-25, 0.1, 0.1 );
|
||||||
var material = new THREE.MeshBasicMaterial( {color: 0xffff00, side: THREE.DoubleSide} );
|
var material = new THREE.MeshBasicMaterial( {color: 0xffff00, side: THREE.DoubleSide} );
|
||||||
var plane = new THREE.Mesh( geometry, material );
|
var plane = new THREE.Mesh( geometry, material );
|
||||||
plane.position.x = raillink[i].position.x;
|
plane.position.x = raillink[i].position.x;
|
||||||
@ -29,14 +29,14 @@ export function RailList(){
|
|||||||
var geometry2 = new THREE.CircleBufferGeometry( 1, 16 );
|
var geometry2 = new THREE.CircleBufferGeometry( 1, 16 );
|
||||||
var material2 = new THREE.MeshBasicMaterial( { color: 0xff2000 } );
|
var material2 = new THREE.MeshBasicMaterial( { color: 0xff2000 } );
|
||||||
var circle1 = new THREE.Mesh( geometry1, material1 );
|
var circle1 = new THREE.Mesh( geometry1, material1 );
|
||||||
circle1.position.x = plane.position.x + (raillink[i].lengthfact-20.5)/2*Math.cos(plane.rotation.z);
|
circle1.position.x = plane.position.x + (raillink[i].lengthfact-25)/2*Math.cos(plane.rotation.z);
|
||||||
circle1.position.z = plane.position.z - (raillink[i].lengthfact-20.5)/2*Math.sin(plane.rotation.z);
|
circle1.position.z = plane.position.z - (raillink[i].lengthfact-25)/2*Math.sin(plane.rotation.z);
|
||||||
circle1.rotation.x = -Math.PI/2;
|
circle1.rotation.x = -Math.PI/2;
|
||||||
scene.add( circle1 );
|
scene.add( circle1 );
|
||||||
|
|
||||||
var circle2 = new THREE.Mesh( geometry2, material2 );
|
var circle2 = new THREE.Mesh( geometry2, material2 );
|
||||||
circle2.position.x = plane.position.x - (raillink[i].lengthfact-20.5)/2*Math.cos(plane.rotation.z);
|
circle2.position.x = plane.position.x - (raillink[i].lengthfact-25)/2*Math.cos(plane.rotation.z);
|
||||||
circle2.position.z = plane.position.z + (raillink[i].lengthfact-20.5)/2*Math.sin(plane.rotation.z);
|
circle2.position.z = plane.position.z + (raillink[i].lengthfact-25)/2*Math.sin(plane.rotation.z);
|
||||||
circle2.rotation.x = -Math.PI/2;
|
circle2.rotation.x = -Math.PI/2;
|
||||||
scene.add( circle2 );
|
scene.add( circle2 );
|
||||||
scene.add( plane );
|
scene.add( plane );
|
||||||
|
@ -549,6 +549,10 @@ export function SectionList() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.resetsection = function(scene){
|
||||||
|
scene.remove(sectiongroup);
|
||||||
|
};
|
||||||
|
|
||||||
this.reposition = function(){
|
this.reposition = function(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,10 @@ export function SignalList() {
|
|||||||
newmesh.scale.x = 0.05;
|
newmesh.scale.x = 0.05;
|
||||||
newmesh.scale.y = 0.05;
|
newmesh.scale.y = 0.05;
|
||||||
newmesh.scale.z = 0.05;
|
newmesh.scale.z = 0.05;
|
||||||
|
newmesh.offset = data[i].offset;
|
||||||
|
newmest.linkCode = data[i].linkCode;
|
||||||
newsignal.mesh = newmesh;
|
newsignal.mesh = newmesh;
|
||||||
|
newsignal.offset = data[i].offset;
|
||||||
newsignal.mesh.status = "01";
|
newsignal.mesh.status = "01";
|
||||||
scope.group.add(newsignal.mesh);
|
scope.group.add(newsignal.mesh);
|
||||||
scope.list.push(newsignal);
|
scope.list.push(newsignal);
|
||||||
@ -101,7 +104,7 @@ export function SignalList() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.loadpromise = function(signaldata,scene,assetloader){
|
this.loadpromise = function(signaldata,scene,assetloader,data){
|
||||||
return new Promise(function(resolve, reject){
|
return new Promise(function(resolve, reject){
|
||||||
for(let i=0;i<signaldata.length;i++){
|
for(let i=0;i<signaldata.length;i++){
|
||||||
let newsignal = new SignalModel(signaldata[i]);
|
let newsignal = new SignalModel(signaldata[i]);
|
||||||
@ -111,11 +114,15 @@ export function SignalList() {
|
|||||||
num = j;
|
num = j;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let newmesh = assetloader.modellist[num].mesh.clone(true);
|
let newmesh = assetloader.modellist[num].mesh.clone(true);
|
||||||
newmesh.uuid = signaldata[i].id;
|
newmesh.uuid = signaldata[i].id;
|
||||||
newmesh.name = signaldata[i].name;
|
newmesh.name = signaldata[i].name;
|
||||||
newmesh.modelid = assetloader.modellist[num].id;
|
newmesh.modelid = assetloader.modellist[num].id;
|
||||||
newmesh.code = signaldata[i].code;
|
newmesh.code = signaldata[i].code;
|
||||||
|
newmesh.offset = data[i].offset;
|
||||||
|
newmesh.linkCode = data[i].linkCode;
|
||||||
|
newmesh.directionType = data[i].directionType;
|
||||||
newmesh.position.x = signaldata[i].position.x;
|
newmesh.position.x = signaldata[i].position.x;
|
||||||
newmesh.position.y = signaldata[i].position.y;
|
newmesh.position.y = signaldata[i].position.y;
|
||||||
newmesh.position.z = signaldata[i].position.z;
|
newmesh.position.z = signaldata[i].position.z;
|
||||||
@ -132,7 +139,30 @@ export function SignalList() {
|
|||||||
resolve("loadedsignal");
|
resolve("loadedsignal");
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
this.resetsignal = function(jlmap3ddata){
|
||||||
|
console.log(jlmap3ddata.linksgroup);
|
||||||
|
console.log(scope);
|
||||||
|
let linkdata = jlmap3ddata.linksgroup;
|
||||||
|
for(let i=0;i<scope.group.children.length;i++){
|
||||||
|
let signaldata = scope.group.children[i];
|
||||||
|
let link = linkdata.getObjectByProperty("code",signaldata.linkCode);
|
||||||
|
let posx = null;
|
||||||
|
|
||||||
|
if(signaldata.offset > link.lengthfact/2){
|
||||||
|
posx = link.position.x + signaldata.offset - link.lengthfact/2-10;
|
||||||
|
}else{
|
||||||
|
posx = link.position.x - (link.lengthfact/2 - signaldata.offset)+10;
|
||||||
|
}
|
||||||
|
//根据线路方向修改信号灯位置
|
||||||
|
if(signaldata.directionType == "01"){
|
||||||
|
signaldata.position.set(posx,0,link.position.z-3);
|
||||||
|
signaldata.rotation.z = ( Math.PI / 2 );
|
||||||
|
}else if(signaldata.directionType == "02"){
|
||||||
|
signaldata.position.set(posx,0,link.position.z+3);
|
||||||
|
signaldata.rotation.z = ( - Math.PI / 2 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
this.init = function(data,realsectionlist,scene,assetloader){
|
this.init = function(data,realsectionlist,scene,assetloader){
|
||||||
|
|
||||||
|
|
||||||
|
@ -243,6 +243,8 @@ export function JLmap3dEdit(dom, data, mapid) {
|
|||||||
|
|
||||||
this.autoss = function(){
|
this.autoss = function(){
|
||||||
console.log("autoss");
|
console.log("autoss");
|
||||||
|
console.log(scope.mapdata);
|
||||||
|
scope.mapdata.signallist.resetsignal(scope.mapdata.linklist);
|
||||||
};
|
};
|
||||||
|
|
||||||
function onWindowResize() {
|
function onWindowResize() {
|
||||||
|
@ -142,7 +142,7 @@ THREE.ScalControls = function ( scene,_camera, _domElement ) {
|
|||||||
// _movemesh.geometry.computeBoundingBox();
|
// _movemesh.geometry.computeBoundingBox();
|
||||||
_movemesh.geometry.computeBoundingSphere();
|
_movemesh.geometry.computeBoundingSphere();
|
||||||
_movemesh.geometry.center();
|
_movemesh.geometry.center();
|
||||||
_movemesh.lengthfact = (_movemesh.geometry.attributes.position.array[_movemesh.rightlist[0]] - _movemesh.geometry.attributes.position.array[_movemesh.leftlist[0]])*2+20.5;
|
_movemesh.lengthfact = (_movemesh.geometry.attributes.position.array[_movemesh.rightlist[0]] - _movemesh.geometry.attributes.position.array[_movemesh.leftlist[0]])*2+28.5;
|
||||||
// testmesh2.position.z = 50;
|
// testmesh2.position.z = 50;
|
||||||
|
|
||||||
// testmesh2.geometry.center();
|
// testmesh2.geometry.center();
|
||||||
|
Loading…
Reference in New Issue
Block a user