xzw 1 год назад
Родитель
Сommit
3b6afb8b46
1 измененных файлов с 16 добавлено и 9 удалено
  1. 16 9
      scene/public/static/js/manage.js

+ 16 - 9
scene/public/static/js/manage.js

@@ -2155,8 +2155,19 @@ function initByTHREE(THREE){
                 
             }) 
             
-            
-            
+            //因为一部分漫游点在模型外,想居中模型,所以bound不加pano:
+            {
+               
+                let bounding = new THREE.Box3  //不包含pano的bound
+                player.model.floors.list.forEach(floor=>{
+                    bounding.union(floor.conservativeBoundingBox)
+                })
+             
+                player.model.boundingBox = bounding
+                player.model.size = bounding.size()
+                player.model.center = bounding.center() 
+                
+            }
             
         } 
         
@@ -2472,21 +2483,17 @@ Manage.prototype.switchBgmState = function(state){//按钮的状态完全代表
 var manage = new Manage();
 
 manage.initMapPanoPos = function(width,height){
-    let bounding = new THREE.Box3  //不包含pano的bound
-    player.model.floors.list.forEach(floor=>{
-        bounding.union(floor.conservativeBoundingBox)
-    })
-    let boundSize = bounding.size()
+    
     let data = {}
     
     let imgSize = new THREE.Vector2(width,height)
-    let bound2dSize = new THREE.Vector2(boundSize.x,boundSize.z)
+    let bound2dSize = new THREE.Vector2(player.model.size.x,player.model.size.z)
     
     
     
     player.model.panos.forEach(pano=>{
         let panoPos = new THREE.Vector2(pano.position.x, pano.position.z);
-        let boundMin = new THREE.Vector2(bounding.min.x, bounding.min.z);
+        let boundMin = new THREE.Vector2(player.model.boundingBox.min.x, player.model.boundingBox.min.z);
         let diff = new THREE.Vector2().subVectors(panoPos, boundMin)
         diff.divide(bound2dSize)
         diff.y = 1-diff.y,  diff.x = 1-diff.x   //暂时先这么写,其实应该用旋转角,旋转180度比较适应所有旋转情况