xzw hace 1 año
padre
commit
47ec3dfada

+ 38 - 21
src/ExtendPointCloudOctree.js

@@ -223,17 +223,21 @@ export class ExtendPointCloudOctree extends PointCloudOctree{
 		viewer.addTimeMark('pick','start')
 
 		let getVal = (a, b) => a != void 0 ? a : b;
-        
-        
-        let r0 = this.nodeMaxLevel > 0 ? this.maxLevel/this.nodeMaxLevel : 0.5
-        let pickWindowSize_ = THREE.Math.clamp( Math.round((1.1-r0)*80),  5, 100)
-		let pickWindowSize = getVal(params.pickWindowSize, pickWindowSize_    ); /* 65 */ //拾取像素边长,越小越精准,但点云稀疏的话可能容易出现识别不到的情况。 另外左下侧会有缝隙无法识别到,缝隙大小和这个值有关//突然发现pickWindowSize在一百以内的变化对pick费时影响甚微,1和100差1毫秒不到,但400时会多4毫秒
-            
+        let pickWindowSize = params.pickWindowSize;   //拾取像素边长,越小越精准,但点云稀疏的话可能容易出现识别不到的情况。 另外左下侧会有缝隙无法识别到,缝隙大小和这个值有关//突然发现pickWindowSize在一百以内的变化对pick费时影响甚微,1和100差1毫秒不到,但400时会多4毫秒
+        if(pickWindowSize == void 0){
+            if(Potree.settings.displayMode == 'showPanos'){ 
+                pickWindowSize = 50
+            }else{
+                let r0 = this.nodeMaxLevel > 0 ? this.maxLevel/this.nodeMaxLevel : 0.5
+                pickWindowSize = THREE.Math.clamp( Math.round((1.1-r0)*80),  15, 100)
+            }
+        }
+          
         if(camera.type == 'OrthographicCamera'){
             var cameraDir = new THREE.Vector3(0,0,-1).applyQuaternion(camera.quaternion) 
             pickWindowSize *= 4  //pointsize比较大时截取太小会没多少点可以选
         }     
-            
+   
             
 		let pickOutsideClipRegion = getVal(params.pickOutsideClipRegion, false);
 
@@ -246,7 +250,7 @@ export class ExtendPointCloudOctree extends PointCloudOctree{
             if(window.testScreen){            
                 let dataUrl = Potree.Utils.renderTargetToDataUrl(pickState.renderTarget, width, height, renderer)
              
-                Common.downloadFile(dataUrl, 'screenshot.jpg')  //为什么图片上不是只有pickWindowSize区域有颜色??
+                Potree.Common.downloadFile(dataUrl, 'screenshot.png')   
                 window.testScreen = 0
             } 
         }
@@ -296,7 +300,7 @@ export class ExtendPointCloudOctree extends PointCloudOctree{
 			pickMaterial.uniforms.uFilterGPSTimeClipRange.value = this.material.uniforms.uFilterGPSTimeClipRange.value;
 			pickMaterial.uniforms.uFilterPointSourceIDClipRange.value = this.material.uniforms.uFilterPointSourceIDClipRange.value;
 
-			pickMaterial.activeAttributeName = "indices";
+			pickMaterial.activeAttributeName = "indices";//indices
 
 			pickMaterial.size = pointSize;
 			pickMaterial.uniforms.minSize.value = this.material.uniforms.minSize.value;
@@ -314,14 +318,18 @@ export class ExtendPointCloudOctree extends PointCloudOctree{
 		pickState.renderTarget.setSize(width, height); //仅绘制屏幕大小的,而不乘以devicePixelRatio
 
 		let pixelPos = new THREE.Vector2(params.x, params.y);
-
+        
 		let gl = renderer.getContext();
+        //规定渲染范围,只渲染一小块
+        /* renderer.setScissorTest(true);
 		gl.enable(gl.SCISSOR_TEST);
-		gl.scissor(  //规定渲染范围,只渲染一小块
+		gl.scissor(  
 			parseInt(pixelPos.x - (pickWindowSize - 1) / 2),
 			parseInt(pixelPos.y - (pickWindowSize - 1) / 2),
 			parseInt(pickWindowSize), parseInt(pickWindowSize));
-
+             */ //---这段没用 
+        pickState.renderTarget.scissor.set(parseInt(pixelPos.x - (pickWindowSize - 1) / 2),  parseInt(pixelPos.y - (pickWindowSize - 1) / 2),parseInt(pickWindowSize), parseInt(pickWindowSize)); 
+        pickState.renderTarget.scissorTest = true
 
 		renderer.state.buffers.depth.setTest(pickMaterial.depthTest);
 		renderer.state.buffers.depth.setMask(pickMaterial.depthWrite);
@@ -331,14 +339,14 @@ export class ExtendPointCloudOctree extends PointCloudOctree{
 		{ // RENDER
 			renderer.setRenderTarget(pickState.renderTarget);
 			gl.clearColor(0, 0, 0, 0);
-			renderer.clear(true, true, true);
+			//renderer.clear(true, true, true);
 
 			let tmp = this.material;
 			this.material = pickMaterial;
             
 			pRenderer.renderOctree(this, nodes, camera, pickState.renderTarget);
             screenshot();
-
+            
 
 			this.material = tmp;
 		}
@@ -355,12 +363,16 @@ export class ExtendPointCloudOctree extends PointCloudOctree{
         //w<pickWindowSize会报错
     
 		gl.readPixels(x, y, pickWindowSize, pickWindowSize, gl.RGBA, gl.UNSIGNED_BYTE, buffer); //这句花费最多时间 pc:2-4, 即使只有1*1像素
- 
+        renderer.clear(true, true, true);  //绘制完就clear否则download的图会有上次的轨迹
+        
+        
 		renderer.setRenderTarget(null);
 		renderer.state.reset();
 		renderer.setScissorTest(false);
 		gl.disable(gl.SCISSOR_TEST);
-
+        
+        
+        
 		let pixels = buffer;
 		let ibuffer = new Uint32Array(buffer.buffer); //四个数整合成一个
 
@@ -407,7 +419,7 @@ export class ExtendPointCloudOctree extends PointCloudOctree{
 			}
 		}
         
-        if(!params.all){
+        if(!params.all && Potree.settings.pickFrontPointRatio){
             if(hits2.length){//add 
                 hits = hits2
             } 
@@ -462,7 +474,7 @@ export class ExtendPointCloudOctree extends PointCloudOctree{
 					point[attributeName] = position;
                     
                     //add
-                    if(!params.all){
+                    if(!params.all && Potree.settings.pickFrontPointRatio ){
                         if(camera.type == 'OrthographicCamera'){
                             let vec = new THREE.Vector3().subVectors(position, camera.position)
                             hit.disSquare = vec.projectOnVector( cameraDir ).length();  //只考虑到相机的垂直距离 
@@ -509,16 +521,21 @@ export class ExtendPointCloudOctree extends PointCloudOctree{
 			if(hits.length === 0){
 				return null;
 			}else{
+                
+                if(Potree.settings.pickFrontPointRatio == 0){//如果不需要选偏离镜头近的,就要离中心近的即可
+                    //console.log(hits[0], hits2, pixelPos)
+                    return hits[0].point;
+                }
+                
                 //为了防止透过点云缝隙,选到后排的点云,将选取的位置离相机的距离考虑进去。倾向选择离相机近、且离鼠标位置近的点。(否则按照原方案只选离鼠标位置最近的,可能从高楼不小心走到下层,导航选点也是)
                 let sorted1 = hits.sort( (a, b) => a.disSquare - b.disSquare  ).slice();
                 
                 let nearest = sorted1[0]  //return nearest.point;  //直接用最近点 在点云稀疏时不太跟手,如地面上,最近点往往在鼠标下方
-                let r = 10      
-                  
+                      
                 hits.forEach( hit=>{
                     let disDiff = hit.disSquare - nearest.disSquare //和最近点的偏差 
                     hit.disDiff = disDiff 
-                    hit.score = -hit.distanceToCenter - disDiff * r
+                    hit.score = -hit.distanceToCenter - disDiff * Potree.settings.pickFrontPointRatio 
                 })
                 
                 let sorted2 = hits.sort( (a, b) => b.score - a.score  );

+ 5 - 0
src/LRU.js

@@ -23,6 +23,11 @@ class LRU{
 		this.items = {};  //按node的id存储。(id为0的就是root,name='r')
 		this.elements = 0;
 		this.numPoints = 0;
+        
+         
+            
+    
+        
 	}
 
 	size(){

+ 1 - 1
src/custom/modules/clipping/Clipping.js

@@ -270,7 +270,7 @@ export class Clipping extends THREE.EventDispatcher{ //实时剪裁
         this.tranMode = mode 
         
         viewer.transformationTool.setModeEnable([mode])
-       
+        viewer.dispatchEvent('content_changed')
     }
     
     

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

@@ -2568,7 +2568,7 @@ Images360.prototype.getNeighbours = function(){ //逐渐自动获取neighbours
         this.depthSampler.updateNearPanos(panos)
         
         let maxWaitDur = browser.isMobile() ? 40 : 60  
-        let changeCount = 0,  maxChangeTex = browser.isMobile() ? 2 : 4,    getCount = 0 
+        let changeCount = 0,  maxChangeTex = browser.isMobile() ? 1 : 3,    getCount = 0 
         let changeTexCount = ()=>{
             changeCount ++;
         }

+ 28 - 6
src/custom/objects/Magnifier.js

@@ -68,7 +68,7 @@ export default class Magnifier extends THREE.Object3D {//放大镜or望远镜
                     colorType = e.material.activeAttributeName
                     e.material.activeAttributeName = 'rgba'
                     e.changePointOpacity(1) 
-                    e.changePointSize(Potree.config.material.realPointSize, true)
+                    //e.changePointSize(Potree.config.material.realPointSize, true)
                 }) 
             };
             
@@ -83,7 +83,7 @@ export default class Magnifier extends THREE.Object3D {//放大镜or望远镜
                     e.material.pointSizeType = sizeType
                     e.material.activeAttributeName = colorType  
                     e.changePointOpacity(opacityBefore.get(e))  
-                    e.changePointSize(sizeBefore.get(e)) 
+                    //e.changePointSize(sizeBefore.get(e)) 
                 })  
             } 
         }
@@ -221,6 +221,9 @@ export default class Magnifier extends THREE.Object3D {//放大镜or望远镜
             })
         }
         
+        this.addEventListener('isVisible',(e)=>{ 
+            if(!this.visible) Potree.settings.pointDensity = Potree.settings.pointDensity //恢复pointBudget
+        })
         
         viewer.scene.view.addEventListener('flyingDone',()=>{
             if(!this.visible)return
@@ -272,9 +275,10 @@ export default class Magnifier extends THREE.Object3D {//放大镜or望远镜
          
         //自身位置 
         //let pos2d = viewer.inputHandler.pointer.clone();   //跟随鼠标 
-        let pos2d = Potree.Utils.getPos2d(aimPos, viewer.mainViewport, viewer.renderArea).vector   //更新目标点的实时二维位置
-        let margin = 0.4, maxY = 0.4
-        let screenPos = pos2d.clone().setY(pos2d.y + (pos2d.y>maxY ? -margin : margin ))
+        let pos2d_ = Potree.Utils.getPos2d(aimPos, viewer.mainViewport, viewer.renderArea)   //更新目标点的实时二维位置
+        let pos2d = pos2d_.vector
+        let margin = width2dPX*1.1 / viewer.mainViewport.resolution2.y * 2  //确保到鼠标的间距占放大镜的比例不变(检查mobile、上下分屏后的变化)
+        let screenPos = pos2d.clone().setY(pos2d.y + (pos2d.y >0 ?  -margin : margin ))
         
         let newPos = new THREE.Vector3(screenPos.x,screenPos.y,0.8).unproject(playerCamera); //z:-1朝外       
         if(playerCamera.type != 'OrthographicCamera'){
@@ -385,4 +389,22 @@ export default class Magnifier extends THREE.Object3D {//放大镜or望远镜
         
     }
    
-}
+}
+
+
+
+
+
+
+
+/* 
+
+    如果遇到放大镜内点云很不正常,应该是深度图错误(可能全景和点云没匹配上)。
+
+
+
+
+
+
+ */
+

+ 31 - 20
src/custom/objects/tool/Measure.js

@@ -25,14 +25,14 @@ var planeMats
 const textSizeRatio = math.linearClamp(window.outerWidth * window.outerHeight , [360*720, 1920*1080], [0.7, 1])  //pc字显示大一些 用
  
 const lineDepthInfo = {
-    clipDistance : 4,//消失距离
-    occlusionDistance: 1,//变为backColor距离 
+    clipDistance : 15,//4,//消失距离
+    occlusionDistance: 3,//1,//变为backColor距离 
 }
  
 const markerMapShrink = browser.isMobile() ? 0.4 : 0.8  //触屏需要更大的热区
 
 const markerSizeInfo = {
-    width2d : 18 / markerMapShrink  ,   nearBound : 1.5, farBound : 15,
+    width2d : 18 / markerMapShrink  , //  nearBound : 1.5, farBound : 15,
 }  
 /* const markerSizeInfo = {
     minSize : 10 ,   maxSize : 15 ,   nearBound : 1.5, farBound : 15,
@@ -223,6 +223,8 @@ export class Measure extends ctrlPolygon{
     }
  
 	update(options={}) { 
+        if(options.index == -1)return
+        
         super.update(options)
       
         if(this.showCoordinates && this.points.length>0){
@@ -272,20 +274,16 @@ export class Measure extends ctrlPolygon{
           
         } */
          
+        let lastIndex = this.points.length - 1
          
-         
-        let lastIndex = this.points.length - 1; 
-        for (let index = 0; index <= lastIndex; index++) {
-            
-            let nextIndex = (index + 1 > lastIndex) ? 0 : index + 1;
-            let previousIndex = (index === 0) ? lastIndex : index - 1;
-            //if(!this.closed && nextIndex == 0  )break; //add
-            
+        
+        let setLabel = (index)=>{
+            let previousIndex = this.getIndex(index, -1)
+            let nextIndex = this.getIndex(index, +1)
+            let previousPoint = this.points[previousIndex];
             let point = this.points[index];
             let nextPoint = this.points[nextIndex];
-            let previousPoint = this.points[previousIndex];
-
-          
+            
             if(this.showDistances){ // edge labels
                 let edgeLabel = this.edgeLabels[index];
                 let distance = point.distanceTo(nextPoint)
@@ -297,9 +295,20 @@ export class Measure extends ctrlPolygon{
                     setEdgeLabel(edgeLabel,point,nextPoint,distance)
                 }  
             }
-        } 
+        }
         
         
+        if(options.index != void 0){//更新第几个点 
+            
+            setLabel(options.index) 
+            let previousIndex = this.getIndex(options.index, -1)
+            setLabel(previousIndex) 
+        }else{  
+            for (let index = 0; index <= lastIndex; index++) { 
+                 setLabel(index)  
+            } 
+        }
+        
         if(Potree.config.measure.mulLabelHideFaraway ){
             this.measureType == 'MulDistance' && this.clearEdgeLabelVisi()
         }
@@ -567,8 +576,10 @@ export class Measure extends ctrlPolygon{
      
             //add for 调试,方便后期增加点
             if(!this.isNew && viewer.inputHandler.pressedKeys['M'.charCodeAt(0)] && this.points.length<this.maxMarkers){  
-                this.addMarker({index:this.markers.indexOf(marker)+1, point:marker.position.clone()})
-                   
+                viewer.measuringTool.history.beforeChange(this)
+                let curIndex = this.markers.indexOf(marker)
+                this.addMarker({index:curIndex+1, point:marker.position.clone(), dataset_point:this.dataset_points[curIndex] && this.dataset_points[curIndex].clone(), points_dataset:this.points_datasets[curIndex]})
+                
             }
 
 
@@ -620,7 +631,7 @@ export class Measure extends ctrlPolygon{
             edge.addEventListener('addHoverEvent', addHoverEvent);
 		}
         
-        super.addMarker({point:o.point, index, marker,  edge})
+        super.addMarker(Object.assign(o, {index, marker,  edge}))
         
         
 		if(this.showEdges){ // edge labels  
@@ -654,7 +665,7 @@ export class Measure extends ctrlPolygon{
 		this.dispatchEvent(event);
 
 		//this.setMarker(this.points.length - 1, point);
-        this.update()//更新一下倒数第二条线   
+        this.update({index})//更新一下倒数第二条线   
         return marker;//add
 	};
 
@@ -795,7 +806,7 @@ export class Measure extends ctrlPolygon{
             this.edgeLabels.splice(edgeIndex, 1);
         }
          
-        this.update(); 
+        this.update({index: this.getIndex(index, -1)}); 
         this.dispatchEvent({type: 'marker_removed', measurement: this});
     }
     

+ 1 - 1
src/custom/objects/tool/MeasuringTool.js

@@ -44,7 +44,7 @@ export class MeasuringTool extends THREE.EventDispatcher{
                 return {
                     measure, 
                     points: measure.points.map(e=>e.clone()),
-                    dataset_points: measure.dataset_points.map(e=>e.clone()),
+                    dataset_points: measure.dataset_points ? measure.dataset_points.map(e=>e&&e.clone()) : null,
                     points_datasets: measure.points_datasets.slice(),
                     datasetId: measure.datasetId
                 }

+ 64 - 54
src/custom/objects/tool/ctrlPolygon.js

@@ -110,7 +110,16 @@ export class ctrlPolygon extends THREE.Object3D {
         
         this.points = [...this.points.slice(0,index), o.point, ...this.points.slice(index,this.points.length)]
 		//this.points.push(o.point);
-         
+        if(o.dataset_point){
+            this.dataset_points = [...this.dataset_points.slice(0,index), o.dataset_point, ...this.dataset_points.slice(index,this.dataset_points.length)]
+        }
+        if(o.points_dataset){
+            this.points_datasets = [...this.points_datasets.slice(0,index), o.points_dataset, ...this.points_datasets.slice(index,this.points_datasets.length)]
+        }
+        
+        
+        
+        
         if(o.marker){
             this.add(o.marker)
             this.markers = [...this.markers.slice(0,index), o.marker, ...this.markers.slice(index,this.markers.length)]
@@ -192,36 +201,20 @@ export class ctrlPolygon extends THREE.Object3D {
         
         I = e.intersect && (e.intersect.adsorption ? e.intersect.location : (e.intersect.orthoIntersect || e.intersect.location))
         
-        
-        let dragPolyBeyondPoint = ()=>{ 
+          
+        if(viewer.inputHandler.pressedKeys[18] || Potree.settings.dragPolyBeyondPoint&&!I ){//alt    dragPolyBeyondPoint可以平移拖拽到无点的地方---测试用
             let i = this.markers.indexOf(e.drag.object);
-            let point = this.points[i]
+            I = this.points[i].clone()
                
-            const projected = point.clone().project(e.drag.dragViewport.camera);
+            const projected = I.clone().project(e.drag.dragViewport.camera);
             projected.x = e.pointer.x
             projected.y = e.pointer.y
-            
-            
+             
             const unprojected = projected.clone().unproject(e.drag.dragViewport.camera);
-            point.copy(unprojected);
-            
-            this.setPosition(i, point); 
-	        this.update();
-	        
-	        this.dispatchEvent({type:'dragChange', index:i});
-            
-            this.editStateChange(true)
-            
-        }
-        //记录数据集
-        
-        //在三维中脱离点云(在map中拉到周围都没有点云的地方)的顶点,无法拖拽怎么办
+            I.copy(unprojected); 
+        } 
          
          
-        if(viewer.inputHandler.pressedKeys[18]){//alt 
-            dragPolyBeyondPoint()
-            return true
-        } 
          
          
         if (I) {  
@@ -244,12 +237,7 @@ export class ctrlPolygon extends THREE.Object3D {
             this.editStateChange(true)
             return true
             
-        }else if(Potree.settings.dragPolyBeyondPoint){//可以平移拖拽到无点的地方---测试用
-            dragPolyBeyondPoint()
-            return true 
-        }
-        
-        
+        } 
         
         
     };
@@ -456,7 +444,7 @@ export class ctrlPolygon extends THREE.Object3D {
         })
         this.isAtWrongPlace = false
         this.setPosition(i, location); 
-        this.update()
+        this.update({index: this.isRect ? null : i})
         
         this.dispatchEvent({type:'dragChange', index:i})
         
@@ -690,42 +678,58 @@ export class ctrlPolygon extends THREE.Object3D {
 
     
     
-    
+    getIndex(index, add){
+        let lastIndex = this.points.length - 1
+        if(add == -1) return (index === 0) ? lastIndex : index - 1;
+        else if(add == 1)  return (index + 1 > lastIndex) ? 0 : index + 1; 
+    }
      
 
     update(options={}){
         if(this.points.length === 0){
 			return;
 		} 
-          
+        //performance.mark('measureUpdate-start')
+        
         let lastIndex = this.points.length - 1
-             
-        for (let index = 0; index <= lastIndex; index++) {
+        
+        
+        if(options.index != void 0){//更新第几个点 
+            this.updateMarker(this.markers[options.index], this.points[options.index])
+            let previousIndex = this.getIndex(options.index, -1)
+            let nextIndex = this.getIndex(options.index, +1) 
+            if( this.closed || nextIndex != 0  ) LineDraw.updateLine( this.edges[options.index], [this.points[options.index], this.points[nextIndex]]) 
+            if( this.closed || previousIndex != lastIndex  ) LineDraw.updateLine( this.edges[previousIndex], [this.points[options.index], this.points[previousIndex]]) 
+     
+        }else{
             
-            let nextIndex = (index + 1 > lastIndex) ? 0 : index + 1;
-            let previousIndex = (index === 0) ? lastIndex : index - 1;
- 
-            let point = this.points[index];
-            let nextPoint = this.points[nextIndex];
-            let previousPoint = this.points[previousIndex];
+            for (let index = 0; index <= lastIndex; index++) {
+                
+                let nextIndex = this.getIndex(index, +1) 
+                let previousIndex = this.getIndex(index, -1)
+     
+                let point = this.points[index];
+                let nextPoint = this.points[nextIndex];
+                let previousPoint = this.points[previousIndex];
 
-            if(options.ifUpdateMarkers){
-                this.updateMarker(this.markers[index], point)
-            }   
-            
-            
-            if(!this.closed && nextIndex == 0  )break; //add
-            { // edges
-                let edge = this.edges[index]; 
-                if(edge){
-                    LineDraw.updateLine(edge, [point, nextPoint]) 
-                    //edge.visible = index < lastIndex || this.isRect || (this.closed && !this.isNew);
-                } 
-            }  
+                if(options.ifUpdateMarkers){
+                    this.updateMarker(this.markers[index], point)
+                }   
+                
+                
+                if(!this.closed && nextIndex == 0  )break; //add
+                { 
+                    let edge = this.edges[index]; 
+                    if(edge){
+                        LineDraw.updateLine(edge, [point, nextPoint]) 
+                    } 
+                }  
+            }
         }
         
         
         
+        
         if(this.areaPlane){
             this.updateAreaPlane()  
         }
@@ -734,6 +738,12 @@ export class ctrlPolygon extends THREE.Object3D {
         viewer.dispatchEvent('content_changed')
         viewer.mapViewer && viewer.mapViewer.dispatchEvent('content_changed') //暂时先这么都通知
         
+        
+        
+        //performance.mark('measureUpdate-end')
+        //let measure = performance.measure('measure-','measureUpdate-start', 'measureUpdate-end' );
+        //console.log('update-time', measure.duration)
+        
     } 
     
     

+ 54 - 41
src/custom/potree.shim.js

@@ -286,11 +286,11 @@ Utils.getMousePointCloudIntersection = function(viewport, mouse, pointer, camera
     let sizeType
     let size = new Map()  
     let visiMap = new Map()
-    let needsUpdate = false;
-    
-    if(pickParams.measuring || Potree.settings.displayMode == 'showPanos') { //(无深度图) 测量或全景模式提高精准度,因为漫游的
+    let needsUpdate = false; 
+
+    if(pickParams.measuring || Potree.settings.displayMode == 'showPanos') { //测量或无深度图时的全景模式提高精准度. (全景模式有深度图时不会执行到这)
         density = Potree.settings.pointDensity 
-        Potree.settings.pointDensity = 'magnifier' 
+        Potree.settings.pointDensity = 'magnifier' //加载最高level
         
         pointclouds.forEach(e=>{//因为全景模式的pointSizeType是fixed所以要还原下
             visiMap.set(e,e.visible)
@@ -300,7 +300,7 @@ Utils.getMousePointCloudIntersection = function(viewport, mouse, pointer, camera
             sizeType = e.material.pointSizeType  
             e.material.pointSizeType = Potree.config.material.pointSizeType 
              
-            e.changePointSize(Potree.config.material.realPointSize*2, true)//更改点云大小到能铺满为止,否则容易识别不到
+            //e.changePointSize(Potree.config.material.realPointSize*2, true)//更改点云大小到能铺满为止,否则容易识别不到
         }) 
         needsUpdate = true
     }else{ 
@@ -323,11 +323,24 @@ Utils.getMousePointCloudIntersection = function(viewport, mouse, pointer, camera
     }
     
     if(needsUpdate){
-        Potree.updatePointClouds(pointclouds,  camera, viewport.resolution );  //最好只更新pick的范围的resolution
+         
+        if(window.notViewOffset){ 
+            Potree.updatePointClouds(pointclouds,  camera, viewport.resolution );  
+        }else{
+            //尽量减少点云加载的范围,集中在pick的空间。但似乎感觉这部分空间没加载到最密
+            let viewWidth = 100//viewer.magnifier ? viewer.magnifier.viewport.resolution.x : 200
+            let camera_ = camera.clone()
+            camera_.setViewOffset( viewport.resolution.x, viewport.resolution.y,   pickParams.x-viewWidth/2, pickParams.y-viewWidth/2,    viewWidth, viewWidth );
+            Potree.updatePointClouds(pointclouds,  camera_, viewport.resolution );   
+        
+        } 
+        
     }
     //------------------------------------------------
     
     
+    
+
     let allPointclouds = [] 
     for(let pointcloud of pointclouds){ 
         
@@ -358,7 +371,7 @@ Utils.getMousePointCloudIntersection = function(viewport, mouse, pointer, camera
         pointclouds.forEach(e=>{
             if(e.visible){
                 e.material.pointSizeType = sizeType
-                e.changePointSize(size.get(e))
+                //e.changePointSize(size.get(e))
             }
             e.visible = visiMap.get(e)  
         })
@@ -1303,41 +1316,41 @@ Potree.updateVisibility = function(pointclouds, camera, areaSize){
          
         //outside不做处理。因为node必须完全在clipBox内才能完全隐藏,而这里的intersect只能识别出部分在clipBox内。因而只能说明不在任意一个box内绝对可见,没有意义,这里需要找出不可见的。
          
-         
-        let prism = pointcloud.material.activeAttributeName == 'prismHeight' && pointcloud.material.prisms && pointcloud.material.prisms.find(e=>e.computing)
-        if(prism){ 
-            let bound = box.clone().applyMatrix4(pointcloud.matrixWorld)
-            if(bound.intersectsBox(prism.prismBound)){
-                /* //node box是否包含points中的一个点
-                let box2 = new THREE.Box2().copy(box)
-                let points2d = prisms.points.map(e=>new THREE.Vector2().copy(e).applyMatrix3(pcWorldInvM3))
-                let intersect = points2d.some(e=>{ 
-                    return box2.containsPoint(e)
-                })   
-                
-                if(!intersect){
-                    //或者多边形中是否包含node box中的一个点
-                    intersect = [ 
-                        new THREE.Vector2(box.min.x, box.min.y),
-                        new THREE.Vector2(box.max.x, box.max.y),
-                        new THREE.Vector2(box.min.x, box.max.y),
-                        new THREE.Vector2(box.max.x, box.min.y),
-                    ].some(e=>{ 
-                        if(math.isPointInArea(points2d, null, e) ){
-                            return true
-                        }
-                        
-                    })
-                    //z是不是在外层已经判断好了?
+        if(visible){ 
+            let prism = pointcloud.material.activeAttributeName == 'prismHeight' && pointcloud.material.prisms && pointcloud.material.prisms.find(e=>e.computing)
+            if(prism){ 
+                let bound = box.clone().applyMatrix4(pointcloud.matrixWorld)
+                if(bound.intersectsBox(prism.prismBound)){
+                    /* //node box是否包含points中的一个点
+                    let box2 = new THREE.Box2().copy(box)
+                    let points2d = prisms.points.map(e=>new THREE.Vector2().copy(e).applyMatrix3(pcWorldInvM3))
+                    let intersect = points2d.some(e=>{ 
+                        return box2.containsPoint(e)
+                    })   
+                    
                     if(!intersect){
-                        visible = false   
-                    }
-                } */
-                //会有两个互不包含点但是交叉了的情况,所以就不仔细判断了(如横竖两个矩形构成十字架)
-            }else visible = false
-           
-        }   
-         
+                        //或者多边形中是否包含node box中的一个点
+                        intersect = [ 
+                            new THREE.Vector2(box.min.x, box.min.y),
+                            new THREE.Vector2(box.max.x, box.max.y),
+                            new THREE.Vector2(box.min.x, box.max.y),
+                            new THREE.Vector2(box.max.x, box.min.y),
+                        ].some(e=>{ 
+                            if(math.isPointInArea(points2d, null, e) ){
+                                return true
+                            }
+                            
+                        })
+                        //z是不是在外层已经判断好了?
+                        if(!intersect){
+                            visible = false   
+                        }
+                    } */
+                    //会有两个互不包含点但是交叉了的情况,所以就不仔细判断了(如横竖两个矩形构成十字架)
+                }else visible = false
+               
+            }   
+        }
 
 		if (node.spacing) {
 			lowestSpacing = Math.min(lowestSpacing, node.spacing);

+ 6 - 5
src/custom/settings.js

@@ -100,11 +100,12 @@ const config = {//配置参数   不可修改
     pointDensity:{
         magnifier:{  
             maxLevelPercent: 1,
-            //pointBudget : 8*1000*1000,  //手机崩溃
+            pointBudget : 1*1000*1000,  //至少显示这么多  
+            minNodeSize : 5,  //pick时调高精度 
         }, 
         panorama:{//显示全景时的漫游。因为点只能显示1个像素的大小,所以必须很密集,但又要限制点的数量
             maxLevelPercent: 0.6,
-            pointBudget : /* 4*1000*1000// */browser.isMobile() ?  0.1*1000*1000 :  0.4*1000*1000,  //点云总最大数
+            pointBudget : /* 4*1000*1000// */browser.isMobile() ?  0.2*1000*1000 :  0.4*1000*1000,  //点云总最大数
             minNodeSize : 100,
         }, 
         
@@ -145,7 +146,7 @@ const config = {//配置参数   不可修改
         },
         screenshot:{
             maxLevelPercent: 1,  
-            pointBudget: 8*1000*1000,
+            pointBudget: browser.isMobile() ? 3.5*1000*1000 :  8*1000*1000,  //一般只有电脑需要截图,手机的加载多会崩
             minNodeSize :   40 / window.devicePixelRatio  ,  
         },
         ultraHigh:{
@@ -313,7 +314,7 @@ const config = {//配置参数   不可修改
      
     background: '#232323',
     mapBG:/* '#232323',   */  '#F5F5F5',   //地图的clearColor
-
+    pickFrontPointRatio:50,
     colors: {  //from navvis
         red:  [213,0,0],
         pink:  [197,17,98],
@@ -464,7 +465,7 @@ let settings = {//设置   可修改
     // moveToCenter:true, //针对数据集间隔很远的场景  dis>5000 容易抖动
     tiles3DMaxMemory: config.tiles3DMaxMemory,
     adsorption:false,//测量时吸附点 
-    
+    pickFrontPointRatio:config.pickFrontPointRatio, //默认pick点云时选中靠近镜头的点的偏向
     dragPolyBeyondPoint: browser.urlHasValue('dragPolyBeyondPoint'),  //ctrlPolygon是否可以拖拽到没点云的地方
 }
 

+ 9 - 2
src/custom/start.js

@@ -370,6 +370,7 @@ export function start(dom, mapDom, number ){ //t-Zvd3w0m
                 }else{
                     var cloudPath = `${Potree.settings.urls.prefix1}/${dataset.webBin}`  //webBin添加原因:每次裁剪之类的操作会换路径,因为oss文件缓存太严重,更新慢
                 }
+                //var cloudPath = `${Potree.scriptPath}/data/test/${dataset.name}/cloud.js` 
                 
                 var timeStamp = dataset.updateTime ? dataset.updateTime.replace(/[^0-9]/ig,'') : '';  //每重算一次后缀随updateTime更新一次 
                 //console.warn(dataset.name, 'timeStamp', timeStamp)
@@ -447,8 +448,14 @@ export function start(dom, mapDom, number ){ //t-Zvd3w0m
     
     
     number && Potree.loadDatasets(Potree.loadDatasetsCallback) 
-     
-     
+    /* 
+    //调试用,加载多个本地
+    Potree.loadDatasetsCallback([
+         {name:'webcloud_0',id:0, orientation:0, location:[0,0,0]},
+         {name:'webcloud_1',id:1, orientation:0.047234761795199476, location:[-0.07925513345058573,-0.0010590072536559839,-2.403613132687564]},
+         {name:'webcloud_2',id:2, orientation:-1.5299545647758208, location:[1.5603736310030292, -0.0009340812579088904, -2.4464530770974139]},
+          
+     ]) */
 
     window.testTransform = function(locationLonLat, location1, location2){
         proj4.defs("NAVVIS:test", "+proj=tmerc +ellps=WGS84 +lon_0=" + locationLonLat[0].toPrecision(15) + " +lat_0=" + locationLonLat[1].toPrecision(15));

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

@@ -615,20 +615,17 @@ export class Viewer extends ViewerBase{
                     return pointDensity
                 },
                 set: (density)=>{
-                    if(density && density != pointDensity){  
-                        let pointBudget;
-                        var config = Potree.config.pointDensity[density];
-                        
-                        /* if(this.magnifier.visible){//放大镜打开时不要切换pointBudget,否则点云会闪烁。这时使用最高密度。
-                            pointBudget = Potree.config.pointDensity['magnifier'].pointBudget
-                        }else{
-                            pointBudget = config.pointBudget
-                        } */
-                        
-                        
+                    if(density){   
+                        let config = Potree.config.pointDensity[density];
+                        let pointBudget = config.pointBudget;
+                        if(density == 'magnifier'){//尽可能不变pointBudget,否则点云可能会闪烁,因点云被释放又加载,如SS-t-7DUfWAUZ3V 
+                            pointBudget = Math.max(Potree.pointBudget,  Potree.config.pointDensity['magnifier'].pointBudget)
+                        }else if(this.magnifier.visible){//放大镜打开时要保证最低点云数量(全景模式没点)
+                            pointBudget = Math.max(pointBudget,  Potree.config.pointDensity['magnifier'].pointBudget)
+                        } 
+                         
                         viewer.setMinNodeSize(config.minNodeSize || Potree.config.minNodeSize)
-                        viewer.setPointBudget(pointBudget );
-                        //Potree.maxPointLevel = config.maxLevel
+                        viewer.setPointBudget(pointBudget ); 
                         
                         pointDensity = density
                         
@@ -3698,9 +3695,12 @@ export class Viewer extends ViewerBase{
                     
                     mapViewport.camera.zoom = oldStates.mapZoom
                     mapViewport.camera.updateProjectionMatrix()  
+                    
+                    
+                    Potree.Utils.updateVisible(viewer.mapViewer.mapLayer.sceneGroup, 'screenshot-prism', true) 
+                
                 } 
                       
-                Potree.Utils.updateVisible(viewer.mapViewer.mapLayer.sceneGroup, 'screenshot-prism', true) 
                 
                 
                 let recover = ()=>{ 

+ 3 - 3
src/navigation/FirstPersonControlsNew.js

@@ -417,7 +417,7 @@ export class FirstPersonControls extends THREE.EventDispatcher {
                     
                     
                     let slightly = this.keys.ALT.some(e => this.viewer.inputHandler.pressedKeys[e]); 
-                    slightly && (speed *= 0.1)
+                    slightly && (speed *= 0.2)
                     
                     
                     
@@ -794,9 +794,9 @@ export class FirstPersonControls extends THREE.EventDispatcher {
                     if (moveForward && moveBackward) {
                         this.translationDelta.y = 0;
                     } else if (moveForward) {
-                        this.translationDelta.y = this.currentViewport.getMoveSpeed() * (slightly ? 0.1 : 1);
+                        this.translationDelta.y = this.currentViewport.getMoveSpeed() * (slightly ? 0.2 : 1);
                     } else if (moveBackward) {
-                        this.translationDelta.y = -this.currentViewport.getMoveSpeed() * (slightly ? 0.1 : 1);
+                        this.translationDelta.y = -this.currentViewport.getMoveSpeed() * (slightly ? 0.2 : 1);
                     }
                 }