|
@@ -22,29 +22,43 @@ var markerMats = {}
|
|
|
var lineMats ;
|
|
|
var planeMats
|
|
|
|
|
|
+
|
|
|
+
|
|
|
const lineDepthInfo = {
|
|
|
- clipDistance : 4,//消失距离
|
|
|
- occlusionDistance: 1,//变为backColor距离
|
|
|
+ clipDistance : 4,//消失距离
|
|
|
+ occlusionDistance: 1,//变为backColor距离
|
|
|
}
|
|
|
-const LabelDepthInfo = {
|
|
|
- clipDistance : 6,//消失距离
|
|
|
- occlusionDistance: 2,//变为backColor距离
|
|
|
+const planeDepthInfo = {
|
|
|
+ clipDistance : 30,//消失距离
|
|
|
+ occlusionDistance: 4,//变为backColor距离
|
|
|
+ maxOcclusionFactor:0.3,
|
|
|
+ maxClipFactor:0.1
|
|
|
}
|
|
|
-/* const LabelDepthInfo = {
|
|
|
- clipDistance : 0.1,//消失距离
|
|
|
- occlusionDistance: 0.1,//变为backColor距离
|
|
|
-} */
|
|
|
+
|
|
|
+
|
|
|
|
|
|
const markerSizeInfo = {
|
|
|
minSize : 30*2 , maxSize : 65*2, nearBound : 0.2, farBound : 4,
|
|
|
}
|
|
|
const labelSizeInfo = {width2d:190}
|
|
|
const mainLabelProp = {
|
|
|
- backgroundColor: {r: defaultColor.r*255, g: defaultColor.g*255, b: defaultColor.b*255, a:config.measure.default.opacity},
|
|
|
+ //backgroundColor: {r: defaultColor.r*255, g: defaultColor.g*255, b: defaultColor.b*255, a:config.measure.default.opacity},
|
|
|
+ backgroundColor: {r: 0, g: 0, b: 0, a:0},
|
|
|
textColor: {r: textColor.r*255, g: textColor.g*255, b: textColor.b*255, a: 1.0},
|
|
|
+ textBorderColor: {r:255, g: 255, b:255, a: 1.0},
|
|
|
+ textBorderThick:3,
|
|
|
fontsize: 14,
|
|
|
- useDepth : true , borderRadius : 12, margin:{x:20,y:4},
|
|
|
+ borderRadius : 12, margin:{x:20,y:4},
|
|
|
renderOrder : 5, pickOrder:5,
|
|
|
+ disToLine:-0.15,
|
|
|
+
|
|
|
+ useDepth : true ,
|
|
|
+ // 2023.10 尽量不让数字被挡住
|
|
|
+ clipDistance : 50,//消失距离
|
|
|
+ occlusionDistance: 10,//变为backColor距离
|
|
|
+ maxOcclusionFactor:0.2,
|
|
|
+ maxClipFactor:0.1
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
@@ -53,7 +67,7 @@ const subLabelProp = {
|
|
|
backgroundColor: {r: 255, g: 255, b: 255, a:config.measure.default.opacity},
|
|
|
textColor: {r: 0.3, g: 0.3, b:0.3, a: 1.0},
|
|
|
fontsize:12, borderRadius : 12, margin:{x:20,y:4},
|
|
|
- renderOrder : 4, pickOrder:4,
|
|
|
+ renderOrder : 4, pickOrder:4,
|
|
|
}
|
|
|
|
|
|
|
|
@@ -263,15 +277,19 @@ export class Measure extends ctrlPolygon{
|
|
|
if(this.showDistances || this.labelText){ // edge labels
|
|
|
let edgeLabel = this.edgeLabels[index];
|
|
|
let distance = this.labelText || point.distanceTo(nextPoint)
|
|
|
- edgeLabel.shouldVisi = this.labelText || (index < lastIndex || this.isRect || this.closed && !this.isNew ) && distance>0
|
|
|
+ edgeLabel.shouldVisi = (this.labelText || distance>0) && (index < lastIndex || this.isRect || this.closed && !this.isNew )
|
|
|
/* this.closed || */edgeLabel.setVisible(edgeLabel.shouldVisi)
|
|
|
- edgeLabel.sprite.lineDir = new THREE.Vector3().subVectors(point,nextPoint).normalize() //[point,nextPoint]
|
|
|
- if(edgeLabel.visible){
|
|
|
+ if(edgeLabel.shouldVisi){
|
|
|
+ this.lineDir = new THREE.Vector3().subVectors(point,nextPoint).normalize() //[point,nextPoint]
|
|
|
+
|
|
|
setEdgeLabel(edgeLabel,point,nextPoint,distance)
|
|
|
- }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
if(this.measureType == 'Distance' && this.points.length>1){//设置水平垂直辅助线
|
|
|
var pTop, pBtm
|
|
|
if(this.points[0].z > this.points[1].z ){
|
|
@@ -314,9 +332,7 @@ export class Measure extends ctrlPolygon{
|
|
|
this.areaLabel.setText(msg);
|
|
|
this.areaLabel.setVisible(true)
|
|
|
//}
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
+ }
|
|
|
|
|
|
};
|
|
|
|
|
@@ -324,21 +340,33 @@ 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)
|
|
|
+
|
|
|
+ if(this.lineDir){
|
|
|
+ if(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(this.lineDir)
|
|
|
+
|
|
|
+ let efficiency = 0.35; // 0-1 数值越高,r越容易接近1或-1,label越容易在倾斜后靠近近端点。
|
|
|
+ let r = 0.5*efficiency*cos + 0.5
|
|
|
+
|
|
|
+ center = p1.clone().multiplyScalar(1-r).add(p2.clone().multiplyScalar(r)); //label在线上滑动,使尽量保持在视觉中心
|
|
|
+ label.setPos(center)
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //归零
|
|
|
+ this.orient2dInfo = null
|
|
|
+ this.markers.forEach(e=>e.needsUpdate=true)
|
|
|
+ }else{
|
|
|
+
|
|
|
+ label.setPos(center)
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
- 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)
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
|
|
@@ -355,7 +383,7 @@ export class Measure extends ctrlPolygon{
|
|
|
marker.addEventListener('drop',(e)=>{
|
|
|
viewer.inputHandler.dispatchEvent({type: 'isMeasuring', v:false, cause:'stopDragging'} )
|
|
|
})
|
|
|
-
|
|
|
+ marker.measure = this
|
|
|
let edge
|
|
|
{ // edges
|
|
|
edge = LineDraw.createFatLine( [ ],{material:this.getLineMat('edgeDefault')} )
|
|
@@ -381,6 +409,7 @@ export class Measure extends ctrlPolygon{
|
|
|
|
|
|
if(this.showEdges){ // edge labels
|
|
|
const edgeLabel = this.createEdgeLabel('edgeLabel', !this.closed)
|
|
|
+ edgeLabel.measure = this
|
|
|
this.edgeLabels.push(edgeLabel);
|
|
|
|
|
|
}
|
|
@@ -539,15 +568,18 @@ export class Measure extends ctrlPolygon{
|
|
|
|
|
|
setLabelHightState(label, state){
|
|
|
if(state){
|
|
|
- let color = new THREE.Color(Potree.config.measure.highlight.color)
|
|
|
- label.backgroundColor = {r:255*color.r, g:255*color.g, b:255*color.b, a:config.measure.highlight.opacity},
|
|
|
+ let color = new THREE.Color(Potree.config.measure.highlight.color)
|
|
|
+ //label.sprite.material.opacity = config.measure.highlight.opacity
|
|
|
+
|
|
|
+ //label.backgroundColor = {r:255*color.r, g:255*color.g, b:255*color.b, a:config.measure.highlight.opacity},
|
|
|
//label.backgroundColor.a = config.measure.highlight.opacity
|
|
|
label.sprite.material.useDepth = false;
|
|
|
//label.textColor = {r: this.color.r*255, g: this.color.g*255, b: this.color.b*255, a: 1}
|
|
|
}else{
|
|
|
- label.backgroundColor = {r: this.color.r*255, g: this.color.g*255, b: this.color.b*255, a:config.measure.default.opacity}
|
|
|
+ //label.backgroundColor = {r: this.color.r*255, g: this.color.g*255, b: this.color.b*255, a:config.measure.default.opacity}
|
|
|
//label.backgroundColor.a = config.measure.default.opacity
|
|
|
label.sprite.material.useDepth = true
|
|
|
+ //label.sprite.material.opacity = 0.98
|
|
|
//label.textColor = {r: 255, g: 255, b: 255, a: 1}
|
|
|
|
|
|
}
|
|
@@ -734,7 +766,7 @@ export class Measure extends ctrlPolygon{
|
|
|
|
|
|
createEdgeLabel(name, hasHoverEvent){
|
|
|
|
|
|
- mainLabelProp.backgroundColor = {r: this.color.r*255, g: this.color.g*255, b: this.color.b*255, a:config.measure.default.opacity}
|
|
|
+ //mainLabelProp.backgroundColor = {r: this.color.r*255, g: this.color.g*255, b: this.color.b*255, a:config.measure.default.opacity}
|
|
|
|
|
|
|
|
|
const edgeLabel = new TextSprite(
|
|
@@ -753,9 +785,13 @@ export class Measure extends ctrlPolygon{
|
|
|
edgeLabel.addEventListener('click',()=>{
|
|
|
if(!this.isNew) this.focus()
|
|
|
})
|
|
|
+ //edgeLabel.sprite.material.opacity = config.measure.default.opacity
|
|
|
}
|
|
|
edgeLabel.visible = false
|
|
|
edgeLabel.sprite.material.depthTestWhenPick = true
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
Potree.Utils.setObjectLayers(edgeLabel, 'measure' )
|
|
|
this.add(edgeLabel)
|
|
|
return edgeLabel
|
|
@@ -803,7 +839,8 @@ export class Measure extends ctrlPolygon{
|
|
|
markerMats['default' + color] = new DepthBasicMaterial($.extend({},lineDepthInfo,{
|
|
|
transparent: !0,
|
|
|
opacity: 1,
|
|
|
- map: texLoader.load(Potree.resourcePath+'/textures/pic_point_s32.png' ),
|
|
|
+ //map: texLoader.load(Potree.resourcePath+'/textures/pic_point_s32.png' ),
|
|
|
+ map: texLoader.load(Potree.resourcePath+'/textures/arrows_l_32.png' ),
|
|
|
useDepth:true,
|
|
|
replaceColor:this.color,
|
|
|
beReplacedRed: 0.184, //0.18431372
|
|
@@ -812,7 +849,7 @@ export class Measure extends ctrlPolygon{
|
|
|
markerMats['select' + color] = new DepthBasicMaterial($.extend({},lineDepthInfo,{
|
|
|
transparent: !0,
|
|
|
opacity: 1,
|
|
|
- map: texLoader.load(Potree.resourcePath+'/textures/pic_point32.png' ),
|
|
|
+ map: texLoader.load(Potree.resourcePath+'/textures/arrows_l_32.png' ),
|
|
|
//useDepth:true ,
|
|
|
replaceColor: new THREE.Color(Potree.config.measure.highlight.color) ,
|
|
|
beReplacedRed: 0.184, //0.18431372
|
|
@@ -843,7 +880,7 @@ export class Measure extends ctrlPolygon{
|
|
|
|
|
|
let color = this.color.getHexString()
|
|
|
if(!lineMats['edgeDefault'+color]){
|
|
|
- lineMats['edgeDefault'+color] = LineDraw.createFatLineMat({
|
|
|
+ lineMats['edgeDefault'+color] = LineDraw.createFatLineMat(Object.assign({}, lineDepthInfo, {
|
|
|
color: this.color,
|
|
|
lineWidth: config.measure.lineWidth,
|
|
|
useDepth :true,
|
|
@@ -854,15 +891,15 @@ export class Measure extends ctrlPolygon{
|
|
|
transparent: true,
|
|
|
opacity: config.measure.default.opacity,
|
|
|
depthTestWhenPick:true,
|
|
|
- })
|
|
|
- lineMats['edgeSelect'+color] = LineDraw.createFatLineMat({
|
|
|
+ }))
|
|
|
+ lineMats['edgeSelect'+color] = LineDraw.createFatLineMat(Object.assign({}, lineDepthInfo,{
|
|
|
color: Potree.config.measure.highlight.color ,
|
|
|
dashSize: 0.5,
|
|
|
gapSize: 0.2,
|
|
|
lineWidth: config.measure.lineWidth ,
|
|
|
transparent: true,
|
|
|
opacity: config.measure.highlight.opacity
|
|
|
- })
|
|
|
+ }))
|
|
|
}
|
|
|
|
|
|
|
|
@@ -878,7 +915,7 @@ export class Measure extends ctrlPolygon{
|
|
|
|
|
|
createAreaPlane(){
|
|
|
planeMats || (planeMats = {
|
|
|
- default: new DepthBasicMaterial( $.extend({},LabelDepthInfo,{
|
|
|
+ default: new DepthBasicMaterial( $.extend({},planeDepthInfo,{
|
|
|
color:color,
|
|
|
side:THREE.DoubleSide,
|
|
|
opacity:0.2,
|