xzw пре 9 месеци
родитељ
комит
23f1eb25f5
3 измењених фајлова са 190 додато и 30 уклоњено
  1. 3 3
      scene/public/static/js/Hot.js
  2. 167 11
      scene/public/static/js/main_2020_show.js
  3. 20 16
      scene/public/static/js/manage.js

+ 3 - 3
scene/public/static/js/Hot.js

@@ -1201,7 +1201,7 @@ window.initHot = function (model) {
           div.appendChild(exit);
           div.appendChild(myElement);
 
-          SoundManager.play("hot");
+          //SoundManager.play("hot");
         }
 
         return;
@@ -1215,7 +1215,7 @@ window.initHot = function (model) {
         (g_currentHot = this), (popup.style.display = "block"), popup.classList.add("wait");
         var n = document.createElement("iframe");
 
-        SoundManager.play("hot");
+        //SoundManager.play("hot");
 
         var src = getLink(this.info.link);
         n.src = src;
@@ -1668,7 +1668,7 @@ window.initHot = function (model) {
     document.querySelector(".popup-content").removeChild(document.getElementById("id1"));
     $("#popup iframe:last").remove();
 
-    SoundManager.pause("hot", true); //自动播放被中断的音频 (bgm
+    //SoundManager.pause("hot", true); //自动播放被中断的音频 (bgm
 
     return false;
   };

+ 167 - 11
scene/public/static/js/main_2020_show.js

@@ -4140,7 +4140,7 @@ window.Modernizr = function(n, e, t) {
                           , i = (e.touches[0].clientY - e.touches[1].clientY) / $("#player").height();
                         this.pinchDistance = Math.sqrt(t * t + i * i)
                     }
-                    settings.tourSoundUnable || SoundManager.pause('tour') // 周恩光 点击场景时停止语音
+                    //settings.tourSoundUnable || SoundManager.pause('tour') // 周恩光 点击场景时停止语音
                     this.emit(u.InputStart, "touch")
                 }
             }
@@ -4164,7 +4164,7 @@ window.Modernizr = function(n, e, t) {
                     case c.LEFT:
                         this.startRotationFrom(e.clientX, e.clientY)
                     }
-                    settings.tourSoundUnable || SoundManager.pause('tour') // 周恩光 点击场景时停止语音
+                    //settings.tourSoundUnable || SoundManager.pause('tour') // 周恩光 点击场景时停止语音
                     this.emit(u.InputStart, "mouse")
                 }
             }
@@ -4568,6 +4568,8 @@ window.Modernizr = function(n, e, t) {
             }
             ,
             n.prototype.checkAndHandleWalkingtourInterruption = function(e) {//快速停止。 改:去掉判断nextWarpStyle,因为这个属性改乱了,导致点击停止按钮不执行
+                return //xzw add 拖拽不停止
+                
                 return /* e === u.WALK && ( */this.interrupt(g.NONE),
                 this.pauseWalkingSection(),
                 this.player.fastForwardActivePanoFlight(),
@@ -4575,6 +4577,7 @@ window.Modernizr = function(n, e, t) {
             }
             ,
             n.prototype.handlePlayerMove = function(e) {
+                return //xzw add 拖拽不停止
                 this.transitionStage === y.Interlude && this.interrupt(g.NONE),
                 this.emit("update.controls")
             }
@@ -4590,6 +4593,7 @@ window.Modernizr = function(n, e, t) {
             }
             ,
             n.prototype.handlePlayerInputStart = function(e) {
+                return //xzw add 拖拽不停止
                 this.transitionStage === y.Interlude && this.interrupt(g.NONE)
             }
             ,
@@ -4916,7 +4920,7 @@ window.Modernizr = function(n, e, t) {
                         var dis = pano.position.distanceTo(this.player.currentPano.position)
                         
                         if(dis<result.dis){
-                            result.item = item, result.dis = dis, result.location = location
+                            result.item = item, result.dis = dis, result.location = location, result.angle = null
                         }else if(dis == result.dis){//如果两个位置相同,优先播放在导览条上离激活的最近的那段导览 
                              
                               
@@ -5118,9 +5122,40 @@ window.Modernizr = function(n, e, t) {
                 this.emit(p.TourEnd)
             }
             ,
+             
             n.prototype.goToHighlight = function(e) {
-                this.highlightItem = e //add
-                if (this.wouldInterrupt()){
+                //if(player.isWarping() )return //add
+                
+                //this.highlightItem = e //add
+                
+                if(this.waitHighlight)return this.waitHighlight = e //继续等待
+                if(player.flying){
+                    this.waitHighlight = e
+                    return player.once("flying.ended",()=>{ 
+                        let e = this.waitHighlight
+                        this.waitHighlight = null
+                        this.goToHighlight(e)
+                    })
+                }else if(player.isWarping()){
+                    this.waitHighlight = e
+                    return this.once("warp.end",()=>{ 
+                        setTimeout(()=>{
+                            let e = this.waitHighlight
+                            this.waitHighlight = null
+                            this.goToHighlight(e)
+                        },200)
+                       
+                    })  
+               
+                    /* return setTimeout(()=>{
+                        this.once("warp.end",()=>{ 
+                            this.goToHighlight(e)
+                        })
+                    },100)  */ 
+                }  
+                 
+                
+                /* if (this.wouldInterrupt()){
                     let soon
                     if(this.itemCompare(this.destinationItem,e,'equal') ){
                         this.interrupt() 
@@ -5140,7 +5175,7 @@ window.Modernizr = function(n, e, t) {
                     
                    
                         
-                }else {
+                }else { */
                     if (A.debug("<tour.goto " + e + ">"),
                     this.isInterrupted())
                         return;
@@ -5154,7 +5189,7 @@ window.Modernizr = function(n, e, t) {
                     this.once('warp.end',()=>{
                         this.highlightItem = null //add
                     })
-                }
+                //}
             }
             ,
             n.prototype.prevHighlight = function() {
@@ -20473,6 +20508,7 @@ window.Modernizr = function(n, e, t) {
             }
             ,
             n.prototype.popInCpm = function() {
+                return //xzw add 否则点击导览item会在底下显示红色标记
                 c.path.mapGuides && this.currentPanoMarker.placed && this.fadeInCpm(2)
             }
             ,
@@ -20608,7 +20644,7 @@ window.Modernizr = function(n, e, t) {
                 this.warpDestPano
             }
             ,
-            n.prototype.brushToWarpPano = function(e, t) {
+            n.prototype.brushToWarpPano = function(e, t) { 
                 if (this.discardPathObject(),
                 !this.setWarpDestPano())
                     return !1;
@@ -22066,7 +22102,7 @@ window.Modernizr = function(n, e, t) {
                 this.updateModel()
                  
                 this.guider2 = new PanTransGuide(this)
-                
+                this.guider3 = new UserGuide(this)
             }
 			 
 			
@@ -24523,6 +24559,8 @@ window.Modernizr = function(n, e, t) {
             }
             ,
             n.prototype.tourInterlude = function(e, t) {
+               return //xzw add
+                
                 this.history.invalidate();
                 this.path.discardSlow();
 				//xzw:  
@@ -59517,13 +59555,131 @@ window.tourPlayCtl = {
             }else{
                 director.goPrev(director.currentItem)
             }
-        }
+        } 
+    } 
+     
+}
+ */
+ 
+ 
+ 
+ 
+ 
+ 
+class UserGuide{
+    constructor(player){
+        let lastCurItem
+        this.player = player
+        this.pausedByBtn = true
         
+        SoundManager.list.find(e=>e.name == 'tour').audio.addEventListener('ended', ()=>{ 
+             player.director.tourIsPlaying && this.go(1) //下一个点
+        });
+        player.on("flying.ended",(a,b,pano,d)=>{  
+            //更新导览进度条  导览片段的选中与当前点位所属片段对应。 
+            player.director.setCurrentItem( player.director.findNearestItem(true,true) )
+             
+        }) 
+        
+        player.director.on("update.controls", ()=>{  //更新了currentItem的话
+            if(player.director.itemCompare(lastCurItem, player.director.currentItem,'equal' )) return 
+            lastCurItem = player.director.currentItem?.slice()
+            
+            if(!player.director.tourIsPlaying){
+                if(this.pausedByBtn) return 
+                else this.play()
+            }
+            /* let folder = player.model.heroLocations[player.director.currentItem[0]]
+            let items = folder.heroLocations ? folder.heroLocations : [folder] 
+            if(items.some(e=>e.panoId == player.currentPano.id)){ */
+            let curItem = player.model.getHeroDescriptorByIndex(player.director.currentItem)
+            if(player.currentPano.id == curItem.panoId){ 
+                this.setMusic()
+            }else{//走到了导览以外的区域
+                this.pause(false)//SoundManager.pause('tour') 
+            }
+        })
+                
+        player.director.playTourNearBy = this.play.bind(this)
+        player.director.stopTour = this.pause.bind(this)
+    }
+    
+    play(){
+        //从当前index开始播放,如果在导览区域,就在当前点播音乐,如果不是就跳到当前导览区域第一个点
+        //假定导览都在漫游模式  //假设不同导览区域不存在相同漫游点
         
+        let curItem = player.model.getHeroDescriptorByIndex(player.director.currentItem || [0,0])
+        let playMusic = ()=>{
+            this.setMusic()
+        }
+        if(player.currentPano.id != curItem.panoId){
+            player.flyToPano({pano: player.model.panos.get(curItem.panoId), quaternion:curItem.quaternion},()=>{
+                playMusic()
+            })
+        }else{
+            playMusic()
+        }
+        player.director.tourInProgress = player.director.tourIsPlaying = true
+        player.director.emit("update.controls")
     } 
+    pause(byBtn=true){
+        SoundManager.pause('tour')
+        player.director.tourInProgress = player.director.tourIsPlaying = false 
+        player.director.emit("update.controls")
+        this.pausedByBtn = byBtn
+    }
+    
+    
+    go(axis){
+        let length = player.model.heroLocations.length
+        let cur = player.director.currentItem
+        let next = [(cur[0]+axis) % length, 0]  
+        let nextItem = player.model.getHeroDescriptorByIndex(next)
+        
+        player.flyToPano({pano: player.model.panos.get(nextItem.panoId), quaternion:nextItem.quaternion},()=>{
+            this.setMusic()
+        })
+        Hot.closePopup();
+    }
+    
+    
+    setMusic(){
+        var musicInfo = player.model.heroLocations[player.director.currentItem[0]].musicInfo
+                
+        if(!settings.tourSoundUnable && musicInfo && musicInfo.music  ){
+
+            let musicType = localStorage.getItem('xunirole') || 'male'
+
+            let isMale = musicType.indexOf('female') < 0
+
+            let fixMusic = isMale?musicInfo.music:(musicInfo.fmusic||musicInfo.music)
+            let src = fixMusic
+            let audioObj = SoundManager.list.find(e=>e.name == 'tour')
+            let audioSrc1 = common.getFileNameFromUrl(audioObj.src);  
+            let audioSrc2 = common.getFileNameFromUrl(src)  
+               
+            if(audioSrc1 == audioSrc2){//应该是继续播放该folder 
+               /*  if(player.director.currentItem[1] == 0){//从头开始播放 因为可能暂停后然后再点该缩略图播
+                    SoundManager.play('tour',null,0)  // currentTime = 0; 
+                }else*/ if( audioObj.audio.paused && audioObj.audio.currentTime < audioObj.audio.duration   ){//未播完
+                     SoundManager.play('tour')//继续播。为什么会有暂停的情况?如果手动切换到bgm了呢?
+                } 
+            }else{//很可能是该folder的起始  */
+                SoundManager.play('tour', manage.dealURL(src))
+            }                                                         
+                             
+        }
+    }
+    
      
 }
- */
+  
+ 
+window.tourPlayCtl = { 
+    go(axis){ 
+        player.guider3.go(axis) 
+    }
+} 
  
 /* 
 warpTravel_BLACK =

+ 20 - 16
scene/public/static/js/manage.js

@@ -2541,10 +2541,10 @@ function initByTHREE(THREE){
             }
             
             //const pauseWhenGoNextPano = true //到有音频的地方先暂停,用户自己打开播放(后加的需求)
-            const pauseWhenChangeArea = false//true
+             const pauseWhenChangeArea = false//true
             
             {//根据漫游点切换音频
-                let curAudio  
+                /*let curAudio  
                 let bgmObject = SoundManager.list.find(e=>e.name == 'bgm')
                 let setCurBgm = (pano)=>{ 
                     if(!window.DATA.panoAreas)return
@@ -2569,24 +2569,26 @@ function initByTHREE(THREE){
                         //}
                         
                     }
-                }
-                player.on("flying.ended",(a,b,pano,d)=>{
-                    //pauseWhenGoNextPano && manage.switchBgmState(false)
-                    pano && setCurBgm(pano) 
-                    //更新导览进度条  导览片段的选中与当前点位所属片段对应。
-                    //player.director.setCurrentItem( player.director.findNearestItem(true,true) )
-                }) 
+                } */
+                /* player.on("flying.ended",(a,b,pano,d)=>{ 
+                    //pano && setCurBgm(pano) 
+                    
+                })  */
                 
                 player.on("view.changed",(e)=>{//位移和旋转时都要判断最近item
-                  if(!player.director.highlightItem && e.cameraWorldMatrixChanged && !player.flying && !player.isWarping()  ){
-                    player.director.setCurrentItem( player.director.findNearestItem(true,true) )
-                  }
+                    if(!player.director.highlightItem && e.cameraWorldMatrixChanged && !player.flying && !player.isWarping()  ){
+                        common.intervalTool.isWaiting('tourUpdateCurItem',()=>{
+                            console.log('setCurrentItem')
+                            player.director.setCurrentItem( player.director.findNearestItem(true,true) )
+                             
+                        }, 521)
+                    }                        
                 })  
                 player.director.setCurrentItem( player.director.findNearestItem(true,true) ) 
                 
                 
                 
-                player.on("mode.changed", ()=>{ //飞出后不播放 也不显示按钮
+                /* player.on("mode.changed", ()=>{ //飞出后不播放 也不显示按钮
                     if(player.mode != 'panorama'){
                         SoundManager.pause('bgm')
                         $("#bgm").hide()
@@ -2596,7 +2598,7 @@ function initByTHREE(THREE){
                             $("#bgm").show()
                         }
                     }
-                })
+                }) 
                  
                 
                 manage.addEventListener('pauseSound',(e)=>{
@@ -2607,7 +2609,7 @@ function initByTHREE(THREE){
                 })
                 
                 
-                player.currentPano && setCurBgm(player.currentPano)
+                player.currentPano && setCurBgm(player.currentPano)*/
                 
                  
             }
@@ -2758,7 +2760,7 @@ var SoundManager = {//暂不支持同时播放
             
             
             object.audio.oncanplaythrough = ()=>{ 
-                //Log(`${object.name} canplaythrough  `) 
+                Log(`${object.name} canplaythrough, duration: ${object.audio.duration} `) 
             }
         }
         
@@ -2885,6 +2887,8 @@ Manage.prototype.loadAudio = function() { //相关:g_tourAudio \  g_playAudio
 
  
 Manage.prototype.switchBgmState = function(state){//按钮的状态完全代表是否应该播放bgm,即使还没加载完
+    return //改为不播放音乐
+    
     this.bgmShouldPlay = state