修改文字显示,行车路径,行车计算

This commit is contained in:
sunzhenyu 2019-10-17 18:48:36 +08:00
parent 6fa90f5c79
commit f847629b92
22 changed files with 213 additions and 156 deletions

View File

@ -352,7 +352,7 @@ export function SectionList() {
}else{
scope.standtrack.push(testmesh1);
var box = new THREE.BoxHelper( testmesh1, 0xff0000 );
scope.sectiongroup.add( box );
// scope.sectiongroup.add( box );
}
scope.sections.modellist.push(testmesh1);
}

View File

@ -161,7 +161,8 @@ export function JLmap3dEdit(dom, data, mapid) {
let exporter = new THREE.OBJExporter();
console.log(scope.mapdata);
// let exportmodels = scope.mapdata.linklist.linksgroup;
let exportmodels = scope.mapdata.sectionlist.switchgroup;
// let exportmodels = scope.mapdata.sectionlist.switchgroup;
let exportmodels = scope.mapdata.stationstandlist.group;
let result = exporter.parse( exportmodels );
console.log(result);

View File

@ -6,11 +6,6 @@ import {OBJLoader} from '@/jlmap3d/main/loaders/OBJLoader.js';
import {MTLLoader} from '@/jlmap3d/main/loaders/MTLLoader.js';
import { FBXLoader } from '@/jlmap3d/main/loaders/FBXLoader.js';
// controls
import {OrbitControls} from '@/jlmap3d/main/control/OrbitControls.js';
import { DragControls } from '@/jlmap3d/main/control/DragControls.js';
// component
// data
import { Jl3ddata } from '@/jlmap3d/main/model/jl3ddata';
@ -20,11 +15,14 @@ import { SetRender } from '@/jlmap3d/config/SetRender';
import { SetScene } from '@/jlmap3d/config/SetScene';
import { SetLights } from '@/jlmap3d/config/SetLights';
// controls
import {OrbitControls} from '@/jlmap3d/main/control/OrbitControls.js';
import { DragControls } from '@/jlmap3d/main/control/DragControls.js';
// 加载器
import { ModelLoad } from '@/jlmap3d/main/loaders/simulationloader';
// connect
import {Jl3dDriving} from '@/jlmap3d/jl3ddrive/moveupdate/DrivingConnect';
import { getPublishMapVersion, getPublishMapDetail, getPublish3dMapDetail} from '@/api/jlmap3d/load3ddata';
// utils
@ -40,7 +38,7 @@ var clock = new THREE.Clock();
export function JLmapDriving(dom, data, skinCode,storemod) {
const scope = this;
let scope = this;
//界面更新函数
let updatemmi = {};
@ -49,7 +47,7 @@ export function JLmapDriving(dom, data, skinCode,storemod) {
this.animateswitch = false;
this.cctvswitch = false;
// 初始化webgl渲染
const renderer = SetRender(dom);
let renderer = SetRender(dom);
renderer.domElement.style.position = 'absolute';
renderer.domElement.style.top = '0';
@ -63,9 +61,9 @@ export function JLmapDriving(dom, data, skinCode,storemod) {
// 定义相机
//let camera = SetCamera(dom);
// 定义场景(渲染容器)
const scene = SetScene();
let scene = SetScene();
const speed = 0;
let speed = 0;
let drivingcode = null;
@ -98,7 +96,7 @@ export function JLmapDriving(dom, data, skinCode,storemod) {
// 地图模型数据
let mapdata = new Jl3ddata();
let camera = new THREE.PerspectiveCamera(70, dom.clientWidth/dom.clientHeight, 1, 1100);
let camera = new THREE.PerspectiveCamera(70, dom.clientWidth/dom.clientHeight, 1, 11000);
camera.position.set( 0, 0, 0 );
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
@ -119,12 +117,13 @@ export function JLmapDriving(dom, data, skinCode,storemod) {
sound.play();
});
const controls3 = new MouseControls(camera, 1.6);
let controls3 = new MouseControls(camera, 1.6);
controls3.enabled = true;
// controls3.getObject().rotation.x = Math.PI/2;
scene.add(controls3.getObject());
let cameracctv = new THREE.PerspectiveCamera(70, dom.clientWidth/dom.clientHeight, 1, 120);
cameracctv.position.set( 5, -3,27 );
cameracctv.position.set( 2, -1,27 );
cameracctv.rotation.y = Math.PI/5*3;
camera.add(cameracctv);
@ -138,6 +137,32 @@ export function JLmapDriving(dom, data, skinCode,storemod) {
if(mapdata.trainlisttest.group.children[0]){
updatemmi.updatedrivingcode(mapdata.trainlisttest.group.children[0].name);
scope.Subscribe.initdrivercode(mapdata.trainlisttest.group.children[0].name);
for(let k in mapdata.rails.switchrail){
const ddd = storemod.getters['map/getDeviceByCode'](k);
let switchdata = mapdata.rails.switchrail[k];
mapdata.rails.switchrail[k].locateType = ddd.locateType;
if(ddd.locateType == "01"){
//1--向左 2--向右
//__\__ __/__
if(mapdata.rails.switchrail[k].directtype == "1"){
mapdata.rails.linkrail[switchdata.alink].lconnect = switchdata.blink;
mapdata.rails.linkrail[switchdata.blink].rconnect = switchdata.alink;
}else if(mapdata.rails.switchrail[k].directtype == "2"){
mapdata.rails.linkrail[switchdata.alink].rconnect = switchdata.blink;
mapdata.rails.linkrail[switchdata.blink].lconnect = switchdata.alink;
}
}else if(ddd.locateType == "02"){
if(mapdata.rails.switchrail[k].directtype == "1"){
mapdata.rails.linkrail[switchdata.alink].lconnect = switchdata.clink;
mapdata.rails.linkrail[switchdata.clink].rconnect = switchdata.alink;
}else if(mapdata.rails.switchrail[k].directtype == "2"){
mapdata.rails.linkrail[switchdata.alink].rconnect = switchdata.clink;
mapdata.rails.linkrail[switchdata.clink].lconnect = switchdata.alink;
}
}
}
clearInterval(timer);
}
}
@ -187,7 +212,7 @@ export function JLmapDriving(dom, data, skinCode,storemod) {
controls3.getObject().position.x = mapdata.trainlisttest.list[drivingcode].matrixWorld.elements[12]-27;
controls3.getObject().position.y=10;
controls3.getObject().position.z = mapdata.trainlisttest.list[drivingcode].children[0].matrixWorld.elements[14];
controls3.getObject().rotation.x = Math.PI/2;
console.log(controls3);
}
@ -231,14 +256,11 @@ export function JLmapDriving(dom, data, skinCode,storemod) {
updatemmi.updatedrivingcode = function(code) {
drivingcode = code;
mapdata.trainlisttest.list[drivingcode].children[0].add(controls3.getObject());
mapdata.trainlisttest.list[drivingcode].children[0].add(scope.assetloader.modellist[4].mesh);
controls3.getObject().position.x = 20;
controls3.getObject().position.x = 10;
controls3.getObject().position.y = 0;
controls3.getObject().position.z = 5;
controls3.getObject().position.z = 2.5;
controls3.getObject().rotation.x = Math.PI/2;
controls3.getObject().rotation.y = -Math.PI/2;
scope.assetloader.modellist[4].mesh.position.x = 34;
scope.assetloader.modellist[4].mesh.position.y = 0;
};
this.dispose = function() {
@ -379,9 +401,9 @@ export function JLmapDriving(dom, data, skinCode,storemod) {
if (event.button == '0') {
// 定义光线
const raycaster = new THREE.Raycaster();
let raycaster = new THREE.Raycaster();
// 定义平面鼠标点击坐标
const mouse = new THREE.Vector2();
let mouse = new THREE.Vector2();
mouse.x = (event.clientX / window.innerWidth) * 2 - 1;
mouse.y = -(event.clientY / window.innerHeight) * 2 + 1;
@ -393,7 +415,7 @@ export function JLmapDriving(dom, data, skinCode,storemod) {
if (scope.raycasterswitch == 'stand') {
// 从站台对象组获取点击目标
const intersects1 = raycaster.intersectObjects( mapdata.stationstandlist.textlist);
let intersects1 = raycaster.intersectObjects( mapdata.stationstandlist.textlist);
// 获取最近处点击到的模型对象
if (intersects1[0]) {
// 遍历对象组获取对象坐标更新相机数据
@ -411,7 +433,7 @@ export function JLmapDriving(dom, data, skinCode,storemod) {
}
if (scope.raycasterswitch == 'train') {
const intersects = raycaster.intersectObjects( mapdata.trainlisttest.textlist);
let intersects = raycaster.intersectObjects( mapdata.trainlisttest.textlist);
if (intersects[0]) {
for (let j=0; j<mapdata.trainlisttest.list.length; j++) {
if (intersects[0].object.name == mapdata.trainlisttest.list[j].name) {
@ -425,7 +447,7 @@ export function JLmapDriving(dom, data, skinCode,storemod) {
if (scope.raycasterswitch == 'section') {
// console.log(mapdata.sectionlist.sections.modellist);
const intersects = raycaster.intersectObjects( mapdata.sectionlist.sections.modellist, true);
let intersects = raycaster.intersectObjects( mapdata.sectionlist.sections.modellist, true);
if (intersects[0]) {
scope.helpbox = new THREE.BoxHelper( intersects[0].object, 0xff0000 );
@ -435,7 +457,7 @@ export function JLmapDriving(dom, data, skinCode,storemod) {
if (scope.raycasterswitch == 'signal') {
const intersects = raycaster.intersectObjects( mapdata.signallist.group.children, true);
let intersects = raycaster.intersectObjects( mapdata.signallist.group.children, true);
if (intersects[0]) {
scope.helpbox = new THREE.BoxHelper( intersects[0].object, 0xff0000 );
@ -444,7 +466,7 @@ export function JLmapDriving(dom, data, skinCode,storemod) {
}
if (scope.raycasterswitch == 'switch') {
const intersects = raycaster.intersectObjects( mapdata.sectionlist.switchs.modellist, true);
let intersects = raycaster.intersectObjects( mapdata.sectionlist.switchs.modellist, true);
if (intersects[0]) {
scope.helpbox = new THREE.BoxHelper( intersects[0].object, 0xff0000 );

View File

@ -157,13 +157,13 @@ export function Jl3dDriving(updatemmi,sound) {
if (trainlisttest.list[code].runMode == '02') {
if (trainlisttest.list[code].isStandTrack == true) {
trainlisttest.list[code].speeds = parseFloat(data.body[tl].v*10/36/20/trainlisttest.list[code].len);
trainlisttest.list[code].speeds = parseFloat(data.body[tl].v*10/36/21/trainlisttest.list[code].len);
} else {
trainlisttest.list[code].speeds = parseFloat(data.body[tl].v*10/36/20/trainlisttest.list[code].len);
trainlisttest.list[code].speeds = parseFloat(data.body[tl].v*10/36/21/trainlisttest.list[code].len);
}
} else {
trainlisttest.list[code].speeds = parseFloat(data.body[tl].v*10/36/20/trainlisttest.list[code].len);
trainlisttest.list[code].speeds = parseFloat(data.body[tl].v*10/36/21/trainlisttest.list[code].len);
}
if (code == drivingcode) {
@ -195,22 +195,25 @@ export function Jl3dDriving(updatemmi,sound) {
} else {
updatemmi.updateatospeed(-1);
}
let syncdata = {
type: 'Train',
code: code,
linkCode: trainlisttest.list[code].nowcode,
percent: 0
};
if(trainlisttest.list[code].progress<1){
let syncdata = {
type: 'Train',
code: code,
linkCode: trainlisttest.list[code].nowcode,
percent: 0
};
if (trainlisttest.list[code].status == '02') {
syncdata.percent = trainlisttest.list[code].progress;
} else {
syncdata.percent = 1 - trainlisttest.list[code].progress;
if (trainlisttest.list[code].status == '02') {
syncdata.percent = trainlisttest.list[code].progress;
} else {
syncdata.percent = 1 - trainlisttest.list[code].progress;
}
// console.log(syncdata);
// console.log(trainlisttest.list[code].nextcurve);
// console.log("=============");
scope.teststomp.send('/app/topic/simulation/client/drive', syncdata);
}
// console.log(syncdata);
// console.log(trainlisttest.list[code].nextcurve);
// console.log("=============");
scope.teststomp.send('/app/topic/simulation/client/drive', syncdata);
}
}
}
@ -426,6 +429,7 @@ export function Jl3dDriving(updatemmi,sound) {
trainlisttest.list[code].progress = (rotaposx-rails.linkrail[data.body[i].linkCode].lp.x)/rails.linkrail[data.body[i].linkCode].lengthfact;
trainlisttest.list[code].status = '02';
trainlisttest.list[code].curve = rails.linkrail[data.body[i].linkCode].lineleft;
trainlisttest.list[code].nextcurve = null;
}
} else if (data.body[i].directionType == '03') { // 向左
@ -439,49 +443,64 @@ export function Jl3dDriving(updatemmi,sound) {
for (let tl=0; tl<6; tl++) {
trainlisttest.list[code].children[tl].position.z = -rotaposz;
}
trainlisttest.list[code].progress = 1-(rotaposx-rails.linkrail[data.body[i].linkCode].lp.x)/rails.linkrail[data.body[i].linkCode].lengthfact;
trainlisttest.list[code].status = '03';
trainlisttest.list[code].curve = rails.linkrail[data.body[i].linkCode].lineright;
trainlisttest.list[code].progress = 1-(rotaposx-rails.linkrail[data.body[i].linkCode].lp.x)/rails.linkrail[data.body[i].linkCode].lengthfact;
trainlisttest.list[code].status = '03';
trainlisttest.list[code].curve = rails.linkrail[data.body[i].linkCode].lineright;
trainlisttest.list[code].nextcurve = null;
}
}
// console.log(rails.linkrail[data.body[i].linkCode]);
// console.log(data.body[i].linkCode)
// console.log(nextcode);
trainlisttest.list[code].len = rails.linkrail[data.body[i].linkCode].lengthfact;
if(trainlisttest.list[code].nextcurve == null){
let nextcode;
if(data.body[i].directionType == '02'){
trainlisttest.list[code].status = '02';
nextcode = rails.linkrail[data.body[i].linkCode].rconnect;
if(nextcode){
trainlisttest.list[code].nextcurve = rails.linkrail[nextcode].lineleft;
trainlisttest.list[code].nextlen = rails.linkrail[nextcode].lengthfact;
if(code != drivingcode){
let nextcode;
if(data.body[i].directionType == '02'){
if(rails.linkrail[data.body[i].linkCode].lineleft){
trainlisttest.list[code].status = '02';
trainlisttest.list[code].curve = rails.linkrail[data.body[i].linkCode].lineleft;
trainlisttest.list[code].len = rails.linkrail[data.body[i].linkCode].lengthfact;
trainlisttest.list[code].progress = data.body[i].linkOffsetPercent;
trainlisttest.list[code].speeds = parseFloat(trainlisttest.list[code].speed*10/36/21/trainlisttest.list[code].len);
}
}else if(data.body[i].directionType == '03'){
if(rails.linkrail[data.body[i].linkCode].lineright){
trainlisttest.list[code].status = '03';
trainlisttest.list[code].curve = rails.linkrail[data.body[i].linkCode].lineright;
trainlisttest.list[code].len = rails.linkrail[data.body[i].linkCode].lengthfact;
trainlisttest.list[code].progress = 1-data.body[i].linkOffsetPercent;
trainlisttest.list[code].speeds = parseFloat(trainlisttest.list[code].speed*10/36/21/trainlisttest.list[code].len);
}
}
trainlisttest.list[code].nextcode = nextcode;
}else{
let nextcode;
if(data.body[i].directionType == '02'){
trainlisttest.list[code].status = '02';
nextcode = rails.linkrail[data.body[i].linkCode].rconnect;
if(nextcode){
trainlisttest.list[code].nextcurve = rails.linkrail[nextcode].lineleft;
trainlisttest.list[code].nextlen = rails.linkrail[nextcode].lengthfact;
}
}else if(data.body[i].directionType == '03'){
trainlisttest.list[code].status = '03';
nextcode = rails.linkrail[data.body[i].linkCode].lconnect;
if(nextcode){
trainlisttest.list[code].nextcurve = rails.linkrail[nextcode].lineright;
trainlisttest.list[code].nextlen = rails.linkrail[nextcode].lengthfact;
}
}else if(data.body[i].directionType == '03'){
trainlisttest.list[code].status = '03';
nextcode = rails.linkrail[data.body[i].linkCode].lconnect;
if(nextcode){
trainlisttest.list[code].nextcurve = rails.linkrail[nextcode].lineright;
trainlisttest.list[code].nextlen = rails.linkrail[nextcode].lengthfact;
}
trainlisttest.list[code].nextcode = nextcode;
}
trainlisttest.list[code].nextcode = nextcode;
console.log(data.body[i].directionType);
console.log(data.body[i].linkCode);
console.log(rails.linkrail[data.body[i].linkCode].lengthfact);
// console.log(data.body[i].directionType);
// console.log(data.body[i].linkCode);
// console.log(rails.linkrail[data.body[i].linkCode].lengthfact);
// console.log(rails.linkrail[data.body[i].linkCode].lconnect);
// console.log(rails.linkrail[data.body[i].linkCode].rconnect);
// console.log("--------------------");
@ -489,8 +508,8 @@ export function Jl3dDriving(updatemmi,sound) {
// console.log(rails.linkrail[rails.linkrail[data.body[i].linkCode].lconnect].rconnect);
// console.log("---------------------");
// console.log(trainlisttest.list[code].curve.points);
// console.log(rails.linkrail[nextcode].lineright.points);
console.log("***********************");
// console.log(rails.linkrail[nextcode].lineleft.points);
// console.log("***********************");
// console.log(rails.linkrail[nextcode].lineleft.points);

View File

@ -19,7 +19,8 @@ export function UpdateTrain(camera,traindata,control){
if(trainmodel.status == "03"){
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.01){
if(Math.abs( point.z -trainmodel.children[0].matrixWorld.elements[14]) >0.001){
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();
@ -51,7 +52,7 @@ export function UpdateTrain(camera,traindata,control){
trainmodel.children[rs].position.z += offsetz;
for(let xh=0;xh<trainmodel.children[rs].rotalist.length;xh++){
if((trainmodel.children[rs].matrixWorld.elements[12]-8)<=trainmodel.children[rs].rotalist[0].posr.x){
if((trainmodel.children[rs].matrixWorld.elements[12]-6)<=trainmodel.children[rs].rotalist[0].posr.x){
if(rs != 5){
let asd = trainmodel.children[rs].rotalist[0];
@ -77,7 +78,8 @@ export function UpdateTrain(camera,traindata,control){
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.01){
if(Math.abs( point.z -trainmodel.children[0].matrixWorld.elements[14]) >0.001){
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();
@ -108,7 +110,7 @@ export function UpdateTrain(camera,traindata,control){
trainmodel.children[rs].position.z += offsetz;
for(let xh=0;xh<trainmodel.children[rs].rotalist.length;xh++){
if((trainmodel.children[rs].matrixWorld.elements[12]+8)>=trainmodel.children[rs].rotalist[0].posr.x){
if((trainmodel.children[rs].matrixWorld.elements[12]+6)>=trainmodel.children[rs].rotalist[0].posr.x){
if(rs != 5){
let asd = trainmodel.children[rs].rotalist[0];
@ -132,8 +134,6 @@ export function UpdateTrain(camera,traindata,control){
}
// console.log(trainmodel.rotalist);
}
trainmodel.progress += trainmodel.speeds;
}
}
@ -142,12 +142,19 @@ export function UpdateTrain(camera,traindata,control){
// if(trainmodel.status == '02'){
// }else if(trainmodel.status == '03'){
// }
trainmodel.curve = trainmodel.nextcurve;
trainmodel.nextcurve = null;
trainmodel.nextlen = null;
trainmodel.progress = 0;
trainmodel.len = trainmodel.nextlen;
trainmodel.nowcode = trainmodel.nextcode;
trainmodel.speeds = parseFloat(trainmodel.speed*10/36/21/trainmodel.len);
trainmodel.curve = trainmodel.nextcurve;
trainmodel.nextcurve = null;
trainmodel.nextlen = null;
trainmodel.nextcode = null;
}
// console.log(trainmodel.name);
@ -203,7 +210,7 @@ export function UpdateTrain(camera,traindata,control){
trainmodel.children[rs].position.z += offsetz;
for(let xh=0;xh<trainmodel.children[rs].rotalist.length;xh++){
if((trainmodel.children[rs].matrixWorld.elements[12]-8)<=trainmodel.children[rs].rotalist[0].posr.x){
if((trainmodel.children[rs].matrixWorld.elements[12]-6)<=trainmodel.children[rs].rotalist[0].posr.x){
if(rs != 5){
let asd = trainmodel.children[rs].rotalist[0];
@ -264,7 +271,7 @@ export function UpdateTrain(camera,traindata,control){
trainmodel.children[rs].position.z += offsetz;
for(let xh=0;xh<trainmodel.children[rs].rotalist.length;xh++){
if((trainmodel.children[rs].matrixWorld.elements[12]+8)>=trainmodel.children[rs].rotalist[0].posr.x){
if((trainmodel.children[rs].matrixWorld.elements[12]+6)>=trainmodel.children[rs].rotalist[0].posr.x){
if(rs != 5){
let asd = trainmodel.children[rs].rotalist[0];

View File

@ -17,7 +17,6 @@ import { SetRender } from '@/jlmap3d/config/SetRender';
import { SetScene } from '@/jlmap3d/config/SetScene';
import { SetLights } from '@/jlmap3d/config/SetLights';
//controls
import { OrbitControls } from '@/jlmap3d/main/control/OrbitControls';
import { DragControls } from '@/jlmap3d/main/control/DragControls';

View File

@ -9,7 +9,7 @@ let defaultsignal = {
deviceType:"signal",
type:"low",
picUrl:"",
assetUrl:"https://joylink.club/oss/models/signal/d3d.FBX"
assetUrl:"../../static/model/signal/d3d.FBX"
}
let defaulttrain = {
@ -107,7 +107,7 @@ export function AssetLoader(){
this.materiallist = [];
//初始化资源加载器
this.setmodellist = function (data){
// console.log("setmodellist");
let defaultmodel1 = new AssetModel(defaultsignal);
scope.modellist.push(defaultmodel1);
@ -443,10 +443,9 @@ export function AssetLoader(){
var loader = new THREE.FBXLoader();
loader.load( asset.assetUrl, function ( object ) {
let mixer = new THREE.AnimationMixer( object );
// object.traverse(function (node) {//获取其中对象
// node.frustumCulled = true;
//
// });
//object.traverse(function (node) {//获取其中对象
// node.frustumCulled = true;
//});
if(asset.deviceType == "train"){
@ -455,7 +454,7 @@ export function AssetLoader(){
let name = "c"+j;
for(let i=0;i<object.children.length;i++){
if(object.children[i].name == name){
object.children[i].position.x = object.children[i].position.x+10;
object.children[i].position.x = object.children[i].position.x;
//object.children[i].position.y = j*10;
realtrain.add(object.children[i]);
i--;

View File

@ -65,6 +65,7 @@ export function ModelLoad(data,scope,netdata,mapdata,camera,controls,scene,store
let switchdata = JSON.parse(netdata.switchs);
let signaldata = JSON.parse(netdata.signals);
let standsdata = JSON.parse(netdata.stands);
console.log(netdata.assets);
assetloader.setmodellist(netdata.assets);
assetloader.assetpromise(sceneload)
@ -101,6 +102,13 @@ export function ModelLoad(data,scope,netdata,mapdata,camera,controls,scene,store
});
})
.then(function(data){
for(let mn=0;mn<scope.assetloader.modellist.length;mn++){
if(scope.assetloader.modellist[mn].name && scope.assetloader.modellist[mn].name == "suidao"){
// scope.assetloader.modellist[mn].mesh.rotation.x = Math.PI/2;
console.log(scope.assetloader.modellist[mn].mesh.position);
scene.add(scope.assetloader.modellist[mn].mesh);
}
}
scope.animateswitch = true;

View File

@ -32,7 +32,7 @@ export function ModelLoad(data,scope,netdata,mapdata,camera,controls,scene,mixer
if(netdata.assets){
let assetsdata = JSON.parse(netdata.sections);
console.log(netdata);
// console.log(netdata);
if(assetsdata.link){
isSection = true;
}
@ -57,13 +57,13 @@ export function ModelLoad(data,scope,netdata,mapdata,camera,controls,scene,mixer
jlmap3ddata.stationstandlist = new StationStandList();
//初始化测试列车
jlmap3ddata.trainlisttest = new TrainList();
jlmap3ddata.realsectionlist = new RealSectionList();
jlmap3ddata.rails = new RailList();
let loaderdata = JSON.parse(netdata.sections);
let switchdata = JSON.parse(netdata.switchs);
let signaldata = JSON.parse(netdata.signals);
let standsdata = JSON.parse(netdata.stands);
jlmap3ddata.realsectionlist = new RealSectionList();
assetloader.setmodellist(netdata.assets);
assetloader.assetpromise(sceneload)
@ -99,55 +99,17 @@ export function ModelLoad(data,scope,netdata,mapdata,camera,controls,scene,mixer
});
})
// .then(function(data){
// return new Promise(function(resolve, reject){
//
// let loader = new THREE.OBJLoader( );
//
// loader.load( '../../static/rail/fuzhoupath.obj', function ( obj ) {
//
// let object = obj;
// //console.log(object.children.length);
//
// let rail = [];
// for(let i=0;i<object.children.length;i++){
// let name = object.children[i].name.split("_");
// let newmeshname = name[0]+"_"+name[1]+"_"+name[2]+"."+name[3];
//
// let vexlist = [];
// //console.log( object.children[i].geometry.attributes.position.array);
// for(let j=0;j<object.children[i].geometry.attributes.position.array.length;j){
// //console.log(object.children[i].geometry.attributes.position.array[j]);
// let ved = new THREE.Vector3( object.children[i].geometry.attributes.position.array[j], object.children[i].geometry.attributes.position.array[j+1], object.children[i].geometry.attributes.position.array[j+2] );
// j=j+3;
//
// vexlist.push(ved);
// }
//
// if(jlmap3ddata.sectionlist.sections.datalist[newmeshname].code){
// jlmap3ddata.sectionlist.sections.datalist[newmeshname].rail = vexlist;
// //console.log(jlmap3ddata.sectionlist.sections.datalist[n].rail.length);
// }
// }
//
// resolve("loadedrealsection");
// }, onProgress, onError );
//
// });
// })
.then(function(data){
.then(function(data){
for(let mn=0;mn<scope.assetloader.modellist.length;mn++){
if(scope.assetloader.modellist[mn].name && scope.assetloader.modellist[mn].name == "驾驶台"){
scope.assetloader.modellist[mn].mesh.position.y = -50000;
// scene.add(scope.assetloader.modellist[mn].mesh);
}
if(scope.assetloader.modellist[mn].name && scope.assetloader.modellist[mn].name == "suidao"){
scope.assetloader.modellist[mn].mesh.rotation.x = Math.PI/2;
// scope.assetloader.modellist[mn].mesh.rotation.x = Math.PI/2;
scope.assetloader.modellist[mn].mesh.position.y -=0.1;
scene.add(scope.assetloader.modellist[mn].mesh);
}
}
scope.animateswitch = true;
mapdata = jlmap3ddata;

View File

@ -10,6 +10,7 @@ export function RailList(){
};
this.init = function(linkdata,switchdata,scene,storemod){
for(let i=0;i<linkdata.length;i++){
scope.linkrail[linkdata[i].code] = {
lp:linkdata[i].rail[0],
@ -19,10 +20,25 @@ export function RailList(){
lengthfact:linkdata[i].lengthfact,
lineleft:null,
lineright:null,
points:[]
points:[],
type:null
};
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(scope.linkrail[linkdata[i].code].lp.x,0,scope.linkrail[linkdata[i].code].lp.z));
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(scope.linkrail[linkdata[i].code].rp.x,0,scope.linkrail[linkdata[i].code].rp.z));
if(linkdata[i].rotation._z == 0){
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(scope.linkrail[linkdata[i].code].lp.x+2,0,scope.linkrail[linkdata[i].code].lp.z));
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(scope.linkrail[linkdata[i].code].rp.x-2,0,scope.linkrail[linkdata[i].code].rp.z));
scope.linkrail[linkdata[i].code].type = 0;
}else{
if(linkdata[i].rotation._z>0){
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(scope.linkrail[linkdata[i].code].lp.x+2.1,0,scope.linkrail[linkdata[i].code].lp.z-0.6));
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(scope.linkrail[linkdata[i].code].rp.x-2.1,0,scope.linkrail[linkdata[i].code].rp.z+0.6));
scope.linkrail[linkdata[i].code].type = 1;
}else{
scope.linkrail[linkdata[i].code].type = 2;
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(scope.linkrail[linkdata[i].code].lp.x+2.1,0,scope.linkrail[linkdata[i].code].lp.z+0.6));
scope.linkrail[linkdata[i].code].points.push(new THREE.Vector3(scope.linkrail[linkdata[i].code].rp.x-2.1,0,scope.linkrail[linkdata[i].code].rp.z-0.6));
}
}
}
for(let i=0;i<switchdata.length;i++){
@ -37,21 +53,45 @@ export function RailList(){
if(scope.linkrail[switchdata[i].blink].lp.x < switchdata[i].position.x){
scope.linkrail[switchdata[i].blink].points.push(new THREE.Vector3(switchdata[i].position.x,switchdata[i].position.y,switchdata[i].position.z));
scope.linkrail[switchdata[i].blink].points.push(new THREE.Vector3(scope.linkrail[switchdata[i].alink].lp.x,0,scope.linkrail[switchdata[i].alink].lp.z));
if(scope.linkrail[switchdata[i].alink].type == 1){
scope.linkrail[switchdata[i].blink].points.push(new THREE.Vector3(scope.linkrail[switchdata[i].alink].lp.x+2.1,0,scope.linkrail[switchdata[i].alink].lp.z-0.6));
}else if(scope.linkrail[switchdata[i].alink].type == 2){
scope.linkrail[switchdata[i].blink].points.push(new THREE.Vector3(scope.linkrail[switchdata[i].alink].lp.x+2.1,0,scope.linkrail[switchdata[i].alink].lp.z+0.6));
}else{
scope.linkrail[switchdata[i].blink].points.push(new THREE.Vector3(scope.linkrail[switchdata[i].alink].lp.x+2,0,scope.linkrail[switchdata[i].alink].lp.z));
}
scope.switchrail[switchdata[i].code].directtype = "1";
}else{
scope.linkrail[switchdata[i].blink].points.splice(0,0,new THREE.Vector3(switchdata[i].position.x,switchdata[i].position.y,switchdata[i].position.z));
scope.linkrail[switchdata[i].blink].points.splice(0,0,new THREE.Vector3(scope.linkrail[switchdata[i].alink].rp.x,0,scope.linkrail[switchdata[i].alink].rp.z));
if(scope.linkrail[switchdata[i].alink].type == 1){
scope.linkrail[switchdata[i].blink].points.splice(0,0,new THREE.Vector3(scope.linkrail[switchdata[i].alink].rp.x-2.1,0,scope.linkrail[switchdata[i].alink].rp.z+0.6));
}else if(scope.linkrail[switchdata[i].alink].type == 2){
scope.linkrail[switchdata[i].blink].points.splice(0,0,new THREE.Vector3(scope.linkrail[switchdata[i].alink].rp.x-2.1,0,scope.linkrail[switchdata[i].alink].rp.z-0.6));
}else{
scope.linkrail[switchdata[i].blink].points.splice(0,0,new THREE.Vector3(scope.linkrail[switchdata[i].alink].rp.x-2,0,scope.linkrail[switchdata[i].alink].rp.z));
}
scope.switchrail[switchdata[i].code].directtype = "2";
}
//
if(scope.linkrail[switchdata[i].clink].lp.x < switchdata[i].position.x){
scope.linkrail[switchdata[i].clink].points.push(new THREE.Vector3(switchdata[i].position.x,switchdata[i].position.y,switchdata[i].position.z));
scope.linkrail[switchdata[i].clink].points.push(new THREE.Vector3(scope.linkrail[switchdata[i].alink].lp.x,0,scope.linkrail[switchdata[i].alink].lp.z));
if(scope.linkrail[switchdata[i].alink].type == 1){
scope.linkrail[switchdata[i].clink].points.push(new THREE.Vector3(scope.linkrail[switchdata[i].alink].lp.x+2.1,0,scope.linkrail[switchdata[i].alink].lp.z-0.6));
}else if(scope.linkrail[switchdata[i].alink].type == 2){
scope.linkrail[switchdata[i].clink].points.push(new THREE.Vector3(scope.linkrail[switchdata[i].alink].lp.x+2.1,0,scope.linkrail[switchdata[i].alink].lp.z+0.6));
}else{
scope.linkrail[switchdata[i].clink].points.push(new THREE.Vector3(scope.linkrail[switchdata[i].alink].lp.x+2,0,scope.linkrail[switchdata[i].alink].lp.z));
}
scope.switchrail[switchdata[i].code].directtype = "1";
}else{
scope.linkrail[switchdata[i].clink].points.splice(0,0,new THREE.Vector3(switchdata[i].position.x,switchdata[i].position.y,switchdata[i].position.z));
scope.linkrail[switchdata[i].clink].points.splice(0,0,new THREE.Vector3(scope.linkrail[switchdata[i].alink].rp.x,0,scope.linkrail[switchdata[i].alink].rp.z));
if(scope.linkrail[switchdata[i].alink].type == 1){
scope.linkrail[switchdata[i].clink].points.splice(0,0,new THREE.Vector3(scope.linkrail[switchdata[i].alink].rp.x-2.1,0,scope.linkrail[switchdata[i].alink].rp.z+0.6));
}else if(scope.linkrail[switchdata[i].alink].type == 2){
scope.linkrail[switchdata[i].clink].points.splice(0,0,new THREE.Vector3(scope.linkrail[switchdata[i].alink].rp.x-2.1,0,scope.linkrail[switchdata[i].alink].rp.z-0.6));
}else{
scope.linkrail[switchdata[i].clink].points.splice(0,0,new THREE.Vector3(scope.linkrail[switchdata[i].alink].rp.x-2,0,scope.linkrail[switchdata[i].alink].rp.z));
}
scope.switchrail[switchdata[i].code].directtype = "2";
}
@ -80,6 +120,8 @@ export function RailList(){
}
for(let i=0;i<linkdata.length;i++){
scope.linkrail[linkdata[i].code].lineleft = new THREE.CatmullRomCurve3(scope.linkrail[linkdata[i].code].points);
// scope.linkrail[linkdata[i].code].lineleft.curveType = "catmullrom";
// scope.linkrail[linkdata[i].code].lineleft.tension = 0.2;
let rightpoints = [];
scope.linkrail[linkdata[i].code].points.forEach(item=>{
rightpoints.push(item);
@ -87,6 +129,8 @@ export function RailList(){
);
rightpoints.reverse();
scope.linkrail[linkdata[i].code].lineright = new THREE.CatmullRomCurve3(rightpoints);
// scope.linkrail[linkdata[i].code].lineright.curveType = "catmullrom";
// scope.linkrail[linkdata[i].code].lineright.tension = 0.1;
var points = scope.linkrail[linkdata[i].code].lineleft.getPoints( 50 );
var geometry = new THREE.BufferGeometry().setFromPoints( points );
@ -95,14 +139,8 @@ export function RailList(){
// Create the final object to add to the scene
var curveObject = new THREE.Line( geometry, material );
scene.add(curveObject);
console.log(scope.linkrail[linkdata[i].code].lineleft.points);
console.log(scope.linkrail[linkdata[i].code].lineright.points);
console.log("**********************");
}
// console.log(linkdata);
console.log(scope.linkrail);
console.log(scope.switchrail);
}
this.getrail = function(){

View File

@ -285,7 +285,9 @@ export default {
.trainstatus{
left:0;
top:0;
width:350px;
width:fit-content;
width:-webkit-fit-content;
width:-moz-fit-content;
height:30px;
background: #000000;
position:absolute;

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
static/model/signal/d3d.FBX Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.