Merge remote-tracking branch 'origin/test' into test

This commit is contained in:
thesai 2021-12-20 11:06:26 +08:00
commit 8195bafa03
3 changed files with 1059 additions and 1003 deletions

View File

@ -297,8 +297,7 @@ export function JLmap3d(dom, data,skinCode,storemod,routegroup,project) {
//三维交互点击事件函数
function onselect(event) {
if(event.button == "0"){
if(controlManager.controlMode != 'fps'){
if(controlManager.controlMode != 'fps' && event.button == "0" && stationstandlist){
//定义光线
let raycaster = new THREE.Raycaster();
//定义平面鼠标点击坐标
@ -307,7 +306,6 @@ export function JLmap3d(dom, data,skinCode,storemod,routegroup,project) {
mouse.y = -(event.clientY / window.innerHeight) * 2 + 1;
raycaster.setFromCamera( mouse, controlManager.orbitCamera );
//从站台对象组获取点击目标
let intersects1 = raycaster.intersectObjects( stationstandlist.group.children,true);
@ -321,7 +319,6 @@ export function JLmap3d(dom, data,skinCode,storemod,routegroup,project) {
}
}
}
}
//相机轨迹动画
this.camerarailmove = function(){

View File

@ -1,141 +1,152 @@
import { AssetModel } from '@/jlmap3d/main/loaders/model/Assetmodel';
import { Assetmaterial } from '@/jlmap3d/main/loaders/model/Assetmaterial';
import { getBaseUrl } from '@/utils/baseUrl';
import { Loading } from 'element-ui';
import {
AssetModel
} from '@/jlmap3d/main/loaders/model/Assetmodel';
import {
Assetmaterial
} from '@/jlmap3d/main/loaders/model/Assetmaterial';
import {
getBaseUrl
} from '@/utils/baseUrl';
import {
Loading
} from 'element-ui';
const BASE_API = getBaseUrl();
import { JL3D_LOCAL_STATIC,BASE_ASSET_API } from '@/api/jlmap3d/assets3d.js';
import {
JL3D_LOCAL_STATIC,
BASE_ASSET_API
} from '@/api/jlmap3d/assets3d.js';
let defaultsignal = {
id:"3",
name:"低位三灯",
deviceType:"signal",
type:"low",
picUrl:"",
url:BASE_ASSET_API+"/MODEL/2020-07-10/13-42231.FBX"
id: "3",
name: "低位三灯",
deviceType: "signal",
type: "low",
picUrl: "",
url: BASE_ASSET_API + "/MODEL/2020-07-10/13-42231.FBX"
}
let defaulttrain = {
id:"9",
name:"6节列车",
deviceType:"train",
type:"num4",
picUrl:"",
url:BASE_ASSET_API+"/MODEL/2020-11-16/57-53841.FBX"
id: "9",
name: "6节列车",
deviceType: "train",
type: "num4",
picUrl: "",
url: BASE_ASSET_API + "/MODEL/2020-11-16/57-53841.FBX"
}
let defaultstation = {
id:"8",
name:"内侧车站",
deviceType:"stand",
type:"num4",
picUrl:"",
url:BASE_ASSET_API+"/MODEL/2020-11-16/52-60478.FBX"
id: "8",
name: "内侧车站",
deviceType: "stand",
type: "num4",
picUrl: "",
url: BASE_ASSET_API + "/MODEL/2020-11-16/52-60478.FBX"
}
let waicestation = {
id:"10",
name:"外侧车站",
deviceType:"standwaice",
type:"num4",
picUrl:"",
url:BASE_ASSET_API+"/MODEL/2020-11-16/53-61736.FBX"
id: "10",
name: "外侧车站",
deviceType: "standwaice",
type: "num4",
picUrl: "",
url: BASE_ASSET_API + "/MODEL/2020-11-16/53-61736.FBX"
}
let defaultswitch = {
id:"11",
name:"道岔",
deviceType:"switch",
type:"fuzhou",
picUrl:"",
url:BASE_ASSET_API+"/MODEL/2020-07-10/17-43789.FBX"
id: "11",
name: "道岔",
deviceType: "switch",
type: "fuzhou",
picUrl: "",
url: BASE_ASSET_API + "/MODEL/2020-07-10/17-43789.FBX"
}
let defaultsuidao = {
id:"16",
name:"suidao",
deviceType:"suidao",
type:"suidao",
picUrl:"",
url:BASE_ASSET_API+"/MODEL/2020-07-10/21-35677.FBX"
id: "16",
name: "suidao",
deviceType: "suidao",
type: "suidao",
picUrl: "",
url: BASE_ASSET_API + "/MODEL/2020-07-10/21-35677.FBX"
}
let defaultbackground = {
id:"16",
name:"background",
deviceType:"background",
type:"background",
picUrl:"",
url:BASE_ASSET_API+"/MODEL/2020-07-10/21-35677.FBX"
id: "16",
name: "background",
deviceType: "background",
type: "background",
picUrl: "",
url: BASE_ASSET_API + "/MODEL/2020-07-10/21-35677.FBX"
}
let defaultautorail = {
id:"100",
name:"autorail",
deviceType:"autorail",
type:"autorail",
picUrl:"",
url:BASE_ASSET_API+"/MODEL/auto/rail.FBX"
id: "100",
name: "autorail",
deviceType: "autorail",
type: "autorail",
picUrl: "",
url: BASE_ASSET_API + "/MODEL/auto/rail.FBX"
}
let autoswitch = {
id:"104",
name:"道岔",
deviceType:"autoswitch",
type:"fuzhou",
picUrl:"",
url:BASE_ASSET_API+"/MODEL/2020-07-10/17-43789.FBX"
id: "104",
name: "道岔",
deviceType: "autoswitch",
type: "fuzhou",
picUrl: "",
url: BASE_ASSET_API + "/MODEL/2020-07-10/17-43789.FBX"
}
let autoswitch1 = {
id:"102",
name:"道岔1",
deviceType:"autoswitch1",
type:"fuzhou",
picUrl:"",
url:BASE_ASSET_API+"/MODEL/2020-07-10/17-43789.FBX"
id: "102",
name: "道岔1",
deviceType: "autoswitch1",
type: "fuzhou",
picUrl: "",
url: BASE_ASSET_API + "/MODEL/2020-07-10/17-43789.FBX"
}
let autoswitch2 = {
id:"103",
name:"道岔2",
deviceType:"autoswitch2",
type:"fuzhou",
picUrl:"",
url:BASE_ASSET_API+"/MODEL/2020-07-10/17-43789.FBX"
id: "103",
name: "道岔2",
deviceType: "autoswitch2",
type: "fuzhou",
picUrl: "",
url: BASE_ASSET_API + "/MODEL/2020-07-10/17-43789.FBX"
}
let nologonc = {
id:"n1",
name:"高架内侧车站",
deviceType:"nologonc",
type:"nologonc",
picUrl:"",
url:"/MODEL/2021-11-26/531-67215.FBX"
id: "n1",
name: "高架内侧车站",
deviceType: "nologonc",
type: "nologonc",
picUrl: "",
url: "/MODEL/2021-11-26/531-67215.FBX"
}
let nologowc = {
id:"n2",
name:"高架外侧车站",
deviceType:"nologowc",
type:"nologowc",
picUrl:"",
url:"/MODEL/2021-11-26/532-84618.FBX"
id: "n2",
name: "高架外侧车站",
deviceType: "nologowc",
type: "nologowc",
picUrl: "",
url: "/MODEL/2021-11-26/532-84618.FBX"
}
let nologohc = {
id:"n3",
name:"换乘车站",
deviceType:"nologohc",
type:"nologohc",
picUrl:"",
url:"/MODEL/2021-11-26/534-3276.FBX"
id: "n3",
name: "换乘车站",
deviceType: "nologohc",
type: "nologohc",
picUrl: "",
url: "/MODEL/2021-11-26/534-3276.FBX"
}
export function AssetLoader(){
export function AssetLoader() {
let scope = this;
@ -148,8 +159,8 @@ export function AssetLoader(){
this.materiallist = [];
//初始化资源加载器
this.setmodellist = function (data,trainoffset){
if(trainoffset){
this.setmodellist = function(data, trainoffset) {
if (trainoffset) {
scope.trainoffset = trainoffset;
}
let defaultmodel1 = new AssetModel(defaultsignal);
@ -174,12 +185,12 @@ export function AssetLoader(){
scope.modellist.push(defaultswitch2);
let modeldata = JSON.parse(data);
for(let j=0;j<modeldata.length;j++){
for (let j = 0; j < modeldata.length; j++) {
let had = false;
for(let i=0;i<scope.modellist.length;i++){
for (let i = 0; i < scope.modellist.length; i++) {
if(scope.modellist[i].id == modeldata[j].id){
if (scope.modellist[i].id == modeldata[j].id) {
had = true;
@ -188,7 +199,7 @@ export function AssetLoader(){
}
if(had == false){
if (had == false) {
let model = new AssetModel(modeldata[j]);
scope.modellist.push(modeldata[j]);
}
@ -196,12 +207,12 @@ export function AssetLoader(){
}
}
this.setModelListOver = function (data,trainoffset,others,project){
if(trainoffset){
this.setModelListOver = function(data, trainoffset, others, project) {
if (trainoffset) {
scope.trainoffset = trainoffset;
}
if(project == "nologo"){
if (project == "nologo") {
let nologoStationNc = new AssetModel(nologonc);
scope.modellist.push(nologonc);
@ -211,25 +222,33 @@ export function AssetLoader(){
let nologoStationHc = new AssetModel(nologohc);
scope.modellist.push(nologohc);
}
if(others){
if (project == "say") {
let nologoStationNc = new AssetModel(nologonc);
scope.modellist.push(nologonc);
let nologoStationHc = new AssetModel(nologohc);
scope.modellist.push(nologohc);
}
if (others) {
let otherData = others;
for(let j=0;j<otherData.length;j++){
for (let j = 0; j < otherData.length; j++) {
let model = new AssetModel(otherData[j]);
scope.modellist.push(otherData[j]);
}
}
let modeldata = data;
for(let j=0;j<modeldata.length;j++){
for (let j = 0; j < modeldata.length; j++) {
let had = false;
for(let i=0;i<scope.modellist.length;i++){
if(scope.modellist[i].id == modeldata[j].id){
for (let i = 0; i < scope.modellist.length; i++) {
if (scope.modellist[i].id == modeldata[j].id) {
had = true;
i = scope.modellist.length;
}
}
if(had == false){
if(modeldata[j].url != ""){
if (had == false) {
if (modeldata[j].url != "") {
let model = new AssetModel(modeldata[j]);
scope.modellist.push(modeldata[j]);
}
@ -238,19 +257,19 @@ export function AssetLoader(){
}
this.setmodellistnew = function (data,trainoffset){
this.setmodellistnew = function(data, trainoffset) {
if(trainoffset){
if (trainoffset) {
scope.trainoffset = trainoffset;
}
let modeldata = JSON.parse(data);
for(let j=0;j<modeldata.assets.length;j++){
for (let j = 0; j < modeldata.assets.length; j++) {
let had = false;
for(let i=0;i<scope.modellist.length;i++){
for (let i = 0; i < scope.modellist.length; i++) {
if(scope.modellist[i].id == modeldata.assets[j].id){
if (scope.modellist[i].id == modeldata.assets[j].id) {
had = true;
@ -259,7 +278,7 @@ export function AssetLoader(){
}
if(had == false){
if (had == false) {
let model = new AssetModel(modeldata.assets[j]);
scope.modellist.push(modeldata.assets[j]);
@ -273,23 +292,23 @@ export function AssetLoader(){
assetname: "spmxa",
deviceType: "spmxa",
id: "spmxa",
mesh:"",
mesh: "",
packageName: "spmxa",
type: "spmxa",
url: "/MODEL/2021-04-13/1427-29057.FBX",
};
this.assetPromiseOver = function (scene){
this.assetPromiseOver = function(scene) {
let initlist = [];
for(let i=0;i<scope.modellist.length;i++){
for (let i = 0; i < scope.modellist.length; i++) {
// console.log(scope.modellist);
initlist.push(fbxPromiseOver(scope.modellist[i]));
if(scope.modellist[i].packageName == "西安三隧道"){
if (scope.modellist[i].packageName == "西安三隧道") {
scope.modellist.push(specilModelXiAn);
initlist.push(fbxPromiseOver(specilModelXiAn));
}
}
return new Promise(function(resolve, reject){
return new Promise(function(resolve, reject) {
Promise.all(initlist).then((result) => {
@ -303,13 +322,13 @@ export function AssetLoader(){
}
this.assetpromise = function (scene){
this.assetpromise = function(scene) {
let initlist = [];
for(let i=0;i<scope.modellist.length;i++){
for (let i = 0; i < scope.modellist.length; i++) {
initlist.push(fbxpromiseold(scope.modellist[i]));
}
return new Promise(function(resolve, reject){
return new Promise(function(resolve, reject) {
Promise.all(initlist).then((result) => {
@ -322,8 +341,8 @@ export function AssetLoader(){
});
}
this.assetinit = function(scene){
return new Promise(function(resolve, reject){
this.assetinit = function(scene) {
return new Promise(function(resolve, reject) {
let signal = new AssetModel(defaultsignal);
scope.modellist.push(signal);
@ -350,17 +369,17 @@ export function AssetLoader(){
scope.modellist.push(autoswitchs);
fbxpromise(signal)
.then(function(data){
.then(function(data) {
////console.log(data);
// console.log("test");
return fbxpromise(train);
})
.then(function(data){
.then(function(data) {
////console.log(data);
// console.log("test");
return fbxpromise(station);
})
.then(function(data){
.then(function(data) {
////console.log(data);
// console.log("test");
return fbxpromise(wstation);
@ -373,30 +392,32 @@ export function AssetLoader(){
// ////console.log(data);
// return fbxpromise(autosuidao);
// })
.then(function(data){
.then(function(data) {
////console.log(data);
// console.log("defaultswitch1");
return fbxpromise(defaultswitch1);
})
.then(function(data){
.then(function(data) {
// console.log("defaultswitch2");
////console.log(data);
return fbxpromise(defaultswitch2);
})
.then(function(data){
.then(function(data) {
////console.log(data);
// console.log("autoswitchs");
return fbxpromise(autoswitchs);
})
.then(function(data){
.then(function(data) {
////console.log(scope.modellist);
resolve("loaderassets");
});
});
}
this.loadnewsection = function(newdata,jlmap3dedit){
let loadingInstance = Loading.service({ fullscreen: true });
this.loadnewsection = function(newdata, jlmap3dedit) {
let loadingInstance = Loading.service({
fullscreen: true
});
let scene = jlmap3dedit.scene;
let newmodel = new AssetModel(newdata);
let jlmap3ddata = jlmap3dedit.mapdata;
@ -404,29 +425,29 @@ export function AssetLoader(){
scene.remove(jlmap3dedit.exportmodel);
var loader = new THREE.FBXLoader();
loader.load( newdata.assetUrl, function ( object ) {
loader.load(newdata.assetUrl, function(object) {
let newmesh = object;
//let mixer = new THREE.AnimationMixer( newmesh );
////console.log(jlmap3ddata.sectionlist);
for(let i=0;i<newmesh.children.length;i++){
for (let i = 0; i < newmesh.children.length; i++) {
let name = newmesh.children[i].name.split("_");
let newmeshname = name[0]+"_"+name[1]+"_"+name[2]+"."+name[3];
let newmeshname = name[0] + "_" + name[1] + "_" + name[2] + "." + name[3];
if(name[0] == "Switch"){
for(let j=0;j<jlmap3ddata.sectionlist.switchs.datalist.length;j++){
if (name[0] == "Switch") {
for (let j = 0; j < jlmap3ddata.sectionlist.switchs.datalist.length; j++) {
if(jlmap3ddata.sectionlist.switchs.datalist[j].name == newmeshname){
if (jlmap3ddata.sectionlist.switchs.datalist[j].name == newmeshname) {
//绿色道岔
var box = new THREE.BoxHelper( newmesh.children[i], 0x00EE00 );
var box = new THREE.BoxHelper(newmesh.children[i], 0x00EE00);
scene.add(box);
let nowname = jlmap3ddata.sectionlist.switchs.datalist[j].name;
let nowcode = jlmap3ddata.sectionlist.switchs.datalist[j].code;
newmesh.children[i].name = nowname;
newmesh.children[i].code = nowcode;
for(let n=0;n<newmesh.children[i].children.length;n++){
for (let n = 0; n < newmesh.children[i].children.length; n++) {
newmesh.children[i].children[n].code = nowcode;
}
@ -437,21 +458,21 @@ export function AssetLoader(){
}
}
if(name[0] == "Section"){
if (name[0] == "Section") {
//物理区段
for(let j=0;j<jlmap3ddata.sectionlist.sections.datalist.length;j++){
for (let j = 0; j < jlmap3ddata.sectionlist.sections.datalist.length; j++) {
if(jlmap3ddata.sectionlist.sections.datalist[j].name == newmeshname){
if (jlmap3ddata.sectionlist.sections.datalist[j].name == newmeshname) {
if(jlmap3ddata.sectionlist.sections.datalist[j].isStandTrack == true){
if (jlmap3ddata.sectionlist.sections.datalist[j].isStandTrack == true) {
//红色站台区段
var box = new THREE.BoxHelper( newmesh.children[i], 0xff0000 );
}else{
var box = new THREE.BoxHelper(newmesh.children[i], 0xff0000);
} else {
//蓝色其他区段
var box = new THREE.BoxHelper( newmesh.children[i], 0x0000ff );
var box = new THREE.BoxHelper(newmesh.children[i], 0x0000ff);
}
scene.add( box );
scene.add(box);
let nowname = jlmap3ddata.sectionlist.sections.datalist[j].name;
let nowcode = jlmap3ddata.sectionlist.sections.datalist[j].code;
@ -465,10 +486,10 @@ export function AssetLoader(){
}
}
if(name[0] == "Singal"){
if (name[0] == "Singal") {
for(let j=0;j<jlmap3ddata.signallist.list.length;j++){
if(jlmap3ddata.signallist.list[j].mesh.code == newmeshname){
for (let j = 0; j < jlmap3ddata.signallist.list.length; j++) {
if (jlmap3ddata.signallist.list[j].mesh.code == newmeshname) {
jlmap3ddata.signallist.list[j].mesh.position.x = newmesh.children[i].position.x;
jlmap3ddata.signallist.list[j].mesh.position.y = newmesh.children[i].position.y;
jlmap3ddata.signallist.list[j].mesh.position.z = newmesh.children[i].position.z;
@ -478,10 +499,10 @@ export function AssetLoader(){
}
}
if(name[0] == "Station"){
if (name[0] == "Station") {
for(let j=0;j<jlmap3ddata.stationstandlist.list.length;j++){
if(jlmap3ddata.stationstandlist.list[j].mesh.code == newmeshname){
for (let j = 0; j < jlmap3ddata.stationstandlist.list.length; j++) {
if (jlmap3ddata.stationstandlist.list[j].mesh.code == newmeshname) {
jlmap3ddata.stationstandlist.list[j].mesh.position.x = newmesh.children[i].position.x;
jlmap3ddata.stationstandlist.list[j].mesh.position.y = newmesh.children[i].position.y;
jlmap3ddata.stationstandlist.list[j].mesh.position.z = newmesh.children[i].position.z;
@ -496,25 +517,25 @@ export function AssetLoader(){
scene.add(newmesh);
loadingInstance.close();
//console.log("add");
} );
});
}
//新载入资源
this.loadnewasset = function(jlmap3dedit,newdata,num){
this.loadnewasset = function(jlmap3dedit, newdata, num) {
let newmodel = new AssetModel(newdata);
scope.modellist.push(newmodel);
fbxload(newmodel);
var loader = new THREE.FBXLoader();
loader.load( newdata.assetUrl, function ( object ) {
loader.load(newdata.assetUrl, function(object) {
jlmap3dedit.transcontrol.detach();
jlmap3dedit.mapdata.signallist.group.remove(jlmap3dedit.mapdata.signallist.list[num].mesh);
object.name = newdata.uuid;
object.code = jlmap3dedit.mapdata.signallist.list[num].mesh.code;
for(let j=0;j<object.children.length;j++){
for (let j = 0; j < object.children.length; j++) {
object.children[j].code = jlmap3dedit.mapdata.signallist.list[num].mesh.code;
}
@ -534,20 +555,20 @@ export function AssetLoader(){
jlmap3dedit.mapdata.signallist.list[num].mesh = object;
jlmap3dedit.mapdata.signallist.group.add( object );
jlmap3dedit.mapdata.signallist.group.add(object);
jlmap3dedit.transcontrol.attach(jlmap3dedit.selectmodel);
jlmap3dedit.selectmodel = jlmap3dedit.mapdata.signallist.list[num].mesh;
return jlmap3dedit.selectmodel;
} );
});
}
this.loadoldasset = function(jlmap3dedit,newdata,num){
this.loadoldasset = function(jlmap3dedit, newdata, num) {
let assetnum = null;
for(let i=0;i<scope.modellist.length;i++){
for (let i = 0; i < scope.modellist.length; i++) {
if(newdata.uuid == scope.modellist[i].uuid){
if (newdata.uuid == scope.modellist[i].uuid) {
assetnum = i;
}
}
@ -559,7 +580,7 @@ export function AssetLoader(){
newmesh.name = scope.modellist[assetnum].uuid;
newmesh.code = jlmap3dedit.mapdata.signallist.list[num].mesh.code;
for(let j=0;j<newmesh.children.length;j++){
for (let j = 0; j < newmesh.children.length; j++) {
newmesh.children[j].code = jlmap3dedit.mapdata.signallist.list[num].mesh.code;
}
@ -574,54 +595,54 @@ export function AssetLoader(){
jlmap3dedit.mapdata.signallist.list[num].mesh = null;
jlmap3dedit.mapdata.signallist.list[num].mesh = newmesh;
jlmap3dedit.mapdata.signallist.group.add( jlmap3dedit.mapdata.signallist.list[num].mesh );
jlmap3dedit.mapdata.signallist.group.add(jlmap3dedit.mapdata.signallist.list[num].mesh);
jlmap3dedit.transcontrol.attach(jlmap3dedit.mapdata.signallist.list[num].mesh);
jlmap3dedit.selectmodel = jlmap3dedit.mapdata.signallist.list[num].mesh;
return jlmap3dedit.selectmodel;
}
//去除未加载资源并释放内存
this.updatelist = function(){
this.updatelist = function() {
}
//创建新模型
this.createmodel = function(){
this.createmodel = function() {
}
//创建新材质
this.creatematerial = function(){
this.creatematerial = function() {
}
function fbxload(asset){
function fbxload(asset) {
var loader = new THREE.FBXLoader();
loader.load( asset.assetUrl, function ( object ) {
loader.load(asset.assetUrl, function(object) {
//object.scale.set(0.1,0.1,0.1);
asset.mesh = object;
} );
});
}
function fbxpromise(asset){
return new Promise(function(resolve, reject){
function fbxpromise(asset) {
return new Promise(function(resolve, reject) {
var loader = new THREE.FBXLoader();
loader.load( asset.url, function ( object ) {
let mixer = new THREE.AnimationMixer( object );
loader.load(asset.url, function(object) {
let mixer = new THREE.AnimationMixer(object);
//object.traverse(function (node) {//获取其中对象
// node.frustumCulled = true;
//});
if(asset.deviceType == "train" ){
if (asset.deviceType == "train") {
let realtrain = new THREE.Group();
for(let j=6;j>0;j--){
let name = "C"+j;
for(let i=0;i<object.children.length;i++){
if(object.children[i].name == name){
for (let j = 6; j > 0; j--) {
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+scope.trainoffset;
object.children[i].position.x = object.children[i].position.x + scope.trainoffset;
//object.children[i].position.y = j*10;
realtrain.add(object.children[i]);
i--;
@ -631,35 +652,35 @@ export function AssetLoader(){
asset.mesh = realtrain;
asset.animations = object.animations[0].tracks;
}else{
} else {
asset.mesh = object;
}
//object.scale.set(0.1,0.1,0.1);
resolve("fbxload");
} );
});
});
}
function fbxpromiseold(asset){
return new Promise(function(resolve, reject){
function fbxpromiseold(asset) {
return new Promise(function(resolve, reject) {
var loader = new THREE.FBXLoader();
loader.load( asset.assetUrl, function ( object ) {
let mixer = new THREE.AnimationMixer( object );
loader.load(asset.assetUrl, function(object) {
let mixer = new THREE.AnimationMixer(object);
//object.traverse(function (node) {//获取其中对象
// node.frustumCulled = true;
//});
asset.type = asset.deviceType;
if(asset.deviceType == "train"){
if (asset.deviceType == "train") {
let realtrain = new THREE.Group();
for(let j=6;j>0;j--){
let name = "c"+j;
for(let i=0;i<object.children.length;i++){
if(object.children[i].name == name){
for (let j = 6; j > 0; j--) {
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+scope.trainoffset;
object.children[i].position.x = object.children[i].position.x + scope.trainoffset;
//object.children[i].position.y = j*10;
realtrain.add(object.children[i]);
i--;
@ -669,40 +690,40 @@ export function AssetLoader(){
asset.mesh = realtrain;
asset.animations = object.animations[0].tracks;
}else{
} else {
asset.mesh = object;
}
//object.scale.set(0.1,0.1,0.1);
resolve("fbxload");
} );
});
});
}
function fbxPromiseOver(asset){
return new Promise(function(resolve, reject){
function fbxPromiseOver(asset) {
return new Promise(function(resolve, reject) {
var loader = new THREE.FBXLoader();
loader.load( BASE_ASSET_API+asset.url, function ( object ) {
let mixer = new THREE.AnimationMixer( object );
loader.load(BASE_ASSET_API + asset.url, function(object) {
let mixer = new THREE.AnimationMixer(object);
//object.traverse(function (node) {//获取其中对象
// node.frustumCulled = true;
//});
if(asset.code){
if (asset.code) {
scope.modelgroup[asset.code] = object;
}else{
if(asset.type == "train" && object.children.length>4){
} else {
if (asset.type == "train" && object.children.length > 4) {
let realtrain = new THREE.Group();
let j = object.children.length;
for(j;j>0;j--){
let name = "C"+j;
for(let i=0;i<object.children.length;i++){
if(object.children[i].name == name){
for (j; j > 0; j--) {
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+scope.trainoffset;
object.children[i].position.x = object.children[i].position.x + scope.trainoffset;
//object.children[i].position.y = j*10;
realtrain.add(object.children[i]);
i--;
@ -712,12 +733,12 @@ export function AssetLoader(){
asset.mesh = realtrain;
asset.animations = object.animations[0].tracks;
}else if(asset.type == "train" && object.name == "C6"){
} else if (asset.type == "train" && object.name == "C6") {
let realtrain = new THREE.Group();
object.position.x = object.position.x+scope.trainoffset;
object.position.x = object.position.x + scope.trainoffset;
realtrain.add(object);
asset.mesh = realtrain;
}else{
} else {
asset.mesh = object;
}
@ -726,7 +747,7 @@ export function AssetLoader(){
//object.scale.set(0.1,0.1,0.1);
resolve("fbxload");
} );
});
});
}

View File

@ -1,5 +1,9 @@
import {StationStandModel} from '@/jlmap3d/main/newmodel/StationStandModel.js';
import { JL3D_LOCAL_STATIC } from '@/api/jlmap3d/assets3d.js';
import {
StationStandModel
} from '@/jlmap3d/main/newmodel/StationStandModel.js';
import {
JL3D_LOCAL_STATIC
} from '@/api/jlmap3d/assets3d.js';
export function StationStandListN() {
let scope = this;
@ -12,19 +16,19 @@ export function StationStandListN() {
this.group.name = "station";
this.textlist = [];
this.initpromise = function(stationdata,standsdata,psddata,scene,assetloader,mixers,actionss,mode){
return new Promise(function(resolve, reject){
this.initpromise = function(stationdata, standsdata, psddata, scene, assetloader, mixers, actionss, mode) {
return new Promise(function(resolve, reject) {
let stations = stationdata;
let selectmesh1;
for(let j=0;j<assetloader.modellist.length;j++){
if(assetloader.modellist[j].deviceType == "stand"){
for (let j = 0; j < assetloader.modellist.length; j++) {
if (assetloader.modellist[j].deviceType == "stand") {
selectmesh1 = assetloader.modellist[j].mesh;
}
}
for(let i=0;i<standsdata.length;i++){
for (let i = 0; i < standsdata.length; i++) {
let newstationstand = new StationStandModel(standsdata[i]);
newstationstand.code = standsdata[i].code;
@ -52,22 +56,22 @@ export function StationStandListN() {
scope.list[standsdata[i].code] = newstationstand;
let newclip = selectmesh1.animations[ 0 ];
for(let j=0;j<newstationmesh.children.length;j++){
let newclip = selectmesh1.animations[0];
for (let j = 0; j < newstationmesh.children.length; j++) {
if(newstationmesh.children[j].name == "top"){
if (newstationmesh.children[j].name == "top") {
newstationmesh.children[j].animations = [];
newstationmesh.children[j].animations.push(newclip.clone());
let mixer = new THREE.AnimationMixer( newstationmesh.children[j] );
let mixer = new THREE.AnimationMixer(newstationmesh.children[j]);
for(let n=0;n<psddata.length;n++){
if(psddata[n].standCode == newstationstand.direction2.code){
for (let n = 0; n < psddata.length; n++) {
if (psddata[n].standCode == newstationstand.direction2.code) {
let key = psddata[n].code;
actionss[key] = {
status:"01",
action:mixer.clipAction( newstationmesh.children[j].animations[0])
status: "01",
action: mixer.clipAction(newstationmesh.children[j].animations[0])
};
actionss[key].action.setLoop(THREE.LoopOnce);
actionss[key].action.clampWhenFinished = true;
@ -78,18 +82,18 @@ export function StationStandListN() {
}
}
if(newstationmesh.children[j].name == "down"){
if (newstationmesh.children[j].name == "down") {
newstationmesh.children[j].animations = [];
newstationmesh.children[j].animations.push(newclip.clone());
let mixer = new THREE.AnimationMixer( newstationmesh.children[j] );
for(let n=0;n<psddata.length;n++){
if(psddata[n].standCode == newstationstand.direction1.code){
let mixer = new THREE.AnimationMixer(newstationmesh.children[j]);
for (let n = 0; n < psddata.length; n++) {
if (psddata[n].standCode == newstationstand.direction1.code) {
let key = psddata[n].code;
actionss[key] = {
status:"01",
action:mixer.clipAction( newstationmesh.children[j].animations[0])
status: "01",
action: mixer.clipAction(newstationmesh.children[j].animations[0])
};
actionss[key].action.setLoop(THREE.LoopOnce);
actionss[key].action.clampWhenFinished = true;
@ -102,17 +106,21 @@ export function StationStandListN() {
}
if(mode){
if(mode == "02"){
let textgeometry = new THREE.PlaneBufferGeometry( 65, 90, 1 );
if (mode) {
if (mode == "02") {
let textgeometry = new THREE.PlaneBufferGeometry(65, 90, 1);
let textt = new THREE.CanvasTexture(getTextCanvas(stationdata[i]));
let textmaterial = new THREE.MeshBasicMaterial( { side: THREE.DoubleSide,map:textt ,transparent: true} );
let textplane = new THREE.Mesh( textgeometry, textmaterial );
let textmaterial = new THREE.MeshBasicMaterial({
side: THREE.DoubleSide,
map: textt,
transparent: true
});
let textplane = new THREE.Mesh(textgeometry, textmaterial);
textplane.name = stationdata[i].code;
textplane.modeltype = "textplane";
textplane.position.y = 80;
textplane.rotation.x = Math.PI/2;
textplane.rotation.x = Math.PI / 2;
//textplane.position.x = -30;
scope.textlist.push(textplane);
newstationmesh.add(textplane);
@ -134,8 +142,8 @@ export function StationStandListN() {
});
}
this.loadpromise = function(stationdata,standsdata,psddata,scene,assetloader,mixers,actionss,mode,otherStation,project){
return new Promise(function(resolve, reject){
this.loadpromise = function(stationdata, standsdata, psddata, scene, assetloader, mixers, actionss, mode, otherStation, project) {
return new Promise(function(resolve, reject) {
// console.log(standsdata);
let stations = stationdata;
let selectmesh1;
@ -143,54 +151,64 @@ export function StationStandListN() {
let selectmesh3;
let specilmesh;
let nologonc,nologowc,nologohc;
let nologonc, nologowc, nologohc;
for(let j=0;j<assetloader.modellist.length;j++){
for (let j = 0; j < assetloader.modellist.length; j++) {
// console.log(assetloader.modellist[j].type);
if(assetloader.modellist[j].type == "stationInside"){
if (assetloader.modellist[j].type == "stationInside") {
selectmesh1 = assetloader.modellist[j].mesh;
}
if(assetloader.modellist[j].type == "stationOutside"){
if (assetloader.modellist[j].type == "stationOutside") {
selectmesh2 = assetloader.modellist[j].mesh;
// assetloader.modellist[num2].mesh.rotation.y = Math.PI/2;
}
if(assetloader.modellist[j].type == "stationThree"){
if (assetloader.modellist[j].type == "stationThree") {
selectmesh3 = assetloader.modellist[j].mesh;
// assetloader.modellist[num2].mesh.rotation.y = Math.PI/2;
}
if(assetloader.modellist[j].type == "spmxa"){
if (assetloader.modellist[j].type == "spmxa") {
specilmesh = assetloader.modellist[j].mesh;
}
if(project == "nologo"){
if(assetloader.modellist[j].type == "nologonc"){
if (project == "nologo") {
if (assetloader.modellist[j].type == "nologonc") {
nologonc = assetloader.modellist[j].mesh;
// assetloader.modellist[num2].mesh.rotation.y = Math.PI/2;
}
if(assetloader.modellist[j].type == "nologowc"){
if (assetloader.modellist[j].type == "nologowc") {
nologowc = assetloader.modellist[j].mesh;
// assetloader.modellist[num2].mesh.rotation.y = Math.PI/2;
}
if(assetloader.modellist[j].type == "nologohc"){
if (assetloader.modellist[j].type == "nologohc") {
nologohc = assetloader.modellist[j].mesh;
}
}
if (project == "say") {
if (assetloader.modellist[j].type == "nologonc") {
nologonc = assetloader.modellist[j].mesh;
// assetloader.modellist[num2].mesh.rotation.y = Math.PI/2;
}
if (assetloader.modellist[j].type == "nologohc") {
nologohc = assetloader.modellist[j].mesh;
}
}
}
selectmesh1.traverse( function ( child ) {
selectmesh1.traverse(function(child) {
if ( child.isMesh ) {
if (child.isMesh) {
child.renderOrder = 9;
}
} );
selectmesh2.traverse( function ( child ) {
});
selectmesh2.traverse(function(child) {
if ( child.isMesh ) {
if (child.isMesh) {
child.renderOrder = 9;
}
} );
});
// selectmesh3.traverse( function ( child ) {
//
// if ( child.isMesh ) {
@ -200,19 +218,19 @@ export function StationStandListN() {
// } );
//新车门动画获取待定
let allClear = 0;
for(let j=0;j<standsdata.length;j++){
for (let j = 0; j < standsdata.length; j++) {
allClear = 0;
for(let i=0;i<psddata.length;i++){
for (let i = 0; i < psddata.length; i++) {
for(let n=0;n<standsdata[j].stands.length;n++){
if(psddata[i].standCode == standsdata[j].stands[n].code){
for (let n = 0; n < standsdata[j].stands.length; n++) {
if (psddata[i].standCode == standsdata[j].stands[n].code) {
allClear++;
standsdata[j].stands[n].position = psddata[i].position;
}
}
if(allClear == standsdata[j].stands.length){
if (allClear == standsdata[j].stands.length) {
standsdata[j].stands.sort(compare);
i = psddata.length;
}
@ -222,7 +240,7 @@ export function StationStandListN() {
//
// console.log(psddata);
for(let i=0;i<standsdata.length;i++){
for (let i = 0; i < standsdata.length; i++) {
let newstationstand = new StationStandModel(standsdata[i]);
@ -240,66 +258,81 @@ export function StationStandListN() {
// newstationstand.direction2.name = standsdata[i].direction2.name;
// newstationstand.direction2.screenDoorOpenStatus = "01";
let newstationmesh = null;
let newclip =null;
let newclip = null;
let nowModelType = "normal";
if(otherStation){
for(let o=0;o<otherStation.length;o++){
if(standsdata[i].code == otherStation[o].code){
let selectmeshother = assetloader.modelgroup[ otherStation[o].code];
if (otherStation) {
for (let o = 0; o < otherStation.length; o++) {
if (standsdata[i].code == otherStation[o].code) {
let selectmeshother = assetloader.modelgroup[otherStation[o].code];
newstationmesh = selectmeshother;
newclip = selectmeshother.animations[ 0 ];
newclip = selectmeshother.animations[0];
nowModelType = "specil";
newstationmesh.traverse( function ( child ) {
newstationmesh.traverse(function(child) {
if ( child.isMesh ) {
if (child.isMesh) {
child.renderOrder = 9;
}
} );
});
}
}
}
if(nowModelType == "normal"){
if(standsdata[i].stands.length<=2){
if (nowModelType == "normal") {
if (standsdata[i].stands.length <= 2) {
if(standsdata[i].inside == undefined){
if (standsdata[i].inside == undefined) {
newstationmesh = selectmesh1.clone(true);
newclip = selectmesh1.animations[ 0 ];
}else if(standsdata[i].inside == true){
newclip = selectmesh1.animations[0];
} else if (standsdata[i].inside == true) {
newstationmesh = selectmesh1.clone(true);
newclip = selectmesh1.animations[ 0 ];
}else{
newclip = selectmesh1.animations[0];
} else {
newstationmesh = selectmesh2.clone(true);
newclip = selectmesh2.animations[ 0 ];
newclip = selectmesh2.animations[0];
}
}else{
} else {
newstationmesh = selectmesh3.clone(true);
newclip = selectmesh3.animations[ 0 ];
newclip = selectmesh3.animations[0];
}
if(standsdata[i].code == "Station17596"){
if (standsdata[i].code == "Station17596") {
newstationmesh = specilmesh.clone(true);
newclip = specilmesh.animations[ 0 ];
newclip = specilmesh.animations[0];
}
if(project == "nologo"){
if(i == 1){
if (project == "nologo") {
if (i == 1) {
newstationmesh = nologohc.clone(true);
newclip = nologohc.animations[ 0 ];
newclip = nologohc.animations[0];
}
if(i == 2){
if (i == 2) {
newstationmesh = selectmesh2.clone(true);
newclip = selectmesh2.animations[ 0 ];
newclip = selectmesh2.animations[0];
}
if(i == 3){
if (i == 3) {
newstationmesh = nologonc.clone(true);
newclip = nologonc.animations[ 0 ];
newclip = nologonc.animations[0];
}
if(i == 4){
if (i == 4) {
newstationmesh = nologowc.clone(true);
newclip = nologowc.animations[ 0 ];
newclip = nologowc.animations[0];
}
}
console.log(nologohc);
if (project == "say") {
if (i == 1) {
newstationmesh = nologohc.clone(true);
newclip = nologohc.animations[0];
}
if (i == 3) {
newstationmesh = nologonc.clone(true);
newclip = nologonc.animations[0];
}
if (i == 4) {
newstationmesh = nologonc.clone(true);
newclip = nologonc.animations[0];
}
}
}
@ -321,25 +354,25 @@ export function StationStandListN() {
//
scope.list[standsdata[i].code] = newstationstand;
//
for(let j=0;j<standsdata[i].stands.length;j++){
let num = j+1;
for (let j = 0; j < standsdata[i].stands.length; j++) {
let num = j + 1;
let addAnimaMesh = newstationmesh.getObjectByName('door'+num);
let addAnimaMesh = newstationmesh.getObjectByName('door' + num);
if(addAnimaMesh){
newstationmesh.getObjectByName('door'+num).animations = [];
if(newclip){
newstationmesh.getObjectByName('door'+num).animations.push(newclip.clone());
let mixer = new THREE.AnimationMixer( newstationmesh.getObjectByName('door'+num) );
if (addAnimaMesh) {
newstationmesh.getObjectByName('door' + num).animations = [];
if (newclip) {
newstationmesh.getObjectByName('door' + num).animations.push(newclip.clone());
let mixer = new THREE.AnimationMixer(newstationmesh.getObjectByName('door' + num));
for(let n=0;n<psddata.length;n++){
for (let n = 0; n < psddata.length; n++) {
if(psddata[n].standCode == standsdata[i].stands[j].code){
if (psddata[n].standCode == standsdata[i].stands[j].code) {
let key = psddata[n].code;
actionss[key] = {
status:"01",
action:mixer.clipAction( newstationmesh.getObjectByName('door'+num).animations[0])
status: "01",
action: mixer.clipAction(newstationmesh.getObjectByName('door' + num).animations[0])
};
actionss[key].action.setLoop(THREE.LoopOnce);
actionss[key].action.clampWhenFinished = true;
@ -356,17 +389,21 @@ export function StationStandListN() {
}
if(mode){
if(mode == "02"){
let textgeometry = new THREE.PlaneBufferGeometry( 65, 90, 1 );
if (mode) {
if (mode == "02") {
let textgeometry = new THREE.PlaneBufferGeometry(65, 90, 1);
let textt = new THREE.CanvasTexture(getTextCanvas(standsdata[i]));
let textmaterial = new THREE.MeshBasicMaterial( { side: THREE.DoubleSide,map:textt ,transparent: true} );
let textplane = new THREE.Mesh( textgeometry, textmaterial );
let textmaterial = new THREE.MeshBasicMaterial({
side: THREE.DoubleSide,
map: textt,
transparent: true
});
let textplane = new THREE.Mesh(textgeometry, textmaterial);
textplane.name = standsdata[i].code;
textplane.modeltype = "textplane";
textplane.position.y = 70;
textplane.rotation.x = Math.PI/2;
textplane.rotation.x = Math.PI / 2;
textplane.position.z = 80;
scope.textlist.push(textplane);
newstationmesh.add(textplane);
@ -386,7 +423,7 @@ export function StationStandListN() {
}
}
var compare = function (obj1, obj2) {
var compare = function(obj1, obj2) {
var val1 = obj1.position.y;
var val2 = obj2.position.y;
if (val1 < val2) {
@ -400,8 +437,9 @@ var compare = function (obj1, obj2) {
//canvas文字贴图方法
//PS:待提炼 增强功能
var stationcanvas = new Image();
stationcanvas.src = JL3D_LOCAL_STATIC+"/texture/msgtnew.png";
function getTextCanvas(text){
stationcanvas.src = JL3D_LOCAL_STATIC + "/texture/msgtnew.png";
function getTextCanvas(text) {
let canvas = document.getElementById('canvastexture');
canvas.width = 128;
@ -411,27 +449,27 @@ function getTextCanvas(text){
let ctx = canvas.getContext('2d');
//ctx.fillStyle = '#FFFFFF';
ctx.fillRect(0, 0,128,256);
ctx.fillRect(0, 0, 128, 256);
ctx.fillStyle = '#FFFFFF';
// ctx.textAlign = 'center';
// ctx.textBaseline = 'middle';
ctx.clearRect(0,0,128,256);
ctx.clearRect(0, 0, 128, 256);
ctx.drawImage(stationcanvas,0,0,128,256);
ctx.drawImage(stationcanvas, 0, 0, 128, 256);
ctx.font = "10px";
ctx.fillText("车站: "+text.name, 15,25);
ctx.fillText("车站: " + text.name, 15, 25);
ctx.fillText("漫游", 18,48);
ctx.fillText("信息", 54,48);
ctx.fillText("备忘", 93,48);
ctx.fillText("漫游", 18, 48);
ctx.fillText("信息", 54, 48);
ctx.fillText("备忘", 93, 48);
ctx.fillText("车站序号: "+text.name, 10,115);
ctx.fillText("车站序号: " + text.name, 10, 115);
ctx.fillText("公里标记:",10 ,135);
ctx.fillText(text.kmPost,10 ,155);
ctx.fillText("公里标记:", 10, 135);
ctx.fillText(text.kmPost, 10, 155);
let data = ctx.getImageData(0, 0,128,256);
let data = ctx.getImageData(0, 0, 128, 256);
return data;
}