From 99305b1f482debef5b20b3b4938eb4932ae883de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Csunzy=E2=80=9D?= <“sunzhenyu@joylink.club”> Date: Mon, 20 Dec 2021 10:39:24 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BE=90=E5=B7=9E?= =?UTF-8?q?=E4=B8=89=E4=BD=8D=E6=B2=99=E7=9B=98=E6=A8=A1=E5=9E=8B=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/jlmap3d/main/loaders/AssetLoader.js | 1288 +++++++++-------- .../main/newmodel/StationStandListN.js | 746 +++++----- 2 files changed, 1042 insertions(+), 992 deletions(-) diff --git a/src/jlmap3d/main/loaders/AssetLoader.js b/src/jlmap3d/main/loaders/AssetLoader.js index 8b6364634..a4a2fdca2 100644 --- a/src/jlmap3d/main/loaders/AssetLoader.js +++ b/src/jlmap3d/main/loaders/AssetLoader.js @@ -1,734 +1,756 @@ -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; + let scope = this; - this.name = null; + this.name = null; - this.trainoffset = 0; + this.trainoffset = 0; + + this.modellist = []; + this.modelgroup = []; - this.modellist = []; - this.modelgroup = []; + this.materiallist = []; + //初始化资源加载器 + this.setmodellist = function(data, trainoffset) { + if (trainoffset) { + scope.trainoffset = trainoffset; + } + let defaultmodel1 = new AssetModel(defaultsignal); + scope.modellist.push(defaultmodel1); - this.materiallist = []; - //初始化资源加载器 - this.setmodellist = function (data,trainoffset){ - if(trainoffset){ - scope.trainoffset = trainoffset; - } - let defaultmodel1 = new AssetModel(defaultsignal); - scope.modellist.push(defaultmodel1); + let defaultmodel2 = new AssetModel(defaulttrain); + scope.modellist.push(defaultmodel2); - let defaultmodel2 = new AssetModel(defaulttrain); - scope.modellist.push(defaultmodel2); + let station = new AssetModel(defaultstation); + scope.modellist.push(station); - let station = new AssetModel(defaultstation); - scope.modellist.push(station); + let suidao = new AssetModel(defaultsuidao); + scope.modellist.push(suidao); - let suidao = new AssetModel(defaultsuidao); - scope.modellist.push(suidao); + let background = new AssetModel(defaultbackground); + scope.modellist.push(defaultbackground); - let background = new AssetModel(defaultbackground); - scope.modellist.push(defaultbackground); + let defaultswitch1 = new AssetModel(autoswitch1); + scope.modellist.push(defaultswitch1); - let defaultswitch1 = new AssetModel(autoswitch1); - scope.modellist.push(defaultswitch1); + let defaultswitch2 = new AssetModel(autoswitch2); + scope.modellist.push(defaultswitch2); - let defaultswitch2 = new AssetModel(autoswitch2); - scope.modellist.push(defaultswitch2); + let modeldata = JSON.parse(data); + for (let j = 0; j < modeldata.length; j++) { + let had = false; + for (let i = 0; i < scope.modellist.length; i++) { - let modeldata = JSON.parse(data); - for(let j=0;j { - - resolve("loaderassets"); //['成功了', 'success'] - }).catch((error) => { - //console.log(error); - }); - - }); - } - - - this.assetpromise = function (scene){ - let initlist = []; - for(let i=0;i { - - resolve("loaderassets"); //['成功了', 'success'] - }).catch((error) => { - //console.log(error); - }); - - }); - } - - this.assetinit = function(scene){ - return new Promise(function(resolve, reject){ - let signal = new AssetModel(defaultsignal); - scope.modellist.push(signal); - - let train = new AssetModel(defaulttrain); - scope.modellist.push(train); - - let station = new AssetModel(defaultstation); - scope.modellist.push(station); - - let wstation = new AssetModel(waicestation); - scope.modellist.push(wstation); - - let autorail = new AssetModel(defaultautorail); - scope.modellist.push(autorail); - - let defaultswitch1 = new AssetModel(autoswitch1); - scope.modellist.push(defaultswitch1); - - let defaultswitch2 = new AssetModel(autoswitch2); - scope.modellist.push(defaultswitch2); - - - let autoswitchs = new AssetModel(autoswitch); - scope.modellist.push(autoswitchs); - - fbxpromise(signal) - .then(function(data){ - ////console.log(data); - // console.log("test"); - return fbxpromise(train); - }) - .then(function(data){ - ////console.log(data); - // console.log("test"); - return fbxpromise(station); - }) - .then(function(data){ - ////console.log(data); - // console.log("test"); - return fbxpromise(wstation); - }) - // .then(function(data){ - // ////console.log(data); - // return fbxpromise(autorail); - // }) - // .then(function(data){ - // ////console.log(data); - // return fbxpromise(autosuidao); - // }) - .then(function(data){ - ////console.log(data); - // console.log("defaultswitch1"); - return fbxpromise(defaultswitch1); - }) - .then(function(data){ - // console.log("defaultswitch2"); - ////console.log(data); - return fbxpromise(defaultswitch2); - }) - .then(function(data){ - ////console.log(data); - // console.log("autoswitchs"); - return fbxpromise(autoswitchs); - }) - .then(function(data){ - ////console.log(scope.modellist); - resolve("loaderassets"); - }); - }); - } - - this.loadnewsection = function(newdata,jlmap3dedit){ - let loadingInstance = Loading.service({ fullscreen: true }); - let scene = jlmap3dedit.scene; - let newmodel = new AssetModel(newdata); - let jlmap3ddata = jlmap3dedit.mapdata; - scope.modellist.push(newmodel); - - scene.remove(jlmap3dedit.exportmodel); - var loader = new THREE.FBXLoader(); - loader.load( newdata.assetUrl, function ( object ) { - - let newmesh = object; - - //let mixer = new THREE.AnimationMixer( newmesh ); - ////console.log(jlmap3ddata.sectionlist); - for(let i=0;i { + + resolve("loaderassets"); //['成功了', 'success'] + }).catch((error) => { + //console.log(error); + }); + + }); + } + + + this.assetpromise = function(scene) { + let initlist = []; + for (let i = 0; i < scope.modellist.length; i++) { + initlist.push(fbxpromiseold(scope.modellist[i])); + + } + return new Promise(function(resolve, reject) { + + + Promise.all(initlist).then((result) => { + + resolve("loaderassets"); //['成功了', 'success'] + }).catch((error) => { + //console.log(error); + }); + + }); + } + + this.assetinit = function(scene) { + return new Promise(function(resolve, reject) { + let signal = new AssetModel(defaultsignal); + scope.modellist.push(signal); + + let train = new AssetModel(defaulttrain); + scope.modellist.push(train); + + let station = new AssetModel(defaultstation); + scope.modellist.push(station); + + let wstation = new AssetModel(waicestation); + scope.modellist.push(wstation); + + let autorail = new AssetModel(defaultautorail); + scope.modellist.push(autorail); + + let defaultswitch1 = new AssetModel(autoswitch1); + scope.modellist.push(defaultswitch1); + + let defaultswitch2 = new AssetModel(autoswitch2); + scope.modellist.push(defaultswitch2); + + + let autoswitchs = new AssetModel(autoswitch); + scope.modellist.push(autoswitchs); + + fbxpromise(signal) + .then(function(data) { + ////console.log(data); + // console.log("test"); + return fbxpromise(train); + }) + .then(function(data) { + ////console.log(data); + // console.log("test"); + return fbxpromise(station); + }) + .then(function(data) { + ////console.log(data); + // console.log("test"); + return fbxpromise(wstation); + }) + // .then(function(data){ + // ////console.log(data); + // return fbxpromise(autorail); + // }) + // .then(function(data){ + // ////console.log(data); + // return fbxpromise(autosuidao); + // }) + .then(function(data) { + ////console.log(data); + // console.log("defaultswitch1"); + return fbxpromise(defaultswitch1); + }) + .then(function(data) { + // console.log("defaultswitch2"); + ////console.log(data); + return fbxpromise(defaultswitch2); + }) + .then(function(data) { + ////console.log(data); + // console.log("autoswitchs"); + return fbxpromise(autoswitchs); + }) + .then(function(data) { + ////console.log(scope.modellist); + resolve("loaderassets"); + }); + }); + } + + this.loadnewsection = function(newdata, jlmap3dedit) { + let loadingInstance = Loading.service({ + fullscreen: true + }); + let scene = jlmap3dedit.scene; + let newmodel = new AssetModel(newdata); + let jlmap3ddata = jlmap3dedit.mapdata; + scope.modellist.push(newmodel); + + scene.remove(jlmap3dedit.exportmodel); + var loader = new THREE.FBXLoader(); + 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++) { + + let name = newmesh.children[i].name.split("_"); + 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 (jlmap3ddata.sectionlist.switchs.datalist[j].name == newmeshname) { + //绿色道岔 + 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++) { + newmesh.children[i].children[n].code = nowcode; + } + + jlmap3ddata.sectionlist.switchs.modellist[j] = newmesh.children[i]; + j = jlmap3ddata.sectionlist.switchs.datalist.length; + + } + } + } + + if (name[0] == "Section") { + + //物理区段 + 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].isStandTrack == true) { + //红色站台区段 + var box = new THREE.BoxHelper(newmesh.children[i], 0xff0000); + } else { + //蓝色其他区段 + var box = new THREE.BoxHelper(newmesh.children[i], 0x0000ff); + } + scene.add(box); + + let nowname = jlmap3ddata.sectionlist.sections.datalist[j].name; + let nowcode = jlmap3ddata.sectionlist.sections.datalist[j].code; + newmesh.children[i].name = nowname; + newmesh.children[i].code = nowcode; + jlmap3ddata.sectionlist.sections.modellist[j] = newmesh.children[i]; + j = jlmap3ddata.sectionlist.sections.datalist.length; + + } + + } + } + + if (name[0] == "Singal") { + + 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; + + j = jlmap3ddata.signallist.list.length; + } + } + } + + if (name[0] == "Station") { + + 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; + + j = jlmap3ddata.stationstandlist.list.length; + } + } + } + + } + + scene.add(newmesh); + loadingInstance.close(); + //console.log("add"); + }); - let newmodel = new AssetModel(newdata); - scope.modellist.push(newmodel); - fbxload(newmodel); + } + //新载入资源 + this.loadnewasset = function(jlmap3dedit, newdata, num) { - var loader = new THREE.FBXLoader(); - loader.load( newdata.assetUrl, function ( object ) { + let newmodel = new AssetModel(newdata); + scope.modellist.push(newmodel); + fbxload(newmodel); - jlmap3dedit.transcontrol.detach(); - jlmap3dedit.mapdata.signallist.group.remove(jlmap3dedit.mapdata.signallist.list[num].mesh); + var loader = new THREE.FBXLoader(); + loader.load(newdata.assetUrl, function(object) { - object.name = newdata.uuid; - object.code = jlmap3dedit.mapdata.signallist.list[num].mesh.code; - for(let j=0;j0;j--){ - let name = "C"+j; - for(let i=0;i0;j--){ - let name = "c"+j; - for(let i=0;i4){ - - let realtrain = new THREE.Group(); - let j = object.children.length; - for(j;j>0;j--){ - let name = "C"+j; - for(let i=0;i 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.y = j*10; + realtrain.add(object.children[i]); + i--; + } + } + } + asset.mesh = realtrain; + asset.animations = object.animations[0].tracks; + + } else { + asset.mesh = object; + + } + //object.scale.set(0.1,0.1,0.1); + + resolve("fbxload"); + }); + + }); + } + + 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); + //object.traverse(function (node) {//获取其中对象 + // node.frustumCulled = true; + //}); + asset.type = asset.deviceType; + 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) { + + 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--; + } + } + } + asset.mesh = realtrain; + asset.animations = object.animations[0].tracks; + + } else { + asset.mesh = object; + + } + //object.scale.set(0.1,0.1,0.1); + + resolve("fbxload"); + }); + + }); + } + + 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); + //object.traverse(function (node) {//获取其中对象 + // node.frustumCulled = true; + //}); + + if (asset.code) { + scope.modelgroup[asset.code] = object; + } 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) { + + 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--; + } + } + } + asset.mesh = realtrain; + asset.animations = object.animations[0].tracks; + + } else if (asset.type == "train" && object.name == "C6") { + let realtrain = new THREE.Group(); + object.position.x = object.position.x + scope.trainoffset; + realtrain.add(object); + asset.mesh = realtrain; + } else { + asset.mesh = object; + + } + } + + //object.scale.set(0.1,0.1,0.1); + + resolve("fbxload"); + }); + + }); + } } diff --git a/src/jlmap3d/main/newmodel/StationStandListN.js b/src/jlmap3d/main/newmodel/StationStandListN.js index e31169675..0b67b7546 100644 --- a/src/jlmap3d/main/newmodel/StationStandListN.js +++ b/src/jlmap3d/main/newmodel/StationStandListN.js @@ -1,437 +1,465 @@ -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; + let scope = this; - this.type = "stationstandlist"; + this.type = "stationstandlist"; - this.list = []; + this.list = []; - this.group = new THREE.Group(); - this.group.name = "station"; - this.textlist = []; + this.group = new THREE.Group(); + 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; + let stations = stationdata; + let selectmesh1; - for(let j=0;j val2) { - return 1; - } else { - return 0; - } +var compare = function(obj1, obj2) { + var val1 = obj1.position.y; + var val2 = obj2.position.y; + if (val1 < val2) { + return -1; + } else if (val1 > val2) { + return 1; + } else { + return 0; + } } //canvas文字贴图方法 //PS:待提炼 增强功能 var stationcanvas = new Image(); -stationcanvas.src = JL3D_LOCAL_STATIC+"/texture/msgtnew.png"; -function getTextCanvas(text){ - let canvas = document.getElementById('canvastexture'); +stationcanvas.src = JL3D_LOCAL_STATIC + "/texture/msgtnew.png"; - canvas.width = 128; - canvas.height = 256; - // canvas.style.width = width; - // canvas.style.height = height; +function getTextCanvas(text) { + let canvas = document.getElementById('canvastexture'); - let ctx = canvas.getContext('2d'); - //ctx.fillStyle = '#FFFFFF'; - ctx.fillRect(0, 0,128,256); + canvas.width = 128; + canvas.height = 256; + // canvas.style.width = width; + // canvas.style.height = height; - ctx.fillStyle = '#FFFFFF'; - // ctx.textAlign = 'center'; - // ctx.textBaseline = 'middle'; - ctx.clearRect(0,0,128,256); + let ctx = canvas.getContext('2d'); + //ctx.fillStyle = '#FFFFFF'; + ctx.fillRect(0, 0, 128, 256); - ctx.drawImage(stationcanvas,0,0,128,256); + ctx.fillStyle = '#FFFFFF'; + // ctx.textAlign = 'center'; + // ctx.textBaseline = 'middle'; + ctx.clearRect(0, 0, 128, 256); - ctx.font = "10px"; - ctx.fillText("车站: "+text.name, 15,25); + ctx.drawImage(stationcanvas, 0, 0, 128, 256); - ctx.fillText("漫游", 18,48); - ctx.fillText("信息", 54,48); - ctx.fillText("备忘", 93,48); + ctx.font = "10px"; + ctx.fillText("车站: " + text.name, 15, 25); - ctx.fillText("车站序号: "+text.name, 10,115); + ctx.fillText("漫游", 18, 48); + ctx.fillText("信息", 54, 48); + ctx.fillText("备忘", 93, 48); - ctx.fillText("公里标记:",10 ,135); - ctx.fillText(text.kmPost,10 ,155); + ctx.fillText("车站序号: " + text.name, 10, 115); - let data = ctx.getImageData(0, 0,128,256); - return data; + ctx.fillText("公里标记:", 10, 135); + ctx.fillText(text.kmPost, 10, 155); + + let data = ctx.getImageData(0, 0, 128, 256); + return data; } From 8b0f62ca3938d6fbfcc365a40528d5557c8ea3da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Csunzy=E2=80=9D?= <“sunzhenyu@joylink.club”> Date: Mon, 20 Dec 2021 10:46:20 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BE=90=E5=B7=9E?= =?UTF-8?q?=E4=B8=89=E4=BD=8D=E6=B2=99=E7=9B=98=E6=A8=A1=E5=9E=8B=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/jlmap3d/jl3dsimulation/jlmap3d.js | 19 ++++++++----------- src/jlmap3d/main/loaders/AssetLoader.js | 1 - .../main/newmodel/StationStandListN.js | 10 ++++++++++ 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/jlmap3d/jl3dsimulation/jlmap3d.js b/src/jlmap3d/jl3dsimulation/jlmap3d.js index 290bdc528..95698f847 100644 --- a/src/jlmap3d/jl3dsimulation/jlmap3d.js +++ b/src/jlmap3d/jl3dsimulation/jlmap3d.js @@ -297,17 +297,15 @@ export function JLmap3d(dom, data,skinCode,storemod,routegroup,project) { //三维交互点击事件函数 function onselect(event) { - if(event.button == "0"){ - if(controlManager.controlMode != 'fps'){ - //定义光线 - let raycaster = new THREE.Raycaster(); - //定义平面鼠标点击坐标 - let mouse = new THREE.Vector2(); - mouse.x = (event.clientX / window.innerWidth) * 2 - 1; - mouse.y = -(event.clientY / window.innerHeight) * 2 + 1; - - raycaster.setFromCamera( mouse, controlManager.orbitCamera ); + if(controlManager.controlMode != 'fps' && event.button == "0" && stationstandlist){ + //定义光线 + let raycaster = new THREE.Raycaster(); + //定义平面鼠标点击坐标 + let mouse = new THREE.Vector2(); + mouse.x = (event.clientX / window.innerWidth) * 2 - 1; + mouse.y = -(event.clientY / window.innerHeight) * 2 + 1; + raycaster.setFromCamera( mouse, controlManager.orbitCamera ); //从站台对象组获取点击目标 let intersects1 = raycaster.intersectObjects( stationstandlist.group.children,true); @@ -319,7 +317,6 @@ export function JLmap3d(dom, data,skinCode,storemod,routegroup,project) { controlManager.attachFpsCamera(intersects1[0].object.parent,intersects1[0].point); } } - } } } diff --git a/src/jlmap3d/main/loaders/AssetLoader.js b/src/jlmap3d/main/loaders/AssetLoader.js index a4a2fdca2..c9f0daef6 100644 --- a/src/jlmap3d/main/loaders/AssetLoader.js +++ b/src/jlmap3d/main/loaders/AssetLoader.js @@ -226,7 +226,6 @@ export function AssetLoader() { if (project == "say") { let nologoStationNc = new AssetModel(nologonc); scope.modellist.push(nologonc); - console.log(nologohc); let nologoStationHc = new AssetModel(nologohc); scope.modellist.push(nologohc); } diff --git a/src/jlmap3d/main/newmodel/StationStandListN.js b/src/jlmap3d/main/newmodel/StationStandListN.js index 0b67b7546..ac87debcc 100644 --- a/src/jlmap3d/main/newmodel/StationStandListN.js +++ b/src/jlmap3d/main/newmodel/StationStandListN.js @@ -184,6 +184,16 @@ export function StationStandListN() { } } + 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) {