tremble преди 3 години
родител
ревизия
45208f96f0
променени са 1 файла, в които са добавени 95 реда и са изтрити 17 реда
  1. 95 17
      js/main_2020_show.js

+ 95 - 17
js/main_2020_show.js

@@ -4173,6 +4173,7 @@ window.Modernizr = function(n, e, t) {
                     case c.LEFT:
                         this.startRotationFrom(e.clientX, e.clientY)
                     }
+                    SoundManager.pause('tour') // zeg 点击场景时停止语音
                     this.emit(u.InputStart, "mouse")
                 }
             }
@@ -4533,6 +4534,22 @@ window.Modernizr = function(n, e, t) {
                 this.updateModel(),
                 this.resetAll(),
                 this.bindEvents()
+                // zeg 查询pano对应的导览片段
+                if(!this.panoIdMap) {
+                    this.panoIdMap = new Map()
+                    this.model.heroLocations.forEach( (value, index) => {
+                        // value.heroLocations.forEach( hl => {
+                            if(!value.heroLocations) return
+                            let hl = value.heroLocations[0]
+                            let arr = this.panoIdMap.get(hl.panoId)
+                            if(arr){
+                                this.panoIdMap.set(hl.panoId, [...arr, index])
+                            } else {
+                                this.panoIdMap.set(hl.panoId, [index])
+                            }
+                        // })
+                    })
+                }
             }
             ,
             n.prototype.resetAll = function() {
@@ -4786,8 +4803,17 @@ window.Modernizr = function(n, e, t) {
                 //音频 
                 
                 var musicInfo = this.model.heroLocations[this.destinationItem[0]].musicInfo
-                if(musicInfo && musicInfo.music){
-                    let src = musicInfo.music.includes(g_Prefix.slice(-10)) ? musicInfo.music :  g_Prefix + musicInfo.music;
+                // zeg 手动导览不播放音频
+                if(musicInfo && musicInfo.music && !e){
+
+                    let musicType = localStorage.getItem('xunirole') || 'male'
+
+                    let isMale = musicType.indexOf('female') < 0
+
+                    let fixMusic = isMale?musicInfo.music:(musicInfo.fmusic||musicInfo.music)
+
+                    // let src = musicInfo.music.includes(g_Prefix.slice(-10)) ? musicInfo.music :  g_Prefix + 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)
@@ -4806,6 +4832,9 @@ window.Modernizr = function(n, e, t) {
                     
                      
                 }
+
+                let oldPos = this.player.position.clone();
+                let oldPano = this.player.currentPano
                 
                 if (this.onTheBus = !0,
                 this.emit("update.controls"),
@@ -4822,6 +4851,7 @@ window.Modernizr = function(n, e, t) {
                 if (this.player.flying || this.player.isWarping())
                     A.warn("Cannot go to new destination while player is flying or warping.");
                 else {
+
                     var r = this.model.getHeroDescriptorByIndex(this.destinationItem)
                       , o = null
                       , a1 = null;
@@ -4831,6 +4861,7 @@ window.Modernizr = function(n, e, t) {
                         //var walk = window.DATA.black ? 'black' : 'walk';
                         //若是点击item,直接瞬间过渡。
                         var s = e ? 'black' : this.getMomentTour(this.destinationItem)   //window.DATA.momentTour || "walk";
+                        if(this.destinationItem[0] == 0 && this.destinationItem[1] == 0) s = 'black' // 周恩光加 返回最初导览点是瞬间过渡
                         a1 = this.player.warpToPanoByHeroIndex.bind(this.player, this.destinationItem, v.Show, m.Slow,  s, true, i, this.actionComplete.bind(this)),
                         o = this.arrivedAtDestination.bind(this, !0)
                     
@@ -4861,8 +4892,15 @@ window.Modernizr = function(n, e, t) {
                 this.emit("update.controls"),
                 this.tourIsPlaying)
                     return this.atEndOfTour() && !this.endlessLoop ? (this.tourInProgress = !1,
-                    this.stopTour(true),
-                    this.emit(p.TourEnd),
+                    void this.awaitCompletion(function() {
+                        this.transitionStage = y.Interlude,
+                        this.player.tourInterlude(this.nextItem(this.currentItem),this.actionComplete.bind(this))
+                    }
+                    .bind(this), function(){
+                        this.currentItem = [0,0],
+                        this.stopTour(true),
+                        this.emit(p.TourEnd)
+                    }.bind(this)),
                     void (this.player.mode === c.PANORAMA && this.model.fadePanoMarkers(a.panorama.markerOpacity))) : void this.awaitCompletion(function() {
                         this.transitionStage = y.Interlude,
                         this.player.tourInterlude(this.nextItem(this.currentItem),this.actionComplete.bind(this))
@@ -4871,7 +4909,33 @@ window.Modernizr = function(n, e, t) {
             }
             ,
             n.prototype.playTour = function() {
-                if (!this.bounceable())
+                if (!this.bounceable()) {
+
+                    if(!this.currentItem) this.currentItem = []
+                    if(this.currentItem[0] != 0 || this.destinationItem[0]!= this.nItems-1){
+                        // zeg 从当前pano进行自动导览
+                        let currentPanoDestinations = this.panoIdMap.get(this.player.currentPano.id)
+                        // this.model.heroLocations.forEach( (value, index) => {
+                            // if(value.heroLocations.find( hl => hl.panoId == this.player.currentPano.id )) {
+                            //     currentPanoDestinations.push(index)
+                            // }
+                        // })
+
+                        if(!currentPanoDestinations) { 
+                            // let panoIndex = this.model.panos.list.findIndex( pano => pano.id == this.player.currentPano.id )
+                            let panoIndex = this.model.panos.list.indexOf( this.player.currentPano )
+                            let neighbourIndex = [ panoIndex + 1, panoIndex - 1, panoIndex + 2, panoIndex - 2, panoIndex + 3, panoIndex - 3 ]
+                            for(var i = 0; i < neighbourIndex.length; i++) {
+                                currentPanoDestinations = this.panoIdMap.get(this.model.panos.list[neighbourIndex[i]]&&this.model.panos.list[neighbourIndex[i]].id)
+                                if(currentPanoDestinations && currentPanoDestinations[0] != 0) break
+                            }
+                            if(!currentPanoDestinations) currentPanoDestinations = [0];
+                        }
+                        if(currentPanoDestinations.indexOf(this.currentItem[0]) == -1) {
+                            this.currentItem[0] = currentPanoDestinations[0]
+                        }
+                    }
+
                     return this.tourIsPlaying ? void A.info("tour is already playing") : void (this.wouldInterrupt() || (this.player.emit("tour_auto", this.defaultWarpStyle),
                     this.tourInProgress = !0,
                     this.reachSource = "play",
@@ -4882,8 +4946,10 @@ window.Modernizr = function(n, e, t) {
                     this.emit("update.controls"),
                     this.emit(p.TourStart),
                     this.player.enablePreRendering(),
+                    this.currentItem[1] = null,
                     this.walkingSectionPaused ? (this.clearWalkingSectionPaused(),
                     this.goToDestination()) : this.goNext()))
+                }
             } 
 			,
 			/* n.prototype.bgmReplay = function() {//xzw add  结束tour后可能要继续播放背景音乐
@@ -4892,6 +4958,7 @@ window.Modernizr = function(n, e, t) {
 			} */
 			 
             n.prototype.stopTour = function(isAutoStop) {//停止导览        isAutoStop 希望仅在飞完结束自动停止时的stopTour不停止tourSound, 这样才能完整播放tourSound.  不过似乎会在倒数第二个片段点击按钮停止导览时也视作自动结束的(执行this.interrupt() )。
+                SoundManager.pause('tour'), // zeg 自动导览暂停时同时停止语音
                 this.isInterrupted() || this.transitionStage === y.Moving && this.checkAndHandleWalkingtourInterruption(this.nextWarpStyle) || (this.tourIsPlaying && (this.player.zoomEnabled = this.wasZoomEnabled),
                 this.tourIsPlaying = !1, 
                 this.interrupt(),
@@ -5055,18 +5122,28 @@ window.Modernizr = function(n, e, t) {
             n.prototype.tourAdvance = function(e) {//e是1或-1
                 
                 A.debug("tourAdvance(" + e + ")") 
+
+                // zeg改
                 if(null === this.currentItem || void 0 === this.currentItem){
-                    this.setDestinationItem(this.firstDestination()) 
-                }else{ 
-                    var item    
-                    if(e == 1){
-                        item = this.nextItem(this.currentItem)
-                    }else if(e == -1){
-                        item = this.prevItem(this.currentItem)    
-                        
-                    }  
-                    this.setDestinationItem(item) 
+                    // this.setDestinationItem(this.firstDestination()) 
+                    // this.setDestinationItem([currentPanoDestinations[0], 0]) 
+                    this.setDestinationItem([this.currentItem[0], 0]) 
+                }
+                else if(this.currentItem[1] == null) {
+                    this.setDestinationItem([this.currentItem[0], 0])
                 }
+                else{ 
+                    
+                        var item    
+                        if(e == 1){
+                            item = this.nextItem(this.currentItem)
+                        }else if(e == -1){
+                            item = this.prevItem(this.currentItem)    
+                            
+                        }
+                        this.setDestinationItem(item) 
+                }
+                
                 if(this.itemCompare(this.destinationItem, this.finalDestination(), 'equal')[0] < 0 ){ 
                     this.useSpecialTransition("reverse-looping to end") 
                 }else if(this.itemCompare(this.destinationItem, this.firstDestination(), 'equal')){ 
@@ -23606,8 +23683,9 @@ window.Modernizr = function(n, e, t) {
                 var defaultRotTime = DATA.tourRotTime * 1000
                 var timeEachItem = 2e3 / (DATA.tourWalkSpeed + DATA.tourBlackSpeed) * 200 //预估时间假设每个item飞的时间(如果距离远就少了)
                  
-                //var currentLocation = this.model.heroLocations[this.director.currentItem[0]] 
-                var currentLocation = this.model.getHeroDescriptorByIndex(this.director.currentItem)
+                // zeg 标注一下
+                var currentLocation = this.model.heroLocations[this.director.currentItem[0]] 
+                // var currentLocation = this.model.getHeroDescriptorByIndex(this.director.currentItem)
                 
                 var rotTime
                 if(currentLocation.rotTime == void 0 || currentLocation.rotTime == ''){