|
@@ -251,7 +251,7 @@ export class Images360 extends THREE.EventDispatcher{
|
|
|
},
|
|
|
set: (mode)=> {
|
|
|
latestRequestMode = mode
|
|
|
- //console.warn('Request setMode: ' + mode)
|
|
|
+ console.warn('Request setMode: ' + mode)
|
|
|
|
|
|
if(mode != displayMode){
|
|
|
let config = Potree.config.displayMode[mode]
|
|
@@ -313,7 +313,8 @@ export class Images360 extends THREE.EventDispatcher{
|
|
|
|
|
|
|
|
|
if(config2.showSkybox || config2.pointUsePanoTex){
|
|
|
- let wait = ()=> {
|
|
|
+ let wait = (e)=> {
|
|
|
+ if(e.pano && e.pano != this.currentPano)return//loadedDepthImg
|
|
|
setTimeout( ()=>{
|
|
|
if(latestRequestMode == mode ){
|
|
|
Potree.settings.displayMode = mode
|
|
@@ -421,7 +422,7 @@ export class Images360 extends THREE.EventDispatcher{
|
|
|
|
|
|
|
|
|
this.dispatchEvent({type:'endChangeMode',mode})
|
|
|
- //console.log('setModeSuccess: ' + mode)
|
|
|
+ console.log('setModeSuccess: ' + mode)
|
|
|
}else{
|
|
|
|
|
|
//this.dispatchEvent({type:'endChangeMode',mode})
|
|
@@ -663,7 +664,7 @@ export class Images360 extends THREE.EventDispatcher{
|
|
|
this.dispatchEvent({type:'flyToPano', toPano})
|
|
|
return done(true);
|
|
|
}
|
|
|
- if(this.latestToPano && this.latestToPano != toPano){
|
|
|
+ if(this.latestToPano && this.latestToPano != toPano){//还在飞
|
|
|
return done(false)
|
|
|
}
|
|
|
|
|
@@ -689,7 +690,8 @@ export class Images360 extends THREE.EventDispatcher{
|
|
|
|
|
|
{//不飞的话是否不要执行这段?
|
|
|
|
|
|
- let wait = ()=> {
|
|
|
+ let wait = (e)=> {
|
|
|
+ if(e.pano && this.latestToPano && e.pano != this.latestToPano.pano)return//loadedDepthImg
|
|
|
if(this.latestToPano != toPano)return Potree.Log('已经取消')//如果取消了
|
|
|
setTimeout(()=>{
|
|
|
if(this.latestToPano != toPano)return
|
|
@@ -697,7 +699,7 @@ export class Images360 extends THREE.EventDispatcher{
|
|
|
},1)
|
|
|
this.removeEventListener('loadedDepthImg', wait)
|
|
|
}
|
|
|
- if(!pano.depthTex && pano.pointcloud.hasDepthTex){ //需要用到depthTex计算neighbour
|
|
|
+ if(!pano.depthTex && pano.pointcloud.hasDepthTex){ //点云模式也要加载depthTex,因获取neighbour需要用到
|
|
|
this.addEventListener('loadedDepthImg', wait)
|
|
|
return pano.loadDepthImg()
|
|
|
}
|
|
@@ -822,7 +824,7 @@ export class Images360 extends THREE.EventDispatcher{
|
|
|
this.resetHighMap()
|
|
|
}
|
|
|
|
|
|
- this.smoothZoomTo(1, toPano.duration / 2);
|
|
|
+ this.smoothZoomTo(toPano.zoomLevel || 1, toPano.duration / 2);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -1609,7 +1611,7 @@ export class Images360 extends THREE.EventDispatcher{
|
|
|
|
|
|
if(pano0.pointcloud != pano1.pointcloud){ //距离太远的数据集,过渡会畸变。所以扩大skybox
|
|
|
let dis = pano0.position.distanceTo(pano1.position)
|
|
|
- if(dis > 100){
|
|
|
+ if(dis > 50){
|
|
|
let bound = getPanoBound(pano0).union(getPanoBound(pano1))
|
|
|
let size = bound.getSize(new THREE.Vector3)
|
|
|
let max = Math.max(size.x, size.y, size.z)
|
|
@@ -1730,7 +1732,7 @@ export class Images360 extends THREE.EventDispatcher{
|
|
|
})
|
|
|
|
|
|
//剔除那些突然间离相机很近的dir。有可能是拍摄的人、或者杆子、树
|
|
|
- const maxRatio = 8
|
|
|
+
|
|
|
/* dirs2.forEach((e,i)=>{
|
|
|
console.log(i, e.dis)
|
|
|
let smallThanBefore = ()=>{
|
|
@@ -1752,6 +1754,7 @@ export class Images360 extends THREE.EventDispatcher{
|
|
|
}
|
|
|
|
|
|
}) */
|
|
|
+ const maxRatio1 = 3 , maxRatio2 = 8 //超过maxRatio1就要加入判断,而最终结果的设限其实是maxRatio2
|
|
|
const minWidth = 0.5
|
|
|
let computeWidth = (start,end)=>{
|
|
|
start+=1 //不包含start和end
|
|
@@ -1769,21 +1772,28 @@ export class Images360 extends THREE.EventDispatcher{
|
|
|
start+=1 //不包含start和end
|
|
|
for(let m=start;m<end;m++){
|
|
|
dirs2[m].disB = dirs2[end].dis * 0.8
|
|
|
- console.log('changeDis', m, dirs2[m].disB)
|
|
|
+ //console.log('changeDis', m, dirs2[m].disB)
|
|
|
}
|
|
|
}
|
|
|
let start = -1
|
|
|
for(let i=0;i<count1;i++){//遍历时将左边dis比之小很多且宽度较小的改大
|
|
|
//console.log(i, dirs2[i].dis)
|
|
|
let j = i-1
|
|
|
- while(j>start && dirs2[i].dis / dirs2[j].dis > maxRatio){
|
|
|
- j--
|
|
|
- }
|
|
|
- let count = i-j
|
|
|
- if(count > 1 && (count == 2 || computeWidth(j,i)<minWidth)){//若只有一个不用判断宽度直接修改,count == 2 即只有一个
|
|
|
+ let ratios = 0
|
|
|
+ while(j>start && dirs2[i].dis / dirs2[j].dis > maxRatio1){
|
|
|
+ ratios += dirs2[i].dis / dirs2[j].dis
|
|
|
+ j--
|
|
|
+ }
|
|
|
+ let count = i-j-1
|
|
|
+ ratios /= count
|
|
|
+ if(count > 0 && computeWidth(j,i)< minWidth * ratios / maxRatio2 ){
|
|
|
changeDis(j,i)
|
|
|
start = i //在此之前的修改过,之后不用再判断
|
|
|
}
|
|
|
+ /* if(count > 0 && (count == 1 || computeWidth(j,i)<minWidth)){//若只有一个不用判断宽度直接修改
|
|
|
+ changeDis(j,i)
|
|
|
+ start = i //在此之前的修改过,之后不用再判断
|
|
|
+ } */
|
|
|
}
|
|
|
|
|
|
|
|
@@ -1807,14 +1817,33 @@ export class Images360 extends THREE.EventDispatcher{
|
|
|
/* let sideDis_ = [(sideDis0[0] + sideDis1[1])/2, (sideDis0[1] + sideDis1[0])/2];
|
|
|
let sideDis = [Math.min(sideDis0[0] , sideDis1[1]), Math.min(sideDis0[1] , sideDis1[0])]//
|
|
|
*/
|
|
|
-
|
|
|
+ /* let maxH = 40, minH = 2, height = pano.ceilZ - pano.floorPosition.z, minR = 0.5, maxR = 2
|
|
|
+
|
|
|
+ let r = minR + ( maxR - minR) * THREE.Math.clamp((height - minH) / (maxH - minH),0,1) //THREE.Math.smoothstep(currentDis, op.nearBound, op.farBound);
|
|
|
+
|
|
|
+ let getZ = (deg)=>{
|
|
|
+ deg *= r
|
|
|
+ deg = THREE.Math.clamp(deg, 1, 80);
|
|
|
+ return Math.tan(THREE.Math.degToRad(deg))
|
|
|
+ }
|
|
|
+ */
|
|
|
|
|
|
if(pano0.pointcloud.hasDepthTex && pano0.pointcloud.hasDepthTex){
|
|
|
let panos = [pano0,pano1]
|
|
|
let vecs = [vec.clone().negate(), vec]
|
|
|
let axis = [[-1,1],[1,-1]]
|
|
|
let dis2d = new THREE.Vector2().subVectors(pano0.position, pano1.position).length()//水平上的距离
|
|
|
- let angles = [THREE.Math.degToRad(40), THREE.Math.degToRad(70)] //正的在左边 尽量能够平分中间这段墙体
|
|
|
+
|
|
|
+ let maxDis = 50, minDis = 0.5, minR = 0.2, maxR = 1.2
|
|
|
+ let r = maxR - ( maxR - minR) * THREE.Math.clamp((dis2d - minDis) / (maxDis - minDis),0,1) //dis2d越大,角度要越小 //THREE.Math.smoothstep(currentDis, op.nearBound, op.farBound);
|
|
|
+ //console.log('dis2d',dis2d,'r',r)
|
|
|
+ let angles = [35,65].map(deg=>{ //正的在左边 尽量能够平分中间这段墙体。
|
|
|
+ let angle = THREE.Math.clamp(deg * r, 5, 80);
|
|
|
+ //console.log('angle',angle)
|
|
|
+ return THREE.Math.degToRad(angle)
|
|
|
+ })
|
|
|
+
|
|
|
+ //let angles = [THREE.Math.degToRad(40), THREE.Math.degToRad(70)]
|
|
|
axis.forEach((axis_, index0)=>{
|
|
|
let disToSides = []
|
|
|
let accordingPano = index0 == 0 ? pano0 : pano1; //根据离该点在vec方向上的距离顺序来存顶点
|
|
@@ -2610,7 +2639,7 @@ export class Images360 extends THREE.EventDispatcher{
|
|
|
|
|
|
|
|
|
zoomFovTo( fov ) { //通过fov来算zoomLevel
|
|
|
- let zoomLevel = this.baseFov / fov;
|
|
|
+ let zoomLevel = Potree.config.view.fov /* this.baseFov */ / fov;
|
|
|
this.zoomTo( zoomLevel );
|
|
|
}
|
|
|
smoothZoomTo(aimLevel, dur=0) {
|
|
@@ -2628,50 +2657,34 @@ export class Images360 extends THREE.EventDispatcher{
|
|
|
}
|
|
|
|
|
|
|
|
|
- /* zoomDefault{
|
|
|
- this.zoomTo(1, !0)
|
|
|
- }
|
|
|
- smoothZoomToDefault(e, t) {
|
|
|
- var i, n = this.zoomLevel,
|
|
|
- r = function(e) {
|
|
|
- e > 1 && (e = 1),
|
|
|
- i = n * (1 - e) + e,
|
|
|
- this.zoomTo(i, !0)
|
|
|
- }
|
|
|
- .bind(this),
|
|
|
- o = function() {
|
|
|
- this.zoomDefault(),
|
|
|
- t && window.setTimeout(t, 50)
|
|
|
- }
|
|
|
- .bind(this);
|
|
|
- transitions.start(r, e, o, null, 0, easing[settings.transition.blendEasing])
|
|
|
- } */
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
updateZoomPano() {
|
|
|
if (!this.panoRenderer.zoomPanoRenderingDisabled && Potree.settings.displayMode == 'showPanos') {
|
|
|
var currentPano = this.currentPano;
|
|
|
if (currentPano) {
|
|
|
- var activationThreshold = Potree.settings.navTileClass == '2k' && Potree.settings.tileClass == '4k' ? 1.7 : Potree.settings.zoom.activationThreshold//1.1
|
|
|
- var t = this.zoomLevel > activationThreshold,
|
|
|
+
|
|
|
+ let levelThreshold1 = Potree.settings.navTileClass == '1k' ? 1.3 : 1.7 , levelThreshold2 = 2
|
|
|
+
|
|
|
+ var t = this.zoomLevel > levelThreshold1,
|
|
|
n = !(this.flying && this.nextPano && this.nextPano !== this.currentPano),
|
|
|
r = t && n;
|
|
|
this.tileDownloader.tilePrioritizer.setZoomingActive(r);
|
|
|
this.panoRenderer.setZoomingActive(r, currentPano, !0);
|
|
|
|
|
|
- var o = (pano, zoomedFlag)=>{
|
|
|
+ var o = (pano, ifZoom)=>{
|
|
|
this.panoRenderer.resetRenderStatus(pano.id, !1, !0, this.qualityManager.getMaxNavPanoSize());
|
|
|
this.panoRenderer.clearAllQueuedUploadsForPano(pano.id);
|
|
|
this.panoRenderer.renderPanoTiles(pano.id, null, !1, !1);
|
|
|
- pano.setZoomed(zoomedFlag);
|
|
|
+ pano.setZoomed(ifZoom);
|
|
|
}
|
|
|
|
|
|
|
|
|
- if (r && (!currentPano.zoomed || this.qualityManager.zoomLevelResolution && this.qualityManager.zoomLevelResolution != '4k')) {
|
|
|
+ if (r && (!currentPano.zoomed || this.qualityManager.zoomLevelResolution && this.qualityManager.zoomLevelResolution != '4k')) {//needZoom
|
|
|
currentPano.zoomed || o(currentPano, !0);
|
|
|
|
|
|
- if(Potree.settings.navTileClass == '1k' && Potree.settings.tileClass != '1k' && this.zoomLevel < 2){
|
|
|
+ if(Potree.settings.navTileClass == '1k' && Potree.settings.tileClass != '1k' && this.zoomLevel < levelThreshold2){
|
|
|
this.panoRenderer.enableHighQuality( function() {//开启2k
|
|
|
if(Potree.settings.tileClass != '4k') o(currentPano, !0);
|
|
|
}.bind(this));
|
|
@@ -2687,23 +2700,23 @@ export class Images360 extends THREE.EventDispatcher{
|
|
|
|
|
|
|
|
|
|
|
|
- if(r && Potree.settings.navTileClass == '1k' && Potree.settings.tileClass == '4k' ){ //目前只有手机端navTileClass == '1k'
|
|
|
+ if(r && Potree.settings.navTileClass == '1k' && Potree.settings.tileClass == '4k' ){ //目前只有手机端navTileClass == '1k' (分三个梯度)
|
|
|
var change = (zoomedFlag)=>{
|
|
|
this.qualityManager.updateMaximums()//更新maxZoomPanoSize
|
|
|
this.panoRenderer.setupZoomRenderTarget() //更新renderTarget
|
|
|
//currentPano.setZoomed(t);//更新uniforms贴图
|
|
|
}
|
|
|
- this.qualityManager.zoomLevelResolution = this.zoomLevel >= 2 ? '4k' : this.zoomLevel > 1.1 ? '2k' : '1k'
|
|
|
+ this.qualityManager.zoomLevelResolution = this.zoomLevel >= levelThreshold2 ? '4k' : this.zoomLevel > levelThreshold1 ? '2k' : '1k'
|
|
|
|
|
|
- if(this.oldZoomLevel < 2 && this.zoomLevel >= 2){//1k/2k-4k
|
|
|
+ if(this.oldZoomLevel < levelThreshold2 && this.zoomLevel >= levelThreshold2){//1k/2k-4k
|
|
|
change()
|
|
|
o(currentPano, t)
|
|
|
- }else if(this.oldZoomLevel <= Potree.settings.zoom.activationThreshold && this.zoomLevel > Potree.settings.zoom.activationThreshold){//1k-2k
|
|
|
+ }else if(this.oldZoomLevel <= levelThreshold1 && this.zoomLevel > levelThreshold1){//1k-2k
|
|
|
change()
|
|
|
- }else if(this.oldZoomLevel > 2 && this.zoomLevel <= 2){//4k-2k/1k
|
|
|
+ }else if(this.oldZoomLevel > levelThreshold2 && this.zoomLevel <= levelThreshold2){//4k-2k/1k
|
|
|
change()
|
|
|
o(currentPano, t)
|
|
|
- }else if(this.oldZoomLevel > Potree.settings.zoom.activationThreshold && this.zoomLevel <= Potree.settings.zoom.activationThreshold){//2k-1k
|
|
|
+ }else if(this.oldZoomLevel > levelThreshold1 && this.zoomLevel <= levelThreshold1){//2k-1k
|
|
|
change()
|
|
|
}
|
|
|
this.oldZoomLevel = this.zoomLevel
|
|
@@ -2741,7 +2754,7 @@ export class Images360 extends THREE.EventDispatcher{
|
|
|
|
|
|
if(Potree.settings.isTest){
|
|
|
var colorHue = Math.random();
|
|
|
- tile.material.color = (new THREE.Color()).setHSL(colorHue, 0.5, 0.9)
|
|
|
+ tile.material.color = (new THREE.Color()).setHSL(colorHue, 0.6, 0.7)
|
|
|
}
|
|
|
|
|
|
tile.visible = false
|
|
@@ -2782,7 +2795,11 @@ export class Images360 extends THREE.EventDispatcher{
|
|
|
cube.name = 'highMapCube'
|
|
|
this.highMapCube = cube
|
|
|
viewer.scene.scene.add(cube)
|
|
|
- //cube.scale.set(0.01,0.01,0.01)
|
|
|
+
|
|
|
+ {
|
|
|
+ let s = 0.1
|
|
|
+ cube.scale.set(s,s,s)
|
|
|
+ }//注:由于原本的mesh上加了深度贴图,可能距离镜头比这里的近。凡是在cube以内的部分都会挡住cube导致模糊。但是应该不常见吧。
|
|
|
|
|
|
this.highMapCube.visible = false;
|
|
|
viewer.setObjectLayers(this.highMapCube, 'sceneObjects'/* 'skybox' */) //如果是skybox层,点云可见时会被遮住,depthTest为false呢? 但不会遮住场景物体
|
|
@@ -2859,6 +2876,7 @@ export class Images360 extends THREE.EventDispatcher{
|
|
|
if(!this.highMapCube) return
|
|
|
//console.warn('showHighMap')
|
|
|
this.highMapCube.visible = true;
|
|
|
+
|
|
|
}
|
|
|
hideHighMap(){
|
|
|
if(!this.highMapCube) return
|
|
@@ -2881,10 +2899,7 @@ export class Images360 extends THREE.EventDispatcher{
|
|
|
//}
|
|
|
let pano = new Panorama( info, this );
|
|
|
|
|
|
- /* pano.mesh.layers.set(Potree.config.renderLayers.marker)
|
|
|
- pano.marker.layers.set(Potree.config.renderLayers.marker) */
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
pano.addEventListener('dispose',(e)=>{
|
|
|
if(this.closestPano == pano) this.closestPano = null
|
|
|
})
|
|
@@ -2910,29 +2925,12 @@ export class Images360 extends THREE.EventDispatcher{
|
|
|
|
|
|
this.tileDownloader.setPanoData(this.panos, [] /* , Potree.settings.number */);
|
|
|
|
|
|
- {
|
|
|
- /* var panosBound = new THREE.Box3
|
|
|
- this.panos.forEach(pano=>{
|
|
|
- panosBound.expandByPoint(pano.position)
|
|
|
- })
|
|
|
- let center = panosBound.getCenter(new THREE.Vector3)
|
|
|
- let minBound = (new THREE.Box3()).setFromCenterAndSize(center, new THREE.Vector3(1,1,1))
|
|
|
- panosBound.union(minBound)
|
|
|
-
|
|
|
- this.bound = {
|
|
|
- bounding:panosBound,
|
|
|
- size: panosBound.getSize(new THREE.Vector3),
|
|
|
- center,
|
|
|
- } */
|
|
|
-
|
|
|
+ {
|
|
|
let minSize = new THREE.Vector3(1,1,1)
|
|
|
this.bound = math.getBoundByPoints(this.panos.map(e=>e.position), minSize)
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
viewer.scene.pointclouds.forEach(pointcloud=>pointcloud.getPanosBound())
|
|
|
-
|
|
|
|
|
|
-
|
|
|
}
|
|
|
|
|
|
|
|
@@ -3010,7 +3008,7 @@ Images360.prototype.checkAndWaitForPanoLoad = function() {
|
|
|
throw msg;
|
|
|
}
|
|
|
}
|
|
|
-}()
|
|
|
+}()//加载全景图的流程:请求下载当前点的最低分辨率图(不过有可能已经下载了),并且请求uploadTile渲染当前漫游点,若tile都upload完(先6个)会发送消息,LoadComplete 从而回调成功。
|
|
|
|
|
|
|
|
|
|