浏览代码

fix: 修复一个大bug!之前的canvas大小没有乘deviceRatio,手机很模糊! 另外手机浏览默认改为2k

xzw 2 年之前
父节点
当前提交
5daf67654d

+ 7 - 5
src/custom/materials/ModelTextureMaterial.js

@@ -83,7 +83,8 @@ let shader = {
             ceilHeight1:{
             ceilHeight1:{
                 type: "f",
                 type: "f",
 				value: 2
 				value: 2
-            }
+            },
+             
         },
         },
        
        
         vertexShader: prefixVertex + `
         vertexShader: prefixVertex + `
@@ -198,6 +199,7 @@ let shader = {
                 uniform float cameraHeight1;
                 uniform float cameraHeight1;
                 uniform float ceilHeight0;
                 uniform float ceilHeight0;
                 uniform float ceilHeight1;
                 uniform float ceilHeight1;
+                 
                 
                 
                 vec2 getDepth(vec3 dir, sampler2D depthMap, float heightDown, float heightUp, vec4 eyePos){
                 vec2 getDepth(vec3 dir, sampler2D depthMap, float heightDown, float heightUp, vec4 eyePos){
                     vec2 depthValue = vec2(0.0, 0.0);
                     vec2 depthValue = vec2(0.0, 0.0);
@@ -211,8 +213,8 @@ let shader = {
                     float distance = (depth.g + depth.r / 256.) * 255.;  //为什么要乘以255 
                     float distance = (depth.g + depth.r / 256.) * 255.;  //为什么要乘以255 
                     
                     
                     if(distance == 0.0){//漫游点底部识别不到的区域,给一个地板高度 
                     if(distance == 0.0){//漫游点底部识别不到的区域,给一个地板高度 
-                         if(uv2.y < 0.25) distance = heightUp / dir.y;    
-                         else if(uv2.y > 0.75) distance = heightDown / -dir.y;   
+                         if(uv2.y < depthTexUVyLimit) distance = heightUp / dir.y;    
+                         else if(uv2.y > 1.0 - depthTexUVyLimit) distance = heightDown / -dir.y;   
                          else distance = 100000.0;//给个超级远的值
                          else distance = 100000.0;//给个超级远的值
                     } 
                     } 
                     
                     
@@ -292,7 +294,7 @@ let shader = {
 export default class ModelTextureMaterial extends THREE.RawShaderMaterial { 
 export default class ModelTextureMaterial extends THREE.RawShaderMaterial { 
 	constructor( ){ 
 	constructor( ){ 
     
     
-        let defines = {}
+        let defines = {depthTexUVyLimit: Potree.config.depthTexUVyLimit}
          
          
        
        
         
         
@@ -410,7 +412,7 @@ export default class ModelTextureMaterial extends THREE.RawShaderMaterial {
         let hasDepthTex = this.pano0 && this.pano1 && this.pano0.pointcloud.hasDepthTex && this.pano1.pointcloud.hasDepthTex  //暂时不知道一个有图一个没图怎么写所以
         let hasDepthTex = this.pano0 && this.pano1 && this.pano0.pointcloud.hasDepthTex && this.pano1.pointcloud.hasDepthTex  //暂时不知道一个有图一个没图怎么写所以
         
         
         Potree.Utils.addOrRemoveDefine(this, 'hasDepthTex', hasDepthTex?'add':'remove' )
         Potree.Utils.addOrRemoveDefine(this, 'hasDepthTex', hasDepthTex?'add':'remove' )
-        
+         
         
         
     }
     }
     
     

+ 11 - 148
src/custom/modules/panos/DepthImageSampler.js

@@ -74,15 +74,14 @@ class DepthImageSampler {
         //console.log('depth', depth,  uv.y)
         //console.log('depth', depth,  uv.y)
         if (!distance){
         if (!distance){
             const margin =  0.1
             const margin =  0.1
-            if(uv.y > 0.75){//漫游点底部识别不到的区域,给一个地板高度
-                //let height = origin.distanceTo(currentPano.floorPosition); 
+            if(uv.y > 1-Potree.config.depthTexUVyLimit){//漫游点底部识别不到的区域,给一个地板高度
                 
                 
                 distance = (currentPano.floorPosition.z - origin.z - margin) / dir.z
                 distance = (currentPano.floorPosition.z - origin.z - margin) / dir.z
                 location.copy(dir).multiplyScalar(distance).add(origin);
                 location.copy(dir).multiplyScalar(distance).add(origin);
                 let normal = new THREE.Vector3(0,0,1)
                 let normal = new THREE.Vector3(0,0,1)
                 
                 
                 return {location, normal, distance} 
                 return {location, normal, distance} 
-            }else if(uv.y < 0.25){
+            }else if(uv.y < Potree.config.depthTexUVyLimit){
                 let ceilZ = currentPano.getCeilHeight()
                 let ceilZ = currentPano.getCeilHeight()
                 if(ceilZ == Infinity)return !1
                 if(ceilZ == Infinity)return !1
                 else{ 
                 else{ 
@@ -91,11 +90,11 @@ class DepthImageSampler {
                     let normal = new THREE.Vector3(0,0,-1)
                     let normal = new THREE.Vector3(0,0,-1)
                     return {location, normal, distance} 
                     return {location, normal, distance} 
                 } 
                 } 
-            }return !1;  //应该是天空或模型外 , 因为很少有漫游点的地方还拍不到地板
+            }
+            //console.log('无穷远')
+            return !1;  //应该是天空或模型外 , 因为很少有漫游点的地方还拍不到地板
         }  
         }  
-        
-        //this.mainDepth = depth
-       
+         
         location.copy(dir).multiplyScalar(distance).add(origin);
         location.copy(dir).multiplyScalar(distance).add(origin);
         
         
         if(!onlyPos){
         if(!onlyPos){
@@ -116,10 +115,7 @@ class DepthImageSampler {
           , pB = this.getNearbyPoint(origin, uv,  0, -1)
           , pB = this.getNearbyPoint(origin, uv,  0, -1)
           , pT = this.getNearbyPoint(origin, uv,  0, 1);
           , pT = this.getNearbyPoint(origin, uv,  0, 1);
            
            
-        } */
-         
-          
-     
+        } */ 
         //console.log(location, normal,  distance)
         //console.log(location, normal,  distance)
           
           
         return {location, normal,  distance} 
         return {location, normal,  distance} 
@@ -182,153 +178,20 @@ class DepthImageSampler {
         }
         }
          
          
          
          
-        /* 四个面拼成一个菱形 */        
-          
+        /* 四个面拼成一个菱形 */   
     } 
     } 
       
       
-    
-    /* makeUvToPosMap(intersect, matrix1, vec1, vec2) {
-        var o = intersect.object.geometry
-          , a = o.attributes.position.array
-          , s = new THREE.Vector3(a[3 * intersect.face.a],a[3 * intersect.face.a + 1],a[3 * intersect.face.a + 2]).applyMatrix4(intersect.object.matrixWorld)
-          , c = new THREE.Vector3(a[3 * intersect.face.b],a[3 * intersect.face.b + 1],a[3 * intersect.face.b + 2]).applyMatrix4(intersect.object.matrixWorld)
-          , l = new THREE.Vector3(a[3 * intersect.face.c],a[3 * intersect.face.c + 1],a[3 * intersect.face.c + 2]).applyMatrix4(intersect.object.matrixWorld);
-        vec1.subVectors(s, c),
-        vec2.subVectors(l, c);
-        var u = o.attributes.uv.array
-          , d = new THREE.Vector2(u[2 * intersect.face.a],u[2 * intersect.face.a + 1])
-          , p = new THREE.Vector2(u[2 * intersect.face.b],u[2 * intersect.face.b + 1])
-          , h = new THREE.Vector2(u[2 * intersect.face.c],u[2 * intersect.face.c + 1])
-          , f = d.sub(p)
-          , g = h.sub(p);
-        matrix1.set(f.x, g.x, 0, f.y, g.y, 0, 0, 0, 1),
-        matrix1.getInverse(matrix1)
-    } */
-    
-
-  
-    /* getNearbyPoint(  point, origin, uv, o, a, s, x, y) {
-        var add = new THREE.Vector3(x, y , 0 ) 
-          , depth = this.getDepth(uv.x + add.x, uv.y + add.y  );
-           
-        if (void 0 !== depth) {
-            var f = add.applyMatrix3(o);
-            return (new THREE.Vector3).addScaledVector(a, f.x).addScaledVector(s, f.y).add(point).sub(origin).normalize().multiplyScalar(depth).add(origin)
-        }
-    } */
-    
-    
+   
     
     
 }
 }
 
 
 /* 
 /* 
     注:
     注:
-     
-
+      
     由于有时候获取intersect需要知道是哪个点云,所以还是不能用这个。如加测量线。
     由于有时候获取intersect需要知道是哪个点云,所以还是不能用这个。如加测量线。
 
 
  */
  */
 
 
 export default DepthImageSampler
 export default DepthImageSampler
 
 
-
-    /* var i = n(4)
-      , r = function() {
-        function t(t) {
-            
-        }
-        return t.prototype.getDepth = function(t, e) {
-            var n = Math.round(t)
-              , i = Math.round(e);
-            if (!(n < 0 || i < 0 || n >= this.width || i >= this.height)) {
-                var r = this.context.getImageData(n, i, 1, 1).data;
-                return r[1] + r[0] / 256
-            }
-        }
-        ,
-        Object.defineProperty(t.prototype, "width", {
-            get: function() {
-                return this.context.canvas.width
-            },
-            enumerable: !0,
-            configurable: !0
-        }),
-        Object.defineProperty(t.prototype, "height", {
-            get: function() {
-                return this.context.canvas.height
-            },
-            enumerable: !0,
-            configurable: !0
-        }),
-        t
-    }();
-    e.CanvasDepthImage = r;
-    var o = function() {
-        function t() {}
-        return t.sample = function(e, n, r, o, a) {
-            var s = n.uv
-              , c = s.x * (e.width - 1)
-              , l = (1 - s.y) * (e.height - 1)
-              , u = e.getDepth(c, l);
-            if (!u)
-                return !1;
-            o.copy(n.point).sub(r).normalize().multiplyScalar(u).add(r);
-            var d = new i.Matrix3
-              , p = new i.Vector3
-              , h = new i.Vector3;
-            t.makeUvToPosMap(n, d, p, h);
-            var f = this.getNearbyPoint(e, n.point, r, s, d, p, h, -1, 0)
-              , g = this.getNearbyPoint(e, n.point, r, s, d, p, h, 1, 0)
-              , m = this.getNearbyPoint(e, n.point, r, s, d, p, h, 0, -1)
-              , v = this.getNearbyPoint(e, n.point, r, s, d, p, h, 0, 1);
-            return this.planeFit(o, r, f, g, m, v, a)
-        }
-        ,
-        t.makeUvToPosMap = function(t, e, n, r) {
-            var o = t.object.geometry
-              , a = o.attributes.position.array
-              , s = new i.Vector3(a[3 * t.face.a],a[3 * t.face.a + 1],a[3 * t.face.a + 2]).applyMatrix4(t.object.matrixWorld)
-              , c = new i.Vector3(a[3 * t.face.b],a[3 * t.face.b + 1],a[3 * t.face.b + 2]).applyMatrix4(t.object.matrixWorld)
-              , l = new i.Vector3(a[3 * t.face.c],a[3 * t.face.c + 1],a[3 * t.face.c + 2]).applyMatrix4(t.object.matrixWorld);
-            n.subVectors(s, c),
-            r.subVectors(l, c);
-            var u = o.attributes.uv.array
-              , d = new i.Vector2(u[2 * t.face.a],u[2 * t.face.a + 1])
-              , p = new i.Vector2(u[2 * t.face.b],u[2 * t.face.b + 1])
-              , h = new i.Vector2(u[2 * t.face.c],u[2 * t.face.c + 1])
-              , f = d.sub(p)
-              , g = h.sub(p);
-            e.set(f.x, g.x, 0, f.y, g.y, 0, 0, 0, 1),
-            e.getInverse(e)
-        }
-        ,
-        t.getNearbyPoint = function(t, e, n, r, o, a, s, c, l) {
-            var u = new i.Vector3(c / (t.width - 1),l / (t.height - 1))
-              , d = (r.x + u.x) * (t.width - 1)
-              , p = (1 - (r.y + u.y)) * (t.height - 1)
-              , h = t.getDepth(d, p);
-            if (void 0 !== h) {
-                var f = u.applyMatrix3(o);
-                return (new i.Vector3).addScaledVector(a, f.x).addScaledVector(s, f.y).add(e).sub(n).normalize().multiplyScalar(h).add(n)
-            }
-        }
-        ,
-        t.planeFit = function(t, e, n, r, o, a, s) {
-            s.set(0, 0, 0);
-            var c = t.clone().sub(e)
-              , l = new i.Plane;
-            function u(e, n) {
-                e && n && (l.setFromCoplanarPoints(t, e, n),
-                s.addScaledVector(l.normal, c.dot(l.normal) < 0 ? 1 : -1))
-            }
-            return u(n, o),
-            u(n, a),
-            u(r, o),
-            u(r, a),
-            (0 !== s.x || 0 !== s.y || 0 !== s.z) && (s.normalize(),
-            !0)
-        }
-        ,
-        t
-    }();
-    */
+ 

+ 30 - 30
src/custom/modules/panos/Images360.js

@@ -1241,13 +1241,11 @@ export class Images360 extends THREE.EventDispatcher{
             }else{
             }else{
                 return 0
                 return 0
             }  
             }  
-            
-        }
-        
-        
+        } 
         
         
         var request = [//必要条件 
         var request = [//必要条件 
-            Images360.filters.inPanoDirection( this.position, direction, option1), 
+            Images360.filters.inFloorDirection( this.position, direction, option1 ),  //原先用inPanoDirection,但容易穿楼层,当mouse较低或较高
+            Images360.filters.inPanoDirection( this.position, this.getDirection(), option1/* , true */),  //垂直方向上再稍微限制一下, 要接近视线方向,避免点击前方时因无路而到下一楼。但不能太高,否则楼梯上稍微朝下点击都到不了上方。之所以使用视线方向是因为镜头方向比鼠标方向目的性更强。
             //Images360.filters.isNeighbourPanoTo(this.currentPano), 
             //Images360.filters.isNeighbourPanoTo(this.currentPano), 
             Images360.filters.not(this.currentPano),
             Images360.filters.not(this.currentPano),
             Images360.filters.isEnabled(),
             Images360.filters.isEnabled(),
@@ -1262,21 +1260,17 @@ export class Images360 extends THREE.EventDispatcher{
                 } 
                 } 
             }  */
             }  */
         ] 
         ] 
-        
-        
+         
         var list = [//决胜项目
         var list = [//决胜项目
             Images360.scoreFunctions.distanceSquared(this.position,  1  ),
             Images360.scoreFunctions.distanceSquared(this.position,  1  ),
             
             
             Images360.scoreFunctions[o]( this.position, direction,true),
             Images360.scoreFunctions[o]( this.position, direction,true),
-             
-             
+               
             (pano)=>{
             (pano)=>{
                 let neighbour = this.isNeighbour(this.currentPano, pano) 
                 let neighbour = this.isNeighbour(this.currentPano, pano) 
                                                                                         
                                                                                         
                 return neighbour ? directionFactor  : 0; 
                 return neighbour ? directionFactor  : 0; 
-            } 
-             
-            
+            }  
             /* (pano)=>{//尽量不穿越地板到下一层
             /* (pano)=>{//尽量不穿越地板到下一层
                 let dis = getHeightDis(pano)
                 let dis = getHeightDis(pano)
                 return -dis * directionFactor * 0.1;
                 return -dis * directionFactor * 0.1;
@@ -1290,7 +1284,7 @@ export class Images360 extends THREE.EventDispatcher{
                 } 
                 } 
             } */
             } */
         ]; 
         ]; 
-        if(!byKey && viewer.inputHandler.intersect && this.currentPano ){//方便上下楼, 考虑panos之间的角度差
+        if(!byKey && viewer.inputHandler.intersect && this.currentPano ){//方便上下楼, 考虑panos之间的角度差  
             let pos1 = this.currentPano.floorPosition 
             let pos1 = this.currentPano.floorPosition 
             let vec1 = new THREE.Vector3().subVectors(viewer.inputHandler.intersect.location, pos1 ).normalize()//应该只有atPano时才会执行到这吧? 
             let vec1 = new THREE.Vector3().subVectors(viewer.inputHandler.intersect.location, pos1 ).normalize()//应该只有atPano时才会执行到这吧? 
             list.push(  function(pano) { 
             list.push(  function(pano) { 
@@ -1313,7 +1307,7 @@ export class Images360 extends THREE.EventDispatcher{
         n.pano = null),
         n.pano = null),
         e || (e = 0);
         e || (e = 0);
         var r = Common.sortByScore(this.panos, t, i);
         var r = Common.sortByScore(this.panos, t, i);
-        console.log('findRankedByScore', r && r.map(u=>u.item.id + '|  ' + math.toPrecision(u.score,4) + "  | " + math.toPrecision(u.scores,4)))
+        //console.log('findRankedByScore', r && r.map(u=>u.item.id + '|  ' + math.toPrecision(u.score,4) + "  | " + math.toPrecision(u.scores,4)))
         
         
         
         
         return !r || 0 === r.length || e >= r.length ? null : (n && (n.candidates = r,
         return !r || 0 === r.length || e >= r.length ? null : (n && (n.candidates = r,
@@ -2023,19 +2017,23 @@ Images360.prototype.checkAndWaitForPanoLoad = function() {
 
 
 
 
 Images360.filters = { 
 Images360.filters = { 
-    inPanoDirection : function(pos, dir, i) { 
+    inPanoDirection : function(pos, dir, i, log) { //pano在mouse的方向上
         return function(pano) { 
         return function(pano) { 
             var r = pano.floorPosition.clone().sub(pos).normalize() 
             var r = pano.floorPosition.clone().sub(pos).normalize() 
             var o = pano.position.clone().sub(pos).normalize()
             var o = pano.position.clone().sub(pos).normalize()
-            return r.dot(dir) > i || o.dot(dir) > i 
-            
-            
+            log && console.log('dire',pano.id, r.dot(dir),  o.dot(dir) )
+            return r.dot(dir) > i || o.dot(dir) > i  
         }
         }
     },
     },
-    inFloorDirection: function(pos, e, o) {//许钟文 改 for鱼眼
-		return function(n) {
-			var i = n.floorPosition.clone().sub(pos).setZ(0).normalize();//改成在xz方向上,否则点击墙面不会移动
-			return i.dot(e) > o
+    inFloorDirection: function(pos, dir, min, log) { //pano在mouse的水平方向上
+		return function(pano) {
+            var vec = new THREE.Vector2().subVectors(pano.floorPosition, pos).normalize()
+            var dir_ = new THREE.Vector2().copy(dir).normalize()
+            log && console.log('dire', pano.id, vec.dot(dir_)  )
+            return vec.dot(dir_) > min
+            
+			/* var i = pano.floorPosition.clone().sub(pos).setZ(0).normalize();//改成在xz方向上,否则点击墙面不会移动
+			return i.dot(dir.clone().setZ(0)) > min  */
 		}
 		}
 	}, 
 	}, 
     isNotBehindNormal: function(e, t) {
     isNotBehindNormal: function(e, t) {
@@ -2129,7 +2127,7 @@ Images360.prototype.updateCube = (function(){//增加细分的版本,且垂直
     let minTanBeta = minDis / height    /* (pano0.position.z - pano0.floorPosition.z) */
     let minTanBeta = minDis / height    /* (pano0.position.z - pano0.floorPosition.z) */
     let minBeta = Math.atan(minTanBeta)
     let minBeta = Math.atan(minTanBeta)
     const maxSinAlpha = Math.cos(minBeta) // 注:beta = Math/2 - alpha
     const maxSinAlpha = Math.cos(minBeta) // 注:beta = Math/2 - alpha
-    
+    const skyHeight = 50
     return function(pano0, pano1){
     return function(pano0, pano1){
     
     
         if(Potree.settings.displayMode != 'showPanos' || pano0 == pano1
         if(Potree.settings.displayMode != 'showPanos' || pano0 == pano1
@@ -2174,7 +2172,7 @@ Images360.prototype.updateCube = (function(){//增加细分的版本,且垂直
             let sinAlpha = Math.abs(pano0.position.z - pano1.position.z) / dis //俯仰角的sin,随角度增大而增大 0-1
             let sinAlpha = Math.abs(pano0.position.z - pano1.position.z) / dis //俯仰角的sin,随角度增大而增大 0-1
             let score = (1+sinAlpha*20) * dis //score越大创建的mesh越不适合 
             let score = (1+sinAlpha*20) * dis //score越大创建的mesh越不适合 
             let isNeighbour = this.isNeighbour(pano0, pano1)   
             let isNeighbour = this.isNeighbour(pano0, pano1)   
-            console.log(pano0.id, pano1.id,  maxSinAlpha.toFixed(2), sinAlpha.toFixed(2),  score.toFixed(2), isNeighbour)
+            //console.log(pano0.id, pano1.id,  maxSinAlpha.toFixed(2), sinAlpha.toFixed(2),  score.toFixed(2), isNeighbour)
             
             
             let depthTiming = Potree.timeCollect.depthSampler.median    //pc firefox达到4.  chrome为0.01
             let depthTiming = Potree.timeCollect.depthSampler.median    //pc firefox达到4.  chrome为0.01
             
             
@@ -2211,7 +2209,7 @@ Images360.prototype.updateCube = (function(){//增加细分的版本,且垂直
             let getFar = (dir, pano, origin, height)=>{//获取在这个方向上和墙体intersect的距离  
             let getFar = (dir, pano, origin, height)=>{//获取在这个方向上和墙体intersect的距离  
                 //在垂直方向上分出多个方向,取一个最可能的接近真实的距离
                 //在垂直方向上分出多个方向,取一个最可能的接近真实的距离
                 let maxH = 40, minH = 2, minR = 0.5, maxR = 2  
                 let maxH = 40, minH = 2, minR = 0.5, maxR = 2  
-                height = height == void 0 ? (pano.ceilZ - pano.floorPosition.z) : height
+                height = height == void 0 ? (Math.min(skyHeight,pano.ceilZ) - pano.floorPosition.z) : height
                 //let r = height (maxH - minH)* 0.14  // 高度越小,角度越小 
                 //let r = height (maxH - minH)* 0.14  // 高度越小,角度越小 
                 //let r = minR + ( maxR - minR) * THREE.Math.clamp((height - minH)  / (maxH - minH),0,1)   //THREE.Math.smoothstep(currentDis,  op.nearBound,  op.farBound);
                 //let r = minR + ( maxR - minR) * THREE.Math.clamp((height - minH)  / (maxH - minH),0,1)   //THREE.Math.smoothstep(currentDis,  op.nearBound,  op.farBound);
                 let r = math.linearClamp(height, minH,maxH,   minR,  maxR) 
                 let r = math.linearClamp(height, minH,maxH,   minR,  maxR) 
@@ -2251,7 +2249,7 @@ Images360.prototype.updateCube = (function(){//增加细分的版本,且垂直
                 minZ = pano.floorPosition.z
                 minZ = pano.floorPosition.z
                 
                 
                 maxZ = pano.getCeilHeight()
                 maxZ = pano.getCeilHeight()
-                let skyHeight = 50
+                
                 if(maxZ == Infinity) maxZ = skyHeight;   //maxZ = Math.max(skyHeight, maxZ)
                 if(maxZ == Infinity) maxZ = skyHeight;   //maxZ = Math.max(skyHeight, maxZ)
                 
                 
                 
                 
@@ -2389,7 +2387,9 @@ Images360.prototype.updateCube = (function(){//增加细分的版本,且垂直
             
             
             let addSide = ()=>{//两个漫游点间两边各加一些侧线 
             let addSide = ()=>{//两个漫游点间两边各加一些侧线 
                 //中点处的
                 //中点处的
-                let midMaxZ = (pano0.ceilZ + pano1.ceilZ)/2
+                let top0 = pano0.ceilZ == Infinity ?  skyHeight : pano0.ceilZ 
+                let top1 = pano1.ceilZ == Infinity ?  skyHeight : pano1.ceilZ 
+                let midMaxZ = (top0 + top1)/2
                 let midMinZ = (pano0.floorPosition.z+pano1.floorPosition.z)/2;
                 let midMinZ = (pano0.floorPosition.z+pano1.floorPosition.z)/2;
                 let mid = new THREE.Vector3().addVectors(pano0.position, pano1.position).multiplyScalar(0.5)
                 let mid = new THREE.Vector3().addVectors(pano0.position, pano1.position).multiplyScalar(0.5)
                  
                  
@@ -2448,7 +2448,7 @@ Images360.prototype.updateCube = (function(){//增加细分的版本,且垂直
                                 disToSides.forEach(e=>{//求z
                                 disToSides.forEach(e=>{//求z
                                     let ratio = e.disToPano2d / dis2d
                                     let ratio = e.disToPano2d / dis2d
                                     let r = accordingPano == pano0 ? (1-ratio) : ratio
                                     let r = accordingPano == pano0 ? (1-ratio) : ratio
-                                    let sideMaxZ_ = pano0.ceilZ * r + pano1.ceilZ * (1-r);
+                                    let sideMaxZ_ = top0 * r + top1 * (1-r);
                                     let sideMinZ_ = pano0.floorPosition.z * r + pano1.floorPosition.z * (1-r);
                                     let sideMinZ_ = pano0.floorPosition.z * r + pano1.floorPosition.z * (1-r);
                                     [sideMaxZ_,sideMinZ_].forEach(z=>{  
                                     [sideMaxZ_,sideMinZ_].forEach(z=>{  
                                         posArr.push(e.pano.position.clone().setZ(z).add(e.dir_)) //是直接使用最长dis的那个intersect点好还是mid
                                         posArr.push(e.pano.position.clone().setZ(z).add(e.dir_)) //是直接使用最长dis的那个intersect点好还是mid
@@ -2596,8 +2596,8 @@ Images360.prototype.updateCube = (function(){//增加细分的版本,且垂直
             
             
             
             
          */
          */
-        
-}())
+    } 
+})()
 
 
     
     
 
 

+ 14 - 9
src/custom/modules/panos/Panorama.js

@@ -81,7 +81,7 @@ class Panorama extends THREE.EventDispatcher{
             if(e.reason == 'screenshot' || e.visible){
             if(e.reason == 'screenshot' || e.visible){
                 this.label && (this.label.visible = e.visible)//截图时隐藏下
                 this.label && (this.label.visible = e.visible)//截图时隐藏下
             }
             }
-            Potree.Utils.updateVisible(this.label2, 'panoVisi', e.visible)
+            this.label2 && Potree.Utils.updateVisible(this.label2, 'panoVisi', e.visible)
         })
         })
         /*  
         /*  
         漫游点可见性:旧
         漫游点可见性:旧
@@ -285,8 +285,8 @@ class Panorama extends THREE.EventDispatcher{
         this.marker = marker 
         this.marker = marker 
         
         
         this.images360.node.add(marker)
         this.images360.node.add(marker)
-        Potree.settings.isTest && this.createTextLabel()
-        this.createTextLabel2() 
+        Potree.settings.isTest && this.addLabel()
+        //this.addLabel2() 
          
          
         marker.addEventListener('mouseover', this.hoverOn.bind(this));  
         marker.addEventListener('mouseover', this.hoverOn.bind(this));  
         marker.addEventListener('mouseleave', this.hoverOff.bind(this)); 
         marker.addEventListener('mouseleave', this.hoverOff.bind(this)); 
@@ -518,7 +518,7 @@ class Panorama extends THREE.EventDispatcher{
 
 
     
     
     
     
-    createTextLabel(){
+    addLabel(){ 
         this.removeTextLabel()
         this.removeTextLabel()
         this.label = new TextSprite(Object.assign({},
         this.label = new TextSprite(Object.assign({},
            labelProp, {text: this.id + "("+this.originID+")"}) //{text: `id:${this.id}, dataset:${this.pointcloud.name}, 4dkkId:${this.originID}`}
            labelProp, {text: this.id + "("+this.originID+")"}) //{text: `id:${this.id}, dataset:${this.pointcloud.name}, 4dkkId:${this.originID}`}
@@ -527,8 +527,8 @@ class Panorama extends THREE.EventDispatcher{
         this.floorPosition && this.label.position.copy(this.floorPosition)
         this.floorPosition && this.label.position.copy(this.floorPosition)
     }
     }
     
     
-    createTextLabel2(){   
-          
+    addLabel2(){  
+        if(this.label2)return
         this.label2 = new TextSprite(Object.assign({},
         this.label2 = new TextSprite(Object.assign({},
            labelProp2, {text: /* this.originID  */   parseInt(this.id)+1   }) //{text: `id:${this.id}, dataset:${this.pointcloud.name}, 4dkkId:${this.originID}`}
            labelProp2, {text: /* this.originID  */   parseInt(this.id)+1   }) //{text: `id:${this.id}, dataset:${this.pointcloud.name}, 4dkkId:${this.originID}`}
         ); 
         ); 
@@ -537,6 +537,7 @@ class Panorama extends THREE.EventDispatcher{
         let s = 0.4
         let s = 0.4
         this.label2.scale.set(s,s,s)
         this.label2.scale.set(s,s,s)
         Potree.Utils.updateVisible(this.label2, 'notDisplay', false)
         Potree.Utils.updateVisible(this.label2, 'notDisplay', false)
+        Potree.Utils.updateVisible(this.label2, 'panoVisi', this.visible)
     }
     }
     
     
     removeTextLabel(){
     removeTextLabel(){
@@ -569,8 +570,11 @@ class Panorama extends THREE.EventDispatcher{
                      
                      
             
             
             //用三个间隔120度散开,和中心垂直线成一定夹角的三个向量去求 最高高度 (不求平均的原因:万一是0不好算)
             //用三个间隔120度散开,和中心垂直线成一定夹角的三个向量去求 最高高度 (不求平均的原因:万一是0不好算)
-            let rotMat = new THREE.Matrix4().makeRotationX(THREE.Math.degToRad(40))// 角度不能小于天花板中空的半径,大概就是0.2*Math.PI=36度
-             
+            
+            let rotMat = new THREE.Matrix4().makeRotationX((Potree.config.depthTexUVyLimit+0.01)*Math.PI)// 角度不能小于天花板中空的半径 
+            
+            
+            
             let dirs = [new THREE.Vector3(0,0,1).applyMatrix4(rotMat)];
             let dirs = [new THREE.Vector3(0,0,1).applyMatrix4(rotMat)];
             if(depthTiming < 1){
             if(depthTiming < 1){
                 let rotMat1 = new THREE.Matrix4().makeRotationZ(Math.PI*2 / 3);
                 let rotMat1 = new THREE.Matrix4().makeRotationZ(Math.PI*2 / 3);
@@ -582,7 +586,8 @@ class Panorama extends THREE.EventDispatcher{
             }
             }
              
              
             let zs = dirs.map(dir_=>{ 
             let zs = dirs.map(dir_=>{ 
-                let intersect = viewer.images360.getIntersect(this, dir_) 
+                let dir = dir_.clone().applyMatrix4(this.panoMatrix2)  //pano不一定是垂直的, 需要把之前的dirInPano先转成真实的dir,防止超出角度限制
+                let intersect = viewer.images360.getIntersect(this, dir) 
                 let z = intersect ? intersect.location.z : Infinity/* this.position.z+skyHeight */ //没有intersect代表可能是天空
                 let z = intersect ? intersect.location.z : Infinity/* this.position.z+skyHeight */ //没有intersect代表可能是天空
                 return z 
                 return z 
             })
             })

+ 17 - 16
src/custom/modules/panos/tile/PanoRenderer.js

@@ -154,7 +154,7 @@ class PanoRenderer extends THREE.EventDispatcher{
             r && this.deactiveDescripor(r.renderTarget) 
             r && this.deactiveDescripor(r.renderTarget) 
             r = this.activeDescripor(l)  
             r = this.activeDescripor(l)  
             if (!r) { 
             if (!r) { 
-                var ren = this.initTiledPano(l, !browser.isMobile()); 
+                var ren = this.initTiledPano(l,  !browser.isMobile() ); 
                 r = this.initDescriptor(ren.width);
                 r = this.initDescriptor(ren.width);
                 r.renderTarget = ren;
                 r.renderTarget = ren;
             }
             }
@@ -397,7 +397,7 @@ class PanoRenderer extends THREE.EventDispatcher{
 
 
         
         
     updateUploadQueue(maxNPF,maxPF/* e, t */) {//参数是 maxNonBaseUploadsPerFrame and maxBaseUploadsPerFrame, 优先上传512
     updateUploadQueue(maxNPF,maxPF/* e, t */) {//参数是 maxNonBaseUploadsPerFrame and maxBaseUploadsPerFrame, 优先上传512
-        maxNPF || (maxNPF = 1);
+        //maxNPF || (maxNPF = 1);
         for (var i = 0, n = 0;;) {
         for (var i = 0, n = 0;;) {
             //let old = this.forceQueue.slice(0)
             //let old = this.forceQueue.slice(0)
            
            
@@ -568,14 +568,16 @@ class PanoRenderer extends THREE.EventDispatcher{
     }
     }
 
 
     updateZoomedPanoFromBase(pano) {//因更换pano所以将pano的rendertarget渲染到panoRenderer的zoomRenderTarget上
     updateZoomedPanoFromBase(pano) {//因更换pano所以将pano的rendertarget渲染到panoRenderer的zoomRenderTarget上
-        if (!this.zoomPanoRenderingDisabled && this.zoomRenderTarget) {
+        if (!this.zoomPanoRenderingDisabled) {
             var t = this.getActiveRenderTargetDescriptor(pano.id);
             var t = this.getActiveRenderTargetDescriptor(pano.id);
             if (t && t.renderTarget ) {
             if (t && t.renderTarget ) {
-                var i = Math.min(this.qualityManager.maxRenderTargetSize, this.qualityManager.getMaxZoomPanoSize()), //change
-                    n = t.renderTarget,
-                    r = t.size;
-                this.copyCubeMap(n.texture, this.zoomRenderTarget, r, r, i, i),
-                    this.copyBaseRenderStatusToZoomed(pano.id)
+                if(this.zoomRenderTarget){
+                    var i = Math.min(this.qualityManager.maxRenderTargetSize, this.qualityManager.getMaxZoomPanoSize()), //change
+                        n = t.renderTarget,
+                        r = t.size;
+                    this.copyCubeMap(n.texture, this.zoomRenderTarget, r, r, i, i);
+                }
+                this.copyBaseRenderStatusToZoomed(pano.id)
             } 
             } 
         }
         }
     }
     }
@@ -744,11 +746,10 @@ class PanoRenderer extends THREE.EventDispatcher{
 PanoRenderer.prototype.setupZoomRenderTarget = function(){
 PanoRenderer.prototype.setupZoomRenderTarget = function(){
     var targets = {};
     var targets = {};
     return function(){
     return function(){
-        if(this.qualityManager.maxRenderTargetSize == '2k' && this.qualityManager.getMaxNavPanoSize()=='2k')return; //不使用zoomTarget 直接用pano的tiledPanoRenderTarget,防崩溃
-        
-        
+        if(this.qualityManager.maxRenderTargetSize == 2048 && this.qualityManager.getMaxNavPanoSize()==2048)return; //不使用zoomTarget 直接用pano的tiledPanoRenderTarget,防崩溃
         
         
-        if (this.qualityManager.getMaxZoomPanoSize() >= this.qualityManager.getMaxNavPanoSize() /* && (config.tileClass != "2k" ||config.tileClass != "1k")   */) {
+         
+        if (this.qualityManager.getMaxZoomPanoSize() >= this.qualityManager.getMaxNavPanoSize()  ) {
          //部分手机2k时copyCubeMap会重载 , 所以如果没有超出当前分辨率,就不使用zoomRenderTarget。但在微信依旧会重载,只是优化了些,safari几乎不会。
          //部分手机2k时copyCubeMap会重载 , 所以如果没有超出当前分辨率,就不使用zoomRenderTarget。但在微信依旧会重载,只是优化了些,safari几乎不会。
             if (this.zoomRenderTarget && this.zoomRenderTarget.width === this.qualityManager.getMaxZoomPanoSize())
             if (this.zoomRenderTarget && this.zoomRenderTarget.width === this.qualityManager.getMaxZoomPanoSize())
                 return;
                 return;
@@ -872,8 +873,8 @@ PanoRenderer.prototype.update = function () {
     //this.uploadIntervalCancelled = true ; //不使用setTimeout,而是在sceneRenderer每帧都update
     //this.uploadIntervalCancelled = true ; //不使用setTimeout,而是在sceneRenderer每帧都update
     
     
     if(viewer.images360.latestRequestMode == 'showPanos'){  
     if(viewer.images360.latestRequestMode == 'showPanos'){  
-        let maxNonBaseUploadsPerFrame = viewer.lastFrameChanged ? Common.getBestCount('maxStandard', 1,  2, undefined, undefined /* ,true  */) : 2  //this.maxNonBaseUploadsPerFrame //原先2。这是每帧uploadTile非512的瓦片tex的数量。之前的2太卡了,降为1。(检测卡顿方法:在一个pano点旋转至所有2048的tile都加载完,然后之后到这个点看看卡不卡。因为该点tiles都下载完了所以会在飞过来时陆续都加载,所以容易卡)
-        let maxBaseUploadsPerFrame = viewer.lastFrameChanged ? Common.getBestCount('maxBase',1,6,     2, 20  /* ,true */ ) : 6 //this.maxBaseUploadsPerFrame //原先6. 但持续前进过程中会请求加载下一个漫游图,一次加6张会卡的。
+        let maxNonBaseUploadsPerFrame = viewer.lastFrameChanged ? Common.getBestCount('maxStandard', 0,  2,  1,  10   /*  ,true */    ) : 2    // 这是每帧uploadTile非512的瓦片tex的数量。 手机在前进时可能会总是0,直到到漫游点后为2
+        let maxBaseUploadsPerFrame = viewer.lastFrameChanged ? Common.getBestCount('maxBase',1,6,  1, 14 /* ,true */ ) : 6 //this.maxBaseUploadsPerFrame //原先6. 但持续前进过程中会请求加载下一个漫游图,一次加6张会卡的。
          
          
         this.updateUploadQueue(maxNonBaseUploadsPerFrame, maxBaseUploadsPerFrame) 
         this.updateUploadQueue(maxNonBaseUploadsPerFrame, maxBaseUploadsPerFrame) 
         
         
@@ -961,8 +962,8 @@ PanoRenderer.prototype.uploadTile = function () {//重写
              
              
             /*if(failHistory[id+':'+ panoSize+ ':' +tileIndex]){
             /*if(failHistory[id+':'+ panoSize+ ':' +tileIndex]){
                 console.log('uploadTile retry',id, panoSize, tileIndex)
                 console.log('uploadTile retry',id, panoSize, tileIndex)
-            } 
-            console.log('uploadTile 成功', id, panoSize, tileIndex) */  
+            }   
+            console.log('uploadTile 成功', id, panoSize, tileIndex) */
 
 
             var C = tileX * tileSize,
             var C = tileX * tileSize,
                 I = tileY * tileSize,
                 I = tileY * tileSize,

+ 4 - 3
src/custom/settings.js

@@ -309,7 +309,8 @@ const config = {//配置参数   不可修改
         "deep orange": [ 255,61,0],
         "deep orange": [ 255,61,0],
          
          
     },
     },
-    depTexDlCount : browser.isMobile() ? 1 : 3
+    depTexDlCount : browser.isMobile() ? 1 : 3,
+    depthTexUVyLimit: 0.141, // 在这个范围内是没有深度的,从图片算的0.14003, 设置为稍大于这个数值
 }
 }
 
 
  
  
@@ -391,7 +392,7 @@ let settings = {//设置   可修改
                                  
                                  
     },
     },
     navConstantly:true,
     navConstantly:true,
-    navTileClass: browser.isMobile() ? '1k' : '2k',  //默认加载到
+    navTileClass:  /*  browser.isMobile() ? '1k' :  */  '2k',  //默认加载到
     tileClass:'4k',     //最高可达
     tileClass:'4k',     //最高可达
     /* loadTilesWhenUnfocus:false, //页面unfocus时也仍在加载tiles
     /* loadTilesWhenUnfocus:false, //页面unfocus时也仍在加载tiles
     loadPointsWhenUnfocus:true, //页面unfocus时也仍在加载点云 */
     loadPointsWhenUnfocus:true, //页面unfocus时也仍在加载点云 */
@@ -427,7 +428,7 @@ let settings = {//设置   可修改
     precision:2,  // 两位小数 
     precision:2,  // 两位小数 
     useV4url:true, //v4的全景图等路径不一样 scene_view_data
     useV4url:true, //v4的全景图等路径不一样 scene_view_data
     
     
-    useRTskybox:true,  //直接使用rtEDL绘制到屏幕,当是全景模式时. 在降4倍时能给render节省1毫秒,gpu时间未测
+    useRTskybox:true,  //直接使用rtEDL绘制到屏幕,当是全景模式时. 在降4倍时能给render节省1毫秒,gpu时间未测 
     useRTPoint:true,    //直接使用rtEDL绘制到屏幕,当是点云模式时。可以大大节省gpu时间
     useRTPoint:true,    //直接使用rtEDL绘制到屏幕,当是点云模式时。可以大大节省gpu时间
     pointEnableRT:false,//点云是否允许绘制到rtEDL。只在有需要时使用
     pointEnableRT:false,//点云是否允许绘制到rtEDL。只在有需要时使用
     cloudSameMat:true,  //因为点云个数较多,就使用相同的材质,可见降低绘制速度(要保证所有点云的maxNodelevel一样,且要算出 material.spacing的平均值)
     cloudSameMat:true,  //因为点云个数较多,就使用相同的材质,可见降低绘制速度(要保证所有点云的maxNodelevel一样,且要算出 material.spacing的平均值)

+ 39 - 37
src/custom/start.js

@@ -48,6 +48,9 @@ export function start(dom, mapDom, number ){ //t-Zvd3w0m
         }); 
         }); 
         Potree.settings.sizeFitToLevel = true//当type为衰减模式时自动根据level调节大小。每长一级,大小就除以2
         Potree.settings.sizeFitToLevel = true//当type为衰减模式时自动根据level调节大小。每长一级,大小就除以2
         Potree.settings.rotAroundPoint = false
         Potree.settings.rotAroundPoint = false
+        if(/* Potree.settings.isTest && */ browser.isMobile()){
+            changeLog()
+        }
     }  
     }  
 
 
     Potree.loadDatasetsCallback = function(data, ifReload){
     Potree.loadDatasetsCallback = function(data, ifReload){
@@ -902,51 +905,50 @@ export function mergeEditStart(dom){
  
  
  
  
  
  
-/* var changeLog = ()=>{ //如果移动端加了test反而出不来bug的话,用这个
-        
-    
-        var textarea = document.createElement('textarea');
-          textarea.id = "consoleLog";
-          
-          textarea.style.width = '160px';
-          textarea.style.height =  '200px'
-          textarea.style.position = 'fixed'
-          textarea.style.right = 0
-          textarea.style.bottom = '0'
-          textarea.style['z-index'] = 9999;
-          textarea.style.color = 'black';
-          textarea.style.opacity = 0.9;
-          textarea.style['font-size'] = '12px';
-          textarea.style['backgroundColor'] = '#ffffff'
+var changeLog = ()=>{  
          
          
-          
+    var textarea = document.createElement('textarea');
+    textarea.id = "consoleLog";
 
 
-          document.getElementsByTagName("body")[0].appendChild(textarea);
-          var list = ["log", "error", "warn", "debug", "info", "time", "timeEnd"]
-          var exchange = function (o) {
-            console["old" + o] = console[o];
-            console[o] = function () {
-              var args =   Array.from(arguments)
-              console["old" + o].apply(this, arguments)
-              var t = document.getElementById("consoleLog").innerHTML;
-              
-              var str = ''
-              args.forEach(a=>{
-                  str += a + ' '
-              })
-              document.getElementById("consoleLog").innerHTML = str + "\n\n" + t;
-            }
-          }
+    textarea.style.width = '160px';
+    textarea.style.height =  '200px'
+    textarea.style.position = 'fixed'
+    textarea.style.left = 0
+    textarea.style.bottom = '50px'
+    textarea.style['z-index'] = 9999;
+    textarea.style.color = 'black';
+    textarea.style.opacity = 0.9;
+    textarea.style['font-size'] = '12px';
+    textarea.style['backgroundColor'] = '#ffffff'
 
 
-          for (var i = 0; i < list.length; i++) {
-            exchange(list[i])
-          } 
+
+
+    document.getElementsByTagName("body")[0].appendChild(textarea);
+    var list = ["log", "error", "warn", "debug", "info", "time", "timeEnd"]
+    var exchange = function (o) {
+    console["old" + o] = console[o];
+    console[o] = function () {
+      var args =   Array.from(arguments)
+      console["old" + o].apply(this, arguments)
+      var t = document.getElementById("consoleLog").innerHTML;
+      
+      var str = ''
+      args.forEach(a=>{
+          str += a + ' '
+      })
+      document.getElementById("consoleLog").innerHTML = str + "\n\n" + t;
+    }
+    }
+
+    for (var i = 0; i < list.length; i++) {
+        exchange(list[i])
+    } 
    
    
     
     
     
     
 }
 }
  
  
-changeLog() */
+ 
  
  
  
  
  
  

+ 3 - 7
src/custom/utils/Common.js

@@ -311,16 +311,12 @@ var Common = {
         let count
         let count
         if(timeStamp.length){
         if(timeStamp.length){
             let dur = performance.now() - timeStamp[timeStamp.length-1].startTime;  //dur在iphoneX中静止有7,pc是2
             let dur = performance.now() - timeStamp[timeStamp.length-1].startTime;  //dur在iphoneX中静止有7,pc是2
-            /* let k = -(maxCount-minCount)/(durBound2 - durBound1)
-            let m = maxCount - durBound1 * k
-            count = THREE.MathUtils.clamp(Math.round(k * dur + m), minCount, maxCount )    
-             */
+           
             count = Math.round(math.linearClamp(dur, durBound1,durBound2,   maxCount,  minCount))
             count = Math.round(math.linearClamp(dur, durBound1,durBound2,   maxCount,  minCount))
              
              
             if(ifLog){//注意,console.log本身用时挺高, 降4倍时可能占用0.5毫秒
             if(ifLog){//注意,console.log本身用时挺高, 降4倍时可能占用0.5毫秒
-               name && console.log(name,   count , ' ,dur:', dur)
-            }
-            
+               name && console.log(name,   count , ' ,dur:', dur.toFixed(3))
+            } 
         }else{
         }else{
             count = maxCount  //  ? 
             count = maxCount  //  ? 
         } 
         } 

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

@@ -3911,8 +3911,8 @@ export class Viewer extends ViewerBase{
 		if(this.stats){
 		if(this.stats){
 			this.stats.begin();
 			this.stats.begin();
 		}
 		}
-        viewer.addTimeMark('loop','start')
-		 
+       
+        performance.mark('loop-start') ;// 无论有没有reportTimings都要获取,因为getBestCound需要
 
 
 		this.update(this.clock.getDelta(), timestamp);
 		this.update(this.clock.getDelta(), timestamp);
         this.magnifier.render();
         this.magnifier.render();

+ 2 - 65
src/custom/viewer/viewerBase.js

@@ -124,8 +124,6 @@ export class ViewerBase extends THREE.EventDispatcher{
 
 
             w = this.renderArea.clientWidth;
             w = this.renderArea.clientWidth;
             h = this.renderArea.clientHeight
             h = this.renderArea.clientHeight
-            
-
              
              
             if(w !== this.screenSizeInfo.W || h !== this.screenSizeInfo.H || o.forceUpdateSize || this.screenSizeInfo.pixelRatio != window.devicePixelRatio){
             if(w !== this.screenSizeInfo.W || h !== this.screenSizeInfo.H || o.forceUpdateSize || this.screenSizeInfo.pixelRatio != window.devicePixelRatio){
                 this.screenSizeInfo.W = w 
                 this.screenSizeInfo.W = w 
@@ -142,74 +140,13 @@ export class ViewerBase extends THREE.EventDispatcher{
     }   
     }   
 
 
 
 
-    /* updateScreenSize(o={}) { //容易出错。。
-           
-        var render = false, ratio, w, h;
-        //记录应当render的大小
-        if (o.width != void 0 && o.height != void 0) {
-            w = o.width
-            h = o.height
-            render = true
-            ratio = 1
-        }else { 
-            w = this.renderArea.clientWidth;
-            h = this.renderArea.clientHeight 
-
-            let refreshWin = ()=>{
-                this.screenSizeInfo.windowWidth = window.innerWidth
-                this.screenSizeInfo.windowHeight = window.innerHeight
-            }
  
  
-            let prepareToRender = ()=>{
-                w = this.renderArea.clientWidth;
-                h = this.renderArea.clientHeight
-                this.screenSizeInfo.W = w 
-                this.screenSizeInfo.H = h 
-                refreshWin() //render后才refreshWin
-                render = true   
-                this.screenSizeInfo.pixelRatio = window.devicePixelRatio  //如果player放在小窗口了,也要监测devicePixelRatio,因为缩放时client宽高不会改变
-                //config.isMobile ? (ratio = Math.min(window.devicePixelRatio, 2)) : (ratio = window.devicePixelRatio)
-                ratio = window.devicePixelRatio
-                //console.log('setSize11', w) 
-                o.forceUpdateSize = false ;//防止再次render
-            }
-
-            let ifNeedUpdate = ()=>{
-                w = this.renderArea.clientWidth;
-                h = this.renderArea.clientHeight
-                return o.forceUpdateSize || w !== this.screenSizeInfo.W || h !== this.screenSizeInfo.H || this.screenSizeInfo.pixelRatio != window.devicePixelRatio
-            }
-            
-            if(ifNeedUpdate()){
-                //当只有一个有效viewport时,且因为改变整个窗口大小而触发的话,延时
-                let canInterval = !o.forceUpdateSize && this.viewports.filter(e=>e.active).length==1 && (this.screenSizeInfo.windowWidth != window.innerWidth || this.screenSizeInfo.windowHeight != window.innerHeight  ) 
-                  
-                if(canInterval){
-                    Common.intervalTool.isWaiting('updateScreenSize', ()=>{ //延时update,防止崩溃 , 未到时间就拦截(第一次直接执行)
-                         if(ifNeedUpdate()){
-                            prepareToRender()
-                            return true
-                         }
-                    }, 500) 
-                }else{  
-                    //console.log('soon', window.innerWidth, this.screenSizeInfo.windowWidth)
-                    prepareToRender() 
-                } 
-                 
-            }    
-            
-        }
-        if (render) { 
-            this.setSize(w, h, ratio); 
-        } 
-    }  */
-
      
      
     setSize(width, height, devicePixelRatio, onlyForTarget){ 
     setSize(width, height, devicePixelRatio, onlyForTarget){ 
         //console.log('setSize', width) 
         //console.log('setSize', width) 
         if(!onlyForTarget){//onlyForTarget表示不更改当前renderer,只是为了rendertarget才要改变viewport
         if(!onlyForTarget){//onlyForTarget表示不更改当前renderer,只是为了rendertarget才要改变viewport
-                       
-            this.renderer.setSize(width, height, null, devicePixelRatio); // resize之后会自动clear(似乎因为setScissor ),所以一定要立刻绘制,所以setSize要在cameraChanged、update之前
+            this.renderer.setPixelRatio(devicePixelRatio)    
+            this.renderer.setSize(width, height ); // resize之后会自动clear(似乎因为setScissor ),所以一定要立刻绘制,所以setSize要在cameraChanged、update之前
                                                                            
                                                                            
         }
         }
        
        

+ 7 - 2
src/navigation/FirstPersonControlsNew.js

@@ -81,11 +81,13 @@ export class FirstPersonControls extends THREE.EventDispatcher {
             if(!viewport)return
             if(!viewport)return
             let camera = viewport.camera 
             let camera = viewport.camera 
             let mode 
             let mode 
+             
+             
             if(e.isTouch){
             if(e.isTouch){
                 if(e.touches.length == 1){
                 if(e.touches.length == 1){
                     mode = (!e.dragViewport || e.dragViewport.name == 'MainView') ? 'rotate' : 'pan' 
                     mode = (!e.dragViewport || e.dragViewport.name == 'MainView') ? 'rotate' : 'pan' 
                 }else if(e.touches.length == 2){
                 }else if(e.touches.length == 2){
-                    mode = 'pan-scale'
+                    mode = Potree.settings.displayMode == 'showPanos' ? 'scale' : 'pan-scale'
                 }else{
                 }else{
                     mode = (!e.dragViewport || e.dragViewport.name == 'MainView') ? 'pan' : 'scale' 
                     mode = (!e.dragViewport || e.dragViewport.name == 'MainView') ? 'pan' : 'scale' 
                 } 
                 } 
@@ -93,6 +95,9 @@ export class FirstPersonControls extends THREE.EventDispatcher {
                 //mode = e.buttons === Buttons.LEFT && (!e.dragViewport || e.dragViewport.name == 'MainView') ? 'rotate' : 'pan'
                 //mode = e.buttons === Buttons.LEFT && (!e.dragViewport || e.dragViewport.name == 'MainView') ? 'rotate' : 'pan'
                 mode = e.buttons === Buttons.LEFT && camera.type != 'OrthographicCamera' ? 'rotate' : 'pan'
                 mode = e.buttons === Buttons.LEFT && camera.type != 'OrthographicCamera' ? 'rotate' : 'pan'
             }
             }
+            
+            
+            
             //console.log('mode  ', mode )
             //console.log('mode  ', mode )
             let moveSpeed = this.currentViewport.getMoveSpeed();
             let moveSpeed = this.currentViewport.getMoveSpeed();
             if (e.drag.startHandled === undefined) {///???????
             if (e.drag.startHandled === undefined) {///???????
@@ -335,7 +340,7 @@ export class FirstPersonControls extends THREE.EventDispatcher {
 
 
 
 
         let dolly = (e={})=>{
         let dolly = (e={})=>{
-                       
+                  
             if(Potree.settings.displayMode == 'showPanos' && this.currentViewport == viewer.mainViewport/* this.currentViewport.unableChangePos */){//全景时 
             if(Potree.settings.displayMode == 'showPanos' && this.currentViewport == viewer.mainViewport/* this.currentViewport.unableChangePos */){//全景时 
                 this.dispatchEvent({type:'dollyStopCauseUnable',delta:e.delta, scale:e.scale})
                 this.dispatchEvent({type:'dollyStopCauseUnable',delta:e.delta, scale:e.scale})
                 return 
                 return 

+ 3 - 3
src/navigation/InputHandlerNew.js

@@ -398,11 +398,11 @@ export class InputHandler extends THREE.EventDispatcher {
 		this.dragViewport = this.hoverViewport = viewport
 		this.dragViewport = this.hoverViewport = viewport
       
       
         
         
-        if(isTouch || !Potree.settings.intersectWhenHover ){ 
+        //if(isTouch || !Potree.settings.intersectWhenHover ){ 
             this.hoveredElements = this.getHoveredElements();
             this.hoveredElements = this.getHoveredElements();
-            this.intersect = this.getIntersect(viewport)
+            this.intersect = this.getIntersect(viewport) //更新intersect,避免在没有mousemove但flyToPano后intersect未更新。
             //this.intersect = this.getWholeIntersect()  
             //this.intersect = this.getWholeIntersect()  
-        }
+        //}
         if(!viewport)return //why add this?
         if(!viewport)return //why add this?
         if (!this.drag) {
         if (!this.drag) {
             let target = (isTouch||e.button == THREE.MOUSE.LEFT) && this.hoveredElements.find(el => (//只有左键能拖拽
             let target = (isTouch||e.button == THREE.MOUSE.LEFT) && this.hoveredElements.find(el => (//只有左键能拖拽