xzw 2 سال پیش
والد
کامیت
052e66c9ce
3فایلهای تغییر یافته به همراه17 افزوده شده و 16 حذف شده
  1. 2 3
      src/custom/viewer/ViewerNew.js
  2. 2 1
      src/custom/viewer/Viewport.js
  3. 13 12
      src/custom/viewer/viewerBase.js

+ 2 - 3
src/custom/viewer/ViewerNew.js

@@ -689,8 +689,7 @@ export class Viewer extends ViewerBase{
             
         }) 
         
-        
-        
+         
         
         if(Potree.settings.editType != 'pano' && Potree.settings.editType != 'merge'){
               
@@ -3067,7 +3066,7 @@ export class Viewer extends ViewerBase{
             } 
             
             if(needSResize){
-                this.emitResizeMsg( { viewport:view} )
+                this.ifEmitResize( { viewport:view} )
             } 
              
             viewer.dispatchEvent({type: "render.begin",  viewer: viewer, viewport:view, params });

+ 2 - 1
src/custom/viewer/Viewport.js

@@ -61,6 +61,7 @@ export default class Viewport extends THREE.EventDispatcher{
                 quaternion: this.camera.quaternion.clone(),
                 active:this.active,
                 resolution:this.resolution.clone(),
+                resolution2:this.resolution2.clone(), //有时clientWidth没变但是ratio缩放了
             }; 
         }
         let projectionChanged = true, positionChanged = true, quaternionChanged = true, activeChanged = true, resolutionChanged = true
@@ -75,7 +76,7 @@ export default class Viewport extends THREE.EventDispatcher{
             positionChanged = !this.camera.position.equals(this.previousState.position)  
             quaternionChanged = !this.camera.quaternion.equals(this.previousState.quaternion) 
             activeChanged = this.active != this.previousState.active
-            resolutionChanged = !this.resolution.equals(this.previousState.resolution)
+            resolutionChanged = !this.resolution.equals(this.previousState.resolution) || !this.resolution2.equals(this.previousState.resolution2)
         }   
         copy() 
         

+ 13 - 12
src/custom/viewer/viewerBase.js

@@ -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})  
+                } 
                   
             }                
         }