|
@@ -17,7 +17,7 @@ import CursorDeal from "../../utils/CursorDeal.js";
|
|
|
let texLoader = new THREE.TextureLoader()
|
|
let texLoader = new THREE.TextureLoader()
|
|
|
|
|
|
|
|
const labelSizeInfo = {width2d:180} //稍微小点防止字体模糊
|
|
const labelSizeInfo = {width2d:180} //稍微小点防止字体模糊
|
|
|
-
|
|
|
|
|
|
|
+const quaBase = new THREE.Quaternion().setFromEuler(new THREE.Euler(-Math.PI/2,0, Math.PI/2))
|
|
|
const titleLineHeight = 2
|
|
const titleLineHeight = 2
|
|
|
|
|
|
|
|
|
|
|
|
@@ -68,10 +68,7 @@ const getMarkerMat = function (name) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-const getMeshQuaInPath = (lineDir)=>{
|
|
|
|
|
- const quaBase = new THREE.Quaternion().setFromEuler(new THREE.Euler(-Math.PI/2,0, Math.PI/2))
|
|
|
|
|
- return math.getQuaFromPosAim( new THREE.Vector3, lineDir ).multiply(quaBase)
|
|
|
|
|
-}
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
const getEndCaps = (function () {
|
|
const getEndCaps = (function () {
|
|
|
let endCap, map
|
|
let endCap, map
|
|
@@ -305,6 +302,7 @@ export class Path extends ctrlPolygon{
|
|
|
viewer.measuringTool.history.afterChange(this)
|
|
viewer.measuringTool.history.afterChange(this)
|
|
|
this.updateEdge()
|
|
this.updateEdge()
|
|
|
this.hideArrowUntilUpdate()
|
|
this.hideArrowUntilUpdate()
|
|
|
|
|
+ this.dispatchEvent({type:'addMarkerByUser',index})
|
|
|
this.dispatchEvent('changed')
|
|
this.dispatchEvent('changed')
|
|
|
}else{
|
|
}else{
|
|
|
this.isNew || viewer.measuringTool.isAdding || this.setSelected('click') //viewer.focusOnObject(this, 'measure') //正在添加测量线时不要focus其他线(容易误触)
|
|
this.isNew || viewer.measuringTool.isAdding || this.setSelected('click') //viewer.focusOnObject(this, 'measure') //正在添加测量线时不要focus其他线(容易误触)
|
|
@@ -373,14 +371,14 @@ export class Path extends ctrlPolygon{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- getPosByIntersect(e, type){//intersect落在线上的位置,以及在哪两个点之间
|
|
|
|
|
|
|
+ getPosByIntersect(e, type, points=this.points){//intersect落在线上的位置,以及在哪两个点之间
|
|
|
let modelMatrixInvert = this.edge.matrixWorld.clone().invert()
|
|
let modelMatrixInvert = this.edge.matrixWorld.clone().invert()
|
|
|
|
|
|
|
|
if( !Potree.settings.pathSmooth ){
|
|
if( !Potree.settings.pathSmooth ){
|
|
|
let prevIndex = Math.floor(e.hoveredElement.faceIndex / 2) //端点1(可能是最后一个)
|
|
let prevIndex = Math.floor(e.hoveredElement.faceIndex / 2) //端点1(可能是最后一个)
|
|
|
let nextIndex = this.getIndex(prevIndex, 1) //端点2(可能是第一个)
|
|
let nextIndex = this.getIndex(prevIndex, 1) //端点2(可能是第一个)
|
|
|
let index = prevIndex + 1 //新点在端点1后
|
|
let index = prevIndex + 1 //新点在端点1后
|
|
|
- let point = math.getFootPoint(e.hoveredElement.point, this.points[prevIndex], this.points[nextIndex] );
|
|
|
|
|
|
|
+ let point = math.getFootPoint(e.hoveredElement.point, points[prevIndex], points[nextIndex] );
|
|
|
|
|
|
|
|
return {index, prevIndex, point }
|
|
return {index, prevIndex, point }
|
|
|
}else{
|
|
}else{
|
|
@@ -397,7 +395,7 @@ export class Path extends ctrlPolygon{
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
let prevIndex,nextIndex
|
|
let prevIndex,nextIndex
|
|
|
- let count = this.points.length - 1
|
|
|
|
|
|
|
+ let count = points.length - 1
|
|
|
for(let i=0;i<count;i++){
|
|
for(let i=0;i<count;i++){
|
|
|
if(prevIndex == void 0 && i / count <= this.UtoTMapArr[prevIndex0] && (i+1) / count > this.UtoTMapArr[prevIndex0]){
|
|
if(prevIndex == void 0 && i / count <= this.UtoTMapArr[prevIndex0] && (i+1) / count > this.UtoTMapArr[prevIndex0]){
|
|
|
prevIndex = i //该片段端点1在原先points中哪个点之后(可包含)
|
|
prevIndex = i //该片段端点1在原先points中哪个点之后(可包含)
|
|
@@ -422,7 +420,7 @@ export class Path extends ctrlPolygon{
|
|
|
let AB = new THREE.Vector3().subVectors(B,A)
|
|
let AB = new THREE.Vector3().subVectors(B,A)
|
|
|
let searchIndex
|
|
let searchIndex
|
|
|
while(j <= nextIndex){ //根据APlen长度算区间
|
|
while(j <= nextIndex){ //根据APlen长度算区间
|
|
|
- let len = AB.clone().normalize().dot(new THREE.Vector3().subVectors(this.points[j+1], A)) //在AB的投影长度
|
|
|
|
|
|
|
+ let len = AB.clone().normalize().dot(new THREE.Vector3().subVectors(points[j+1], A)) //在AB的投影长度
|
|
|
if(len > APlen){
|
|
if(len > APlen){
|
|
|
searchIndex = j
|
|
searchIndex = j
|
|
|
break
|
|
break
|
|
@@ -557,14 +555,15 @@ export class Path extends ctrlPolygon{
|
|
|
this.updateEdge()
|
|
this.updateEdge()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- updateEdge(){
|
|
|
|
|
- if(this.pauseUpdateEdge || this.lastUpdatePoints_ && Potree.Common.ifSame(this.lastUpdatePoints_,this.points) && this.halfPathWidth == this.lastHalfPathWidth) return //没变 不更新
|
|
|
|
|
|
|
+ updateEdge(o={}){
|
|
|
|
|
+ if(!o.force && (this.pauseUpdateEdge || this.lastUpdatePoints_ && Potree.Common.ifSame(this.lastUpdatePoints_,this.points) && this.halfPathWidth == this.lastHalfPathWidth)) return //没变 不更新
|
|
|
//this.edge.geometry = MeshDraw.getExtrudeGeo(edgeExtrudePoints, null, {extrudePath: this.points, openEnded:true, shapeDontClose:true/* , dontSmooth:true, steps: this.points.length-1 */})
|
|
//this.edge.geometry = MeshDraw.getExtrudeGeo(edgeExtrudePoints, null, {extrudePath: this.points, openEnded:true, shapeDontClose:true/* , dontSmooth:true, steps: this.points.length-1 */})
|
|
|
//getExtrudeGeo是平滑过的曲线,和设计不一样,且容易翻转,转角有时候细分过少
|
|
//getExtrudeGeo是平滑过的曲线,和设计不一样,且容易翻转,转角有时候细分过少
|
|
|
|
|
|
|
|
//只允许path水平放置
|
|
//只允许path水平放置
|
|
|
let geo
|
|
let geo
|
|
|
- let points = this.getDifferentPoint(this.points)
|
|
|
|
|
|
|
+
|
|
|
|
|
+ let points = this.getDifferentPoint(this.points)
|
|
|
let count = points.length
|
|
let count = points.length
|
|
|
this.edge.geometry.dispose()
|
|
this.edge.geometry.dispose()
|
|
|
|
|
|
|
@@ -733,13 +732,15 @@ export class Path extends ctrlPolygon{
|
|
|
this.removePoint(this.markers.indexOf(marker))
|
|
this.removePoint(this.markers.indexOf(marker))
|
|
|
|
|
|
|
|
}else{//点击选中点
|
|
}else{//点击选中点
|
|
|
- this.dispatchEvent({type:'markerSelect', marker})
|
|
|
|
|
|
|
+ this.markers.forEach(marker_=>{
|
|
|
|
|
+ marker_ != marker && this.setMarkerSelected(marker_, 'unclick' );
|
|
|
|
|
+ })
|
|
|
this.setMarkerSelected(marker, 'click' );
|
|
this.setMarkerSelected(marker, 'click' );
|
|
|
|
|
+
|
|
|
|
|
|
|
|
setTimeout(()=>{
|
|
setTimeout(()=>{
|
|
|
viewer.addEventListener('global_click', (e)=>{ //点击空白处取消全部
|
|
viewer.addEventListener('global_click', (e)=>{ //点击空白处取消全部
|
|
|
- if(e.clickElement?.oriObject == marker)return
|
|
|
|
|
- this.dispatchEvent({type:'markerSelect', marker, cancel:true})
|
|
|
|
|
|
|
+ //if(e.clickElement?.oriObject == marker)return
|
|
|
this.setMarkerSelected(marker, 'unclick' );
|
|
this.setMarkerSelected(marker, 'unclick' );
|
|
|
}, {once:true} )
|
|
}, {once:true} )
|
|
|
},10)
|
|
},10)
|
|
@@ -748,7 +749,7 @@ export class Path extends ctrlPolygon{
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
marker.addEventListener('startDragging',(e)=>{
|
|
marker.addEventListener('startDragging',(e)=>{
|
|
|
- this.isNew || this.setMarkerSelected(marker, 'click' ); //选中
|
|
|
|
|
|
|
+ this.isNew || this.setMarkerSelected(marker, 'drag' ); //选中
|
|
|
this.isNew || viewer.measuringTool.history.beforeChange(this)
|
|
this.isNew || viewer.measuringTool.history.beforeChange(this)
|
|
|
this.arrows && Potree.Utils.updateVisible(this.arrows, 'dragging', false)
|
|
this.arrows && Potree.Utils.updateVisible(this.arrows, 'dragging', false)
|
|
|
//Potree.Common.waitTool.cancel('pathUpdateArrowDelay')
|
|
//Potree.Common.waitTool.cancel('pathUpdateArrowDelay')
|
|
@@ -768,7 +769,7 @@ export class Path extends ctrlPolygon{
|
|
|
|
|
|
|
|
this.lastDropTime = Date.now()
|
|
this.lastDropTime = Date.now()
|
|
|
this.isNew || viewer.measuringTool.history.afterChange(this)
|
|
this.isNew || viewer.measuringTool.history.afterChange(this)
|
|
|
- this.setMarkerSelected(marker, 'unclick' );
|
|
|
|
|
|
|
+ this.setMarkerSelected(marker, 'undrag' );
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
@@ -787,9 +788,9 @@ export class Path extends ctrlPolygon{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- updateEndCaps(){
|
|
|
|
|
- let len = this.points.length
|
|
|
|
|
- let pts = this.geoPoints.length>0 ? this.geoPoints : this.points
|
|
|
|
|
|
|
+ updateEndCaps(points=this.points){//更新端点 (这把points提到参数里是因为有个隐藏点的项目)
|
|
|
|
|
+ let len = points.length
|
|
|
|
|
+ let pts = this.geoPoints.length>0 ? this.geoPoints : points
|
|
|
let len2 = pts.length
|
|
let len2 = pts.length
|
|
|
|
|
|
|
|
|
|
|
|
@@ -799,11 +800,11 @@ export class Path extends ctrlPolygon{
|
|
|
if(len>1){
|
|
if(len>1){
|
|
|
let dir = i==0 ? new THREE.Vector3().subVectors(pts[1], pts[0])
|
|
let dir = i==0 ? new THREE.Vector3().subVectors(pts[1], pts[0])
|
|
|
: new THREE.Vector3().subVectors(pts[len2-2], pts[len2-1])
|
|
: new THREE.Vector3().subVectors(pts[len2-2], pts[len2-1])
|
|
|
- e.quaternion.copy(getMeshQuaInPath(dir))
|
|
|
|
|
|
|
+ e.quaternion.copy(this.getMeshQuaInPath(dir))
|
|
|
}else{
|
|
}else{
|
|
|
i==0 ? e.quaternion.set(0,0,0,1) : e.quaternion.set(0,0,1,0) //两个半圆拼成一个圆点
|
|
i==0 ? e.quaternion.set(0,0,0,1) : e.quaternion.set(0,0,1,0) //两个半圆拼成一个圆点
|
|
|
}
|
|
}
|
|
|
- e.position.copy(this.points[i==0 ? 0 : len-1])
|
|
|
|
|
|
|
+ e.position.copy(points[i==0 ? 0 : len-1])
|
|
|
let s = this.halfPathWidth * 2.15
|
|
let s = this.halfPathWidth * 2.15
|
|
|
e.scale.set(s,s,s)
|
|
e.scale.set(s,s,s)
|
|
|
}
|
|
}
|
|
@@ -880,13 +881,13 @@ export class Path extends ctrlPolygon{
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
- removePoint(index){
|
|
|
|
|
|
|
+ removePoint(index){//外部调用
|
|
|
|
|
|
|
|
if(index == -1){
|
|
if(index == -1){
|
|
|
return //双击会这样,加了迅速删除, 可能因为没来得及删
|
|
return //双击会这样,加了迅速删除, 可能因为没来得及删
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- viewer.measuringTool.history.beforeChange(this)
|
|
|
|
|
|
|
+ viewer.measuringTool.history.beforeChange(this) //不同于通过点击marker来删除的已在别处执行了,外部调用的话要补
|
|
|
this.removeMarker(index)
|
|
this.removeMarker(index)
|
|
|
this.hideArrowUntilUpdate()
|
|
this.hideArrowUntilUpdate()
|
|
|
viewer.measuringTool.history.afterChange(this)
|
|
viewer.measuringTool.history.afterChange(this)
|
|
@@ -898,18 +899,37 @@ export class Path extends ctrlPolygon{
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
+ removeMarker(index ){ //通过pen点击marker来删除点
|
|
|
|
|
+
|
|
|
|
|
+ super.removeMarker(index)
|
|
|
|
|
+
|
|
|
|
|
+ this.points_datasets.splice(index, 1);
|
|
|
|
|
+ this.dataset_points && this.dataset_points.splice(index, 1)
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ let labelIndex = index
|
|
|
|
|
+ if(this.markerLabels[labelIndex]){
|
|
|
|
|
+ this.markerLabels[labelIndex].dispose()
|
|
|
|
|
+ this.markerLabels.splice(labelIndex, 1);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ this.update({index: this.getIndex(index, -1)});
|
|
|
|
|
+ this.dispatchEvent({type: 'marker_removed', measurement: this});
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
|
setMarkerSelected(marker, state ){
|
|
setMarkerSelected(marker, state ){
|
|
|
|
|
|
|
|
state == 'hover' && (marker.markerSelectStates.hover = true )
|
|
state == 'hover' && (marker.markerSelectStates.hover = true )
|
|
|
state == 'unhover' && (marker.markerSelectStates.hover = false )
|
|
state == 'unhover' && (marker.markerSelectStates.hover = false )
|
|
|
- state == 'click' && (marker.markerSelectStates.click = true ) //click or drag
|
|
|
|
|
- state == 'unclick' && (marker.markerSelectStates.click = false )
|
|
|
|
|
-
|
|
|
|
|
|
|
+ state == 'click' && (marker.markerSelectStates.click = true, this.dispatchEvent({type:'markerSelect', marker})) //click or drag
|
|
|
|
|
+ state == 'unclick' && (marker.markerSelectStates.click = false, this.dispatchEvent({type:'markerSelect', marker, cancel:true}))
|
|
|
|
|
+ state == 'drag' && (marker.markerSelectStates.drag = true ) //click or drag
|
|
|
|
|
+ state == 'undrag' && (marker.markerSelectStates.drag = false )
|
|
|
|
|
|
|
|
- if(marker.markerSelectStates.click){
|
|
|
|
|
|
|
+ if(marker.markerSelectStates.click || marker.markerSelectStates.drag){
|
|
|
marker.material = getMarkerMat('drag')
|
|
marker.material = getMarkerMat('drag')
|
|
|
marker.renderOrder = marker.pickOrder = Potree.config.renderOrders.path.marker +1
|
|
marker.renderOrder = marker.pickOrder = Potree.config.renderOrders.path.marker +1
|
|
|
}else if(marker.markerSelectStates.hover){
|
|
}else if(marker.markerSelectStates.hover){
|
|
@@ -922,6 +942,7 @@ export class Path extends ctrlPolygon{
|
|
|
|
|
|
|
|
//marker.selected = absoluteState
|
|
//marker.selected = absoluteState
|
|
|
|
|
|
|
|
|
|
+
|
|
|
viewer.mapViewer && viewer.mapViewer.dispatchEvent('content_changed')
|
|
viewer.mapViewer && viewer.mapViewer.dispatchEvent('content_changed')
|
|
|
viewer.dispatchEvent('content_changed')
|
|
viewer.dispatchEvent('content_changed')
|
|
|
}
|
|
}
|
|
@@ -993,25 +1014,6 @@ export class Path extends ctrlPolygon{
|
|
|
}))
|
|
}))
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- removeMarker(index ){
|
|
|
|
|
-
|
|
|
|
|
- super.removeMarker(index)
|
|
|
|
|
-
|
|
|
|
|
- this.points_datasets.splice(index, 1);
|
|
|
|
|
- this.dataset_points && this.dataset_points.splice(index, 1)
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- let labelIndex = index
|
|
|
|
|
- if(this.markerLabels[labelIndex]){
|
|
|
|
|
- this.markerLabels[labelIndex].dispose()
|
|
|
|
|
- this.markerLabels.splice(labelIndex, 1);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- this.update({index: this.getIndex(index, -1)});
|
|
|
|
|
- this.dispatchEvent({type: 'marker_removed', measurement: this});
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
setPosition(index, position) {
|
|
setPosition(index, position) {
|
|
|
super.setPosition(index, position)
|
|
super.setPosition(index, position)
|
|
@@ -1263,7 +1265,7 @@ export class Path extends ctrlPolygon{
|
|
|
scaleMap.set(e.lineInfo.path, scaleMatrix)
|
|
scaleMap.set(e.lineInfo.path, scaleMatrix)
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
- let qua = getMeshQuaInPath(e.lineInfo.dir)//math.getQuaFromPosAim( new THREE.Vector3, e.lineInfo.dir ).multiply(quaBase)
|
|
|
|
|
|
|
+ let qua = this.getMeshQuaInPath(e.lineInfo.dir)//math.getQuaFromPosAim( new THREE.Vector3, e.lineInfo.dir ).multiply(quaBase)
|
|
|
let quaMatrix = new THREE.Matrix4().makeRotationFromQuaternion(qua)
|
|
let quaMatrix = new THREE.Matrix4().makeRotationFromQuaternion(qua)
|
|
|
scaleQuaMatrix = e.lineInfo.scaleQuaMatrix = new THREE.Matrix4().multiplyMatrices(quaMatrix, scaleMatrix)
|
|
scaleQuaMatrix = e.lineInfo.scaleQuaMatrix = new THREE.Matrix4().multiplyMatrices(quaMatrix, scaleMatrix)
|
|
|
}
|
|
}
|
|
@@ -1282,7 +1284,9 @@ export class Path extends ctrlPolygon{
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
+ getMeshQuaInPath(lineDir){
|
|
|
|
|
+ return math.getQuaFromPosAim( new THREE.Vector3, lineDir ).multiply(quaBase)
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|