xzw 5 yıl önce
ebeveyn
işleme
a43178ba8f
5 değiştirilmiş dosya ile 147 ekleme ve 24 silme
  1. 29 1
      css/main.css
  2. 6 4
      edit.html
  3. 2 0
      index.html
  4. 52 9
      js/main_2020_edit.js
  5. 58 10
      js/main_2020_show.js

+ 29 - 1
css/main.css

@@ -7054,4 +7054,32 @@ a.hasHover.tag-link:hover {
     #gui-name {
         font-size: 14px;
     }
-}
+}
+
+
+
+
+
+#hot{ 
+	padding: 0;
+	position: relative;
+	width: 100%;
+	height: 100%;
+    pointer-events:none; 
+	z-index: 101; 
+}
+#hot>div{
+    position: absolute;
+    z-index: 999;
+    color: #fff;
+    -webkit-user-select: none;
+    -moz-user-select: none;
+    -ms-user-select: none;
+    user-select: none;
+    border-radius: 5px;
+    background-color: rgba(34, 34, 34, 0.3);
+    display:none;
+    padding:10px;
+    transform:translate(20px, -50%);
+}    
+

+ 6 - 4
edit.html

@@ -100,6 +100,8 @@
                     <!-- 画布区域 -->
                     <div class="webgl-inside">
                         <div class="content">
+                            <div id="hot"> 
+                            </div>
                             <div id="popup">
                                 <div class="popup-content">
 
@@ -1390,17 +1392,17 @@
     </div>
 
     <script> 
-        
+        /*
         //本地:
         var token ="eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhZG1pbiIsInJvbGUiOm51bGwsIm1hbmFnZXIiOm51bGwsImlkIjoxLCJ1c2VyTmFtZSI6ImFkbWluIiwiZXhwIjoxNTk3MTA5MDk0LCJpYXQiOjE1OTcwMjI2OTQsImp0aSI6ImY4YzI1MTcyLWM0NmUtNGNmYi04MjRhLWJkMmU2YWRmOWVjZSJ9.kUEmWOCJ0WONTkUI1vTToLePfzgbLiWwhU5nEWIsvlg"
         var ceshi = 'http://47.107.252.54:8105';
-        /*
+        
         //大场景: 
         var ceshi = 'http://47.107.252.54:8105';
         var token = window.localStorage.dcj_token 
         if (!token) {
            window.location.href = '../list/index.html'
-        }
+        }*/
         
         
         //军史馆:
@@ -1408,7 +1410,7 @@
         var token = window.localStorage.bigscenetoken 
         if (!token) {
            window.location.href = "http://192.168.0.44:8101/bigscene/#/"
-        }*/
+        } 
         
         
         

+ 2 - 0
index.html

@@ -48,6 +48,8 @@
 </head>
 
 <body>
+    <div id="hot"> 
+    </div>
     <div id="popup">
         <div class="popup-content">
 

+ 52 - 9
js/main_2020_edit.js

@@ -6874,7 +6874,7 @@ function o(a, s, l) {
                     }
                     $(".model-title").text(i.name);
                     var t = M.pageTitle;
-                    2 !== S.valueFromHash("mls", 0) && (t = i.name),
+                    2 !== S.valueFromHash("mls", 0) && i.name && (t = i.name),
                     document.title = t,
                     S.isMobile() ? $("#gui-fullscreen").css("display", "none") : ($("[rel=tooltip]").tooltip({
                         delay: {
@@ -14788,7 +14788,7 @@ function o(a, s, l) {
         "use strict";
         function n(e, t, i) {
             this.sid = e,
-            this.position = this.conversionArray(t.position) 
+            this.position = (new g.Vector3).fromArray( this.conversionArray(t.position) )
             
             if(t.quaternion){
                 this.quaternion = t.quaternion;
@@ -14802,6 +14802,7 @@ function o(a, s, l) {
             this.styleTex = [] // 存储热点icon的图片 [{src:...}, {src:...} ] 最多两个,里面是带有src的object, 可以是img
              
             this.build()
+            t.infoAttribute && t.infoAttribute.title && this.createTitleElem(t.infoAttribute.title)
             this.changeTex()
         }
         var g = e("three")
@@ -14810,6 +14811,7 @@ function o(a, s, l) {
           , v = e("../enum/Viewmode")
           , d = e("../objects/Panorama")
           , o = e("../util/texture")
+          , math = e("../util/math")
           , p = new g.Raycaster
           , a = new g.PlaneBufferGeometry(g_HotMeshSize.g_HotMeshWidth,g_HotMeshSize.g_HotMeshHeight,1,1)
            
@@ -14851,7 +14853,7 @@ function o(a, s, l) {
             }))
               , t = parseFloat(window.MP_PREFETCHED_MODELDATA.hotIconScale);
             e.dynamic = !0,
-            e.position.copy((new g.Vector3).fromArray(this.position));
+            e.position.copy(this.position);
             if(this.quaternion){
                 e.quaternion.copy(this.quaternion)
             }else{
@@ -14868,6 +14870,22 @@ function o(a, s, l) {
             
             
         }
+        n.prototype.createTitleElem = function(title){
+            var root = $("#hot");
+            var elem = $(`<div> ${title}</div>`)
+            root.append(elem);
+            this.titleElem = elem;
+        } 
+        n.prototype.showTitle = function(){
+            if(!this.titleElem)return;
+            var pos = math.getPos2d(this.position, player.camera, $("#player")[0])
+            this.titleElem.css( { "left" : `${pos.pos.x}px`,  "top": `${pos.pos.y}px ` });
+            this.titleElem.css("display","block");
+        } 
+        n.prototype.hideTitle = function(){
+            if(!this.titleElem)return;
+            this.titleElem.css("display","none");
+        }
         ,
         n.prototype.closestPanoTowardTag = function(e, t) {
             var i = []
@@ -14984,8 +15002,8 @@ function o(a, s, l) {
                 return e;
             var t = [];
             for (var i in e)
-                t.push(parseFloat(e[i]));
-            return t
+                t.push(parseFloat(e[i])); 
+            return t   
         }
          
         
@@ -14998,7 +15016,8 @@ function o(a, s, l) {
         "../enum/Viewmode": 51,
         "../objects/Panorama": 148,
         "../util/texture": 194,
-        "../settings": 166
+        "../settings": 166,
+        "../util/math": 190,
     }],
     123: [function(M, R, e) {
         (function(e) {
@@ -20856,7 +20875,7 @@ function o(a, s, l) {
                     this.emit(W.ViewChanged)
                     //add:
                     if (window.panoVisiSet && panoVisiSet.setPanoVisible) panoVisiSet.updateFootIconSize();
- 
+                    this.intersectHot && this.intersectHot.showTitle()
                     
                 }
                 this.model.supportsTiles && (this.updateTileDownloader(F),
@@ -21099,6 +21118,7 @@ function o(a, s, l) {
                     window.hotIntersect = !1)
                     return;
                 }
+                this.intersectHot && this.intersectHot.hideTitle() 
                 if (0 === n.length)
                     return this.intersectHot = null,
                     "add" != g_HotStatus && $("#player").css("cursor", ""),
@@ -21106,7 +21126,9 @@ function o(a, s, l) {
                      
                 var o = n[0];
                 if ("hotSprite" == o.object.type){
-                    return this.intersectHot = o.object.belongHot, $(`.toolRight .spotList ul li[data-spid=${this.intersectHot.sid}]`).addClass("active"),
+                    return this.intersectHot = o.object.belongHot,
+                    this.intersectHot.showTitle(),
+                    $(`.toolRight .spotList ul li[data-spid=${this.intersectHot.sid}]`).addClass("active"),
                     void $("#player").css("cursor", "pointer"); 
                 }
                 $(".toolRight .spotList ul li").removeClass("active")
@@ -28801,7 +28823,28 @@ function o(a, s, l) {
                     i.set(t.x, t.y, -1)
                 }
                 n && i.normalize()
-            }
+            },
+            //add:
+            getPos2d : function(point, camera, dom){
+                var camera = camera ;
+                var dom = dom;
+                var pos = point.clone().project(camera)	//比之前hotspot的计算方式写得简单  project用于3转2(求法同shader); unproject用于2转3 :new r.Vector3(e.x, e.y, -1).unproject(this.camera);
+                
+                var x,y;
+                x = (pos.x + 1) / 2 * dom.clientWidth;
+                y = (1 - (pos.y + 1) / 2) * dom.clientHeight; 
+          
+                var inSight = x <= dom.clientWidth &&  x >= 0 
+                            && y <= dom.clientHeight &&  y >= 0 
+             
+            
+                return {
+                    pos: new THREE.Vector2(x,y),
+                    vector:  pos,
+                    trueSide : pos.z<1, //trueSide为false时,即使在屏幕范围内可见,也是反方向的另一个不可以被渲染的点   参见Tag.update
+                    inSight : inSight	//在屏幕范围内可见
+                };
+            },
         }
     }
     , {

+ 58 - 10
js/main_2020_show.js

@@ -6544,8 +6544,8 @@ window.Modernizr = function(n, e, t) {
                 $(".model-title").text(e.name);
                 var i = Q.pageTitle;
                 // 2 !== K.valueFromHash("mls", 0) && (i = e.name + " - " + i),
-                2 !== K.valueFromHash("mls", 0) && (i = e.name),
-                document.title = i,
+                2 !== K.valueFromHash("mls", 0) && i.name && (i = e.name),
+                document.title = i ,
                 K.isMobile() ? $("#gui-fullscreen").css("display", "none") : ($("[rel=tooltip]").tooltip({
                     delay: {
                         show: 50,
@@ -15365,7 +15365,7 @@ window.Modernizr = function(n, e, t) {
         "use strict";
 		function hot(sid,d,model){
 			this.sid = sid;
-            this.position = this.conversionArray(d.position); 
+            this.position = (new r.Vector3).fromArray( this.conversionArray(d.position) )
 			if(d.quaternion){
                 this.quaternion = d.quaternion;
             }else{
@@ -15380,6 +15380,7 @@ window.Modernizr = function(n, e, t) {
             this.styleTex = [] // 存储热点icon的图片 [{src:...}, {src:...} ] 最多两个,里面是带有src的object, 可以是img
             
 			this.build();
+            d.infoAttribute && d.infoAttribute.title && this.createTitleElem(d.infoAttribute.title)
             this.changeTex()
 		}
 		var r = e("three")
@@ -15387,6 +15388,7 @@ window.Modernizr = function(n, e, t) {
 		, a = e("../settings")
 		, s = e("../enum/Viewmode")
 		, p = e("../objects/Panorama")
+        , math = e("../util/math")
         , te = e("../util/texture");
         var raycaster = new r.Raycaster;
         //热点大小
@@ -15431,7 +15433,7 @@ window.Modernizr = function(n, e, t) {
             var sprite = new r.Mesh( geometry, shaderMaterial );
             var hotIconScale = parseFloat(window.MP_PREFETCHED_MODELDATA.hotIconScale);
 			sprite.dynamic = true; 
-			sprite.position.copy(new r.Vector3().fromArray(this.position));
+			sprite.position.copy(this.position);
             if(this.quaternion){
                 sprite.quaternion.copy(this.quaternion)
             }else{
@@ -15447,7 +15449,24 @@ window.Modernizr = function(n, e, t) {
             this.model.add(sprite); 
             g_HotMeshes.push(sprite);
 		}
-		
+        hot.prototype.createTitleElem = function(title){
+            var root = $("#hot");
+            var elem = $(`<div> ${title}</div>`)
+            root.append(elem);
+            this.titleElem = elem;
+        } 
+        hot.prototype.showTitle = function(){
+            if(!this.titleElem)return;
+            var pos = math.getPos2d(this.position, player.camera, $("#player")[0])
+            this.titleElem.css( { "left" : `${pos.pos.x}px`,  "top": `${pos.pos.y}px ` });
+            this.titleElem.css("display","block");
+        } 
+        hot.prototype.hideTitle = function(){
+            if(!this.titleElem)return;
+            this.titleElem.css("display","none");
+        }
+        
+        
 		hot.prototype.closestPanoTowardTag = function(e, t) {
 			var i = []
 			  , o = []
@@ -15614,7 +15633,8 @@ window.Modernizr = function(n, e, t) {
 		"../enum/Viewmode":51,
 		"../objects/Panorama":148,
 		"../util/texture":194,
-		"../settings":166
+		"../settings":166,
+        "../util/math": 190,
 	}], 
 	/************************************创建热点模型************************************ */
     123: [function(e, t, i) {//tag
@@ -21745,8 +21765,11 @@ window.Modernizr = function(n, e, t) {
                     this.updateFromControls(i),
                     this.getCurrentNodePanos(t),
                     this.hasChanged(e) && (this.lastChangeTime = Date.now(),
-                    !this.mouseDown && this.containsMouse && this.updateIntersect(),
-                    this.emit(w.ViewChanged)),
+                        !this.mouseDown && this.containsMouse && this.updateIntersect(),
+                        this.emit(w.ViewChanged),
+                        this.intersectHot && this.intersectHot.showTitle()
+                    
+                    ),
                     this.model.supportsTiles && (this.updateTileDownloader(t),
                     this.updatePanoRenderer(t)),
                     this.updatePreRendering(t),
@@ -22007,7 +22030,7 @@ window.Modernizr = function(n, e, t) {
                     console.log(points[0]);
                     points.length >= 1? ($('#player').css('cursor', 'cell'),window.hotPointPos = points[0].point): ($('#player').css('cursor', 'not-allowed'), window.hotPointsPos = false)
                 }
-				
+				this.intersectHot && this.intersectHot.hideTitle() 
                 if (0 === n.length){
 					this.intersectHot = null;  //add
 					if(g_HotStatus!="add") $("#player").css("cursor","");
@@ -22017,9 +22040,11 @@ window.Modernizr = function(n, e, t) {
                 var o = n[0];
 				if(o.object.type == "hotSprite"){ //add
 					this.intersectHot =  o.object.belongHot; 
+                    this.intersectHot.showTitle() 
 					$("#player").css("cursor","pointer");
 					return;
 				}
+                
 				this.intersectHot = null;
                 
                 var intersect = this.hoverOverlay(this.overlayGroup && o && o.object.parent.parent == this.overlayGroup && o.object)
@@ -30089,7 +30114,30 @@ window.Modernizr = function(n, e, t) {
                     i.set(t.x, t.y, -1)
                 }
                 n && i.normalize()
-            }
+            },
+            //add:
+            getPos2d : function(point, camera, dom){
+                var camera = camera ;
+                var dom = dom;
+                var pos = point.clone().project(camera)	//比之前hotspot的计算方式写得简单  project用于3转2(求法同shader); unproject用于2转3 :new r.Vector3(e.x, e.y, -1).unproject(this.camera);
+                
+                var x,y;
+                x = (pos.x + 1) / 2 * dom.clientWidth;
+                y = (1 - (pos.y + 1) / 2) * dom.clientHeight; 
+          
+                var inSight = x <= dom.clientWidth &&  x >= 0 
+                            && y <= dom.clientHeight &&  y >= 0 
+             
+            
+                return {
+                    pos: new THREE.Vector2(x,y),
+                    vector:  pos,
+                    trueSide : pos.z<1, //trueSide为false时,即使在屏幕范围内可见,也是反方向的另一个不可以被渲染的点   参见Tag.update
+                    inSight : inSight	//在屏幕范围内可见
+                };
+            } 
+         
+            
         }
     }
     , {