xzw 4 年之前
父节点
当前提交
fab6db4990
共有 2 个文件被更改,包括 201 次插入27 次删除
  1. 189 21
      js/main_2020_show.js
  2. 12 6
      js/overlay.js

+ 189 - 21
js/main_2020_show.js

@@ -15389,6 +15389,8 @@ window.Modernizr = function(n, e, t) {
             this.quaternion || (this.quaternion = new THREE.Quaternion().setFromEuler(this.rotation)) 
             this.quaternion || (this.quaternion = new THREE.Quaternion().setFromEuler(this.rotation)) 
             this.isSprite = d.isSprite
             this.isSprite = d.isSprite
             this.noAction = d.noAction
             this.noAction = d.noAction
+            this.linkOutside = d.linkOutside
+            
             this.link = d.link;
             this.link = d.link;
 			this.model = model;
 			this.model = model;
 			this.size = d.size;
 			this.size = d.size;
@@ -15401,7 +15403,7 @@ window.Modernizr = function(n, e, t) {
             this.changeTex()
             this.changeTex()
             
             
             this.setVisiblePanos(d.visiblePanos); 
             this.setVisiblePanos(d.visiblePanos); 
-            
+            this.infoAttribute = d.infoAttribute;
 		}
 		}
 		var r = e("three")
 		var r = e("three")
 		, f = e("../shaders")
 		, f = e("../shaders")
@@ -15535,10 +15537,33 @@ window.Modernizr = function(n, e, t) {
 				return null
 				return null
 			}
 			}
 			return g && g.length > 0 && g[0].pano
 			return g && g.length > 0 && g[0].pano
-		},
+		} 
             
             
-		
-		hot.prototype.examine = function(e, hotListSta) { 
+        var getLink = function(link){
+            var src = '';
+            var r = link.substring(link.indexOf("html") + 4)//给热点后面加上随机数,让热点确保是最新的
+              , o = "en" == manage.number("lang") ? "&lang=" + manage.number("lang") : "";//如果热点的内容是英文版的
+            -1 == r.indexOf("?") ? src = link + "?time=" + randomTime().getTime() + "&id=" + window.number + o : src = link + "&time=" + randomTime().getTime() + "&id=" + window.number + o 
+                
+            return src
+            
+        }
+		hot.prototype.examine = function(e, options) { 
+            options = options || {}
+            if(this.linkOutside && this.infoAttribute.iframe && this.infoAttribute.iframe[0] && !options.dontOpen){
+                var src = getLink(this.infoAttribute.iframe[0]);
+                /* var newPage = window.open(src, "_blank" ); 
+                newPage.focus(); */
+                
+                var href = window.location.href
+                var index =  href.indexOf("&")
+                if(index>-1) href = href.substr(0,index)   /* pushState replaceState*/
+                history.pushState(null, "", href+'&qs=1&firstView=pano:'+player.currentPano.id+',qua:'+ player.quaternion.toArray());
+                window.location.href = src
+                return;
+            }
+        
+        
             if(!player.currentPano)return;
             if(!player.currentPano)return;
 			var hotPop = document.getElementById('popup');
 			var hotPop = document.getElementById('popup');
             //获取那个热点的链接 
             //获取那个热点的链接 
@@ -15555,11 +15580,8 @@ window.Modernizr = function(n, e, t) {
                 } 
                 } 
                 if(g_tourAudio)g_tourAudio.pause()
                 if(g_tourAudio)g_tourAudio.pause()
                 
                 
-                //给热点后面加上随机数,让热点确保是最新的
-                var hotLinkParameter = this.link.substring(this.link.indexOf("html")+4);
-                //如果热点的内容是英文版的
-                var lang = manage.number("lang") == "en" ? "&lang="+ manage.number("lang") : "" ;
-                hotLinkParameter.indexOf("?") == -1 ? myElement.src = this.link + "?time="+randomTime().getTime() + "&id=" + window.number +lang : myElement.src = this.link + "&time="+randomTime().getTime() + "&id=" + window.number + lang;
+                var src = getLink(this.link   )
+                myElement.src = src; 
                 myElement.id = "id1";
                 myElement.id = "id1";
 				myElement.allowTransparency = "true";
 				myElement.allowTransparency = "true";
 				// myElement.scrolling = "no";
 				// myElement.scrolling = "no";
@@ -19494,7 +19516,7 @@ window.Modernizr = function(n, e, t) {
                 this.UP = A.UP.clone(),
                 this.UP = A.UP.clone(),
                 this.longestStep = 0,
                 this.longestStep = 0,
                 this.upcomingTransType = null,
                 this.upcomingTransType = null,
-                this.burnsDir = 1,
+                this.burnsDir = 1,  //导览在DOLLHOUSE停留时的旋转方向 1 或 -1
                 this.prevNextDist = 0,
                 this.prevNextDist = 0,
                 this.nextI = 0,
                 this.nextI = 0,
                 this.activeTransType = null,
                 this.activeTransType = null,
@@ -20324,8 +20346,7 @@ window.Modernizr = function(n, e, t) {
             }
             }
             ,
             ,
             n.prototype._warpCameraAim = function(e, t) {
             n.prototype._warpCameraAim = function(e, t) {
-
-            
+     
                 var i = this.warpDestHeroLoc.quaternion
                 var i = this.warpDestHeroLoc.quaternion
                   , n = this.playerControls.cameras[a.PANORAMA]
                   , n = this.playerControls.cameras[a.PANORAMA]
                   , o = new r.Vector3(0,0,1).applyQuaternion(i).normalize()
                   , o = new r.Vector3(0,0,1).applyQuaternion(i).normalize()
@@ -21672,9 +21693,11 @@ window.Modernizr = function(n, e, t) {
                     //window.DownInterface && new DownInterface().state(this,Hot);
                     //window.DownInterface && new DownInterface().state(this,Hot);
                     window.Hotpoint && new Hotpoint().state(this,Hot);
                     window.Hotpoint && new Hotpoint().state(this,Hot);
                 }
                 }
-                if(!this.overlayInitedPlay /* && !settings.isEdit */ && this.overlayGroup.children.length){
-                    this.overlayGroup.children.forEach((overlay)=>{overlay.plane.material.map.image.play()})
-                    this.overlayInitedPlay = true
+                if( this.overlayGroup.children.length){
+                    this.overlayGroup.children.forEach((overlay)=>{
+                        overlay.overlayType == "video" /* && overlay.inSight */&&  overlay.plane.material.map.image.play()
+                    })
+                    //this.overlayInitedPlay = true
                 }
                 }
             }
             }
             ,
             ,
@@ -21976,8 +21999,15 @@ window.Modernizr = function(n, e, t) {
                         this.intersectHot && this.intersectHot.showTitle() 
                         this.intersectHot && this.intersectHot.showTitle() 
                         for(var i in this.model.hots){
                         for(var i in this.model.hots){
                             this.model.hots[i].update(this.camera)
                             this.model.hots[i].update(this.camera)
-                        }
+                        } 
+
                     }
                     }
+
+                    /* if(e.cameraChanged){
+                        this.controlVideosPlay()
+                    } */
+
+
                     this.model.supportsTiles && (this.updateTileDownloader(t),
                     this.model.supportsTiles && (this.updateTileDownloader(t),
                     this.updatePanoRenderer(t)),
                     this.updatePanoRenderer(t)),
                     this.updatePreRendering(t),
                     this.updatePreRendering(t),
@@ -21989,6 +22019,57 @@ window.Modernizr = function(n, e, t) {
                     this.model.supportsTiles && this.updateZoomPano()
                     this.model.supportsTiles && this.updateZoomPano()
                 }
                 }
             }(),
             }(),
+
+
+
+            /* n.prototype.controlVideosPlay = function() {//判断box视频是否可见 不可见就暂停
+                var lastMode, lastPano;
+                return function(){
+                    var mode = this.mode;
+                    var pano = mode == "panorama" ? this.currentPano : "";
+                    
+                    if(mode != "panorama" || pano != lastPano){
+                        overlay.noBlock = null
+                    }
+                    
+                    this.overlayGroup.children.forEach((overlay)=>{
+                        if(overlay.overlayType == "video" ){
+                            var matrix = overlay.plane.matrixWorld;
+                            var inSight = false;
+                            var cameraDir = this.getDirection();
+                            var planeDir = (new r.Vector3).copy(d.FORWARD).applyQuaternion(overlay.plane.quaternion)
+                            var vertexes = []
+                            if(cameraDir.angleTo(planeDir)>Math.PI/2){//朝向相机视线
+                                for(let i=0; i<4; i++){
+                                    var vertex = overlay.plane.geometry.vertices[i].clone().applyMatrix4(matrix)
+                                    vertexes.push(vertex)
+                                    if(overlay.noBlock == null){
+                                        if(!m.ifShelter(vertex)){
+                                            overlay.noBlock = true 
+                                        }
+                                        inSight = true; break;
+                                    }else{
+                                        overlay.noBlock = true
+                                    }
+                                    
+                                    if(m.getPos2d(vertex, this.camera, $("#player")[0]).inSight){
+                                        
+                                        inSight = true; break;
+                                    }
+                                }
+                            }
+                            overlay.inSight = inSight 
+                            if(!inSight)overlay.plane.material.map.image.pause()
+                            else overlay.plane.material.map.image.play()//maybe fail
+                        }
+                    })
+                    lastMode = mode, lastPano = pano
+                }  
+            }() */
+
+
+
+
             n.prototype.updatePersistentZooming = function(e) {
             n.prototype.updatePersistentZooming = function(e) {
                 1 === this.zooming ? this.zoomBy(1 + this.zoomSpeed * e) : this.zooming === -1 && this.zoomBy(1 - this.zoomSpeed * e)
                 1 === this.zooming ? this.zoomBy(1 + this.zoomSpeed * e) : this.zooming === -1 && this.zoomBy(1 - this.zoomSpeed * e)
             }
             }
@@ -22083,7 +22164,7 @@ window.Modernizr = function(n, e, t) {
             }
             }
             ,
             ,
             n.prototype.hasChanged = function(e) {
             n.prototype.hasChanged = function(e) {
-                if (!this.previousState)
+                /* if (!this.previousState)
                     return this.previousState = {
                     return this.previousState = {
                         allFloorsVisible: this.model.allFloorsVisible,
                         allFloorsVisible: this.model.allFloorsVisible,
                         position: this.position.clone(),
                         position: this.position.clone(),
@@ -22125,7 +22206,65 @@ window.Modernizr = function(n, e, t) {
                 this.previousState.modelPosition.copy(this.model.position),
                 this.previousState.modelPosition.copy(this.model.position),
                 this.previousState.modelCenter.copy(this.model.center),
                 this.previousState.modelCenter.copy(this.model.center),
                 this.previousState.zoomLevel = this.zoomLevel,
                 this.previousState.zoomLevel = this.zoomLevel,
-                !t
+                !t */
+
+                if (!this.previousState)
+                    {
+                        this.previousState = {
+                            allFloorsVisible: this.model.allFloorsVisible,
+                            position: this.position.clone(),
+                            quaternion: this.quaternion.clone(),
+                            mouse: this.mouse.clone(),
+                            //labelScaleFactor: this.getLabelScaleFactor(),
+                            currentFloor: this.model.currentFloor,
+                            projectionMatrix: this.camera.projectionMatrix.clone(),
+                            worldMatrix: this.camera.matrixWorld.clone(),
+                            mode: this.mode,
+                            modelPosition: this.model.position.clone(),
+                            modelCenter: this.model.center.clone(),
+                            zoomLevel: this.zoomLevel
+                        };
+                        return !0;
+                    }
+                    //许钟文改 分成相机是否改变cameraChanged 和其他
+                    var a = this.position.equals(this.previousState.position) &&  this.quaternion.equals(this.previousState.quaternion)&& this.camera.matrixWorld.equals(this.previousState.worldMatrix) && this.camera.projectionMatrix.equals(this.previousState.projectionMatrix) && this.mode === this.previousState.mode &&  this.zoomLevel === this.previousState.zoomLevel && this.model.center.equals(this.previousState.modelCenter) && this.model.position.equals(this.previousState.modelPosition)  
+                    var t = a && this.mouse.equals(this.previousState.mouse) && this.model.allFloorsVisible === this.previousState.allFloorsVisible   /* && this.getLabelScaleFactor() === this.previousState.labelScaleFactor */ && this.model.currentFloor === this.previousState.currentFloor  && null === this.nextPano ;
+                    e.cameraChanged = !a;
+                    
+                   /*  if(!t){//主要判断相机是否旋转
+                        e.cameraChanged2 = !MathLight.closeTo(this.quaternion, this.previousState.quaternion, 3) || !MathLight.closeTo(this.position, this.previousState.position, 4)  
+                    }else e.cameraChanged2 = false */
+                    
+                    
+                    e.allFloorsVisible = this.model.allFloorsVisible !== this.previousState.allFloorsVisible,
+                    e.moved = !this.position.equals(this.previousState.position),
+                    e.rotated = !this.quaternion.equals(this.previousState.quaternion),
+                    e.mouseMoved = !this.mouse.equals(this.previousState.mouse),
+                   // e.labelScaleFactor = this.getLabelScaleFactor() !== this.previousState.labelScaleFactor,
+                    e.floorChanged = this.model.currentFloor !== this.previousState.currentFloor,
+                    e.cameraProjectionChanged = !this.camera.projectionMatrix.equals(this.previousState.projectionMatrix),
+                    e.cameraWorldMatrixChanged = !this.camera.matrixWorld.equals(this.previousState.worldMatrix),
+                    e.modeChanged = this.mode !== this.previousState.mode,
+                    e.modelPositionChanged = !this.model.position.equals(this.previousState.modelPosition),
+                    e.modelCenterChanged = !this.model.center.equals(this.previousState.modelCenter),
+                    e.nextPanoActive = null !== this.nextPano,
+                    e.zoomLevel = this.zoomLevel !== this.previousState.zoomLevel,
+                     
+                    this.previousState.allFloorsVisible = this.model.allFloorsVisible,
+                    this.previousState.position.copy(this.position),
+                    this.previousState.quaternion.copy(this.quaternion),
+                    this.previousState.mouse.copy(this.mouse),
+                    //this.previousState.labelScaleFactor = this.getLabelScaleFactor(),
+                    this.previousState.currentFloor = this.model.currentFloor,
+                    this.previousState.projectionMatrix.copy(this.camera.projectionMatrix),
+                    this.previousState.worldMatrix.copy(this.camera.matrixWorld),
+                    this.previousState.mode = this.mode,
+                    this.previousState.modelPosition.copy(this.model.position),
+                    this.previousState.modelCenter.copy(this.model.center),
+                    this.previousState.zoomLevel = this.zoomLevel;
+                    //console.log("cameraChanged2 "+ e.cameraChanged2 + ", mouseMoved "+e.mouseMoved)
+                    
+                    return !t
             }
             }
             ,
             ,
             n.prototype.updateIntersect = function() {
             n.prototype.updateIntersect = function() {
@@ -22143,8 +22282,7 @@ window.Modernizr = function(n, e, t) {
             ,
             ,
 			n.prototype.checkHotClick = function() { 
 			n.prototype.checkHotClick = function() { 
 				if(this.intersectHot){
 				if(this.intersectHot){
-					
-					this.intersectHot.noAction || this.intersectHot.examine(this);
+                    this.intersectHot.noAction || this.intersectHot.examine(this) 
 					
 					
 					
 					
 					
 					
@@ -25773,7 +25911,7 @@ window.Modernizr = function(n, e, t) {
                 softBendTilt: 4,
                 softBendTilt: 4,
                 softBendEnd: .3,
                 softBendEnd: .3,
                 doBurns: true, //r.valueFromHash("kb", !0),
                 doBurns: true, //r.valueFromHash("kb", !0),
-                burnsAngle: 8,
+                burnsAngle: 8, //导览在每个点停留时的旋转角度
                 minBurnsAngle: 35,
                 minBurnsAngle: 35,
                 minDownAngle: -35,
                 minDownAngle: -35,
                 maxTurnPerSec: 280,
                 maxTurnPerSec: 280,
@@ -29673,6 +29811,34 @@ window.Modernizr = function(n, e, t) {
             "use strict";
             "use strict";
             function n(e, t) {
             function n(e, t) {
                 var i = r(t);
                 var i = r(t);
+                 
+                
+                var replaceAll = function (str, f, e) {
+                  //f全部替换成e
+                  var reg = new RegExp(f, "g"); //创建正则RegExp对象   
+                  return str.replace(reg, e);
+                }; 
+                var urlFirstView = c.valueFromHash('firstView');
+                try{  
+                    urlFirstView = replaceAll(urlFirstView, "pano", '"pano"')  
+                    urlFirstView = replaceAll(urlFirstView, "qua:", '"qua":[') 
+                    urlFirstView = "{"+urlFirstView+"]}"
+                    let info = JSON.parse(urlFirstView);   
+                    i.pano = t.list[info.pano] //panos.get(info.pano)
+                    if(!i.pano){
+                        urlFirstView = false
+                        console.error('检测到firstView但是 找不到该pano')
+                    }else{
+                        i.quaternion = new THREE.Quaternion().fromArray(info.qua)
+                        i.zoom = -1;
+                        i.mode = "panorama"
+                        i.setByUrl = true
+                    } 
+                }catch(e){
+                    urlFirstView = false
+                    console.error('检测到firstView但是解析出错'+e)
+                } 
+                 
                 if (Object.keys(i).length > 0)
                 if (Object.keys(i).length > 0)
                     return i;
                     return i;
                 if (e.heroImage)
                 if (e.heroImage)
@@ -30688,7 +30854,9 @@ window.Modernizr = function(n, e, t) {
             isLoaded: function(e) {
             isLoaded: function(e) {
                 return !!a[e]
                 return !!a[e]
             }
             }
+            
         }
         }
+        window.Texture = t.exports
     }
     }
     , {
     , {
         "../settings": 166,
         "../settings": 166,

+ 12 - 6
js/overlay.js

@@ -51,7 +51,7 @@ var initOverlay = function(THREE){
                 video.setAttribute("crossOrigin", 'Anonymous')//要在src设置好前解决跨域
                 video.setAttribute("crossOrigin", 'Anonymous')//要在src设置好前解决跨域
                 $(video).on('contextmenu', function () { return false; });//禁止右键点击出
                 $(video).on('contextmenu', function () { return false; });//禁止右键点击出
                  
                  
-                video.src = info.file;
+                video.src = manage.dealURL(info.file)  ;
                 info.media = video;
                 info.media = video;
                 info.type = "video"
                 info.type = "video"
                 
                 
@@ -61,10 +61,14 @@ var initOverlay = function(THREE){
                 video.volume = 0
                 video.volume = 0
                 video.muted = true
                 video.muted = true
             }else if(info.media.includes('photo')){
             }else if(info.media.includes('photo')){
-                var img = new Image();
-                /* img.src = "https://4dkk.4dage.com/images/images"+Config.projectNum+"/overlay"+this.sid+".jpg?m="+new Date().getTime()
+                /* var img = new Image();
+                 
+                img.src = manage.dealURL(info.file) //"https://4dkk.4dage.com/images/images"+Config.projectNum+"/overlay"+this.sid+".jpg?m="+new Date().getTime()
                 info.media = img
                 info.media = img
-                info.type = "photo"  */
+                 */
+                
+                info.type = "photo"  
+                
             }
             }
             plane.material.opacity = 1;
             plane.material.opacity = 1;
             plane.material.color = new THREE.Color(1,1,1) 
             plane.material.color = new THREE.Color(1,1,1) 
@@ -89,8 +93,10 @@ var initOverlay = function(THREE){
             if(!plane.material.map){
             if(!plane.material.map){
                 if(info.type == "video"){ 
                 if(info.type == "video"){ 
                     plane.material.map = new THREE.VideoTexture( info.media );  
                     plane.material.map = new THREE.VideoTexture( info.media );  
-                }else{
-                    plane.material.map = texture.load(info.media) 
+                }else{  
+                    plane.material.map = Texture.load(info.file,()=>{
+                        if(this._loadDone)this._loadDone()
+                    }) 
                 } 
                 } 
                 plane.material.map.wrapS = plane.material.map.wrapT = THREE.ClampToEdgeWrapping;
                 plane.material.map.wrapS = plane.material.map.wrapT = THREE.ClampToEdgeWrapping;
                 plane.material.map.minFilter = THREE.LinearFilter;
                 plane.material.map.minFilter = THREE.LinearFilter;