This commit is contained in:
zyy 2020-09-16 17:53:44 +08:00
commit 8c9f18f239
16 changed files with 600 additions and 110 deletions

View File

@ -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);

View File

@ -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;i<alignmentModel.railpoint.length;i++){
newpointlist.push(new THREE.Vector3(alignmentModel.railpoint[i].x,alignmentModel.railpoint[i].y,alignmentModel.railpoint[i].z));
}
let closedSpline = new THREE.CatmullRomCurve3(newpointlist);
closedSpline.type = 'catmullrom';
closedSpline.closed = false;
let extrudeSettings = {
steps : 5,
curveSegments : 1,
bevelSegments : 1,
bevelEnabled : false,
extrudePath : closedSpline,
};
var shape = new THREE.Shape();
shape.moveTo( 0,-2 );
shape.lineTo( 0, 2 );
let selectmaterial = oldobject.material;
var geometry = new THREE.ExtrudeBufferGeometry( shape, extrudeSettings );
let newAlignmentSection = new THREE.Mesh( geometry, selectmaterial );
newAlignmentSection.code = oldobject.code;
newAlignmentSection.railpoint = [];
for(let i=0;i<newpointlist.length;i++){
newAlignmentSection.railpoint[i] = {
x:newpointlist[i].x,
y:newpointlist[i].y,
z:newpointlist[i].z
}
}
newAlignmentSection.lengthFact = closedSpline.arcLengthDivisions/4;
if(newpointlist.length>2){
newAlignmentSection.lengthFact = newAlignmentSection.lengthFact/5;
}
let len = newAlignmentSection.lengthFact;
// closedSpline.arcLengthDivisions;
let count = newAlignmentSection.geometry.attributes.position.count/3;
for(let i=0;i<count;i++){
let ui=i*6;
if(i%2 != 0){
newAlignmentSection.geometry.attributes.uv.array[ui] = 0;
newAlignmentSection.geometry.attributes.uv.array[ui+1] = 1;
newAlignmentSection.geometry.attributes.uv.array[ui+2] = len;
newAlignmentSection.geometry.attributes.uv.array[ui+3] = 1;
newAlignmentSection.geometry.attributes.uv.array[ui+4] = len;
newAlignmentSection.geometry.attributes.uv.array[ui+5] = 0;
}else{
newAlignmentSection.geometry.attributes.uv.array[ui] = 0;
newAlignmentSection.geometry.attributes.uv.array[ui+1] = 0;
newAlignmentSection.geometry.attributes.uv.array[ui+2] = 0;
newAlignmentSection.geometry.attributes.uv.array[ui+3] = 1;
newAlignmentSection.geometry.attributes.uv.array[ui+4] = len;
newAlignmentSection.geometry.attributes.uv.array[ui+5] = 0;
}
}
newAlignmentSection.meshtype = "section";
scope.mapdata.sectionlist.sections.datalist[alignmentCode].mesh = newAlignmentSection;
objectparent.add(newAlignmentSection);
};
function onWindowResize() {
//窗口自适应
scope.camera.aspect = window.innerWidth / window.innerHeight;

View File

@ -331,11 +331,7 @@ export function SectionList() {
console.log(stopsections[i]);
if(stopsections[i+1] ){
for(let j=0,lenj=stopsections[i].reals.length;j<lenj;j++){
console.log("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
console.log(stopsections[i].reals[j]);
console.log(scope.sections.datalist);
console.log(scope.sections.datalist[stopsections[i].reals[j].section.rightSectionCode]);
let topnextpoint = {};
if(scope.sections.datalist[stopsections[i].reals[j].section.code].railpoint == 0){
@ -388,14 +384,14 @@ export function SectionList() {
assetloader.modellist[num2].mesh.rotation.x = 0;
}
}
//根据站台区段创建站台位置 128停车点距离
for(let j=0,lenj=stations.length;j<lenj;j++){
// console.log(j);
console.log(stations[j]);
let direction1 = scope.sections.datalist[stations[j].stands[0].section];
let direction2 = scope.sections.datalist[stations[j].stands[1].section];
console.log(direction1);
let x = direction1.railpoint[0].x+direction1.leftStopPointOffset+62;
let x = direction1.railpoint[0].x+direction1.leftStopPointOffset+64;
let z = (direction1.railpoint[0].z+direction2.railpoint[0].z)/2;
let mesh;
if(stations[j].stands[0].inside == true){
@ -804,21 +800,16 @@ export function SectionList() {
data.mesh = testmesh2;
}
// var box = new THREE.BoxHelper( testmesh2, 0xffffff );
// scope.sectiongroup.add( box );
}
this.loadpromise = function(jlmap3ddata,assetloader,sectiondata,scene){
// console.log("-------------------");
// console.log(jlmap3ddata.sectionlist.sections.datalist);
// console.log(sectiondata);
this.loadpromise = function(jlmap3ddata,assetloader,sectiondata,section2d,switch2d,scene){
var texture = new THREE.TextureLoader().load( '../../static/test/z0251.png' );
texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
texture.repeat.set( 1,1);
var selectmaterial = new THREE.MeshPhongMaterial( { map: texture,transparent:true,alphaTest:0.1 } );
scene.add(scope.sectiongroup);
return new Promise(function(resolve, reject){
for(let i=0,leni = sectiondata.length;i<leni;i++){
@ -835,24 +826,14 @@ export function SectionList() {
};
let testmesh2 = null;
if(newsection.standTrack == true){
}
if(newsection.railpoint.length>2){
// 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<section2d.length;i++){
if(section2d[i].type == "01" || section2d[i].type == "03"){
scope.sections.datalist[section2d[i].code].rsection = section2d[i].rightSectionCode;
scope.sections.datalist[section2d[i].code].lsection = section2d[i].leftSectionCode;
scope.sections.datalist[section2d[i].code].points = section2d[i].points;
scope.sections.datalist[section2d[i].code].pointslength = section2d[i].points.length-1;
if(section2d[i].standTrack == true){
scope.sections.datalist[section2d[i].code].standLeftX = section2d[i].points[0].x;
scope.sections.datalist[section2d[i].code].standLeftY = section2d[i].points[0].y;
scope.sections.datalist[section2d[i].code].standRightLeftX = section2d[i].points[1].x;
scope.sections.datalist[section2d[i].code].standRightRightY = section2d[i].points[1].y;
scope.sections.datalist[section2d[i].code].leftStopPointOffset = section2d[i].leftStopPointOffset;
scope.sections.datalist[section2d[i].code].rightStopPointOffset = section2d[i].leftStopPointOffset+124;
}
}
}
//连接区段
for(let i=0;i<switch2d.length;i++){
let acode = switch2d[i].sectionACode;
let bcode = switch2d[i].sectionBCode;
let ccode = switch2d[i].sectionCCode;
// console.log(switchdata[i]);
let aposx = (scope.sections.datalist[acode].points[0].x + scope.sections.datalist[acode].points[scope.sections.datalist[acode].pointslength].x)/2;
let cposx = (scope.sections.datalist[ccode].points[0].x + scope.sections.datalist[ccode].points[scope.sections.datalist[ccode].pointslength].x)/2;
let aposy = (scope.sections.datalist[acode].points[0].y + scope.sections.datalist[acode].points[scope.sections.datalist[acode].pointslength].y)/2;
let cposy = (scope.sections.datalist[ccode].points[0].y + scope.sections.datalist[ccode].points[scope.sections.datalist[ccode].pointslength].y)/2;
// console.log("----------------");
if(aposx > 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");
});

View File

@ -126,10 +126,9 @@ export function StationStandList() {
let newstationstand = new StationStandModel(standsdata[i]);
let newstationmesh;
let stands = [];
console.log("--------------------");
for(let j=0;j<jlmapstanddata.length;j++){
if(jlmapstanddata[j].stationCode == standsdata[i].code && jlmapstanddata[j].small != true){
console.log(jlmapstanddata[j]);
let changestand = {
code : jlmapstanddata[j].code,
position : jlmapstanddata[j].position,

View File

@ -110,7 +110,7 @@ let views4 = [
{
left: 0,
bottom: 0,
width: 0.5,
width: 0.24,
height: 0.5,
background: new THREE.Color( 0.5, 0.5, 0.7 ),
eye: [ 3.7, 16, 26 ],
@ -118,9 +118,9 @@ let views4 = [
fov: 30
},
{
left: 0,
bottom: 0.5,
width: 0.5,
left:0.25,
bottom: 0,
width: 0.24,
height: 0.5,
background: new THREE.Color( 0.5, 0.5, 0.7 ),
eye: [ 3.7,17,-4 ],
@ -130,7 +130,7 @@ let views4 = [
{
left: 0.5,
bottom: 0,
width: 0.5,
width: 0.24,
height: 0.5,
background: new THREE.Color( 0.7, 0.5, 0.5 ),
eye: [ -60, 6,11],
@ -138,9 +138,9 @@ let views4 = [
fov: 45
},
{
left: 0.5,
bottom: 0.5,
width: 0.5,
left: 0.75,
bottom: 0,
width: 0.24,
height: 0.5,
background: new THREE.Color( 0.5, 0.7, 0.7 ),
eye: [ -7,17,2],
@ -154,7 +154,7 @@ let views2 = [
left: 0,
bottom: 0,
width: 0.5,
height: 1,
height: 0.5,
background: new THREE.Color( 0.5, 0.5, 0.7 ),
eye: [ 3.7, 16, 26 ],
up: [3.7, 10 ,16 ],
@ -164,16 +164,83 @@ let views2 = [
left: 0.5,
bottom: 0,
width: 0.5,
height: 1,
height: 0.5,
background: new THREE.Color( 0.7, 0.5, 0.5 ),
eye: [ -60, 6,11],
up: [ -59, 5.9,11 ],
fov: 60
},
];
export function Jl3dpassflow(dom,skinCode,routegroup) {
let scope = this;
//
// let views4 = [
// {
// left: 0,
// bottom: 0,
// width: 0.5,
// height: 0.5,
// background: new THREE.Color( 0.5, 0.5, 0.7 ),
// eye: [ 3.7, 16, 26 ],
// up: [3.7, 10 ,16 ],
// fov: 30
// },
// {
// left: 0,
// bottom: 0.5,
// width: 0.5,
// height: 0.5,
// background: new THREE.Color( 0.5, 0.5, 0.7 ),
// eye: [ 3.7,17,-4 ],
// up: [ 3.7, 10 ,16],
// fov: 30
// },
// {
// left: 0.5,
// bottom: 0,
// width: 0.5,
// height: 0.5,
// background: new THREE.Color( 0.7, 0.5, 0.5 ),
// eye: [ -60, 6,11],
// up: [ -59, 5.9,11 ],
// fov: 45
// },
// {
// left: 0.5,
// bottom: 0.5,
// width: 0.5,
// height: 0.5,
// background: new THREE.Color( 0.5, 0.7, 0.7 ),
// eye: [ -7,17,2],
// up: [-7, 10, 8],
// fov: 60
// }
// ];
//
// let views2 = [
// {
// left: 0,
// bottom: 0,
// width: 0.5,
// height: 1,
// background: new THREE.Color( 0.5, 0.5, 0.7 ),
// eye: [ 3.7, 16, 26 ],
// up: [3.7, 10 ,16 ],
// fov: 60
// },
// {
// left: 0.5,
// bottom: 0,
// width: 0.5,
// height: 1,
// background: new THREE.Color( 0.7, 0.5, 0.5 ),
// eye: [ -60, 6,11],
// up: [ -59, 5.9,11 ],
// fov: 60
// },
// ];
export function Jl3dpassflow(dom,skinCode,routegroup,viewMap) {
let scope = this;
initView(viewMap);
this.dom = dom;
this.nowcode = null;
this.animateswitch = false;
@ -440,6 +507,142 @@ export function Jl3dpassflow(dom,skinCode,routegroup) {
animate();
})
});
function initView(viewMap){
if(viewMap == "normal"){
views4 = [
{
left: 0,
bottom: 0,
width: 0.5,
height: 0.5,
background: new THREE.Color( 0.5, 0.5, 0.7 ),
eye: [ 3.7, 16, 26 ],
up: [3.7, 10 ,16 ],
fov: 30
},
{
left: 0,
bottom: 0.5,
width: 0.5,
height: 0.5,
background: new THREE.Color( 0.5, 0.5, 0.7 ),
eye: [ 3.7,17,-4 ],
up: [ 3.7, 10 ,16],
fov: 30
},
{
left: 0.5,
bottom: 0,
width: 0.5,
height: 0.5,
background: new THREE.Color( 0.7, 0.5, 0.5 ),
eye: [ -60, 6,11],
up: [ -59, 5.9,11 ],
fov: 45
},
{
left: 0.5,
bottom: 0.5,
width: 0.5,
height: 0.5,
background: new THREE.Color( 0.5, 0.7, 0.7 ),
eye: [ -7,17,2],
up: [-7, 10, 8],
fov: 60
}
];
views2 = [
{
left: 0,
bottom: 0,
width: 0.5,
height: 1,
background: new THREE.Color( 0.5, 0.5, 0.7 ),
eye: [ 3.7, 16, 26 ],
up: [3.7, 10 ,16 ],
fov: 60
},
{
left: 0.5,
bottom: 0,
width: 0.5,
height: 1,
background: new THREE.Color( 0.7, 0.5, 0.5 ),
eye: [ -60, 6,11],
up: [ -59, 5.9,11 ],
fov: 60
},
];
}else{
views4 = [
{
left: 0,
bottom: 0,
width: 0.24,
height: 0.5,
background: new THREE.Color( 0.5, 0.5, 0.7 ),
eye: [ 3.7, 16, 26 ],
up: [3.7, 10 ,16 ],
fov: 30
},
{
left:0.25,
bottom: 0,
width: 0.24,
height: 0.5,
background: new THREE.Color( 0.5, 0.5, 0.7 ),
eye: [ 3.7,17,-4 ],
up: [ 3.7, 10 ,16],
fov: 30
},
{
left: 0.5,
bottom: 0,
width: 0.24,
height: 0.5,
background: new THREE.Color( 0.7, 0.5, 0.5 ),
eye: [ -60, 6,11],
up: [ -59, 5.9,11 ],
fov: 45
},
{
left: 0.75,
bottom: 0,
width: 0.24,
height: 0.5,
background: new THREE.Color( 0.5, 0.7, 0.7 ),
eye: [ -7,17,2],
up: [-7, 10, 8],
fov: 60
}
];
views2 = [
{
left: 0,
bottom: 0,
width: 0.5,
height: 0.5,
background: new THREE.Color( 0.5, 0.5, 0.7 ),
eye: [ 3.7, 16, 26 ],
up: [3.7, 10 ,16 ],
fov: 60
},
{
left: 0.5,
bottom: 0,
width: 0.5,
height: 0.5,
background: new THREE.Color( 0.7, 0.5, 0.5 ),
eye: [ -60, 6,11],
up: [ -59, 5.9,11 ],
fov: 60
},
];
}
}
function inithumans(){
originhuman1 = scope.modelmanager.man1.mesh;
originhuman1.progress = 1;

View File

@ -266,33 +266,41 @@ export function Jlmap3dSubscribeNew(jlmap3d,routegroup,jsonwebwork) {
// }
// trainlisttest.list[code].len = rails.sectionrail[data.section].lengthfact;
trainlisttest.list[code].status = '1';
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);
let tangent = rails.sectionrail[data.section].lineleft.getTangentAt(data.offset).normalize();
trainlisttest.list[code].children[0].axis.crossVectors(trainlisttest.list[code].children[0].up, tangent).normalize();
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 = parseFloat(point.z) - parseFloat(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;
}
if(trainlisttest.list[code].children[1].rotalist.length > 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.length;xh++){
if((trainlisttest.list[code].children[rs].matrixWorld.elements[12])>=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;xh<trainlisttest.list[code].children[rs].rotalist.length;xh++){
if((trainlisttest.list[code].children[rs].matrixWorld.elements[12])<=trainlisttest.list[code].children[rs].rotalist[0].posr.x){
@ -385,11 +401,10 @@ export function Jlmap3dSubscribeNew(jlmap3d,routegroup,jsonwebwork) {
if(rs != 5){
let asd = trainlisttest.list[code].children[rs].rotalist[0];
trainlisttest.list[code].children[rs+1].rotalist.push(asd);
}
//let offsetx = trainlisttest.list[code].children[1].matrixWorld.elements[12]-trainlisttest.list[code].children[0].children[3].matrixWorld.elements[12];
trainlisttest.list[code].children[rs].rotation.z = trainlisttest.list[code].children[rs].rotalist[0].rota;
// trainlisttest.list[code].children[rs].rotation.y = trainlisttest.list[code].children[rs].rotalist[0].roty;
trainlisttest.list[code].children[rs].rotation.z = trainlisttest.list[code].children[rs].rotalist[0].rotz;
trainlisttest.list[code].children[rs].rotalist.splice(0,1)
xh--;
}else{

View File

@ -14,7 +14,7 @@ THREE.ScalControls = function ( scene,_camera, _domElement ) {
var objectparent = null;
var selectmaterial = null;
var oldobject = null;
var sectionList = [];
var geometry = new THREE.BoxBufferGeometry( 1, 1, 1 );
var material = new THREE.MeshBasicMaterial( {color: 0x00ff00} );
@ -58,7 +58,7 @@ THREE.ScalControls = function ( scene,_camera, _domElement ) {
cube.name = "left";
cubegroup.add( cube );
_objects.push(cube);
let scalMode = null;
if ( _objects instanceof THREE.Camera ) {
@ -130,7 +130,12 @@ THREE.ScalControls = function ( scene,_camera, _domElement ) {
if ( _raycaster.ray.intersectPlane( _plane, _intersection ) ) {
_selected.position.copy( _intersection.sub( _offset ).applyMatrix4( _inverseMatrix ) );
_selected.position.y = 0;
// if(scalMode == "plane"){
// _selected.position.y = 0;
// }else{
//
// }
if(_movemesh.meshtype = "section"){
newsectioncreate();
@ -263,7 +268,6 @@ THREE.ScalControls = function ( scene,_camera, _domElement ) {
_selected = null;
console.log("mouseup");
}
_domElement.style.cursor = _hovered ? 'pointer' : 'auto';
@ -362,29 +366,56 @@ THREE.ScalControls = function ( scene,_camera, _domElement ) {
for(let i=0;i<_movemesh.railpoint.length;i++){
newpointlist.push(new THREE.Vector3(_movemesh.railpoint[i].x,_movemesh.railpoint[i].y,_movemesh.railpoint[i].z));
}
console.log(scalMode);
if(_movemesh.railpoint.length>2){
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){

View File

@ -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{

View File

@ -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<nm;n++){
// var geometry = new THREE.CircleGeometry( 0.05, 16 );
// var material = new THREE.MeshBasicMaterial( { color: 0xffff00 } );

View File

@ -100,9 +100,9 @@ this.loadpromise = function(sectionList,sectiondata,rails,scene,assetloader){
// console.log(newsection);
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';
@ -115,8 +115,15 @@ this.loadpromise = function(sectionList,sectiondata,rails,scene,assetloader){
extrudePath : closedSpline,
};
var shape = new THREE.Shape();
shape.moveTo( 0,-2 );
shape.lineTo( 0, 2 );
if(newsection.railpoint[0].y != newsection.railpoint[2].y){
console.log(newsection);
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 mesh = new THREE.Mesh( geometry, selectmaterial );
let count = mesh.geometry.attributes.position.count/3;
@ -155,15 +162,14 @@ this.loadpromise = function(sectionList,sectiondata,rails,scene,assetloader){
closedSpline.closed = false;
// Set up settings for later extrusion
var extrudeSettings = {
steps : 1,
steps : 5,
curveSegments : 1,
bevelSegments : 1,
bevelEnabled : false,
extrudePath : closedSpline,
};
var shape = new THREE.Shape();
shape.moveTo( -2,0 );
shape.lineTo( 2,0 );
// Extrude the triangle along the CatmullRom curve
var geometry = new THREE.ExtrudeBufferGeometry( shape, extrudeSettings );
var mesh = new THREE.Mesh( geometry, selectmaterial );

View File

@ -211,9 +211,7 @@ export function StationStandListN() {
for(let n=0;n<psddata.length;n++){
for(let m=0;m<newstationstand.stands.length;m++){
console.log("====================");
console.log(newstationstand.stands[m]);
console.log(psddata[n]);
if(psddata[n].standCode == newstationstand.stands[m].code && newstationstand.stands[m].right == false){
let key = psddata[n].code;
@ -241,9 +239,7 @@ export function StationStandListN() {
let mixer = new THREE.AnimationMixer( newstationmesh.children[j] );
for(let n=0;n<psddata.length;n++){
for(let m=0;m<newstationstand.stands.length;m++){
console.log("====================");
console.log(newstationstand.stands[m]);
console.log(psddata[n]);
if(psddata[n].standCode == newstationstand.stands[m].code && newstationstand.stands[m].right == true){
let key = psddata[n].code;
actionss[key] = {

View File

@ -210,6 +210,13 @@ export function TrainListN() {
fclip = new THREE.AnimationClip("four",2,ntracks2);
// ntracks2 = assetloader.modellist[n].animations.slice(6,13);
//
// fclip = new THREE.AnimationClip("four",2,ntracks2);
//
// ntracks1 = assetloader.modellist[n].animations.slice(0,5);
//
// tclip = new THREE.AnimationClip("three",2,ntracks1);
n = 0;
}
}

View File

@ -8,7 +8,7 @@
<el-button type="transscal" @click="transscal">放大缩小</el-button>
<el-button type="vexscal" @click="vexscal">拉伸</el-button>
<el-button type="testrail" @click="testrail">测试轨迹</el-button>
@ -57,9 +57,6 @@ export default {
async transscal(){
this.$emit('transscal');
},
async vexscal(){
this.$emit('vexscal');
},
async testrail(){
this.$emit('testrail');
},

View File

@ -45,6 +45,13 @@
<el-input ></el-input>
</el-form-item>
<el-button v-if="selectmodel.meshtype == 'section'" @click="leftAlignment">区段左对齐</el-button>
<el-button v-if="selectmodel.meshtype == 'section'" @click="rightAlignment">区段右对齐</el-button>
<el-button type="vexscal" @click="vexScalPlane">平面拉伸</el-button>
<el-button type="vexscal" @click="vexScalVertical">高度改变</el-button>
<!-- <el-form-item label="是否显示:" prop="visible">
<el-checkbox ></el-checkbox>
@ -160,6 +167,20 @@ export default {
},
init: function() {
},
leftAlignment(){
this.$emit('alignment',this.selectmodel.code,"left");
},
rightAlignment(){
this.$emit('alignment',this.selectmodel.code,"right");
},
vexScalPlane(scalMode){
this.$emit('vexscal',"plane");
},
vexScalVertical(scalMode){
this.$emit('vexscal',"vertical");
},
switchproperty(){
this.activeName = "second";

View File

@ -8,13 +8,13 @@
<Edit-Action ref="action" @saction="saction" @actionevent="actionevent">
</Edit-Action>
<Edit-Property ref="property" :selectmodel='selectmodel'>
<Edit-Property ref="property" :selectmodel='selectmodel' @alignment="alignment" @vexscal= "vexscal" >
</Edit-Property>
<Edit-Assets ref="assets" @smodel="smodel" @stexture="stexture">
</Edit-Assets>
<Edit-Menu ref="menu" @transpos="transpos" @transrota="transrota" @transscal="transscal" @vexscal= "vexscal" @testrail="testrail" @autoss="autoss" @expo="expo" @save="save"
<Edit-Menu ref="menu" @transpos="transpos" @transrota="transrota" @transscal="transscal" @testrail="testrail" @autoss="autoss" @expo="expo" @save="save"
@savetest="savetest" @back="back">
</Edit-Menu>
@ -171,10 +171,10 @@
this.jlmap3dedit.transcontrol.setMode('scale');
this.jlmap3dedit.vexscaloff();
},
vexscal(){
vexscal(scalMode){
this.jlmap3dedit.transcontrol.detach();
this.jlmap3dedit.vexscal();
this.jlmap3dedit.vexscal(scalMode);
console.log("vexscal");
},
testrail(){
@ -187,6 +187,10 @@
this.jlmap3dedit.exportsection();
},
alignment(alignmentCode,direct){
this.jlmap3dedit.alignmentSection(alignmentCode,direct);
},
save() {
//console.log("save");
console.log(this.jlmap3dedit.assetManager);

View File

@ -82,7 +82,7 @@ export default {
init: function () {
// let mapdata = this.$store.state.socket.device;
const dom = document.getElementById('jl3d');
this.jl3d = new Jl3dpassflow(dom,this.$route.query.mapid,this.$route.query.group);
this.jl3d = new Jl3dpassflow(dom,this.$route.query.mapid,this.$route.query.group,"normal");
},
switchrender() {
if (this.renderswitch == true) {