|
@@ -36,7 +36,7 @@ const LabelDepthInfo = {
|
|
|
} */
|
|
|
|
|
|
const markerSizeInfo = {
|
|
|
- minSize : 25 , maxSize : 65, nearBound : 0.2, farBound : 4,
|
|
|
+ minSize : 30*2 , maxSize : 65*2, nearBound : 0.2, farBound : 4,
|
|
|
}
|
|
|
const labelSizeInfo = {width2d:190}
|
|
|
const mainLabelProp = {
|
|
@@ -229,12 +229,18 @@ export class Measure extends ctrlPolygon{
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
|
|
|
+ /* viewer.addEventListener('camera_changed',(e)=>{
|
|
|
+ if(e.changeInfo.positionChanged){
|
|
|
+ setLabelPos()
|
|
|
+ }
|
|
|
+ }) */
|
|
|
|
|
|
|
|
|
let setEdgeLabel = (label,p1,p2,distance)=>{//设置label位置和字
|
|
|
- let center = new THREE.Vector3().addVectors(p1,p2).multiplyScalar(0.5);
|
|
|
- label.setPos(center)
|
|
|
+ this.setEdgeLabelPos(label,p1,p2)
|
|
|
+
|
|
|
distance = distance == void 0 ? p1.distanceTo(p2) : distance;
|
|
|
var text = this.labelText || viewer.unitConvert.convert(distance, 'distance', Potree.settings.precision, this.unitSystem, 0.1 , true)//distance要传0.1 这个factor
|
|
|
label.setText(text)
|
|
@@ -259,10 +265,10 @@ export class Measure extends ctrlPolygon{
|
|
|
let distance = this.labelText || point.distanceTo(nextPoint)
|
|
|
edgeLabel.shouldVisi = this.labelText || (index < lastIndex || this.isRect || this.closed && !this.isNew ) && distance>0
|
|
|
/* this.closed || */edgeLabel.setVisible(edgeLabel.shouldVisi)
|
|
|
+ edgeLabel.sprite.lineDir = new THREE.Vector3().subVectors(point,nextPoint).normalize() //[point,nextPoint]
|
|
|
if(edgeLabel.visible){
|
|
|
setEdgeLabel(edgeLabel,point,nextPoint,distance)
|
|
|
}
|
|
|
- edgeLabel.sprite.lineDir = new THREE.Vector3().subVectors(point,nextPoint).normalize() //[point,nextPoint]
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -314,7 +320,28 @@ export class Measure extends ctrlPolygon{
|
|
|
|
|
|
};
|
|
|
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+ setEdgeLabelPos(label,p1,p2){ //调整label的位置,使倾斜后看起来在线的中心,而不要挡住端点
|
|
|
+ let center = new THREE.Vector3().addVectors(p1,p2).multiplyScalar(0.5);
|
|
|
+
|
|
|
+ if(!label.sprite.lineDir || viewer.mainViewport.camera.type == 'OrthographicCamera'){
|
|
|
+ label.setPos(center)
|
|
|
+ }else{
|
|
|
+ let eyePos = viewer.mainViewport.camera.position;
|
|
|
+ let dir = viewer.mainViewport.view.direction //new THREE.Vector3().subVectors(center,eyePos).normalize()
|
|
|
+ let vec = label.sprite.lineDir
|
|
|
+ let cos = dir.dot(vec)
|
|
|
+
|
|
|
+ let efficiency = 0.35; // 0-1 数值越高,r越容易接近1或-1,label越容易在倾斜后靠近近端点。
|
|
|
+ let r = 0.5*efficiency*cos + 0.5
|
|
|
+ //console.log(r, cos )
|
|
|
+ center = p1.clone().multiplyScalar(1-r).add(p2.clone().multiplyScalar(r)); //label在线上滑动,使尽量保持在视觉中心
|
|
|
+ label.setPos(center)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
addMarker (o={}) {
|
|
|
|
|
@@ -790,7 +817,7 @@ export class Measure extends ctrlPolygon{
|
|
|
replaceColor:this.color,
|
|
|
beReplacedRed: 0.184, //0.18431372
|
|
|
mapColorReplace:true
|
|
|
- }))
|
|
|
+ }))
|
|
|
}
|
|
|
return markerMats[type + color]
|
|
|
|