xzw 2 år sedan
förälder
incheckning
b8227721d0

+ 24 - 10
src/ExtendPointCloudOctree.js

@@ -212,12 +212,16 @@ export class ExtendPointCloudOctree extends PointCloudOctree{
 		viewer.addTimeMark('pick','start')
 
 		let getVal = (a, b) => a != void 0 ? a : b;
-        
-       
+         
       
         let pickWindowSize_ = THREE.Math.clamp( Math.round((1.1-this.maxLevel/this.nodeMaxLevel)*80),  5, 100)
 		let pickWindowSize = getVal(params.pickWindowSize, pickWindowSize_    ); /* 65 */ //拾取像素边长,越小越精准,但点云稀疏的话可能容易出现识别不到的情况。 另外左下侧会有缝隙无法识别到,缝隙大小和这个值有关//突然发现pickWindowSize在一百以内的变化对pick费时影响甚微,1和100差1毫秒不到,但400时会多4毫秒
             
+        if(camera.type == 'OrthographicCamera'){
+            var cameraDir = new THREE.Vector3(0,0,-1).applyQuaternion(camera.quaternion) 
+            pickWindowSize *= 4  //pointsize比较大时截取太小会没多少点可以选
+        }  
+            
 		let pickOutsideClipRegion = getVal(params.pickOutsideClipRegion, false);
 
 		let size = viewport ? viewport.resolution : renderer.getSize(new THREE.Vector2());
@@ -446,7 +450,12 @@ export class ExtendPointCloudOctree extends PointCloudOctree{
                     
                     //add
                     if(!params.all){
-                        hit.disSquare = camera.position.distanceToSquared(position)
+                        if(camera.type == 'OrthographicCamera'){
+                            let vec = new THREE.Vector3().subVectors(position, camera.position)
+                            hit.disSquare = vec.projectOnVector( cameraDir ).lengthSq();  //只考虑到相机的垂直距离 
+                        }else{ 
+                            hit.disSquare = camera.position.distanceToSquared(position)
+                        }  
                     }
 				} else if (attributeName === 'indices') {
 
@@ -488,13 +497,18 @@ export class ExtendPointCloudOctree extends PointCloudOctree{
 				return null;
 			}else{
                 //为了防止透过点云缝隙,选到后排的点云,将选取的位置离相机的距离考虑进去。倾向选择离相机近、且离鼠标位置近的点。(否则按照原方案只选离鼠标位置最近的,可能从高楼不小心走到下层,导航选点也是)
-                let sorted1 = hits.sort( (a, b) => a.disSquare - b.disSquare  );
+                let sorted1 = hits.sort( (a, b) => a.disSquare - b.disSquare  ).slice();
                 
                 let nearest = sorted1[0]  //return nearest.point;  //直接用最近点 在点云稀疏时不太跟手,如地面上,最近点往往在鼠标下方
+                 
+                let r  
+                if(camera.type != 'OrthographicCamera'){ 
+                    let ratio = 0.1 //系数越大越不跟手,但更容易pick近处的。 (当pick的点较远时,获取框内的点距离可能差别很大,就要所以除以disSquare)
+                    r = rSquare/Math.max(nearest.disSquare,0.001) * ratio
+                }else{ 
+                    r = 10      //大一点才能pick到表面的点,但太大了有时不跟手,且总容易吸附到近点
+                }
                 
-                
-                let ratio = 0.1 //系数越大越不跟手,但更容易pick近处的。 (当pick的点较远时,获取框内的点距离可能差别很大,就要所以除以disSquare)
-                let r = rSquare/Math.max(nearest.disSquare,0.001) * ratio
                 hits.forEach( hit=>{
                     let disDiff = hit.disSquare - nearest.disSquare //和最近点的偏差 
                     hit.disDiff = disDiff 
@@ -503,10 +517,10 @@ export class ExtendPointCloudOctree extends PointCloudOctree{
                 
                 let sorted2 = hits.sort( (a, b) => b.score - a.score  );
                    
-                //console.log(sorted2, 'nearest',nearest) 
+                //console.log(sorted2[0].point.position.z ) 
                 return sorted2[0].point; 
                   
-				//return hits[0].point;
+				 
 			}
 		}
 
@@ -555,7 +569,7 @@ export class ExtendPointCloudOctree extends PointCloudOctree{
             } 
             
         }  
-        //console.log('changePointSize:'  + this.dataset_id + ' , num: ' + (num && num.toPrecision(3)) + ' , size: ' + size.toPrecision(3),  'nodeMaxLevel', nodeMaxLevel.toPrecision(3), 'testMaxNodeCount',viewer.testMaxNodeCount     /* this.material.spacing */)
+        //console.log('changePointSize:'  + this.dataset_id + ' , num: ' + (num && num.toPrecision(3)) + ' , size: ' + size.toPrecision(3),  'nodeMaxLevel', nodeMaxLevel.toPrecision(3), 'testMaxNodeCount',this.testMaxNodeCount     /* this.material.spacing */)
         if(size){
             if(Potree.settings.sortCloudMat){//被废弃,不给material分组了
                 this.size = size;this.material.size = size

+ 12 - 8
src/custom/objects/Magnifier.js

@@ -3,7 +3,7 @@ import * as THREE from "../../../libs/three.js/build/three.module.js";
 import math from '../utils/math.js'
 import browser from '../utils/browser.js'
 import Viewport from '../viewer/Viewport.js'
- 
+import {ExtendView} from "../../viewer/ExtendView.js"; 
 const texLoader = new THREE.TextureLoader() 
 const circleGeo = new THREE.CircleGeometry(1.45,100);
 const sphereGeo = new THREE.SphereBufferGeometry(0.018,10,10);
@@ -19,7 +19,7 @@ let maxPX = 1366*1024 //ipad pro.  大于这个分辨率的就直接用devicePix
 const width2dPX = Math.round(window.devicePixelRatio >= 2 ? ( window.screen.width * window.screen.height >= maxPX ? window.devicePixelRatio/1.2 : window.devicePixelRatio/1.5)*w : w)  //触屏或高分辨率的可能要放大些。但在手机上不能太大
 //console.log('width2dPX', width2dPX)
 
-
+const orthoView = new ExtendView();
 
 export default class Magnifier extends THREE.Object3D {//放大镜or望远镜
 	constructor (viewer) {
@@ -242,19 +242,23 @@ export default class Magnifier extends THREE.Object3D {//放大镜or望远镜
         if(playerCamera.type == 'OrthographicCamera'){
             
             var finalDisToAim = 2
-            
-        }else{ 
-            
+             
+        }else{  
             var finalDisToAim =  dis>magDisMin ? dis > fareast ? magDisMax : (dis-magDisMin) / (fareast-magDisMin) * (magDisMax-magDisMin) + magDisMin :  dis / 2;    //dis>magDistance_ ? magDistance_ : dis / 2;
-         
+            
         }
-        
+         
         this.camera.position.copy(aimPos).add(dirToCamera.multiplyScalar(finalDisToAim))
         this.camera.lookAt(aimPos)
         this.camera.fov = playerCamera.type == 'OrthographicCamera' ? 30 : playerCamera.fov / 2
         this.camera.updateProjectionMatrix()
         
-        
+        if(playerCamera.type == 'OrthographicCamera'){
+            orthoView.position.copy(this.camera.position)
+            orthoView.yaw = viewer.mainViewport.view.yaw;
+            orthoView.pitch = viewer.mainViewport.view.pitch;
+            orthoView.applyToCamera(this.camera)
+        }
 
          
         //自身位置 

+ 2 - 4
src/custom/objects/tool/ctrlPolygon.js

@@ -204,9 +204,7 @@ export class ctrlPolygon extends THREE.Object3D {
             viewer.dispatchEvent({type:'dragMarker', object:this})
             return true
         }
-        
-        
-        
+         
         
     };
     
@@ -216,7 +214,7 @@ export class ctrlPolygon extends THREE.Object3D {
     
     
     dragChange(intersectPos, i, atMap){
-        
+         
         let len = this.markers.length 
         let oldPoint = this.points[i]; 
         if(atMap){

+ 1 - 1
src/viewer/ExtendView.js

@@ -316,7 +316,7 @@ class ExtendView extends View {
         let camera = info.camera || viewport.camera
         
         let startZoom = camera.zoom 
-        let endPosition = info.endPosition 
+        let endPosition = info.endPosition || info.position
         let boundSize = info.boundSize
         let endZoom = info.endZoom
         let margin = info.margin || {x:0,y:0}/* 200 */ //像素

+ 2 - 2
src/viewer/NavigationCube.js

@@ -878,8 +878,8 @@ class NavCubeViewer extends ViewerBase{
                 startCamera = viewer.scene.cameraO
                 endCamera = viewer.scene.cameraP 
             }else{
-                 
-                view.setView(viewer.mainViewport,  { position:view.position,
+                console.log('switchView2', 'not ortho')
+                view.setView({ position:viewInfo.position,
                     endPitch: viewInfo.pitch, endYaw: viewInfo.yaw ,   
                     startCamera,  endCamera,            
                     callback:()=>{