Просмотр исходного кода

热点大小自动调整的bug, panoVisible设置允许转到dollhosue模式,方便看多楼层的情况

xzw 2 лет назад
Родитель
Сommit
856466b098
4 измененных файлов с 106 добавлено и 131 удалено
  1. 3 6
      js/Hot.js
  2. 84 96
      js/edit.js
  3. 6 25
      js/main_2020_edit.js
  4. 13 4
      js/manage.js

+ 3 - 6
js/Hot.js

@@ -970,12 +970,9 @@ window.initHot = function(model){
                     
         updateScale(e, t) {//自适应调节大小 
             if(!DATA.autoAdjustHotScale || this.texType != 'shine' || !this.plane )return
-            //let renderSize = player.sceneRenderer.renderer.domElement 
-            let renderSize = player.sceneRenderer.renderer.getSize()
-            
-            var scale = convertTool.getScaleForConstantSize($.extend(autoSizeInfo,{
-                camera:player.camera,  resolution:{x:renderSize.width, y:renderSize.height},
-                position: this.position.clone() ,
+             
+            var scale = convertTool.getScaleForConstantSize($.extend({},autoSizeInfo,{ 
+                position: this.position.clone()  
             }))
             this.plane.scale.set(scale,scale,scale)
             

+ 84 - 96
js/edit.js

@@ -5295,17 +5295,38 @@ var VisiSet = {
         green: "#00c8ae"
     },
     init: function() {
-        this.footIconSizeRatio =  Math.max(player.model.size.x, player.model.size.z)  / 30; 
+        this.footIconSizeRatio =  Math.max(player.model.size.x, player.model.size.z)  / 25; 
         
         this.meshGroup = new THREE.Object3D;
         this.meshGroup.name = "setVisible-group"
         
         player.model.add(this.meshGroup)
         $("#hotVisible button").on("click", ()=>{
-            VisiSet.enterSet(VisiSet.beginSetTagVisible.bind(VisiSet))
-            
+            VisiSet.enterSet(VisiSet.beginSetTagVisible.bind(VisiSet)) 
+        })
+        
+        
+        player.on("mode.changing",(from,to)=>{
+            if(to == "panorama" && (VisiSet.setPanoVisible || VisiSet.setTagVisible || VisiSet.setPanoLog)){
+                VisiSet.finishSetPanoVisible()
+                VisiSet.finishSetTagVisible()
+                VisiSet.finishSetPanoLog()
+            }
+        })
+        
+        player.model.on("floor.changed",(toFloor)=>{
+            if (VisiSet.setPanoVisible || VisiSet.setTagVisible || VisiSet.setPanoLog ){
+                VisiSet.changePanoVisi(true, toFloor)
+            } 
+        }) 
+        
+        player.on("view.changed",(e)=>{
+            if(e.cameraChanged && (VisiSet.setPanoVisible || VisiSet.setTagVisible || VisiSet.setPanoLog)){
+                VisiSet.updateFootIconSize();
+            }
         })
         
+        
         this.changeBtn.on("click",()=>{//隐藏与显示该点
             if(this.changeBtn.attr("function") == "hide"){
                 for(let i in this.panoVLines){
@@ -5330,7 +5351,7 @@ var VisiSet = {
 				var s = Math.max(-list[1].score*2,   4);	//i==1的一定显示
                 for(var i=1;i<list.length;i++){ 
                     if(-list[i].score < s){  
-                        if(ifBlock(this.panoVsetting, list[i].pano)){
+                        if(ifBlock(this.panoVsetting, list[i].item)){
                             list[i].block = true   //有阻挡 
                         }
                         list[i].good = true  
@@ -5338,12 +5359,12 @@ var VisiSet = {
                         okList || (okList = list.filter(e=>e.good && !e.block));//绝对可以使用的
                           
                         if(okList.length <2 ){
-                            if(!ifBlock(this.panoVsetting, list[i].pano)){
+                            if(!ifBlock(this.panoVsetting, list[i].item)){
                                 if(okList.length == 0){
                                     okList.push(list[i])
                                 }else{//1 
-                                    var lastPos = okList[0].pano.position.clone().sub(this.panoVsetting.position).setY(0);
-                                    var thisPos = list[i].pano.position.clone().sub(this.panoVsetting.position).setY(0);
+                                    var lastPos = okList[0].item.position.clone().sub(this.panoVsetting.position).setY(0);
+                                    var thisPos = list[i].item.position.clone().sub(this.panoVsetting.position).setY(0);
                                     if(lastPos.angleTo(thisPos) > Math.PI / 2){
                                         console.log('再加一个  角度'+THREE.Math.radToDeg(lastPos.angleTo(thisPos)))
                                         break;
@@ -5357,9 +5378,9 @@ var VisiSet = {
                     }
                 }
                 if(okList.length==0){//如果length为0,至少加一个pano, 虽然是遮挡的
-                    okList.push(list[0].pano)
+                    okList.push(list[0].item)
                 }
-                okList.forEach(e=>this.dealPanoVisible(e.pano.id))
+                okList.forEach(e=>this.dealPanoVisible(e.item.id))
                 
                 console.log(okList)
                 
@@ -5379,8 +5400,8 @@ var VisiSet = {
             player.flyToMode("floorplan", fun);
         }
 
-        permitTranMode(false)
-        if (!player.modeTran) {
+        permitTranMode(['dollhouse','floorplan'])
+        if ( player.modeTran == void 0) {
             player.afterCModeFuc = ()=>{
                 enter()
             }
@@ -5407,8 +5428,8 @@ var VisiSet = {
         this.changePanoVisi(true)
     },
      
-    changePanoVisi:function(state){
-        var floor = player.model.allFloorsVisible ? 'all' : player.model.currentFloor
+    changePanoVisi:function(state, toFloor){
+        var floor = player.model.allFloorsVisible ? 'all' : (toFloor || player.model.currentFloor)
         if(this.setPanoVisible){
             if(floor != 'all' && this.panoVsetting && floor != this.panoVsetting.floor){//如果切换到其他楼,取消选中该pano
                 this.pauseSetPanoVisible('unsaved')
@@ -5762,43 +5783,7 @@ var VisiSet = {
                 alert("保存漫游可行失败")
             }
         })
-
-        /* var o = {
-            name_t: "panoVisible",
-            f: this.pauseSetPanoVisible,
-            url: Config.prefixEditProPCApi+"/saveLinkPano",
-            dialog: i18n.get('设置'),
-            data: { data: JSON.stringify(PanoData) }
-        }
-       
-        var dataDeal = uploadsSaving.saveFucforPC(o);
-        dataDeal.group[0] = function () {
-            //实施:
-
-            for (var i in player.panoVTemp) {
-                var pano = player.model.panos.index[i];
-                pano.seeMarkers = player.panoVTemp[i].seeMarkers;
-                pano.neighbourUUIDs = player.panoVTemp[i].neighbourUUIDs;
-                pano.neighbourPanos = player.panoVTemp[i].neighbourPanos;
-            }
-
-            if(!player.model.checkHasNeighbor(player.currentPano)){//currentPano变为孤立点  就要换一个防止飞入
-                var list = player.model.panos.sortByScore([function(pano){return player.model.checkHasNeighbor(pano)}], 
-                    [function(pano){return -pano.position.distanceTo(player.currentPano.position)}])	
-                if(list && list.length){
-                    player.currentPano = list[0].pano;//找最近的一非孤立点
-                    player.model.noPanoHasNeighbor = false; //更新状态
-                }else{
-                    player.model.noPanoHasNeighbor = true; //更新状态
-                } 
-            }else{
-                player.model.noPanoHasNeighbor = false; //更新状态
-            }
-            
-            dataDeal.done();
-            player.model.updateFootIconSize(player.cameraControls.activeControl)//更新一下center大小  写在最后
-        } */
-
+  
     },
 
     searchNeib: function(panoId) {
@@ -5939,10 +5924,9 @@ var VisiSet = {
 
     showFootIcons: function(pano, isPanovisible) {
         if (!this.footIcons) {
-            footTex1 = Texture.load("images/edit/End_128.png");
-            //Store.FootIcon); 
+            footTex1 = Texture.load("images/edit/End_128.png"); 
             footTex2 = Texture.load("images/edit/End_unable_128.png");
-            //Store.FootIcon_unable);
+            footTex1.anisotropy = footTex2.anisotropy = 4
             this.footIcons = [];
             var scale = 0.4;
 
@@ -5971,7 +5955,7 @@ var VisiSet = {
                     name: "footIcon"
                 })
                 var foot = new THREE.Mesh(geo,mat)
-                foot.position.copy( panos.index[r].position.clone().setY(player.model.center.y) )    /* panos.index[r].floorPosition.clone()  *///不用floorPosition是因为有出现和position的水平位置不一样的点,一般是偏移很远的不可见点,拍摄的bug
+                foot.position.copy( panos.index[r].floorPosition.clone()  )    /* panos.index[r].floorPosition.clone()  *///不用floorPosition是因为有出现和position的水平位置不一样的点,一般是偏移很远的不可见点,拍摄的bug
                 
                 foot.lookAt(foot.position.clone().add(new THREE.Vector3(0,1,0)));
                 foot.name = panos.index[r].id;
@@ -5982,9 +5966,8 @@ var VisiSet = {
                 this.footIcons.push(foot)
             }
         }
-        //this.changePanoVisi(true)
-        for (var i = 0; i < this.footIcons.length; i++) {
-            //this.footIcons[i].visible = true;
+        
+        for (var i = 0; i < this.footIcons.length; i++) { 
             this.changeFIconState(this.footIcons[i], false)
             var panos = player.model.panos;
             if (isPanovisible) {
@@ -6085,19 +6068,29 @@ var VisiSet = {
 
     updateFootIconSize: function() {
         //根据相机位置 改变footIcon大小,使在范围内看到的热点大小一致,防止太小点击不到
-        if (!this.footIcons)
-            return;
-        var s = player.cameraControls.controls.floorplan.absoluteScale *  2.8
-        s = THREE.Math.clamp(s, 0.5 * this.footIconSizeRatio, 1.4 * this.footIconSizeRatio);
-        this.footIcons.forEach(function(f) {
-            try {
-
+        if (!this.footIcons)  return;
+        
+        if(player.mode == 'floorplan'){
+            var s = player.cameraControls.controls.floorplan.absoluteScale *  2.8
+            s = THREE.Math.clamp(s, 0.5 * this.footIconSizeRatio, 1.4 * this.footIconSizeRatio);
+            this.footIcons.forEach(function(f) {
+                try { 
+                    f.scale.copy(f.oriScale).multiplyScalar(s); 
+                } catch (e) {
+                    console.log(e)
+                }
+            })  
+        }else{
+            let maxDis = 7, maxScale = 2 * this.footIconSizeRatio,   k = maxScale / maxDis 
+            this.footIcons.forEach(function(f) { 
+                let s
+                let dis = f.position.distanceTo(player.position)
+                if(dis >= maxDis) s = maxScale
+                else s = dis * k 
                 f.scale.copy(f.oriScale).multiplyScalar(s);
-
-            } catch (e) {
-                console.log(e)
-            }
-        })
+                //f.quaternion.copy(player.camera.quaternion)
+            })
+        } 
     },
     
     
@@ -6122,9 +6115,7 @@ var VisiSet = {
                 
                 player.model.panos.list.forEach(pano2=>{
                     if(pano1 == pano2)return
-                    if(pano1.id == '9'&& pano2.id == '0'){
-                        console.log(1)
-                    }
+                     
                     var visiNew = !ifBlock(pano1,pano2)
                     var visiOld = !!(this.panoVLines[pano2.id] && this.panoVLines[pano2.id].visible)
                     if(visiNew != visiOld){
@@ -6262,28 +6253,7 @@ var VisiSet = {
         }
     },
 
-    /* saveTagVisibles : function () { //保存到服务器  
-		if (this.tagVsetting) this.saveLastTagVi(this.tagVsetting); //获取最后设置的那个热点的改动
-		//可能出现数据没变但保存的情况。比如先改变了然后切换别的热点但切换回来时又改回来。
-		var tags = [];
-		for (var i in this.tagVTemp) {
-			tags.push({
-				sid: i,
-				value: this.tagVTemp[i]//turnToPanoIndex(this.tagVTemp[i])
-			})
-		}
-
-		 
-		if (tags.length == 0) {//没有需要保存的改动
-			 
-			this.finishSetTagVisible()
-			return;
-		}
-		 
-		return tags; 
-	} */
-
-    //afterSaveTagVisibles : function(){
+     
     saveTagVisibles: function() {
         if (this.tagVsetting)
             this.saveLastTagVi(this.tagVsetting);
@@ -6387,8 +6357,26 @@ var VisiSet = {
 
 
 
-function permitTranMode(state) {
-    state ? $(".pinBottom.left").removeClass('hide') : $(".pinBottom.left").addClass('hide');
+function permitTranMode(state ) {
+    if(state instanceof Array){//仅显示state包含的模式
+        $(".pinBottom.left").removeClass('hide')
+        $(".pinBottom.left .viewContainer>*:not(#gui-modes-map)").addClass('hide');
+        $(".pinBottom.left #gui-modes-map>*").addClass('hide');
+        //注:panorama需转为inside
+        state.forEach(m=> $(".pinBottom.left #gui-modes-"+m).removeClass('hide'))
+        player.roomLebelClickUnabled = true
+    }else{
+        if(state){
+            player.roomLebelClickUnabled = false
+            $(".pinBottom.left").removeClass('hide'),
+            $(".pinBottom.left .viewContainer>*").removeClass('hide') ,
+            $(".pinBottom.left #gui-modes-map>*").removeClass('hide') 
+        }else{
+            player.roomLebelClickUnabled = true
+            $(".pinBottom.left").addClass('hide');
+        } 
+    }
+    //一旦存在有隐藏的模式,必定会隐藏导览等其他按钮。
 }
 
 

+ 6 - 25
js/main_2020_edit.js

@@ -6287,12 +6287,7 @@ function o(a, s, l) {
                         gui_action: "click_toggle_all_floors_button",
                         interaction_source: "gui"
                     })),
-                    n.removeClass("open")
-                    
-                    //add:
-                    if (window.VisiSet && (VisiSet.setPanoVisible || VisiSet.setTagVisible || VisiSet.setPanoLog)){
-                        VisiSet.changePanoVisi(true)
-                    }
+                    n.removeClass("open") 
                     
                 })
             }
@@ -21252,21 +21247,11 @@ function o(a, s, l) {
                     !this.mouseDown && this.containsMouse && this.updateIntersect()  
                     this.emit(W.ViewChanged, N)
                     //add:
-                    if (window.VisiSet && (VisiSet.setPanoVisible || VisiSet.setTagVisible || VisiSet.setPanoLog)) VisiSet.updateFootIconSize();
-                    
-                    //this.intersectHot && this.intersectHot.showTitle()
-                    
-                    //editTool.hotpoint.showTitileSpots && editTool.hotpoint.showTitileSpots.forEach(e=>e.showTitle())
+                    if(N.cameraChanged){ 
+                        Hot.updateHots()
+                        this.mode == "panorama" && window.cad && cad.setSign({ x: this.position.x, y: this.position.z },this.cameraControls.controls.panorama.lon);
+                    } 
                     
-                    /* for(var i in this.model.hots){
-                        this.model.hots[i].update(this)
-                        this.model.hots[i].updateTitle(this)
-                    } */
-                    Hot.updateHots()
-                    /* if(this.mode == 'panorama')this.model.hotGroup&&this.model.hotGroup.children.forEach(overlay=>{
-                        overlay.update() 
-                    }) */
-                    this.mode == "panorama" && window.cad && cad.setSign({ x: this.position.x, y: this.position.z },this.cameraControls.controls.panorama.lon);
                     
                 }
                 this.model.supportsTiles && (this.updateTileDownloader(F),
@@ -22360,11 +22345,7 @@ function o(a, s, l) {
                 
                 
                 this.modeTran = this.mode + "-" + i;
-                if(this.mode == "floorplan" && window.VisiSet && (VisiSet.setPanoVisible || VisiSet.setTagVisible || VisiSet.setPanoLog)){
-                    VisiSet.finishSetPanoVisible()
-                    VisiSet.finishSetTagVisible()
-                    VisiSet.finishSetPanoLog()
-                }
+               
                 
                 /* if(editTool.atPanel == "screen"){
                     if(this.mode == "panorama") $(".confirmSnap").addClass("unable")

+ 13 - 4
js/manage.js

@@ -237,9 +237,7 @@ var LineDraw = {
         if(o.mat){
             mat = o.mat
         }else{
-            let prop = {
-                lineWidth: o.lineWidth || 1,
-                //windows无效。 似乎mac/ios上粗细有效 ? 
+            let prop = {  
                 color: o.color || defaultColor,
                 transparent: o.dontAlwaysSeen ? false : true,
                 depthTest: o.dontAlwaysSeen ? true : false, 
@@ -462,6 +460,17 @@ var convertTool = {
         var w;  
         var i = new THREE.Vector3, o = new THREE.Vector3, l = new THREE.Vector3, c = new THREE.Vector3, h = new THREE.Vector3
          
+        if(!op.resolution){
+            let renderSize = player.sceneRenderer.renderer.getSize()
+            op.resolution = {x:renderSize.width, y:renderSize.height} 
+        } 
+        if(!op.camera){
+            let camera = player.cameraControls.activeControl ? player.cameraControls.activeControl.camera : player.camera
+            let camera2 = camera.clone(); 
+            camera2.matrixWorld.copy(player.camera.matrixWorld) //因为其他原因该camera的matrixWorld被还原了,而player.camera的是正确的
+            op.camera = camera2
+        }
+         
         if(op.width2d) w = op.width2d //如果恒定二维宽度
         else{//否则考虑上距离,加一丢丢近大远小的效果
             var currentDis, nearBound, farBound
@@ -1441,7 +1450,7 @@ function initByTHREE(THREE){
                     this.elem.css('display','none');	return;
                 }
                     
-                if(this.shelterByModel && convertTool.ifShelter(this.position , p.vector,  this.floorIndex )){
+                if(this.shelterByModel && convertTool.ifShelter(this.position , p.vector, player.camera, this.floorIndex )){
                     this.elem.css('display','none');	return; 
                 }
             }