|
|
@@ -148,7 +148,7 @@ export class Path extends ctrlPolygon{
|
|
|
this.selectStates = {}
|
|
|
this.setFadeFar(null)
|
|
|
this.geoPoints = []
|
|
|
- this.titleLineHeight = titleLineHeight || prop.titleLineHeight
|
|
|
+ this.lineHeight = prop.lineHeight == void 0 ? titleLineHeight : prop.lineHeight
|
|
|
|
|
|
|
|
|
{
|
|
|
@@ -168,13 +168,13 @@ 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, this.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'
|
|
|
+ line.name = 'line'
|
|
|
this.titleLine = line
|
|
|
group.add(line)
|
|
|
group.add(this.titleLabel)
|
|
|
- this.titleLabel.position.z = this.titleLineHeight
|
|
|
+ this.titleLabel.position.z = this.lineHeight
|
|
|
this.add(group);
|
|
|
this.setTitleVisi(this.titleLabel.parent, false, 'noPoint')
|
|
|
this.setTitle(Potree.settings.isOfficial ? '' : 'title' )
|
|
|
@@ -201,56 +201,54 @@ export class Path extends ctrlPolygon{
|
|
|
this.lineDragPoint.material = state ? dragPointMat.hover : dragPointMat.default
|
|
|
this.titleLabel.sprite.material.opacity = state ? 0.5 : 1
|
|
|
}
|
|
|
-
|
|
|
- let ifHover = ()=>{
|
|
|
+ let autoPointState = ()=>{
|
|
|
+ setDragPointState(this.editEnable && (hoverState.lineDragPoint || grabbingObject == 'lineDragPoint'))
|
|
|
+ }
|
|
|
+ let autoCursor = ()=>{
|
|
|
if(this.editEnable && Object.values(hoverState).some(e=>e)){
|
|
|
- CursorDeal.remove('hoverGrab')
|
|
|
- }else{
|
|
|
CursorDeal.add('hoverGrab')
|
|
|
+ }else{
|
|
|
+ CursorDeal.remove('hoverGrab')
|
|
|
}
|
|
|
+ autoPointState()
|
|
|
}
|
|
|
[line, this.lineDragPoint].forEach(e=>e.addEventListener('mouseover',(e)=>{
|
|
|
hoverState[e.target.name] = 1
|
|
|
- ifHover()
|
|
|
+ autoCursor()
|
|
|
}));
|
|
|
[line, this.lineDragPoint].forEach(e=>e.addEventListener('mouseleave',(e)=>{
|
|
|
hoverState[e.target.name] = 0
|
|
|
- ifHover()
|
|
|
+ autoCursor()
|
|
|
}));
|
|
|
|
|
|
-
|
|
|
- line.addEventListener('startDragging',(e)=>{
|
|
|
- this.editEnable && CursorDeal.add('grabbing')
|
|
|
- });
|
|
|
- line.addEventListener('drop',(e)=>{
|
|
|
- this.editEnable && CursorDeal.remove('grabbing')
|
|
|
- });
|
|
|
-
|
|
|
- line.addEventListener('drag',(e)=>{
|
|
|
+ [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})
|
|
|
}
|
|
|
- });
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ }));
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
}
|
|
|
@@ -435,8 +433,7 @@ export class Path extends ctrlPolygon{
|
|
|
}//如果后续还出现index错误的问题,可以改为绘制时用折线,完成后用曲线。
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
|
|
|
createMarkerLabel(text, hasHoverEvent){
|
|
|
|
|
|
@@ -511,15 +508,18 @@ export class Path extends ctrlPolygon{
|
|
|
viewer.dispatchEvent('content_changed')
|
|
|
}
|
|
|
|
|
|
- setTitleLineHeight(len){
|
|
|
- this.titleLineHeight = parseFloat(len)
|
|
|
-
|
|
|
+ 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.normal.clone().multiplyScalar(this.lineLength).applyMatrix4(this.matrixWorld)
|
|
|
- let normal = this.normal.clone().applyQuaternion(this.getWorldQuaternion(new THREE.Quaternion))
|
|
|
+ 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
|
|
|
@@ -529,9 +529,9 @@ export class Path extends ctrlPolygon{
|
|
|
moveVec = moveVec.projectOnVector(normal)
|
|
|
|
|
|
|
|
|
- let newLength = Math.max(0, this.lineLength + moveVec.dot(normal) )
|
|
|
+ let newLength = Math.max(0, this.lineHeight + moveVec.dot(normal) )
|
|
|
//console.log(moveVec,newLength)
|
|
|
- this.changeLineLen(newLength)
|
|
|
+ this.setLineHeight(newLength)
|
|
|
this.dispatchEvent('dragLineLen')
|
|
|
|
|
|
}
|