From fc3ebff6c9eea3da13d7580e9517f8e380c26944 Mon Sep 17 00:00:00 2001 From: aixianling Date: Tue, 2 Jul 2024 18:50:20 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=96=B0=E9=BC=93=E6=8D=A3=E5=9C=B0?= =?UTF-8?q?=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/bgf.png | Bin 2262 -> 0 bytes src/views/AppThreeMap.vue | 27 +++++++++++++++++---------- 2 files changed, 17 insertions(+), 10 deletions(-) delete mode 100644 public/bgf.png diff --git a/public/bgf.png b/public/bgf.png deleted file mode 100644 index fd2ba5f3d941e6af62b3fdd9eedab8b04ff1e8c5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2262 zcmeAS@N?(olHy`uVBq!ia0y~yU;;9k7&zE~)R&4YzZe)e=6bp~hE&XXd()8bkbwZh zL6)bUKmT+8nEXs-=Ym$35&Ple<-QVR?Khbj8r~~2FeqeH zTdtpehl!!W?6s}kzi-wUw1XJbnA8rA*R~S59{an^LB{Ts5 D5i|z_ diff --git a/src/views/AppThreeMap.vue b/src/views/AppThreeMap.vue index 1d80c22..7c3c46c 100644 --- a/src/views/AppThreeMap.vue +++ b/src/views/AppThreeMap.vue @@ -251,7 +251,7 @@ export default { * @desc 创建相机 * */ setCamera() { - this.camera = new THREE.PerspectiveCamera(10, window.innerWidth / window.innerHeight, 1, 2000); + this.camera = new THREE.PerspectiveCamera(10, rootEl.innerWidth / rootEl.innerHeight, 1, 2000); this.camera.up.x = 0; this.camera.up.y = 0; this.camera.up.z = 1; @@ -267,16 +267,16 @@ export default { this.renderer.setPixelRatio(window.devicePixelRatio * 1); this.renderer.sortObjects = true; // 渲染顺序 this.renderer.setClearColor('#212121'); - this.renderer.setSize(window.innerWidth, window.innerHeight); + this.renderer.setSize(rootEl.innerWidth, rootEl.innerHeight); rootEl.appendChild(this.renderer.domElement); function onWindowResize() { - this.camera.aspect = window.innerWidth / window.innerHeight; + this.camera.aspect = rootEl.innerWidth / rootEl.innerHeight; this.camera.updateProjectionMatrix(); - this.renderer.setSize(window.innerWidth, window.innerHeight); + this.renderer.setSize(rootEl.innerWidth, rootEl.innerHeight); } - window.addEventListener('resize', onWindowResize.bind(this), false); + rootEl.addEventListener('resize', onWindowResize.bind(this), false); } /** @@ -304,8 +304,8 @@ export default { let that = this; function onMouseMove(event) { - const x = (event.clientX / window.innerWidth) * 2 - 1; //标准设备横坐标 - const y = -(event.clientY / window.innerHeight) * 2 + 1; //标准设备纵坐标 + const x = (event.clientX / rootEl.innerWidth) * 2 - 1; //标准设备横坐标 + const y = -(event.clientY / rootEl.innerHeight) * 2 + 1; //标准设备纵坐标 const standardVector = new THREE.Vector3(x, y, 0.5); //标准设备坐标 //标准设备坐标转世界坐标 const worldVector = standardVector.unproject(that.camera); @@ -354,7 +354,7 @@ export default { * @desc 创建地面函数 * */ makeGround() { - const maps = new THREE.TextureLoader().load('/bgf.png'); + const maps = new THREE.TextureLoader().load('http://10.0.97.209/presource/datascreen/img/bgf.png'); maps.wrapS = maps.wrapT = THREE.RepeatWrapping; maps.repeat.set(14, 14); // 纹理 y,x方向重铺 maps.needsUpdate = false; // 纹理更新 @@ -476,9 +476,16 @@ export default { }) } }, + watch: { + search: { + immediate: true, deep: true, handler() { + const {$waitFor} = window + this.getData().then(() => $waitFor(this.geoMap)).then(() => this.geoMap.addMarkers()) + } + } + }, mounted() { - Promise.all([this.getData(), - this.loadLib()]).then(() => { + this.loadLib().then(() => { this.geoMap = this.initMap(); this.geoMap.init(); })