From e96c5023821c43c26993086de3a12eaf65a9d6d1 Mon Sep 17 00:00:00 2001 From: ZhangXianQiang <1135831638@qq.com> Date: 星期四, 18 四月 2024 18:05:11 +0800 Subject: [PATCH] Merge branch 'dev-threejs' --- src/views/screen/components/screen-map-three/experience/utils/sizes.js | 44 +++++++++++++++++++++++--------------------- 1 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/views/screen/components/screen-map-three/experience/utils/sizes.js b/src/views/screen/components/screen-map-three/experience/utils/sizes.js index af7c98d..2c3aa9b 100644 --- a/src/views/screen/components/screen-map-three/experience/utils/sizes.js +++ b/src/views/screen/components/screen-map-three/experience/utils/sizes.js @@ -3,31 +3,33 @@ */ import EventEmitter from './eventEmitter'; export default class Sizes extends EventEmitter { - constructor() { + constructor(canvas) { super(); - this.width = document.body.clientWidth; - this.height = document.body.clientHeight; - this.device = document.body.clientWidth <= 968 ? 'mobile' : 'pc'; - // 璁惧鍍忕礌 + this.container = document.querySelector('.map-container'); this.pixelRatio = Math.min(window.devicePixelRatio, 2); + this.width = this.container.offsetWidth; + this.height = this.container.offsetHeight; + this.device = document.body.clientWidth <= 968 ? 'mobile' : 'pc'; + // this.resizeObserver = new ResizeObserver(entries => { + // let rect = canvas.getBoundingClientRect(); + // this.scaleX = rect.width / this.width; + // this.scaleY = rect.height / this.height; + // console.log(this.scaleX, this.scaleY); + // }) + // this.resizeObserver.observe(this.container); // 瀹介珮鍙樺寲 - window.addEventListener('resize', () => { - // this.width = window.innerWidth; - // this.height = window.innerHeight; + // window.addEventListener('resize', () => { + // this.pixelRatio = Math.min(window.devicePixelRatio, 2); + // this.trigger('resize'); - this.width = document.body.clientWidth; - this.height = document.body.clientHeight; - this.pixelRatio = Math.min(window.devicePixelRatio, 2); - this.trigger('resize'); - - if(this.width < 968 && this.device !== 'mobile') { - this.device = 'mobile'; - this.trigger('devicechange'); - } else if(this.width >= 968 && this.device !== 'pc') { - this.device = 'pc'; - this.trigger('devicechange'); - } - }); + // if (this.width < 968 && this.device !== 'mobile') { + // this.device = 'mobile'; + // this.trigger('devicechange'); + // } else if (this.width >= 968 && this.device !== 'pc') { + // this.device = 'pc'; + // this.trigger('devicechange'); + // } + // }); } } \ No newline at end of file -- Gitblit v1.8.0