|
@@ -212,12 +212,16 @@ export class ExtendPointCloudOctree extends PointCloudOctree{
|
|
viewer.addTimeMark('pick','start')
|
|
viewer.addTimeMark('pick','start')
|
|
|
|
|
|
let getVal = (a, b) => a != void 0 ? a : b;
|
|
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_ = 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毫秒
|
|
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 pickOutsideClipRegion = getVal(params.pickOutsideClipRegion, false);
|
|
|
|
|
|
let size = viewport ? viewport.resolution : renderer.getSize(new THREE.Vector2());
|
|
let size = viewport ? viewport.resolution : renderer.getSize(new THREE.Vector2());
|
|
@@ -446,7 +450,12 @@ export class ExtendPointCloudOctree extends PointCloudOctree{
|
|
|
|
|
|
//add
|
|
//add
|
|
if(!params.all){
|
|
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') {
|
|
} else if (attributeName === 'indices') {
|
|
|
|
|
|
@@ -488,13 +497,18 @@ export class ExtendPointCloudOctree extends PointCloudOctree{
|
|
return null;
|
|
return null;
|
|
}else{
|
|
}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 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=>{
|
|
hits.forEach( hit=>{
|
|
let disDiff = hit.disSquare - nearest.disSquare //和最近点的偏差
|
|
let disDiff = hit.disSquare - nearest.disSquare //和最近点的偏差
|
|
hit.disDiff = disDiff
|
|
hit.disDiff = disDiff
|
|
@@ -503,10 +517,10 @@ export class ExtendPointCloudOctree extends PointCloudOctree{
|
|
|
|
|
|
let sorted2 = hits.sort( (a, b) => b.score - a.score );
|
|
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 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(size){
|
|
if(Potree.settings.sortCloudMat){//被废弃,不给material分组了
|
|
if(Potree.settings.sortCloudMat){//被废弃,不给material分组了
|
|
this.size = size;this.material.size = size
|
|
this.size = size;this.material.size = size
|