xzw il y a 1 an
Parent
commit
2b72a2eab1
2 fichiers modifiés avec 101 ajouts et 25 suppressions
  1. 100 24
      public/lib/potree/potree.js
  2. 1 1
      public/lib/potree/potree.js.map

+ 100 - 24
public/lib/potree/potree.js

@@ -76988,7 +76988,7 @@ void main()
 	            
 	            
 	            
-	        }else if(prop.type == 'obsg' || prop.type == 'b3dm'){  //3d tiles  
+	        }else if(prop.type == 'osgb' || prop.type == 'b3dm'){  //3d tiles  
 	        
 	            let callback = (object)=>{
 	                 
@@ -77647,7 +77647,7 @@ void main()
 	    pickFrontPointRatio:config$1.pickFrontPointRatio, //默认pick点云时选中靠近镜头的点的偏向
 	    dragPolyBeyondPoint: browser.urlHasValue('dragPolyBeyondPoint'),  //ctrlPolygon是否可以拖拽到没点云的地方
 	    panoZoomByPointer: false,//全景图是否定点缩放
-
+	    areaAtNotPlane: false
 	};
 
 
@@ -96134,7 +96134,7 @@ void main()
 	        this.type = type;
 	        
 	        this.maxMarkers = Number.MAX_SAFE_INTEGER;
-	      
+	       
 	         
 	        this.transformData(prop);
 	        for(let i in prop){
@@ -96659,10 +96659,13 @@ void main()
 	    
 	    }
 	    
-	    getPoint2dInfo(points){ //在更新areaplane之前必须更新过point2dInfo
-	        if(this.facePlane && this.atPlane){ 
+	    getPoint2dInfo(points){ //在更新areaplane之前必须更新过point2dInfo (针对所有点在同一平面上的)
+	        if(this.facePlane && (this.atPlane || Potree.settings.areaAtNotPlane)){
+	 
+	            let facePlane = this.getFacePlane();  
+	            
 	            var originPoint0 = points[0].clone(); 
-	            var qua = math.getQuaBetween2Vector(this.facePlane.normal, new Vector3(0,0,1), new Vector3(0,0,1));
+	            var qua = math.getQuaBetween2Vector(facePlane.normal, new Vector3(0,0,1), new Vector3(0,0,1));
 	            let points2d = points.map(e=>e.clone().applyQuaternion(qua));  
 	        
 	            this.point2dInfo = {
@@ -96764,31 +96767,101 @@ void main()
 	         
 	        
 	        if(this.points.length>2){
-	            if(this.point2dInfo){
-	                this.areaPlane.geometry = MeshDraw.getShapeGeo(this.point2dInfo.points2d);
-	                let center = math.getCenterOfGravityPoint(this.point2dInfo.points2d); //重心 
-	                      
-	                let firstPos =  this.point2dInfo.points2d[0].clone();
-	                firstPos.z = 0;                  //因为shape只读取了xy,所以位移下, 再算出最终位置,得到差距
-	                firstPos.applyQuaternion(this.point2dInfo.quaInverse);
-	                let vec = this.point2dInfo.originPoint0.clone().sub(firstPos);
-	                center = new Vector3(center.x, center.y, 0);
-	                center.applyQuaternion(this.point2dInfo.quaInverse);
-	                this.areaPlane.quaternion.copy(this.point2dInfo.quaInverse); 
-	                this.areaPlane.position.copy(vec);       
-	                center.add(vec);
-	                this.center = center; 
-	            }else {//prism 
 	            
+	            if(this.isPrism){
 	                let z = this.horizonZ || 0;
 	                let points2d = this.points.map(e=>e.clone().setZ(z));
 	                this.areaPlane.geometry = MeshDraw.getShapeGeo(points2d); //z=0
 	                let center = math.getCenterOfGravityPoint(points2d); //重心 
 	                this.areaPlaneCenter = new Vector3(center.x, center.y, z);
 	                this.areaPlane.position.z = z;
+	            }else if(this.point2dInfo){
+	            
+	                if(Potree.settings.areaAtNotPlane){
+	                    //测点不在同一平面的面积.   (缺点:容易出现三角缺块, 以及搭错线导致超出理想边界外。故暂不开放) //测试桥面 SG-arqnGgAR7om&formal
+	                    //参考 http://indoor.popsmart.cn:8084/sxswsw-sx/   找到场景中面积测量线的方法:window.scene.children[18].children[0].material.color.r = 1
+	                    let geometry = new Geometry; 
+	                    let faceArray = [], triangles;
+	                    
+	                     /* if(window.used3){ //更差 
+	                        const xyPoints = this.points.map(d => d.toArray());
+	                        const mesh2D = d3.Delaunay.from(xyPoints);  
+	                        triangles = []
+	                        for(let i=0;i<mesh2D.triangles.length/3;i++){
+	                            triangles.push([mesh2D.triangles[i*3],mesh2D.triangles[i*3+1],mesh2D.triangles[i*3+2]])
+	                        } 
+	                    }else{  */
+	                        triangles = ShapeUtils.triangulateShape(this.point2dInfo.points2d, [] );
+	                    //}
+	                     
+	                    
+	                    if(triangles.length == 0)return
+	                    this._area = 0;
+	                    for( var i = 0; i < triangles.length; i++ ){
+	                        faceArray[i] = new Face3( triangles[i][0], triangles[i][1], triangles[i][2] );
+	                        let nor = new Vector3().crossVectors(
+	                            new Vector3().subVectors(this.points[triangles[i][0]], this.points[triangles[i][2]] ),
+	                            new Vector3().subVectors(this.points[triangles[i][1]], this.points[triangles[i][2]])
+	                        ); 
+	                        this._area += nor.length() / 2;
+	                        nor.normalize();
+	                        faceArray[i].normal.copy(nor);
+	                    }
+	                    geometry.vertices = this.points;
+	                    geometry.faces = faceArray;
+	                   
+
+	                    this.areaPlane.geometry = new BufferGeometry().fromGeometry(geometry); //不知道为何不转为bufferGeometry显示不出
+	                    
+	                    //this.center
+	                    //参考getFacePlane  在这里建立_normal?
+	                    
+	                    
+	                    
+	                    
+	                    /* let center = this.getCenter()
+	                          
+	                    let firstPos =  this.point2dInfo.points2d[0].clone()
+	                    firstPos.z = 0                  //因为shape只读取了xy,所以位移下, 再算出最终位置,得到差距
+	                    firstPos.applyQuaternion(this.point2dInfo.quaInverse)
+	                    let vec = this.point2dInfo.originPoint0.clone().sub(firstPos)
+	                    center = new THREE.Vector3(center.x, center.y, 0)
+	                    center.applyQuaternion(this.point2dInfo.quaInverse)
+	                    this.areaPlane.quaternion.copy(this.point2dInfo.quaInverse) 
+	                    this.areaPlane.position.copy(vec)       
+	                    center.add(vec)
+	                    this.center = center
+	                     */
+	                    
+	                    
+	                    
+	                    
+	                }else {
+	                    //if(this.point2dInfo){//旧的。 之前的规定点要在同一平面
+	                        this.areaPlane.geometry = MeshDraw.getShapeGeo(this.point2dInfo.points2d);
+	                        let center = math.getCenterOfGravityPoint(this.point2dInfo.points2d); //重心 
+	                              
+	                        let firstPos =  this.point2dInfo.points2d[0].clone();
+	                        firstPos.z = 0;                  //因为shape只读取了xy,所以位移下, 再算出最终位置,得到差距
+	                        firstPos.applyQuaternion(this.point2dInfo.quaInverse);
+	                        let vec = this.point2dInfo.originPoint0.clone().sub(firstPos);
+	                        center = new Vector3(center.x, center.y, 0);
+	                        center.applyQuaternion(this.point2dInfo.quaInverse);
+	                        this.areaPlane.quaternion.copy(this.point2dInfo.quaInverse); 
+	                        this.areaPlane.position.copy(vec);       
+	                        center.add(vec);
+	                        this.center = center;
+	                    
+	                    //}
+	                    
+	                }
 	                
+	          
+	             
+	                 
 	            }
 	        }else {
+	             
 	            this.areaPlane.geometry = new Geometry();
 	            
 	        } 
@@ -97365,7 +97438,9 @@ void main()
 	        
 	    getArea(){ 
 	        let area;
-	        if(this.point2dInfo){
+	        if(this._area != void 0){
+	            area = this._area;
+	        }else if(this.point2dInfo){
 	            area = Math.abs(math.getArea(this.point2dInfo.points2d));//this.getArea();
 	        }else {//mulDistance Ring 2d面
 	            area = Math.abs(math.getArea(this.points));
@@ -98148,13 +98223,14 @@ void main()
 	                side:DoubleSide,
 	                opacity:0.2,
 	                transparent:true,
-	                useDepth:true 
+	                useDepth:true,             
 	            })), 
 	            selected: new MeshBasicMaterial({
 	                color:  color ,
 	                side:DoubleSide,
 	                opacity:0.3,
 	                transparent:true, 
+	                //wireframe:true                
 	            })
 	        },Measure$1.planeMats = planeMats);
 	        return super.createAreaPlane(planeMats.default)
@@ -98246,7 +98322,7 @@ void main()
 	                   
 	        }else if(prop.measureType == 'Area'){
 	            prop.showDistances = true,  
-	            prop.atPlane = true,                
+	            Potree.settings.areaAtNotPlane || (prop.atPlane = true);                
 	            prop.showEdges = true,
 	            prop.closed = true, 
 	            prop.minMarkers = 3;  

Fichier diff supprimé car celui-ci est trop grand
+ 1 - 1
public/lib/potree/potree.js.map