|
|
@@ -17,7 +17,7 @@ import CursorDeal from "../../utils/CursorDeal.js";
|
|
|
let texLoader = new THREE.TextureLoader()
|
|
|
|
|
|
const labelSizeInfo = {width2d:180} //稍微小点防止字体模糊
|
|
|
-
|
|
|
+const quaBase = new THREE.Quaternion().setFromEuler(new THREE.Euler(-Math.PI/2,0, Math.PI/2))
|
|
|
const titleLineHeight = 2
|
|
|
|
|
|
|
|
|
@@ -27,18 +27,18 @@ const arrowCountMax = 1000; //箭头总数不能超过这个值。 The count val
|
|
|
let lastArrowCamPos, lastArrowCount = 0
|
|
|
|
|
|
const depthProps = {
|
|
|
- useDepth : true ,
|
|
|
+ useDepth : true ,
|
|
|
//startClipDis : 0.5,
|
|
|
- clipDistance : 2,//消失距离
|
|
|
+ clipDistance : 0.5,//消失距离
|
|
|
//startOcclusDis: 0.5,
|
|
|
- occlusionDistance: 0.7,//变为backColor距离
|
|
|
+ occlusionDistance: 0.3,//变为backColor距离
|
|
|
maxOcclusionFactor:0.9,
|
|
|
maxClipFactor:1
|
|
|
}
|
|
|
const planeGeo = new THREE.PlaneBufferGeometry(1,1)
|
|
|
const voidGeometry = new THREE.BufferGeometry()
|
|
|
|
|
|
-let markerMats
|
|
|
+let markerMats, dragPointMat
|
|
|
const getMarkerMat = function (name) {
|
|
|
if(!markerMats){
|
|
|
markerMats = {
|
|
|
@@ -68,10 +68,11 @@ 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 () {
|
|
|
let endCap, map
|
|
|
@@ -148,6 +149,9 @@ export class Path extends ctrlPolygon{
|
|
|
this.selectStates = {}
|
|
|
this.setFadeFar(null)
|
|
|
this.geoPoints = []
|
|
|
+ this.lineHeight = prop.lineHeight == void 0 ? titleLineHeight : prop.lineHeight
|
|
|
+
|
|
|
+
|
|
|
{
|
|
|
let group = new THREE.Object3D; group.name = 'titleGroup'
|
|
|
this.titleLabel = new TextSprite(Object.assign({}, depthProps,{
|
|
|
@@ -165,42 +169,90 @@ export class Path extends ctrlPolygon{
|
|
|
textAlign: Potree.settings.isOfficial && 'left'
|
|
|
}))
|
|
|
this.titleLabel.sprite.material.depthTest = false
|
|
|
- let line = LineDraw.createFatLine([new THREE.Vector3(0,0,0), new THREE.Vector3(0,0,titleLineHeight)], Object.assign({},depthProps,{color: '#ffffff', lineWidth: 1, transparent:true, fadeFar: this.fadeFar}))
|
|
|
+ let line = LineDraw.createFatLine([new THREE.Vector3(0,0,0), new THREE.Vector3(0,0, this.lineHeight)], Object.assign({},depthProps,{color: '#ffffff', lineWidth: 1, transparent:true, fadeFar: this.fadeFar}))
|
|
|
line.renderOrder = Potree.config.renderOrders.line
|
|
|
+ line.name = 'line'
|
|
|
+ this.titleLine = line
|
|
|
group.add(line)
|
|
|
group.add(this.titleLabel)
|
|
|
- this.titleLabel.position.z = titleLineHeight
|
|
|
+ this.titleLabel.position.z = this.lineHeight
|
|
|
this.add(group);
|
|
|
this.setTitleVisi(this.titleLabel.parent, false, 'noPoint')
|
|
|
this.setTitle(Potree.settings.isOfficial ? '' : 'title' )
|
|
|
-
|
|
|
|
|
|
- line.addEventListener('mouseover',(e)=>{
|
|
|
- this.editEnable && CursorDeal.add('hoverGrab')
|
|
|
- });
|
|
|
- line.addEventListener('startDragging',(e)=>{
|
|
|
- this.editEnable && CursorDeal.add('grabbing')
|
|
|
- });
|
|
|
- line.addEventListener('drop',(e)=>{
|
|
|
- this.editEnable && CursorDeal.remove('grabbing')
|
|
|
- });
|
|
|
- line.addEventListener('mouseleave',(e)=>{
|
|
|
- this.editEnable && CursorDeal.remove('hoverGrab')
|
|
|
-
|
|
|
- });
|
|
|
- line.addEventListener('drag',(e)=>{
|
|
|
+ if(!dragPointMat){
|
|
|
+ let map = texLoader.load(Potree.resourcePath+'/textures/whiteCircle.png',()=>{})
|
|
|
+ dragPointMat = {
|
|
|
+ default: new THREE.MeshBasicMaterial({
|
|
|
+ map, transparent:true, color:'#0fe', opacity:0, depthTest:false,
|
|
|
+ }),
|
|
|
+ hover: new THREE.MeshBasicMaterial({
|
|
|
+ map, transparent:true, color:'#0fe', opacity:0.4, depthTest:false,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.lineDragPoint = new THREE.Mesh(planeGeo, dragPointMat.default) //修改线高度时出现的小圆点
|
|
|
+ this.lineDragPoint.scale.set(0.15,0.15,0.15);
|
|
|
+ this.lineDragPoint.name = 'lineDragPoint'
|
|
|
+ this.lineDragPoint.renderOrder = this.lineDragPoint.pickOrder = 10;
|
|
|
+ this.titleLabel.add(this.lineDragPoint)
|
|
|
+
|
|
|
+ let hoverState = {}, grabbingObject
|
|
|
+ let setDragPointState = (state)=>{
|
|
|
+ this.lineDragPoint.material = state ? dragPointMat.hover : dragPointMat.default
|
|
|
+ this.titleLabel.sprite.material.opacity = state ? 0.5 : 1
|
|
|
+ }
|
|
|
+ let autoPointState = ()=>{
|
|
|
+ setDragPointState(this.editEnable && (hoverState.lineDragPoint || grabbingObject == 'lineDragPoint'))
|
|
|
+ }
|
|
|
+ let autoCursor = ()=>{
|
|
|
+ if(this.editEnable && Object.values(hoverState).some(e=>e)){
|
|
|
+ CursorDeal.add('hoverGrab')
|
|
|
+ }else{
|
|
|
+ CursorDeal.remove('hoverGrab')
|
|
|
+ }
|
|
|
+ autoPointState()
|
|
|
+ }
|
|
|
+ [line, this.lineDragPoint].forEach(e=>e.addEventListener('mouseover',(e)=>{
|
|
|
+ hoverState[e.target.name] = 1
|
|
|
+ autoCursor()
|
|
|
+ }));
|
|
|
+ [line, this.lineDragPoint].forEach(e=>e.addEventListener('mouseleave',(e)=>{
|
|
|
+ hoverState[e.target.name] = 0
|
|
|
+ autoCursor()
|
|
|
+ }));
|
|
|
+
|
|
|
+ [line, this.lineDragPoint].forEach(e=>e.addEventListener('startDragging',(e)=>{
|
|
|
+ grabbingObject = e.target.name
|
|
|
+ this.editEnable && (CursorDeal.add('grabbing'), autoPointState())
|
|
|
+ }));
|
|
|
+ [line, this.lineDragPoint].forEach(e=>e.addEventListener('drop',(e)=>{
|
|
|
+ grabbingObject = null
|
|
|
+ this.editEnable && (CursorDeal.remove('grabbing'), autoPointState())
|
|
|
+ }));
|
|
|
+
|
|
|
+ [line, this.lineDragPoint].forEach(e=>e.addEventListener('drag',(e)=>{
|
|
|
if(this.editEnable){//一旦用户拖动了title,title就固定了,不再随着path居中
|
|
|
- let position
|
|
|
- if(e.intersect?.location){
|
|
|
- position = e.intersect?.location
|
|
|
- }else{
|
|
|
- let {x,y} = Potree.Utils.getPointerPosAtHeight(0,e.pointer)
|
|
|
- position = new THREE.Vector3(x,y,0)
|
|
|
+ if(e.target.name == 'line'){
|
|
|
+ let position
|
|
|
+ if(e.intersect?.location){
|
|
|
+ position = e.intersect?.location
|
|
|
+ }else{
|
|
|
+ let {x,y} = Potree.Utils.getPointerPosAtHeight(0,e.pointer)
|
|
|
+ position = new THREE.Vector3(x,y,0)
|
|
|
+ }
|
|
|
+ this.updateTitlePos(position)
|
|
|
+ this.dispatchEvent({type:'titlePosChanged', position , root:e.intersect?.pointcloud || e.intersect?.object})
|
|
|
+ }else if(e.target.name == 'lineDragPoint'){
|
|
|
+ this.dragLineLen(e)
|
|
|
}
|
|
|
- this.updateTitlePos(position)
|
|
|
- this.dispatchEvent({type:'titlePosChanged', position , root:e.intersect?.pointcloud || e.intersect?.object})
|
|
|
+
|
|
|
}
|
|
|
- });
|
|
|
+ }));
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
{//和measure不同的是它的边是连在一起的一整条
|
|
|
@@ -255,6 +307,7 @@ export class Path extends ctrlPolygon{
|
|
|
viewer.measuringTool.history.afterChange(this)
|
|
|
this.updateEdge()
|
|
|
this.hideArrowUntilUpdate()
|
|
|
+ this.dispatchEvent({type:'addMarkerByUser',index})
|
|
|
this.dispatchEvent('changed')
|
|
|
}else{
|
|
|
this.isNew || viewer.measuringTool.isAdding || this.setSelected('click') //viewer.focusOnObject(this, 'measure') //正在添加测量线时不要focus其他线(容易误触)
|
|
|
@@ -323,24 +376,31 @@ export class Path extends ctrlPolygon{
|
|
|
|
|
|
|
|
|
|
|
|
- getPosByIntersect(e, type){//intersect落在线上的位置,以及在哪两个点之间
|
|
|
-
|
|
|
+ getPosByIntersect(e, type, points=this.points){//intersect落在线上的位置,以及在哪两个点之间
|
|
|
+ let modelMatrixInvert = this.edge.matrixWorld.clone().invert()
|
|
|
+
|
|
|
if( !Potree.settings.pathSmooth ){
|
|
|
let prevIndex = Math.floor(e.hoveredElement.faceIndex / 2) //端点1(可能是最后一个)
|
|
|
let nextIndex = this.getIndex(prevIndex, 1) //端点2(可能是第一个)
|
|
|
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 }
|
|
|
}else{
|
|
|
-
|
|
|
+ let hoverAtGeo = e.hoveredElement.point.clone().applyMatrix4(modelMatrixInvert)
|
|
|
let prevIndex0 = Math.floor(e.hoveredElement.faceIndex / 2) //所在的mesh片段的端点1
|
|
|
let nextIndex0 = prevIndex0 + 1 //所在的mesh片段的端点2
|
|
|
+
|
|
|
+ let point = math.getFootPoint(hoverAtGeo, this.geoPoints[prevIndex0], this.geoPoints[nextIndex0] ); //新点位置
|
|
|
+ //console.log('point',point)
|
|
|
|
|
|
- let point = math.getFootPoint(e.hoveredElement.point, this.geoPoints[prevIndex0], this.geoPoints[nextIndex0] ); //新点位置
|
|
|
- if(type == 'onlyPoint')return {point}
|
|
|
+ if(type == 'onlyPoint'){
|
|
|
+ point.applyMatrix4(this.edge.matrixWorld)
|
|
|
+ return {point}
|
|
|
+ }
|
|
|
|
|
|
let prevIndex,nextIndex
|
|
|
- let count = this.points.length - 1
|
|
|
+ let count = points.length - 1
|
|
|
for(let i=0;i<count;i++){
|
|
|
if(prevIndex == void 0 && i / count <= this.UtoTMapArr[prevIndex0] && (i+1) / count > this.UtoTMapArr[prevIndex0]){
|
|
|
prevIndex = i //该片段端点1在原先points中哪个点之后(可包含)
|
|
|
@@ -365,7 +425,7 @@ export class Path extends ctrlPolygon{
|
|
|
let AB = new THREE.Vector3().subVectors(B,A)
|
|
|
let searchIndex
|
|
|
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){
|
|
|
searchIndex = j
|
|
|
break
|
|
|
@@ -378,12 +438,14 @@ export class Path extends ctrlPolygon{
|
|
|
nextIndex = prevIndex + 1
|
|
|
//console.log(prevIndex, nextIndex)
|
|
|
let index = prevIndex + 1 //新点在端点1后
|
|
|
+
|
|
|
+ point.applyMatrix4(this.edge.matrixWorld)
|
|
|
return {index, prevIndex, point }
|
|
|
}
|
|
|
}//如果后续还出现index错误的问题,可以改为绘制时用折线,完成后用曲线。
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
createMarkerLabel(text, hasHoverEvent){
|
|
|
@@ -453,20 +515,61 @@ export class Path extends ctrlPolygon{
|
|
|
if(this.color == color)return
|
|
|
this.color = color
|
|
|
let c = new THREE.Color().set(this.color)
|
|
|
- this.titleLabel.setTextColor({r: c.r*255, g:c.g*255, b:c.b*255, a:0.5})
|
|
|
+
|
|
|
+
|
|
|
+ let hsb = new THREE.Color().set(this.color).getHSV()
|
|
|
+ let textColor = new THREE.Color().setHSV(hsb.h, hsb.s, 100) //make bright full
|
|
|
+
|
|
|
+ this.titleLabel.setTextColor({r: textColor.r*255, g:textColor.g*255, b:textColor.b*255, a:0.95})
|
|
|
this.updateSelectStyle() //apply color
|
|
|
|
|
|
viewer.dispatchEvent('content_changed')
|
|
|
}
|
|
|
|
|
|
- updateEdge(){
|
|
|
- if(this.lastUpdatePoints_ && Potree.Common.ifSame(this.lastUpdatePoints_,this.points) && this.halfPathWidth == this.lastHalfPathWidth) return //没变 不更新
|
|
|
+ setLineHeight(len){
|
|
|
+ if(len == this.lineHeight)return
|
|
|
+ this.lineHeight = parseFloat(len)
|
|
|
+ this.titleLabel.position.z = this.lineHeight
|
|
|
+ this.titleLabel.updatePose()
|
|
|
+ LineDraw.updateLine(this.titleLine, [new THREE.Vector3(0,0,0), new THREE.Vector3(0,0,this.lineHeight )])
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ dragLineLen(e){ //拖拽线的顶端修改线长度
|
|
|
+ let endPos = this.titleLabel.getWorldPosition(new THREE.Vector3)
|
|
|
+ let normal = new THREE.Vector3(0,0,1)
|
|
|
+ const projected = endPos.clone().project(e.drag.dragViewport.camera);
|
|
|
+ projected.x = e.pointer.x
|
|
|
+ projected.y = e.pointer.y
|
|
|
+
|
|
|
+ const unprojected = projected.clone().unproject(e.drag.dragViewport.camera);
|
|
|
+ let moveVec = new THREE.Vector3().subVectors(unprojected, endPos);
|
|
|
+ moveVec = moveVec.projectOnVector(normal)
|
|
|
+
|
|
|
+
|
|
|
+ let newLength = Math.max(0, this.lineHeight + moveVec.dot(normal) )
|
|
|
+ //console.log(moveVec,newLength)
|
|
|
+ this.setLineHeight(newLength)
|
|
|
+ this.dispatchEvent('dragLineLen')
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ reDraw(){
|
|
|
+ this.pauseUpdateEdge = true
|
|
|
+ super.reDraw()
|
|
|
+ this.pauseUpdateEdge = false
|
|
|
+ this.updateEdge()
|
|
|
+ }
|
|
|
+
|
|
|
+ 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 */})
|
|
|
//getExtrudeGeo是平滑过的曲线,和设计不一样,且容易翻转,转角有时候细分过少
|
|
|
|
|
|
//只允许path水平放置
|
|
|
let geo
|
|
|
- let points = this.getDifferentPoint(this.points)
|
|
|
+
|
|
|
+ let points = this.getDifferentPoint(this.points)
|
|
|
let count = points.length
|
|
|
this.edge.geometry.dispose()
|
|
|
|
|
|
@@ -474,13 +577,20 @@ export class Path extends ctrlPolygon{
|
|
|
geo = voidGeometry
|
|
|
this.geoPoints = []
|
|
|
this.curve = null
|
|
|
- }else{
|
|
|
+ this.edge.position.set(0,0,0)
|
|
|
+ }else{
|
|
|
+ { //avoidBigNumber
|
|
|
+ let boundCenter = this.getCenter('bound')
|
|
|
+ points = points.map(e=>e.clone().sub(boundCenter))//防止大数 avoidBigNumber 不过prism的点云效果不对,传入了大数,不好改,等提bug了再说吧
|
|
|
+ this.edge.position.copy(boundCenter)
|
|
|
+ }
|
|
|
if(Potree.settings.pathSmooth){//使用曲线
|
|
|
let curve = this.curve = new THREE.CatmullRomCurve3(points, false )
|
|
|
curve.UtoTMapArr = [] //用于存储 getSpacedPoints得到的点对应points的百分比对应
|
|
|
let oldCount = count
|
|
|
- count = Math.max(2, Math.round(this.getTotalDistance() * 200)), points = curve.getSpacedPoints(count-1) //拆分为更密集的点
|
|
|
-
|
|
|
+ count = THREE.Math.clamp(Math.round(this.getTotalDistance() * 200), 2, 100000 ), points = curve.getSpacedPoints(count-1) //拆分为更密集的点
|
|
|
+ //count太多很卡住
|
|
|
+
|
|
|
/* //window.arcLengthDivisions && (curve.arcLengthDivisions = arcLengthDivisions) //默认200,但改为1也没变化呀
|
|
|
let oldCount = count
|
|
|
//减少点数(拐弯的部分紧凑些,直线部分宽松些):
|
|
|
@@ -539,7 +649,8 @@ export class Path extends ctrlPolygon{
|
|
|
let sideVec //该点两边对应的向量
|
|
|
let uvX
|
|
|
if(i==0 || i==count-1){
|
|
|
- sideVec = new THREE.Vector3().copy(math.getNormal2d({p1: i==0 ? B : O, p2: i==0 ? O : A})).setZ(0).multiplyScalar(this.halfPathWidth) //垂线
|
|
|
+ let nor = math.getNormal2d({p1: i==0 ? B : O, p2: i==0 ? O : A}) || new THREE.Vector3(1,0,0)
|
|
|
+ sideVec = new THREE.Vector3().copy(nor).setZ(0).multiplyScalar(this.halfPathWidth) //垂线
|
|
|
uvX = i==0 ? 0 : 1 //percent of length
|
|
|
}else{
|
|
|
let OA = new THREE.Vector3().subVectors(A,O).setZ(0).normalize() //只保证俯视角度正确。(如果两点有高度差,该段四个点不会在同一平面,看起来有扭转,有的地方会肥大,但从俯视角度看是正确的。)
|
|
|
@@ -547,7 +658,8 @@ export class Path extends ctrlPolygon{
|
|
|
let angle = math.getAngle(OA, OB, 'z')
|
|
|
|
|
|
if(math.closeTo(angle,0,1e-4) || math.closeTo(angle,Math.PI,1e-4) || math.closeTo(angle, -Math.PI,1e-4)){ //这时候直接加两个向量算出的平分线不准,故直接找垂线
|
|
|
- sideVec = new THREE.Vector3().copy(math.getNormal2d({p1: O, p2: A})).setZ(0).multiplyScalar(this.halfPathWidth) //垂线
|
|
|
+ let nor = math.getNormal2d({p1: O, p2: A}) || new THREE.Vector3(1,0,0)
|
|
|
+ sideVec = new THREE.Vector3().copy(nor).setZ(0).multiplyScalar(this.halfPathWidth) //垂线
|
|
|
//console.log('接近0或180',angle, sideVec)
|
|
|
}else{
|
|
|
let midVecLength = this.halfPathWidth / Math.sin(angle/2)
|
|
|
@@ -626,13 +738,16 @@ export class Path extends ctrlPolygon{
|
|
|
this.removePoint(this.markers.indexOf(marker))
|
|
|
|
|
|
}else{//点击选中点
|
|
|
- this.dispatchEvent({type:'markerSelect', marker})
|
|
|
+ this.markers.forEach(marker_=>{
|
|
|
+ marker_ != marker && this.setMarkerSelected(marker_, 'unclick' );
|
|
|
+ })
|
|
|
this.setMarkerSelected(marker, 'click' );
|
|
|
+
|
|
|
|
|
|
setTimeout(()=>{
|
|
|
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' );
|
|
|
}, {once:true} )
|
|
|
},10)
|
|
|
@@ -641,7 +756,7 @@ export class Path extends ctrlPolygon{
|
|
|
})
|
|
|
|
|
|
marker.addEventListener('startDragging',(e)=>{
|
|
|
- this.isNew || this.setMarkerSelected(marker, 'click' ); //选中
|
|
|
+ this.isNew || this.setMarkerSelected(marker, 'drag' ); //选中
|
|
|
this.isNew || viewer.measuringTool.history.beforeChange(this)
|
|
|
this.arrows && Potree.Utils.updateVisible(this.arrows, 'dragging', false)
|
|
|
//Potree.Common.waitTool.cancel('pathUpdateArrowDelay')
|
|
|
@@ -661,7 +776,7 @@ export class Path extends ctrlPolygon{
|
|
|
|
|
|
this.lastDropTime = Date.now()
|
|
|
this.isNew || viewer.measuringTool.history.afterChange(this)
|
|
|
- this.setMarkerSelected(marker, 'unclick' );
|
|
|
+ this.setMarkerSelected(marker, 'undrag' );
|
|
|
})
|
|
|
|
|
|
|
|
|
@@ -680,9 +795,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
|
|
|
|
|
|
|
|
|
@@ -692,18 +807,19 @@ export class Path extends ctrlPolygon{
|
|
|
if(len>1){
|
|
|
let dir = i==0 ? new THREE.Vector3().subVectors(pts[1], pts[0])
|
|
|
: new THREE.Vector3().subVectors(pts[len2-2], pts[len2-1])
|
|
|
- e.quaternion.copy(getMeshQuaInPath(dir))
|
|
|
+ e.quaternion.copy(this.getMeshQuaInPath(dir))
|
|
|
}else{
|
|
|
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
|
|
|
e.scale.set(s,s,s)
|
|
|
}
|
|
|
})
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
setEditEnable(state){//是否显示可修改控件
|
|
|
+ if(!this.endCaps)return
|
|
|
this.editEnable = !!state
|
|
|
this.markers.forEach(e=>Potree.Utils.updateVisible(e,'editEnable', this.editEnable))
|
|
|
this.endCaps.forEach((e,i)=>Potree.Utils.updateVisible(e,'editEnable', !this.editEnable))
|
|
|
@@ -773,13 +889,13 @@ export class Path extends ctrlPolygon{
|
|
|
}
|
|
|
|
|
|
|
|
|
- removePoint(index){
|
|
|
+ removePoint(index){//外部调用
|
|
|
|
|
|
if(index == -1){
|
|
|
return //双击会这样,加了迅速删除, 可能因为没来得及删
|
|
|
}
|
|
|
|
|
|
- viewer.measuringTool.history.beforeChange(this)
|
|
|
+ viewer.measuringTool.history.beforeChange(this) //不同于通过点击marker来删除的已在别处执行了,外部调用的话要补
|
|
|
this.removeMarker(index)
|
|
|
this.hideArrowUntilUpdate()
|
|
|
viewer.measuringTool.history.afterChange(this)
|
|
|
@@ -791,18 +907,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 ){
|
|
|
|
|
|
state == 'hover' && (marker.markerSelectStates.hover = true )
|
|
|
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.renderOrder = marker.pickOrder = Potree.config.renderOrders.path.marker +1
|
|
|
}else if(marker.markerSelectStates.hover){
|
|
|
@@ -815,6 +950,7 @@ export class Path extends ctrlPolygon{
|
|
|
|
|
|
//marker.selected = absoluteState
|
|
|
|
|
|
+
|
|
|
viewer.mapViewer && viewer.mapViewer.dispatchEvent('content_changed')
|
|
|
viewer.dispatchEvent('content_changed')
|
|
|
}
|
|
|
@@ -854,19 +990,26 @@ export class Path extends ctrlPolygon{
|
|
|
updateSelectStyle(){
|
|
|
|
|
|
|
|
|
- let c = new THREE.Color().set(this.color).getHSL({ h: 0, s: 0, l: 0 })
|
|
|
+
|
|
|
|
|
|
+ //let c = new THREE.Color().set(this.color).getHSL({ h: 0, s: 0, l: 0 })
|
|
|
+ let hsv = new THREE.Color().set(this.color).getHSV()
|
|
|
let color, arrowColor
|
|
|
if(this.selectStates.click){
|
|
|
color = '#00C8AF'
|
|
|
arrowColor = '#ffffff'
|
|
|
+
|
|
|
}else if(this.selectStates.hover){
|
|
|
- color = new THREE.Color().setHSL(c.h, c.s, c.l - 0.1 )
|
|
|
- arrowColor = new THREE.Color().setHSL(c.h, c.s, c.l >= 0.4 ? c.l - 0.3 : c.l + 0.3 )
|
|
|
- }else{
|
|
|
- arrowColor = new THREE.Color().setHSL(c.h, c.s, c.l >= 0.4 ? c.l - 0.3 : c.l + 0.3 )
|
|
|
+ /* color = new THREE.Color().setHSL(c.h, c.s, c.l - 0.1 )
|
|
|
+ arrowColor = new THREE.Color().setHSL(c.h, c.s, c.l >= 0.4 ? c.l - 0.3 : c.l + 0.3 ) */
|
|
|
+ color = new THREE.Color().setHSV(hsv.h, hsv.s, hsv.v - 10 )
|
|
|
+ arrowColor = new THREE.Color().setHSV(hsv.h, hsv.s, hsv.v >= 40 ? hsv.v - 30 : hsv.v + 30 )
|
|
|
|
|
|
+ }else{
|
|
|
+ //arrowColor = new THREE.Color().setHSL(c.h, c.s, c.l >= 0.4 ? c.l - 0.3 : c.l + 0.3 )
|
|
|
+ arrowColor = new THREE.Color().setHSV(hsv.h, hsv.s, hsv.v >= 40 ? hsv.v - 30 : hsv.v + 30 )
|
|
|
color = this.color
|
|
|
+
|
|
|
}
|
|
|
|
|
|
if(this.arrows){
|
|
|
@@ -876,28 +1019,30 @@ export class Path extends ctrlPolygon{
|
|
|
}
|
|
|
([this.edge, this.endCaps[0].children[0]].forEach(e=>{
|
|
|
e.material.color.set(color)
|
|
|
+ e.material.uniforms.maxClipFactor.value = this.selectStates.click ? 0.4 : this.selectStates.hover ? 0.6 : depthProps.maxClipFactor
|
|
|
+ e.material.uniforms.occlusionDistance.value = this.selectStates.click ? 0.6 : this.selectStates.hover ? 0.7 : depthProps.occlusionDistance
|
|
|
}))
|
|
|
}
|
|
|
|
|
|
- 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) {
|
|
|
super.setPosition(index, position)
|
|
|
@@ -1149,7 +1294,7 @@ export class Path extends ctrlPolygon{
|
|
|
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)
|
|
|
scaleQuaMatrix = e.lineInfo.scaleQuaMatrix = new THREE.Matrix4().multiplyMatrices(quaMatrix, scaleMatrix)
|
|
|
}
|
|
|
@@ -1168,13 +1313,16 @@ export class Path extends ctrlPolygon{
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
+ getMeshQuaInPath(lineDir){
|
|
|
+
|
|
|
+ return math.getQuaFromPosAim( new THREE.Vector3, lineDir ).multiply(quaBase)
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
|
Path.prototype.cloneMarker = Measure.prototype.cloneMarker
|
|
|
Path.prototype.updateDatasetBelong = Measure.prototype.updateDatasetBelong
|
|
|
-Path.prototype.reDraw = Measure.prototype.reDraw
|
|
|
+//Path.prototype.reDraw = Measure.prototype.reDraw
|
|
|
/*
|
|
|
没有intersect的点的dataset_point怎么赋值
|
|
|
|