xzw 10 ماه پیش
والد
کامیت
a64b8ae10a
1فایلهای تغییر یافته به همراه75 افزوده شده و 38 حذف شده
  1. 75 38
      scene/public/static/js/main_2020_show.js

+ 75 - 38
scene/public/static/js/main_2020_show.js

@@ -4901,7 +4901,7 @@ window.Modernizr = function(n, e, t) {
             
             
             
-            n.prototype.findNearestItem = function(endToStart=true, searchEvery){//找到离currentPano最近的导览 //searchEvery: 找最小片段,不必是每个区域开头
+            n.prototype.findNearestItem = function(endToStart=true, searchEvery){//找到离currentPano最近的导览
                 /* if(this.atDestinationPano(this.player.currentPano)){//在终点直接从头。但有的场景可能不希望如此,就想跳到所属的展区开始。
                     return [0,0]   //2023.7.7发现在点击item后播放会从头开始
                 } */
@@ -4916,12 +4916,19 @@ window.Modernizr = function(n, e, t) {
                         if(dis<result.dis){
                             result.item = item, result.dis = dis
                         }else if(dis == result.dis){//如果两个位置相同,优先播放在导览条上离激活的最近的那段导览 
-                            /* if(this.itemCompare(item,  this.currentItem, 'equal')){
+                            
+                            /* if(this.itemCompare(item,  this.currentItem, 'equal')){//优先用当前的
                                 result.item = item, result.dis = dis
-                            } */ 
-                            if(this.currentItem && Math.abs(item[0]-this.currentItem[0]) < Math.abs(result.item[0]-this.currentItem[0])){
+                            }else if(this.currentItem && Math.abs(item[0]-this.currentItem[0]) < Math.abs(result.item[0]-this.currentItem[0])){
                                 result.item = item, result.dis = dis
-                            }  
+                            } */ 
+                            if(this.currentItem){
+                                let dis1 = [Math.abs(item[0] - this.currentItem[0]), Math.abs(item[1] - this.currentItem[1])] //当前差距
+                                let dis2 = [Math.abs(result.item[0] - this.currentItem[0]), Math.abs(result.item[1] - this.currentItem[1])]
+                                if( this.itemCompare(dis1, dis2, 'less')){ 
+                                    result.item = item, result.dis = dis
+                                }
+                            }
                         }
                     } 
                 }
@@ -4940,7 +4947,6 @@ window.Modernizr = function(n, e, t) {
                     }  
                     
                 })
-                
                  
                 
                 if(endToStart && this.atEndOfTour(result.item)){ //如果是最后一个点,直接跳到开头,否则导览开始就在终点的话不会从头开始
@@ -23504,7 +23510,7 @@ window.Modernizr = function(n, e, t) {
                 if (this.updateLastView(),
                 this.mode !== u.PANORAMA) {
                     var m;
-                    void this.flyToNewMode({
+                    return void this.flyToNewMode({
                         mode: u.PANORAMA,
                         pano: i,
                         duration: o,
@@ -59322,19 +59328,21 @@ class PanTransGuide{
         let path = this.player.path
         let last
         
-        let index = this.player.model.heroLocations.findIndex(e=>e.name == '沉浸看展')
-        let locations = this.player.model.heroLocations[index].heroLocations
-        this.player.model.heroLocations.splice(index,1)
-        
-        
-        return//  2025 不用这个了
-        
-        
+        let index = this.player.model.heroLocations.findIndex(e=>e.name == '沉浸看展') //先去掉之前旧的数据
+        if(index>-1){
+            let locations = this.player.model.heroLocations[index].heroLocations
+            this.player.model.heroLocations.splice(index,1)
+        }
         
-        locations.forEach((e,i)=>{
-            if(e.cameraMode != 'panorama')return
-          
-            if(i>0){   
+        let get = (e, originItem)=>{  
+            if(e.cameraMode != 'panorama'){ 
+                e.originItem = originItem
+                this.nodes.push(e) 
+                return
+            }
+                
+              
+            if(last){   
                 path.setWarpDestination(e)
                 path.setWarpDestPano()
                 let A = path.getHeroPano(last), 
@@ -59348,8 +59356,7 @@ class PanTransGuide{
                         path.nodes = [A.id,B.id];//直接加入
                     }
                 }
-                
-                
+                 
                 
                 let wholeDis = 0, disSections = []
                 path.nodes.forEach((cur,i)=>{
@@ -59367,21 +59374,26 @@ class PanTransGuide{
                 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})
+                        /* 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()
+           
+        }
         
+        this.player.model.heroLocations.forEach((e,i)=>{ 
+            if(e.heroLocations){
+               e.heroLocations.forEach((a,j)=> get(a, [i,j])) 
+            }else{
+               get(e,[i,0])
+            }  
+        })    
          
     }
     
@@ -59389,7 +59401,9 @@ class PanTransGuide{
         if(this.player.flying)return
         let aimNode
         let cur = this.nodes[this.currentIndex]
-        if(cur.panoId != this.player.currentPano.id){//已走动
+         
+        
+        if(cur.panoId != this.player.currentPano.id && player.mode == 'panorama'){//已走动){//已走动
             let curs = this.nodes.filter(e=>e.panoId == this.player.currentPano)   
             curs.sort((a,b)=>{      //如果有多个,找到和currentIndex最接近的,可能是刚走过的
                 let indexA = this.nodes.indexOf(a)
@@ -59399,15 +59413,17 @@ class PanTransGuide{
             cur = curs[0]
             if(!cur){//不在道上 . 找离当前位置最近的node
                 let disMap = new Map
-                this.nodes.forEach(e=>{
+                let nodes_ = this.nodes.filter(e=>!e.originItem)
+                 
+                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)=>{     
+                let sorted = nodes_.slice().sort((a,b)=>{     
                     return disMap.get(a) - disMap.get(b)
                 })
               
                 this.currentIndex = this.nodes.indexOf(sorted[0])//next
-                if(axis == 'prev'){
+                if(axis == -1){
                     this.moveIndex(-1) 
                 }
                 aimNode = this.nodes[this.currentIndex]
@@ -59415,13 +59431,22 @@ class PanTransGuide{
         }
         let lastIndex = this.currentIndex
         if(!aimNode){
-            this.moveIndex(axis == 'prev' ? -1 : 1)
-            aimNode = this.nodes[this.currentIndex]
+            this.moveIndex(axis)
+            aimNode = this.nodes[this.currentIndex] 
+        }
+        
+        if(aimNode.originItem){//要飞出的,直接用导览飞 
+            player.director.setDestinationItem(aimNode.originItem) 
+            player.director.goToDestination() 
+            return
         }
         
         //let dis = this.player.model.panos.get(aimNode.panoId).position.distanceTo(this.player.position)
-        let moveStyle = (lastIndex == 0 && axis == 'prev' || this.currentIndex == 0 && axis != 'prev') ? "blackToPano" : "flyToPano" 
-        this.player[moveStyle]({pano: this.player.model.panos.get(aimNode.panoId),quaternion:aimNode.quaternion})
+        let moveStyle = (lastIndex == 0 && axis == -1 || this.currentIndex == 0 && axis != -1) ? "blackToPano" : "flyToPano" 
+        this.player[moveStyle]({pano: this.player.model.panos.get(aimNode.panoId), quaternion:aimNode.quaternion}, ()=>{
+            //更新导览进度条
+            player.director.setDestinationItem( player.director.findNearestItem(true,true) )
+        })
        
     }
     
@@ -59436,12 +59461,24 @@ class PanTransGuide{
 
 
 //2025新的需求  沉浸看展直接使用导览
-
 window.tourPlayCtl = { 
+    go(axis){
+        player.guider2.go(axis)
+        
+    }
+}
+
+
+
+
+ 
+
+/* window.tourPlayCtl = { 
     
     go(axis){
         
         let director = player.director
+        let path = player.path
         
         director.setCurrentItem(player.director.findNearestItem(true,true)) 
 
@@ -59471,7 +59508,7 @@ window.tourPlayCtl = {
     } 
      
 }
-
+ */