xzw 1 year ago
parent
commit
ceb28fec87
2 changed files with 5 additions and 1 deletions
  1. 1 0
      src/custom/modules/clipModel/Clip.js
  2. 4 1
      src/custom/objects/tool/Measure.js

+ 1 - 0
src/custom/modules/clipModel/Clip.js

@@ -173,6 +173,7 @@ var Clip = {
         this.box.rotation.set(0,0, this.boxData.rotAngle) 
     }, 
     setScale(s){
+        s = Math.max(0.0001, s)  //0的话相当于没有box所以不能为0
         this.boxData.scaleXY = s
         this.box.scale.x = viewer.bound.boundSize.x * s
         this.box.scale.y = viewer.bound.boundSize.y * s 

+ 4 - 1
src/custom/objects/tool/Measure.js

@@ -341,7 +341,7 @@ export class Measure extends ctrlPolygon{
     setEdgeLabelPos(label,p1,p2){ //调整label的位置,使倾斜后看起来在线的中心,而不要挡住端点
         let center = new THREE.Vector3().addVectors(p1,p2).multiplyScalar(0.5);  
         
-        if(this.lineDir){
+        if(this.lineDir && this.lineDir.length() > 0){
             if(viewer.mainViewport.camera.type == 'OrthographicCamera'){
                 label.setPos(center) 
             }else{
@@ -366,6 +366,9 @@ export class Measure extends ctrlPolygon{
                     ray.set(nearPoint, cos>0?this.lineDir:this.lineDir.clone().negate())
                     let camDirPlane = new THREE.Plane().setFromNormalAndCoplanarPoint(dir,  eyePos) 
                     nearPoint = ray.ray.intersectPlane(camDirPlane, new THREE.Vector3()) 
+                    if(!nearPoint){//线是垂直的,视线是水平的时候 
+                        return label.setPos(center) 
+                    } 
                 }