修改道岔模型,编辑器显示停车点
This commit is contained in:
parent
0a77b1e4f6
commit
523a2ac803
@ -141,28 +141,31 @@ export function Jlmap3ddata(mapid,scope){
|
||||
let switchdata = JSON.parse(netdata.switchs);
|
||||
let signaldata = JSON.parse(netdata.signals);
|
||||
let standsdata = JSON.parse(netdata.stands);
|
||||
// console.log(mapdata);
|
||||
console.log(mapdata);
|
||||
assetloader.setmodellist(netdata.assets,5);
|
||||
assetloader.assetpromise(scene)
|
||||
.then(function(data){
|
||||
//console.log(data);
|
||||
return jlmap3ddata.linklist.loadpromise(loaderdata.link,scene,assetloader);
|
||||
return jlmap3ddata.linklist.loadpromise(loaderdata.link,scene,assetloader);
|
||||
})
|
||||
.then(function(data){
|
||||
return jlmap3ddata.sectionlist.sectionpromise(loaderdata.link,mapdata.linkList,mapdata.sectionList,switchdata,scene);
|
||||
})
|
||||
.then(function(data){
|
||||
//console.log(data);
|
||||
return jlmap3ddata.sectionlist.loadpromise(jlmap3ddata,assetloader,loaderdata.section,switchdata,scene);
|
||||
return jlmap3ddata.sectionlist.loadpromise(jlmap3ddata,assetloader,loaderdata.section,switchdata,scene);
|
||||
})
|
||||
.then(function(data){
|
||||
//console.log(data);
|
||||
return jlmap3ddata.signallist.loadpromise(signaldata,scene,assetloader,mapdata.signalList);
|
||||
return jlmap3ddata.signallist.loadpromise(signaldata,scene,assetloader,mapdata.signalList);
|
||||
})
|
||||
.then(function(data){
|
||||
//console.log(data);
|
||||
return jlmap3ddata.stationstandlist.initpromise(jlmap3ddata,mapdata.stationList,mapdata.stationStandList,scene,assetloader,standsdata);
|
||||
return jlmap3ddata.stationstandlist.initpromise(jlmap3ddata,mapdata.stationList,mapdata.stationStandList,scene,assetloader,standsdata);
|
||||
})
|
||||
.then(function(data){
|
||||
//console.log(data);
|
||||
return jlmap3ddata.trainlisttest.initpromise(mapdata.trainList,scene,assetloader,"0");
|
||||
return jlmap3ddata.trainlisttest.initpromise(mapdata.trainList,scene,assetloader,"0");
|
||||
})
|
||||
// .then(function(data){
|
||||
// //console.log(data);
|
||||
|
@ -23,6 +23,7 @@ export function SectionList() {
|
||||
this.standtrack = [];
|
||||
|
||||
this.initpromise = function(jlmap3ddata,assetloader,sectiondata,switchdata,scene){
|
||||
console.log(sectiondata);
|
||||
return new Promise(function(resolve, reject){
|
||||
scene.add(scope.sectiongroup);
|
||||
scene.add(scope.switchgroup);
|
||||
@ -44,11 +45,11 @@ export function SectionList() {
|
||||
newsection.linkCode = sectiondata[i].linkCode;
|
||||
|
||||
scope.sections.datalist.push(newsection);
|
||||
// scope.sections.modellist.push("");
|
||||
// sections.modellist.push("");
|
||||
}
|
||||
}
|
||||
buildsuidao(linkdata,scope.sections,assetloader,scene);
|
||||
// console.log(scope.sections.datalist);
|
||||
buildsuidao(linkdata,sections,assetloader,scene);
|
||||
// console.log(sections.datalist);
|
||||
//定义区分道岔组
|
||||
let switchlist = [];
|
||||
//遍历道岔数据
|
||||
@ -193,6 +194,224 @@ export function SectionList() {
|
||||
resolve("loadersection");
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
this.sectionpromise = function(linkdata,linklist,sectiondata,switchdata,scene){
|
||||
// console.log(linkdata);
|
||||
// console.log(linklist);
|
||||
// console.log(sectiondata);
|
||||
return new Promise(function(resolve, reject){
|
||||
let linkrail = [];
|
||||
let switchrail = [];
|
||||
for(let i=0;i<linkdata.length;i++){
|
||||
linkrail[linkdata[i].code] = {
|
||||
lp:linkdata[i].rail[0],
|
||||
rp:linkdata[i].rail[1],
|
||||
lconnect:null,
|
||||
rconnect:null,
|
||||
lengthfact:linkdata[i].lengthfact,
|
||||
lineleft:null,
|
||||
lineright:null,
|
||||
points:[],
|
||||
type:null
|
||||
};
|
||||
}
|
||||
|
||||
for(let i=0;i<switchdata.length;i++){
|
||||
switchrail[switchdata[i].code] = {
|
||||
alink:switchdata[i].alink,
|
||||
blink:switchdata[i].blink,
|
||||
clink:switchdata[i].clink,
|
||||
position:switchdata[i].position,
|
||||
directtype:null,
|
||||
locateType:0
|
||||
};
|
||||
|
||||
if(linkrail[switchdata[i].blink].lp.x < switchdata[i].position.x){
|
||||
linkrail[switchdata[i].alink].lswitch = switchdata[i].code;
|
||||
linkrail[switchdata[i].blink].rswitch = switchdata[i].code;
|
||||
|
||||
}else{
|
||||
linkrail[switchdata[i].alink].rswitch = switchdata[i].code;
|
||||
linkrail[switchdata[i].blink].lswitch = switchdata[i].code;
|
||||
}
|
||||
//
|
||||
if(linkrail[switchdata[i].clink].lp.x < switchdata[i].position.x){
|
||||
linkrail[switchdata[i].alink].lswitch = switchdata[i].code;
|
||||
linkrail[switchdata[i].clink].rswitch = switchdata[i].code;
|
||||
}else{
|
||||
linkrail[switchdata[i].alink].rswitch = switchdata[i].code;
|
||||
linkrail[switchdata[i].clink].lswitch = switchdata[i].code;
|
||||
}
|
||||
}
|
||||
|
||||
for(let i=0;i<linkdata.length;i++){
|
||||
if(linkdata[i].rotation._z == 0){
|
||||
linkrail[linkdata[i].code].type = 0;
|
||||
if(linkrail[linkdata[i].code].lswitch){
|
||||
let switchpoint = switchrail[linkrail[linkdata[i].code].lswitch].position;
|
||||
linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x,0,switchpoint.z));
|
||||
}
|
||||
|
||||
linkrail[linkdata[i].code].points.push(new THREE.Vector3(linkrail[linkdata[i].code].lp.x,0,linkrail[linkdata[i].code].lp.z));
|
||||
linkrail[linkdata[i].code].points.push(new THREE.Vector3(linkrail[linkdata[i].code].rp.x,0,linkrail[linkdata[i].code].rp.z));
|
||||
|
||||
if(linkrail[linkdata[i].code].rswitch){
|
||||
let switchpoint = switchrail[linkrail[linkdata[i].code].rswitch].position;
|
||||
linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x,0,switchpoint.z));
|
||||
}
|
||||
|
||||
}else{
|
||||
|
||||
if(linkdata[i].rotation._z>0){
|
||||
let testline = new THREE.CatmullRomCurve3([
|
||||
new THREE.Vector3(linkrail[linkdata[i].code].lp.x,0,linkrail[linkdata[i].code].lp.z),
|
||||
new THREE.Vector3(linkrail[linkdata[i].code].rp.x,0,linkrail[linkdata[i].code].rp.z)
|
||||
]);
|
||||
|
||||
linkrail[linkdata[i].code].type = 1;
|
||||
if(linkrail[linkdata[i].code].lswitch){
|
||||
let switchpoint = switchrail[linkrail[linkdata[i].code].lswitch].position;
|
||||
linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x,0,switchpoint.z));
|
||||
linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x+1.5,0,switchpoint.z));
|
||||
linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x+2,0,switchpoint.z));
|
||||
linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x+4.5,0,switchpoint.z-0.05));
|
||||
}
|
||||
|
||||
linkrail[linkdata[i].code].points.push(testline.getPointAt(0.12));
|
||||
linkrail[linkdata[i].code].points.push(testline.getPointAt(0.22));
|
||||
linkrail[linkdata[i].code].points.push(testline.getPointAt(0.82));
|
||||
linkrail[linkdata[i].code].points.push(testline.getPointAt(0.92));
|
||||
|
||||
if(linkrail[linkdata[i].code].rswitch){
|
||||
let switchpoint = switchrail[linkrail[linkdata[i].code].rswitch].position;
|
||||
linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x-4.5,0,switchpoint.z+0.05));
|
||||
linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x-2,0,switchpoint.z));
|
||||
linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x-1.5,0,switchpoint.z));
|
||||
linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x,0,switchpoint.z));
|
||||
}
|
||||
|
||||
}else{
|
||||
let testline = new THREE.CatmullRomCurve3([
|
||||
new THREE.Vector3(linkrail[linkdata[i].code].lp.x,0,linkrail[linkdata[i].code].lp.z),
|
||||
new THREE.Vector3(linkrail[linkdata[i].code].rp.x,0,linkrail[linkdata[i].code].rp.z)
|
||||
]);
|
||||
linkrail[linkdata[i].code].type = 2;
|
||||
if(linkrail[linkdata[i].code].lswitch){
|
||||
let switchpoint = switchrail[linkrail[linkdata[i].code].lswitch].position;
|
||||
linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x,0,switchpoint.z));
|
||||
linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x+1.5,0,switchpoint.z));
|
||||
linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x+2,0,switchpoint.z));
|
||||
linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x+4.5,0,switchpoint.z+0.05));
|
||||
}
|
||||
|
||||
linkrail[linkdata[i].code].points.push(testline.getPointAt(0.12));
|
||||
linkrail[linkdata[i].code].points.push(testline.getPointAt(0.22));
|
||||
linkrail[linkdata[i].code].points.push(testline.getPointAt(0.82));
|
||||
linkrail[linkdata[i].code].points.push(testline.getPointAt(0.92));
|
||||
|
||||
if(linkrail[linkdata[i].code].rswitch){
|
||||
let switchpoint = switchrail[linkrail[linkdata[i].code].rswitch].position;
|
||||
linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x-4.5,0,switchpoint.z-0.05));
|
||||
linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x-2,0,switchpoint.z));
|
||||
linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x-1.5,0,switchpoint.z));
|
||||
linkrail[linkdata[i].code].points.push(new THREE.Vector3(switchpoint.x,0,switchpoint.z));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for(let i=0;i<linkdata.length;i++){
|
||||
linkrail[linkdata[i].code].lineleft = new THREE.CatmullRomCurve3(linkrail[linkdata[i].code].points);
|
||||
linkrail[linkdata[i].code].lineleft.curveType = "centripetal";
|
||||
// linkrail[linkdata[i].code].lineleft.tension = 0.2;
|
||||
let rightpoints = [];
|
||||
linkrail[linkdata[i].code].points.forEach(item=>{
|
||||
rightpoints.push(item);
|
||||
}
|
||||
);
|
||||
rightpoints.reverse();
|
||||
linkrail[linkdata[i].code].lineright = new THREE.CatmullRomCurve3(rightpoints);
|
||||
linkrail[linkdata[i].code].lineright.curveType = "centripetal";
|
||||
|
||||
// scope.linkrail[linkdata[i].code].lineright.tension = 0.11;
|
||||
var points = linkrail[linkdata[i].code].lineleft.getPoints( 50 );
|
||||
var geometry = new THREE.BufferGeometry().setFromPoints( points );
|
||||
var material;
|
||||
if(linkrail[linkdata[i].code].type == 0){
|
||||
material = new THREE.LineBasicMaterial( { color : 0xff0000 } );
|
||||
}
|
||||
if(linkrail[linkdata[i].code].type == 1){
|
||||
material = new THREE.LineBasicMaterial( { color : 0x00ff00 } );
|
||||
}
|
||||
if(linkrail[linkdata[i].code].type == 2){
|
||||
material = new THREE.LineBasicMaterial( { color : 0x0000ff } );
|
||||
}
|
||||
|
||||
|
||||
// Create the final object to add to the scene
|
||||
var curveObject = new THREE.Line( geometry, material );
|
||||
|
||||
curveObject.position.y = Math.random();
|
||||
scene.add(curveObject);
|
||||
}
|
||||
|
||||
let standsections = [];
|
||||
for(let i=0,len=sectiondata.length;i<len;i++){
|
||||
if(sectiondata[i].isStandTrack == true){
|
||||
standsections.push(sectiondata[i]);
|
||||
}
|
||||
}
|
||||
console.log(standsections);
|
||||
console.log(linklist);
|
||||
for(let i=0,leni=standsections.length;i<leni;i++){
|
||||
for(let j=0,lenj=linklist.length;j<lenj;j++){
|
||||
if(standsections[i].linkCode == linklist[j].code){
|
||||
|
||||
console.log(standsections[i].linkCode);
|
||||
// console.log(standsections[i]);
|
||||
// console.log(linklist[j]);
|
||||
// console.log("====================================");
|
||||
|
||||
let progress1 = standsections[i].leftStopPointOffset/linklist[j].lengthFact;
|
||||
let progress2 = standsections[i].rightStopPointOffset/linklist[j].lengthFact;
|
||||
let point1 = linkrail[linklist[j].code].lineleft.getPointAt(progress1);
|
||||
|
||||
var geometry = new THREE.CircleGeometry( 3, 16 );
|
||||
var material = new THREE.MeshBasicMaterial( { color: 0xffff00 } );
|
||||
let circle1 = new THREE.Mesh( geometry, material );
|
||||
circle1.position.x = point1.x;
|
||||
circle1.position.y = point1.y;
|
||||
circle1.position.z = point1.z;
|
||||
circle1.rotation.x = -Math.PI/2;
|
||||
scene.add( circle1 );
|
||||
|
||||
let point2 = linkrail[linklist[j].code].lineleft.getPointAt(progress2);
|
||||
let circle2 = new THREE.Mesh( geometry, material );
|
||||
circle2.position.x = point2.x;
|
||||
circle2.position.y = point2.y;
|
||||
circle2.position.z = point2.z;
|
||||
circle2.rotation.x = -Math.PI/2;
|
||||
scene.add( circle2 );
|
||||
console.log(standsections[i].leftStopPointOffset);
|
||||
console.log(standsections[i].rightStopPointOffset);
|
||||
console.log(linkrail[linklist[j].code].lineleft.points);
|
||||
console.log(linklist[j].lengthFact);
|
||||
console.log(point1);
|
||||
console.log(point2);
|
||||
console.log("====================================");
|
||||
|
||||
j = lenj;
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
resolve("loadersection");
|
||||
});
|
||||
|
||||
}
|
||||
//
|
||||
// this.init = function(sectiondata,switchdata,scene){
|
||||
@ -209,8 +428,8 @@ export function SectionList() {
|
||||
// newsection.isStandTrack = sectiondata[i].isStandTrack;
|
||||
// newsection.type = sectiondata[i].type;
|
||||
//
|
||||
// scope.sections.datalist.push(newsection);
|
||||
// // scope.sections.modellist.push("");
|
||||
// sections.datalist.push(newsection);
|
||||
// // sections.modellist.push("");
|
||||
// }
|
||||
//
|
||||
// }
|
||||
@ -263,8 +482,8 @@ export function SectionList() {
|
||||
//
|
||||
// newswitch.index = i;
|
||||
//
|
||||
// scope.switchs.datalist.push(newswitch);
|
||||
// scope.switchs.modellist.push("");
|
||||
// switchs.datalist.push(newswitch);
|
||||
// switchs.modellist.push("");
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -291,7 +510,7 @@ export function SectionList() {
|
||||
newsection.linkCode = sectiondata[i].linkCode;
|
||||
|
||||
scope.sections.datalist.push(newsection);
|
||||
// scope.sections.modellist.push("");
|
||||
// sections.modellist.push("");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,7 @@ let autoswitch1 = {
|
||||
deviceType:"autoswitch1",
|
||||
type:"fuzhou",
|
||||
picUrl:"",
|
||||
assetUrl:modelurl+"/models/auto/switch1.FBX"
|
||||
assetUrl:"../../static/model/auto/switch1.FBX"
|
||||
}
|
||||
|
||||
let autoswitch2 = {
|
||||
@ -105,7 +105,7 @@ let autoswitch2 = {
|
||||
deviceType:"autoswitch2",
|
||||
type:"fuzhou",
|
||||
picUrl:"",
|
||||
assetUrl:modelurl+"/models/auto/switch2.FBX"
|
||||
assetUrl:"../../static/model/auto/switch2.FBX"
|
||||
}
|
||||
|
||||
export function AssetLoader(){
|
||||
|
@ -10,7 +10,7 @@ export function RailList(){
|
||||
};
|
||||
|
||||
this.init = function(linkdata,switchdata,scene,storemod){
|
||||
|
||||
console.log(linkdata);
|
||||
for(let i=0;i<linkdata.length;i++){
|
||||
scope.linkrail[linkdata[i].code] = {
|
||||
lp:linkdata[i].rail[0],
|
||||
@ -194,39 +194,39 @@ export function RailList(){
|
||||
rightpoints.reverse();
|
||||
scope.linkrail[linkdata[i].code].lineright = new THREE.CatmullRomCurve3(rightpoints);
|
||||
scope.linkrail[linkdata[i].code].lineright.curveType = "centripetal";
|
||||
//
|
||||
// for(let n=0,nm=scope.linkrail[linkdata[i].code].lineleft.points.length;n<nm;n++){
|
||||
// var geometry = new THREE.CircleGeometry( 0.05, 16 );
|
||||
// var material = new THREE.MeshBasicMaterial( { color: 0xffff00 } );
|
||||
// var circle = new THREE.Mesh( geometry, material );
|
||||
// console.log(n);
|
||||
// console.log(scope.linkrail[linkdata[i].code].lineleft.points[n]);
|
||||
// circle.position.x = scope.linkrail[linkdata[i].code].lineleft.points[n].x;
|
||||
// circle.position.y = scope.linkrail[linkdata[i].code].lineleft.points[n].y;
|
||||
// circle.position.z = scope.linkrail[linkdata[i].code].lineleft.points[n].z;
|
||||
// circle.rotation.x = -Math.PI/2;
|
||||
// scene.add( circle );
|
||||
// }
|
||||
// // scope.linkrail[linkdata[i].code].lineright.tension = 0.11;
|
||||
// var points = scope.linkrail[linkdata[i].code].lineleft.getPoints( 50 );
|
||||
// var geometry = new THREE.BufferGeometry().setFromPoints( points );
|
||||
// var material;
|
||||
// if(scope.linkrail[linkdata[i].code].type == 0){
|
||||
// material = new THREE.LineBasicMaterial( { color : 0xff0000 } );
|
||||
// }
|
||||
// if(scope.linkrail[linkdata[i].code].type == 1){
|
||||
// material = new THREE.LineBasicMaterial( { color : 0x00ff00 } );
|
||||
// }
|
||||
// if(scope.linkrail[linkdata[i].code].type == 2){
|
||||
// material = new THREE.LineBasicMaterial( { color : 0x0000ff } );
|
||||
// }
|
||||
//
|
||||
//
|
||||
// // Create the final object to add to the scene
|
||||
// var curveObject = new THREE.Line( geometry, material );
|
||||
//
|
||||
// curveObject.position.y = Math.random();
|
||||
// scene.add(curveObject);
|
||||
|
||||
for(let n=0,nm=scope.linkrail[linkdata[i].code].lineleft.points.length;n<nm;n++){
|
||||
var geometry = new THREE.CircleGeometry( 0.05, 16 );
|
||||
var material = new THREE.MeshBasicMaterial( { color: 0xffff00 } );
|
||||
var circle = new THREE.Mesh( geometry, material );
|
||||
console.log(n);
|
||||
console.log(scope.linkrail[linkdata[i].code].lineleft.points[n]);
|
||||
circle.position.x = scope.linkrail[linkdata[i].code].lineleft.points[n].x;
|
||||
circle.position.y = scope.linkrail[linkdata[i].code].lineleft.points[n].y;
|
||||
circle.position.z = scope.linkrail[linkdata[i].code].lineleft.points[n].z;
|
||||
circle.rotation.x = -Math.PI/2;
|
||||
scene.add( circle );
|
||||
}
|
||||
// scope.linkrail[linkdata[i].code].lineright.tension = 0.11;
|
||||
var points = scope.linkrail[linkdata[i].code].lineleft.getPoints( 50 );
|
||||
var geometry = new THREE.BufferGeometry().setFromPoints( points );
|
||||
var material;
|
||||
if(scope.linkrail[linkdata[i].code].type == 0){
|
||||
material = new THREE.LineBasicMaterial( { color : 0xff0000 } );
|
||||
}
|
||||
if(scope.linkrail[linkdata[i].code].type == 1){
|
||||
material = new THREE.LineBasicMaterial( { color : 0x00ff00 } );
|
||||
}
|
||||
if(scope.linkrail[linkdata[i].code].type == 2){
|
||||
material = new THREE.LineBasicMaterial( { color : 0x0000ff } );
|
||||
}
|
||||
|
||||
|
||||
// Create the final object to add to the scene
|
||||
var curveObject = new THREE.Line( geometry, material );
|
||||
|
||||
curveObject.position.y = Math.random();
|
||||
scene.add(curveObject);
|
||||
}
|
||||
|
||||
}
|
||||
|
Binary file not shown.
BIN
static/model/auto/switch11.FBX
Normal file
BIN
static/model/auto/switch11.FBX
Normal file
Binary file not shown.
Binary file not shown.
BIN
static/model/auto/switch22.FBX
Normal file
BIN
static/model/auto/switch22.FBX
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user