Bläddra i källkod

Merge branch 'master' of http://192.168.0.115:3000/chenzhiguang/bigSceneEdit_java

tremble 3 år sedan
förälder
incheckning
7f2c3f3915
4 ändrade filer med 193 tillägg och 20 borttagningar
  1. 12 0
      edit.html
  2. 30 2
      js/edit.js
  3. 77 9
      js/main_2020_edit.js
  4. 74 9
      js/main_2020_show.js

+ 12 - 0
edit.html

@@ -1384,6 +1384,18 @@
                                 <input id="mouseMarkerColor" type="color" />
                                 <input id="mouseMarkerColor" type="color" />
                             </ul>
                             </ul>
                         </li>
                         </li>
+                        <li data-name="floorPlanAngle">
+                            <div class="itemTitle">
+                                <span>平面图方向固定</span>
+                            </div>
+                            <ul class="MenuOptions innerBtn">
+                                <li class="halfCell chosen" index="0">无</li>
+                                <li class="halfCell" index="1">1</li>
+                                <li class="halfCell" index="2">2</li>
+                                <li class="halfCell" index="3">3</li>
+                                <li class="halfCell" index="4">4</li>
+                            </ul>
+                        </li>
                         <li data-name="other">
                         <li data-name="other">
                             <div class="itemTitle">
                             <div class="itemTitle">
                                 <span>其他设置</span>
                                 <span>其他设置</span>

+ 30 - 2
js/edit.js

@@ -129,6 +129,34 @@ EditTools.prototype.init = function() {
     }) 
     }) 
     
     
     
     
+    
+    //平面图方向固定
+    this.fpAngleOptions = new MenuOptions({
+        dom: $(".toolRight .information [data-name=floorPlanAngle]  .MenuOptions"),
+        uiCallBack : (o)=>{    
+            var name = o.name || o.$li.attr('index')
+            
+            _settings.floorPlanAngle = parseFloat(name) * Math.PI/2  //设置好方向 (0是无效的,将不设置)
+             
+            
+            if(name != 0){  
+                if(player.mode != 'floorplan' && player.modeTran.split('-')!= 'floorplan'){
+                    player.flyToMode('floorplan')
+                }else{
+                    player.flyToMode('floorplan',()=>{ 
+                        player.cameraControls.controls.floorplan.rotateToAngle(_settings.floorPlanAngle)
+                    })
+                }
+                
+            } 
+            
+        }, 
+        callbackWhenChose:(o)=>{
+            var name = o.$li.attr('index')
+             
+        }
+    })
+    this.fpAngleOptions.updateChoseAtUI({name: Math.round(_settings.floorPlanAngle/(Math.PI/2))})
 
 
 }
 }
 //点击的时候激活状态
 //点击的时候激活状态
@@ -286,9 +314,9 @@ EditTools.prototype.initSaveAll = function() {
                 cadBorderColor: $('#cadBorderColor').val(),
                 cadBorderColor: $('#cadBorderColor').val(),
                 cadBorderWidth: $('#cad-size').val(),
                 cadBorderWidth: $('#cad-size').val(),
                 showCad: $('input[name="show-cad"]').is(':checked'),
                 showCad: $('input[name="show-cad"]').is(':checked'),
+                /**********/
                 
                 
-                
-                
+                floorPlanAngle: _settings.floorPlanAngle || 0 //俯视图旋转角
             }
             }
  
  
              
              

+ 77 - 9
js/main_2020_edit.js

@@ -3289,24 +3289,87 @@ function o(a, s, l) {
         }
         }
         ,
         ,
         
         
-        n.prototype.getDefaultAbsoluteScale = function(modelSize) {
+        /* n.prototype.getDefaultAbsoluteScale = function(modelSize) {
             var t = Math.max(modelSize.x, modelSize.z)
             var t = Math.max(modelSize.x, modelSize.z)
               , i = Math.min(modelSize.x, modelSize.z)
               , i = Math.min(modelSize.x, modelSize.z)
               , n = Math.max(t, i * this.camera.aspect)
               , n = Math.max(t, i * this.camera.aspect)
               , r = Math.max(i, t * this.camera.aspect);
               , r = Math.max(i, t * this.camera.aspect);
             var absoluteScale = (p.aspectRatio() < 1 ? r : n) / 2 / l.orthoBase * 1.2
             var absoluteScale = (p.aspectRatio() < 1 ? r : n) / 2 / l.orthoBase * 1.2
             return absoluteScale
             return absoluteScale
+        }, */
+        n.prototype.getDefaultAbsoluteScale = function(modelSize, ratio) {
+            let defaultRatio = 1.2 ,   absoluteScale 
+    
+            
+            if(_settings.floorPlanAngle){//指定了角度的话,就和browser.aspectRatio()无关,总使用纵向
+                var angle = parseFloat(_settings.floorPlanAngle)
+                    
+                
+                modelSize = modelSize.clone().applyEuler(new THREE.Euler(0, angle, 0))
+                
+                var n = Math.max(Math.abs(modelSize.x), Math.abs(modelSize.z) * this.camera.aspect) //视口宽高比 >= 1 情况下,模型所占最大视口尺寸
+                
+                var screenSize = Math.min($("#player").width(), $("#player").height())
+                var maxSize = 800;//模型最大占据像素
+                ratio = ratio != void 0 ? ratio :  Math.max(screenSize *  defaultRatio / maxSize,  defaultRatio) ; 
+                
+                absoluteScale = n / 2 / l.orthoBase * ratio;  //根据模型所占最大视口尺寸调整缩放
+            }else{ 
+                var t = Math.max(modelSize.x, modelSize.z)
+                  , i = Math.min(modelSize.x, modelSize.z)
+                  , n = Math.max(t, i * this.camera.aspect)
+                  , r = Math.max(i, t * this.camera.aspect);
+                absoluteScale = (p.aspectRatio() < 1 ? r : n) / 2 / l.orthoBase * defaultRatio 
+            }
+            return absoluteScale
         },
         },
         
         
+         
         
         
-        
-        n.prototype.rotateToView = function(e, t) {
-            var i = 0;
-            p.aspectRatio() < 1 == e.x < e.z ? 0 < t.z && (i = Math.PI) : i = 0 < t.x ? Math.PI / 2 : -Math.PI / 2,
-            this.rotateLeft(i),
-            this.update(0)
+        n.prototype.rotateToView = function(modelSize, direction) {
+            let i = 0, n = p.aspectRatio() < 1  //是否模型尺寸显“细长” 
+              
+            if(_settings.floorPlanAngle ){//规定了cadImage旋转值的话 (0是无效的,将不设置)
+                i = parseFloat(_settings.floorPlanAngle)
+                 
+                
+            }else{ 
+                let r = modelSize.x < modelSize.z; //是否视口为“窄屏”
+                
+                if(n === r)                                     //“细长” 且 “窄屏”,说明模型尺寸比例与视口比例匹配,相机坐标只需要调转“前”“后”
+                {
+                    if(direction.z > 0)                         //(第一种情况)相机是否位于背面。 注:在默认情况下webgl的相机朝向-z, direction.z > 0 说明相机视野已经偏向+z,说明相机位于模型“背面”
+                    {
+                        i = Math.PI;                            //经度上做180度轨道角位移,使相机移到静止模型的“前面”
+                    }
+                                                                //(第二种情况) 不做处理
+
+                }
+                else if(direction.x > 0)                        
+                {
+                    i = Math.PI / 2;                           
+                }
+                else
+                {
+                    i = -Math.PI / 2;                        
+                }
+            }
+              
+
+            this.rotateLeft(i);
+            this.update(0);
+            
+            
         }
         }
         ,
         ,
+        n.prototype.rotateToAngle = function(angle){//add  旋转到特定角度 
+            this.rotateLeft(angle + this.lon);
+            this.update(0); 
+            
+        }
+        ,
+        
+        
         n.prototype.pan = function(e, t) {
         n.prototype.pan = function(e, t) {
             this.camera.updateMatrix(),
             this.camera.updateMatrix(),
             this.panLeft(e * (this.camera.right - this.camera.left) / $("#player").width()),
             this.panLeft(e * (this.camera.right - this.camera.left) / $("#player").width()),
@@ -3510,6 +3573,7 @@ function o(a, s, l) {
             n += this.phiDelta,
             n += this.phiDelta,
             n = Math.max(this.minPolarAngle, Math.min(this.maxPolarAngle, n)),
             n = Math.max(this.minPolarAngle, Math.min(this.maxPolarAngle, n)),
             n = Math.max(1e-6, Math.min(Math.PI - 1e-6, n));
             n = Math.max(1e-6, Math.min(Math.PI - 1e-6, n));
+            this.lon = i, this.lat = n//add
             var r = this.updateZoom();
             var r = this.updateZoom();
             r = Math.max(this.minDistance, Math.min(this.maxDistance, r)),
             r = Math.max(this.minDistance, Math.min(this.maxDistance, r)),
             this.target.add(this.panVector),
             this.target.add(this.panVector),
@@ -13917,7 +13981,7 @@ function o(a, s, l) {
                 t.hotIconScale = parseFloat(t.hotIconScale || 1) 
                 t.hotIconScale = parseFloat(t.hotIconScale || 1) 
                 window.DATA = t
                 window.DATA = t
                 
                 
-                 
+                  
                 
                 
                 t.model.summary = t.summary
                 t.model.summary = t.summary
                 t.model.name = t.name
                 t.model.name = t.name
@@ -14153,7 +14217,11 @@ function o(a, s, l) {
                                 }
                                 }
                                  
                                  
                             }
                             }
-                                    
+                            
+                            {//其他
+                                _settings.floorPlanAngle = DATA.floorPlanAngle || 0  
+                            }
+                                  
                             
                             
                             
                             
                             
                             

+ 74 - 9
js/main_2020_show.js

@@ -3386,24 +3386,86 @@ window.Modernizr = function(n, e, t) {
             this.currentScale = this.absoluteScale
             this.currentScale = this.absoluteScale
         }
         }
         ,
         ,
-        n.prototype.getDefaultAbsoluteScale = function(modelSize) {
-            var t = Math.max(modelSize.x, modelSize.z)
-              , i = Math.min(modelSize.x, modelSize.z)
-              , n = Math.max(t, i * this.camera.aspect)
-              , r = Math.max(i, t * this.camera.aspect);
-            var absoluteScale = (h.aspectRatio() < 1 ? r : n) / 2 / o.orthoBase * 1.2 
+        n.prototype.getDefaultAbsoluteScale = function(modelSize, ratio) {
+            let defaultRatio = 1.2 ,   absoluteScale 
+    
+            
+            if(_settings.floorPlanAngle){//指定了角度的话,就和browser.aspectRatio()无关,总使用纵向
+                var angle = parseFloat(_settings.floorPlanAngle)
+                    
+                
+                modelSize = modelSize.clone().applyEuler(new THREE.Euler(0, angle, 0))
+                
+                var n = Math.max(Math.abs(modelSize.x), Math.abs(modelSize.z) * this.camera.aspect) //视口宽高比 >= 1 情况下,模型所占最大视口尺寸
+                
+                var screenSize = Math.min($("#player").width(), $("#player").height())
+                var maxSize = 800;//模型最大占据像素
+                ratio = ratio != void 0 ? ratio :  Math.max(screenSize *  defaultRatio / maxSize,  defaultRatio) ; 
+                
+                absoluteScale = n / 2 / o.orthoBase * ratio;  //根据模型所占最大视口尺寸调整缩放
+            }else{ 
+                var t = Math.max(modelSize.x, modelSize.z)
+                  , i = Math.min(modelSize.x, modelSize.z)
+                  , n = Math.max(t, i * this.camera.aspect)
+                  , r = Math.max(i, t * this.camera.aspect);
+                absoluteScale = (h.aspectRatio() < 1 ? r : n) / 2 / o.orthoBase * defaultRatio 
+            }
             return absoluteScale
             return absoluteScale
         },
         },
         
         
         
         
-        n.prototype.rotateToView = function(e, t) {
+        /* n.prototype.rotateToView = function(e, t) {
             var i = 0
             var i = 0
               , n = h.aspectRatio() < 1
               , n = h.aspectRatio() < 1
               , r = e.x < e.z;
               , r = e.x < e.z;
             n === r ? t.z > 0 && (i = Math.PI) : i = t.x > 0 ? Math.PI / 2 : -Math.PI / 2,
             n === r ? t.z > 0 && (i = Math.PI) : i = t.x > 0 ? Math.PI / 2 : -Math.PI / 2,
             this.rotateLeft(i),
             this.rotateLeft(i),
             this.update(0)
             this.update(0)
+        },
+         */
+        n.prototype.rotateToView = function(modelSize, direction) {
+            let i = 0, n = h.aspectRatio() < 1  //是否模型尺寸显“细长” 
+              
+            if(_settings.floorPlanAngle ){//规定了cadImage旋转值的话 (0是无效的,将不设置)
+                i = parseFloat(_settings.floorPlanAngle)
+                 
+                
+            }else{ 
+                let r = modelSize.x < modelSize.z; //是否视口为“窄屏”
+                
+                if(n === r)                                     //“细长” 且 “窄屏”,说明模型尺寸比例与视口比例匹配,相机坐标只需要调转“前”“后”
+                {
+                    if(direction.z > 0)                         //(第一种情况)相机是否位于背面。 注:在默认情况下webgl的相机朝向-z, direction.z > 0 说明相机视野已经偏向+z,说明相机位于模型“背面”
+                    {
+                        i = Math.PI;                            //经度上做180度轨道角位移,使相机移到静止模型的“前面”
+                    }
+                                                                //(第二种情况) 不做处理
+
+                }
+                else if(direction.x > 0)                        
+                {
+                    i = Math.PI / 2;                           
+                }
+                else
+                {
+                    i = -Math.PI / 2;                        
+                }
+            }
+              
+
+            this.rotateLeft(i);
+            this.update(0);
+            
+            
+        }
+        ,
+        n.prototype.rotateToAngle = function(angle){//add  旋转到特定角度 
+            this.rotateLeft(angle + this.lon);
+            this.update(0); 
+            
         }
         }
+        
+        
         ,
         ,
         n.prototype.pan = function(e, t) {
         n.prototype.pan = function(e, t) {
             this.camera.updateMatrix(),
             this.camera.updateMatrix(),
@@ -3619,9 +3681,10 @@ window.Modernizr = function(n, e, t) {
               , n = Math.atan2(Math.sqrt(this.offset.x * this.offset.x + this.offset.z * this.offset.z), this.offset.y);
               , n = Math.atan2(Math.sqrt(this.offset.x * this.offset.x + this.offset.z * this.offset.z), this.offset.y);
             this.autoRotate && this.rotateLeft(this.getAutoRotationAngle()),
             this.autoRotate && this.rotateLeft(this.getAutoRotationAngle()),
             i += this.thetaDelta,
             i += this.thetaDelta,
-            n += this.phiDelta,
+            n += this.phiDelta, 
             n = Math.max(this.minPolarAngle, Math.min(this.maxPolarAngle, n)),
             n = Math.max(this.minPolarAngle, Math.min(this.maxPolarAngle, n)),
             n = Math.max(f, Math.min(Math.PI - f, n));
             n = Math.max(f, Math.min(Math.PI - f, n));
+            this.lon = i, this.lat = n//add
             var r = this.updateZoom();
             var r = this.updateZoom();
             r = Math.max(this.minDistance, Math.min(this.maxDistance, r)),
             r = Math.max(this.minDistance, Math.min(this.maxDistance, r)),
             this.target.add(this.panVector),
             this.target.add(this.panVector),
@@ -14437,7 +14500,9 @@ window.Modernizr = function(n, e, t) {
                         DATA.tourRotTime = settings.tourRotTime; //默认停留2秒
                         DATA.tourRotTime = settings.tourRotTime; //默认停留2秒
                     }
                     }
                 }
                 }
-                
+                {//其他
+                    _settings.floorPlanAngle = DATA.floorPlanAngle || 0  
+                }
             }).fail(e=>{
             }).fail(e=>{
                 alert("缺少someData文件,请检查场景码是否正确。")
                 alert("缺少someData文件,请检查场景码是否正确。")
             })
             })