|
@@ -10,6 +10,7 @@ export class ViewerBase extends THREE.EventDispatcher{
|
|
|
this.name = args.name
|
|
|
this.renderArea = domElement
|
|
|
this.oldResolution = new THREE.Vector2()
|
|
|
+ this.oldResolution2 = new THREE.Vector2()
|
|
|
|
|
|
this.screenSizeInfo = {
|
|
|
W:0, H:0, pixelRatio:1 , windowWidth:0, windowHeight:0
|
|
@@ -124,14 +125,15 @@ export class ViewerBase extends THREE.EventDispatcher{
|
|
|
|
|
|
w = this.renderArea.clientWidth;
|
|
|
h = this.renderArea.clientHeight
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
if(w !== this.screenSizeInfo.W || h !== this.screenSizeInfo.H || o.forceUpdateSize || this.screenSizeInfo.pixelRatio != window.devicePixelRatio){
|
|
|
this.screenSizeInfo.W = w
|
|
|
this.screenSizeInfo.H = h
|
|
|
render = true
|
|
|
this.screenSizeInfo.pixelRatio = window.devicePixelRatio //如果player放在小窗口了,也要监测devicePixelRatio,因为缩放时client宽高不会改变
|
|
|
//config.isMobile ? (ratio = Math.min(window.devicePixelRatio, 2)) : (ratio = window.devicePixelRatio)
|
|
|
- ratio = window.devicePixelRatio
|
|
|
+ ratio = window.devicePixelRatio
|
|
|
}
|
|
|
}
|
|
|
if (render) {
|
|
@@ -190,18 +192,17 @@ export class ViewerBase extends THREE.EventDispatcher{
|
|
|
|
|
|
|
|
|
if(!onlyForTarget){//因为onlyForTarget不传递devicePixelRatio所以不发送了
|
|
|
- this.emitResizeMsg({viewport:this.viewports[0], deviceRatio:devicePixelRatio})
|
|
|
- }
|
|
|
+ this.ifEmitResize({viewport:this.viewports[0], deviceRatio:devicePixelRatio})
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
|
- emitResizeMsg(e){//切换viewport渲染时就发送一次, 通知一些材质更新resolution。
|
|
|
- if(!e.viewport.resolution.equals(this.oldResolution)){
|
|
|
+ ifEmitResize(e){//切换viewport渲染时, 若这些viewport大小不同就发送一次, 通知一些材质更新resolution。
|
|
|
+ if(!e.viewport.resolution.equals(this.oldResolution)||!e.viewport.resolution2.equals(this.oldResolution2)){
|
|
|
this.dispatchEvent($.extend(e, {type:'resize'}))
|
|
|
this.oldResolution.copy(e.viewport.resolution)
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
+ this.oldResolution2.copy(e.viewport.resolution2)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
@@ -229,9 +230,9 @@ export class ViewerBase extends THREE.EventDispatcher{
|
|
|
//this.changeTime = (this.changeTime || 0) +1
|
|
|
//}
|
|
|
viewport.needRender = true //直接写这咯
|
|
|
- if(viewport.resolutionChanged){
|
|
|
- this.emitResizeMsg({viewport})
|
|
|
- }
|
|
|
+ if(changeInfo.resolutionChanged){
|
|
|
+ this.dispatchEvent( {type:'resize', viewport})
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
}
|