xzw 1 год назад
Родитель
Сommit
40553cf26a
2 измененных файлов с 25 добавлено и 9 удалено
  1. 6 5
      src/custom/modules/mergeModel/MergeEditor.js
  2. 19 4
      src/custom/objects/tool/Compass.js

+ 6 - 5
src/custom/modules/mergeModel/MergeEditor.js

@@ -768,12 +768,12 @@ let MergeEditor = {
     },
     
     
-    setGroundPlaneImg(src,scale){//设置地面图
+    setGroundPlaneImg(src,scale,angle){//设置地面图
         
-        this.goundScale = scale
+        this.goundScale = scale || 1, this.goundAngle = angle || 0
         let oldSrc = this.curGroundImgSrc
         this.curGroundImgSrc = src
-        const ratio = 0.04
+        const ratio = 0.03
         
         
         if(src){
@@ -782,14 +782,15 @@ let MergeEditor = {
                 let {width, height} = this.groundPlane.material.map.image
                 this.groundPlane.scale.set(width*s, height*s)  
                 viewer.dispatchEvent('content_changed')
-                
+                this.groundPlane.rotation.z = THREE.Math.degToRad(this.goundAngle)
                 return
             }
             
             let map = texLoader.load(src,(tex)=>{
                 if(this.curGroundImgSrc == src){
                     const s = ratio * this.goundScale
-                    this.groundPlane.scale.set(tex.image.width*s, tex.image.height*s)  
+                    this.groundPlane.scale.set(tex.image.width*s, tex.image.height*s) 
+                    this.groundPlane.rotation.z = THREE.Math.degToRad(this.goundAngle)
                     viewer.dispatchEvent('content_changed')
                 } 
             })

+ 19 - 4
src/custom/objects/tool/Compass.js

@@ -198,7 +198,7 @@ class Compass extends THREE.EventDispatcher{
    
     }
     
-    update(quaternion){
+    update(quaternion){ 
         if(!this.show)return;
         if(!quaternion) quaternion = this.viewport.camera.quaternion.clone();
         this.updateCamera(quaternion)
@@ -277,10 +277,25 @@ class Compass extends THREE.EventDispatcher{
     }
     
     
-    autoJudgeDisplay(){
-         
-    }
     
+    setAutoDisplay(state){//被直接改变了dom的显示
+        
+        this.autoJudgeShow = state
+        
+        if(state){ 
+            this._autoDisplayEvent = ()=>{
+                let oldShow = this.show
+                this.show = !!this.renderer.domElement.clientHeight
+                if(oldShow != this.show){
+                    this.update()
+                }
+            }
+            viewer.addEventListener('update_start',this._autoDisplayEvent)
+          
+        }else{
+            viewer.removeEventListener('update_start',this._autoDisplayEvent)
+        }
+    }
     
     
     setDomPos(){