xzw 3 years ago
parent
commit
a64eb6bf64
4 changed files with 109 additions and 47 deletions
  1. 37 10
      js/Hot.js
  2. 6 1
      js/main_2020_edit.js
  3. 50 26
      js/main_2020_show.js
  4. 16 10
      js/manage.js

+ 37 - 10
js/Hot.js

@@ -2,6 +2,19 @@
 //合并热点和展览 
 g_currentHot = null
 
+
+
+
+
+ 
+
+const playVideoWhenFlyOut = false
+
+const playCountMax = 2;//同时可播放的最大个数
+
+
+
+
 window.initHot = function(model){
       
     var objLoader = new THREE.OBJLoader()    
@@ -335,12 +348,11 @@ window.initHot = function(model){
                 }else{
                     if(!this.info.texSrc)return
                     var video = $(`<video  controls="controls" loop autoplay x5-playsinline="" webkit-playsinline="true" playsinline="true" controlslist="nodownload"></video>`)[0]
-                    video.src = manage.dealURL(this.info.texSrc);
+                    if(window.isEdit) video.src = manage.dealURL(this.info.texSrc);
                     video.name = this.info.fileName
                 } 
                 
                 
-                
                 video.setAttribute("crossOrigin", 'Anonymous')//要在src设置好前解决跨域
                 
                 $(video).on('contextmenu', function() {
@@ -351,9 +363,10 @@ window.initHot = function(model){
                 this.texMedia = video;
                   
                 video.oncanplaythrough = ()=> {
-                    if(this.texMedia == video){
-                        this.material_.map.needsUpdate = !0 
-                        video.play() 
+                    if(this.texMedia == video){ 
+                        this.material_.map.needsUpdate = !0  
+                        this.update(player) 
+                        //video.play() 
                     } 
                 }
                 
@@ -898,6 +911,13 @@ window.initHot = function(model){
                   
                 var cornerPointInfo = this.getCornerPoint(); 
                 var cornerPoint
+                
+                
+                if(cornerPointInfo.diffLon < 3  || cornerPointInfo.diffLat < 3 ){
+                    //console.log('two far and small')
+                    return false
+                }
+                
                 if(cornerPointInfo.diffLon < 15 && cornerPointInfo.diffLat < 15){//当很小的时候,只判断中心点即可
                     cornerPoint = [cornerPointInfo.cornerPoint[0]];
                 }else{
@@ -912,7 +932,7 @@ window.initHot = function(model){
                 }
                  
             }else{//飞出要判断模型阻挡,有点耗时就算了
-                return true
+                return playVideoWhenFlyOut//true
             }
         }
                 
@@ -921,7 +941,7 @@ window.initHot = function(model){
         update(player){
          
             if(player.mode == 'panorama'){//实时监测播放
-                if(this.texType == "video"){
+                if(this.texType == "video" && !player.flying){ //飞行时不判断
                     if(this.visible && !this.pausedByUser && this.inSight()){
                         this.videoControl(true) 
                     }else{
@@ -965,15 +985,21 @@ window.initHot = function(model){
            
         }
         
+        loadVideo(video){
+            if(video.src)return 
+            video.src = manage.dealURL(this.info.texSrc); 
+        }
 
 
         videoControl(state){
             if(this.texType != "video" || !this.material_.map)return
             var video = this.material_.map.image
+           
+            
             if(!state || state == 'stop'){
                 if(!video.paused){
                     video.pause()
-                    //console.log("pause " + this.sid)
+                    console.log("pause " + this.sid)
                 }
                
                 if(state == 'stop'){
@@ -983,8 +1009,9 @@ window.initHot = function(model){
                  
             }else if(state){
                 if(video.paused){
+                    this.loadVideo(video)
                     video.play()
-                    //console.log("play " + this.sid)                    
+                    console.log("play " + this.sid)                    
                 }                    
                   
             }
@@ -1564,7 +1591,7 @@ window.initHot = function(model){
             console.log('requestDownload', e.hot.info.texSrc)
             e.hot.requestDownload(e.type, ()=>{
                 var i = loadings.indexOf(e)
-                console.log('requestDownloaded index', i)
+                //console.log('requestDownloaded index', i)
                 i > -1 && loadings.splice(i,1)
             })
         })

+ 6 - 1
js/main_2020_edit.js

@@ -20303,7 +20303,7 @@ function o(a, s, l) {
                 this.bindEvents(e.container),
                 this.updateModel()
                 
-                window.bus.dispatchEvent({type:'playerAndModelReady'})
+                
                 
             }
             ,
@@ -20979,6 +20979,9 @@ function o(a, s, l) {
             t.prototype.startInside = function(e, t, i, n, r) {
                 r = r || $.Deferred();
                 var o = (this.currentPano = e) && !e.isAligned();
+                
+                window.bus.dispatchEvent({type:'playerAndModelReady'}) 
+                
                 if (t = o ? e.position : t || e.position,
                 i = i || e.quaternion,
                 e) {
@@ -22256,6 +22259,8 @@ function o(a, s, l) {
                 
                 this.emit(W.ModeChanging, u, i, n, p)
                 n && (this.currentPano = n)
+                window.bus.dispatchEvent({type:'playerAndModelReady'}) 
+                
                 
                 this.switchCameraMode(i, l)
                 

+ 50 - 26
js/main_2020_show.js

@@ -5003,7 +5003,7 @@ window.Modernizr = function(n, e, t) {
             
             
             
-            n.prototype.playTourNearBy = function() {
+            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),
@@ -5245,7 +5245,8 @@ window.Modernizr = function(n, e, t) {
             }
             ,
             n.prototype.getMomentTour = function(destinationItem) {//add
-                var wholeMomentTour = window.DATA.momentTour || "walk"; //最外层
+              
+                var wholeMomentTour = window.DATA.momentTour || "walk"; //最外层  还有一种是'std'
                  
                 if(!destinationItem) return wholeMomentTour
                 else{
@@ -17689,36 +17690,58 @@ window.Modernizr = function(n, e, t) {
                 return a.get(t, {
                     responseType: "json",
                     auth: this.isPublic ? null : f.authorizationHeader
-                }).done(function(e) {
+                }).done(function(e) { 
+                    
                     window.data2 = e;
                     this.roomLabels = []
                     if(!e){
                         console.error("data2 is null") 
-                    }else{  
+                    }else{   
                         g_data2 = hotMatcher(e);
                         this.hotsCount = 0; 
                         
-                        //因为热点保存后在hots里的顺序会被修改,所以使用order来记录顺序,这里要重排序:
-                        if(e.hots){  
-                            var sids = Object.keys(e.hots).sort((a,b)=>{return e.hots[a].order - e.hots[b].order});
-                            sids.forEach((sid)=>{
-                                e.hots[sid].sid = sid
-                                new Hot(e.hots[sid], e.hots[sid].version != 'multi' && "byHot" )
-                            })
+                        let create = ()=>{
+                            
+                            //因为热点保存后在hots里的顺序会被修改,所以使用order来记录顺序,这里要重排序:
+                            if(e.hots){  
+                                var sids = Object.keys(e.hots).sort((a,b)=>{return e.hots[a].order - e.hots[b].order});
+                                sids.forEach((sid)=>{
+                                    e.hots[sid].sid = sid
+                                    
+                                    //if(e.hots[sid].texType == "shine" || e.hots[sid].texType == "photo" ){
+                                        
+                                        //e.hots[sid].styleImg = []
+                                        
+                                        
+                                        new Hot(e.hots[sid], e.hots[sid].version != 'multi' && "byHot" )
+                                    //}
+                                })
+                            } 
+                            
+                            if(e.overlays){
+                                e.overlays.forEach((info)=>{ 
+                                    //if(info.file.includes('m/data/762/edit/20210312_112357584.mp4') )return;
+                                    new Hot(info, 'byOverlay')  
+                                })
+                            } 
+                            Hot.createHotList();
+                            Hot.startLoad()  
+                            if(DATA.roomLabels){
+                                DATA.roomLabels.forEach((data)=>{
+                                    this.roomLabels.push(new RoomLabel(data))
+                                })
+                            }
+                            
+                            
                         }
-                        
-                        if(e.overlays){
-                            e.overlays.forEach((info)=>{ 
-                                //if(info.file.includes('m/data/762/edit/20210312_112357584.mp4') )return;
-                                new Hot(info, 'byOverlay')  
-                            })
-                        } 
-                        Hot.createHotList();
-                        Hot.startLoad()  
-                        if(DATA.roomLabels){
-                            DATA.roomLabels.forEach((data)=>{
-                                this.roomLabels.push(new RoomLabel(data))
-                            })
+                        if(player.currentPano){
+                            create()
+                        }else{
+                            let f = ()=>{
+                                window.bus.removeEventListener('playerAndModelReady',f) 
+                                create() 
+                            }
+                            window.bus.addEventListener('playerAndModelReady',f) 
                         }
                         
                         g_index = w.valueFromHash("m");
@@ -21403,7 +21426,7 @@ window.Modernizr = function(n, e, t) {
                 this.updateModel()
                 this.modeTran = ''
                 
-                window.bus.dispatchEvent({type:'playerAndModelReady'})
+                
             }
 			 
 			
@@ -22037,6 +22060,7 @@ window.Modernizr = function(n, e, t) {
             n.prototype.startInside = function(e, t, i, n, r) {
                 r = r || $.Deferred(),
                 this.currentPano = e;
+                window.bus.dispatchEvent({type:'playerAndModelReady'})
                 var o = e && !e.isAligned();
                 if (t = o ? e.position : t || e.position,
                 i = i || e.quaternion,
@@ -23455,7 +23479,7 @@ window.Modernizr = function(n, e, t) {
                 n && (this.currentPano = n),
                 this.switchCameraMode(i, c),
                 y.cancelById(V.LookTransition);
-                
+                window.bus.dispatchEvent({type:'playerAndModelReady'}) 
                 
                 
                  //before fly---------------------

+ 16 - 10
js/manage.js

@@ -1297,7 +1297,12 @@ function initByTHREE(THREE){
             if(window.player.model){
                 this.init()
             }else{
-                window.bus.addEventListener('playerAndModelReady',this.init.bind(this))
+                let f = ()=>{
+                    window.bus.removeEventListener('playerAndModelReady',f) 
+                    this.init() 
+                }
+                window.bus.addEventListener('playerAndModelReady',f) 
+                   
             }
             
         }
@@ -1441,15 +1446,18 @@ function initByTHREE(THREE){
     }
     window.RoomLabel = RoomLabel
 
-    window.bus.addEventListener('playerAndModelReady',()=>{
+
+
+    let f = ()=>{
+        window.bus.removeEventListener('playerAndModelReady',f)
+         
         player.on("mode.changing",(currentMode, mode, pano, duration)=>{ 
             let noLine = mode == 'floorplan';
             if(noLine){
                 $('.widgets-doll-labels').addClass('noLine').addClass('noCorner')
             }else{
                 $('.widgets-doll-labels').removeClass('noLine').removeClass('noCorner')
-            }
-        
+            } 
         })
         
         
@@ -1462,11 +1470,9 @@ function initByTHREE(THREE){
                      
                  //} 
              } 
-        })
-        
-        
-        
-    })
+        })  
+    }
+    window.bus.addEventListener('playerAndModelReady',f) //player model currentPano都已有
     
     
     
@@ -1552,7 +1558,7 @@ var SoundManager = {//暂不支持同时播放
             if(object.audio){
                 object.audio.pause()
                 object.callback && object.callback(false)
-                Log(name + ' 中断音频 '+  "("+common.getFileNameFromUrl(object.audio.src)+')' )
+                object.audio.src && Log(name + ' 中断音频 '+  "("+common.getFileNameFromUrl(object.audio.src)+')' )
             }