Selaa lähdekoodia

Merge branch 'dev' of http://192.168.0.115:3000/bill/traffic-laser into dev

bill 1 vuosi sitten
vanhempi
commit
20a37b295f
2 muutettua tiedostoa jossa 25 lisäystä ja 26 poistoa
  1. 24 25
      public/static/lib/potree/potree.js
  2. 1 1
      public/static/lib/potree/potree.js.map

+ 24 - 25
public/static/lib/potree/potree.js

@@ -82246,53 +82246,51 @@ void main()
 	    setEdgeLabelPos(label,p1,p2){ //调整label的位置,使倾斜后看起来在线的中心,而不要挡住端点
 	    setEdgeLabelPos(label,p1,p2){ //调整label的位置,使倾斜后看起来在线的中心,而不要挡住端点
 	        let center = new Vector3().addVectors(p1,p2).multiplyScalar(0.5);  
 	        let center = new Vector3().addVectors(p1,p2).multiplyScalar(0.5);  
 	        
 	        
-	        if(this.lineDir){
+	        if(this.lineDir && this.lineDir.length() > 0){
 	            if(viewer.mainViewport.camera.type == 'OrthographicCamera'){
 	            if(viewer.mainViewport.camera.type == 'OrthographicCamera'){
 	                label.setPos(center); 
 	                label.setPos(center); 
 	            }else {
 	            }else {
+	                //根据视线和线的夹角(后又加入相机和两个端点距离差)来决定标签偏移位置。+
 	                let eyePos = viewer.mainViewport.camera.position;
 	                let eyePos = viewer.mainViewport.camera.position;
 	                let dir = viewer.mainViewport.view.direction; //new THREE.Vector3().subVectors(center,eyePos).normalize()
 	                let dir = viewer.mainViewport.view.direction; //new THREE.Vector3().subVectors(center,eyePos).normalize()
 	                 
 	                 
-	                let centerDir = new Vector3().subVectors(center,eyePos).normalize();
-	                let p1Dir = new Vector3().subVectors(p1,eyePos).normalize();
-	                let p2Dir = new Vector3().subVectors(p2,eyePos).normalize();
-	                
-	                /* let cos1 =  p1Dir.dot(centerDir)
-	                let cos2 =  p2Dir.dot(centerDir)
-	                let diff = Math.abs(cos1/cos2)
-	                diff = math.linearClamp(diff,0,2,  ) */
-	                
-	                let dis1 = p1.distanceToSquared(eyePos);
-	                let dis2 = p2.distanceToSquared(eyePos);
-	                let diff = Math.abs(dis1/dis2);
-	                diff<1 && (diff = 1/diff);
-	                diff = math.linearClamp(diff,0, 10,    0,1 );
-	                
-	                
-	                
-	                
-	                /* if(centerDir.dot(dir)<0){//中点在相机后方,就不设置
+	                /*let centerDir = new THREE.Vector3().subVectors(center,eyePos).normalize()
+	                if(centerDir.dot(dir)<0){//中点在相机后方,就不设置
 	                    label.setPos(center)
 	                    label.setPos(center)
 	                    return
 	                    return
 	                } */
 	                } */
 	                let cos = dir.dot(this.lineDir); 
 	                let cos = dir.dot(this.lineDir); 
-	                let nearPoint = cos > 0 ? p2 : p1; //近端点。  
-	                let nearPointDir = new Vector3().subVectors(nearPoint,eyePos);
+	                let nearPoint = cos > 0 ? p2 : p1; //近端点。 
+	                let far = cos > 0 ? p1 : p2; //远端点。 
+	                let nearPointDir = new Vector3().subVectors(nearPoint,eyePos);//.normalize()
 	                //使label在中点和近端点中变化, 近端点可能到了相机后方,需要投影到相机所在平面上
 	                //使label在中点和近端点中变化, 近端点可能到了相机后方,需要投影到相机所在平面上
 	                if(nearPointDir.dot(dir)<0){//近端点到了相机后方,前移。 
 	                if(nearPointDir.dot(dir)<0){//近端点到了相机后方,前移。 
+	                //let hfov = cameraLight.getHFOVForCamera(viewer.mainViewport.camera , true  ); //暂且只看水平fov 
+	                //if(nearPointDir.dot(dir)<Math.cos(hfov/2)){//近端点在镜头外,前移。    --但是这个就得把点转化成在镜头边缘而非左右两边(camDirPlane上)
 	                    let ray = new Raycaster();
 	                    let ray = new Raycaster();
 	                    ray.set(nearPoint, cos>0?this.lineDir:this.lineDir.clone().negate());
 	                    ray.set(nearPoint, cos>0?this.lineDir:this.lineDir.clone().negate());
 	                    let camDirPlane = new Plane().setFromNormalAndCoplanarPoint(dir,  eyePos); 
 	                    let camDirPlane = new Plane().setFromNormalAndCoplanarPoint(dir,  eyePos); 
 	                    nearPoint = ray.ray.intersectPlane(camDirPlane, new Vector3()); 
 	                    nearPoint = ray.ray.intersectPlane(camDirPlane, new Vector3()); 
+	                    
+	                    if(!nearPoint)console.error('no?',cos, this.lineDir, p1, p2, dir);
 	                } 
 	                } 
-	                
-	                //let vec = label.sprite.lineDir
 	                  
 	                  
-	                let efficiency = 0.3; // 0-1  数值越高,r越容易接近1或-1,label越容易在倾斜后靠近近端点。 
+	                  
+	                //防止离远了之后也偏移很多,但远了之后相机到端点vec和到中点的vec的夹角接近,不需要怎么偏移的。  
+	                let dis1 = nearPoint.distanceToSquared(eyePos);
+	                let dis2 = far.distanceToSquared(eyePos);
+	                let diff = Math.abs(dis1/dis2);
+	                diff<1 && (diff = 1/diff);
+	                diff = math.linearClamp(diff,0, 30,    0,1 ); 
+	                  
+	                  
+	                  
+	                let efficiency = 0.7; // 0-1  数值越高,r越容易接近1或-1,label越容易在倾斜后靠近近端点。 
 	                //let r = 0.5*efficiency*cos + 0.5  
 	                //let r = 0.5*efficiency*cos + 0.5  
 	                let r = 0.5*efficiency*diff*cos + 0.5;
 	                let r = 0.5*efficiency*diff*cos + 0.5;
 	                r = MathUtils$1.clamp(r,0.1,0.9);
 	                r = MathUtils$1.clamp(r,0.1,0.9);
 	                
 	                
+	                //视线越接近线的方向,标签应该越往近端点偏移,防止看起来几乎在远端。
 	                if(cos > 0){
 	                if(cos > 0){
 	                    center = p1.clone().multiplyScalar(1-r).add(nearPoint.clone().multiplyScalar(r)); //label在线上滑动,使尽量保持在视觉中心
 	                    center = p1.clone().multiplyScalar(1-r).add(nearPoint.clone().multiplyScalar(r)); //label在线上滑动,使尽量保持在视觉中心
 	                }else {
 	                }else {
@@ -103734,6 +103732,7 @@ ENDSEC
 	        this.box.rotation.set(0,0, this.boxData.rotAngle); 
 	        this.box.rotation.set(0,0, this.boxData.rotAngle); 
 	    }, 
 	    }, 
 	    setScale(s){
 	    setScale(s){
+	        s = Math.max(0.0001, s);  //0的话相当于没有box所以不能为0
 	        this.boxData.scaleXY = s;
 	        this.boxData.scaleXY = s;
 	        this.box.scale.x = viewer.bound.boundSize.x * s;
 	        this.box.scale.x = viewer.bound.boundSize.x * s;
 	        this.box.scale.y = viewer.bound.boundSize.y * s; 
 	        this.box.scale.y = viewer.bound.boundSize.y * s; 

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1 - 1
public/static/lib/potree/potree.js.map