Parcourir la source

fix: 就近导览

xzw il y a 3 ans
Parent
commit
9cb1b28cbf
2 fichiers modifiés avec 82 ajouts et 4 suppressions
  1. 1 1
      js/Hot.js
  2. 81 3
      js/main_2020_show.js

+ 1 - 1
js/Hot.js

@@ -1488,7 +1488,7 @@ window.initHot = function(model){
                             {
                                 e._loadDones.forEach(a=>a())
                                 e._loadDones = null
-                                e.photoHasRequestLoad = true
+                                //e.photoHasRequestLoad = true  //这句不能加,否则会无法执行callback
                             }
                             e.material_.needsUpdate = true
                             

+ 81 - 3
js/main_2020_show.js

@@ -4908,8 +4908,57 @@ window.Modernizr = function(n, e, t) {
                     .bind(this), this.goNext.bind(this))
             }
             ,
+            
+            
+            
+            
+            n.prototype.findNearestItem = function(){//找到离currentPano最近的导览
+                var result = {item:[0,0], dis:Infinity};
+                var compare = (location, item)=>{
+                    if(location.panoId != void 0 && location.panoId!= "outside"){
+                        var pano = this.model.panos.index[location.panoId];
+                        var dis = pano.position.distanceTo(this.player.currentPano.position)
+                        if(dis<result.dis){
+                            result.item = item, result.dis = dis
+                        }else if(dis == result.dis){//如果两个位置相同,优先播放在导览条上离激活的最近的那段导览 
+                            /* 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])){
+                                result.item = item, result.dis = dis
+                            }
+                            
+                            
+                        }
+                    }
+                    
+                }
+                this.model.heroLocations.forEach((e,i)=>{
+                    if(e.heroLocations){
+                       /* e.heroLocations.forEach((a,j)=>{
+                           compare(a, [i,j])
+                       }) */
+                       var location = e.heroLocations.find(e=>e.panoId != void 0)
+                       location && compare(location, [i,0])
+                       
+                    }else{
+                       compare(e, [i,0])
+                    }  
+                    
+                })
+                return result.item
+                
+            }
+            
+            
+            
+            
+            
+            
+            
+            
             n.prototype.playTour = function() {
-                if (!this.bounceable()) {
+                if (!this.bounceable() && this.model.heroLocations.length) {
 
                     if(!this.currentItem) this.currentItem = []
                     if(this.currentItem[0] != 0 || this.destinationItem[0]!= this.nItems-1){
@@ -4951,6 +5000,34 @@ window.Modernizr = function(n, e, t) {
                     this.goToDestination()) : this.goNext()))
                 }
             } 
+            
+            
+            
+            n.prototype.playTourNearBy = function() {
+                
+                if (!this.bounceable()){
+                    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",
+                    this.tourIsPlaying = !0,
+                    this.wasZoomEnabled = this.player.zoomEnabled,
+                    this.player.zoomEnabled = !1,
+                    this.resetSpecialTransition(),
+                    this.emit("update.controls"),
+                    this.emit(p.TourStart),
+                    this.player.enablePreRendering(),
+ 
+                    /* this.walkingSectionPaused ? (this.clearWalkingSectionPaused(),
+                    this.goToDestination()) : this.goNext())) */
+                    
+                    
+                    this.setDestinationItem(this.findNearestItem()) , this.goToDestination()) )
+               } 
+                
+                
+                
+            }
+            
 			,
 			/* n.prototype.bgmReplay = function() {//xzw add  结束tour后可能要继续播放背景音乐
 			  
@@ -5144,7 +5221,7 @@ window.Modernizr = function(n, e, t) {
                         this.setDestinationItem(item) 
                 }
                 
-                if(this.itemCompare(this.destinationItem, this.finalDestination(), 'equal')[0] < 0 ){ 
+                if(this.itemCompare(this.destinationItem, this.finalDestination(), 'equal')){ 
                     this.useSpecialTransition("reverse-looping to end") 
                 }else if(this.itemCompare(this.destinationItem, this.firstDestination(), 'equal')){ 
                     this.useSpecialTransition("looping back to start")
@@ -8947,6 +9024,7 @@ window.Modernizr = function(n, e, t) {
         }
         function r() {
             C.playTour(),
+            //C.playTourNearBy(),
             I && clearTimeout(I),
             d(),
             _.removeClass("fadeIn")
@@ -23765,7 +23843,7 @@ window.Modernizr = function(n, e, t) {
             ,
             n.prototype.getCurrentNodePanos = function(e) {
                 this.model.panos.map;
-                if (e.length = 0, this.path.nodes){
+                if (e.length = 0, this.path.nodes.length){
                     
                     var momentTour = this.director.getMomentTour(this.director.destinationItem)  
                     if(momentTour == 'black'){ //改 upcomingPanos如果是black的只需要起点和终点