xzw 2 months ago
parent
commit
93abaff826

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

@@ -824,7 +824,7 @@ export class Measure extends ctrlPolygon{
         }
     
         
-        if(!ignoreGuideLine && this.measureType == 'Distance'){
+        if(!this.horVerShowAlways && !ignoreGuideLine && this.measureType == 'Distance'){
             this.horEdgeLabel.visible = this.verEdgeLabel.visible = this.horGuideEdge.visible = this.verGuideEdge.visible = !!(state && this.shouldShowHorVerGuide)
         }
     }

+ 19 - 7
src/custom/objects/tool/Path.js

@@ -476,21 +476,27 @@ export class Path extends ctrlPolygon{
             this.curve = null
         }else{
             if(Potree.settings.pathSmooth){//使用曲线
-                let curve = new THREE.CatmullRomCurve3(points, false    )  
+                let curve = this.curve = new THREE.CatmullRomCurve3(points, false    )  
                 curve.UtoTMapArr = [] //用于存储 getSpacedPoints得到的点对应points的百分比对应
-                //window.arcLengthDivisions  && (curve.arcLengthDivisions = arcLengthDivisions) //默认200,但改为1也没变化呀
-                count = Math.max(2, Math.round(this.getTotalDistance() * 400)),  points = curve.getSpacedPoints(count-1) //拆分为更密集的点
-                this.curve = curve
+                let oldCount = count
+                count = Math.max(2, Math.round(this.getTotalDistance() * 200)),  points = curve.getSpacedPoints(count-1) //拆分为更密集的点
+        
+                /* //window.arcLengthDivisions  && (curve.arcLengthDivisions = arcLengthDivisions) //默认200,但改为1也没变化呀
+                let oldCount = count 
                 //减少点数(拐弯的部分紧凑些,直线部分宽松些):
                 let lastVec  
                 let newPoints = []
                 this.UtoTMapArr = []
+                let pointIndexs = []//找出新点中对应原先控制点的index,这些点必须加入拐点,否则会出现控制点偏移path(当它所在部分接近直线时) 
+                for(let n=1;n<oldCount-1;n++){
+                    pointIndexs.push( curve.UtoTMapArr.findIndex(e=>e>= n / (oldCount-1) ) )
+                }                
                 for(let i=0;i<count;i++){
                     let point = points[i];
                     let last = points[i-1]
                     let next = points[i+1]
                     
-                    if(i == 0 || i == count-1) {
+                    if(i == 0 || i == count-1 ) {
                         newPoints.push(point) //直接加入
                         this.UtoTMapArr.push(i == 0 ? 0 : 1)
                     }
@@ -498,7 +504,7 @@ export class Path extends ctrlPolygon{
                         let curVec = new THREE.Vector3().subVectors(next,point)
                         if(!lastVec) lastVec = curVec
                         if(i>1){// 和上一个加入点的vec之间的夹角如果过大就加入 
-                            if(curVec.angleTo(lastVec) > 0.05){//最小角度
+                            if(pointIndexs.includes(i) || curVec.angleTo(lastVec) > 0.05){//最小角度
                                 newPoints.push(point)
                                 this.UtoTMapArr.push(curve.UtoTMapArr[i])
                                 lastVec = curVec
@@ -507,7 +513,13 @@ export class Path extends ctrlPolygon{
                     }  
                 }  
                 points = newPoints 
-                count = points.length
+                */
+                
+                let result = MeshDraw.lessCurvePoints(points, oldCount, 0.05, curve.UtoTMapArr) 
+                this.UtoTMapArr = result.newUtoTMapArr
+                points = result.newPoints  
+                count = points.length 
+                
                 //delete curve.UtoTMapArr 
             }
             let lastSideVec

+ 2 - 2
src/custom/start.js

@@ -228,12 +228,12 @@ export function start(dom, mapDom, number ){ //t-Zvd3w0m
                            ,{"x":43.58,"y":27.7,"z":-0.97},{"x":40.22,"y":35.37,"z":-0.67}// 拐弯向右 
                            ,{"x":39.18,"y":36.71,"z":0.35},{"x":38.69,"y":36.04,"z":18.04} // 拐弯向上  }
                          ],
-                        color:'#b86', radius:0.08, height:0.13
+                        color:'#b86', radius:0.08, height:0.13, tension:0.3, lessSpace:60
                     }, 
                     {//地下管子 藍色
                         path:[{"x":-108.24,"y":-70.61,"z":-7.52}, {"x":-57.8,"y":-39.31,"z":-6.72},{"x":-18.8,"y":-15.35,"z":-5.01},{"x":55.87,"y":31.67,"z":-0.04},{"x":110.53,"y":66.48,"z":5.14}
                         ],
-                        color:'#48a', radius:0.08, height:-0.5
+                        color:'#48a', radius:0.08, height:-0.5, lessSpace:60
                     }   
                 ] ,
                 /* 'SG-t-h0I7LnfGFwj':[ //港华M层

+ 9 - 9
src/custom/viewer/ViewerNew.js

@@ -6503,11 +6503,11 @@ export class Viewer extends ViewerBase{
                 
                 
                 var index = 0
-                var addMesh = ({color, path, height,fromDataset, radius=0.08, datasetId=Potree.settings.originDatasetId, spaceDis, tension=0.1, visiEntity}={})=>{//height:在path之上的高度,负数代表在path之下
+                function addMesh({color, path, height,fromDataset, radius=0.08, datasetId=Potree.settings.originDatasetId,  tension=0.3, visiEntity}={}){//height:在path之上的高度,负数代表在path之下
                     var name = 'tube_'+index
-                    
+                    let options = arguments[0]
                 
-                    let radialSegments = 30//THREE.Math.clamp( Math.round(radius * 800), 10, 40)
+                    let radialSegments = THREE.Math.clamp( Math.round(radius * 800), 10, 40)
                     let radSegments = Math.PI*2 / radialSegments
                     var circlePts = [];//横截面
                     for(let i=0;i<radialSegments;i++){
@@ -6524,27 +6524,27 @@ export class Viewer extends ViewerBase{
                             pos = Potree.Utils.datasetPosTransform({ fromDataset: true, position:e, datasetId}) 
                         }else{
                             pos = new THREE.Vector3().copy(e)
-                        }
+                        } 
                          
                         return pos.setZ(pos.z+height)
                     })
                     console.log(linePath)
-                    let geo = MeshDraw.getExtrudeGeo( circlePts, null,{ extrudePath:linePath, tension, spaceDis}   )
+                    let geo = MeshDraw.getExtrudeGeo( circlePts, null, Object.assign(options,  { extrudePath:linePath, tension })   )
                     var mesh = new THREE.Mesh(geo,mat);
                     mesh.name = name
                     window[name] = mesh
-                    
+                     
                     mesh.boundingBox = boundingBox
                     mesh.matrixAutoUpdate = false
                     fromDataset || mesh.matrix.copy(viewer.scene.pointclouds[0].transformMatrix)
                     mesh.matrixWorldNeedsUpdate = true
                     
-                    this.scene.scene.add(mesh);
+                    viewer.scene.scene.add(mesh);
                      
                      
                      
                     if(visiEntity){
-                        this.modules.SiteModel.bus.addEventListener('buildingChange',(e)=>{
+                        viewer.modules.SiteModel.bus.addEventListener('buildingChange',(e)=>{
                             Potree.Utils.updateVisible(mesh,'isInEntity', e.entity && e.entity.name == visiEntity)
                         })
                     }
@@ -6566,7 +6566,7 @@ export class Viewer extends ViewerBase{
         JSON.stringify(viewer.scene.measurements.find(e=>e.visible).dataset_points.map(e=>Potree.math.toPrecision(e.toArray(),3)))
      
          */
-    } 
+    }  
     
     addSprite(e){//api
         let sprite