ソースを参照

fix: bug 前进后退按区域第一个。在导览播放时点击item或前进后退会继续播放

xzw 10 ヶ月 前
コミット
06e63165e9
2 ファイル変更96 行追加22 行削除
  1. 82 16
      scene/public/static/js/main_2020_show.js
  2. 14 6
      scene/public/static/js/manage.js

+ 82 - 16
scene/public/static/js/main_2020_show.js

@@ -4966,6 +4966,7 @@ window.Modernizr = function(n, e, t) {
                     return [0,0]                                  //但注意最后是区域的话result.item是区域开头,除非站在最末最末尾的位置,上面的atDestinationPano直接返回
                     return [0,0]                                  //但注意最后是区域的话result.item是区域开头,除非站在最末最末尾的位置,上面的atDestinationPano直接返回
                 }
                 }
                 
                 
+                 
                 return result.item
                 return result.item
                 
                 
             }
             }
@@ -5118,13 +5119,27 @@ window.Modernizr = function(n, e, t) {
             }
             }
             ,
             ,
             n.prototype.goToHighlight = function(e) {
             n.prototype.goToHighlight = function(e) {
+                this.highlightItem = e //add
                 if (this.wouldInterrupt()){
                 if (this.wouldInterrupt()){
-                    this.itemCompare(this.destinationItem,e,'equal') ? this.interrupt() : this.redirectToItem(e, "goToHighlight");
-                    
+                    let soon
+                    if(this.itemCompare(this.destinationItem,e,'equal') ){
+                        this.interrupt() 
+                        soon = true
+                    }else{
+                        this.redirectToItem(e, "goToHighlight") 
+                    }
                     setTimeout(()=>{
                     setTimeout(()=>{
-                        this.playTour() // 切换导览时(点击列表item),不要停止导览
-                    },2000) 
+                        this.once(soon ? "tour.end" : "warp.end",()=>{ 
+                            console.log(this.currentItem)
+                            setTimeout(()=>{
+                                this.highlightItem = null
+                                this.playTour() // 切换导览时(点击列表item),不要停止导览 
+                            },700) 
+                        }) 
+                    },10)
                     
                     
+                   
+                        
                 }else {
                 }else {
                     if (A.debug("<tour.goto " + e + ">"),
                     if (A.debug("<tour.goto " + e + ">"),
                     this.isInterrupted())
                     this.isInterrupted())
@@ -5136,6 +5151,9 @@ window.Modernizr = function(n, e, t) {
                     h.trackAlways("reach_highlight", {
                     h.trackAlways("reach_highlight", {
                         reach_source: "thumb"
                         reach_source: "thumb"
                     })
                     })
+                    this.once('warp.end',()=>{
+                        this.highlightItem = null //add
+                    })
                 }
                 }
             }
             }
             ,
             ,
@@ -21713,6 +21731,7 @@ window.Modernizr = function(n, e, t) {
             ,
             ,
             n.prototype.endWarpState = function() {
             n.prototype.endWarpState = function() {
                 this.warping = !1
                 this.warping = !1
+                this.director.emit('warp.end')//xzw add
             }
             }
             ,
             ,
             n.prototype.warpToPano = function(e, t, i, n) {
             n.prototype.warpToPano = function(e, t, i, n) {
@@ -23682,7 +23701,7 @@ window.Modernizr = function(n, e, t) {
             n.prototype.warpToPano = function(o={}) {
             n.prototype.warpToPano = function(o={}) {
                 
                 
             }
             }
-            n.prototype.blackToPano = function(o={}) {//add 瞬间过渡
+            n.prototype.blackToPano = function(o={},callback) {//add 瞬间过渡
                 //o.panoId = "8bc9156b288d48459e4e0f74d7051ef1"
                 //o.panoId = "8bc9156b288d48459e4e0f74d7051ef1"
                 if(this.flying || this.isWarping() )return; 
                 if(this.flying || this.isWarping() )return; 
                 let pano = o.pano || this.model.panos.index[o.panoId] 
                 let pano = o.pano || this.model.panos.index[o.panoId] 
@@ -23694,7 +23713,7 @@ window.Modernizr = function(n, e, t) {
                         pano ,
                         pano ,
                         duration: o.duration,
                         duration: o.duration,
                         quaternion: o.quaternion ,
                         quaternion: o.quaternion ,
-                        //callback: t
+                        callback
                     })
                     })
                 }
                 }
                
                
@@ -23706,7 +23725,7 @@ window.Modernizr = function(n, e, t) {
  
  
                 var retry = ()=>{
                 var retry = ()=>{
                     this.waitingToWarp = !1,
                     this.waitingToWarp = !1,
-                    this.blackToPano(o)
+                    this.blackToPano(o,callback)
                 }
                 }
                 
                 
                 if (this.checkAndWaitForPanoLoad(pano, "high", "low", this.basePanoSize, retry))
                 if (this.checkAndWaitForPanoLoad(pano, "high", "low", this.basePanoSize, retry))
@@ -23732,7 +23751,7 @@ window.Modernizr = function(n, e, t) {
                     this.flying = false
                     this.flying = false
                     this.nextPano = null 
                     this.nextPano = null 
                     this.updateMarkerVisi();//add
                     this.updateMarkerVisi();//add
-                    
+                    callback && callback()
                 } )
                 } )
                 
                 
             }
             }
@@ -59330,7 +59349,7 @@ class PanTransGuide{
         }
         }
         
         
         
         
-        let get = (e,originItem)=>{
+        /* let get = (e,originItem)=>{
             if(e.cameraMode != 'panorama'){ 
             if(e.cameraMode != 'panorama'){ 
                 return 
                 return 
             }
             }
@@ -59344,17 +59363,17 @@ class PanTransGuide{
             }else{
             }else{
                get(e,[i,0])
                get(e,[i,0])
             }  
             }  
-        }) 
+        })  */
     }
     }
     
     
     
     
-    go(axis){
+    go(axis, interrupt){//仅使用每个导览区域第一个的版本
         if(this.player.flying)return
         if(this.player.flying)return
         let aimNode
         let aimNode
         let cur = this.nodes[this.currentIndex]
         let cur = this.nodes[this.currentIndex]
          
          
         
         
-        if(cur.panoId != this.player.currentPano.id && player.mode == 'panorama'){//已走动){//已走动
+        /* if(cur.panoId != this.player.currentPano.id && player.mode == 'panorama'){//已走动){//已走动
             let curs = this.nodes.filter(e=>e.panoId == this.player.currentPano)   
             let curs = this.nodes.filter(e=>e.panoId == this.player.currentPano)   
             curs.sort((a,b)=>{      //如果有多个,找到和currentIndex最接近的,可能是刚走过的
             curs.sort((a,b)=>{      //如果有多个,找到和currentIndex最接近的,可能是刚走过的
                 let indexA = this.nodes.indexOf(a)
                 let indexA = this.nodes.indexOf(a)
@@ -59379,7 +59398,7 @@ class PanTransGuide{
                 }
                 }
                 aimNode = this.nodes[this.currentIndex]
                 aimNode = this.nodes[this.currentIndex]
             }
             }
-        }
+        } 
         let lastIndex = this.currentIndex
         let lastIndex = this.currentIndex
         if(!aimNode){
         if(!aimNode){
             this.moveIndex(axis)
             this.moveIndex(axis)
@@ -59390,7 +59409,7 @@ class PanTransGuide{
             player.director.setDestinationItem(aimNode.originItem) 
             player.director.setDestinationItem(aimNode.originItem) 
             player.director.goToDestination() 
             player.director.goToDestination() 
             return
             return
-        }
+        } 
         
         
         //let dis = this.player.model.panos.get(aimNode.panoId).position.distanceTo(this.player.position)
         //let dis = this.player.model.panos.get(aimNode.panoId).position.distanceTo(this.player.position)
         let moveStyle = (lastIndex == 0 && axis == -1 || this.currentIndex == 0 && axis != -1) ? "blackToPano" : "flyToPano" 
         let moveStyle = (lastIndex == 0 && axis == -1 || this.currentIndex == 0 && axis != -1) ? "blackToPano" : "flyToPano" 
@@ -59398,6 +59417,35 @@ class PanTransGuide{
             //更新导览进度条 //已转移
             //更新导览进度条 //已转移
             //player.director.setCurrentItem( player.director.findNearestItem(true,true) )
             //player.director.setCurrentItem( player.director.findNearestItem(true,true) )
         })
         })
+        */
+        let director = player.director
+        
+        let destItem
+        /*if(axis == 1){ 
+            destItem = director.nextItem(director.currentItem)
+        }else{ 
+            destItem = director.prevItem(director.currentItem)
+        } */
+        let dest = (director.currentItem[0]+axis + player.model.heroLocations.length ) % player.model.heroLocations.length 
+            destItem = [dest,0] 
+        let location = player.model.getHeroDescriptorByIndex(destItem)
+        if(location.panoId != void 0 && location.panoId != "outside"){
+            let moveStyle = (director.currentItem[0] == 0 && director.currentItem[1] == 0 && axis == -1 || destItem[0] == 0 && destItem[1] == 0 && axis != -1) ? "blackToPano" : "flyToPano" 
+            player[moveStyle]({pano: player.model.panos.get(location.panoId), quaternion:location.quaternion},()=>{
+                
+                interrupt && setTimeout(()=>{director.playTour(),1}) 
+            })
+        
+        }else{//如果飞出就直接执行导览的
+            if(axis == 1){
+                director.goNext(director.currentItem)
+            }else{
+                director.goPrev(director.currentItem)
+            }
+            interrupt && player.director.once("tour.end",()=>{
+                 setTimeout(()=>{director.playTour(),1}) 
+            }) 
+        }
        
        
     }
     }
     
     
@@ -59415,8 +59463,23 @@ class PanTransGuide{
 //2025新的需求  沉浸看展直接使用导览
 //2025新的需求  沉浸看展直接使用导览
 window.tourPlayCtl = { 
 window.tourPlayCtl = { 
     go(axis){
     go(axis){
-        player.guider2.go(axis)
         
         
+        let interrupt = player.director.wouldInterrupt()
+        
+        if (interrupt){
+            //不执行
+            player.director.once("tour.end",()=>{
+                setTimeout(()=>{
+                    player.guider2.go(axis, interrupt) 
+                },100) //立即执行会一直loading,不知为啥
+            })
+            player.director.redirectToItem(player.director.destinationItem, "goToHighlight");
+           
+            
+        }else{
+            player.guider2.go(axis)
+        }
+         
     }
     }
 }
 }
 
 
@@ -59462,9 +59525,12 @@ window.tourPlayCtl = {
 }
 }
  */
  */
 
 
+/* 
+warpTravel_BLACK =
+ype.goToHighlight = fun
 
 
 
 
-
+ */
 
 
 
 
  
  

+ 14 - 6
scene/public/static/js/manage.js

@@ -2427,7 +2427,10 @@ function initByTHREE(THREE){
     {
     {
         let f = ()=>{
         let f = ()=>{
             window.bus.removeEventListener('playerAndModelReady',f)
             window.bus.removeEventListener('playerAndModelReady',f)
-             
+            
+            document.querySelector('#openMusic').style.display='block'
+            $("#bgm").hide();
+            
             player.on("mode.changing",(currentMode, mode, pano, duration)=>{ 
             player.on("mode.changing",(currentMode, mode, pano, duration)=>{ 
                 let noLine = mode == 'floorplan';
                 let noLine = mode == 'floorplan';
                 if(noLine){
                 if(noLine){
@@ -2553,8 +2556,7 @@ function initByTHREE(THREE){
                         curAudio = areaAudio
                         curAudio = areaAudio
                          
                          
                         if(canPlay){
                         if(canPlay){
-                            SoundManager.play('bgm')
-                            $("#bgm").show();
+                            SoundManager.play('bgm') 
                         }
                         }
                         
                         
                         if(areaAudio || window.DATA.backgroundMusic){
                         if(areaAudio || window.DATA.backgroundMusic){
@@ -2573,11 +2575,11 @@ function initByTHREE(THREE){
                 }) 
                 }) 
                 
                 
                 player.on("view.changed",(e)=>{//位移和旋转时都要判断最近item
                 player.on("view.changed",(e)=>{//位移和旋转时都要判断最近item
-                  if(e.cameraWorldMatrixChanged && !player.flying/*  && !player.isWarping() */  ){
+                  if(!player.director.highlightItem && e.cameraWorldMatrixChanged && !player.flying && !player.isWarping()  ){
                     player.director.setCurrentItem( player.director.findNearestItem(true,true) )
                     player.director.setCurrentItem( player.director.findNearestItem(true,true) )
                   }
                   }
                 })  
                 })  
-                   
+                player.director.setCurrentItem( player.director.findNearestItem(true,true) ) 
                 
                 
                 
                 
                 
                 
@@ -2608,7 +2610,12 @@ function initByTHREE(THREE){
             }
             }
             
             
             CursorDeal.init()
             CursorDeal.init()
-            
+            /* player.director.on("tour.end",()=>{
+                console.log("tour.end")
+            })
+            player.director.on("warp.end",()=>{
+                console.log("warp.end")
+            }) */
         } 
         } 
         
         
         
         
@@ -2830,6 +2837,7 @@ Manage.prototype.loadAudio = function() { //相关:g_tourAudio \  g_playAudio
             
             
         }
         }
     })  
     })  
+    
     SoundManager.createAudio({
     SoundManager.createAudio({
         name:'tour',
         name:'tour',
         level:0, 
         level:0,