|
@@ -1188,74 +1188,74 @@ export class Images360 extends THREE.EventDispatcher{
|
|
|
fitPanoTowardPoint(o){ //寻找最适合的点位
|
|
|
var point = o.point, //相机最佳位置
|
|
|
target = o.target || o.point, //实际要看的位置
|
|
|
- require = o.require || [],
|
|
|
- rank = o.rank || [],
|
|
|
- force = o.force,
|
|
|
- getAll = o.getAll,
|
|
|
+ require = o.require || [],
|
|
|
+ rank = o.rank || [],
|
|
|
+ force = o.force,
|
|
|
+ getAll = o.getAll,
|
|
|
bestDistance = o.bestDistance || 0,
|
|
|
sameFloor = o.sameFloor,
|
|
|
maxDis = o.maxDis,
|
|
|
- dir = o.dir
|
|
|
+ dir = o.dir;
|
|
|
|
|
|
- let camera = viewer.scene.getActiveCamera()
|
|
|
+ let camera = viewer.scene.getActiveCamera();
|
|
|
if(target && !dir){
|
|
|
- dir = new THREE.Vector3().subVectors(target,point).normalize()
|
|
|
+ dir = new Vector3().subVectors(target,point).normalize();
|
|
|
}
|
|
|
- let atFloor = sameFloor && viewer.modules.SiteModel.pointInWhichEntity(point, 'floor')
|
|
|
+ let atFloor = sameFloor && viewer.modules.SiteModel.pointInWhichEntity(point, 'floor');
|
|
|
|
|
|
//if(o.floor)require.push(Panorama.filters.atFloor(o.floor))
|
|
|
|
|
|
- let checkIntersect = o.checkIntersect
|
|
|
+ let checkIntersect = o.checkIntersect;
|
|
|
let base = Math.max(300, viewer.bound.boundSize.length()*3);
|
|
|
|
|
|
|
|
|
if(o.boundSphere){//只接受boundSphere
|
|
|
- let aspect = 1//size.x / size.y
|
|
|
- let dis
|
|
|
+ let aspect = 1;//size.x / size.y
|
|
|
+ let dis;
|
|
|
if(camera.aspect > aspect){//视野更宽则用bound的纵向来决定
|
|
|
- dis = /* size.y */o.boundSphere.radius/* / 2 *// THREE.Math.degToRad(camera.fov / 2)
|
|
|
- }else{
|
|
|
+ dis = /* size.y */o.boundSphere.radius/* / 2 *// MathUtils.degToRad(camera.fov / 2);
|
|
|
+ }else {
|
|
|
let hfov = cameraLight.getHFOVForCamera(camera , true );
|
|
|
- dis = /* size.x */ o.boundSphere.radius /* / 2 */ / (hfov / 2)
|
|
|
+ dis = /* size.x */ o.boundSphere.radius /* / 2 */ / (hfov / 2);
|
|
|
}
|
|
|
- bestDistance = dis//*0.8
|
|
|
+ bestDistance = dis;//*0.8
|
|
|
|
|
|
}
|
|
|
- let disSquareMap = new Map()
|
|
|
+ let disSquareMap = new Map();
|
|
|
|
|
|
- let bestDisSquared = bestDistance * bestDistance
|
|
|
- let maxDisSquared = maxDis && (maxDis * maxDis)
|
|
|
+ let bestDisSquared = bestDistance * bestDistance;
|
|
|
+ let maxDisSquared = maxDis && (maxDis * maxDis);
|
|
|
this.panos.forEach(pano=>{
|
|
|
let dis2 = pano.position.distanceToSquared(target); //距离目标点
|
|
|
- disSquareMap.set(pano, dis2)
|
|
|
- })
|
|
|
- let panos = this.panos.sort((p1,p2)=>{return disSquareMap.get(p1)-disSquareMap.get(p2)})
|
|
|
+ disSquareMap.set(pano, dis2);
|
|
|
+ });
|
|
|
+ let panos = this.panos.sort((p1,p2)=>{return disSquareMap.get(p1)-disSquareMap.get(p2)});
|
|
|
|
|
|
|
|
|
if(maxDisSquared){//热点超过最大距离不可见的
|
|
|
- let panos2 = [], pano, i=0
|
|
|
+ let panos2 = [], pano, i=0;
|
|
|
while(pano = panos[i], disSquareMap.get(pano) < maxDisSquared){
|
|
|
- panos2.push(pano)
|
|
|
+ panos2.push(pano);
|
|
|
i++;
|
|
|
}
|
|
|
if(panos2.length == 0)return {pano, msg:'tooFar'} //全部都大于maxDis, 就返回最近的
|
|
|
- panos = panos2
|
|
|
+ panos = panos2;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
rank.push((pano)=>{
|
|
|
let dis1 = Math.abs(pano.position.distanceToSquared(point) - bestDisSquared); //距离最佳位置
|
|
|
- disSquareMap.set(pano, dis1)
|
|
|
+ disSquareMap.set(pano, dis1);
|
|
|
if(!target){
|
|
|
return -dis1
|
|
|
- }else{
|
|
|
- let dis2 = disSquareMap.get(pano)
|
|
|
- let vec2 = new THREE.Vector3().subVectors(target,pano.position).normalize()
|
|
|
- let cos = dir.dot(vec2)
|
|
|
+ }else {
|
|
|
+ let dis2 = disSquareMap.get(pano);
|
|
|
+ let vec2 = new Vector3().subVectors(target,pano.position).normalize();
|
|
|
+ let cos = dir.dot(vec2);
|
|
|
//let result = (- dis1 - Math.pow(dis2 , 1.5)) / (cos + 2) // cos+2是为了调整到1-3,
|
|
|
|
|
|
- let result = (dis1 + dis2*0.3) * ( -1 + cos*0.9 ) //尽量贴近最佳位置的角度, 或贴近相机原来的角度 。尽量靠近最佳观测点,并且优先选择靠近目标点的位置.(注意cos的乘数不能太接近1,否则容易只考虑角度)
|
|
|
+ let result = (dis1 + dis2*0.3) * ( -1 + cos*0.9 ); //尽量贴近最佳位置的角度, 或贴近相机原来的角度 。尽量靠近最佳观测点,并且优先选择靠近目标点的位置.(注意cos的乘数不能太接近1,否则容易只考虑角度)
|
|
|
//Potree.Log(pano.id, dis1, dis2, cos, result,{font:{toFixed:2,fontSize:10}})
|
|
|
|
|
|
return result
|
|
@@ -1264,40 +1264,54 @@ export class Images360 extends THREE.EventDispatcher{
|
|
|
//注:热点最好加上法线信息,这样可以多加一个限制,尽量顺着热点像展示的方向。
|
|
|
},
|
|
|
(pano)=>{
|
|
|
- let score = 0
|
|
|
+ let score = 0;
|
|
|
if(pano.depthTex && checkIntersect){
|
|
|
- let intersect = !!viewer.ifPointBlockedByIntersect(target, pano.id, true) //viewer.inputHandler.ifBlockedByIntersect({pos3d:target, margin:0.1, cameraPos:pano})
|
|
|
+ let intersect = !!viewer.ifPointBlockedByIntersect(target, pano.id, true); //viewer.inputHandler.ifBlockedByIntersect({pos3d:target, margin:0.1, cameraPos:pano})
|
|
|
if(intersect){
|
|
|
- score = 0
|
|
|
+ score = 0;
|
|
|
}else {
|
|
|
- score = base * 2
|
|
|
+ score = base * 2;
|
|
|
}
|
|
|
- }else{
|
|
|
- score = base * 1.5 //没加载好的话,不管了 , 几乎当做无遮挡,否则容易到不了最近点
|
|
|
+ }else {
|
|
|
+ score = base * 1.5; //没加载好的话,不管了 , 几乎当做无遮挡,否则容易到不了最近点
|
|
|
}
|
|
|
return score
|
|
|
}
|
|
|
|
|
|
- )
|
|
|
-
|
|
|
-
|
|
|
- var g = Common.sortByScore(panos, require, rank);
|
|
|
- console.log(g)
|
|
|
+ );
|
|
|
|
|
|
-
|
|
|
- let pano = g && g.length > 0 && g[0].item
|
|
|
+
|
|
|
+ var g = Common$1.sortByScore(panos, require, rank);
|
|
|
+ //console.log(g)
|
|
|
+
|
|
|
+ /* let result1 = g && g.slice(0, 10)
|
|
|
+ if(result1){
|
|
|
+ g = Common.sortByScore(result1, [], [(e)=>{//避免遮挡
|
|
|
+ let pano = e.item;
|
|
|
+ let score = 0, log = ''
|
|
|
+
|
|
|
+ if(atFloor && atFloor.panos.includes(pano)){//如果不在任何一楼呢?
|
|
|
+ score += 600, log+='atFloor'
|
|
|
+ }
|
|
|
+ return {score, log}
|
|
|
+ }]);
|
|
|
+ if(g){
|
|
|
+ g.forEach(e=>{e.item = e.item.item})
|
|
|
+ }
|
|
|
+ console.log(g)
|
|
|
+ } */
|
|
|
+ let pano = g && g.length > 0 && g[0].item;
|
|
|
if(pano && checkIntersect){
|
|
|
- let intersect = !!viewer.ifPointBlockedByIntersect(target, pano.id, true)
|
|
|
+ let intersect = !!viewer.ifPointBlockedByIntersect(target, pano.id, true);
|
|
|
|
|
|
if(intersect){
|
|
|
return {pano, msg : 'sheltered'}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //if(getAll)return g;
|
|
|
- return pano
|
|
|
+ //if(getAll)return g;
|
|
|
+ return pano
|
|
|
|
|
|
-
|
|
|
//注:深度图有的位置会不准确,以至于会算出错误的遮挡、选择错误的pano,解决办法只能是移动下热点到更好的位置
|
|
|
}
|
|
|
|