修改初始位置因为角度偏移问题
This commit is contained in:
parent
0e7805121a
commit
f2f89d2be2
@ -257,7 +257,7 @@ export function Jl3dDriving(jlmap3d) {
|
|||||||
// 遍历获取所在轨道
|
// 遍历获取所在轨道
|
||||||
|
|
||||||
if (trainlisttest.list[code].dispose != data.body[i].dispose && data.body[i].dispose == false) {
|
if (trainlisttest.list[code].dispose != data.body[i].dispose && data.body[i].dispose == false) {
|
||||||
|
console.log(data.body[i]);
|
||||||
if (sectionlist.sections.datalist[data.body[i].sectionCode].code) {
|
if (sectionlist.sections.datalist[data.body[i].sectionCode].code) {
|
||||||
trainlisttest.group.add(trainlisttest.list[code]);
|
trainlisttest.group.add(trainlisttest.list[code]);
|
||||||
trainlisttest.list[code].position.y = 0;
|
trainlisttest.list[code].position.y = 0;
|
||||||
@ -282,12 +282,17 @@ export function Jl3dDriving(jlmap3d) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const rotaposz = sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].z;
|
const rotaposz = sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].z;
|
||||||
|
console.log("02");
|
||||||
|
console.log(code);
|
||||||
|
console.log(rotaposx);
|
||||||
|
console.log(rotaposz);
|
||||||
trainlisttest.list[code].rotation.y = 0;
|
trainlisttest.list[code].rotation.y = 0;
|
||||||
trainlisttest.list[code].position.x = rotaposx;
|
trainlisttest.list[code].position.x = rotaposx;
|
||||||
trainlisttest.list[code].position.y = 0;
|
trainlisttest.list[code].position.y = 0;
|
||||||
for (let tl=0; tl<6; tl++) {
|
for (let tl=0; tl<6; tl++) {
|
||||||
trainlisttest.list[code].children[tl].position.z = rotaposz;
|
trainlisttest.list[code].children[tl].position.z = rotaposz;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x>sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) {
|
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x>sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) {
|
||||||
vexlist.push(new THREE.Vector3(rotaposx, 0, rotaposz));
|
vexlist.push(new THREE.Vector3(rotaposx, 0, rotaposz));
|
||||||
for (let m=sectionlist.sections.datalist[data.body[i].sectionCode].rail.length-1; m>=0; m--) {
|
for (let m=sectionlist.sections.datalist[data.body[i].sectionCode].rail.length-1; m>=0; m--) {
|
||||||
@ -323,15 +328,13 @@ export function Jl3dDriving(jlmap3d) {
|
|||||||
rotaposx = sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x+offset*data.body[i].sectionOffsetPercent;
|
rotaposx = sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x+offset*data.body[i].sectionOffsetPercent;
|
||||||
}
|
}
|
||||||
const rotaposz = sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].z;
|
const rotaposz = sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].z;
|
||||||
|
|
||||||
trainlisttest.list[code].rotation.y = Math.PI;
|
trainlisttest.list[code].rotation.y = Math.PI;
|
||||||
trainlisttest.list[code].position.x = rotaposx;
|
trainlisttest.list[code].position.x = rotaposx;
|
||||||
trainlisttest.list[code].position.y = 0;
|
trainlisttest.list[code].position.y = 0;
|
||||||
for (let tl=0; tl<6; tl++) {
|
for (let tl=0; tl<6; tl++) {
|
||||||
trainlisttest.list[code].children[tl].position.z = rotaposz;
|
trainlisttest.list[code].children[tl].position.z = rotaposz;
|
||||||
}
|
}
|
||||||
if (data.body[i].groupNumber == '001') {
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x<sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) {
|
if (sectionlist.sections.datalist[data.body[i].sectionCode].rail[0].x<sectionlist.sections.datalist[data.body[i].sectionCode].rail[1].x) {
|
||||||
vexlist.push(new THREE.Vector3(rotaposx, 0, rotaposz));
|
vexlist.push(new THREE.Vector3(rotaposx, 0, rotaposz));
|
||||||
for (let m=sectionlist.sections.datalist[data.body[i].sectionCode].rail.length-1; m>=0; m--) {
|
for (let m=sectionlist.sections.datalist[data.body[i].sectionCode].rail.length-1; m>=0; m--) {
|
||||||
@ -347,7 +350,6 @@ export function Jl3dDriving(jlmap3d) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
trainlisttest.list[code].status = '03';
|
trainlisttest.list[code].status = '03';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -355,8 +357,16 @@ export function Jl3dDriving(jlmap3d) {
|
|||||||
trainlisttest.list[code].isStandTrack = sectionlist.sections.datalist[data.body[i].sectionCode].isStandTrack;
|
trainlisttest.list[code].isStandTrack = sectionlist.sections.datalist[data.body[i].sectionCode].isStandTrack;
|
||||||
trainlisttest.list[code].progress = 0;
|
trainlisttest.list[code].progress = 0;
|
||||||
trainlisttest.list[code].len = sectionlist.sections.datalist[data.body[i].sectionCode].distance;
|
trainlisttest.list[code].len = sectionlist.sections.datalist[data.body[i].sectionCode].distance;
|
||||||
trainlisttest.list[code].speed = data.body[i].speed;
|
|
||||||
trainlisttest.list[code].speeds = parseFloat(data.body[i].speed*10/36/20/trainlisttest.list[code].len);
|
if(data.body[i].speed == 0){
|
||||||
|
trainlisttest.list[code].speeds = data.body[i].speed;
|
||||||
|
trainlisttest.list[code].speeds = 0.1;
|
||||||
|
trainlisttest.list[code].startmark = 1;
|
||||||
|
}else{
|
||||||
|
trainlisttest.list[code].speeds = data.body[i].speed;
|
||||||
|
trainlisttest.list[code].speeds = parseFloat(data.body[i].speed*10/36/20/trainlisttest.list[code].len);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (trainlisttest.list[code].dispose != data.body[i].dispose && data.body[i].dispose == true) {
|
} else if (trainlisttest.list[code].dispose != data.body[i].dispose && data.body[i].dispose == true) {
|
||||||
|
@ -9,7 +9,8 @@ export function UpdateTrain(camera,traindata,control){
|
|||||||
if(traindata.group.children[j].progress != null){
|
if(traindata.group.children[j].progress != null){
|
||||||
|
|
||||||
let trainmodel = traindata.group.children[j];
|
let trainmodel = traindata.group.children[j];
|
||||||
if(trainmodel.speeds > 0 && trainmodel.speeds){
|
if(trainmodel.startmark == 1){
|
||||||
|
trainmodel.startmark =0;
|
||||||
let speed = null;
|
let speed = null;
|
||||||
if(traindata.group.children[j].progress<1){
|
if(traindata.group.children[j].progress<1){
|
||||||
|
|
||||||
@ -69,47 +70,53 @@ export function UpdateTrain(camera,traindata,control){
|
|||||||
trainmodel.progress += trainmodel.speeds;
|
trainmodel.progress += trainmodel.speeds;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if(trainmodel.speeds > 0 && trainmodel.speeds){
|
||||||
|
let speed = null;
|
||||||
|
if(traindata.group.children[j].progress<1){
|
||||||
|
|
||||||
if(trainmodel.status == "02"){
|
let movecurve = trainmodel.curve;
|
||||||
if(movecurve.points.length>1){
|
|
||||||
let point = movecurve.getPointAt(trainmodel.progress);
|
|
||||||
if(Math.abs( point.z -trainmodel.children[0].matrixWorld.elements[14]) >0.1){
|
|
||||||
trainmodel.children[0].up = new THREE.Vector3(1,0,0);
|
|
||||||
let tangent = movecurve.getTangentAt(traindata.group.children[j].progress).normalize();
|
|
||||||
trainmodel.children[0].axis.crossVectors(trainmodel.children[0].up, tangent).normalize();
|
|
||||||
let radians = Math.acos(trainmodel.children[0].up.dot(tangent));
|
|
||||||
trainmodel.children[0].quaternion.setFromAxisAngle(trainmodel.children[0].axis, radians);
|
|
||||||
|
|
||||||
let rotas = {
|
if(trainmodel.status == "03"){
|
||||||
posr:point,
|
if(movecurve.points.length>1){
|
||||||
rota:trainmodel.children[0].rotation.y
|
let point = movecurve.getPointAt(traindata.group.children[j].progress);
|
||||||
|
if(Math.abs( point.z -trainmodel.children[0].matrixWorld.elements[14]) >0.1){
|
||||||
|
trainmodel.children[0].up = new THREE.Vector3(-1,0,0);
|
||||||
|
let tangent = movecurve.getTangentAt(traindata.group.children[j].progress).normalize();
|
||||||
|
trainmodel.children[0].axis.crossVectors(trainmodel.children[0].up, tangent).normalize();
|
||||||
|
let radians = Math.acos(trainmodel.children[0].up.dot(tangent));
|
||||||
|
trainmodel.children[0].quaternion.setFromAxisAngle(trainmodel.children[0].axis, radians);
|
||||||
|
let rotas = {
|
||||||
|
posr:point,
|
||||||
|
rota:trainmodel.children[0].rotation.y
|
||||||
|
}
|
||||||
|
trainmodel.children[1].rotalist.push(rotas);
|
||||||
|
|
||||||
|
let offsetz = parseFloat(trainmodel.children[0].matrixWorld.elements[14]) - parseFloat(point.z);
|
||||||
|
trainmodel.children[0].position.z += offsetz;
|
||||||
|
//trainmodel.position.z = point.z;
|
||||||
}
|
}
|
||||||
trainmodel.children[1].rotalist.push(rotas);
|
|
||||||
let offsetz = parseFloat(point.z) - parseFloat(trainmodel.children[0].matrixWorld.elements[14]);
|
|
||||||
trainmodel.children[0].position.z += offsetz;
|
|
||||||
//trainmodel.position.z = point.z;
|
|
||||||
}
|
|
||||||
|
|
||||||
trainmodel.position.x = point.x;
|
trainmodel.position.x = point.x;
|
||||||
trainmodel.position.y = 0;
|
trainmodel.position.y = 0;
|
||||||
if(trainmodel.children[1].rotalist.length > 0 || trainmodel.children[2].rotalist.length > 0 || trainmodel.children[3].rotalist.length > 0 || trainmodel.children[4].rotalist.length > 0|| trainmodel.children[5].rotalist.length > 0){
|
|
||||||
|
|
||||||
for(let rs = 1;rs<6;rs++){
|
if(trainmodel.children[1].rotalist.length > 0 || trainmodel.children[2].rotalist.length > 0 || trainmodel.children[3].rotalist.length > 0 || trainmodel.children[4].rotalist.length > 0|| trainmodel.children[5].rotalist.length > 0){
|
||||||
|
for(let rs = 1;rs<6;rs++){
|
||||||
//console.log(rs);
|
//console.log(rs);
|
||||||
if(trainmodel.children[rs].rotalist[0]){
|
if(trainmodel.children[rs].rotalist[0]){
|
||||||
|
let offsetz = parseFloat(trainmodel.children[rs].matrixWorld.elements[14]) - parseFloat(trainmodel.children[rs].rotalist[0].posr.z);
|
||||||
|
|
||||||
let offsetz = parseFloat(trainmodel.children[rs].rotalist[0].posr.z) - parseFloat(trainmodel.children[rs].matrixWorld.elements[14]);
|
|
||||||
trainmodel.children[rs].position.z += offsetz;
|
trainmodel.children[rs].position.z += offsetz;
|
||||||
|
|
||||||
for(let xh=0;xh<trainmodel.children[rs].rotalist.length;xh++){
|
for(let xh=0;xh<trainmodel.children[rs].rotalist.length;xh++){
|
||||||
if((trainmodel.children[rs].matrixWorld.elements[12]+38)>=trainmodel.children[rs].rotalist[0].posr.x){
|
if((trainmodel.children[rs].matrixWorld.elements[12]-38)<=trainmodel.children[rs].rotalist[0].posr.x){
|
||||||
|
|
||||||
if(rs != 5){
|
if(rs != 5){
|
||||||
let asd = trainmodel.children[rs].rotalist[0];
|
let asd = trainmodel.children[rs].rotalist[0];
|
||||||
trainmodel.children[rs+1].rotalist.push(asd);
|
trainmodel.children[rs+1].rotalist.push(asd);
|
||||||
|
|
||||||
}
|
}
|
||||||
//let offsetx = trainmodel.children[1].matrixWorld.elements[12]-trainmodel.children[0].children[3].matrixWorld.elements[12];
|
|
||||||
|
|
||||||
trainmodel.children[rs].rotation.y = trainmodel.children[rs].rotalist[0].rota;
|
trainmodel.children[rs].rotation.y = trainmodel.children[rs].rotalist[0].rota;
|
||||||
trainmodel.children[rs].rotalist.splice(0,1)
|
trainmodel.children[rs].rotalist.splice(0,1)
|
||||||
@ -119,126 +126,122 @@ export function UpdateTrain(camera,traindata,control){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//console.log(trainmodel.children[rs].rotalist.length);
|
//console.log(trainmodel.children[rs].rotalist.length);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
// console.log(trainmodel.rotalist);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
trainmodel.progress += trainmodel.speeds;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}else if(trainmodel.speeds < 0 && trainmodel.speeds){
|
|
||||||
let speed = null;
|
|
||||||
if(traindata.group.children[j].progress<1){
|
|
||||||
|
|
||||||
let movecurve = trainmodel.curve;
|
|
||||||
|
|
||||||
if(trainmodel.status == "03" && trainmodel.progress>0){
|
|
||||||
if(movecurve.points.length>1){
|
|
||||||
let point = movecurve.getPointAt(traindata.group.children[j].progress);
|
|
||||||
if(Math.abs( point.z -trainmodel.children[0].matrixWorld.elements[14]) >0.1){
|
|
||||||
trainmodel.children[0].up = new THREE.Vector3(-1,0,0);
|
|
||||||
let tangent = movecurve.getTangentAt(traindata.group.children[j].progress).normalize();
|
|
||||||
trainmodel.children[0].axis.crossVectors(trainmodel.children[0].up, tangent).normalize();
|
|
||||||
let radians = Math.acos(trainmodel.children[0].up.dot(tangent));
|
|
||||||
trainmodel.children[0].quaternion.setFromAxisAngle(trainmodel.children[0].axis, radians);
|
|
||||||
let rotas = {
|
|
||||||
posr:point,
|
|
||||||
rota:trainmodel.children[0].rotation.y
|
|
||||||
}
|
|
||||||
trainmodel.children[1].rotalist.push(rotas);
|
|
||||||
|
|
||||||
let offsetz = parseFloat(trainmodel.children[0].matrixWorld.elements[14]) - parseFloat(point.z);
|
|
||||||
trainmodel.children[0].position.z += offsetz;
|
|
||||||
//trainmodel.position.z = point.z;
|
|
||||||
}
|
|
||||||
|
|
||||||
trainmodel.position.x = point.x;
|
|
||||||
trainmodel.position.y = 0;
|
|
||||||
|
|
||||||
if(trainmodel.children[1].rotalist.length > 0 || trainmodel.children[2].rotalist.length > 0 || trainmodel.children[3].rotalist.length > 0 || trainmodel.children[4].rotalist.length > 0|| trainmodel.children[5].rotalist.length > 0){
|
|
||||||
for(let rs = 1;rs<6;rs++){
|
|
||||||
//console.log(rs);
|
|
||||||
if(trainmodel.children[rs].rotalist[0]){
|
|
||||||
let offsetz = parseFloat(trainmodel.children[rs].matrixWorld.elements[14]) - parseFloat(trainmodel.children[rs].rotalist[0].posr.z);
|
|
||||||
|
|
||||||
trainmodel.children[rs].position.z += offsetz;
|
|
||||||
|
|
||||||
for(let xh=0;xh<trainmodel.children[rs].rotalist.length;xh++){
|
|
||||||
if((trainmodel.children[rs].matrixWorld.elements[12]-38)<=trainmodel.children[rs].rotalist[0].posr.x){
|
|
||||||
|
|
||||||
if(rs != 5){
|
|
||||||
let asd = trainmodel.children[rs].rotalist[0];
|
|
||||||
trainmodel.children[rs+1].rotalist.push(asd);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
trainmodel.children[rs].rotation.y = trainmodel.children[rs].rotalist[0].rota;
|
|
||||||
trainmodel.children[rs].rotalist.splice(0,1)
|
|
||||||
xh--;
|
|
||||||
}else{
|
|
||||||
xh = trainmodel.children[rs].rotalist.length;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//console.log(trainmodel.children[rs].rotalist.length);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if(trainmodel.progress > -(trainmodel.speeds)){
|
|
||||||
trainmodel.progress += trainmodel.speeds;
|
trainmodel.progress += trainmodel.speeds;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(trainmodel.status == "02"){
|
||||||
|
if(movecurve.points.length>1){
|
||||||
|
let point = movecurve.getPointAt(trainmodel.progress);
|
||||||
|
if(Math.abs( point.z -trainmodel.children[0].matrixWorld.elements[14]) >0.1){
|
||||||
|
trainmodel.children[0].up = new THREE.Vector3(1,0,0);
|
||||||
|
let tangent = movecurve.getTangentAt(traindata.group.children[j].progress).normalize();
|
||||||
|
trainmodel.children[0].axis.crossVectors(trainmodel.children[0].up, tangent).normalize();
|
||||||
|
let radians = Math.acos(trainmodel.children[0].up.dot(tangent));
|
||||||
|
trainmodel.children[0].quaternion.setFromAxisAngle(trainmodel.children[0].axis, radians);
|
||||||
|
|
||||||
|
let rotas = {
|
||||||
|
posr:point,
|
||||||
|
rota:trainmodel.children[0].rotation.y
|
||||||
|
}
|
||||||
|
trainmodel.children[1].rotalist.push(rotas);
|
||||||
|
let offsetz = parseFloat(point.z) - parseFloat(trainmodel.children[0].matrixWorld.elements[14]);
|
||||||
|
trainmodel.children[0].position.z += offsetz;
|
||||||
|
//trainmodel.position.z = point.z;
|
||||||
|
}
|
||||||
|
|
||||||
|
trainmodel.position.x = point.x;
|
||||||
|
trainmodel.position.y = 0;
|
||||||
|
if(trainmodel.children[1].rotalist.length > 0 || trainmodel.children[2].rotalist.length > 0 || trainmodel.children[3].rotalist.length > 0 || trainmodel.children[4].rotalist.length > 0|| trainmodel.children[5].rotalist.length > 0){
|
||||||
|
|
||||||
|
for(let rs = 1;rs<6;rs++){
|
||||||
|
//console.log(rs);
|
||||||
|
if(trainmodel.children[rs].rotalist[0]){
|
||||||
|
|
||||||
|
let offsetz = parseFloat(trainmodel.children[rs].rotalist[0].posr.z) - parseFloat(trainmodel.children[rs].matrixWorld.elements[14]);
|
||||||
|
trainmodel.children[rs].position.z += offsetz;
|
||||||
|
|
||||||
|
for(let xh=0;xh<trainmodel.children[rs].rotalist.length;xh++){
|
||||||
|
if((trainmodel.children[rs].matrixWorld.elements[12]+38)>=trainmodel.children[rs].rotalist[0].posr.x){
|
||||||
|
|
||||||
|
if(rs != 5){
|
||||||
|
let asd = trainmodel.children[rs].rotalist[0];
|
||||||
|
trainmodel.children[rs+1].rotalist.push(asd);
|
||||||
|
|
||||||
|
}
|
||||||
|
//let offsetx = trainmodel.children[1].matrixWorld.elements[12]-trainmodel.children[0].children[3].matrixWorld.elements[12];
|
||||||
|
|
||||||
|
trainmodel.children[rs].rotation.y = trainmodel.children[rs].rotalist[0].rota;
|
||||||
|
trainmodel.children[rs].rotalist.splice(0,1)
|
||||||
|
xh--;
|
||||||
|
}else{
|
||||||
|
xh = trainmodel.children[rs].rotalist.length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//console.log(trainmodel.children[rs].rotalist.length);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
// console.log(trainmodel.rotalist);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
trainmodel.progress += trainmodel.speeds;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(trainmodel.status == "02"){
|
}else if(trainmodel.speeds < 0 && trainmodel.speeds){
|
||||||
if(movecurve.points.length>1 && trainmodel.progress>0){
|
let speed = null;
|
||||||
|
if(traindata.group.children[j].progress<1){
|
||||||
|
|
||||||
let point = movecurve.getPointAt(trainmodel.progress);
|
let movecurve = trainmodel.curve;
|
||||||
if(Math.abs( point.z -trainmodel.children[0].matrixWorld.elements[14]) >0.1){
|
|
||||||
trainmodel.children[0].up = new THREE.Vector3(1,0,0);
|
|
||||||
let tangent = movecurve.getTangentAt(traindata.group.children[j].progress).normalize();
|
|
||||||
trainmodel.children[0].axis.crossVectors(trainmodel.children[0].up, tangent).normalize();
|
|
||||||
let radians = Math.acos(trainmodel.children[0].up.dot(tangent));
|
|
||||||
trainmodel.children[0].quaternion.setFromAxisAngle(trainmodel.children[0].axis, radians);
|
|
||||||
|
|
||||||
let rotas = {
|
if(trainmodel.status == "03" && trainmodel.progress>0){
|
||||||
posr:point,
|
if(movecurve.points.length>1){
|
||||||
rota:trainmodel.children[0].rotation.y
|
let point = movecurve.getPointAt(traindata.group.children[j].progress);
|
||||||
|
if(Math.abs( point.z -trainmodel.children[0].matrixWorld.elements[14]) >0.1){
|
||||||
|
trainmodel.children[0].up = new THREE.Vector3(-1,0,0);
|
||||||
|
let tangent = movecurve.getTangentAt(traindata.group.children[j].progress).normalize();
|
||||||
|
trainmodel.children[0].axis.crossVectors(trainmodel.children[0].up, tangent).normalize();
|
||||||
|
let radians = Math.acos(trainmodel.children[0].up.dot(tangent));
|
||||||
|
trainmodel.children[0].quaternion.setFromAxisAngle(trainmodel.children[0].axis, radians);
|
||||||
|
let rotas = {
|
||||||
|
posr:point,
|
||||||
|
rota:trainmodel.children[0].rotation.y
|
||||||
|
}
|
||||||
|
trainmodel.children[1].rotalist.push(rotas);
|
||||||
|
|
||||||
|
let offsetz = parseFloat(trainmodel.children[0].matrixWorld.elements[14]) - parseFloat(point.z);
|
||||||
|
trainmodel.children[0].position.z += offsetz;
|
||||||
|
//trainmodel.position.z = point.z;
|
||||||
}
|
}
|
||||||
trainmodel.children[1].rotalist.push(rotas);
|
|
||||||
let offsetz = parseFloat(point.z) - parseFloat(trainmodel.children[0].matrixWorld.elements[14]);
|
|
||||||
trainmodel.children[0].position.z += offsetz;
|
|
||||||
//trainmodel.position.z = point.z;
|
|
||||||
}
|
|
||||||
|
|
||||||
trainmodel.position.x = point.x;
|
trainmodel.position.x = point.x;
|
||||||
trainmodel.position.y = 0;
|
trainmodel.position.y = 0;
|
||||||
if(trainmodel.children[1].rotalist.length > 0 || trainmodel.children[2].rotalist.length > 0 || trainmodel.children[3].rotalist.length > 0 || trainmodel.children[4].rotalist.length > 0|| trainmodel.children[5].rotalist.length > 0){
|
|
||||||
|
|
||||||
for(let rs = 1;rs<6;rs++){
|
if(trainmodel.children[1].rotalist.length > 0 || trainmodel.children[2].rotalist.length > 0 || trainmodel.children[3].rotalist.length > 0 || trainmodel.children[4].rotalist.length > 0|| trainmodel.children[5].rotalist.length > 0){
|
||||||
|
for(let rs = 1;rs<6;rs++){
|
||||||
//console.log(rs);
|
//console.log(rs);
|
||||||
if(trainmodel.children[rs].rotalist[0]){
|
if(trainmodel.children[rs].rotalist[0]){
|
||||||
|
let offsetz = parseFloat(trainmodel.children[rs].matrixWorld.elements[14]) - parseFloat(trainmodel.children[rs].rotalist[0].posr.z);
|
||||||
|
|
||||||
let offsetz = parseFloat(trainmodel.children[rs].rotalist[0].posr.z) - parseFloat(trainmodel.children[rs].matrixWorld.elements[14]);
|
|
||||||
trainmodel.children[rs].position.z += offsetz;
|
trainmodel.children[rs].position.z += offsetz;
|
||||||
|
|
||||||
for(let xh=0;xh<trainmodel.children[rs].rotalist.length;xh++){
|
for(let xh=0;xh<trainmodel.children[rs].rotalist.length;xh++){
|
||||||
if((trainmodel.children[rs].matrixWorld.elements[12]+38)>=trainmodel.children[rs].rotalist[0].posr.x){
|
if((trainmodel.children[rs].matrixWorld.elements[12]-38)<=trainmodel.children[rs].rotalist[0].posr.x){
|
||||||
|
|
||||||
if(rs != 5){
|
if(rs != 5){
|
||||||
let asd = trainmodel.children[rs].rotalist[0];
|
let asd = trainmodel.children[rs].rotalist[0];
|
||||||
trainmodel.children[rs+1].rotalist.push(asd);
|
trainmodel.children[rs+1].rotalist.push(asd);
|
||||||
|
|
||||||
}
|
}
|
||||||
//let offsetx = trainmodel.children[1].matrixWorld.elements[12]-trainmodel.children[0].children[3].matrixWorld.elements[12];
|
|
||||||
|
|
||||||
trainmodel.children[rs].rotation.y = trainmodel.children[rs].rotalist[0].rota;
|
trainmodel.children[rs].rotation.y = trainmodel.children[rs].rotalist[0].rota;
|
||||||
trainmodel.children[rs].rotalist.splice(0,1)
|
trainmodel.children[rs].rotalist.splice(0,1)
|
||||||
@ -248,23 +251,85 @@ export function UpdateTrain(camera,traindata,control){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//console.log(trainmodel.children[rs].rotalist.length);
|
//console.log(trainmodel.children[rs].rotalist.length);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(trainmodel.progress > -(trainmodel.speeds)){
|
||||||
|
trainmodel.progress += trainmodel.speeds;
|
||||||
}
|
}
|
||||||
// console.log(trainmodel.rotalist);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if(trainmodel.progress > -(trainmodel.speeds)){
|
|
||||||
trainmodel.progress += trainmodel.speeds;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
if(trainmodel.status == "02"){
|
||||||
|
if(movecurve.points.length>1 && trainmodel.progress>0){
|
||||||
|
|
||||||
|
let point = movecurve.getPointAt(trainmodel.progress);
|
||||||
|
if(Math.abs( point.z -trainmodel.children[0].matrixWorld.elements[14]) >0.1){
|
||||||
|
trainmodel.children[0].up = new THREE.Vector3(1,0,0);
|
||||||
|
let tangent = movecurve.getTangentAt(traindata.group.children[j].progress).normalize();
|
||||||
|
trainmodel.children[0].axis.crossVectors(trainmodel.children[0].up, tangent).normalize();
|
||||||
|
let radians = Math.acos(trainmodel.children[0].up.dot(tangent));
|
||||||
|
trainmodel.children[0].quaternion.setFromAxisAngle(trainmodel.children[0].axis, radians);
|
||||||
|
|
||||||
|
let rotas = {
|
||||||
|
posr:point,
|
||||||
|
rota:trainmodel.children[0].rotation.y
|
||||||
|
}
|
||||||
|
trainmodel.children[1].rotalist.push(rotas);
|
||||||
|
let offsetz = parseFloat(point.z) - parseFloat(trainmodel.children[0].matrixWorld.elements[14]);
|
||||||
|
trainmodel.children[0].position.z += offsetz;
|
||||||
|
//trainmodel.position.z = point.z;
|
||||||
|
}
|
||||||
|
|
||||||
|
trainmodel.position.x = point.x;
|
||||||
|
trainmodel.position.y = 0;
|
||||||
|
if(trainmodel.children[1].rotalist.length > 0 || trainmodel.children[2].rotalist.length > 0 || trainmodel.children[3].rotalist.length > 0 || trainmodel.children[4].rotalist.length > 0|| trainmodel.children[5].rotalist.length > 0){
|
||||||
|
|
||||||
|
for(let rs = 1;rs<6;rs++){
|
||||||
|
//console.log(rs);
|
||||||
|
if(trainmodel.children[rs].rotalist[0]){
|
||||||
|
|
||||||
|
let offsetz = parseFloat(trainmodel.children[rs].rotalist[0].posr.z) - parseFloat(trainmodel.children[rs].matrixWorld.elements[14]);
|
||||||
|
trainmodel.children[rs].position.z += offsetz;
|
||||||
|
|
||||||
|
for(let xh=0;xh<trainmodel.children[rs].rotalist.length;xh++){
|
||||||
|
if((trainmodel.children[rs].matrixWorld.elements[12]+38)>=trainmodel.children[rs].rotalist[0].posr.x){
|
||||||
|
|
||||||
|
if(rs != 5){
|
||||||
|
let asd = trainmodel.children[rs].rotalist[0];
|
||||||
|
trainmodel.children[rs+1].rotalist.push(asd);
|
||||||
|
|
||||||
|
}
|
||||||
|
//let offsetx = trainmodel.children[1].matrixWorld.elements[12]-trainmodel.children[0].children[3].matrixWorld.elements[12];
|
||||||
|
|
||||||
|
trainmodel.children[rs].rotation.y = trainmodel.children[rs].rotalist[0].rota;
|
||||||
|
trainmodel.children[rs].rotalist.splice(0,1)
|
||||||
|
xh--;
|
||||||
|
}else{
|
||||||
|
xh = trainmodel.children[rs].rotalist.length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//console.log(trainmodel.children[rs].rotalist.length);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
// console.log(trainmodel.rotalist);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(trainmodel.progress > -(trainmodel.speeds)){
|
||||||
|
trainmodel.progress += trainmodel.speeds;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,6 +152,7 @@ export function TrainList() {
|
|||||||
newmesh.speed = 0;
|
newmesh.speed = 0;
|
||||||
newmesh.speeds = 0;
|
newmesh.speeds = 0;
|
||||||
newmesh.progress = null;
|
newmesh.progress = null;
|
||||||
|
newmesh.startmark = 0;
|
||||||
|
|
||||||
|
|
||||||
scope.list[data[i].code] = newmesh;
|
scope.list[data[i].code] = newmesh;
|
||||||
|
Loading…
Reference in New Issue
Block a user