|
@@ -370,38 +370,73 @@ var enter = ({
|
|
|
};
|
|
|
};
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ let getMeasurePointsInfo = (fixPoint, onlyMoveBasePoint)=>{
|
|
|
+ let fixPoint2d = new THREE.Vector2.copy(fixPoint)
|
|
|
+ let baselineP12d = new THREE.Vector2.copy(baseLine.points[0])
|
|
|
+ let baselineP22d = new THREE.Vector2.copy(baseLine.points[1])
|
|
|
+ let foot_2d = Potree.math.getFootPoint(fixPoint2d, baselineP12d, baselineP22d)
|
|
|
+ let foot1_P1 = new THREE.Vector3(foot_2d.x, foot_2d.y, fixPoint.z)
|
|
|
+ let foot1_P2 = new THREE.Vector3(foot_2d.x, foot_2d.y, baseLine.points[0].z)
|
|
|
+ let info = {
|
|
|
+ disMeasure1:{
|
|
|
+ points: [new THREE.Vector3().copy(fixPoint), foot1_P1],
|
|
|
+ guideLinePoints : [foot1_P1, foot1_P2], //到基准线平面的垂直辅助线
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!onlyMoveBasePoint){
|
|
|
+ let basePoint2d = new THREE.Vector2().copy(fixPoint.basePoint)
|
|
|
+ let anotherPoint2d = new THREE.Vector2().addVectors(basePoint2d, basePoint2d.clone().add(new THREE.Vector2().subVectors(baselineP12d,baselineP22d)))//测量线方向上另一点
|
|
|
+ let foot2_2d = Potree.math.getFootPoint(fixPoint2d, basePoint2d, anotherPoint2d)
|
|
|
+ let foot2_P1 = new THREE.Vector3(foot2_2d.x, foot2_2d.y, fixPoint.basePoint.z)
|
|
|
+ let foot2_P2 = new THREE.Vector3(foot1_2d.x, foot1_2d.y, fixPoint.basePoint.z)
|
|
|
+ info.disMeasure2 = {
|
|
|
+ points : new THREE.Vector3().copy(fixPoint), footP1],
|
|
|
+ guideLinePoints : [foot2_P1, foot2_P2, foot1_P2],
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return info
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
let createMeasureForPoint = (fixPoint)=>{
|
|
|
let baseLine = viewer.scene.measurements.find(e=>e.isBaseLine && e.points.length == 2)
|
|
|
if(!baseLine){
|
|
|
return console.error('创建失败,因基准线不存在')
|
|
|
}
|
|
|
|
|
|
+ let info = getMeasurePointsInfo(fixPoint)
|
|
|
|
|
|
- let fixPoint2d = new THREE.Vector2.copy(fixPoint)
|
|
|
- let baselineP12d = new THREE.Vector2.copy(baseLine.points[0])
|
|
|
- let baselineP22d = new THREE.Vector2.copy(baseLine.points[1])
|
|
|
- let foot1 = Potree.math.getFootPoint(fixPoint2d, baselineP12d, baselineP22d)
|
|
|
|
|
|
- let info1 = {
|
|
|
+ let info1 = {//垂直于基准线的水平测量线
|
|
|
measureType : 'Hor Distance',
|
|
|
- unableChange: true,
|
|
|
- points: [new THREE.Vector3().copy(fixPoint), new THREE.Vector3(foot1.x, foot1.y, fixPoint.z)],
|
|
|
- projectPos: new THREE.Vector3(foot1.x, foot1.y, baseLine.points[0].z),
|
|
|
-
|
|
|
+ unableDrag: true,
|
|
|
+ points: info.disMeasure1.points,
|
|
|
+ guideLinePoints : info.disMeasure1.guideLinePoints
|
|
|
}
|
|
|
- /* let info2 = {
|
|
|
- measureType : 'Distance'
|
|
|
- } */
|
|
|
let disMeasure1 = viewer.measuringTool.createMeasureFromData(info1);
|
|
|
- //let disMeasure2 = viewer.measuringTool.createMeasureFromData(info2);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ let info2 = {//平行于基准线的水平测量线
|
|
|
+ measureType : 'Hor Distance',
|
|
|
+ unableDrag: true,
|
|
|
+ points: info.disMeasure2.points,
|
|
|
+ guideLinePoints : info.disMeasure2.guideLinePoints
|
|
|
+ }
|
|
|
+ let disMeasure2 = viewer.measuringTool.createMeasureFromData(info2);
|
|
|
|
|
|
|
|
|
fixPoint.disMeasure1 = disMeasure1
|
|
|
+ fixPoint.disMeasure2 = disMeasure2
|
|
|
}
|
|
|
|
|
|
let removeMeasureForPoint = (fixPoint)=>{
|
|
|
viewer.scene.removeMeasurement(fixPoint.disMeasure1);
|
|
|
-
|
|
|
+ viewer.scene.removeMeasurement(fixPoint.disMeasure2);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -660,15 +695,14 @@ var enter = ({
|
|
|
|
|
|
createFixPoint({measure, graph, pos, basePoint}){//创建固定点或多线段
|
|
|
|
|
|
-
|
|
|
-
|
|
|
const bus = mitt();
|
|
|
let info = {
|
|
|
- measureType : 'MulDistance'
|
|
|
+ measureType : 'MulDistance', color : "#3290ff"
|
|
|
}
|
|
|
let measureFun, fixPoint
|
|
|
- if(graph){
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+ if(graph){
|
|
|
if(graph.length == 0){
|
|
|
measure = viewer.measuringTool.startInsertion( info,
|
|
|
() => {
|
|
@@ -680,16 +714,11 @@ var enter = ({
|
|
|
}else{
|
|
|
info.points = graph;
|
|
|
info.sid = Math.random()//sid;
|
|
|
- info.bus = bus;
|
|
|
- //info.color = color
|
|
|
- measure = viewer.measuringTool.createMeasureFromData(info);
|
|
|
- Potree.Log("drawMeasure由数据新建: " + measure.id, {
|
|
|
- font: {
|
|
|
- color: "#00c7b2"
|
|
|
- },
|
|
|
- });
|
|
|
- measureFun = getMeasureFunction(measure, bus, true)
|
|
|
+ info.bus = bus;
|
|
|
+ measure = viewer.measuringTool.createMeasureFromData(info);
|
|
|
}
|
|
|
+
|
|
|
+ measureFun = getMeasureFunction(measure, bus, true)
|
|
|
}else{
|
|
|
fixPoint = new THREE.Vector3().copy(pos)
|
|
|
THREE.EventDispatcher.call(fixPoint)
|
|
@@ -707,18 +736,31 @@ var enter = ({
|
|
|
// 退出测量模式,清除之前操作
|
|
|
|
|
|
bus,
|
|
|
- destroy : isMeasure ? measureFun.clear : ()=>{
|
|
|
-
|
|
|
+ destroy : measureFun ? measureFun.clear : ()=>{
|
|
|
+ removeMeasureForPoint(fixPoint)
|
|
|
+ let index = viewer.fixPoints.indexOf(fixPoint)
|
|
|
+ index > -1 && viewer.fixPoints.splice(index,1)
|
|
|
},
|
|
|
quitMeasure(){//退出测量模式,删除测量线
|
|
|
removeMeasureForPoint(fixPoint)
|
|
|
+
|
|
|
},
|
|
|
changePos(pos){//固定点修改
|
|
|
fixPoint.copy(pos)
|
|
|
-
|
|
|
-
|
|
|
+ let info = getMeasurePointsInfo(fixPoint)
|
|
|
+ fixPoint.disMeasure1.points = info.disMeasure1.points
|
|
|
+ fixPoint.disMeasure1.guideLinePoints = info.disMeasure1.guideLinePoints
|
|
|
+ fixPoint.disMeasure1.guideLine.updateGuideLines()
|
|
|
+ fixPoint.disMeasure2.points = info.disMeasure2.points
|
|
|
+ fixPoint.disMeasure2.guideLinePoints = info.disMeasure2.guideLinePoints
|
|
|
+ fixPoint.disMeasure2.guideLine.updateGuideLines()
|
|
|
},
|
|
|
- changeBase(){//基准点修改
|
|
|
+ changeBase(pos){//基准点修改
|
|
|
+ fixPoint.basePoint.copy(pos)
|
|
|
+ let info = getMeasurePointsInfo(fixPoint,true)
|
|
|
+ fixPoint.disMeasure2.points = info.disMeasure2.points
|
|
|
+ fixPoint.disMeasure2.guideLinePoints = info.disMeasure2.guideLinePoints
|
|
|
+ fixPoint.disMeasure2.guideLine.updateGuideLines()
|
|
|
|
|
|
},
|
|
|
graphDrawComplete: measureFun.end,
|