xzw 6 mesi fa
parent
commit
92c7ac249c

+ 12 - 9
src/custom/modules/clipModel/Clip.js

@@ -599,7 +599,7 @@ var Clip = {
         return new Promise((resolve,reject)=>{ 
             if(Clip.screenshoting )return reject()
             let rulerBound = {}//因为margin 扩大bound  
-            
+            let meterPerPixel
          
             let visiPointclouds = viewer.scene.pointclouds.filter(e=> Potree.Utils.getObjVisiByReason(e, 'datasetSelection'))
             let camera = viewer.mainViewport.camera
@@ -662,7 +662,7 @@ var Clip = {
                 s = minWidth/max 
             }
             w *= s, h *= s
-            material.size *= s  
+            
             s != 1 && console.log('宽度缩放倍数',s)  
             
             
@@ -672,7 +672,7 @@ var Clip = {
             w = Math.round(w)     
             h = Math.round(h)
              
-            let focusObjectInfo = [{boundingBox, points}, 'boundingBox', 0, { dontChangeCamDir:true,  dontMoveMap:true, boundScale:1 }]
+            let focusObjectInfo = [{boundingBox, points}, 'boundingBox', 0, { dontChangeCamDir:true,  dontMoveMap:true, boundScale:1, minBound : 0.1 }]
             
             
             //分块渲染截图,最后拼合图片。需要使每一块的点数不超过pointBudget, 且尺寸不超过4096(会崩溃),过小的话一般不会超过pointBudget,除非是深度较大后排点云多。
@@ -685,17 +685,20 @@ var Clip = {
             
             console.log({wc,hc,w,h})
             
-            let meterPerPixel = boundSize.x / w
             
-            /* let text = `1 : ${(meterPerPixel).toFixed(4)}(${unitText})` */
             
              
             
             let beforeScreenshot = ()=>{
-                if(rulerToolFactory){
+                //if(rulerToolFactory){
                     let ruler = Clip.getRulerBound()
                     Object.assign(rulerBound,ruler)
-                }
+                    //因为focusOnObject时有最小边界,所以当box很小时截图区域不止box
+                    let cameraBoundSizeX = ruler.right-ruler.left 
+                    meterPerPixel = cameraBoundSizeX / w
+                    let zoom = viewer.mainViewport.camera.zoom 
+                    material.size *= Math.min(zoom / minZoom, 10 );//限制一下,避免测试时界面点云很小,截图点云很大
+                //}
             } 
             
             let {getImagePromise, finishPromise} = viewer.startScreenshot({ type: 'default', bgOpacity:0,   focusObjectInfo, maxTimeForPointLoad : 3e5, pointDensity:'screenshot2', splitRenderInfo, beforeScreenshot }, w, h, 1 )
@@ -724,11 +727,11 @@ var Clip = {
                     let rulerMargin = 20//标尺外的margin  px 
                     let labelInfo = {
                         bottomRatioToImg, horizonCenter:true,//leftRatioToImg,  
-                        textColor: /* rulerToolFactory ? */ {r: 0, g: 0, b: 0, a: 1} /* : { r: 255, g: 255, b: 255, a: 1 } */, 
+                        textColor:  rulerToolFactory ?  {r: 0, g: 0, b: 0, a: 1}  : { r: 255, g: 255, b: 255, a: 1 } , 
                         textBorderColor : { r: 30, g: 30, b: 30, a: 1 },
                         textBorderThick : rulerToolFactory ? 0 : 1 ,
                         fontsize,
-                        fontWeight: /* rulerToolFactory ? */ 'normal'/* :'Bold' */,
+                        fontWeight: rulerToolFactory ?  'normal' :'Bold' ,
                         outputCanvas : true,
                         bgColor: rulerToolFactory ? {r:255,g:255,b:255,a:255}:null
                     }

+ 1 - 1
src/custom/viewer/ViewerNew.js

@@ -4385,7 +4385,7 @@ export class Viewer extends ViewerBase{
                  
                 boundSize.x *= scale //稍微放大一些,不然会靠到屏幕边缘
                 boundSize.y *= scale  
-                let min = 1
+                let min = o.minBound || 1
                 boundSize.x = Math.max(min, boundSize.x)
                 boundSize.y = Math.max(min, boundSize.y)
             }

+ 3 - 2
src/viewer/ExtendView.js

@@ -199,9 +199,10 @@ class ExtendView extends View {
                 this.lookAt(endTarget); //compute radius for orbitcontrol 
             }else if(endQuaternion){
                 this.rotation = new THREE.Euler().setFromQuaternion(endQuaternion)
-            }else if(endYaw != void 0){
+            } 
+            if(endYaw != void 0){//前面两种在正俯视仰视时不准,故额外加一个这个
                 this.yaw = endYaw,  this.pitch = endPitch
-            }
+            }            
             //if(dir.x == 0 && dir.y == 0)this.yaw = 0 //统一一下 朝上的话是正的。朝下的一般不是0,会保留一个接近0的小数所以不用管
            
             posWaitDone || done()