xzw 4 years ago
parent
commit
5d37e7f686
2 changed files with 181 additions and 112 deletions
  1. 165 78
      web/public/static/js/main_2020_show.js
  2. 16 34
      web/public/static/js/overlay.js

+ 165 - 78
web/public/static/js/main_2020_show.js

@@ -4964,42 +4964,49 @@ window.Modernizr = function(n, e, t) {
                     
                 }    
 
-                
                 if (this.onTheBus = !0,
                 this.emit("update.controls"),
                 this.player.updateLastView(),
-                !n && this.atDestinationPano())
+                !n && this.atDestinationPano()){
+                    var r = this.model.getHeroDescriptorByIndex(this.destinationItem)
+                    if(r.zoom && r.zoom != this.player.zoomLevel){//add
+                        this.player.smoothZoomFovTo(null, r.zoom, a.warp.teleportTime) //瞬间过渡的时间
+                    }
                     return void this.arrivedAtDestination(!0);
+                }
                 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
-                      , a = null;
+                      , a1 = null;
                     if (r.isPano()) {
                     
                         //var s = 0 === this.destinationItem || e ? u.BLACK : this.nextWarpStyle;
                         //var walk = window.MP_PREFETCHED_MODELDATA.black ? 'black' : 'walk';
-                        var s = this.getMomentTour(this.destinationItem)   //window.MP_PREFETCHED_MODELDATA.momentTour || "walk";
-
+                                                                                                                                 
                      
-                        if(e == 'noMusic'){
-                            var aim = new THREE.Vector3(0,0,-1).applyQuaternion(r.quaternion).add(r.position)   
-                            a = this.player.flyToPano.bind(this.player, {pano: this.model.panos.index[r.panoId], lookAtPoint: aim }, this.actionComplete.bind(this))
-                        }else{
-                            a = this.player.warpToPanoByHeroIndex.bind(this.player, this.destinationItem, v.Show, m.Slow,  s, true, i, this.actionComplete.bind(this))
-                        }
-                        
+                        var s1 = this.getMomentTour(this.destinationItem)   //window.MP_PREFETCHED_MODELDATA.momentTour || "walk";
+                        a1 = this.player.warpToPanoByHeroIndex.bind(this.player, this.destinationItem, v.Show, m.Slow,  s1, true, i, this.actionComplete.bind(this)),
                         o = this.arrivedAtDestination.bind(this, !0)
-                        
+                     
+                        if(r.zoom && r.zoom != this.player.zoomLevel){//add
+                            this.player.smoothZoomFovTo(null, r.zoom, a.warp.teleportTime) //瞬间过渡的时间
+                                                                                                                                                                    
+                              
+                                                                                                                                                                      
+                        }
+                    
+                                                                    
+                    
                     } else{
-                        a = this.player.warpToNonPanoByHeroIndex.bind(this.player, this.destinationItem, this.actionComplete.bind(this)),
+                        a1 = this.player.warpToNonPanoByHeroIndex.bind(this.player, this.destinationItem, this.actionComplete.bind(this)),
                         o = this.arrivedAtDestination.bind(this, !1);
                     }
                     this.transitionStage = y.Moving,
                     this.model.fadePanoMarkers(0),
                     this.awaitCompletion(function() {
-                        a();          
+                        a1();          
                     }
                     .bind(this), o),
                     this.emit("update.controls") 
@@ -5289,21 +5296,21 @@ window.Modernizr = function(n, e, t) {
                 }
                   
                 
-                var momentTour = this.getMomentTour(this.destinationItem);
-                if ( "black" === momentTour) { // 方奕卓 瞬间过渡, 相机缩放至1
-                    var zoomLevel = this.player.zoomLevel;
-                    this.player.zoomEnabled = true;
-                    var zoom = function(e, d) {
-                        this.player.zoomTo((1-e)*zoomLevel, true)        
-    
-                    }.bind(this)
-                    s.start(zoom, 1500, function(){
-                        
-                    }, 0, d.easeOutQuad, "zoom")
-                } 
-                
+               
+                 
                 this.goToDestination()
             }
+            
+            
+            
+            
+            
+            
+            
+            
+            
+            
+            
             ,
             n.prototype.getMomentTour = function(destinationItem) {//add
                 var wholeMomentTour = window.MP_PREFETCHED_MODELDATA.momentTour || "walk"; //最外层
@@ -20301,9 +20308,9 @@ window.Modernizr = function(n, e, t) {
             ,
             n.prototype.getHeroDescriptorByHeroIndex = function(e) {
                 var t = this.model.heroCount();
-                if (null !== this.warpDestHeroLoc && t < 2)
+                /* if (null !== this.warpDestHeroLoc && t < 2)
                     return y.info("ShowPath.getHeroDescriptorByHeroIndex() -> Only one hero location is available."),
-                    this.model.getHeroDescriptorByIndex(0);
+                    this.model.getHeroDescriptorByIndex(0); */
                 var i = this.model.getHeroDescriptorByIndex(e);
                 if (i) {
                     var n = i.isPano() ? i.panoId : i.cameraMode;
@@ -20818,6 +20825,7 @@ window.Modernizr = function(n, e, t) {
                             var l = this.playerControls.cameras[a.PANORAMA];
                             n.setFromQuaternion(l.quaternion, c.warp.eOrder);
                             var u = r * s / i;
+                            u = Math.sign(u) * Math.max(u, 0.0001) //add  如果音频长的话,使旋转可见,否则以为停住了
                             n.y += u,
                             o.set(0, 0, -1),
                             o.applyEuler(n),
@@ -20832,18 +20840,7 @@ window.Modernizr = function(n, e, t) {
                 this.startWarpState(),
                 p.start(u, i, h, 0, d.easeInOutQuad, "wait")
 
-                //zoom动画  方奕卓  相机缩放 
-                var currentGuide = player.model.getHeroDescriptorByIndex(player.director.currentItem)  
-                if(currentGuide.zoom && currentGuide.zoom != this.player.zoomLevel){
-                    this.player.zoomEnabled = true;
-                    var startZoom = this.player.zoomLevel
-                    var zoom = function(e, d) { 
-                        var zoomLevel = currentGuide.zoom.toFixed(2) * e + startZoom * (1-e);
-                        this.player.zoomTo( zoomLevel, true)        
-
-                    }.bind(this)
-                    p.start(zoom, 2000, null, 0, d.easeOutQuad, "zoom")
-                }
+                
             }
             ,
             n.prototype.warpToNonPano = function(e) {
@@ -20865,6 +20862,18 @@ window.Modernizr = function(n, e, t) {
                     e && e()
             }
             ,
+            
+            
+            
+            
+            
+            
+            
+            
+            
+            
+            
+            
             n.prototype._resetWarpShaderParams = function(e) {
                 this.player.mode === a.PANORAMA && (void 0 !== e.material.uniforms.blackout && (e.material.uniforms.blackout.value = 0),
                 void 0 !== e.material.uniforms.modelAlpha && (e.material.uniforms.modelAlpha.value = 0))
@@ -21640,7 +21649,7 @@ window.Modernizr = function(n, e, t) {
                 this.mouseDown = !1,
                 this.mouseDownTimer = null,
                 this.couldBeLongTap = !1,
-                this.containsMouse = !0,
+                this.containsMouse = !1, //
                 this.isTouchEvent = !1,
                 this.isPanoHover = !1,
                 this.reticule = new a(this),
@@ -23256,20 +23265,35 @@ window.Modernizr = function(n, e, t) {
                     }
                     hots[index].mesh.visible = visible; 
                 } 
-            },
+            } 
+            var getQuaByAim = function (aim, center) {
+                return new THREE.Quaternion().setFromUnitVectors(new THREE.Vector3(0, 0, -1), aim.clone().sub(center).normalize())
+                //或var _ = (new THREE.Matrix4).lookAt(pano.position, aim, new THREE.Vector3(0,1,0));  aimQua = (new THREE.Quaternion).setFromRotationMatrix(_);
+            } 
+            
             n.prototype.flyToPano = function(e, t) {
-                console.log(e.pano.id)
+                                      
 
                 var i = e.pano
-                  , n = e.lookAtPoint
+                  , aim = e.lookAtPoint
+                  , aimQua = e.quaternion //ADD
                   , o = e.duration
                   , a = e.aimDuration
                   , s = e.maxDistanceOverride
                   , l = e.skipWarpingCheck
                   , c = e.constantMoveSpeed
                   , h = null
-                  , p = null;
-                  window.specialScene && specialScene.special().specifySpot && specialScene.special().specifySpot(i);
+                  , p = null 
+                
+                if (aim) aimQua = getQuaByAim(aim, i.position)
+                else aimQua = aimQua 
+            
+                var zoomLevel = e.zoomLevel || 1  //add  
+                  
+                if(this.flying) return t && t(e)  
+                window.specialScene && specialScene.special().specifySpot && specialScene.special().specifySpot(i);
+                
+                
                 if (this.isWarping() && !l && (this.path.activeTransType === x.BLACK || this.path.activeTransType === x.STD))
                     return F.warn("Player.flyToPano() -> Cannot fly when warping"),
                     t && t(),
@@ -23277,12 +23301,12 @@ window.Modernizr = function(n, e, t) {
                 if (this.updateLastView(),
                 this.mode !== u.PANORAMA) {
                     var m;
-                    return n && (m = (new r.Quaternion).setFromUnitVectors(d.FORWARD, n.sub(i.position).normalize())),
+                                                                                                                      
                     void this.flyToNewMode({
                         mode: u.PANORAMA,
                         pano: i,
                         duration: o,
-                        quaternion: m,
+                        quaternion: aimQua ,
                         callback: t
                     })
                 }
@@ -23308,40 +23332,45 @@ window.Modernizr = function(n, e, t) {
                         var E = s || f.transition.flytimeMaxDistanceThreshold;
                         I = Math.min(this.currentPano.position.distanceTo(i.position), E) * f.transition.flytimeDistanceMultiplier + f.transition.flyTime
                     }
+                    
+                    
                     if (f.transition.flySpeed > .01 && (I = 1e3 * this.currentPano.position.distanceTo(i.position) / f.transition.flySpeed),
-                    1 !== this.zoomLevel)
+                    zoomLevel !== this.zoomLevel)
                         switch (f.zoom.transitionStyle) {
-                        case 1:
-                            this.smoothZoomToDefault(I / 2);
+                        case 1: 
+                            this.smoothZoomFovTo(null, zoomLevel, zoomLevel == 1 ? I / 2 : I); //改
                             break;
                         case 2:
                             return h = g.deepExtend(e),
                             p = this.flyToPano.bind(this, h, t),
-                            void this.smoothZoomToDefault(f.zoom.restoreTime * (this.zoomLevel - 1), p)
+                            void this.smoothZoomFovTo(null, zoomLevel, f.zoom.restoreTime * (this.zoomLevel - 1), p)
                         }
-                    if (n) {
+                        
+                        
+                        
+                    if (aimQua) {
                         y.cancelById(V.LookTransition),
                         I *= f.transition.aimSlowFactor;
                         var b = this.cameraControls.activeControl.camera.quaternion.clone()
-                          , _ = (new r.Matrix4).lookAt(i.position, n, d.UP)
-                          , T = (new r.Quaternion).setFromRotationMatrix(_)
+                          
+                                                                           
                           , S = b.clone()
                           , M = new r.Vector3;
                         if (i === this.currentPano) {
                             var R = d.FORWARD.clone().applyQuaternion(b)
-                              , P = d.FORWARD.clone().applyQuaternion(T)
+                              , P = d.FORWARD.clone().applyQuaternion(aimQua)
                               , O = R.angleTo(P);
                             return void 0 !== a && null !== a || (a = 1 * Math.sqrt(O) / f.tags.navigate.rotateSpeedFactor * 1e3),
                             void y.start(function(e) {
                                 S.copy(b),
-                                v.quaternion(S, T)(e),
+                                v.quaternion(S, aimQua)(e),
                                 M.copy(d.FORWARD).applyQuaternion(S).add(this.cameraControls.activeControl.camera.position),
                                 this.cameraControls.activeControl.lookAt(M)
                             }
                             .bind(this), a, C, 0, A[f.transition.movementEasing], null, V.LookTransition)
                         }
                     }
-                    if (i === this.currentPano || this.flying)
+                    if (i === this.currentPano )
                         return void C();
                     this.flying = !0;
                     var L = this.position.clone()
@@ -23366,17 +23395,17 @@ window.Modernizr = function(n, e, t) {
                         this.model.changefloorLogoOpa({index:1, opa:1, dur: 250})//this.model.floorLogoShow(1,250);
                     }
                     //=======================================
-
+            
                     
-                    n && y.start(function(e) {
+                    aimQua && y.start(function(e) {
                         S.copy(b),
-                        v.quaternion(S, T)(e),
+                        v.quaternion(S, aimQua)(e),
                         M.copy(d.FORWARD).applyQuaternion(S).add(this.cameraControls.activeControl.camera.position),
                         this.cameraControls.activeControl.lookAt(M)
                     }
                     .bind(this), I, null, 0, A[f.transition.movementEasing], null, V.LookTransition);
                     var B = c ? null : A[f.transition.movementEasing];
-                    this.nextPano = i 
+                    this.nextPano = i,
                     
                     
                     //===========================
@@ -24081,20 +24110,20 @@ window.Modernizr = function(n, e, t) {
                 var currentLocation = this.model.heroLocations[this.director.currentItem[0]] 
                 var restChildCount = currentLocation.heroLocations ? (currentLocation.heroLocations.length-this.director.currentItem[1]-1) : 0
                 var current = g_tourAudio ? 1e3 * g_tourAudio.currentTime : 0
-                var waitTime = currentLocation && currentLocation.musicInfo.music ? currentLocation.musicInfo.time - current : 2e3;  
+                var rotTime = currentLocation && currentLocation.musicInfo.music ? currentLocation.musicInfo.time - current : 2e3;  
                 
                 if(restChildCount){//如果当前folder中还有剩下的item,平分一下时间
                     var timeEachItem = 2000;//假设每个item飞的时间
-                    var waitTime = Math.max(0, (waitTime-timeEachItem*restChildCount) / (restChildCount+1));
+                    var rotTime = (rotTime-timeEachItem*restChildCount) / (restChildCount+1);
                      
                 } 
-                
-                // console.log("waitTime "+waitTime +" at item "+this.director.currentItem + ",musicCurrentTime:"+current) 
+                rotTime = Math.max(0, rotTime)
+                //console.log("rotTime "+rotTime +" at item "+this.director.currentItem + ",musicCurrentTime:"+current) 
                   
 
                 this.path.waitNextStep(e, function() {
                     t && t()
-                }.bind(this), waitTime)
+                }.bind(this), rotTime)
             }
             ,
             n.prototype.stopInterlude = function() {
@@ -24128,15 +24157,30 @@ window.Modernizr = function(n, e, t) {
                 }) : u.PANORAMA && (e.scan_id = this.currentPano.id),
                 e) : e
             }
+            
             ,
             n.prototype.getCurrentNodePanos = function(e) {
                 this.model.panos.map;
-                if (e.length = 0,
-                this.path.nodes)
-                    for (var t = 0; t < this.path.nodes.length; t++) {
-                        var i = this.path.nodes[t];
-                        e.push(this.model.panos.get(i))
+                if (e.length = 0, this.path.nodes){
+                    
+                    var momentTour = this.director.getMomentTour(this.director.destinationItem)  
+                    if(momentTour == 'black'){ //改 upcomingPanos如果是black的只需要起点和终点
+                        if(this.path.nodes.length){
+                            e.push(this.model.panos.get(this.path.nodes[0]))
+                        }
+                        if(this.path.nodes.length>1){
+                            e.push(this.model.panos.get(this.path.nodes[this.path.nodes.length-1]))
+                        }
+                    }else{ 
+                        for (var t = 0; t < this.path.nodes.length; t++) {
+                            var i = this.path.nodes[t];
+                            e.push(this.model.panos.get(i))
+                        }
                     }
+                    
+                    
+                    
+                }
             }
             ,
             n.prototype.zoomIncrementally = function(e) {
@@ -24225,6 +24269,22 @@ window.Modernizr = function(n, e, t) {
 
                 y.start(r, e, o, null, 0, A[f.transition.blendEasing])
             }
+            n.prototype.smoothZoomFovTo = function (fov, zoomLevel, dur, callback) {//add
+                
+                var i,
+                    n = this.zoomLevel,
+                    aimLevel = zoomLevel || this.baseFov / fov
+
+                if (n == aimLevel) return
+
+                var fun = function (e) {
+                    e > 1 && (e = 1), (i = n * (1 - e) + e * aimLevel),
+                    this.zoomTo(i, !0)
+                }.bind(this)
+
+                y.start(fun, dur, callback, null, 0, A[f.transition.blendEasing])
+            }
+                    
             ,
             n.prototype.updateZoomPano = function() {
                 if (!this.panoRenderer.zoomPanoRenderingDisabled && this.mode === u.PANORAMA) {
@@ -30065,7 +30125,7 @@ window.Modernizr = function(n, e, t) {
                         var t = e.neighbourPanos || e.findNeighourPanos()
                           , i = [];
                         for (var n in t)
-                            i.push(this.index[n]);
+                            t[n] && i.push(this.index[n]);  //add: t[n] &&
                         return i
                     }
                     .bind(this),
@@ -30530,7 +30590,7 @@ window.Modernizr = function(n, e, t) {
             }
         }
         var r = e("../exception/DeviceMismatchException");
-        t.exports = {
+        window.browser = t.exports = {
             isFullscreen: function() {
                 return document.fullscreenElement || document.mozFullscreenElement || document.mozFullScreenElement || document.webkitFullscreenElement || document.msFullscreenElement
             },
@@ -30862,6 +30922,7 @@ window.Modernizr = function(n, e, t) {
             getHFOVFromVFOV: o,
             getVFOVFromHFOV: a
         }
+        window.MathLight = t.exports
     }
     , {
         "./MathLight": 176
@@ -30992,7 +31053,32 @@ window.Modernizr = function(n, e, t) {
                 for (var i in t.prototype)
                     e.prototype[i] = t.prototype[i]
             }
+            ,
+            
+            getVisiblePano : function(position, options={}){//add
+                var visiblePanos = []; 
+                var B = position.clone(); 
+                var panos = options.panos ||  player.model.panos.list;
+                 
+                panos.forEach((pano)=>{
+                    if(!pano.isAligned())return;
+                    var A = pano.position.clone();
+                      
+                    var ray = new THREE.Raycaster(A.clone(), B.clone().sub(A).normalize(), 0, A.distanceTo(B) - (options.tolerance||0) ) 
+                    var o = ray.intersectObjects(options.model || player.model.colliders, true);
+                     
+                     
+                    if (!o || !o.length)visiblePanos.push(pano );
+                     
+                    
+                })  	  
+             
+                return visiblePanos
+            } 
+       
+            
         },
+        
         Math.sign = function(e) {
             return e < 0 ? -1 : 1
         }
@@ -31175,6 +31261,7 @@ window.Modernizr = function(n, e, t) {
         }
         ,
         t.exports = n
+        window.easing = n
     }
     , {}],
     187: [function(e, t, i) {
@@ -31225,7 +31312,7 @@ window.Modernizr = function(n, e, t) {
     }],
     188: [function(e, t, i) {
         "use strict";
-        t.exports = {
+        window.lerp =  t.exports = {
             vector: function(e, t) {
                 var i = e.clone();
                 return t = t.clone(),
@@ -31784,7 +31871,7 @@ window.Modernizr = function(n, e, t) {
     195: [function(e, t, i) {
         "use strict";
         var n = e("./easing");
-        t.exports = {
+        window.transitions = t.exports = {
             globalDone: null,
             funcs: [],
             counter: 0,

+ 16 - 34
web/public/static/js/overlay.js

@@ -104,42 +104,24 @@ var initOverlay = function(THREE){
         
         if(info.media){ 
             if(info.media.includes('video')){
-                var id = "video"+ this.sid  
-                var video = $(`<video id="${ id }" style='display:none' controls="controls" loop autoplay x5-playsinline="" webkit-playsinline="true" playsinline="true" controlslist="nodownload"></video>`)[0]
-                if(!window.isEdit){
-                    $("body").append(video)
+                var video = $('<video controls="controls" loop x5-playsinline="" webkit-playsinline="true" playsinline="true" controlslist="nodownload"></video>')[0]
+                video.setAttribute("crossOrigin", 'Anonymous')//要在src设置好前解决跨域
+                $(video).on('contextmenu', function () { return false; });//禁止右键点击出
+                 
+                video.src = manage.dealURL(info.file)  ;
+                info.media = video;
+                info.type = "video"
                 
-                    this.videoPlayer = videojs(id, {}, function onPlayerReady() {
-                        videojs.log('Your player is ready!');
-                                   
-                        // In this context, `this` is the player that was created by Video.js.
-                        this.play();
-                  
-
-                        // How about an event listener?
-                        this.on('ended', function() {
-                            videojs.log('Awww...over so soon?!');
-                        });
-                    });
-                }   
+                video.addEventListener('loadeddata', ()=>{
+                    // console.log(this.sid + " loaded!!!")
+                })
                 
                 this.hideWhenPlayDone && video.addEventListener('ended', ()=>{
                     this.visible = false
                 })
-                video.setAttribute("crossOrigin", 'Anonymous')
-                //要在src设置好前解决跨域
-                $(video).on('contextmenu', function() {
-                    return false;
-                });
-                //禁止右键点击出
-
-                video.src = manage.dealURL(info.file);
-                info.media = video;
-                info.type = "video"
-
-                /* video.addEventListener('loadeddata', ()=>{
-                    console.log(this.sid + " loaded!!!")
-                }) */
+                
+                
+                
                 video.volume = 0
                 video.muted = true
                 if(info.loop == false){
@@ -363,15 +345,15 @@ var initOverlay = function(THREE){
         
         
         if(!state || state == 'stop'){
-            this.videoPlayer.pause()
+            this.plane.material.map.image.paused || this.plane.material.map.image.pause()
             if(state == 'stop'){
-                this.videoPlayer.currentTime(0) 
+                this.plane.material.map.image.currentTime = 0;
                 this.playCount = 0
             }
             //console.log("pause")
         }else if(state && (this.loop !== false || this.playCount == 0 || this.plane.material.map.image.currentTime<this.plane.material.map.image.duration)
           && (!this.playPanos || this.playPanos.find(pano=>player.currentPano == pano)  )){ 
-            this.videoPlayer.play()
+            this.plane.material.map.image.paused && this.plane.material.map.image.play()
             this.playCount = this.playCount ? (this.playCount+1) : 1
             //console.log("play")
         }