xzw 1 год назад
Родитель
Сommit
082bfe94c5
2 измененных файлов с 104 добавлено и 6 удалено
  1. 99 1
      scene/public/static/js/main_2020_show.js
  2. 5 5
      scene/public/static/js/manage.js

+ 99 - 1
scene/public/static/js/main_2020_show.js

@@ -58825,5 +58825,103 @@ window.Modernizr = function(n, e, t) {
 }, {}, [116]);
 
 
-
+class PanTransGuide{    
+    constructor(player){
+        this.player = player
+        this.currentIndex = 0
+        this.getNodes()
+        
+       
+    }
+    getNodes(){
+        this.nodes = []
+        let path = this.player.path
+        let last
+        this.player.model.heroLocations.forEach((e,i)=>{
+             
+            if(i>0){   
+                path.setWarpDestination(e)
+                path.setWarpDestPano()
+                path.nodes = path.findShortestPath(path.getHeroPano(last), path.warpDestPano)
+                
+                let wholeDis = 0, disSections = []
+                path.nodes.forEach((cur,i)=>{
+                    if(i==0)return
+                    let prePano = this.player.model.panos.get(path.nodes[i-1])
+                    let curPano = this.player.model.panos.get(cur)
+                    let dis = prePano.position.distanceTo(curPano.position)
+                    disSections.push(dis)
+                    wholeDis += dis
+                },0)
+                
+                let quaStart = last.quaternion
+                let quaEnd = e.quaternion
+                
+                path.nodes.forEach((panoId,j)=>{ 
+                    if(j == 0){
+                        if(path.nodes.length == 1)return this.nodes.push({panoId,quaternion:quaEnd})//原地旋转
+                        if(i > 0)return //和上一段末尾重复
+                        return this.nodes.push({panoId,quaternion:quaStart})
+                    }
+                    let r = disSections[j-1] / wholeDis
+                    let quaternion = quaStart.clone()
+                    lerp.quaternion(quaternion, quaEnd)(r) 
+                    this.nodes.push({panoId, quaternion})
+                })
+            }
+            
+            last = e
+        })
+          
+        //path.setWarpDestinationByHeroIndex()
+        
+         
+    }
+    
+    go(axis){
+        if(this.player.flying)return
+        let aimNode
+        let cur = this.nodes[this.currentIndex]
+        if(cur.panoId != this.player.currentPano.id){//已走动
+            let curs = this.nodes.filter(e=>e.panoId == this.player.currentPano)   
+            curs.sort((a,b)=>{      //如果有多个,找到和currentIndex最接近的,可能是刚走过的
+                let indexA = this.nodes.indexOf(a)
+                let indexB = this.nodes.indexOf(b)
+                return Math.abs(indexA - this.currentIndex) < Math.abs(indexB - this.currentIndex)
+            })
+            cur = curs[0]
+            if(!cur){//不在道上 . 找离当前位置最近的node
+                let disMap = new Map
+                this.nodes.forEach(e=>{
+                    disMap.set(e,player.currentPano.position.distanceToSquared(this.player.model.panos.get(e.panoId).position))
+                })
+                let sorted = this.nodes.slice().sort((a,b)=>{     
+                    return disMap.get(a) - disMap.get(b)
+                })
+              
+                this.currentIndex = this.nodes.indexOf(sorted[0])//next
+                if(axis == 'prev'){
+                    this.moveIndex(-1) 
+                }
+                aimNode = this.nodes[this.currentIndex]
+            }
+        }
+        if(!aimNode){
+            this.moveIndex(axis == 'prev' ? -1 : 1)
+            aimNode = this.nodes[this.currentIndex]
+        }
+        
+        this.player.flyToPano({pano: this.player.model.panos.get(aimNode.panoId),quaternion:aimNode.quaternion})
+       
+    }
+    
+     
+    moveIndex(step){
+        this.currentIndex += step
+        this.currentIndex %= this.nodes.length
+        return this.currentIndex
+    }
+    
+  
+}
  

+ 5 - 5
scene/public/static/js/manage.js

@@ -2050,14 +2050,14 @@ function initByTHREE(THREE){
          
         
         {//ui控制显示
-            let changeShow = (e)=>{ 
-                hide = !e.show 
+            let changeShow = (show)=>{ 
+                hide = !show 
                 e.show && init()
-                gradualShow ? updateArrow() : (arrows.visible = e.show)
+                gradualShow ? updateArrow() : (arrows.visible = !hide)
             }
             
-            player.on('changeArrowShow',changeShow) 
-            changeShow({show:!hide})
+            player.on('changeArrowShow', changeShow) 
+            changeShow({ !hide})
         }
         
     }